private static void DumpExpImpl( MidBuiltinApp app, Span span) { span.Write("{0}(", app.Decl.Name); span.Add(from a in app.Args select a.Dump(), ", "); span.Write(")"); }
private AttrInfo DecomposeAttrImpl( MidBuiltinApp app, DecomposeAttrContext context) { string template = app.Decl.GetTemplate("blend"); if (template == null) { throw OperationTooComplexError(app.Range); } var args = app.Args.ToArray(); switch (template) { case "AddFloat4": { var left = DecomposeAttr(args[0], context); var right = DecomposeAttr(args[1], context); return new OpInfo( app.Range, D3D11_BLEND_OP.D3D11_BLEND_OP_ADD, left, right); } case "MulFloat4": { var left = DecomposeAttr(args[0], context); var right = DecomposeAttr(args[1], context); return new TermInfo(app.Range, left, right); } case "MulFloat_Float4": { var left = DecomposeAttr(args[0], context.SwitchToAlpha()); var right = DecomposeAttr(args[1], context); return new TermInfo(app.Range, left, right); } case "MulFloat4_Float": { var left = DecomposeAttr(args[0], context); var right = DecomposeAttr(args[1], context.SwitchToAlpha()); return new TermInfo(app.Range, left, right); } case "GetAlpha": { var arg = DecomposeAttr(args[0], context.SwitchToAlpha()); return arg; } case "SubFloat": { var left = DecomposeAttr(args[0], context); var right = DecomposeAttr(args[1], context); return new SubInfo(app.Range, left, right); } case "IntToFloat": { var arg = DecomposeAttr(args[0], context); return arg; } default: throw OperationTooComplexError(app.Range); } }
private EmitValHLSL EmitExpImpl(MidBuiltinApp app, Span span) { var template = app.Decl.GetTemplate("hlsl"); switch (template) { case "__ConstantRef": return EmitConstantRef(app.Args.First(), span); case "__UniformRef": return EmitUniformRef(app.Args.First(), span); default: break; } var args = (from a in app.Args select EmitBuiltinAppArg(a, span)).ToArray(); switch (template) { case "__GetElem": return GetElem( args[0], args[1]); default: break; } var resultType = EmitType(app.Type); var resultString = string.Format(template, args); if (resultType is VoidTypeHLSL) { span.WriteLine("{0};", resultString); return VoidVal; } if (!(resultType is RealTypeHLSL)) { Diagnostics.Add( Severity.Error, new SourceRange(), "Invalid return type for HLSL builtin function '{0}'", app.Decl.Name); return new ErrorValHLSL(); } return new SimpleValHLSL( resultString, (RealTypeHLSL) resultType); }
public void PreEmitExpImpl( MidBuiltinApp app, Span span) { var template = app.Decl.GetTemplate("hlsl"); // Ugly special cases for @Uniform and @Constant parameters // \todo: Get rid of these by handling these references // on-demand... switch (template) { case "__ConstantRef": return; case "__UniformRef": return; default: break; } foreach (var a in app.Args) { PreEmitExp(a, span); } }
private void TransformChildrenImpl( MidBuiltinApp app) { app.Args = (from a in app.Args select Transform(a)).ToArray(); }
private AttributeInfo DecomposeAttrImpl( SourceRange range, MidBuiltinApp midApp) { var name = midApp.Decl.GetTemplate("hlsl"); var args = midApp.Args.ToArray(); if (name == "__VertexFetch") { var buffer = args[0]; var offset = args[1]; var stride = args[2]; var index = args[3]; var inputVertexStream = DecomposeVertexStream(buffer, offset, stride); var inputIndex = DecomposeAttr(midApp.Range, index); return GenerateInputElements( midApp.Range, "", midApp.Type, inputVertexStream, inputIndex, 0); /* var inputSlotClass = ""; var stepRate = 0; if (index is MidAttributeRef) { var indexAttribRef = (MidAttributeRef)index; if (indexAttribRef.Decl == _vertexID) { inputSlotClass = "D3D11_INPUT_PER_VERTEX_DATA"; } else if (indexAttribRef.Decl == _instanceID) { inputSlotClass = "D3D11_INPUT_PER_INSTANCE_DATA"; stepRate = 1; } DecomposeInputElements( span: span, name: name, type: exp.Type, inputSlotIndex: inputSlotIndex, inputSlotClass: inputSlotClass, stepRate: stepRate); }*/ } throw OperationTooComplex(midApp.Range); }