DxilResourceBase.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // //
  3. // DxilResourceBase.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. // Base class to represent DXIL SRVs, UAVs, CBuffers, and Samplers. //
  9. // //
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #pragma once
  12. #include <string>
  13. #include "DxilConstants.h"
  14. namespace llvm {
  15. class Value;
  16. class Constant;
  17. }
  18. namespace hlsl {
  19. /// Base class to represent HLSL SRVs, UAVs, CBuffers, and Samplers.
  20. class DxilResourceBase {
  21. public:
  22. using Class = DXIL::ResourceClass;
  23. using Kind = DXIL::ResourceKind;
  24. public:
  25. DxilResourceBase(Class C);
  26. virtual ~DxilResourceBase() {}
  27. Class GetClass() const;
  28. DxilResourceBase::Kind GetKind() const;
  29. unsigned GetID() const;
  30. unsigned GetSpaceID() const;
  31. unsigned GetLowerBound() const;
  32. unsigned GetUpperBound() const;
  33. unsigned GetRangeSize() const;
  34. llvm::Constant *GetGlobalSymbol() const;
  35. const std::string &GetGlobalName() const;
  36. llvm::Value *GetHandle() const;
  37. bool IsAllocated() const;
  38. bool IsUnbounded() const;
  39. void SetKind(DxilResourceBase::Kind ResourceKind);
  40. void SetSpaceID(unsigned SpaceID);
  41. void SetLowerBound(unsigned LB);
  42. void SetRangeSize(unsigned RangeSize);
  43. void SetGlobalSymbol(llvm::Constant *pGV);
  44. void SetGlobalName(const std::string &Name);
  45. void SetHandle(llvm::Value *pHandle);
  46. // TODO: check whether we can make this a protected method.
  47. void SetID(unsigned ID);
  48. const char *GetResClassName() const;
  49. const char *GetResDimName() const;
  50. const char *GetResIDPrefix() const;
  51. const char *GetResBindPrefix() const;
  52. protected:
  53. void SetClass(Class C);
  54. private:
  55. Class m_Class; // Resource class (SRV, UAV, CBuffer, Sampler).
  56. Kind m_Kind; // Detail resource kind( texture2D...).
  57. unsigned m_ID; // Unique ID within the class.
  58. unsigned m_SpaceID; // Root signature space.
  59. unsigned m_LowerBound; // Range lower bound.
  60. unsigned m_RangeSize; // Range size in entries.
  61. llvm::Constant *m_pSymbol; // Global variable.
  62. std::string m_Name; // Unmangled name of the global variable.
  63. llvm::Value *m_pHandle; // Cached resource handle for SM5.0- (and maybe SM5.1).
  64. };
  65. } // namespace hlsl