srg-strip-unused-none-fallback.azsl 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 contains the fallback key and it should not be removed.
  4. // In the end no SRG should be stripped.
  5. ShaderResourceGroupSemantic slot1
  6. {
  7. FrequencyId = 1;
  8. };
  9. ShaderResourceGroupSemantic slot2
  10. {
  11. FrequencyId = 2;
  12. };
  13. ShaderResourceGroupSemantic slot3
  14. {
  15. FrequencyId = 3;
  16. ShaderVariantFallback = 128;
  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. If SRG3 is stripped then this can be stripped too.
  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 and it is the chosen fallback.
  38. // Should not be removed when --strip-unused-srgs is used.
  39. ShaderResourceGroup SRG3 : slot3
  40. {
  41. ConstantBuffer<SRG2::MB> m_mycbs; ConstantBuffer<SRG1::CB> m_srgcb; SRG2::MB m_mbr;
  42. float4 m_uniformColor;
  43. Texture2D m_texture;
  44. Buffer<float> m_buffer;
  45. Sampler m_dynamicSampler;
  46. Sampler m_staticSampler
  47. {
  48. AddressU = Wrap;
  49. AddressV = Wrap;
  50. AddressW = Wrap;
  51. MagFilter = Linear;
  52. };
  53. row_major float3x4 m_modelToWorld;
  54. row_major float3x3 m_normalMatrix;
  55. float4x4 GetWorldMatrix()
  56. {
  57. float4x4 modelToWorld = float4x4(
  58. float4(1, 0, 0, 0),
  59. float4(0, 1, 0, 0),
  60. float4(0, 0, 1, 0),
  61. float4(0, 0, 0, 1));
  62. modelToWorld[0] = m_modelToWorld[0];
  63. modelToWorld[1] = m_modelToWorld[1];
  64. modelToWorld[2] = m_modelToWorld[2];
  65. return modelToWorld;
  66. }
  67. float3x3 GetNormalMatrix()
  68. {
  69. return m_normalMatrix;
  70. }
  71. };
  72. float4 MainPS(float2 uv) : SV_Target0
  73. {
  74. return SRG1::m_uniforms.color;
  75. }