Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shader compilation: reading 0 as int instead of float #334

Closed
Gerwin2k opened this issue Sep 25, 2023 · 4 comments
Closed

Shader compilation: reading 0 as int instead of float #334

Gerwin2k opened this issue Sep 25, 2023 · 4 comments

Comments

@Gerwin2k
Copy link

Thanks to the new shader error logging I could trace this.

error(#162) Wrong operand types:
no operation ":" exists that takes a left-hand operand of type "highp float" and a right operand of type "const int" 

Only an issue with older Windows Radeon Drivers for cards like HD 6xxx / HD 7xxx.
Seemingly fixed by making the 0 into a 0.0. Which makes the shader compiler recognize it as float.
Fixes true color rendering for my system. Also seems to speed up 8-bit GPU rendering, so I figure the system was somehow tripping over it constantly?

Fix in Shaders\textureSampleFunc.h

// GB 2023, changed 0 to 0.0 four times:
vec2 wrapCoordF(vec2 uv, vec2 edge)
{
	uv += vec2(0.5,-0.5);

	uv = fmod(uv, edge);
	uv.x += (uv.x < 0.0) ? edge.x : 0.0;
	uv.y += (uv.y < 0.0) ? edge.y : 0.0;

	uv -= vec2(0.5,-0.5);
	return uv;
}

// GB 2023, changed 0 to 0.0 four times:
// Approximate the distortion that happens in software when floor and ceiling textures are not 64x64.
vec2 wrapCoordFlatF(vec2 uv, vec2 edge)
{
	float coord = fmod(uv.x, 64.0) * 64.0 + fmod(uv.y, 64.0);
	uv = wrapCoordF(vec2(coord / edge.y, coord), edge);
	uv.x += (uv.x < 0.0) ? edge.x : 0.0;
	uv.y += (uv.y < 0.0) ? edge.y : 0.0;
	return uv;
}
@luciusDXL
Copy link
Owner

sigh - GLSL compilers strike again. Ok, I will post a fix tonight (right now that file has other changes that I have to finish first).

@Gerwin2k
Copy link
Author

No hurry.

The retro WIN32 / XP build, that worked on, has this change already.

Just thought it would be useful to post the finding here, for whatever it is worth.

@luciusDXL
Copy link
Owner

luciusDXL commented Sep 26, 2023

No hurry.

The retro WIN32 / XP build, that worked on, has this change already.

Just thought it would be useful to post the finding here, for whatever it is worth.

Oh it is definitely useful. My consternation isn't with you, its with the GLSL compiler design (everyone writes their own, they are all broken in their own special ways). I'm glad you are reporting this since if one person reports an issue, most likely many people are silently suffering from the same issue.

@luciusDXL
Copy link
Owner

Fixed in the 1.09.52 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants