mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2024-12-13 13:40:56 +00:00
OpenGL2: Misc fixes and cleanup
Fix two constants in GLSL shaders. Remove f suffix from float and fix int to float assignment. They were causing shader compile errors in OpenGL ES 2 context. Remove disabling clip plane. Clip plane is unused and never enabled in the opengl2 renderer. Remove disabling it to avoid causing a GL error when using OpenGL 3.2 core profile or OpenGL ES. Make VAO cache vertex stride be size of srfVert_t since that is what is uploaded to the GPU. No behavior change. There is a disabled debug id in srfVert_t though which if enabled changes srfVert_t size.
This commit is contained in:
parent
14cc4cc6cb
commit
39e2113c73
11 changed files with 28 additions and 53 deletions
|
@ -56,5 +56,5 @@ void main()
|
|||
current.y *= 0.0625;
|
||||
#endif
|
||||
|
||||
gl_FragColor = vec4(current, 1.0f);
|
||||
gl_FragColor = vec4(current, 1.0);
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ float ambientOcclusion(sampler2D depthMap, const vec2 tex, const float zFarDivZN
|
|||
poissonDisc[7] = vec2(-0.5579782, 0.7491854);
|
||||
poissonDisc[8] = vec2(0.7320465, 0.6317794);
|
||||
|
||||
float result = 0;
|
||||
float result = 0.0;
|
||||
|
||||
float sampleZ = getLinearDepth(depthMap, tex, zFarDivZNear);
|
||||
float scaleZ = zFarDivZNear * sampleZ;
|
||||
|
|
|
@ -58,7 +58,7 @@ void GL_BindToTMU( image_t *image, int tmu )
|
|||
ri.Printf(PRINT_WARNING, "GL_BindToTMU: NULL image\n");
|
||||
}
|
||||
|
||||
GL_BindMultiTexture(GL_TEXTURE0_ARB + tmu, target, texture);
|
||||
GL_BindMultiTexture(GL_TEXTURE0 + tmu, target, texture);
|
||||
}
|
||||
|
||||
|
||||
|
@ -435,7 +435,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
|||
int oldSort;
|
||||
double originalTime;
|
||||
FBO_t* fbo = NULL;
|
||||
qboolean inQuery = qfalse;
|
||||
|
||||
// save original time for entity shader offsets
|
||||
originalTime = backEnd.refdef.floatTime;
|
||||
|
@ -593,10 +592,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
|||
RB_EndSurface();
|
||||
}
|
||||
|
||||
if (inQuery) {
|
||||
qglEndQuery(GL_SAMPLES_PASSED);
|
||||
}
|
||||
|
||||
if (glRefConfig.framebufferObject)
|
||||
FBO_Bind(fbo);
|
||||
|
||||
|
@ -657,7 +652,6 @@ void RB_SetGL2D (void) {
|
|||
GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
|
||||
|
||||
GL_Cull( CT_TWO_SIDED );
|
||||
qglDisable( GL_CLIP_PLANE0 );
|
||||
|
||||
// set time for 2D shaders
|
||||
backEnd.refdef.time = ri.Milliseconds();
|
||||
|
|
|
@ -203,11 +203,11 @@ void R_AddCapShadowmapCmd( int map, int cubeSide ) {
|
|||
|
||||
/*
|
||||
=============
|
||||
R_PostProcessingCmd
|
||||
R_AddPostProcessCmd
|
||||
|
||||
=============
|
||||
*/
|
||||
void R_AddPostProcessCmd( ) {
|
||||
void R_AddPostProcessCmd( void ) {
|
||||
postProcessCommand_t *cmd;
|
||||
|
||||
cmd = R_GetCommandBuffer( sizeof( *cmd ) );
|
||||
|
|
|
@ -35,7 +35,7 @@ static struct
|
|||
}
|
||||
glDsaState;
|
||||
|
||||
void GL_BindNullTextures()
|
||||
void GL_BindNullTextures(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -141,7 +141,7 @@ GLvoid APIENTRY GLDSA_GenerateTextureMipmapEXT(GLuint texture, GLenum target)
|
|||
qglGenerateMipmap(target);
|
||||
}
|
||||
|
||||
void GL_BindNullProgram()
|
||||
void GL_BindNullProgram(void)
|
||||
{
|
||||
qglUseProgram(0);
|
||||
glDsaState.program = 0;
|
||||
|
@ -205,7 +205,7 @@ GLvoid APIENTRY GLDSA_ProgramUniformMatrix4fvEXT(GLuint program, GLint location,
|
|||
qglUniformMatrix4fv(location, count, transpose, value);
|
||||
}
|
||||
|
||||
void GL_BindNullFramebuffers()
|
||||
void GL_BindNullFramebuffers(void)
|
||||
{
|
||||
qglBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glDsaState.drawFramebuffer = glDsaState.readFramebuffer = 0;
|
||||
|
|
|
@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "tr_local.h"
|
||||
#include "tr_dsa.h"
|
||||
|
||||
void GLimp_InitExtraExtensions()
|
||||
void GLimp_InitExtraExtensions(void)
|
||||
{
|
||||
char *extension;
|
||||
const char* result[3] = { "...ignoring %s\n", "...using %s\n", "...%s not found\n" };
|
||||
|
|
|
@ -526,10 +526,6 @@ void RB_RenderFlares (void) {
|
|||
return; // none visible
|
||||
}
|
||||
|
||||
if ( backEnd.viewParms.isPortal ) {
|
||||
qglDisable (GL_CLIP_PLANE0);
|
||||
}
|
||||
|
||||
Mat4Copy(glState.projection, oldprojection);
|
||||
Mat4Copy(glState.modelview, oldmodelview);
|
||||
Mat4Identity(matrix);
|
||||
|
|
|
@ -331,17 +331,6 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLchar *extra, char *
|
|||
AGEN_LIGHTING_SPECULAR,
|
||||
AGEN_PORTAL));
|
||||
|
||||
Q_strcat(dest, size,
|
||||
va("#ifndef texenv_t\n"
|
||||
"#define texenv_t\n"
|
||||
"#define TEXENV_MODULATE %i\n"
|
||||
"#define TEXENV_ADD %i\n"
|
||||
"#define TEXENV_REPLACE %i\n"
|
||||
"#endif\n",
|
||||
GL_MODULATE,
|
||||
GL_ADD,
|
||||
GL_REPLACE));
|
||||
|
||||
fbufWidthScale = 1.0f / ((float)glConfig.vidWidth);
|
||||
fbufHeightScale = 1.0f / ((float)glConfig.vidHeight);
|
||||
Q_strcat(dest, size,
|
||||
|
|
|
@ -435,7 +435,7 @@ void RE_BeginScene(const refdef_t *fd)
|
|||
}
|
||||
|
||||
|
||||
void RE_EndScene()
|
||||
void RE_EndScene(void)
|
||||
{
|
||||
// the next scene rendered in this frame will tack on after this one
|
||||
r_firstSceneDrawSurf = tr.refdef.numDrawSurfs;
|
||||
|
|
|
@ -261,7 +261,6 @@ void RB_ShadowFinish( void ) {
|
|||
qglEnable( GL_STENCIL_TEST );
|
||||
qglStencilFunc( GL_NOTEQUAL, 0, 255 );
|
||||
|
||||
qglDisable (GL_CLIP_PLANE0);
|
||||
GL_Cull( CT_TWO_SIDED );
|
||||
|
||||
GL_BindToTMU( tr.whiteImage, TB_COLORMAP );
|
||||
|
|
|
@ -751,7 +751,7 @@ void VaoCache_Commit(void)
|
|||
if (indexSet < vc.surfaceIndexSets + vc.numSurfaces)
|
||||
{
|
||||
tess.firstIndex = indexSet->bufferOffset / sizeof(glIndex_t);
|
||||
//ri.Printf(PRINT_ALL, "firstIndex %d numIndexes %d as %d\n", tess.firstIndex, tess.numIndexes, batchLength - vc.batchLengths);
|
||||
//ri.Printf(PRINT_ALL, "firstIndex %d numIndexes %d as %d\n", tess.firstIndex, tess.numIndexes, (int)(batchLength - vc.batchLengths));
|
||||
//ri.Printf(PRINT_ALL, "vc.numSurfaces %d vc.numBatches %d\n", vc.numSurfaces, vc.numBatches);
|
||||
}
|
||||
// If not, rebuffer the batch
|
||||
|
@ -792,7 +792,7 @@ void VaoCache_Commit(void)
|
|||
vcq.indexCommitSize += indexesSize;
|
||||
}
|
||||
|
||||
//ri.Printf(PRINT_ALL, "committing %d to %d, %d to %d as %d\n", vcq.vertexCommitSize, vc.vertexOffset, vcq.indexCommitSize, vc.indexOffset, batchLength - vc.batchLengths);
|
||||
//ri.Printf(PRINT_ALL, "committing %d to %d, %d to %d as %d\n", vcq.vertexCommitSize, vc.vertexOffset, vcq.indexCommitSize, vc.indexOffset, (int)(batchLength - vc.batchLengths));
|
||||
|
||||
if (vcq.vertexCommitSize)
|
||||
{
|
||||
|
@ -812,9 +812,6 @@ void VaoCache_Commit(void)
|
|||
|
||||
void VaoCache_Init(void)
|
||||
{
|
||||
srfVert_t vert;
|
||||
int dataSize;
|
||||
|
||||
vc.vao = R_CreateVao("VaoCache", NULL, VAOCACHE_VERTEX_BUFFER_SIZE, NULL, VAOCACHE_INDEX_BUFFER_SIZE, VAO_USAGE_DYNAMIC);
|
||||
|
||||
vc.vao->attribs[ATTR_INDEX_POSITION].enabled = 1;
|
||||
|
@ -849,21 +846,21 @@ void VaoCache_Init(void)
|
|||
vc.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].normalized = GL_TRUE;
|
||||
vc.vao->attribs[ATTR_INDEX_COLOR].normalized = GL_TRUE;
|
||||
|
||||
vc.vao->attribs[ATTR_INDEX_POSITION].offset = 0; dataSize = sizeof(vert.xyz);
|
||||
vc.vao->attribs[ATTR_INDEX_TEXCOORD].offset = dataSize; dataSize += sizeof(vert.st);
|
||||
vc.vao->attribs[ATTR_INDEX_LIGHTCOORD].offset = dataSize; dataSize += sizeof(vert.lightmap);
|
||||
vc.vao->attribs[ATTR_INDEX_NORMAL].offset = dataSize; dataSize += sizeof(vert.normal);
|
||||
vc.vao->attribs[ATTR_INDEX_TANGENT].offset = dataSize; dataSize += sizeof(vert.tangent);
|
||||
vc.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].offset = dataSize; dataSize += sizeof(vert.lightdir);
|
||||
vc.vao->attribs[ATTR_INDEX_COLOR].offset = dataSize; dataSize += sizeof(vert.color);
|
||||
vc.vao->attribs[ATTR_INDEX_POSITION].offset = offsetof(srfVert_t, xyz);
|
||||
vc.vao->attribs[ATTR_INDEX_TEXCOORD].offset = offsetof(srfVert_t, st);
|
||||
vc.vao->attribs[ATTR_INDEX_LIGHTCOORD].offset = offsetof(srfVert_t, lightmap);
|
||||
vc.vao->attribs[ATTR_INDEX_NORMAL].offset = offsetof(srfVert_t, normal);
|
||||
vc.vao->attribs[ATTR_INDEX_TANGENT].offset = offsetof(srfVert_t, tangent);
|
||||
vc.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].offset = offsetof(srfVert_t, lightdir);
|
||||
vc.vao->attribs[ATTR_INDEX_COLOR].offset = offsetof(srfVert_t, color);
|
||||
|
||||
vc.vao->attribs[ATTR_INDEX_POSITION].stride = dataSize;
|
||||
vc.vao->attribs[ATTR_INDEX_TEXCOORD].stride = dataSize;
|
||||
vc.vao->attribs[ATTR_INDEX_LIGHTCOORD].stride = dataSize;
|
||||
vc.vao->attribs[ATTR_INDEX_NORMAL].stride = dataSize;
|
||||
vc.vao->attribs[ATTR_INDEX_TANGENT].stride = dataSize;
|
||||
vc.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].stride = dataSize;
|
||||
vc.vao->attribs[ATTR_INDEX_COLOR].stride = dataSize;
|
||||
vc.vao->attribs[ATTR_INDEX_POSITION].stride = sizeof(srfVert_t);
|
||||
vc.vao->attribs[ATTR_INDEX_TEXCOORD].stride = sizeof(srfVert_t);
|
||||
vc.vao->attribs[ATTR_INDEX_LIGHTCOORD].stride = sizeof(srfVert_t);
|
||||
vc.vao->attribs[ATTR_INDEX_NORMAL].stride = sizeof(srfVert_t);
|
||||
vc.vao->attribs[ATTR_INDEX_TANGENT].stride = sizeof(srfVert_t);
|
||||
vc.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].stride = sizeof(srfVert_t);
|
||||
vc.vao->attribs[ATTR_INDEX_COLOR].stride = sizeof(srfVert_t);
|
||||
|
||||
Vao_SetVertexPointers(vc.vao);
|
||||
|
||||
|
@ -888,7 +885,7 @@ void VaoCache_CheckAdd(qboolean *endSurface, qboolean *recycleVertexBuffer, qboo
|
|||
|
||||
if (vc.vao->vertexesSize < vc.vertexOffset + vcq.vertexCommitSize + vertexesSize)
|
||||
{
|
||||
//ri.Printf(PRINT_ALL, "out of space in vertex cache: %d < %d + %d + %d\n", vc.vao->vertexesSize, vc.vertexOffset, vc.vertexCommitSize, vertexesSize);
|
||||
//ri.Printf(PRINT_ALL, "out of space in vertex cache: %d < %d + %d + %d\n", vc.vao->vertexesSize, vc.vertexOffset, vcq.vertexCommitSize, vertexesSize);
|
||||
*recycleVertexBuffer = qtrue;
|
||||
*recycleIndexBuffer = qtrue;
|
||||
*endSurface = qtrue;
|
||||
|
@ -966,6 +963,6 @@ void VaoCache_AddSurface(srfVert_t *verts, int numVerts, glIndex_t *indexes, int
|
|||
queueEntry->numIndexes = numIndexes;
|
||||
vcq.numSurfaces++;
|
||||
|
||||
vcq.vertexCommitSize += sizeof(srfVert_t) * numVerts;;
|
||||
vcq.vertexCommitSize += sizeof(srfVert_t) * numVerts;
|
||||
vcq.indexCommitSize += sizeof(glIndex_t) * numIndexes;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue