Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 3 files). Show all
Unified · Split
| @@ -721,11 +721,16 @@ QHash<SimpleProgramKey, gpu::PipelinePointer> GeometryCache::_simplePrograms; · 720 unmodified lines | ||
| 721 | 721 | gpu::ShaderPointer GeometryCache::_simpleShader; |
| 722 | 722 | gpu::ShaderPointer GeometryCache::_transparentShader; |
| 723 | 723 | gpu::ShaderPointer GeometryCache::_unlitShader; |
| 724 | +gpu::ShaderPointer GeometryCache::_forwardSimpleShader; | |
| 725 | +gpu::ShaderPointer GeometryCache::_forwardTransparentShader; | |
| 726 | +gpu::ShaderPointer GeometryCache::_forwardUnlitShader; | |
| 724 | 727 | gpu::ShaderPointer GeometryCache::_simpleFadeShader; |
| 725 | 728 | gpu::ShaderPointer GeometryCache::_unlitFadeShader; |
| 726 | 729 | |
| 727 | 730 | render::ShapePipelinePointer GeometryCache::_simpleOpaquePipeline; |
| 728 | 731 | render::ShapePipelinePointer GeometryCache::_simpleTransparentPipeline; |
| 732 | +render::ShapePipelinePointer GeometryCache::_forwardSimpleOpaquePipeline; | |
| 733 | +render::ShapePipelinePointer GeometryCache::_forwardSimpleTransparentPipeline; | |
| 729 | 734 | render::ShapePipelinePointer GeometryCache::_simpleOpaqueFadePipeline; |
| 730 | 735 | render::ShapePipelinePointer GeometryCache::_simpleTransparentFadePipeline; |
| 731 | 736 | render::ShapePipelinePointer GeometryCache::_simpleWirePipeline; |
| @@ -805,6 +810,8 @@ void GeometryCache::initializeShapePipelines() { · 73 unmodified lines | ||
| 805 | 810 | if (!_simpleOpaquePipeline) { |
| 806 | 811 | _simpleOpaquePipeline = getShapePipeline(false, false, true, false); |
| 807 | 812 | _simpleTransparentPipeline = getShapePipeline(false, true, true, false); |
| 813 | + _forwardSimpleOpaquePipeline = getShapePipeline(false, false, true, false, false, true); | |
| 814 | + _forwardSimpleTransparentPipeline = getShapePipeline(false, true, true, false, false, true); | |
| 808 | 815 | _simpleOpaqueFadePipeline = getFadingShapePipeline(false, false, false, false, false); |
| 809 | 816 | _simpleTransparentFadePipeline = getFadingShapePipeline(false, true, false, false, false); |
| 810 | 817 | _simpleWirePipeline = getShapePipeline(false, false, true, true); |
| @@ -812,9 +819,9 @@ void GeometryCache::initializeShapePipelines() { · 1 unmodified line | ||
| 812 | 819 | } |
| 813 | 820 | |
| 814 | 821 | render::ShapePipelinePointer GeometryCache::getShapePipeline(bool textured, bool transparent, bool culled, |
| 815 | − bool unlit, bool depthBias) { | |
| 822 | + bool unlit, bool depthBias, bool forward) { | |
| 816 | 823 | |
| 817 | − return std::make_shared<render::ShapePipeline>(getSimplePipeline(textured, transparent, culled, unlit, depthBias, false, true), nullptr, | |
| 824 | + return std::make_shared<render::ShapePipeline>(getSimplePipeline(textured, transparent, culled, unlit, depthBias, false, true, forward), nullptr, | |
| 818 | 825 | [](const render::ShapePipeline& pipeline, gpu::Batch& batch, render::Args* args) { |
| 819 | 826 | batch.setResourceTexture(gr::Texture::MaterialAlbedo, DependencyManager::get<TextureCache>()->getWhiteTexture()); |
| 820 | 827 | DependencyManager::get<DeferredLightingEffect>()->setupKeyLightBatch(args, batch); |
| @@ -2165,6 +2172,7 @@ public: · 1344 unmodified lines | ||
| 2165 | 2172 | HAS_DEPTH_BIAS_FLAG, |
| 2166 | 2173 | IS_FADING_FLAG, |
| 2167 | 2174 | IS_ANTIALIASED_FLAG, |
| 2175 | + IS_FORWARD_FLAG, | |
| 2168 | 2176 | |
| 2169 | 2177 | NUM_FLAGS, |
| 2170 | 2178 | }; |
| @@ -2177,6 +2185,7 @@ public: · 6 unmodified lines | ||
| 2177 | 2185 | HAS_DEPTH_BIAS = (1 << HAS_DEPTH_BIAS_FLAG), |
| 2178 | 2186 | IS_FADING = (1 << IS_FADING_FLAG), |
| 2179 | 2187 | IS_ANTIALIASED = (1 << IS_ANTIALIASED_FLAG), |
| 2188 | + IS_FORWARD = (1 << IS_FORWARD_FLAG), | |
| 2180 | 2189 | }; |
| 2181 | 2190 | typedef unsigned short Flags; |
| 2182 | 2191 | |
| @@ -2189,6 +2198,7 @@ public: · 6 unmodified lines | ||
| 2189 | 2198 | bool hasDepthBias() const { return isFlag(HAS_DEPTH_BIAS); } |
| 2190 | 2199 | bool isFading() const { return isFlag(IS_FADING); } |
| 2191 | 2200 | bool isAntiAliased() const { return isFlag(IS_ANTIALIASED); } |
| 2201 | + bool isForward() const { return isFlag(IS_FORWARD); } | |
| 2192 | 2202 | |
| 2193 | 2203 | Flags _flags = 0; |
| 2194 | 2204 | #if defined(__clang__) |
| @@ -2200,9 +2210,9 @@ public: · 5 unmodified lines | ||
| 2200 | 2210 | |
| 2201 | 2211 | |
| 2202 | 2212 | SimpleProgramKey(bool textured = false, bool transparent = false, bool culled = true, |
| 2203 | − bool unlit = false, bool depthBias = false, bool fading = false, bool isAntiAliased = true) { | |
| 2213 | + bool unlit = false, bool depthBias = false, bool fading = false, bool isAntiAliased = true, bool forward = false) { | |
| 2204 | 2214 | _flags = (textured ? IS_TEXTURED : 0) | (transparent ? IS_TRANSPARENT : 0) | (culled ? IS_CULLED : 0) | |
| 2205 | − (unlit ? IS_UNLIT : 0) | (depthBias ? HAS_DEPTH_BIAS : 0) | (fading ? IS_FADING : 0) | (isAntiAliased ? IS_ANTIALIASED : 0); | |
| 2215 | + (unlit ? IS_UNLIT : 0) | (depthBias ? HAS_DEPTH_BIAS : 0) | (fading ? IS_FADING : 0) | (isAntiAliased ? IS_ANTIALIASED : 0) | (forward ? IS_FORWARD : 0); | |
| 2206 | 2216 | } |
| 2207 | 2217 | |
| 2208 | 2218 | SimpleProgramKey(int bitmask) : _flags(bitmask) {} |
| @@ -2255,8 +2265,8 @@ void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool tra · 46 unmodified lines | ||
| 2255 | 2265 | } |
| 2256 | 2266 | } |
| 2257 | 2267 | |
| 2258 | −gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transparent, bool culled, bool unlit, bool depthBiased, bool fading, bool isAntiAliased) { | |
| 2259 | − SimpleProgramKey config { textured, transparent, culled, unlit, depthBiased, fading, isAntiAliased }; | |
| 2268 | +gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transparent, bool culled, bool unlit, bool depthBiased, bool fading, bool isAntiAliased, bool forward) { | |
| 2269 | + SimpleProgramKey config { textured, transparent, culled, unlit, depthBiased, fading, isAntiAliased, forward }; | |
| 2260 | 2270 | |
| 2261 | 2271 | // If the pipeline already exists, return it |
| 2262 | 2272 | auto it = _simplePrograms.find(config); |
| @@ -2269,13 +2279,20 @@ gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transp · 6 unmodified lines | ||
| 2269 | 2279 | static std::once_flag once; |
| 2270 | 2280 | std::call_once(once, [&]() { |
| 2271 | 2281 | using namespace shader::render_utils::program; |
| 2272 | − auto PS = DISABLE_DEFERRED ? forward_simple_textured : simple_textured; | |
| 2273 | − // Use the forward pipeline for both here, otherwise transparents will be unlit | |
| 2274 | − auto PSTransparent = DISABLE_DEFERRED ? forward_simple_textured_transparent : forward_simple_textured_transparent; | |
| 2275 | − auto PSUnlit = DISABLE_DEFERRED ? forward_simple_textured_unlit : simple_textured_unlit; | |
| 2276 | − _simpleShader = gpu::Shader::createProgram(PS); | |
| 2277 | − _transparentShader = gpu::Shader::createProgram(PSTransparent); | |
| 2278 | − _unlitShader = gpu::Shader::createProgram(PSUnlit); | |
| 2282 | + | |
| 2283 | + _forwardSimpleShader = gpu::Shader::createProgram(forward_simple_textured); | |
| 2284 | + _forwardTransparentShader = gpu::Shader::createProgram(forward_simple_textured_transparent); | |
| 2285 | + _forwardUnlitShader = gpu::Shader::createProgram(forward_simple_textured_unlit); | |
| 2286 | + if (DISABLE_DEFERRED) { | |
| 2287 | + _simpleShader = _forwardSimpleShader; | |
| 2288 | + _transparentShader = _forwardTransparentShader; | |
| 2289 | + _unlitShader = _forwardUnlitShader; | |
| 2290 | + } else { | |
| 2291 | + _simpleShader = gpu::Shader::createProgram(simple_textured); | |
| 2292 | + // Use the forward pipeline for both here, otherwise transparents will be unlit | |
| 2293 | + _transparentShader = gpu::Shader::createProgram(forward_simple_textured_transparent); | |
| 2294 | + _unlitShader = gpu::Shader::createProgram(simple_textured_unlit); | |
| 2295 | + } | |
| 2279 | 2296 | }); |
| 2280 | 2297 | } else { |
| 2281 | 2298 | static std::once_flag once; |
| @@ -2308,8 +2325,14 @@ gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transp · 26 unmodified lines | ||
| 2308 | 2325 | PrepareStencil::testMaskDrawShapeNoAA(*state); |
| 2309 | 2326 | } |
| 2310 | 2327 | |
| 2311 | − gpu::ShaderPointer program = (config.isUnlit()) ? (config.isFading() ? _unlitFadeShader : _unlitShader) : | |
| 2312 | − (config.isFading() ? _simpleFadeShader : (config.isTransparent() ? _transparentShader : _simpleShader)); | |
| 2328 | + gpu::ShaderPointer program; | |
| 2329 | + if (config.isForward()) { | |
| 2330 | + program = (config.isUnlit()) ? (config.isFading() ? _unlitFadeShader : _forwardUnlitShader) : | |
| 2331 | + (config.isFading() ? _simpleFadeShader : (config.isTransparent() ? _forwardTransparentShader : _forwardSimpleShader)); | |
| 2332 | + } else { | |
| 2333 | + program = (config.isUnlit()) ? (config.isFading() ? _unlitFadeShader : _unlitShader) : | |
| 2334 | + (config.isFading() ? _simpleFadeShader : (config.isTransparent() ? _transparentShader : _simpleShader)); | |
| 2335 | + } | |
| 2313 | 2336 | gpu::PipelinePointer pipeline = gpu::Pipeline::create(program, state); |
| 2314 | 2337 | _simplePrograms.insert(config, pipeline); |
| 2315 | 2338 | return pipeline; |