#include "intoverflow.h"
cvar_t gl_max_size = {CF_CLIENT | CF_ARCHIVE, "gl_max_size", "2048", "maximum allowed texture size, can be used to reduce video memory usage, limited by hardware capabilities (typically 2048, 4096, or 8192)"};
-cvar_t gl_max_lightmapsize = {CF_CLIENT | CF_ARCHIVE, "gl_max_lightmapsize", "1024", "maximum allowed texture size for lightmap textures, use larger values to improve rendering speed, as long as there is enough video memory available (setting it too high for the hardware will cause very bad performance)"};
+cvar_t gl_max_lightmapsize = {CF_CLIENT | CF_ARCHIVE, "gl_max_lightmapsize", "512", "maximum allowed texture size for lightmap textures, use larger values to improve rendering speed, as long as there is enough video memory available (setting it too high for the hardware will cause very bad performance)"};
cvar_t gl_picmip = {CF_CLIENT | CF_ARCHIVE, "gl_picmip", "0", "reduces resolution of textures by powers of 2, for example 1 will halve width/height, reducing texture memory usage by 75%"};
cvar_t gl_picmip_world = {CF_CLIENT | CF_ARCHIVE, "gl_picmip_world", "0", "extra picmip level for world textures (may be negative, which will then reduce gl_picmip for these)"};
cvar_t r_picmipworld = {CF_CLIENT | CF_ARCHIVE, "r_picmipworld", "1", "whether gl_picmip shall apply to world textures too (setting this to 0 is a shorthand for gl_picmip_world -9999999)"};
// stores backup copy of texture for deferred texture updates (gl_nopartialtextureupdates cvar)
unsigned char *bufferpixels;
+ unsigned char *modifiedpixels;
+ int modified_width, modified_height, modified_depth;
+ int modified_offset_x, modified_offset_y, modified_offset_z;
qbool buffermodified;
// pointer to texturepool (check this to see if the texture is allocated)
}
R_UploadFullTexture(glt, data);
- if ((glt->flags & TEXF_ALLOWUPDATES) && gl_nopartialtextureupdates.integer)
+ if (glt->flags & TEXF_ALLOWUPDATES)
glt->bufferpixels = (unsigned char *)Mem_Alloc(texturemempool, glt->tilewidth*glt->tileheight*glt->tiledepth*glt->sides*glt->bytesperpixel);
+ glt->modifiedpixels = NULL;
+ glt->modified_width = glt->modified_height = glt->modified_depth = glt->modified_offset_x = glt->modified_offset_y = glt->modified_offset_z = 0;
+
// free any temporary processing buffer we allocated...
if (temppixels)
Mem_Free(temppixels);
return;
}
// update part of the texture
- if (glt->bufferpixels)
+ if (glt->bufferpixels || (glt->bufferpixels && (x || y || z || width != glt->inputwidth || height != glt->inputheight || depth != glt->inputdepth)))
{
int j;
int bpp = glt->bytesperpixel;
height = glt->tileheight - y;
if (width < 1 || height < 1)
return;
- glt->dirty = true;
- glt->buffermodified = true;
+
output += y*outputskip + x*bpp;
+ /* Cloudwalk FIXME: Broken shit, disabled for now.
+ // TODO: Optimize this further.
+ if(!gl_nopartialtextureupdates.integer)
+ {
+ // Calculate the modified region, and resize it as it gets bigger.
+ if(!glt->buffermodified)
+ {
+ glt->modified_offset_x = x;
+ glt->modified_offset_y = y;
+ glt->modified_offset_z = z;
+
+ glt->modified_width = width;
+ glt->modified_height = height;
+ glt->modified_depth = depth;
+ }
+ else
+ {
+ if(x < glt->modified_offset_x) glt->modified_offset_x = x;
+ if(y < glt->modified_offset_y) glt->modified_offset_y = y;
+ if(z < glt->modified_offset_z) glt->modified_offset_z = z;
+
+ if(width + x > glt->modified_width) glt->modified_width = width + x;
+ if(height + y > glt->modified_height) glt->modified_height = height + y;
+ if(depth + z > glt->modified_depth) glt->modified_depth = depth + z;
+ }
+
+ if(!&glt->modifiedpixels || &output < &glt->modifiedpixels)
+ glt->modifiedpixels = output;
+ }
+ */
+
for (j = 0;j < height;j++, output += outputskip, input += inputskip)
memcpy(output, input, width*bpp);
+
+ glt->dirty = true;
+ glt->buffermodified = true;
}
- else if (x || y || z || width != glt->inputwidth || height != glt->inputheight || depth != glt->inputdepth)
- R_UploadPartialTexture(glt, data, x, y, z, width, height, depth);
else
R_UploadFullTexture(glt, data);
}
if (glt->buffermodified && glt->bufferpixels)
{
glt->buffermodified = false;
- R_UploadFullTexture(glt, glt->bufferpixels);
+ if(!glt->modifiedpixels)
+ R_UploadFullTexture(glt, glt->bufferpixels);
+ else
+ R_UploadPartialTexture(glt, glt->modifiedpixels, glt->modified_offset_x, glt->modified_offset_y, glt->modified_offset_z, glt->modified_width, glt->modified_height, glt->modified_depth);
}
+ glt->modified_offset_x = glt->modified_offset_y = glt->modified_offset_z = glt->modified_width = glt->modified_height = glt->modified_depth = 0;
+ glt->modifiedpixels = NULL;
glt->dirty = false;
return glt->texnum;
}