Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by kubapl
EngineCoder do you have an example.


1. Download and install Cg toolkit.
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by kubapl
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



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 this post


Link to post
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.asm
In this example, normal_map.fp is the GLSL fragment program and normal_map.frag.asm will be the compiled assembly file.

Share this post


Link to post
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 this post


Link to post
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.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this