Merge remote-tracking branch 'gzdoom/master' into swmodels
This commit is contained in:
commit
7e544c66fe
356 changed files with 11017 additions and 23856 deletions
|
|
@ -47,7 +47,7 @@ void PolyTriangleDrawer::ClearBuffers(DCanvas *canvas)
|
|||
|
||||
void PolyTriangleDrawer::SetViewport(const DrawerCommandQueuePtr &queue, int x, int y, int width, int height, DCanvas *canvas, bool span_drawers)
|
||||
{
|
||||
uint8_t *dest = (uint8_t*)canvas->GetBuffer();
|
||||
uint8_t *dest = (uint8_t*)canvas->GetPixels();
|
||||
int dest_width = canvas->GetWidth();
|
||||
int dest_height = canvas->GetHeight();
|
||||
int dest_pitch = canvas->GetPitch();
|
||||
|
|
@ -605,7 +605,7 @@ void DrawPolyTrianglesCommand::Execute(DrawerThread *thread)
|
|||
void DrawRectCommand::Execute(DrawerThread *thread)
|
||||
{
|
||||
auto renderTarget = PolyRenderer::Instance()->RenderTarget;
|
||||
const void *destOrg = renderTarget->GetBuffer();
|
||||
const void *destOrg = renderTarget->GetPixels();
|
||||
int destWidth = renderTarget->GetWidth();
|
||||
int destHeight = renderTarget->GetHeight();
|
||||
int destPitch = renderTarget->GetPitch();
|
||||
|
|
|
|||
|
|
@ -39,12 +39,9 @@
|
|||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "swrenderer/r_swcolormaps.h"
|
||||
|
||||
EXTERN_CVAR(Bool, r_shadercolormaps)
|
||||
EXTERN_CVAR(Int, screenblocks)
|
||||
EXTERN_CVAR(Float, r_visibility)
|
||||
|
||||
void InitGLRMapinfoData();
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PolyRenderer *PolyRenderer::Instance()
|
||||
|
|
@ -57,12 +54,12 @@ PolyRenderer::PolyRenderer()
|
|||
{
|
||||
}
|
||||
|
||||
void PolyRenderer::RenderView(player_t *player)
|
||||
void PolyRenderer::RenderView(player_t *player, DCanvas *target)
|
||||
{
|
||||
using namespace swrenderer;
|
||||
|
||||
RenderTarget = screen;
|
||||
|
||||
RenderTarget = target;
|
||||
RenderToCanvas = false;
|
||||
int width = SCREENWIDTH;
|
||||
int height = SCREENHEIGHT;
|
||||
float trueratio;
|
||||
|
|
@ -71,13 +68,6 @@ void PolyRenderer::RenderView(player_t *player)
|
|||
|
||||
RenderActorView(player->mo, false);
|
||||
|
||||
// Apply special colormap if the target cannot do it
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->ShaderColormap() && RenderTarget->IsBgra() && !(r_shadercolormaps && screen->Accel2D))
|
||||
{
|
||||
Threads.MainThread()->DrawQueue->Push<ApplySpecialColormapRGBACommand>(cameraLight->ShaderColormap(), screen);
|
||||
}
|
||||
|
||||
Threads.MainThread()->FlushDrawQueue();
|
||||
PolyDrawerWaitCycles.Clock();
|
||||
DrawerThreads::WaitForWorkers();
|
||||
|
|
@ -90,21 +80,19 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int
|
|||
|
||||
viewwidth = width;
|
||||
RenderTarget = canvas;
|
||||
RenderToCanvas = true;
|
||||
R_SetWindow(Viewpoint, Viewwindow, 12, width, height, height, true);
|
||||
//viewport->SetViewport(&Thread, width, height, Viewwindow.WidescreenRatio);
|
||||
viewwindowx = x;
|
||||
viewwindowy = y;
|
||||
viewactive = true;
|
||||
|
||||
canvas->Lock(true);
|
||||
|
||||
RenderActorView(actor, dontmaplines);
|
||||
Threads.MainThread()->FlushDrawQueue();
|
||||
DrawerThreads::WaitForWorkers();
|
||||
|
||||
canvas->Unlock();
|
||||
|
||||
RenderTarget = screen;
|
||||
RenderTarget = nullptr;
|
||||
RenderToCanvas = false;
|
||||
R_ExecuteSetViewSize(Viewpoint, Viewwindow);
|
||||
float trueratio;
|
||||
ActiveRatio(width, height, &trueratio);
|
||||
|
|
@ -186,7 +174,7 @@ void PolyRenderer::SetSceneViewport()
|
|||
{
|
||||
using namespace swrenderer;
|
||||
|
||||
if (RenderTarget == screen) // Rendering to screen
|
||||
if (!RenderToCanvas) // Rendering to screen
|
||||
{
|
||||
int height;
|
||||
if (screenblocks >= 10)
|
||||
|
|
@ -209,7 +197,6 @@ void PolyRenderer::SetupPerspectiveMatrix()
|
|||
|
||||
if (!bDidSetup)
|
||||
{
|
||||
InitGLRMapinfoData();
|
||||
bDidSetup = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class PolyRenderer
|
|||
public:
|
||||
PolyRenderer();
|
||||
|
||||
void RenderView(player_t *player);
|
||||
void RenderView(player_t *player, DCanvas *target);
|
||||
void RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines);
|
||||
void RenderRemainingPlayerSprites();
|
||||
|
||||
|
|
@ -61,6 +61,7 @@ public:
|
|||
|
||||
PolyRenderThreads Threads;
|
||||
DCanvas *RenderTarget = nullptr;
|
||||
bool RenderToCanvas = false;
|
||||
FViewWindow Viewwindow;
|
||||
FRenderViewpoint Viewpoint;
|
||||
PolyLightVisibility Light;
|
||||
|
|
|
|||
|
|
@ -58,8 +58,9 @@ void RenderPolyDecal::Render(PolyRenderThread *thread, const PolyClipPlane &clip
|
|||
|
||||
// Calculate unclipped position and UV coordinates
|
||||
|
||||
double edge_left = tex->LeftOffset * decal->ScaleX;
|
||||
double edge_right = (tex->GetWidth() - tex->LeftOffset) * decal->ScaleX;
|
||||
// decals should not use renderer specific offsets.
|
||||
double edge_left = tex->GetLeftOffset(0) * decal->ScaleX;
|
||||
double edge_right = (tex->GetWidth() - tex->GetLeftOffset(0)) * decal->ScaleX;
|
||||
|
||||
DVector2 angvec = (line->v2->fPos() - line->v1->fPos()).Unit();
|
||||
DVector2 normal = { angvec.Y, -angvec.X };
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
EXTERN_CVAR(Bool, r_drawplayersprites)
|
||||
EXTERN_CVAR(Bool, r_deathcamera)
|
||||
EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor)
|
||||
EXTERN_CVAR(Bool, r_shadercolormaps)
|
||||
|
||||
void RenderPolyPlayerSprites::Render(PolyRenderThread *thread)
|
||||
{
|
||||
|
|
@ -180,7 +179,8 @@ void RenderPolyPlayerSprites::RenderRemainingSprites()
|
|||
DTA_FillColor, sprite.FillColor,
|
||||
DTA_SpecialColormap, sprite.special,
|
||||
DTA_ColorOverlay, sprite.overlay.d,
|
||||
DTA_ColormapStyle, sprite.usecolormapstyle ? &sprite.colormapstyle : nullptr,
|
||||
DTA_Color, sprite.LightColor | 0xff000000, // the color here does not have a valid alpha component.
|
||||
DTA_Desaturate, sprite.Desaturate,
|
||||
TAG_DONE);
|
||||
}
|
||||
|
||||
|
|
@ -218,6 +218,9 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
|||
const auto &viewwindow = PolyRenderer::Instance()->Viewwindow;
|
||||
DCanvas *renderTarget = PolyRenderer::Instance()->RenderTarget;
|
||||
|
||||
// Force it to use software rendering when drawing to a canvas texture.
|
||||
bool renderToCanvas = PolyRenderer::Instance()->RenderToCanvas;
|
||||
|
||||
sprframe = &SpriteFrames[sprdef->spriteframes + pspr->GetFrame()];
|
||||
|
||||
picnum = sprframe->Texture[0];
|
||||
|
|
@ -261,7 +264,7 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
|||
double pspriteyscale = pspritexscale * yaspectMul;
|
||||
double pspritexiscale = 1 / pspritexscale;
|
||||
|
||||
int tleft = tex->GetScaledLeftOffset();
|
||||
int tleft = tex->GetScaledLeftOffsetPo();
|
||||
int twidth = tex->GetScaledWidth();
|
||||
|
||||
// calculate edges of the shape
|
||||
|
|
@ -286,16 +289,16 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
|||
|
||||
vis.renderflags = owner->renderflags;
|
||||
|
||||
vis.texturemid = (BASEYCENTER - sy) * tex->Scale.Y + tex->TopOffset;
|
||||
vis.texturemid = (BASEYCENTER - sy) * tex->Scale.Y + tex->GetTopOffsetPo();
|
||||
|
||||
if (viewpoint.camera->player && (renderTarget != screen ||
|
||||
if (viewpoint.camera->player && (renderToCanvas ||
|
||||
viewheight == renderTarget->GetHeight() ||
|
||||
(renderTarget->GetWidth() > (BASEXCENTER * 2))))
|
||||
{ // Adjust PSprite for fullscreen views
|
||||
AWeapon *weapon = dyn_cast<AWeapon>(pspr->GetCaller());
|
||||
if (weapon != nullptr && weapon->YAdjust != 0)
|
||||
{
|
||||
if (renderTarget != screen || viewheight == renderTarget->GetHeight())
|
||||
if (renderToCanvas || viewheight == renderTarget->GetHeight())
|
||||
{
|
||||
vis.texturemid -= weapon->YAdjust;
|
||||
}
|
||||
|
|
@ -385,13 +388,6 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
|||
noaccel = true;
|
||||
}
|
||||
}
|
||||
// If we're drawing with a special colormap, but shaders for them are disabled, do
|
||||
// not accelerate.
|
||||
if (!r_shadercolormaps && (vis.Light.BaseColormap >= &SpecialSWColormaps[0] &&
|
||||
vis.Light.BaseColormap <= &SpecialSWColormaps.Last()))
|
||||
{
|
||||
noaccel = true;
|
||||
}
|
||||
// If drawing with a BOOM colormap, disable acceleration.
|
||||
if (vis.Light.BaseColormap == &NormalLight && NormalLight.Maps != realcolormaps.Maps)
|
||||
{
|
||||
|
|
@ -417,7 +413,7 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
|||
|
||||
// Check for hardware-assisted 2D. If it's available, and this sprite is not
|
||||
// fuzzy, don't draw it until after the switch to 2D mode.
|
||||
if (!noaccel && renderTarget == screen && (DFrameBuffer *)screen->Accel2D)
|
||||
if (!noaccel && !renderToCanvas)
|
||||
{
|
||||
FRenderStyle style = vis.RenderStyle;
|
||||
style.CheckFuzz();
|
||||
|
|
@ -448,19 +444,12 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
|||
{
|
||||
accelSprite.special = PolyCameraLight::Instance()->ShaderColormap();
|
||||
}
|
||||
else if (colormap_to_use->Color == PalEntry(255, 255, 255) &&
|
||||
colormap_to_use->Desaturate == 0)
|
||||
else
|
||||
{
|
||||
accelSprite.overlay = colormap_to_use->Fade;
|
||||
accelSprite.overlay.a = uint8_t(vis.Light.ColormapNum * 255 / NUMCOLORMAPS);
|
||||
}
|
||||
else
|
||||
{
|
||||
accelSprite.usecolormapstyle = true;
|
||||
accelSprite.colormapstyle.Color = colormap_to_use->Color;
|
||||
accelSprite.colormapstyle.Fade = colormap_to_use->Fade;
|
||||
accelSprite.colormapstyle.Desaturate = colormap_to_use->Desaturate;
|
||||
accelSprite.colormapstyle.FadeLevel = vis.Light.ColormapNum / float(NUMCOLORMAPS);
|
||||
accelSprite.LightColor = colormap_to_use->Color;
|
||||
accelSprite.Desaturate = (uint8_t)clamp(colormap_to_use->Desaturate, 0, 255);
|
||||
}
|
||||
|
||||
AcceleratedSprites.Push(accelSprite);
|
||||
|
|
@ -512,7 +501,7 @@ void PolyNoAccelPlayerSprite::Render(PolyRenderThread *thread)
|
|||
y1 = centerY - texturemid * yscale;
|
||||
y2 = y1 + pic->GetHeight() * yscale;
|
||||
}
|
||||
args.Draw(thread, x1, x2, y1, y2, 0.0f, 1.0f, 0.0f, 1.0f);
|
||||
args.Draw(thread, viewwindowx + x1, viewwindowx + x2, viewwindowy + y1, viewwindowy + y2, 0.0f, 1.0f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -83,8 +83,8 @@ public:
|
|||
bool flip = false;
|
||||
FSpecialColormap *special = nullptr;
|
||||
PalEntry overlay = 0;
|
||||
FColormapStyle colormapstyle;
|
||||
bool usecolormapstyle = false;
|
||||
PalEntry LightColor = 0xffffffff;
|
||||
uint8_t Desaturate = 0;
|
||||
};
|
||||
|
||||
class RenderPolyPlayerSprites
|
||||
|
|
|
|||
|
|
@ -63,9 +63,9 @@ bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right)
|
|||
|
||||
double offsetX;
|
||||
if (flipTextureX)
|
||||
offsetX = (tex->GetWidth() - tex->LeftOffset) * thingxscalemul;
|
||||
offsetX = (tex->GetWidth() - tex->GetLeftOffsetPo()) * thingxscalemul;
|
||||
else
|
||||
offsetX = tex->LeftOffset * thingxscalemul;
|
||||
offsetX = tex->GetLeftOffsetPo() * thingxscalemul;
|
||||
|
||||
left = DVector2(pos.X - viewpoint.Sin * offsetX, pos.Y + viewpoint.Cos * offsetX);
|
||||
right = DVector2(left.X + viewpoint.Sin * spriteWidth, left.Y - viewpoint.Cos * spriteWidth);
|
||||
|
|
@ -110,7 +110,7 @@ void RenderPolySprite::Render(PolyRenderThread *thread, const PolyClipPlane &cli
|
|||
double thingyscalemul = thing->Scale.Y / tex->Scale.Y;
|
||||
double spriteHeight = thingyscalemul * tex->GetHeight();
|
||||
|
||||
posZ -= (tex->GetHeight() - tex->TopOffset) * thingyscalemul;
|
||||
posZ -= (tex->GetHeight() - tex->GetTopOffsetPo()) * thingyscalemul;
|
||||
posZ = PerformSpriteClipAdjustment(thing, thingpos, spriteHeight, posZ);
|
||||
|
||||
//double depth = 1.0;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ void RenderPolyWallSprite::Render(PolyRenderThread *thread, const PolyClipPlane
|
|||
// Determine left and right edges of sprite. The sprite's angle is its normal,
|
||||
// so the edges are 90 degrees each side of it.
|
||||
double x2 = tex->GetScaledWidth() * spriteScale.X;
|
||||
double x1 = tex->GetScaledLeftOffset() * spriteScale.X;
|
||||
double x1 = tex->GetScaledLeftOffsetPo() * spriteScale.X;
|
||||
DVector2 left, right;
|
||||
left.X = pos.X - x1 * angcos;
|
||||
left.Y = pos.Y - x1 * angsin;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue