diff options
| author | Yong He <yonghe@outlook.com> | 2018-01-17 14:48:07 -0500 |
|---|---|---|
| committer | Yong He <yonghe@outlook.com> | 2018-01-17 20:54:56 -0500 |
| commit | caf6f7a03793be3fc74683994414776f3604ad8a (patch) | |
| tree | d9d3e3a4e4a45d5e09d613159be2faaf137e0e72 /source/slang/emit.cpp | |
| parent | 68f529af8d0eb8ec45a2d73e82c4ee372015ce01 (diff) | |
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`.
Diffstat (limited to 'source/slang/emit.cpp')
| -rw-r--r-- | source/slang/emit.cpp | 54 |
1 files changed, 51 insertions, 3 deletions
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<Slang::EmitVisitor, Slang::ExprEmitArg>::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<HLSLStreamOutputType>()) + { + return true; + } else if(type->As<TextureTypeBase>()) { // 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<HLSLMaxVertexCountAttribute>()) + { + emit("[maxvertexcount("); + Emit(attrib->value); + emit(")]\n"); + } + if (auto attrib = entryPointLayout->entryPoint->FindModifier<HLSLInstanceAttribute>()) + { + 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<IRHighLevelDeclDecoration>()) + { + if (decor->decl) + { + auto primType = decor->decl->FindModifier<HLSLGeometryShaderInputPrimitiveTypeModifier>(); + if (dynamic_cast<HLSLTriangleModifier*>(primType)) + emit("triangle "); + else if (dynamic_cast<HLSLPointModifier*>(primType)) + emit("point "); + else if (dynamic_cast<HLSLLineModifier*>(primType)) + emit("line "); + else if (dynamic_cast<HLSLLineAdjModifier*>(primType)) + emit("lineadj "); + else if (dynamic_cast<HLSLTriangleAdjModifier*>(primType)) + emit("triangleadj "); + } + } emitIRParamType(ctx, paramType, paramName); emitIRSemantics(ctx, pp); + pIdx++; } emit(")"); |
