From caf6f7a03793be3fc74683994414776f3604ad8a Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 17 Jan 2018 14:48:07 -0500 Subject: All compiler fixes to get ir branch work with falcor feature demo. - support overloaded generic function. this involves adding a new expression type, `OverloadedExpr2` to hold the candidate expressions for the generic function decl being referenced. - make BitNot a normal IROp instead of an IRPseudoOp - make sure we clone the decorations of parameters when cloning ir functions - propagate geometry shader entry point attributes (`[maxvertexcount]` and `[instance]`) through HLSL emit - IR emit: handle geometry shader entry-point parameter decorations, such as 'triangle'. - IR emit: treat geometry shader stream output typed ir value as `should fold into use`. --- source/slang/emit.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) (limited to 'source/slang/emit.cpp') diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index 33328fbb1..18a10460f 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -2315,7 +2315,7 @@ struct EmitVisitor CASE(kIRPseudoOp_Pos, +); CASE(kIROp_Neg, -); CASE(kIROp_Not, !); - CASE(kIRPseudoOp_BitNot, ~); + CASE(kIROp_BitNot, ~); #undef CASE #define CASE(NAME, OP) case kIRPseudoOp_##NAME: EmitUnaryAssignExpr(outerPrec, kEOp_Prefix, #OP, "", callExpr); return @@ -2554,6 +2554,11 @@ struct EmitVisitor emitName(expr->lookupResult2.getName()); } + void visitOverloadedExpr2(OverloadedExpr2* expr, ExprEmitArg const& arg) + { + ExprVisitorWithArg::dispatch(expr->candidiateExprs[0].Ptr(), arg); + } + void setSampleRateFlag() { context->shared->entryPointLayout->flags |= EntryPointLayout::Flag::usesAnySampleRateInput; @@ -4928,6 +4933,10 @@ emitDeclImpl(decl, nullptr); // types. return true; } + else if (type->As()) + { + return true; + } else if(type->As()) { // GLSL doesn't allow texture/resource types to @@ -5512,7 +5521,12 @@ emitDeclImpl(decl, nullptr); emitIROperand(ctx, inst->getArg(0)); } break; - + case kIROp_BitNot: + { + emit("~"); + emitIROperand(ctx, inst->getArg(0)); + } + break; case kIROp_Sample: emitIROperand(ctx, inst->getArg(0)); emit(".Sample("); @@ -6266,7 +6280,22 @@ emitDeclImpl(decl, nullptr); emit(")]\n"); } break; - + case Stage::Geometry: + { + if (auto attrib = entryPointLayout->entryPoint->FindModifier()) + { + emit("[maxvertexcount("); + Emit(attrib->value); + emit(")]\n"); + } + if (auto attrib = entryPointLayout->entryPoint->FindModifier()) + { + emit("[instance("); + Emit(attrib->value); + emit(")]\n"); + } + } + break; // TODO: There are other stages that will need this kind of handling. default: break; @@ -6279,6 +6308,7 @@ emitDeclImpl(decl, nullptr); emit("("); auto firstParam = func->getFirstParam(); + int pIdx = 0; for( auto pp = firstParam; pp; pp = pp->getNextParam() ) { if(pp != firstParam) @@ -6286,9 +6316,27 @@ emitDeclImpl(decl, nullptr); auto paramName = getIRName(pp); auto paramType = pp->getType(); + if (auto decor = pp->findDecoration()) + { + if (decor->decl) + { + 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 "); + } + } emitIRParamType(ctx, paramType, paramName); emitIRSemantics(ctx, pp); + pIdx++; } emit(")"); -- cgit v1.2.3 From 9cecdfbb00c0174a9cbfc721149acf2e0b4ecd3c Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 17 Jan 2018 20:58:00 -0500 Subject: cleanup unused code. --- source/slang/emit.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'source/slang/emit.cpp') diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index 18a10460f..53f02cc56 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -6308,7 +6308,6 @@ emitDeclImpl(decl, nullptr); emit("("); auto firstParam = func->getFirstParam(); - int pIdx = 0; for( auto pp = firstParam; pp; pp = pp->getNextParam() ) { if(pp != firstParam) @@ -6336,7 +6335,6 @@ emitDeclImpl(decl, nullptr); emitIRParamType(ctx, paramType, paramName); emitIRSemantics(ctx, pp); - pIdx++; } emit(")"); -- cgit v1.2.3