resource_array2.hlsl 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // RUN: %dxc -E main -T ps_6_0 -Od %s | FileCheck %s
  2. // Make sure unused resources are handled even when
  3. // they're arrays.
  4. // CHECK: @main
  5. static bool gG;
  6. static bool gG2;
  7. static bool gG3;
  8. Texture2D tex0[42] : register(t0);
  9. Texture2D tex1 : register(t42);
  10. Texture2D tex2[2][2] : register(t43);
  11. const uint idx1;
  12. const uint idx2;
  13. const uint idx3;
  14. static Texture2D local_tex1;
  15. static Texture2D local_tex2;
  16. static Texture2D local_tex3;
  17. Texture2D f(bool foo) {
  18. [branch]
  19. if (foo)
  20. return local_tex1;
  21. else
  22. return tex1;
  23. }
  24. Texture2D g(bool foo) {
  25. [branch]
  26. if (foo)
  27. return local_tex2;
  28. else
  29. return local_tex3;
  30. }
  31. Texture2D h(bool foo3) {
  32. return foo3 ? f(gG2) : g(gG3);
  33. }
  34. [RootSignature("CBV(b0), DescriptorTable(SRV(t0, numDescriptors=42), SRV(t42), SRV(t43, numDescriptors=4))")]
  35. float4 main() : sv_target {
  36. // CHECK: %[[handle:.+]] = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 0, i32 0, i32 42
  37. local_tex1 = tex0[idx1];
  38. local_tex2 = tex0[idx2];
  39. local_tex3 = tex2[idx3][idx1];
  40. gG = true;
  41. gG2 = false;
  42. gG3 = false;
  43. // CHECK: @dx.op.textureLoad.f32(i32 66, %dx.types.Handle %[[handle]]
  44. return h(gG).Load(0);
  45. };