SimpleHs1.hlsl 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // RUN: %dxc -E main -T hs_6_0 %s | FileCheck %s
  2. // CHECK: SV_RenderTargetArrayIndex or SV_ViewportArrayIndex from any shader feeding rasterizer
  3. // CHECK: InputControlPointCount=3
  4. // CHECK: OutputControlPointCount=3
  5. // CHECK: Domain=tri
  6. // CHECK: OutputPrimitive=triangle_cw
  7. // CHECK: storePatchConstant
  8. // CHECK: outputControlPointID
  9. //--------------------------------------------------------------------------------------
  10. // SimpleTessellation.hlsl
  11. //
  12. // Advanced Technology Group (ATG)
  13. // Copyright (C) Microsoft Corporation. All rights reserved.
  14. //--------------------------------------------------------------------------------------
  15. struct VSSceneIn
  16. {
  17. float3 pos : POSITION;
  18. float3 norm : NORMAL;
  19. float2 tex : TEXCOORD0;
  20. };
  21. struct PSSceneIn
  22. {
  23. float4 pos : SV_Position;
  24. float2 tex : TEXCOORD0;
  25. float3 norm : NORMAL;
  26. uint RTIndex : SV_RenderTargetArrayIndex;
  27. };
  28. cbuffer cb0
  29. {
  30. float4x4 g_mWorldViewProj;
  31. };
  32. Texture2D g_txDiffuse : register( t0 );
  33. SamplerState g_sampler : register( s0 );
  34. //////////////////////////////////////////////////////////////////////////////////////////
  35. // Regular VS/PS rendering
  36. PSSceneIn VSSceneMain( VSSceneIn input )
  37. {
  38. PSSceneIn output;
  39. output.pos = mul( float4( input.pos, 1.0 ), g_mWorldViewProj );
  40. output.tex = input.tex;
  41. output.norm = input.norm;
  42. return output;
  43. }
  44. float4 PSSceneMain( PSSceneIn input ) : SV_Target
  45. {
  46. return g_txDiffuse.Sample( g_sampler, input.tex );
  47. }
  48. //////////////////////////////////////////////////////////////////////////////////////////
  49. // Simple forwarding Tessellation shaders
  50. struct HSPerVertexData
  51. {
  52. // This is just the original vertex verbatim. In many real life cases this would be a
  53. // control point instead
  54. PSSceneIn v;
  55. };
  56. struct HSPerPatchData
  57. {
  58. // We at least have to specify tess factors per patch
  59. // As we're tesselating triangles, there will be 4 tess factors
  60. // In real life case this might contain face normal, for example
  61. float edges[ 3 ] : SV_TessFactor;
  62. float inside : SV_InsideTessFactor;
  63. };
  64. float4 HSPerPatchFunc()
  65. {
  66. return 1.8;
  67. }
  68. HSPerPatchData HSPerPatchFunc( const InputPatch< PSSceneIn, 3 > points )
  69. {
  70. HSPerPatchData d;
  71. d.edges[ 0 ] = 1;
  72. d.edges[ 1 ] = 1;
  73. d.edges[ 2 ] = 1;
  74. d.inside = 1;
  75. return d;
  76. }
  77. // hull per-control point shader
  78. [domain("tri")]
  79. [partitioning("fractional_odd")]
  80. [outputtopology("triangle_cw")]
  81. [patchconstantfunc("HSPerPatchFunc")]
  82. [outputcontrolpoints(3)]
  83. HSPerVertexData main( const uint id : SV_OutputControlPointID,
  84. const InputPatch< PSSceneIn, 3 > points )
  85. {
  86. HSPerVertexData v;
  87. // Just forward the vertex
  88. v.v = points[ id ];
  89. return v;
  90. }