d3dx12_check_feature_support.h 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107
  1. //*********************************************************
  2. //
  3. // Copyright (c) Microsoft Corporation.
  4. // Licensed under the MIT License (MIT).
  5. //
  6. //*********************************************************
  7. #pragma once
  8. #ifndef __cplusplus
  9. #error D3DX12 requires C++
  10. #endif
  11. #include "d3d12.h"
  12. //================================================================================================
  13. // D3DX12 Check Feature Support
  14. //================================================================================================
  15. #include <vector>
  16. class CD3DX12FeatureSupport
  17. {
  18. public: // Function declaration
  19. // Default constructor that creates an empty object
  20. CD3DX12FeatureSupport() noexcept;
  21. // Initialize data from the given device
  22. HRESULT Init(ID3D12Device* pDevice);
  23. // Retreives the status of the object. If an error occurred in the initialization process, the function returns the error code.
  24. HRESULT GetStatus() const noexcept { return m_hStatus; }
  25. // Getter functions for each feature class
  26. // D3D12_OPTIONS
  27. BOOL DoublePrecisionFloatShaderOps() const noexcept;
  28. BOOL OutputMergerLogicOp() const noexcept;
  29. D3D12_SHADER_MIN_PRECISION_SUPPORT MinPrecisionSupport() const noexcept;
  30. D3D12_TILED_RESOURCES_TIER TiledResourcesTier() const noexcept;
  31. D3D12_RESOURCE_BINDING_TIER ResourceBindingTier() const noexcept;
  32. BOOL PSSpecifiedStencilRefSupported() const noexcept;
  33. BOOL TypedUAVLoadAdditionalFormats() const noexcept;
  34. BOOL ROVsSupported() const noexcept;
  35. D3D12_CONSERVATIVE_RASTERIZATION_TIER ConservativeRasterizationTier() const noexcept;
  36. BOOL StandardSwizzle64KBSupported() const noexcept;
  37. BOOL CrossAdapterRowMajorTextureSupported() const noexcept;
  38. BOOL VPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation() const noexcept;
  39. D3D12_RESOURCE_HEAP_TIER ResourceHeapTier() const noexcept;
  40. D3D12_CROSS_NODE_SHARING_TIER CrossNodeSharingTier() const noexcept;
  41. UINT MaxGPUVirtualAddressBitsPerResource() const noexcept;
  42. // FEATURE_LEVELS
  43. D3D_FEATURE_LEVEL MaxSupportedFeatureLevel() const noexcept;
  44. // FORMAT_SUPPORT
  45. HRESULT FormatSupport(DXGI_FORMAT Format, D3D12_FORMAT_SUPPORT1& Support1, D3D12_FORMAT_SUPPORT2& Support2) const;
  46. // MUTLTISAMPLE_QUALITY_LEVELS
  47. HRESULT MultisampleQualityLevels(DXGI_FORMAT Format, UINT SampleCount, D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS Flags, UINT& NumQualityLevels) const;
  48. // FORMAT_INFO
  49. HRESULT FormatInfo(DXGI_FORMAT Format, UINT8& PlaneCount) const;
  50. // GPU_VIRTUAL_ADDRESS_SUPPORT
  51. UINT MaxGPUVirtualAddressBitsPerProcess() const noexcept;
  52. // SHADER_MODEL
  53. D3D_SHADER_MODEL HighestShaderModel() const noexcept;
  54. // D3D12_OPTIONS1
  55. BOOL WaveOps() const noexcept;
  56. UINT WaveLaneCountMin() const noexcept;
  57. UINT WaveLaneCountMax() const noexcept;
  58. UINT TotalLaneCount() const noexcept;
  59. BOOL ExpandedComputeResourceStates() const noexcept;
  60. BOOL Int64ShaderOps() const noexcept;
  61. // PROTECTED_RESOURCE_SESSION_SUPPORT
  62. D3D12_PROTECTED_RESOURCE_SESSION_SUPPORT_FLAGS ProtectedResourceSessionSupport(UINT NodeIndex = 0) const;
  63. // ROOT_SIGNATURE
  64. D3D_ROOT_SIGNATURE_VERSION HighestRootSignatureVersion() const noexcept;
  65. // ARCHITECTURE1
  66. BOOL TileBasedRenderer(UINT NodeIndex = 0) const;
  67. BOOL UMA(UINT NodeIndex = 0) const;
  68. BOOL CacheCoherentUMA(UINT NodeIndex = 0) const;
  69. BOOL IsolatedMMU(UINT NodeIndex = 0) const;
  70. // D3D12_OPTIONS2
  71. BOOL DepthBoundsTestSupported() const noexcept;
  72. D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER ProgrammableSamplePositionsTier() const noexcept;
  73. // SHADER_CACHE
  74. D3D12_SHADER_CACHE_SUPPORT_FLAGS ShaderCacheSupportFlags() const noexcept;
  75. // COMMAND_QUEUE_PRIORITY
  76. BOOL CommandQueuePrioritySupported(D3D12_COMMAND_LIST_TYPE CommandListType, UINT Priority);
  77. // D3D12_OPTIONS3
  78. BOOL CopyQueueTimestampQueriesSupported() const noexcept;
  79. BOOL CastingFullyTypedFormatSupported() const noexcept;
  80. D3D12_COMMAND_LIST_SUPPORT_FLAGS WriteBufferImmediateSupportFlags() const noexcept;
  81. D3D12_VIEW_INSTANCING_TIER ViewInstancingTier() const noexcept;
  82. BOOL BarycentricsSupported() const noexcept;
  83. // EXISTING_HEAPS
  84. BOOL ExistingHeapsSupported() const noexcept;
  85. // D3D12_OPTIONS4
  86. BOOL MSAA64KBAlignedTextureSupported() const noexcept;
  87. D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER SharedResourceCompatibilityTier() const noexcept;
  88. BOOL Native16BitShaderOpsSupported() const noexcept;
  89. // SERIALIZATION
  90. D3D12_HEAP_SERIALIZATION_TIER HeapSerializationTier(UINT NodeIndex = 0) const;
  91. // CROSS_NODE
  92. // CrossNodeSharingTier handled in D3D12Options
  93. BOOL CrossNodeAtomicShaderInstructions() const noexcept;
  94. // D3D12_OPTIONS5
  95. BOOL SRVOnlyTiledResourceTier3() const noexcept;
  96. D3D12_RENDER_PASS_TIER RenderPassesTier() const noexcept;
  97. D3D12_RAYTRACING_TIER RaytracingTier() const noexcept;
  98. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4)
  99. // DISPLAYABLE
  100. BOOL DisplayableTexture() const noexcept;
  101. // SharedResourceCompatibilityTier handled in D3D12Options4
  102. #endif
  103. // D3D12_OPTIONS6
  104. BOOL AdditionalShadingRatesSupported() const noexcept;
  105. BOOL PerPrimitiveShadingRateSupportedWithViewportIndexing() const noexcept;
  106. D3D12_VARIABLE_SHADING_RATE_TIER VariableShadingRateTier() const noexcept;
  107. UINT ShadingRateImageTileSize() const noexcept;
  108. BOOL BackgroundProcessingSupported() const noexcept;
  109. // QUERY_META_COMMAND
  110. HRESULT QueryMetaCommand(D3D12_FEATURE_DATA_QUERY_META_COMMAND& dQueryMetaCommand) const;
  111. // D3D12_OPTIONS7
  112. D3D12_MESH_SHADER_TIER MeshShaderTier() const noexcept;
  113. D3D12_SAMPLER_FEEDBACK_TIER SamplerFeedbackTier() const noexcept;
  114. // PROTECTED_RESOURCE_SESSION_TYPE_COUNT
  115. UINT ProtectedResourceSessionTypeCount(UINT NodeIndex = 0) const;
  116. // PROTECTED_RESOURCE_SESSION_TYPES
  117. std::vector<GUID> ProtectedResourceSessionTypes(UINT NodeIndex = 0) const;
  118. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3)
  119. // D3D12_OPTIONS8
  120. BOOL UnalignedBlockTexturesSupported() const noexcept;
  121. // D3D12_OPTIONS9
  122. BOOL MeshShaderPipelineStatsSupported() const noexcept;
  123. BOOL MeshShaderSupportsFullRangeRenderTargetArrayIndex() const noexcept;
  124. BOOL AtomicInt64OnTypedResourceSupported() const noexcept;
  125. BOOL AtomicInt64OnGroupSharedSupported() const noexcept;
  126. BOOL DerivativesInMeshAndAmplificationShadersSupported() const noexcept;
  127. D3D12_WAVE_MMA_TIER WaveMMATier() const noexcept;
  128. #endif
  129. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4)
  130. // D3D12_OPTIONS10
  131. BOOL VariableRateShadingSumCombinerSupported() const noexcept;
  132. BOOL MeshShaderPerPrimitiveShadingRateSupported() const noexcept;
  133. // D3D12_OPTIONS11
  134. BOOL AtomicInt64OnDescriptorHeapResourceSupported() const noexcept;
  135. #endif
  136. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 600)
  137. // D3D12_OPTIONS12
  138. D3D12_TRI_STATE MSPrimitivesPipelineStatisticIncludesCulledPrimitives() const noexcept;
  139. BOOL EnhancedBarriersSupported() const noexcept;
  140. BOOL RelaxedFormatCastingSupported() const noexcept;
  141. #endif
  142. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 602)
  143. // D3D12_OPTIONS13
  144. BOOL UnrestrictedBufferTextureCopyPitchSupported() const noexcept;
  145. BOOL UnrestrictedVertexElementAlignmentSupported() const noexcept;
  146. BOOL InvertedViewportHeightFlipsYSupported() const noexcept;
  147. BOOL InvertedViewportDepthFlipsZSupported() const noexcept;
  148. BOOL TextureCopyBetweenDimensionsSupported() const noexcept;
  149. BOOL AlphaBlendFactorSupported() const noexcept;
  150. #endif
  151. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606)
  152. // D3D12_OPTIONS14
  153. BOOL AdvancedTextureOpsSupported() const noexcept;
  154. BOOL WriteableMSAATexturesSupported() const noexcept;
  155. BOOL IndependentFrontAndBackStencilRefMaskSupported() const noexcept;
  156. // D3D12_OPTIONS15
  157. BOOL TriangleFanSupported() const noexcept;
  158. BOOL DynamicIndexBufferStripCutSupported() const noexcept;
  159. #endif
  160. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608)
  161. // D3D12_OPTIONS16
  162. BOOL DynamicDepthBiasSupported() const noexcept;
  163. #endif
  164. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
  165. BOOL GPUUploadHeapSupported() const noexcept;
  166. // D3D12_OPTIONS17
  167. BOOL NonNormalizedCoordinateSamplersSupported() const noexcept;
  168. BOOL ManualWriteTrackingResourceSupported() const noexcept;
  169. // D3D12_OPTIONS18
  170. BOOL RenderPassesValid() const noexcept;
  171. #endif
  172. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610)
  173. BOOL MismatchingOutputDimensionsSupported() const noexcept;
  174. UINT SupportedSampleCountsWithNoOutputs() const noexcept;
  175. BOOL PointSamplingAddressesNeverRoundUp() const noexcept;
  176. BOOL RasterizerDesc2Supported() const noexcept;
  177. BOOL NarrowQuadrilateralLinesSupported() const noexcept;
  178. BOOL AnisoFilterWithPointMipSupported() const noexcept;
  179. UINT MaxSamplerDescriptorHeapSize() const noexcept;
  180. UINT MaxSamplerDescriptorHeapSizeWithStaticSamplers() const noexcept;
  181. UINT MaxViewDescriptorHeapSize() const noexcept;
  182. #endif
  183. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 611)
  184. BOOL ComputeOnlyWriteWatchSupported() const noexcept;
  185. #endif
  186. private: // Private structs and helpers declaration
  187. struct ProtectedResourceSessionTypesLocal : D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_TYPES
  188. {
  189. std::vector<GUID> TypeVec;
  190. };
  191. // Helper function to decide the highest shader model supported by the system
  192. // Stores the result in m_dShaderModel
  193. // Must be updated whenever a new shader model is added to the d3d12.h header
  194. HRESULT QueryHighestShaderModel();
  195. // Helper function to decide the highest root signature supported
  196. // Must be updated whenever a new root signature version is added to the d3d12.h header
  197. HRESULT QueryHighestRootSignatureVersion();
  198. // Helper funcion to decide the highest feature level
  199. HRESULT QueryHighestFeatureLevel();
  200. // Helper function to initialize local protected resource session types structs
  201. HRESULT QueryProtectedResourceSessionTypes(UINT NodeIndex, UINT Count);
  202. private: // Member data
  203. // Pointer to the underlying device
  204. ID3D12Device* m_pDevice;
  205. // Stores the error code from initialization
  206. HRESULT m_hStatus;
  207. // Feature support data structs
  208. D3D12_FEATURE_DATA_D3D12_OPTIONS m_dOptions;
  209. D3D_FEATURE_LEVEL m_eMaxFeatureLevel;
  210. D3D12_FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT m_dGPUVASupport;
  211. D3D12_FEATURE_DATA_SHADER_MODEL m_dShaderModel;
  212. D3D12_FEATURE_DATA_D3D12_OPTIONS1 m_dOptions1;
  213. std::vector<D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_SUPPORT> m_dProtectedResourceSessionSupport;
  214. D3D12_FEATURE_DATA_ROOT_SIGNATURE m_dRootSignature;
  215. std::vector<D3D12_FEATURE_DATA_ARCHITECTURE1> m_dArchitecture1;
  216. D3D12_FEATURE_DATA_D3D12_OPTIONS2 m_dOptions2;
  217. D3D12_FEATURE_DATA_SHADER_CACHE m_dShaderCache;
  218. D3D12_FEATURE_DATA_COMMAND_QUEUE_PRIORITY m_dCommandQueuePriority;
  219. D3D12_FEATURE_DATA_D3D12_OPTIONS3 m_dOptions3;
  220. D3D12_FEATURE_DATA_EXISTING_HEAPS m_dExistingHeaps;
  221. D3D12_FEATURE_DATA_D3D12_OPTIONS4 m_dOptions4;
  222. std::vector<D3D12_FEATURE_DATA_SERIALIZATION> m_dSerialization; // Cat2 NodeIndex
  223. D3D12_FEATURE_DATA_CROSS_NODE m_dCrossNode;
  224. D3D12_FEATURE_DATA_D3D12_OPTIONS5 m_dOptions5;
  225. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4)
  226. D3D12_FEATURE_DATA_DISPLAYABLE m_dDisplayable;
  227. #endif
  228. D3D12_FEATURE_DATA_D3D12_OPTIONS6 m_dOptions6;
  229. D3D12_FEATURE_DATA_D3D12_OPTIONS7 m_dOptions7;
  230. std::vector<D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_TYPE_COUNT> m_dProtectedResourceSessionTypeCount; // Cat2 NodeIndex
  231. std::vector<ProtectedResourceSessionTypesLocal> m_dProtectedResourceSessionTypes; // Cat3
  232. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3)
  233. D3D12_FEATURE_DATA_D3D12_OPTIONS8 m_dOptions8;
  234. D3D12_FEATURE_DATA_D3D12_OPTIONS9 m_dOptions9;
  235. #endif
  236. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4)
  237. D3D12_FEATURE_DATA_D3D12_OPTIONS10 m_dOptions10;
  238. D3D12_FEATURE_DATA_D3D12_OPTIONS11 m_dOptions11;
  239. #endif
  240. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 600)
  241. D3D12_FEATURE_DATA_D3D12_OPTIONS12 m_dOptions12;
  242. #endif
  243. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 602)
  244. D3D12_FEATURE_DATA_D3D12_OPTIONS13 m_dOptions13;
  245. #endif
  246. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606)
  247. D3D12_FEATURE_DATA_D3D12_OPTIONS14 m_dOptions14;
  248. D3D12_FEATURE_DATA_D3D12_OPTIONS15 m_dOptions15;
  249. #endif
  250. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608)
  251. D3D12_FEATURE_DATA_D3D12_OPTIONS16 m_dOptions16;
  252. #endif
  253. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
  254. D3D12_FEATURE_DATA_D3D12_OPTIONS17 m_dOptions17;
  255. #endif
  256. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
  257. D3D12_FEATURE_DATA_D3D12_OPTIONS18 m_dOptions18;
  258. #endif
  259. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610)
  260. D3D12_FEATURE_DATA_D3D12_OPTIONS19 m_dOptions19;
  261. #endif
  262. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 611)
  263. D3D12_FEATURE_DATA_D3D12_OPTIONS20 m_dOptions20;
  264. #endif
  265. };
  266. // Implementations for CD3DX12FeatureSupport functions
  267. // Macro to set up a getter function for each entry in feature support data
  268. // The getter function will have the same name as the feature option name
  269. #define FEATURE_SUPPORT_GET(RETTYPE,FEATURE,OPTION) \
  270. inline RETTYPE CD3DX12FeatureSupport::OPTION() const noexcept \
  271. { \
  272. return FEATURE.OPTION; \
  273. }
  274. // Macro to set up a getter function for each entry in feature support data
  275. // Also specifies the name for the function which can be different from the feature name
  276. #define FEATURE_SUPPORT_GET_NAME(RETTYPE,FEATURE,OPTION,NAME) \
  277. inline RETTYPE CD3DX12FeatureSupport::NAME() const noexcept \
  278. {\
  279. return FEATURE.OPTION; \
  280. }
  281. // Macro to set up a getter function for feature data indexed by the graphics node ID
  282. // The default parameter is 0, or the first availabe graphics device node
  283. #define FEATURE_SUPPORT_GET_NODE_INDEXED(RETTYPE,FEATURE,OPTION) \
  284. inline RETTYPE CD3DX12FeatureSupport::OPTION(UINT NodeIndex) const \
  285. {\
  286. return FEATURE[NodeIndex].OPTION; \
  287. }
  288. // Macro to set up a getter function for feature data indexed by NodeIndex
  289. // Allows a custom name for the getter function
  290. #define FEATURE_SUPPORT_GET_NODE_INDEXED_NAME(RETTYPE,FEATURE,OPTION,NAME) \
  291. inline RETTYPE CD3DX12FeatureSupport::NAME(UINT NodeIndex) const \
  292. {\
  293. return FEATURE[NodeIndex].OPTION; \
  294. }
  295. inline CD3DX12FeatureSupport::CD3DX12FeatureSupport() noexcept
  296. : m_pDevice(nullptr)
  297. , m_hStatus(E_INVALIDARG)
  298. , m_dOptions{}
  299. , m_eMaxFeatureLevel{}
  300. , m_dGPUVASupport{}
  301. , m_dShaderModel{}
  302. , m_dOptions1{}
  303. , m_dRootSignature{}
  304. , m_dOptions2{}
  305. , m_dShaderCache{}
  306. , m_dCommandQueuePriority{}
  307. , m_dOptions3{}
  308. , m_dExistingHeaps{}
  309. , m_dOptions4{}
  310. , m_dCrossNode{}
  311. , m_dOptions5{}
  312. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4)
  313. , m_dDisplayable{}
  314. #endif
  315. , m_dOptions6{}
  316. , m_dOptions7{}
  317. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3)
  318. , m_dOptions8{}
  319. , m_dOptions9{}
  320. #endif
  321. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4)
  322. , m_dOptions10{}
  323. , m_dOptions11{}
  324. #endif
  325. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 600)
  326. , m_dOptions12{}
  327. #endif
  328. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 602)
  329. , m_dOptions13{}
  330. #endif
  331. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606)
  332. , m_dOptions14{}
  333. , m_dOptions15{}
  334. #endif
  335. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608)
  336. , m_dOptions16{}
  337. #endif
  338. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
  339. , m_dOptions17{}
  340. #endif
  341. #if defined (D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
  342. , m_dOptions18{}
  343. #endif
  344. #if defined (D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610)
  345. , m_dOptions19{}
  346. #endif
  347. #if defined (D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 611)
  348. , m_dOptions20{}
  349. #endif
  350. {}
  351. inline HRESULT CD3DX12FeatureSupport::Init(ID3D12Device* pDevice)
  352. {
  353. if (!pDevice)
  354. {
  355. m_hStatus = E_INVALIDARG;
  356. return m_hStatus;
  357. }
  358. m_pDevice = pDevice;
  359. // Initialize static feature support data structures
  360. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &m_dOptions, sizeof(m_dOptions))))
  361. {
  362. m_dOptions = {};
  363. }
  364. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT, &m_dGPUVASupport, sizeof(m_dGPUVASupport))))
  365. {
  366. m_dGPUVASupport = {};
  367. }
  368. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS1, &m_dOptions1, sizeof(m_dOptions1))))
  369. {
  370. m_dOptions1 = {};
  371. }
  372. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS2, &m_dOptions2, sizeof(m_dOptions2))))
  373. {
  374. m_dOptions2 = {};
  375. }
  376. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_SHADER_CACHE, &m_dShaderCache, sizeof(m_dShaderCache))))
  377. {
  378. m_dShaderCache = {};
  379. }
  380. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS3, &m_dOptions3, sizeof(m_dOptions3))))
  381. {
  382. m_dOptions3 = {};
  383. }
  384. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_EXISTING_HEAPS, &m_dExistingHeaps, sizeof(m_dExistingHeaps))))
  385. {
  386. m_dExistingHeaps = {};
  387. }
  388. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS4, &m_dOptions4, sizeof(m_dOptions4))))
  389. {
  390. m_dOptions4 = {};
  391. }
  392. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_CROSS_NODE, &m_dCrossNode, sizeof(m_dCrossNode))))
  393. {
  394. m_dCrossNode = {};
  395. }
  396. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS5, &m_dOptions5, sizeof(m_dOptions5))))
  397. {
  398. m_dOptions5 = {};
  399. }
  400. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4)
  401. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_DISPLAYABLE, &m_dDisplayable, sizeof(m_dDisplayable))))
  402. {
  403. m_dDisplayable = {};
  404. }
  405. #endif
  406. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS6, &m_dOptions6, sizeof(m_dOptions6))))
  407. {
  408. m_dOptions6 = {};
  409. }
  410. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS7, &m_dOptions7, sizeof(m_dOptions7))))
  411. {
  412. m_dOptions7 = {};
  413. }
  414. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3)
  415. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS8, &m_dOptions8, sizeof(m_dOptions8))))
  416. {
  417. m_dOptions8 = {};
  418. }
  419. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS9, &m_dOptions9, sizeof(m_dOptions9))))
  420. {
  421. m_dOptions9 = {};
  422. }
  423. #endif
  424. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4)
  425. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS10, &m_dOptions10, sizeof(m_dOptions10))))
  426. {
  427. m_dOptions10 = {};
  428. }
  429. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS11, &m_dOptions11, sizeof(m_dOptions11))))
  430. {
  431. m_dOptions11 = {};
  432. }
  433. #endif
  434. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 600)
  435. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS12, &m_dOptions12, sizeof(m_dOptions12))))
  436. {
  437. m_dOptions12 = {};
  438. m_dOptions12.MSPrimitivesPipelineStatisticIncludesCulledPrimitives = D3D12_TRI_STATE::D3D12_TRI_STATE_UNKNOWN;
  439. }
  440. #endif
  441. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 602)
  442. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS13, &m_dOptions13, sizeof(m_dOptions13))))
  443. {
  444. m_dOptions13 = {};
  445. }
  446. #endif
  447. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606)
  448. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS14, &m_dOptions14, sizeof(m_dOptions14))))
  449. {
  450. m_dOptions14 = {};
  451. }
  452. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS15, &m_dOptions15, sizeof(m_dOptions15))))
  453. {
  454. m_dOptions15 = {};
  455. }
  456. #endif
  457. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608)
  458. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS16, &m_dOptions16, sizeof(m_dOptions16))))
  459. {
  460. m_dOptions16 = {};
  461. }
  462. #endif
  463. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
  464. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS17, &m_dOptions17, sizeof(m_dOptions17))))
  465. {
  466. m_dOptions17 = {};
  467. }
  468. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS18, &m_dOptions18, sizeof(m_dOptions18))))
  469. {
  470. m_dOptions18.RenderPassesValid = false;
  471. }
  472. #endif
  473. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610)
  474. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS19, &m_dOptions19, sizeof(m_dOptions19))))
  475. {
  476. m_dOptions19 = {};
  477. m_dOptions19.SupportedSampleCountsWithNoOutputs = 1;
  478. m_dOptions19.MaxSamplerDescriptorHeapSize = D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE;
  479. m_dOptions19.MaxSamplerDescriptorHeapSizeWithStaticSamplers = D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE;
  480. m_dOptions19.MaxViewDescriptorHeapSize = D3D12_MAX_SHADER_VISIBLE_DESCRIPTOR_HEAP_SIZE_TIER_1;
  481. }
  482. #endif
  483. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 611)
  484. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS20, &m_dOptions20, sizeof(m_dOptions20))))
  485. {
  486. m_dOptions20 = {};
  487. }
  488. #endif
  489. // Initialize per-node feature support data structures
  490. const UINT uNodeCount = m_pDevice->GetNodeCount();
  491. m_dProtectedResourceSessionSupport.resize(uNodeCount);
  492. m_dArchitecture1.resize(uNodeCount);
  493. m_dSerialization.resize(uNodeCount);
  494. m_dProtectedResourceSessionTypeCount.resize(uNodeCount);
  495. m_dProtectedResourceSessionTypes.resize(uNodeCount);
  496. for (UINT NodeIndex = 0; NodeIndex < uNodeCount; NodeIndex++)
  497. {
  498. m_dProtectedResourceSessionSupport[NodeIndex].NodeIndex = NodeIndex;
  499. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_PROTECTED_RESOURCE_SESSION_SUPPORT, &m_dProtectedResourceSessionSupport[NodeIndex], sizeof(m_dProtectedResourceSessionSupport[NodeIndex]))))
  500. {
  501. m_dProtectedResourceSessionSupport[NodeIndex].Support = D3D12_PROTECTED_RESOURCE_SESSION_SUPPORT_FLAG_NONE;
  502. }
  503. m_dArchitecture1[NodeIndex].NodeIndex = NodeIndex;
  504. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE1, &m_dArchitecture1[NodeIndex], sizeof(m_dArchitecture1[NodeIndex]))))
  505. {
  506. D3D12_FEATURE_DATA_ARCHITECTURE dArchLocal = {};
  507. dArchLocal.NodeIndex = NodeIndex;
  508. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE, &dArchLocal, sizeof(dArchLocal))))
  509. {
  510. dArchLocal.TileBasedRenderer = false;
  511. dArchLocal.UMA = false;
  512. dArchLocal.CacheCoherentUMA = false;
  513. }
  514. m_dArchitecture1[NodeIndex].TileBasedRenderer = dArchLocal.TileBasedRenderer;
  515. m_dArchitecture1[NodeIndex].UMA = dArchLocal.UMA;
  516. m_dArchitecture1[NodeIndex].CacheCoherentUMA = dArchLocal.CacheCoherentUMA;
  517. m_dArchitecture1[NodeIndex].IsolatedMMU = false;
  518. }
  519. m_dSerialization[NodeIndex].NodeIndex = NodeIndex;
  520. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_SERIALIZATION, &m_dSerialization[NodeIndex], sizeof(m_dSerialization[NodeIndex]))))
  521. {
  522. m_dSerialization[NodeIndex].HeapSerializationTier = D3D12_HEAP_SERIALIZATION_TIER_0;
  523. }
  524. m_dProtectedResourceSessionTypeCount[NodeIndex].NodeIndex = NodeIndex;
  525. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_PROTECTED_RESOURCE_SESSION_TYPE_COUNT, &m_dProtectedResourceSessionTypeCount[NodeIndex], sizeof(m_dProtectedResourceSessionTypeCount[NodeIndex]))))
  526. {
  527. m_dProtectedResourceSessionTypeCount[NodeIndex].Count = 0;
  528. }
  529. // Special procedure to initialize local protected resource session types structs
  530. // Must wait until session type count initialized
  531. QueryProtectedResourceSessionTypes(NodeIndex, m_dProtectedResourceSessionTypeCount[NodeIndex].Count);
  532. }
  533. // Initialize features that requires highest version check
  534. if (FAILED(m_hStatus = QueryHighestShaderModel()))
  535. {
  536. return m_hStatus;
  537. }
  538. if (FAILED(m_hStatus = QueryHighestRootSignatureVersion()))
  539. {
  540. return m_hStatus;
  541. }
  542. // Initialize Feature Levels data
  543. if (FAILED(m_hStatus = QueryHighestFeatureLevel()))
  544. {
  545. return m_hStatus;
  546. }
  547. return m_hStatus;
  548. }
  549. // 0: D3D12_OPTIONS
  550. FEATURE_SUPPORT_GET(BOOL, m_dOptions, DoublePrecisionFloatShaderOps);
  551. FEATURE_SUPPORT_GET(BOOL, m_dOptions, OutputMergerLogicOp);
  552. FEATURE_SUPPORT_GET(D3D12_SHADER_MIN_PRECISION_SUPPORT, m_dOptions, MinPrecisionSupport);
  553. FEATURE_SUPPORT_GET(D3D12_TILED_RESOURCES_TIER, m_dOptions, TiledResourcesTier);
  554. FEATURE_SUPPORT_GET(D3D12_RESOURCE_BINDING_TIER, m_dOptions, ResourceBindingTier);
  555. FEATURE_SUPPORT_GET(BOOL, m_dOptions, PSSpecifiedStencilRefSupported);
  556. FEATURE_SUPPORT_GET(BOOL, m_dOptions, TypedUAVLoadAdditionalFormats);
  557. FEATURE_SUPPORT_GET(BOOL, m_dOptions, ROVsSupported);
  558. FEATURE_SUPPORT_GET(D3D12_CONSERVATIVE_RASTERIZATION_TIER, m_dOptions, ConservativeRasterizationTier);
  559. FEATURE_SUPPORT_GET(BOOL, m_dOptions, StandardSwizzle64KBSupported);
  560. FEATURE_SUPPORT_GET(BOOL, m_dOptions, CrossAdapterRowMajorTextureSupported);
  561. FEATURE_SUPPORT_GET(BOOL, m_dOptions, VPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation);
  562. FEATURE_SUPPORT_GET(D3D12_RESOURCE_HEAP_TIER, m_dOptions, ResourceHeapTier);
  563. // Special procedure for handling caps that is also part of other features
  564. inline D3D12_CROSS_NODE_SHARING_TIER CD3DX12FeatureSupport::CrossNodeSharingTier() const noexcept
  565. {
  566. if (m_dCrossNode.SharingTier > D3D12_CROSS_NODE_SHARING_TIER_NOT_SUPPORTED)
  567. {
  568. return m_dCrossNode.SharingTier;
  569. }
  570. else
  571. {
  572. return m_dOptions.CrossNodeSharingTier;
  573. }
  574. }
  575. inline UINT CD3DX12FeatureSupport::MaxGPUVirtualAddressBitsPerResource() const noexcept
  576. {
  577. if (m_dOptions.MaxGPUVirtualAddressBitsPerResource > 0)
  578. {
  579. return m_dOptions.MaxGPUVirtualAddressBitsPerResource;
  580. }
  581. else
  582. {
  583. return m_dGPUVASupport.MaxGPUVirtualAddressBitsPerResource;
  584. }
  585. }
  586. // 1: Architecture
  587. // Combined with Architecture1
  588. // 2: Feature Levels
  589. // Simply returns the highest supported feature level
  590. inline D3D_FEATURE_LEVEL CD3DX12FeatureSupport::MaxSupportedFeatureLevel() const noexcept
  591. {
  592. return m_eMaxFeatureLevel;
  593. }
  594. // 3: Feature Format Support
  595. inline HRESULT CD3DX12FeatureSupport::FormatSupport(DXGI_FORMAT Format, D3D12_FORMAT_SUPPORT1& Support1, D3D12_FORMAT_SUPPORT2& Support2) const
  596. {
  597. D3D12_FEATURE_DATA_FORMAT_SUPPORT dFormatSupport;
  598. dFormatSupport.Format = Format;
  599. // It is possible that the function call returns an error
  600. HRESULT result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &dFormatSupport, sizeof(D3D12_FEATURE_DATA_FORMAT_SUPPORT));
  601. Support1 = dFormatSupport.Support1;
  602. Support2 = dFormatSupport.Support2; // Two outputs. Probably better just to take in the struct as an argument?
  603. return result;
  604. }
  605. // 4: Multisample Quality Levels
  606. inline HRESULT CD3DX12FeatureSupport::MultisampleQualityLevels(DXGI_FORMAT Format, UINT SampleCount, D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS Flags, UINT& NumQualityLevels) const
  607. {
  608. D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS dMultisampleQualityLevels;
  609. dMultisampleQualityLevels.Format = Format;
  610. dMultisampleQualityLevels.SampleCount = SampleCount;
  611. dMultisampleQualityLevels.Flags = Flags;
  612. HRESULT result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS, &dMultisampleQualityLevels, sizeof(D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS));
  613. if (SUCCEEDED(result))
  614. {
  615. NumQualityLevels = dMultisampleQualityLevels.NumQualityLevels;
  616. }
  617. else
  618. {
  619. NumQualityLevels = 0;
  620. }
  621. return result;
  622. }
  623. // 5: Format Info
  624. inline HRESULT CD3DX12FeatureSupport::FormatInfo(DXGI_FORMAT Format, UINT8& PlaneCount) const
  625. {
  626. D3D12_FEATURE_DATA_FORMAT_INFO dFormatInfo;
  627. dFormatInfo.Format = Format;
  628. HRESULT result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_FORMAT_INFO, &dFormatInfo, sizeof(D3D12_FEATURE_DATA_FORMAT_INFO));
  629. if (FAILED(result))
  630. {
  631. PlaneCount = 0;
  632. }
  633. else
  634. {
  635. PlaneCount = dFormatInfo.PlaneCount;
  636. }
  637. return result;
  638. }
  639. // 6: GPU Virtual Address Support
  640. // MaxGPUVirtualAddressBitsPerResource handled in D3D12Options
  641. FEATURE_SUPPORT_GET(UINT, m_dGPUVASupport, MaxGPUVirtualAddressBitsPerProcess);
  642. // 7: Shader Model
  643. inline D3D_SHADER_MODEL CD3DX12FeatureSupport::HighestShaderModel() const noexcept
  644. {
  645. return m_dShaderModel.HighestShaderModel;
  646. }
  647. // 8: D3D12 Options1
  648. FEATURE_SUPPORT_GET(BOOL, m_dOptions1, WaveOps);
  649. FEATURE_SUPPORT_GET(UINT, m_dOptions1, WaveLaneCountMin);
  650. FEATURE_SUPPORT_GET(UINT, m_dOptions1, WaveLaneCountMax);
  651. FEATURE_SUPPORT_GET(UINT, m_dOptions1, TotalLaneCount);
  652. FEATURE_SUPPORT_GET(BOOL, m_dOptions1, ExpandedComputeResourceStates);
  653. FEATURE_SUPPORT_GET(BOOL, m_dOptions1, Int64ShaderOps);
  654. // 10: Protected Resource Session Support
  655. inline D3D12_PROTECTED_RESOURCE_SESSION_SUPPORT_FLAGS CD3DX12FeatureSupport::ProtectedResourceSessionSupport(UINT NodeIndex) const
  656. {
  657. return m_dProtectedResourceSessionSupport[NodeIndex].Support;
  658. }
  659. // 12: Root Signature
  660. inline D3D_ROOT_SIGNATURE_VERSION CD3DX12FeatureSupport::HighestRootSignatureVersion() const noexcept
  661. {
  662. return m_dRootSignature.HighestVersion;
  663. }
  664. // 16: Architecture1
  665. // Same data fields can be queried from m_dArchitecture
  666. FEATURE_SUPPORT_GET_NODE_INDEXED(BOOL, m_dArchitecture1, TileBasedRenderer);
  667. FEATURE_SUPPORT_GET_NODE_INDEXED(BOOL, m_dArchitecture1, UMA);
  668. FEATURE_SUPPORT_GET_NODE_INDEXED(BOOL, m_dArchitecture1, CacheCoherentUMA);
  669. FEATURE_SUPPORT_GET_NODE_INDEXED(BOOL, m_dArchitecture1, IsolatedMMU);
  670. // 18: D3D12 Options2
  671. FEATURE_SUPPORT_GET(BOOL, m_dOptions2, DepthBoundsTestSupported);
  672. FEATURE_SUPPORT_GET(D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER, m_dOptions2, ProgrammableSamplePositionsTier);
  673. // 19: Shader Cache
  674. FEATURE_SUPPORT_GET_NAME(D3D12_SHADER_CACHE_SUPPORT_FLAGS, m_dShaderCache, SupportFlags, ShaderCacheSupportFlags);
  675. // 20: Command Queue Priority
  676. inline BOOL CD3DX12FeatureSupport::CommandQueuePrioritySupported(D3D12_COMMAND_LIST_TYPE CommandListType, UINT Priority)
  677. {
  678. m_dCommandQueuePriority.CommandListType = CommandListType;
  679. m_dCommandQueuePriority.Priority = Priority;
  680. if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_COMMAND_QUEUE_PRIORITY, &m_dCommandQueuePriority, sizeof(D3D12_FEATURE_DATA_COMMAND_QUEUE_PRIORITY))))
  681. {
  682. return false;
  683. }
  684. return m_dCommandQueuePriority.PriorityForTypeIsSupported;
  685. }
  686. // 21: D3D12 Options3
  687. FEATURE_SUPPORT_GET(BOOL, m_dOptions3, CopyQueueTimestampQueriesSupported);
  688. FEATURE_SUPPORT_GET(BOOL, m_dOptions3, CastingFullyTypedFormatSupported);
  689. FEATURE_SUPPORT_GET(D3D12_COMMAND_LIST_SUPPORT_FLAGS, m_dOptions3, WriteBufferImmediateSupportFlags);
  690. FEATURE_SUPPORT_GET(D3D12_VIEW_INSTANCING_TIER, m_dOptions3, ViewInstancingTier);
  691. FEATURE_SUPPORT_GET(BOOL, m_dOptions3, BarycentricsSupported);
  692. // 22: Existing Heaps
  693. FEATURE_SUPPORT_GET_NAME(BOOL, m_dExistingHeaps, Supported, ExistingHeapsSupported);
  694. // 23: D3D12 Options4
  695. FEATURE_SUPPORT_GET(BOOL, m_dOptions4, MSAA64KBAlignedTextureSupported);
  696. FEATURE_SUPPORT_GET(D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER, m_dOptions4, SharedResourceCompatibilityTier);
  697. FEATURE_SUPPORT_GET(BOOL, m_dOptions4, Native16BitShaderOpsSupported);
  698. // 24: Serialization
  699. FEATURE_SUPPORT_GET_NODE_INDEXED(D3D12_HEAP_SERIALIZATION_TIER, m_dSerialization, HeapSerializationTier);
  700. // 25: Cross Node
  701. // CrossNodeSharingTier handled in D3D12Options
  702. FEATURE_SUPPORT_GET_NAME(BOOL, m_dCrossNode, AtomicShaderInstructions, CrossNodeAtomicShaderInstructions);
  703. // 27: D3D12 Options5
  704. FEATURE_SUPPORT_GET(BOOL, m_dOptions5, SRVOnlyTiledResourceTier3);
  705. FEATURE_SUPPORT_GET(D3D12_RENDER_PASS_TIER, m_dOptions5, RenderPassesTier);
  706. FEATURE_SUPPORT_GET(D3D12_RAYTRACING_TIER, m_dOptions5, RaytracingTier);
  707. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4)
  708. // 28: Displayable
  709. FEATURE_SUPPORT_GET(BOOL, m_dDisplayable, DisplayableTexture);
  710. // SharedResourceCompatibilityTier handled in D3D12Options4
  711. #endif
  712. // 30: D3D12 Options6
  713. FEATURE_SUPPORT_GET(BOOL, m_dOptions6, AdditionalShadingRatesSupported);
  714. FEATURE_SUPPORT_GET(BOOL, m_dOptions6, PerPrimitiveShadingRateSupportedWithViewportIndexing);
  715. FEATURE_SUPPORT_GET(D3D12_VARIABLE_SHADING_RATE_TIER, m_dOptions6, VariableShadingRateTier);
  716. FEATURE_SUPPORT_GET(UINT, m_dOptions6, ShadingRateImageTileSize);
  717. FEATURE_SUPPORT_GET(BOOL, m_dOptions6, BackgroundProcessingSupported);
  718. // 31: Query Meta Command
  719. // Keep the original call routine
  720. inline HRESULT CD3DX12FeatureSupport::QueryMetaCommand(D3D12_FEATURE_DATA_QUERY_META_COMMAND& dQueryMetaCommand) const
  721. {
  722. return m_pDevice->CheckFeatureSupport(D3D12_FEATURE_QUERY_META_COMMAND, &dQueryMetaCommand, sizeof(D3D12_FEATURE_DATA_QUERY_META_COMMAND));
  723. }
  724. // 32: D3D12 Options7
  725. FEATURE_SUPPORT_GET(D3D12_MESH_SHADER_TIER, m_dOptions7, MeshShaderTier);
  726. FEATURE_SUPPORT_GET(D3D12_SAMPLER_FEEDBACK_TIER, m_dOptions7, SamplerFeedbackTier);
  727. // 33: Protected Resource Session Type Count
  728. FEATURE_SUPPORT_GET_NODE_INDEXED_NAME(UINT, m_dProtectedResourceSessionTypeCount, Count, ProtectedResourceSessionTypeCount);
  729. // 34: Protected Resource Session Types
  730. FEATURE_SUPPORT_GET_NODE_INDEXED_NAME(std::vector<GUID>, m_dProtectedResourceSessionTypes, TypeVec, ProtectedResourceSessionTypes);
  731. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3)
  732. // 36: Options8
  733. FEATURE_SUPPORT_GET(BOOL, m_dOptions8, UnalignedBlockTexturesSupported);
  734. // 37: Options9
  735. FEATURE_SUPPORT_GET(BOOL, m_dOptions9, MeshShaderPipelineStatsSupported);
  736. FEATURE_SUPPORT_GET(BOOL, m_dOptions9, MeshShaderSupportsFullRangeRenderTargetArrayIndex);
  737. FEATURE_SUPPORT_GET(BOOL, m_dOptions9, AtomicInt64OnTypedResourceSupported);
  738. FEATURE_SUPPORT_GET(BOOL, m_dOptions9, AtomicInt64OnGroupSharedSupported);
  739. FEATURE_SUPPORT_GET(BOOL, m_dOptions9, DerivativesInMeshAndAmplificationShadersSupported);
  740. FEATURE_SUPPORT_GET(D3D12_WAVE_MMA_TIER, m_dOptions9, WaveMMATier);
  741. #endif
  742. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4)
  743. // 39: Options10
  744. FEATURE_SUPPORT_GET(BOOL, m_dOptions10, VariableRateShadingSumCombinerSupported);
  745. FEATURE_SUPPORT_GET(BOOL, m_dOptions10, MeshShaderPerPrimitiveShadingRateSupported);
  746. // 40: Options11
  747. FEATURE_SUPPORT_GET(BOOL, m_dOptions11, AtomicInt64OnDescriptorHeapResourceSupported);
  748. #endif
  749. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 600)
  750. // 41: Options12
  751. FEATURE_SUPPORT_GET(D3D12_TRI_STATE, m_dOptions12, MSPrimitivesPipelineStatisticIncludesCulledPrimitives);
  752. FEATURE_SUPPORT_GET(BOOL, m_dOptions12, EnhancedBarriersSupported);
  753. FEATURE_SUPPORT_GET(BOOL, m_dOptions12, RelaxedFormatCastingSupported);
  754. #endif
  755. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 602)
  756. // 42: Options13
  757. FEATURE_SUPPORT_GET(BOOL, m_dOptions13, UnrestrictedBufferTextureCopyPitchSupported);
  758. FEATURE_SUPPORT_GET(BOOL, m_dOptions13, UnrestrictedVertexElementAlignmentSupported);
  759. FEATURE_SUPPORT_GET(BOOL, m_dOptions13, InvertedViewportHeightFlipsYSupported);
  760. FEATURE_SUPPORT_GET(BOOL, m_dOptions13, InvertedViewportDepthFlipsZSupported);
  761. FEATURE_SUPPORT_GET(BOOL, m_dOptions13, TextureCopyBetweenDimensionsSupported);
  762. FEATURE_SUPPORT_GET(BOOL, m_dOptions13, AlphaBlendFactorSupported);
  763. #endif
  764. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606)
  765. // 43: Options14
  766. FEATURE_SUPPORT_GET(BOOL, m_dOptions14, AdvancedTextureOpsSupported);
  767. FEATURE_SUPPORT_GET(BOOL, m_dOptions14, WriteableMSAATexturesSupported);
  768. FEATURE_SUPPORT_GET(BOOL, m_dOptions14, IndependentFrontAndBackStencilRefMaskSupported);
  769. // 44: Options15
  770. FEATURE_SUPPORT_GET(BOOL, m_dOptions15, TriangleFanSupported);
  771. FEATURE_SUPPORT_GET(BOOL, m_dOptions15, DynamicIndexBufferStripCutSupported);
  772. #endif
  773. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608)
  774. // 45: Options16
  775. FEATURE_SUPPORT_GET(BOOL, m_dOptions16, DynamicDepthBiasSupported);
  776. #endif
  777. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
  778. FEATURE_SUPPORT_GET(BOOL, m_dOptions16, GPUUploadHeapSupported);
  779. // 46: Options17
  780. FEATURE_SUPPORT_GET(BOOL, m_dOptions17, NonNormalizedCoordinateSamplersSupported);
  781. FEATURE_SUPPORT_GET(BOOL, m_dOptions17, ManualWriteTrackingResourceSupported);
  782. // 47: Option18
  783. FEATURE_SUPPORT_GET(BOOL, m_dOptions18, RenderPassesValid);
  784. #endif
  785. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610)
  786. FEATURE_SUPPORT_GET(BOOL, m_dOptions19, MismatchingOutputDimensionsSupported);
  787. FEATURE_SUPPORT_GET(UINT, m_dOptions19, SupportedSampleCountsWithNoOutputs);
  788. FEATURE_SUPPORT_GET(BOOL, m_dOptions19, PointSamplingAddressesNeverRoundUp);
  789. FEATURE_SUPPORT_GET(BOOL, m_dOptions19, RasterizerDesc2Supported);
  790. FEATURE_SUPPORT_GET(BOOL, m_dOptions19, NarrowQuadrilateralLinesSupported);
  791. FEATURE_SUPPORT_GET(BOOL, m_dOptions19, AnisoFilterWithPointMipSupported);
  792. FEATURE_SUPPORT_GET(UINT, m_dOptions19, MaxSamplerDescriptorHeapSize);
  793. FEATURE_SUPPORT_GET(UINT, m_dOptions19, MaxSamplerDescriptorHeapSizeWithStaticSamplers);
  794. FEATURE_SUPPORT_GET(UINT, m_dOptions19, MaxViewDescriptorHeapSize);
  795. #endif
  796. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 611)
  797. // 49: Options20
  798. FEATURE_SUPPORT_GET(BOOL, m_dOptions20, ComputeOnlyWriteWatchSupported);
  799. #endif
  800. // Helper function to decide the highest shader model supported by the system
  801. // Stores the result in m_dShaderModel
  802. // Must be updated whenever a new shader model is added to the d3d12.h header
  803. inline HRESULT CD3DX12FeatureSupport::QueryHighestShaderModel()
  804. {
  805. // Check support in descending order
  806. HRESULT result;
  807. const D3D_SHADER_MODEL allModelVersions[] =
  808. {
  809. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606)
  810. D3D_SHADER_MODEL_6_8,
  811. #endif
  812. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3)
  813. D3D_SHADER_MODEL_6_7,
  814. #endif
  815. D3D_SHADER_MODEL_6_6,
  816. D3D_SHADER_MODEL_6_5,
  817. D3D_SHADER_MODEL_6_4,
  818. D3D_SHADER_MODEL_6_3,
  819. D3D_SHADER_MODEL_6_2,
  820. D3D_SHADER_MODEL_6_1,
  821. D3D_SHADER_MODEL_6_0,
  822. D3D_SHADER_MODEL_5_1
  823. };
  824. constexpr size_t numModelVersions = sizeof(allModelVersions) / sizeof(D3D_SHADER_MODEL);
  825. for (size_t i = 0; i < numModelVersions; i++)
  826. {
  827. m_dShaderModel.HighestShaderModel = allModelVersions[i];
  828. result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &m_dShaderModel, sizeof(D3D12_FEATURE_DATA_SHADER_MODEL));
  829. if (result != E_INVALIDARG)
  830. {
  831. // Indicates that the version is recognizable by the runtime and stored in the struct
  832. // Also terminate on unexpected error code
  833. if (FAILED(result))
  834. {
  835. m_dShaderModel.HighestShaderModel = static_cast<D3D_SHADER_MODEL>(0);
  836. }
  837. return result;
  838. }
  839. }
  840. // Shader model may not be supported. Continue the rest initializations
  841. m_dShaderModel.HighestShaderModel = static_cast<D3D_SHADER_MODEL>(0);
  842. return S_OK;
  843. }
  844. // Helper function to decide the highest root signature supported
  845. // Must be updated whenever a new root signature version is added to the d3d12.h header
  846. inline HRESULT CD3DX12FeatureSupport::QueryHighestRootSignatureVersion()
  847. {
  848. HRESULT result;
  849. const D3D_ROOT_SIGNATURE_VERSION allRootSignatureVersions[] =
  850. {
  851. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
  852. D3D_ROOT_SIGNATURE_VERSION_1_2,
  853. #endif
  854. D3D_ROOT_SIGNATURE_VERSION_1_1,
  855. D3D_ROOT_SIGNATURE_VERSION_1_0,
  856. D3D_ROOT_SIGNATURE_VERSION_1,
  857. };
  858. constexpr size_t numRootSignatureVersions = sizeof(allRootSignatureVersions) / sizeof(D3D_ROOT_SIGNATURE_VERSION);
  859. for (size_t i = 0; i < numRootSignatureVersions; i++)
  860. {
  861. m_dRootSignature.HighestVersion = allRootSignatureVersions[i];
  862. result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_ROOT_SIGNATURE, &m_dRootSignature, sizeof(D3D12_FEATURE_DATA_ROOT_SIGNATURE));
  863. if (result != E_INVALIDARG)
  864. {
  865. if (FAILED(result))
  866. {
  867. m_dRootSignature.HighestVersion = static_cast<D3D_ROOT_SIGNATURE_VERSION>(0);
  868. }
  869. // If succeeded, the highest version is already written into the member struct
  870. return result;
  871. }
  872. }
  873. // No version left. Set to invalid value and continue.
  874. m_dRootSignature.HighestVersion = static_cast<D3D_ROOT_SIGNATURE_VERSION>(0);
  875. return S_OK;
  876. }
  877. // Helper funcion to decide the highest feature level
  878. inline HRESULT CD3DX12FeatureSupport::QueryHighestFeatureLevel()
  879. {
  880. HRESULT result;
  881. // Check against a list of all feature levels present in d3dcommon.h
  882. // Needs to be updated for future feature levels
  883. const D3D_FEATURE_LEVEL allLevels[] =
  884. {
  885. #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3)
  886. D3D_FEATURE_LEVEL_12_2,
  887. #endif
  888. D3D_FEATURE_LEVEL_12_1,
  889. D3D_FEATURE_LEVEL_12_0,
  890. D3D_FEATURE_LEVEL_11_1,
  891. D3D_FEATURE_LEVEL_11_0,
  892. D3D_FEATURE_LEVEL_10_1,
  893. D3D_FEATURE_LEVEL_10_0,
  894. D3D_FEATURE_LEVEL_9_3,
  895. D3D_FEATURE_LEVEL_9_2,
  896. D3D_FEATURE_LEVEL_9_1,
  897. D3D_FEATURE_LEVEL_1_0_CORE,
  898. D3D_FEATURE_LEVEL_1_0_GENERIC
  899. };
  900. D3D12_FEATURE_DATA_FEATURE_LEVELS dFeatureLevel;
  901. dFeatureLevel.NumFeatureLevels = static_cast<UINT>(sizeof(allLevels) / sizeof(D3D_FEATURE_LEVEL));
  902. dFeatureLevel.pFeatureLevelsRequested = allLevels;
  903. result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_FEATURE_LEVELS, &dFeatureLevel, sizeof(D3D12_FEATURE_DATA_FEATURE_LEVELS));
  904. if (SUCCEEDED(result))
  905. {
  906. m_eMaxFeatureLevel = dFeatureLevel.MaxSupportedFeatureLevel;
  907. }
  908. else
  909. {
  910. m_eMaxFeatureLevel = static_cast<D3D_FEATURE_LEVEL>(0);
  911. if (result == DXGI_ERROR_UNSUPPORTED)
  912. {
  913. // Indicates that none supported. Continue initialization
  914. result = S_OK;
  915. }
  916. }
  917. return result;
  918. }
  919. // Helper function to initialize local protected resource session types structs
  920. inline HRESULT CD3DX12FeatureSupport::QueryProtectedResourceSessionTypes(UINT NodeIndex, UINT Count)
  921. {
  922. auto& CurrentPRSTypes = m_dProtectedResourceSessionTypes[NodeIndex];
  923. CurrentPRSTypes.NodeIndex = NodeIndex;
  924. CurrentPRSTypes.Count = Count;
  925. CurrentPRSTypes.TypeVec.resize(CurrentPRSTypes.Count);
  926. CurrentPRSTypes.pTypes = CurrentPRSTypes.TypeVec.data();
  927. HRESULT result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_PROTECTED_RESOURCE_SESSION_TYPES, &m_dProtectedResourceSessionTypes[NodeIndex], sizeof(D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_TYPES));
  928. if (FAILED(result))
  929. {
  930. // Resize TypeVec to empty
  931. CurrentPRSTypes.TypeVec.clear();
  932. }
  933. return result;
  934. }
  935. #undef FEATURE_SUPPORT_GET
  936. #undef FEATURE_SUPPORT_GET_NAME
  937. #undef FEATURE_SUPPORT_GET_NODE_INDEXED
  938. #undef FEATURE_SUPPORT_GET_NODE_INDEXED_NAME
  939. // end CD3DX12FeatureSupport