Skip to content

Commit bef2f2a

Browse files
committed
Move loop to check for single params into
legalizeEntryPointParameterForGLSL()
1 parent 00c2ae8 commit bef2f2a

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

source/slang/slang-ir-glsl-legalize.cpp

+20-18
Original file line numberDiff line numberDiff line change
@@ -2453,23 +2453,10 @@ void legalizeRayTracingEntryPointParameterForGLSL(
24532453
GLSLLegalizationContext* context,
24542454
IRFunc* func,
24552455
IRParam* pp,
2456-
IRVarLayout* paramLayout)
2456+
IRVarLayout* paramLayout,
2457+
bool hasSingleOutOrInOutParam)
24572458
{
2458-
auto firstBlock = func->getFirstBlock();
2459-
2460-
// Count the number of inout or out parameters
2461-
int inoutOrOutParamCount = 0;
2462-
for (auto _param = firstBlock->getFirstParam(); _param; _param = _param->getNextParam())
2463-
{
2464-
auto _paramType = _param->getDataType();
2465-
if (as<IROutType>(_paramType) || as<IRInOutType>(_paramType))
2466-
{
2467-
inoutOrOutParamCount++;
2468-
}
2469-
}
2470-
2471-
// If we have just one inout or out param, we don't need consolidation.
2472-
if (inoutOrOutParamCount <= 1)
2459+
if (hasSingleOutOrInOutParam)
24732460
{
24742461
handleSingleParam(context, func, pp, paramLayout);
24752462
return;
@@ -3165,7 +3152,6 @@ void legalizeEntryPointParameterForGLSL(
31653152
}
31663153
}
31673154

3168-
31693155
// We need to create a global variable that will replace the parameter.
31703156
// It seems superficially obvious that the variable should have
31713157
// the same type as the parameter.
@@ -3322,7 +3308,23 @@ void legalizeEntryPointParameterForGLSL(
33223308
case Stage::Intersection:
33233309
case Stage::Miss:
33243310
case Stage::RayGeneration:
3325-
legalizeRayTracingEntryPointParameterForGLSL(context, func, pp, paramLayout);
3311+
{
3312+
// Count the number of inout or out parameters
3313+
int inoutOrOutParamCount = 0;
3314+
auto firstBlock = func->getFirstBlock();
3315+
for (auto _param = firstBlock->getFirstParam(); _param; _param = _param->getNextParam())
3316+
{
3317+
auto _paramType = _param->getDataType();
3318+
if (as<IROutType>(_paramType) || as<IRInOutType>(_paramType))
3319+
{
3320+
inoutOrOutParamCount++;
3321+
}
3322+
}
3323+
3324+
// If we have just one inout or out param, we don't need consolidation.
3325+
bool hasSingleOutOrInOutParam = inoutOrOutParamCount <= 1;
3326+
legalizeRayTracingEntryPointParameterForGLSL(context, func, pp, paramLayout, hasSingleOutOrInOutParam);
3327+
}
33263328
return;
33273329
}
33283330

0 commit comments

Comments
 (0)