hsAttribute.hlsl 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // RUN: %dxc -E main -T hs_6_0 %s | FileCheck %s
  2. // CHECK: InputControlPointCount=3
  3. // CHECK: OutputControlPointCount=3
  4. // CHECK: Domain=tri
  5. // CHECK: OutputPrimitive=triangle_cw
  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[ 3 ] : SV_TessFactor;
  60. float inside : SV_InsideTessFactor;
  61. };
  62. float4 HSPerPatchFunc()
  63. {
  64. return 1.8;
  65. }
  66. HSPerPatchData HSPerPatchFunc( const InputPatch< PSSceneIn, 3 > points )
  67. {
  68. HSPerPatchData d;
  69. d.edges[ 0 ] = 1;
  70. d.edges[ 1 ] = 1;
  71. d.edges[ 2 ] = 1;
  72. d.inside = 1;
  73. return d;
  74. }
  75. // hull per-control point shader
  76. [domain("tri")]
  77. [partitioning("fractional_odd")]
  78. [outputtopology("triangle_cw")]
  79. [patchconstantfunc("HSPerPatchFunc")]
  80. [outputcontrolpoints(3)]
  81. HSPerVertexData main( const uint id : SV_OutputControlPointID,
  82. const InputPatch< PSSceneIn, 3 > points )
  83. {
  84. HSPerVertexData v;
  85. // Just forward the vertex
  86. v.v = points[ id ];
  87. return v;
  88. }