From d8793e3874da71a316aa35eb620b5195d0f4ecec 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: --- src/gallium/frontends/rusticl/api/memory.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gallium/frontends/rusticl/api/memory.rs b/src/gallium/frontends/rusticl/api/memory.rs index a6075ef07c1..146d1c5b540 100644 --- a/src/gallium/frontends/rusticl/api/memory.rs +++ b/src/gallium/frontends/rusticl/api/memory.rs @@ -27,12 +27,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 @@ -912,7 +912,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) { @@ -3050,7 +3050,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.