MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Load

Method Load

Source/Engine/Graphics/Materials/DeferredMaterialShader.cpp:113–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113bool DeferredMaterialShader::Load()
114{
115 // TODO: support instancing when using ForwardShadingFeature
116 _instanced = _info.BlendMode == MaterialBlendMode::Opaque && _info.ShadingModel != MaterialShadingModel::CustomLit;
117
118 bool failed = false;
119 auto psDesc = GPUPipelineState::Description::Default;
120 psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None;
121 if (EnumHasAnyFlags(_info.FeaturesFlags, MaterialFeaturesFlags::DisableDepthTest))
122 {
123 psDesc.DepthFunc = ComparisonFunc::Always;
124 if (!psDesc.DepthWriteEnable)
125 psDesc.DepthEnable = false;
126 }
127
128#if GPU_ALLOW_TESSELLATION_SHADERS
129 // Check if use tessellation (both material and runtime supports it)
130 const bool useTess = _info.TessellationMode != TessellationMethod::None && GPUDevice::Instance->Limits.HasTessellation;
131 if (useTess)
132 {
133 psDesc.HS = _shader->GetHS("HS");
134 psDesc.DS = _shader->GetDS("DS");
135 }
136#endif
137
138 psDesc.StencilEnable = true;
139 psDesc.StencilReadMask = 0;
140 psDesc.StencilPassOp = StencilOperation::Replace;
141
142 // GBuffer Pass
143 psDesc.VS = _shader->GetVS("VS");
144 failed |= psDesc.VS == nullptr;
145 psDesc.PS = _shader->GetPS("PS_GBuffer");
146 _cache.Default.Init(psDesc);
147 psDesc.VS = _shader->GetVS("VS", 1);
148 failed |= psDesc.VS == nullptr;
149 _cacheInstanced.Default.Init(psDesc);
150
151 // GBuffer Pass with lightmap (pixel shader permutation for USE_LIGHTMAP=1)
152 psDesc.VS = _shader->GetVS("VS");
153 failed |= psDesc.VS == nullptr;
154 psDesc.PS = _shader->GetPS("PS_GBuffer", 1);
155 _cache.DefaultLightmap.Init(psDesc);
156 psDesc.VS = _shader->GetVS("VS", 1);
157 failed |= psDesc.VS == nullptr;
158 _cacheInstanced.DefaultLightmap.Init(psDesc);
159
160 // GBuffer Pass with skinning
161 psDesc.VS = _shader->GetVS("VS_Skinned");
162 psDesc.PS = _shader->GetPS("PS_GBuffer");
163 _cache.DefaultSkinned.Init(psDesc);
164
165 psDesc.StencilEnable = false;
166 psDesc.StencilPassOp = StencilOperation::Keep;
167
168#if USE_EDITOR
169 if (_shader->HasShader("PS_QuadOverdraw"))
170 {

Callers

nothing calls this directly

Calls 4

EnumHasAnyFlagsFunction · 0.85
HasShaderMethod · 0.80
GetPSMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected