コード例 #1
0
 public PhysicsDebugEffect(GraphicsDevice graphicsDevice)
     : base(graphicsDevice, bytecode ?? (bytecode = EffectBytecode.FromBytesSafe(binaryBytecode)))
 {
     parameters = new ParameterCollection();
     Color = new Color4(1.0f);
     WorldViewProj = Matrix.Identity;
     UseUv = true;
 }
コード例 #2
0
ファイル: EffectProgram.cs プロジェクト: Powerino73/paradox
 public EffectProgram GetOrCreateShader(GraphicsDevice graphicsDevice, EffectBytecode bytecode)
 {
     lock (ShaderLibrary)
     {
         EffectProgram effectProgram;
         if (!ShaderLibrary.TryGetValue(bytecode, out effectProgram))
         {
             effectProgram = new EffectProgram(graphicsDevice, bytecode);
             ShaderLibrary.Add(bytecode, effectProgram);
         }
         return effectProgram;
     }
 }
コード例 #3
0
        private EffectProgram(GraphicsDevice device, EffectBytecode bytecode)
            : base(device)
        {
            effectBytecode = bytecode;

            // make a copy of the effect's reflection before modifying it.
            Reflection = new EffectReflection
            {
                // The members that are not modified and can be shallowly copied.
                SamplerStates = effectBytecode.Reflection.SamplerStates,
                ShaderStreamOutputDeclarations = effectBytecode.Reflection.ShaderStreamOutputDeclarations,
                StreamOutputRasterizedStream = effectBytecode.Reflection.StreamOutputRasterizedStream,
                StreamOutputStrides = effectBytecode.Reflection.StreamOutputStrides,

                // The members that are modified and should be deeply copied.
                ConstantBuffers = effectBytecode.Reflection.ConstantBuffers.Select(cb => cb.Clone()).ToList(),
                ResourceBindings = new List<EffectParameterResourceData>(effectBytecode.Reflection.ResourceBindings),
            };

            CreateShaders();
        }
コード例 #4
0
 private EffectProgram(GraphicsDevice device, EffectBytecode bytecode)
     : base(device)
 {
     effectBytecode = bytecode;
     CreateShaders();
 }
コード例 #5
0
        public static void Write(string name, CompilerParameters parameters, EffectBytecode effectData, TextWriter writer)
        {
            const string codeTemplate = @"//------------------------------------------------------------------------------
// <auto-generated>
//     Paradox Effect Compiler File Generated:
{0}//
//     Command Line: {7}
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace {1} 
{{
    {2} class {3}
    {{
        {4} static readonly byte[] {5} = new byte[] {{
{6}
        }};
    }}
}}
";
            var effectToGenerateText = new StringBuilder();
            effectToGenerateText.AppendFormat("//     Effect [{0}]\r\n", name);

            var buffer = new MemoryStream();
            effectData.WriteTo(buffer);

            var bufferAsText = new StringBuilder();
            var bufferArray = buffer.ToArray();
            for (int i = 0; i < bufferArray.Length; i++)
            {
                bufferAsText.Append(bufferArray[i]).Append(", ");
                if (i > 0 && (i % 64) == 0)
                {
                    bufferAsText.AppendLine();
                }
            }

            var classDeclaration = parameters.Get(EffectSourceCodeKeys.ClassDeclaration);
            var fieldDeclaration = parameters.Get(EffectSourceCodeKeys.FieldDeclaration);
            var nameSpace = parameters.Get(EffectSourceCodeKeys.Namespace);
            var className = parameters.Get(EffectSourceCodeKeys.ClassName) ?? name;
            var fieldName = parameters.Get(EffectSourceCodeKeys.FieldName);

            var commandLine = string.Join(" ", Environment.GetCommandLineArgs());

            var graphicsPlatform = parameters.Get(CompilerParameters.GraphicsPlatformKey);
            string paradoxDefine = "undefined";
            switch (graphicsPlatform)
            {
                case GraphicsPlatform.Direct3D11:
                    paradoxDefine = "SILICONSTUDIO_PARADOX_GRAPHICS_API_DIRECT3D11";
                    break;
                case GraphicsPlatform.OpenGL:
                    paradoxDefine = "SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLCORE";
                    break;
                case GraphicsPlatform.OpenGLES:
                    paradoxDefine = "SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES";
                    break;
            }

            writer.WriteLine("#if {0}", paradoxDefine);
            writer.Write(codeTemplate,
                         effectToGenerateText, // {0} 
                         nameSpace,            // {1} 
                         classDeclaration,     // {2} 
                         className,            // {3} 
                         fieldDeclaration,     // {4} 
                         fieldName,            // {5} 
                         bufferAsText,         // {6}
                         commandLine);         // {7}

            writer.WriteLine("#endif");

            writer.Flush();
        }
コード例 #6
0
ファイル: EffectProgram.cs プロジェクト: Powerino73/paradox
 public static EffectProgram New(GraphicsDevice graphicsDevice, EffectBytecode bytecode)
 {
     var effectProgramLibrary = graphicsDevice.GetOrCreateSharedData(GraphicsDeviceSharedDataType.PerDevice, typeof(EffectProgram), d => new EffectProgramLibrary());
     return effectProgramLibrary.GetOrCreateShader(graphicsDevice, bytecode);
 }