OpenMSX switching video gives errors

Страница 1/2
| 2

By Accumulator

Champion (339)

Аватар пользователя Accumulator

25-03-2023, 10:50

Switching video output like TV, simple, HQ etc.....

gives:
Error(s) compiling shader "scale2x.vert":
0:14(18): error: initializer of const variable `pi' must be a constant expression
Error(s) compiling shader "scale2x.vert":
0:14(18): error: initializer of const variable `pi' must be a constant expression
Error(s) compiling shader "scale2x.vert":
0:14(18): error: initializer of const variable `pi' must be a constant expression
Error(s) compiling shader "scale2x.vert":
0:14(18): error: initializer of const variable `pi' must be a constant expression
Error(s) compiling shader "scale2x.vert":
0:14(18): error: initializer of const variable `pi' must be a constant expression
Error(s) compiling shader "scale2x.vert":
0:14(18): error: initializer of const variable `pi' must be a constant expression

Для того, чтобы оставить комментарий, необходимо регистрация или !login

By Juan Luis

Master (143)

Аватар пользователя Juan Luis

25-03-2023, 23:57

Accumulator, perhaps your computer contains an OpenGL version where pi constant is already defined for shaders. OpenMSX compiles scale2x.vert vertex shader program during execution. The file should have a similar code to this (my version is 0.14, a little bit old, but it should be similar):

uniform mat4 u_mvpMatrix;
uniform vec3 texSize;

attribute vec4 a_position;
attribute vec3 a_texCoord;

varying vec2 texStep; // could be uniform
varying vec2 coord2pi;
varying vec2 texCoord;
varying vec2 videoCoord;

float pi = 4.0 * atan(1.0);
float pi2 = 2.0 * pi;

void main()
{
	gl_Position = u_mvpMatrix * a_position;
	texCoord = a_texCoord.xy;
	coord2pi = a_texCoord.xy * texSize.xy * pi2;
	texStep = 1.0 / texSize.xy;

#if SUPERIMPOSE
	videoCoord = a_texCoord.xz;
#endif
}

I propose several solutions, but you must copy scale2x.vert with other name before trying them. Restore the file if my solutions don't work:

First possible solution: If pi is already defined by yout openGL version, try to comment pi definition:
//float pi = 4.0 * atan(1.0);

Second possible solution: If my earlier proposal doesn't work (you will get an error on pi2 definition), try to define pi as constant
const float pi = 4.0 * atan(1.0);

Third possible solution: If both earlier proposals don't work, try to rename pi as c_pi in definition and uses of pi variable:

...
float c_pi = 4.0 * atan(1.0);
float pi2 = 2.0 * c_pi;
...

Fourth possible solution is pi should be defined as uniform above, but this would be a openMSX error because openMSX code should pass pi as uniform variable before invoking shader, but I don't think so. Uniform variables are constant during shader execution. Could you tell us your OpenMSX version?

Anyway, I hope you can solve the problem.

By Manuel

Ascended (19469)

Аватар пользователя Manuel

26-03-2023, 10:50

@Accumulator which openMSX version, video card and driver are you using?

By Accumulator

Champion (339)

Аватар пользователя Accumulator

26-03-2023, 16:32

On this laptop OpenMSX 17.0, HD Graphics 500, Mesa 22.2.5, i915

By Juan Luis

Master (143)

Аватар пользователя Juan Luis

27-03-2023, 04:13

One question more. Are you using Linux like OS?

By Accumulator

Champion (339)

Аватар пользователя Accumulator

28-03-2023, 17:05

All my machines are running Linux OS, Fedora, Ubuntu and Debian, dual boot.

By Accumulator

Champion (339)

Аватар пользователя Accumulator

30-03-2023, 01:37

Kernel 5.19 and up., one is ARM, MT8173

By TomH

Champion (370)

Аватар пользователя TomH

30-03-2023, 06:37

Personally I'd quickly try giving just:

float pi = 3.1415926538;

a whirl; the guess being that your OpenGL is failing to recognise that atan(1.0) is a constant expression. It unambiguously is a constant expression per the language rules — "The return value of any built-in function [is a constant expression] ... if all of the arguments to the function are themselves constant expressions." — but that test would certainly help to diagnose.

By Accumulator

Champion (339)

Аватар пользователя Accumulator

30-03-2023, 15:36

OK. Will check. Does it also affect colors producing by the emulator?

By Accumulator

Champion (339)

Аватар пользователя Accumulator

30-03-2023, 18:35

Best solution is from TomH, however

I changed it to:

const float pi = 3.1415926538;

works perfectly. No Errors.
removing pi, (//) results in pi undefined (const float & float)

uniform mat4 u_mvpMatrix;
uniform vec3 texSize;

attribute vec4 a_position;
attribute vec3 a_texCoord;

varying vec2 texStep; // could be uniform
varying vec2 coord2pi;
varying vec2 texCoord;
varying vec2 videoCoord;

const float pi = 3.1415926538;
const float pi2 = 2.0 * pi;

void main()
{
	gl_Position = u_mvpMatrix * a_position;
	texCoord = a_texCoord.xy;
	coord2pi = a_texCoord.xy * texSize.xy * pi2;
	texStep = 1.0 / texSize.xy;

#if SUPERIMPOSE
	videoCoord = a_texCoord.xz;
#endif
}

By TomH

Champion (370)

Аватар пользователя TomH

30-03-2023, 21:15

Accumulator wrote:

OK. Will check. Does it also affect colors producing by the emulator?

I'm not an openMSX developer and it's really hard to guess what the purpose of coord2pi is here; the frequency is wrong for it to be for a composite colour subcarrier and it's way, way too high for something like a CRT-esque barrel distortion. I guess maybe there's some sort of softening filter that offers a sine-style transition between colours?

Regardless, it should make absolutely no difference — you've just substituted the direct value of PI to an unnecessarily-lengthy precision in place of letting the compiler figure it out at the GPU's specific precision.

Страница 1/2
| 2