lol, +1 on the popcorns.
lol, +1 on the popcorns.
Just for the OP's info, here are the worthwhile features that should be added to GLSL:
- Explicit uniform locations.
Yes, UBOs go a long way here, but sometimes all you want to do is just set a single vec4. GLSL has had explicit attribute locations for ages, why not for uniforms too? This isn't a hardware limitation (HLSL could always let you set ": register(c0)" for example), it's a design flaw. Add "layout (location=" qualifiers to uniform declarations.- Default values allowed for sampler uniforms.
This is daft - why can't you declare "uniform sampler2D myTexture = 3;" and then just bind the texture object to GL_TEXTURE3 without having to query the uniform location and set it's value after compilation? Sure, it's a one-time-only op, but it just needlessly adds to the boilerplate supporting infrastructure you must write before you can actually start doing interesting and fun things.- User-specified entry-points.
Again, it's daft that you must always use main () as your entry-point for every shader. If you have many shaders that all share the same inputs, outputs and uniforms, you might want to combine them all into a single source file. Same with shared subroutines. YES Alfonse, I know about the const GLchar ** param to glShaderSource, but that means having to split your shader sources across multiple files, load and verify each file individually, and build up the array each time. A new version of glShaderSource that accepts a const GLchar *entrypoint param.
Something of a personal wish-list I admit, but get this stuff fixed and then maybe we can start talking about bolting on OOP pretties.
Understood. Then what I was asking for is somehow can be accomplished with performance penalty using something like OpenCL or CUDA...
We already have that. Welcome to 2011; glad you could make it.Default values allowed for sampler uniforms.
This is daft - why can't you declare "uniform sampler2D myTexture = 3;" and then just bind the texture object to GL_TEXTURE3 without having to query the uniform location and set it's value after compilation? Sure, it's a one-time-only op, but it just needlessly adds to the boilerplate supporting infrastructure you must write before you can actually start doing interesting and fun things.
Granted that; not up to speed with the full 4.2 spec.
I would like to see support for #include too. this means you must be able to specify a callback function to be called on each #include which will fetch the included file's text to the GLSL compiler.
currently, if you want to use includes, you have to run your own preprocessor beforehand.
An slightly better solution for this is what Cg supports. It provides APIs for you to give it the text content of included files beforehand (cgSetCompilerIncludeString) as well as a callback (as you describe) to be called if a #include is seen for a file you haven't given it already (cgSetCompilerIncludeCallback).
As a side-note, it also provides cgSetCompilerIncludeFile, where you can provide a disk pathname to the content for a specific include file (instead of the already-loaded content string directly), but GL wouldn't want to support that (since GL doesn't access the filesystem. the server may be running on a completely different host than the client.).
In fact, if we had this (#include support) as well as what I describe here (i.e. using const values and normal GLSL conditional expressions to define "shader permutations", and having the compiler automatically cut-away unreachable code), I think that'd totally eliminate my needs for "sprintf"ing of GLSL shaders together (which is necessary now).
Last edited by Dark Photon; 07-16-2012 at 08:16 AM.
There is http://www.opengl.org/registry/specs...ge_include.txt, though the developer is responsible for loading the include files themselves and linking the file to the contents in GL. I haven't used it myself though, as we have a preprocessor class in our project.I would like to see support for #include too. this means you must be able to specify a callback function to be called on each #include which will fetch the included file's text to the GLSL compiler.