Shader/Spirv: Fix OpFunctionParameter type

This commit is contained in:
Jérôme Leclercq 2021-05-22 16:45:57 +02:00
parent f4bc104810
commit 709604c070
2 changed files with 18 additions and 18 deletions

View File

@ -617,7 +617,7 @@ namespace Nz
for (const auto& param : func.parameters)
{
UInt32 paramResultId = m_writer.AllocateResultId();
m_instructions.Append(SpirvOp::OpFunctionParameter, param.typeId, paramResultId);
m_instructions.Append(SpirvOp::OpFunctionParameter, param.pointerTypeId, paramResultId);
RegisterVariable(varIndex++, param.typeId, paramResultId, SpirvStorageClass::Function);
}

View File

@ -129,6 +129,23 @@ namespace Nz
}
}
void Visit(ShaderAst::CallFunctionExpression& node) override
{
AstRecursiveVisitor::Visit(node);
assert(m_funcIndex);
auto& func = m_funcs[*m_funcIndex];
auto& funcCall = func.funcCalls.emplace_back();
funcCall.firstVarIndex = func.variables.size();
for (const auto& parameter : node.parameters)
{
auto& var = func.variables.emplace_back();
var.typeId = m_constantCache.Register(*m_constantCache.BuildPointerType(GetExpressionType(*parameter), SpirvStorageClass::Function));
}
}
void Visit(ShaderAst::DeclareFunctionStatement& node) override
{
std::optional<ShaderStageType> entryPointType = node.entryStage;
@ -253,23 +270,6 @@ namespace Nz
m_constantCache.Register(*m_constantCache.BuildType(node.description));
}
void Visit(ShaderAst::CallFunctionExpression& node) override
{
AstRecursiveVisitor::Visit(node);
assert(m_funcIndex);
auto& func = m_funcs[*m_funcIndex];
auto& funcCall = func.funcCalls.emplace_back();
funcCall.firstVarIndex = func.variables.size();
for (const auto& parameter : node.parameters)
{
auto& var = func.variables.emplace_back();
var.typeId = m_constantCache.Register(*m_constantCache.BuildPointerType(GetExpressionType(*parameter), SpirvStorageClass::Function));
}
}
void Visit(ShaderAst::DeclareVariableStatement& node) override
{
AstRecursiveVisitor::Visit(node);