- use the templated warp functions instead of the limited GZDoom 1.x version. gl_WarpBuffer has been removed.

This commit is contained in:
Christoph Oelckers 2016-04-28 19:04:01 +02:00
parent 27a3b6aafd
commit e3fad118d2
3 changed files with 14 additions and 89 deletions

View File

@ -123,88 +123,6 @@ void gl_SetTextureMode(int type)
}
}
//===========================================================================
//
// FGLTex::WarpBuffer
//
//===========================================================================
BYTE *gl_WarpBuffer(BYTE *buffer, int Width, int Height, int warp, float Speed)
{
if (Width > 256 || Height > 256) return buffer;
DWORD *in = (DWORD*)buffer;
DWORD *out = (DWORD*)new BYTE[4 * Width*Height];
static DWORD linebuffer[256]; // anything larger will bring down performance so it is excluded above.
DWORD timebase = DWORD(r_FrameTime*Speed * 23 / 28);
int xsize = Width;
int ysize = Height;
int xmask = xsize - 1;
int ymask = ysize - 1;
int ds_xbits;
int i;
if (warp == 1)
{
for (ds_xbits = -1, i = Width; i; i >>= 1, ds_xbits++);
// pending consolidation with the software renderer's code.
/*
for (x = xsize - 1; x >= 0; x--)
{
int yt, yf = (finesine[(timebase + (x + 17) * 128)&FINEMASK] >> 13) & ymask;
const DWORD *source = in + x;
DWORD *dest = out + x;
for (yt = ysize; yt; yt--, yf = (yf + 1)&ymask, dest += xsize)
{
*dest = *(source + (yf << ds_xbits));
}
}
timebase = DWORD(r_FrameTime*Speed * 32 / 28);
int y;
for (y = ysize - 1; y >= 0; y--)
{
int xt, xf = (finesine[(timebase + y * 128)&FINEMASK] >> 13) & xmask;
DWORD *source = out + (y << ds_xbits);
DWORD *dest = linebuffer;
for (xt = xsize; xt; xt--, xf = (xf + 1)&xmask)
{
*dest++ = *(source + xf);
}
memcpy(out + y*xsize, linebuffer, xsize * sizeof(DWORD));
}
*/
}
else
{
int ybits;
for (ybits = -1, i = ysize; i; i >>= 1, ybits++);
/*
DWORD timebase = (r_FrameTime * Speed * 40 / 28);
for (x = xsize - 1; x >= 0; x--)
{
for (int y = ysize - 1; y >= 0; y--)
{
int xt = (x + 128
+ ((finesine[(y * 128 + timebase * 5 + 900) & 8191] * 2) >> FRACBITS)
+ ((finesine[(x * 256 + timebase * 4 + 300) & 8191] * 2) >> FRACBITS)) & xmask;
int yt = (y + 128
+ ((finesine[(y * 128 + timebase * 3 + 700) & 8191] * 2) >> FRACBITS)
+ ((finesine[(x * 256 + timebase * 4 + 1200) & 8191] * 2) >> FRACBITS)) & ymask;
const DWORD *source = in + (xt << ybits) + yt;
DWORD *dest = out + (x << ybits) + y;
*dest = *source;
}
}
*/
}
delete[] buffer;
return (BYTE*)out;
}
//==========================================================================
//
//

View File

@ -47,6 +47,7 @@
#include "templates.h"
#include "sc_man.h"
#include "colormatcher.h"
#include "textures/warpbuffer.h"
//#include "gl/gl_intern.h"
@ -72,7 +73,6 @@ EXTERN_CVAR(Bool, gl_texture_usehires)
// The GL texture maintenance class
//
//===========================================================================
BYTE *gl_WarpBuffer(BYTE *buffer, int Width, int Height, int warp, float Speed);
//===========================================================================
//
@ -310,11 +310,18 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla
if (!tex->bHasCanvas)
{
buffer = CreateTexBuffer(translation, w, h, hirescheck, true, alphatrans);
if (tex->bWarped && gl.glslversion == 0)
if (tex->bWarped && gl.glslversion == 0 && w*h <= 256*256) // do not software-warp larger textures, especially on the old systems that still need this fallback.
{
// need to warp
buffer = gl_WarpBuffer(buffer, w, h, tex->bWarped, static_cast<FWarpTexture*>(tex)->GetSpeed());
static_cast<FWarpTexture*>(tex)->GenTime = r_FrameTime;
// need to do software warping
FWarpTexture *wt = static_cast<FWarpTexture*>(tex);
unsigned char *warpbuffer = new unsigned char[w*h*4];
if (tex->bWarped != 2)
WarpBufferType1((DWORD*)warpbuffer, (const DWORD*)buffer, w, h, wt->WidthOffsetMultiplier, wt->HeightOffsetMultiplier, r_FrameTime, wt->Speed);
else
WarpBufferType2((DWORD*)warpbuffer, (const DWORD*)buffer, w, h, wt->WidthOffsetMultiplier, wt->HeightOffsetMultiplier, r_FrameTime, wt->Speed);
delete[] buffer;
buffer = warpbuffer;
wt->GenTime = r_FrameTime;
}
tex->ProcessData(buffer, w, h, false);
}

View File

@ -555,12 +555,12 @@ public:
FTexture *GetRedirect(bool wantwarped);
DWORD GenTime;
float Speed;
int WidthOffsetMultiplier, HeightOffsetMultiplier; // [mxd]
protected:
FTexture *SourcePic;
BYTE *Pixels;
Span **Spans;
float Speed;
int WidthOffsetMultiplier, HeightOffsetMultiplier; // [mxd]
virtual void MakeTexture (DWORD time);
int NextPo2 (int v); // [mxd]