SimpleHs11.hlsl 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // RUN: %dxc -E main -T hs_6_0 %s 2>&1 | FileCheck %s
  2. // Same as SimpleHS10.hlsl, except that now we check that the compiler didn't
  3. // lie when it told us which overload it selected.
  4. // CHECK: SV_TessFactor 0
  5. // CHECK: SV_InsideTessFactor 0
  6. // CHECK: define void @main
  7. // CHECK: define void {{.*}}HSPerPatchFunc
  8. // CHECK: dx.op.storePatchConstant.f32{{.*}}float 1.0
  9. // CHECK: dx.op.storePatchConstant.f32{{.*}}float 2.0
  10. // CHECK: dx.op.storePatchConstant.f32{{.*}}float 3.0
  11. // CHECK: dx.op.storePatchConstant.f32{{.*}}float 4.0
  12. //--------------------------------------------------------------------------------------
  13. // SimpleTessellation.hlsl
  14. //
  15. // Advanced Technology Group (ATG)
  16. // Copyright (C) Microsoft Corporation. All rights reserved.
  17. //--------------------------------------------------------------------------------------
  18. struct PSSceneIn
  19. {
  20. float4 pos : SV_Position;
  21. float2 tex : TEXCOORD0;
  22. float3 norm : NORMAL;
  23. uint RTIndex : SV_RenderTargetArrayIndex;
  24. };
  25. //////////////////////////////////////////////////////////////////////////////////////////
  26. // Simple forwarding Tessellation shaders
  27. struct HSPerVertexData
  28. {
  29. // This is just the original vertex verbatim. In many real life cases this would be a
  30. // control point instead
  31. PSSceneIn v;
  32. };
  33. struct HSPerPatchData
  34. {
  35. // We at least have to specify tess factors per patch
  36. // As we're tesselating triangles, there will be 4 tess factors
  37. // In real life case this might contain face normal, for example
  38. float edges[3] : SV_TessFactor;
  39. float inside : SV_InsideTessFactor;
  40. };
  41. // This function has the same name as the patch constant function, but
  42. // its signature prevents it from being a candidate.
  43. float4 HSPerPatchFunc()
  44. {
  45. return 1.8;
  46. }
  47. // This overload is a patch constant function candidate because it has an
  48. // output with the SV_TessFactor semantic. However, the compiler should
  49. // *not* select it because there is another overload defined later in this
  50. // translation unit (which is the old compiler's behavior). If it did, then
  51. // the semantic checker will report an error due to this overload's input
  52. // having 32 elements (versus the expected 3).
  53. HSPerPatchData HSPerPatchFunc(const InputPatch< PSSceneIn, 32 > points)
  54. {
  55. HSPerPatchData d;
  56. d.edges[0] = -5;
  57. d.edges[1] = -6;
  58. d.edges[2] = -7;
  59. d.inside = -8;
  60. return d;
  61. }
  62. // hull per-control point shader
  63. [domain("tri")]
  64. [partitioning("fractional_odd")]
  65. [outputtopology("triangle_cw")]
  66. [patchconstantfunc("HSPerPatchFunc")]
  67. [outputcontrolpoints(3)]
  68. HSPerVertexData main( const uint id : SV_OutputControlPointID,
  69. const InputPatch< PSSceneIn, 3 > points )
  70. {
  71. HSPerVertexData v;
  72. // Just forward the vertex
  73. v.v = points[ id ];
  74. return v;
  75. }
  76. HSPerPatchData HSPerPatchFunc(const InputPatch< PSSceneIn, 3 > points)
  77. {
  78. HSPerPatchData d;
  79. d.edges[0] = 1;
  80. d.edges[1] = 2;
  81. d.edges[2] = 3;
  82. d.inside = 4;
  83. return d;
  84. }