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

glrenderer2 fails with opengl2 drivers due textureCubeLod #13

Open
infapi00 opened this issue Jul 17, 2020 · 2 comments
Open

glrenderer2 fails with opengl2 drivers due textureCubeLod #13

infapi00 opened this issue Jul 17, 2020 · 2 comments

Comments

@infapi00
Copy link

Not sure if the glrenderer2 is maintained, but just in case.

When testing with a opengl2 driver it fails during shader compilation due this error:
0:253(14): error: no function with name 'textureCubeLod'

That function has been changing names through glsl versions, and there is some code at GLSL_GetHeader to handle that:

	// HACK: abuse the GLSL preprocessor to turn GLSL 1.20 shaders into 1.30 ones
	if(glRefConfig.glslMajorVersion > 1 || (glRefConfig.glslMajorVersion == 1 && glRefConfig.glslMinorVersion >= 30))
	{
		if (glRefConfig.glslMajorVersion > 1 || (glRefConfig.glslMajorVersion == 1 && glRefConfig.glslMinorVersion >= 50))
			Q_strcat(dest, size, "#version 150\n");
		else
			Q_strcat(dest, size, "#version 130\n");

		if(shaderType == GL_VERTEX_SHADER)
		{
			Q_strcat(dest, size, "#define attribute in\n");
			Q_strcat(dest, size, "#define varying out\n");
		}
		else
		{
			Q_strcat(dest, size, "#define varying in\n");

			Q_strcat(dest, size, "out vec4 out_Color;\n");
			Q_strcat(dest, size, "#define gl_FragColor out_Color\n");
			Q_strcat(dest, size, "#define texture2D texture\n");
			Q_strcat(dest, size, "#define textureCubeLod textureLod\n");
			Q_strcat(dest, size, "#define shadow2D texture\n");
		}
	}
	else
	{
		Q_strcat(dest, size, "#version 120\n");
		Q_strcat(dest, size, "#define shadow2D(a,b) shadow2D(a,b).r \n");
	}

For our case, it goes through the second else, as on opengl 2.1, it was using GLSL 1.20 so the name was textureCubeLod. But the problem is that on GLSL 1.20 core that function is available but only for vertex shaders. To be used on fragment shaders, it is needed the extension GL_ARB_shader_texture_lod. So a quick workaround (tested and working) would be the following one:

	else
	{
		Q_strcat(dest, size, "#version 120\n");
		Q_strcat(dest, size, "#extension GL_ARB_shader_texture_lod : enable\n");
		Q_strcat(dest, size, "#define shadow2D(a,b) shadow2D(a,b).r \n");
	}

But again, that is a workaround, as we need to check if that extension is available (skimming I see some extension-handling code at tr_extensions.c), and probably something else that Im missing. Also again, not sure if there is a real interest to maintain the non-vulkan renderers.

The specific device tested was the rpi4, which Mesa OpenGL driver exposes 2.1 (as a embedded device, it is more focused on GLES).

bvarner added a commit to bvarner/vkQuake3 that referenced this issue Aug 22, 2022
@nixguru
Copy link

nixguru commented Aug 25, 2022

Confirmed this issue when compiling and running on Raspberry Pi 4 with Vulkan drivers on Manjaro Linux. Applied patch to source, recompiled, and issue was resolved. Confirmed fix.

@runlevel5
Copy link
Contributor

Thanks for the bug report. I do not think OpenGL2 is the main focus of this project. After all there are alternatives ports (such as Quake3e) that has much better support for OpenGL2 renderer. IMHO vkQuake3 should remove OpenGL2 renderer

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

3 participants