summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineOpenGL
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-09-25 06:02:36 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-09-25 06:02:36 +0000
commit05072ba4a9c693f50565436314b785a40df8b355 (patch)
tree32aa86a3d2c8a59a7ba63c0822cd8e9ba3c3588a /Graphics/GraphicsEngineOpenGL
parentappveyor: updated cmake command (diff)
downloadDiligentCore-05072ba4a9c693f50565436314b785a40df8b355.tar.gz
DiligentCore-05072ba4a9c693f50565436314b785a40df8b355.zip
GL backend: fixed issue with random glBindBuffer() calls messing up currently bound VAO
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.h8
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h2
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h5
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/Texture1DArray_OGL.h30
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/Texture1D_OGL.h30
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/Texture2DArray_OGL.h40
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/Texture2D_OGL.h30
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/Texture3D_OGL.h30
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.h18
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/TextureCubeArray_OGL.h24
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/TextureCube_OGL.h34
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp34
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp16
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp3
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp1
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp54
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/Texture1DArray_OGL.cpp38
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/Texture1D_OGL.cpp15
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp13
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp37
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/Texture3D_OGL.cpp13
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp57
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp25
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp29
24 files changed, 310 insertions, 276 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.h
index bdb6f26c..89e16017 100644
--- a/Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.h
+++ b/Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.h
@@ -45,13 +45,15 @@ public:
BufferGLImpl(IReferenceCounters* pRefCounters,
FixedBlockMemoryAllocator& BuffViewObjMemAllocator,
- RenderDeviceGLImpl* pDeviceGL,
+ RenderDeviceGLImpl* pDeviceGL,
+ DeviceContextGLImpl* pCtxGL,
const BufferDesc& BuffDesc,
const BufferData* pBuffData,
bool bIsDeviceInternal);
BufferGLImpl(IReferenceCounters* pRefCounters,
FixedBlockMemoryAllocator& BuffViewObjMemAllocator,
- class RenderDeviceGLImpl* pDeviceGL,
+ class RenderDeviceGLImpl* pDeviceGL,
+ DeviceContextGLImpl* pCtxGL,
const BufferDesc& BuffDesc,
GLuint GLHandle,
bool bIsDeviceInternal);
@@ -60,7 +62,7 @@ public:
/// Queries the specific interface, see IObject::QueryInterface() for details
virtual void QueryInterface( const INTERFACE_ID& IID, IObject** ppInterface )override;
- void UpdateData(GLContextState& CtxState, Uint32 Offset, Uint32 Size, const PVoid pData);
+ void UpdateData(DeviceContextGLImpl* pCtxGL, Uint32 Offset, Uint32 Size, const PVoid pData);
void CopyData(GLContextState& CtxState, BufferGLImpl& SrcBufferGL, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size);
void Map(GLContextState& CtxState, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData );
void Unmap();
diff --git a/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h
index 67a66568..739e8e2f 100644
--- a/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h
+++ b/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h
@@ -162,6 +162,8 @@ public:
void CommitRenderTargets();
+ void ResetVAO();
+
protected:
friend class BufferGLImpl;
friend class TextureBaseGL;
diff --git a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h
index 729ea310..6df86c96 100644
--- a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h
+++ b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h
@@ -23,6 +23,7 @@
#pragma once
+#include <memory>
#include "RenderDeviceBase.h"
#include "GLContext.h"
#include "VAOCache.h"
@@ -99,6 +100,8 @@ public:
size_t GetCommandQueueCount()const { return 1; }
Uint64 GetCommandQueueMask()const { return Uint64{1};}
+ void InitTexRegionRender();
+
protected:
friend class DeviceContextGLImpl;
friend class TextureBaseGL;
@@ -122,7 +125,7 @@ protected:
GPUInfo m_GPUInfo;
- TexRegionRender m_TexRegionRender;
+ std::unique_ptr<TexRegionRender> m_pTexRegionRender;
private:
virtual void TestTextureFormat( TEXTURE_FORMAT TexFormat )override final;
diff --git a/Graphics/GraphicsEngineOpenGL/include/Texture1DArray_OGL.h b/Graphics/GraphicsEngineOpenGL/include/Texture1DArray_OGL.h
index 79a28fdb..ddbc4148 100644
--- a/Graphics/GraphicsEngineOpenGL/include/Texture1DArray_OGL.h
+++ b/Graphics/GraphicsEngineOpenGL/include/Texture1DArray_OGL.h
@@ -31,21 +31,21 @@ 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* 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(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ class RenderDeviceGLImpl* pDeviceGL,
+ class GLContextState& GLState,
+ const TextureDesc& TexDesc,
+ const TextureData* pInitData = nullptr,
+ bool bIsDeviceInternal = false);
+
+ Texture1DArray_OGL(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ class RenderDeviceGLImpl* pDeviceGL,
+ class GLContextState& GLState,
+ const TextureDesc& TexDesc,
+ GLuint GLTextureHandle,
+ bool bIsDeviceInternal = false);
~Texture1DArray_OGL();
virtual void UpdateData( class GLContextState& CtxState,
diff --git a/Graphics/GraphicsEngineOpenGL/include/Texture1D_OGL.h b/Graphics/GraphicsEngineOpenGL/include/Texture1D_OGL.h
index 7c980707..488c62db 100644
--- a/Graphics/GraphicsEngineOpenGL/include/Texture1D_OGL.h
+++ b/Graphics/GraphicsEngineOpenGL/include/Texture1D_OGL.h
@@ -31,21 +31,21 @@ 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* 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(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ class RenderDeviceGLImpl* pDeviceGL,
+ class GLContextState& GLState,
+ const TextureDesc& TexDesc,
+ const TextureData* pInitData = nullptr,
+ bool bIsDeviceInternal = false);
+
+ Texture1D_OGL(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ class RenderDeviceGLImpl* pDeviceGL,
+ class GLContextState& GLState,
+ const TextureDesc& TexDesc,
+ GLuint GLTextureHandle,
+ bool bIsDeviceInternal = false);
~Texture1D_OGL();
virtual void UpdateData( class GLContextState& CtxState,
diff --git a/Graphics/GraphicsEngineOpenGL/include/Texture2DArray_OGL.h b/Graphics/GraphicsEngineOpenGL/include/Texture2DArray_OGL.h
index 23ecd714..9c9e5a0d 100644
--- a/Graphics/GraphicsEngineOpenGL/include/Texture2DArray_OGL.h
+++ b/Graphics/GraphicsEngineOpenGL/include/Texture2DArray_OGL.h
@@ -31,28 +31,28 @@ 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* 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(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ class RenderDeviceGLImpl* pDeviceGL,
+ class GLContextState& GLState,
+ const TextureDesc& TexDesc,
+ const TextureData* pInitData = nullptr,
+ bool bIsDeviceInternal = false );
+
+ Texture2DArray_OGL(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ class RenderDeviceGLImpl* pDeviceGL,
+ class GLContextState& GLState,
+ 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 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 f3d77744..8e54b368 100644
--- a/Graphics/GraphicsEngineOpenGL/include/Texture2D_OGL.h
+++ b/Graphics/GraphicsEngineOpenGL/include/Texture2D_OGL.h
@@ -31,21 +31,21 @@ 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* 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(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ class RenderDeviceGLImpl* pDeviceGL,
+ class GLContextState& GLState,
+ const TextureDesc& TexDesc,
+ const TextureData* pInitData = nullptr,
+ bool bIsDeviceInternal = false);
+
+ Texture2D_OGL(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ class RenderDeviceGLImpl* pDeviceGL,
+ class GLContextState& GLState,
+ const TextureDesc& TexDesc,
+ GLuint GLTextureHandle,
+ bool bIsDeviceInternal = false);
~Texture2D_OGL();
virtual void UpdateData( class GLContextState& CtxState,
diff --git a/Graphics/GraphicsEngineOpenGL/include/Texture3D_OGL.h b/Graphics/GraphicsEngineOpenGL/include/Texture3D_OGL.h
index 351f779f..fbe61ae2 100644
--- a/Graphics/GraphicsEngineOpenGL/include/Texture3D_OGL.h
+++ b/Graphics/GraphicsEngineOpenGL/include/Texture3D_OGL.h
@@ -31,21 +31,21 @@ 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* 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(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ class RenderDeviceGLImpl* pDeviceGL,
+ class GLContextState& GLState,
+ const TextureDesc& TexDesc,
+ const TextureData* pInitData = nullptr,
+ bool bIsDeviceInternal = false);
+
+ Texture3D_OGL(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ class RenderDeviceGLImpl* pDeviceGL,
+ class GLContextState& GLState,
+ const TextureDesc& TexDesc,
+ GLuint GLTextureHandle,
+ bool bIsDeviceInternal = false);
~Texture3D_OGL();
virtual void UpdateData(class GLContextState& CtxState,
diff --git a/Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.h b/Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.h
index 5bdbad54..305f133b 100644
--- a/Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.h
+++ b/Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.h
@@ -44,19 +44,19 @@ public:
using TTextureBase = TextureBase<ITextureGL, RenderDeviceGLImpl, TextureViewGLImpl, FixedBlockMemoryAllocator>;
using ViewImplType = TextureViewGLImpl;
- TextureBaseGL(IReferenceCounters* pRefCounters,
- FixedBlockMemoryAllocator& TexViewObjAllocator,
- RenderDeviceGLImpl* pDeviceGL,
- const TextureDesc& TexDesc,
+ 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,
+ TextureBaseGL(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ RenderDeviceGLImpl* pDeviceGL,
+ GLContextState& GLState,
+ const TextureDesc& TexDesc,
GLuint GLTextureHandle,
GLenum BindTarget,
bool bIsDeviceInternal);
diff --git a/Graphics/GraphicsEngineOpenGL/include/TextureCubeArray_OGL.h b/Graphics/GraphicsEngineOpenGL/include/TextureCubeArray_OGL.h
index 44ed106c..b2c3217f 100644
--- a/Graphics/GraphicsEngineOpenGL/include/TextureCubeArray_OGL.h
+++ b/Graphics/GraphicsEngineOpenGL/include/TextureCubeArray_OGL.h
@@ -31,19 +31,19 @@ namespace Diligent
class TextureCubeArray_OGL final : public TextureBaseGL
{
public:
- TextureCubeArray_OGL( IReferenceCounters* pRefCounters,
+ TextureCubeArray_OGL(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ class RenderDeviceGLImpl* pDeviceGL,
+ class GLContextState& GLState,
+ 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,
- const TextureData* pInitData = nullptr,
- bool bIsDeviceInternal = false );
-
- TextureCubeArray_OGL( IReferenceCounters* pRefCounters,
- FixedBlockMemoryAllocator& TexViewObjAllocator,
- class RenderDeviceGLImpl* pDeviceGL,
- class DeviceContextGLImpl* pDeviceContext,
- const TextureDesc& TexDesc,
+ class RenderDeviceGLImpl* pDeviceGL,
+ class GLContextState& GLState,
+ const TextureDesc& TexDesc,
GLuint GLTextureHandle,
bool bIsDeviceInternal = false);
~TextureCubeArray_OGL();
diff --git a/Graphics/GraphicsEngineOpenGL/include/TextureCube_OGL.h b/Graphics/GraphicsEngineOpenGL/include/TextureCube_OGL.h
index ee0ce688..8e85ec0c 100644
--- a/Graphics/GraphicsEngineOpenGL/include/TextureCube_OGL.h
+++ b/Graphics/GraphicsEngineOpenGL/include/TextureCube_OGL.h
@@ -31,21 +31,21 @@ 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* 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(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ class RenderDeviceGLImpl* pDeviceGL,
+ class GLContextState& GLState,
+ const TextureDesc& TexDesc,
+ const TextureData* pInitData = nullptr,
+ bool bIsDeviceInternal = false);
+
+ TextureCube_OGL(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ class RenderDeviceGLImpl* pDeviceGL,
+ class GLContextState& GLState,
+ const TextureDesc& TexDesc,
+ GLuint GLTextureHandle,
+ bool bIsDeviceInternal = false);
~TextureCube_OGL();
virtual void UpdateData(class GLContextState& CtxState,
@@ -54,8 +54,8 @@ public:
const Box& DstBox,
const TextureSubResData& SubresData)override final;
- virtual void AttachToFramebuffer( const struct TextureViewDesc& ViewDesc,
- GLenum AttachmentPoint )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 b4b7802c..50e462e8 100644
--- a/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp
@@ -70,6 +70,7 @@ static GLenum GetBufferBindTarget(const BufferDesc& Desc)
BufferGLImpl::BufferGLImpl(IReferenceCounters* pRefCounters,
FixedBlockMemoryAllocator& BuffViewObjMemAllocator,
RenderDeviceGLImpl* pDeviceGL,
+ DeviceContextGLImpl* pCtxGL,
const BufferDesc& BuffDesc,
const BufferData* pBuffData /*= nullptr*/,
bool bIsDeviceInternal) :
@@ -83,6 +84,13 @@ BufferGLImpl::BufferGLImpl(IReferenceCounters* pRefCounters,
LOG_ERROR_AND_THROW("Static buffer must be initialized with data at creation time");
auto Target = GetBufferBindTarget(BuffDesc);
+
+ if (Target == GL_ARRAY_BUFFER || Target == GL_ELEMENT_ARRAY_BUFFER)
+ {
+ // We must unbind VAO because otherwise we will break the bindings
+ pCtxGL->ResetVAO();
+ }
+
// 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);
@@ -138,12 +146,18 @@ BufferGLImpl::BufferGLImpl(IReferenceCounters* pRefCounters,
glBindBuffer(Target, 0);
}
-static BufferDesc GetBufferDescFromGLHandle(BufferDesc BuffDesc, GLuint BufferHandle)
+static BufferDesc GetBufferDescFromGLHandle(DeviceContextGLImpl* pCtxGL, BufferDesc BuffDesc, GLuint BufferHandle)
{
// NOTE: the operations in this function are merely for debug purposes.
// If binding a buffer to a target does not work, these operations can be skipped
GLenum BindTarget = GetBufferBindTarget(BuffDesc);
+ if (BindTarget == GL_ARRAY_BUFFER || BindTarget == GL_ELEMENT_ARRAY_BUFFER)
+ {
+ // We must unbind VAO because otherwise we will break the bindings
+ pCtxGL->ResetVAO();
+ }
+
glBindBuffer(BindTarget, BufferHandle);
CHECK_GL_ERROR("Failed to bind GL buffer to ", BindTarget, " target");
@@ -162,13 +176,14 @@ static BufferDesc GetBufferDescFromGLHandle(BufferDesc BuffDesc, GLuint BufferHa
return BuffDesc;
}
-BufferGLImpl::BufferGLImpl(IReferenceCounters* pRefCounters,
- FixedBlockMemoryAllocator& BuffViewObjMemAllocator,
- RenderDeviceGLImpl* pDeviceGL,
- const BufferDesc& BuffDesc,
+BufferGLImpl::BufferGLImpl(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& BuffViewObjMemAllocator,
+ RenderDeviceGLImpl* pDeviceGL,
+ DeviceContextGLImpl* pCtxGL,
+ const BufferDesc& BuffDesc,
GLuint GLHandle,
bool bIsDeviceInternal) :
- TBufferBase( pRefCounters, BuffViewObjMemAllocator, pDeviceGL, GetBufferDescFromGLHandle(BuffDesc, GLHandle), bIsDeviceInternal),
+ TBufferBase( pRefCounters, BuffViewObjMemAllocator, pDeviceGL, GetBufferDescFromGLHandle(pCtxGL, BuffDesc, GLHandle), bIsDeviceInternal),
// Attach to external buffer handle
m_GlBuffer(true, GLObjectWrappers::GLBufferObjCreateReleaseHelper(GLHandle)),
m_uiMapTarget(0),
@@ -184,14 +199,17 @@ BufferGLImpl::~BufferGLImpl()
IMPLEMENT_QUERY_INTERFACE( BufferGLImpl, IID_BufferGL, TBufferBase )
-void BufferGLImpl :: UpdateData(GLContextState& CtxState, Uint32 Offset, Uint32 Size, const PVoid pData)
+void BufferGLImpl :: UpdateData(DeviceContextGLImpl* pCtxGL, Uint32 Offset, Uint32 Size, const PVoid pData)
{
+ // We must unbind VAO because otherwise we will break the bindings
+ pCtxGL->ResetVAO();
+
BufferMemoryBarrier(
GL_BUFFER_UPDATE_BARRIER_BIT,// Reads or writes to buffer objects via any OpenGL API functions that allow
// modifying their contents will reflect data written by shaders prior to the barrier.
// Additionally, writes via these commands issued after the barrier will wait on
// the completion of any shader writes to the same memory initiated prior to the barrier.
- CtxState);
+ pCtxGL->GetContextState());
glBindBuffer(GL_ARRAY_BUFFER, m_GlBuffer);
// All buffer bind targets (GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER etc.) relate to the same
diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
index 9a682e3a..db68bc29 100644
--- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
@@ -51,10 +51,10 @@ using namespace std;
namespace Diligent
{
DeviceContextGLImpl::DeviceContextGLImpl(IReferenceCounters* pRefCounters, class RenderDeviceGLImpl* pDeviceGL, bool bIsDeferred) :
- TDeviceContextBase(pRefCounters, pDeviceGL, bIsDeferred),
- m_ContextState (pDeviceGL),
- m_CommitedResourcesTentativeBarriers(0),
- m_DefaultFBO (false)
+ TDeviceContextBase (pRefCounters, pDeviceGL, bIsDeferred),
+ m_ContextState (pDeviceGL),
+ m_CommitedResourcesTentativeBarriers (0),
+ m_DefaultFBO (false)
{
m_BoundWritableTextures.reserve( 16 );
m_BoundWritableBuffers.reserve( 16 );
@@ -1108,7 +1108,7 @@ namespace Diligent
TDeviceContextBase::UpdateBuffer(pBuffer, Offset, Size, pData, StateTransitionMode);
auto* pBufferGL = ValidatedCast<BufferGLImpl>(pBuffer);
- pBufferGL->UpdateData(m_ContextState, Offset, Size, pData);
+ pBufferGL->UpdateData(this, Offset, Size, pData);
}
void DeviceContextGLImpl::CopyBuffer(IBuffer* pSrcBuffer,
@@ -1197,4 +1197,10 @@ namespace Diligent
{
}
+
+ void DeviceContextGLImpl::ResetVAO()
+ {
+ m_bVAOIsUpToDate = false;
+ m_ContextState.BindVAO(GLObjectWrappers::GLVertexArrayObj{false});
+ }
}
diff --git a/Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp b/Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp
index 15bc60e6..fca37d8e 100644
--- a/Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp
@@ -140,6 +140,9 @@ void EngineFactoryOpenGLImpl::CreateDeviceAndSwapChainGL(const EngineGLCreateInf
pDeviceContextOpenGL->QueryInterface(IID_DeviceContext, reinterpret_cast<IObject**>(ppImmediateContext) );
pRenderDeviceOpenGL->SetImmediateContext(pDeviceContextOpenGL);
+ // Need to create immediate context first
+ pRenderDeviceOpenGL->InitTexRegionRender();
+
TSwapChain *pSwapChainGL = NEW_RC_OBJ(RawMemAllocator, "SwapChainGLImpl instance", TSwapChain)(EngineCI, SCDesc, pRenderDeviceOpenGL, pDeviceContextOpenGL );
pSwapChainGL->QueryInterface(IID_SwapChain, reinterpret_cast<IObject**>(ppSwapChain) );
diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp b/Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp
index 8cc2c98b..4d0b2bad 100644
--- a/Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp
@@ -151,7 +151,6 @@ namespace Diligent
GLuint VAOHandle = 0;
if( UpdateBoundObject( m_VAOId, VAO, VAOHandle ) )
{
- VERIFY( VAOHandle, "VAO Handle is zero" );
glBindVertexArray( VAOHandle );
CHECK_GL_ERROR( "Failed to set VAO" );
}
diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
index 22111b39..0df97e66 100644
--- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
@@ -72,8 +72,7 @@ RenderDeviceGLImpl :: RenderDeviceGLImpl(IReferenceCounters* pRefCounters
}
},
// Device caps must be filled in before the constructor of Pipeline Cache is called!
- m_GLContext(InitAttribs, m_DeviceCaps, pSCDesc),
- m_TexRegionRender(this)
+ m_GLContext(InitAttribs, m_DeviceCaps, pSCDesc)
{
GLint NumExtensions = 0;
glGetIntegerv( GL_NUM_EXTENSIONS,& NumExtensions );
@@ -110,13 +109,22 @@ RenderDeviceGLImpl :: ~RenderDeviceGLImpl()
IMPLEMENT_QUERY_INTERFACE( RenderDeviceGLImpl, IID_RenderDeviceGL, TRenderDeviceBase )
+void RenderDeviceGLImpl :: InitTexRegionRender()
+{
+ m_pTexRegionRender.reset(new TexRegionRender(this));
+}
+
void RenderDeviceGLImpl :: CreateBuffer(const BufferDesc& BuffDesc, const BufferData* pBuffData, IBuffer **ppBuffer, bool bIsDeviceInternal)
{
CreateDeviceObject( "buffer", BuffDesc, ppBuffer,
[&]()
{
+ auto spDeviceContext = GetImmediateContext();
+ VERIFY(spDeviceContext, "Immediate device context has been destroyed");
+ auto* pDeviceContextGL = spDeviceContext.RawPtr<DeviceContextGLImpl>();
+
BufferGLImpl *pBufferOGL( NEW_RC_OBJ(m_BufObjAllocator, "BufferGLImpl instance", BufferGLImpl)
- (m_BuffViewObjAllocator, this, BuffDesc, pBuffData, bIsDeviceInternal ) );
+ (m_BuffViewObjAllocator, this, pDeviceContextGL, BuffDesc, pBuffData, bIsDeviceInternal ) );
pBufferOGL->QueryInterface( IID_Buffer, reinterpret_cast<IObject**>(ppBuffer) );
pBufferOGL->CreateDefaultViews();
OnCreateDeviceObject( pBufferOGL );
@@ -135,8 +143,12 @@ void RenderDeviceGLImpl :: CreateBufferFromGLHandle(Uint32 GLHandle, const Buffe
CreateDeviceObject( "buffer", BuffDesc, ppBuffer,
[&]()
{
+ auto spDeviceContext = GetImmediateContext();
+ VERIFY(spDeviceContext, "Immediate device context has been destroyed");
+ auto* pDeviceContextGL = spDeviceContext.RawPtr<DeviceContextGLImpl>();
+
BufferGLImpl *pBufferOGL( NEW_RC_OBJ(m_BufObjAllocator, "BufferGLImpl instance", BufferGLImpl)
- (m_BuffViewObjAllocator, this, BuffDesc, GLHandle, false ) );
+ (m_BuffViewObjAllocator, this, pDeviceContextGL, BuffDesc, GLHandle, false ) );
pBufferOGL->QueryInterface( IID_Buffer, reinterpret_cast<IObject**>(ppBuffer) );
pBufferOGL->CreateDefaultViews();
OnCreateDeviceObject( pBufferOGL );
@@ -170,7 +182,8 @@ void RenderDeviceGLImpl :: CreateTexture(const TextureDesc& TexDesc, const Textu
{
auto spDeviceContext = GetImmediateContext();
VERIFY(spDeviceContext, "Immediate device context has been destroyed");
- auto pDeviceContext = spDeviceContext.RawPtr<DeviceContextGLImpl>();
+ auto& GLState = spDeviceContext.RawPtr<DeviceContextGLImpl>()->GetContextState();
+
const auto& FmtInfo = GetTextureFormatInfo( TexDesc.Format );
if( !FmtInfo.Supported )
{
@@ -182,37 +195,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, pData, bIsDeviceInternal);
+ (m_TexViewObjAllocator, this, GLState, 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, pData, bIsDeviceInternal);
+ (m_TexViewObjAllocator, this, GLState, 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, pData, bIsDeviceInternal);
+ (m_TexViewObjAllocator, this, GLState, 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, pData, bIsDeviceInternal);
+ (m_TexViewObjAllocator, this, GLState, 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, pData, bIsDeviceInternal);
+ (m_TexViewObjAllocator, this, GLState, 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, pData, bIsDeviceInternal);
+ (m_TexViewObjAllocator, this, GLState, 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, pData, bIsDeviceInternal);
+ (m_TexViewObjAllocator, this, GLState, TexDesc, pData, bIsDeviceInternal);
break;
default: LOG_ERROR_AND_THROW( "Unknown texture type. (Did you forget to initialize the Type member of TextureDesc structure?)" );
@@ -238,43 +251,44 @@ void RenderDeviceGLImpl::CreateTextureFromGLHandle(Uint32 GLHandle, const Textur
{
auto spDeviceContext = GetImmediateContext();
VERIFY(spDeviceContext, "Immediate device context has been destroyed");
- auto pDeviceContext = spDeviceContext.RawPtr<DeviceContextGLImpl>();
+ auto& GLState = spDeviceContext.RawPtr<DeviceContextGLImpl>()->GetContextState();
+
TextureBaseGL *pTextureOGL = nullptr;
switch(TexDesc.Type)
{
case RESOURCE_DIM_TEX_1D:
pTextureOGL = NEW_RC_OBJ(m_TexObjAllocator, "Texture1D_OGL instance", Texture1D_OGL)
- (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, GLHandle);
+ (m_TexViewObjAllocator, this, GLState, TexDesc, GLHandle);
break;
case RESOURCE_DIM_TEX_1D_ARRAY:
pTextureOGL = NEW_RC_OBJ(m_TexObjAllocator, "Texture1DArray_OGL instance", Texture1DArray_OGL)
- (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, GLHandle);
+ (m_TexViewObjAllocator, this, GLState, TexDesc, GLHandle);
break;
case RESOURCE_DIM_TEX_2D:
pTextureOGL = NEW_RC_OBJ(m_TexObjAllocator, "Texture2D_OGL instance", Texture2D_OGL)
- (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, GLHandle);
+ (m_TexViewObjAllocator, this, GLState, TexDesc, GLHandle);
break;
case RESOURCE_DIM_TEX_2D_ARRAY:
pTextureOGL = NEW_RC_OBJ(m_TexObjAllocator, "Texture2DArray_OGL instance", Texture2DArray_OGL)
- (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, GLHandle);
+ (m_TexViewObjAllocator, this, GLState, TexDesc, GLHandle);
break;
case RESOURCE_DIM_TEX_3D:
pTextureOGL = NEW_RC_OBJ(m_TexObjAllocator, "Texture3D_OGL instance", Texture3D_OGL)
- (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, GLHandle);
+ (m_TexViewObjAllocator, this, GLState, TexDesc, GLHandle);
break;
case RESOURCE_DIM_TEX_CUBE:
pTextureOGL = NEW_RC_OBJ(m_TexObjAllocator, "TextureCube_OGL instance", TextureCube_OGL)
- (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, GLHandle);
+ (m_TexViewObjAllocator, this, GLState, TexDesc, GLHandle);
break;
case RESOURCE_DIM_TEX_CUBE_ARRAY:
pTextureOGL = NEW_RC_OBJ(m_TexObjAllocator, "TextureCubeArray_OGL instance", TextureCubeArray_OGL)
- (m_TexViewObjAllocator, this, pDeviceContext, TexDesc, GLHandle);
+ (m_TexViewObjAllocator, this, GLState, TexDesc, GLHandle);
break;
default: LOG_ERROR_AND_THROW( "Unknown texture type. (Did you forget to initialize the Type member of TextureDesc structure?)" );
diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture1DArray_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture1DArray_OGL.cpp
index a559559b..ccb3cb20 100644
--- a/Graphics/GraphicsEngineOpenGL/src/Texture1DArray_OGL.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/Texture1DArray_OGL.cpp
@@ -32,19 +32,17 @@
namespace Diligent
{
-Texture1DArray_OGL::Texture1DArray_OGL( IReferenceCounters* pRefCounters,
- FixedBlockMemoryAllocator& TexViewObjAllocator,
- RenderDeviceGLImpl* pDeviceGL,
- DeviceContextGLImpl* pDeviceContext,
- const TextureDesc& TexDesc,
- const TextureData* pInitData /*= nullptr*/,
- bool bIsDeviceInternal /*= false*/) :
+Texture1DArray_OGL::Texture1DArray_OGL(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ RenderDeviceGLImpl* pDeviceGL,
+ GLContextState& GLState,
+ const TextureDesc& TexDesc,
+ const TextureData* pInitData /*= nullptr*/,
+ bool bIsDeviceInternal /*= false*/) :
TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, TexDesc,
GL_TEXTURE_1D_ARRAY, pInitData, bIsDeviceInternal)
{
- auto &ContextState = pDeviceContext->GetContextState();
-
- ContextState.BindTexture(-1, m_BindTarget, m_GlTexture);
+ GLState.BindTexture(-1, m_BindTarget, m_GlTexture);
// levels format width height
glTexStorage2D(m_BindTarget, m_Desc.MipLevels, m_GLTexFormat, m_Desc.Width, m_Desc.ArraySize);
@@ -72,7 +70,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, pInitData->pSubResources[Slice*m_Desc.MipLevels + Mip]);
+ Texture1DArray_OGL::UpdateData(GLState, Mip, Slice, DstBox, pInitData->pSubResources[Slice*m_Desc.MipLevels + Mip]);
}
}
}
@@ -82,17 +80,17 @@ Texture1DArray_OGL::Texture1DArray_OGL( IReferenceCounters* pRefCounters
}
}
- ContextState.BindTexture( -1, m_BindTarget, GLObjectWrappers::GLTextureObj( false ) );
+ GLState.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) :
- TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, pDeviceContext, TexDesc, GLTextureHandle, GL_TEXTURE_1D_ARRAY, bIsDeviceInternal)
+Texture1DArray_OGL::Texture1DArray_OGL(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ RenderDeviceGLImpl* pDeviceGL,
+ GLContextState& GLState,
+ const TextureDesc& TexDesc,
+ GLuint GLTextureHandle,
+ bool bIsDeviceInternal) :
+ TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, GLState, TexDesc, GLTextureHandle, GL_TEXTURE_1D_ARRAY, bIsDeviceInternal)
{
}
diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture1D_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture1D_OGL.cpp
index 8ef3da68..92fb1c02 100644
--- a/Graphics/GraphicsEngineOpenGL/src/Texture1D_OGL.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/Texture1D_OGL.cpp
@@ -35,16 +35,13 @@ namespace Diligent
Texture1D_OGL::Texture1D_OGL( IReferenceCounters* pRefCounters,
FixedBlockMemoryAllocator& TexViewObjAllocator,
RenderDeviceGLImpl* pDeviceGL,
- DeviceContextGLImpl* pDeviceContext,
+ GLContextState& GLState,
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();
-
- ContextState.BindTexture(-1, m_BindTarget, m_GlTexture);
+ GLState.BindTexture(-1, m_BindTarget, m_GlTexture);
// levels format width
glTexStorage1D(m_BindTarget, m_Desc.MipLevels, m_GLTexFormat, m_Desc.Width);
@@ -70,7 +67,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, pInitData->pSubResources[Mip] );
+ Texture1D_OGL::UpdateData( GLState, Mip, 0, DstBox, pInitData->pSubResources[Mip] );
}
}
else
@@ -79,17 +76,17 @@ Texture1D_OGL::Texture1D_OGL( IReferenceCounters* pRefCounters,
}
}
- ContextState.BindTexture(-1, m_BindTarget, GLObjectWrappers::GLTextureObj(false) );
+ GLState.BindTexture(-1, m_BindTarget, GLObjectWrappers::GLTextureObj(false) );
}
Texture1D_OGL::Texture1D_OGL( IReferenceCounters* pRefCounters,
FixedBlockMemoryAllocator& TexViewObjAllocator,
RenderDeviceGLImpl* pDeviceGL,
- DeviceContextGLImpl* pDeviceContext,
+ GLContextState& GLState,
const TextureDesc& TexDesc,
GLuint GLTextureHandle,
bool bIsDeviceInternal) :
- TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, pDeviceContext, TexDesc, GLTextureHandle, GL_TEXTURE_1D, bIsDeviceInternal)
+ TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, GLState, TexDesc, GLTextureHandle, GL_TEXTURE_1D, bIsDeviceInternal)
{
}
diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp
index 9b4b1b12..1ce9da56 100644
--- a/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp
@@ -36,14 +36,13 @@ namespace Diligent
Texture2DArray_OGL::Texture2DArray_OGL( IReferenceCounters* pRefCounters,
FixedBlockMemoryAllocator& TexViewObjAllocator,
RenderDeviceGLImpl* pDeviceGL,
- DeviceContextGLImpl* pDeviceContext,
+ GLContextState& GLState,
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);
+ GLState.BindTexture(-1, m_BindTarget, m_GlTexture);
if( m_Desc.SampleCount > 1 )
{
@@ -90,7 +89,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, pInitData->pSubResources[Slice*m_Desc.MipLevels + Mip]);
+ Texture2DArray_OGL::UpdateData(GLState, Mip, Slice, DstBox, pInitData->pSubResources[Slice*m_Desc.MipLevels + Mip]);
}
}
}
@@ -101,17 +100,17 @@ Texture2DArray_OGL::Texture2DArray_OGL( IReferenceCounters* pRefCounters
}
}
- ContextState.BindTexture( -1, m_BindTarget, GLObjectWrappers::GLTextureObj(false) );
+ GLState.BindTexture( -1, m_BindTarget, GLObjectWrappers::GLTextureObj(false) );
}
Texture2DArray_OGL::Texture2DArray_OGL( IReferenceCounters* pRefCounters,
FixedBlockMemoryAllocator& TexViewObjAllocator,
RenderDeviceGLImpl* pDeviceGL,
- DeviceContextGLImpl* pDeviceContext,
+ GLContextState& GLState,
const TextureDesc& TexDesc,
GLuint GLTextureHandle,
bool bIsDeviceInternal) :
- TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, pDeviceContext, TexDesc, GLTextureHandle,
+ TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, GLState, TexDesc, GLTextureHandle,
TexDesc.SampleCount > 1 ? GL_TEXTURE_2D_MULTISAMPLE_ARRAY : GL_TEXTURE_2D_ARRAY, bIsDeviceInternal)
{
}
diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp
index f010a5e9..c781a943 100644
--- a/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp
@@ -33,17 +33,16 @@
namespace Diligent
{
-Texture2D_OGL::Texture2D_OGL( IReferenceCounters* pRefCounters,
- FixedBlockMemoryAllocator& TexViewObjAllocator,
- RenderDeviceGLImpl* pDeviceGL,
- DeviceContextGLImpl* pDeviceContext,
- const TextureDesc& TexDesc,
- const TextureData* pInitData /*= nullptr*/,
- bool bIsDeviceInternal /*= false*/) :
+Texture2D_OGL::Texture2D_OGL( IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ RenderDeviceGLImpl* pDeviceGL,
+ GLContextState& GLState,
+ 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);
+ GLState.BindTexture(-1, m_BindTarget, m_GlTexture);
if( m_Desc.SampleCount > 1 )
{
@@ -94,7 +93,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, pInitData->pSubResources[Mip] );
+ Texture2D_OGL::UpdateData( GLState, Mip, 0, DstBox, pInitData->pSubResources[Mip] );
}
}
else
@@ -104,17 +103,17 @@ Texture2D_OGL::Texture2D_OGL( IReferenceCounters* pRefCounters,
}
}
- ContextState.BindTexture( -1, m_BindTarget, GLObjectWrappers::GLTextureObj(false) );
+ GLState.BindTexture( -1, m_BindTarget, GLObjectWrappers::GLTextureObj(false) );
}
-Texture2D_OGL::Texture2D_OGL( IReferenceCounters *pRefCounters,
- FixedBlockMemoryAllocator& TexViewObjAllocator,
- RenderDeviceGLImpl *pDeviceGL,
- DeviceContextGLImpl *pDeviceContext,
- const TextureDesc& TexDesc,
- GLuint GLTextureHandle,
- bool bIsDeviceInternal) :
- TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, pDeviceContext, TexDesc, GLTextureHandle,
+Texture2D_OGL::Texture2D_OGL( IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ RenderDeviceGLImpl* pDeviceGL,
+ GLContextState& GLState,
+ const TextureDesc& TexDesc,
+ GLuint GLTextureHandle,
+ bool bIsDeviceInternal) :
+ TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, GLState, TexDesc, GLTextureHandle,
TexDesc.SampleCount > 1 ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D, bIsDeviceInternal)
{
}
diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture3D_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture3D_OGL.cpp
index 77228eb1..ba766342 100644
--- a/Graphics/GraphicsEngineOpenGL/src/Texture3D_OGL.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/Texture3D_OGL.cpp
@@ -36,15 +36,14 @@ namespace Diligent
Texture3D_OGL::Texture3D_OGL( IReferenceCounters* pRefCounters,
FixedBlockMemoryAllocator& TexViewObjAllocator,
RenderDeviceGLImpl* pDeviceGL,
- DeviceContextGLImpl* pDeviceContext,
+ GLContextState& GLState,
const TextureDesc& TexDesc,
const TextureData* pInitData /*= TextureData()*/,
bool bIsDeviceInternal /*= false*/) :
TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, TexDesc,
GL_TEXTURE_3D, pInitData, bIsDeviceInternal)
{
- auto &ContextState = pDeviceContext->GetContextState();
- ContextState.BindTexture(-1, m_BindTarget, m_GlTexture);
+ GLState.BindTexture(-1, m_BindTarget, m_GlTexture);
// levels format width height depth
glTexStorage3D(m_BindTarget, m_Desc.MipLevels, m_GLTexFormat, m_Desc.Width, m_Desc.Height, m_Desc.Depth);
@@ -73,7 +72,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, pInitData->pSubResources[Mip] );
+ Texture3D_OGL::UpdateData( GLState, Mip, 0, DstBox, pInitData->pSubResources[Mip] );
}
}
else
@@ -82,17 +81,17 @@ Texture3D_OGL::Texture3D_OGL( IReferenceCounters* pRefCounters,
}
}
- ContextState.BindTexture( -1, m_BindTarget, GLObjectWrappers::GLTextureObj(false) );
+ GLState.BindTexture( -1, m_BindTarget, GLObjectWrappers::GLTextureObj(false) );
}
Texture3D_OGL::Texture3D_OGL( IReferenceCounters* pRefCounters,
FixedBlockMemoryAllocator& TexViewObjAllocator,
RenderDeviceGLImpl* pDeviceGL,
- DeviceContextGLImpl* pDeviceContext,
+ GLContextState& GLState,
const TextureDesc& TexDesc,
GLuint GLTextureHandle,
bool bIsDeviceInternal) :
- TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, pDeviceContext, TexDesc, GLTextureHandle, GL_TEXTURE_3D, bIsDeviceInternal)
+ TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, GLState, TexDesc, GLTextureHandle, GL_TEXTURE_3D, bIsDeviceInternal)
{
}
diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp
index 77e0c788..7786a9d4 100644
--- a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp
@@ -53,10 +53,9 @@ TextureBaseGL::TextureBaseGL(IReferenceCounters* pRefCounters,
LOG_ERROR_AND_THROW("Static Texture must be initialized with data at creation time");
}
-static GLenum GetTextureInternalFormat(DeviceContextGLImpl *pDeviceContextGL, GLenum BindTarget, const GLObjectWrappers::GLTextureObj& GLTex, TEXTURE_FORMAT TexFmtFromDesc)
+static GLenum GetTextureInternalFormat(GLContextState& GLState, GLenum BindTarget, const GLObjectWrappers::GLTextureObj& GLTex, TEXTURE_FORMAT TexFmtFromDesc)
{
- auto &ContextState = pDeviceContextGL->GetContextState();
- ContextState.BindTexture(-1, BindTarget, GLTex);
+ GLState.BindTexture(-1, BindTarget, GLTex);
GLenum QueryBindTarget = BindTarget;
if (BindTarget == GL_TEXTURE_CUBE_MAP || BindTarget == GL_TEXTURE_CUBE_MAP_ARRAY)
@@ -74,19 +73,17 @@ static GLenum GetTextureInternalFormat(DeviceContextGLImpl *pDeviceContextGL, GL
else
UNSUPPORTED("Texture format cannot be queried and must be provided by the texture description");
#endif
- ContextState.BindTexture(-1, BindTarget, GLObjectWrappers::GLTextureObj(false) );
+ GLState.BindTexture(-1, BindTarget, GLObjectWrappers::GLTextureObj(false) );
return GlFormat;
}
-static TextureDesc GetTextureDescFromGLHandle(DeviceContextGLImpl *pDeviceContextGL, TextureDesc TexDesc, GLuint GLHandle, GLenum BindTarget)
+static TextureDesc GetTextureDescFromGLHandle(GLContextState& GLState, TextureDesc TexDesc, GLuint GLHandle, GLenum BindTarget)
{
- auto &ContextState = pDeviceContextGL->GetContextState();
-
VERIFY(BindTarget != GL_TEXTURE_CUBE_MAP_ARRAY, "Cubemap arrays are not currently supported");
GLObjectWrappers::GLTextureObj TmpGLTexWrapper(true, GLObjectWrappers::GLTextureCreateReleaseHelper(GLHandle));
- ContextState.BindTexture(-1, BindTarget, TmpGLTexWrapper);
+ GLState.BindTexture(-1, BindTarget, TmpGLTexWrapper);
GLenum QueryBindTarget = BindTarget;
if (BindTarget == GL_TEXTURE_CUBE_MAP)
@@ -162,23 +159,23 @@ static TextureDesc GetTextureDescFromGLHandle(DeviceContextGLImpl *pDeviceContex
VERIFY(TexDesc.MipLevels != 0, "Unable to query the number of mip levels, so it must be specified by the texture description.");
}
- ContextState.BindTexture(-1, BindTarget, GLObjectWrappers::GLTextureObj(false) );
+ GLState.BindTexture(-1, BindTarget, GLObjectWrappers::GLTextureObj(false) );
return TexDesc;
}
-TextureBaseGL::TextureBaseGL(IReferenceCounters *pRefCounters,
- FixedBlockMemoryAllocator& TexViewObjAllocator,
- RenderDeviceGLImpl *pDeviceGL,
- DeviceContextGLImpl *pDeviceContext,
- const TextureDesc& TexDesc,
- GLuint GLTextureHandle,
- GLenum BindTarget,
- bool bIsDeviceInternal/* = false*/) :
- TTextureBase( pRefCounters, TexViewObjAllocator, pDeviceGL, GetTextureDescFromGLHandle(pDeviceContext, TexDesc, GLTextureHandle, BindTarget), bIsDeviceInternal ),
+TextureBaseGL::TextureBaseGL(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ RenderDeviceGLImpl* pDeviceGL,
+ GLContextState& GLState,
+ const TextureDesc& TexDesc,
+ GLuint GLTextureHandle,
+ GLenum BindTarget,
+ bool bIsDeviceInternal/* = false*/) :
+ TTextureBase( pRefCounters, TexViewObjAllocator, pDeviceGL, GetTextureDescFromGLHandle(GLState, TexDesc, GLTextureHandle, BindTarget), bIsDeviceInternal ),
// Create texture object wrapper, but use external texture handle
m_GlTexture(true, GLObjectWrappers::GLTextureCreateReleaseHelper(GLTextureHandle)),
m_BindTarget(BindTarget),
- m_GLTexFormat( GetTextureInternalFormat(pDeviceContext, BindTarget, m_GlTexture, TexDesc.Format) )
+ m_GLTexFormat( GetTextureInternalFormat(GLState, BindTarget, m_GlTexture, TexDesc.Format) )
{
}
@@ -363,16 +360,16 @@ void TextureBaseGL::UpdateData( GLContextState& CtxState, Uint32 MipLevel, Uin
//}
//
-void TextureBaseGL :: CopyData(DeviceContextGLImpl *pDeviceCtxGL,
- TextureBaseGL *pSrcTextureGL,
- Uint32 SrcMipLevel,
- Uint32 SrcSlice,
- const Box *pSrcBox,
- Uint32 DstMipLevel,
- Uint32 DstSlice,
- Uint32 DstX,
- Uint32 DstY,
- Uint32 DstZ)
+void TextureBaseGL :: CopyData(DeviceContextGLImpl* pDeviceCtxGL,
+ TextureBaseGL* pSrcTextureGL,
+ Uint32 SrcMipLevel,
+ Uint32 SrcSlice,
+ const Box* pSrcBox,
+ Uint32 DstMipLevel,
+ Uint32 DstSlice,
+ Uint32 DstX,
+ Uint32 DstY,
+ Uint32 DstZ)
{
const auto& SrcTexDesc = pSrcTextureGL->GetDesc();
@@ -435,7 +432,7 @@ void TextureBaseGL :: CopyData(DeviceContextGLImpl *pDeviceCtxGL,
VERIFY( &TexViewObjAllocator == &m_dbgTexViewObjAllocator, "Texture view allocator does not match allocator provided during texture initialization" );
}
#endif
- auto &TexRegionRender = pRenderDeviceGL->m_TexRegionRender;
+ auto& TexRegionRender = *pRenderDeviceGL->m_pTexRegionRender;
TexRegionRender.SetStates(pDeviceCtxGL);
// Create temporary SRV for the entire source texture
diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp
index d3bb4d2d..76544f2f 100644
--- a/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp
@@ -36,7 +36,7 @@ namespace Diligent
TextureCubeArray_OGL::TextureCubeArray_OGL( IReferenceCounters* pRefCounters,
FixedBlockMemoryAllocator& TexViewObjAllocator,
RenderDeviceGLImpl* pDeviceGL,
- DeviceContextGLImpl* pDeviceContext,
+ GLContextState& GLState,
const TextureDesc& TexDesc,
const TextureData* pInitData /*= nullptr*/,
bool bIsDeviceInternal /*= false*/) :
@@ -44,8 +44,7 @@ TextureCubeArray_OGL::TextureCubeArray_OGL( IReferenceCounters* pRefCoun
{
VERIFY(m_Desc.SampleCount == 1, "Multisampled texture cube arrays are not supported");
- auto &ContextState = pDeviceContext->GetContextState();
- ContextState.BindTexture(-1, m_BindTarget, m_GlTexture);
+ GLState.BindTexture(-1, m_BindTarget, m_GlTexture);
// Every OpenGL API call that operates on cubemap array textures takes layer-faces, not array layers.
// For example, when you allocate storage for the texture, you would use glTexStorage3D? or glTexImage3D? or similar.
@@ -79,7 +78,7 @@ TextureCubeArray_OGL::TextureCubeArray_OGL( IReferenceCounters* pRefCoun
// 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, pInitData->pSubResources[Slice*m_Desc.MipLevels + Mip]);
+ TextureCubeArray_OGL::UpdateData(GLState, Mip, Slice, DstBox, pInitData->pSubResources[Slice*m_Desc.MipLevels + Mip]);
}
}
}
@@ -89,17 +88,17 @@ TextureCubeArray_OGL::TextureCubeArray_OGL( IReferenceCounters* pRefCoun
}
}
- ContextState.BindTexture( -1, m_BindTarget, GLObjectWrappers::GLTextureObj(false) );
+ GLState.BindTexture( -1, m_BindTarget, GLObjectWrappers::GLTextureObj(false) );
}
-TextureCubeArray_OGL::TextureCubeArray_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_CUBE_MAP_ARRAY, bIsDeviceInternal)
+TextureCubeArray_OGL::TextureCubeArray_OGL( IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ RenderDeviceGLImpl* pDeviceGL,
+ GLContextState& GLState,
+ const TextureDesc& TexDesc,
+ GLuint GLTextureHandle,
+ bool bIsDeviceInternal) :
+ TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, GLState, TexDesc, GLTextureHandle, GL_TEXTURE_CUBE_MAP_ARRAY, bIsDeviceInternal)
{
}
diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp
index 686e3919..ac0e089b 100644
--- a/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp
@@ -33,10 +33,10 @@
namespace Diligent
{
-TextureCube_OGL::TextureCube_OGL( IReferenceCounters* pRefCounters,
+TextureCube_OGL::TextureCube_OGL( IReferenceCounters* pRefCounters,
FixedBlockMemoryAllocator& TexViewObjAllocator,
- class RenderDeviceGLImpl* pDeviceGL,
- class DeviceContextGLImpl* pDeviceContext,
+ class RenderDeviceGLImpl* pDeviceGL,
+ GLContextState& GLState,
const TextureDesc& TexDesc,
const TextureData* pInitData /*= nullptr*/,
bool bIsDeviceInternal /*= false*/) :
@@ -44,8 +44,7 @@ TextureCube_OGL::TextureCube_OGL( IReferenceCounters* pRefCounters,
{
VERIFY(m_Desc.SampleCount == 1, "Multisampled cubemap textures are not supported");
- auto &ContextState = pDeviceContext->GetContextState();
- ContextState.BindTexture(-1, m_BindTarget, m_GlTexture);
+ GLState.BindTexture(-1, m_BindTarget, m_GlTexture);
VERIFY( m_Desc.ArraySize == 6, "Cubemap texture is expected to have 6 slices");
// levels format width height
@@ -77,7 +76,7 @@ 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, pInitData->pSubResources[Face*m_Desc.MipLevels + Mip] );
+ TextureCube_OGL::UpdateData( GLState, Mip, Face, DstBox, pInitData->pSubResources[Face*m_Desc.MipLevels + Mip] );
}
}
}
@@ -87,17 +86,17 @@ TextureCube_OGL::TextureCube_OGL( IReferenceCounters* pRefCounters,
}
}
- ContextState.BindTexture( -1, m_BindTarget, GLObjectWrappers::GLTextureObj(false) );
+ GLState.BindTexture( -1, m_BindTarget, GLObjectWrappers::GLTextureObj(false) );
}
-TextureCube_OGL::TextureCube_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_CUBE_MAP, bIsDeviceInternal)
+TextureCube_OGL::TextureCube_OGL( IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ RenderDeviceGLImpl* pDeviceGL,
+ GLContextState& GLState,
+ const TextureDesc& TexDesc,
+ GLuint GLTextureHandle,
+ bool bIsDeviceInternal) :
+ TextureBaseGL(pRefCounters, TexViewObjAllocator, pDeviceGL, GLState, TexDesc, GLTextureHandle, GL_TEXTURE_CUBE_MAP, bIsDeviceInternal)
{
}