summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineOpenGL
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-08-09 16:15:55 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-08-09 16:15:55 +0000
commit2fd9fdeb05ced45886718650ff5eeb812f0d180b (patch)
tree6c14f9db05dc37124d727df1c75d4b4f016f0c33 /Graphics/GraphicsEngineOpenGL
parentOpenGL backend: added handling of Buffers and RW Buffers (diff)
downloadDiligentCore-2fd9fdeb05ced45886718650ff5eeb812f0d180b.tar.gz
DiligentCore-2fd9fdeb05ced45886718650ff5eeb812f0d180b.zip
Cosmetic code changes
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h64
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp246
2 files changed, 156 insertions, 154 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h
index 2be0a192..96653441 100644
--- a/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h
+++ b/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h
@@ -48,44 +48,44 @@ class DeviceContextGLImpl final : public DeviceContextBase<IDeviceContextGL, Dev
public:
using TDeviceContextBase = DeviceContextBase<IDeviceContextGL, DeviceContextGLImplTraits>;
- DeviceContextGLImpl( IReferenceCounters *pRefCounters, class RenderDeviceGLImpl *pDeviceGL, bool bIsDeferred );
+ DeviceContextGLImpl(IReferenceCounters* pRefCounters, class RenderDeviceGLImpl* pDeviceGL, bool bIsDeferred);
/// Queries the specific interface, see IObject::QueryInterface() for details.
virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface )override final;
- virtual void SetPipelineState(IPipelineState *pPipelineState)override final;
+ virtual void SetPipelineState(IPipelineState* pPipelineState)override final;
- virtual void TransitionShaderResources(IPipelineState *pPipelineState, IShaderResourceBinding *pShaderResourceBinding)override final;
+ virtual void TransitionShaderResources(IPipelineState* pPipelineState, IShaderResourceBinding* pShaderResourceBinding)override final;
- virtual void CommitShaderResources(IShaderResourceBinding *pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)override final;
+ virtual void CommitShaderResources(IShaderResourceBinding* pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)override final;
virtual void SetStencilRef(Uint32 StencilRef)override final;
virtual void SetBlendFactors(const float* pBlendFactors = nullptr)override final;
- virtual void SetVertexBuffers( Uint32 StartSlot,
- Uint32 NumBuffersSet,
- IBuffer** ppBuffers,
- Uint32* pOffsets,
- RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
- SET_VERTEX_BUFFERS_FLAGS Flags )override final;
+ virtual void SetVertexBuffers(Uint32 StartSlot,
+ Uint32 NumBuffersSet,
+ IBuffer** ppBuffers,
+ Uint32* pOffsets,
+ RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
+ SET_VERTEX_BUFFERS_FLAGS Flags)override final;
virtual void InvalidateState()override final;
- virtual void SetIndexBuffer( IBuffer *pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode )override final;
+ virtual void SetIndexBuffer(IBuffer* pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)override final;
- virtual void SetViewports( Uint32 NumViewports, const Viewport *pViewports, Uint32 RTWidth, Uint32 RTHeight )override final;
+ virtual void SetViewports(Uint32 NumViewports, const Viewport* pViewports, Uint32 RTWidth, Uint32 RTHeight)override final;
- virtual void SetScissorRects( Uint32 NumRects, const Rect *pRects, Uint32 RTWidth, Uint32 RTHeight )override final;
+ virtual void SetScissorRects(Uint32 NumRects, const Rect *pRects, Uint32 RTWidth, Uint32 RTHeight)override final;
- virtual void SetRenderTargets( Uint32 NumRenderTargets,
- ITextureView* ppRenderTargets[],
- ITextureView* pDepthStencil,
- RESOURCE_STATE_TRANSITION_MODE StateTransitionMode )override final;
+ virtual void SetRenderTargets(Uint32 NumRenderTargets,
+ ITextureView* ppRenderTargets[],
+ ITextureView* pDepthStencil,
+ RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)override final;
- virtual void Draw( DrawAttribs &DrawAttribs )override final;
+ virtual void Draw(DrawAttribs& DrawAttribs)override final;
- virtual void DispatchCompute( const DispatchComputeAttribs &DispatchAttrs )override final;
+ virtual void DispatchCompute(const DispatchComputeAttribs& DispatchAttrs)override final;
virtual void ClearDepthStencil(ITextureView* pView,
CLEAR_DEPTH_STENCIL_FLAGS ClearFlags,
@@ -93,7 +93,7 @@ public:
Uint8 Stencil,
RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)override final;
- virtual void ClearRenderTarget( ITextureView *pView, const float *RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode )override final;
+ virtual void ClearRenderTarget(ITextureView* pView, const float* RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)override final;
virtual void Flush()override final;
@@ -125,34 +125,34 @@ public:
virtual void CopyTexture(const CopyTextureAttribs& CopyAttribs)override final;
- virtual void MapTextureSubresource( ITexture* pTexture,
- Uint32 MipLevel,
- Uint32 ArraySlice,
- MAP_TYPE MapType,
- MAP_FLAGS MapFlags,
- const Box* pMapRegion,
- MappedTextureSubresource& MappedData )override final;
+ virtual void MapTextureSubresource(ITexture* pTexture,
+ Uint32 MipLevel,
+ Uint32 ArraySlice,
+ MAP_TYPE MapType,
+ MAP_FLAGS MapFlags,
+ const Box* pMapRegion,
+ MappedTextureSubresource& MappedData)override final;
virtual void UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice)override final;
- virtual void GenerateMips( ITextureView *pTexView )override;
+ virtual void GenerateMips(ITextureView* pTexView)override;
virtual void FinishFrame()override final;
virtual void TransitionResourceStates(Uint32 BarrierCount, StateTransitionDesc* pResourceBarriers)override final;
- virtual void FinishCommandList(class ICommandList **ppCommandList)override final;
+ virtual void FinishCommandList(class ICommandList** ppCommandList)override final;
- virtual void ExecuteCommandList(class ICommandList *pCommandList)override final;
+ virtual void ExecuteCommandList(class ICommandList* pCommandList)override final;
virtual void SignalFence(IFence* pFence, Uint64 Value)override final;
virtual bool UpdateCurrentGLContext()override final;
- void BindProgramResources( Uint32 &NewMemoryBarriers, IShaderResourceBinding *pResBinding );
+ void BindProgramResources(Uint32& NewMemoryBarriers, IShaderResourceBinding* pResBinding);
GLContextState &GetContextState(){return m_ContextState;}
@@ -169,7 +169,7 @@ private:
Uint32 m_CommitedResourcesTentativeBarriers;
std::vector<class TextureBaseGL*> m_BoundWritableTextures;
- std::vector<class BufferGLImpl*> m_BoundWritableBuffers;
+ std::vector<class BufferGLImpl*> m_BoundWritableBuffers;
bool m_bVAOIsUpToDate = false;
GLObjectWrappers::GLFrameBufferObj m_DefaultFBO;
diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
index 0dfff8a5..77342fa0 100644
--- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
@@ -50,11 +50,11 @@ using namespace std;
namespace Diligent
{
- DeviceContextGLImpl::DeviceContextGLImpl( IReferenceCounters *pRefCounters, class RenderDeviceGLImpl *pDeviceGL, bool bIsDeferred ) :
+ DeviceContextGLImpl::DeviceContextGLImpl(IReferenceCounters* pRefCounters, class RenderDeviceGLImpl* pDeviceGL, bool bIsDeferred) :
TDeviceContextBase(pRefCounters, pDeviceGL, bIsDeferred),
- m_ContextState(pDeviceGL),
+ m_ContextState (pDeviceGL),
m_CommitedResourcesTentativeBarriers(0),
- m_DefaultFBO(false)
+ m_DefaultFBO (false)
{
m_BoundWritableTextures.reserve( 16 );
m_BoundWritableBuffers.reserve( 16 );
@@ -133,21 +133,21 @@ namespace Diligent
}
}
- void DeviceContextGLImpl::TransitionShaderResources(IPipelineState *pPipelineState, IShaderResourceBinding *pShaderResourceBinding)
+ void DeviceContextGLImpl::TransitionShaderResources(IPipelineState* pPipelineState, IShaderResourceBinding* pShaderResourceBinding)
{
}
- void DeviceContextGLImpl::CommitShaderResources(IShaderResourceBinding *pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)
+ void DeviceContextGLImpl::CommitShaderResources(IShaderResourceBinding* pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)
{
- if(!DeviceContextBase::CommitShaderResources(pShaderResourceBinding, StateTransitionMode, 0))
+ if (!DeviceContextBase::CommitShaderResources(pShaderResourceBinding, StateTransitionMode, 0))
return;
- if(m_CommitedResourcesTentativeBarriers != 0)
+ if (m_CommitedResourcesTentativeBarriers != 0)
LOG_INFO_MESSAGE("Not all tentative resource barriers have been executed since the last call to CommitShaderResources(). Did you forget to call Draw()/DispatchCompute() ?");
m_CommitedResourcesTentativeBarriers = 0;
- BindProgramResources( m_CommitedResourcesTentativeBarriers, pShaderResourceBinding );
+ BindProgramResources(m_CommitedResourcesTentativeBarriers, pShaderResourceBinding);
// m_CommitedResourcesTentativeBarriers will contain memory barriers that will be required
// AFTER the actual draw/dispatch command is executed. Before that they have no meaning
}
@@ -169,14 +169,14 @@ namespace Diligent
}
}
- void DeviceContextGLImpl::SetVertexBuffers( Uint32 StartSlot,
- Uint32 NumBuffersSet,
- IBuffer** ppBuffers,
- Uint32* pOffsets,
- RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
- SET_VERTEX_BUFFERS_FLAGS Flags )
+ void DeviceContextGLImpl::SetVertexBuffers(Uint32 StartSlot,
+ Uint32 NumBuffersSet,
+ IBuffer** ppBuffers,
+ Uint32* pOffsets,
+ RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
+ SET_VERTEX_BUFFERS_FLAGS Flags)
{
- TDeviceContextBase::SetVertexBuffers( StartSlot, NumBuffersSet, ppBuffers, pOffsets, StateTransitionMode, Flags );
+ TDeviceContextBase::SetVertexBuffers(StartSlot, NumBuffersSet, ppBuffers, pOffsets, StateTransitionMode, Flags);
m_bVAOIsUpToDate = false;
}
@@ -190,18 +190,18 @@ namespace Diligent
m_bVAOIsUpToDate = false;
}
- void DeviceContextGLImpl::SetIndexBuffer( IBuffer *pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode )
+ void DeviceContextGLImpl::SetIndexBuffer(IBuffer* pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)
{
- TDeviceContextBase::SetIndexBuffer( pIndexBuffer, ByteOffset, StateTransitionMode );
+ TDeviceContextBase::SetIndexBuffer(pIndexBuffer, ByteOffset, StateTransitionMode);
m_bVAOIsUpToDate = false;
}
- void DeviceContextGLImpl::SetViewports( Uint32 NumViewports, const Viewport *pViewports, Uint32 RTWidth, Uint32 RTHeight )
+ void DeviceContextGLImpl::SetViewports(Uint32 NumViewports, const Viewport* pViewports, Uint32 RTWidth, Uint32 RTHeight)
{
- TDeviceContextBase::SetViewports( NumViewports, pViewports, RTWidth, RTHeight );
+ TDeviceContextBase::SetViewports(NumViewports, pViewports, RTWidth, RTHeight);
- VERIFY( NumViewports == m_NumViewports, "Unexpected number of viewports" );
- if( NumViewports == 1 )
+ VERIFY(NumViewports == m_NumViewports, "Unexpected number of viewports");
+ if (NumViewports == 1)
{
const auto& vp = m_Viewports[0];
// Note that OpenGL and DirectX use different origin of
@@ -231,40 +231,40 @@ namespace Diligent
{
// GL_INVALID_VALUE is generated if either width or height is negative
// https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glViewport.xml
- glViewport( x, y, w, h );
+ glViewport(x, y, w, h);
}
else
{
// GL_INVALID_VALUE is generated if either width or height is negative
// https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glViewportIndexed.xhtml
- glViewportIndexedf( 0, BottomLeftX, BottomLeftY, vp.Width, vp.Height );
+ glViewportIndexedf(0, BottomLeftX, BottomLeftY, vp.Width, vp.Height);
}
- CHECK_GL_ERROR( "Failed to set viewport" );
+ CHECK_GL_ERROR("Failed to set viewport");
- glDepthRangef( vp.MinDepth, vp.MaxDepth );
- CHECK_GL_ERROR( "Failed to set depth range" );
+ glDepthRangef(vp.MinDepth, vp.MaxDepth);
+ CHECK_GL_ERROR("Failed to set depth range");
}
else
{
- for( Uint32 i = 0; i < NumViewports; ++i )
+ for (Uint32 i = 0; i < NumViewports; ++i)
{
const auto& vp = m_Viewports[i];
float BottomLeftY = static_cast<float>(RTHeight) - (vp.TopLeftY + vp.Height);
float BottomLeftX = vp.TopLeftX;
- glViewportIndexedf( i, BottomLeftX, BottomLeftY, vp.Width, vp.Height );
- CHECK_GL_ERROR( "Failed to set viewport #", i );
- glDepthRangef( vp.MinDepth, vp.MaxDepth );
- CHECK_GL_ERROR( "Failed to set depth range for viewport #", i );
+ glViewportIndexedf(i, BottomLeftX, BottomLeftY, vp.Width, vp.Height);
+ CHECK_GL_ERROR("Failed to set viewport #", i);
+ glDepthRangef(vp.MinDepth, vp.MaxDepth );
+ CHECK_GL_ERROR("Failed to set depth range for viewport #", i);
}
}
}
- void DeviceContextGLImpl::SetScissorRects( Uint32 NumRects, const Rect *pRects, Uint32 RTWidth, Uint32 RTHeight )
+ void DeviceContextGLImpl::SetScissorRects(Uint32 NumRects, const Rect* pRects, Uint32 RTWidth, Uint32 RTHeight)
{
TDeviceContextBase::SetScissorRects(NumRects, pRects, RTWidth, RTHeight);
- VERIFY( NumRects == m_NumScissorRects, "Unexpected number of scissor rects" );
- if( NumRects == 1 )
+ VERIFY(NumRects == m_NumScissorRects, "Unexpected number of scissor rects");
+ if (NumRects == 1)
{
const auto& Rect = m_ScissorRects[0];
// Note that OpenGL and DirectX use different origin
@@ -289,14 +289,14 @@ namespace Diligent
}
else
{
- for( Uint32 sr = 0; sr < NumRects; ++sr )
+ for (Uint32 sr = 0; sr < NumRects; ++sr)
{
const auto& Rect = m_ScissorRects[sr];
auto glBottom = RTHeight - Rect.bottom;
auto width = Rect.right - Rect.left;
auto height = Rect.bottom - Rect.top;
glScissorIndexed(sr, Rect.left, glBottom, width, height );
- CHECK_GL_ERROR( "Failed to set scissor rect #", sr );
+ CHECK_GL_ERROR("Failed to set scissor rect #", sr);
}
}
}
@@ -342,12 +342,12 @@ namespace Diligent
SetViewports(1, nullptr, 0, 0);
}
- void DeviceContextGLImpl::SetRenderTargets( Uint32 NumRenderTargets,
- ITextureView* ppRenderTargets[],
- ITextureView* pDepthStencil,
- RESOURCE_STATE_TRANSITION_MODE StateTransitionMode )
+ void DeviceContextGLImpl::SetRenderTargets(Uint32 NumRenderTargets,
+ ITextureView* ppRenderTargets[],
+ ITextureView* pDepthStencil,
+ RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)
{
- if( TDeviceContextBase::SetRenderTargets( NumRenderTargets, ppRenderTargets, pDepthStencil ) )
+ if (TDeviceContextBase::SetRenderTargets( NumRenderTargets, ppRenderTargets, pDepthStencil))
CommitRenderTargets();
}
@@ -413,15 +413,15 @@ namespace Diligent
auto& Resource = UB.pResources[ArrInd];
if (Resource)
{
- auto* pBufferOGL = Resource.RawPtr<BufferGLImpl>();
- pBufferOGL->BufferMemoryBarrier(
+ auto* pBufferGL = Resource.RawPtr<BufferGLImpl>();
+ pBufferGL->BufferMemoryBarrier(
GL_UNIFORM_BARRIER_BIT,// Shader uniforms sourced from buffer objects after the barrier
// will reflect data written by shaders prior to the barrier
m_ContextState);
- glBindBufferBase(GL_UNIFORM_BUFFER, UniformBuffBindPoint, pBufferOGL->m_GlBuffer);
+ glBindBufferBase(GL_UNIFORM_BUFFER, UniformBuffBindPoint, pBufferGL->m_GlBuffer);
CHECK_GL_ERROR("Failed to bind uniform buffer");
- //glBindBufferRange(GL_UNIFORM_BUFFER, it->Index, pBufferOGL->m_GlBuffer, 0, pBufferOGL->GetDesc().uiSizeInBytes);
+ //glBindBufferRange(GL_UNIFORM_BUFFER, it->Index, pBufferGL->m_GlBuffer, 0, pBufferGL->GetDesc().uiSizeInBytes);
glUniformBlockBinding(GLProgID, UB.UBIndex + ArrInd, UniformBuffBindPoint);
CHECK_GL_ERROR("glUniformBlockBinding() failed");
@@ -455,10 +455,10 @@ namespace Diligent
Sam.SamplerType == GL_INT_SAMPLER_BUFFER ||
Sam.SamplerType == GL_UNSIGNED_INT_SAMPLER_BUFFER)
{
- auto* pBufViewOGL = Resource.RawPtr<BufferViewGLImpl>();
- auto* pBuffer = pBufViewOGL->GetBuffer();
+ auto* pBufViewGL = Resource.RawPtr<BufferViewGLImpl>();
+ auto* pBuffer = pBufViewGL->GetBuffer();
- m_ContextState.BindTexture( TextureIndex, GL_TEXTURE_BUFFER, pBufViewOGL->GetTexBufferHandle() );
+ m_ContextState.BindTexture( TextureIndex, GL_TEXTURE_BUFFER, pBufViewGL->GetTexBufferHandle() );
m_ContextState.BindSampler( TextureIndex, GLObjectWrappers::GLSamplerObj(false) ); // Use default texture sampling parameters
ValidatedCast<BufferGLImpl>(pBuffer)->BufferMemoryBarrier(
@@ -469,10 +469,10 @@ namespace Diligent
}
else
{
- auto* pTexViewOGL = Resource.RawPtr<TextureViewGLImpl>();
- m_ContextState.BindTexture( TextureIndex, pTexViewOGL->GetBindTarget(), pTexViewOGL->GetHandle() );
+ auto* pTexViewGL = Resource.RawPtr<TextureViewGLImpl>();
+ m_ContextState.BindTexture( TextureIndex, pTexViewGL->GetBindTarget(), pTexViewGL->GetHandle() );
- auto* pTexture = pTexViewOGL->GetTexture();
+ auto* pTexture = pTexViewGL->GetTexture();
ValidatedCast<TextureBaseGL>(pTexture)->TextureMemoryBarrier(
GL_TEXTURE_FETCH_BARRIER_BIT, // Texture fetches from shaders, including fetches from buffer object
// memory via buffer textures, after the barrier will reflect data
@@ -486,7 +486,7 @@ namespace Diligent
}
else
{
- auto pSampler = pTexViewOGL->GetSampler();
+ auto pSampler = pTexViewGL->GetSampler();
pSamplerGL = ValidatedCast<SamplerGLImpl>(pSampler);
}
@@ -536,12 +536,12 @@ namespace Diligent
Img.ImageType == GL_INT_IMAGE_BUFFER ||
Img.ImageType == GL_UNSIGNED_INT_IMAGE_BUFFER)
{
- auto* pBuffViewOGL = Resource.RawPtr<BufferViewGLImpl>();
- const auto& ViewDesc = pBuffViewOGL->GetDesc();
+ auto* pBuffViewGL = Resource.RawPtr<BufferViewGLImpl>();
+ const auto& ViewDesc = pBuffViewGL->GetDesc();
VERIFY( ViewDesc.ViewType == BUFFER_VIEW_UNORDERED_ACCESS, "Unexpected buffer view type" );
- auto* pBufferOGL = pBuffViewOGL->GetBuffer<BufferGLImpl>();
- pBufferOGL->BufferMemoryBarrier(
+ auto* pBufferGL = pBuffViewGL->GetBuffer<BufferGLImpl>();
+ pBufferGL->BufferMemoryBarrier(
GL_SHADER_IMAGE_ACCESS_BARRIER_BIT,// Memory accesses using shader image load, store, and atomic built-in
// functions issued after the barrier will reflect data written by shaders
// prior to the barrier. Additionally, image stores and atomics issued after
@@ -549,20 +549,20 @@ namespace Diligent
// stores, texture fetches, vertex fetches) initiated prior to the barrier
// complete.
m_ContextState);
- m_BoundWritableBuffers.push_back(pBufferOGL);
+ m_BoundWritableBuffers.push_back(pBufferGL);
auto GlFormat = TypeToGLTexFormat(ViewDesc.Format.ValueType, ViewDesc.Format.NumComponents, ViewDesc.Format.IsNormalized);
- m_ContextState.BindImage(Img.BindingPoint + ArrInd, pBuffViewOGL, GL_READ_WRITE, GlFormat);
+ m_ContextState.BindImage(Img.BindingPoint + ArrInd, pBuffViewGL, GL_READ_WRITE, GlFormat);
}
else
{
- auto* pTexViewOGL = Resource.RawPtr<TextureViewGLImpl>();
- const auto& ViewDesc = pTexViewOGL->GetDesc();
+ auto* pTexViewGL = Resource.RawPtr<TextureViewGLImpl>();
+ const auto& ViewDesc = pTexViewGL->GetDesc();
VERIFY( ViewDesc.ViewType == TEXTURE_VIEW_UNORDERED_ACCESS, "Unexpected buffer view type" );
if (ViewDesc.AccessFlags & UAV_ACCESS_FLAG_WRITE)
{
- auto* pTexGL = pTexViewOGL->GetTexture<TextureBaseGL>();
+ auto* pTexGL = pTexViewGL->GetTexture<TextureBaseGL>();
pTexGL->TextureMemoryBarrier(
GL_SHADER_IMAGE_ACCESS_BARRIER_BIT,// Memory accesses using shader image load, store, and atomic built-in
// functions issued after the barrier will reflect data written by shaders
@@ -579,12 +579,12 @@ namespace Diligent
#ifdef _DEBUG
// Check that the texure being bound has immutable storage
{
- m_ContextState.BindTexture(-1, pTexViewOGL->GetBindTarget(), pTexViewOGL->GetHandle());
+ m_ContextState.BindTexture(-1, pTexViewGL->GetBindTarget(), pTexViewGL->GetHandle());
GLint IsImmutable = 0;
- glGetTexParameteriv( pTexViewOGL->GetBindTarget(), GL_TEXTURE_IMMUTABLE_FORMAT, &IsImmutable );
+ glGetTexParameteriv( pTexViewGL->GetBindTarget(), GL_TEXTURE_IMMUTABLE_FORMAT, &IsImmutable );
CHECK_GL_ERROR( "glGetTexParameteriv() failed" );
VERIFY( IsImmutable, "Only immutable textures can be bound to pipeline using glBindImageTexture()" );
- m_ContextState.BindTexture( -1, pTexViewOGL->GetBindTarget(), GLObjectWrappers::GLTextureObj(false) );
+ m_ContextState.BindTexture( -1, pTexViewGL->GetBindTarget(), GLObjectWrappers::GLTextureObj(false) );
}
#endif
auto GlTexFormat = TexFormatToGLInternalTexFormat( ViewDesc.Format );
@@ -602,7 +602,7 @@ namespace Diligent
// That means that if an integer texture is being bound, its
// GL_TEXTURE_MIN_FILTER and GL_TEXTURE_MAG_FILTER must be NEAREST,
// otherwise it will be incomplete
- m_ContextState.BindImage(Img.BindingPoint + ArrInd, pTexViewOGL, ViewDesc.MostDetailedMip, Layered, Layer, GLAccess, GlTexFormat);
+ m_ContextState.BindImage(Img.BindingPoint + ArrInd, pTexViewGL, ViewDesc.MostDetailedMip, Layered, Layer, GLAccess, GlTexFormat);
}
}
else
@@ -622,21 +622,21 @@ namespace Diligent
auto& Resource = SB.pResources[ArrInd];
if (Resource)
{
- auto* pBufferViewOGL = Resource.RawPtr<BufferViewGLImpl>();
- const auto& ViewDesc = pBufferViewOGL->GetDesc();
+ auto* pBufferViewGL = Resource.RawPtr<BufferViewGLImpl>();
+ const auto& ViewDesc = pBufferViewGL->GetDesc();
VERIFY( ViewDesc.ViewType == BUFFER_VIEW_UNORDERED_ACCESS || ViewDesc.ViewType == BUFFER_VIEW_SHADER_RESOURCE, "Unexpected buffer view type" );
- auto* pBufferOGL = pBufferViewOGL->GetBuffer<BufferGLImpl>();
- pBufferOGL->BufferMemoryBarrier(
+ auto* pBufferGL = pBufferViewGL->GetBuffer<BufferGLImpl>();
+ pBufferGL->BufferMemoryBarrier(
GL_SHADER_STORAGE_BARRIER_BIT,// Accesses to shader storage blocks after the barrier
// will reflect writes prior to the barrier
m_ContextState);
- glBindBufferRange(GL_SHADER_STORAGE_BUFFER, SB.Binding + ArrInd, pBufferOGL->m_GlBuffer, ViewDesc.ByteOffset, ViewDesc.ByteWidth);
+ glBindBufferRange(GL_SHADER_STORAGE_BUFFER, SB.Binding + ArrInd, pBufferGL->m_GlBuffer, ViewDesc.ByteOffset, ViewDesc.ByteWidth);
CHECK_GL_ERROR("Failed to bind shader storage buffer");
if (ViewDesc.ViewType == BUFFER_VIEW_UNORDERED_ACCESS)
- m_BoundWritableBuffers.push_back(pBufferOGL);
+ m_BoundWritableBuffers.push_back(pBufferGL);
}
else
{
@@ -711,11 +711,11 @@ namespace Diligent
auto* pRenderDeviceGL = m_pDevice.RawPtr<RenderDeviceGLImpl>();
auto CurrNativeGLContext = pRenderDeviceGL->m_GLContext.GetCurrentNativeGLContext();
const auto& PipelineDesc = m_pPipelineState->GetDesc().GraphicsPipeline;
- if(!m_bVAOIsUpToDate)
+ if (!m_bVAOIsUpToDate)
{
auto& VAOCache = pRenderDeviceGL->GetVAOCache(CurrNativeGLContext);
- IBuffer *pIndexBuffer = drawAttribs.IsIndexed ? m_pIndexBuffer.RawPtr() : nullptr;
- if(PipelineDesc.InputLayout.NumElements > 0 || pIndexBuffer != nullptr)
+ IBuffer* pIndexBuffer = drawAttribs.IsIndexed ? m_pIndexBuffer.RawPtr() : nullptr;
+ if (PipelineDesc.InputLayout.NumElements > 0 || pIndexBuffer != nullptr)
{
const auto& VAO = VAOCache.GetVAO( m_pPipelineState, pIndexBuffer, m_VertexStreams, m_NumVertexStreams, m_ContextState );
m_ContextState.BindVAO( VAO );
@@ -749,7 +749,7 @@ namespace Diligent
}
GLenum IndexType = 0;
Uint32 FirstIndexByteOffset = 0;
- if( drawAttribs.IsIndexed )
+ if (drawAttribs.IsIndexed)
{
IndexType = TypeToGLType( drawAttribs.IndexType );
VERIFY( IndexType == GL_UNSIGNED_BYTE || IndexType == GL_UNSIGNED_SHORT || IndexType == GL_UNSIGNED_INT,
@@ -781,7 +781,7 @@ namespace Diligent
glBindBuffer( GL_DRAW_INDIRECT_BUFFER, pIndirectDrawAttribsGL->m_GlBuffer );
- if( drawAttribs.IsIndexed )
+ if (drawAttribs.IsIndexed)
{
//typedef struct {
// GLuint count;
@@ -814,44 +814,44 @@ namespace Diligent
}
else
{
- if( drawAttribs.NumInstances > 1 )
+ if (drawAttribs.NumInstances > 1)
{
- if( drawAttribs.IsIndexed )
+ if (drawAttribs.IsIndexed)
{
- if( drawAttribs.BaseVertex )
+ if (drawAttribs.BaseVertex)
{
- if( drawAttribs.FirstInstanceLocation )
- glDrawElementsInstancedBaseVertexBaseInstance( GlTopology, drawAttribs.NumIndices, IndexType, reinterpret_cast<GLvoid*>( static_cast<size_t>(FirstIndexByteOffset) ), drawAttribs.NumInstances, drawAttribs.BaseVertex, drawAttribs.FirstInstanceLocation );
+ if (drawAttribs.FirstInstanceLocation)
+ glDrawElementsInstancedBaseVertexBaseInstance(GlTopology, drawAttribs.NumIndices, IndexType, reinterpret_cast<GLvoid*>( static_cast<size_t>(FirstIndexByteOffset) ), drawAttribs.NumInstances, drawAttribs.BaseVertex, drawAttribs.FirstInstanceLocation);
else
- glDrawElementsInstancedBaseVertex( GlTopology, drawAttribs.NumIndices, IndexType, reinterpret_cast<GLvoid*>( static_cast<size_t>(FirstIndexByteOffset) ), drawAttribs.NumInstances, drawAttribs.BaseVertex );
+ glDrawElementsInstancedBaseVertex(GlTopology, drawAttribs.NumIndices, IndexType, reinterpret_cast<GLvoid*>( static_cast<size_t>(FirstIndexByteOffset) ), drawAttribs.NumInstances, drawAttribs.BaseVertex);
}
else
{
- if( drawAttribs.FirstInstanceLocation )
- glDrawElementsInstancedBaseInstance( GlTopology, drawAttribs.NumIndices, IndexType, reinterpret_cast<GLvoid*>( static_cast<size_t>(FirstIndexByteOffset) ), drawAttribs.NumInstances, drawAttribs.FirstInstanceLocation );
+ if (drawAttribs.FirstInstanceLocation)
+ glDrawElementsInstancedBaseInstance(GlTopology, drawAttribs.NumIndices, IndexType, reinterpret_cast<GLvoid*>( static_cast<size_t>(FirstIndexByteOffset) ), drawAttribs.NumInstances, drawAttribs.FirstInstanceLocation);
else
- glDrawElementsInstanced( GlTopology, drawAttribs.NumIndices, IndexType, reinterpret_cast<GLvoid*>( static_cast<size_t>(FirstIndexByteOffset) ), drawAttribs.NumInstances );
+ glDrawElementsInstanced(GlTopology, drawAttribs.NumIndices, IndexType, reinterpret_cast<GLvoid*>( static_cast<size_t>(FirstIndexByteOffset) ), drawAttribs.NumInstances);
}
}
else
{
- if( drawAttribs.FirstInstanceLocation )
- glDrawArraysInstancedBaseInstance( GlTopology, drawAttribs.StartVertexLocation, drawAttribs.NumVertices, drawAttribs.NumInstances, drawAttribs.FirstInstanceLocation );
+ if (drawAttribs.FirstInstanceLocation)
+ glDrawArraysInstancedBaseInstance(GlTopology, drawAttribs.StartVertexLocation, drawAttribs.NumVertices, drawAttribs.NumInstances, drawAttribs.FirstInstanceLocation);
else
- glDrawArraysInstanced( GlTopology, drawAttribs.StartVertexLocation, drawAttribs.NumVertices, drawAttribs.NumInstances );
+ glDrawArraysInstanced(GlTopology, drawAttribs.StartVertexLocation, drawAttribs.NumVertices, drawAttribs.NumInstances);
}
}
else
{
- if( drawAttribs.IsIndexed )
+ if (drawAttribs.IsIndexed)
{
- if( drawAttribs.BaseVertex )
- glDrawElementsBaseVertex( GlTopology, drawAttribs.NumIndices, IndexType, reinterpret_cast<GLvoid*>( static_cast<size_t>(FirstIndexByteOffset) ), drawAttribs.BaseVertex );
+ if (drawAttribs.BaseVertex)
+ glDrawElementsBaseVertex(GlTopology, drawAttribs.NumIndices, IndexType, reinterpret_cast<GLvoid*>( static_cast<size_t>(FirstIndexByteOffset) ), drawAttribs.BaseVertex);
else
- glDrawElements( GlTopology, drawAttribs.NumIndices, IndexType, reinterpret_cast<GLvoid*>( static_cast<size_t>(FirstIndexByteOffset) ) );
+ glDrawElements(GlTopology, drawAttribs.NumIndices, IndexType, reinterpret_cast<GLvoid*>( static_cast<size_t>(FirstIndexByteOffset)));
}
else
- glDrawArrays( GlTopology, drawAttribs.StartVertexLocation, drawAttribs.NumVertices );
+ glDrawArrays(GlTopology, drawAttribs.StartVertexLocation, drawAttribs.NumVertices);
}
CHECK_GL_ERROR( "OpenGL draw command failed" );
}
@@ -864,7 +864,7 @@ namespace Diligent
m_CommitedResourcesTentativeBarriers = 0;
}
- void DeviceContextGLImpl::DispatchCompute( const DispatchComputeAttribs &DispatchAttrs )
+ void DeviceContextGLImpl::DispatchCompute(const DispatchComputeAttribs& DispatchAttrs)
{
#ifdef DEVELOPMENT
if (!DvpVerifyDispatchArguments(DispatchAttrs))
@@ -872,11 +872,11 @@ namespace Diligent
#endif
#if GL_ARB_compute_shader
- if( DispatchAttrs.pIndirectDispatchAttribs )
+ if (DispatchAttrs.pIndirectDispatchAttribs)
{
CHECK_DYNAMIC_TYPE( BufferGLImpl, DispatchAttrs.pIndirectDispatchAttribs );
- auto* pBufferOGL = static_cast<BufferGLImpl*>(DispatchAttrs.pIndirectDispatchAttribs);
- pBufferOGL->BufferMemoryBarrier(
+ auto* pBufferGL = static_cast<BufferGLImpl*>(DispatchAttrs.pIndirectDispatchAttribs);
+ pBufferGL->BufferMemoryBarrier(
GL_COMMAND_BARRIER_BIT,// Command data sourced from buffer objects by
// Draw*Indirect and DispatchComputeIndirect commands after the barrier
// will reflect data written by shaders prior to the barrier.The buffer
@@ -884,18 +884,18 @@ namespace Diligent
// and DISPATCH_INDIRECT_BUFFER bindings.
m_ContextState);
- glBindBuffer( GL_DISPATCH_INDIRECT_BUFFER, pBufferOGL->m_GlBuffer );
+ glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, pBufferGL->m_GlBuffer);
CHECK_GL_ERROR( "Failed to bind a buffer for dispatch indirect command" );
- glDispatchComputeIndirect( DispatchAttrs.DispatchArgsByteOffset );
- CHECK_GL_ERROR( "glDispatchComputeIndirect() failed" );
+ glDispatchComputeIndirect(DispatchAttrs.DispatchArgsByteOffset);
+ CHECK_GL_ERROR("glDispatchComputeIndirect() failed");
- glBindBuffer( GL_DISPATCH_INDIRECT_BUFFER, 0 );
+ glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, 0);
}
else
{
- glDispatchCompute( DispatchAttrs.ThreadGroupCountX, DispatchAttrs.ThreadGroupCountY, DispatchAttrs.ThreadGroupCountZ );
- CHECK_GL_ERROR( "glDispatchCompute() failed" );
+ glDispatchCompute(DispatchAttrs.ThreadGroupCountX, DispatchAttrs.ThreadGroupCountY, DispatchAttrs.ThreadGroupCountZ);
+ CHECK_GL_ERROR("glDispatchCompute() failed");
}
// IMPORTANT: new pending memory barriers in the context must be set
@@ -917,11 +917,11 @@ namespace Diligent
{
// Unlike OpenGL, in D3D10+, the full extent of the resource view is always cleared.
// Viewport and scissor settings are not applied.
- if( pView != nullptr )
+ if (pView != nullptr)
{
VERIFY( pView->GetDesc().ViewType == TEXTURE_VIEW_DEPTH_STENCIL, "Incorrect view type: depth stencil is expected" );
CHECK_DYNAMIC_TYPE( TextureViewGLImpl, pView );
- if( pView != m_pBoundDepthStencil )
+ if (pView != m_pBoundDepthStencil)
{
UNEXPECTED( "Depth stencil buffer being cleared is not bound to the pipeline" );
LOG_ERROR_MESSAGE( "Depth stencil buffer must be bound to the pipeline to be cleared" );
@@ -929,7 +929,7 @@ namespace Diligent
}
else
{
- if( !m_IsDefaultFramebufferBound )
+ if (!m_IsDefaultFramebufferBound)
{
UNEXPECTED( "Default depth stencil buffer being cleared is not bound to the pipeline" );
LOG_ERROR_MESSAGE( "Default depth stencil buffer must be bound to the pipeline to be cleared" );
@@ -955,24 +955,26 @@ namespace Diligent
m_ContextState.EnableScissorTest( ScissorTestEnabled );
}
- void DeviceContextGLImpl::ClearRenderTarget( ITextureView *pView, const float *RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode )
+ void DeviceContextGLImpl::ClearRenderTarget(ITextureView* pView, const float* RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)
{
// Unlike OpenGL, in D3D10+, the full extent of the resource view is always cleared.
// Viewport and scissor settings are not applied.
Int32 RTIndex = -1;
- if( pView != nullptr )
+ if (pView != nullptr)
{
VERIFY( pView->GetDesc().ViewType == TEXTURE_VIEW_RENDER_TARGET, "Incorrect view type: render target is expected" );
CHECK_DYNAMIC_TYPE( TextureViewGLImpl, pView );
- for( Uint32 rt = 0; rt < m_NumBoundRenderTargets; ++rt )
- if( m_pBoundRenderTargets[rt] == pView )
+ for (Uint32 rt = 0; rt < m_NumBoundRenderTargets; ++rt)
+ {
+ if (m_pBoundRenderTargets[rt] == pView)
{
RTIndex = rt;
break;
}
+ }
- if( RTIndex == -1 )
+ if (RTIndex == -1)
{
UNEXPECTED( "Render target being cleared is not bound to the pipeline" );
LOG_ERROR_MESSAGE( "Render target must be bound to the pipeline to be cleared" );
@@ -980,7 +982,7 @@ namespace Diligent
}
else
{
- if( m_IsDefaultFramebufferBound )
+ if (m_IsDefaultFramebufferBound)
RTIndex = 0;
else
{
@@ -1024,12 +1026,12 @@ namespace Diligent
{
}
- void DeviceContextGLImpl::FinishCommandList(class ICommandList **ppCommandList)
+ void DeviceContextGLImpl::FinishCommandList(class ICommandList** ppCommandList)
{
LOG_ERROR("Deferred contexts are not supported in OpenGL mode");
}
- void DeviceContextGLImpl::ExecuteCommandList(class ICommandList *pCommandList)
+ void DeviceContextGLImpl::ExecuteCommandList(class ICommandList* pCommandList)
{
LOG_ERROR("Deferred contexts are not supported in OpenGL mode");
}
@@ -1121,13 +1123,13 @@ namespace Diligent
CopyAttribs.DstMipLevel, CopyAttribs.DstSlice, CopyAttribs.DstX, CopyAttribs.DstY, CopyAttribs.DstZ);
}
- void DeviceContextGLImpl::MapTextureSubresource( ITexture* pTexture,
- Uint32 MipLevel,
- Uint32 ArraySlice,
- MAP_TYPE MapType,
- MAP_FLAGS MapFlags,
- const Box* pMapRegion,
- MappedTextureSubresource& MappedData )
+ void DeviceContextGLImpl::MapTextureSubresource(ITexture* pTexture,
+ Uint32 MipLevel,
+ Uint32 ArraySlice,
+ MAP_TYPE MapType,
+ MAP_FLAGS MapFlags,
+ const Box* pMapRegion,
+ MappedTextureSubresource& MappedData)
{
TDeviceContextBase::MapTextureSubresource(pTexture, MipLevel, ArraySlice, MapType, MapFlags, pMapRegion, MappedData);
LOG_ERROR_MESSAGE("Texture mapping is not supported in OpenGL");
@@ -1141,7 +1143,7 @@ namespace Diligent
LOG_ERROR_MESSAGE("Texture mapping is not supported in OpenGL");
}
- void DeviceContextGLImpl::GenerateMips( ITextureView *pTexView )
+ void DeviceContextGLImpl::GenerateMips( ITextureView* pTexView )
{
TDeviceContextBase::GenerateMips(pTexView);
auto* pTexViewGL = ValidatedCast<TextureViewGLImpl>(pTexView);