DxilResource.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. static bool classof(const DxilResourceBase *R) {
  55. return R->GetClass() == DXIL::ResourceClass::SRV || R->GetClass() == DXIL::ResourceClass::UAV;
  56. }
  57. private:
  58. unsigned m_SampleCount;
  59. unsigned m_ElementStride; // in bytes
  60. CompType m_CompType;
  61. DXIL::SamplerFeedbackType m_SamplerFeedbackType;
  62. bool m_bGloballyCoherent;
  63. bool m_bHasCounter;
  64. bool m_bROV;
  65. };
  66. } // namespace hlsl