summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D11
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-04-17 16:20:09 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-04-17 16:20:09 +0000
commiteb129d6308eaca88131656fd58124355cb1b391a (patch)
tree5335bb16ba10f6aa26d436b6d47318fc5fde9f16 /Graphics/GraphicsEngineD3D11
parentImplementing device context in vulkan (diff)
downloadDiligentCore-eb129d6308eaca88131656fd58124355cb1b391a.tar.gz
DiligentCore-eb129d6308eaca88131656fd58124355cb1b391a.zip
Added template version of RawPtr function to allow more convenient type conversion
Diffstat (limited to 'Graphics/GraphicsEngineD3D11')
-rw-r--r--Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp17
-rw-r--r--Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp14
-rw-r--r--Graphics/GraphicsEngineD3D11/src/RenderDeviceFactoryD3D11.cpp2
-rw-r--r--Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp2
-rw-r--r--Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp2
-rw-r--r--Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp6
6 files changed, 22 insertions, 21 deletions
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<PipelineStateD3D11Impl>(m_pPipelineState.RawPtr())->GetD3D11DepthStencilState() : nullptr;
+ ID3D11DepthStencilState *pd3d11DSS =
+ m_pPipelineState ? m_pPipelineState.RawPtr<PipelineStateD3D11Impl>()->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<PipelineStateD3D11Impl>(m_pPipelineState.RawPtr())->GetD3D11BlendState();
+ pd3d11BS = m_pPipelineState.RawPtr<PipelineStateD3D11Impl>()->GetD3D11BlendState();
}
m_pd3d11DeviceContext->OMSetBlendState(pd3d11BS, m_BlendFactors, SampleMask);
}
@@ -576,7 +577,7 @@ namespace Diligent
return;
}
- BufferD3D11Impl *pBuffD3D11 = static_cast<BufferD3D11Impl *>(m_pIndexBuffer.RawPtr());
+ BufferD3D11Impl *pBuffD3D11 = m_pIndexBuffer.RawPtr<BufferD3D11Impl>();
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<BufferD3D11Impl>(CurrStream.pBuffer.RawPtr());
+ auto *pBuffD3D11Impl = CurrStream.pBuffer.RawPtr<BufferD3D11Impl>();
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<PipelineStateD3D11Impl>(m_pPipelineState.RawPtr());
+ auto *pPipelineStateD3D11 = m_pPipelineState.RawPtr<PipelineStateD3D11Impl>();
#ifdef _DEBUG
if (pPipelineStateD3D11->GetDesc().IsComputePipeline)
{
@@ -793,7 +794,7 @@ namespace Diligent
{
if (m_pSwapChain)
{
- pd3d11DSV = ValidatedCast<ISwapChainD3D11>(m_pSwapChain.RawPtr())->GetDSV();
+ pd3d11DSV = m_pSwapChain.RawPtr<ISwapChainD3D11>()->GetDSV();
VERIFY_EXPR(pd3d11DSV != nullptr);
}
else
@@ -826,7 +827,7 @@ namespace Diligent
{
if (m_pSwapChain)
{
- pd3d11RTV = ValidatedCast<ISwapChainD3D11>(m_pSwapChain.RawPtr())->GetRTV();
+ pd3d11RTV = m_pSwapChain.RawPtr<ISwapChainD3D11>()->GetRTV();
VERIFY_EXPR(pd3d11RTV != nullptr);
}
else
@@ -925,7 +926,7 @@ namespace Diligent
if (m_pSwapChain)
{
NumRenderTargets = 1;
- auto *pSwapChainD3D11 = ValidatedCast<ISwapChainD3D11>(m_pSwapChain.RawPtr());
+ auto *pSwapChainD3D11 = m_pSwapChain.RawPtr<ISwapChainD3D11>();
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<D3D11_INPUT_ELEMENT_DESC, STDAllocatorRawMem<D3D11_INPUT_ELEMENT_DESC> > d311InputElements(STD_ALLOCATOR_RAW_MEM(D3D11_INPUT_ELEMENT_DESC, GetRawAllocator(), "Allocator for vector<D3D11_INPUT_ELEMENT_DESC>") );
LayoutElements_To_D3D11_INPUT_ELEMENT_DESCs(m_LayoutElements, d311InputElements);
- ID3DBlob *pVSByteCode = ValidatedCast<ShaderD3D11Impl>(m_pVS.RawPtr())->GetBytecode();
+ ID3DBlob *pVSByteCode = m_pVS.RawPtr<ShaderD3D11Impl>()->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<ShaderD3D11Impl>(m_pVS.RawPtr());
+ auto *pVSD3D11 = m_pVS.RawPtr<ShaderD3D11Impl>();
return static_cast<ID3D11VertexShader*>(pVSD3D11->GetD3D11Shader());
}
ID3D11PixelShader* PipelineStateD3D11Impl::GetD3D11PixelShader()
{
if(!m_pPS)return nullptr;
- auto *pPSD3D11 = ValidatedCast<ShaderD3D11Impl>(m_pPS.RawPtr());
+ auto *pPSD3D11 = m_pPS.RawPtr<ShaderD3D11Impl>();
return static_cast<ID3D11PixelShader*>(pPSD3D11->GetD3D11Shader());
}
ID3D11GeometryShader* PipelineStateD3D11Impl::GetD3D11GeometryShader()
{
if(!m_pGS)return nullptr;
- auto *pGSD3D11 = ValidatedCast<ShaderD3D11Impl>(m_pGS.RawPtr());
+ auto *pGSD3D11 = m_pGS.RawPtr<ShaderD3D11Impl>();
return static_cast<ID3D11GeometryShader*>(pGSD3D11->GetD3D11Shader());
}
ID3D11DomainShader* PipelineStateD3D11Impl::GetD3D11DomainShader()
{
if(!m_pDS)return nullptr;
- auto *pDSD3D11 = ValidatedCast<ShaderD3D11Impl>(m_pDS.RawPtr());
+ auto *pDSD3D11 = m_pDS.RawPtr<ShaderD3D11Impl>();
return static_cast<ID3D11DomainShader*>(pDSD3D11->GetD3D11Shader());
}
ID3D11HullShader* PipelineStateD3D11Impl::GetD3D11HullShader()
{
if(!m_pHS)return nullptr;
- auto *pHSD3D11 = ValidatedCast<ShaderD3D11Impl>(m_pHS.RawPtr());
+ auto *pHSD3D11 = m_pHS.RawPtr<ShaderD3D11Impl>();
return static_cast<ID3D11HullShader*>(pHSD3D11->GetD3D11Shader());
}
ID3D11ComputeShader* PipelineStateD3D11Impl::GetD3D11ComputeShader()
{
if(!m_pCS)return nullptr;
- auto *pCSD3D11 = ValidatedCast<ShaderD3D11Impl>(m_pCS.RawPtr());
+ auto *pCSD3D11 = m_pCS.RawPtr<ShaderD3D11Impl>();
return static_cast<ID3D11ComputeShader*>(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<DeviceContextD3D11Impl>(pDeferredCtx.RawPtr());
+ auto *pDeferredCtxD3D11 = pDeferredCtx.RawPtr<DeviceContextD3D11Impl>();
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<ITextureView>(CachedResource.pView.RawPtr());
+ auto *pTexView = CachedResource.pView.RawPtr<ITextureView>();
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<Uint32>(pSamAttribs->BindPoint) + pSamAttribs->BindCount, NumCachedSamplers);
for(Uint32 BindPoint = pSamAttribs->BindPoint; BindPoint < EndBindPoint; ++BindPoint )
- ResourceCache.SetSampler(BindPoint, ValidatedCast<SamplerD3D11Impl>(StaticSampler.second.RawPtr()) );
+ ResourceCache.SetSampler(BindPoint, StaticSampler.second.RawPtr<SamplerD3D11Impl>() );
}
}
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<RenderDeviceD3D11Impl>(m_pRenderDevice.RawPtr())->GetD3D11Device();
+ auto *pDevice = m_pRenderDevice.RawPtr<RenderDeviceD3D11Impl>()->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<DeviceContextD3D11Impl>(pDeviceContext.RawPtr());
+ auto *pImmediateCtxD3D11 = pDeviceContext.RawPtr<DeviceContextD3D11Impl>();
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<RenderDeviceD3D11Impl>(m_pRenderDevice.RawPtr())->GetD3D11Device();
+ auto *pd3d11Device = m_pRenderDevice.RawPtr<RenderDeviceD3D11Impl>()->GetD3D11Device();
CreateDXGISwapChain(pd3d11Device);
}
else