bogner created this revision. bogner added reviewers: beanz, python3kgae. Herald added subscribers: Anastasia, mcrosier. Herald added a reviewer: aaron.ballman. Herald added a project: All. bogner requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Also test all shader types and be a bit more careful to make shaders reasonably valid in these tests. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D158820 Files: clang/include/clang/Basic/Attr.td clang/test/SemaHLSL/entry_shader.hlsl clang/test/SemaHLSL/shader_type_attr.hlsl clang/test/SemaHLSL/valid-shader-stages.hlsl
Index: clang/test/SemaHLSL/valid-shader-stages.hlsl =================================================================== --- /dev/null +++ clang/test/SemaHLSL/valid-shader-stages.hlsl @@ -0,0 +1,37 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -finclude-default-header -o - %s -verify + +// expected-no-diagnostics + +[shader("pixel")] void pixel(); +[shader("vertex")] void vertex(); +[shader("geometry")] void geometry(); +[shader("hull")] void hull(); +[shader("domain")] void domain(); +[shader("raygeneration")] void raygeneration(); +[shader("intersection")] void intersection(); +[shader("anyhit")] void anyhit(); +[shader("closesthit")] void closesthit(); +[shader("miss")] void miss(); +[shader("callable")] void callable(); + +[numthreads(1,1,1)][shader("compute")] void compute() {} +[numthreads(1,1,1)][shader("mesh")] void mesh() {} + +#ifndef __DXC_VERSION_MAJOR +// TODO: These should all come from the implicit header eventually. +#define inout +#define in +struct BuiltInTriangleIntersectionAttributes { + float2 barycentrics; +}; +#endif + +typedef BuiltInTriangleIntersectionAttributes Attrs; +struct Payload { + float4 color; +}; + +[shader("raygeneration")] void raygeneration() {} +[shader("closesthit")] void closesthit(inout Payload payload, in Attrs attr) {} +[shader("anyhit")] void anyhit(inout Payload payload, in Attrs attr) {} +[shader("miss")] void miss(inout Payload payload) {} Index: clang/test/SemaHLSL/shader_type_attr.hlsl =================================================================== --- clang/test/SemaHLSL/shader_type_attr.hlsl +++ clang/test/SemaHLSL/shader_type_attr.hlsl @@ -28,7 +28,7 @@ } // namespace spec // expected-error@+1 {{'shader' attribute parameters do not match the previous declaration}} -[shader("compute")] +[shader("pixel")] // expected-note@+1 {{conflicting attribute is here}} [shader("vertex")] int doubledUp() { @@ -40,7 +40,7 @@ int forwardDecl(); // expected-error@+1 {{'shader' attribute parameters do not match the previous declaration}} -[shader("compute")] +[shader("compute"), numthreads(8,1,1)] int forwardDecl() { return 1; } @@ -58,17 +58,17 @@ #endif // END of FAIL // CHECK:HLSLShaderAttr 0x{{[0-9a-fA-F]+}} <line:61:2, col:18> Compute -[shader("compute")] +[shader("compute"), numthreads(8,1,1)] int entry() { return 1; } // Because these two attributes match, they should both appear in the AST -[shader("compute")] +[shader("compute"), numthreads(8,1,1)] // CHECK:HLSLShaderAttr 0x{{[0-9a-fA-F]+}} <line:67:2, col:18> Compute int secondFn(); -[shader("compute")] +[shader("compute"), numthreads(8,1,1)] // CHECK:HLSLShaderAttr 0x{{[0-9a-fA-F]+}} <line:71:2, col:18> Compute int secondFn() { return 1; Index: clang/test/SemaHLSL/entry_shader.hlsl =================================================================== --- clang/test/SemaHLSL/entry_shader.hlsl +++ clang/test/SemaHLSL/entry_shader.hlsl @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -x hlsl -hlsl-entry foo -o - %s -DSHADER='"anyHit"' -verify +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -x hlsl -hlsl-entry foo -o - %s -DSHADER='"mesh"' -verify // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -x hlsl -hlsl-entry foo -o - %s -DSHADER='"compute"' // expected-error@+1 {{'shader' attribute on entry function does not match the target profile}} Index: clang/include/clang/Basic/Attr.td =================================================================== --- clang/include/clang/Basic/Attr.td +++ clang/include/clang/Basic/Attr.td @@ -4143,8 +4143,8 @@ EnumArgument<"Type", "ShaderType", [ "pixel", "vertex", "geometry", "hull", "domain", "compute", - "library", "raygeneration", "intersection", "anyHit", - "closestHit", "miss", "callable", "mesh", "amplification" + "library", "raygeneration", "intersection", "anyhit", + "closesthit", "miss", "callable", "mesh", "amplification" ], [ "Pixel", "Vertex", "Geometry", "Hull", "Domain", "Compute", @@ -4232,4 +4232,3 @@ let Subjects = SubjectList<[TypedefName], ErrorDiag>; let Documentation = [Undocumented]; } -
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits