Divide Framework
0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Commands.inl
Go to the documentation of this file.
1
/*
2
Copyright (c) 2018 DIVIDE-Studio
3
Copyright (c) 2009 Ionut Cava
4
5
This file is part of DIVIDE Framework.
6
7
Permission is hereby granted, free of charge, to any person obtaining a copy
8
of this software
9
and associated documentation files (the "Software"), to deal in the Software
10
without restriction,
11
including without limitation the rights to use, copy, modify, merge, publish,
12
distribute, sublicense,
13
and/or sell copies of the Software, and to permit persons to whom the
14
Software is furnished to do so,
15
subject to the following conditions:
16
17
The above copyright notice and this permission notice shall be included in
18
all copies or substantial portions of the Software.
19
20
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
IMPLIED,
22
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23
PARTICULAR PURPOSE AND NONINFRINGEMENT.
24
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25
DAMAGES OR OTHER LIABILITY,
26
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27
IN CONNECTION WITH THE SOFTWARE
28
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30
*/
31
32
#pragma once
33
#ifndef DVD_GFX_COMMAND_INL_
34
#define DVD_GFX_COMMAND_INL_
35
36
#include "
CommandBuffer.h
"
37
#include "
ClipPlanes.h
"
38
#include "
DescriptorSetsFwd.h
"
39
#include "
GenericDrawCommand.h
"
40
#include "
PushConstants.h
"
41
#include "
Platform/Video/Textures/Headers/Texture.h
"
42
#include "
Platform/Video/Buffers/RenderTarget/Headers/RenderTarget.h
"
43
#include "
Platform/Video/Buffers/VertexBuffer/Headers/BufferLocks.h
"
44
#include "
Platform/Video/Headers/DescriptorSets.h
"
45
#include "
Rendering/Camera/Headers/CameraSnapshot.h
"
46
#include "
Utility/Headers/TextLabel.h
"
47
48
struct
ImDrawData;
49
50
namespace
Divide
{
51
class
Pipeline;
52
class
ShaderBuffer;
53
54
namespace
GFX {
55
56
template
<CommandType EnumVal>
57
void
Command<EnumVal>::addToBuffer
(
CommandBuffer
* buffer )
const
58
{
59
using
CType =
MapToDataType<EnumVal>
;
60
buffer->
add
(
static_cast<
const
CType&
>
(*
this
) );
61
}
62
63
template
<CommandType EnumVal>
64
void
Command<EnumVal>::DeleteCmd
(
CommandBase
*& cmd )
const
65
{
66
using
CType =
MapToDataType<EnumVal>
;
67
CmdAllocator<CType>::GetPool().deleteElement( cmd->
As
<CType>() );
68
cmd =
nullptr
;
69
}
70
71
DEFINE_COMMAND_BEGIN
(
BindPipelineCommand
,
CommandType::BIND_PIPELINE
);
72
const
Pipeline
* _pipeline =
nullptr
;
73
DEFINE_COMMAND_END
(
BindPipelineCommand
);
74
75
DEFINE_COMMAND_BEGIN
(
SendPushConstantsCommand
,
CommandType::SEND_PUSH_CONSTANTS
);
76
UniformData
* _uniformData =
nullptr
;
77
PushConstantsStruct
_fastData{};
78
DEFINE_COMMAND_END
(
SendPushConstantsCommand
);
79
80
DEFINE_COMMAND_BEGIN
(
DrawCommand
,
CommandType::DRAW_COMMANDS
);
81
GenericDrawCommandContainer
_drawCommands
;
82
DEFINE_COMMAND_END
(
DrawCommand
);
83
84
DEFINE_COMMAND_BEGIN
(
SetViewportCommand
,
CommandType::SET_VIEWPORT
);
85
Rect<I32>
_viewport
;
86
DEFINE_COMMAND_END
(
SetViewportCommand
);
87
88
DEFINE_COMMAND_BEGIN
(
PushViewportCommand
,
CommandType::PUSH_VIEWPORT
);
89
Rect<I32>
_viewport
;
90
DEFINE_COMMAND_END
(
PushViewportCommand
);
91
92
DEFINE_COMMAND
(
PopViewportCommand
,
CommandType::POP_VIEWPORT
);
93
94
DEFINE_COMMAND_BEGIN
(
BeginRenderPassCommand
,
CommandType::BEGIN_RENDER_PASS
);
95
RenderTargetID
_target{
INVALID_RENDER_TARGET_ID
};
96
RTDrawDescriptor
_descriptor{};
97
RTClearDescriptor
_clearDescriptor{};
98
Str<64>
_name{};
99
DEFINE_COMMAND_END
(
BeginRenderPassCommand
);
100
101
DEFINE_COMMAND_BEGIN
(
EndRenderPassCommand
,
CommandType::END_RENDER_PASS
);
102
RTTransitionMask
_transitionMask = {
true
,
true
,
true
,
true
,
true
};
103
DEFINE_COMMAND_END
(
EndRenderPassCommand
);
104
105
DEFINE_COMMAND_BEGIN
(
BeginGPUQueryCommand
,
CommandType::BEGIN_GPU_QUERY
);
106
U32
_queryMask{ 0u };
107
DEFINE_COMMAND_END
(
BeginGPUQueryCommand
);
108
109
DEFINE_COMMAND_BEGIN
(
EndGPUQueryCommand
,
CommandType::END_GPU_QUERY
);
110
QueryResults
* _resultContainer{
nullptr
};
111
bool
_waitForResults{
false
};
112
DEFINE_COMMAND_END
(
EndGPUQueryCommand
);
113
114
DEFINE_COMMAND_BEGIN
(
BlitRenderTargetCommand
,
CommandType::BLIT_RT
);
115
RenderTargetID
_source{
INVALID_RENDER_TARGET_ID
};
116
RenderTargetID
_destination{
INVALID_RENDER_TARGET_ID
};
117
RTBlitParams
_params{};
118
DEFINE_COMMAND_END
(
BlitRenderTargetCommand
);
119
120
DEFINE_COMMAND_BEGIN
(
CopyTextureCommand
,
CommandType::COPY_TEXTURE
);
121
Handle<Texture>
_source{ INVALID_HANDLE<Texture> };
122
Handle<Texture>
_destination{ INVALID_HANDLE<Texture> };
123
U8
_sourceMSAASamples{ 0u };
124
U8
_destinationMSAASamples{ 0u };
125
CopyTexParams
_params
;
126
DEFINE_COMMAND_END
(
CopyTextureCommand
);
127
128
DEFINE_COMMAND_BEGIN
(
ReadTextureCommand
,
CommandType::READ_TEXTURE
);
129
Handle<Texture>
_texture{ INVALID_HANDLE<Texture> };
130
PixelAlignment
_pixelPackAlignment{};
131
U8
_mipLevel{0u};
132
DELEGATE_STD<void, const ImageReadbackData&>
_callback
;
133
DEFINE_COMMAND_END
(
ReadTextureCommand
);
134
135
DEFINE_COMMAND_BEGIN
(
ClearTextureCommand
,
CommandType::CLEAR_TEXTURE
);
136
Handle<Texture>
_texture{ INVALID_HANDLE<Texture> };
138
UColour4
_clearColour
;
139
SubRange
_layerRange{0u,
U16_MAX
};
140
U8
_mipLevel{ 0u };
141
DEFINE_COMMAND_END
(
ClearTextureCommand
);
142
143
DEFINE_COMMAND_BEGIN
(
ComputeMipMapsCommand
,
CommandType::COMPUTE_MIPMAPS
);
144
Handle<Texture>
_texture{ INVALID_HANDLE<Texture> };
145
SubRange
_layerRange{ 0u, 1u };
146
SubRange
_mipRange{ 0u,
U16_MAX
};
147
ImageUsage
_usage{
ImageUsage::COUNT
};
148
DEFINE_COMMAND_END
(
ComputeMipMapsCommand
);
149
150
DEFINE_COMMAND_BEGIN
(
SetScissorCommand
,
CommandType::SET_SCISSOR
);
151
Rect<I32>
_rect
;
152
DEFINE_COMMAND_END
(
SetScissorCommand
);
153
154
DEFINE_COMMAND_BEGIN
(
SetCameraCommand
,
CommandType::SET_CAMERA
);
155
CameraSnapshot
_cameraSnapshot
;
156
DEFINE_COMMAND_END
(
SetCameraCommand
);
157
158
DEFINE_COMMAND_BEGIN
(
PushCameraCommand
,
CommandType::PUSH_CAMERA
);
159
CameraSnapshot
_cameraSnapshot
;
160
DEFINE_COMMAND_END
(
PushCameraCommand
);
161
162
DEFINE_COMMAND
(
PopCameraCommand
,
CommandType::POP_CAMERA
);
163
164
DEFINE_COMMAND_BEGIN
(
SetClipPlanesCommand
,
CommandType::SET_CLIP_PLANES
);
165
FrustumClipPlanes
_clippingPlanes
;
166
DEFINE_COMMAND_END
(
SetClipPlanesCommand
);
167
168
DEFINE_COMMAND_BEGIN
(
BindShaderResourcesCommand
,
CommandType::BIND_SHADER_RESOURCES
);
169
DescriptorSet
_set
;
170
DescriptorSetUsage
_usage{
DescriptorSetUsage::COUNT
};
171
DEFINE_COMMAND_END
(
BindShaderResourcesCommand
);
172
173
DEFINE_COMMAND_BEGIN
(
BeginDebugScopeCommand
,
CommandType::BEGIN_DEBUG_SCOPE
);
174
Str<64>
_scopeName
;
175
U32
_scopeId{
U32_MAX
};
176
DEFINE_COMMAND_END
(
BeginDebugScopeCommand
);
177
178
DEFINE_COMMAND
(
EndDebugScopeCommand
,
CommandType::END_DEBUG_SCOPE
);
179
180
DEFINE_COMMAND_BEGIN
(
AddDebugMessageCommand
,
CommandType::ADD_DEBUG_MESSAGE
);
181
Str<64>
_msg
;
182
U32
_msgId{
U32_MAX
};
183
DEFINE_COMMAND_END
(
AddDebugMessageCommand
);
184
185
DEFINE_COMMAND_BEGIN
(
DispatchComputeCommand
,
CommandType::DISPATCH_COMPUTE
);
186
vec3<U32>
_computeGroupSize
;
187
DEFINE_COMMAND_END
(
DispatchComputeCommand
);
188
189
DEFINE_COMMAND_BEGIN
(
MemoryBarrierCommand
,
CommandType::MEMORY_BARRIER
);
190
BufferLocks
_bufferLocks
;
191
TextureLayoutChanges
_textureLayoutChanges
;
192
DEFINE_COMMAND_END
(
MemoryBarrierCommand
);
193
194
DEFINE_COMMAND_BEGIN
(
ReadBufferDataCommand
,
CommandType::READ_BUFFER_DATA
);
195
ShaderBuffer
* _buffer{
nullptr
};
196
std::pair<bufferPtr, size_t> _target {
nullptr
, 0u };
197
U32
_offsetElementCount{ 0 };
198
U32
_elementCount{ 0 };
199
DEFINE_COMMAND_END
(
ReadBufferDataCommand
);
200
201
DEFINE_COMMAND_BEGIN
(
ClearBufferDataCommand
,
CommandType::CLEAR_BUFFER_DATA
);
202
ShaderBuffer
* _buffer{
nullptr
};
203
U32
_offsetElementCount{ 0 };
204
U32
_elementCount{ 0 };
205
DEFINE_COMMAND_END
(
ClearBufferDataCommand
);
206
207
};
//namespace GFX
208
};
//namespace Divide
209
210
#endif
//DVD_GFX_COMMAND_INL_
BufferLocks.h
CameraSnapshot.h
ClipPlanes.h
CommandBuffer.h
DEFINE_COMMAND_BEGIN
#define DEFINE_COMMAND_BEGIN(Name, Enum)
Definition:
Commands.h:87
DEFINE_COMMAND_END
#define DEFINE_COMMAND_END(Name)
Definition:
Commands.h:93
DEFINE_COMMAND
#define DEFINE_COMMAND(Name, Enum)
Definition:
Commands.h:95
DescriptorSets.h
DescriptorSetsFwd.h
GenericDrawCommand.h
PushConstants.h
RenderTarget.h
TextLabel.h
Texture.h
Divide::GFX::CommandBuffer
Definition:
CommandBuffer.h:110
Divide::GFX::CommandBuffer::add
T * add()
Definition:
CommandBuffer.inl:77
Divide::Pipeline
Definition:
Pipeline.h:59
Divide::Rect
Definition:
MathVectors.h:1460
Divide::ShaderBuffer
Definition:
ShaderBuffer.h:52
Divide::Str
Definition:
String.h:44
Divide::vec3
Definition:
MathVectors.h:480
Divide::vec4< U8 >
Divide::GFX::MapToDataType
typename MapToDataType_t< T >::type MapToDataType
Definition:
Commands.h:48
Divide::GFX::CommandType::BEGIN_RENDER_PASS
@ BEGIN_RENDER_PASS
Divide::GFX::CommandType::SET_VIEWPORT
@ SET_VIEWPORT
Divide::GFX::CommandType::CLEAR_BUFFER_DATA
@ CLEAR_BUFFER_DATA
Divide::GFX::CommandType::POP_VIEWPORT
@ POP_VIEWPORT
Divide::GFX::CommandType::COPY_TEXTURE
@ COPY_TEXTURE
Divide::GFX::CommandType::END_GPU_QUERY
@ END_GPU_QUERY
Divide::GFX::CommandType::PUSH_VIEWPORT
@ PUSH_VIEWPORT
Divide::GFX::CommandType::SET_CLIP_PLANES
@ SET_CLIP_PLANES
Divide::GFX::CommandType::BIND_PIPELINE
@ BIND_PIPELINE
Divide::GFX::CommandType::READ_BUFFER_DATA
@ READ_BUFFER_DATA
Divide::GFX::CommandType::END_RENDER_PASS
@ END_RENDER_PASS
Divide::GFX::CommandType::POP_CAMERA
@ POP_CAMERA
Divide::GFX::CommandType::MEMORY_BARRIER
@ MEMORY_BARRIER
Divide::GFX::CommandType::SEND_PUSH_CONSTANTS
@ SEND_PUSH_CONSTANTS
Divide::GFX::CommandType::COMPUTE_MIPMAPS
@ COMPUTE_MIPMAPS
Divide::GFX::CommandType::DISPATCH_COMPUTE
@ DISPATCH_COMPUTE
Divide::GFX::CommandType::BEGIN_DEBUG_SCOPE
@ BEGIN_DEBUG_SCOPE
Divide::GFX::CommandType::BLIT_RT
@ BLIT_RT
Divide::GFX::CommandType::DRAW_COMMANDS
@ DRAW_COMMANDS
Divide::GFX::CommandType::READ_TEXTURE
@ READ_TEXTURE
Divide::GFX::CommandType::SET_CAMERA
@ SET_CAMERA
Divide::GFX::CommandType::BEGIN_GPU_QUERY
@ BEGIN_GPU_QUERY
Divide::GFX::CommandType::PUSH_CAMERA
@ PUSH_CAMERA
Divide::GFX::CommandType::END_DEBUG_SCOPE
@ END_DEBUG_SCOPE
Divide::GFX::CommandType::BIND_SHADER_RESOURCES
@ BIND_SHADER_RESOURCES
Divide::GFX::CommandType::ADD_DEBUG_MESSAGE
@ ADD_DEBUG_MESSAGE
Divide::GFX::CommandType::SET_SCISSOR
@ SET_SCISSOR
Divide::GFX::CommandType::CLEAR_TEXTURE
@ CLEAR_TEXTURE
Divide
Handle console commands that start with a forward slash.
Definition:
AIProcessor.cpp:7
Divide::ImageUsage
ImageUsage
Definition:
RenderAPIEnums.h:117
Divide::ImageUsage::COUNT
@ COUNT
Divide::RTBlitParams
eastl::fixed_vector< RTBlitEntry, MAX_BLIT_ENTRIES, false > RTBlitParams
Definition:
RTDrawDescriptor.h:77
Divide::DELEGATE_STD
std::function< Ret(Args...) > DELEGATE_STD
Definition:
PlatformDefines.h:743
Divide::U8
uint8_t U8
Definition:
PlatformDataTypes.h:44
Divide::TextureLayoutChanges
eastl::fixed_vector< TextureLayoutChange, 6, true > TextureLayoutChanges
Definition:
Texture.h:77
Divide::BufferLocks
eastl::fixed_vector< BufferLock, 6, true > BufferLocks
Definition:
BufferLocks.h:63
Divide::U16_MAX
constexpr U16 U16_MAX
Definition:
PlatformDataTypes.h:102
Divide::INVALID_RENDER_TARGET_ID
constexpr RenderTargetID INVALID_RENDER_TARGET_ID
Definition:
RenderAPIEnums.h:39
Divide::U32_MAX
constexpr U32 U32_MAX
Definition:
PlatformDataTypes.h:104
Divide::GenericDrawCommandContainer
eastl::fixed_vector< GenericDrawCommand, 1, true > GenericDrawCommandContainer
Definition:
GenericDrawCommand.h:96
Divide::RTClearDescriptor
std::array< RTClearEntry, RT_MAX_ATTACHMENT_COUNT > RTClearDescriptor
Definition:
RTDrawDescriptor.h:78
Divide::RTTransitionMask
bool[RT_MAX_ATTACHMENT_COUNT] RTTransitionMask
Definition:
RTDrawDescriptor.h:79
Divide::RenderTargetID
U32 RenderTargetID
Definition:
RenderAPIEnums.h:38
Divide::DescriptorSetUsage
DescriptorSetUsage
Definition:
RenderAPIEnums.h:68
Divide::DescriptorSetUsage::COUNT
@ COUNT
Divide::U32
uint32_t U32
Definition:
PlatformDataTypes.h:46
Divide::QueryResults
std::array< std::pair< QueryType, I64 >, to_base(QueryType::COUNT)> QueryResults
Definition:
RenderAPIEnums.h:884
Divide::CameraSnapshot
Definition:
CameraSnapshot.h:39
Divide::ClipPlaneList< to_base(ClipPlaneIndex::COUNT)>
Divide::CopyTexParams
Definition:
TextureData.h:39
Divide::DescriptorSet
Definition:
DescriptorSets.h:136
Divide::GFX::AddDebugMessageCommand
Definition:
Commands.inl:180
Divide::GFX::AddDebugMessageCommand::_msg
Str< 64 > _msg
Definition:
Commands.inl:181
Divide::GFX::BeginDebugScopeCommand
Definition:
Commands.inl:173
Divide::GFX::BeginDebugScopeCommand::_scopeName
Str< 64 > _scopeName
Definition:
Commands.inl:174
Divide::GFX::BeginGPUQueryCommand
Definition:
Commands.inl:105
Divide::GFX::BeginRenderPassCommand
Definition:
Commands.inl:94
Divide::GFX::BindPipelineCommand
Definition:
Commands.inl:71
Divide::GFX::BindShaderResourcesCommand
Definition:
Commands.inl:168
Divide::GFX::BindShaderResourcesCommand::_set
DescriptorSet _set
Definition:
Commands.inl:169
Divide::GFX::BlitRenderTargetCommand
Definition:
Commands.inl:114
Divide::GFX::ClearBufferDataCommand
Definition:
Commands.inl:201
Divide::GFX::ClearTextureCommand
Definition:
Commands.inl:135
Divide::GFX::ClearTextureCommand::_clearColour
UColour4 _clearColour
r = depth, g = stencil if target is a depth(+stencil) attachment
Definition:
Commands.inl:138
Divide::GFX::CommandBase
Definition:
Commands.h:51
Divide::GFX::CommandBase::As
FORCE_INLINE T * As()
Definition:
Commands.h:60
Divide::GFX::Command::DeleteCmd
virtual void DeleteCmd(CommandBase *&cmd) const final
Definition:
Commands.inl:64
Divide::GFX::Command::addToBuffer
virtual void addToBuffer(CommandBuffer *buffer) const final
Definition:
Commands.inl:57
Divide::GFX::ComputeMipMapsCommand
Definition:
Commands.inl:143
Divide::GFX::CopyTextureCommand
Definition:
Commands.inl:120
Divide::GFX::CopyTextureCommand::_params
CopyTexParams _params
Definition:
Commands.inl:125
Divide::GFX::DispatchComputeCommand
Definition:
Commands.inl:185
Divide::GFX::DispatchComputeCommand::_computeGroupSize
vec3< U32 > _computeGroupSize
Definition:
Commands.inl:186
Divide::GFX::DrawCommand
Definition:
Commands.inl:80
Divide::GFX::DrawCommand::_drawCommands
GenericDrawCommandContainer _drawCommands
Definition:
Commands.inl:81
Divide::GFX::EndDebugScopeCommand
Definition:
Commands.inl:178
Divide::GFX::EndGPUQueryCommand
Definition:
Commands.inl:109
Divide::GFX::EndRenderPassCommand
Definition:
Commands.inl:101
Divide::GFX::MemoryBarrierCommand
Definition:
Commands.inl:189
Divide::GFX::MemoryBarrierCommand::_textureLayoutChanges
TextureLayoutChanges _textureLayoutChanges
Definition:
Commands.inl:191
Divide::GFX::MemoryBarrierCommand::_bufferLocks
BufferLocks _bufferLocks
Definition:
Commands.inl:190
Divide::GFX::PopCameraCommand
Definition:
Commands.inl:162
Divide::GFX::PopViewportCommand
Definition:
Commands.inl:92
Divide::GFX::PushCameraCommand
Definition:
Commands.inl:158
Divide::GFX::PushCameraCommand::_cameraSnapshot
CameraSnapshot _cameraSnapshot
Definition:
Commands.inl:159
Divide::GFX::PushViewportCommand
Definition:
Commands.inl:88
Divide::GFX::PushViewportCommand::_viewport
Rect< I32 > _viewport
Definition:
Commands.inl:89
Divide::GFX::ReadBufferDataCommand
Definition:
Commands.inl:194
Divide::GFX::ReadTextureCommand
Definition:
Commands.inl:128
Divide::GFX::ReadTextureCommand::_callback
DELEGATE_STD< void, const ImageReadbackData & > _callback
Definition:
Commands.inl:132
Divide::GFX::SendPushConstantsCommand
Definition:
Commands.inl:75
Divide::GFX::SetCameraCommand
Definition:
Commands.inl:154
Divide::GFX::SetCameraCommand::_cameraSnapshot
CameraSnapshot _cameraSnapshot
Definition:
Commands.inl:155
Divide::GFX::SetClipPlanesCommand
Definition:
Commands.inl:164
Divide::GFX::SetClipPlanesCommand::_clippingPlanes
FrustumClipPlanes _clippingPlanes
Definition:
Commands.inl:165
Divide::GFX::SetScissorCommand
Definition:
Commands.inl:150
Divide::GFX::SetScissorCommand::_rect
Rect< I32 > _rect
Definition:
Commands.inl:151
Divide::GFX::SetViewportCommand
Definition:
Commands.inl:84
Divide::GFX::SetViewportCommand::_viewport
Rect< I32 > _viewport
Definition:
Commands.inl:85
Divide::Handle
Definition:
PlatformDefines.h:519
Divide::PixelAlignment
Definition:
TextureDescriptor.h:45
Divide::PushConstantsStruct
Definition:
PushConstants.h:41
Divide::RTDrawDescriptor
Definition:
RTDrawDescriptor.h:83
Divide::SubRange
Definition:
DescriptorSets.h:44
Divide::UniformData
Definition:
PushConstants.h:58
Source
Platform
Video
Headers
Commands.inl
Generated on Fri May 17 2024 16:59:54 for Divide Framework by
1.9.6