SimpleHs10.hlsl 2.6 KB

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