Module: Mesa Branch: master Commit: 43a42b6e1d063ba86cd9af342b2d3a9768bfae8b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=43a42b6e1d063ba86cd9af342b2d3a9768bfae8b
Author: Serge Martin <[email protected]> Date: Sun Oct 11 20:12:12 2020 +0200 clover: clCreateImage: calculate image row_pitch and slice_pitch when not provided Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Karol Herbst <[email protected]> Reviewed-by: Francisco Jerez <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7069> --- src/gallium/frontends/clover/api/memory.cpp | 16 ++++++++++++---- 1 file 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: _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
