srg-layouts.azsl 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. ShaderResourceGroupSemantic ExampleBinding { FrequencyId = 0; };
  2. ShaderResourceGroup ExampleSRG : ExampleBinding
  3. {
  4. // This sample structure used to test packing rules is taken from here:
  5. // https://github.com/Microsoft/DirectXShaderCompiler/blob/master/docs/SPIR-V.rst
  6. struct S {
  7. float3 f;
  8. };
  9. // Packing offsets can be veryfied here:
  10. // http://shader-playground.timjones.io/e61c324359d57bc5914a090be821bee4
  11. // Packing offset // ConstantBuffer StructuredBuffer RelaxedStd140
  12. struct T {
  13. float a_float; // 0 0 0
  14. float3 b_float3; // 4 4 4
  15. S c_S_float3; // 16 16 16
  16. float2x3 d_float2x3; // 32 28 32
  17. row_major float2x3 e_float2x3; // 80 52 80
  18. int f_int_3[3]; // 112 76 112
  19. float2 g_float2_2[2]; // 160 88 160
  20. S h_S_float3[2]; // 192 104 192
  21. float i_float[3][3]; // 224 128 224
  22. S j_S_float3[2][2]; // 368 164 368
  23. }; // Size is 428 Size is 212 Size is 432
  24. struct Light { // 144 bytes Source : https://developer.nvidia.com/content/how-about-constant-buffers
  25. float3 Position;
  26. float Radius;
  27. float4 Color;
  28. float3 AttenuationParams;
  29. uint Type;
  30. float4 SpotDirectionAndAngle;
  31. float4 ShadowRect;
  32. float4x4 ShadowMatrix;
  33. };
  34. T m_T;
  35. ConstantBuffer<T> m_CB_a; // stride = 272 (relaxed) or 428 (strict)
  36. ConstantBuffer<T> m_CB_b[2]; // stride = 272 (relaxed) or 428 (strict)
  37. ConstantBuffer<Light> m_CB_c; // stride = 144
  38. Buffer<float4> m_B_d; // stride = 16
  39. StructuredBuffer<S> m_SB_e; // stride = 12
  40. Buffer<float2> m_B_f[2]; // stride = 8
  41. StructuredBuffer<S> m_SB_g[2]; // stride = 12
  42. TextureCube m_texCube1; // stride = 16 (default)
  43. Texture2D<float3> m_tex2d1; // stride = 12
  44. };