Skip to content

Commit

Permalink
RTSS: Parameter::Content is not exhaustive - pass it as int
Browse files Browse the repository at this point in the history
  • Loading branch information
paroj committed Feb 8, 2025
1 parent 304e851 commit 5645470
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 44 deletions.
18 changes: 9 additions & 9 deletions Components/RTShaderSystem/include/OgreShaderFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ class _OgreRTSSExport Function : public RTShaderSystemAlloc
// Interface.
public:
/// @deprecated
ParameterPtr resolveInputParameter(Parameter::Semantic semantic, int index, const Parameter::Content content, GpuConstantType type);
ParameterPtr resolveInputParameter(Parameter::Semantic semantic, int index, int content, GpuConstantType type);

/** Resolve input parameter of this function
@param content The content of the parameter.
@param type The type of the desired parameter.
@return parameter instance in case of that resolve operation succeeded.
*/
ParameterPtr resolveInputParameter(Parameter::Content content, GpuConstantType type = GCT_UNKNOWN)
ParameterPtr resolveInputParameter(int content, GpuConstantType type = GCT_UNKNOWN)
{
return resolveInputParameter(Parameter::SPS_UNKNOWN, 0, content, type);
}
Expand All @@ -143,20 +143,20 @@ class _OgreRTSSExport Function : public RTShaderSystemAlloc
* @param type The type of the desired parameter.
* @return parameter or NULL if not found
*/
ParameterPtr getInputParameter(Parameter::Content content, GpuConstantType type = GCT_UNKNOWN)
ParameterPtr getInputParameter(int content, GpuConstantType type = GCT_UNKNOWN)
{
return _getParameterByContent(mInputParameters, content, type);
}

/// @deprecated
ParameterPtr resolveOutputParameter(Parameter::Semantic semantic, int index, const Parameter::Content content, GpuConstantType type);
ParameterPtr resolveOutputParameter(Parameter::Semantic semantic, int index, int content, GpuConstantType type);

/** Resolve output parameter of this function
@param content The content of the parameter.
@param type The type of the desired parameter.
@return parameter instance in case of that resolve operation succeeded.
*/
ParameterPtr resolveOutputParameter(Parameter::Content content, GpuConstantType type = GCT_UNKNOWN)
ParameterPtr resolveOutputParameter(int content, GpuConstantType type = GCT_UNKNOWN)
{
return resolveOutputParameter(Parameter::SPS_UNKNOWN, 0, content, type);
}
Expand All @@ -167,7 +167,7 @@ class _OgreRTSSExport Function : public RTShaderSystemAlloc
* @param type The type of the desired parameter.
* @return parameter or NULL if not found
*/
ParameterPtr getOutputParameter(Parameter::Content content, GpuConstantType type = GCT_UNKNOWN)
ParameterPtr getOutputParameter(int content, GpuConstantType type = GCT_UNKNOWN)
{
return _getParameterByContent(mOutputParameters, content, type);
}
Expand All @@ -189,7 +189,7 @@ class _OgreRTSSExport Function : public RTShaderSystemAlloc
@param type The type of the desired parameter.
@return parameter instance in case of that resolve operation succeeded.
*/
ParameterPtr resolveLocalParameter(Parameter::Content content, GpuConstantType type = GCT_UNKNOWN);
ParameterPtr resolveLocalParameter(int content, GpuConstantType type = GCT_UNKNOWN);


ParameterPtr resolveLocalStructParameter(const String& type, const String& name);
Expand All @@ -199,7 +199,7 @@ class _OgreRTSSExport Function : public RTShaderSystemAlloc
* @param content
* @return parameter or NULL if not found
*/
ParameterPtr getLocalParameter(Parameter::Content content)
ParameterPtr getLocalParameter(int content)
{
return _getParameterByContent(mLocalParameters, content, GCT_UNKNOWN);
}
Expand Down Expand Up @@ -261,7 +261,7 @@ class _OgreRTSSExport Function : public RTShaderSystemAlloc

static ParameterPtr _getParameterByName(const ShaderParameterList& parameterList, const String& name);
static ParameterPtr _getParameterBySemantic(const ShaderParameterList& parameterList, const Parameter::Semantic semantic, int index);
static ParameterPtr _getParameterByContent(const ShaderParameterList& parameterList, const Parameter::Content content, GpuConstantType type);
static ParameterPtr _getParameterByContent(const ShaderParameterList& parameterList, int content, GpuConstantType type);

/** Class destructor */
~Function();
Expand Down
17 changes: 8 additions & 9 deletions Components/RTShaderSystem/include/OgreShaderParameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,8 @@ class _OgreRTSSExport Parameter : public RTShaderSystemAlloc
@param content The content of this parameter.
@param size
*/
Parameter(GpuConstantType type, const String& name,
const Semantic& semantic, int index,
const Content& content, size_t size = 0);
Parameter(GpuConstantType type, const String& name, const Semantic& semantic, int index, int content,
size_t size = 0);

/** Class destructor */
virtual ~Parameter() {};
Expand All @@ -226,7 +225,7 @@ class _OgreRTSSExport Parameter : public RTShaderSystemAlloc
int getIndex() const { return mIndex; }

/** Return the content of this parameter. */
Content getContent() const { return mContent; }
int getContent() const { return mContent; }

/** Returns true if this instance is a ConstParameter otherwise false. */
virtual bool isConstParameter() const { return false; }
Expand Down Expand Up @@ -273,7 +272,7 @@ class _OgreRTSSExport Parameter : public RTShaderSystemAlloc
// Index of this parameter.
int mIndex;
// The content of this parameter.
Content mContent;
int mContent;
// Number of elements in the parameter (for arrays)
size_t mSize;

Expand Down Expand Up @@ -301,7 +300,7 @@ class _OgreRTSSExport UniformParameter : public Parameter
*/
UniformParameter(GpuConstantType type, const String& name,
const Semantic& semantic, int index,
const Content& content,
int content,
uint16 variability, size_t size);

/** Class constructor.
Expand Down Expand Up @@ -551,7 +550,7 @@ class _OgreRTSSExport ParameterFactory
// Interface.
public:

static ParameterPtr createInPosition(int index, Parameter::Content content = Parameter::SPC_POSITION_OBJECT_SPACE);
static ParameterPtr createInPosition(int index, int content = Parameter::SPC_POSITION_OBJECT_SPACE);
static ParameterPtr createOutPosition(int index);

static ParameterPtr createInNormal(int index);
Expand All @@ -565,8 +564,8 @@ class _OgreRTSSExport ParameterFactory
static ParameterPtr createInColor(int index);
static ParameterPtr createOutColor(int index);

static ParameterPtr createInTexcoord(GpuConstantType type, int index, Parameter::Content content);
static ParameterPtr createOutTexcoord(GpuConstantType type, int index, Parameter::Content content);
static ParameterPtr createInTexcoord(GpuConstantType type, int index, int content);
static ParameterPtr createOutTexcoord(GpuConstantType type, int index, int content);

static ParameterPtr createConstParam(const Vector2& val);
static ParameterPtr createConstParam(const Vector3& val);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ bool IntegratedPSSM3::resolveParameters(ProgramSet* programSet)
for (auto& p : mShadowTextureParamsList)
{
p.mWorldViewProjMatrix = vsProgram->resolveParameter(GpuProgramParameters::ACT_TEXTURE_WORLDVIEWPROJ_MATRIX, lightIndex);
p.mVSOutLightPosition = vsMain->resolveOutputParameter(Parameter::Content(Parameter::SPC_POSITION_LIGHT_SPACE0 + lightIndex));
p.mVSOutLightPosition = vsMain->resolveOutputParameter(Parameter::SPC_POSITION_LIGHT_SPACE0 + lightIndex);
p.mPSInLightPosition = psMain->resolveInputParameter(p.mVSOutLightPosition);
auto stype = mUseTextureCompare ? GCT_SAMPLER2DSHADOW : GCT_SAMPLER2D;
p.mTextureSampler = psProgram->resolveParameter(stype, "shadow_map", p.mTextureSamplerIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ bool NormalMapLighting::createCpuSubPrograms(ProgramSet* programSet)
psProgram->addPreprocessorDefines("POM_LAYER_COUNT=32");

// Resolve texture coordinates.
auto vsInTexcoord = vsMain->resolveInputParameter(
Parameter::Content(Parameter::SPC_TEXTURE_COORDINATE0 + mVSTexCoordSetIndex), GCT_FLOAT2);
auto vsOutTexcoord = vsMain->resolveOutputParameter(
Parameter::Content(Parameter::SPC_TEXTURE_COORDINATE0 + mVSTexCoordSetIndex), GCT_FLOAT2);
auto vsInTexcoord =
vsMain->resolveInputParameter(Parameter::SPC_TEXTURE_COORDINATE0 + mVSTexCoordSetIndex, GCT_FLOAT2);
auto vsOutTexcoord =
vsMain->resolveOutputParameter(Parameter::SPC_TEXTURE_COORDINATE0 + mVSTexCoordSetIndex, GCT_FLOAT2);
auto psInTexcoord = psMain->resolveInputParameter(vsOutTexcoord);

// Resolve normal.
Expand Down
7 changes: 3 additions & 4 deletions Components/RTShaderSystem/src/OgreShaderFFPTexturing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ bool FFPTexturing::resolveFunctionsParams(TextureUnitParams* textureUnitParams,
Program* psProgram = programSet->getCpuProgram(GPT_FRAGMENT_PROGRAM);
Function* vsMain = vsProgram->getEntryPointFunction();
Function* psMain = psProgram->getEntryPointFunction();
Parameter::Content texCoordContent = Parameter::SPC_UNKNOWN;
int texCoordContent = Parameter::SPC_UNKNOWN;

switch (textureUnitParams->mTexCoordCalcMethod)
{
Expand All @@ -143,15 +143,14 @@ bool FFPTexturing::resolveFunctionsParams(TextureUnitParams* textureUnitParams,
break;

if (textureUnitParams->mTextureMatrix.get() == NULL)
texCoordContent = Parameter::Content(Parameter::SPC_TEXTURE_COORDINATE0 + textureUnitParams->mTextureUnitState->getTextureCoordSet());
texCoordContent = Parameter::SPC_TEXTURE_COORDINATE0 + textureUnitParams->mTextureUnitState->getTextureCoordSet();

// assume already resolved
if(vsMain->getOutputParameter(texCoordContent, textureUnitParams->mVSInTextureCoordinateType))
break;

textureUnitParams->mVSInputTexCoord = vsMain->resolveInputParameter(
Parameter::Content(Parameter::SPC_TEXTURE_COORDINATE0 +
textureUnitParams->mTextureUnitState->getTextureCoordSet()),
Parameter::SPC_TEXTURE_COORDINATE0 + textureUnitParams->mTextureUnitState->getTextureCoordSet(),
textureUnitParams->mVSInTextureCoordinateType);
break;

Expand Down
4 changes: 2 additions & 2 deletions Components/RTShaderSystem/src/OgreShaderFFPTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ bool FFPTransform::createCpuSubPrograms(ProgramSet* programSet)
vsProgram->setUseColumnMajorMatrices(false);
}

auto wMatrix = vsEntry->resolveInputParameter(
Parameter::Content(Parameter::SPC_TEXTURE_COORDINATE0 + mInstancingTexCoordIndex), GCT_MATRIX_3X4);
auto wMatrix = vsEntry->resolveInputParameter(Parameter::SPC_TEXTURE_COORDINATE0 + mInstancingTexCoordIndex,
GCT_MATRIX_3X4);
stage.callFunction(FFP_FUNC_TRANSFORM, wMatrix, positionIn, Out(positionIn).xyz());

if(mDoLightCalculations)
Expand Down
14 changes: 7 additions & 7 deletions Components/RTShaderSystem/src/OgreShaderFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ THE SOFTWARE.
namespace Ogre {
namespace RTShader {

static GpuConstantType typeFromContent(Parameter::Content content)
static GpuConstantType typeFromContent(int content)
{
switch (content)
{
Expand Down Expand Up @@ -72,7 +72,7 @@ static GpuConstantType typeFromContent(Parameter::Content content)
}
}

static Parameter::Semantic semanticFromContent(Parameter::Content content, bool isVSOut = false)
static Parameter::Semantic semanticFromContent(int content, bool isVSOut = false)
{
switch (content)
{
Expand Down Expand Up @@ -109,7 +109,7 @@ static Parameter::Semantic semanticFromContent(Parameter::Content content, bool
}

/// fixed index for texcoords, next free semantic slot else
static int indexFromContent(Parameter::Content content)
static int indexFromContent(int content)
{
int c = int(content);
if(c < Parameter::SPC_TEXTURE_COORDINATE0 || c > Parameter::SPC_TEXTURE_COORDINATE7)
Expand Down Expand Up @@ -225,7 +225,7 @@ static String getParameterName(const char* prefix, Parameter::Semantic semantic,
//-----------------------------------------------------------------------------
ParameterPtr Function::resolveInputParameter(Parameter::Semantic semantic,
int index,
const Parameter::Content content,
int content,
GpuConstantType type)
{
if(type == GCT_UNKNOWN)
Expand Down Expand Up @@ -286,7 +286,7 @@ ParameterPtr Function::resolveInputParameter(Parameter::Semantic semantic,
//-----------------------------------------------------------------------------
ParameterPtr Function::resolveOutputParameter(Parameter::Semantic semantic,
int index,
Parameter::Content content,
int content,
GpuConstantType type)
{
if(type == GCT_UNKNOWN)
Expand Down Expand Up @@ -400,7 +400,7 @@ ParameterPtr Function::resolveLocalStructParameter(const String& type, const Str
}

//-----------------------------------------------------------------------------
ParameterPtr Function::resolveLocalParameter(const Parameter::Content content, GpuConstantType type)
ParameterPtr Function::resolveLocalParameter(int content, GpuConstantType type)
{
ParameterPtr param;

Expand Down Expand Up @@ -534,7 +534,7 @@ ParameterPtr Function::_getParameterBySemantic(const ShaderParameterList& parame
}

//-----------------------------------------------------------------------------
ParameterPtr Function::_getParameterByContent(const ShaderParameterList& parameterList, const Parameter::Content content, GpuConstantType type)
ParameterPtr Function::_getParameterByContent(const ShaderParameterList& parameterList, int content, GpuConstantType type)
{
if(type == GCT_UNKNOWN)
type = typeFromContent(content);
Expand Down
10 changes: 5 additions & 5 deletions Components/RTShaderSystem/src/OgreShaderParameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ Parameter::Parameter() : mName(""), mType(GCT_UNKNOWN), mSemantic(SPS_UNKNOWN),
//-----------------------------------------------------------------------
Parameter::Parameter(GpuConstantType type, const String& name,
const Semantic& semantic, int index,
const Content& content, size_t size) :
int content, size_t size) :
mName(name), mType(type), mSemantic(semantic), mIndex(index), mContent(content), mSize(size), mUsed(false), mIsHighP(false)
{
}

//-----------------------------------------------------------------------
UniformParameter::UniformParameter(GpuConstantType type, const String& name,
const Semantic& semantic, int index,
const Content& content,
int content,
uint16 variability, size_t size) : Parameter(type, name, semantic, index, content, size)
{
mIsAutoConstantReal = false;
Expand Down Expand Up @@ -330,7 +330,7 @@ void UniformParameter::bind(GpuProgramParametersSharedPtr paramsPtr)
}

//-----------------------------------------------------------------------
ParameterPtr ParameterFactory::createInPosition(int index, Parameter::Content content)
ParameterPtr ParameterFactory::createInPosition(int index, int content)
{
return std::make_shared<Parameter>(GCT_FLOAT4, "iPos_" + StringConverter::toString(index),
Parameter::SPS_POSITION, index,
Expand Down Expand Up @@ -430,7 +430,7 @@ ParameterPtr ParameterFactory::createOutColor(int index)
}

//-----------------------------------------------------------------------
ParameterPtr ParameterFactory::createInTexcoord(GpuConstantType type, int index, Parameter::Content content)
ParameterPtr ParameterFactory::createInTexcoord(GpuConstantType type, int index, int content)
{
switch (type)
{
Expand Down Expand Up @@ -473,7 +473,7 @@ ParameterPtr ParameterFactory::createInTexcoord(GpuConstantType type, int index,
}

//-----------------------------------------------------------------------
ParameterPtr ParameterFactory::createOutTexcoord(GpuConstantType type, int index, Parameter::Content content)
ParameterPtr ParameterFactory::createOutTexcoord(GpuConstantType type, int index, int content)
{
switch (type)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ bool ShaderExInstancedViewports::resolveParameters(ProgramSet* programSet)

mVSOriginalOutPositionProjectiveSpace = vsMain->resolveOutputParameter(Parameter::SPC_POSITION_PROJECTIVE_SPACE);

#define SPC_POSITION_PROJECTIVE_SPACE_AS_TEXCORD ((Parameter::Content)(Parameter::SPC_CUSTOM_CONTENT_BEGIN + 1))
#define SPC_POSITION_PROJECTIVE_SPACE_AS_TEXCORD (Parameter::SPC_CUSTOM_CONTENT_BEGIN + 1)

mVSOutPositionProjectiveSpace = vsMain->resolveOutputParameter(SPC_POSITION_PROJECTIVE_SPACE_AS_TEXCORD, GCT_FLOAT4);

Expand Down
4 changes: 2 additions & 2 deletions Samples/ShaderSystem/src/OgreShaderExTextureAtlasSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ bool TextureAtlasSampler::resolveParameters(ProgramSet* programSet)
//
// Define vertex shader parameters used to find the position of the textures in the atlas
//
Parameter::Content indexContent = (Parameter::Content)((int)Parameter::SPC_TEXTURE_COORDINATE0 + mAtlasTexcoordPos);
int indexContent = Parameter::SPC_TEXTURE_COORDINATE0 + mAtlasTexcoordPos;
GpuConstantType indexType = GCT_FLOAT4;

mVSInpTextureTableIndex = vsMain->resolveInputParameter(indexContent, indexType);
Expand Down Expand Up @@ -173,7 +173,7 @@ bool TextureAtlasSampler::addFunctionInvocations(ProgramSet* programSet)
if (mIsAtlasTextureUnits[j] == true)
{
//Find the texture coordinates texel and sampler from the original FFPTexturing
ParameterPtr texcoord = psMain->getInputParameter((Parameter::Content)(Parameter::SPC_TEXTURE_COORDINATE0 + j), GCT_FLOAT2);
ParameterPtr texcoord = psMain->getInputParameter(Parameter::SPC_TEXTURE_COORDINATE0 + j, GCT_FLOAT2);
ParameterPtr texel = psMain->getLocalParameter(c_ParamTexel + StringConverter::toString(j));
UniformParameterPtr sampler = psProgram->getParameterByType(GCT_SAMPLER2D, j);

Expand Down

0 comments on commit 5645470

Please sign in to comment.