Skip to content

Commit 90679f1

Browse files
committedJul 31, 2024·
Report shader arrays sized after spec constants as zero-sized
This effectively disables validation of the size of the data provided.
1 parent 88d9325 commit 90679f1

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed
 

‎thirdparty/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ Files extracted from upstream source:
845845
Some downstream changes have been made and are identified by
846846
`// -- GODOT begin --` and `// -- GODOT end --` comments.
847847
They can be reapplied using the patches included in the `patches`
848-
folder.
848+
folder, in order.
849849

850850

851851
## squish
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
diff --git a/thirdparty/spirv-reflect/spirv_reflect.c b/thirdparty/spirv-reflect/spirv_reflect.c
2+
index c96dd85439..2ca9c8580d 100644
3+
--- a/thirdparty/spirv-reflect/spirv_reflect.c
4+
+++ b/thirdparty/spirv-reflect/spirv_reflect.c
5+
@@ -2692,6 +2692,13 @@ static SpvReflectResult ParseDescriptorBlockVariableSizes(SpvReflectPrvParser* p
6+
// ...then array
7+
uint32_t element_count = (p_member_var->array.dims_count > 0 ? 1 : 0);
8+
for (uint32_t i = 0; i < p_member_var->array.dims_count; ++i) {
9+
+// -- GODOT begin --
10+
+ if (p_member_var->array.spec_constant_op_ids[i] != (uint32_t)INVALID_VALUE) {
11+
+ // Force size to be reported as 0 to effectively disable buffer size validation, since
12+
+ // the value is unreliable anyway as only valid for the default values of the SCs involved.
13+
+ element_count = 0;
14+
+ }
15+
+// -- GODOT end --
16+
element_count *= p_member_var->array.dims[i];
17+
}
18+
p_member_var->size = element_count * p_member_var->array.stride;

‎thirdparty/spirv-reflect/spirv_reflect.c

+7
Original file line numberDiff line numberDiff line change
@@ -2692,6 +2692,13 @@ static SpvReflectResult ParseDescriptorBlockVariableSizes(SpvReflectPrvParser* p
26922692
// ...then array
26932693
uint32_t element_count = (p_member_var->array.dims_count > 0 ? 1 : 0);
26942694
for (uint32_t i = 0; i < p_member_var->array.dims_count; ++i) {
2695+
// -- GODOT begin --
2696+
if (p_member_var->array.spec_constant_op_ids[i] != (uint32_t)INVALID_VALUE) {
2697+
// Force size to be reported as 0 to effectively disable buffer size validation, since
2698+
// the value is unreliable anyway as only valid for the default values of the SCs involved.
2699+
element_count = 0;
2700+
}
2701+
// -- GODOT end --
26952702
element_count *= p_member_var->array.dims[i];
26962703
}
26972704
p_member_var->size = element_count * p_member_var->array.stride;

0 commit comments

Comments
 (0)
Please sign in to comment.