X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=gl_rmain.c;h=a8a92dd1b6fa63ec91ad7491417689ea105b5df3;hb=HEAD;hp=aae45056151281c32ad1ae9c38b5d74c4e613e08;hpb=aaf4625d4da84828ce7bde206e3b5b60de77f9e5;p=xonotic%2Fdarkplaces.git diff --git a/gl_rmain.c b/gl_rmain.c index aae45056..7113caca 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -254,7 +254,7 @@ cvar_t r_buffermegs[R_BUFFERDATA_COUNT] = {CF_CLIENT | CF_ARCHIVE, "r_buffermegs_uniform", "0.25", "uniform buffer size for one frame"}, }; -cvar_t r_q1bsp_lightmap_updates_enabled = {CF_CLIENT | CF_ARCHIVE, "r_q1bsp_lightmap_updates_enabled", "1", "allow lightmaps to be updated on Q1BSP maps (don't turn this off except for debugging)"}; +cvar_t r_q1bsp_lightmap_updates_enabled = {CF_CLIENT, "r_q1bsp_lightmap_updates_enabled", "1", "allow lightmaps to be updated on Q1BSP maps (don't turn this off except for debugging)"}; cvar_t r_q1bsp_lightmap_updates_combine = {CF_CLIENT | CF_ARCHIVE, "r_q1bsp_lightmap_updates_combine", "2", "combine lightmap texture updates to make fewer glTexSubImage2D calls, modes: 0 = immediately upload lightmaps (may be thousands of small 3x3 updates), 1 = combine to one call, 2 = combine to one full texture update (glTexImage2D) which tells the driver it does not need to lock the resource (faster on most drivers)"}; cvar_t r_q1bsp_lightmap_updates_hidden_surfaces = {CF_CLIENT | CF_ARCHIVE, "r_q1bsp_lightmap_updates_hidden_surfaces", "0", "update lightmaps on surfaces that are not visible, so that updates only occur on frames where lightstyles changed value (animation or light switches), only makes sense with combine = 2"}; @@ -533,7 +533,7 @@ static void R_BuildFogHeightTexture(void) float c[4]; float f; inpixels = NULL; - strlcpy(r_refdef.fogheighttexturename, r_refdef.fog_height_texturename, sizeof(r_refdef.fogheighttexturename)); + dp_strlcpy(r_refdef.fogheighttexturename, r_refdef.fog_height_texturename, sizeof(r_refdef.fogheighttexturename)); if (r_refdef.fogheighttexturename[0]) inpixels = loadimagepixelsbgra(r_refdef.fogheighttexturename, true, false, false, NULL); if (!inpixels) @@ -1023,7 +1023,7 @@ static char *ShaderModeInfo_GetShaderText(shadermodeinfo_t *modeinfo, qbool prin static void R_GLSL_CompilePermutation(r_glsl_permutation_t *p, unsigned int mode, uint64_t permutation) { - int i; + unsigned i; int ubibind; int sampler; shadermodeinfo_t *modeinfo = &shadermodeinfo[SHADERLANGUAGE_GLSL][mode]; @@ -1044,7 +1044,7 @@ static void R_GLSL_CompilePermutation(r_glsl_permutation_t *p, unsigned int mode permutationname[0] = 0; sourcestring = ShaderModeInfo_GetShaderText(modeinfo, true, false); - strlcat(permutationname, modeinfo->filename, sizeof(permutationname)); + dp_strlcat(permutationname, modeinfo->filename, sizeof(permutationname)); // we need 140 for r_glsl_skeletal (GL_ARB_uniform_buffer_object) if(vid.support.glshaderversion >= 140) @@ -1098,7 +1098,7 @@ static void R_GLSL_CompilePermutation(r_glsl_permutation_t *p, unsigned int mode vertstrings_list[vertstrings_count++] = modeinfo->pretext; geomstrings_list[geomstrings_count++] = modeinfo->pretext; fragstrings_list[fragstrings_count++] = modeinfo->pretext; - strlcat(permutationname, modeinfo->name, sizeof(permutationname)); + dp_strlcat(permutationname, modeinfo->name, sizeof(permutationname)); // now add all the permutation pretexts for (i = 0;i < SHADERPERMUTATION_COUNT;i++) @@ -1108,7 +1108,7 @@ static void R_GLSL_CompilePermutation(r_glsl_permutation_t *p, unsigned int mode vertstrings_list[vertstrings_count++] = shaderpermutationinfo[i].pretext; geomstrings_list[geomstrings_count++] = shaderpermutationinfo[i].pretext; fragstrings_list[fragstrings_count++] = shaderpermutationinfo[i].pretext; - strlcat(permutationname, shaderpermutationinfo[i].name, sizeof(permutationname)); + dp_strlcat(permutationname, shaderpermutationinfo[i].name, sizeof(permutationname)); } else { @@ -1359,7 +1359,7 @@ static void R_SetupShader_SetPermutationGLSL(unsigned int mode, uint64_t permuta if (!r_glsl_permutation->program) { // remove features until we find a valid permutation - int i; + unsigned i; for (i = 0;i < SHADERPERMUTATION_COUNT;i++) { // reduce i more quickly whenever it would not remove any bits @@ -1418,7 +1418,8 @@ void R_GLSL_Restart_f(cmd_state_t *cmd) static void R_GLSL_DumpShader_f(cmd_state_t *cmd) { - int i, language, mode, dupe; + unsigned i; + int language, mode, dupe; char *text; shadermodeinfo_t *modeinfo; qfile_t *file; @@ -2260,7 +2261,7 @@ skinframe_t *R_SkinFrame_Find(const char *name, int textureflags, int comparewid return NULL; item = (skinframe_t *)Mem_ExpandableArray_AllocRecord(&r_skinframe.array); memset(item, 0, sizeof(*item)); - strlcpy(item->basename, basename, sizeof(item->basename)); + dp_strlcpy(item->basename, basename, sizeof(item->basename)); item->textureflags = compareflags; item->comparewidth = comparewidth; item->compareheight = compareheight; @@ -2989,7 +2990,7 @@ rtexture_t *R_GetCubemap(const char *basename) return r_texture_whitecube; r_texture_numcubemaps++; r_texture_cubemaps[i] = (cubemapinfo_t *)Mem_Alloc(r_main_mempool, sizeof(cubemapinfo_t)); - strlcpy(r_texture_cubemaps[i]->basename, basename, sizeof(r_texture_cubemaps[i]->basename)); + dp_strlcpy(r_texture_cubemaps[i]->basename, basename, sizeof(r_texture_cubemaps[i]->basename)); r_texture_cubemaps[i]->texture = R_LoadCubemap(r_texture_cubemaps[i]->basename); return r_texture_cubemaps[i]->texture; } @@ -3010,8 +3011,6 @@ static void R_Main_FreeViewCache(void) static void R_Main_ResizeViewCache(void) { int numentities = r_refdef.scene.numentities; - int numclusters = r_refdef.scene.worldmodel ? r_refdef.scene.worldmodel->brush.num_pvsclusters : 1; - int numclusterbytes = r_refdef.scene.worldmodel ? r_refdef.scene.worldmodel->brush.num_pvsclusterbytes : 1; int numleafs = r_refdef.scene.worldmodel ? r_refdef.scene.worldmodel->brush.num_leafs : 1; int numsurfaces = r_refdef.scene.worldmodel ? r_refdef.scene.worldmodel->num_surfaces : 1; if (r_refdef.viewcache.maxentities < numentities) @@ -3021,14 +3020,7 @@ static void R_Main_ResizeViewCache(void) Mem_Free(r_refdef.viewcache.entityvisible); r_refdef.viewcache.entityvisible = (unsigned char *)Mem_Alloc(r_main_mempool, r_refdef.viewcache.maxentities); } - if (r_refdef.viewcache.world_numclusters != numclusters) - { - r_refdef.viewcache.world_numclusters = numclusters; - r_refdef.viewcache.world_numclusterbytes = numclusterbytes; - if (r_refdef.viewcache.world_pvsbits) - Mem_Free(r_refdef.viewcache.world_pvsbits); - r_refdef.viewcache.world_pvsbits = (unsigned char *)Mem_Alloc(r_main_mempool, r_refdef.viewcache.world_numclusterbytes); - } + // bones_was_here: r_refdef.viewcache.world_pvsbits was (re)allocated here, now done in Mod_BSP_FatPVS() if (r_refdef.viewcache.world_numleafs != numleafs) { r_refdef.viewcache.world_numleafs = numleafs; @@ -4379,7 +4371,7 @@ static void R_View_SetFrustum(const int *scissor) //PlaneClassify(&frustum[4]); } -static void R_View_UpdateWithScissor(const int *myscissor) +static void R_View_Update(const int *myscissor) { R_Main_ResizeViewCache(); R_View_SetFrustum(myscissor); @@ -4387,14 +4379,6 @@ static void R_View_UpdateWithScissor(const int *myscissor) R_View_UpdateEntityVisible(); } -static void R_View_Update(void) -{ - R_Main_ResizeViewCache(); - R_View_SetFrustum(NULL); - R_View_WorldVisibility(!r_refdef.view.usevieworiginculling); - R_View_UpdateEntityVisible(); -} - float viewscalefpsadjusted = 1.0f; void R_SetupView(qbool allowwaterclippingplane, int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight) @@ -4418,7 +4402,7 @@ void R_SetupView(qbool allowwaterclippingplane, int viewfbo, rtexture_t *viewdep // GL is weird because it's bottom to top, r_refdef.view.y is top to bottom. // Unless the render target is a FBO... - viewy_adjusted = viewfbo ? viewy : vid.height - viewheight - viewy; + viewy_adjusted = viewfbo ? viewy : vid.mode.height - viewheight - viewy; if (!r_refdef.view.useperspective) R_Viewport_InitOrtho3D(&r_refdef.view.viewport, &r_refdef.view.matrix, viewx, viewy_adjusted, viewwidth, viewheight, r_refdef.view.ortho_x, r_refdef.view.ortho_y, -r_refdef.farclip, r_refdef.farclip, customclipplane); @@ -4461,7 +4445,7 @@ void R_ResetViewRendering2D_Common(int viewfbo, rtexture_t *viewdepthtexture, rt // GL is weird because it's bottom to top, r_refdef.view.y is top to bottom. // Unless the render target is a FBO... - viewy_adjusted = viewfbo ? viewy : vid.height - viewheight - viewy; + viewy_adjusted = viewfbo ? viewy : vid.mode.height - viewheight - viewy; R_Viewport_InitOrtho(&viewport, &identitymatrix, viewx, viewy_adjusted, viewwidth, viewheight, 0, 0, x2, y2, -10, 100, NULL); R_Mesh_SetRenderTargets(viewfbo, viewdepthtexture, viewcolortexture, NULL, NULL, NULL); @@ -4761,7 +4745,7 @@ void R_Water_AddWaterPlane(msurface_t *surface, int entno) if (p->materialflags & (MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_REFLECTION) && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brush.FatPVS && r_refdef.scene.worldmodel->brush.PointInLeaf && r_refdef.scene.worldmodel->brush.PointInLeaf(r_refdef.scene.worldmodel, center)->clusterindex >= 0) { - r_refdef.scene.worldmodel->brush.FatPVS(r_refdef.scene.worldmodel, center, 2, p->pvsbits, sizeof(p->pvsbits), p->pvsvalid); + r_refdef.scene.worldmodel->brush.FatPVS(r_refdef.scene.worldmodel, center, 2, &p->pvsbits, r_main_mempool, p->pvsvalid); p->pvsvalid = true; } } @@ -4867,10 +4851,7 @@ static void R_Water_ProcessPlanes(int fbo, rtexture_t *depthtexture, rtexture_t GL_ScissorTest(false); R_ClearScreen(r_refdef.fogenabled); GL_ScissorTest(true); - if(r_water_scissormode.integer & 2) - R_View_UpdateWithScissor(myscissor); - else - R_View_Update(); + R_View_Update(r_water_scissormode.integer & 2 ? myscissor : NULL); R_AnimCache_CacheVisibleEntities(); if(r_water_scissormode.integer & 1) GL_Scissor(myscissor[0], myscissor[1], myscissor[2], myscissor[3]); @@ -4925,7 +4906,7 @@ static void R_Water_ProcessPlanes(int fbo, rtexture_t *depthtexture, rtexture_t if(r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brush.FatPVS) { r_refdef.view.usecustompvs = true; - r_refdef.scene.worldmodel->brush.FatPVS(r_refdef.scene.worldmodel, visorigin, 2, r_refdef.viewcache.world_pvsbits, (r_refdef.viewcache.world_numclusters+7)>>3, false); + r_refdef.scene.worldmodel->brush.FatPVS(r_refdef.scene.worldmodel, visorigin, 2, &r_refdef.viewcache.world_pvsbits, r_main_mempool, false); } } @@ -4935,10 +4916,7 @@ static void R_Water_ProcessPlanes(int fbo, rtexture_t *depthtexture, rtexture_t GL_ScissorTest(false); R_ClearScreen(r_refdef.fogenabled); GL_ScissorTest(true); - if(r_water_scissormode.integer & 2) - R_View_UpdateWithScissor(myscissor); - else - R_View_Update(); + R_View_Update(r_water_scissormode.integer & 2 ? myscissor : NULL); R_AnimCache_CacheVisibleEntities(); if(r_water_scissormode.integer & 1) GL_Scissor(myscissor[0], myscissor[1], myscissor[2], myscissor[3]); @@ -4983,7 +4961,7 @@ static void R_Water_ProcessPlanes(int fbo, rtexture_t *depthtexture, rtexture_t if(p->camera_entity && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brush.FatPVS) { r_refdef.view.usecustompvs = true; - r_refdef.scene.worldmodel->brush.FatPVS(r_refdef.scene.worldmodel, visorigin, 2, r_refdef.viewcache.world_pvsbits, (r_refdef.viewcache.world_numclusters+7)>>3, false); + r_refdef.scene.worldmodel->brush.FatPVS(r_refdef.scene.worldmodel, visorigin, 2, &r_refdef.viewcache.world_pvsbits, r_main_mempool, false); } // camera needs no clipplane @@ -4999,7 +4977,7 @@ static void R_Water_ProcessPlanes(int fbo, rtexture_t *depthtexture, rtexture_t GL_ScissorTest(false); R_ClearScreen(r_refdef.fogenabled); GL_ScissorTest(true); - R_View_Update(); + R_View_Update(NULL); R_AnimCache_CacheVisibleEntities(); R_RenderScene(rt->fbo, rt->depthtexture, rt->colortexture[0], 0, 0, rt->texturewidth, rt->textureheight); @@ -5011,7 +4989,7 @@ static void R_Water_ProcessPlanes(int fbo, rtexture_t *depthtexture, rtexture_t r_fb.water.renderingscene = false; r_refdef.view = originalview; R_ResetViewRendering3D(fbo, depthtexture, colortexture, viewx, viewy, viewwidth, viewheight); - R_View_Update(); + R_View_Update(NULL); R_AnimCache_CacheVisibleEntities(); goto finish; error: @@ -5083,8 +5061,8 @@ static void R_Bloom_StartFrame(void) viewscalefpsadjusted = 1.0f; scale = r_viewscale.value * sqrt(viewscalefpsadjusted); - if (vid.samples) - scale *= sqrt(vid.samples); // supersampling + if (vid.mode.samples) + scale *= sqrt(vid.mode.samples); // supersampling scale = bound(0.03125f, scale, 4.0f); screentexturewidth = (int)ceil(r_refdef.view.width * scale); screentextureheight = (int)ceil(r_refdef.view.height * scale); @@ -5782,7 +5760,7 @@ void R_RenderView(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, i r_refdef.view.showdebug = true; - R_View_Update(); + R_View_Update(NULL); if (r_timereport_active) R_TimeReport("visibility"); @@ -6575,7 +6553,7 @@ static void R_LoadQWSkin(r_qwskincache_t *cache, const char *skinname) char name[MAX_QPATH]; skinframe_t *skinframe; unsigned char pixels[296*194]; - strlcpy(cache->name, skinname, sizeof(cache->name)); + dp_strlcpy(cache->name, skinname, sizeof(cache->name)); dpsnprintf(name, sizeof(name), "skins/%s.pcx", cache->name); if (developer_loading.integer) Con_Printf("loading %s\n", name); @@ -10197,10 +10175,10 @@ void R_DebugLine(vec3_t start, vec3_t end) Vector4Set(w[1], end[0], end[1], end[2], 1); R_Viewport_TransformToScreen(&r_refdef.view.viewport, w[0], s[0]); R_Viewport_TransformToScreen(&r_refdef.view.viewport, w[1], s[1]); - x1 = s[0][0] * vid_conwidth.value / vid.width; - y1 = (vid.height - s[0][1]) * vid_conheight.value / vid.height; - x2 = s[1][0] * vid_conwidth.value / vid.width; - y2 = (vid.height - s[1][1]) * vid_conheight.value / vid.height; + x1 = s[0][0] * vid_conwidth.value / vid.mode.width; + y1 = (vid.mode.height - s[0][1]) * vid_conheight.value / vid.mode.height; + x2 = s[1][0] * vid_conwidth.value / vid.mode.width; + y2 = (vid.mode.height - s[1][1]) * vid_conheight.value / vid.mode.height; //Con_DPrintf("R_DebugLine: %.0f,%.0f to %.0f,%.0f\n", x1, y1, x2, y2); // add the line to the UI mesh for drawing later @@ -10209,11 +10187,11 @@ void R_DebugLine(vec3_t start, vec3_t end) if (fabs(x2 - x1) > fabs(y2 - y1)) { offsetx = 0; - offsety = 0.5f * width * vid_conheight.value / vid.height; + offsety = 0.5f * width * vid_conheight.value / vid.mode.height; } else { - offsetx = 0.5f * width * vid_conwidth.value / vid.width; + offsetx = 0.5f * width * vid_conwidth.value / vid.mode.width; offsety = 0; } surf = Mod_Mesh_AddSurface(mod, Mod_Mesh_GetTexture(mod, "white", 0, 0, MATERIALFLAG_WALL | MATERIALFLAG_VERTEXCOLOR | MATERIALFLAG_ALPHAGEN_VERTEX | MATERIALFLAG_ALPHA | MATERIALFLAG_BLENDED | MATERIALFLAG_NOSHADOW), true);