DxilResource.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. DXIL::SamplerFeedbackType GetSamplerFeedbackType() const;
  38. void SetSamplerFeedbackType(DXIL::SamplerFeedbackType Value);
  39. bool IsGloballyCoherent() const;
  40. void SetGloballyCoherent(bool b);
  41. bool HasCounter() const;
  42. void SetHasCounter(bool b);
  43. bool IsRO() const;
  44. bool IsRW() const;
  45. void SetRW(bool bRW);
  46. bool IsROV() const;
  47. void SetROV(bool bROV);
  48. bool IsAnyTexture() const;
  49. bool IsStructuredBuffer() const;
  50. bool IsTypedBuffer() const;
  51. bool IsRawBuffer() const;
  52. bool IsTBuffer() const;
  53. bool IsFeedbackTexture() const;
  54. bool HasAtomic64Use() const;
  55. void SetHasAtomic64Use(bool b);
  56. static bool classof(const DxilResourceBase *R) {
  57. return R->GetClass() == DXIL::ResourceClass::SRV || R->GetClass() == DXIL::ResourceClass::UAV;
  58. }
  59. private:
  60. unsigned m_SampleCount;
  61. unsigned m_ElementStride; // in bytes
  62. CompType m_CompType;
  63. DXIL::SamplerFeedbackType m_SamplerFeedbackType;
  64. bool m_bGloballyCoherent;
  65. bool m_bHasCounter;
  66. bool m_bROV;
  67. bool m_bHasAtomic64Use;
  68. };
  69. } // namespace hlsl