Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report shader arrays sized after spec constants as zero-sized #94985

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion thirdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ Files extracted from upstream source:
Some downstream changes have been made and are identified by
`// -- GODOT begin --` and `// -- GODOT end --` comments.
They can be reapplied using the patches included in the `patches`
folder.
folder, in order.


## squish
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/thirdparty/spirv-reflect/spirv_reflect.c b/thirdparty/spirv-reflect/spirv_reflect.c
index c96dd85439..2ca9c8580d 100644
--- a/thirdparty/spirv-reflect/spirv_reflect.c
+++ b/thirdparty/spirv-reflect/spirv_reflect.c
@@ -2692,6 +2692,13 @@ static SpvReflectResult ParseDescriptorBlockVariableSizes(SpvReflectPrvParser* p
// ...then array
uint32_t element_count = (p_member_var->array.dims_count > 0 ? 1 : 0);
for (uint32_t i = 0; i < p_member_var->array.dims_count; ++i) {
+// -- GODOT begin --
+ if (p_member_var->array.spec_constant_op_ids[i] != (uint32_t)INVALID_VALUE) {
+ // Force size to be reported as 0 to effectively disable buffer size validation, since
+ // the value is unreliable anyway as only valid for the default values of the SCs involved.
+ element_count = 0;
+ }
+// -- GODOT end --
element_count *= p_member_var->array.dims[i];
}
p_member_var->size = element_count * p_member_var->array.stride;
7 changes: 7 additions & 0 deletions thirdparty/spirv-reflect/spirv_reflect.c
Original file line number Diff line number Diff line change
Expand Up @@ -2692,6 +2692,13 @@ static SpvReflectResult ParseDescriptorBlockVariableSizes(SpvReflectPrvParser* p
// ...then array
uint32_t element_count = (p_member_var->array.dims_count > 0 ? 1 : 0);
for (uint32_t i = 0; i < p_member_var->array.dims_count; ++i) {
// -- GODOT begin --
if (p_member_var->array.spec_constant_op_ids[i] != (uint32_t)INVALID_VALUE) {
// Force size to be reported as 0 to effectively disable buffer size validation, since
// the value is unreliable anyway as only valid for the default values of the SCs involved.
element_count = 0;
}
// -- GODOT end --
element_count *= p_member_var->array.dims[i];
}
p_member_var->size = element_count * p_member_var->array.stride;
Expand Down
Loading