Skip to content

Commit 2e04278

Browse files
MD3: Use explicit uniform locations
1 parent 78ad272 commit 2e04278

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

Quake/gl_shaders.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,6 @@ void GL_CreateShaders (void)
368368
for (poseverttype = 0; poseverttype < 3; poseverttype++)
369369
glprogs.alias[oit][mode][alphatest][poseverttype] =
370370
GL_CreateProgram (alias_vertex_shader, alias_fragment_shader, "alias|OIT %d; MODE %d; ALPHATEST %d; POSEVERTTYPE %d", oit, mode, alphatest, poseverttype);
371-
glprogs.alias_numverts_loc = GL_GetUniformLocationFunc (glprogs.alias[0][0][0][2], "u_numVerts");
372-
glprogs.alias_numposes_loc = GL_GetUniformLocationFunc (glprogs.alias[0][0][0][2], "u_numPoses");
373371

374372
glprogs.debug3d = GL_CreateProgram (debug3d_vertex_shader, debug3d_fragment_shader, "debug3d");
375373

Quake/gl_shaders.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,8 +1095,8 @@ ALIAS_INSTANCE_BUFFER
10951095
"#elif POSEVERTTYPE == 2 \n"
10961096
" layout (location = 0) in vec2 in_uv;\n"
10971097
"\n"
1098-
" uniform int u_numVerts;\n"
1099-
" uniform int u_numPoses;\n"
1098+
" layout(location=0) uniform int NumVerts;\n"
1099+
" layout(location=1) uniform int NumPoses;\n"
11001100
"\n"
11011101
" layout (std430, binding = 2) restrict readonly buffer PoseData\n"
11021102
" {\n"
@@ -1105,9 +1105,9 @@ ALIAS_INSTANCE_BUFFER
11051105
"\n"
11061106
" PoseVertex GetPoseVertex (uint pose)\n"
11071107
" {\n"
1108-
" uint safePose = clamp(pose, 0u, uint(u_numPoses - 1));\n"
1108+
" uint safePose = clamp(pose, 0u, uint(NumPoses - 1));\n"
11091109
"\n"
1110-
" int index = int(safePose) * u_numVerts + gl_VertexID;\n"
1110+
" int index = int(safePose) * NumVerts + gl_VertexID;\n"
11111111
" uvec2 data = PackedPosNor[index];\n"
11121112
" PoseVertex ret;\n"
11131113
" ret.pos = vec3((ivec3(data.xxy >> uvec3(0, 16, 0)) & 65535) - 32768);\n"

Quake/glquake.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,6 @@ typedef struct glprogs_s {
534534
GLuint skycubemap[2][2]; // [anim][dither]
535535
GLuint skyboxside[2]; // [dither]
536536
GLuint alias[2][3][2][3]; // [OIT][mode:standard/dithered/noperspective][alpha test][poseverttype]
537-
GLint alias_numverts_loc;
538-
GLint alias_numposes_loc;
539537
GLuint sprites[2]; // [dither]
540538
GLuint particles[2][2]; // [OIT][dither]
541539
GLuint debug3d;

Quake/r_alias.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,8 @@ void R_FlushAliasInstances (qboolean showtris)
409409
GL_BindBuffersRange (GL_SHADER_STORAGE_BUFFER, 1, 2, buffers, offsets, sizes);
410410

411411
if (poseverttype == PV_MD3) {
412-
GL_Uniform1iFunc (glprogs.alias_numverts_loc, hdr->numverts_vbo);
413-
GL_Uniform1iFunc (glprogs.alias_numposes_loc, hdr->numposes);
412+
GL_Uniform1iFunc (0, hdr->numverts_vbo);
413+
GL_Uniform1iFunc (1, hdr->numposes);
414414
}
415415
GL_BindTextures (0, 2, textures);
416416
GL_DrawElementsInstancedFunc (GL_TRIANGLES, hdr->numindexes, GL_UNSIGNED_SHORT, (void*)hdr->eboofs, ibuf.count);
@@ -463,8 +463,8 @@ void R_FlushAliasInstances (qboolean showtris)
463463
GL_BindBuffersRange (GL_SHADER_STORAGE_BUFFER, 1, 2, buffers, offsets, sizes);
464464

465465
if (poseverttype == PV_MD3) {
466-
GL_Uniform1iFunc (glprogs.alias_numverts_loc, hdr->numverts_vbo);
467-
GL_Uniform1iFunc (glprogs.alias_numposes_loc, hdr->numposes);
466+
GL_Uniform1iFunc (0, hdr->numverts_vbo);
467+
GL_Uniform1iFunc (1, hdr->numposes);
468468
}
469469
GL_BindTextures (0, 2, textures);
470470
GL_DrawElementsInstancedFunc (GL_TRIANGLES, hdr->numindexes, GL_UNSIGNED_SHORT, (void*)hdr->eboofs, ibuf.count);

0 commit comments

Comments
 (0)