]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
removed TEXF_MANUALFLUSHUPDATES flag, now bufferpixels flushing occurs
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 28 Dec 2009 14:29:05 +0000 (14:29 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 28 Dec 2009 14:29:05 +0000 (14:29 +0000)
automatically when R_Mesh_TexBind uses the texture
changed default value of gl_nopartialtextureupdates from 0 to 1

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9725 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c
gl_textures.c
model_brush.c
r_textures.h

index 6b3dcf9d76379344d4b72bc69b001d5adbad23f9..abf2ab9ed4cdf4925309c0ba7dd0d495ab6f30c9 100644 (file)
@@ -11759,17 +11759,6 @@ void R_DrawWorldSurfaces(qboolean skysurfaces, qboolean writedepth, qboolean dep
                                }
                        }
                }
-               if (updated)
-               {
-                       int count = model->brushq3.num_mergedlightmaps;
-                       for (i = 0;i < count;i++)
-                       {
-                               if (model->brushq3.data_deluxemaps[i])
-                                       R_FlushTexture(model->brushq3.data_deluxemaps[i]);
-                               if (model->brushq3.data_lightmaps[i])
-                                       R_FlushTexture(model->brushq3.data_lightmaps[i]);
-                       }
-               }
        }
        // don't do anything if there were no surfaces
        if (!numsurfacelist)
@@ -11891,17 +11880,6 @@ void R_DrawModelSurfaces(entity_render_t *ent, qboolean skysurfaces, qboolean wr
                                R_BuildLightMap(ent, surfaces + j);
                        }
                }
-               if (updated)
-               {
-                       int count = model->brushq3.num_mergedlightmaps;
-                       for (i = 0;i < count;i++)
-                       {
-                               if (model->brushq3.data_deluxemaps[i])
-                                       R_FlushTexture(model->brushq3.data_deluxemaps[i]);
-                               if (model->brushq3.data_lightmaps[i])
-                                       R_FlushTexture(model->brushq3.data_lightmaps[i]);
-                       }
-               }
        }
        if (update)
                for (j = model->firstmodelsurface, endj = model->firstmodelsurface + model->nummodelsurfaces;j < endj;j++)
index e81ae04124f7e1937ac49e08d96c5ac9dda1a374..318ddecb552be6a5968d8f5f1bda4a09b899c65a 100644 (file)
@@ -19,7 +19,7 @@ cvar_t gl_texturecompression_q3bsplightmaps = {CVAR_SAVE, "gl_texturecompression
 cvar_t gl_texturecompression_q3bspdeluxemaps = {CVAR_SAVE, "gl_texturecompression_q3bspdeluxemaps", "0", "whether to compress deluxemaps in q3bsp format levels (only levels compiled with q3map2 -deluxe have these)"};
 cvar_t gl_texturecompression_sky = {CVAR_SAVE, "gl_texturecompression_sky", "0", "whether to compress sky textures"};
 cvar_t gl_texturecompression_lightcubemaps = {CVAR_SAVE, "gl_texturecompression_lightcubemaps", "1", "whether to compress light cubemaps (spotlights and other light projection images)"};
-cvar_t gl_nopartialtextureupdates = {CVAR_SAVE, "gl_nopartialtextureupdates", "0", "use alternate path for dynamic lightmap updates"};
+cvar_t gl_nopartialtextureupdates = {CVAR_SAVE, "gl_nopartialtextureupdates", "1", "use alternate path for dynamic lightmap updates that avoids a possibly slow code path in the driver"};
 
 int            gl_filter_min = GL_LINEAR_MIPMAP_LINEAR;
 int            gl_filter_mag = GL_LINEAR;
@@ -98,7 +98,7 @@ typedef struct gltexture_s
        void *updatacallback_data;
        // --- [11/22/2007 Black]
 
-       // stores backup copy of texture for deferred texture updates (r_nopartialtextureupdates cvar)
+       // stores backup copy of texture for deferred texture updates (gl_nopartialtextureupdates cvar)
        unsigned char *bufferpixels;
        qboolean buffermodified;
 
@@ -927,20 +927,6 @@ static void R_Upload(gltexture_t *glt, const unsigned char *data, int fragx, int
        qglBindTexture(gltexturetypeenums[glt->texturetype], oldbindtexnum);CHECKGLERROR
 }
 
-int R_RealGetTexture(rtexture_t *rt)
-{
-       if (rt)
-       {
-               gltexture_t *glt;
-               glt = (gltexture_t *)rt;
-               if (glt->flags & GLTEXF_DYNAMIC)
-                       R_UpdateDynamicTexture(glt);
-               return glt->texnum;
-       }
-       else
-               return 0;
-}
-
 static rtexture_t *R_SetupTexture(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, int depth, int sides, int flags, textype_t textype, int texturetype, const unsigned char *data, const unsigned int *palette)
 {
        int i, size;
@@ -1157,30 +1143,34 @@ void R_UpdateTexture(rtexture_t *rt, const unsigned char *data, int x, int y, in
                        height = glt->tileheight - y;
                if (width < 1 || height < 1)
                        return;
+               glt->dirty = true;
                glt->buffermodified = true;
                output += y*outputskip + x*bpp;
                for (j = 0;j < height;j++, output += outputskip, input += inputskip)
                        memcpy(output, input, width*bpp);
-               if (!(glt->flags & TEXF_MANUALFLUSHUPDATES))
-                       R_FlushTexture(rt);
        }
        else
                R_Upload(glt, data, x, y, 0, width, height, 1);
 }
 
-void R_FlushTexture(rtexture_t *rt)
+int R_RealGetTexture(rtexture_t *rt)
 {
-       gltexture_t *glt;
-       if (rt == NULL)
-               Host_Error("R_FlushTexture: no texture supplied");
-
-       // update part of the texture
-       glt = (gltexture_t *)rt;
-
-       if (!glt->buffermodified || !glt->bufferpixels)
-               return;
-       glt->buffermodified = false;
-       R_Upload(glt, glt->bufferpixels, 0, 0, 0, glt->tilewidth, glt->tileheight, glt->tiledepth);
+       if (rt)
+       {
+               gltexture_t *glt;
+               glt = (gltexture_t *)rt;
+               if (glt->flags & GLTEXF_DYNAMIC)
+                       R_UpdateDynamicTexture(glt);
+               if (glt->buffermodified && glt->bufferpixels)
+               {
+                       glt->buffermodified = false;
+                       R_Upload(glt, glt->bufferpixels, 0, 0, 0, glt->tilewidth, glt->tileheight, glt->tiledepth);
+               }
+               glt->dirty = false;
+               return glt->texnum;
+       }
+       else
+               return 0;
 }
 
 void R_ClearTexture (rtexture_t *rt)
index b164254860002a72c340a129184ba6de5d36ddf0..4e9ac3a6729798752e60af60dd5111d1e4180486 100644 (file)
@@ -2444,9 +2444,9 @@ static void Mod_Q1BSP_LoadFaces(lump_t *l)
                                loadmodel->brushq3.num_mergedlightmaps = lightmapnumber + 1;
                                loadmodel->brushq3.data_lightmaps = Mem_Realloc(loadmodel->mempool, loadmodel->brushq3.data_lightmaps, loadmodel->brushq3.num_mergedlightmaps * sizeof(loadmodel->brushq3.data_lightmaps[0]));
                                loadmodel->brushq3.data_deluxemaps = Mem_Realloc(loadmodel->mempool, loadmodel->brushq3.data_deluxemaps, loadmodel->brushq3.num_mergedlightmaps * sizeof(loadmodel->brushq3.data_deluxemaps[0]));
-                               loadmodel->brushq3.data_lightmaps[lightmapnumber] = lightmaptexture = R_LoadTexture2D(loadmodel->texturepool, va("lightmap%i", lightmapnumber), lightmapsize, lightmapsize, NULL, TEXTYPE_BGRA, TEXF_FORCELINEAR | TEXF_ALLOWUPDATES | TEXF_MANUALFLUSHUPDATES, NULL);
+                               loadmodel->brushq3.data_lightmaps[lightmapnumber] = lightmaptexture = R_LoadTexture2D(loadmodel->texturepool, va("lightmap%i", lightmapnumber), lightmapsize, lightmapsize, NULL, TEXTYPE_BGRA, TEXF_FORCELINEAR | TEXF_ALLOWUPDATES, NULL);
                                if (loadmodel->brushq1.nmaplightdata)
-                                       loadmodel->brushq3.data_deluxemaps[lightmapnumber] = deluxemaptexture = R_LoadTexture2D(loadmodel->texturepool, va("deluxemap%i", lightmapnumber), lightmapsize, lightmapsize, NULL, TEXTYPE_BGRA, TEXF_FORCELINEAR | TEXF_ALLOWUPDATES | TEXF_MANUALFLUSHUPDATES, NULL);
+                                       loadmodel->brushq3.data_deluxemaps[lightmapnumber] = deluxemaptexture = R_LoadTexture2D(loadmodel->texturepool, va("deluxemap%i", lightmapnumber), lightmapsize, lightmapsize, NULL, TEXTYPE_BGRA, TEXF_FORCELINEAR | TEXF_ALLOWUPDATES, NULL);
                                lightmapnumber++;
                                Mod_AllocLightmap_Reset(&allocState);
                                Mod_AllocLightmap_Block(&allocState, ssize, tsize, &lightmapx, &lightmapy);
@@ -4695,9 +4695,9 @@ static void Mod_Q3BSP_LoadLightmaps(lump_t *l, lump_t *faceslump)
                                        ;
                                if (developer_loading.integer)
                                        Con_Printf("lightmap merge texture #%i is %ix%i (%i of %i used)\n", lightmapindex, mergewidth*size, mergeheight*size, min(j, mergewidth*mergeheight), mergewidth*mergeheight);
-                               loadmodel->brushq3.data_lightmaps[lightmapindex] = R_LoadTexture2D(loadmodel->texturepool, va("lightmap%04i", lightmapindex), mergewidth * size, mergeheight * size, NULL, TEXTYPE_BGRA, TEXF_FORCELINEAR | (gl_texturecompression_q3bsplightmaps.integer ? TEXF_COMPRESS : TEXF_ALLOWUPDATES | TEXF_MANUALFLUSHUPDATES), NULL);
+                               loadmodel->brushq3.data_lightmaps[lightmapindex] = R_LoadTexture2D(loadmodel->texturepool, va("lightmap%04i", lightmapindex), mergewidth * size, mergeheight * size, NULL, TEXTYPE_BGRA, TEXF_FORCELINEAR | (gl_texturecompression_q3bsplightmaps.integer ? TEXF_COMPRESS : TEXF_ALLOWUPDATES), NULL);
                                if (loadmodel->brushq3.data_deluxemaps)
-                                       loadmodel->brushq3.data_deluxemaps[lightmapindex] = R_LoadTexture2D(loadmodel->texturepool, va("deluxemap%04i", lightmapindex), mergewidth * size, mergeheight * size, NULL, TEXTYPE_BGRA, TEXF_FORCELINEAR | (gl_texturecompression_q3bspdeluxemaps.integer ? TEXF_COMPRESS : TEXF_ALLOWUPDATES | TEXF_MANUALFLUSHUPDATES), NULL);
+                                       loadmodel->brushq3.data_deluxemaps[lightmapindex] = R_LoadTexture2D(loadmodel->texturepool, va("deluxemap%04i", lightmapindex), mergewidth * size, mergeheight * size, NULL, TEXTYPE_BGRA, TEXF_FORCELINEAR | (gl_texturecompression_q3bspdeluxemaps.integer ? TEXF_COMPRESS : TEXF_ALLOWUPDATES), NULL);
                        }
                        mergewidth = R_TextureWidth(loadmodel->brushq3.data_lightmaps[lightmapindex]) / size;
                        mergeheight = R_TextureHeight(loadmodel->brushq3.data_lightmaps[lightmapindex]) / size;
@@ -4717,14 +4717,6 @@ static void Mod_Q3BSP_LoadLightmaps(lump_t *l, lump_t *faceslump)
                }
        }
 
-       for (i = 0;i < loadmodel->brushq3.num_mergedlightmaps;i++)
-       {
-               if (loadmodel->brushq3.data_deluxemaps && loadmodel->brushq3.data_deluxemaps[i])
-                       R_FlushTexture(loadmodel->brushq3.data_deluxemaps[i]);
-               if (loadmodel->brushq3.data_lightmaps[i])
-                       R_FlushTexture(loadmodel->brushq3.data_lightmaps[i]);
-       }
-
        Mem_Free(convertedpixels);
        if(external)
        {
index 63ce2222fce2bb7398832b83f6014dca5810a5b7..07485408387002f2eaf06b4f32262afab9d5cd7b 100644 (file)
 #define TEXF_COMPARE 0x00000800
 // indicates texture should use lower precision where supported
 #define TEXF_LOWPRECISION 0x00001000
-// indicates texture should support R_UpdateTexture
+// indicates texture should support R_UpdateTexture, actual uploads may be delayed until R_Mesh_TexBind if gl_nopartialtextureupdates is on
 #define TEXF_ALLOWUPDATES 0x00002000
-// indicates texture should support R_FlushTexture (improving speed on multiple partial updates per draw)
-#define TEXF_MANUALFLUSHUPDATES 0x00004000
 // used for checking if textures mismatch
 #define TEXF_IMPORTANTBITS (TEXF_ALPHA | TEXF_MIPMAP | TEXF_CLAMP | TEXF_FORCENEAREST | TEXF_FORCELINEAR | TEXF_PICMIP | TEXF_COMPRESS | TEXF_COMPARE | TEXF_LOWPRECISION)
 
@@ -95,12 +93,9 @@ rtexture_t *R_LoadTextureShadowMapCube(rtexturepool_t *rtexturepool, const char
 void R_FreeTexture(rtexture_t *rt);
 
 // update a portion of the image data of a texture, used by lightmap updates
-// and procedural textures such as video playback.
-// if TEXF_MANUALFLUSHUPDATES is used, you MUST call R_FlushTexture to apply the updates
+// and procedural textures such as video playback, actual uploads may be
+// delayed by gl_nopartialtextureupdates cvar until R_Mesh_TexBind uses it
 void R_UpdateTexture(rtexture_t *rt, const unsigned char *data, int x, int y, int width, int height);
-// if TEXF_MANUALFLUSHUPDATES is used, call this to apply the updates,
-// otherwise this function does nothing
-void R_FlushTexture(rtexture_t *rt);
 
 // returns the renderer dependent texture slot number (call this before each
 // use, as a texture might not have been precached)