diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-02-09 01:28:02 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-02-09 01:28:02 +0000 |
| commit | 26a81f5d5aef3e8d367c7e91870becce7c21e1f9 (patch) | |
| tree | 47a80be0a9f5d26ac632785825aa0b6dc524a6a6 /Graphics/GraphicsEngineD3D11 | |
| parent | Defined constructos to fix build errors on Apple's clang (diff) | |
| download | DiligentCore-26a81f5d5aef3e8d367c7e91870becce7c21e1f9.tar.gz DiligentCore-26a81f5d5aef3e8d367c7e91870becce7c21e1f9.zip | |
Updated IRenderDevice::CreateTexture and IRenderDevice::CreateBuffer to take pointers to initial data rather than references
Diffstat (limited to 'Graphics/GraphicsEngineD3D11')
13 files changed, 46 insertions, 42 deletions
diff --git a/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.h index 042bd54d..8b39f607 100644 --- a/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.h @@ -47,7 +47,7 @@ public: FixedBlockMemoryAllocator& BuffViewObjMemAllocator, class RenderDeviceD3D11Impl* pDeviceD3D11, const BufferDesc& BuffDesc, - const BufferData& BuffData = BufferData()); + const BufferData* pBuffData = nullptr); BufferD3D11Impl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& BuffViewObjMemAllocator, diff --git a/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.h index 6f13f86e..95548464 100644 --- a/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.h @@ -47,11 +47,11 @@ public: Uint32 NumDeferredContexts ); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final; - virtual void CreateBuffer(const BufferDesc& BuffDesc, const BufferData& BuffData, IBuffer** ppBuffer)override final; + virtual void CreateBuffer(const BufferDesc& BuffDesc, const BufferData* pBuffData, IBuffer** ppBuffer)override final; virtual void CreateShader(const ShaderCreationAttribs& ShaderCreationAttribs, IShader** ppShader)override final; - virtual void CreateTexture(const TextureDesc& TexDesc, const TextureData& Data, ITexture** ppTexture)override final; + virtual void CreateTexture(const TextureDesc& TexDesc, const TextureData* pData, ITexture** ppTexture)override final; virtual void CreateSampler(const SamplerDesc& SamplerDesc, ISampler** ppSampler)override final; diff --git a/Graphics/GraphicsEngineD3D11/include/Texture1D_D3D11.h b/Graphics/GraphicsEngineD3D11/include/Texture1D_D3D11.h index 4deffaf3..c7dc79ce 100644 --- a/Graphics/GraphicsEngineD3D11/include/Texture1D_D3D11.h +++ b/Graphics/GraphicsEngineD3D11/include/Texture1D_D3D11.h @@ -39,7 +39,7 @@ public: FixedBlockMemoryAllocator& TexViewObjAllocator, class RenderDeviceD3D11Impl* pDeviceD3D11, const TextureDesc& TexDesc, - const TextureData& InitData = TextureData()); + const TextureData* pInitData = nullptr); Texture1D_D3D11(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& TexViewObjAllocator, diff --git a/Graphics/GraphicsEngineD3D11/include/Texture2D_D3D11.h b/Graphics/GraphicsEngineD3D11/include/Texture2D_D3D11.h index fcefb8f4..e9e50680 100644 --- a/Graphics/GraphicsEngineD3D11/include/Texture2D_D3D11.h +++ b/Graphics/GraphicsEngineD3D11/include/Texture2D_D3D11.h @@ -39,7 +39,7 @@ public: FixedBlockMemoryAllocator& TexViewObjAllocator, class RenderDeviceD3D11Impl* pDeviceD3D11, const TextureDesc& TexDesc, - const TextureData& InitData = TextureData()); + const TextureData* pInitData = nullptr); Texture2D_D3D11(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& TexViewObjAllocator, diff --git a/Graphics/GraphicsEngineD3D11/include/Texture3D_D3D11.h b/Graphics/GraphicsEngineD3D11/include/Texture3D_D3D11.h index 8add8341..0d95f42c 100644 --- a/Graphics/GraphicsEngineD3D11/include/Texture3D_D3D11.h +++ b/Graphics/GraphicsEngineD3D11/include/Texture3D_D3D11.h @@ -39,7 +39,7 @@ public: FixedBlockMemoryAllocator& TexViewObjAllocator, class RenderDeviceD3D11Impl* pDeviceD3D11, const TextureDesc& TexDesc, - const TextureData& InitData = TextureData()); + const TextureData* pInitData = nullptr); Texture3D_D3D11(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& TexViewObjAllocator, diff --git a/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h b/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h index 7b0a4b0e..56ef5bc3 100644 --- a/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h +++ b/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h @@ -48,7 +48,7 @@ public: FixedBlockMemoryAllocator& TexViewObjAllocator, class RenderDeviceD3D11Impl* pDeviceD3D11, const TextureDesc& TexDesc, - const TextureData& InitData = TextureData()); + const TextureData* pInitData = nullptr); ~TextureBaseD3D11(); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final; @@ -73,8 +73,9 @@ public: protected: void CreateViewInternal( const struct TextureViewDesc &ViewDesc, ITextureView **ppView, bool bIsDefaultView )override final; - void PrepareD3D11InitData(const TextureData &InitData, Uint32 NumSubresources, - std::vector<D3D11_SUBRESOURCE_DATA, STDAllocatorRawMem<D3D11_SUBRESOURCE_DATA> > &D3D11InitData); + void PrepareD3D11InitData(const TextureData* pInitData, + Uint32 NumSubresources, + std::vector<D3D11_SUBRESOURCE_DATA, STDAllocatorRawMem<D3D11_SUBRESOURCE_DATA> >& D3D11InitData); virtual void CreateSRV( TextureViewDesc& SRVDesc, ID3D11ShaderResourceView** ppD3D11SRV ) = 0; virtual void CreateRTV( TextureViewDesc& RTVDesc, ID3D11RenderTargetView** ppD3D11RTV ) = 0; diff --git a/Graphics/GraphicsEngineD3D11/src/BufferD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/BufferD3D11Impl.cpp index d5ba8ae3..5688e137 100644 --- a/Graphics/GraphicsEngineD3D11/src/BufferD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/BufferD3D11Impl.cpp @@ -39,12 +39,12 @@ BufferD3D11Impl :: BufferD3D11Impl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& BuffViewObjMemAllocator, RenderDeviceD3D11Impl* pRenderDeviceD3D11, const BufferDesc& BuffDesc, - const BufferData& BuffData /*= BufferData()*/) : + const BufferData* pBuffData /*= nullptr*/) : TBufferBase(pRefCounters, BuffViewObjMemAllocator, pRenderDeviceD3D11, BuffDesc, false) { #define LOG_BUFFER_ERROR_AND_THROW(...) LOG_ERROR_AND_THROW("Buffer \"", m_Desc.Name ? m_Desc.Name : "", "\": ", ##__VA_ARGS__); - if( m_Desc.Usage == USAGE_STATIC && BuffData.pData == nullptr ) + if( m_Desc.Usage == USAGE_STATIC && (pBuffData == nullptr || pBuffData->pData == nullptr)) LOG_BUFFER_ERROR_AND_THROW("Static buffer must be initialized with data at creation time"); if (m_Desc.BindFlags & BIND_UNIFORM_BUFFER) @@ -90,8 +90,8 @@ BufferD3D11Impl :: BufferD3D11Impl(IReferenceCounters* pRefCounters, D3D11BuffDesc.CPUAccessFlags = CPUAccessFlagsToD3D11CPUAccessFlags( m_Desc.CPUAccessFlags ); D3D11_SUBRESOURCE_DATA InitData; - InitData.pSysMem = BuffData.pData; - InitData.SysMemPitch = BuffData.DataSize; + InitData.pSysMem = pBuffData ? pBuffData->pData : nullptr; + InitData.SysMemPitch = pBuffData ? pBuffData->DataSize : 0; InitData.SysMemSlicePitch = 0; auto *pDeviceD3D11 = pRenderDeviceD3D11->GetD3D11Device(); diff --git a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp index f6b9087f..2d08f430 100644 --- a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp @@ -120,13 +120,13 @@ void RenderDeviceD3D11Impl :: CreateBufferFromD3DResource(ID3D11Buffer* pd3d11Bu ); } -void RenderDeviceD3D11Impl :: CreateBuffer(const BufferDesc& BuffDesc, const BufferData& BuffData, IBuffer** ppBuffer) +void RenderDeviceD3D11Impl :: CreateBuffer(const BufferDesc& BuffDesc, const BufferData* pBuffData, IBuffer** ppBuffer) { CreateDeviceObject("buffer", BuffDesc, ppBuffer, [&]() { BufferD3D11Impl* pBufferD3D11( NEW_RC_OBJ(m_BufObjAllocator, "BufferD3D11Impl instance", BufferD3D11Impl) - (m_BuffViewObjAllocator, this, BuffDesc, BuffData ) ); + (m_BuffViewObjAllocator, this, BuffDesc, pBuffData ) ); pBufferD3D11->QueryInterface( IID_Buffer, reinterpret_cast<IObject**>(ppBuffer) ); pBufferD3D11->CreateDefaultViews(); OnCreateDeviceObject( pBufferD3D11 ); @@ -206,7 +206,7 @@ void RenderDeviceD3D11Impl::CreateTextureFromD3DResource(ID3D11Texture3D* pd3d11 } -void RenderDeviceD3D11Impl :: CreateTexture(const TextureDesc& TexDesc, const TextureData& Data, ITexture** ppTexture) +void RenderDeviceD3D11Impl :: CreateTexture(const TextureDesc& TexDesc, const TextureData* pData, ITexture** ppTexture) { CreateDeviceObject( "texture", TexDesc, ppTexture, [&]() @@ -217,7 +217,7 @@ void RenderDeviceD3D11Impl :: CreateTexture(const TextureDesc& TexDesc, const Te case RESOURCE_DIM_TEX_1D: case RESOURCE_DIM_TEX_1D_ARRAY: pTextureD3D11 = NEW_RC_OBJ(m_TexObjAllocator, "Texture1D_D3D11 instance", Texture1D_D3D11) - (m_TexViewObjAllocator, this, TexDesc, Data ); + (m_TexViewObjAllocator, this, TexDesc, pData ); break; case RESOURCE_DIM_TEX_2D: @@ -225,12 +225,12 @@ void RenderDeviceD3D11Impl :: CreateTexture(const TextureDesc& TexDesc, const Te case RESOURCE_DIM_TEX_CUBE: case RESOURCE_DIM_TEX_CUBE_ARRAY: pTextureD3D11 = NEW_RC_OBJ(m_TexObjAllocator, "Texture2D_D3D11 instance", Texture2D_D3D11) - (m_TexViewObjAllocator, this, TexDesc, Data ); + (m_TexViewObjAllocator, this, TexDesc, pData ); break; case RESOURCE_DIM_TEX_3D: pTextureD3D11 = NEW_RC_OBJ(m_TexObjAllocator, "Texture3D_D3D11 instance", Texture3D_D3D11) - (m_TexViewObjAllocator, this, TexDesc, Data ); + (m_TexViewObjAllocator, this, TexDesc, pData ); break; default: LOG_ERROR_AND_THROW( "Unknown texture type. (Did you forget to initialize the Type member of TextureDesc structure?)" ); diff --git a/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp index 3ea67a04..1666a034 100644 --- a/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp @@ -87,7 +87,7 @@ void SwapChainD3D11Impl::CreateRTVandDSV() DepthBufferDesc.CPUAccessFlags = CPU_ACCESS_NONE; DepthBufferDesc.MiscFlags = MISC_TEXTURE_FLAG_NONE; RefCntAutoPtr<ITexture> ptex2DDepthBuffer; - m_pRenderDevice->CreateTexture(DepthBufferDesc, TextureData{}, &ptex2DDepthBuffer); + m_pRenderDevice->CreateTexture(DepthBufferDesc, nullptr, &ptex2DDepthBuffer); auto pDSV = ptex2DDepthBuffer->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL); m_pDepthStencilView = RefCntAutoPtr<ITextureViewD3D11>(pDSV, IID_TextureViewD3D11); } diff --git a/Graphics/GraphicsEngineD3D11/src/Texture1D_D3D11.cpp b/Graphics/GraphicsEngineD3D11/src/Texture1D_D3D11.cpp index 603b63e3..855a3b67 100644 --- a/Graphics/GraphicsEngineD3D11/src/Texture1D_D3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/Texture1D_D3D11.cpp @@ -33,8 +33,8 @@ Texture1D_D3D11 :: Texture1D_D3D11(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& TexViewObjAllocator, RenderDeviceD3D11Impl* pRenderDeviceD3D11, const TextureDesc& TexDesc, - const TextureData& InitData /*= TextureData()*/) : - TextureBaseD3D11(pRefCounters, TexViewObjAllocator, pRenderDeviceD3D11, TexDesc, InitData) + const TextureData* pInitData /*= nullptr*/) : + TextureBaseD3D11(pRefCounters, TexViewObjAllocator, pRenderDeviceD3D11, TexDesc, pInitData) { auto D3D11TexFormat = TexFormatToDXGI_Format(m_Desc.Format, m_Desc.BindFlags); auto D3D11BindFlags = BindFlagsToD3D11BindFlags(m_Desc.BindFlags); @@ -56,7 +56,7 @@ Texture1D_D3D11 :: Texture1D_D3D11(IReferenceCounters* pRefCounters, }; std::vector<D3D11_SUBRESOURCE_DATA, STDAllocatorRawMem<D3D11_SUBRESOURCE_DATA>> D3D11InitData( STD_ALLOCATOR_RAW_MEM(D3D11_SUBRESOURCE_DATA, GetRawAllocator(), "Allocator for vector<D3D11_SUBRESOURCE_DATA>") ); - PrepareD3D11InitData(InitData, Tex1DDesc.ArraySize * Tex1DDesc.MipLevels, D3D11InitData); + PrepareD3D11InitData(pInitData, Tex1DDesc.ArraySize * Tex1DDesc.MipLevels, D3D11InitData); ID3D11Texture1D *ptex1D = nullptr; HRESULT hr = pDeviceD3D11->CreateTexture1D(&Tex1DDesc, D3D11InitData.size() ? D3D11InitData.data() : nullptr, &ptex1D); @@ -120,7 +120,7 @@ Texture1D_D3D11 :: Texture1D_D3D11(IReferenceCounters* pRefCounters, RenderDeviceD3D11Impl* pDeviceD3D11, RESOURCE_STATE InitialState, ID3D11Texture1D* pd3d11Texture) : - TextureBaseD3D11(pRefCounters, TexViewObjAllocator, pDeviceD3D11, TexDescFromD3D11Texture1D{}(pd3d11Texture), TextureData{}) + TextureBaseD3D11(pRefCounters, TexViewObjAllocator, pDeviceD3D11, TexDescFromD3D11Texture1D{}(pd3d11Texture), nullptr) { m_pd3d11Texture = pd3d11Texture; SetState(InitialState); diff --git a/Graphics/GraphicsEngineD3D11/src/Texture2D_D3D11.cpp b/Graphics/GraphicsEngineD3D11/src/Texture2D_D3D11.cpp index f4c075e9..c1d61bb0 100644 --- a/Graphics/GraphicsEngineD3D11/src/Texture2D_D3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/Texture2D_D3D11.cpp @@ -33,8 +33,8 @@ Texture2D_D3D11 :: Texture2D_D3D11(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& TexViewObjAllocator, RenderDeviceD3D11Impl* pRenderDeviceD3D11, const TextureDesc& TexDesc, - const TextureData& InitData /*= TextureData()*/) : - TextureBaseD3D11(pRefCounters, TexViewObjAllocator, pRenderDeviceD3D11, TexDesc, InitData) + const TextureData* pInitData /*= nullptr*/) : + TextureBaseD3D11(pRefCounters, TexViewObjAllocator, pRenderDeviceD3D11, TexDesc, pInitData) { auto D3D11TexFormat = TexFormatToDXGI_Format(m_Desc.Format, m_Desc.BindFlags); auto D3D11BindFlags = BindFlagsToD3D11BindFlags(m_Desc.BindFlags); @@ -64,7 +64,7 @@ Texture2D_D3D11 :: Texture2D_D3D11(IReferenceCounters* pRefCounters, }; std::vector<D3D11_SUBRESOURCE_DATA, STDAllocatorRawMem<D3D11_SUBRESOURCE_DATA>> D3D11InitData( STD_ALLOCATOR_RAW_MEM(D3D11_SUBRESOURCE_DATA, GetRawAllocator(), "Allocator for vector<D3D11_SUBRESOURCE_DATA>") ); - PrepareD3D11InitData(InitData, Tex2DDesc.ArraySize * Tex2DDesc.MipLevels, D3D11InitData); + PrepareD3D11InitData(pInitData, Tex2DDesc.ArraySize * Tex2DDesc.MipLevels, D3D11InitData); ID3D11Texture2D *ptex2D = nullptr; HRESULT hr = pDeviceD3D11->CreateTexture2D(&Tex2DDesc, D3D11InitData.size() ? D3D11InitData.data() : nullptr, &ptex2D); @@ -127,7 +127,7 @@ Texture2D_D3D11 :: Texture2D_D3D11(IReferenceCounters* pRefCounters, RenderDeviceD3D11Impl* pDeviceD3D11, RESOURCE_STATE InitialState, ID3D11Texture2D* pd3d11Texture) : - TextureBaseD3D11(pRefCounters, TexViewObjAllocator, pDeviceD3D11, TexDescFromD3D11Texture2D{}(pd3d11Texture), TextureData{}) + TextureBaseD3D11(pRefCounters, TexViewObjAllocator, pDeviceD3D11, TexDescFromD3D11Texture2D{}(pd3d11Texture), nullptr) { m_pd3d11Texture = pd3d11Texture; SetState(InitialState); diff --git a/Graphics/GraphicsEngineD3D11/src/Texture3D_D3D11.cpp b/Graphics/GraphicsEngineD3D11/src/Texture3D_D3D11.cpp index 12731883..9635ac3c 100644 --- a/Graphics/GraphicsEngineD3D11/src/Texture3D_D3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/Texture3D_D3D11.cpp @@ -33,8 +33,8 @@ Texture3D_D3D11 :: Texture3D_D3D11(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& TexViewObjAllocator, RenderDeviceD3D11Impl* pRenderDeviceD3D11, const TextureDesc& TexDesc, - const TextureData& InitData /*= TextureData()*/) : - TextureBaseD3D11(pRefCounters, TexViewObjAllocator, pRenderDeviceD3D11, TexDesc, InitData) + const TextureData* pInitData /*= nullptr*/) : + TextureBaseD3D11(pRefCounters, TexViewObjAllocator, pRenderDeviceD3D11, TexDesc, pInitData) { auto D3D11TexFormat = TexFormatToDXGI_Format(m_Desc.Format, m_Desc.BindFlags); auto D3D11BindFlags = BindFlagsToD3D11BindFlags(m_Desc.BindFlags); @@ -57,7 +57,7 @@ Texture3D_D3D11 :: Texture3D_D3D11(IReferenceCounters* pRefCounters, }; std::vector<D3D11_SUBRESOURCE_DATA, STDAllocatorRawMem<D3D11_SUBRESOURCE_DATA>> D3D11InitData( STD_ALLOCATOR_RAW_MEM(D3D11_SUBRESOURCE_DATA, GetRawAllocator(), "Allocator for vector<D3D11_SUBRESOURCE_DATA>") ); - PrepareD3D11InitData(InitData, Tex3DDesc.MipLevels, D3D11InitData); + PrepareD3D11InitData(pInitData, Tex3DDesc.MipLevels, D3D11InitData); ID3D11Texture3D *ptex3D = nullptr; HRESULT hr = pDeviceD3D11->CreateTexture3D(&Tex3DDesc, D3D11InitData.size() ? D3D11InitData.data() : nullptr, &ptex3D); @@ -119,7 +119,7 @@ Texture3D_D3D11 :: Texture3D_D3D11(IReferenceCounters* pRefCounters, RenderDeviceD3D11Impl* pDeviceD3D11, RESOURCE_STATE InitialState, ID3D11Texture3D* pd3d11Texture) : - TextureBaseD3D11(pRefCounters, TexViewObjAllocator, pDeviceD3D11, TexDescFromD3D11Texture3D{}(pd3d11Texture), TextureData{}) + TextureBaseD3D11(pRefCounters, TexViewObjAllocator, pDeviceD3D11, TexDescFromD3D11Texture3D{}(pd3d11Texture), nullptr) { m_pd3d11Texture = pd3d11Texture; SetState(InitialState); diff --git a/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp index 2dfdba75..48c82c4b 100644 --- a/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp @@ -36,23 +36,23 @@ TextureBaseD3D11 :: TextureBaseD3D11(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& TexViewObjAllocator, RenderDeviceD3D11Impl* pRenderDeviceD3D11, const TextureDesc& TexDesc, - const TextureData& InitData /*= TextureData()*/) : + const TextureData* pInitData /*= nullptr*/) : TTextureBase(pRefCounters, TexViewObjAllocator, pRenderDeviceD3D11, TexDesc) { - if( TexDesc.Usage == USAGE_STATIC && InitData.pSubResources == nullptr ) - LOG_ERROR_AND_THROW("Static Texture must be initialized with data at creation time"); + if( TexDesc.Usage == USAGE_STATIC && (pInitData == nullptr || pInitData->pSubResources == nullptr)) + LOG_ERROR_AND_THROW("Static textures must be initialized with data at creation time"); SetState(RESOURCE_STATE_UNDEFINED); } IMPLEMENT_QUERY_INTERFACE( TextureBaseD3D11, IID_TextureD3D11, TTextureBase ) -void TextureBaseD3D11::CreateViewInternal( const struct TextureViewDesc &ViewDesc, ITextureView **ppView, bool bIsDefaultView ) +void TextureBaseD3D11::CreateViewInternal( const struct TextureViewDesc& ViewDesc, ITextureView** ppView, bool bIsDefaultView ) { VERIFY( ppView != nullptr, "View pointer address is null" ); if( !ppView )return; VERIFY(* ppView == nullptr, "Overwriting reference to existing object may cause memory leaks" ); - * ppView = nullptr; + *ppView = nullptr; try { @@ -121,24 +121,27 @@ void TextureBaseD3D11::CreateViewInternal( const struct TextureViewDesc &ViewDes } } -void TextureBaseD3D11 :: PrepareD3D11InitData(const TextureData& InitData, Uint32 NumSubresources, - std::vector<D3D11_SUBRESOURCE_DATA, STDAllocatorRawMem<D3D11_SUBRESOURCE_DATA> > &D3D11InitData) +void TextureBaseD3D11 :: PrepareD3D11InitData(const TextureData* pInitData, + Uint32 NumSubresources, + std::vector<D3D11_SUBRESOURCE_DATA, STDAllocatorRawMem<D3D11_SUBRESOURCE_DATA> > & D3D11InitData) { - if( InitData.pSubResources ) + if (pInitData != nullptr && pInitData->pSubResources != nullptr) { - if( NumSubresources == InitData.NumSubresources ) + if( NumSubresources == pInitData->NumSubresources ) { D3D11InitData.resize(NumSubresources); for(UINT Subres=0; Subres < NumSubresources; ++Subres) { - auto &CurrSubres = InitData.pSubResources[Subres]; + auto &CurrSubres = pInitData->pSubResources[Subres]; D3D11InitData[Subres].pSysMem = CurrSubres.pData; D3D11InitData[Subres].SysMemPitch = CurrSubres.Stride; D3D11InitData[Subres].SysMemSlicePitch = CurrSubres.DepthStride; } } else + { UNEXPECTED( "Incorrect number of subrsources" ); + } } } |
