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
661
662
663
664
665
666
667
668
669
|
#pragma once
#include "Runtime/GfxDevice/GfxDevice.h"
#include "Runtime/GfxDevice/ChannelAssigns.h"
#include "Runtime/GfxDevice/threaded/ThreadedDeviceStates.h"
#include "Runtime/GfxDevice/threaded/ClientIDMapper.h"
struct ClientDeviceVBO;
enum GfxCommand
{
kGfxCmd_Unused = 10000,
kGfxCmd_InvalidateState,
kGfxCmd_VerifyState,
kGfxCmd_SetMaxBufferedFrames,
kGfxCmd_Clear,
kGfxCmd_SetUserBackfaceMode,
kGfxCmd_SetInvertProjectionMatrix,
kGfxCmd_SetViewportOffset,
kGfxCmd_CreateBlendState,
kGfxCmd_CreateDepthState,
kGfxCmd_CreateStencilState,
kGfxCmd_CreateRasterState,
kGfxCmd_SetBlendState,
kGfxCmd_SetDepthState,
kGfxCmd_SetStencilState,
kGfxCmd_SetRasterState,
kGfxCmd_SetSRGBState,
kGfxCmd_SetWorldMatrix,
kGfxCmd_SetViewMatrix,
kGfxCmd_SetProjectionMatrix,
kGfxCmd_SetInverseScale,
kGfxCmd_SetNormalizationBackface,
kGfxCmd_SetFFLighting,
kGfxCmd_SetMaterial,
kGfxCmd_SetColor,
kGfxCmd_SetViewport,
kGfxCmd_SetScissorRect,
kGfxCmd_DisableScissor,
kGfxCmd_CreateTextureCombiners,
kGfxCmd_DeleteTextureCombiners,
kGfxCmd_SetTextureCombiners,
kGfxCmd_SetTexture,
kGfxCmd_SetTextureParams,
kGfxCmd_SetTextureTransform,
kGfxCmd_SetTextureName,
kGfxCmd_SetMaterialProperties,
kGfxCmd_CreateGpuProgram,
kGfxCmd_SetShaders,
kGfxCmd_CreateShaderParameters,
kGfxCmd_DestroySubProgram,
kGfxCmd_SetConstantBufferInfo,
kGfxCmd_DisableLights,
kGfxCmd_SetLight,
kGfxCmd_SetAmbient,
kGfxCmd_EnableFog,
kGfxCmd_DisableFog,
kGfxCmd_BeginSkinning,
kGfxCmd_SkinMesh,
kGfxCmd_EndSkinning,
kGfxCmd_BeginStaticBatching,
kGfxCmd_StaticBatchMesh,
kGfxCmd_EndStaticBatching,
kGfxCmd_BeginDynamicBatching,
kGfxCmd_DynamicBatchMesh,
#if ENABLE_SPRITES
kGfxCmd_DynamicBatchSprite,
#endif
kGfxCmd_EndDynamicBatching,
kGfxCmd_AddBatchingStats,
kGfxCmd_CreateRenderColorSurface,
kGfxCmd_CreateRenderDepthSurface,
kGfxCmd_DestroyRenderSurface,
kGfxCmd_DiscardContents,
kGfxCmd_SetRenderTarget,
kGfxCmd_SetRenderTargetWithFlags,
kGfxCmd_ResolveColorSurface,
kGfxCmd_ResolveDepthIntoTexture,
kGfxCmd_SetSurfaceFlags,
kGfxCmd_UploadTexture2D,
kGfxCmd_UploadTextureSubData2D,
kGfxCmd_UploadTextureCube,
kGfxCmd_UploadTexture3D,
kGfxCmd_DeleteTexture,
kGfxCmd_BeginFrame,
kGfxCmd_EndFrame,
kGfxCmd_PresentFrame,
kGfxCmd_HandleInvalidState,
kGfxCmd_FinishRendering,
kGfxCmd_InsertCPUFence,
kGfxCmd_ImmediateVertex,
kGfxCmd_ImmediateNormal,
kGfxCmd_ImmediateColor,
kGfxCmd_ImmediateTexCoordAll,
kGfxCmd_ImmediateTexCoord,
kGfxCmd_ImmediateBegin,
kGfxCmd_ImmediateEnd,
kGfxCmd_CaptureScreenshot,
kGfxCmd_ReadbackImage,
kGfxCmd_GrabIntoRenderTexture,
kGfxCmd_SetActiveContext,
kGfxCmd_ResetFrameStats,
kGfxCmd_BeginFrameStats,
kGfxCmd_EndFrameStats,
kGfxCmd_SaveDrawStats,
kGfxCmd_RestoreDrawStats,
kGfxCmd_SynchronizeStats,
kGfxCmd_SetAntiAliasFlag,
kGfxCmd_SetWireframe,
kGfxCmd_DrawUserPrimitives,
kGfxCmd_Quit,
kGfxCmd_VBO_UpdateVertexData,
kGfxCmd_VBO_UpdateIndexData,
kGfxCmd_VBO_Draw,
kGfxCmd_VBO_DrawCustomIndexed,
kGfxCmd_VBO_Recreate,
kGfxCmd_VBO_MapVertexStream,
kGfxCmd_VBO_IsVertexBufferLost,
kGfxCmd_VBO_SetVertexStreamMode,
kGfxCmd_VBO_SetIndicesDynamic,
kGfxCmd_VBO_GetRuntimeMemorySize,
kGfxCmd_VBO_GetVertexSize,
kGfxCmd_VBO_AddExtraUvChannels,
kGfxCmd_VBO_CopyExtraUvChannels,
kGfxCmd_VBO_Constructor,
kGfxCmd_VBO_Destructor,
kGfxCmd_VBO_UseAsStreamOutput,
kGfxCmd_DynVBO_Chunk,
kGfxCmd_DynVBO_DrawChunk,
kGfxCmd_DisplayList_Call,
kGfxCmd_DisplayList_End,
kGfxCmd_CreateWindow,
kGfxCmd_SetActiveWindow,
kGfxCmd_WindowReshape,
kGfxCmd_WindowDestroy,
kGfxCmd_BeginRendering,
kGfxCmd_EndRendering,
kGfxCmd_AcquireThreadOwnership,
kGfxCmd_ReleaseThreadOwnership,
kGfxCmd_BeginProfileEvent,
kGfxCmd_EndProfileEvent,
kGfxCmd_ProfileControl,
kGfxCmd_BeginTimerQueries,
kGfxCmd_EndTimerQueries,
kGfxCmd_TimerQuery_Constructor,
kGfxCmd_TimerQuery_Destructor,
kGfxCmd_TimerQuery_Measure,
kGfxCmd_TimerQuery_GetElapsed,
kGfxCmd_InsertCustomMarker,
kGfxCmd_SetComputeBufferData,
kGfxCmd_GetComputeBufferData,
kGfxCmd_CopyComputeBufferCount,
kGfxCmd_SetRandomWriteTargetTexture,
kGfxCmd_SetRandomWriteTargetBuffer,
kGfxCmd_ClearRandomWriteTargets,
kGfxCmd_CreateComputeProgram,
kGfxCmd_DestroyComputeProgram,
kGfxCmd_CreateComputeConstantBuffers,
kGfxCmd_DestroyComputeConstantBuffers,
kGfxCmd_CreateComputeBuffer,
kGfxCmd_DestroyComputeBuffer,
kGfxCmd_UpdateComputeConstantBuffers,
kGfxCmd_UpdateComputeResources,
kGfxCmd_DispatchComputeProgram,
kGfxCmd_DrawNullGeometry,
kGfxCmd_DrawNullGeometryIndirect,
kGfxCmd_QueryGraphicsCaps,
kGfxCmd_SetGpuProgramParameters,
kGfxCmd_DeleteGPUSkinningInfo,
kGfxCmd_SkinOnGPU,
kGfxCmd_UpdateSkinSourceData,
kGfxCmd_UpdateSkinBonePoses,
// Keep platform specific flags last
#if UNITY_XENON
kGfxCmd_RawVBO_Constructor,
kGfxCmd_RawVBO_Destructor,
kGfxCmd_RawVBO_Next,
kGfxCmd_RawVBO_Write,
kGfxCmd_RawVBO_InvalidateGpuCache,
kGfxCmd_EnablePersistDisplayOnQuit,
kGfxCmd_OnLastFrameCallback,
kGfxCmd_RegisterTexture2D,
kGfxCmd_PatchTexture2D,
kGfxCmd_DeleteTextureEntryOnly,
kGfxCmd_UnbindAndDelayReleaseTexture,
kGfxCmd_SetTextureWrapModes,
kGfxCmd_VideoPlayer_Constructor,
kGfxCmd_VideoPlayer_Destructor,
kGfxCmd_VideoPlayer_Render,
kGfxCmd_VideoPlayer_Pause,
kGfxCmd_VideoPlayer_Resume,
kGfxCmd_VideoPlayer_Stop,
kGfxCmd_VideoPlayer_SetPlaySpeed,
kGfxCmd_VideoPlayer_Play,
kGfxCmd_SetHiStencilState,
kGfxCmd_HiStencilFlush,
kGfxCmd_SetNullPixelShader,
kGfxCmd_EnableHiZ,
#endif
kGfxCmd_Count
};
typedef int GfxCmdBool;
struct GfxCmdClear
{
UInt32 clearFlags;
Vector4f color;
float depth;
int stencil;
};
struct GfxCmdSetNormalizationBackface
{
NormalizationMode mode;
bool backface;
};
struct GfxCmdSetFFLighting
{
bool on;
bool separateSpecular;
ColorMaterialMode colorMaterial;
};
struct GfxCmdCreateTextureCombiners
{
int count;
bool hasVertexColorOrLighting;
bool usesAddSpecular;
};
struct GfxCmdSetTexture
{
ShaderType shaderType;
int unit;
int samplerUnit;
TextureID texture;
TextureDimension dim;
float bias;
};
struct GfxCmdSetTextureParams
{
TextureID texture;
TextureDimension texDim;
TextureFilterMode filter;
TextureWrapMode wrap;
int anisoLevel;
bool hasMipMap;
TextureColorSpace colorSpace;
};
struct GfxCmdSetTextureName
{
TextureID texture;
int nameLength;
};
struct GfxCmdSetTextureBias
{
int unit;
float bias;
};
struct GfxCmdSetTextureTransform
{
int unit;
TextureDimension dim;
TexGenMode texGen;
bool identity;
Matrix4x4f matrix;
};
struct GfxCmdSetMaterialProperties
{
int propertyCount;
int bufferSize;
};
#if !ENABLE_GFXDEVICE_REMOTE_PROCESS
struct GfxCmdCreateGpuProgram
{
const char *source;
CreateGpuProgramOutput* output;
GpuProgram** result;
};
#endif
struct GfxCmdSetShaders
{
ClientIDWrapper(GpuProgram) programs[kShaderTypeCount];
ClientIDWrapper(const GpuProgramParameters) params[kShaderTypeCount];
int paramsBufferSize[kShaderTypeCount];
};
struct GfxCmdCreateShaderParameters
{
ShaderLab::SubProgram* program;
FogMode fogMode;
};
struct GfxCmdBeginStaticBatching
{
ChannelAssigns channels;
GfxPrimitiveType topology;
};
struct GfxCmdStaticBatchMesh
{
UInt32 firstVertex;
UInt32 vertexCount;
IndexBufferData indices;
UInt32 firstIndexByte;
UInt32 indexCount;
};
struct GfxCmdEndStaticBatching
{
ClientDeviceVBO* vbo;
Matrix4x4f matrix;
TransformType transformType;
int sourceChannels;
};
struct GfxCmdBeginDynamicBatching
{
ChannelAssigns shaderChannels;
UInt32 channelsInVBO;
size_t maxVertices;
size_t maxIndices;
GfxPrimitiveType topology;
};
struct GfxCmdDynamicBatchMesh
{
Matrix4x4f matrix;
VertexBufferData vertices;
UInt32 firstVertex;
UInt32 vertexCount;
IndexBufferData indices;
UInt32 firstIndexByte;
UInt32 indexCount;
};
#if ENABLE_SPRITES
struct GfxCmdDynamicBatchSprite
{
Matrix4x4f matrix;
const SpriteRenderData *sprite;
ColorRGBA32 color;
};
#endif
struct GfxCmdEndDynamicBatching
{
TransformType transformType;
};
struct GfxCmdAddBatchingStats
{
int batchedTris;
int batchedVerts;
int batchedCalls;
};
struct GfxCmdCreateRenderColorSurface
{
TextureID textureID;
int width;
int height;
int samples;
int depth;
TextureDimension dim;
RenderTextureFormat format;
UInt32 createFlags;
};
struct GfxCmdCreateRenderDepthSurface
{
TextureID textureID;
int width;
int height;
int samples;
TextureDimension dim;
DepthBufferFormat depthFormat;
UInt32 createFlags;
};
struct GfxCmdSetRenderTarget
{
ClientIDWrapperHandle(RenderSurfaceHandle) colorHandles[kMaxSupportedRenderTargets];
ClientIDWrapperHandle(RenderSurfaceHandle) depthHandle;
int colorCount;
int mipLevel;
CubemapFace face;
};
struct GfxCmdResolveDepthIntoTexture
{
ClientIDWrapperHandle(RenderSurfaceHandle) colorHandle;
ClientIDWrapperHandle(RenderSurfaceHandle) depthHandle;
};
struct GfxCmdSetSurfaceFlags
{
ClientIDWrapperHandle(RenderSurfaceHandle) surf;
UInt32 flags;
UInt32 keepFlags;
};
struct GfxCmdUploadTexture2D
{
TextureID texture;
TextureDimension dimension;
int srcSize;
int width;
int height;
TextureFormat format;
int mipCount;
UInt32 uploadFlags;
int skipMipLevels;
TextureUsageMode usageMode;
TextureColorSpace colorSpace;
};
struct GfxCmdUploadTextureSubData2D
{
TextureID texture;
int srcSize;
int mipLevel;
int x;
int y;
int width;
int height;
TextureFormat format;
TextureColorSpace colorSpace;
};
struct GfxCmdUploadTextureCube
{
TextureID texture;
int srcSize;
int faceDataSize;
int size;
TextureFormat format;
int mipCount;
UInt32 uploadFlags;
TextureColorSpace colorSpace;
};
struct GfxCmdUploadTexture3D
{
TextureID texture;
int srcSize;
int width;
int height;
int depth;
TextureFormat format;
int mipCount;
UInt32 uploadFlags;
};
struct GfxCmdDrawUserPrimitives
{
GfxPrimitiveType type;
int vertexCount;
UInt32 vertexChannels;
int stride;
};
struct GfxCmdVBODraw
{
#if ENABLE_GFXDEVICE_REMOTE_PROCESS
ClientDeviceVBO vbo;
#else
ClientDeviceVBO* vbo;
#endif
ChannelAssigns channels;
UInt32 firstIndexByte;
UInt32 indexCount;
GfxPrimitiveType topology;
UInt32 firstVertex;
UInt32 vertexCount;
};
struct GfxCmdVBODrawCustomIndexed
{
#if ENABLE_GFXDEVICE_REMOTE_PROCESS
ClientDeviceVBO vbo;
#else
ClientDeviceVBO* vbo;
#endif
ChannelAssigns channels;
UInt32 indexCount;
GfxPrimitiveType topology;
UInt32 vertexRangeBegin;
UInt32 vertexRangeEnd;
UInt32 drawVertexCount;
};
struct GfxCmdVBODrawStripWireframe
{
#if ENABLE_GFXDEVICE_REMOTE_PROCESS
ClientDeviceVBO vbo;
#else
ClientDeviceVBO* vbo;
#endif
ChannelAssigns channels;
UInt32 indexCount;
UInt32 triCount;
UInt32 vertexCount;
};
struct GfxCmdVBOMapVertexStream
{
#if ENABLE_GFXDEVICE_REMOTE_PROCESS
ClientDeviceVBO vbo;
#else
ClientDeviceVBO* vbo;
#endif
unsigned stream;
UInt32 size;
};
struct GfxCmdVBOSetVertexStreamMode
{
#if ENABLE_GFXDEVICE_REMOTE_PROCESS
ClientDeviceVBO vbo;
#else
ClientDeviceVBO* vbo;
#endif
unsigned stream;
int mode;
};
struct GfxCmdVBOSetSetIndicesDynamic
{
#if ENABLE_GFXDEVICE_REMOTE_PROCESS
ClientDeviceVBO vbo;
#else
ClientDeviceVBO* vbo;
#endif
int dynamic;
};
struct GfxCmdVBOAddExtraUvChannels
{
#if ENABLE_GFXDEVICE_REMOTE_PROCESS
ClientDeviceVBO vbo;
#else
ClientDeviceVBO* vbo;
#endif
UInt32 size;
int extraUvCount;
};
struct GfxCmdVBOCopyExtraUvChannels
{
#if ENABLE_GFXDEVICE_REMOTE_PROCESS
ClientDeviceVBO dest;
ClientDeviceVBO source;
#else
ClientDeviceVBO* dest;
ClientDeviceVBO* source;
#endif
};
struct GfxCmdVector3
{
float x;
float y;
float z;
};
struct GfxCmdVector4
{
float x;
float y;
float z;
float w;
};
struct GfxCmdImmediateTexCoord
{
int unit;
float x;
float y;
float z;
};
struct GfxCmdCaptureScreenshot
{
int left;
int bottom;
int width;
int height;
UInt8* rgba32;
bool* success;
};
struct GfxCmdReadbackImage
{
ImageReference& image;
int left;
int bottom;
int width;
int height;
int destX;
int destY;
bool* success;
};
struct GfxCmdGrabIntoRenderTexture
{
ClientIDWrapperHandle(RenderSurfaceHandle) rs;
ClientIDWrapperHandle(RenderSurfaceHandle) rd;
int x;
int y;
int width;
int height;
};
struct GfxCmdDynVboChunk
{
UInt32 channelMask;
UInt32 vertexStride;
UInt32 actualVertices;
UInt32 actualIndices;
UInt32 renderMode;
};
#if UNITY_WIN && UNITY_EDITOR
struct GfxCmdWindowReshape
{
int width;
int height;
DepthBufferFormat depthFormat;
int antiAlias;
};
struct GfxCmdCreateWindow
{
HWND window;
int width;
int height;
DepthBufferFormat depthFormat;
int antiAlias;
};
#endif
|