Add test case for read-only storage texture passed to helper function (#2414)

This is based on spv.paramMemory.frag.out which exercises the
writeonly storage image case.

This appears to need desktop GLSL.

The generated SPIR-V fails validation because the image_write function
takes a parameter which is pointer to an OpTypeImage with Unknown format.
But the parameters passed in are pointer to OpTypeImage with formats Rgba32f
and Rgba16f. The validator rejects this, saying the parameter types must
match.
This commit is contained in:
David Neto 2020-10-07 18:10:27 -04:00 committed by GitHub
parent 3ce148638b
commit 2067d1a93e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 173 additions and 0 deletions

View File

@ -0,0 +1,139 @@
spv.paramMemory.420.frag
Validation failed
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 69
Capability Shader
Capability StorageImageReadWithoutFormat
Capability StorageImageWriteWithoutFormat
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 27 66
ExecutionMode 4 OriginUpperLeft
Source GLSL 420
SourceExtension "GL_EXT_shader_image_load_formatted"
Name 4 "main"
Name 16 "image_load(I21;vi2;"
Name 14 "image"
Name 15 "coords"
Name 23 "image_store(I21;vi2;vf4;"
Name 20 "image"
Name 21 "coords"
Name 22 "data"
Name 27 "in_coords"
Name 35 "read1"
Name 36 "image1"
Name 37 "param"
Name 40 "read2"
Name 41 "image2"
Name 42 "param"
Name 47 "image3"
Name 51 "param"
Name 53 "param"
Name 57 "image4"
Name 61 "param"
Name 63 "param"
Name 66 "out_color"
Decorate 14(image) Coherent
Decorate 14(image) NonWritable
Decorate 20(image) Coherent
Decorate 20(image) NonReadable
Decorate 27(in_coords) Flat
Decorate 27(in_coords) Location 0
Decorate 36(image1) DescriptorSet 0
Decorate 36(image1) Binding 0
Decorate 36(image1) Coherent
Decorate 36(image1) NonWritable
Decorate 41(image2) DescriptorSet 0
Decorate 41(image2) Binding 2
Decorate 41(image2) NonWritable
Decorate 47(image3) DescriptorSet 0
Decorate 47(image3) Binding 1
Decorate 47(image3) Coherent
Decorate 47(image3) NonReadable
Decorate 57(image4) DescriptorSet 0
Decorate 57(image4) Binding 3
Decorate 57(image4) NonReadable
Decorate 66(out_color) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeImage 6(float) 2D nonsampled format:Unknown
8: TypePointer UniformConstant 7
9: TypeInt 32 1
10: TypeVector 9(int) 2
11: TypePointer Function 10(ivec2)
12: TypeVector 6(float) 4
13: TypeFunction 12(fvec4) 8(ptr) 11(ptr)
18: TypePointer Function 12(fvec4)
19: TypeFunction 2 8(ptr) 11(ptr) 18(ptr)
26: TypePointer Input 10(ivec2)
27(in_coords): 26(ptr) Variable Input
36(image1): 8(ptr) Variable UniformConstant
41(image2): 8(ptr) Variable UniformConstant
45: TypeImage 6(float) 2D nonsampled format:Rgba32f
46: TypePointer UniformConstant 45
47(image3): 46(ptr) Variable UniformConstant
49: 6(float) Constant 1056964608
55: TypeImage 6(float) 2D nonsampled format:Rgba16f
56: TypePointer UniformConstant 55
57(image4): 56(ptr) Variable UniformConstant
59: 6(float) Constant 1073741824
65: TypePointer Output 12(fvec4)
66(out_color): 65(ptr) Variable Output
67: 6(float) Constant 0
68: 12(fvec4) ConstantComposite 67 67 67 67
4(main): 2 Function None 3
5: Label
35(read1): 18(ptr) Variable Function
37(param): 11(ptr) Variable Function
40(read2): 18(ptr) Variable Function
42(param): 11(ptr) Variable Function
51(param): 11(ptr) Variable Function
53(param): 18(ptr) Variable Function
61(param): 11(ptr) Variable Function
63(param): 18(ptr) Variable Function
38: 10(ivec2) Load 27(in_coords)
Store 37(param) 38
39: 12(fvec4) FunctionCall 16(image_load(I21;vi2;) 36(image1) 37(param)
Store 35(read1) 39
43: 10(ivec2) Load 27(in_coords)
Store 42(param) 43
44: 12(fvec4) FunctionCall 16(image_load(I21;vi2;) 41(image2) 42(param)
Store 40(read2) 44
48: 12(fvec4) Load 35(read1)
50: 12(fvec4) VectorTimesScalar 48 49
52: 10(ivec2) Load 27(in_coords)
Store 51(param) 52
Store 53(param) 50
54: 2 FunctionCall 23(image_store(I21;vi2;vf4;) 47(image3) 51(param) 53(param)
58: 12(fvec4) Load 40(read2)
60: 12(fvec4) VectorTimesScalar 58 59
62: 10(ivec2) Load 27(in_coords)
Store 61(param) 62
Store 63(param) 60
64: 2 FunctionCall 23(image_store(I21;vi2;vf4;) 57(image4) 61(param) 63(param)
Store 66(out_color) 68
Return
FunctionEnd
16(image_load(I21;vi2;): 12(fvec4) Function None 13
14(image): 8(ptr) FunctionParameter
15(coords): 11(ptr) FunctionParameter
17: Label
25: 7 Load 14(image)
28: 10(ivec2) Load 27(in_coords)
29: 12(fvec4) ImageRead 25 28
ReturnValue 29
FunctionEnd
23(image_store(I21;vi2;vf4;): 2 Function None 19
20(image): 8(ptr) FunctionParameter
21(coords): 11(ptr) FunctionParameter
22(data): 18(ptr) FunctionParameter
24: Label
32: 7 Load 20(image)
33: 10(ivec2) Load 27(in_coords)
34: 12(fvec4) Load 22(data)
ImageWrite 32 33 34
Return
FunctionEnd

View File

@ -0,0 +1,33 @@
#version 420
// Need this extension to permit passing a formatless readonly image to a helper function.
#extension GL_EXT_shader_image_load_formatted : require
readonly coherent uniform layout(set = 0, binding = 0) image2D image1;
readonly uniform layout(set = 0, binding = 2) image2D image2;
writeonly coherent uniform layout(set = 0, binding = 1, rgba32f) image2D image3;
writeonly uniform layout(set = 0, binding = 3, rgba16f) image2D image4;
flat in layout(location = 0) ivec2 in_coords;
out layout(location = 0) vec4 out_color;
vec4 image_load(readonly coherent image2D image, ivec2 coords)
{
return imageLoad(image, in_coords);
}
void image_store(writeonly coherent image2D image, ivec2 coords, vec4 data)
{
imageStore(image, in_coords, data);
}
void main()
{
vec4 read1 = image_load(image1, in_coords);
vec4 read2 = image_load(image2, in_coords);
image_store(image3, in_coords, read1*0.5);
image_store(image4, in_coords, read2*2.0);
out_color = vec4(0.0);
}

View File

@ -376,6 +376,7 @@ INSTANTIATE_TEST_SUITE_P(
"spv.offsets.frag", "spv.offsets.frag",
"spv.Operations.frag", "spv.Operations.frag",
"spv.paramMemory.frag", "spv.paramMemory.frag",
"spv.paramMemory.420.frag",
"spv.precision.frag", "spv.precision.frag",
"spv.precisionArgs.frag", "spv.precisionArgs.frag",
"spv.precisionNonESSamp.frag", "spv.precisionNonESSamp.frag",