SimpleGS1.hlsl 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // RUN: %dxc -E main -T gs_6_0 %s | FileCheck %s
  2. // CHECK: SV_RenderTargetArrayIndex or SV_ViewportArrayIndex from any shader feeding rasterizer
  3. // CHECK: InputPrimitive=point
  4. // CHECK: OutputTopology=triangle
  5. // CHECK: OutputStreamMask=1
  6. // CHECK: OutputPositionPresent=1
  7. // CHECK: emitStream
  8. // CHECK: emitStream
  9. // CHECK: emitStream
  10. // CHECK: cutStream
  11. struct VSOut {
  12. float2 uv : TEXCOORD0;
  13. float4 clr : COLOR;
  14. float4 pos : SV_Position;
  15. };
  16. struct VSOutGSIn {
  17. float3 posSize : POSSIZE;
  18. float4 clr : COLOR;
  19. uint index :SV_RenderTargetArrayIndex;
  20. };
  21. struct VSOutGSArrayIn {
  22. float3 posSize : POSSIZE;
  23. float2 clr[2] : COLOR;
  24. };
  25. struct VSOutGSMatIn {
  26. float3 posSize : POSSIZE;
  27. float2x2 clr[2] : COLOR;
  28. };
  29. cbuffer b : register(b0) {
  30. float2 invViewportSize;
  31. };
  32. float4 NDC(float2 screen) {
  33. screen *= invViewportSize * 2;
  34. screen.x = screen.x - 1;
  35. screen.y = 1 - screen.y;
  36. return float4(screen, 0.5f, 1);
  37. }
  38. // geometry shader that outputs 3 vertices from a point
  39. [maxvertexcount(3)] void main(point VSOutGSIn points[1], inout TriangleStream<VSOut> stream) {
  40. VSOut v;
  41. const float2 verts[3] =
  42. {
  43. float2(-0.5f, -0.5f),
  44. float2(1.5f, -0.5f),
  45. float2(-0.5f, 1.5f)};
  46. const float sz = points[0].posSize.z;
  47. const float2 org = points[0].posSize.xy;
  48. const float4 clr = float4(points[0].clr); //[0][1], points[ 0 ].clr[1][0]);
  49. // triangle strip for the particle
  50. v.uv = float2(0, 0);
  51. v.clr = clr;
  52. v.pos = NDC(org + verts[0] * sz);
  53. stream.Append(v);
  54. v.uv = float2(2, 0);
  55. v.clr = clr;
  56. v.pos = NDC(org + verts[1] * sz);
  57. stream.Append(v);
  58. v.uv = float2(0, 2);
  59. v.clr = clr;
  60. v.pos = NDC(org + verts[2] * sz);
  61. stream.Append(v);
  62. stream.RestartStrip();
  63. }