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 --- .../GraphicsEngine/include/DeviceContextBase.h | 2 +- .../src/DeviceContextD3D11Impl.cpp | 17 +++++++------- .../src/PipelineStateD3D11Impl.cpp | 14 ++++++------ .../src/RenderDeviceFactoryD3D11.cpp | 2 +- .../src/ShaderResourceLayoutD3D11.cpp | 2 +- .../src/ShaderResourcesD3D11.cpp | 2 +- .../GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp | 6 ++--- .../src/DeviceContextD3D12Impl.cpp | 26 +++++++++++----------- .../src/RenderDeviceD3D12Impl.cpp | 4 ++-- .../src/RenderDeviceFactoryD3D12.cpp | 2 +- Graphics/GraphicsEngineD3D12/src/RootSignature.cpp | 22 +++++++++--------- .../src/ShaderResourceLayoutD3D12.cpp | 6 ++--- .../GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp | 8 +++---- .../src/DeviceContextGLImpl.cpp | 22 +++++++++--------- .../src/RenderDeviceGLImpl.cpp | 6 ++--- .../GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp | 6 ++--- 16 files changed, 74 insertions(+), 73 deletions(-) (limited to 'Graphics') diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.h b/Graphics/GraphicsEngine/include/DeviceContextBase.h index 8099afc7..a586d393 100644 --- a/Graphics/GraphicsEngine/include/DeviceContextBase.h +++ b/Graphics/GraphicsEngine/include/DeviceContextBase.h @@ -262,7 +262,7 @@ inline bool DeviceContextBase :: CommitShaderResources(IShaderRes if (pShaderResourceBinding) { - auto *pPSOImpl = ValidatedCast(m_pPipelineState.RawPtr()); + auto *pPSOImpl = m_pPipelineState.RawPtr(); if (pPSOImpl->IsIncompatibleWith(pShaderResourceBinding->GetPipelineState())) { LOG_ERROR_MESSAGE("Shader resource binding object is not compatible with the currently bound pipeline state"); 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 diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp index f2c7d805..9fbb8785 100644 --- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp @@ -77,7 +77,7 @@ namespace Diligent DeviceContextD3D12Impl::~DeviceContextD3D12Impl() { if(m_bIsDeferred) - ValidatedCast(m_pDevice.RawPtr())->DisposeCommandContext(m_pCurrCmdCtx); + m_pDevice.RawPtr()->DisposeCommandContext(m_pCurrCmdCtx); else { if (m_NumCommandsInCurCtx != 0) @@ -169,7 +169,7 @@ namespace Diligent return; auto *pCtx = RequestCmdContext(); - auto *pPipelineStateD3D12 = ValidatedCast(m_pPipelineState.RawPtr()); + auto *pPipelineStateD3D12 = m_pPipelineState.RawPtr(); m_pCommittedResourceCache = pPipelineStateD3D12->CommitAndTransitionShaderResources(pShaderResourceBinding, *pCtx, true, (Flags & COMMIT_SHADER_RESOURCES_FLAG_TRANSITION_RESOURCES)!=0); } @@ -257,7 +257,7 @@ namespace Diligent void DeviceContextD3D12Impl::CommitD3D12VertexBuffers(GraphicsContext &GraphCtx) { - auto *pPipelineStateD3D12 = ValidatedCast(m_pPipelineState.RawPtr()); + auto *pPipelineStateD3D12 = m_pPipelineState.RawPtr(); // Do not initialize array with zeroes for performance reasons D3D12_VERTEX_BUFFER_VIEW VBViews[MaxBufferSlots];// = {} @@ -331,7 +331,7 @@ namespace Diligent CommitD3D12IndexBuffer(DrawAttribs.IndexType); } - auto *pPipelineStateD3D12 = ValidatedCast(m_pPipelineState.RawPtr()); + auto *pPipelineStateD3D12 = m_pPipelineState.RawPtr(); if(m_bCommittedD3D12VBsUpToDate) TransitionD3D12VertexBuffers(GraphCtx); @@ -397,7 +397,7 @@ namespace Diligent } #endif - auto *pPipelineStateD3D12 = ValidatedCast(m_pPipelineState.RawPtr()); + auto *pPipelineStateD3D12 = m_pPipelineState.RawPtr(); auto &ComputeCtx = RequestCmdContext()->AsComputeContext(); ComputeCtx.SetRootSignature( pPipelineStateD3D12->GetD3D12RootSignature() ); @@ -453,7 +453,7 @@ namespace Diligent { if (m_pSwapChain) { - pDSVD3D12 = ValidatedCast(m_pSwapChain.RawPtr())->GetDepthBufferDSV(); + pDSVD3D12 = m_pSwapChain.RawPtr()->GetDepthBufferDSV(); } else { @@ -485,7 +485,7 @@ namespace Diligent { if (m_pSwapChain) { - pd3d12RTV = ValidatedCast(m_pSwapChain.RawPtr())->GetCurrentBackBufferRTV(); + pd3d12RTV = m_pSwapChain.RawPtr()->GetCurrentBackBufferRTV(); } else { @@ -506,7 +506,7 @@ namespace Diligent void DeviceContextD3D12Impl::Flush(bool RequestNewCmdCtx) { - auto pDeviceD3D12Impl = ValidatedCast(m_pDevice.RawPtr()); + auto pDeviceD3D12Impl = m_pDevice.RawPtr(); if( m_pCurrCmdCtx ) { VERIFY(!m_bIsDeferred, "Deferred contexts cannot execute command lists directly"); @@ -680,7 +680,7 @@ namespace Diligent if (m_pSwapChain) { NumRenderTargets = 1; - auto *pSwapChainD3D12 = ValidatedCast(m_pSwapChain.RawPtr()); + auto *pSwapChainD3D12 = m_pSwapChain.RawPtr(); ppRTVs[0] = pSwapChainD3D12->GetCurrentBackBufferRTV(); pDSV = pSwapChainD3D12->GetDepthBufferDSV(); } @@ -693,8 +693,8 @@ namespace Diligent else { for( Uint32 rt = 0; rt < NumRenderTargets; ++rt ) - ppRTVs[rt] = ValidatedCast(m_pBoundRenderTargets[rt].RawPtr()); - pDSV = ValidatedCast(m_pBoundDepthStencil.RawPtr()); + ppRTVs[rt] = m_pBoundRenderTargets[rt].RawPtr(); + pDSV = m_pBoundDepthStencil.RawPtr(); } RequestCmdContext()->AsGraphicsContext().SetRenderTargets(NumRenderTargets, ppRTVs, pDSV); } @@ -838,7 +838,7 @@ namespace Diligent void DeviceContextD3D12Impl::GenerateMips(TextureViewD3D12Impl *pTexView) { auto *pCtx = RequestCmdContext(); - m_MipsGenerator.GenerateMips(ValidatedCast(m_pDevice.RawPtr()), pTexView, *pCtx); + m_MipsGenerator.GenerateMips(m_pDevice.RawPtr(), pTexView, *pCtx); ++m_NumCommandsInCurCtx; } @@ -866,7 +866,7 @@ namespace Diligent InvalidateState(); CommandListD3D12Impl* pCmdListD3D12 = ValidatedCast(pCommandList); - ValidatedCast(m_pDevice.RawPtr())->CloseAndExecuteCommandContext(pCmdListD3D12->Close(), true); + m_pDevice.RawPtr()->CloseAndExecuteCommandContext(pCmdListD3D12->Close(), true); } void DeviceContextD3D12Impl::TransitionTextureState(ITexture *pTexture, D3D12_RESOURCE_STATES State) diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp index 027b94bf..3fe77025 100644 --- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp @@ -202,7 +202,7 @@ void RenderDeviceD3D12Impl::FinishFrame(bool ReleaseAllResources) { if (auto pImmediateCtx = m_wpImmediateContext.Lock()) { - auto pImmediateCtxD3D12 = ValidatedCast(pImmediateCtx.RawPtr()); + auto pImmediateCtxD3D12 = pImmediateCtx.RawPtr(); if(pImmediateCtxD3D12->GetNumCommandsInCtx() != 0) LOG_ERROR_MESSAGE("There are outstanding commands in the immediate device context when finishing the frame. This is an error and may cause unpredicted behaviour. Call Flush() to submit all commands for execution before finishing the frame"); } @@ -211,7 +211,7 @@ void RenderDeviceD3D12Impl::FinishFrame(bool ReleaseAllResources) { if (auto pDeferredCtx = wpDeferredCtx.Lock()) { - auto pDeferredCtxD3D12 = ValidatedCast(pDeferredCtx.RawPtr()); + auto pDeferredCtxD3D12 = pDeferredCtx.RawPtr(); if(pDeferredCtxD3D12->GetNumCommandsInCtx() != 0) LOG_ERROR_MESSAGE("There are outstanding commands in the deferred device context when finishing the frame. This is an error and may cause unpredicted behaviour. Close all deferred contexts and execute them before finishing the frame"); } diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp index 8f05e917..9fed8e56 100644 --- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp @@ -385,7 +385,7 @@ void EngineFactoryD3D12Impl::CreateSwapChainD3D12( IRenderDevice *pDevice, { if (auto pDeferredCtx = pDeviceD3D12->GetDeferredContext(ctx)) { - auto *pDeferredCtxD3D12 = ValidatedCast(pDeferredCtx.RawPtr()); + auto *pDeferredCtxD3D12 = pDeferredCtx.RawPtr(); pDeferredCtxD3D12->SetSwapChain(pSwapChainD3D12); // We cannot bind default render target here because // there is no guarantee that deferred context will be used diff --git a/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp b/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp index 2011bebe..dbe18717 100644 --- a/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp @@ -643,7 +643,7 @@ void TransitionResource(CommandContext &Ctx, { VERIFY(RangeType == D3D12_DESCRIPTOR_RANGE_TYPE_CBV, "Unexpected descriptor range type"); // Not using QueryInterface() for the sake of efficiency - auto *pBuffToTransition = ValidatedCast(Res.pObject.RawPtr()); + auto *pBuffToTransition = Res.pObject.RawPtr(); if( !pBuffToTransition->CheckAllStates(D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER) ) Ctx.TransitionResource(pBuffToTransition, D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER ); } @@ -652,7 +652,7 @@ void TransitionResource(CommandContext &Ctx, case CachedResourceType::BufSRV: { VERIFY(RangeType == D3D12_DESCRIPTOR_RANGE_TYPE_SRV, "Unexpected descriptor range type"); - auto *pBuffViewD3D12 = ValidatedCast(Res.pObject.RawPtr()); + auto *pBuffViewD3D12 = Res.pObject.RawPtr(); auto *pBuffToTransition = ValidatedCast(pBuffViewD3D12->GetBuffer()); if( !pBuffToTransition->CheckAllStates(D3D12_RESOURCE_STATE_SHADER_RESOURCE) ) Ctx.TransitionResource(pBuffToTransition, D3D12_RESOURCE_STATE_SHADER_RESOURCE ); @@ -662,7 +662,7 @@ void TransitionResource(CommandContext &Ctx, case CachedResourceType::BufUAV: { VERIFY(RangeType == D3D12_DESCRIPTOR_RANGE_TYPE_UAV, "Unexpected descriptor range type"); - auto *pBuffViewD3D12 = ValidatedCast(Res.pObject.RawPtr()); + auto *pBuffViewD3D12 = Res.pObject.RawPtr(); auto *pBuffToTransition = ValidatedCast(pBuffViewD3D12->GetBuffer()); if( !pBuffToTransition->CheckAllStates(D3D12_RESOURCE_STATE_UNORDERED_ACCESS) ) Ctx.TransitionResource(pBuffToTransition, D3D12_RESOURCE_STATE_UNORDERED_ACCESS ); @@ -672,7 +672,7 @@ void TransitionResource(CommandContext &Ctx, case CachedResourceType::TexSRV: { VERIFY(RangeType == D3D12_DESCRIPTOR_RANGE_TYPE_SRV, "Unexpected descriptor range type"); - auto *pTexViewD3D12 = ValidatedCast(Res.pObject.RawPtr()); + auto *pTexViewD3D12 = Res.pObject.RawPtr(); auto *pTexToTransition = ValidatedCast(pTexViewD3D12->GetTexture()); if( !pTexToTransition->CheckAllStates(D3D12_RESOURCE_STATE_SHADER_RESOURCE) ) Ctx.TransitionResource(pTexToTransition, D3D12_RESOURCE_STATE_SHADER_RESOURCE ); @@ -682,7 +682,7 @@ void TransitionResource(CommandContext &Ctx, case CachedResourceType::TexUAV: { VERIFY(RangeType == D3D12_DESCRIPTOR_RANGE_TYPE_UAV, "Unexpected descriptor range type"); - auto *pTexViewD3D12 = ValidatedCast(Res.pObject.RawPtr()); + auto *pTexViewD3D12 = Res.pObject.RawPtr(); auto *pTexToTransition = ValidatedCast(pTexViewD3D12->GetTexture()); if( !pTexToTransition->CheckAllStates(D3D12_RESOURCE_STATE_UNORDERED_ACCESS) ) Ctx.TransitionResource(pTexToTransition, D3D12_RESOURCE_STATE_UNORDERED_ACCESS ); @@ -711,7 +711,7 @@ void DbgVerifyResourceState(ShaderResourceCacheD3D12::Resource &Res, { VERIFY(RangeType == D3D12_DESCRIPTOR_RANGE_TYPE_CBV, "Unexpected descriptor range type"); // Not using QueryInterface() for the sake of efficiency - auto *pBuffToTransition = ValidatedCast(Res.pObject.RawPtr()); + auto *pBuffToTransition = Res.pObject.RawPtr(); auto State = pBuffToTransition->GetState(); if( (State & D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER) != D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER ) LOG_ERROR_MESSAGE("Resource \"", pBuffToTransition->GetDesc().Name, "\" is not in D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER state. Did you forget to call TransitionShaderResources() or specify COMMIT_SHADER_RESOURCES_FLAG_TRANSITION_RESOURCES flag in a call to CommitShaderResources()?" ); @@ -721,7 +721,7 @@ void DbgVerifyResourceState(ShaderResourceCacheD3D12::Resource &Res, case CachedResourceType::BufSRV: { VERIFY(RangeType == D3D12_DESCRIPTOR_RANGE_TYPE_SRV, "Unexpected descriptor range type"); - auto *pBuffViewD3D12 = ValidatedCast(Res.pObject.RawPtr()); + auto *pBuffViewD3D12 = Res.pObject.RawPtr(); auto *pBuffToTransition = ValidatedCast(pBuffViewD3D12->GetBuffer()); auto State = pBuffToTransition->GetState(); if( (State & D3D12_RESOURCE_STATE_SHADER_RESOURCE) != D3D12_RESOURCE_STATE_SHADER_RESOURCE ) @@ -732,7 +732,7 @@ void DbgVerifyResourceState(ShaderResourceCacheD3D12::Resource &Res, case CachedResourceType::BufUAV: { VERIFY(RangeType == D3D12_DESCRIPTOR_RANGE_TYPE_UAV, "Unexpected descriptor range type"); - auto *pBuffViewD3D12 = ValidatedCast(Res.pObject.RawPtr()); + auto *pBuffViewD3D12 = Res.pObject.RawPtr(); auto *pBuffToTransition = ValidatedCast(pBuffViewD3D12->GetBuffer()); auto State = pBuffToTransition->GetState(); if( (State & D3D12_RESOURCE_STATE_UNORDERED_ACCESS) != D3D12_RESOURCE_STATE_UNORDERED_ACCESS ) @@ -743,7 +743,7 @@ void DbgVerifyResourceState(ShaderResourceCacheD3D12::Resource &Res, case CachedResourceType::TexSRV: { VERIFY(RangeType == D3D12_DESCRIPTOR_RANGE_TYPE_SRV, "Unexpected descriptor range type"); - auto *pTexViewD3D12 = ValidatedCast(Res.pObject.RawPtr()); + auto *pTexViewD3D12 = Res.pObject.RawPtr(); auto *pTexToTransition = ValidatedCast(pTexViewD3D12->GetTexture()); auto State = pTexToTransition->GetState(); if( (State & D3D12_RESOURCE_STATE_SHADER_RESOURCE) != D3D12_RESOURCE_STATE_SHADER_RESOURCE ) @@ -754,7 +754,7 @@ void DbgVerifyResourceState(ShaderResourceCacheD3D12::Resource &Res, case CachedResourceType::TexUAV: { VERIFY(RangeType == D3D12_DESCRIPTOR_RANGE_TYPE_UAV, "Unexpected descriptor range type"); - auto *pTexViewD3D12 = ValidatedCast(Res.pObject.RawPtr()); + auto *pTexViewD3D12 = Res.pObject.RawPtr(); auto *pTexToTransition = ValidatedCast(pTexViewD3D12->GetTexture()); auto State = pTexToTransition->GetState(); if( (State & D3D12_RESOURCE_STATE_UNORDERED_ACCESS) != D3D12_RESOURCE_STATE_UNORDERED_ACCESS ) @@ -1018,7 +1018,7 @@ void RootSignature::CommitRootViews(ShaderResourceCacheD3D12& ResourceCache, #endif auto& Res = ResourceCache.GetRootTable(RootInd).GetResource(0, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, dbgShaderType); - auto *pBuffToTransition = ValidatedCast(Res.pObject.RawPtr()); + auto *pBuffToTransition = Res.pObject.RawPtr(); if( !pBuffToTransition->CheckAllStates(D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER) ) Ctx.TransitionResource(pBuffToTransition, D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER); diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp index 5fc8d9b5..c8476e4c 100644 --- a/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp @@ -734,7 +734,7 @@ bool ShaderResourceLayoutD3D12::SRV_CBV_UAV::IsBound(Uint32 ArrayIndex) auto &CachedRes = RootTable.GetResource(OffsetFromTableStart + ArrayIndex, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, m_ParentResLayout.m_pResources->GetShaderType()); if( CachedRes.pObject != nullptr ) { - VERIFY(CachedRes.CPUDescriptorHandle.ptr != 0 || ValidatedCast(CachedRes.pObject.RawPtr())->GetDesc().Usage == USAGE_DYNAMIC, "No relevant descriptor handle"); + VERIFY(CachedRes.CPUDescriptorHandle.ptr != 0 || CachedRes.pObject.RawPtr()->GetDesc().Usage == USAGE_DYNAMIC, "No relevant descriptor handle"); return true; } } @@ -948,7 +948,7 @@ void ShaderResourceLayoutD3D12::dbgVerifyBindings()const if( !CachedRes.pObject || // Dynamic buffers do not have CPU descriptor handle as they do not keep D3D12 buffer, and space is allocated from the GPU ring buffer - CachedRes.CPUDescriptorHandle.ptr == 0 && !(CachedRes.Type==CachedResourceType::CBV && ValidatedCast(CachedRes.pObject.RawPtr())->GetDesc().Usage == USAGE_DYNAMIC) ) + CachedRes.CPUDescriptorHandle.ptr == 0 && !(CachedRes.Type==CachedResourceType::CBV && CachedRes.pObject.RawPtr()->GetDesc().Usage == USAGE_DYNAMIC) ) LOG_ERROR_MESSAGE( "No resource is bound to ", GetShaderVariableTypeLiteralName(res.Attribs.GetVariableType()), " variable \"", res.Attribs.GetPrintName(ArrInd), "\" in shader \"", GetShaderName(), "\"" ); if (res.Attribs.BindCount > 1 && res.IsValidSampler()) @@ -958,7 +958,7 @@ void ShaderResourceLayoutD3D12::dbgVerifyBindings()const if(SamInfo.Attribs.BindCount == 1) { const auto &CachedSampler = m_pResourceCache->GetRootTable(SamInfo.RootIndex).GetResource(SamInfo.OffsetFromTableStart, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, m_pResources->GetShaderType()); - if( auto *pTexView = ValidatedCast(CachedRes.pObject.RawPtr()) ) + if( auto *pTexView = CachedRes.pObject.RawPtr() ) { auto *pSampler = const_cast(pTexView)->GetSampler(); if (pSampler != nullptr && CachedSampler.pObject != pSampler) diff --git a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp index 8e5beb12..7aba15b9 100644 --- a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp @@ -70,7 +70,7 @@ void SwapChainD3D12Impl::InitBuffersAndViews() BackBufferDesc.Name = Name.c_str(); RefCntAutoPtr pBackBufferTex; - ValidatedCast(m_pRenderDevice.RawPtr())->CreateTexture(BackBufferDesc, pBackBuffer, &pBackBufferTex); + m_pRenderDevice.RawPtr()->CreateTexture(BackBufferDesc, pBackBuffer, &pBackBufferTex); TextureViewDesc RTVDesc; RTVDesc.ViewType = TEXTURE_VIEW_RENDER_TARGET; RefCntAutoPtr pRTV; @@ -151,12 +151,12 @@ void SwapChainD3D12Impl::UpdateSwapChain(bool CreateNew) VERIFY(pDeviceContext, "Immediate context has been released"); if (pDeviceContext) { - RenderDeviceD3D12Impl *pDeviceD3D12 = ValidatedCast(m_pRenderDevice.RawPtr()); + RenderDeviceD3D12Impl *pDeviceD3D12 = m_pRenderDevice.RawPtr(); pDeviceContext->Flush(); try { - auto *pImmediateCtxD3D12 = ValidatedCast(pDeviceContext.RawPtr()); + auto *pImmediateCtxD3D12 = pDeviceContext.RawPtr(); bool bIsDefaultFBBound = pImmediateCtxD3D12->IsDefaultFBBound(); // All references to the swap chain must be released before it can be resized @@ -170,7 +170,7 @@ void SwapChainD3D12Impl::UpdateSwapChain(bool CreateNew) if(CreateNew) { m_pSwapChain.Release(); - auto *pd3d12CmdQueue = ValidatedCast(m_pRenderDevice.RawPtr())->GetCmdQueue()->GetD3D12CommandQueue(); + auto *pd3d12CmdQueue = m_pRenderDevice.RawPtr()->GetCmdQueue()->GetD3D12CommandQueue(); CreateDXGISwapChain(pd3d12CmdQueue); } else diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp index a771318d..41592b37 100644 --- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp @@ -286,7 +286,7 @@ namespace Diligent { if (m_IsDefaultFramebufferBound) { - auto *pSwapChainGL = ValidatedCast(m_pSwapChain.RawPtr()); + auto *pSwapChainGL = m_pSwapChain.RawPtr(); GLuint DefaultFBOHandle = pSwapChainGL->GetDefaultFBO(); if (m_DefaultFBO != DefaultFBOHandle) { @@ -310,7 +310,7 @@ namespace Diligent for (Uint32 rt = 0; rt < NumRenderTargets; ++rt) pBoundRTVs[rt] = m_pBoundRenderTargets[rt]; - auto *pRenderDeviceGL = ValidatedCast(m_pDevice.RawPtr()); + auto *pRenderDeviceGL = m_pDevice.RawPtr(); auto CurrentNativeGLContext = m_ContextState.GetCurrentGLContext(); auto &FBOCache = pRenderDeviceGL->GetFBOCache(CurrentNativeGLContext); const auto& FBO = FBOCache.GetFBO(NumRenderTargets, pBoundRTVs, m_pBoundDepthStencil, m_ContextState); @@ -331,13 +331,13 @@ namespace Diligent void DeviceContextGLImpl::BindProgramResources( Uint32 &NewMemoryBarriers, IShaderResourceBinding *pResBinding ) { - auto *pRenderDeviceGL = ValidatedCast(m_pDevice.RawPtr()); + auto *pRenderDeviceGL = m_pDevice.RawPtr(); if (!m_pPipelineState) { LOG_ERROR("No pipeline state is bound"); return; } - auto *pPipelineStateGL = ValidatedCast(m_pPipelineState.RawPtr()); + auto *pPipelineStateGL = m_pPipelineState.RawPtr(); auto *pShaderResBindingGL = ValidatedCast(pResBinding); const auto &DeviceCaps = pRenderDeviceGL->GetDeviceCaps(); @@ -390,7 +390,7 @@ namespace Diligent auto& Resource = it->pResources[ArrInd]; if (Resource) { - auto *pBufferOGL = ValidatedCast(Resource.RawPtr()); + auto *pBufferOGL = Resource.RawPtr(); pBufferOGL->BufferMemoryBarrier( GL_UNIFORM_BARRIER_BIT,// Shader uniforms sourced from buffer objects after the barrier // will reflect data written by shaders prior to the barrier @@ -432,7 +432,7 @@ namespace Diligent it->Type == GL_INT_SAMPLER_BUFFER || it->Type == GL_UNSIGNED_INT_SAMPLER_BUFFER ) { - auto *pBufViewOGL = ValidatedCast(Resource.RawPtr()); + auto *pBufViewOGL = Resource.RawPtr(); auto *pBuffer = pBufViewOGL->GetBuffer(); m_ContextState.BindTexture( TextureIndex, GL_TEXTURE_BUFFER, pBufViewOGL->GetTexBufferHandle() ); @@ -447,7 +447,7 @@ namespace Diligent } else { - auto *pTexViewOGL = ValidatedCast(Resource.RawPtr()); + auto *pTexViewOGL = Resource.RawPtr(); m_ContextState.BindTexture( TextureIndex, pTexViewOGL->GetBindTarget(), pTexViewOGL->GetHandle() ); auto *pTexture = pTexViewOGL->GetTexture(); @@ -507,7 +507,7 @@ namespace Diligent auto &Resource = it->pResources[ArrInd]; if( Resource ) { - auto *pTexViewOGL = ValidatedCast(Resource.RawPtr()); + auto *pTexViewOGL = Resource.RawPtr(); const auto &ViewDesc = pTexViewOGL->GetDesc(); if( ViewDesc.AccessFlags & UAV_ACCESS_FLAG_WRITE ) @@ -574,7 +574,7 @@ namespace Diligent auto &Resource = it->pResources[ArrInd]; if( Resource ) { - auto *pBufferViewOGL = ValidatedCast(Resource.RawPtr()); + auto *pBufferViewOGL = Resource.RawPtr(); const auto &ViewDesc = pBufferViewOGL->GetDesc(); VERIFY( ViewDesc.ViewType == BUFFER_VIEW_UNORDERED_ACCESS || ViewDesc.ViewType == BUFFER_VIEW_SHADER_RESOURCE, "Unexpceted buffer view type" ); @@ -661,7 +661,7 @@ namespace Diligent return; } - auto *pRenderDeviceGL = ValidatedCast(m_pDevice.RawPtr()); + auto *pRenderDeviceGL = m_pDevice.RawPtr(); auto CurrNativeGLContext = pRenderDeviceGL->m_GLContext.GetCurrentNativeGLContext(); const auto& PipelineDesc = m_pPipelineState->GetDesc().GraphicsPipeline; if(!m_bVAOIsUpToDate) @@ -983,7 +983,7 @@ namespace Diligent bool DeviceContextGLImpl::UpdateCurrentGLContext() { - auto *pRenderDeviceGL = ValidatedCast(m_pDevice.RawPtr()); + auto *pRenderDeviceGL = m_pDevice.RawPtr(); auto NativeGLContext = pRenderDeviceGL->m_GLContext.GetCurrentNativeGLContext(); if (NativeGLContext == NULL) return false; diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp index 12f40f1a..b62c1288 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp @@ -147,7 +147,7 @@ void RenderDeviceGLImpl :: CreateTexture(const TextureDesc& TexDesc, const Textu { auto spDeviceContext = GetImmediateContext(); VERIFY(spDeviceContext, "Immediate device context has been destroyed"); - auto pDeviceContext = ValidatedCast( spDeviceContext.RawPtr() ); + auto pDeviceContext = spDeviceContext.RawPtr(); const auto &FmtInfo = GetTextureFormatInfo( TexDesc.Format ); if( !FmtInfo.Supported ) { @@ -215,7 +215,7 @@ void RenderDeviceGLImpl::CreateTextureFromGLHandle(Uint32 GLHandle, const Textur { auto spDeviceContext = GetImmediateContext(); VERIFY(spDeviceContext, "Immediate device context has been destroyed"); - auto pDeviceContext = ValidatedCast( spDeviceContext.RawPtr() ); + auto pDeviceContext = spDeviceContext.RawPtr(); TextureBaseGL *pTextureOGL = nullptr; switch(TexDesc.Type) { @@ -514,7 +514,7 @@ void RenderDeviceGLImpl::TestTextureFormat( TEXTURE_FORMAT TexFormat ) auto spDeviceContext = GetImmediateContext(); VERIFY(spDeviceContext, "Immediate device context has been destroyed"); - auto *pContextGL = ValidatedCast( spDeviceContext.RawPtr() ); + auto *pContextGL = spDeviceContext.RawPtr(); auto &ContextState = pContextGL->GetContextState(); const int TestTextureDim = 32; diff --git a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp index bebaacb3..3456d7bf 100644 --- a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp @@ -72,7 +72,7 @@ IMPLEMENT_QUERY_INTERFACE( SwapChainGLImpl, IID_SwapChainGL, TSwapChainBase ) void SwapChainGLImpl::Present(Uint32 SyncInterval) { #if PLATFORM_WIN32 || PLATFORM_LINUX || PLATFORM_ANDROID - auto *pDeviceGL = ValidatedCast(m_pRenderDevice.RawPtr()); + auto *pDeviceGL = m_pRenderDevice.RawPtr(); auto &GLContext = pDeviceGL->m_GLContext; GLContext.SwapBuffers(); #elif PLATFORM_MACOS @@ -85,7 +85,7 @@ void SwapChainGLImpl::Present(Uint32 SyncInterval) void SwapChainGLImpl::Resize( Uint32 NewWidth, Uint32 NewHeight ) { #if PLATFORM_ANDROID - auto *pDeviceGL = ValidatedCast(m_pRenderDevice.RawPtr()); + auto *pDeviceGL = m_pRenderDevice.RawPtr(); auto &GLContext = pDeviceGL->m_GLContext; GLContext.UpdateScreenSize(); NewWidth = GLContext.GetScreenWidth(); @@ -98,7 +98,7 @@ void SwapChainGLImpl::Resize( Uint32 NewWidth, Uint32 NewHeight ) VERIFY( pDeviceContext, "Immediate context has been released" ); if( pDeviceContext ) { - auto *pImmediateCtxGL = ValidatedCast( pDeviceContext.RawPtr() ); + auto *pImmediateCtxGL = pDeviceContext.RawPtr(); bool bIsDefaultFBBound = pImmediateCtxGL->IsDefaultFBBound(); // To update the viewport is the only thing we need to do in OpenGL -- cgit v1.2.3