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

Diligent Engine API Reference

BufferGLImpl.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 "BufferGL.h"
27 #include "BufferBase.h"
28 #include "GLObjectWrapper.h"
29 #include "AsyncWritableResource.h"
30 #include "BaseInterfacesGL.h"
31 #include "BufferViewGLImpl.h"
32
33
34 namespace Diligent
35 {
36
37 class FixedBlockMemoryAllocator;
38
40 class BufferGLImpl : public BufferBase<IBufferGL, BufferViewGLImpl, FixedBlockMemoryAllocator>, public AsyncWritableResource
41 {
42 public:
43 typedef BufferBase<IBufferGL, BufferViewGLImpl, FixedBlockMemoryAllocator> TBufferBase;
44
45 BufferGLImpl(IReferenceCounters *pRefCounters,
46 FixedBlockMemoryAllocator &BuffViewObjMemAllocator,
47 class RenderDeviceGLImpl *pDeviceGL,
48 const BufferDesc& BuffDesc,
49 const BufferData& BuffData,
50 bool bIsDeviceInternal);
51 BufferGLImpl(IReferenceCounters *pRefCounters,
52 FixedBlockMemoryAllocator &BuffViewObjMemAllocator,
53 class RenderDeviceGLImpl *pDeviceGL,
54 const BufferDesc& BuffDesc,
55 GLuint GLHandle,
56 bool bIsDeviceInternal);
57 ~BufferGLImpl();
58
60 virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override;
61
62 virtual void UpdateData(IDeviceContext *pContext, Uint32 Offset, Uint32 Size, const PVoid pData)override;
63 virtual void CopyData( IDeviceContext *pContext, IBuffer *pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size )override;
64 virtual void Map( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData )override;
65 virtual void Unmap( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags )override;
66
67 void BufferMemoryBarrier( Uint32 RequiredBarriers, class GLContextState &GLContextState );
68
69 const GLObjectWrappers::GLBufferObj& GetGLHandle(){ return m_GlBuffer; }
70
71 virtual GLuint GetGLBufferHandle()override final { return GetGLHandle(); }
72 virtual void* GetNativeHandle()override final { return reinterpret_cast<void*>(static_cast<size_t>(GetGLBufferHandle())); }
73
74 private:
75 virtual void CreateViewInternal( const struct BufferViewDesc &ViewDesc, class IBufferView **ppView, bool bIsDefaultView )override;
76
77 friend class DeviceContextGLImpl;
78 friend class VAOCache;
79
80 GLObjectWrappers::GLBufferObj m_GlBuffer;
81 Uint32 m_uiMapTarget;
82 const GLenum m_GLUsageHint;
83 const Bool m_bUseMapWriteDiscardBugWA;
84 };
85
86 }
Diligent::BufferGLImpl::GetNativeHandle
virtual void * GetNativeHandle() override final
Returns native buffer handle specific to the underlying graphics API.
Definition: BufferGLImpl.h:72
Diligent::BufferGLImpl::Unmap
virtual void Unmap(IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags) override
Base implementation of IBuffer::Unmap()
Definition: BufferGLImpl.cpp:314
Diligent::BufferViewDesc
Buffer view description.
Definition: BufferView.h:39
Diligent::BufferData
Describes the buffer initial data.
Definition: Buffer.h:176
Diligent
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34
Diligent::DeviceContextGLImpl
Implementation of the Diligent::IDeviceContextGL interface.
Definition: DeviceContextGLImpl.h:35
Diligent::BufferBase
Template class implementing base functionality for a buffer object.
Definition: BufferBase.h:46
Diligent::BufferGLImpl::GetGLBufferHandle
virtual GLuint GetGLBufferHandle() override final
Returns OpenGL buffer handle.
Definition: BufferGLImpl.h:71
Diligent::RenderDeviceGLImpl
Implementation of the render device interface in OpenGL.
Definition: RenderDeviceGLImpl.h:53
Diligent::IBuffer
Buffer interface.
Definition: Buffer.h:200
Diligent::IDeviceContext
Device context interface.
Definition: DeviceContext.h:443
Diligent::BufferGLImpl::Map
virtual void Map(IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData) override
Base implementation of IBuffer::Map(); validates input parameters.
Definition: BufferGLImpl.cpp:230
Diligent::BufferDesc
Buffer description.
Definition: Buffer.h:57
Diligent::FixedBlockMemoryAllocator
Memory allocator that allocates memory in a fixed-size chunks.
Definition: FixedBlockMemoryAllocator.h:50
Diligent::BufferGLImpl
Implementation of the Diligent::IBufferGL interface.
Definition: BufferGLImpl.h:40
Diligent::BufferGLImpl::QueryInterface
virtual void QueryInterface(const Diligent::INTERFACE_ID &IID, IObject **ppInterface) override
Queries the specific interface, see IObject::QueryInterface() for details.
Diligent::IBufferView
Buffer view interface.
Definition: BufferView.h:91
Diligent::MAP_TYPE
MAP_TYPE
Resource mapping type.
Definition: GraphicsTypes.h:125
Diligent::BufferGLImpl::CopyData
virtual void CopyData(IDeviceContext *pContext, IBuffer *pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size) override
Base implementation of IBuffer::CopyData(); validates input parameters.
Definition: BufferGLImpl.cpp:200
Diligent::BufferGLImpl::UpdateData
virtual void UpdateData(IDeviceContext *pContext, Uint32 Offset, Uint32 Size, const PVoid pData) override
Base implementation of IBuffer::UpdateData(); validates input parameters.
Definition: BufferGLImpl.cpp:177