Diligent Engine API Reference: D:/GitHub/DiligentEngine/DiligentCore/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h Source File

Diligent Engine API Reference

DeviceContextGLImpl.h
1 /* Copyright 2015-2018 Egor Yusov
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
12 *
13 * In no event and under no legal theory, whether in tort (including negligence),
14 * contract, or otherwise, unless required by applicable law (such as deliberate
15 * and grossly negligent acts) or agreed to in writing, shall any Contributor be
16 * liable for any damages, including any direct, indirect, special, incidental,
17 * or consequential damages of any character arising as a result of this License or
18 * out of the use or inability to use the software (including but not limited to damages
19 * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
20 * all other commercial damages or losses), even if such Contributor has been advised
21 * of the possibility of such damages.
22 */
23
24 #pragma once
25
26 #include "DeviceContextGL.h"
27 #include "DeviceContextBase.h"
28 #include "BaseInterfacesGL.h"
29 #include "GLContextState.h"
30
31 namespace Diligent
32 {
33
35 class DeviceContextGLImpl : public DeviceContextBase<IDeviceContextGL>
36 {
37 public:
38 typedef DeviceContextBase<IDeviceContextGL> TDeviceContextBase;
39
40 DeviceContextGLImpl( IReferenceCounters *pRefCounters, class RenderDeviceGLImpl *pDeviceGL, bool bIsDeferred );
41
43 virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final;
44
45 virtual void SetPipelineState(IPipelineState *pPipelineState)override final;
46
47 virtual void TransitionShaderResources(IPipelineState *pPipelineState, IShaderResourceBinding *pShaderResourceBinding)override final;
48
49 virtual void CommitShaderResources(IShaderResourceBinding *pShaderResourceBinding, Uint32 Flags)override final;
50
51 virtual void SetStencilRef(Uint32 StencilRef)override final;
52
53 virtual void SetBlendFactors(const float* pBlendFactors = nullptr)override final;
54
55 virtual void SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pStrides, Uint32 *pOffsets, Uint32 Flags )override final;
56
57 virtual void InvalidateState()override final;
58
59 virtual void SetIndexBuffer( IBuffer *pIndexBuffer, Uint32 ByteOffset )override final;
60
61 virtual void SetViewports( Uint32 NumViewports, const Viewport *pViewports, Uint32 RTWidth, Uint32 RTHeight )override final;
62
63 virtual void SetScissorRects( Uint32 NumRects, const Rect *pRects, Uint32 RTWidth, Uint32 RTHeight )override final;
64
65 virtual void SetRenderTargets( Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil )override final;
66
67 virtual void Draw( DrawAttribs &DrawAttribs )override final;
68
69 virtual void DispatchCompute( const DispatchComputeAttribs &DispatchAttrs )override final;
70
71 virtual void ClearDepthStencil( ITextureView *pView, Uint32 ClearFlags, float fDepth, Uint8 Stencil)override final;
72
73 virtual void ClearRenderTarget( ITextureView *pView, const float *RGBA )override final;
74
75 virtual void Flush()override final;
76
77 virtual void FinishCommandList(class ICommandList **ppCommandList)override final;
78
79 virtual void ExecuteCommandList(class ICommandList *pCommandList)override final;
80
81 virtual bool UpdateCurrentGLContext()override final;
82
83 void BindProgramResources( Uint32 &NewMemoryBarriers, IShaderResourceBinding *pResBinding );
84
85 GLContextState &GetContextState(){return m_ContextState;}
86
87 void CommitRenderTargets();
88
89 protected:
90 friend class BufferGLImpl;
91 friend class TextureBaseGL;
92 friend class ShaderGLImpl;
93
94 GLContextState m_ContextState;
95
96 private:
97 Uint32 m_CommitedResourcesTentativeBarriers;
98
99 std::vector<class TextureBaseGL*> m_BoundWritableTextures;
100 std::vector<class BufferGLImpl*> m_BoundWritableBuffers;
101
102 bool m_bVAOIsUpToDate = false;
103 };
104
105 }
Diligent::TextureBaseGL
Base implementation of the Diligent::ITextureGL interface.
Definition: TextureBaseGL.h:41
Diligent::ShaderGLImpl
Implementation of the Diligent::IShaderGL interface.
Definition: ShaderGLImpl.h:67
Diligent::DeviceContextGLImpl::InvalidateState
virtual void InvalidateState() override final
Invalidates the cached context state.
Definition: DeviceContextGLImpl.cpp:167
Diligent
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34
Diligent::DeviceContextGLImpl::SetPipelineState
virtual void SetPipelineState(IPipelineState *pPipelineState) override final
Base implementation of IDeviceContext::SetPipelineState(); caches references to the pipeline state ob...
Definition: DeviceContextGLImpl.cpp:63
Diligent::DeviceContextGLImpl::UpdateCurrentGLContext
virtual bool UpdateCurrentGLContext() override final
Attaches to the active GL context in the thread.
Definition: DeviceContextGLImpl.cpp:959
Diligent::DeviceContextGLImpl::SetViewports
virtual void SetViewports(Uint32 NumViewports, const Viewport *pViewports, Uint32 RTWidth, Uint32 RTHeight) override final
Sets an array of viewports.
Definition: DeviceContextGLImpl.cpp:183
Diligent::DeviceContextBase
Base implementation of the device context.
Definition: DeviceContextBase.h:68
Diligent::DeviceContextGLImpl
Implementation of the Diligent::IDeviceContextGL interface.
Definition: DeviceContextGLImpl.h:35
Diligent::Viewport
Describes the viewport.
Definition: DeviceContext.h:376
Diligent::DeviceContextGLImpl::SetBlendFactors
virtual void SetBlendFactors(const float *pBlendFactors=nullptr) override final
Definition: DeviceContextGLImpl.cpp:153
Diligent::DeviceContextGLImpl::FinishCommandList
virtual void FinishCommandList(class ICommandList **ppCommandList) override final
Finishes recording commands and generates a command list.
Definition: DeviceContextGLImpl.cpp:949
Diligent::IShaderResourceBinding
Shader resource binding interface.
Definition: ShaderResourceBinding.h:40
Diligent::RenderDeviceGLImpl
Implementation of the render device interface in OpenGL.
Definition: RenderDeviceGLImpl.h:53
Diligent::DeviceContextGLImpl::ClearDepthStencil
virtual void ClearDepthStencil(ITextureView *pView, Uint32 ClearFlags, float fDepth, Uint8 Stencil) override final
Clears a depth-stencil view.
Definition: DeviceContextGLImpl.cpp:840
Diligent::DispatchComputeAttribs
Describes dispatch command arguments.
Definition: DeviceContext.h:312
Diligent::DeviceContextGLImpl::SetVertexBuffers
virtual void SetVertexBuffers(Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pStrides, Uint32 *pOffsets, Uint32 Flags) override final
Base implementation of IDeviceContext::SetVertexBuffers(); validates parameters and caches references...
Definition: DeviceContextGLImpl.cpp:161
Diligent::DeviceContextGLImpl::Draw
virtual void Draw(DrawAttribs &DrawAttribs) override final
Executes a draw command.
Definition: DeviceContextGLImpl.cpp:639
Diligent::DeviceContextGLImpl::Flush
virtual void Flush() override final
Flushes the command buffer.
Definition: DeviceContextGLImpl.cpp:944
Diligent::DeviceContextGLImpl::SetIndexBuffer
virtual void SetIndexBuffer(IBuffer *pIndexBuffer, Uint32 ByteOffset) override final
Base implementation of IDeviceContext::SetIndexBuffer(); caches the strong reference to the index buf...
Definition: DeviceContextGLImpl.cpp:177
Diligent::DeviceContextGLImpl::CommitShaderResources
virtual void CommitShaderResources(IShaderResourceBinding *pShaderResourceBinding, Uint32 Flags) override final
Commits shader resources to the device context.
Definition: DeviceContextGLImpl.cpp:129
Diligent::IBuffer
Buffer interface.
Definition: Buffer.h:200
Diligent::DeviceContextGLImpl::SetScissorRects
virtual void SetScissorRects(Uint32 NumRects, const Rect *pRects, Uint32 RTWidth, Uint32 RTHeight) override final
Sets active scissor rects.
Definition: DeviceContextGLImpl.cpp:242
Diligent::DeviceContextGLImpl::SetRenderTargets
virtual void SetRenderTargets(Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil) override final
Binds one or more render targets and the depth-stencil buffer to the pipeline. It also sets the viewp...
Definition: DeviceContextGLImpl.cpp:315
Diligent::ITextureView
Texture view interface.
Definition: TextureView.h:163
Diligent::ICommandList
Command list interface.
Definition: CommandList.h:42
Diligent::BufferGLImpl
Implementation of the Diligent::IBufferGL interface.
Definition: BufferGLImpl.h:40
Diligent::DeviceContextGLImpl::ExecuteCommandList
virtual void ExecuteCommandList(class ICommandList *pCommandList) override final
Executes recorded commands in a command list.
Definition: DeviceContextGLImpl.cpp:954
Diligent::IPipelineState
Definition: PipelineState.h:209
Diligent::DrawAttribs
Defines the draw command attributes.
Definition: DeviceContext.h:212
Diligent::Rect
Describes the rectangle.
Definition: DeviceContext.h:420
Diligent::DeviceContextGLImpl::ClearRenderTarget
virtual void ClearRenderTarget(ITextureView *pView, const float *RGBA) override final
Clears a render target view.
Definition: DeviceContextGLImpl.cpp:883
Diligent::DeviceContextGLImpl::QueryInterface
virtual void QueryInterface(const Diligent::INTERFACE_ID &IID, IObject **ppInterface) override final
Queries the specific interface, see IObject::QueryInterface() for details.
Diligent::DeviceContextGLImpl::SetStencilRef
virtual void SetStencilRef(Uint32 StencilRef) override final
Sets the stencil reference value.
Definition: DeviceContextGLImpl.cpp:144
Diligent::DeviceContextGLImpl::DispatchCompute
virtual void DispatchCompute(const DispatchComputeAttribs &DispatchAttrs) override final
Executes a dispatch compute command.
Definition: DeviceContextGLImpl.cpp:804
Diligent::DeviceContextGLImpl::TransitionShaderResources
virtual void TransitionShaderResources(IPipelineState *pPipelineState, IShaderResourceBinding *pShaderResourceBinding) override final
Transitions shader resources to the require states.
Definition: DeviceContextGLImpl.cpp:124