SimpleHs8.hlsl 2.0 KB

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