Fix Test/hlsl.namespace.frag test case

Before this change, the example is rejected by DXC:

$ dxc -T ps_6_0 hlsl.namespace.frag
hlsl.namespace.frag:22:73: error: call to non-static member function
without an object argument
    return N1::getVec() + N2::getVec() + N2::N3::getVec() + N2::N3::C1::getVec() * N2::gf;
                                                                ~~~~~~~~~~~~^~~~~~

The call to the class member function requires an object, or we ned to
make the function static.  This update makes the function static.

This also fixes SPIR-V validation: without this change the call
to that getVec does not have enough arguments:

error: line 69: OpFunctionCall Function <id>'s parameter count does not
match the argument count.
  %43 = OpFunctionCall %v4float %N2__N3__C1__getVec_
This commit is contained in:
David Neto 2022-02-16 17:10:29 -05:00
parent 90d4bd05cd
commit 63dbacaa94
2 changed files with 45 additions and 54 deletions

View File

@ -17,9 +17,8 @@ gl_FragCoord origin is upper left
0:? Sequence 0:? Sequence
0:12 Branch: Return with expression 0:12 Branch: Return with expression
0:12 'v2' ( global 4-component vector of float) 0:12 'v2' ( global 4-component vector of float)
0:15 Function Definition: N2::N3::C1::getVec( ( temp 4-component vector of float) 0:15 Function Definition: N2::N3::C1::getVec( ( global 4-component vector of float)
0:15 Function Parameters: 0:15 Function Parameters:
0:15 '@this' ( temp structure{})
0:? Sequence 0:? Sequence
0:15 Branch: Return with expression 0:15 Branch: Return with expression
0:15 'v2' ( global 4-component vector of float) 0:15 'v2' ( global 4-component vector of float)
@ -34,7 +33,7 @@ gl_FragCoord origin is upper left
0:22 Function Call: N2::getVec( ( temp 4-component vector of float) 0:22 Function Call: N2::getVec( ( temp 4-component vector of float)
0:22 Function Call: N2::N3::getVec( ( temp 4-component vector of float) 0:22 Function Call: N2::N3::getVec( ( temp 4-component vector of float)
0:22 vector-scale ( temp 4-component vector of float) 0:22 vector-scale ( temp 4-component vector of float)
0:22 Function Call: N2::N3::C1::getVec( ( temp 4-component vector of float) 0:22 Function Call: N2::N3::C1::getVec( ( global 4-component vector of float)
0:22 'N2::gf' ( global float) 0:22 'N2::gf' ( global float)
0:21 Function Definition: main( ( temp void) 0:21 Function Definition: main( ( temp void)
0:21 Function Parameters: 0:21 Function Parameters:
@ -70,9 +69,8 @@ gl_FragCoord origin is upper left
0:? Sequence 0:? Sequence
0:12 Branch: Return with expression 0:12 Branch: Return with expression
0:12 'v2' ( global 4-component vector of float) 0:12 'v2' ( global 4-component vector of float)
0:15 Function Definition: N2::N3::C1::getVec( ( temp 4-component vector of float) 0:15 Function Definition: N2::N3::C1::getVec( ( global 4-component vector of float)
0:15 Function Parameters: 0:15 Function Parameters:
0:15 '@this' ( temp structure{})
0:? Sequence 0:? Sequence
0:15 Branch: Return with expression 0:15 Branch: Return with expression
0:15 'v2' ( global 4-component vector of float) 0:15 'v2' ( global 4-component vector of float)
@ -87,7 +85,7 @@ gl_FragCoord origin is upper left
0:22 Function Call: N2::getVec( ( temp 4-component vector of float) 0:22 Function Call: N2::getVec( ( temp 4-component vector of float)
0:22 Function Call: N2::N3::getVec( ( temp 4-component vector of float) 0:22 Function Call: N2::N3::getVec( ( temp 4-component vector of float)
0:22 vector-scale ( temp 4-component vector of float) 0:22 vector-scale ( temp 4-component vector of float)
0:22 Function Call: N2::N3::C1::getVec( ( temp 4-component vector of float) 0:22 Function Call: N2::N3::C1::getVec( ( global 4-component vector of float)
0:22 'N2::gf' ( global float) 0:22 'N2::gf' ( global float)
0:21 Function Definition: main( ( temp void) 0:21 Function Definition: main( ( temp void)
0:21 Function Parameters: 0:21 Function Parameters:
@ -101,82 +99,75 @@ gl_FragCoord origin is upper left
0:? 'N2::gf' ( global float) 0:? 'N2::gf' ( global float)
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) 0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
Validation failed
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 8000a // Generated by (magic number): 8000a
// Id's are bound by 54 // Id's are bound by 50
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 52 EntryPoint Fragment 4 "main" 48
ExecutionMode 4 OriginUpperLeft ExecutionMode 4 OriginUpperLeft
Source HLSL 500 Source HLSL 500
Name 4 "main" Name 4 "main"
Name 9 "N1::getVec(" Name 9 "N1::getVec("
Name 11 "N2::getVec(" Name 11 "N2::getVec("
Name 13 "N2::N3::getVec(" Name 13 "N2::N3::getVec("
Name 15 "C1" Name 15 "N2::N3::C1::getVec("
Name 19 "N2::N3::C1::getVec(" Name 17 "@main("
Name 18 "@this" Name 20 "v1"
Name 21 "@main(" Name 24 "v2"
Name 24 "v1" Name 41 "N2::gf"
Name 28 "v2" Name 48 "@entryPointOutput"
Name 45 "N2::gf" Decorate 48(@entryPointOutput) Location 0
Name 52 "@entryPointOutput"
Decorate 52(@entryPointOutput) Location 0
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeFloat 32 6: TypeFloat 32
7: TypeVector 6(float) 4 7: TypeVector 6(float) 4
8: TypeFunction 7(fvec4) 8: TypeFunction 7(fvec4)
15(C1): TypeStruct 19: TypePointer Private 7(fvec4)
16: TypePointer Function 15(C1) 20(v1): 19(ptr) Variable Private
17: TypeFunction 7(fvec4) 16(ptr) 24(v2): 19(ptr) Variable Private
23: TypePointer Private 7(fvec4) 40: TypePointer Private 6(float)
24(v1): 23(ptr) Variable Private 41(N2::gf): 40(ptr) Variable Private
28(v2): 23(ptr) Variable Private 47: TypePointer Output 7(fvec4)
44: TypePointer Private 6(float) 48(@entryPointOutput): 47(ptr) Variable Output
45(N2::gf): 44(ptr) Variable Private
51: TypePointer Output 7(fvec4)
52(@entryPointOutput): 51(ptr) Variable Output
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
53: 7(fvec4) FunctionCall 21(@main() 49: 7(fvec4) FunctionCall 17(@main()
Store 52(@entryPointOutput) 53 Store 48(@entryPointOutput) 49
Return Return
FunctionEnd FunctionEnd
9(N1::getVec(): 7(fvec4) Function None 8 9(N1::getVec(): 7(fvec4) Function None 8
10: Label 10: Label
25: 7(fvec4) Load 24(v1) 21: 7(fvec4) Load 20(v1)
ReturnValue 25 ReturnValue 21
FunctionEnd FunctionEnd
11(N2::getVec(): 7(fvec4) Function None 8 11(N2::getVec(): 7(fvec4) Function None 8
12: Label 12: Label
29: 7(fvec4) Load 28(v2) 25: 7(fvec4) Load 24(v2)
ReturnValue 29 ReturnValue 25
FunctionEnd FunctionEnd
13(N2::N3::getVec(): 7(fvec4) Function None 8 13(N2::N3::getVec(): 7(fvec4) Function None 8
14: Label 14: Label
32: 7(fvec4) Load 28(v2) 28: 7(fvec4) Load 24(v2)
ReturnValue 32 ReturnValue 28
FunctionEnd FunctionEnd
19(N2::N3::C1::getVec(): 7(fvec4) Function None 17 15(N2::N3::C1::getVec(): 7(fvec4) Function None 8
18(@this): 16(ptr) FunctionParameter 16: Label
20: Label 31: 7(fvec4) Load 24(v2)
35: 7(fvec4) Load 28(v2) ReturnValue 31
ReturnValue 35
FunctionEnd FunctionEnd
21(@main(): 7(fvec4) Function None 8 17(@main(): 7(fvec4) Function None 8
22: Label 18: Label
38: 7(fvec4) FunctionCall 9(N1::getVec() 34: 7(fvec4) FunctionCall 9(N1::getVec()
39: 7(fvec4) FunctionCall 11(N2::getVec() 35: 7(fvec4) FunctionCall 11(N2::getVec()
40: 7(fvec4) FAdd 38 39 36: 7(fvec4) FAdd 34 35
41: 7(fvec4) FunctionCall 13(N2::N3::getVec() 37: 7(fvec4) FunctionCall 13(N2::N3::getVec()
42: 7(fvec4) FAdd 40 41 38: 7(fvec4) FAdd 36 37
43: 7(fvec4) FunctionCall 19(N2::N3::C1::getVec() 39: 7(fvec4) FunctionCall 15(N2::N3::C1::getVec()
46: 6(float) Load 45(N2::gf) 42: 6(float) Load 41(N2::gf)
47: 7(fvec4) VectorTimesScalar 43 46 43: 7(fvec4) VectorTimesScalar 39 42
48: 7(fvec4) FAdd 42 47 44: 7(fvec4) FAdd 38 43
ReturnValue 48 ReturnValue 44
FunctionEnd FunctionEnd

View File

@ -12,7 +12,7 @@ namespace N2 {
float4 getVec() { return v2; } float4 getVec() { return v2; }
class C1 { class C1 {
float4 getVec() { return v2; } static float4 getVec() { return v2; }
}; };
} }
} }