summaryrefslogtreecommitdiffstats
path: root/src/runtimerender/Qt3DSRenderDynamicObjectSystemCommands.h
blob: 0628d8d84518906655e9a432e0c7c5e3632a6d1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
/****************************************************************************
**
** Copyright (C) 2008-2012 NVIDIA Corporation.
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt 3D Studio.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#pragma once
#ifndef QT3DS_RENDER_EFFECT_SYSTEM_COMMANDS_H
#define QT3DS_RENDER_EFFECT_SYSTEM_COMMANDS_H
#include "Qt3DSRender.h"
#include "foundation/StringTable.h"
#include "render/Qt3DSRenderBaseTypes.h"
#include "foundation/Qt3DSIntrinsics.h"
#include "foundation/Qt3DSFlags.h"

namespace qt3ds {
namespace render {
    namespace dynamic {
        using qt3ds::render::NVRenderBufferBarrierFlags;

        struct CommandTypes
        {
            enum Enum {
                Unknown = 0,
                AllocateBuffer,
                BindTarget,
                BindBuffer,
                BindShader,
                ApplyInstanceValue,
                ApplyBufferValue,
                // Apply the depth buffer as an input texture.
                ApplyDepthValue,
                Render, // Render to current FBO
                ApplyDepth,
                ApplyBlending,
                ApplyRenderState, // apply a render state
                ApplyBlitFramebuffer,
                ApplyValue,
                DepthStencil,
                AllocateImage,
                ApplyImageValue,
                AllocateDataBuffer,
                ApplyDataBufferValue,
                ApplyCulling
            };
        };

#define QT3DS_RENDER_EFFECTS_ITERATE_COMMAND_TYPES                                                   \
    QT3DS_RENDER_EFFECTS_HANDLE_COMMAND_TYPES(AllocateBuffer)                                        \
    QT3DS_RENDER_EFFECTS_HANDLE_COMMAND_TYPES(BindTarget)                                            \
    QT3DS_RENDER_EFFECTS_HANDLE_COMMAND_TYPES(BindBuffer)                                            \
    QT3DS_RENDER_EFFECTS_HANDLE_COMMAND_TYPES(BindShader)                                            \
    QT3DS_RENDER_EFFECTS_HANDLE_COMMAND_TYPES(ApplyInstanceValue)                                    \
    QT3DS_RENDER_EFFECTS_HANDLE_COMMAND_TYPES(ApplyBufferValue)                                      \
    QT3DS_RENDER_EFFECTS_HANDLE_COMMAND_TYPES(ApplyDepthValue)                                       \
    QT3DS_RENDER_EFFECTS_HANDLE_COMMAND_TYPES(Render)                                                \
    QT3DS_RENDER_EFFECTS_HANDLE_COMMAND_TYPES(ApplyBlending)                                         \
    QT3DS_RENDER_EFFECTS_HANDLE_COMMAND_TYPES(ApplyRenderState)                                      \
    QT3DS_RENDER_EFFECTS_HANDLE_COMMAND_TYPES(ApplyBlitFramebuffer)                                  \
    QT3DS_RENDER_EFFECTS_HANDLE_COMMAND_TYPES(ApplyValue)                                            \
    QT3DS_RENDER_EFFECTS_HANDLE_COMMAND_TYPES(DepthStencil)                                          \
    QT3DS_RENDER_EFFECTS_HANDLE_COMMAND_TYPES(AllocateImage)                                         \
    QT3DS_RENDER_EFFECTS_HANDLE_COMMAND_TYPES(ApplyImageValue)                                       \
    QT3DS_RENDER_EFFECTS_HANDLE_COMMAND_TYPES(AllocateDataBuffer)                                    \
    QT3DS_RENDER_EFFECTS_HANDLE_COMMAND_TYPES(ApplyDataBufferValue)                                  \
    QT3DS_RENDER_EFFECTS_HANDLE_COMMAND_TYPES(ApplyCulling)

        // All commands need at least two constructors.  One for when they are created that should
        // setup all their member variables and one for when we are copying commands from an outside
        // entity into the effect system.  We have to re-register strings in that case because we
        // can't assume the outside entity was using the same string table we are...
        struct SCommand
        {
            CommandTypes::Enum m_Type;
            SCommand(CommandTypes::Enum inType)
                : m_Type(inType)
            {
            }
            SCommand()
                : m_Type(CommandTypes::Unknown)
            {
            }
            // Implemented in UICRenderEffectSystem.cpp
            static QT3DSU32 GetSizeofCommand(const SCommand &inCommand);
            static void CopyConstructCommand(QT3DSU8 *inDataBuffer, const SCommand &inCommand,
                                             IStringTable &inStrTable);
        };

        struct AllocateBufferFlagValues
        {
            enum Enum {
                SceneLifetime = 1,
            };
        };

        struct SAllocateBufferFlags : public NVFlags<AllocateBufferFlagValues::Enum, QT3DSU32>
        {
            SAllocateBufferFlags(QT3DSU32 inValues)
                : NVFlags<AllocateBufferFlagValues::Enum, QT3DSU32>(inValues)
            {
            }
            SAllocateBufferFlags() {}
            void SetSceneLifetime(bool inValue)
            {
                clearOrSet(inValue, AllocateBufferFlagValues::SceneLifetime);
            }
            // If isSceneLifetime is unset the buffer is assumed to be frame lifetime and will be
            // released after this render operation.
            bool IsSceneLifetime() const
            {
                return this->operator&(AllocateBufferFlagValues::SceneLifetime);
            }
        };

        struct SAllocateBuffer : public SCommand
        {
            CRegisteredString m_Name;
            NVRenderTextureFormats::Enum m_Format;
            NVRenderTextureMagnifyingOp::Enum m_FilterOp;
            NVRenderTextureCoordOp::Enum m_TexCoordOp;
            QT3DSF32 m_SizeMultiplier;
            SAllocateBufferFlags m_BufferFlags;
            SAllocateBuffer()
                : SCommand(CommandTypes::AllocateBuffer)
                , m_Format(NVRenderTextureFormats::RGBA8)
                , m_FilterOp(NVRenderTextureMagnifyingOp::Linear)
                , m_TexCoordOp(NVRenderTextureCoordOp::ClampToEdge)
                , m_SizeMultiplier(1.0f)
            {
            }
            SAllocateBuffer(CRegisteredString inName, NVRenderTextureFormats::Enum inFormat,
                            NVRenderTextureMagnifyingOp::Enum inFilterOp,
                            NVRenderTextureCoordOp::Enum inCoordOp, QT3DSF32 inMultiplier,
                            SAllocateBufferFlags inFlags)
                : SCommand(CommandTypes::AllocateBuffer)
                , m_Name(inName)
                , m_Format(inFormat)
                , m_FilterOp(inFilterOp)
                , m_TexCoordOp(inCoordOp)
                , m_SizeMultiplier(inMultiplier)
                , m_BufferFlags(inFlags)
            {
            }
            SAllocateBuffer(const SAllocateBuffer &inOther, IStringTable &inStrTable)
                : SCommand(CommandTypes::AllocateBuffer)
                , m_Name(inStrTable.RegisterStr(inOther.m_Name))
                , m_Format(inOther.m_Format)
                , m_FilterOp(inOther.m_FilterOp)
                , m_TexCoordOp(inOther.m_TexCoordOp)
                , m_SizeMultiplier(inOther.m_SizeMultiplier)
                , m_BufferFlags(inOther.m_BufferFlags)
            {
            }
        };

        struct SAllocateImage : public SAllocateBuffer
        {
            NVRenderImageAccessType::Enum m_Access;

            SAllocateImage()
                : SAllocateBuffer()
                , m_Access(NVRenderImageAccessType::ReadWrite)
            {
                m_Type = CommandTypes::AllocateImage;
            }
            SAllocateImage(CRegisteredString inName, NVRenderTextureFormats::Enum inFormat,
                           NVRenderTextureMagnifyingOp::Enum inFilterOp,
                           NVRenderTextureCoordOp::Enum inCoordOp, QT3DSF32 inMultiplier,
                           SAllocateBufferFlags inFlags, NVRenderImageAccessType::Enum inAccess)
                : SAllocateBuffer(inName, inFormat, inFilterOp, inCoordOp, inMultiplier, inFlags)
                , m_Access(inAccess)
            {
                m_Type = CommandTypes::AllocateImage;
            }

            SAllocateImage(const SAllocateImage &inOther, IStringTable &inStrTable)
                : SAllocateBuffer(inStrTable.RegisterStr(inOther.m_Name), inOther.m_Format,
                                  inOther.m_FilterOp, inOther.m_TexCoordOp,
                                  inOther.m_SizeMultiplier, inOther.m_BufferFlags)
                , m_Access(inOther.m_Access)
            {
                m_Type = CommandTypes::AllocateImage;
            }
        };

        struct SAllocateDataBuffer : public SCommand
        {
            CRegisteredString m_Name;
            NVRenderBufferBindValues::Enum m_DataBufferType;
            CRegisteredString m_WrapName;
            NVRenderBufferBindValues::Enum m_DataBufferWrapType;
            QT3DSF32 m_Size;
            SAllocateBufferFlags m_BufferFlags;

            SAllocateDataBuffer()
                : SCommand(CommandTypes::AllocateDataBuffer)
            {
            }

            SAllocateDataBuffer(CRegisteredString inName,
                                NVRenderBufferBindValues::Enum inBufferType,
                                CRegisteredString inWrapName,
                                NVRenderBufferBindValues::Enum inBufferWrapType, QT3DSF32 inSize,
                                SAllocateBufferFlags inFlags)
                : SCommand(CommandTypes::AllocateDataBuffer)
                , m_Name(inName)
                , m_DataBufferType(inBufferType)
                , m_WrapName(inWrapName)
                , m_DataBufferWrapType(inBufferWrapType)
                , m_Size(inSize)
                , m_BufferFlags(inFlags)
            {
            }

            SAllocateDataBuffer(const SAllocateDataBuffer &inOther, IStringTable &inStrTable)
                : SCommand(CommandTypes::AllocateDataBuffer)
                , m_Name(inStrTable.RegisterStr(inOther.m_Name))
                , m_DataBufferType(inOther.m_DataBufferType)
                , m_WrapName(inStrTable.RegisterStr(inOther.m_WrapName))
                , m_DataBufferWrapType(inOther.m_DataBufferWrapType)
                , m_Size(inOther.m_Size)
                , m_BufferFlags(inOther.m_BufferFlags)
            {
            }
        };

        struct SBindTarget : public SCommand
        {
            NVRenderTextureFormats::Enum m_OutputFormat;

            SBindTarget(NVRenderTextureFormats::Enum inFormat = NVRenderTextureFormats::RGBA8)
                : SCommand(CommandTypes::BindTarget)
                , m_OutputFormat(inFormat)
            {
            }
            SBindTarget(const SBindTarget &inOther, IStringTable &)
                : SCommand(CommandTypes::BindTarget)
                , m_OutputFormat(inOther.m_OutputFormat)
            {
            }
        };

        struct SBindBuffer : public SCommand
        {
            CRegisteredString m_BufferName;
            bool m_NeedsClear;
            SBindBuffer(CRegisteredString inBufName, bool inNeedsClear)
                : SCommand(CommandTypes::BindBuffer)
                , m_BufferName(inBufName)
                , m_NeedsClear(inNeedsClear)
            {
            }
            SBindBuffer(const SBindBuffer &inOther, IStringTable &inTable)
                : SCommand(CommandTypes::BindBuffer)
                , m_BufferName(inTable.RegisterStr(inOther.m_BufferName))
                , m_NeedsClear(inOther.m_NeedsClear)
            {
            }
        };

        struct SBindShader : public SCommand
        {
            CRegisteredString m_ShaderPath;
            // One GLSL file can hold multiple shaders in the case of multipass effects.
            // This makes it significantly easier for authors to reason about the shader
            // but it means we need to #define a preprocessor token to indicate which
            // effect we intend to compile at this point.
            CRegisteredString m_ShaderDefine;
            SBindShader(CRegisteredString inShaderPath,
                        CRegisteredString inShaderDefine = CRegisteredString())
                : SCommand(CommandTypes::BindShader)
                , m_ShaderPath(inShaderPath)
                , m_ShaderDefine(inShaderDefine)
            {
            }
            SBindShader()
                : SCommand(CommandTypes::BindShader)
            {
            }
            SBindShader(const SBindShader &inOther, IStringTable &inTable)
                : SCommand(CommandTypes::BindShader)
                , m_ShaderPath(inTable.RegisterStr(inOther.m_ShaderPath))
                , m_ShaderDefine(inTable.RegisterStr(inOther.m_ShaderDefine))
            {
            }
        };

        // The value sits immediately after the 'this' object
        // in memory.
        // If propertyName is not valid then we attempt to apply all of the effect property values
        // to the shader, ignoring ones that don't match up.
        struct SApplyInstanceValue : public SCommand
        {
            // Name of value to apply in shader
            CRegisteredString m_PropertyName;
            // type of value
            NVRenderShaderDataTypes::Enum m_ValueType;
            // offset in the effect data section of value.
            QT3DSU32 m_ValueOffset;
            SApplyInstanceValue(CRegisteredString inName, NVRenderShaderDataTypes::Enum inValueType,
                                QT3DSU32 inValueOffset)
                : SCommand(CommandTypes::ApplyInstanceValue)
                , m_PropertyName(inName)
                , m_ValueType(inValueType)
                , m_ValueOffset(inValueOffset)
            {
            }
            // Default will attempt to apply all effect values to the currently bound shader
            SApplyInstanceValue()
                : SCommand(CommandTypes::ApplyInstanceValue)
                , m_ValueType(NVRenderShaderDataTypes::Unknown)
                , m_ValueOffset(0)
            {
            }
            SApplyInstanceValue(const SApplyInstanceValue &inOther, IStringTable &inTable)
                : SCommand(CommandTypes::ApplyInstanceValue)
                , m_PropertyName(inTable.RegisterStr(inOther.m_PropertyName))
                , m_ValueType(inOther.m_ValueType)
                , m_ValueOffset(inOther.m_ValueOffset)
            {
            }
        };

        struct SApplyValue : public SCommand
        {
            CRegisteredString m_PropertyName;
            NVRenderShaderDataTypes::Enum m_ValueType;
            NVDataRef<QT3DSU8> m_Value;
            SApplyValue(CRegisteredString inName, NVRenderShaderDataTypes::Enum inValueType)
                : SCommand(CommandTypes::ApplyValue)
                , m_PropertyName(inName)
                , m_ValueType(inValueType)
            {
            }
            // Default will attempt to apply all effect values to the currently bound shader
            SApplyValue()
                : SCommand(CommandTypes::ApplyValue)
                , m_ValueType(NVRenderShaderDataTypes::Unknown)
            {
            }

            SApplyValue(const SApplyValue &inOther, IStringTable &inTable)
                : SCommand(CommandTypes::ApplyValue)
                , m_PropertyName(inTable.RegisterStr(inOther.m_PropertyName))
                , m_ValueType(inOther.m_ValueType)
                , m_Value(inOther.m_Value)
            {
            }
        };

        // bind a buffer to a given shader parameter.
        struct SApplyBufferValue : public SCommand
        {
            // If no buffer name is given then the special buffer [source]
            // is assumed.
            CRegisteredString m_BufferName;
            // If no param name is given, the buffer is bound to the
            // input texture parameter (texture0).
            CRegisteredString m_ParamName;

            SApplyBufferValue(CRegisteredString bufferName, CRegisteredString shaderParam)
                : SCommand(CommandTypes::ApplyBufferValue)
                , m_BufferName(bufferName)
                , m_ParamName(shaderParam)
            {
            }
            SApplyBufferValue(const SApplyBufferValue &inOther, IStringTable &inTable)
                : SCommand(CommandTypes::ApplyBufferValue)
                , m_BufferName(inTable.RegisterStr(inOther.m_BufferName))
                , m_ParamName(inTable.RegisterStr(inOther.m_ParamName))
            {
            }
        };

        // bind a buffer to a given shader parameter.
        struct SApplyImageValue : public SCommand
        {
            CRegisteredString m_ImageName; ///< name which the image was allocated
            CRegisteredString m_ParamName; ///< must match the name in the shader
            bool m_BindAsTexture; ///< bind image as texture
            bool m_NeedSync; ///< if true we add a memory barrier before usage

            SApplyImageValue(CRegisteredString bufferName, CRegisteredString shaderParam,
                             bool inBindAsTexture, bool inNeedSync)
                : SCommand(CommandTypes::ApplyImageValue)
                , m_ImageName(bufferName)
                , m_ParamName(shaderParam)
                , m_BindAsTexture(inBindAsTexture)
                , m_NeedSync(inNeedSync)
            {
            }
            SApplyImageValue(const SApplyImageValue &inOther, IStringTable &inTable)
                : SCommand(CommandTypes::ApplyImageValue)
                , m_ImageName(inTable.RegisterStr(inOther.m_ImageName))
                , m_ParamName(inTable.RegisterStr(inOther.m_ParamName))
                , m_BindAsTexture(inOther.m_BindAsTexture)
                , m_NeedSync(inOther.m_NeedSync)
            {
            }
        };

        // bind a buffer to a given shader parameter.
        struct SApplyDataBufferValue : public SCommand
        {
            CRegisteredString m_ParamName; ///< must match the name in the shader
            NVRenderBufferBindValues::Enum m_BindAs; ///< to which target we bind this buffer

            SApplyDataBufferValue(CRegisteredString inShaderParam,
                                  NVRenderBufferBindValues::Enum inBufferType)
                : SCommand(CommandTypes::ApplyDataBufferValue)
                , m_ParamName(inShaderParam)
                , m_BindAs(inBufferType)
            {
            }
            SApplyDataBufferValue(const SApplyDataBufferValue &inOther, IStringTable &inTable)
                : SCommand(CommandTypes::ApplyDataBufferValue)
                , m_ParamName(inTable.RegisterStr(inOther.m_ParamName))
                , m_BindAs(inOther.m_BindAs)
            {
            }
        };

        struct SApplyDepthValue : public SCommand
        {
            // If no param name is given, the buffer is bound to the
            // input texture parameter (texture0).
            CRegisteredString m_ParamName;
            SApplyDepthValue(CRegisteredString param)
                : SCommand(CommandTypes::ApplyDepthValue)
                , m_ParamName(param)
            {
            }
            SApplyDepthValue(const SApplyDepthValue &inOther, IStringTable &inTable)
                : SCommand(CommandTypes::ApplyDepthValue)
                , m_ParamName(inTable.RegisterStr(inOther.m_ParamName))
            {
            }
        };

        struct SRender : public SCommand
        {
            bool m_DrawIndirect;
            SRender(bool inDrawIndirect)
                : SCommand(CommandTypes::Render)
                , m_DrawIndirect(inDrawIndirect)
            {
            }

            SRender(const SRender &inOther, IStringTable &)
                : SCommand(CommandTypes::Render)
                , m_DrawIndirect(inOther.m_DrawIndirect)
            {
            }
        };

        struct SApplyCulling : public SCommand
        {
            NVRenderFaces::Enum m_CullMode;
            SApplyCulling(NVRenderFaces::Enum cullMode)
                : SCommand(CommandTypes::ApplyCulling)
                , m_CullMode(cullMode)
            {
            }
            SApplyCulling(const SApplyCulling &inOther, IStringTable &)
                : SCommand(CommandTypes::ApplyCulling)
                , m_CullMode(inOther.m_CullMode)
            {
            }
        };

        struct SApplyDepth : public SCommand
        {
            NVRenderBoolOp::Enum m_depthFunc;
            bool m_depthMask;

            SApplyDepth(NVRenderBoolOp::Enum depthFunc, bool depthMask)
                : SCommand(CommandTypes::ApplyDepth)
                , m_depthFunc(depthFunc)
                , m_depthMask(depthMask)
            {
            }

            SApplyDepth(const SApplyDepth &other, IStringTable &)
                : SCommand(CommandTypes::ApplyDepth)
                , m_depthFunc(other.m_depthFunc)
                , m_depthMask(other.m_depthMask)
            {
            }
        };

        struct SApplyBlending : public SCommand
        {
            NVRenderSrcBlendFunc::Enum m_SrcBlendFunc;
            NVRenderDstBlendFunc::Enum m_DstBlendFunc;

            SApplyBlending(NVRenderSrcBlendFunc::Enum inSrcBlendFunc,
                           NVRenderDstBlendFunc::Enum inDstBlendFunc)
                : SCommand(CommandTypes::ApplyBlending)
                , m_SrcBlendFunc(inSrcBlendFunc)
                , m_DstBlendFunc(inDstBlendFunc)
            {
            }

            SApplyBlending(const SApplyBlending &inOther, IStringTable &)
                : SCommand(CommandTypes::ApplyBlending)
                , m_SrcBlendFunc(inOther.m_SrcBlendFunc)
                , m_DstBlendFunc(inOther.m_DstBlendFunc)
            {
            }
        };

        struct SApplyRenderState : public SCommand
        {
            NVRenderState::Enum m_RenderState;
            bool m_Enabled;

            SApplyRenderState(qt3ds::render::NVRenderState::Enum inRenderStateValue, bool inEnabled)
                : SCommand(CommandTypes::ApplyRenderState)
                , m_RenderState(inRenderStateValue)
                , m_Enabled(inEnabled)
            {
            }

            SApplyRenderState(const SApplyRenderState &inOther, IStringTable &)
                : SCommand(CommandTypes::ApplyRenderState)
                , m_RenderState(inOther.m_RenderState)
                , m_Enabled(inOther.m_Enabled)
            {
            }
        };

        struct SApplyBlitFramebuffer : public SCommand
        {
            // If no buffer name is given then the special buffer [source]
            // is assumed. Which is the default render target
            CRegisteredString m_SourceBufferName;
            // If no buffer name is given then the special buffer [dest]
            // is assumed. Which is the default render target
            CRegisteredString m_DestBufferName;

            SApplyBlitFramebuffer(CRegisteredString inSourceBufferName,
                                  CRegisteredString inDestBufferName)
                : SCommand(CommandTypes::ApplyBlitFramebuffer)
                , m_SourceBufferName(inSourceBufferName)
                , m_DestBufferName(inDestBufferName)
            {
            }

            SApplyBlitFramebuffer(const SApplyBlitFramebuffer &inOther, IStringTable &inTable)
                : SCommand(CommandTypes::ApplyBlitFramebuffer)
                , m_SourceBufferName(inTable.RegisterStr(inOther.m_SourceBufferName))
                , m_DestBufferName(inTable.RegisterStr(inOther.m_DestBufferName))
            {
            }
        };

        struct DepthStencilFlagValues
        {
            enum Enum {
                NoFlagValue = 0,
                ClearStencil = 1 << 0,
                ClearDepth = 1 << 1,
            };
        };

        struct SDepthStencilFlags : public NVFlags<DepthStencilFlagValues::Enum>
        {
            bool HasClearStencil() const { return operator&(DepthStencilFlagValues::ClearStencil); }
            void SetClearStencil(bool value)
            {
                clearOrSet(value, DepthStencilFlagValues::ClearStencil);
            }

            bool HasClearDepth() const { return operator&(DepthStencilFlagValues::ClearDepth); }
            void SetClearDepth(bool value)
            {
                clearOrSet(value, DepthStencilFlagValues::ClearDepth);
            }
        };

        struct SDepthStencil : public SCommand
        {
            CRegisteredString m_BufferName;
            SDepthStencilFlags m_Flags;
            qt3ds::render::NVRenderStencilOp::Enum m_StencilFailOperation;
            qt3ds::render::NVRenderStencilOp::Enum m_DepthPassOperation;
            qt3ds::render::NVRenderStencilOp::Enum m_DepthFailOperation;
            qt3ds::render::NVRenderBoolOp::Enum m_StencilFunction;
            QT3DSU32 m_Reference;
            QT3DSU32 m_Mask;

            SDepthStencil()
                : SCommand(CommandTypes::DepthStencil)
                , m_StencilFailOperation(qt3ds::render::NVRenderStencilOp::Keep)
                , m_DepthPassOperation(qt3ds::render::NVRenderStencilOp::Keep)
                , m_DepthFailOperation(qt3ds::render::NVRenderStencilOp::Keep)
                , m_StencilFunction(qt3ds::render::NVRenderBoolOp::Equal)
                , m_Reference(0)
                , m_Mask(QT3DS_MAX_U32)
            {
            }

            SDepthStencil(CRegisteredString bufName, SDepthStencilFlags flags,
                          qt3ds::render::NVRenderStencilOp::Enum inStencilOp,
                          qt3ds::render::NVRenderStencilOp::Enum inDepthPassOp,
                          qt3ds::render::NVRenderStencilOp::Enum inDepthFailOp,
                          qt3ds::render::NVRenderBoolOp::Enum inStencilFunc, QT3DSU32 value, QT3DSU32 mask)
                : SCommand(CommandTypes::DepthStencil)
                , m_BufferName(bufName)
                , m_Flags(flags)
                , m_StencilFailOperation(inStencilOp)
                , m_DepthPassOperation(inDepthPassOp)
                , m_DepthFailOperation(inDepthFailOp)
                , m_StencilFunction(inStencilFunc)
                , m_Reference(value)
                , m_Mask(mask)
            {
            }

            SDepthStencil(const SDepthStencil &inOther, IStringTable &inTable)
                : SCommand(CommandTypes::DepthStencil)
                , m_BufferName(inTable.RegisterStr(inOther.m_BufferName))
                , m_Flags(inOther.m_Flags)
                , m_StencilFailOperation(inOther.m_StencilFailOperation)
                , m_DepthPassOperation(inOther.m_DepthPassOperation)
                , m_DepthFailOperation(inOther.m_DepthFailOperation)
                , m_StencilFunction(inOther.m_StencilFunction)
                , m_Reference(inOther.m_Reference)
                , m_Mask(inOther.m_Mask)
            {
            }
        };
    }
}
}

#endif