From 3e136b9a3152d408469e7314eb231ccc0732af0f Mon Sep 17 00:00:00 2001 From: codereader Date: Sun, 14 Mar 2021 10:04:55 +0100 Subject: [PATCH] #5532: Migrating texgen param expressions to use the expression slots --- include/ishaderlayer.h | 6 ++++++ radiantcore/shaders/Doom3ShaderLayer.cpp | 1 - radiantcore/shaders/Doom3ShaderLayer.h | 15 +++++++-------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/ishaderlayer.h b/include/ishaderlayer.h index 936548f5d0..72a281a493 100644 --- a/include/ishaderlayer.h +++ b/include/ishaderlayer.h @@ -105,6 +105,9 @@ class IShaderLayer enum Slot { AlphaTest = 0, + TexGenParam1, + TexGenParam2, + TexGenParam3, NumExpressionSlots }; }; @@ -136,6 +139,9 @@ class IShaderLayer */ virtual void evaluateExpressions(std::size_t time, const IRenderEntity& entity) = 0; + // Returns the requested expression + virtual shaders::IShaderExpression::Ptr getExpression(Expression::Slot slot) = 0; + /** * The flags set on this stage. */ diff --git a/radiantcore/shaders/Doom3ShaderLayer.cpp b/radiantcore/shaders/Doom3ShaderLayer.cpp index 2a993b824b..ecb135f8c5 100644 --- a/radiantcore/shaders/Doom3ShaderLayer.cpp +++ b/radiantcore/shaders/Doom3ShaderLayer.cpp @@ -85,7 +85,6 @@ void ExpressionSlots::assign(IShaderLayer::Expression::Slot slot, const IShaderE if (!newExpression) { expressionSlot.expression.reset(); - expressionSlot.expressionIndex = ExpressionSlot::Unused; expressionSlot.registerIndex = defaultRegisterIndex; return; } diff --git a/radiantcore/shaders/Doom3ShaderLayer.h b/radiantcore/shaders/Doom3ShaderLayer.h index dc5a08b558..50cb31f9c7 100644 --- a/radiantcore/shaders/Doom3ShaderLayer.h +++ b/radiantcore/shaders/Doom3ShaderLayer.h @@ -21,17 +21,11 @@ struct ExpressionSlot // The register holding the evaluated float std::size_t registerIndex; - // The index of this expression in the slots array - std::size_t expressionIndex; - - // The expression itself + // The expression itself (empty if unused) IShaderExpression::Ptr expression; - static const std::size_t Unused = std::numeric_limits::max(); - ExpressionSlot() : - registerIndex(REG_ZERO), - expressionIndex(Unused) + registerIndex(REG_ZERO) {} }; @@ -252,6 +246,11 @@ class Doom3ShaderLayer : } } + shaders::IShaderExpression::Ptr getExpression(Expression::Slot slot) override + { + return _expressionSlots[slot].expression; + } + /** * \brief * Set the bindable texture object.