Beispiel #1
0
        private void AddProgramProcessor(ProgramProcessor processor)
        {
            if (this.programProcessorMap.ContainsKey(processor.TargetLanguage))
            {
                throw new AxiomException("A processor for language " + processor.TargetLanguage + " already exists");
            }

            this.programProcessorMap.Add(processor.TargetLanguage, processor);
        }
Beispiel #2
0
        internal override bool PreCreateGpuPrograms(ProgramSet programSet)
        {
            Program  vsProgram = programSet.CpuVertexProgram;
            Program  fsProgram = programSet.CpuFragmentProgram;
            Function vsMain    = vsProgram.EntryPointFunction;
            Function fsMain    = fsProgram.EntryPointFunction;
            bool     success;

            //compact vertex shader outputs.
            success = ProgramProcessor.CompactVsOutputs(vsMain, fsMain);
            if (success == false)
            {
                return(false);
            }

            return(true);
        }
Beispiel #3
0
 private void RemoveProgramProcessor(ProgramProcessor processor)
 {
     this.programProcessorMap.Remove(processor.TargetLanguage);
 }
Beispiel #4
0
        private bool CreateGpuPrograms(ProgramSet programSet)
        {
            // Before we start we need to make sure that the pixel shader input
            //  parameters are the same as the vertex output, this required by
            //  shader models 4 and 5.
            // This change may incrase the number of register used in older shader
            //  models - this is why the check is present here.
            bool isVs4 = GpuProgramManager.Instance.IsSyntaxSupported("vs_4_0");

            if (isVs4)
            {
                SynchronizePixelnToBeVertexOut(programSet);
            }

            //Grab the matching writer
            string        language      = ShaderGenerator.Instance.TargetLangauge;
            ProgramWriter programWriter = null;

            if (this.programWritersMap.ContainsKey(language))
            {
                programWriter = this.programWritersMap[language];
            }
            else
            {
                programWriter = ProgramWriterManager.Instance.CreateProgramWriter(language);
                this.programWritersMap.Add(language, programWriter);
            }

            ProgramProcessor programProcessor = null;

            if (this.programProcessorMap.ContainsKey(language) == false)
            {
                throw new AxiomException("Could not find processor for language " + language);
            }

            programProcessor = this.programProcessorMap[language];


            bool success;

            //Call the pre creation of GPU programs method
            success = programProcessor.PreCreateGpuPrograms(programSet);
            if (success == false)
            {
                return(false);
            }

            //Create the vertex shader program
            GpuProgram vsGpuProgram;

            vsGpuProgram = CreateGpuProgram(programSet.CpuVertexProgram, programWriter, language,
                                            ShaderGenerator.Instance.VertexShaderProfiles,
                                            ShaderGenerator.Instance.VertexShaderProfilesList,
                                            ShaderGenerator.Instance.ShaderChachePath);

            if (vsGpuProgram == null)
            {
                return(false);
            }

            programSet.GpuVertexProgram = vsGpuProgram;

            //update flags
            programSet.GpuVertexProgram.IsSkeletalAnimationIncluded =
                programSet.CpuVertexProgram.SkeletalAnimationIncluded;

            //Create the fragment shader program.
            GpuProgram psGpuProgram;

            psGpuProgram = CreateGpuProgram(programSet.CpuFragmentProgram, programWriter, language,
                                            ShaderGenerator.Instance.FragmentShaderProfiles,
                                            ShaderGenerator.Instance.FragmentShaderProfilesList,
                                            ShaderGenerator.Instance.ShaderChachePath);

            if (psGpuProgram == null)
            {
                return(false);
            }

            programSet.GpuFragmentProgram = psGpuProgram;

            //Call the post creation of GPU programs method.
            success = programProcessor.PostCreateGpuPrograms(programSet);
            if (success == false)
            {
                return(false);
            }

            return(true);
        }
Beispiel #5
0
		private void RemoveProgramProcessor( ProgramProcessor processor )
		{
			this.programProcessorMap.Remove( processor.TargetLanguage );
		}
Beispiel #6
0
		private void AddProgramProcessor( ProgramProcessor processor )
		{
			if ( this.programProcessorMap.ContainsKey( processor.TargetLanguage ) )
			{
				throw new AxiomException( "A processor for language " + processor.TargetLanguage + " already exists" );
			}

			this.programProcessorMap.Add( processor.TargetLanguage, processor );
		}