DxilFunctionProps.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // //
  3. // DxilFunctionProps.h //
  4. // Copyright (C) Microsoft Corporation. All rights reserved. //
  5. // This file is distributed under the University of Illinois Open Source //
  6. // License. See LICENSE.TXT for details. //
  7. // //
  8. // Function properties for a dxil shader function. //
  9. // //
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #pragma once
  12. #include "dxc/DXIL/DxilConstants.h"
  13. namespace llvm {
  14. class Function;
  15. class Constant;
  16. }
  17. namespace hlsl {
  18. struct DxilFunctionProps {
  19. DxilFunctionProps() {
  20. memset(this, 0, sizeof(DxilFunctionProps));
  21. }
  22. union {
  23. // Compute shader.
  24. struct {
  25. unsigned numThreads[3];
  26. } CS;
  27. // Geometry shader.
  28. struct {
  29. DXIL::InputPrimitive inputPrimitive;
  30. unsigned maxVertexCount;
  31. unsigned instanceCount;
  32. DXIL::PrimitiveTopology
  33. streamPrimitiveTopologies[DXIL::kNumOutputStreams];
  34. } GS;
  35. // Hull shader.
  36. struct {
  37. llvm::Function *patchConstantFunc;
  38. DXIL::TessellatorDomain domain;
  39. DXIL::TessellatorPartitioning partition;
  40. DXIL::TessellatorOutputPrimitive outputPrimitive;
  41. unsigned inputControlPoints;
  42. unsigned outputControlPoints;
  43. float maxTessFactor;
  44. } HS;
  45. // Domain shader.
  46. struct {
  47. DXIL::TessellatorDomain domain;
  48. unsigned inputControlPoints;
  49. } DS;
  50. // Vertex shader.
  51. struct {
  52. llvm::Constant *clipPlanes[DXIL::kNumClipPlanes];
  53. } VS;
  54. // Pixel shader.
  55. struct {
  56. bool EarlyDepthStencil;
  57. } PS;
  58. // Ray Tracing shaders
  59. struct {
  60. union {
  61. unsigned payloadSizeInBytes;
  62. unsigned paramSizeInBytes;
  63. };
  64. unsigned attributeSizeInBytes;
  65. } Ray;
  66. // Mesh shader.
  67. struct {
  68. unsigned numThreads[3];
  69. unsigned maxVertexCount;
  70. unsigned maxPrimitiveCount;
  71. DXIL::MeshOutputTopology outputTopology;
  72. unsigned payloadSizeInBytes;
  73. } MS;
  74. // Amplification shader.
  75. struct {
  76. unsigned numThreads[3];
  77. unsigned payloadSizeInBytes;
  78. } AS;
  79. } ShaderProps;
  80. DXIL::ShaderKind shaderKind;
  81. // TODO: Should we have an unmangled name here for ray tracing shaders?
  82. bool IsPS() const { return shaderKind == DXIL::ShaderKind::Pixel; }
  83. bool IsVS() const { return shaderKind == DXIL::ShaderKind::Vertex; }
  84. bool IsGS() const { return shaderKind == DXIL::ShaderKind::Geometry; }
  85. bool IsHS() const { return shaderKind == DXIL::ShaderKind::Hull; }
  86. bool IsDS() const { return shaderKind == DXIL::ShaderKind::Domain; }
  87. bool IsCS() const { return shaderKind == DXIL::ShaderKind::Compute; }
  88. bool IsGraphics() const {
  89. return (shaderKind >= DXIL::ShaderKind::Pixel && shaderKind <= DXIL::ShaderKind::Domain) ||
  90. shaderKind == DXIL::ShaderKind::Mesh || shaderKind == DXIL::ShaderKind::Amplification;
  91. }
  92. bool IsRayGeneration() const { return shaderKind == DXIL::ShaderKind::RayGeneration; }
  93. bool IsIntersection() const { return shaderKind == DXIL::ShaderKind::Intersection; }
  94. bool IsAnyHit() const { return shaderKind == DXIL::ShaderKind::AnyHit; }
  95. bool IsClosestHit() const { return shaderKind == DXIL::ShaderKind::ClosestHit; }
  96. bool IsMiss() const { return shaderKind == DXIL::ShaderKind::Miss; }
  97. bool IsCallable() const { return shaderKind == DXIL::ShaderKind::Callable; }
  98. bool IsRay() const {
  99. return (shaderKind >= DXIL::ShaderKind::RayGeneration && shaderKind <= DXIL::ShaderKind::Callable);
  100. }
  101. bool IsMS() const { return shaderKind == DXIL::ShaderKind::Mesh; }
  102. bool IsAS() const { return shaderKind == DXIL::ShaderKind::Amplification; }
  103. };
  104. } // namespace hlsl