[iOS] glslopt_target enum missing in SDK glsl_optimizer.h

Minor issues with the Ogre API that can be trivial to fix
Post Reply
simedj
Goblin
Posts: 262
Joined: Fri Nov 18, 2011 6:50 pm

[iOS] glslopt_target enum missing in SDK glsl_optimizer.h

Post by simedj » Fri Mar 07, 2014 10:09 am

In OgreGLSLESProgramManagerCommon.cpp:

Code: Select all

#if !OGRE_NO_GLES2_GLSL_OPTIMISER
#if OGRE_NO_GLES3_SUPPORT == 0
        mGLSLOptimiserContext = glslopt_initialize(kGlslTargetOpenGLES30);
#else
        mGLSLOptimiserContext = glslopt_initialize(kGlslTargetOpenGLES20);
#endif
#endif
I've been getting build errors that kGlslTargetOpenGLES20 is not recognised. After some digging, I realised that our version of glsl_optimizer.h (in prebuilt iOS dependencies) is missing it!

Here's our version

Code: Select all

#pragma once
#ifndef GLSL_OPTIMIZER_H
#define GLSL_OPTIMIZER_H

/*
 Main GLSL optimizer interface.
 See ../../README.md for more instructions.

 General usage:

 ctx = glslopt_initialize();
 for (lots of shaders) {
   shader = glslopt_optimize (ctx, shaderType, shaderSource, options);
   if (glslopt_get_status (shader)) {
     newSource = glslopt_get_output (shader);
   } else {
     errorLog = glslopt_get_log (shader);
   }
   glslopt_shader_delete (shader);
 }
 glslopt_cleanup (ctx);
*/

struct glslopt_shader;
struct glslopt_ctx;

enum glslopt_shader_type {
	kGlslOptShaderVertex = 0,
	kGlslOptShaderFragment,
};

// Options flags for glsl_optimize
enum glslopt_options {
	kGlslOptionSkipPreprocessor = (1<<0), // Skip preprocessing shader source. Saves some time if you know you don't need it.
	kGlslOptionNotFullShader = (1<<1), // Passed shader is not the full shader source. This makes some optimizations weaker.
};

glslopt_ctx* glslopt_initialize (bool openglES);
void glslopt_cleanup (glslopt_ctx* ctx);

glslopt_shader* glslopt_optimize (glslopt_ctx* ctx, glslopt_shader_type type, const char* shaderSource, unsigned options);
bool glslopt_get_status (glslopt_shader* shader);
const char* glslopt_get_output (glslopt_shader* shader);
const char* glslopt_get_raw_output (glslopt_shader* shader);
const char* glslopt_get_log (glslopt_shader* shader);
void glslopt_shader_delete (glslopt_shader* shader);


#endif /* GLSL_OPTIMIZER_H */
And here's a version used in HLSL2GLSLFork project:
https://github.com/aras-p/glsl-optimize ... ptimizer.h

Note this bit:

Code: Select all

// Optimizer target language
enum glslopt_target {
	kGlslTargetOpenGL = 0,
	kGlslTargetOpenGLES20 = 1,
	kGlslTargetOpenGLES30 = 2
};
I'm going to try hacking that into my header and seeing what happens, but it suggests you're maybe getting a wrong version of this lib?
0 x
Looking to find experienced Ogre & shader developers/artists. PM me with a contact email address if interested.

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 1
Contact:

Re: [iOS] glslopt_target enum missing in SDK glsl_optimizer.

Post by Wolfmanfx » Fri Mar 07, 2014 10:32 am

The prebuild version is bit out of date better would be to just build and include the correct headers.
0 x

simedj
Goblin
Posts: 262
Joined: Fri Nov 18, 2011 6:50 pm

Re: [iOS] glslopt_target enum missing in SDK glsl_optimizer.

Post by simedj » Fri Mar 07, 2014 10:48 am

LOL, MasterFalcon has spent all week trying to convince me that building my own libs is a bad idea :)
That's why I switched to the iOS7 pre-built dependencies in the first place, because trying to build my own was becoming a massive PITA!

Either way - if you're supplying pre-built libs which don't build against Ogre, isn't this still a bug? Cg/HLSL2GLSL support works on iOS but it seems safe to say GLSL optimisation is broken, unless you build your own?
0 x
Looking to find experienced Ogre & shader developers/artists. PM me with a contact email address if interested.

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 1
Contact:

Re: [iOS] glslopt_target enum missing in SDK glsl_optimizer.

Post by Wolfmanfx » Fri Mar 07, 2014 10:57 am

For Android I just build the optimizer :) but maybe he is right in your case to save your time :)
I have to try it if its really broken or if the he just copy the old header and forgot to replace with the updated enum.
0 x

simedj
Goblin
Posts: 262
Joined: Fri Nov 18, 2011 6:50 pm

Re: [iOS] glslopt_target enum missing in SDK glsl_optimizer.

Post by simedj » Fri Mar 07, 2014 1:41 pm

Well I only get the 200 linker errors or so... "Undefined symbols for architecture i386". Some are definitely pointing at glsloptimise, others at Ogre itself. I'll have to rebuild Ogre without glsloptimise to be sure.

One investigation I did suggests a wrong version is used:
$ lipo -info ogre/ogre1.9/build/ios/sdk/lib/Debug/libhlsl2glsl.a
Architectures in the fat file: ogre/ogre1.9/build/ios/sdk/lib/Debug/libhlsl2glsl.a are: armv7 (cputype (12) cpusubtype (11)) (cputype (16777228) cpusubtype (0)) i386 x86_64

lipo -info ogre/ogre1.9/build/ios/sdk/lib/Debug/libglsl_optimizer.a
Architectures in the fat file: ogre/ogre1.9/build/ios/sdk/lib/Debug/libglsl_optimizer.a are: armv7 i386
The 2nd one has different architectures than everything else.
0 x
Looking to find experienced Ogre & shader developers/artists. PM me with a contact email address if interested.

simedj
Goblin
Posts: 262
Joined: Fri Nov 18, 2011 6:50 pm

Re: [iOS] glslopt_target enum missing in SDK glsl_optimizer.

Post by simedj » Fri Mar 07, 2014 7:39 pm

There's a problem with the libhlsl2glsl.a in the precompiled package too - I get a linker error:
Undefined symbols for architecture i386:
"_Hlsl2Glsl_Finalize", referenced from:
Ogre::GLSLESCgProgramFactory::~GLSLESCgProgramFactory() in libRenderSystem_GLES2Static.a(OgreGLSLESCgProgramFactory.o)
I built my own version but then I noticed in my newer hlsl2glsl.h, there IS NO Hlsl2Glsl_Finalize() - instead we have Hlsl2Glsl_Shutdown().
So something weird happened with this lib too. I could either build my own version of just before that method got renamed, or we should change Ogre - in either case the precompiled dependencies have problems.

I think I will locally modify GLSLESCgProgramFactory and check things work with my own build of hlsl2glsl, then re-enable glsloptimizer and build that too. Assuming this all works, I could submit my binaries (armv7, armv7s, arm64) if that's helpful?
0 x
Looking to find experienced Ogre & shader developers/artists. PM me with a contact email address if interested.

simedj
Goblin
Posts: 262
Joined: Fri Nov 18, 2011 6:50 pm

Re: [iOS] glslopt_target enum missing in SDK glsl_optimizer.

Post by simedj » Fri Mar 07, 2014 8:20 pm

Well it's not quite so simple - what a surprise!

They changed Hlsl2Glsl_Parse and Hlsl2Glsl_Translate to accept an additional parameter of type ETargetVersion back in 2012: https://github.com/aras-p/hlsl2glslfork ... 656d80d2b3

I have no idea what version we should be using, so I am going to try ETargetGLSL_ES_100.
0 x
Looking to find experienced Ogre & shader developers/artists. PM me with a contact email address if interested.

simedj
Goblin
Posts: 262
Joined: Fri Nov 18, 2011 6:50 pm

Re: [iOS] glslopt_target enum missing in SDK glsl_optimizer.

Post by simedj » Sun Mar 09, 2014 9:18 pm

So I made those changes, build and everything now works :)
To summarise, I am building Ogre 1.9 from source against the pre-build iOS7 dependencies. I had to build HLSL2GLSL myself and then had to tweak GLES2 Rendersystem - I think these changes are going to be required in Ogre source unless you deliberately build a 2 year old version of HLSL2GLSL. But I did NOT have to rebuild any other dependency libs.

I don't know I have a developer/contributor account for Ogre; is it easier I post a patch file? I can post my libhlsl2glsl files too if you want them.
0 x
Looking to find experienced Ogre & shader developers/artists. PM me with a contact email address if interested.

User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4291
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 2
Contact:

Re: [iOS] glslopt_target enum missing in SDK glsl_optimizer.

Post by spacegaier » Tue Mar 03, 2015 10:39 pm

simedj wrote:I don't know I have a developer/contributor account for Ogre; is it easier I post a patch file? I can post my libhlsl2glsl files too if you want them.
Is there still anything that needs to be fixed in the Ogre code base? If yes, here are the details on how to: http://www.ogre3d.org/developers/submit-patch
0 x
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...

Post Reply