diff --git a/src/gallium/frontends/clover/api/memory.cpp b/src/gallium/frontends/clover/api/memory.cpp index cf29657f675..965b044cdbb 100644 --- a/src/gallium/frontends/clover/api/memory.cpp +++ b/src/gallium/frontends/clover/api/memory.cpp @@ -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: