Skip to content

Commit

Permalink
#5532: Migrating texgen param expressions to use the expression slots
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Mar 14, 2021
1 parent 9b4e70d commit 3e136b9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
6 changes: 6 additions & 0 deletions include/ishaderlayer.h
Expand Up @@ -105,6 +105,9 @@ class IShaderLayer
enum Slot
{
AlphaTest = 0,
TexGenParam1,
TexGenParam2,
TexGenParam3,
NumExpressionSlots
};
};
Expand Down Expand Up @@ -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.
*/
Expand Down
1 change: 0 additions & 1 deletion radiantcore/shaders/Doom3ShaderLayer.cpp
Expand Up @@ -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;
}
Expand Down
15 changes: 7 additions & 8 deletions radiantcore/shaders/Doom3ShaderLayer.h
Expand Up @@ -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<std::size_t>::max();

ExpressionSlot() :
registerIndex(REG_ZERO),
expressionIndex(Unused)
registerIndex(REG_ZERO)
{}
};

Expand Down Expand Up @@ -252,6 +246,11 @@ class Doom3ShaderLayer :
}
}

shaders::IShaderExpression::Ptr getExpression(Expression::Slot slot) override
{
return _expressionSlots[slot].expression;
}

/**
* \brief
* Set the bindable texture object.
Expand Down

0 comments on commit 3e136b9

Please sign in to comment.