This repository has been archived by the owner on Oct 4, 2022. It is now read-only.
/
IRenderer.h
2627 lines (2150 loc) · 92.3 KB
/
IRenderer.h
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
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#pragma once
#include "Cry_Geo.h"
#include "Cry_Camera.h"
#include <CryEngineAPI.h>
#include <IFlares.h> // <> required for Interfuscator
#include <AzCore/Casting/numeric_cast.h>
#include "IResourceCompilerHelper.h" // for IResourceCompilerHelper::ERcCallResult
// forward declarations
struct SRenderingPassInfo;
struct IFoliage;
struct SRTStack;
// Callback used for DXTCompress
typedef void (* MIPDXTcallback)(const void* buffer, size_t count, void* userData);
typedef void (* GpuCallbackFunc)(DWORD context);
// Callback for shadercache miss
typedef void (* ShaderCacheMissCallback)(const char* acShaderRequest);
struct ICaptureFrameListener
{
virtual ~ICaptureFrameListener (){}
virtual bool OnNeedFrameData(unsigned char*& pConvertedTextureBuf) = 0;
virtual void OnFrameCaptured(void) = 0;
virtual int OnGetFrameWidth(void) = 0;
virtual int OnGetFrameHeight(void) = 0;
virtual int OnCaptureFrameBegin(int* pTexHandle) = 0;
enum ECaptureFrameFlags
{
eCFF_NoCaptureThisFrame = (0 << 1),
eCFF_CaptureThisFrame = (1 << 1),
};
};
// Forward declarations.
//////////////////////////////////////////////////////////////////////
typedef void* WIN_HWND;
typedef void* WIN_HINSTANCE;
typedef void* WIN_HDC;
typedef void* WIN_HGLRC;
class CREMesh;
class CMesh;
//class CImage;
struct CStatObj;
class CVegetation;
struct ShadowMapFrustum;
struct IStatObj;
class CObjManager;
struct SPrimitiveGroup;
struct ICharacterInstance;
class CRendElementBase;
class CRenderObject;
class CTexMan;
//class ColorF;
class CShadowVolEdge;
class CCamera;
class CDLight;
struct SDeferredLightVolume;
struct ILog;
struct IConsole;
struct ICVar;
struct ITimer;
struct ISystem;
class IGPUParticleEngine;
class ICrySizer;
struct IRenderAuxGeom;
struct SREPointSpriteCreateParams;
struct SPointSpriteVertex;
struct RenderLMData;
struct SShaderParam;
struct SSkyLightRenderParams;
struct SParticleRenderInfo;
struct SParticleAddJobCompare;
struct IColorGradingController;
class IStereoRenderer;
struct IFFont;
struct IFFont_RenderProxy;
struct STextDrawContext;
struct IRenderMesh;
class IOpticsManager;
struct ShadowFrustumMGPUCache;
struct IAsyncTextureCompileListener;
struct IClipVolume;
struct SClipVolumeBlendInfo;
class IImageFile;
class CRenderView;
struct SDynTexture2;
class CTexture;
//////////////////////////////////////////////////////////////////////
typedef unsigned char bvec4[4];
typedef float vec4_t[4];
typedef unsigned char byte;
typedef float vec2_t[2];
//DOC-IGNORE-BEGIN
#include "Cry_Color.h"
#include "Tarray.h"
#include <IFont.h>
//DOC-IGNORE-END
#define MAX_NUM_VIEWPORTS 7
// Query types for CryInd editor (used in EF_Query() function).
enum ERenderQueryTypes
{
EFQ_DeleteMemoryArrayPtr = 1,
EFQ_DeleteMemoryPtr,
EFQ_GetShaderCombinations,
EFQ_SetShaderCombinations,
EFQ_CloseShaderCombinations,
EFQ_MainThreadList,
EFQ_RenderThreadList,
EFQ_RenderMultithreaded,
EFQ_RecurseLevel,
EFQ_IncrementFrameID,
EFQ_DeviceLost,
EFQ_LightSource,
EFQ_Alloc_APITextures,
EFQ_Alloc_APIMesh,
// Memory allocated by meshes in system memory.
EFQ_Alloc_Mesh_SysMem,
EFQ_Mesh_Count,
EFQ_HDRModeEnabled,
EFQ_ParticlesTessellation,
EFQ_WaterTessellation,
EFQ_MeshTessellation,
EFQ_GetShadowPoolFrustumsNum,
EFQ_GetShadowPoolAllocThisFrameNum,
EFQ_GetShadowMaskChannelsNum,
EFQ_GetTiledShadingSkippedLightsNum,
// Description:
// Query will return all textures in the renderer,
// pass pointer to an SRendererQueryGetAllTexturesParam instance
EFQ_GetAllTextures,
// Description:
// Release resources allocated by GetAllTextures query
// pass pointer to an SRendererQueryGetAllTexturesParam instance, populated by EFQ_GetAllTextures
EFQ_GetAllTexturesRelease,
// Description:
// Query will return all IRenderMesh objects in the renderer,
// Pass an array pointer to be allocated and filled with the IRendermesh pointers. The calling function is responsible for freeing this memory.
// This was originally a two pass process, but proved to be non-thread-safe, leading to buffer overruns and underruns.
EFQ_GetAllMeshes,
// Summary:
// Multigpu (crossfire/sli) is enabled.
EFQ_MultiGPUEnabled,
EFQ_SetDrawNearFov,
EFQ_GetDrawNearFov,
EFQ_TextureStreamingEnabled,
EFQ_MSAAEnabled,
EFQ_AAMode,
EFQ_Fullscreen,
EFQ_GetTexStreamingInfo,
EFQ_GetMeshPoolInfo,
// Description:
// True when shading is done in linear space, de-gamma on texture lookup, gamma on frame buffer writing (sRGB), false otherwise.
EFQ_sLinearSpaceShadingEnabled,
// The percentages of overscan borders for left/right and top/bottom to adjust the title safe area.
EFQ_OverscanBorders,
// Get num active post effects
EFQ_NumActivePostEffects,
// Get size of textures memory pool
EFQ_TexturesPoolSize,
EFQ_RenderTargetPoolSize,
EFQ_GetShaderCacheInfo,
EFQ_GetFogCullDistance,
EFQ_GetMaxRenderObjectsNum,
EFQ_IsRenderLoadingThreadActive,
EFQ_GetParticleVertexBufferSize,
EFQ_GetParticleIndexBufferSize,
EFQ_GetMaxParticleContainer,
EFQ_GetSkinningDataPoolSize,
EFQ_GetViewportDownscaleFactor,
EFQ_ReverseDepthEnabled,
EFQ_GetLastD3DDebugMessage
};
struct ID3DDebugMessage
{
public:
virtual void Release() = 0;
virtual const char* GetMessage() const = 0;
protected:
ID3DDebugMessage() {}
virtual ~ID3DDebugMessage() {}
};
enum EScreenAspectRatio
{
eAspect_Unknown,
eAspect_4_3,
eAspect_16_9,
eAspect_16_10,
};
class SBoundingVolume
{
public:
SBoundingVolume()
: m_vCenter(0, 0, 0)
, m_fRadius(0) {}
~SBoundingVolume() {}
void SetCenter(const Vec3& center) { m_vCenter = center; }
void SetRadius(float radius) { m_fRadius = radius; }
const Vec3& GetCenter() const { return m_vCenter; }
float GetRadius() const { return m_fRadius; }
protected:
Vec3 m_vCenter;
float m_fRadius;
};
class SMinMaxBox
: public SBoundingVolume
{
public:
SMinMaxBox()
{
Clear();
}
SMinMaxBox(const Vec3& min, const Vec3& max) :
m_min(min),
m_max(max)
{
UpdateSphere();
}
// Summary:
// Destructor
virtual ~SMinMaxBox() {}
void AddPoint(const Vec3& pt)
{
if (pt.x > m_max.x)
{
m_max.x = pt.x;
}
if (pt.x < m_min.x)
{
m_min.x = pt.x;
}
if (pt.y > m_max.y)
{
m_max.y = pt.y;
}
if (pt.y < m_min.y)
{
m_min.y = pt.y;
}
if (pt.z > m_max.z)
{
m_max.z = pt.z;
}
if (pt.z < m_min.z)
{
m_min.z = pt.z;
}
// Summary:
// Updates the center and radius.
UpdateSphere();
}
void AddPoint(float x, float y, float z)
{
AddPoint(Vec3(x, y, z));
}
void Union(const SMinMaxBox& box) { AddPoint(box.GetMin()); AddPoint(box.GetMax()); }
const Vec3& GetMin() const { return m_min; }
const Vec3& GetMax() const { return m_max; }
void SetMin(const Vec3& min) { m_min = min; UpdateSphere(); }
void SetMax(const Vec3& max) { m_max = max; UpdateSphere(); }
float GetWidthInX() const { return m_max.x - m_min.x; }
float GetWidthInY() const { return m_max.y - m_min.y; }
float GetWidthInZ() const { return m_max.z - m_min.z; }
bool PointInBBox(const Vec3& pt) const;
bool ViewFrustumCull(const CameraViewParameters& viewParameters, const Matrix44& mat);
void Transform(const Matrix34& mat)
{
Vec3 verts[8];
CalcVerts(verts);
Clear();
for (int i = 0; i < 8; i++)
{
AddPoint(mat.TransformPoint(verts[i]));
}
}
// Summary:
// Resets the bounding box.
void Clear()
{
m_min = Vec3(999999.0f, 999999.0f, 999999.0f);
m_max = Vec3(-999999.0f, -999999.0f, -999999.0f);
}
protected:
void UpdateSphere()
{
m_vCenter = m_min;
m_vCenter += m_max;
m_vCenter *= 0.5f;
Vec3 rad = m_max;
rad -= m_vCenter;
m_fRadius = rad.len();
}
void CalcVerts(Vec3 pVerts[8]) const
{
pVerts[0].Set(m_max.x, m_max.y, m_max.z);
pVerts[4].Set(m_max.x, m_max.y, m_min.z);
pVerts[1].Set(m_min.x, m_max.y, m_max.z);
pVerts[5].Set(m_min.x, m_max.y, m_min.z);
pVerts[2].Set(m_min.x, m_min.y, m_max.z);
pVerts[6].Set(m_min.x, m_min.y, m_min.z);
pVerts[3].Set(m_max.x, m_min.y, m_max.z);
pVerts[7].Set(m_max.x, m_min.y, m_min.z);
}
private:
Vec3 m_min; // Original object space BV.
Vec3 m_max;
};
//////////////////////////////////////////////////////////////////////
// All possible primitive types
enum PublicRenderPrimitiveType
{
prtTriangleList,
prtTriangleStrip,
prtLineList,
prtLineStrip
};
//////////////////////////////////////////////////////////////////////
#define R_CULL_DISABLE 0
#define R_CULL_NONE 0
#define R_CULL_FRONT 1
#define R_CULL_BACK 2
//////////////////////////////////////////////////////////////////////
#define R_DEFAULT_LODBIAS 0
//////////////////////////////////////////////////////////////////////
#define R_SOLID_MODE 0
#define R_WIREFRAME_MODE 1
#define R_DX9_RENDERER 2
#define R_DX11_RENDERER 3
#define R_NULL_RENDERER 4
#define R_CUBAGL_RENDERER 5
#define R_GL_RENDERER 6
#define R_METAL_RENDERER 7
#define R_DX12_RENDERER 8
//////////////////////////////////////////////////////////////////////
// Render features
#define RFT_FREE_0x1 0x1
#define RFT_ALLOW_RECTTEX 0x2
#define RFT_OCCLUSIONQUERY 0x4
#define RFT_FREE_0x8 0x8
#define RFT_HWGAMMA 0x10
#define RFT_FREE_0x20 0x20
#define RFT_COMPRESSTEXTURE 0x40
#define RFT_FREE_0x80 0x80
#define RFT_ALLOWANISOTROPIC 0x100 // Allows anisotropic texture filtering.
#define RFT_SUPPORTZBIAS 0x200
#define RFT_FREE_0x400 0x400
#define RFT_FREE_0x800 0x800
#define RFT_FREE_0x1000 0x1000
#define RFT_FREE_0x2000 0x2000
#define RFT_OCCLUSIONTEST 0x8000 // Support hardware occlusion test.
#define RFT_HW_ARM_MALI 0x04000 // Unclassified ARM (MALI) hardware.
#define RFT_HW_INTEL 0x10000 // Unclassified intel hardware.
#define RFT_HW_QUALCOMM 0x10000 // Unclassified Qualcomm hardware
#define RFT_HW_ATI 0x20000 // Unclassified ATI hardware.
#define RFT_HW_NVIDIA 0x40000 // Unclassified NVidia hardware.
#define RFT_HW_MASK 0x74000 // Graphics chip mask.
#define RFT_HW_HDR 0x80000 // Hardware supports high dynamic range rendering.
#define RFT_HW_SM20 0x100000 // Shader model 2.0
#define RFT_HW_SM2X 0x200000 // Shader model 2.X
#define RFT_HW_SM30 0x400000 // Shader model 3.0
#define RFT_HW_SM40 0x800000 // Shader model 4.0
#define RFT_HW_SM50 0x1000000 // Shader model 5.0
#define RFT_FREE_0x2000000 0x2000000
#define RFT_FREE_0x4000000 0x4000000
#define RFT_FREE_0x8000000 0x8000000
#define RFT_HW_VERTEX_STRUCTUREDBUF 0x10000000 // Supports Structured Buffers in the Vertex Shader.
#define RFT_RGBA 0x20000000 // RGBA order (otherwise BGRA).
#define RFT_COMPUTE_SHADERS 0x40000000 // Compute Shaders support
#define RFT_HW_VERTEXTEXTURES 0x80000000 // Vertex texture fetching supported.
//====================================================================
// PrecacheResources flags
#define FPR_NEEDLIGHT 1
#define FPR_2D 2
#define FPR_HIGHPRIORITY 4
#define FPR_SYNCRONOUS 8
#define FPR_STARTLOADING 16
#define FPR_SINGLE_FRAME_PRIORITY_UPDATE 32
//=====================================================================
// SetRenderTarget flags
#define SRF_SCREENTARGET 1
#define SRF_USE_ORIG_DEPTHBUF 2
#define SRF_USE_ORIG_DEPTHBUF_MSAA 4
//====================================================================
// Draw shaders flags (EF_EndEf3d)
#define SHDF_ALLOWHDR BIT(0)
#define SHDF_CUBEMAPGEN BIT(1)
#define SHDF_ZPASS BIT(2)
#define SHDF_ZPASS_ONLY BIT(3)
#define SHDF_DO_NOT_CLEAR_Z_BUFFER BIT(4)
#define SHDF_ALLOWPOSTPROCESS BIT(5)
#define SHDF_ALLOW_AO BIT(8)
#define SHDF_ALLOW_WATER BIT(9)
#define SHDF_NOASYNC BIT(10)
#define SHDF_NO_DRAWNEAR BIT(11)
#define SHDF_STREAM_SYNC BIT(13)
#define SHDF_NO_SHADOWGEN BIT(15)
//////////////////////////////////////////////////////////////////////
// Virtual screen size
const float VIRTUAL_SCREEN_WIDTH = 800.0f;
const float VIRTUAL_SCREEN_HEIGHT = 600.0f;
//////////////////////////////////////////////////////////////////////
// Object states
#define OS_ALPHA_BLEND 0x1
#define OS_ADD_BLEND 0x2
#define OS_MULTIPLY_BLEND 0x4
#define OS_TRANSPARENT (OS_ALPHA_BLEND | OS_ADD_BLEND | OS_MULTIPLY_BLEND)
#define OS_NODEPTH_TEST 0x8
#define OS_NODEPTH_WRITE 0x10
#define OS_ANIM_BLEND 0x20
#define OS_ENVIRONMENT_CUBEMAP 0x40
// Render State flags
#define GS_BLSRC_MASK 0xf
#define GS_BLSRC_ZERO 0x1
#define GS_BLSRC_ONE 0x2
#define GS_BLSRC_DSTCOL 0x3
#define GS_BLSRC_ONEMINUSDSTCOL 0x4
#define GS_BLSRC_SRCALPHA 0x5
#define GS_BLSRC_ONEMINUSSRCALPHA 0x6
#define GS_BLSRC_DSTALPHA 0x7
#define GS_BLSRC_ONEMINUSDSTALPHA 0x8
#define GS_BLSRC_ALPHASATURATE 0x9
#define GS_BLSRC_SRCALPHA_A_ZERO 0xa // separate alpha blend state
#define GS_BLSRC_SRC1ALPHA 0xb // dual source blending
#define GS_BLDST_MASK 0xf0
#define GS_BLDST_ZERO 0x10
#define GS_BLDST_ONE 0x20
#define GS_BLDST_SRCCOL 0x30
#define GS_BLDST_ONEMINUSSRCCOL 0x40
#define GS_BLDST_SRCALPHA 0x50
#define GS_BLDST_ONEMINUSSRCALPHA 0x60
#define GS_BLDST_DSTALPHA 0x70
#define GS_BLDST_ONEMINUSDSTALPHA 0x80
#define GS_BLDST_ONE_A_ZERO 0x90 // separate alpha blend state
#define GS_BLDST_ONEMINUSSRC1ALPHA 0xa0 // dual source blending
#define GS_DEPTHWRITE 0x00000100
#define GS_COLMASK_RT1 0x00000200
#define GS_COLMASK_RT2 0x00000400
#define GS_COLMASK_RT3 0x00000800
#define GS_NOCOLMASK_R 0x00001000
#define GS_NOCOLMASK_G 0x00002000
#define GS_NOCOLMASK_B 0x00004000
#define GS_NOCOLMASK_A 0x00008000
#define GS_COLMASK_RGB (GS_NOCOLMASK_A)
#define GS_COLMASK_A (GS_NOCOLMASK_R | GS_NOCOLMASK_G | GS_NOCOLMASK_B)
#define GS_COLMASK_NONE (GS_NOCOLMASK_R | GS_NOCOLMASK_G | GS_NOCOLMASK_B | GS_NOCOLMASK_A)
#define GS_COLMASK_MASK GS_COLMASK_NONE
#define GS_COLMASK_SHIFT 12
#define GS_WIREFRAME 0x00010000
#define GS_NODEPTHTEST 0x00040000
#define GS_BLEND_MASK 0x0f0000ff
#define GS_DEPTHFUNC_LEQUAL 0x00000000
#define GS_DEPTHFUNC_EQUAL 0x00100000
#define GS_DEPTHFUNC_GREAT 0x00200000
#define GS_DEPTHFUNC_LESS 0x00300000
#define GS_DEPTHFUNC_GEQUAL 0x00400000
#define GS_DEPTHFUNC_NOTEQUAL 0x00500000
#define GS_DEPTHFUNC_HIZEQUAL 0x00600000 // keep hi-z test, always pass fine depth. Useful for debug display
#define GS_DEPTHFUNC_ALWAYS 0x00700000
#define GS_DEPTHFUNC_MASK 0x00700000
#define GS_STENCIL 0x00800000
#define GS_BLEND_OP_MASK 0x03000000
#define GS_BLOP_MAX 0x01000000
#define GS_BLOP_MIN 0x02000000
// Separate alpha blend mode
#define GS_BLALPHA_MASK 0x0c000000
#define GS_BLALPHA_MIN 0x04000000
#define GS_BLALPHA_MAX 0x08000000
#define GS_ALPHATEST_MASK 0xf0000000
#define GS_ALPHATEST_GREATER 0x10000000
#define GS_ALPHATEST_LESS 0x20000000
#define GS_ALPHATEST_GEQUAL 0x40000000
#define GS_ALPHATEST_LEQUAL 0x80000000
#define FORMAT_8_BIT 8
#define FORMAT_24_BIT 24
#define FORMAT_32_BIT 32
//==================================================================
// StencilStates
//Note: If these are altered, g_StencilFuncLookup and g_StencilOpLookup arrays
// need to be updated in turn
#define FSS_STENCFUNC_ALWAYS 0x0
#define FSS_STENCFUNC_NEVER 0x1
#define FSS_STENCFUNC_LESS 0x2
#define FSS_STENCFUNC_LEQUAL 0x3
#define FSS_STENCFUNC_GREATER 0x4
#define FSS_STENCFUNC_GEQUAL 0x5
#define FSS_STENCFUNC_EQUAL 0x6
#define FSS_STENCFUNC_NOTEQUAL 0x7
#define FSS_STENCFUNC_MASK 0x7
#define FSS_STENCIL_TWOSIDED 0x8
#define FSS_CCW_SHIFT 16
#define FSS_STENCOP_KEEP 0x0
#define FSS_STENCOP_REPLACE 0x1
#define FSS_STENCOP_INCR 0x2
#define FSS_STENCOP_DECR 0x3
#define FSS_STENCOP_ZERO 0x4
#define FSS_STENCOP_INCR_WRAP 0x5
#define FSS_STENCOP_DECR_WRAP 0x6
#define FSS_STENCOP_INVERT 0x7
#define FSS_STENCFAIL_SHIFT 4
#define FSS_STENCFAIL_MASK (0x7 << FSS_STENCFAIL_SHIFT)
#define FSS_STENCZFAIL_SHIFT 8
#define FSS_STENCZFAIL_MASK (0x7 << FSS_STENCZFAIL_SHIFT)
#define FSS_STENCPASS_SHIFT 12
#define FSS_STENCPASS_MASK (0x7 << FSS_STENCPASS_SHIFT)
#define STENC_FUNC(op) (op)
#define STENC_CCW_FUNC(op) (op << FSS_CCW_SHIFT)
#define STENCOP_FAIL(op) (op << FSS_STENCFAIL_SHIFT)
#define STENCOP_ZFAIL(op) (op << FSS_STENCZFAIL_SHIFT)
#define STENCOP_PASS(op) (op << FSS_STENCPASS_SHIFT)
#define STENCOP_CCW_FAIL(op) (op << (FSS_STENCFAIL_SHIFT + FSS_CCW_SHIFT))
#define STENCOP_CCW_ZFAIL(op) (op << (FSS_STENCZFAIL_SHIFT + FSS_CCW_SHIFT))
#define STENCOP_CCW_PASS(op) (op << (FSS_STENCPASS_SHIFT + FSS_CCW_SHIFT))
//Stencil masks
#define BIT_STENCIL_RESERVED 0x80
#define BIT_STENCIL_INSIDE_CLIPVOLUME 0x40
#define STENC_VALID_BITS_NUM 7
#define STENC_MAX_REF ((1 << STENC_VALID_BITS_NUM) - 1)
// Read FrameBuffer type
enum ERB_Type
{
eRB_BackBuffer,
eRB_FrontBuffer,
eRB_ShadowBuffer
};
enum EVertexCostTypes
{
EVCT_STATIC = 0,
EVCT_VEGETATION,
EVCT_SKINNED,
EVCT_NUM
};
//////////////////////////////////////////////////////////////////////
struct SDispFormat
{
int m_Width;
int m_Height;
int m_BPP;
};
struct SAAFormat
{
char szDescr[64];
int nSamples;
int nQuality;
};
// Summary:
// Info about Terrain sector texturing.
struct SSectorTextureSet
{
SSectorTextureSet(unsigned short nT0)
{
nTex0 = nT0;
fTexOffsetX = fTexOffsetY = 0;
fTexScale = 1.f;
}
unsigned short nTex0;
float fTexOffsetX, fTexOffsetY, fTexScale;
};
struct IRenderNode;
struct SShaderItem;
struct IParticleVertexCreator;
struct SAddParticlesToSceneJob
{
void GetMemoryUsage(ICrySizer* pSizer) const {}
SShaderItem* pShaderItem;
CRenderObject* pRenderObject;
IParticleVertexCreator* pPVC;
int16 nCustomTexId;
}
_ALIGN(16)
;
#ifdef SUPPORT_HW_MOUSE_CURSOR
class IHWMouseCursor
{
public:
virtual ~IHWMouseCursor() {}
virtual void SetPosition(int x, int y) = 0;
virtual void Show() = 0;
virtual void Hide() = 0;
};
#endif
//////////////////////////////////////////////////////////////////////
//DOC-IGNORE-BEGIN
#include <IShader.h> // <> required for Interfuscator
//DOC-IGNORE-END
#include <IRenderMesh.h>
#include "IMeshBaking.h"
// Flags passed in function FreeResources.
#define FRR_SHADERS 1
#define FRR_SHADERTEXTURES 2
#define FRR_TEXTURES 4
#define FRR_SYSTEM 8
#define FRR_RESTORE 0x10
#define FRR_REINITHW 0x20
#define FRR_DELETED_MESHES 0x40
#define FRR_FLUSH_TEXTURESTREAMING 0x80
#define FRR_OBJECTS 0x100
#define FRR_RENDERELEMENTS 0x200
#define FRR_RP_BUFFERS 0x400
#define FRR_SYSTEM_RESOURCES 0x800
#define FRR_POST_EFFECTS 0x1000
#define FRR_ALL -1
// Refresh render resources flags.
// Flags passed in function RefreshResources.
#define FRO_SHADERS 1
#define FRO_SHADERTEXTURES 2
#define FRO_TEXTURES 4
#define FRO_GEOMETRY 8
#define FRO_FORCERELOAD 0x10
//=============================================================================
// Shaders render target stuff.
#define FRT_CLEAR_DEPTH 0x1
#define FRT_CLEAR_STENCIL 0x2
#define FRT_CLEAR_COLOR 0x4
#define FRT_CLEAR (FRT_CLEAR_COLOR | FRT_CLEAR_DEPTH | FRT_CLEAR_STENCIL)
#define FRT_CLEAR_FOGCOLOR 0x8
#define FRT_CLEAR_IMMEDIATE 0x10
#define FRT_CLEAR_COLORMASK 0x20
#define FRT_CLEAR_RESET_VIEWPORT 0x40
#define FRT_CAMERA_REFLECTED_WATERPLANE 0x40
#define FRT_CAMERA_REFLECTED_PLANE 0x80
#define FRT_CAMERA_CURRENT 0x100
#define FRT_USE_FRONTCLIPPLANE 0x200
#define FRT_USE_BACKCLIPPLANE 0x400
#define FRT_GENERATE_MIPS 0x800
#define FRT_RENDTYPE_CUROBJECT 0x1000
#define FRT_RENDTYPE_CURSCENE 0x2000
#define FRT_RENDTYPE_RECURSIVECURSCENE 0x4000
#define FRT_RENDTYPE_COPYSCENE 0x8000
// Summary:
// Flags used in DrawText function.
// See also:
// SDrawTextInfo
// Remarks:
// Text must be fixed pixel size.
enum EDrawTextFlags
{
eDrawText_Left = 0, // default left alignment if neither Center or Right are specified
eDrawText_Center = BIT(0), // centered alignment, otherwise right or left
eDrawText_Right = BIT(1), // right alignment, otherwise center or left
eDrawText_CenterV = BIT(2), // center vertically, otherwise top
eDrawText_Bottom = BIT(3), // bottom alignment
eDrawText_2D = BIT(4), // 3 component vector is used for xy screen position, otherwise it's 3d world space position
eDrawText_FixedSize = BIT(5), // font size is defined in the actual pixel resolution, otherwise it's in the virtual 800x600
eDrawText_800x600 = BIT(6), // position are specified in the virtual 800x600 resolution, otherwise coordinates are in pixels
eDrawText_Monospace = BIT(7), // non proportional font rendering (Font width is same for all characters)
eDrawText_Framed = BIT(8), // draw a transparent, rectangular frame behind the text to ease readability independent from the background
eDrawText_DepthTest = BIT(9), // text should be occluded by world geometry using the depth buffer
eDrawText_IgnoreOverscan = BIT(10), // ignore the overscan borders, text should be drawn at the location specified
eDrawText_UseTransform = BIT(11), // use a transform for the text
};
// Debug stats/views for Partial resolves
// if REFRACTION_PARTIAL_RESOLVE_DEBUG_VIEWS is enabled, make sure REFRACTION_PARTIAL_RESOLVE_STATS is too
#if defined(PERFORMANCE_BUILD)
#define REFRACTION_PARTIAL_RESOLVE_STATS 1
#define REFRACTION_PARTIAL_RESOLVE_DEBUG_VIEWS 0
#elif defined(_RELEASE) // note: _RELEASE is defined in PERFORMANCE_BUILD, so this check must come second
#define REFRACTION_PARTIAL_RESOLVE_STATS 0
#define REFRACTION_PARTIAL_RESOLVE_DEBUG_VIEWS 0
#else
#define REFRACTION_PARTIAL_RESOLVE_STATS 1
#define REFRACTION_PARTIAL_RESOLVE_DEBUG_VIEWS 1
#endif
#if REFRACTION_PARTIAL_RESOLVE_DEBUG_VIEWS
enum ERefractionPartialResolvesDebugViews
{
eRPR_DEBUG_VIEW_2D_AREA = 1,
eRPR_DEBUG_VIEW_3D_BOUNDS,
eRPR_DEBUG_VIEW_2D_AREA_OVERLAY
};
#endif
//////////////////////////////////////////////////////////////////////////
// Description:
// This structure used in DrawText method of renderer.
// It provide all necessary information of how to render text on screen.
// See also:
// IRenderer::Draw2dText
struct SDrawTextInfo
{
// Summary:
// One of EDrawTextFlags flags.
// See also:
// EDrawTextFlags
int flags;
// Summary:
// Text color, (r,g,b,a) all members must be specified.
float color[4];
float xscale;
float yscale;
SDrawTextInfo()
{
flags = 0;
color[0] = color[1] = color[2] = color[3] = 1;
xscale = 1.0f;
yscale = 1.0f;
}
};
#define UIDRAW_TEXTSIZEFACTOR (12.0f)
#define MIN_RESOLUTION_SCALE (0.25f)
#define MAX_RESOLUTION_SCALE (4.0f)
#if defined(AZ_RESTRICTED_PLATFORM)
#include AZ_RESTRICTED_FILE(IRenderer_h, AZ_RESTRICTED_PLATFORM)
#else
//SLI/CROSSFIRE GPU maximum count
#define MAX_GPU_NUM 4
#endif
#define MAX_FRAME_ID_STEP_PER_FRAME 20
const int MAX_GSM_LODS_NUM = 16;
const f32 DRAW_NEAREST_MIN = 0.03f;
const f32 DRAW_NEAREST_MAX = 40.0f;
//===================================================================
//////////////////////////////////////////////////////////////////////
struct IRenderDebugListener
{
virtual ~IRenderDebugListener() {}
virtual void OnDebugDraw() = 0;
};
//////////////////////////////////////////////////////////////////////
struct ILoadtimeCallback
{
virtual void LoadtimeUpdate(float fDeltaTime) = 0;
virtual void LoadtimeRender() = 0;
virtual ~ILoadtimeCallback(){}
};
//////////////////////////////////////////////////////////////////////
struct ISyncMainWithRenderListener
{
virtual void SyncMainWithRender() = 0;
virtual ~ISyncMainWithRenderListener(){}
};
//////////////////////////////////////////////////////////////////////
enum ERenderType
{
eRT_Undefined,
eRT_Null,
eRT_DX11,
eRT_DX12,
eRT_XboxOne, // ACCEPTED_USE
eRT_PS4, // ACCEPTED_USE
eRT_OpenGL,
eRT_Metal,
};
//////////////////////////////////////////////////////////////////////
// Enum for types of deferred lights
enum eDeferredLightType
{
eDLT_DeferredLight = 0,
eDLT_NumShadowCastingLights = eDLT_DeferredLight + 1,
// these lights cannot cast shadows
eDLT_DeferredCubemap = eDLT_NumShadowCastingLights,
eDLT_DeferredAmbientLight,
eDLT_NumLightTypes,
};
const float RENDERER_LIGHT_UNIT_SCALE = 10000.0f; // Scale factor between photometric and internal light units
//////////////////////////////////////////////////////////////////////
struct SCustomRenderInitArgs
{
bool appStartedFromMediaCenter;
};
#if defined(ANDROID)
enum
{
CULL_SIZEX = 128
};
enum
{
CULL_SIZEY = 64
};
#else
enum
{
CULL_SIZEX = 256
};
enum
{
CULL_SIZEY = 128
};
#endif
//////////////////////////////////////////////////////////////////////
// Description:
// Z-buffer as occlusion buffer definitions: used, shared and initialized in engine and renderer.
struct SHWOccZBuffer
{
uint32* pHardwareZBuffer;
uint32* pZBufferVMem;
uint32 ZBufferSizeX;
uint32 ZBufferSizeY;
uint32 HardwareZBufferRSXOff;
uint32 ZBufferVMemRSXOff;
uint32 pad[2]; // Keep 32 byte aligned
SHWOccZBuffer()
: pHardwareZBuffer(NULL)
, pZBufferVMem(NULL)
, ZBufferSizeX(CULL_SIZEX)
, ZBufferSizeY(CULL_SIZEY)
, ZBufferVMemRSXOff(0)
, HardwareZBufferRSXOff(0){}
};
class ITextureStreamListener
{
public:
virtual void OnCreatedStreamedTexture(void* pHandle, const char* name, int nMips, int nMinMipAvailable) = 0;
virtual void OnDestroyedStreamedTexture(void* pHandle) = 0;
virtual void OnTextureWantsMip(void* pHandle, int nMinMip) = 0;
virtual void OnTextureHasMip(void* pHandle, int nMinMip) = 0;
virtual void OnBegunUsingTextures(void** pHandles, size_t numHandles) = 0;
virtual void OnEndedUsingTextures(void** pHandle, size_t numHandles) = 0;
protected:
virtual ~ITextureStreamListener() {}
};
#if defined(CRY_ENABLE_RC_HELPER)
////////////////////////////////////////////////////////////////////////////
// Listener for asynchronous texture compilation.
// Connects the listener to the task-queue of pending compilation requests.
enum ERcExitCode;
struct IAsyncTextureCompileListener
{
public:
virtual void OnCompilationStarted(const char* source, const char* target, int nPending) = 0;
virtual void OnCompilationFinished(const char* source, const char* target, IResourceCompilerHelper::ERcCallResult nReturnCode) = 0;
virtual void OnCompilationQueueTriggered(int nPending) = 0;
virtual void OnCompilationQueueDepleted() = 0;
protected:
virtual ~IAsyncTextureCompileListener() {}
};
#endif
enum eDolbyVisionMode
{
eDVM_Disabled,
eDVM_RGBPQ,
eDVM_Vision,