From 5cf012cfbc7017b46912b9f59a9f76a2d4b870b3 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Wed, 27 Dec 2017 21:45:08 -0800 Subject: Reworked Common and Platform modules to break interdependenices; Replaced static const->static constexpr where appropriate --- .../include/D3DShaderResourceLoader.h | 6 ++-- .../include/D3DTypeConversionImpl.h | 10 +++--- .../include/ShaderResources.h | 42 +++++++++++----------- .../GraphicsEngineD3DBase/src/ShaderD3DBase.cpp | 4 +-- .../GraphicsEngineD3DBase/src/ShaderResources.cpp | 4 +-- 5 files changed, 34 insertions(+), 32 deletions(-) (limited to 'Graphics/GraphicsEngineD3DBase') diff --git a/Graphics/GraphicsEngineD3DBase/include/D3DShaderResourceLoader.h b/Graphics/GraphicsEngineD3DBase/include/D3DShaderResourceLoader.h index 16e1022b..5b3920d4 100644 --- a/Graphics/GraphicsEngineD3DBase/include/D3DShaderResourceLoader.h +++ b/Graphics/GraphicsEngineD3DBase/include/D3DShaderResourceLoader.h @@ -96,7 +96,7 @@ namespace Diligent auto OpenBracketPos = Name.find('['); if (String::npos != OpenBracketPos) { - VERIFY(BindCount == 1, "When array elements are enumerated individually, BindCount is expected to always be 1") + VERIFY(BindCount == 1, "When array elements are enumerated individually, BindCount is expected to always be 1"); // Name == "g_tex2DDiffuse[0]" // ^ @@ -107,7 +107,7 @@ namespace Diligent #ifdef _DEBUG for (const auto &ExistingRes : Resources) { - VERIFY(ExistingRes.Name != Name, "Resource with the same name has already been enumerated. All array elements are expected to be enumerated one after another") + VERIFY(ExistingRes.Name != Name, "Resource with the same name has already been enumerated. All array elements are expected to be enumerated one after another"); } #endif for( UINT ArrElem = Res+1; ArrElem < shaderDesc.BoundResources; ++ArrElem) @@ -179,7 +179,7 @@ namespace Diligent case D3D_SIT_UAV_APPEND_STRUCTURED: UNSUPPORTED( "Append structured buffers are not supported" ); break; case D3D_SIT_UAV_CONSUME_STRUCTURED: UNSUPPORTED( "Consume structured buffers are not supported" ); break; case D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER: UNSUPPORTED( "RW structured buffers with counter are not supported" ); break; - default: UNEXPECTED("Unexpected resource type") + default: UNEXPECTED("Unexpected resource type"); } Resources.emplace_back(std::move(Name), BindingDesc.BindPoint, BindCount, BindingDesc.Type, VarType, BindingDesc.Dimension, D3DShaderResourceAttribs::InvalidSamplerId, IsStaticSampler); } diff --git a/Graphics/GraphicsEngineD3DBase/include/D3DTypeConversionImpl.h b/Graphics/GraphicsEngineD3DBase/include/D3DTypeConversionImpl.h index db5beda7..8ac47a4c 100644 --- a/Graphics/GraphicsEngineD3DBase/include/D3DTypeConversionImpl.h +++ b/Graphics/GraphicsEngineD3DBase/include/D3DTypeConversionImpl.h @@ -142,7 +142,7 @@ namespace Diligent } else { - UNEXPECTED( "Incorrect fill mode (", FillMode, ")" ) + UNEXPECTED( "Incorrect fill mode (", FillMode, ")" ); return static_cast(0); } } @@ -170,7 +170,7 @@ namespace Diligent } else { - UNEXPECTED( "Incorrect cull mode (", CullMode, ")" ) + UNEXPECTED( "Incorrect cull mode (", CullMode, ")" ); return static_cast(0); } } @@ -238,7 +238,7 @@ namespace Diligent } else { - UNEXPECTED("Incorrect blend factor (", bf, ")" ) + UNEXPECTED("Incorrect blend factor (", bf, ")" ); return static_cast( 0 ); } } @@ -269,7 +269,7 @@ namespace Diligent } else { - UNEXPECTED( "Incorrect blend operation (", BlendOp, ")" ) + UNEXPECTED( "Incorrect blend operation (", BlendOp, ")" ); return static_cast(0); } } @@ -334,7 +334,7 @@ namespace Diligent } else { - UNEXPECTED( "Stencil operation (", StencilOp, ") is out of allowed range [1, ", STENCIL_OP_NUM_OPS - 1, "]" ) + UNEXPECTED( "Stencil operation (", StencilOp, ") is out of allowed range [1, ", STENCIL_OP_NUM_OPS - 1, "]" ); return static_cast(0); } } diff --git a/Graphics/GraphicsEngineD3DBase/include/ShaderResources.h b/Graphics/GraphicsEngineD3DBase/include/ShaderResources.h index 7eba6b48..a739fb14 100644 --- a/Graphics/GraphicsEngineD3DBase/include/ShaderResources.h +++ b/Graphics/GraphicsEngineD3DBase/include/ShaderResources.h @@ -51,6 +51,8 @@ // // +#include + #define NOMINMAX #include @@ -118,7 +120,7 @@ struct D3DShaderResourceAttribs } else { - VERIFY(SamplerId == InvalidSamplerId, "Only textures can be assigned valid texture sampler") + VERIFY(SamplerId == InvalidSamplerId, "Only textures can be assigned valid texture sampler"); } if(_IsStaticSampler) @@ -202,7 +204,7 @@ struct D3DShaderResourceAttribs return BindPoint != InvalidBindPoint; } - static const Uint16 InvalidBindPoint = std::numeric_limits::max(); + static constexpr Uint16 InvalidBindPoint = std::numeric_limits::max(); String Name; // Move ctor will not work if it is const const Uint16 BindPoint; @@ -217,34 +219,34 @@ struct D3DShaderResourceAttribs return Name; } private: - static const Uint16 MaxBindPoint = InvalidBindPoint-1; - static const Uint16 MaxBindCount = std::numeric_limits::max(); + static constexpr Uint16 MaxBindPoint = InvalidBindPoint-1; + static constexpr Uint16 MaxBindCount = std::numeric_limits::max(); - static const Uint32 ShaderInputTypeBits = 4; // Max value: D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER==11 - static const Uint32 ShaderInputTypeMask = (1 << ShaderInputTypeBits)-1; - static const Uint32 ShaderInputTypeBitOffset = 0; + static constexpr Uint32 ShaderInputTypeBits = 4; // Max value: D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER==11 + static constexpr Uint32 ShaderInputTypeMask = (1 << ShaderInputTypeBits)-1; + static constexpr Uint32 ShaderInputTypeBitOffset = 0; static_assert( D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER <= ShaderInputTypeMask, "Not enough bits to represent D3D_SHADER_INPUT_TYPE" ); - static const Uint32 VariableTypeBits = 3; // Max value: SHADER_VARIABLE_TYPE_DYNAMIC == 2 - static const Uint32 VariableTypeMask = (1<CreateInputStream(CreationAttribs.FilePath, &pSourceStream); RefCntAutoPtr pFileData(MakeNewRCObj()(0)); if (pSourceStream == nullptr) - LOG_ERROR_AND_THROW("Failed to open shader source file") + LOG_ERROR_AND_THROW("Failed to open shader source file"); pSourceStream->Read(pFileData); // Null terminator is not read from the stream! auto* FileDataPtr = reinterpret_cast(pFileData->GetDataPtr()); @@ -212,7 +212,7 @@ ShaderD3DBase::ShaderD3DBase(const ShaderCreationAttribs &CreationAttribs) } else { - LOG_ERROR_AND_THROW("Shader source must be provided through one of the 'Source', 'FilePath' or 'ByteCode' members") + LOG_ERROR_AND_THROW("Shader source must be provided through one of the 'Source', 'FilePath' or 'ByteCode' members"); } } diff --git a/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp b/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp index 06d5b0e4..ffe846d6 100644 --- a/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp +++ b/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp @@ -221,8 +221,8 @@ Uint32 ShaderResources::FindAssignedSamplerId(const D3DShaderResourceAttribs& Te const auto &Sampler = GetSampler(s); if( StrCmpSuff(Sampler.Name.c_str(), TexSRV.Name.c_str(), D3DSamplerSuffix) ) { - VERIFY(Sampler.GetVariableType() == TexSRV.GetVariableType(), "Inconsistent texture and sampler variable types") - VERIFY(Sampler.BindCount == TexSRV.BindCount || Sampler.BindCount == 1, "Sampler assigned to array \"", TexSRV.Name, "\" is expected to be scalar or have the same dimension (",TexSRV.BindCount,"). Actual sampler array dimension : ", Sampler.BindCount) + VERIFY(Sampler.GetVariableType() == TexSRV.GetVariableType(), "Inconsistent texture and sampler variable types"); + VERIFY(Sampler.BindCount == TexSRV.BindCount || Sampler.BindCount == 1, "Sampler assigned to array \"", TexSRV.Name, "\" is expected to be scalar or have the same dimension (",TexSRV.BindCount,"). Actual sampler array dimension : ", Sampler.BindCount); return s; } } -- cgit v1.2.3