From 92c5460253f9c647be96a373ded616b16961017f Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Fri, 21 Jul 2023 13:59:35 +1000 Subject: [PATCH] glsl: mark structs containing images as bindless Structs are not allowed to contain an image in regular glsl. The only time they are intended to be allowed to be declared in a struct is when they are bindless. Unfortunately the bindless spec does not meantion this behaviour explicitly so there is no spec quote to reference but you can see in the original commit to allow them in mesa that spec clarification was provided 48b7882200c5 The spec also states that certain uses are implicitly bindless as per the following spec quote: "When used as shader inputs, outputs, uniform block members, or temporaries, the value of the sampler is a 64-bit unsigned integer handle and never refers to a texture image unit." Given images are not allowed in regular glsl for the above types similair to being forbidden in structs, we can also assume declarations in structs are implicitly bindless. Reviewed-by: Samuel Pitoiset Part-of: --- src/compiler/glsl/ast_to_hir.cpp | 16 ++++++++++++++++ src/gallium/drivers/zink/ci/zink-radv-navi10-fails.txt | 3 --- src/gallium/drivers/zink/ci/zink-radv-vangogh-fails.txt | 3 --- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp index f9ab838..2092fce 100644 --- a/src/compiler/glsl/ast_to_hir.cpp +++ b/src/compiler/glsl/ast_to_hir.cpp @@ -3753,6 +3753,22 @@ apply_bindless_qualifier_to_variable(const struct ast_type_qualifier *qual, state->bound_sampler_specified || state->bound_image_specified; } + + /* ARB_bindless_texture spec says: + * + * "When used as shader inputs, outputs, uniform block members, + * or temporaries, the value of the sampler is a 64-bit unsigned + * integer handle and never refers to a texture image unit." + * + * The spec doesn't reference images defined inside structs but it was + * clarified with the authors that bindless images are allowed in structs. + * So we treat these images as implicitly bindless just like the types + * in the spec quote above. + */ + if (!var->data.bindless && var->type->is_struct() && + var->type->contains_image()) { + var->data.bindless = true; + } } static void diff --git a/src/gallium/drivers/zink/ci/zink-radv-navi10-fails.txt b/src/gallium/drivers/zink/ci/zink-radv-navi10-fails.txt index 1c59708..5cb0f82 100644 --- a/src/gallium/drivers/zink/ci/zink-radv-navi10-fails.txt +++ b/src/gallium/drivers/zink/ci/zink-radv-navi10-fails.txt @@ -2,9 +2,6 @@ glx@glx-multi-window-single-context,Crash spec@egl_chromium_sync_control@conformance@eglGetSyncValuesCHROMIUM_ust_test,Fail -# Mesa bug not Zink bug. See piglit MR 824 -spec@arb_bindless_texture@compiler@images@return-struct.frag,Crash - # #6115 spec@arb_tessellation_shader@execution@variable-indexing@tes-both-input-array-float-index-rd,Crash spec@arb_tessellation_shader@execution@variable-indexing@tes-both-input-array-vec2-index-rd,Crash diff --git a/src/gallium/drivers/zink/ci/zink-radv-vangogh-fails.txt b/src/gallium/drivers/zink/ci/zink-radv-vangogh-fails.txt index 07591e2..3b9a63a 100644 --- a/src/gallium/drivers/zink/ci/zink-radv-vangogh-fails.txt +++ b/src/gallium/drivers/zink/ci/zink-radv-vangogh-fails.txt @@ -2,9 +2,6 @@ glx@glx-multi-window-single-context,Crash spec@egl_chromium_sync_control@conformance@eglGetSyncValuesCHROMIUM_ust_test,Fail -# Mesa bug not Zink bug. See piglit MR 824 -spec@arb_bindless_texture@compiler@images@return-struct.frag,Crash - # #6115 spec@arb_tessellation_shader@execution@variable-indexing@tes-both-input-array-float-index-rd,Crash spec@arb_tessellation_shader@execution@variable-indexing@tes-both-input-array-vec2-index-rd,Crash -- 2.7.4