PDA

View Full Version : using assembly and glsl in same program



strattonbrazil
06-04-2007, 11:55 AM
Is there a reason why assembly fragment code would fail to compile after a GLSL program is attached?

I'm working with a program that uses assembly and want to replace parts with GLSL. Right now if I bind a GLSL shader calling glUseProgram(...) and glUseProgram(0) to unbind it, any assembly shader I compile afterwards fails at line 1, character -1 and gives me the error 1282. I know the assembly code works as it worked before I started, and the GLSL code compiles fine from the error messages I'm getting.

Is it impossible to use them two shader formats in the same program? Does the state get set to GLSL only or something if you try to use GLSL once?

knackered
06-04-2007, 12:45 PM
??

Jackis
06-04-2007, 02:03 PM
strattonbrazil

It's impossible. If you want to use GLSL - use it. If you want to use ARB - use it. But mixing them is forbidden. It's 2 different languages, 2 different grammars! It's not source and assembly. What you mean by "assembly" is actually a high-level language too, and real assembly is quite far from it.

Imagine, you are writing your program source code on C with SmallTalk and Paslal insertions. Would it compile successfully??

V-man
06-04-2007, 05:13 PM
You means you want to have some GLSL and also you are using ARB_vp/fp in the same exe? Yes, it's possible. I don't know what Jackis is talking about.

Zengar
06-04-2007, 06:13 PM
AFAIK, it is indeed possible. You can use a GLSL program that consits only of a vertex shader together with an ASM fragment program, or a GLSL fragment shader with a ASM vertex program. But you cannot use ASM parts inside your GLSL program object or via versa.

arekkusu
06-05-2007, 12:15 AM
You can freely mix and match fixed function / ARB programs / GLSL shaders for vertex and fragment portions of the pipeline, as long as your varyings all line up OK.

However one restriction is that if you are using a geometry shader, you must use a vertex shader (not fixed function or vertex program.) The spec says it is a link error otherwise.

Jackis
06-05-2007, 03:49 AM
V-man and Zengar,
I understand that he asked if he can write one shader, which consists from GLSL and ARB. I mean, assembly inlines. He meant it also, as I see.
Surely, he can take ARB fragment program and GLSL vertex program, it's not forbidden. But his question was not about it.

knackered
06-05-2007, 04:10 AM
why would you want to?

Zengar
06-05-2007, 04:24 AM
Jackis, I guess you're right. It wasn't very clear from his post to me. Maybe he could comment on it...

strattonbrazil
06-08-2007, 10:45 AM
I'm sorry. I meant the same C++ program. I wasn't trying to combine assembly and GLSL in the same shader.

MalcolmB
06-08-2007, 12:04 PM
You can definetely mix them in C++ if you are using them at different times. Using them at the same time is possible too. This is quoted from the GL_EXT_geometry_shader4 spec which may affect your design descision.

20. Now that a third shader object type is added, what combinations of
GLSL, assembly (ARB or NV) low level and fixed-function do we want
to support?

DISCUSSION: With the addition of the geometry shader, the number of
combinations the GL pipeline could support doubled (there is no
fixed-function geometry shading). Possible combinations now are:

vertex geometry fragment

ff/ASM/GLSL none/ASM/GLSL ff/ASM/GLSL

for a total of 3 x 3 x 3 is 27 combinations. Before the geometry shader
was added, the number of combinations was 9, and those we need to
support. We have a choice on the other 18.

RESOLUTION: It makes sense to draw a line at raster in the GL
pipeline. The 'north' side of this line covers vertex and geometry
shaders, the 'south' side fragment shaders. We now add a simple rule
that states that if a program object contains anything north of this
line, the north side will be 100% GLSL. This means that:

a) GLSL program objects with a vertex shader can only use a geometry
shader and not an assembly geometry program. If an assembly geometry
program is enabled, it is bypassed. This also avoids a tricky case -- a
GLSL program object with a vertex and a fragment program linked
together. Injecting an assembly geometry shader in the middle at run
time won't work well.

b) GLSL program objects with a geometry shader must have a vertex shader
(cannot be ARB/NV or fixed-function vertex shading).

The 'south' side in this program object still can be any of
ff/ARB/NV/GLSL.

"

knackered
06-09-2007, 10:42 AM
it amazes me that they waste time discussing this sort of thing at the arb. just make it either or.