DxilResourceProperties.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // //
  3. // DxilHandleAnnotation.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. // Representation properties for DXIL handle. //
  9. // //
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #pragma once
  12. #include "DxilConstants.h"
  13. namespace llvm {
  14. class Constant;
  15. class Type;
  16. }
  17. namespace hlsl {
  18. struct DxilResourceProperties {
  19. DXIL::ResourceClass Class;
  20. DXIL::ResourceKind Kind;
  21. static constexpr unsigned kSampleCountUndefined = 0x7;
  22. struct DxilTyped {
  23. DXIL::ComponentType CompType : 5; // TypedBuffer/Image.
  24. uint32_t SingleComponent : 1; // Return type is single component.
  25. // 2^SampleCountPow2 for Sample count of Texture2DMS.
  26. uint32_t SampleCountPow2 : 3;
  27. uint32_t Reserved : 23;
  28. };
  29. union {
  30. DxilTyped Typed;
  31. uint32_t ElementStride; // in bytes for StructurizedBuffer.
  32. DXIL::SamplerFeedbackType SamplerFeedbackType; // FeedbackTexture2D.
  33. uint32_t SizeInBytes; // Cbuffer instance size in bytes.
  34. uint32_t RawDword0;
  35. };
  36. struct DxilUAV {
  37. uint32_t bROV : 1; // UAV
  38. uint32_t bGloballyCoherent : 1; // UAV
  39. uint32_t Reserved : 30;
  40. };
  41. union {
  42. DxilUAV UAV;
  43. uint32_t RawDword1;
  44. };
  45. bool operator==(const DxilResourceProperties &);
  46. bool operator!=(const DxilResourceProperties &);
  47. unsigned getSampleCount();
  48. };
  49. static_assert(sizeof(DxilResourceProperties) == 4 * sizeof(uint32_t),
  50. "update shader model and functions read/write "
  51. "DxilResourceProperties when size is changed");
  52. class ShaderModel;
  53. class DxilResourceBase;
  54. struct DxilInst_AnnotateHandle;
  55. namespace resource_helper {
  56. llvm::Constant *getAsConstant(const DxilResourceProperties &, llvm::Type *Ty,
  57. const ShaderModel &);
  58. DxilResourceProperties loadFromConstant(const llvm::Constant &C,
  59. DXIL::ResourceClass RC,
  60. DXIL::ResourceKind RK);
  61. DxilResourceProperties
  62. loadFromAnnotateHandle(DxilInst_AnnotateHandle &annotateHandle, llvm::Type *Ty,
  63. const ShaderModel &);
  64. DxilResourceProperties loadFromResourceBase(DxilResourceBase *);
  65. } // namespace resource_helper
  66. } // namespace hlsl