From 26a81f5d5aef3e8d367c7e91870becce7c21e1f9 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Fri, 8 Feb 2019 17:28:02 -0800 Subject: Updated IRenderDevice::CreateTexture and IRenderDevice::CreateBuffer to take pointers to initial data rather than references --- .../GraphicsEngineOpenGL/include/BufferGLImpl.h | 26 +++++------ .../include/RenderDeviceGLImpl.h | 8 ++-- .../include/Texture1DArray_OGL.h | 41 ++++++++-------- .../GraphicsEngineOpenGL/include/Texture1D_OGL.h | 41 ++++++++-------- .../include/Texture2DArray_OGL.h | 41 ++++++++-------- .../GraphicsEngineOpenGL/include/Texture2D_OGL.h | 41 ++++++++-------- .../GraphicsEngineOpenGL/include/Texture3D_OGL.h | 41 ++++++++-------- .../GraphicsEngineOpenGL/include/TextureBaseGL.h | 54 +++++++++++----------- .../include/TextureCubeArray_OGL.h | 41 ++++++++-------- .../GraphicsEngineOpenGL/include/TextureCube_OGL.h | 41 ++++++++-------- Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp | 34 +++++++------- .../src/RenderDeviceGLImpl.cpp | 24 +++++----- .../GraphicsEngineOpenGL/src/TexRegionRender.cpp | 2 +- .../src/Texture1DArray_OGL.cpp | 42 +++++++++-------- .../GraphicsEngineOpenGL/src/Texture1D_OGL.cpp | 42 +++++++++-------- .../src/Texture2DArray_OGL.cpp | 42 +++++++++-------- .../GraphicsEngineOpenGL/src/Texture2D_OGL.cpp | 30 ++++++------ .../GraphicsEngineOpenGL/src/Texture3D_OGL.cpp | 40 ++++++++-------- .../GraphicsEngineOpenGL/src/TextureBaseGL.cpp | 15 +++--- .../src/TextureCubeArray_OGL.cpp | 28 ++++++----- .../GraphicsEngineOpenGL/src/TextureCube_OGL.cpp | 30 ++++++------ 21 files changed, 377 insertions(+), 327 deletions(-) (limited to 'Graphics/GraphicsEngineOpenGL') 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; - 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; 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(static_cast(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(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(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); -- cgit v1.2.3