@All
Since some years Irrliht engine do have OGLES2 branch, which once things finalized will be released as Irrlicht 1.9.
So far for us it mean that we can try to make it to work directly over ogles2.library, and get rid of GL4ES layer in between.
The problem is that OGLES2 in Irrlich use EGL for context creation, activation, swapbuffers, etc. For us of course it will be better to not have any additional layers, and did the same as it happens to be with pure OpenGL : through SDL.
Why Irrlicht devs going EGL route with context creation , while they still use SDL to create a window, handle events, etc: is unkonwn, maybe for compatibility reassons for win32/x11/android/emscripten/etc. But what we can do for sure it's get rid of it for us and ourself create ogles2 context and use SDL window to render to it.
So to go futher there is relevant files:
EGL Manager (so you can see it just for context creation/destroying/swapbuffers/etc, i.e. minimal stuff with no events and co):
https://sourceforge.net/p/irrlicht/cod ... /Irrlicht/CEGLManager.cpphttps://sourceforge.net/p/irrlicht/cod ... ce/Irrlicht/CEGLManager.hAnd there are relevant CIrrDeviceSDL files (i.e. where we init SDL, create a window, etc).:
https://sourceforge.net/p/irrlicht/cod ... rrlicht/CIrrDeviceSDL.cpphttps://sourceforge.net/p/irrlicht/cod ... /Irrlicht/CIrrDeviceSDL.hAs can be seen, since line 483 we have that:
case video::EDT_OGLES2:
#if defined(_IRR_COMPILE_WITH_OGLES2_) && defined(_IRR_EMSCRIPTEN_PLATFORM_)
{
video::SExposedVideoData data;
ContextManager = new video::CEGLManager();
ContextManager->initialize(CreationParams, data);
VideoDriver = video::createOGLES2Driver(CreationParams, FileSystem, ContextManager);
}
#else
os::Printer::log("No OpenGL-ES2 support compiled in.", ELL_ERROR);
#endif
break;
So, createOGLES2Driver is called with passing CreationParams, FileSystem and, our ContextManager, which is EGL one there and we need to replace it on SDL one.
For that, i go the same route as it was with pure OpenGL: comment there all out, and put just one line:
VideoDriver = video::createOGLES2Driver(CreationParams, FileSystem, this);
Now, we have COGLES2Driver itself:
https://sourceforge.net/p/irrlicht/cod ... rrlicht/COGLES2Driver.cpphttps://sourceforge.net/p/irrlicht/cod ... /Irrlicht/COGLES2Driver.hThere we also change context manager as it done in case with pure OpenGL. Like it was:
COGLES2Driver::COGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager) :
CNullDriver(io, params.WindowSize), COGLES2ExtensionHandler(), CacheHandler(0),
Params(params), ResetRenderStates(true), LockRenderStateMode(false), AntiAlias(params.AntiAlias),
MaterialRenderer2DActive(0), MaterialRenderer2DTexture(0), MaterialRenderer2DNoTexture(0),
CurrentRenderMode(ERM_NONE), Transformation3DChanged(true),
OGLES2ShaderPath(params.OGLES2ShaderPath),
ColorFormat(ECF_R8G8B8), ContextManager(contextManager)
Which one we change that instead of IContextManager* contextManager we do have CIrrDeviceSDL* device, and at the end instead of ContextManager(contextManager) do ContextManager(0) (as in case with pure OpenGL).
And same for createOGLES2Driver:
//IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager)
IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io,CIrrDeviceSDL* device)
{
#ifdef _IRR_COMPILE_WITH_OGLES2_
//COGLES2Driver* driver = new COGLES2Driver(params, io, contextManager);
COGLES2Driver* driver = new COGLES2Driver(params, io, device);
driver->genericDriverInit(params.WindowSize, params.Stencilbuffer); // don't call in constructor, it uses virtual function calls of driver
return driver;
#else
return 0;
#endif // _IRR_COMPILE_WITH_OGLES2_
Now, with SDL we can go 2 ways:
1). Use the same hack as in GL4ES (so instead of MiniGL, we do use OGLES2, but SDL think about it as OpenGL). That also mean that we should call SetVideoModes() with SDL_OPENGL flag being enabled.
2). Second way is that we didn't touch SDL itself, but instead create sdl window via SetVideoModes _without_ SDL_OPENGL flag, so SDL will not involve MiniGL, but instead we in Irrlicht's SDL openwindow() open OGLES2 library, create context, take the intuition window pointer, and call aglMakeCurrent() on it, like this:
bool CIrrDeviceSDL::createWindow()
{
....
LOGLES2 = IExec->OpenLibrary("ogles2.library", 0);
if(!LOGLES2) {
printf("LIBGL: Warning, cannot open ogles2 Library!\n");
return;
}
IOGLES2 = (struct OGLES2IFace *)IExec->GetInterface(LOGLES2, "main", 1, NULL);
if(!IOGLES2) {
printf("LIBGL: Warning, cannot openogles2 Interface!\n");
IExec->CloseLibrary(LOGLES2);
LOGLES2 = NULL;
}
.... SetVideoMode call...
ULONG errCode = 0;
// get intuition window pointer
SDL_SysWMinfo wmi = { 0 };
SDL_GetWMInfo(&wmi);
struct TagItem contextparams[] =
{
{OGLES2_CCT_WINDOW,(ULONG)wmi.window},
{OGLES2_CCT_DEPTH,16},
{OGLES2_CCT_STENCIL,8},
{OGLES2_CCT_VSYNC,0},
{OGLES2_CCT_SINGLE_GET_ERROR_MODE,1},
{OGLES2_CCT_RESIZE_VIEWPORT, TRUE},
{TAG_DONE,0}
};
void *ogles_context = IOGLES2->aglCreateContext2(&errCode,contextparams);
if (ogles_context)
{
IOGLES2->aglMakeCurrent(ogles_context);
}
So i tried both ways, and have at the moment result of "nothing renders on screen" by the very simple test case.
Through, when i run exampe after those changes, i do have in the shell lots of:
Quote:
GLSL shader programm failed to link
GLSL shader programm failed to link
GLSL shader programm failed to link
GLSL shader programm failed to link
GLSL shader programm failed to link
GLSL shader programm failed to link
GL_INVALID_OPERATION: 176
So firstly what i do is delete fully media/shaders/ directory, and start to run it to see what shaders it want to use as necessary basis, and there just 3 shaders for:
1 fragment one - COGLES2Renderer2D.fsh :
precision mediump float;
/* Uniforms */
uniform int uTextureUsage;
uniform sampler2D uTextureUnit;
/* Varyings */
varying vec2 vTextureCoord;
varying vec4 vVertexColor;
void main()
{
vec4 Color = vVertexColor;
if (bool(uTextureUsage))
Color *= texture2D(uTextureUnit, vTextureCoord);
gl_FragColor = Color;
}
2 fragment one: COGLES2Renderer2D_noTex.fsh:
precision mediump float;
/* Varyings */
varying vec4 vVertexColor;
void main()
{
gl_FragColor = vVertexColor;
}
And , 3st one, vertex one, called COGLES2Renderer2D.vsh and there this are:
/* Attributes */
attribute vec4 inVertexPosition;
attribute vec4 inVertexColor;
attribute vec2 inTexCoord0;
/* Uniforms */
uniform float uThickness;
/* Varyings */
varying vec2 vTextureCoord;
varying vec4 vVertexColor;
void main()
{
gl_Position = inVertexPosition;
gl_PointSize = uThickness;
vTextureCoord = inTexCoord0;
vVertexColor = inVertexColor.bgra;
}
So with only just those 3 shaders in the media/shaders directory, i run the example, and while have lots of "could not open" for other shaders, i didn't have error that i must to have some shader to make fixed pipeline working, and , have now just one single
"GLSL shader program failed to link.".
So, i give it ago all 3 through glslangvalidator (to made SPIRV from them) and then W3DShaderInfo, to see if they compiles by Nova : and they all compiles fine..
I also checked via glSnoop what happens now , and that what i have in output:
[0] Patching task Shell Process '01.hello' OGLES2IFace 0x4dde7758
Shell Process '01.hello': my_W3DN_CreateContext: tags 0x597b1888 ([W3DNTag_GPU: 0x4DDE84A8])
[0] Patching task Shell Process '01.hello' NOVA context 0x4dde7ab0
Shell Process '01.hello': OGLES2_glShaderSource: shader 384, count 1, string 0x597b14a0 length 0x0
Line 0: '/* Attributes */
attribute vec4 inVertexPosition;
attribute vec4 inVertexColor;
attribute vec2 inTexCoord0;
/* Uniforms */
uniform float uThickness;
/* Varyings */
varying vec2 vTextureCoord;
varying vec4 vVertexColor;
void main()
{
gl_Position = inVertexPosition;
gl_PointSize = uThickness;
vTextureCoord = inTexCoord0;
vVertexColor = inVertexColor.bgra;
}
'
Shell Process '01.hello': GL error 1282 (GL_INVALID_OPERATION) detected after ShaderSource
Shell Process '01.hello': OGLES2_glCompileShader: shader 384
Shell Process '01.hello': W3DN_CompileShader: errCode 0x597b13a4, tags 0x597b1378 ([W3DNTag_DataBuffer: 0x484CD018][W3DNTag_DataSize: 948][W3DNTag_Log: 0x597B13A0][W3DNTag_LogLevel: 0])
Shell Process '01.hello': W3DN_CompileShader: <- errCode 0 (W3DNEC_SUCCESS). Shader address 0x5a956908
Shell Process '01.hello': OGLES2_glShaderSource: shader 385, count 1, string 0x597b14a0 length 0x0
Line 0: 'precision mediump float;
/* Uniforms */
uniform int uTextureUsage;
uniform sampler2D uTextureUnit;
/* Varyings */
varying vec2 vTextureCoord;
varying vec4 vVertexColor;
void main()
{
vec4 Color = vVertexColor;
if (bool(uTextureUsage))
Color *= texture2D(uTextureUnit, vTextureCoord);
gl_FragColor = Color;
}
'
Shell Process '01.hello': OGLES2_glCompileShader: shader 385
Shell Process '01.hello': W3DN_CompileShader: errCode 0x597b13a4, tags 0x597b1378 ([W3DNTag_DataBuffer: 0x484CD018][W3DNTag_DataSize: 960][W3DNTag_Log: 0x597B13A0][W3DNTag_LogLevel: 0])
Shell Process '01.hello': W3DN_CompileShader: <- errCode 0 (W3DNEC_SUCCESS). Shader address 0x5a956728
Shell Process '01.hello': OGLES2_glShaderSource: shader 386, count 1, string 0x597b14a0 length 0x0
Line 0: '/* Attributes */
attribute vec4 inVertexPosition;
attribute vec4 inVertexColor;
attribute vec2 inTexCoord0;
/* Uniforms */
uniform float uThickness;
/* Varyings */
varying vec2 vTextureCoord;
varying vec4 vVertexColor;
void main()
{
gl_Position = inVertexPosition;
gl_PointSize = uThickness;
vTextureCoord = inTexCoord0;
vVertexColor = inVertexColor.bgra;
}
'
Shell Process '01.hello': OGLES2_glCompileShader: shader 386
Shell Process '01.hello': W3DN_CompileShader: errCode 0x597b13a4, tags 0x597b1378 ([W3DNTag_DataBuffer: 0x484CD018][W3DNTag_DataSize: 948][W3DNTag_Log: 0x597B13A0][W3DNTag_LogLevel: 0])
Shell Process '01.hello': W3DN_CompileShader: <- errCode 0 (W3DNEC_SUCCESS). Shader address 0x5a9569a8
Shell Process '01.hello': OGLES2_glShaderSource: shader 387, count 1, string 0x597b14a0 length 0x0
Line 0: 'precision mediump float;
/* Varyings */
varying vec4 vVertexColor;
void main()
{
gl_FragColor = vVertexColor;
}
'
Shell Process '01.hello': OGLES2_glCompileShader: shader 387
Shell Process '01.hello': W3DN_CompileShader: errCode 0x597b13a4, tags 0x597b1378 ([W3DNTag_DataBuffer: 0x484CD018][W3DNTag_DataSize: 388][W3DNTag_Log: 0x597B13A0][W3DNTag_LogLevel: 0])
Shell Process '01.hello': W3DN_CompileShader: <- errCode 0 (W3DNEC_SUCCESS). Shader address 0x5a956a48
Warp3D Nova profiling results for Shell Process '01.hello':
Function calls used 4.968742 ms, 0.02 % of context life-time 31981.111178 ms
Draw calls/s 0.0
function | call count | errors | duration (ms) | avg. call dur. (us) | % of 4.968742 ms | % of CPU time
CompileShader | 4 | 0 | 4.968742 | 1242.185 | 100.00 | 0.02
Primitive statistics:
Nothing was drawn, vertex count 0
OpenGL ES 2.0 profiling results for Shell Process '01.hello':
Function calls used 113.412411 ms, 0.35 % of context life-time 32099.858206 ms
Frames/s 0.0
function | call count | errors | duration (ms) | avg. call dur. (us) | % of 113.412411 ms | % of CPU time
CompileShader | 4 | 0 | 113.400742 | 28350.185 | 99.99 | 0.35
ShaderSource | 4 | 1 | 0.011669 | 2.917 | 0.01 | 0.00
*) Please note that the above time measurements include time spent inside Warp3D Nova functions
Primitive statistics:
Nothing was drawn, vertex count 0
Wait 1 s before quit...
...waiting over
warp3dnova_free
ogles2_free
glSnoop exiting
So seems we compile there 4 shaders, 2 fragment ones and 2 time strying to compile this vertex one.
And this part make me curious wtf:
Shell Process '01.hello': GL error 1282 (GL_INVALID_OPERATION) detected after ShaderSource
Shell Process '01.hello': OGLES2_glCompileShader: shader 384
Shell Process '01.hello': W3DN_CompileShader: errCode 0x597b13a4, tags 0x597b1378 ([W3DNTag_DataBuffer: 0x484CD018][W3DNTag_DataSize: 948][W3DNTag_Log: 0x597B13A0][W3DNTag_LogLevel: 0])
Shell Process '01.hello': W3DN_CompileShader: <- errCode 0 (W3DNEC_SUCCESS). Shader address 0x5a956908
Shell Process '01.hello': OGLES2_glShaderSource: shader 385, count 1, string 0x597b14a0 length 0x0
It says GL error 1282 (GL_INVALID_OPERATION) firstly, but then says that shader compiles fine ?
I do check also in whole irrlicht sources on "GLSL shader programm failed to link" and found that it come from
https://sourceforge.net/p/irrlicht/cod ... GLES2MaterialRenderer.cppin the LinkProgram().
So that there i stuck for now. Any ideas and help are welcome ! Thanks !