srg-strip-unused-SRG3.azsl 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // This file is used to validate the functionality of the --strip-unused-srgs flag.
  2. // There are three SRGs in this file: SRG1, SRG2 and SRG3.
  3. // Nothing references SRG3, but SRG3 references SRG2.
  4. // The MainPS function references SRG1 and SRG2.
  5. // Only SRG3 should be removed. Both SRG1 and SRG2 should survive.
  6. ShaderResourceGroupSemantic slot1
  7. {
  8. FrequencyId = 1;
  9. };
  10. ShaderResourceGroupSemantic slot2
  11. {
  12. FrequencyId = 2;
  13. };
  14. ShaderResourceGroupSemantic slot3
  15. {
  16. FrequencyId = 3;
  17. };
  18. //Referenced by MainPS
  19. ShaderResourceGroup SRG1 : slot1
  20. {
  21. struct CB
  22. {
  23. float4 color;
  24. };
  25. ConstantBuffer<CB> m_uniforms;
  26. };
  27. // Referenced by SRG3 and MainPS()
  28. ShaderResourceGroup SRG2 : slot2
  29. {
  30. struct MB
  31. {
  32. float4 position;
  33. };
  34. ConstantBuffer<MB> m_uniforms;
  35. MB m_other;
  36. };
  37. // Unused, but references SRG2.
  38. ShaderResourceGroup SRG3 : slot3
  39. {
  40. ConstantBuffer<SRG2::MB> m_mycbs; ConstantBuffer<SRG1::CB> m_srgcb; SRG2::MB m_mbr;
  41. float4 m_uniformColor;
  42. Texture2D m_texture;
  43. Buffer<float> m_buffer;
  44. Sampler m_dynamicSampler;
  45. Sampler m_staticSampler
  46. {
  47. AddressU = Wrap;
  48. AddressV = Wrap;
  49. AddressW = Wrap;
  50. MagFilter = Linear;
  51. };
  52. row_major float3x4 m_modelToWorld;
  53. row_major float3x3 m_normalMatrix;
  54. float4x4 GetWorldMatrix()
  55. {
  56. float4x4 modelToWorld = float4x4(
  57. float4(1, 0, 0, 0),
  58. float4(0, 1, 0, 0),
  59. float4(0, 0, 1, 0),
  60. float4(0, 0, 0, 1));
  61. modelToWorld[0] = m_modelToWorld[0];
  62. modelToWorld[1] = m_modelToWorld[1];
  63. modelToWorld[2] = m_modelToWorld[2];
  64. return modelToWorld;
  65. }
  66. float3x3 GetNormalMatrix()
  67. {
  68. return m_normalMatrix;
  69. }
  70. };
  71. float4 MainPS(float2 uv) : SV_Target0
  72. {
  73. return SRG1::m_uniforms.color + SRG2::m_other.position;
  74. }