From eb129d6308eaca88131656fd58124355cb1b391a Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 17 Apr 2018 09:20:09 -0700 Subject: Added template version of RawPtr function to allow more convenient type conversion --- .../GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp | 17 +++++++++-------- .../GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp | 14 +++++++------- .../src/RenderDeviceFactoryD3D11.cpp | 2 +- .../src/ShaderResourceLayoutD3D11.cpp | 2 +- .../GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp | 2 +- Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp | 6 +++--- 6 files changed, 22 insertions(+), 21 deletions(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index 772ea60c..6f43f0fa 100644 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -547,7 +547,8 @@ namespace Diligent { if (TDeviceContextBase::SetStencilRef(StencilRef, 0)) { - ID3D11DepthStencilState *pd3d11DSS = m_pPipelineState ? ValidatedCast(m_pPipelineState.RawPtr())->GetD3D11DepthStencilState() : nullptr; + ID3D11DepthStencilState *pd3d11DSS = + m_pPipelineState ? m_pPipelineState.RawPtr()->GetD3D11DepthStencilState() : nullptr; m_pd3d11DeviceContext->OMSetDepthStencilState( pd3d11DSS, m_StencilRef ); } } @@ -562,7 +563,7 @@ namespace Diligent if(m_pPipelineState) { SampleMask = m_pPipelineState->GetDesc().GraphicsPipeline.SampleMask; - pd3d11BS = ValidatedCast(m_pPipelineState.RawPtr())->GetD3D11BlendState(); + pd3d11BS = m_pPipelineState.RawPtr()->GetD3D11BlendState(); } m_pd3d11DeviceContext->OMSetBlendState(pd3d11BS, m_BlendFactors, SampleMask); } @@ -576,7 +577,7 @@ namespace Diligent return; } - BufferD3D11Impl *pBuffD3D11 = static_cast(m_pIndexBuffer.RawPtr()); + BufferD3D11Impl *pBuffD3D11 = m_pIndexBuffer.RawPtr(); if( pBuffD3D11->CheckState( D3D11BufferState::UnorderedAccess ) ) { UnbindResourceFromUAV(pBuffD3D11, pBuffD3D11->m_pd3d11Buffer); @@ -620,7 +621,7 @@ namespace Diligent { auto &CurrStream = m_VertexStreams[Slot]; VERIFY( CurrStream.pBuffer, "Attempting to bind a null buffer for rendering" ); - auto *pBuffD3D11Impl = ValidatedCast(CurrStream.pBuffer.RawPtr()); + auto *pBuffD3D11Impl = CurrStream.pBuffer.RawPtr(); ID3D11Buffer *pd3d11Buffer = pBuffD3D11Impl->m_pd3d11Buffer; auto Stride = CurrStream.Stride ? CurrStream.Stride : TightStrides[Slot]; auto Offset = CurrStream.Offset; @@ -675,7 +676,7 @@ namespace Diligent } #endif - auto *pPipelineStateD3D11 = ValidatedCast(m_pPipelineState.RawPtr()); + auto *pPipelineStateD3D11 = m_pPipelineState.RawPtr(); #ifdef _DEBUG if (pPipelineStateD3D11->GetDesc().IsComputePipeline) { @@ -793,7 +794,7 @@ namespace Diligent { if (m_pSwapChain) { - pd3d11DSV = ValidatedCast(m_pSwapChain.RawPtr())->GetDSV(); + pd3d11DSV = m_pSwapChain.RawPtr()->GetDSV(); VERIFY_EXPR(pd3d11DSV != nullptr); } else @@ -826,7 +827,7 @@ namespace Diligent { if (m_pSwapChain) { - pd3d11RTV = ValidatedCast(m_pSwapChain.RawPtr())->GetRTV(); + pd3d11RTV = m_pSwapChain.RawPtr()->GetRTV(); VERIFY_EXPR(pd3d11RTV != nullptr); } else @@ -925,7 +926,7 @@ namespace Diligent if (m_pSwapChain) { NumRenderTargets = 1; - auto *pSwapChainD3D11 = ValidatedCast(m_pSwapChain.RawPtr()); + auto *pSwapChainD3D11 = m_pSwapChain.RawPtr(); pd3d11RTs[0] = pSwapChainD3D11->GetRTV(); pd3d11DSV = pSwapChainD3D11->GetDSV(); VERIFY_EXPR(pd3d11RTs[0] != nullptr && pd3d11DSV != nullptr); diff --git a/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp index 4d1e7c39..be3f72d5 100644 --- a/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp @@ -100,7 +100,7 @@ PipelineStateD3D11Impl::PipelineStateD3D11Impl(IReferenceCounters *pRefCounters, std::vector > d311InputElements(STD_ALLOCATOR_RAW_MEM(D3D11_INPUT_ELEMENT_DESC, GetRawAllocator(), "Allocator for vector") ); LayoutElements_To_D3D11_INPUT_ELEMENT_DESCs(m_LayoutElements, d311InputElements); - ID3DBlob *pVSByteCode = ValidatedCast(m_pVS.RawPtr())->GetBytecode(); + ID3DBlob *pVSByteCode = m_pVS.RawPtr()->GetBytecode(); if( !pVSByteCode ) LOG_ERROR_AND_THROW( "Vertex Shader byte code does not exist" ); @@ -223,42 +223,42 @@ bool PipelineStateD3D11Impl::IsCompatibleWith(const IPipelineState *pPSO)const ID3D11VertexShader* PipelineStateD3D11Impl::GetD3D11VertexShader() { if(!m_pVS)return nullptr; - auto *pVSD3D11 = ValidatedCast(m_pVS.RawPtr()); + auto *pVSD3D11 = m_pVS.RawPtr(); return static_cast(pVSD3D11->GetD3D11Shader()); } ID3D11PixelShader* PipelineStateD3D11Impl::GetD3D11PixelShader() { if(!m_pPS)return nullptr; - auto *pPSD3D11 = ValidatedCast(m_pPS.RawPtr()); + auto *pPSD3D11 = m_pPS.RawPtr(); return static_cast(pPSD3D11->GetD3D11Shader()); } ID3D11GeometryShader* PipelineStateD3D11Impl::GetD3D11GeometryShader() { if(!m_pGS)return nullptr; - auto *pGSD3D11 = ValidatedCast(m_pGS.RawPtr()); + auto *pGSD3D11 = m_pGS.RawPtr(); return static_cast(pGSD3D11->GetD3D11Shader()); } ID3D11DomainShader* PipelineStateD3D11Impl::GetD3D11DomainShader() { if(!m_pDS)return nullptr; - auto *pDSD3D11 = ValidatedCast(m_pDS.RawPtr()); + auto *pDSD3D11 = m_pDS.RawPtr(); return static_cast(pDSD3D11->GetD3D11Shader()); } ID3D11HullShader* PipelineStateD3D11Impl::GetD3D11HullShader() { if(!m_pHS)return nullptr; - auto *pHSD3D11 = ValidatedCast(m_pHS.RawPtr()); + auto *pHSD3D11 = m_pHS.RawPtr(); return static_cast(pHSD3D11->GetD3D11Shader()); } ID3D11ComputeShader* PipelineStateD3D11Impl::GetD3D11ComputeShader() { if(!m_pCS)return nullptr; - auto *pCSD3D11 = ValidatedCast(m_pCS.RawPtr()); + auto *pCSD3D11 = m_pCS.RawPtr(); return static_cast(pCSD3D11->GetD3D11Shader()); } diff --git a/Graphics/GraphicsEngineD3D11/src/RenderDeviceFactoryD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/RenderDeviceFactoryD3D11.cpp index bd8916b9..90f4c6c0 100644 --- a/Graphics/GraphicsEngineD3D11/src/RenderDeviceFactoryD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/RenderDeviceFactoryD3D11.cpp @@ -333,7 +333,7 @@ void EngineFactoryD3D11Impl::CreateSwapChainD3D11( IRenderDevice *pDevice, { if (auto pDeferredCtx = pDeviceD3D11->GetDeferredContext(ctx)) { - auto *pDeferredCtxD3D11 = ValidatedCast(pDeferredCtx.RawPtr()); + auto *pDeferredCtxD3D11 = pDeferredCtx.RawPtr(); pDeferredCtxD3D11->SetSwapChain(pSwapChainD3D11); // Do not bind default render target and viewport to be // consistent with D3D12 diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp index e653fa3a..bc952619 100644 --- a/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp @@ -811,7 +811,7 @@ do{ \ auto &CachedResource = pCachedResources[BindPoint]; if(CachedResource.pView) { - auto *pTexView = ValidatedCast(CachedResource.pView.RawPtr()); + auto *pTexView = CachedResource.pView.RawPtr(); auto *pSampler = pTexView->GetSampler(); if(pSampler != nullptr && pSampler != Sampler.pSampler.RawPtr()) LOG_ERROR_MESSAGE( "All elements of texture array \"", ts.Attribs.Name, "\" in shader \"", GetShaderName(), "\" share the same sampler. However, the sampler set in view for element ", BindPoint - ts.Attribs.BindPoint, " does not match bound sampler. This may cause incorrect behavior on GL platform." ); diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp index 74149c5e..ffc3a963 100644 --- a/Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp @@ -160,7 +160,7 @@ void ShaderResourcesD3D11::InitStaticSamplers(ShaderResourceCacheD3D11 &Resource const auto *pSamAttribs = StaticSampler.first; auto EndBindPoint = std::min( static_cast(pSamAttribs->BindPoint) + pSamAttribs->BindCount, NumCachedSamplers); for(Uint32 BindPoint = pSamAttribs->BindPoint; BindPoint < EndBindPoint; ++BindPoint ) - ResourceCache.SetSampler(BindPoint, ValidatedCast(StaticSampler.second.RawPtr()) ); + ResourceCache.SetSampler(BindPoint, StaticSampler.second.RawPtr() ); } } diff --git a/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp index 5229b504..b50958c7 100644 --- a/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp @@ -51,7 +51,7 @@ SwapChainD3D11Impl::~SwapChainD3D11Impl() void SwapChainD3D11Impl::CreateRTVandDSV() { - auto *pDevice = ValidatedCast(m_pRenderDevice.RawPtr())->GetD3D11Device(); + auto *pDevice = m_pRenderDevice.RawPtr()->GetD3D11Device(); m_pRenderTargetView.Release(); m_pDepthStencilView.Release(); @@ -139,7 +139,7 @@ void SwapChainD3D11Impl::UpdateSwapChain(bool CreateNew) VERIFY(pDeviceContext, "Immediate context has been released"); if (pDeviceContext) { - auto *pImmediateCtxD3D11 = ValidatedCast(pDeviceContext.RawPtr()); + auto *pImmediateCtxD3D11 = pDeviceContext.RawPtr(); bool bIsDefaultFBBound = pImmediateCtxD3D11->IsDefaultFBBound(); if (bIsDefaultFBBound) { @@ -165,7 +165,7 @@ void SwapChainD3D11Impl::UpdateSwapChain(bool CreateNew) // https://msdn.microsoft.com/en-us/library/windows/desktop/ff476425(v=vs.85).aspx#Defer_Issues_with_Flip pImmediateCtxD3D11->Flush(); - auto *pd3d11Device = ValidatedCast(m_pRenderDevice.RawPtr())->GetD3D11Device(); + auto *pd3d11Device = m_pRenderDevice.RawPtr()->GetD3D11Device(); CreateDXGISwapChain(pd3d11Device); } else -- cgit v1.2.3