From 84a48475067af70c9acccc9816dd60e623714328 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 4 Oct 2018 10:25:36 -0400 Subject: Remove need of IRHightLevelDecoration in emit (#660) * * Remove the need for IRHighLevelDecoration in Emit * Use the IRLayoutDecoration for GeometryShaderPrimitiveTypeModifier * Fixing problems with comparison due to naming differences with slang/fxc. --- source/slang/emit.cpp | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'source/slang/emit.cpp') diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index 1b527c01f..521a9fe1f 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -4654,36 +4654,50 @@ struct EmitVisitor emitIREntryPointAttributes(func, ctx, entryPointLayout); } + const CodeGenTarget target = ctx->shared->target; + auto name = getIRFuncName(func); EmitType(resultType, name); emit("("); auto firstParam = func->getFirstParam(); - for( auto pp = firstParam; pp; pp = pp->getNextParam() ) + for( auto pp = firstParam; pp; pp = pp->getNextParam()) { if(pp != firstParam) emit(", "); auto paramName = getIRName(pp); auto paramType = pp->getDataType(); - if (auto decor = pp->findDecoration()) + + if (target == CodeGenTarget::HLSL) { - if (decor->decl) + if (auto layoutDecor = pp->findDecoration()) { - auto primType = decor->decl->FindModifier(); - if (dynamic_cast(primType)) - emit("triangle "); - else if (dynamic_cast(primType)) - emit("point "); - else if (dynamic_cast(primType)) - emit("line "); - else if (dynamic_cast(primType)) - emit("lineadj "); - else if (dynamic_cast(primType)) - emit("triangleadj "); + Layout* layout = layoutDecor->layout; + VarLayout* varLayout = dynamic_cast(layout); + + if (varLayout) + { + auto var = varLayout->getVariable(); + + if (auto primTypeModifier = var->FindModifier()) + { + if (dynamic_cast(primTypeModifier)) + emit("triangle "); + else if (dynamic_cast(primTypeModifier)) + emit("point "); + else if (dynamic_cast(primTypeModifier)) + emit("line "); + else if (dynamic_cast(primTypeModifier)) + emit("lineadj "); + else if (dynamic_cast(primTypeModifier)) + emit("triangleadj "); + } + } } } + emitIRParamType(ctx, paramType, paramName); emitIRSemantics(ctx, pp); -- cgit v1.2.3