SimpleDs1.hlsl 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // RUN: %dxc -E main -T ds_6_0 %s | FileCheck %s
  2. // CHECK: SV_RenderTargetArrayIndex or SV_ViewportArrayIndex from any shader feeding rasterizer
  3. // CHECK: InputControlPointCount=3
  4. // CHECK: OutputPositionPresent=1
  5. // CHECK: domainLocation.f32
  6. // CHECK: loadPatchConstant
  7. //--------------------------------------------------------------------------------------
  8. // SimpleTessellation.hlsl
  9. //
  10. // Advanced Technology Group (ATG)
  11. // Copyright (C) Microsoft Corporation. All rights reserved.
  12. //--------------------------------------------------------------------------------------
  13. struct VSSceneIn {
  14. float3 pos : POSITION;
  15. float3 norm : NORMAL;
  16. float2 tex : TEXCOORD0;
  17. };
  18. struct PSSceneIn {
  19. float4 pos : SV_Position;
  20. float2 tex : TEXCOORD0;
  21. float3 norm : NORMAL;
  22. uint RTIndex : SV_RenderTargetArrayIndex;
  23. };
  24. //////////////////////////////////////////////////////////////////////////////////////////
  25. // Simple forwarding Tessellation shaders
  26. struct HSPerVertexData {
  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. // We at least have to specify tess factors per patch
  33. // As we're tesselating triangles, there will be 4 tess factors
  34. // In real life case this might contain face normal, for example
  35. float edges[3] : SV_TessFactor;
  36. float inside : SV_InsideTessFactor;
  37. };
  38. // domain shader that actually outputs the triangle vertices
  39. [domain("tri")] PSSceneIn main(const float3 bary
  40. : SV_DomainLocation,
  41. const OutputPatch<HSPerVertexData, 3> patch,
  42. const HSPerPatchData perPatchData) {
  43. PSSceneIn v;
  44. // Compute interpolated coordinates
  45. v.pos = patch[0].v.pos * bary.x + patch[1].v.pos * bary.y + patch[2].v.pos * bary.z + perPatchData.edges[1];
  46. v.tex = patch[0].v.tex * bary.x + patch[1].v.tex * bary.y + patch[2].v.tex * bary.z + perPatchData.edges[0];
  47. v.norm = patch[0].v.norm * bary.x + patch[1].v.norm * bary.y + patch[2].v.norm * bary.z + perPatchData.inside;
  48. v.RTIndex = 0;
  49. return v;
  50. }