mirror of
https://github.com/ioquake/ioq3.git
synced 2024-11-10 07:11:46 +00:00
Remove packAlign from R_LevelShot()
Filling the resample buffer didn't correctly handle offset for packAlign if it didn't match the alignment returned by Hunk_AllocateTempMemory(). There isn't SIMD or something that the code wants a specific alignment. Hunk_AllocateTempMemory() is aligned to sizeof(intptr_t) anyway so there isn't a reason to add a memory alignment here.
This commit is contained in:
parent
c010b1ffee
commit
af7812f1a0
2 changed files with 18 additions and 46 deletions
|
@ -532,11 +532,10 @@ the menu system, sampled down from full screen distorted images
|
||||||
void R_LevelShot( screenshotType_e type, const char *ext ) {
|
void R_LevelShot( screenshotType_e type, const char *ext ) {
|
||||||
char fileName[MAX_OSPATH];
|
char fileName[MAX_OSPATH];
|
||||||
byte *source, *allsource;
|
byte *source, *allsource;
|
||||||
byte *resample, *resamplestart;
|
byte *resample;
|
||||||
size_t offset = 0, memcount;
|
size_t offset = 0, memcount;
|
||||||
int spadlen, rpadlen;
|
int spadlen;
|
||||||
int padwidth, linelen;
|
int linelen;
|
||||||
GLint packAlign;
|
|
||||||
byte *src, *dst;
|
byte *src, *dst;
|
||||||
int x, y;
|
int x, y;
|
||||||
int r, g, b;
|
int r, g, b;
|
||||||
|
@ -562,21 +561,10 @@ void R_LevelShot( screenshotType_e type, const char *ext ) {
|
||||||
allsource = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &spadlen);
|
allsource = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &spadlen);
|
||||||
source = allsource + offset;
|
source = allsource + offset;
|
||||||
|
|
||||||
//
|
|
||||||
// Based on RB_ReadPixels
|
|
||||||
qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign);
|
|
||||||
|
|
||||||
linelen = width * 3;
|
linelen = width * 3;
|
||||||
padwidth = PAD(linelen, packAlign);
|
memcount = linelen * height;
|
||||||
|
|
||||||
// Allocate a few more bytes so that we can choose an alignment we like
|
resample = ri.Hunk_AllocateTempMemory(memcount);
|
||||||
resample = ri.Hunk_AllocateTempMemory(padwidth * height + offset + packAlign - 1);
|
|
||||||
|
|
||||||
resamplestart = PADP((intptr_t) resample + offset, packAlign);
|
|
||||||
|
|
||||||
offset = resamplestart - resample;
|
|
||||||
rpadlen = padwidth - linelen;
|
|
||||||
//
|
|
||||||
|
|
||||||
// resample from source
|
// resample from source
|
||||||
xScale = glConfig.vidWidth / (float)(width * 4.0f);
|
xScale = glConfig.vidWidth / (float)(width * 4.0f);
|
||||||
|
@ -600,18 +588,16 @@ void R_LevelShot( screenshotType_e type, const char *ext ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memcount = (width * 3 + rpadlen) * height;
|
|
||||||
|
|
||||||
// gamma correct
|
// gamma correct
|
||||||
if(glConfig.deviceSupportsGamma)
|
if(glConfig.deviceSupportsGamma)
|
||||||
R_GammaCorrect(resample + offset, memcount);
|
R_GammaCorrect(resample, memcount);
|
||||||
|
|
||||||
if ( type == ST_TGA )
|
if ( type == ST_TGA )
|
||||||
RE_SaveTGA(fileName, width, height, resample + offset, rpadlen);
|
RE_SaveTGA(fileName, width, height, resample, 0);
|
||||||
else if ( type == ST_JPEG )
|
else if ( type == ST_JPEG )
|
||||||
RE_SaveJPG(fileName, r_screenshotJpegQuality->integer, width, height, resample + offset, rpadlen);
|
RE_SaveJPG(fileName, r_screenshotJpegQuality->integer, width, height, resample, 0);
|
||||||
else if ( type == ST_PNG )
|
else if ( type == ST_PNG )
|
||||||
RE_SavePNG(fileName, width, height, resample + offset, rpadlen);
|
RE_SavePNG(fileName, width, height, resample, 0);
|
||||||
|
|
||||||
ri.Hunk_FreeTempMemory(resample);
|
ri.Hunk_FreeTempMemory(resample);
|
||||||
ri.Hunk_FreeTempMemory(allsource);
|
ri.Hunk_FreeTempMemory(allsource);
|
||||||
|
|
|
@ -623,11 +623,10 @@ the menu system, sampled down from full screen distorted images
|
||||||
void R_LevelShot( screenshotType_e type, const char *ext ) {
|
void R_LevelShot( screenshotType_e type, const char *ext ) {
|
||||||
char fileName[MAX_OSPATH];
|
char fileName[MAX_OSPATH];
|
||||||
byte *source, *allsource;
|
byte *source, *allsource;
|
||||||
byte *resample, *resamplestart;
|
byte *resample;
|
||||||
size_t offset = 0, memcount;
|
size_t offset = 0, memcount;
|
||||||
int spadlen, rpadlen;
|
int spadlen;
|
||||||
int padwidth, linelen;
|
int linelen;
|
||||||
GLint packAlign;
|
|
||||||
byte *src, *dst;
|
byte *src, *dst;
|
||||||
int x, y;
|
int x, y;
|
||||||
int r, g, b;
|
int r, g, b;
|
||||||
|
@ -653,21 +652,10 @@ void R_LevelShot( screenshotType_e type, const char *ext ) {
|
||||||
allsource = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &spadlen);
|
allsource = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &spadlen);
|
||||||
source = allsource + offset;
|
source = allsource + offset;
|
||||||
|
|
||||||
//
|
|
||||||
// Based on RB_ReadPixels
|
|
||||||
qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign);
|
|
||||||
|
|
||||||
linelen = width * 3;
|
linelen = width * 3;
|
||||||
padwidth = PAD(linelen, packAlign);
|
memcount = linelen * height;
|
||||||
|
|
||||||
// Allocate a few more bytes so that we can choose an alignment we like
|
resample = ri.Hunk_AllocateTempMemory(memcount);
|
||||||
resample = ri.Hunk_AllocateTempMemory(padwidth * height + offset + packAlign - 1);
|
|
||||||
|
|
||||||
resamplestart = PADP((intptr_t) resample + offset, packAlign);
|
|
||||||
|
|
||||||
offset = resamplestart - resample;
|
|
||||||
rpadlen = padwidth - linelen;
|
|
||||||
//
|
|
||||||
|
|
||||||
// resample from source
|
// resample from source
|
||||||
xScale = glConfig.vidWidth / (float)(width * 4.0f);
|
xScale = glConfig.vidWidth / (float)(width * 4.0f);
|
||||||
|
@ -691,18 +679,16 @@ void R_LevelShot( screenshotType_e type, const char *ext ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memcount = (width * 3 + rpadlen) * height;
|
|
||||||
|
|
||||||
// gamma correct
|
// gamma correct
|
||||||
if(glConfig.deviceSupportsGamma)
|
if(glConfig.deviceSupportsGamma)
|
||||||
R_GammaCorrect(resample + offset, memcount);
|
R_GammaCorrect(resample, memcount);
|
||||||
|
|
||||||
if ( type == ST_TGA )
|
if ( type == ST_TGA )
|
||||||
RE_SaveTGA(fileName, width, height, resample + offset, rpadlen);
|
RE_SaveTGA(fileName, width, height, resample, 0);
|
||||||
else if ( type == ST_JPEG )
|
else if ( type == ST_JPEG )
|
||||||
RE_SaveJPG(fileName, r_screenshotJpegQuality->integer, width, height, resample + offset, rpadlen);
|
RE_SaveJPG(fileName, r_screenshotJpegQuality->integer, width, height, resample, 0);
|
||||||
else if ( type == ST_PNG )
|
else if ( type == ST_PNG )
|
||||||
RE_SavePNG(fileName, width, height, resample + offset, rpadlen);
|
RE_SavePNG(fileName, width, height, resample, 0);
|
||||||
|
|
||||||
ri.Hunk_FreeTempMemory(resample);
|
ri.Hunk_FreeTempMemory(resample);
|
||||||
ri.Hunk_FreeTempMemory(allsource);
|
ri.Hunk_FreeTempMemory(allsource);
|
||||||
|
|
Loading…
Reference in a new issue