nuklear_d3d12.hlsl 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #define NK_ROOTSIGNATURE ""\
  2. "RootFlags(ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT),"\
  3. "DescriptorTable("\
  4. "CBV(b0, numDescriptors = 1, flags = DATA_VOLATILE),"\
  5. "SRV(t0, numDescriptors = unbounded, flags = DESCRIPTORS_VOLATILE)"\
  6. "),"\
  7. "RootConstants(num32BitConstants = 1, b1),"\
  8. "StaticSampler(s0, "\
  9. "filter = FILTER_MIN_MAG_MIP_LINEAR,"\
  10. "addressU = TEXTURE_ADDRESS_CLAMP,"\
  11. "addressV = TEXTURE_ADDRESS_CLAMP,"\
  12. "addressW = TEXTURE_ADDRESS_CLAMP,"\
  13. "comparisonFunc = COMPARISON_ALWAYS"\
  14. ")"
  15. cbuffer buffer0 : register(b0)
  16. {
  17. float4x4 ProjectionMatrix;
  18. };
  19. static uint texture_index : register(b1);
  20. sampler sampler0 : register(s0);
  21. Texture2D<float4> textures[] : register(t0);
  22. struct VS_INPUT
  23. {
  24. float2 pos : POSITION;
  25. float4 col : COLOR0;
  26. float2 uv : TEXCOORD0;
  27. };
  28. struct PS_INPUT
  29. {
  30. float4 pos : SV_POSITION;
  31. float4 col : COLOR0;
  32. float2 uv : TEXCOORD0;
  33. };
  34. [RootSignature(NK_ROOTSIGNATURE)]
  35. PS_INPUT vs(VS_INPUT input)
  36. {
  37. PS_INPUT output;
  38. output.pos = mul(ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f));
  39. output.col = input.col;
  40. output.uv = input.uv;
  41. return output;
  42. }
  43. [RootSignature(NK_ROOTSIGNATURE)]
  44. float4 ps(PS_INPUT input) : SV_Target
  45. {
  46. return input.col * textures[texture_index].Sample(sampler0, input.uv);
  47. }