xref: /llvm-project/clang/test/SemaHLSL/Availability/avail-lib-multiple-stages.hlsl (revision 8890209ead2246461985f49c4c9c01cc2371ac09)
1// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library \
2// RUN: -fsyntax-only -verify %s
3
4__attribute__((availability(shadermodel, introduced = 6.5)))
5float fx(float);  // #fx
6
7__attribute__((availability(shadermodel, introduced = 5.0, environment = pixel)))
8__attribute__((availability(shadermodel, introduced = 6.5, environment = compute)))
9float fy(float); // #fy
10
11__attribute__((availability(shadermodel, introduced = 5.0, environment = compute)))
12float fz(float); // #fz
13
14
15void F(float f) {
16  // Make sure we only get this error once, even though this function is scanned twice - once
17  // in compute shader context and once in pixel shader context.
18  // expected-error@#fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
19  // expected-note@#fx {{fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
20  float A = fx(f); // #fx_call
21
22  // expected-error@#fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
23  // expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
24  float B = fy(f); // #fy_call
25
26  // expected-error@#fz_call {{'fz' is unavailable}}
27  // expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 5.0 in compute environment here, but the deployment target is Shader Model 6.0 pixel environment}}
28  float X = fz(f); // #fz_call
29}
30
31void deadCode(float f) {
32  // no diagnostics expected under default diagnostic mode
33  float A = fx(f);
34  float B = fy(f);
35  float X = fz(f);
36}
37
38// Pixel shader
39[shader("pixel")]
40void mainPixel() {
41  F(1.0);
42}
43
44// First Compute shader
45[shader("compute")]
46[numthreads(4,1,1)]
47void mainCompute1() {
48  F(2.0);
49}
50
51// Second compute shader to make sure we do not get duplicate messages if F is called
52// from multiple entry points.
53[shader("compute")]
54[numthreads(4,1,1)]
55void mainCompute2() {
56  F(3.0);
57}
58