View Full Version : Mixing ARB shader, GLSL and maybe NV shader
Just out of curiosity, does anyone know, how most drivers react, if i use more than one shading language in my app?
I donīt want to mix them in VP/FP, those will always be a pair of the same type, but i might want to first use a VP/FP set of ARB_vertex/fragment_program and after that i might want to bind a GLSL VP/FP set. Do i need to first disable the old one, or do drivers not care about that?
I hope itīs understandable, what i mean.
AFAIK you can't have more than one set of shaders active at any one time. (one vertex shader, one fragment shader)
But I'd advice you to always deactivate a shader after you're done with it.
After all, what if you want to use the fixed function pipeline for something.
Or what if, in some future revision, shaders become chainable.
Yes, if i want to use fixed-pipe, i need to deactivate shaders. However, if i only want to switch to another shader, this wouldnīt be that good, because deactivating shaders is AFAIK the same, as switching to another shader (to the fixed-pipe "shader"), which means, i would have two shaderswitches, only to switch to one other shader.
Therefore i would like to simply switch to another shader, without deactivating the old one, but i donīt know, if this is good practice, if the languages are not the same.
03-31-2005, 04:09 AM
You can mix and match to your heart's content.
There is an enable hiearchy that is similar to TEXTURE_1D, TEXTURE_2D, TEXTURE_RECT_ARB, TEXTURE_3D, TEXTURE_CUBE_MAP.
glUseProgram( name ) and glUseProgramObjectARB( handle ) is higher in the enable hierarchy then ARB_vertex_program/ARB_fragment_program.
So you don't have to disable GL_VERTEX_PROGRAM_ARB or GL_FRAGMENT_PROGRAM_ARB. A glUseProgram(0) or glUseProgramObjectARB(0) disables shading, so you'll then execute any enabled vertex_program/fragment_program, else fixed function.
(Just an aside, EXT_vertex_shader is below ARB_vertex_program in the enable hierarchy. EXT_vertex_shader is an old ATI extension that is in no way related to ARB_vertex_shader.)
Interessting. Does that mean, if i have an ASM shader enabled and i enable a GLSL shader and disable it again, that then the ASM shader is active, again?
Or are both disabled, if i disable the GLSL shader?
03-31-2005, 12:59 PM
Interessting. Does that mean, if i have an ASM shader enabled and i enable a GLSL shader and disable it again, that then the ASM shader is active, again?I think that's what he is saying. Previous states must be preserved.
I didn't know this hierarchy thing even existed. Is this what the documents say?
04-01-2005, 03:20 AM
Originally posted by V-man:
Is this what the documents say?Yes.
Interactions with ARB_fragment_program
Enabling an ARB_fragment_shader shader by issuing the command
UseProgramObjectARB(), with a handle which is not zero, results in any
low level fragment shader to be ignored and overrides the enable
FRAGMENT_PROGRAM_ARB. Note that the value for FRAGMENT_PROGRAM_ARB does
not change by installing an ARB_fragment_shader shader.
Interactions with EXT_vertex_shader
14. Enabled state
On implementations that support both EXT_vertex_shader, and
ARB_vertex_program, priority is given to ARB_vertex_program. That is to
say, if both are enabled, the implementation uses the program defined
by ARB_vertex_program and does not execute the currently bound
EXT_vertex_shader shader unless or until ARB_vertex_program is
subsequently disabled. Needless to say, it is not expected that a given
application will actually attempt to use both vertex program API's at
once. FWIW, the texture enable hierachy is also replaced by instructions for ARB_fragment_program and samplers for ARB_vertex_shader/ARB_fragment_shader.
04-01-2005, 04:03 AM
Also, I think Jan has to keep in mind that
GL_VERTEX_PROGRAM_ARB and GL_VERTEX_PROGRAM_NV have the same ID, but
GL_FRAGMENT_PROGRAM_ARB and GL_FRAGMENT_PROGRAM_NV
are not the same ID.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.