diff options
author | Serge Martin <edb@sigluy.net> | 2020-10-11 20:12:12 +0200 |
---|---|---|
committer | Karol Herbst <kherbst@redhat.com> | 2020-10-20 23:46:42 +0200 |
commit | 43a42b6e1d063ba86cd9af342b2d3a9768bfae8b (patch) | |
tree | 3ab4b3a2590d3642fe66cc5ed9c811936f5da936 | |
parent | f2bdb69218829551f7c1f47a77ace122c9da619b (diff) |
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>
-rw-r--r-- | src/gallium/frontends/clover/api/memory.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
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: |