SimpleHs6.hlsl 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // RUN: %dxc -E main -T hs_6_0 %s | FileCheck %s
  2. // CHECK: may only have one InputPatch parameter
  3. //--------------------------------------------------------------------------------------
  4. // SimpleTessellation.hlsl
  5. //
  6. // Advanced Technology Group (ATG)
  7. // Copyright (C) Microsoft Corporation. All rights reserved.
  8. //--------------------------------------------------------------------------------------
  9. struct PSSceneIn
  10. {
  11. float4 pos : SV_Position;
  12. float2 tex : TEXCOORD0;
  13. float3 norm : NORMAL;
  14. uint RTIndex : SV_RenderTargetArrayIndex;
  15. };
  16. //////////////////////////////////////////////////////////////////////////////////////////
  17. // Simple forwarding Tessellation shaders
  18. struct HSPerVertexData
  19. {
  20. // This is just the original vertex verbatim. In many real life cases this would be a
  21. // control point instead
  22. PSSceneIn v;
  23. };
  24. struct HSPerPatchData
  25. {
  26. // We at least have to specify tess factors per patch
  27. // As we're tesselating triangles, there will be 4 tess factors
  28. // In real life case this might contain face normal, for example
  29. float edges[ 3 ] : SV_TessFactor;
  30. float inside : SV_InsideTessFactor;
  31. };
  32. float4 HSPerPatchFunc()
  33. {
  34. return 1.8;
  35. }
  36. HSPerPatchData HSPerPatchFunc( const InputPatch< PSSceneIn, 3 > points, OutputPatch<HSPerVertexData, 5> outp )
  37. {
  38. HSPerPatchData d;
  39. d.edges[ 0 ] = 1;
  40. d.edges[ 1 ] = 1;
  41. d.edges[ 2 ] = 1;
  42. d.inside = 1;
  43. return d;
  44. }
  45. // hull per-control point shader
  46. [domain("tri")]
  47. [partitioning("fractional_odd")]
  48. [outputtopology("triangle_cw")]
  49. [patchconstantfunc("HSPerPatchFunc")]
  50. [outputcontrolpoints(3)]
  51. HSPerVertexData main( const uint id : SV_OutputControlPointID,
  52. const InputPatch< PSSceneIn, 3 > points, const InputPatch< PSSceneIn, 3 > points2 )
  53. {
  54. HSPerVertexData v;
  55. // Just forward the vertex
  56. v.v = points[ id ];
  57. return v;
  58. }