DxilFunctionProps.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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(&ShaderProps, 0, sizeof(ShaderProps));
  21. shaderKind = DXIL::ShaderKind::Invalid;
  22. waveSize = 0;
  23. }
  24. union {
  25. // Compute shader.
  26. struct {
  27. unsigned numThreads[3];
  28. } CS;
  29. // Geometry shader.
  30. struct {
  31. DXIL::InputPrimitive inputPrimitive;
  32. unsigned maxVertexCount;
  33. unsigned instanceCount;
  34. DXIL::PrimitiveTopology
  35. streamPrimitiveTopologies[DXIL::kNumOutputStreams];
  36. } GS;
  37. // Hull shader.
  38. struct {
  39. llvm::Function *patchConstantFunc;
  40. DXIL::TessellatorDomain domain;
  41. DXIL::TessellatorPartitioning partition;
  42. DXIL::TessellatorOutputPrimitive outputPrimitive;
  43. unsigned inputControlPoints;
  44. unsigned outputControlPoints;
  45. float maxTessFactor;
  46. } HS;
  47. // Domain shader.
  48. struct {
  49. DXIL::TessellatorDomain domain;
  50. unsigned inputControlPoints;
  51. } DS;
  52. // Vertex shader.
  53. struct {
  54. llvm::Constant *clipPlanes[DXIL::kNumClipPlanes];
  55. } VS;
  56. // Pixel shader.
  57. struct {
  58. bool EarlyDepthStencil;
  59. } PS;
  60. // Ray Tracing shaders
  61. struct {
  62. union {
  63. unsigned payloadSizeInBytes;
  64. unsigned paramSizeInBytes;
  65. };
  66. unsigned attributeSizeInBytes;
  67. } Ray;
  68. // Mesh shader.
  69. struct {
  70. unsigned numThreads[3];
  71. unsigned maxVertexCount;
  72. unsigned maxPrimitiveCount;
  73. DXIL::MeshOutputTopology outputTopology;
  74. unsigned payloadSizeInBytes;
  75. } MS;
  76. // Amplification shader.
  77. struct {
  78. unsigned numThreads[3];
  79. unsigned payloadSizeInBytes;
  80. } AS;
  81. } ShaderProps;
  82. DXIL::ShaderKind shaderKind;
  83. // WaveSize is currently allowed only on compute shaders, but could be supported on other shader types in the future
  84. unsigned waveSize;
  85. // Save root signature for lib profile entry.
  86. std::vector<uint8_t> serializedRootSignature;
  87. void SetSerializedRootSignature(const uint8_t *pData, unsigned size) {
  88. serializedRootSignature.assign(pData, pData+size);
  89. }
  90. // TODO: Should we have an unmangled name here for ray tracing shaders?
  91. bool IsPS() const { return shaderKind == DXIL::ShaderKind::Pixel; }
  92. bool IsVS() const { return shaderKind == DXIL::ShaderKind::Vertex; }
  93. bool IsGS() const { return shaderKind == DXIL::ShaderKind::Geometry; }
  94. bool IsHS() const { return shaderKind == DXIL::ShaderKind::Hull; }
  95. bool IsDS() const { return shaderKind == DXIL::ShaderKind::Domain; }
  96. bool IsCS() const { return shaderKind == DXIL::ShaderKind::Compute; }
  97. bool IsGraphics() const {
  98. return (shaderKind >= DXIL::ShaderKind::Pixel && shaderKind <= DXIL::ShaderKind::Domain) ||
  99. shaderKind == DXIL::ShaderKind::Mesh || shaderKind == DXIL::ShaderKind::Amplification;
  100. }
  101. bool IsRayGeneration() const { return shaderKind == DXIL::ShaderKind::RayGeneration; }
  102. bool IsIntersection() const { return shaderKind == DXIL::ShaderKind::Intersection; }
  103. bool IsAnyHit() const { return shaderKind == DXIL::ShaderKind::AnyHit; }
  104. bool IsClosestHit() const { return shaderKind == DXIL::ShaderKind::ClosestHit; }
  105. bool IsMiss() const { return shaderKind == DXIL::ShaderKind::Miss; }
  106. bool IsCallable() const { return shaderKind == DXIL::ShaderKind::Callable; }
  107. bool IsRay() const {
  108. return (shaderKind >= DXIL::ShaderKind::RayGeneration && shaderKind <= DXIL::ShaderKind::Callable);
  109. }
  110. bool IsMS() const { return shaderKind == DXIL::ShaderKind::Mesh; }
  111. bool IsAS() const { return shaderKind == DXIL::ShaderKind::Amplification; }
  112. };
  113. } // namespace hlsl