Esempio n. 1
0
        public GLGpuProgram Create(ResourceManager parent, string name, ResourceHandle handle, string group, bool isManual,
                                   IManualResourceLoader loader, GpuProgramType type, string syntaxCode)
        {
            GLGpuProgram ret = new ARBGpuProgram(parent, name, handle, group, isManual, loader);

            ret.Type       = type;
            ret.SyntaxCode = syntaxCode;
            return(ret);
        }
Esempio n. 2
0
        public virtual ResourcePtr create(string name, string group, GpuProgramType gptype, string syntaxCode)
        {
            ResourcePtr ret = new ResourcePtr(OgrePINVOKE.GpuProgramManager_create__SWIG_2(swigCPtr, name, group, (int)gptype, syntaxCode), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Esempio n. 3
0
        public Program(GpuProgramType type)
        {
            this.type                 = type;
            EntryPointFunction        = null;
            SkeletalAnimationIncluded = false;

            this.functions    = new List <Function>();
            this.dependencies = new List <string>();
            this.parameters   = new List <UniformParameter>();
        }
Esempio n. 4
0
 public GpuProgramUsage(GpuProgramUsage oth, Pass parent)
     : base()
 {
     this.type    = oth.type;
     this.parent  = parent;
     this.program = oth.Program;
     // nfz: parameters should be copied not just use a shared ptr to the original
     this.parameters     = new GpuProgramParameters(oth.parameters);
     this.recreateParams = false;
 }
Esempio n. 5
0
        public uint getShaderCount(GpuProgramType type)
        {
            uint ret = RTShaderPINVOKE.ShaderGenerator_getShaderCount(swigCPtr, (int)type);

            if (RTShaderPINVOKE.SWIGPendingException.Pending)
            {
                throw RTShaderPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Esempio n. 6
0
		public Program( GpuProgramType type )
		{
			this.type = type;
			EntryPointFunction = null;
			SkeletalAnimationIncluded = false;

			this.functions = new List<Function>();
			this.dependencies = new List<string>();
			this.parameters = new List<UniformParameter>();
		}
Esempio n. 7
0
        public StringVector getShaderProfilesList(GpuProgramType type)
        {
            StringVector ret = new StringVector(RTShaderPINVOKE.ShaderGenerator_getShaderProfilesList(swigCPtr, (int)type), false);

            if (RTShaderPINVOKE.SWIGPendingException.Pending)
            {
                throw RTShaderPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Esempio n. 8
0
        public static string getProgramTypeName(GpuProgramType programType)
        {
            string ret = OgrePINVOKE.GpuProgram_getProgramTypeName((int)programType);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        public NV3xGpuProgram(string name, GpuProgramType type, string syntaxCode)
            : base(name, type, syntaxCode)
        {
            // generate the program and store the unique name
            Gl.glGenProgramsNV(1, out programId);

            // find the GL enum for the type of program this is
            programType = (type == GpuProgramType.Vertex) ?
                Gl.GL_VERTEX_PROGRAM_NV : Gl.GL_FRAGMENT_PROGRAM_NV;
        }
Esempio n. 10
0
        public GpuProgramType getType()
        {
            GpuProgramType ret = (GpuProgramType)OgrePINVOKE.GpuProgram_getType(swigCPtr);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        public string getProgramTypeName(GpuProgramType programType)
        {
            string ret = OgrePINVOKE.HighLevelGpuProgramPtr_getProgramTypeName(swigCPtr, (int)programType);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Esempio n. 12
0
        public NV3xGpuProgram(string name, GpuProgramType type, string syntaxCode)
            : base(name, type, syntaxCode)
        {
            // generate the program and store the unique name
            Gl.glGenProgramsNV(1, out programId);

            // find the GL enum for the type of program this is
            programType = (type == GpuProgramType.Vertex) ?
                          Gl.GL_VERTEX_PROGRAM_NV : Gl.GL_FRAGMENT_PROGRAM_NV;
        }
        public GLGpuProgram Create(ResourceManager parent, string name, ResourceHandle handle, string group, bool isManual,
                                   IManualResourceLoader loader, GpuProgramType type, string syntaxCode)
        {
            // creates and returns a new ATI fragment shader implementation
            GLGpuProgram ret = new ATIFragmentShaderGpuProgram(parent, name, handle, group, isManual, loader);

            ret.Type       = type;
            ret.SyntaxCode = syntaxCode;
            return(ret);
        }
Esempio n. 14
0
        public string getShaderProfiles(GpuProgramType type)
        {
            string ret = RTShaderPINVOKE.ShaderGenerator_getShaderProfiles(swigCPtr, (int)type);

            if (RTShaderPINVOKE.SWIGPendingException.Pending)
            {
                throw RTShaderPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Esempio n. 15
0
		protected override Resource _create( string name, ResourceHandle handle, string group, bool isManual, IManualResourceLoader loader, GpuProgramType type, string syntaxCode )
		{
			if ( type == GpuProgramType.Vertex )
			{
				return new D3DVertexProgram( this, name, handle, group, isManual, loader, device );
			}
			else
			{
				return new D3DFragmentProgram( this, name, handle, group, isManual, loader, device );
			}
		}
 public CreateGpuProgramScriptCompilerEvent(string file, string name, string resGroup, string source, string syntax,
                                            GpuProgramType prgType)
     : base(CompilerEventType.CreateGpuProgram)
 {
     this.File          = file;
     this.Name          = name;
     this.ResourceGroup = resGroup;
     this.Source        = source;
     this.Syntax        = syntax;
     this.ProgramType   = prgType;
 }
 public CreateHighLevelGpuProgramScriptCompilerEvent(string file, string name, string resGroup, string source,
                                                     string language, GpuProgramType prgType)
     : base(CompilerEventType.CreateHighLevelGpuProgram)
 {
     this.File          = file;
     this.Name          = name;
     this.ResourceGroup = resGroup;
     this.Source        = source;
     this.Language      = language;
     this.ProgramType   = prgType;
 }
        /// <summary>
        ///    Create the specified type of GpuProgram.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public override GpuProgram Create(string name, GpuProgramType type, string syntaxCode)
        {
            switch(type) {
                case GpuProgramType.Vertex:
                    return new D3DVertexProgram(name, device, syntaxCode);

                case GpuProgramType.Fragment:
                    return new D3DFragmentProgram(name, device, syntaxCode);
                default:
                    throw new NotSupportedException("The program type is not supported.");
            }
        }
Esempio n. 19
0
        public static GLenum GetGLShaderType(GpuProgramType programType)
        {
            switch (programType)
            {
            case GpuProgramType.Vertex:
            default:
                return(GLenum.VertexShader);

            case GpuProgramType.Fragment:
                return(GLenum.FragmentShader);
            }
        }
Esempio n. 20
0
		public static GLenum GetGLShaderType( GpuProgramType programType )
		{
			switch ( programType )
			{
				case GpuProgramType.Vertex:
				default:
					return GLenum.VertexShader;

				case GpuProgramType.Fragment:
					return GLenum.FragmentShader;
			}
		}
Esempio n. 21
0
 protected override Resource _create(string name, ResourceHandle handle, string group, bool isManual,
                                     IManualResourceLoader loader, GpuProgramType type, string syntaxCode)
 {
     if (type == GpuProgramType.Vertex)
     {
         return(new D3D9GpuVertexProgram(this, name, handle, group, isManual, loader));
     }
     else
     {
         return(new D3D9GpuFragmentProgram(this, name, handle, group, isManual, loader));
     }
 }
Esempio n. 22
0
        protected void _setProgramParameter(GpuProgramType type, String paramName, Object value, int sizeInBytes)
        {
            switch (type)
            {
            case GpuProgramType.Vertex:
                _updateParameter(vertexProgramUsage.Parameters, paramName, value, sizeInBytes);
                break;

            case GpuProgramType.Fragment:
                _updateParameter(fragmentProgramUsage.Parameters, paramName, value, sizeInBytes);
                break;
            }
        }
Esempio n. 23
0
        public virtual GpuProgram Create(string name, string group, GpuProgramType type, string syntaxCode, bool isManual,
                                         IManualResourceLoader loader)
#endif
        {
            // Call creation implementation
            var ret =
                (GpuProgram)_create(name, (ResourceHandle)name.ToLower().GetHashCode(), group, isManual, loader, type, syntaxCode);

            _add(ret);
            // Tell resource group manager
            ResourceGroupManager.Instance.notifyResourceCreated(ret);
            return(ret);
        }
Esempio n. 24
0
        public void Export(ShaderWriter writer, ref ShaderSubProgramBlob blob, ShaderType type, bool isTier)
        {
            writer.WriteIndent(4);
#warning TODO: convertion (DX to HLSL)
            writer.Write("SubProgram \"{0} ", GpuProgramType.ToGPUPlatform(writer.Platform));
            if (isTier)
            {
                writer.Write("hw_tier{0} ", ShaderHardwareTier.ToString("00"));
            }
            writer.Write("\" {\n");
            writer.WriteIndent(5);

            ref ShaderSubProgram subProgram = ref blob.SubPrograms[(int)BlobIndex];
Esempio n. 25
0
        /// <summary>
        ///    Create the specified type of GpuProgram.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public override GpuProgram Create(string name, GpuProgramType type, string syntaxCode)
        {
            switch (type)
            {
            case GpuProgramType.Vertex:
                return(new D3DVertexProgram(name, device, syntaxCode));

            case GpuProgramType.Fragment:
                return(new D3DFragmentProgram(name, device, syntaxCode));

            default:
                throw new NotSupportedException("The program type is not supported.");
            }
        }
Esempio n. 26
0
        public static int ConvertEnum(GpuProgramType type)
        {
            switch (type)
            {
            case GpuProgramType.Vertex:
                return(Gl.GL_VERTEX_PROGRAM_ARB);

            case GpuProgramType.Fragment:
                return(Gl.GL_FRAGMENT_PROGRAM_ARB);
            }

            // make the compiler happy
            return(0);
        }
        /// <summary>
        ///    Create the specified type of GpuProgram.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public override GpuProgram Create(string name, GpuProgramType type, string syntaxCode)
        {
            // if there is none, this syntax code must not be supported
            // just return the base GL program since it won't be doing anything anyway
            if(factories[syntaxCode] == null) {
                return new GLGpuProgram(name, type, syntaxCode);
            }

            // get a reference to the factory for this syntax code
            IOpenGLGpuProgramFactory factory =
                (IOpenGLGpuProgramFactory)factories[syntaxCode];

            // create the gpu program
            return factory.Create(name, type, syntaxCode);
        }
Esempio n. 28
0
        public virtual GpuProgram Load(string name, string group, string fileName, GpuProgramType type, string syntaxCode)
        {
            lock ( _autoMutex )
            {
                var program = GetByName(name);

                if (program == null)
                {
                    program = CreateProgram(name, group, fileName, type, syntaxCode);
                }

                program.Load();
                return(program);
            }
        }
Esempio n. 29
0
        protected override Resource _create(string name, ulong handle, string group, bool isManual,
                                            IManualResourceLoader loader, GpuProgramType type, string syntaxCode)
        {
            // if there is none, this syntax code must not be supported
            // just return the base GL program since it won't be doing anything anyway
            if (this.factories[syntaxCode] == null)
            {
                return(new GLGpuProgram(this, name, handle, group, isManual, loader));
            }

            // get a reference to the factory for this syntax code
            var factory = (IOpenGLGpuProgramFactory)this.factories[syntaxCode];

            // create the gpu program
            return(factory.Create(this, name, handle, group, isManual, loader, type, syntaxCode));
        }
Esempio n. 30
0
        /// <summary>
        ///    Creates a new, unloaded HighLevelGpuProgram instance.
        /// </summary>
        /// <remarks>
        ///    This method creates a new program of the type specified as the second and third parameters.
        ///    You will have to call further methods on the returned program in order to
        ///    define the program fully before you can load it.
        /// </remarks>
        /// <param name="name">Name of the program to create.</param>
        /// <param name="language">HLSL language to use.</param>
        /// <param name="type">Type of program, i.e. vertex or fragment.</param>
        /// <returns>An unloaded instance of HighLevelGpuProgram.</returns>
        public HighLevelGpuProgram CreateProgram(string name, string language, GpuProgramType type)
        {
            // lookup the factory for the requested program language
            IHighLevelGpuProgramFactory factory = GetFactory(language);

            if (factory == null)
            {
                throw new Exception(string.Format("Could not find HighLevelGpuProgramManager that can compile programs of type '{0}'", language));
            }

            // create the high level program using the factory
            HighLevelGpuProgram program = factory.Create(name, type);

            Add(program);
            return(program);
        }
Esempio n. 31
0
        protected GpuProgram(ResourceManager parent, string name, ResourceHandle handle, string group, bool isManual,
                             IManualResourceLoader loader)
            : base(parent, name, handle, group, isManual, loader)
        {
            this.type    = GpuProgramType.Vertex;
            LoadFromFile = true;
            this.isSkeletalAnimationIncluded = false;
            this.morphAnimation             = false;
            this.poseAnimation              = 0;
            this.vertexTextureFetchRequired = false;
            this.needsAdjacencyInfo         = false;
            this.compileError = false;
            this._loadedManualNamedConstants = false;

            CreateParameterMappingStructures();
        }
Esempio n. 32
0
        /// <summary>
        ///    Create the specified type of GpuProgram.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public override GpuProgram Create(string name, GpuProgramType type, string syntaxCode)
        {
            // if there is none, this syntax code must not be supported
            // just return the base GL program since it won't be doing anything anyway
            if (factories[syntaxCode] == null)
            {
                return(new GLGpuProgram(name, type, syntaxCode));
            }

            // get a reference to the factory for this syntax code
            IOpenGLGpuProgramFactory factory =
                (IOpenGLGpuProgramFactory)factories[syntaxCode];

            // create the gpu program
            return(factory.Create(name, type, syntaxCode));
        }
Esempio n. 33
0
        public void Export(ShaderWriter writer, ShaderSubProgramBlob blob, bool isTier)
        {
            writer.WriteIntent(4);
            writer.Write("SubProgram \"{0} ", GpuProgramType.ToGPUPlatform(writer.Platform));
            if (isTier)
            {
                writer.Write("hw_tier{0} ", ShaderHardwareTier.ToString("00"));
            }
            writer.Write("\" {\n");
            writer.WriteIntent(5);

            blob.SubPrograms[(int)BlobIndex].Export(writer);

            writer.Write('\n');
            writer.WriteIntent(4);
            writer.Write("}\n");
        }
        public void Export(TextWriter writer, ShaderSubProgramBlob blob, Platform platform, bool isTier, Func <ShaderGpuProgramType, ShaderTextExporter> exporterInstantiator)
        {
            writer.WriteIntent(4);
            writer.Write("SubProgram \"{0} ", GpuProgramType.ToGPUPlatform(platform));
            if (isTier)
            {
                writer.Write("hw_tier{0} ", ShaderHardwareTier.ToString("00"));
            }
            writer.Write("\" {\n");
            writer.WriteIntent(5);

            blob.SubPrograms[(int)BlobIndex].Export(writer, exporterInstantiator);

            writer.Write('\n');
            writer.WriteIntent(4);
            writer.Write("}\n");
        }
Esempio n. 35
0
        /// <summary>
        ///		Constructor.
        /// </summary>
        public GLSLProgram(string name, GpuProgramType type, string language) : base(name, type, language)
        {
            // want scenemanager to pass on surface and light states to the rendersystem
            // these can be accessed in GLSL
            passSurfaceAndLightStates = true;

            // only create a shader object if glsl is supported
            if (IsSupported)
            {
                GLSLHelper.CheckForGLSLError("GL Errors before creating shader object.", 0);

                // create shader object
                glHandle = Gl.glCreateShaderObjectARB(type == GpuProgramType.Vertex ? Gl.GL_VERTEX_SHADER_ARB : Gl.GL_FRAGMENT_SHADER_ARB);

                GLSLHelper.CheckForGLSLError("GL Errors creating shader object.", 0);
            }
        }
        /// <summary>
        ///		Constructor.
        /// </summary>
        public GLSLProgram(string name, GpuProgramType type, string language)
            : base(name, type, language)
        {
            // want scenemanager to pass on surface and light states to the rendersystem
            // these can be accessed in GLSL
            passSurfaceAndLightStates = true;

            // only create a shader object if glsl is supported
            if(IsSupported) {
                GLSLHelper.CheckForGLSLError("GL Errors before creating shader object.", 0);

                // create shader object
                glHandle = Gl.glCreateShaderObjectARB(type == GpuProgramType.Vertex ? Gl.GL_VERTEX_SHADER_ARB : Gl.GL_FRAGMENT_SHADER_ARB);

                GLSLHelper.CheckForGLSLError("GL Errors creating shader object.", 0);
            }
        }
Esempio n. 37
0
        public StringBuilder ToString(StringBuilder sb, ShaderSubProgramBlob blob, bool isTier)
        {
            sb.AppendIntent(4).Append("SubProgram").Append(' ');
            sb.Append('"').Append(GpuProgramType.ToGPUPlatform(m_assetsFile.Platform)).Append(' ');
            if (isTier)
            {
                sb.Append("hw_tier").Append(ShaderHardwareTier.ToString("00")).Append(' ');
            }
            sb.Append('"').Append(' ').Append('{').Append('\n');
            sb.AppendIntent(5);

            blob.SubPrograms[(int)BlobIndex].ToString(sb);

            sb.Append('\n');
            sb.AppendIntent(4).Append('}').Append('\n');
            return(sb);
        }
Esempio n. 38
0
        /// <summary>
        ///    Create the specified type of GpuProgram.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        protected override Resource _create( string name, ResourceHandle handle, string group, bool isManual, IManualResourceLoader loader, GpuProgramType type, string syntaxCode )
        {
            switch ( type )
            {
                case GpuProgramType.Vertex:
                    return new XnaVertexProgram( this, name, handle, group, isManual, loader, device );
                case GpuProgramType.Fragment:
                    return new XnaFragmentProgram( this, name, handle, group, isManual, loader, device );
				
                default:
                    throw new NotSupportedException( "The program type is not supported." );
            }
        }
Esempio n. 39
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="name"></param>
		/// <param name="handle"></param>
		/// <param name="group"></param>
		/// <param name="isManual"></param>
		/// <param name="loader"></param>
		/// <param name="type"></param>
		/// <param name="syntaxCode"></param>
		/// <returns></returns>
		protected override Resource _create( string name, ulong handle, string group, bool isManual, IManualResourceLoader loader, GpuProgramType type, string syntaxCode )
		{
			return new DummyGpuProgram( this, name, handle, group, isManual, loader );
		}
Esempio n. 40
0
        public override void UnbindGpuProgram( GpuProgramType type )
        {
            switch ( type )
            {
                case GpuProgramType.Vertex:
                    activeVertexGpuProgramParameters = null;
                    ActiveD3D9Device.VertexShader = null;
                    break;

                case GpuProgramType.Fragment:
                    activeFragmentGpuProgramParameters = null;
                    ActiveD3D9Device.PixelShader = null;
                    break;
            }

            base.UnbindGpuProgram( type );
        }
Esempio n. 41
0
		public override void BindGpuProgramParameters( GpuProgramType type, GpuProgramParameters parms, GpuProgramParameters.GpuParamVariability mask )
		{
			if ( ( mask & GpuProgramParameters.GpuParamVariability.Global ) == GpuProgramParameters.GpuParamVariability.Global )
			{
				//Just copy
				parms.CopySharedParams();
			}

			switch ( type )
			{
				case GpuProgramType.Vertex:
					activeVertexGpuProgramParameters = parms;
					this.currentVertexProgram.BindProgramParameters( parms, (uint) mask );
					break;
				case GpuProgramType.Fragment:
					activeFragmentGpuProgramParameters = parms;
					this.currentFragmentProgram.BindProgramParameters( parms, (uint) mask );
					break;
				case GpuProgramType.Geometry:
				default:
					break;
			}
		}
Esempio n. 42
0
		protected void _setProgramParameter( GpuProgramType type, String paramName, Axiom.Math.Matrix4 value )
		{
			unsafe
			{
				_setProgramParameter( type, paramName, value, sizeof( Axiom.Math.Matrix4 ) );
			}
		}
		public CreateHighLevelGpuProgramScriptCompilerEvent( string file, string name, string resGroup, string source,
			string language, GpuProgramType prgType )
			: base( CompilerEventType.CreateHighLevelGpuProgram )
		{
			File = file;
			Name = name;
			ResourceGroup = resGroup;
			Source = source;
			Language = language;
			ProgramType = prgType;
		}
		public CreateGpuProgramScriptCompilerEvent( string file, string name, string resGroup, string source,
			string syntax, GpuProgramType prgType )
			: base( CompilerEventType.CreateGpuProgram )
		{
			File = file;
			Name = name;
			ResourceGroup = resGroup;
			Source = source;
			Syntax = syntax;
			ProgramType = prgType;
		}
Esempio n. 45
0
		protected void _setProgramParameter( GpuProgramType type, String paramName, Object value, int sizeInBytes )
		{
			switch ( type )
			{
				case GpuProgramType.Vertex:
					_updateParameter( vertexProgramUsage.Params, paramName, value, sizeInBytes );
					break;
				case GpuProgramType.Fragment:
					_updateParameter( fragmentProgramUsage.Params, paramName, value, sizeInBytes );
					break;
			}
		}
Esempio n. 46
0
		protected void _setProgramParameter( GpuProgramType type, String paramName, Axiom.Math.Vector3 value )
		{
			_setProgramParameter( type, paramName, value, sizeof( float ) * 3 );
		}
Esempio n. 47
0
		protected void _setProgramParameter( GpuProgramType type, String paramName, Axiom.Core.ColorEx value )
		{
			_setProgramParameter( type, paramName, value, sizeof( float ) * 4 );
		}
Esempio n. 48
0
 public GpuProgramUsage(GpuProgramUsage oth, Pass parent)
 {
     type = oth.type;
     this.parent = parent;
     program = oth.Program;
     // nfz: parameters should be copied not just use a shared ptr to the original
     parameters = new GpuProgramParameters( oth.parameters );
     recreateParams = false;
 }
Esempio n. 49
0
 public override void BindGpuProgramPassIterationParameters(GpuProgramType gptype)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 ///    Default constructor.
 /// </summary>
 /// <param name="type">Type of program to link to.</param>
 public GpuProgramUsage(GpuProgramType type)
 {
     this.type = type;
 }
Esempio n. 51
0
		protected override Resource _create( string name, ulong handle, string group, bool isManual,
		                                     IManualResourceLoader loader, GpuProgramType type, string syntaxCode )
		{
			// if there is none, this syntax code must not be supported
			// just return the base GL program since it won't be doing anything anyway
			if ( this.factories[ syntaxCode ] == null )
			{
				return new GLGpuProgram( this, name, handle, group, isManual, loader );
			}

			// get a reference to the factory for this syntax code
			var factory = (IOpenGLGpuProgramFactory)this.factories[ syntaxCode ];

			// create the gpu program
			return factory.Create( this, name, handle, group, isManual, loader, type, syntaxCode );
		}
Esempio n. 52
0
		protected void _setProgramParameter( GpuProgramType type, String paramName, float value )
		{
			_setProgramParameter( type, paramName, value, sizeof( float ) );
		}
        /// <summary>
        ///    Creates a new, unloaded HighLevelGpuProgram instance.
        /// </summary>
        /// <remarks>
        ///    This method creates a new program of the type specified as the second and third parameters.
        ///    You will have to call further methods on the returned program in order to 
        ///    define the program fully before you can load it.
        /// </remarks>
        /// <param name="name">Name of the program to create.</param>
        /// <param name="language">HLSL language to use.</param>
        /// <param name="type">Type of program, i.e. vertex or fragment.</param>
        /// <returns>An unloaded instance of HighLevelGpuProgram.</returns>
        public HighLevelGpuProgram CreateProgram(string name, string language, GpuProgramType type)
        {
            // lookup the factory for the requested program language
            IHighLevelGpuProgramFactory factory = GetFactory(language);

            if(factory == null) {
                throw new Exception(string.Format("Could not find HighLevelGpuProgramManager that can compile programs of type '{0}'", language));
            }

            // create the high level program using the factory
            HighLevelGpuProgram program = factory.Create(name, type);
            Add(program);
            return program;
        }
		public GLGpuProgram Create( ResourceManager parent, string name, ResourceHandle handle, string group, bool isManual, IManualResourceLoader loader, GpuProgramType type, string syntaxCode )
		{
			GLGpuProgram ret = new NvparseFragmentProgram( parent, name, handle, group, isManual, loader );
			ret.SyntaxCode = syntaxCode;
			ret.Type = type;
			return ret;
		}
		protected override Resource _create( string name, ulong handle, string group, bool isManual, IManualResourceLoader loader, GpuProgramType type, string syntaxCode )
		{
			CreateGpuProgramDelegate iter = null;

			if ( this._programMap.ContainsKey( syntaxCode ) == false )
			{
				//No factory, this is an unsupported syntax code, probably for another rendersystem
				//Create a basic one, it doens't matter what it is since it won't be used
				return new GLES2GpuProgram( this, name, handle, group, isManual, loader );
			}
			else
			{
				iter = this._programMap[ syntaxCode ];
			}
			return iter( this, name, handle, group, isManual, loader, type, syntaxCode );
		}
Esempio n. 56
0
        public override void BindGpuProgramParameters(GpuProgramType gptype, GpuProgramParameters parms, GpuProgramParameters.GpuParamVariability variability)
        {
            // special case pass iteration
            if (variability == GpuProgramParameters.GpuParamVariability.PassIterationNumber)
            {
                BindGpuProgramPassIterationParameters(gptype);
                return;
            }

            if ((variability & GpuProgramParameters.GpuParamVariability.Global) != 0)
            {
                // D3D9 doesn't support shared constant buffers, so use copy routine
                parms.CopySharedParams();
            }

            switch ( gptype )
            {
                case GpuProgramType.Vertex:
                    activeVertexGpuProgramParameters = parms;

                    if ( parms.HasFloatConstants )
                    {
                        for ( var index = 0; index < parms.FloatConstantCount; index++ )
                        {
                            var entry = parms.GetFloatConstant( index );

                            if ( entry.isSet )
                            {
                                ActiveD3D9Device.SetVertexShaderConstant(index, entry.val, 0, 1);
                            }
                        }
                    }
                    if (parms.HasIntConstants)
                    {
                        for (var index = 0; index < parms.IntConstantCount; index++)
                        {
                            var entry = parms.GetIntConstant(index);

                            if (entry.isSet)
                            {
                                ActiveD3D9Device.SetVertexShaderConstant(index, entry.val, 0, 1);
                            }
                        }
                    }

                    break;

                case GpuProgramType.Fragment:
                    activeFragmentGpuProgramParameters = parms;

                    if (parms.HasFloatConstants)
                    {
                        for (var index = 0; index < parms.FloatConstantCount; index++)
                        {
                            var entry = parms.GetFloatConstant(index);

                            if (entry.isSet)
                            {
                                ActiveD3D9Device.SetPixelShaderConstant(index, entry.val, 0, 1);
                            }
                        }
                    }
                    if ( parms.HasIntConstants )
                    {
                        for ( var index = 0; index < parms.IntConstantCount; index++ )
                        {
                            var entry = parms.GetIntConstant( index );

                            if ( entry.isSet )
                            {
                                ActiveD3D9Device.SetPixelShaderConstant(index, entry.val, 0, 1);
                            }
                        }
                    }

                    
                    break;
            }
        }
Esempio n. 57
0
		public override void UnbindGpuProgram( GpuProgramType type )
		{
			if ( type == GpuProgramType.Vertex && this.currentVertexProgram != null )
			{
				activeVertexGpuProgramParameters = null;
				this.currentVertexProgram.UnbindProgram();
				this.currentVertexProgram = null;
			}
			else if ( type == GpuProgramType.Fragment && this.currentFragmentProgram != null )
			{
				activeFragmentGpuProgramParameters = null;
				this.currentFragmentProgram.UnbindProgram();
				this.currentFragmentProgram = null;
			}

			base.UnbindGpuProgram( type );
		}
		/// <summary>
		///    Creates a new, unloaded HighLevelGpuProgram instance.
		/// </summary>
		/// <remarks>
		///    This method creates a new program of the type specified as the second and third parameters.
		///    You will have to call further methods on the returned program in order to
		///    define the program fully before you can load it.
		/// </remarks>
		/// <param name="name">Name of the program to create.</param>
		/// <param name="group"></param>
		/// <param name="language">HLSL language to use.</param>
		/// <param name="type">Type of program, i.e. vertex or fragment.</param>
		/// <returns>An unloaded instance of HighLevelGpuProgram.</returns>
		public HighLevelGpuProgram CreateProgram( string name, string group, string language, GpuProgramType type )
		{
			// lookup the factory for the requested program language
			var factory = GetFactory( language );

			if ( factory == null )
			{
				throw new AxiomException( "Could not find HighLevelGpuProgramManager that can compile programs of type '{0}'",
				                          language );
			}

			// create the high level program using the factory
			var program = factory.CreateInstance( this, name, (ResourceHandle)name.ToLower().GetHashCode(), group, false, null );
			program.Type = type;
			program.SyntaxCode = language;

			_add( program );
			return program;
		}
		public GLGpuProgram Create( ResourceManager parent, string name, ResourceHandle handle, string group, bool isManual,
		                            IManualResourceLoader loader, GpuProgramType type, string syntaxCode )
		{
			// creates and returns a new ATI fragment shader implementation
			GLGpuProgram ret = new ATIFragmentShaderGpuProgram( parent, name, handle, group, isManual, loader );
			ret.Type = type;
			ret.SyntaxCode = syntaxCode;
			return ret;
		}
Esempio n. 60
0
		public override void BindGpuProgramPassIterationParameters( GpuProgramType gptype )
		{
			//TODO: perhaps not needed?
		}