SimpleHs5.hlsl 2.7 KB

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