Error out writes to shaderRecordNV buffer blocks.

This commit is contained in:
Ashwin Lele 2019-03-04 11:05:55 -08:00
parent d90d548161
commit afa5671fef
7 changed files with 72 additions and 89 deletions

View File

@ -1,7 +1,7 @@
spv.RayGenShader.rgen
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 61
// Id's are bound by 54
Capability RayTracingNV
Extension "SPV_NV_ray_tracing"
@ -18,23 +18,22 @@ spv.RayGenShader.rgen
Name 21 "gl_LaunchSizeNV"
Name 24 "sy"
Name 29 "accNV0"
Name 48 "block"
MemberName 48(block) 0 "arr"
MemberName 48(block) 1 "pad"
Name 50 ""
Name 56 "payload"
Name 60 "accNV1"
Name 37 "block"
MemberName 37(block) 0 "dir"
MemberName 37(block) 1 "origin"
Name 39 ""
Name 50 "accNV1"
Name 53 "payload"
Decorate 11(gl_LaunchIDNV) BuiltIn LaunchIdNV
Decorate 21(gl_LaunchSizeNV) BuiltIn LaunchSizeNV
Decorate 29(accNV0) DescriptorSet 0
Decorate 29(accNV0) Binding 0
Decorate 46 ArrayStride 4
MemberDecorate 48(block) 0 Offset 0
MemberDecorate 48(block) 1 Offset 16
Decorate 48(block) BufferBlock
Decorate 56(payload) Location 0
Decorate 60(accNV1) DescriptorSet 0
Decorate 60(accNV1) Binding 1
MemberDecorate 37(block) 0 Offset 0
MemberDecorate 37(block) 1 Offset 16
Decorate 37(block) BufferBlock
Decorate 50(accNV1) DescriptorSet 0
Decorate 50(accNV1) Binding 1
Decorate 53(payload) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
@ -51,27 +50,19 @@ spv.RayGenShader.rgen
29(accNV0): 28(ptr) Variable UniformConstant
35: TypeFloat 32
36: TypeVector 35(float) 3
37: 35(float) Constant 0
38: 36(fvec3) ConstantComposite 37 37 37
39: 35(float) Constant 1056964608
40: 35(float) Constant 1065353216
41: 36(fvec3) ConstantComposite 40 40 40
42: 35(float) Constant 1061158912
43: TypeInt 32 1
44: 43(int) Constant 1
45: 6(int) Constant 4
46: TypeArray 35(float) 45
47: TypeVector 35(float) 4
48(block): TypeStruct 46 47(fvec4)
49: TypePointer ShaderRecordBufferNV 48(block)
50: 49(ptr) Variable ShaderRecordBufferNV
51: 43(int) Constant 0
52: 43(int) Constant 3
53: TypePointer ShaderRecordBufferNV 35(float)
55: TypePointer RayPayloadNV 47(fvec4)
56(payload): 55(ptr) Variable RayPayloadNV
58: TypePointer ShaderRecordBufferNV 47(fvec4)
60(accNV1): 28(ptr) Variable UniformConstant
37(block): TypeStruct 36(fvec3) 36(fvec3)
38: TypePointer ShaderRecordBufferNV 37(block)
39: 38(ptr) Variable ShaderRecordBufferNV
40: TypeInt 32 1
41: 40(int) Constant 1
42: TypePointer ShaderRecordBufferNV 36(fvec3)
45: 35(float) Constant 1056964608
46: 40(int) Constant 0
49: 35(float) Constant 1061158912
50(accNV1): 28(ptr) Variable UniformConstant
51: TypeVector 35(float) 4
52: TypePointer RayPayloadNV 51(fvec4)
53(payload): 52(ptr) Variable RayPayloadNV
4(main): 2 Function None 3
5: Label
8(lx): 7(ptr) Variable Function
@ -95,11 +86,10 @@ spv.RayGenShader.rgen
32: 6(int) Load 16(ly)
33: 6(int) Load 20(sx)
34: 6(int) Load 24(sy)
TraceNV 30 31 32 33 34 12 38 39 41 42 44
54: 53(ptr) AccessChain 50 51 52
Store 54 40
57: 47(fvec4) Load 56(payload)
59: 58(ptr) AccessChain 50 44
Store 59 57
43: 42(ptr) AccessChain 39 41
44: 36(fvec3) Load 43
47: 42(ptr) AccessChain 39 46
48: 36(fvec3) Load 47
TraceNV 30 31 32 33 34 12 44 45 48 49 41
Return
FunctionEnd

View File

@ -1,7 +1,7 @@
spv.RayGenShader11.rgen
// Module Version 10300
// Generated by (magic number): 80007
// Id's are bound by 60
// Id's are bound by 53
Capability RayTracingNV
Extension "SPV_NV_ray_tracing"
@ -18,20 +18,19 @@ spv.RayGenShader11.rgen
Name 21 "gl_LaunchSizeNV"
Name 24 "sy"
Name 29 "accNV"
Name 48 "block"
MemberName 48(block) 0 "arr"
MemberName 48(block) 1 "pad"
Name 50 ""
Name 56 "payload"
Name 37 "block"
MemberName 37(block) 0 "dir"
MemberName 37(block) 1 "origin"
Name 39 ""
Name 52 "payload"
Decorate 11(gl_LaunchIDNV) BuiltIn LaunchIdNV
Decorate 21(gl_LaunchSizeNV) BuiltIn LaunchSizeNV
Decorate 29(accNV) DescriptorSet 0
Decorate 29(accNV) Binding 0
Decorate 46 ArrayStride 4
MemberDecorate 48(block) 0 Offset 0
MemberDecorate 48(block) 1 Offset 16
Decorate 48(block) Block
Decorate 56(payload) Location 0
MemberDecorate 37(block) 0 Offset 0
MemberDecorate 37(block) 1 Offset 16
Decorate 37(block) Block
Decorate 52(payload) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
@ -48,26 +47,18 @@ spv.RayGenShader11.rgen
29(accNV): 28(ptr) Variable UniformConstant
35: TypeFloat 32
36: TypeVector 35(float) 3
37: 35(float) Constant 0
38: 36(fvec3) ConstantComposite 37 37 37
39: 35(float) Constant 1056964608
40: 35(float) Constant 1065353216
41: 36(fvec3) ConstantComposite 40 40 40
42: 35(float) Constant 1061158912
43: TypeInt 32 1
44: 43(int) Constant 1
45: 6(int) Constant 4
46: TypeArray 35(float) 45
47: TypeVector 35(float) 4
48(block): TypeStruct 46 47(fvec4)
49: TypePointer ShaderRecordBufferNV 48(block)
50: 49(ptr) Variable ShaderRecordBufferNV
51: 43(int) Constant 0
52: 43(int) Constant 3
53: TypePointer ShaderRecordBufferNV 35(float)
55: TypePointer RayPayloadNV 47(fvec4)
56(payload): 55(ptr) Variable RayPayloadNV
58: TypePointer ShaderRecordBufferNV 47(fvec4)
37(block): TypeStruct 36(fvec3) 36(fvec3)
38: TypePointer ShaderRecordBufferNV 37(block)
39: 38(ptr) Variable ShaderRecordBufferNV
40: TypeInt 32 1
41: 40(int) Constant 1
42: TypePointer ShaderRecordBufferNV 36(fvec3)
45: 35(float) Constant 1056964608
46: 40(int) Constant 0
49: 35(float) Constant 1061158912
50: TypeVector 35(float) 4
51: TypePointer RayPayloadNV 50(fvec4)
52(payload): 51(ptr) Variable RayPayloadNV
4(main): 2 Function None 3
5: Label
8(lx): 7(ptr) Variable Function
@ -91,11 +82,10 @@ spv.RayGenShader11.rgen
32: 6(int) Load 16(ly)
33: 6(int) Load 20(sx)
34: 6(int) Load 24(sy)
TraceNV 30 31 32 33 34 12 38 39 41 42 44
54: 53(ptr) AccessChain 50 51 52
Store 54 40
57: 47(fvec4) Load 56(payload)
59: 58(ptr) AccessChain 50 44
Store 59 57
43: 42(ptr) AccessChain 39 41
44: 36(fvec3) Load 43
47: 42(ptr) AccessChain 39 46
48: 36(fvec3) Load 47
TraceNV 30 31 32 33 34 12 44 45 48 49 41
Return
FunctionEnd

View File

@ -31,7 +31,8 @@ ERROR: 0:36: 'gl_HitKindNV' : undeclared identifier
ERROR: 0:37: 'reportIntersectionNV' : no matching overloaded function found
ERROR: 0:38: 'ignoreIntersectionNV' : no matching overloaded function found
ERROR: 0:39: 'terminateRayNV' : no matching overloaded function found
ERROR: 32 compilation errors. No code generated.
ERROR: 0:40: 'assign' : l-value required "anon@3" (can't modify a shaderrecordnv qualified buffer)
ERROR: 33 compilation errors. No code generated.
ERROR: Linking ray-generation stage: Only one shaderRecordNV buffer block is allowed per stage

View File

@ -5,8 +5,9 @@ layout(binding = 1, set = 0) uniform accelerationStructureNV accNV1; // Unused
layout(location = 0) rayPayloadNV vec4 payload;
layout(shaderRecordNV) buffer block
{
float arr[4];
vec4 pad;
vec3 dir;
vec3 origin;
};
void main()
{
@ -14,7 +15,5 @@ void main()
uint ly = gl_LaunchIDNV.y;
uint sx = gl_LaunchSizeNV.x;
uint sy = gl_LaunchSizeNV.y;
traceNV(accNV0, lx, ly, sx, sy, 0u, vec3(0.0f), 0.5f, vec3(1.0f), 0.75f, 1);
arr[3] = 1.0f;
pad = payload;
traceNV(accNV0, lx, ly, sx, sy, 0u, origin, 0.5f, dir, 0.75f, 1);
}

View File

@ -4,8 +4,8 @@ layout(binding = 0, set = 0) uniform accelerationStructureNV accNV;
layout(location = 0) rayPayloadNV vec4 payload;
layout(shaderRecordNV) buffer block
{
float arr[4];
vec4 pad;
vec3 dir;
vec3 origin;
};
void main()
{
@ -13,7 +13,5 @@ void main()
uint ly = gl_LaunchIDNV.y;
uint sx = gl_LaunchSizeNV.x;
uint sy = gl_LaunchSizeNV.y;
traceNV(accNV, lx, ly, sx, sy, 0u, vec3(0.0f), 0.5f, vec3(1.0f), 0.75f, 1);
arr[3] = 1.0f;
pad = payload;
traceNV(accNV, lx, ly, sx, sy, 0u, origin, 0.5f, dir, 0.75f, 1);
}

View File

@ -37,4 +37,5 @@ void main()
reportIntersectionNV(1.0, 1U); // ERROR, unsupported builtin in stage
ignoreIntersectionNV(); // ERROR, unsupported builtin in stage
terminateRayNV(); // ERROR, unsupported builtin in stage
d = 1.0f; // ERROR, can't modify shaderRecordNV block
}

View File

@ -152,6 +152,10 @@ bool TParseContextBase::lValueErrorCheck(const TSourceLoc& loc, const char* op,
case EvqBuffer:
if (node->getQualifier().readonly)
message = "can't modify a readonly buffer";
#ifdef NV_EXTENSIONS
if (node->getQualifier().layoutShaderRecordNV)
message = "can't modify a shaderrecordnv qualified buffer";
#endif
break;
#ifdef NV_EXTENSIONS
case EvqHitAttrNV: