Example #1
0
 public override ShaderCompiler.Operand[] Compile(ShaderCompiler compiler, ShaderCompiler.Operand[] operands,
                                                  FixedShaderParameters parameters, ref DualShareContext shareContext)
 {
     ShaderCompiler.Operand dst = compiler.CreateTemporary(operands[1].Format, operands[1].ArraySize);
     compiler.BeginIf(operands[0]);
     compiler.Mov(operands[1], dst);
     compiler.Else();
     compiler.Mov(operands[2], dst);
     compiler.EndIf();
     return(new ShaderCompiler.Operand[] { dst });
 }
Example #2
0
 public override ShaderCompiler.Operand[] Compile(ShaderCompiler compiler, ShaderCompiler.Operand[] operands,
                                                  FixedShaderParameters parameters, ref DualShareContext shareContext)
 {
     return(new ShaderCompiler.Operand[] {
         compiler.CreateFixed(PinFormat.UInteger, Pin.NotArray, operands[0].ArraySize)
     });
 }
 public override ShaderCompiler.Operand[] Compile(ShaderCompiler compiler, ShaderCompiler.Operand[] operands, FixedShaderParameters parameters, ref DualShareContext shareContext)
 {
     return(new ShaderCompiler.Operand[] { compiler.Convert(operands[0], outFormat) });
 }
Example #4
0
        public ShaderCompiler.Operand[] Compile(ShaderCompiler compiler, ShaderCompiler.Operand[] operands, FixedShaderParameters parameters, ref SharpMedia.Graphics.Shaders.Operations.DualShareContext shareContext)
        {
            // We obtain interfaces (CPU resolve).
            object[] interfaces = InterfaceHelper.ResolveInterfaceArray(inputs[4], parameters);

            // We first register all our "constants" (for fill IDs).
            ShaderCompiler.Operand[] integerConstants = new ShaderCompiler.Operand[interfaces.Length];
            for (int i = 0; i < integerConstants.Length; i++)
            {
                integerConstants[i] = compiler.CreateFixed(PinFormat.Integer, Pin.NotArray, i);
            }

            // We pack out "attributes".
            ShaderCompiler.Operand[] attributes = new ShaderCompiler.Operand[] { operands[2] };

            // We create output colour constant.
            ShaderCompiler.Operand outColour = compiler.CreateTemporary(PinFormat.Floatx4, Pin.NotArray);

            // We switch
            compiler.BeginSwitch(operands[3]);

            // We go through all interfaces.
            for (int i = 0; i < interfaces.Length; i++)
            {
                compiler.BeginCase(integerConstants[i]);

                // We cast to fill.
                IFill fill = interfaces[i] as IFill;

                ShaderCompiler.Operand[] constants =
                    InterfaceHelper.RegisterInterfaceConstants(compiler,
                                                               string.Format("Fills[{0}]", i), parameters, fill);

                fill.Compile(compiler, operands[0], operands[1], attributes, null, constants, outColour);

                compiler.EndCase();
            }

            // We also add "default" handler.
            compiler.BeginDefault();
            compiler.Mov(compiler.CreateFixed(PinFormat.Floatx4, Pin.NotArray, new Math.Vector4f(1.0f, 0.0f, 0.0f, 1.0f)),
                         outColour);
            compiler.EndCase();

            // And end switch.
            compiler.EndSwitch();

            return(new ShaderCompiler.Operand[] { outColour });
        }
Example #5
0
 public ShaderCompiler.Operand[] Compile(ShaderCompiler compiler, ShaderCompiler.Operand[] operands, FixedShaderParameters parameters, ref DualShareContext shareContext)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Example #6
0
        public ShaderCompiler.Operand[] Compile(ShaderCompiler compiler, ShaderCompiler.Operand[] operands, FixedShaderParameters parameters, ref DualShareContext shareContext)
        {
            ShaderCompiler.Operand[] results = new ShaderCompiler.Operand[outputs.Count];

            // We simply emit descriptors.
            int i = 0;

            foreach (KeyValuePair <PinComponent, Pin> pair in outputs)
            {
                results[i++] = compiler.CreateInput(pair.Value.Format, pair.Key);
            }

            return(results);
        }
Example #7
0
 public override ShaderCompiler.Operand[] Compile(ShaderCompiler compiler, ShaderCompiler.Operand[] operands, FixedShaderParameters parameters, ref DualShareContext shareContext)
 {
     return(new ShaderCompiler.Operand[] {
         compiler.Load(operands[0], operands[1], operands.Length >= 3 ? operands[2] : null)
     });
 }
Example #8
0
 public override ShaderCompiler.Operand[] Compile(ShaderCompiler compiler, ShaderCompiler.Operand[] operands, FixedShaderParameters parameters, ref DualShareContext shareContext)
 {
     return(new ShaderCompiler.Operand[] { compiler.Call(ShaderFunction.All, operands[0]) });
 }
 public override ShaderCompiler.Operand[] Compile(ShaderCompiler compiler, ShaderCompiler.Operand[] operands, FixedShaderParameters parameters, ref DualShareContext shareContext)
 {
     return(new ShaderCompiler.Operand[] { compiler.IndexInArray(operands[0], operands[1]) });
 }
Example #10
0
 public override ShaderCompiler.Operand[] Compile(ShaderCompiler compiler, ShaderCompiler.Operand[] operands, FixedShaderParameters parameters, ref DualShareContext shareContext)
 {
     return(new ShaderCompiler.Operand[] { compiler.Expand(operands[0], expandTo, type) });
 }
Example #11
0
        public ShaderCompiler.Operand[] Compile(ShaderCompiler compiler, ShaderCompiler.Operand[] operands, FixedShaderParameters parameters, ref DualShareContext shareContext)
        {
            // We output all.
            int i = 0;

            foreach (KeyValuePair <PinComponent, Pin> p in inputs)
            {
                compiler.Output(operands[i++], p.Key);
            }

            return(new ShaderCompiler.Operand[] { });
        }
Example #12
0
        public ShaderCompiler.Operand[] Compile(ShaderCompiler compiler, ShaderCompiler.Operand[] operands, FixedShaderParameters parameters, ref DualShareContext shareContext)
        {
            // We checked if it is fixed on "constant" level (not named).
            if (!IsReferencable)
            {
                return(new ShaderCompiler.Operand[] {
                    compiler.CreateFixed(output.Format, output.Size, value)
                });
            }


            // We first check if this parameter is fixed.
            if (parameters.IsParameterFixed(name))
            {
                // If it is fixed, we create a fixed constant.
                switch (output.Format)
                {
                case PinFormat.Texture1D:
                case PinFormat.Texture1DArray:
                case PinFormat.Texture2D:
                case PinFormat.Texture2DArray:
                case PinFormat.TextureCube:
                case PinFormat.Texture3D:
                case PinFormat.Sampler:
                case PinFormat.BufferTexture:
                case PinFormat.Interface:
                    // We return "unresolved" parameter, it must be obtained directly.
                    return(new ShaderCompiler.Operand[1] {
                        null
                    });

                default:
                    break;
                }

                return(new ShaderCompiler.Operand[]
                {
                    compiler.CreateFixed(output.Format, output.Size, parameters[name])
                });
            }

            // We locate it.
            uint bufferID = 0;
            uint offset   = 0;

            ConstantBufferLayout[] layouts = parameters.ConstantBuffers;
            foreach (ConstantBufferLayout layout in layouts)
            {
                if (layout.TryGetOffset(name, out offset))
                {
                    break;
                }
                bufferID++;
            }

            // We must emit code.
            return(new ShaderCompiler.Operand[] {
                compiler.CreateConstant(output.Format, output.Size, bufferID, offset)
            });
        }
Example #13
0
 public override ShaderCompiler.Operand[] Compile(ShaderCompiler compiler, ShaderCompiler.Operand[] operands, FixedShaderParameters parameters, ref DualShareContext shareContext)
 {
     return(new ShaderCompiler.Operand[]
     {
         compiler.Swizzle(operands[0], mask)
     });
 }
Example #14
0
 public abstract ShaderCompiler.Operand[] Compile(ShaderCompiler compiler, ShaderCompiler.Operand[] operands,
                                                  FixedShaderParameters parameters, ref DualShareContext shareContext);