GL: Fallback for uniform lookup for arrays of dimension 1 Closes #3047

ie.

struct A {
		vec3 m1;
		vec3 m2;
		vec3 m2;
	};

uniform A a[1];

with a[0] being passed to a function.

Previously it would look for "a.m1", if that is not found then it looks for "a[0].m1" etc.
This commit is contained in:
Jake Turner
2023-09-05 09:36:11 +01:00
parent bfe89e4c17
commit 5e7b25efca
+10
View File
@@ -2176,6 +2176,16 @@ void GLReplay::OpenGLFillCBufferVariables(ResourceId shader, GLuint prog, bool b
GLuint idx = GL.glGetProgramResourceIndex(prog, eGL_UNIFORM, fullname.c_str());
// if this is an array of size 1 try looking for <array_variable_name>[0].<member_name>
if((idx == GL_INVALID_INDEX) && (desc.elements == 1))
{
rdcstr arrayZeroName = prefix;
if(!arrayZeroName.empty() && arrayZeroName.back() == '.')
arrayZeroName.pop_back();
arrayZeroName += "[0]." + var.name;
idx = GL.glGetProgramResourceIndex(prog, eGL_UNIFORM, arrayZeroName.c_str());
}
if(idx == GL_INVALID_INDEX)
{
// this might not be an error, this might be the corresponding member in an array-of-structs