Axiom.RenderSystems.DirectX9.HLSL.HLSLProgram.CompileMicrocode C# (CSharp) Метод

CompileMicrocode() приватный Метод

private CompileMicrocode ( ) : void
Результат void
        private void CompileMicrocode()
	    {
            ConstantTable constantTable = null;
            string errors = null;
            var defines = buildDefines(preprocessorDefines);

            var compileFlags = ShaderFlags.None;
            var parseFlags = ShaderFlags.None;

            parseFlags |= columnMajorMatrices ? ShaderFlags.PackMatrixColumnMajor : ShaderFlags.PackMatrixRowMajor;

#if DEBUG
            compileFlags |= ShaderFlags.Debug;
            parseFlags |= ShaderFlags.Debug;
#endif
            switch (optimizationLevel)
            {
                case OptimizationLevel.Default:
                    compileFlags |= ShaderFlags.OptimizationLevel1;
                    parseFlags |= ShaderFlags.OptimizationLevel1;
                    break;
                case OptimizationLevel.None:
                    compileFlags |= ShaderFlags.SkipOptimization;
                    parseFlags |= ShaderFlags.SkipOptimization;
                    break;
                case OptimizationLevel.LevelZero:
                    compileFlags |= ShaderFlags.OptimizationLevel0;
                    parseFlags |= ShaderFlags.OptimizationLevel0;
                    break;
                case OptimizationLevel.LevelOne:
                    compileFlags |= ShaderFlags.OptimizationLevel1;
                    parseFlags |= ShaderFlags.OptimizationLevel1;
                    break;
                case OptimizationLevel.LevelTwo:
                    compileFlags |= ShaderFlags.OptimizationLevel2;
                    parseFlags |= ShaderFlags.OptimizationLevel2;
                    break;
                case OptimizationLevel.LevelThree:
                    compileFlags |= ShaderFlags.OptimizationLevel3;
                    parseFlags |= ShaderFlags.OptimizationLevel3;
                    break;
            }

            // compile the high level shader to low level microcode
            // note, we need to pack matrices in row-major format for HLSL
            var effectCompiler = new EffectCompiler(Source, defines.ToArray(), includeHandler, parseFlags);
	       

            try
            {
                microcode = effectCompiler.CompileShader(new EffectHandle(entry),
                                                          target,
                                                          compileFlags,
                                                          out errors,
                                                          out constantTable);
            }
            catch (Direct3D9Exception ex)
            {
                throw new AxiomException("HLSL: Unable to compile high level shader {0}:\n{1}", ex, Name);
            }
            finally
            {
                // check for errors
                if ( !String.IsNullOrEmpty( errors ) )
                {
                    if ( microcode != null )
                    {
                        if ( LogManager.Instance != null )
                        {
                            LogManager.Instance.Write( "HLSL: Warnings while compiling high level shader {0}:\n{1}",
                                                       Name, errors );
                        }
                    }
                    else
                    {
                        throw new AxiomException( "HLSL: Unable to compile high level shader {0}:\n{1}", Name, errors );
                    }
                }


                // Get contents of the constant table
                var desc = constantTable.Description;
                CreateParameterMappingStructures( true );


                // Iterate over the constants
                for ( var i = 0; i < desc.Constants; ++i )
                {
                    // Recursively descend through the structure levels
                    ProcessParamElement( constantTable, null, "", i );
                }

                constantTable.Dispose();

                /*
                if ( GpuProgramManager.Instance.SaveMicrocodesToCache )
                {
                    AddMicrocodeToCache();
                }*/

                effectCompiler.Dispose();
            }

	    }