View Full Version : using assembly and glsl in same program
06-04-2007, 12:55 PM
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?
06-04-2007, 01:45 PM
06-04-2007, 03:03 PM
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??
06-04-2007, 06: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.
06-04-2007, 07: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.
06-05-2007, 01: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.
06-05-2007, 04: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.
06-05-2007, 05:10 AM
why would you want to?
06-05-2007, 05:24 AM
Jackis, I guess you're right. It wasn't very clear from his post to me. Maybe he could comment on it...
06-08-2007, 11:45 AM
I'm sorry. I meant the same C++ program. I wasn't trying to combine assembly and GLSL in the same shader.
06-08-2007, 01: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
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
06-09-2007, 11:42 AM
it amazes me that they waste time discussing this sort of thing at the arb. just make it either or.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.