diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2021-01-30 04:00:21 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2021-01-30 04:26:56 +0000 |
| commit | b484ebd657d17ae0a87d14df82419be6771f5069 (patch) | |
| tree | 908dfc3469c94a6ac7e3aa4fa8d5844d0252cc2a /Graphics | |
| parent | Reworked resource validation when binding resources (diff) | |
| download | DiligentCore-b484ebd657d17ae0a87d14df82419be6771f5069.tar.gz DiligentCore-b484ebd657d17ae0a87d14df82419be6771f5069.zip | |
Graphics accessories: added GetPipelineResourceFlagsString function
Diffstat (limited to 'Graphics')
4 files changed, 67 insertions, 28 deletions
diff --git a/Graphics/GraphicsAccessories/interface/GraphicsAccessories.hpp b/Graphics/GraphicsAccessories/interface/GraphicsAccessories.hpp index a73c8877..3c91982e 100644 --- a/Graphics/GraphicsAccessories/interface/GraphicsAccessories.hpp +++ b/Graphics/GraphicsAccessories/interface/GraphicsAccessories.hpp @@ -383,6 +383,7 @@ const char* GetPipelineTypeString(PIPELINE_TYPE PipelineType); const char* GetShaderCompilerTypeString(SHADER_COMPILER Compiler); +String GetPipelineResourceFlagsString(PIPELINE_RESOURCE_FLAGS Flags, bool GetFullName = false); Uint32 ComputeMipLevelsCount(Uint32 Width); Uint32 ComputeMipLevelsCount(Uint32 Width, Uint32 Height); diff --git a/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp b/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp index ac4c906d..7e6ef71b 100644 --- a/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp +++ b/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp @@ -30,6 +30,7 @@ #include "GraphicsAccessories.hpp" #include "DebugUtilities.hpp" #include "Align.hpp" +#include "BasicMath.hpp" namespace Diligent { @@ -474,7 +475,7 @@ const Char* GetBufferViewTypeLiteralName(BUFFER_VIEW_TYPE ViewType) const Char* GetShaderTypeLiteralName(SHADER_TYPE ShaderType) { - static_assert(SHADER_TYPE_LAST == SHADER_TYPE_CALLABLE, "Please handle the new shader type in the switch below"); + static_assert(SHADER_TYPE_LAST == 0x2000, "Please handle the new shader type in the switch below"); switch (ShaderType) { // clang-format off @@ -534,7 +535,7 @@ const Char* GetShaderVariableTypeLiteralName(SHADER_RESOURCE_VARIABLE_TYPE VarTy FullVarTypeNameStrings[SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE] = "SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE"; FullVarTypeNameStrings[SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC] = "SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC"; - static_assert(SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES == SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC + 1, "Not all shader variable types initialized."); + static_assert(SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES == 3, "Not all shader variable types initialized."); bVarTypeStrsInit = true; } @@ -550,7 +551,7 @@ const Char* GetShaderVariableTypeLiteralName(SHADER_RESOURCE_VARIABLE_TYPE VarTy const Char* GetShaderResourceTypeLiteralName(SHADER_RESOURCE_TYPE ResourceType, bool bGetFullName) { - static_assert(SHADER_RESOURCE_TYPE_LAST == SHADER_RESOURCE_TYPE_ACCEL_STRUCT, "Please update the switch below to handle the new shader resource type"); + static_assert(SHADER_RESOURCE_TYPE_LAST == 8, "Please update the switch below to handle the new shader resource type"); switch (ResourceType) { // clang-format off @@ -815,7 +816,7 @@ const Char* GetResourceDimString(RESOURCE_DIMENSION TexType) TexTypeStrings[RESOURCE_DIM_TEX_3D] = "Texture 3D"; TexTypeStrings[RESOURCE_DIM_TEX_CUBE] = "Texture Cube"; TexTypeStrings[RESOURCE_DIM_TEX_CUBE_ARRAY] = "Texture Cube Array"; - static_assert(RESOURCE_DIM_NUM_DIMENSIONS == RESOURCE_DIM_TEX_CUBE_ARRAY + 1, "Not all texture type strings initialized."); + static_assert(RESOURCE_DIM_NUM_DIMENSIONS == 9, "Not all texture type strings initialized."); bTexTypeStrsInit = true; } @@ -832,7 +833,7 @@ const Char* GetBindFlagString(Uint32 BindFlag) { VERIFY((BindFlag & (BindFlag - 1)) == 0, "More than one bind flag is specified"); - static_assert(BIND_FLAGS_LAST == BIND_RAY_TRACING, "Please handle the new bind flag in the switch below"); + static_assert(BIND_FLAGS_LAST == 0x400L, "Please handle the new bind flag in the switch below"); switch (BindFlag) { #define BIND_FLAG_STR_CASE(Flag) \ @@ -976,7 +977,7 @@ const Char* GetBufferModeString(BUFFER_MODE Mode) INIT_BUFF_MODE_STR( BUFFER_MODE_RAW ); #undef INIT_BUFF_MODE_STR // clang-format on - static_assert(BUFFER_MODE_NUM_MODES == BUFFER_MODE_RAW + 1, "Not all buffer mode strings initialized."); + static_assert(BUFFER_MODE_NUM_MODES == 4, "Not all buffer mode strings initialized."); bBuffModeStringsInit = true; } if (Mode >= BUFFER_MODE_UNDEFINED && Mode < BUFFER_MODE_NUM_MODES) @@ -1044,7 +1045,7 @@ String GetBufferDescString(const BufferDesc& Desc) const Char* GetResourceStateFlagString(RESOURCE_STATE State) { VERIFY((State & (State - 1)) == 0, "Single state is expected"); - static_assert(RESOURCE_STATE_MAX_BIT == RESOURCE_STATE_RAY_TRACING, "Please update this function to handle the new resource state"); + static_assert(RESOURCE_STATE_MAX_BIT == 0x80000, "Please update this function to handle the new resource state"); switch (State) { // clang-format off @@ -1143,7 +1144,7 @@ const char* GetSurfaceTransformString(SURFACE_TRANSFORM SrfTransform) const char* GetPipelineTypeString(PIPELINE_TYPE PipelineType) { - static_assert(PIPELINE_TYPE_LAST == PIPELINE_TYPE_RAY_TRACING, "Please update this function to handle the new pipeline type"); + static_assert(PIPELINE_TYPE_LAST == 3, "Please update this function to handle the new pipeline type"); switch (PipelineType) { // clang-format off @@ -1160,7 +1161,7 @@ const char* GetPipelineTypeString(PIPELINE_TYPE PipelineType) const char* GetShaderCompilerTypeString(SHADER_COMPILER Compiler) { - static_assert(SHADER_COMPILER_LAST == SHADER_COMPILER_FXC, "Please update this function to handle the new shader compiler"); + static_assert(SHADER_COMPILER_LAST == 3, "Please update this function to handle the new shader compiler"); switch (Compiler) { // clang-format off @@ -1175,6 +1176,41 @@ const char* GetShaderCompilerTypeString(SHADER_COMPILER Compiler) } } +String GetPipelineResourceFlagsString(PIPELINE_RESOURCE_FLAGS Flags, bool GetFullName /*= false*/) +{ + if (Flags == PIPELINE_RESOURCE_FLAG_UNKNOWN) + return GetFullName ? "PIPELINE_RESOURCE_FLAG_UNKNOWN" : "UNKNOWN"; + String Str; + while (Flags != PIPELINE_RESOURCE_FLAG_UNKNOWN) + { + if (!Str.empty()) + Str += '|'; + + auto Flag = ExtractLSB(Flags); + + static_assert(PIPELINE_RESOURCE_FLAG_LAST == 0x04, "Please update the switch below to handle the new pipeline resource flag."); + switch (Flag) + { + case PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS: + Str.append(GetFullName ? "PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS" : "NO_DYNAMIC_BUFFERS"); + break; + + case PIPELINE_RESOURCE_FLAG_COMBINED_SAMPLER: + Str.append(GetFullName ? "PIPELINE_RESOURCE_FLAG_COMBINED_SAMPLER" : "COMBINED_SAMPLER"); + break; + + case PIPELINE_RESOURCE_FLAG_FORMATTED_BUFFER: + Str.append(GetFullName ? "PIPELINE_RESOURCE_FLAG_FORMATTED_BUFFER" : "FORMATTED_BUFFER"); + break; + + default: + UNEXPECTED("Unexpected pipeline resource flag"); + } + } + return Str; +} + + Uint32 ComputeMipLevelsCount(Uint32 Width) { if (Width == 0) @@ -1199,7 +1235,7 @@ Uint32 ComputeMipLevelsCount(Uint32 Width, Uint32 Height, Uint32 Depth) bool VerifyResourceStates(RESOURCE_STATE State, bool IsTexture) { - static_assert(RESOURCE_STATE_MAX_BIT == RESOURCE_STATE_RAY_TRACING, "Please update this function to handle the new resource state"); + static_assert(RESOURCE_STATE_MAX_BIT == 0x80000, "Please update this function to handle the new resource state"); // clang-format off #define VERIFY_EXCLUSIVE_STATE(ExclusiveState)\ @@ -1313,7 +1349,7 @@ ADAPTER_VENDOR VendorIdToAdapterVendor(Uint32 VendorId) bool IsConsistentShaderType(SHADER_TYPE ShaderType, PIPELINE_TYPE PipelineType) { - static_assert(SHADER_TYPE_LAST == SHADER_TYPE_CALLABLE, "Please update the switch below to handle the new shader type"); + static_assert(SHADER_TYPE_LAST == 0x2000, "Please update the switch below to handle the new shader type"); switch (PipelineType) { case PIPELINE_TYPE_GRAPHICS: @@ -1351,7 +1387,7 @@ Int32 GetShaderTypePipelineIndex(SHADER_TYPE ShaderType, PIPELINE_TYPE PipelineT " is inconsistent with pipeline type ", GetPipelineTypeString(PipelineType)); VERIFY(IsPowerOfTwo(Uint32{ShaderType}), "More than one shader type is specified"); - static_assert(SHADER_TYPE_LAST == SHADER_TYPE_CALLABLE, "Please update the switch below to handle the new shader type"); + static_assert(SHADER_TYPE_LAST == 0x2000, "Please update the switch below to handle the new shader type"); switch (ShaderType) { case SHADER_TYPE_UNKNOWN: @@ -1391,7 +1427,7 @@ Int32 GetShaderTypePipelineIndex(SHADER_TYPE ShaderType, PIPELINE_TYPE PipelineT SHADER_TYPE GetShaderTypeFromPipelineIndex(Int32 Index, PIPELINE_TYPE PipelineType) { - static_assert(SHADER_TYPE_LAST == SHADER_TYPE_CALLABLE, "Please update the switch below to handle the new shader type"); + static_assert(SHADER_TYPE_LAST == 0x2000, "Please update the switch below to handle the new shader type"); switch (PipelineType) { case PIPELINE_TYPE_GRAPHICS: diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h index 9234252c..2bc7cab1 100644 --- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h +++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h @@ -70,22 +70,22 @@ DILIGENT_TYPED_ENUM(VALUE_TYPE, Uint8) /// - TextureDesc to describe bind flags for a texture DILIGENT_TYPED_ENUM(BIND_FLAGS, Uint32) { - BIND_NONE = 0x0L, ///< Undefined binding - BIND_VERTEX_BUFFER = 0x1L, ///< A buffer can be bound as a vertex buffer - BIND_INDEX_BUFFER = 0x2L, ///< A buffer can be bound as an index buffer - BIND_UNIFORM_BUFFER = 0x4L, ///< A buffer can be bound as a uniform buffer + BIND_NONE = 0x0, ///< Undefined binding + BIND_VERTEX_BUFFER = 0x1, ///< A buffer can be bound as a vertex buffer + BIND_INDEX_BUFFER = 0x2, ///< A buffer can be bound as an index buffer + BIND_UNIFORM_BUFFER = 0x4, ///< A buffer can be bound as a uniform buffer /// \warning This flag may not be combined with any other bind flag - BIND_SHADER_RESOURCE = 0x8L, ///< A buffer or a texture can be bound as a shader resource + BIND_SHADER_RESOURCE = 0x8, ///< A buffer or a texture can be bound as a shader resource /// \warning This flag cannot be used with MAP_WRITE_NO_OVERWRITE flag - BIND_STREAM_OUTPUT = 0x10L, ///< A buffer can be bound as a target for stream output stage - BIND_RENDER_TARGET = 0x20L, ///< A texture can be bound as a render target - BIND_DEPTH_STENCIL = 0x40L, ///< A texture can be bound as a depth-stencil target - BIND_UNORDERED_ACCESS = 0x80L, ///< A buffer or a texture can be bound as an unordered access view - BIND_INDIRECT_DRAW_ARGS = 0x100L, ///< A buffer can be bound as the source buffer for indirect draw commands - BIND_INPUT_ATTACHMENT = 0x200L, ///< A texture can be used as render pass input attachment - BIND_RAY_TRACING = 0x400L, ///< A buffer can be used as a scratch buffer or as the source of primitive data - /// for acceleration structure building - BIND_FLAGS_LAST = 0x400L + BIND_STREAM_OUTPUT = 0x10, ///< A buffer can be bound as a target for stream output stage + BIND_RENDER_TARGET = 0x20, ///< A texture can be bound as a render target + BIND_DEPTH_STENCIL = 0x40, ///< A texture can be bound as a depth-stencil target + BIND_UNORDERED_ACCESS = 0x80, ///< A buffer or a texture can be bound as an unordered access view + BIND_INDIRECT_DRAW_ARGS = 0x100, ///< A buffer can be bound as the source buffer for indirect draw commands + BIND_INPUT_ATTACHMENT = 0x200, ///< A texture can be used as render pass input attachment + BIND_RAY_TRACING = 0x400, ///< A buffer can be used as a scratch buffer or as the source of primitive data + /// for acceleration structure building + BIND_FLAGS_LAST = 0x400 }; DEFINE_FLAG_ENUM_OPERATORS(BIND_FLAGS) diff --git a/Graphics/GraphicsEngine/interface/PipelineResourceSignature.h b/Graphics/GraphicsEngine/interface/PipelineResourceSignature.h index eb2c9470..3b6e66c9 100644 --- a/Graphics/GraphicsEngine/interface/PipelineResourceSignature.h +++ b/Graphics/GraphicsEngine/interface/PipelineResourceSignature.h @@ -106,7 +106,9 @@ DILIGENT_TYPED_ENUM(PIPELINE_RESOURCE_FLAGS, Uint8) /// as opposed to structured buffers. If an application will be using /// formatted buffers with buffer UAVs and SRVs, it must specify the /// PIPELINE_RESOURCE_FLAG_FORMATTED_BUFFER flag. - PIPELINE_RESOURCE_FLAG_FORMATTED_BUFFER = 0x04 + PIPELINE_RESOURCE_FLAG_FORMATTED_BUFFER = 0x04, + + PIPELINE_RESOURCE_FLAG_LAST = PIPELINE_RESOURCE_FLAG_FORMATTED_BUFFER }; DEFINE_FLAG_ENUM_OPERATORS(PIPELINE_RESOURCE_FLAGS); |
