DxilResource.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // //
  3. // DxilResource.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 of HLSL SRVs and UAVs. //
  9. // //
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #pragma once
  12. #include "DxilConstants.h"
  13. #include "dxc/DXIL/DxilResourceBase.h"
  14. #include "dxc/DXIL/DxilCompType.h"
  15. namespace hlsl {
  16. /// Use this class to represent an HLSL resource (SRV/UAV).
  17. class DxilResource : public DxilResourceBase {
  18. public:
  19. /// Total number of coordinates necessary to access resource.
  20. static unsigned GetNumCoords(Kind ResourceKind);
  21. /// Total number of resource dimensions (Only width and height for cube).
  22. static unsigned GetNumDimensions(Kind ResourceKind);
  23. /// Total number of resource dimensions for CalcLOD (no array).
  24. static unsigned GetNumDimensionsForCalcLOD(Kind ResourceKind);
  25. /// Total number of offsets (in [-8,7]) necessary to access resource.
  26. static unsigned GetNumOffsets(Kind ResourceKind);
  27. /// Whether the resource kind is texture.
  28. static bool IsAnyTexture(Kind ResourceKind);
  29. DxilResource();
  30. CompType GetCompType() const;
  31. void SetCompType(const CompType CT);
  32. llvm::Type *GetRetType() const;
  33. unsigned GetSampleCount() const;
  34. void SetSampleCount(unsigned SampleCount);
  35. unsigned GetElementStride() const;
  36. void SetElementStride(unsigned ElemStride);
  37. unsigned GetBaseAlignLog2() const;
  38. void SetBaseAlignLog2(unsigned baseAlignLog2);
  39. DXIL::SamplerFeedbackType GetSamplerFeedbackType() const;
  40. void SetSamplerFeedbackType(DXIL::SamplerFeedbackType Value);
  41. bool IsGloballyCoherent() const;
  42. void SetGloballyCoherent(bool b);
  43. bool HasCounter() const;
  44. void SetHasCounter(bool b);
  45. bool IsRO() const;
  46. bool IsRW() const;
  47. void SetRW(bool bRW);
  48. bool IsROV() const;
  49. void SetROV(bool bROV);
  50. bool IsAnyTexture() const;
  51. bool IsStructuredBuffer() const;
  52. bool IsTypedBuffer() const;
  53. bool IsRawBuffer() const;
  54. bool IsTBuffer() const;
  55. bool IsFeedbackTexture() const;
  56. bool HasAtomic64Use() const;
  57. void SetHasAtomic64Use(bool b);
  58. static bool classof(const DxilResourceBase *R) {
  59. return R->GetClass() == DXIL::ResourceClass::SRV || R->GetClass() == DXIL::ResourceClass::UAV;
  60. }
  61. private:
  62. unsigned m_SampleCount;
  63. unsigned m_ElementStride; // in bytes
  64. unsigned m_baseAlignLog2 = 0; // worst-case alignment
  65. CompType m_CompType;
  66. DXIL::SamplerFeedbackType m_SamplerFeedbackType;
  67. bool m_bGloballyCoherent;
  68. bool m_bHasCounter;
  69. bool m_bROV;
  70. bool m_bHasAtomic64Use;
  71. };
  72. } // namespace hlsl