From 7a4dd7ac7ea0ae87f6ae6b2228fb4d51bfa16214 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Fri, 18 Jul 2025 10:21:42 +0200 Subject: [PATCH] rusticl/mem: relax flags validation for clGetSupportedImageFormats While the API spec does describe which flags _may_ be passed in, the overall CL working group agreement is, that implementations should expect random flags to be passed in as other implementations _may_ use them to further restrict or allow image formats. Also fix validation for importing GL objects while at it. Cc: mesa-stable Part-of: (cherry picked from commit d8793e3874da71a316aa35eb620b5195d0f4ecec) --- .pick_status.json | 2 +- src/gallium/frontends/rusticl/api/memory.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 10bd84999c7..c6d1301cbb7 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -5614,7 +5614,7 @@ "description": "rusticl/mem: relax flags validation for clGetSupportedImageFormats", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/gallium/frontends/rusticl/api/memory.rs b/src/gallium/frontends/rusticl/api/memory.rs index 729214c7b56..9906a29b84a 100644 --- a/src/gallium/frontends/rusticl/api/memory.rs +++ b/src/gallium/frontends/rusticl/api/memory.rs @@ -28,12 +28,12 @@ use std::os::raw::c_void; use std::ptr; use std::sync::Arc; -fn validate_mem_flags(flags: cl_mem_flags, images: bool) -> CLResult<()> { +fn validate_mem_flags(flags: cl_mem_flags, import: bool) -> CLResult<()> { let mut valid_flags = cl_bitfield::from( CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY | CL_MEM_KERNEL_READ_AND_WRITE, ); - if !images { + if !import { valid_flags |= cl_bitfield::from( CL_MEM_USE_HOST_PTR | CL_MEM_ALLOC_HOST_PTR @@ -889,7 +889,7 @@ fn get_supported_image_formats( let c = Context::ref_from_raw(context)?; // CL_INVALID_VALUE if flags - validate_mem_flags(flags, true)?; + validate_mem_flags(flags, false)?; // or image_type are not valid if !image_type_valid(image_type) { @@ -3068,7 +3068,7 @@ fn create_from_gl( // CL_INVALID_VALUE if values specified in flags are not valid or if value specified in // texture_target is not one of the values specified in the description of texture_target. - validate_mem_flags(flags, target == GL_ARRAY_BUFFER)?; + validate_mem_flags(flags, true)?; // CL_INVALID_MIP_LEVEL if miplevel is greather than zero and the OpenGL // implementation does not support creating from non-zero mipmap levels.