Diligent Engine API Reference: D:/GitHub/DiligentEngine/DiligentCore/Graphics/GraphicsEngine/interface/Buffer.h Source File

Diligent Engine API Reference

Buffer.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
28
29 #include "DeviceObject.h"
30
31 namespace Diligent
32 {
33
34 // {EC47EAD3-A2C4-44F2-81C5-5248D14F10E4}
35 static constexpr INTERFACE_ID IID_Buffer =
36 { 0xec47ead3, 0xa2c4, 0x44f2, { 0x81, 0xc5, 0x52, 0x48, 0xd1, 0x4f, 0x10, 0xe4 } };
37
39
41 enum BUFFER_MODE : Int32
42 {
44 BUFFER_MODE_UNDEFINED = 0,
45
47 BUFFER_MODE_FORMATTED,
48
50 BUFFER_MODE_STRUCTURED,
51
53 BUFFER_MODE_NUM_MODES
54 };
55
57 struct BufferDesc : DeviceObjectAttribs
58 {
60 Uint32 uiSizeInBytes;
61
63
68 Uint32 BindFlags;
69
71 USAGE Usage;
72
75 Uint32 CPUAccessFlags;
76
78 BUFFER_MODE Mode;
79
81 struct BufferFormat
82 {
84 VALUE_TYPE ValueType;
85
88 Uint32 NumComponents;
89
95 Bool IsNormalized;
96
98
105 BufferFormat() :
106 ValueType( VT_UNDEFINED ),
107 NumComponents( 0 ),
108 IsNormalized(True)
109 {}
110
112 bool operator == (const BufferFormat& RHS)const
113 {
114 return ValueType == RHS.ValueType &&
115 NumComponents == RHS.NumComponents &&
116 IsNormalized == RHS.IsNormalized;
117 }
118 };
119
121
124 BufferFormat Format;
125
131 Uint32 ElementByteStride;
132
134
145 BufferDesc() :
146 uiSizeInBytes(0),
147 BindFlags(0),
148 Usage(USAGE_DEFAULT),
149 CPUAccessFlags(0),
150 Mode( BUFFER_MODE_UNDEFINED ),
151 ElementByteStride(0)
152 {}
153
154
156
163 bool operator == (const BufferDesc& RHS)const
164 {
165 return uiSizeInBytes == RHS.uiSizeInBytes &&
166 BindFlags == RHS.BindFlags &&
167 Usage == RHS.Usage &&
168 CPUAccessFlags == RHS.CPUAccessFlags &&
169 Mode == RHS.Mode &&
170 Format == RHS.Format &&
171 ElementByteStride == RHS.ElementByteStride;
172 }
173 };
174
176 struct BufferData
177 {
179 const void* pData;
180
182 Uint32 DataSize;
183
185
191 BufferData() :
192 pData(nullptr),
193 DataSize(0)
194 {}
195 };
196
198
200 class IBuffer : public IDeviceObject
201 {
202 public:
204 virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ) = 0;
205
207 virtual const BufferDesc& GetDesc()const = 0;
208
210
215 virtual void UpdateData( class IDeviceContext *pContext, Uint32 Offset, Uint32 Size, const PVoid pData) = 0;
216
218
225 virtual void CopyData( IDeviceContext *pContext, IBuffer *pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size ) = 0;
226
228
233 virtual void Map( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData ) = 0;
234
241 virtual void Unmap( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags ) = 0;
242
244
254 virtual void CreateView( const struct BufferViewDesc &ViewDesc, class IBufferView **ppView ) = 0;
255
257
263 virtual IBufferView* GetDefaultView( BUFFER_VIEW_TYPE ViewType ) = 0;
264
266
270 virtual void* GetNativeHandle() = 0;
271 };
272
273 }
Diligent::BufferDesc::operator==
bool operator==(const BufferDesc &RHS) const
Tests if two structures are equivalent.
Definition: Buffer.h:163
Diligent::BufferViewDesc
Buffer view description.
Definition: BufferView.h:39
Diligent::BUFFER_MODE_NUM_MODES
Helper value storing the total number of modes in the enumeration.
Definition: Buffer.h:53
Diligent::BufferData::BufferData
BufferData()
Initializes the structure members with default values.
Definition: Buffer.h:191
Diligent::BufferData
Describes the buffer initial data.
Definition: Buffer.h:176
Diligent::IDeviceObject
Base interface for all objects created by the render device Diligent::IRenderDevice.
Definition: DeviceObject.h:40
Diligent::IBuffer::CreateView
virtual void CreateView(const struct BufferViewDesc &ViewDesc, class IBufferView **ppView)=0
Creates a new buffer view.
Diligent::IBuffer::UpdateData
virtual void UpdateData(class IDeviceContext *pContext, Uint32 Offset, Uint32 Size, const PVoid pData)=0
Updates the data in the buffer.
Diligent::VT_UNDEFINED
Undefined type.
Definition: GraphicsTypes.h:41
Diligent::BufferDesc::Mode
BUFFER_MODE Mode
Buffer mode.
Definition: Buffer.h:78
Diligent
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34
Diligent::BufferDesc::ElementByteStride
Uint32 ElementByteStride
Buffer element stride, in bytes. For a structured buffer (BufferDesc::Mode equals Diligent::BUFFER_MO...
Definition: Buffer.h:131
Diligent::BufferDesc::Usage
USAGE Usage
Buffer usage, see Diligent::USAGE for details.
Definition: Buffer.h:71
Diligent::BUFFER_MODE_UNDEFINED
Undefined mode.
Definition: Buffer.h:44
Diligent::BufferDesc::BufferFormat::operator==
bool operator==(const BufferFormat &RHS) const
Tests if two structures are equivalent.
Definition: Buffer.h:112
Diligent::BUFFER_MODE_STRUCTURED
Structured buffer.
Definition: Buffer.h:50
Diligent::BufferDesc::BufferFormat::BufferFormat
BufferFormat()
Initializes the structure members with default values.
Definition: Buffer.h:105
Diligent::IBuffer::Unmap
virtual void Unmap(IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags)=0
Unmaps the previously mapped buffer.
Diligent::BufferDesc::BufferDesc
BufferDesc()
Initializes the structure members with default values.
Definition: Buffer.h:145
Diligent::IBuffer
Buffer interface.
Definition: Buffer.h:200
Diligent::BUFFER_MODE_FORMATTED
Formated buffer.
Definition: Buffer.h:47
Diligent::IDeviceContext
Device context interface.
Definition: DeviceContext.h:443
Diligent::BUFFER_MODE
BUFFER_MODE
Describes the buffer access mode.
Definition: Buffer.h:41
Diligent::BufferDesc::uiSizeInBytes
Uint32 uiSizeInBytes
Size of the buffer, in bytes. For a uniform buffer, this must be multiple of 16.
Definition: Buffer.h:60
Diligent::IBuffer::GetNativeHandle
virtual void * GetNativeHandle()=0
Returns native buffer handle specific to the underlying graphics API.
Diligent::USAGE_DEFAULT
A resource that requires read and write access by the GPU and can also be occasionally written by the...
Definition: GraphicsTypes.h:95
Diligent::BufferDesc
Buffer description.
Definition: Buffer.h:57
Diligent::VALUE_TYPE
VALUE_TYPE
Value type.
Definition: GraphicsTypes.h:39
Diligent::IBuffer::CopyData
virtual void CopyData(IDeviceContext *pContext, IBuffer *pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size)=0
Copies the data from other buffer.
Diligent::BufferDesc::BufferFormat::ValueType
VALUE_TYPE ValueType
Type of components. For a formatted buffer, this value cannot be VT_UNDEFINED.
Definition: Buffer.h:84
Diligent::IBuffer::Map
virtual void Map(IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData)=0
Maps the buffer.
Diligent::USAGE
USAGE
Resource usage.
Definition: GraphicsTypes.h:84
Diligent::BufferDesc::BufferFormat
Buffer format description.
Definition: Buffer.h:81
Diligent::IBuffer::GetDefaultView
virtual IBufferView * GetDefaultView(BUFFER_VIEW_TYPE ViewType)=0
Returns the pointer to the default view.
Diligent::DeviceObjectAttribs
Describes common device object attributes.
Definition: GraphicsTypes.h:900
Diligent::IBuffer::QueryInterface
virtual void QueryInterface(const Diligent::INTERFACE_ID &IID, IObject **ppInterface)=0
Queries the specific interface, see IObject::QueryInterface() for details.
Diligent::BufferData::DataSize
Uint32 DataSize
Data size, in bytes.
Definition: Buffer.h:182
Diligent::BufferDesc::BufferFormat::NumComponents
Uint32 NumComponents
Number of components. Allowed values: 1, 2, 3, 4. For a formatted buffer, this value cannot be 0...
Definition: Buffer.h:88
Diligent::BufferDesc::Format
BufferFormat Format
Buffer format.
Definition: Buffer.h:124
Diligent::BufferDesc::BindFlags
Uint32 BindFlags
Buffer bind flags, see Diligent::BIND_FLAGS for details.
Definition: Buffer.h:68
Diligent::IBufferView
Buffer view interface.
Definition: BufferView.h:91
Diligent::BufferData::pData
const void * pData
Pointer to the data.
Definition: Buffer.h:179
Diligent::MAP_TYPE
MAP_TYPE
Resource mapping type.
Definition: GraphicsTypes.h:125
Diligent::BufferDesc::CPUAccessFlags
Uint32 CPUAccessFlags
CPU access flags or 0 if no CPU access is allowed, see Diligent::CPU_ACCESS_FLAG for details...
Definition: Buffer.h:75
Diligent::BUFFER_VIEW_TYPE
BUFFER_VIEW_TYPE
Buffer view type.
Definition: GraphicsTypes.h:219
Diligent::IBuffer::GetDesc
virtual const BufferDesc & GetDesc() const =0
Returns the buffer description used to create the object.
Diligent::BufferDesc::BufferFormat::IsNormalized
Bool IsNormalized
For signed and unsigned integer value types (VT_INT8, VT_INT16, VT_INT32, VT_UINT8, VT_UINT16, VT_UINT32) indicates if the value should be normalized to [-1,+1] or [0, 1] range respectively. For floating point types (VT_FLOAT16 and VT_FLOAT32), this member is ignored.
Definition: Buffer.h:95