SimpleHs9.hlsl 2.0 KB

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