From e14557995681a1b2a8b8f6d2a4cb7b1ff168b7f3 Mon Sep 17 00:00:00 2001 From: Ahmed Hesham Date: Wed, 4 Feb 2026 15:00:13 +0000 Subject: [PATCH] rusticl: fix flag validation when creating an image From the OpenCL specification: `CL_MEM_KERNEL_READ_AND_WRITE`: This flag is only used by clGetSupportedImageFormats to query image formats that may be both read from and written to by the same kernel instance. To create a memory object that may be read from and written to use CL_MEM_READ_WRITE. If an application follows the instructions above, i.e. query a list of supported image formats, using `CL_MEM_KERNEL_READ_AND_WRITE` as input, and then attempts to create an image using one of the supported image formats, by calling `clCreateImage` and passing `CL_MEM_READ_WRITE`, the call to the image creation entry point should succeed. This instead fails on Mali devices with the error `CL_IMAGE_FORMAT_NOT_SUPPORTED`. Rusticl fails when validating the image format against its supported flags. Formats that support `PIPE_BIND_SHADER_IMAGE` have their supported flags set as `CL_MEM_WRITE_ONLY` and `CL_MEM_KERNEL_READ_AND_WRITE`. This changes the supported CL flags to be `CL_MEM_WRITE_ONLY` for `PIPE_BIND_SHADER_IMAGE` and `CL_MEM_READ_WRTE | CL_MEM_KERNEL_READ_AND_WRITE` for `PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_SHADER_IMAGE`. Fixes: 3386e142 (rusticl: support read_write images) Fixes OpenCL-CTS test: `test_image_streams` on Mali. Invocation: ``` test_image_streams write 1D CL_RGB CL_SIGNED_INT8 ``` Signed-off-by: Ahmed Hesham (cherry picked from commit e77c984cefbc8bb9d95e0dc47d36b069b1498a5a) Part-of: --- .pick_status.json | 2 +- src/gallium/frontends/rusticl/core/device.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 51e9bdf4f15..f93ecd49ad6 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -5104,7 +5104,7 @@ "description": "rusticl: fix flag validation when creating an image", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "3386e1425f1c4fa52c8fae9511f6c31d2713dac8", "notes": null diff --git a/src/gallium/frontends/rusticl/core/device.rs b/src/gallium/frontends/rusticl/core/device.rs index c3ee1df0abb..e5604069b3b 100644 --- a/src/gallium/frontends/rusticl/core/device.rs +++ b/src/gallium/frontends/rusticl/core/device.rs @@ -297,7 +297,7 @@ impl DeviceBase { PIPE_BIND_SHADER_IMAGE, ) { - flags |= CL_MEM_WRITE_ONLY | CL_MEM_KERNEL_READ_AND_WRITE; + flags |= CL_MEM_WRITE_ONLY; } // TODO: cl_khr_srgb_image_writes @@ -308,7 +308,7 @@ impl DeviceBase { PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_SHADER_IMAGE, ) { - flags |= CL_MEM_READ_WRITE; + flags |= CL_MEM_READ_WRITE | CL_MEM_KERNEL_READ_AND_WRITE; } fs.insert(t, flags as cl_mem_flags);