GLSL Bytecode

This topic is 2556 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hey guys, I'm looking to write some GLSL but need to output into bytecode is this possible?

thanks

Share on other sites
OpenGL 4.1 supports binary GLSL shaders.

Share on other sites
Right .. so what I want to do is write a GLSL shader and see the bytecode output.

Share on other sites
I don't think it (OpenGL 4.1) supports bytecode in the same way HLSL does, you can get a binary blob back from the driver but it can only be reloaded on that same device... not distributed with your application or anything.

There's a big (rather heated) discussion at opengl.org where it was stated pretty authoritatively that GLSL will not get an intermediate format like this anytime in the near future. Although I think OpenGL ES might be getting something, as compiling shaders at runtime on mobile devices can be pretty slow.

Share on other sites
Okay so maybe I wasn't to clear. I'm working on a project that does not support any high level shader languages. So what I am trying to do is write a GLSL shader and then have that translated to the equivalent ARB Assembly or Bytecode.

Thanks

Share on other sites
Maybe somebody more knowledgeable than me can jump in here, but since there is no GLSL bytecode specification your only option would be to try to convert it to ARB assembly (which is before my time so I can't really comment further).

Share on other sites
Hm, it's been a while and I've never been an OpenGL-expert, but IIRC nvidia's cg compiler outputs viewable ARB-assembler. (It compiles many things to many other things.) I once had to compile shaders for an OpenGL project and wanted to look at the compiler output to see what became of my ifs and fors. Anyway, I think I used GLSL as input, but it may have been Cg, I don't know for certain.

Maybe that's something you could look at.

Share on other sites
Yeah, Cg toolkit can be used to convert GLSL to ARB assembly.

Share on other sites
Does CG toolkit have a GUI or is it just code that I add into my VS directory.

Share on other sites
Quote:
 Original post by kubaplDoes CG toolkit have a GUI or is it just code that I add into my VS directory.Do you have a download?

The compiler runs from command prompt.

Share on other sites
EngineCoder do you have an example.

Share on other sites
Quote:
 Original post by kubaplEngineCoder do you have an example.

2. Open command prompt. CD into a directory that contains your GLSL shader.
3. cgc -oglsl -profile arbfp1 normal_map.fp > normal_map.frag.asm
In this example, normal_map.fp is the GLSL fragment program and normal_map.frag.asm will be the compiled assembly file.

Share on other sites
EngineCode:

I've compiled the shader as per your instructions and I get this error:

vertexshader.glsl(0) : error C5052: gl_Vertex is not accessable in this profile(0) : error C5052: gl_MultiTexCoord0 is not accessable in this profile(0) : error C5052: gl_Position is not accessable in this profile

this is my GLSL code

varying vec2 vTexCoord;void main(void){   vTexCoord = gl_MultiTexCoord0.xy;   gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;}

Share on other sites
Quote:
 Original post by kubaplOkay so maybe I wasn't to clear. I'm working on a project that does not support any high level shader languages. So what I am trying to do is write a GLSL shader and then have that translated to the equivalent ARB Assembly or Bytecode.Thanks

What do you mean by this exactly? "Does not support any high level shader languages" A project can't not support high level shader languages. If it supports GL 2.0, it supports high level shader languages. If it doesn't support GL 2.0, then you are either on a cell phone and don't have access to a GPU anyway, or your target market is a 7 year old PC.

My guess is that it does actually support high level shader languages and you are...mistaken or confused somehow.

Share on other sites
Looks like you are trying to compile a vertex shader with a fragment shader profile..
Quote:
 3. cgc -oglsl -profile arbfp1 normal_map.fp > normal_map.frag.asmIn this example, normal_map.fp is the GLSL fragment program and normal_map.frag.asm will be the compiled assembly file.

Share on other sites
Please also keep in mind that not all GLSL features are available in ARB shaders (branching, instruction counts etc.), so you might run into problems with this, too.

Thus you can't just take an existing GLSL shader and convert that to ARB.

Share on other sites

This topic is 2556 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Create an account

Register a new account

• Forum Statistics

• Total Topics
628666
• Total Posts
2984132

• 12
• 10
• 9
• 9
• 10