clover: clCreateImage: calculate image row_pitch and slice_pitch when not provided

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7069>
This commit is contained in:
Serge Martin
2020-10-11 20:12:12 +02:00
committed by Karol Herbst
parent f2bdb69218
commit 43a42b6e1d

View File

@@ -20,6 +20,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
#include "util/format/u_format.h"
#include "util/u_math.h"
#include "api/util.hpp"
#include "core/memory.hpp"
@@ -179,6 +180,9 @@ clCreateImage(cl_context d_ctx, cl_mem_flags d_flags,
ret_error(r_errcode, CL_SUCCESS);
const size_t row_pitch = desc->image_row_pitch ? desc->image_row_pitch :
util_format_get_blocksize(translate_format(*format)) * desc->image_width;
switch (desc->image_type) {
case CL_MEM_OBJECT_IMAGE2D:
if (!desc->image_width || !desc->image_height)
@@ -193,9 +197,9 @@ clCreateImage(cl_context d_ctx, cl_mem_flags d_flags,
return new image2d(ctx, flags, format,
desc->image_width, desc->image_height,
desc->image_row_pitch, host_ptr);
row_pitch, host_ptr);
case CL_MEM_OBJECT_IMAGE3D:
case CL_MEM_OBJECT_IMAGE3D: {
if (!desc->image_width || !desc->image_height || !desc->image_depth)
throw error(CL_INVALID_IMAGE_SIZE);
@@ -207,10 +211,14 @@ clCreateImage(cl_context d_ctx, cl_mem_flags d_flags,
}, ctx.devices()))
throw error(CL_INVALID_IMAGE_SIZE);
const size_t slice_pitch = desc->image_slice_pitch ?
desc->image_slice_pitch : row_pitch * desc->image_height;
return new image3d(ctx, flags, format,
desc->image_width, desc->image_height,
desc->image_depth, desc->image_row_pitch,
desc->image_slice_pitch, host_ptr);
desc->image_depth, row_pitch,
slice_pitch, host_ptr);
}
case CL_MEM_OBJECT_IMAGE1D:
case CL_MEM_OBJECT_IMAGE1D_ARRAY: