Specialisation of HighLevelGpuProgram to provide support for OpenGL Shader Language (GLSL).
GLSL has no target assembler or entry point specification like DirectX 9 HLSL. Vertex and Fragment shaders only have one entry point called "main". When a shader is compiled, microcode is generated but can not be accessed by the application. GLSL also does not provide assembler low level output after compiling. The GL Render system assumes that the Gpu program is a GL Gpu program so GLSLProgram will create a GLSLGpuProgram that is subclassed from GLGpuProgram for the low level implementation. The GLSLProgram class will create a shader object and compile the source but will not create a program object. It's up to GLSLGpuProgram class to request a program object to link the shader object to.

GLSL supports multiple modular shader objects that can be attached to one program object to form a single shader. This is supported through the "attach" material script command. All the modules to be attached are listed on the same line as the attach command seperated by white space.

Inheritance: Axiom.Graphics.HighLevelGpuProgram
Exemplo n.º 1
0
        /// <summary>
        ///		Attach another GLSL Shader to this one.
        /// </summary>
        /// <param name="name"></param>
        public void AttachChildShader(string name)
        {
            // is the name valid and already loaded?
            // check with the high level program manager to see if it was loaded
            HighLevelGpuProgram hlProgram = HighLevelGpuProgramManager.Instance.GetByName(name);

            if (hlProgram != null)
            {
                if (hlProgram.SyntaxCode == "glsl")
                {
                    // make sure attached program source gets loaded and compiled
                    // don't need a low level implementation for attached shader objects
                    // loadHighLevelImpl will only load the source and compile once
                    // so don't worry about calling it several times
                    GLSLProgram childShader = (GLSLProgram)hlProgram;

                    // load the source and attach the child shader only if supported
                    if (IsSupported)
                    {
                        childShader.LoadHighLevelImpl();
                        // add to the constainer
                        attachedGLSLPrograms.Add(childShader);
                        attachedShaderNames += name + " ";
                    }
                }
            }
        }
Exemplo n.º 2
0
        public GLSLGpuProgram(GLSLProgram parent)
            : base(parent.Creator, parent.Name, parent.Handle, parent.Group, false, null)
        {
            // store off the reference to the parent program
            this.glslProgram = parent;

            type       = parent.Type;
            syntaxCode = "glsl";

            if (parent.Type == GpuProgramType.Vertex)
            {
                programId = ++vertexShaderCount;
            }
            else if (parent.Type == GpuProgramType.Fragment)
            {
                programId = ++fragmentShaderCount;
            }
            else
            {
                programId = ++geometryShaderCount;
            }

            // transfer skeletal animation status from parent
            isSkeletalAnimationIncluded = this.glslProgram.IsSkeletalAnimationIncluded;

            // there is nothing to load
            LoadFromFile = false;
        }
Exemplo n.º 3
0
		public GLSLGpuProgram( GLSLProgram parent )
			: base( parent.Creator, parent.Name, parent.Handle, parent.Group, false, null )
		{
			this.Type = parent.Type;
			this.SyntaxCode = "glsl";

			// store off the reference to the parent program
			glslProgram = parent;

			if ( parent.Type == GpuProgramType.Vertex )
			{
				programId = ++vertexShaderCount;
			}
			else if (parent.Type == GpuProgramType.Fragment)
			{
				programId = ++fragmentShaderCount;
			}
			else
			{
			    programId = ++geometryShaderCount;
			}

			// transfer skeletal animation status from parent
			this.IsSkeletalAnimationIncluded = glslProgram.IsSkeletalAnimationIncluded;

			// there is nothing to load
			//LoadFromFile = false;
		}
        public GLSLGpuProgram(GLSLProgram parent)
            : base(parent.Name, parent.Type, "glsl")
        {
            // store off the reference to the parent program
            glslProgram = parent;

            if(parent.Type == GpuProgramType.Vertex) {
                programId = ++vertexShaderCount;
            }
            else {
                programId = ++fragmentShaderCount;
            }

            // there is nothing to load
            loadFromFile = false;
        }
        public GLSLGpuProgram(GLSLProgram parent) : base(parent.Name, parent.Type, "glsl")
        {
            // store off the reference to the parent program
            glslProgram = parent;

            if (parent.Type == GpuProgramType.Vertex)
            {
                programId = ++vertexShaderCount;
            }
            else
            {
                programId = ++fragmentShaderCount;
            }

            // there is nothing to load
            loadFromFile = false;
        }
Exemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="programObject"></param>
        public void AttachToProgramObject(int programObject)
        {
            Gl.glAttachObjectARB(programObject, glHandle);
            GLSLHelper.CheckForGLSLError("Error attaching " + this.name + " shader object to GLSL Program Object.", programObject);

            // atach child objects
            for (int i = 0; i < attachedGLSLPrograms.Count; i++)
            {
                GLSLProgram childShader = (GLSLProgram)attachedGLSLPrograms[i];

                // bug in ATI GLSL linker : modules without main function must be recompiled each time
                // they are linked to a different program object
                // don't check for compile errors since there won't be any
                // *** minor inconvenience until ATI fixes there driver
                childShader.Compile(false);
                childShader.AttachToProgramObject(programObject);
            }
        }