cbuf-usage-phi.hlsl 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // RUN: %dxc -T ps_6_5 -E main -Vd -validator-version 1.5 %s | %D3DReflect %s | FileCheck %s
  2. // Flags needed to ensure usage flags are preserved in reflection with -Qkeep_reflect_in_dxil (implied):
  3. // -T ps_6_5 -Vd -validator-version 1.5
  4. float4 UnusedGlobal[2];
  5. float4 LookupTable[2];
  6. bool TestBool;
  7. bool TestBool2;
  8. cbuffer CB {
  9. int TestInt;
  10. }
  11. float4 main() : SV_Target {
  12. uint Index = 0;
  13. // This introduces a phi for Index, due to use of new cbuffer.
  14. // If unhandled, this results in a zero offset into $Globals for LookupTable usage.
  15. if (TestBool) {
  16. Index = TestInt;
  17. }
  18. return LookupTable[Index]
  19. // This will produce a select with the same problem.
  20. + LookupTable[TestBool2 ? Index : 1];
  21. }
  22. // {{$}} is used to prevent match to 0x<anything>
  23. // CHECK: ID3D12ShaderReflection:
  24. // CHECK: Flags: 0{{$}}
  25. // CHECK: ConstantBuffers: 2
  26. // CHECK: BoundResources: 2
  27. // CHECK: Constant Buffers:
  28. // CHECK: D3D12_SHADER_BUFFER_DESC: Name: $Globals
  29. // CHECK: Type: D3D_CT_CBUFFER
  30. // CHECK: Size: 80
  31. // CHECK: uFlags: 0{{$}}
  32. // CHECK: Num Variables: 4
  33. // CHECK: {
  34. // CHECK: D3D12_SHADER_VARIABLE_DESC: Name: UnusedGlobal
  35. // CHECK: uFlags: 0{{$}}
  36. // CHECK: D3D12_SHADER_VARIABLE_DESC: Name: LookupTable
  37. // CHECK: uFlags: 0x2
  38. // CHECK: D3D12_SHADER_VARIABLE_DESC: Name: TestBool
  39. // CHECK: uFlags: 0x2
  40. // CHECK: D3D12_SHADER_VARIABLE_DESC: Name: TestBool2
  41. // CHECK: uFlags: 0x2
  42. // CHECK: }
  43. // CHECK: ID3D12ShaderReflectionConstantBuffer:
  44. // CHECK: D3D12_SHADER_BUFFER_DESC: Name: CB
  45. // CHECK: {
  46. // CHECK: D3D12_SHADER_VARIABLE_DESC: Name: TestInt
  47. // CHECK: uFlags: 0x2
  48. // CHECK: }
  49. // CHECK: Bound Resources:
  50. // CHECK: D3D12_SHADER_BUFFER_DESC: Name: $Globals
  51. // CHECK: BindCount: 1
  52. // CHECK: BindPoint: 0
  53. // CHECK: Space: 0
  54. // CHECK: uFlags: 0{{$}}
  55. // CHECK: D3D12_SHADER_BUFFER_DESC: Name: CB
  56. // CHECK: BindCount: 1
  57. // CHECK: BindPoint: 1
  58. // CHECK: Space: 0
  59. // CHECK: uFlags: 0{{$}}