cancel
Showing results for 
Search instead for 
Did you mean: 

SDK 0.3.1 Shader compilation failed

veelo
Level 2
A call to ovrHmd_ConfigureRendering results in the following message:
Debug: Compiling shader
uniform vec2 EyeToSourceUVScale;
uniform vec2 EyeToSourceUVOffset;
attribute vec2 Position;
attribute vec4 Color;
attribute vec2 TexCoord0;
varying vec4 oColor;
varying vec2 oTexCoord0;
void main()
{
gl_Position.x = Position.x;
gl_Position.y = Position.y;
gl_Position.z = 0.5;
gl_Position.w = 1.0;
oTexCoord0 = TexCoord0 * EyeToSourceUVScale + EyeToSourceUVOffset;
oTexCoord0.y = 1-oTexCoord0.y;
oColor = Color;
}

failed: ERROR: 0:15: '-' does not operate on 'int' and 'float'


Probably line 74 of CAPI/GL/CAPI_GL_DistortionRenderer.cpp should read:

" oTexCoord0.y = 1.0 - oTexCoord0.y;\n"


Best regards,
Bastiaan.
6 REPLIES 6

renderingpipeli
Level 2
Let me guess, you have a AMD GPU and the OpenGL guy at Oculus only tested on a NVIDIA? 😉

Implicit casts are not allowed in GLSL 1.10 (which this is without any #version directive), 1.20 allows this for int to float. Technically the error is the correct behaviour and AMD is more strict with the specs than NVIDIA (not sure how Intel behaves here). Your patch should be the best solution.

I haven't looked at the sources yet, as this is "old" OpenGL, it will work in compatibility profiles and OpenGL down to 2.0. But on core profiles (e.g. Macs if you want OpenGL > 2.1) it will fail. Is there a core version for those shaders (using a #version declaration, in/out instead of attribute/varying)?

cybereality
Level 16
Thanks for posting the fix. I'll have someone update the code ASAP.
AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV

veelo
Level 2
Somehow I fail to generate a patch, but the fix should be applied to the following line numbers:
74, 141, 207, 244, 246, 248, 343, 345, 347, 418, 420, 422.

Bastiaan.

veelo
Level 2
Maybe you should consider running shaders through the reference compiler [1] for validation. For this it is impractical to have the shader code as a string in the C++ code. The following setup can be a solution: keep the shader code proper in shader files in the code base (which can be verified); generate stringified versions of these and #include them in the C++ code.

Given a shader called Distortion_vs.glsl you can generate a stringified version Distortion_vs.glsl.str with
sed -f stringify.sed Distortion_vs.glsl > Distortion_vs.glsl.str
where stringify.sed contains

s|\\|\\\\|g
s|"|\\"|g
s|$|\\n"|g
s|^|"|g


Line 54 of CAPI_GL_DistortionRenderer.cpp would then look something like

static const char Distortion_vs[] =
#include "Distortion_vs.glsl.str"
;


Another advantage of this configuration is that you get syntax highlighting when writing shader code.

In case various shaders contain common code then you can use the following modification: have the shaders in a single .glsl file and separate the versions with #ifdef/#endif, and give the "#define" in the C++ code. This complicates the situation somewhat because the #version line must be the first and therefore must be omitted from the .glsl file. You would then include it like the following pseudo code (use your favorite string class):

String Distortion_vs = "#version 120\n";
Distortion_vs += "#define SOME_VARIANT\n";
Distortion_vs +=
#include"Distortion_vs.glsl.str"
;

However, before feeding these to the reference compiler, of course the #version and #defines must be put back in.

Best regards,
Bastiaan.

[1] http://www.khronos.org/opengles/sdk/tools/Reference-Compiler/

cybereality
Level 16
Thanks. I've filed a bug report for this.
AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV

veelo
Level 2
Thanks. I forgot another important point: By providing the shaders as files in the SDK (pure and stringified), they can then be used for client distortion rendering as well!

Bastiaan.