DxilFunctionProps.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. } ShaderProps;
  67. DXIL::ShaderKind shaderKind;
  68. // TODO: Should we have an unmangled name here for ray tracing shaders?
  69. bool IsPS() const { return shaderKind == DXIL::ShaderKind::Pixel; }
  70. bool IsVS() const { return shaderKind == DXIL::ShaderKind::Vertex; }
  71. bool IsGS() const { return shaderKind == DXIL::ShaderKind::Geometry; }
  72. bool IsHS() const { return shaderKind == DXIL::ShaderKind::Hull; }
  73. bool IsDS() const { return shaderKind == DXIL::ShaderKind::Domain; }
  74. bool IsCS() const { return shaderKind == DXIL::ShaderKind::Compute; }
  75. bool IsGraphics() const {
  76. return (shaderKind >= DXIL::ShaderKind::Pixel && shaderKind <= DXIL::ShaderKind::Domain);
  77. }
  78. bool IsRayGeneration() const { return shaderKind == DXIL::ShaderKind::RayGeneration; }
  79. bool IsIntersection() const { return shaderKind == DXIL::ShaderKind::Intersection; }
  80. bool IsAnyHit() const { return shaderKind == DXIL::ShaderKind::AnyHit; }
  81. bool IsClosestHit() const { return shaderKind == DXIL::ShaderKind::ClosestHit; }
  82. bool IsMiss() const { return shaderKind == DXIL::ShaderKind::Miss; }
  83. bool IsCallable() const { return shaderKind == DXIL::ShaderKind::Callable; }
  84. bool IsRay() const {
  85. return (shaderKind >= DXIL::ShaderKind::RayGeneration && shaderKind <= DXIL::ShaderKind::Callable);
  86. }
  87. };
  88. } // namespace hlsl