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
|
#pragma once
#include "Runtime/Math/Matrix4x4.h"
#include "Runtime/Math/Vector3.h"
#include "Runtime/Math/Rect.h"
#include "Runtime/Camera/CullResults.h"
#include "GlobalLayeringData.h"
namespace Unity { class Material; }
class Camera;
class Shader;
class RenderTexture;
struct ShadowCullData;
struct RenderLoop;
struct RenderObjectData {
Unity::Material* material; // 4
SInt16 queueIndex; // 2
UInt16 subsetIndex; // 2
SInt16 subShaderIndex; // 2
UInt16 sourceMaterialIndex;// 2
UInt16 lightmapIndex; // 2
int staticBatchIndex; // 4
float distance; // 4
//@TODO: cold?
float distanceAlongView; // 4
VisibleNode* visibleNode; // 4
Shader* shader; // 4 shader to use
GlobalLayeringData
globalLayeringData; // 4
// 36 bytes
};
enum RenderPart { kPartOpaque, kPartAfterOpaque, kPartCount };
typedef dynamic_array<RenderObjectData> RenderObjectDataContainer;
struct RenderLoopContext
{
Camera* m_Camera;
const CullResults* m_CullResults;
const ShadowCullData* m_ShadowCullData;
Matrix4x4f m_CurCameraMatrix;
Rectf m_CameraViewport;
Vector3f m_CurCameraPos;
bool m_SortOrthographic;
bool m_DontRenderRenderables;
bool m_RenderingShaderReplace;
int m_RenderQueueStart;
int m_RenderQueueEnd;
RenderLoop* m_RenderLoop;
};
void AddRenderLoopTempBuffer (RenderLoop* loop, RenderTexture* rt);
void DoForwardVertexRenderLoop (RenderLoopContext& ctx, RenderObjectDataContainer& objects, bool opaque, ActiveLights& activeLights, bool linearLighting, bool clearFrameBuffer);
void DoForwardShaderRenderLoop (
RenderLoopContext& ctx,
RenderObjectDataContainer& objects,
bool opaque,
bool disableDynamicBatching,
RenderTexture* mainShadowMap,
ActiveLights& activeLights,
bool linearLighting,
bool clearFrameBuffer);
void DoPrePassRenderLoop (
RenderLoopContext& ctx,
RenderObjectDataContainer& objects,
RenderObjectDataContainer& outRemainingObjects,
RenderTexture*& outDepthRT,
RenderTexture*& outDepthNormalsRT,
RenderTexture*& outMainShadowMap,
ActiveLights& activeLights,
bool linearLighting,
bool* outDepthWasCopied);
// This is only usable by GfxDeviceGLES, because GfxDeviceGLES only supports ForwardVertexRenderLoop, you'll only see these functions there
// If IsInsideRenderLoop() == true, no state caching will be performed by GfxDeviceGLES
void StartRenderLoop();
void EndRenderLoop();
bool IsInsideRenderLoop();
|