2
0

lib_entries.hlsl 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. // RUN: %dxc -T lib_6_3 -auto-binding-space 11 %s | FileCheck %s
  2. // Make sure entry function exist.
  3. // CHECK: @cs_main()
  4. // Make sure signatures are lowered.
  5. // CHECK: dx.op.threadId
  6. // CHECK: dx.op.groupId
  7. // Make sure entry function exist.
  8. // CHECK: @gs_main()
  9. // Make sure signatures are lowered.
  10. // CHECK: dx.op.loadInput
  11. // CHECK: dx.op.storeOutput
  12. // CHECK: dx.op.emitStream
  13. // CHECK: dx.op.cutStream
  14. // Make sure entry function exist.
  15. // CHECK: @ds_main()
  16. // Make sure signatures are lowered.
  17. // CHECK: dx.op.loadPatchConstant
  18. // CHECK: dx.op.domainLocation
  19. // CHECK: dx.op.loadInput
  20. // CHECK: dx.op.storeOutput
  21. // Make sure patch constant function exist.
  22. // CHECK: HSPerPatchFunc
  23. // Make sure signatures are lowered.
  24. // CHECK: dx.op.storePatchConstant
  25. // Make sure entry function exist.
  26. // CHECK: @hs_main()
  27. // Make sure signatures are lowered.
  28. // CHECK: dx.op.outputControlPointID
  29. // CHECK: dx.op.loadInput
  30. // CHECK: dx.op.storeOutput
  31. // Make sure entry function exist.
  32. // CHECK: @vs_main()
  33. // Make sure signatures are lowered.
  34. // CHECK: dx.op.loadInput
  35. // Dot4 for clipplane
  36. // CHECK: dx.op.dot4
  37. // CHECK: dx.op.storeOutput
  38. // Make sure entry function exist.
  39. // CHECK: @ps_main()
  40. // Make sure signatures are lowered.
  41. // CHECK: dx.op.loadInput
  42. // CHECK: dx.op.storeOutput
  43. // Finish ps_main
  44. // CHECK: ret void
  45. // Make sure function entrys exist.
  46. // CHECK: !dx.entryPoints = !{{{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}}
  47. // Make sure cs doesn't have signature.
  48. // CHECK: !"cs_main", null
  49. void StoreCSOutput(uint2 tid, uint2 gid);
  50. [numthreads(8,8,1)]
  51. void cs_main( uint2 tid : SV_DispatchThreadID, uint2 gid : SV_GroupID, uint2 gtid : SV_GroupThreadID, uint gidx : SV_GroupIndex )
  52. {
  53. StoreCSOutput(tid, gid);
  54. }
  55. // GS
  56. struct GSOut {
  57. float2 uv : TEXCOORD0;
  58. float4 pos : SV_Position;
  59. };
  60. // geometry shader that outputs 3 vertices from a point
  61. [maxvertexcount(3)]
  62. [instance(24)]
  63. void gs_main(InputPatch<GSOut, 2>points, inout PointStream<GSOut> stream) {
  64. stream.Append(points[0]);
  65. stream.RestartStrip();
  66. }
  67. // DS
  68. struct PSSceneIn {
  69. float4 pos : SV_Position;
  70. float2 tex : TEXCOORD0;
  71. float3 norm : NORMAL;
  72. uint RTIndex : SV_RenderTargetArrayIndex;
  73. };
  74. struct HSPerVertexData {
  75. // This is just the original vertex verbatim. In many real life cases this would be a
  76. // control point instead
  77. PSSceneIn v;
  78. };
  79. struct HSPerPatchData {
  80. // We at least have to specify tess factors per patch
  81. // As we're tesselating triangles, there will be 4 tess factors
  82. // In real life case this might contain face normal, for example
  83. float edges[3] : SV_TessFactor;
  84. float inside : SV_InsideTessFactor;
  85. };
  86. // domain shader that actually outputs the triangle vertices
  87. [domain("tri")] PSSceneIn ds_main(const float3 bary
  88. : SV_DomainLocation,
  89. const OutputPatch<HSPerVertexData, 3> patch,
  90. const HSPerPatchData perPatchData) {
  91. PSSceneIn v;
  92. // Compute interpolated coordinates
  93. v.pos = patch[0].v.pos * bary.x + patch[1].v.pos * bary.y + patch[2].v.pos * bary.z + perPatchData.edges[1];
  94. v.tex = patch[0].v.tex * bary.x + patch[1].v.tex * bary.y + patch[2].v.tex * bary.z + perPatchData.edges[0];
  95. v.norm = patch[0].v.norm * bary.x + patch[1].v.norm * bary.y + patch[2].v.norm * bary.z + perPatchData.inside;
  96. v.RTIndex = 0;
  97. return v;
  98. }
  99. // HS
  100. HSPerPatchData HSPerPatchFunc( const InputPatch< PSSceneIn, 3 > points, OutputPatch<HSPerVertexData, 3> outp)
  101. {
  102. HSPerPatchData d;
  103. d.edges[ 0 ] = 1;
  104. d.edges[ 1 ] = 1;
  105. d.edges[ 2 ] = 1;
  106. d.inside = 1;
  107. return d;
  108. }
  109. // hull per-control point shader
  110. [domain("tri")]
  111. [partitioning("fractional_odd")]
  112. [outputtopology("triangle_cw")]
  113. [patchconstantfunc("HSPerPatchFunc")]
  114. [outputcontrolpoints(3)]
  115. HSPerVertexData hs_main( const uint id : SV_OutputControlPointID,
  116. const InputPatch< PSSceneIn, 3 > points)
  117. {
  118. HSPerVertexData v;
  119. // Just forward the vertex
  120. v.v = points[ id ];
  121. return v;
  122. }
  123. // VS
  124. struct VS_INPUT
  125. {
  126. float3 vPosition : POSITION;
  127. float3 vNormal : NORMAL;
  128. float2 vTexcoord : TEXCOORD0;
  129. };
  130. struct VS_OUTPUT
  131. {
  132. float3 vNormal : NORMAL;
  133. float2 vTexcoord : TEXCOORD0;
  134. float4 vPosition : SV_POSITION;
  135. };
  136. cbuffer VSCB {
  137. float4 plane;
  138. }
  139. [clipplanes(plane)]
  140. VS_OUTPUT vs_main(VS_INPUT Input)
  141. {
  142. VS_OUTPUT Output;
  143. Output.vPosition = float4( Input.vPosition, 1.0 );
  144. Output.vNormal = Input.vNormal;
  145. Output.vTexcoord = Input.vTexcoord;
  146. return Output;
  147. }
  148. // PS
  149. [earlydepthstencil]
  150. float4 ps_main(float4 a : A) : SV_TARGET
  151. {
  152. return a;
  153. }