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 | |
| 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')
57 files changed, 502 insertions, 449 deletions
diff --git a/Graphics/GraphicsEngine/interface/BlendState.h b/Graphics/GraphicsEngine/interface/BlendState.h index 8ef91ddf..2853e022 100644 --- a/Graphics/GraphicsEngine/interface/BlendState.h +++ b/Graphics/GraphicsEngine/interface/BlendState.h @@ -378,9 +378,9 @@ struct BlendStateDesc BlendStateDesc()noexcept{} - BlendStateDesc(Bool _AlphaToCoverageEnable, - Bool _IndependentBlendEnable, - const RenderTargetBlendDesc& RT0 = RenderTargetBlendDesc{})noexcept : + BlendStateDesc(Bool _AlphaToCoverageEnable, + Bool _IndependentBlendEnable, + const RenderTargetBlendDesc& RT0 = RenderTargetBlendDesc{})noexcept : AlphaToCoverageEnable (_AlphaToCoverageEnable), IndependentBlendEnable (_IndependentBlendEnable), RenderTargets {RT0} diff --git a/Graphics/GraphicsEngine/interface/RenderDevice.h b/Graphics/GraphicsEngine/interface/RenderDevice.h index 4a4bf8e1..c844df8a 100644 --- a/Graphics/GraphicsEngine/interface/RenderDevice.h +++ b/Graphics/GraphicsEngine/interface/RenderDevice.h @@ -62,10 +62,9 @@ public: /// Creates a new buffer object /// \param [in] BuffDesc - Buffer description, see Diligent::BufferDesc for details. - /// \param [in] BuffData - Reference to a Diligent::BufferData structure that describes - /// the initialization data. To allocate space only, provide default value - /// BufferData(). Static buffers (USAGE_STATIC) must be initialized - /// at creation time. + /// \param [in] pBuffData - Pointer to Diligent::BufferData structure that describes + /// initial buffer data or nullptr if no data is provided. + /// Static buffers (USAGE_STATIC) must be initialized at creation time. /// \param [out] ppBuffer - Address of the memory location where the pointer to the /// buffer interface will be stored. The function calls AddRef(), /// so that the new buffer will contain one refernce and must be @@ -76,7 +75,7 @@ public: /// Stride of a formatted buffer will be computed automatically from the format if /// ElementByteStride member of buffer description is set to default value (0). virtual void CreateBuffer(const BufferDesc& BuffDesc, - const BufferData& BuffData, + const BufferData* pBuffData, IBuffer** ppBuffer) = 0; /// Creates a new shader object @@ -93,10 +92,10 @@ public: /// Creates a new texture object /// \param [in] TexDesc - Texture description, see Diligent::TextureDesc for details. - /// \param [in] Data - Reference to a Diligent::TextureData structure that describes - /// the initialization data. To allocate space only, provide default value - /// TextureData(). Static textures (USAGE_STATIC) must be initialized - /// at creation time. + /// \param [in] pData - Pointer to Diligent::TextureData structure that describes + /// initial texture data or nullptr if no data is provided. + /// Static textures (USAGE_STATIC) must be initialized at creation time. + /// /// \param [out] ppTexture - Address of the memory location where the pointer to the /// texture interface will be stored. /// The function calls AddRef(), so that the new object will contain @@ -113,7 +112,7 @@ public: /// For a 15 x 6 x 4 3D texture, the following array of subresources should be provided:\n /// 15x6x4, 7x3x2, 3x1x1, 1x1x1 virtual void CreateTexture(const TextureDesc& TexDesc, - const TextureData& Data, + const TextureData* pData, ITexture** ppTexture) = 0; /// Creates a new sampler object 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" ); + } } } diff --git a/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h index 3caff1e2..708a65ea 100644 --- a/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h @@ -49,7 +49,7 @@ public: FixedBlockMemoryAllocator& BuffViewObjMemAllocator, class RenderDeviceD3D12Impl* pDeviceD3D12, const BufferDesc& BuffDesc, - const BufferData& BuffData = BufferData()); + const BufferData* pBuffData = nullptr); BufferD3D12Impl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& BuffViewObjMemAllocator, class RenderDeviceD3D12Impl* pDeviceD3D12, diff --git a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h index fca1d58c..3fe6b9f3 100644 --- a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h @@ -57,13 +57,13 @@ public: virtual void CreatePipelineState( const PipelineStateDesc &PipelineDesc, IPipelineState **ppPipelineState )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 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; - void CreateTexture(const TextureDesc& TexDesc, ID3D12Resource *pd3d12Texture, RESOURCE_STATE InitialState, class TextureD3D12Impl **ppTexture); + void CreateTexture(const TextureDesc& TexDesc, ID3D12Resource* pd3d12Texture, RESOURCE_STATE InitialState, class TextureD3D12Impl **ppTexture); virtual void CreateSampler(const SamplerDesc& SamplerDesc, ISampler **ppSampler)override final; @@ -71,9 +71,9 @@ public: virtual ID3D12Device* GetD3D12Device()override final{return m_pd3d12Device;} - virtual void CreateTextureFromD3DResource(ID3D12Resource *pd3d12Texture, RESOURCE_STATE InitialState, ITexture **ppTexture)override final; + virtual void CreateTextureFromD3DResource(ID3D12Resource* pd3d12Texture, RESOURCE_STATE InitialState, ITexture** ppTexture)override final; - virtual void CreateBufferFromD3DResource(ID3D12Resource *pd3d12Buffer, const BufferDesc& BuffDesc, RESOURCE_STATE InitialState, IBuffer **ppBuffer)override final; + virtual void CreateBufferFromD3DResource(ID3D12Resource* pd3d12Buffer, const BufferDesc& BuffDesc, RESOURCE_STATE InitialState, IBuffer **ppBuffer)override final; DescriptorHeapAllocation AllocateDescriptor( D3D12_DESCRIPTOR_HEAP_TYPE Type, UINT Count = 1 ); DescriptorHeapAllocation AllocateGPUDescriptors( D3D12_DESCRIPTOR_HEAP_TYPE Type, UINT Count = 1 ); diff --git a/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h index ad50ab68..b205f843 100644 --- a/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h @@ -50,7 +50,7 @@ public: FixedBlockMemoryAllocator& TexViewObjAllocator, RenderDeviceD3D12Impl* pDeviceD3D12, const TextureDesc& TexDesc, - const TextureData& InitData = TextureData()); + const TextureData* pInitData = nullptr); // Attaches to an existing D3D12 resource TextureD3D12Impl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& TexViewObjAllocator, diff --git a/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp index 6eb2baeb..eaf96a64 100644 --- a/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp @@ -39,7 +39,7 @@ BufferD3D12Impl :: BufferD3D12Impl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& BuffViewObjMemAllocator, RenderDeviceD3D12Impl* pRenderDeviceD3D12, const BufferDesc& BuffDesc, - const BufferData& BuffData /*= BufferData()*/) : + const BufferData* pBuffData /*= nullptr*/) : TBufferBase { pRefCounters, @@ -57,10 +57,10 @@ BufferD3D12Impl :: BufferD3D12Impl(IReferenceCounters* pRefCounters, { #define LOG_BUFFER_ERROR_AND_THROW(...) LOG_ERROR_AND_THROW("Buffer \"", BuffDesc.Name ? BuffDesc.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.Usage == USAGE_DYNAMIC && BuffData.pData != nullptr ) + if( m_Desc.Usage == USAGE_DYNAMIC && pBuffData != nullptr && pBuffData->pData != nullptr ) LOG_BUFFER_ERROR_AND_THROW("Dynamic buffer must be initialized via Map()") Uint32 AlignmentMask = 1; @@ -74,7 +74,7 @@ BufferD3D12Impl :: BufferD3D12Impl(IReferenceCounters* pRefCounters, if (m_Desc.CPUAccessFlags == CPU_ACCESS_WRITE) { - if(BuffData.pData != nullptr ) + if (pBuffData != nullptr && pBuffData->pData != nullptr) LOG_BUFFER_ERROR_AND_THROW("CPU-writable staging buffers must be updated via map") AlignmentMask = D3D12_TEXTURE_DATA_PITCH_ALIGNMENT - 1; @@ -131,7 +131,7 @@ BufferD3D12Impl :: BufferD3D12Impl(IReferenceCounters* pRefCounters, HeapProps.CreationNodeMask = 1; HeapProps.VisibleNodeMask = 1; - bool bInitializeBuffer = (BuffData.pData != nullptr && BuffData.DataSize > 0); + bool bInitializeBuffer = (pBuffData != nullptr && pBuffData->pData != nullptr && pBuffData->DataSize > 0); if(bInitializeBuffer) SetState(RESOURCE_STATE_COPY_DEST); @@ -168,7 +168,7 @@ BufferD3D12Impl :: BufferD3D12Impl(IReferenceCounters* pRefCounters, hr = UploadBuffer->Map(0, nullptr, &DestAddress); if(FAILED(hr)) LOG_ERROR_AND_THROW("Failed to map uload buffer"); - memcpy(DestAddress, BuffData.pData, BuffData.DataSize); + memcpy(DestAddress, pBuffData->pData, pBuffData->DataSize); UploadBuffer->Unmap(0, nullptr); auto InitContext = pRenderDeviceD3D12->AllocateCommandContext(); diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp index b14e13b2..3d73cbdb 100644 --- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp @@ -303,12 +303,12 @@ void RenderDeviceD3D12Impl :: CreateBufferFromD3DResource(ID3D12Resource* pd3d12 ); } -void RenderDeviceD3D12Impl :: CreateBuffer(const BufferDesc& BuffDesc, const BufferData& BuffData, IBuffer** ppBuffer) +void RenderDeviceD3D12Impl :: CreateBuffer(const BufferDesc& BuffDesc, const BufferData* pBuffData, IBuffer** ppBuffer) { CreateDeviceObject("buffer", BuffDesc, ppBuffer, [&]() { - BufferD3D12Impl *pBufferD3D12( NEW_RC_OBJ(m_BufObjAllocator, "BufferD3D12Impl instance", BufferD3D12Impl)(m_BuffViewObjAllocator, this, BuffDesc, BuffData ) ); + BufferD3D12Impl *pBufferD3D12( NEW_RC_OBJ(m_BufObjAllocator, "BufferD3D12Impl instance", BufferD3D12Impl)(m_BuffViewObjAllocator, this, BuffDesc, pBuffData ) ); pBufferD3D12->QueryInterface( IID_Buffer, reinterpret_cast<IObject**>(ppBuffer) ); pBufferD3D12->CreateDefaultViews(); OnCreateDeviceObject( pBufferD3D12 ); @@ -351,18 +351,18 @@ void RenderDeviceD3D12Impl::CreateTexture(const TextureDesc& TexDesc, ID3D12Reso CreateDeviceObject( "texture", TexDesc, ppTexture, [&]() { - TextureD3D12Impl *pTextureD3D12 = NEW_RC_OBJ(m_TexObjAllocator, "TextureD3D12Impl instance", TextureD3D12Impl)(m_TexViewObjAllocator, this, TexDesc, InitialState, pd3d12Texture); + TextureD3D12Impl* pTextureD3D12 = NEW_RC_OBJ(m_TexObjAllocator, "TextureD3D12Impl instance", TextureD3D12Impl)(m_TexViewObjAllocator, this, TexDesc, InitialState, pd3d12Texture); pTextureD3D12->QueryInterface( IID_TextureD3D12, reinterpret_cast<IObject**>(ppTexture) ); } ); } -void RenderDeviceD3D12Impl :: CreateTexture(const TextureDesc& TexDesc, const TextureData& Data, ITexture** ppTexture) +void RenderDeviceD3D12Impl :: CreateTexture(const TextureDesc& TexDesc, const TextureData* pData, ITexture** ppTexture) { CreateDeviceObject( "texture", TexDesc, ppTexture, [&]() { - TextureD3D12Impl *pTextureD3D12 = NEW_RC_OBJ(m_TexObjAllocator, "TextureD3D12Impl instance", TextureD3D12Impl)(m_TexViewObjAllocator, this, TexDesc, Data ); + TextureD3D12Impl* pTextureD3D12 = NEW_RC_OBJ(m_TexObjAllocator, "TextureD3D12Impl instance", TextureD3D12Impl)(m_TexViewObjAllocator, this, TexDesc, pData ); pTextureD3D12->QueryInterface( IID_Texture, reinterpret_cast<IObject**>(ppTexture) ); pTextureD3D12->CreateDefaultViews(); diff --git a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp index aa61a2f0..c9e986b4 100644 --- a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp @@ -96,7 +96,7 @@ void SwapChainD3D12Impl::InitBuffersAndViews() DepthBufferDesc.ClearValue.DepthStencil.Stencil = m_SwapChainDesc.DefaultStencilValue; DepthBufferDesc.Name = "Main depth buffer"; RefCntAutoPtr<ITexture> pDepthBufferTex; - m_pRenderDevice->CreateTexture(DepthBufferDesc, TextureData(), static_cast<ITexture**>(&pDepthBufferTex) ); + m_pRenderDevice->CreateTexture(DepthBufferDesc, nullptr, static_cast<ITexture**>(&pDepthBufferTex) ); auto pDSV = pDepthBufferTex->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL); m_pDepthBufferDSV = RefCntAutoPtr<ITextureViewD3D12>(pDSV, IID_TextureViewD3D12); } diff --git a/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp index 020a8830..736189f5 100644 --- a/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp @@ -75,11 +75,11 @@ TextureD3D12Impl :: TextureD3D12Impl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& TexViewObjAllocator, RenderDeviceD3D12Impl* pRenderDeviceD3D12, const TextureDesc& TexDesc, - const TextureData& InitData /*= TextureData()*/) : + const TextureData* pInitData /*= nullptr*/) : TTextureBase(pRefCounters, TexViewObjAllocator, pRenderDeviceD3D12, TexDesc) { - if( m_Desc.Usage == USAGE_STATIC && InitData.pSubResources == nullptr ) - LOG_ERROR_AND_THROW("Static Texture must be initialized with data at creation time"); + if( m_Desc.Usage == USAGE_STATIC && (pInitData == nullptr || pInitData->pSubResources == nullptr)) + LOG_ERROR_AND_THROW("Static textures must be initialized with data at creation time"); D3D12_RESOURCE_DESC Desc = {}; Desc.Alignment = 0; @@ -155,7 +155,7 @@ TextureD3D12Impl :: TextureD3D12Impl(IReferenceCounters* pRefCounters, pClearValue = &ClearValue; } - bool bInitializeTexture = (InitData.pSubResources != nullptr && InitData.NumSubresources > 0); + bool bInitializeTexture = (pInitData != nullptr && pInitData->pSubResources != nullptr && pInitData->NumSubresources > 0); auto InitialState = bInitializeTexture ? RESOURCE_STATE_COPY_DEST : RESOURCE_STATE_UNDEFINED; SetState(InitialState); auto D3D12State = ResourceStateFlagsToD3D12ResourceStates(InitialState); @@ -170,10 +170,10 @@ TextureD3D12Impl :: TextureD3D12Impl(IReferenceCounters* pRefCounters, if(bInitializeTexture) { Uint32 ExpectedNumSubresources = static_cast<Uint32>(Desc.MipLevels * (Desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? 1 : Desc.DepthOrArraySize) ); - if( InitData.NumSubresources != ExpectedNumSubresources ) - LOG_ERROR_AND_THROW("Incorrect number of subresources in init data. ", ExpectedNumSubresources, " expected, while ", InitData.NumSubresources, " provided"); + if( pInitData->NumSubresources != ExpectedNumSubresources ) + LOG_ERROR_AND_THROW("Incorrect number of subresources in init data. ", ExpectedNumSubresources, " expected, while ", pInitData->NumSubresources, " provided"); - UINT64 uploadBufferSize = GetRequiredIntermediateSize(m_pd3d12Resource, 0, InitData.NumSubresources); + UINT64 uploadBufferSize = GetRequiredIntermediateSize(m_pd3d12Resource, 0, pInitData->NumSubresources); D3D12_HEAP_PROPERTIES UploadHeapProps; UploadHeapProps.Type = D3D12_HEAP_TYPE_UPLOAD; @@ -205,14 +205,14 @@ TextureD3D12Impl :: TextureD3D12Impl(IReferenceCounters* pRefCounters, auto InitContext = pRenderDeviceD3D12->AllocateCommandContext(); // copy data to the intermediate upload heap and then schedule a copy from the upload heap to the default texture VERIFY_EXPR(CheckState(RESOURCE_STATE_COPY_DEST)); - std::vector<D3D12_SUBRESOURCE_DATA, STDAllocatorRawMem<D3D12_SUBRESOURCE_DATA> > D3D12SubResData(InitData.NumSubresources, D3D12_SUBRESOURCE_DATA(), STD_ALLOCATOR_RAW_MEM(D3D12_SUBRESOURCE_DATA, GetRawAllocator(), "Allocator for vector<D3D12_SUBRESOURCE_DATA>") ); + std::vector<D3D12_SUBRESOURCE_DATA, STDAllocatorRawMem<D3D12_SUBRESOURCE_DATA> > D3D12SubResData(pInitData->NumSubresources, D3D12_SUBRESOURCE_DATA(), STD_ALLOCATOR_RAW_MEM(D3D12_SUBRESOURCE_DATA, GetRawAllocator(), "Allocator for vector<D3D12_SUBRESOURCE_DATA>") ); for(size_t subres=0; subres < D3D12SubResData.size(); ++subres) { - D3D12SubResData[subres].pData = InitData.pSubResources[subres].pData; - D3D12SubResData[subres].RowPitch = InitData.pSubResources[subres].Stride; - D3D12SubResData[subres].SlicePitch = InitData.pSubResources[subres].DepthStride; + D3D12SubResData[subres].pData = pInitData->pSubResources[subres].pData; + D3D12SubResData[subres].RowPitch = pInitData->pSubResources[subres].Stride; + D3D12SubResData[subres].SlicePitch = pInitData->pSubResources[subres].DepthStride; } - auto UploadedSize = UpdateSubresources(InitContext->GetCommandList(), m_pd3d12Resource, UploadBuffer, 0, 0, InitData.NumSubresources, D3D12SubResData.data()); + auto UploadedSize = UpdateSubresources(InitContext->GetCommandList(), m_pd3d12Resource, UploadBuffer, 0, 0, pInitData->NumSubresources, D3D12SubResData.data()); VERIFY(UploadedSize == uploadBufferSize, "Incorrect uploaded data size (", UploadedSize, "). ", uploadBufferSize, " is expected"); // Command list fence should only be signaled when submitting cmd list diff --git a/Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.h index 24f0e148..f96feb93 100644 --- a/Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.h +++ b/Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.h @@ -43,22 +43,22 @@ class BufferGLImpl final : public BufferBase<IBufferGL, RenderDeviceGLImpl, Buff public: using TBufferBase = BufferBase<IBufferGL, RenderDeviceGLImpl, BufferViewGLImpl, FixedBlockMemoryAllocator>; - BufferGLImpl(IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator &BuffViewObjMemAllocator, - RenderDeviceGLImpl *pDeviceGL, - const BufferDesc& BuffDesc, - const BufferData& BuffData, - bool bIsDeviceInternal); - BufferGLImpl(IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator &BuffViewObjMemAllocator, - class RenderDeviceGLImpl *pDeviceGL, - const BufferDesc& BuffDesc, - GLuint GLHandle, - bool bIsDeviceInternal); + BufferGLImpl(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& BuffViewObjMemAllocator, + RenderDeviceGLImpl* pDeviceGL, + const BufferDesc& BuffDesc, + const BufferData* pBuffData, + bool bIsDeviceInternal); + BufferGLImpl(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& BuffViewObjMemAllocator, + class RenderDeviceGLImpl* pDeviceGL, + const BufferDesc& BuffDesc, + GLuint GLHandle, + bool bIsDeviceInternal); ~BufferGLImpl(); /// Queries the specific interface, see IObject::QueryInterface() for details - virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override; + virtual void QueryInterface( const INTERFACE_ID& IID, IObject** ppInterface )override; void UpdateData(GLContextState& CtxState, Uint32 Offset, Uint32 Size, const PVoid pData); void CopyData(GLContextState& CtxState, BufferGLImpl& SrcBufferGL, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size); diff --git a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h index 567768be..b0b67c32 100644 --- a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h +++ b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h @@ -59,14 +59,14 @@ public: ~RenderDeviceGLImpl(); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override; - void CreateBuffer(const BufferDesc& BuffDesc, const BufferData &BuffData, IBuffer **ppBufferLayout, bool bIsDeviceInternal); - virtual void CreateBuffer(const BufferDesc& BuffDesc, const BufferData &BuffData, IBuffer **ppBufferLayout)override final; + void CreateBuffer(const BufferDesc& BuffDesc, const BufferData* pBuffData, IBuffer **ppBufferLayout, bool bIsDeviceInternal); + virtual void CreateBuffer(const BufferDesc& BuffDesc, const BufferData* BuffData, IBuffer **ppBufferLayout)override final; void CreateShader(const ShaderCreationAttribs &ShaderCreationAttribs, IShader **ppShader, bool bIsDeviceInternal ); virtual void CreateShader(const ShaderCreationAttribs &ShaderCreationAttribs, IShader **ppShader)override final; - void CreateTexture(const TextureDesc& TexDesc, const TextureData &Data, ITexture **ppTexture, bool bIsDeviceInternal); - virtual void CreateTexture(const TextureDesc& TexDesc, const TextureData &Data, ITexture **ppTexture)override final; + void CreateTexture(const TextureDesc& TexDesc, const TextureData* pData, ITexture **ppTexture, bool bIsDeviceInternal); + virtual void CreateTexture(const TextureDesc& TexDesc, const TextureData* Data, ITexture **ppTexture)override final; void CreateSampler(const SamplerDesc& SamplerDesc, ISampler **ppSampler, bool bIsDeviceInternal); virtual void CreateSampler(const SamplerDesc& SamplerDesc, ISampler **ppSampler)override final; diff --git a/Graphics/GraphicsEngineOpenGL/include/Texture1DArray_OGL.h b/Graphics/GraphicsEngineOpenGL/include/Texture1DArray_OGL.h index bddee490..1ee3576d 100644 --- a/Graphics/GraphicsEngineOpenGL/include/Texture1DArray_OGL.h +++ b/Graphics/GraphicsEngineOpenGL/include/Texture1DArray_OGL.h @@ -31,28 +31,31 @@ namespace Diligent class Texture1DArray_OGL final : public TextureBaseGL { public: - Texture1DArray_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceGLImpl *pDeviceGL, - class DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - const TextureData& InitData = TextureData(), - bool bIsDeviceInternal = false); - - Texture1DArray_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceGLImpl *pDeviceGL, - class DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - GLuint GLTextureHandle, - bool bIsDeviceInternal = false); + Texture1DArray_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceGLImpl* pDeviceGL, + class DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + const TextureData* pInitData = nullptr, + bool bIsDeviceInternal = false); + + Texture1DArray_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceGLImpl* pDeviceGL, + class DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + GLuint GLTextureHandle, + bool bIsDeviceInternal = false); ~Texture1DArray_OGL(); - virtual void UpdateData( class GLContextState &CtxState, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData )override final; - virtual void AttachToFramebuffer( const struct TextureViewDesc& ViewDesc, GLenum AttachmentPoint )override final; - -private: + virtual void UpdateData( class GLContextState& CtxState, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData )override final; + virtual void AttachToFramebuffer( const struct TextureViewDesc& ViewDesc, + GLenum AttachmentPoint )override final; }; } diff --git a/Graphics/GraphicsEngineOpenGL/include/Texture1D_OGL.h b/Graphics/GraphicsEngineOpenGL/include/Texture1D_OGL.h index 2b7b90e0..c273d8ef 100644 --- a/Graphics/GraphicsEngineOpenGL/include/Texture1D_OGL.h +++ b/Graphics/GraphicsEngineOpenGL/include/Texture1D_OGL.h @@ -31,28 +31,31 @@ namespace Diligent class Texture1D_OGL final : public TextureBaseGL { public: - Texture1D_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceGLImpl *pDeviceGL, - class DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - const TextureData& InitData = TextureData(), - bool bIsDeviceInternal = false); - - Texture1D_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceGLImpl *pDeviceGL, - class DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - GLuint GLTextureHandle, - bool bIsDeviceInternal = false); + Texture1D_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceGLImpl* pDeviceGL, + class DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + const TextureData* pInitData = nullptr, + bool bIsDeviceInternal = false); + + Texture1D_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceGLImpl* pDeviceGL, + class DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + GLuint GLTextureHandle, + bool bIsDeviceInternal = false); ~Texture1D_OGL(); - virtual void UpdateData( class GLContextState &CtxState, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData )override final; - virtual void AttachToFramebuffer( const struct TextureViewDesc& ViewDesc, GLenum AttachmentPoint )override final; - -private: + virtual void UpdateData( class GLContextState& CtxState, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData )override final; + virtual void AttachToFramebuffer( const struct TextureViewDesc& ViewDesc, + GLenum AttachmentPoint )override final; }; } diff --git a/Graphics/GraphicsEngineOpenGL/include/Texture2DArray_OGL.h b/Graphics/GraphicsEngineOpenGL/include/Texture2DArray_OGL.h index a59a5ae6..e49038fa 100644 --- a/Graphics/GraphicsEngineOpenGL/include/Texture2DArray_OGL.h +++ b/Graphics/GraphicsEngineOpenGL/include/Texture2DArray_OGL.h @@ -31,28 +31,31 @@ namespace Diligent class Texture2DArray_OGL final : public TextureBaseGL { public: - Texture2DArray_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceGLImpl *pDeviceGL, - class DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - const TextureData& InitData = TextureData(), - bool bIsDeviceInternal = false ); - - Texture2DArray_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceGLImpl *pDeviceGL, - class DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - GLuint GLTextureHandle, - bool bIsDeviceInternal = false); + Texture2DArray_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceGLImpl* pDeviceGL, + class DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + const TextureData* pInitData = nullptr, + bool bIsDeviceInternal = false ); + + Texture2DArray_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceGLImpl* pDeviceGL, + class DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + GLuint GLTextureHandle, + bool bIsDeviceInternal = false); ~Texture2DArray_OGL(); - virtual void UpdateData( class GLContextState &CtxState, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData )override final; - virtual void AttachToFramebuffer( const struct TextureViewDesc& ViewDesc, GLenum AttachmentPoint )override final; - -private: + virtual void UpdateData( class GLContextState& CtxState, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData )override final; + virtual void AttachToFramebuffer( const struct TextureViewDesc& ViewDesc, + GLenum AttachmentPoint )override final; }; } diff --git a/Graphics/GraphicsEngineOpenGL/include/Texture2D_OGL.h b/Graphics/GraphicsEngineOpenGL/include/Texture2D_OGL.h index cc300c19..28c00876 100644 --- a/Graphics/GraphicsEngineOpenGL/include/Texture2D_OGL.h +++ b/Graphics/GraphicsEngineOpenGL/include/Texture2D_OGL.h @@ -31,28 +31,31 @@ namespace Diligent class Texture2D_OGL final : public TextureBaseGL { public: - Texture2D_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceGLImpl *pDeviceGL, - class DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - const TextureData& InitData = TextureData(), - bool bIsDeviceInternal = false); - - Texture2D_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceGLImpl *pDeviceGL, - class DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - GLuint GLTextureHandle, - bool bIsDeviceInternal = false); + Texture2D_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceGLImpl* pDeviceGL, + class DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + const TextureData* pInitData = nullptr, + bool bIsDeviceInternal = false); + + Texture2D_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceGLImpl* pDeviceGL, + class DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + GLuint GLTextureHandle, + bool bIsDeviceInternal = false); ~Texture2D_OGL(); - virtual void UpdateData( class GLContextState &CtxState, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData )override final; - virtual void AttachToFramebuffer( const struct TextureViewDesc& ViewDesc, GLenum AttachmentPoint )override final; - -private: + virtual void UpdateData( class GLContextState& CtxState, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData )override final; + virtual void AttachToFramebuffer( const struct TextureViewDesc& ViewDesc, + GLenum AttachmentPoint )override final; }; } diff --git a/Graphics/GraphicsEngineOpenGL/include/Texture3D_OGL.h b/Graphics/GraphicsEngineOpenGL/include/Texture3D_OGL.h index 5075e3da..4760273d 100644 --- a/Graphics/GraphicsEngineOpenGL/include/Texture3D_OGL.h +++ b/Graphics/GraphicsEngineOpenGL/include/Texture3D_OGL.h @@ -31,28 +31,31 @@ namespace Diligent class Texture3D_OGL final : public TextureBaseGL { public: - Texture3D_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceGLImpl *pDeviceGL, - class DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - const TextureData& InitData = TextureData(), - bool bIsDeviceInternal = false ); - - Texture3D_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceGLImpl *pDeviceGL, - class DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - GLuint GLTextureHandle, - bool bIsDeviceInternal = false); + Texture3D_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceGLImpl* pDeviceGL, + class DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + const TextureData* pInitData = nullptr, + bool bIsDeviceInternal = false ); + + Texture3D_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceGLImpl* pDeviceGL, + class DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + GLuint GLTextureHandle, + bool bIsDeviceInternal = false); ~Texture3D_OGL(); - virtual void UpdateData(class GLContextState &CtxState, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData)override final; - virtual void AttachToFramebuffer( const struct TextureViewDesc& ViewDesc, GLenum AttachmentPoint )override final; - -private: + virtual void UpdateData(class GLContextState& CtxState, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData)override final; + virtual void AttachToFramebuffer( const struct TextureViewDesc& ViewDesc, + GLenum AttachmentPoint )override final; }; } diff --git a/Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.h b/Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.h index 43579036..fb21a406 100644 --- a/Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.h +++ b/Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.h @@ -44,26 +44,26 @@ public: using TTextureBase = TextureBase<ITextureGL, RenderDeviceGLImpl, TextureViewGLImpl, FixedBlockMemoryAllocator>; using ViewImplType = TextureViewGLImpl; - TextureBaseGL(IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - RenderDeviceGLImpl *pDeviceGL, - const TextureDesc &TexDesc, - GLenum BindTarget, - const TextureData &InitData = TextureData(), - bool bIsDeviceInternal = false); - - TextureBaseGL(IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceGLImpl *pDeviceGL, - class DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - GLuint GLTextureHandle, - GLenum BindTarget, - bool bIsDeviceInternal); + TextureBaseGL(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + RenderDeviceGLImpl* pDeviceGL, + const TextureDesc& TexDesc, + GLenum BindTarget, + const TextureData* pInitData = nullptr, + bool bIsDeviceInternal = false); + + TextureBaseGL(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceGLImpl* pDeviceGL, + class DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + GLuint GLTextureHandle, + GLenum BindTarget, + bool bIsDeviceInternal); ~TextureBaseGL(); - virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override; + virtual void QueryInterface( const INTERFACE_ID& IID, IObject** ppInterface )override; const GLObjectWrappers::GLTextureObj& GetGLHandle()const{ return m_GlTexture; } virtual GLenum GetBindTarget()const override final{return m_BindTarget;} @@ -73,16 +73,16 @@ public: virtual void AttachToFramebuffer(const struct TextureViewDesc& ViewDesc, GLenum AttachmentPoint) = 0; - void CopyData(DeviceContextGLImpl *pDeviceCtxGL, - TextureBaseGL *pSrcTextureGL, - Uint32 SrcMipLevel, - Uint32 SrcSlice, - const Box *pSrcBox, - Uint32 DstMipLevel, - Uint32 DstSlice, - Uint32 DstX, - Uint32 DstY, - Uint32 DstZ); + void CopyData(DeviceContextGLImpl* pDeviceCtxGL, + TextureBaseGL* pSrcTextureGL, + Uint32 SrcMipLevel, + Uint32 SrcSlice, + const Box* pSrcBox, + Uint32 DstMipLevel, + Uint32 DstSlice, + Uint32 DstX, + Uint32 DstY, + Uint32 DstZ); virtual GLuint GetGLTextureHandle()override final { return GetGLHandle(); } virtual void* GetNativeHandle()override final { return reinterpret_cast<void*>(static_cast<size_t>(GetGLTextureHandle())); } diff --git a/Graphics/GraphicsEngineOpenGL/include/TextureCubeArray_OGL.h b/Graphics/GraphicsEngineOpenGL/include/TextureCubeArray_OGL.h index da1803ff..779c6c80 100644 --- a/Graphics/GraphicsEngineOpenGL/include/TextureCubeArray_OGL.h +++ b/Graphics/GraphicsEngineOpenGL/include/TextureCubeArray_OGL.h @@ -31,28 +31,31 @@ namespace Diligent class TextureCubeArray_OGL final : public TextureBaseGL { public: - TextureCubeArray_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceGLImpl *pDeviceGL, - class DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - const TextureData& InitData = TextureData(), - bool bIsDeviceInternal = false ); - - TextureCubeArray_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceGLImpl *pDeviceGL, - class DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - GLuint GLTextureHandle, - bool bIsDeviceInternal = false); + TextureCubeArray_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceGLImpl* pDeviceGL, + class DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + const TextureData* pInitData = nullptr, + bool bIsDeviceInternal = false ); + + TextureCubeArray_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceGLImpl* pDeviceGL, + class DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + GLuint GLTextureHandle, + bool bIsDeviceInternal = false); ~TextureCubeArray_OGL(); - virtual void UpdateData( class GLContextState &CtxState, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData )override final; - virtual void AttachToFramebuffer( const struct TextureViewDesc& ViewDesc, GLenum AttachmentPoint )override final; - -private: + virtual void UpdateData(class GLContextState& CtxState, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData)override final; + virtual void AttachToFramebuffer( const struct TextureViewDesc& ViewDesc, + GLenum AttachmentPoint )override final; }; } diff --git a/Graphics/GraphicsEngineOpenGL/include/TextureCube_OGL.h b/Graphics/GraphicsEngineOpenGL/include/TextureCube_OGL.h index 0b7a9ed8..8e7ccec0 100644 --- a/Graphics/GraphicsEngineOpenGL/include/TextureCube_OGL.h +++ b/Graphics/GraphicsEngineOpenGL/include/TextureCube_OGL.h @@ -31,28 +31,31 @@ namespace Diligent class TextureCube_OGL final : public TextureBaseGL { public: - TextureCube_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceGLImpl *pDeviceGL, - class DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - const TextureData& InitData = TextureData(), - bool bIsDeviceInternal = false); - - TextureCube_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceGLImpl *pDeviceGL, - class DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - GLuint GLTextureHandle, - bool bIsDeviceInternal = false); + TextureCube_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceGLImpl* pDeviceGL, + class DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + const TextureData* pInitData = nullptr, + bool bIsDeviceInternal = false); + + TextureCube_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceGLImpl* pDeviceGL, + class DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + GLuint GLTextureHandle, + bool bIsDeviceInternal = false); ~TextureCube_OGL(); - virtual void UpdateData( class GLContextState &CtxState, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData )override final; - virtual void AttachToFramebuffer( const struct TextureViewDesc& ViewDesc, GLenum AttachmentPoint )override final; - -private: + virtual void UpdateData(class GLContextState& CtxState, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData)override final; + virtual void AttachToFramebuffer( const struct TextureViewDesc& ViewDesc, + GLenum AttachmentPoint )override final; }; } diff --git a/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp index a9ea2fb6..f0319479 100644 --- a/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp @@ -67,32 +67,32 @@ static GLenum GetBufferBindTarget(const BufferDesc& Desc) return Target; } -BufferGLImpl::BufferGLImpl(IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator &BuffViewObjMemAllocator, - RenderDeviceGLImpl *pDeviceGL, - const BufferDesc& BuffDesc, - const BufferData &BuffData /*= BufferData()*/, - bool bIsDeviceInternal) : +BufferGLImpl::BufferGLImpl(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& BuffViewObjMemAllocator, + RenderDeviceGLImpl* pDeviceGL, + const BufferDesc& BuffDesc, + const BufferData* pBuffData /*= nullptr*/, + bool bIsDeviceInternal) : TBufferBase( pRefCounters, BuffViewObjMemAllocator, pDeviceGL, BuffDesc, bIsDeviceInternal), m_GlBuffer(true), // Create buffer immediately m_uiMapTarget(0), m_GLUsageHint(UsageToGLUsage(BuffDesc.Usage)), m_bUseMapWriteDiscardBugWA(GetUseMapWriteDiscardBugWA(pDeviceGL)) { - if( BuffDesc.Usage == USAGE_STATIC && BuffData.pData == nullptr ) + if( BuffDesc.Usage == USAGE_STATIC && (pBuffData == nullptr || pBuffData->pData == nullptr) ) LOG_ERROR_AND_THROW("Static buffer must be initialized with data at creation time"); auto Target = GetBufferBindTarget(BuffDesc); // TODO: find out if it affects performance if the buffer is originally bound to one target // and then bound to another (such as first to GL_ARRAY_BUFFER and then to GL_UNIFORM_BUFFER) glBindBuffer(Target, m_GlBuffer); - VERIFY(BuffData.pData == nullptr || BuffData.DataSize >= BuffDesc.uiSizeInBytes, "Data pointer is null or data size is not consistent with buffer size" ); + VERIFY(pBuffData == nullptr || pBuffData->pData == nullptr || pBuffData->DataSize >= BuffDesc.uiSizeInBytes, "Data pointer is null or data size is not consistent with buffer size" ); GLsizeiptr DataSize = BuffDesc.uiSizeInBytes; const GLvoid *pData = nullptr; - if( BuffData.pData && BuffData.DataSize >= BuffDesc.uiSizeInBytes ) + if( pBuffData != nullptr && pBuffData->pData != nullptr && pBuffData->DataSize >= BuffDesc.uiSizeInBytes ) { - pData = BuffData.pData; - DataSize = BuffData.DataSize; + pData = pBuffData->pData; + DataSize = pBuffData->DataSize; } // Create and initialize a buffer object's data store @@ -162,12 +162,12 @@ static BufferDesc GetBufferDescFromGLHandle(BufferDesc BuffDesc, GLuint BufferHa return BuffDesc; } -BufferGLImpl::BufferGLImpl(IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator &BuffViewObjMemAllocator, - RenderDeviceGLImpl *pDeviceGL, - const BufferDesc& BuffDesc, - GLuint GLHandle, - bool bIsDeviceInternal) : +BufferGLImpl::BufferGLImpl(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& BuffViewObjMemAllocator, + RenderDeviceGLImpl* pDeviceGL, + const BufferDesc& BuffDesc, + GLuint GLHandle, + bool bIsDeviceInternal) : TBufferBase( pRefCounters, BuffViewObjMemAllocator, pDeviceGL, GetBufferDescFromGLHandle(BuffDesc, GLHandle), bIsDeviceInternal), // Attach to external buffer handle m_GlBuffer(true, GLObjectWrappers::GLBufferObjCreateReleaseHelper(GLHandle)), diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp index 1923bf2e..b681708f 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp @@ -102,13 +102,13 @@ RenderDeviceGLImpl :: ~RenderDeviceGLImpl() IMPLEMENT_QUERY_INTERFACE( RenderDeviceGLImpl, IID_RenderDeviceGL, TRenderDeviceBase ) -void RenderDeviceGLImpl :: CreateBuffer(const BufferDesc& BuffDesc, const BufferData& BuffData, IBuffer **ppBuffer, bool bIsDeviceInternal) +void RenderDeviceGLImpl :: CreateBuffer(const BufferDesc& BuffDesc, const BufferData* pBuffData, IBuffer **ppBuffer, bool bIsDeviceInternal) { CreateDeviceObject( "buffer", BuffDesc, ppBuffer, [&]() { BufferGLImpl *pBufferOGL( NEW_RC_OBJ(m_BufObjAllocator, "BufferGLImpl instance", BufferGLImpl) - (m_BuffViewObjAllocator, this, BuffDesc, BuffData, bIsDeviceInternal ) ); + (m_BuffViewObjAllocator, this, BuffDesc, pBuffData, bIsDeviceInternal ) ); pBufferOGL->QueryInterface( IID_Buffer, reinterpret_cast<IObject**>(ppBuffer) ); pBufferOGL->CreateDefaultViews(); OnCreateDeviceObject( pBufferOGL ); @@ -116,7 +116,7 @@ void RenderDeviceGLImpl :: CreateBuffer(const BufferDesc& BuffDesc, const Buffer ); } -void RenderDeviceGLImpl :: CreateBuffer(const BufferDesc& BuffDesc, const BufferData& BuffData, IBuffer **ppBuffer) +void RenderDeviceGLImpl :: CreateBuffer(const BufferDesc& BuffDesc, const BufferData* BuffData, IBuffer **ppBuffer) { CreateBuffer(BuffDesc, BuffData, ppBuffer, false); } @@ -155,7 +155,7 @@ void RenderDeviceGLImpl :: CreateShader(const ShaderCreationAttribs& ShaderCreat CreateShader(ShaderCreationAttribs, ppShader, false); } -void RenderDeviceGLImpl :: CreateTexture(const TextureDesc& TexDesc, const TextureData& Data, ITexture **ppTexture, bool bIsDeviceInternal) +void RenderDeviceGLImpl :: CreateTexture(const TextureDesc& TexDesc, const TextureData* pData, ITexture **ppTexture, bool bIsDeviceInternal) { CreateDeviceObject( "texture", TexDesc, ppTexture, [&]() @@ -174,37 +174,37 @@ void RenderDeviceGLImpl :: CreateTexture(const TextureDesc& TexDesc, const Textu { case RESOURCE_DIM_TEX_1D: pTextureOGL = NEW_RC_OBJ(m_TexObjAllocator, "Texture1D_OGL instance", Texture1D_OGL) - (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, Data, bIsDeviceInternal); + (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, pData, bIsDeviceInternal); break; case RESOURCE_DIM_TEX_1D_ARRAY: pTextureOGL = NEW_RC_OBJ(m_TexObjAllocator, "Texture1DArray_OGL instance", Texture1DArray_OGL) - (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, Data, bIsDeviceInternal); + (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, pData, bIsDeviceInternal); break; case RESOURCE_DIM_TEX_2D: pTextureOGL = NEW_RC_OBJ(m_TexObjAllocator, "Texture2D_OGL instance", Texture2D_OGL) - (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, Data, bIsDeviceInternal); + (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, pData, bIsDeviceInternal); break; case RESOURCE_DIM_TEX_2D_ARRAY: pTextureOGL = NEW_RC_OBJ(m_TexObjAllocator, "Texture2DArray_OGL instance", Texture2DArray_OGL) - (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, Data, bIsDeviceInternal); + (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, pData, bIsDeviceInternal); break; case RESOURCE_DIM_TEX_3D: pTextureOGL = NEW_RC_OBJ(m_TexObjAllocator, "Texture3D_OGL instance", Texture3D_OGL) - (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, Data, bIsDeviceInternal); + (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, pData, bIsDeviceInternal); break; case RESOURCE_DIM_TEX_CUBE: pTextureOGL = NEW_RC_OBJ(m_TexObjAllocator, "TextureCube_OGL instance", TextureCube_OGL) - (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, Data, bIsDeviceInternal); + (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, pData, bIsDeviceInternal); break; case RESOURCE_DIM_TEX_CUBE_ARRAY: pTextureOGL = NEW_RC_OBJ(m_TexObjAllocator, "TextureCubeArray_OGL instance", TextureCubeArray_OGL) - (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, Data, bIsDeviceInternal); + (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, pData, bIsDeviceInternal); break; default: LOG_ERROR_AND_THROW( "Unknown texture type. (Did you forget to initialize the Type member of TextureDesc structure?)" ); @@ -217,7 +217,7 @@ void RenderDeviceGLImpl :: CreateTexture(const TextureDesc& TexDesc, const Textu ); } -void RenderDeviceGLImpl::CreateTexture(const TextureDesc& TexDesc, const TextureData& Data, ITexture **ppTexture) +void RenderDeviceGLImpl::CreateTexture(const TextureDesc& TexDesc, const TextureData* Data, ITexture **ppTexture) { CreateTexture(TexDesc, Data, ppTexture, false); } diff --git a/Graphics/GraphicsEngineOpenGL/src/TexRegionRender.cpp b/Graphics/GraphicsEngineOpenGL/src/TexRegionRender.cpp index 07d525b5..f0793679 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TexRegionRender.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TexRegionRender.cpp @@ -92,7 +92,7 @@ namespace Diligent CBDesc.Usage = USAGE_DYNAMIC; CBDesc.BindFlags = BIND_UNIFORM_BUFFER; CBDesc.CPUAccessFlags = CPU_ACCESS_WRITE; - pDeviceGL->CreateBuffer( CBDesc, BufferData(), &m_pConstantBuffer, + pDeviceGL->CreateBuffer( CBDesc, nullptr, &m_pConstantBuffer, true // We must indicate the buffer is internal device object ); diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture1DArray_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture1DArray_OGL.cpp index dd7f2488..4b14bfdb 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture1DArray_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture1DArray_OGL.cpp @@ -32,15 +32,15 @@ namespace Diligent { -Texture1DArray_OGL::Texture1DArray_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - RenderDeviceGLImpl *pDeviceGL, - DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - const TextureData &InitData /*= TextureData()*/, - bool bIsDeviceInternal /*= false*/) : +Texture1DArray_OGL::Texture1DArray_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + RenderDeviceGLImpl* pDeviceGL, + DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + const TextureData* pInitData /*= nullptr*/, + bool bIsDeviceInternal /*= false*/) : TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, TexDesc, - GL_TEXTURE_1D_ARRAY, InitData, bIsDeviceInternal) + GL_TEXTURE_1D_ARRAY, pInitData, bIsDeviceInternal) { auto &ContextState = pDeviceContext->GetContextState(); @@ -58,9 +58,9 @@ Texture1DArray_OGL::Texture1DArray_OGL( IReferenceCounters *pRefCounters, SetDefaultGLParameters(); - if( InitData.pSubResources ) + if (pInitData != nullptr && pInitData->pSubResources != nullptr) { - if( m_Desc.MipLevels * m_Desc.ArraySize == InitData.NumSubresources ) + if (m_Desc.MipLevels * m_Desc.ArraySize == pInitData->NumSubresources) { for(Uint32 Slice = 0; Slice < m_Desc.ArraySize; ++Slice ) { @@ -72,7 +72,7 @@ Texture1DArray_OGL::Texture1DArray_OGL( IReferenceCounters *pRefCounters, // we will get into TextureBaseGL::UpdateData(), because instance of Texture1DArray_OGL // is not fully constructed yet. // To call the required function, we need to explicitly specify the class: - Texture1DArray_OGL::UpdateData(ContextState, Mip, Slice, DstBox, InitData.pSubResources[Slice*m_Desc.MipLevels + Mip]); + Texture1DArray_OGL::UpdateData(ContextState, Mip, Slice, DstBox, pInitData->pSubResources[Slice*m_Desc.MipLevels + Mip]); } } } @@ -85,13 +85,13 @@ Texture1DArray_OGL::Texture1DArray_OGL( IReferenceCounters *pRefCounters, ContextState.BindTexture( -1, m_BindTarget, GLObjectWrappers::GLTextureObj( false ) ); } -Texture1DArray_OGL::Texture1DArray_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - RenderDeviceGLImpl *pDeviceGL, - DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - GLuint GLTextureHandle, - bool bIsDeviceInternal) : +Texture1DArray_OGL::Texture1DArray_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + RenderDeviceGLImpl* pDeviceGL, + DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + GLuint GLTextureHandle, + bool bIsDeviceInternal) : TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, pDeviceContext, TexDesc, GLTextureHandle, GL_TEXTURE_1D_ARRAY, bIsDeviceInternal) { } @@ -100,7 +100,11 @@ Texture1DArray_OGL::~Texture1DArray_OGL() { } -void Texture1DArray_OGL::UpdateData( GLContextState &ContextState, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData ) +void Texture1DArray_OGL::UpdateData( GLContextState& ContextState, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData ) { TextureBaseGL::UpdateData(ContextState, MipLevel, Slice, DstBox, SubresData); diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture1D_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture1D_OGL.cpp index 9e86f6ae..bcff1681 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture1D_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture1D_OGL.cpp @@ -32,14 +32,14 @@ namespace Diligent { -Texture1D_OGL::Texture1D_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - RenderDeviceGLImpl *pDeviceGL, - DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - const TextureData &InitData /*= TextureData()*/, - bool bIsDeviceInternal /*= false*/) : - TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, TexDesc, GL_TEXTURE_1D, InitData, bIsDeviceInternal) +Texture1D_OGL::Texture1D_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + RenderDeviceGLImpl* pDeviceGL, + DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + const TextureData* pInitData /*= nullptr*/, + bool bIsDeviceInternal /*= false*/) : + TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, TexDesc, GL_TEXTURE_1D, pInitData, bIsDeviceInternal) { auto *pDeviceContextGL = ValidatedCast<DeviceContextGLImpl>(pDeviceContext); auto &ContextState = pDeviceContextGL->GetContextState(); @@ -58,9 +58,9 @@ Texture1D_OGL::Texture1D_OGL( IReferenceCounters *pRefCounters, SetDefaultGLParameters(); - if( InitData.pSubResources ) + if (pInitData != nullptr && pInitData->pSubResources != nullptr) { - if( m_Desc.MipLevels == InitData.NumSubresources ) + if (m_Desc.MipLevels == pInitData->NumSubresources) { for(Uint32 Mip = 0; Mip < m_Desc.MipLevels; ++Mip) { @@ -70,7 +70,7 @@ Texture1D_OGL::Texture1D_OGL( IReferenceCounters *pRefCounters, // we will get into TextureBaseGL::UpdateData(), because instance of Texture1D_OGL // is not fully constructed yet. // To call the required function, we need to explicitly specify the class: - Texture1D_OGL::UpdateData( ContextState, Mip, 0, DstBox, InitData.pSubResources[Mip] ); + Texture1D_OGL::UpdateData( ContextState, Mip, 0, DstBox, pInitData->pSubResources[Mip] ); } } else @@ -82,13 +82,13 @@ Texture1D_OGL::Texture1D_OGL( IReferenceCounters *pRefCounters, ContextState.BindTexture(-1, m_BindTarget, GLObjectWrappers::GLTextureObj(false) ); } -Texture1D_OGL::Texture1D_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - RenderDeviceGLImpl *pDeviceGL, - DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - GLuint GLTextureHandle, - bool bIsDeviceInternal) : +Texture1D_OGL::Texture1D_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + RenderDeviceGLImpl* pDeviceGL, + DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + GLuint GLTextureHandle, + bool bIsDeviceInternal) : TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, pDeviceContext, TexDesc, GLTextureHandle, GL_TEXTURE_1D, bIsDeviceInternal) { } @@ -97,7 +97,11 @@ Texture1D_OGL::~Texture1D_OGL() { } -void Texture1D_OGL::UpdateData( GLContextState &ContextState, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData ) +void Texture1D_OGL::UpdateData( GLContextState& ContextState, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData ) { TextureBaseGL::UpdateData(ContextState, MipLevel, Slice, DstBox, SubresData); diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp index 8d746517..0abee41f 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp @@ -33,14 +33,14 @@ namespace Diligent { -Texture2DArray_OGL::Texture2DArray_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - RenderDeviceGLImpl *pDeviceGL, - DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - const TextureData &InitData /*= TextureData()*/, - bool bIsDeviceInternal /*= false*/) : - TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, TexDesc, TexDesc.SampleCount > 1 ? GL_TEXTURE_2D_MULTISAMPLE_ARRAY : GL_TEXTURE_2D_ARRAY, InitData, bIsDeviceInternal) +Texture2DArray_OGL::Texture2DArray_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + RenderDeviceGLImpl* pDeviceGL, + DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + const TextureData* pInitData /*= nullptr*/, + bool bIsDeviceInternal /*= false*/) : + TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, TexDesc, TexDesc.SampleCount > 1 ? GL_TEXTURE_2D_MULTISAMPLE_ARRAY : GL_TEXTURE_2D_ARRAY, pInitData, bIsDeviceInternal) { auto &ContextState = pDeviceContext->GetContextState(); ContextState.BindTexture(-1, m_BindTarget, m_GlTexture); @@ -76,9 +76,9 @@ Texture2DArray_OGL::Texture2DArray_OGL( IReferenceCounters *pRefCounters, SetDefaultGLParameters(); - if( InitData.pSubResources ) + if (pInitData != nullptr && pInitData->pSubResources != nullptr) { - if( m_Desc.MipLevels * m_Desc.ArraySize == InitData.NumSubresources ) + if( m_Desc.MipLevels * m_Desc.ArraySize == pInitData->NumSubresources ) { for(Uint32 Slice = 0; Slice < m_Desc.ArraySize; ++Slice) { @@ -90,7 +90,7 @@ Texture2DArray_OGL::Texture2DArray_OGL( IReferenceCounters *pRefCounters, // we will get into TextureBaseGL::UpdateData(), because instance of Texture2DArray_OGL // is not fully constructed yet. // To call the required function, we need to explicitly specify the class: - Texture2DArray_OGL::UpdateData(ContextState, Mip, Slice, DstBox, InitData.pSubResources[Slice*m_Desc.MipLevels + Mip]); + Texture2DArray_OGL::UpdateData(ContextState, Mip, Slice, DstBox, pInitData->pSubResources[Slice*m_Desc.MipLevels + Mip]); } } } @@ -105,13 +105,13 @@ Texture2DArray_OGL::Texture2DArray_OGL( IReferenceCounters *pRefCounters, ContextState.BindTexture( -1, m_BindTarget, GLObjectWrappers::GLTextureObj(false) ); } -Texture2DArray_OGL::Texture2DArray_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - RenderDeviceGLImpl *pDeviceGL, - DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - GLuint GLTextureHandle, - bool bIsDeviceInternal) : +Texture2DArray_OGL::Texture2DArray_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + RenderDeviceGLImpl* pDeviceGL, + DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + GLuint GLTextureHandle, + bool bIsDeviceInternal) : TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, pDeviceContext, TexDesc, GLTextureHandle, TexDesc.SampleCount > 1 ? GL_TEXTURE_2D_MULTISAMPLE_ARRAY : GL_TEXTURE_2D_ARRAY, bIsDeviceInternal) { @@ -121,7 +121,11 @@ Texture2DArray_OGL::~Texture2DArray_OGL() { } -void Texture2DArray_OGL::UpdateData(GLContextState &ContextState, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData) +void Texture2DArray_OGL::UpdateData(GLContextState& ContextState, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData) { TextureBaseGL::UpdateData(ContextState, MipLevel, Slice, DstBox, SubresData); diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp index 0ae41b4c..8ade1444 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp @@ -33,14 +33,14 @@ namespace Diligent { -Texture2D_OGL::Texture2D_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - RenderDeviceGLImpl *pDeviceGL, - DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - const TextureData &InitData /*= TextureData()*/, - bool bIsDeviceInternal /*= false*/) : - TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, TexDesc, TexDesc.SampleCount > 1 ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D, InitData, bIsDeviceInternal) +Texture2D_OGL::Texture2D_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + RenderDeviceGLImpl* pDeviceGL, + DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + const TextureData* pInitData /*= nullptr*/, + bool bIsDeviceInternal /*= false*/) : + TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, TexDesc, TexDesc.SampleCount > 1 ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D, pInitData, bIsDeviceInternal) { auto &ContextState = pDeviceContext->GetContextState(); ContextState.BindTexture(-1, m_BindTarget, m_GlTexture); @@ -62,7 +62,7 @@ Texture2D_OGL::Texture2D_OGL( IReferenceCounters *pRefCounters, SetDefaultGLParameters(); - VERIFY( InitData.pSubResources == nullptr, "Multisampled textures cannot be modified directly" ); + VERIFY( pInitData == nullptr, "Multisampled textures cannot be modified directly" ); #else LOG_ERROR_AND_THROW("Multisampled textures are not supported"); #endif @@ -82,9 +82,9 @@ Texture2D_OGL::Texture2D_OGL( IReferenceCounters *pRefCounters, SetDefaultGLParameters(); - if( InitData.pSubResources ) + if (pInitData != nullptr && pInitData->pSubResources != nullptr) { - if( m_Desc.MipLevels == InitData.NumSubresources ) + if (m_Desc.MipLevels == pInitData->NumSubresources) { for(Uint32 Mip = 0; Mip < m_Desc.MipLevels; ++Mip) { @@ -94,7 +94,7 @@ Texture2D_OGL::Texture2D_OGL( IReferenceCounters *pRefCounters, // we will get into TextureBaseGL::UpdateData(), because instance of Texture2D_OGL // is not fully constructed yet. // To call the required function, we need to explicitly specify the class: - Texture2D_OGL::UpdateData( ContextState, Mip, 0, DstBox, InitData.pSubResources[Mip] ); + Texture2D_OGL::UpdateData( ContextState, Mip, 0, DstBox, pInitData->pSubResources[Mip] ); } } else @@ -123,7 +123,11 @@ Texture2D_OGL::~Texture2D_OGL() { } -void Texture2D_OGL::UpdateData( GLContextState &ContextState, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData ) +void Texture2D_OGL::UpdateData( GLContextState& ContextState, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData ) { TextureBaseGL::UpdateData(ContextState, MipLevel, Slice, DstBox, SubresData); diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture3D_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture3D_OGL.cpp index f3244bbe..53ddccb7 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture3D_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture3D_OGL.cpp @@ -33,15 +33,15 @@ namespace Diligent { -Texture3D_OGL::Texture3D_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - RenderDeviceGLImpl *pDeviceGL, - DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - const TextureData &InitData /*= TextureData()*/, - bool bIsDeviceInternal /*= false*/) : +Texture3D_OGL::Texture3D_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + RenderDeviceGLImpl* pDeviceGL, + DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + const TextureData* pInitData /*= TextureData()*/, + bool bIsDeviceInternal /*= false*/) : TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, TexDesc, - GL_TEXTURE_3D, InitData, bIsDeviceInternal) + GL_TEXTURE_3D, pInitData, bIsDeviceInternal) { auto &ContextState = pDeviceContext->GetContextState(); ContextState.BindTexture(-1, m_BindTarget, m_GlTexture); @@ -60,9 +60,9 @@ Texture3D_OGL::Texture3D_OGL( IReferenceCounters *pRefCounters, SetDefaultGLParameters(); - if( InitData.pSubResources ) + if (pInitData != nullptr && pInitData->pSubResources != nullptr) { - if( m_Desc.MipLevels == InitData.NumSubresources ) + if (m_Desc.MipLevels == pInitData->NumSubresources) { for(Uint32 Mip = 0; Mip < m_Desc.MipLevels; ++Mip) { @@ -73,7 +73,7 @@ Texture3D_OGL::Texture3D_OGL( IReferenceCounters *pRefCounters, // we will get into TextureBaseGL::UpdateData(), because instance of Texture3D_OGL // is not fully constructed yet. // To call the required function, we need to explicitly specify the class: - Texture3D_OGL::UpdateData( ContextState, Mip, 0, DstBox, InitData.pSubResources[Mip] ); + Texture3D_OGL::UpdateData( ContextState, Mip, 0, DstBox, pInitData->pSubResources[Mip] ); } } else @@ -85,13 +85,13 @@ Texture3D_OGL::Texture3D_OGL( IReferenceCounters *pRefCounters, ContextState.BindTexture( -1, m_BindTarget, GLObjectWrappers::GLTextureObj(false) ); } -Texture3D_OGL::Texture3D_OGL( IReferenceCounters *pRefCounters, +Texture3D_OGL::Texture3D_OGL( IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& TexViewObjAllocator, - RenderDeviceGLImpl *pDeviceGL, - DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - GLuint GLTextureHandle, - bool bIsDeviceInternal) : + RenderDeviceGLImpl* pDeviceGL, + DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + GLuint GLTextureHandle, + bool bIsDeviceInternal) : TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, pDeviceContext, TexDesc, GLTextureHandle, GL_TEXTURE_3D, bIsDeviceInternal) { } @@ -101,7 +101,11 @@ Texture3D_OGL::~Texture3D_OGL() } -void Texture3D_OGL::UpdateData( GLContextState &ContextState, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData ) +void Texture3D_OGL::UpdateData( GLContextState& ContextState, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData ) { TextureBaseGL::UpdateData(ContextState, MipLevel, Slice, DstBox, SubresData); diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp index f423c26c..93cec5ca 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp @@ -35,12 +35,13 @@ namespace Diligent { -TextureBaseGL::TextureBaseGL(IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - RenderDeviceGLImpl *pDeviceGL, - const TextureDesc& TexDesc, - GLenum BindTarget, - const TextureData &InitData /*= TextureData()*/, bool bIsDeviceInternal /*= false*/) : +TextureBaseGL::TextureBaseGL(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + RenderDeviceGLImpl* pDeviceGL, + const TextureDesc& TexDesc, + GLenum BindTarget, + const TextureData* pInitData /*= nullptr*/, + bool bIsDeviceInternal /*= false*/) : TTextureBase( pRefCounters, TexViewObjAllocator, pDeviceGL, TexDesc, bIsDeviceInternal ), m_GlTexture(true), // Create Texture immediately m_BindTarget(BindTarget), @@ -48,7 +49,7 @@ TextureBaseGL::TextureBaseGL(IReferenceCounters *pRefCounters, //m_uiMapTarget(0) { VERIFY( m_GLTexFormat != 0, "Unsupported texture format" ); - if( TexDesc.Usage == USAGE_STATIC && InitData.pSubResources == nullptr ) + if( TexDesc.Usage == USAGE_STATIC && pInitData == nullptr ) LOG_ERROR_AND_THROW("Static Texture must be initialized with data at creation time"); } diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp index f0366d99..21304f39 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp @@ -33,14 +33,14 @@ namespace Diligent { -TextureCubeArray_OGL::TextureCubeArray_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - RenderDeviceGLImpl *pDeviceGL, - DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - const TextureData &InitData /*= TextureData()*/, - bool bIsDeviceInternal /*= false*/) : - TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, TexDesc, GL_TEXTURE_CUBE_MAP_ARRAY, InitData, bIsDeviceInternal) +TextureCubeArray_OGL::TextureCubeArray_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + RenderDeviceGLImpl* pDeviceGL, + DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + const TextureData* pInitData /*= nullptr*/, + bool bIsDeviceInternal /*= false*/) : + TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, TexDesc, GL_TEXTURE_CUBE_MAP_ARRAY, pInitData, bIsDeviceInternal) { VERIFY(m_Desc.SampleCount == 1, "Multisampled texture cube arrays are not supported"); @@ -64,10 +64,10 @@ TextureCubeArray_OGL::TextureCubeArray_OGL( IReferenceCounters *pRefCounters, SetDefaultGLParameters(); - if( InitData.pSubResources ) + if (pInitData != nullptr && pInitData->pSubResources != nullptr) { VERIFY( (m_Desc.ArraySize % 6) == 0, "Array size must be multiple of 6"); - if( m_Desc.MipLevels * m_Desc.ArraySize == InitData.NumSubresources ) + if (m_Desc.MipLevels * m_Desc.ArraySize == pInitData->NumSubresources) { for(Uint32 Slice = 0; Slice < m_Desc.ArraySize; ++Slice) { @@ -79,7 +79,7 @@ TextureCubeArray_OGL::TextureCubeArray_OGL( IReferenceCounters *pRefCounters, // we will get into TextureBaseGL::UpdateData(), because instance of TextureCubeArray_OGL // is not fully constructed yet. // To call the required function, we need to explicitly specify the class: - TextureCubeArray_OGL::UpdateData(ContextState, Mip, Slice, DstBox, InitData.pSubResources[Slice*m_Desc.MipLevels + Mip]); + TextureCubeArray_OGL::UpdateData(ContextState, Mip, Slice, DstBox, pInitData->pSubResources[Slice*m_Desc.MipLevels + Mip]); } } } @@ -107,7 +107,11 @@ TextureCubeArray_OGL::~TextureCubeArray_OGL() { } -void TextureCubeArray_OGL::UpdateData( GLContextState &ContextState, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData ) +void TextureCubeArray_OGL::UpdateData( GLContextState& ContextState, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData ) { TextureBaseGL::UpdateData(ContextState, MipLevel, Slice, DstBox, SubresData); diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp index 71c159b1..bb55c9ad 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp @@ -33,14 +33,14 @@ namespace Diligent { -TextureCube_OGL::TextureCube_OGL( IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceGLImpl *pDeviceGL, - class DeviceContextGLImpl *pDeviceContext, - const TextureDesc& TexDesc, - const TextureData &InitData /*= TextureData()*/, - bool bIsDeviceInternal /*= false*/) : - TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, TexDesc, GL_TEXTURE_CUBE_MAP, InitData, bIsDeviceInternal) +TextureCube_OGL::TextureCube_OGL( IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceGLImpl* pDeviceGL, + class DeviceContextGLImpl* pDeviceContext, + const TextureDesc& TexDesc, + const TextureData* pInitData /*= nullptr*/, + bool bIsDeviceInternal /*= false*/) : + TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, TexDesc, GL_TEXTURE_CUBE_MAP, pInitData, bIsDeviceInternal) { VERIFY(m_Desc.SampleCount == 1, "Multisampled cubemap textures are not supported"); @@ -62,10 +62,10 @@ TextureCube_OGL::TextureCube_OGL( IReferenceCounters *pRefCounters, //} SetDefaultGLParameters(); - if( InitData.pSubResources ) + if (pInitData != nullptr && pInitData->pSubResources != nullptr) { const auto ExpectedSubresources = m_Desc.MipLevels*6; - if( m_Desc.MipLevels*6 == InitData.NumSubresources ) + if( m_Desc.MipLevels*6 == pInitData->NumSubresources ) { for(Uint32 Face = 0; Face < 6; ++Face) { @@ -77,13 +77,13 @@ TextureCube_OGL::TextureCube_OGL( IReferenceCounters *pRefCounters, // we will get into TextureBaseGL::UpdateData(), because instance of TextureCube_OGL // is not fully constructed yet. // To call the required function, we need to explicitly specify the class: - TextureCube_OGL::UpdateData( ContextState, Mip, Face, DstBox, InitData.pSubResources[Face*m_Desc.MipLevels + Mip] ); + TextureCube_OGL::UpdateData( ContextState, Mip, Face, DstBox, pInitData->pSubResources[Face*m_Desc.MipLevels + Mip] ); } } } else { - UNEXPECTED("Incorrect number of subresources. ", InitData.NumSubresources, " while ", ExpectedSubresources," is expected" ); (void)ExpectedSubresources; + UNEXPECTED("Incorrect number of subresources. ", pInitData->NumSubresources, " while ", ExpectedSubresources," is expected" ); (void)ExpectedSubresources; } } @@ -117,7 +117,11 @@ static const GLenum CubeMapFaces[6] = GL_TEXTURE_CUBE_MAP_NEGATIVE_Z }; -void TextureCube_OGL::UpdateData( GLContextState &ContextState, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData ) +void TextureCube_OGL::UpdateData( GLContextState& ContextState, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData ) { TextureBaseGL::UpdateData(ContextState, MipLevel, Slice, DstBox, SubresData); diff --git a/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h b/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h index 7e702a0c..f3d1784b 100644 --- a/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h @@ -53,7 +53,7 @@ public: FixedBlockMemoryAllocator& BuffViewObjMemAllocator, RenderDeviceVkImpl* pDeviceVk, const BufferDesc& BuffDesc, - const BufferData& BuffData = BufferData()); + const BufferData* pBuffData = nullptr); BufferVkImpl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& BuffViewObjMemAllocator, diff --git a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h index 9ec268f3..64410774 100644 --- a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h @@ -70,11 +70,11 @@ public: virtual void CreatePipelineState( const PipelineStateDesc &PipelineDesc, IPipelineState** ppPipelineState )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; void CreateTexture(const TextureDesc& TexDesc, VkImage vkImgHandle, RESOURCE_STATE InitialState, class TextureVkImpl** ppTexture); diff --git a/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h b/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h index 00f02fe2..4d040a0e 100644 --- a/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h @@ -50,7 +50,7 @@ public: FixedBlockMemoryAllocator& TexViewObjAllocator, RenderDeviceVkImpl* pDeviceVk, const TextureDesc& TexDesc, - const TextureData& InitData = TextureData()); + const TextureData* pInitData = nullptr); // Attaches to an existing Vk resource TextureVkImpl(IReferenceCounters* pRefCounters, diff --git a/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp index 1876d6b2..faeff985 100644 --- a/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp @@ -40,16 +40,16 @@ BufferVkImpl :: BufferVkImpl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& BuffViewObjMemAllocator, RenderDeviceVkImpl* pRenderDeviceVk, const BufferDesc& BuffDesc, - const BufferData& BuffData /*= BufferData()*/) : + const BufferData* pBuffData /*= nullptr*/) : TBufferBase(pRefCounters, BuffViewObjMemAllocator, pRenderDeviceVk, BuffDesc, false), m_DynamicAllocations(STD_ALLOCATOR_RAW_MEM(VulkanDynamicAllocation, GetRawAllocator(), "Allocator for vector<VulkanDynamicAllocation>")) { #define LOG_BUFFER_ERROR_AND_THROW(...) LOG_ERROR_AND_THROW("Buffer \"", BuffDesc.Name ? BuffDesc.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.Usage == USAGE_DYNAMIC && BuffData.pData != nullptr ) + if( m_Desc.Usage == USAGE_DYNAMIC && pBuffData != nullptr && pBuffData->pData != nullptr ) LOG_BUFFER_ERROR_AND_THROW("Dynamic buffer must be initialized via Map()") if (m_Desc.Usage == USAGE_CPU_ACCESSIBLE) @@ -59,7 +59,7 @@ BufferVkImpl :: BufferVkImpl(IReferenceCounters* pRefCounters, if (m_Desc.CPUAccessFlags == CPU_ACCESS_WRITE) { - if(BuffData.pData != nullptr ) + if (pBuffData != nullptr ) LOG_BUFFER_ERROR_AND_THROW("CPU-writable staging buffers must be updated via map") } } @@ -185,7 +185,7 @@ BufferVkImpl :: BufferVkImpl(IReferenceCounters* pRefCounters, auto err = LogicalDevice.BindBufferMemory(m_VulkanBuffer, Memory, AlignedOffset); CHECK_VK_ERROR_AND_THROW(err, "Failed to bind buffer memory"); - bool bInitializeBuffer = (BuffData.pData != nullptr && BuffData.DataSize > 0); + bool bInitializeBuffer = (pBuffData != nullptr && pBuffData->pData != nullptr && pBuffData->DataSize > 0); RESOURCE_STATE InitialState = RESOURCE_STATE_UNDEFINED; if( bInitializeBuffer ) { @@ -211,7 +211,7 @@ BufferVkImpl :: BufferVkImpl(IReferenceCounters* pRefCounters, auto* StagingData = reinterpret_cast<uint8_t*>(StagingMemoryAllocation.Page->GetCPUMemory()); if (StagingData == nullptr) LOG_BUFFER_ERROR_AND_THROW("Failed to allocate staging data"); - memcpy(StagingData + AlignedStagingMemOffset, BuffData.pData, BuffData.DataSize); + memcpy(StagingData + AlignedStagingMemOffset, pBuffData->pData, pBuffData->DataSize); err = LogicalDevice.BindBufferMemory(StagingBuffer, StagingBufferMemory, AlignedStagingMemOffset); CHECK_VK_ERROR_AND_THROW(err, "Failed to bind staging bufer memory"); diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index d2e2326a..42ea4022 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -98,7 +98,7 @@ namespace Diligent DummyVBDesc.Usage = USAGE_DEFAULT; DummyVBDesc.uiSizeInBytes = 32; RefCntAutoPtr<IBuffer> pDummyVB; - m_pDevice->CreateBuffer(DummyVBDesc, BufferData{}, &pDummyVB); + m_pDevice->CreateBuffer(DummyVBDesc, nullptr, &pDummyVB); m_DummyVB = pDummyVB.RawPtr<BufferVkImpl>(); } diff --git a/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp b/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp index 54e64aab..fc9af5a8 100644 --- a/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp +++ b/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp @@ -171,7 +171,7 @@ namespace Diligent ConstantsCBDesc.Usage = USAGE_DYNAMIC; ConstantsCBDesc.CPUAccessFlags = CPU_ACCESS_WRITE; ConstantsCBDesc.uiSizeInBytes = 32; - DeviceVkImpl.CreateBuffer(ConstantsCBDesc, BufferData(), &m_ConstantsCB); + DeviceVkImpl.CreateBuffer(ConstantsCBDesc, nullptr, &m_ConstantsCB); FindPSOs(TEX_FORMAT_RGBA8_UNORM); FindPSOs(TEX_FORMAT_BGRA8_UNORM); diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp index 05edf7a2..dbf2893f 100644 --- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp @@ -419,12 +419,12 @@ void RenderDeviceVkImpl :: CreateBufferFromVulkanResource(VkBuffer vkBuffer, con } -void RenderDeviceVkImpl :: CreateBuffer(const BufferDesc& BuffDesc, const BufferData &BuffData, IBuffer **ppBuffer) +void RenderDeviceVkImpl :: CreateBuffer(const BufferDesc& BuffDesc, const BufferData* pBuffData, IBuffer **ppBuffer) { CreateDeviceObject("buffer", BuffDesc, ppBuffer, [&]() { - BufferVkImpl* pBufferVk( NEW_RC_OBJ(m_BufObjAllocator, "BufferVkImpl instance", BufferVkImpl)(m_BuffViewObjAllocator, this, BuffDesc, BuffData ) ); + BufferVkImpl* pBufferVk( NEW_RC_OBJ(m_BufObjAllocator, "BufferVkImpl instance", BufferVkImpl)(m_BuffViewObjAllocator, this, BuffDesc, pBuffData ) ); pBufferVk->QueryInterface( IID_Buffer, reinterpret_cast<IObject**>(ppBuffer) ); pBufferVk->CreateDefaultViews(); OnCreateDeviceObject( pBufferVk ); @@ -474,12 +474,12 @@ void RenderDeviceVkImpl::CreateTexture(const TextureDesc& TexDesc, VkImage vkImg } -void RenderDeviceVkImpl :: CreateTexture(const TextureDesc& TexDesc, const TextureData &Data, ITexture **ppTexture) +void RenderDeviceVkImpl :: CreateTexture(const TextureDesc& TexDesc, const TextureData* pData, ITexture **ppTexture) { CreateDeviceObject( "texture", TexDesc, ppTexture, [&]() { - TextureVkImpl* pTextureVk = NEW_RC_OBJ(m_TexObjAllocator, "TextureVkImpl instance", TextureVkImpl)(m_TexViewObjAllocator, this, TexDesc, Data ); + TextureVkImpl* pTextureVk = NEW_RC_OBJ(m_TexObjAllocator, "TextureVkImpl instance", TextureVkImpl)(m_TexViewObjAllocator, this, TexDesc, pData ); pTextureVk->QueryInterface( IID_Texture, reinterpret_cast<IObject**>(ppTexture) ); pTextureVk->CreateDefaultViews(); diff --git a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp index f3837886..27743a2e 100644 --- a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp @@ -396,7 +396,7 @@ void SwapChainVkImpl::InitBuffersAndViews() DepthBufferDesc.ClearValue.DepthStencil.Stencil = m_SwapChainDesc.DefaultStencilValue; DepthBufferDesc.Name = "Main depth buffer"; RefCntAutoPtr<ITexture> pDepthBufferTex; - m_pRenderDevice->CreateTexture(DepthBufferDesc, TextureData(), static_cast<ITexture**>(&pDepthBufferTex) ); + m_pRenderDevice->CreateTexture(DepthBufferDesc, nullptr, static_cast<ITexture**>(&pDepthBufferTex) ); auto pDSV = pDepthBufferTex->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL); m_pDepthBufferDSV = RefCntAutoPtr<ITextureViewVk>(pDSV, IID_TextureViewVk); } diff --git a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp index 82d461d1..71cf5ae8 100644 --- a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp @@ -40,11 +40,11 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& TexViewObjAllocator, RenderDeviceVkImpl* pRenderDeviceVk, const TextureDesc& TexDesc, - const TextureData& InitData /*= TextureData()*/) : + const TextureData* pInitData /*= nullptr*/) : TTextureBase(pRefCounters, TexViewObjAllocator, pRenderDeviceVk, TexDesc) { - if( m_Desc.Usage == USAGE_STATIC && InitData.pSubResources == nullptr ) - LOG_ERROR_AND_THROW("Static Texture must be initialized with data at creation time"); + if( m_Desc.Usage == USAGE_STATIC && (pInitData == nullptr || pInitData->pSubResources == nullptr) ) + LOG_ERROR_AND_THROW("Static textures must be initialized with data at creation time"); const auto& LogicalDevice = pRenderDeviceVk->GetLogicalDevice(); @@ -139,7 +139,7 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters, // and the transition away from this layout is not guaranteed to preserve that data. ImageCI.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; - bool bInitializeTexture = (InitData.pSubResources != nullptr && InitData.NumSubresources > 0); + bool bInitializeTexture = (pInitData != nullptr && pInitData->pSubResources != nullptr && pInitData->NumSubresources > 0); m_VulkanImage = LogicalDevice.CreateImage(ImageCI, m_Desc.Name); @@ -197,10 +197,10 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters, if(bInitializeTexture) { Uint32 ExpectedNumSubresources = ImageCI.mipLevels * ImageCI.arrayLayers; - if( InitData.NumSubresources != ExpectedNumSubresources ) - LOG_ERROR_AND_THROW("Incorrect number of subresources in init data. ", ExpectedNumSubresources, " expected, while ", InitData.NumSubresources, " provided"); + if (pInitData->NumSubresources != ExpectedNumSubresources ) + LOG_ERROR_AND_THROW("Incorrect number of subresources in init data. ", ExpectedNumSubresources, " expected, while ", pInitData->NumSubresources, " provided"); - std::vector<VkBufferImageCopy> Regions(InitData.NumSubresources); + std::vector<VkBufferImageCopy> Regions(pInitData->NumSubresources); Uint64 uploadBufferSize = 0; Uint32 subres = 0; @@ -208,7 +208,7 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters, { for(Uint32 mip = 0; mip < ImageCI.mipLevels; ++mip) { - const auto& SubResData = InitData.pSubResources[subres]; (void)SubResData; + const auto& SubResData = pInitData->pSubResources[subres]; (void)SubResData; auto& CopyRegion = Regions[subres]; auto MipWidth = std::max(m_Desc.Width >> mip, 1u); @@ -255,7 +255,7 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters, ++subres; } } - VERIFY_EXPR(subres == InitData.NumSubresources); + VERIFY_EXPR(subres == pInitData->NumSubresources); VkBufferCreateInfo VkStaginBuffCI = {}; VkStaginBuffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; @@ -291,7 +291,7 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters, { for(Uint32 mip = 0; mip < ImageCI.mipLevels; ++mip) { - const auto &SubResData = InitData.pSubResources[subres]; + const auto &SubResData = pInitData->pSubResources[subres]; const auto &CopyRegion = Regions[subres]; auto MipWidth = CopyRegion.imageExtent.width; @@ -325,7 +325,7 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters, ++subres; } } - VERIFY_EXPR(subres == InitData.NumSubresources); + VERIFY_EXPR(subres == pInitData->NumSubresources); err = LogicalDevice.BindBufferMemory(StagingBuffer, StagingBufferMemory, AlignedStagingMemOffset); CHECK_VK_ERROR_AND_THROW(err, "Failed to bind staging bufer memory"); diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp index 54ac6d9e..ab8b7cd5 100644 --- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp +++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp @@ -94,7 +94,7 @@ namespace VulkanUtilities return CreateVulkanObject<VkCommandPool>(vkCreateCommandPool, CmdPoolCI, DebugName, "command pool"); } - BufferWrapper VulkanLogicalDevice::CreateBuffer(const VkBufferCreateInfo &BufferCI, + BufferWrapper VulkanLogicalDevice::CreateBuffer(const VkBufferCreateInfo& BufferCI, const char* DebugName)const { VERIFY_EXPR(BufferCI.sType == VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO); diff --git a/Graphics/GraphicsTools/include/CommonlyUsedStates.h b/Graphics/GraphicsTools/include/CommonlyUsedStates.h index 6257b3c2..b97553d3 100644 --- a/Graphics/GraphicsTools/include/CommonlyUsedStates.h +++ b/Graphics/GraphicsTools/include/CommonlyUsedStates.h @@ -65,9 +65,9 @@ namespace Diligent static const BlendStateDesc BS_AlphaBlend = { - False, // AlphaToCoverageEnable - False, // IndependentBlendEnable - RenderTargetBlendDesc// RT0 + False, // AlphaToCoverageEnable + False, // IndependentBlendEnable + RenderTargetBlendDesc // Render Target 0 { True, // BlendEnable False, // LogicOperationEnable diff --git a/Graphics/GraphicsTools/src/GraphicsUtilities.cpp b/Graphics/GraphicsTools/src/GraphicsUtilities.cpp index c203a7a3..29837ec3 100644 --- a/Graphics/GraphicsTools/src/GraphicsUtilities.cpp +++ b/Graphics/GraphicsTools/src/GraphicsUtilities.cpp @@ -41,7 +41,7 @@ void CreateUniformBuffer( IRenderDevice *pDevice, Uint32 Size, const Char *Name, CBDesc.Usage = Usage; CBDesc.BindFlags = BindFlags; CBDesc.CPUAccessFlags = CPUAccessFlags; - pDevice->CreateBuffer( CBDesc, BufferData(), ppBuffer ); + pDevice->CreateBuffer( CBDesc, nullptr, ppBuffer ); } template<class TConverter> diff --git a/Graphics/GraphicsTools/src/TextureUploaderD3D12.cpp b/Graphics/GraphicsTools/src/TextureUploaderD3D12.cpp index 0905033e..8eff3ae2 100644 --- a/Graphics/GraphicsTools/src/TextureUploaderD3D12.cpp +++ b/Graphics/GraphicsTools/src/TextureUploaderD3D12.cpp @@ -239,7 +239,7 @@ namespace Diligent BuffDesc.uiSizeInBytes = Desc.Height * RowStride; RefCntAutoPtr<IBuffer> pStagingBuffer; - m_pDevice->CreateBuffer(BuffDesc, BufferData(), &pStagingBuffer); + m_pDevice->CreateBuffer(BuffDesc, nullptr, &pStagingBuffer); PVoid CpuVirtualAddress = nullptr; RefCntAutoPtr<IBufferD3D12> pStagingBufferD3D12(pStagingBuffer, IID_BufferD3D12); diff --git a/Graphics/GraphicsTools/src/TextureUploaderGL.cpp b/Graphics/GraphicsTools/src/TextureUploaderGL.cpp index 06c5dfc7..c820d186 100644 --- a/Graphics/GraphicsTools/src/TextureUploaderGL.cpp +++ b/Graphics/GraphicsTools/src/TextureUploaderGL.cpp @@ -187,7 +187,7 @@ namespace Diligent BuffDesc.uiSizeInBytes = Desc.Height * RowStride; RefCntAutoPtr<IBuffer> pStagingBuffer; - m_pDevice->CreateBuffer(BuffDesc, BufferData(), &pBuffer->m_pStagingBuffer); + m_pDevice->CreateBuffer(BuffDesc, nullptr, &pBuffer->m_pStagingBuffer); } PVoid CpuAddress = nullptr; |
