diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2017-12-28 05:45:08 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2017-12-28 05:45:08 +0000 |
| commit | 5cf012cfbc7017b46912b9f59a9f76a2d4b870b3 (patch) | |
| tree | 911054514a37c26a82cb4152bf04fcf148d9556b /Graphics/GraphicsEngineD3DBase | |
| parent | Removed legacy visual studio project and solution files (diff) | |
| download | DiligentCore-5cf012cfbc7017b46912b9f59a9f76a2d4b870b3.tar.gz DiligentCore-5cf012cfbc7017b46912b9f59a9f76a2d4b870b3.zip | |
Reworked Common and Platform modules to break interdependenices;
Replaced static const->static constexpr where appropriate
Diffstat (limited to 'Graphics/GraphicsEngineD3DBase')
5 files changed, 34 insertions, 32 deletions
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<D3D_FILL_MODE>(0); } } @@ -170,7 +170,7 @@ namespace Diligent } else { - UNEXPECTED( "Incorrect cull mode (", CullMode, ")" ) + UNEXPECTED( "Incorrect cull mode (", CullMode, ")" ); return static_cast<D3D_CULL_MODE>(0); } } @@ -238,7 +238,7 @@ namespace Diligent } else { - UNEXPECTED("Incorrect blend factor (", bf, ")" ) + UNEXPECTED("Incorrect blend factor (", bf, ")" ); return static_cast<D3D_BLEND>( 0 ); } } @@ -269,7 +269,7 @@ namespace Diligent } else { - UNEXPECTED( "Incorrect blend operation (", BlendOp, ")" ) + UNEXPECTED( "Incorrect blend operation (", BlendOp, ")" ); return static_cast<D3D_BLEND_OP>(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<D3D_STENCIL_OP>(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 <memory> + #define NOMINMAX #include <d3dcommon.h> @@ -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<Uint16>::max(); + static constexpr Uint16 InvalidBindPoint = std::numeric_limits<Uint16>::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<Uint16>::max(); + static constexpr Uint16 MaxBindPoint = InvalidBindPoint-1; + static constexpr Uint16 MaxBindCount = std::numeric_limits<Uint16>::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<<VariableTypeBits)-1; - static const Uint32 VariableTypeBitOffset = ShaderInputTypeBitOffset + ShaderInputTypeBits; + static constexpr Uint32 VariableTypeBits = 3; // Max value: SHADER_VARIABLE_TYPE_DYNAMIC == 2 + static constexpr Uint32 VariableTypeMask = (1<<VariableTypeBits)-1; + static constexpr Uint32 VariableTypeBitOffset = ShaderInputTypeBitOffset + ShaderInputTypeBits; static_assert( SHADER_VARIABLE_TYPE_NUM_TYPES-1 <= VariableTypeMask, "Not enough bits to represent SHADER_VARIABLE_TYPE" ); - static const Uint32 SRVDimBits = 4; // Max value: D3D_SRV_DIMENSION_BUFFEREX == 11 - static const Uint32 SRVDimMask = (1<<SRVDimBits)-1; - static const Uint32 SRVDimBitOffset = VariableTypeBitOffset + VariableTypeBits; + static constexpr Uint32 SRVDimBits = 4; // Max value: D3D_SRV_DIMENSION_BUFFEREX == 11 + static constexpr Uint32 SRVDimMask = (1<<SRVDimBits)-1; + static constexpr Uint32 SRVDimBitOffset = VariableTypeBitOffset + VariableTypeBits; static_assert( D3D_SRV_DIMENSION_BUFFEREX <= SRVDimMask, "Not enough bits to represent D3D_SRV_DIMENSION" ); - static const Uint32 SamplerIdBits = 32 - 1 - ShaderInputTypeBits - VariableTypeBits - SRVDimBits; - static const Uint32 SamplerIdMask = (1 << SamplerIdBits) - 1; - static const Uint32 SamplerIdBitOffset = SRVDimBitOffset + SRVDimBits; + static constexpr Uint32 SamplerIdBits = 32 - 1 - ShaderInputTypeBits - VariableTypeBits - SRVDimBits; + static constexpr Uint32 SamplerIdMask = (1 << SamplerIdBits) - 1; + static constexpr Uint32 SamplerIdBitOffset = SRVDimBitOffset + SRVDimBits; public: - static const Uint32 InvalidSamplerId = SamplerIdMask; + static constexpr Uint32 InvalidSamplerId = SamplerIdMask; private: - static const Uint32 IsStaticSamplerFlagBits = 1; - static const Uint32 IsStaticSamplerFlagMask = (1 << IsStaticSamplerFlagBits) - 1; - static const Uint32 IsStaticSamplerFlagBitOffset = SamplerIdBitOffset + SamplerIdBits; + static constexpr Uint32 IsStaticSamplerFlagBits = 1; + static constexpr Uint32 IsStaticSamplerFlagMask = (1 << IsStaticSamplerFlagBits) - 1; + static constexpr Uint32 IsStaticSamplerFlagBitOffset = SamplerIdBitOffset + SamplerIdBits; static_assert(IsStaticSamplerFlagBitOffset == 31, "Unexpected static sampler flag offset"); static Uint32 PackAttribs(D3D_SHADER_INPUT_TYPE _InputType, SHADER_VARIABLE_TYPE _VariableType, D3D_SRV_DIMENSION SRVDimension, Uint32 SamplerId, bool _IsStaticSampler) diff --git a/Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp b/Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp index d16d4815..e64aea85 100644 --- a/Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp +++ b/Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp @@ -180,7 +180,7 @@ ShaderD3DBase::ShaderD3DBase(const ShaderCreationAttribs &CreationAttribs) CreationAttribs.pShaderSourceStreamFactory->CreateInputStream(CreationAttribs.FilePath, &pSourceStream); RefCntAutoPtr<Diligent::IDataBlob> pFileData(MakeNewRCObj<Diligent::DataBlobImpl>()(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<Char*>(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; } } |
