DxilResourceProperties.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. union {
  23. struct {
  24. DXIL::ComponentType CompType : 5; // TypedBuffer/Image.
  25. uint32_t SingleComponent : 1; // Return type is single component.
  26. // 2^SampleCountPow2 for Sample count of Texture2DMS.
  27. uint32_t SampleCountPow2 : 3;
  28. uint32_t Reserved : 23;
  29. } Typed;
  30. uint32_t ElementStride; // in bytes for StructurizedBuffer.
  31. DXIL::SamplerFeedbackType SamplerFeedbackType; // FeedbackTexture2D.
  32. uint32_t SizeInBytes; // Cbuffer instance size in bytes.
  33. uint32_t RawDword0;
  34. };
  35. union {
  36. struct {
  37. uint32_t bROV : 1; // UAV
  38. uint32_t bGloballyCoherent : 1; // UAV
  39. uint32_t Reserved : 30;
  40. } UAV;
  41. uint32_t RawDword1;
  42. };
  43. bool operator==(const DxilResourceProperties &);
  44. bool operator!=(const DxilResourceProperties &);
  45. unsigned getSampleCount();
  46. };
  47. static_assert(sizeof(DxilResourceProperties) == 4 * sizeof(uint32_t),
  48. "update shader model and functions read/write "
  49. "DxilResourceProperties when size is changed");
  50. class ShaderModel;
  51. class DxilResourceBase;
  52. struct DxilInst_AnnotateHandle;
  53. namespace resource_helper {
  54. llvm::Constant *getAsConstant(const DxilResourceProperties &, llvm::Type *Ty,
  55. const ShaderModel &);
  56. DxilResourceProperties loadFromConstant(const llvm::Constant &C,
  57. DXIL::ResourceClass RC,
  58. DXIL::ResourceKind RK);
  59. DxilResourceProperties
  60. loadFromAnnotateHandle(DxilInst_AnnotateHandle &annotateHandle, llvm::Type *Ty,
  61. const ShaderModel &);
  62. DxilResourceProperties loadFromResourceBase(DxilResourceBase *);
  63. }; // namespace resource_helper
  64. } // namespace hlsl