Merge remote-tracking branch 'remotes/origin/3.0_work'

This commit is contained in:
Christoph Oelckers 2017-03-13 00:02:16 +01:00
commit 439e4f9f94
36 changed files with 107 additions and 63 deletions

View file

@ -66,7 +66,7 @@ void PolyRenderer::RenderView(player_t *player)
int stHeight = gST_Y;
float trueratio;
ActiveRatio(width, height, &trueratio);
viewport->SetViewport(width, height, trueratio);
viewport->SetViewport(&Thread, width, height, trueratio);
RenderActorView(player->mo, false);
@ -89,7 +89,7 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int
viewwidth = width;
viewport->RenderTarget = canvas;
R_SetWindow(viewport->viewpoint, viewport->viewwindow, 12, width, height, height, true);
viewport->SetViewport(width, height, viewport->viewwindow.WidescreenRatio);
viewport->SetViewport(&Thread, width, height, viewport->viewwindow.WidescreenRatio);
viewwindowx = x;
viewwindowy = y;
viewactive = true;
@ -105,7 +105,7 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int
R_ExecuteSetViewSize(viewport->viewpoint, viewport->viewwindow);
float trueratio;
ActiveRatio(width, height, &trueratio);
viewport->SetViewport(width, height, viewport->viewwindow.WidescreenRatio);
viewport->SetViewport(&Thread, width, height, viewport->viewwindow.WidescreenRatio);
viewactive = savedviewactive;
}

View file

@ -139,7 +139,7 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan
args.uniforms.flags = 0;
args.SetColormap(front->ColorMap);
args.SetTexture(tex, decal->Translation, true);
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->WallGlobVis(foggy);
args.uniforms.globvis = (float)PolyRenderer::Instance()->Thread.Light->WallGlobVis(foggy);
if (fullbrightSprite || cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
{
args.uniforms.light = 256;

View file

@ -76,7 +76,7 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, const Vec4f &clipP
PolyDrawArgs args;
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->ParticleGlobVis(foggy);
args.uniforms.globvis = (float)PolyRenderer::Instance()->Thread.Light->ParticleGlobVis(foggy);
if (fullbrightSprite || cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
{

View file

@ -112,7 +112,7 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const Vec4f &c
UVTransform xform(ceiling ? fakeFloor->top.model->planes[sector_t::ceiling].xform : fakeFloor->top.model->planes[sector_t::floor].xform, tex);
PolyDrawArgs args;
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->SlopePlaneGlobVis(foggy) * 48.0f;
args.uniforms.globvis = (float)PolyRenderer::Instance()->Thread.Light->SlopePlaneGlobVis(foggy) * 48.0f;
args.uniforms.light = (uint32_t)(lightlevel / 255.0f * 256.0f);
if (cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
args.uniforms.light = 256;
@ -310,7 +310,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan
swrenderer::CameraLight *cameraLight = swrenderer::CameraLight::Instance();
PolyDrawArgs args;
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->SlopePlaneGlobVis(foggy) * 48.0f;
args.uniforms.globvis = (float)PolyRenderer::Instance()->Thread.Light->SlopePlaneGlobVis(foggy) * 48.0f;
args.uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f);
if (cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
args.uniforms.light = 256;

View file

@ -228,7 +228,7 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, floa
int actualextralight = foggy ? 0 : viewpoint.extralight << 4;
int spriteshade = swrenderer::LightVisibility::LightLevelToShade(owner->Sector->lightlevel + actualextralight, foggy);
double minz = double((2048 * 4) / double(1 << 20));
ColormapNum = GETPALOOKUP(swrenderer::LightVisibility::Instance()->SpriteGlobVis(foggy) / minz, spriteshade);
ColormapNum = GETPALOOKUP(PolyRenderer::Instance()->Thread.Light->SpriteGlobVis(foggy) / minz, spriteshade);
if (sprite->GetID() < PSP_TARGETCENTER)
{

View file

@ -93,7 +93,7 @@ void PolyDrawSectorPortal::SaveGlobals()
savedextralight = viewpoint.extralight;
savedpos = viewpoint.Pos;
savedangles = viewpoint.Angles;
savedvisibility = swrenderer::LightVisibility::Instance()->GetVisibility();
savedvisibility = PolyRenderer::Instance()->Thread.Light->GetVisibility();
savedcamera = viewpoint.camera;
savedsector = viewpoint.sector;
@ -102,7 +102,7 @@ void PolyDrawSectorPortal::SaveGlobals()
// Don't let gun flashes brighten the sky box
AActor *sky = Portal->mSkybox;
viewpoint.extralight = 0;
swrenderer::LightVisibility::Instance()->SetVisibility(PolyRenderer::Instance()->Thread.Viewport.get(), sky->args[0] * 0.25f);
PolyRenderer::Instance()->Thread.Light->SetVisibility(PolyRenderer::Instance()->Thread.Viewport.get(), sky->args[0] * 0.25f);
viewpoint.Pos = sky->InterpolatedPosition(viewpoint.TicFrac);
viewpoint.Angles.Yaw = savedangles.Yaw + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * viewpoint.TicFrac);
}
@ -133,7 +133,7 @@ void PolyDrawSectorPortal::RestoreGlobals()
viewpoint.camera = savedcamera;
viewpoint.sector = savedsector;
viewpoint.Pos = savedpos;
swrenderer::LightVisibility::Instance()->SetVisibility(PolyRenderer::Instance()->Thread.Viewport.get(), savedvisibility);
PolyRenderer::Instance()->Thread.Light->SetVisibility(PolyRenderer::Instance()->Thread.Viewport.get(), savedvisibility);
viewpoint.extralight = savedextralight;
viewpoint.Angles = savedangles;
R_SetViewAngle(viewpoint, viewwindow);

View file

@ -244,7 +244,7 @@ void RenderPolyScene::RenderPortals(int portalDepth)
PolyDrawArgs args;
args.objectToClip = &WorldToClip;
args.mode = TriangleDrawMode::Fan;
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->WallGlobVis(foggy);
args.uniforms.globvis = (float)PolyRenderer::Instance()->Thread.Light->WallGlobVis(foggy);
args.uniforms.color = 0;
args.uniforms.light = 256;
args.uniforms.flags = TriUniforms::fixed_light;

View file

@ -57,7 +57,7 @@ void PolySkyDome::Render(const TriMatrix &worldToClip)
int rc = mRows + 1;
PolyDrawArgs args;
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->WallGlobVis(foggy);
args.uniforms.globvis = (float)PolyRenderer::Instance()->Thread.Light->WallGlobVis(foggy);
args.uniforms.light = 256;
args.uniforms.flags = 0;
args.uniforms.subsectorDepth = RenderPolyScene::SkySubsectorDepth;

View file

@ -141,7 +141,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPla
swrenderer::CameraLight *cameraLight = swrenderer::CameraLight::Instance();
PolyDrawArgs args;
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->SpriteGlobVis(foggy);
args.uniforms.globvis = (float)PolyRenderer::Instance()->Thread.Light->SpriteGlobVis(foggy);
args.uniforms.flags = 0;
if (fullbrightSprite || cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
{

View file

@ -249,7 +249,7 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane
}
PolyDrawArgs args;
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->WallGlobVis(foggy);
args.uniforms.globvis = (float)PolyRenderer::Instance()->Thread.Light->WallGlobVis(foggy);
args.uniforms.light = (uint32_t)(GetLightLevel() / 255.0f * 256.0f);
args.uniforms.flags = 0;
args.uniforms.subsectorDepth = SubsectorDepth;

View file

@ -102,7 +102,7 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, const Vec4f &cli
swrenderer::CameraLight *cameraLight = swrenderer::CameraLight::Instance();
PolyDrawArgs args;
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->WallGlobVis(foggy);
args.uniforms.globvis = (float)PolyRenderer::Instance()->Thread.Light->WallGlobVis(foggy);
if (fullbrightSprite || cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
{
args.uniforms.light = 256;

View file

@ -782,7 +782,7 @@ namespace swrenderer
if (cameraLight->FixedColormap() == nullptr && cameraLight->FixedLightLevel() < 0)
{
wallshade = LightVisibility::LightLevelToShade(mLineSegment->sidedef->GetLightLevel(foggy, mFrontSector->lightlevel) + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get()), foggy);
double GlobVis = LightVisibility::Instance()->WallGlobVis(foggy);
double GlobVis = Thread->Light->WallGlobVis(foggy);
rw_lightleft = float(GlobVis / WallC.sz1);
rw_lightstep = float((GlobVis / WallC.sz2 - rw_lightleft) / (WallC.sx2 - WallC.sx1));
}

View file

@ -515,6 +515,8 @@ namespace swrenderer
this->rw_pic = pic;
this->mask = mask;
Thread->PrepareTexture(pic);
if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits)
{
ProcessWallNP2(walltop, wallbottom, texturemid, swall, lwall, top, bottom);

View file

@ -59,7 +59,7 @@ namespace swrenderer
}
drawerargs.SetSolidColor(3);
drawerargs.SetTexture(Thread->Viewport.get(), texture);
drawerargs.SetTexture(Thread, texture);
double planeang = (pl->xform.Angle + pl->xform.baseAngle).Radians();
double xstep, ystep, leftxfrac, leftyfrac, rightxfrac, rightyfrac;
@ -120,7 +120,7 @@ namespace swrenderer
// [RH] set foggy flag
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE));
GlobVis = LightVisibility::Instance()->FlatPlaneGlobVis(foggy) / planeheight;
GlobVis = Thread->Light->FlatPlaneGlobVis(foggy) / planeheight;
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->FixedLightLevel() >= 0)

View file

@ -198,8 +198,8 @@ namespace swrenderer
angle1 = (uint32_t)((UMulScale16(ang, frontcyl) + frontpos) >> FRACBITS);
angle2 = (uint32_t)((UMulScale16(ang, backcyl) + backpos) >> FRACBITS);
drawerargs.SetFrontTexture(viewport, frontskytex, angle1);
drawerargs.SetBackTexture(viewport, backskytex, angle2);
drawerargs.SetFrontTexture(Thread, frontskytex, angle1);
drawerargs.SetBackTexture(Thread, backskytex, angle2);
drawerargs.SetTextureVStep(uv_step);
drawerargs.SetTextureVPos(uv_pos);
drawerargs.SetDest(viewport, start_x, y1);

View file

@ -80,7 +80,7 @@ namespace swrenderer
auto viewport = Thread->Viewport.get();
drawerargs.SetSolidColor(3);
drawerargs.SetTexture(Thread->Viewport.get(), texture);
drawerargs.SetTexture(Thread, texture);
lxscale = _xscale * ifloatpow2[drawerargs.TextureWidthBits()];
lyscale = _yscale * ifloatpow2[drawerargs.TextureHeightBits()];
@ -157,7 +157,7 @@ namespace swrenderer
basecolormap = colormap;
bool foggy = level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE);;
planelightfloat = (LightVisibility::Instance()->SlopePlaneGlobVis(foggy) * lxscale * lyscale) / (fabs(pl->height.ZatPoint(Thread->Viewport->viewpoint.Pos) - Thread->Viewport->viewpoint.Pos.Z)) / 65536.f;
planelightfloat = (Thread->Light->SlopePlaneGlobVis(foggy) * lxscale * lyscale) / (fabs(pl->height.ZatPoint(Thread->Viewport->viewpoint.Pos) - Thread->Viewport->viewpoint.Pos.Z)) / 65536.f;
if (pl->height.fC() > 0)
planelightfloat = -planelightfloat;

View file

@ -62,6 +62,7 @@ namespace swrenderer
MainThread = mainThread;
FrameMemory = std::make_unique<RenderMemory>();
Viewport = std::make_unique<RenderViewport>();
Light = std::make_unique<LightVisibility>();
DrawQueue = std::make_shared<DrawerCommandQueue>(this);
OpaquePass = std::make_unique<RenderOpaquePass>(this);
TranslucentPass = std::make_unique<RenderTranslucentPass>(this);
@ -87,4 +88,38 @@ namespace swrenderer
else
return pal_drawers.get();
}
void RenderThread::PrepareTexture(FTexture *texture)
{
if (texture == nullptr)
return;
// Textures may not have loaded/refreshed yet. The shared code doing
// this is not thread safe. By calling GetPixels in a mutex lock we
// make sure that only one thread is loading a texture at any given
// time.
//
// It is critical that this function is called before any direct
// calls to GetPixels for this to work.
static std::mutex loadmutex;
loadmutex.lock();
try
{
texture->GetPixels();
const FTexture::Span *spans;
texture->GetColumn(0, &spans);
if (Viewport->RenderTarget->IsBgra())
{
texture->GetPixelsBgra();
texture->GetColumnBgra(0, &spans);
}
loadmutex.unlock();
}
catch (...)
{
loadmutex.unlock();
throw;
}
}
}

View file

@ -43,6 +43,7 @@ namespace swrenderer
class RenderClipSegment;
class RenderMemory;
class RenderViewport;
class LightVisibility;
class SWPixelFormatDrawers;
class SWTruecolorDrawers;
class SWPalDrawers;
@ -69,6 +70,7 @@ namespace swrenderer
std::unique_ptr<DrawSegmentList> DrawSegments;
std::unique_ptr<RenderClipSegment> ClipSegments;
std::unique_ptr<RenderViewport> Viewport;
std::unique_ptr<LightVisibility> Light;
DrawerCommandQueuePtr DrawQueue;
std::thread thread;
@ -78,6 +80,9 @@ namespace swrenderer
short cliptop[MAXWIDTH];
SWPixelFormatDrawers *Drawers(RenderViewport *viewport);
// Make sure texture can accessed safely
void PrepareTexture(FTexture *texture);
private:
std::unique_ptr<SWTruecolorDrawers> tc_drawers;

View file

@ -274,7 +274,7 @@ void SWCanvas::FillSimplePoly(DCanvas *canvas, FTexture *tex, FVector2 *points,
// Setup constant texture mapping parameters.
SpanDrawerArgs drawerargs;
drawerargs.SetTexture(viewport, tex);
drawerargs.SetTexture(&thread, tex);
if (colormap)
drawerargs.SetLight(colormap, 0, clamp(shade >> FRACBITS, 0, NUMCOLORMAPS - 1));
else

View file

@ -365,10 +365,10 @@ void FSoftwareRenderer::CleanLevelData()
double FSoftwareRenderer::GetVisibility()
{
return LightVisibility::Instance()->GetVisibility();
return mScene.MainThread()->Light->GetVisibility();
}
void FSoftwareRenderer::SetVisibility(double vis)
{
LightVisibility::Instance()->SetVisibility(mScene.MainThread()->Viewport.get(), vis);
mScene.MainThread()->Light->SetVisibility(mScene.MainThread()->Viewport.get(), vis);
}

View file

@ -93,12 +93,6 @@ namespace swrenderer
/////////////////////////////////////////////////////////////////////////
LightVisibility *LightVisibility::Instance()
{
static LightVisibility instance;
return &instance;
}
// Changes how rapidly things get dark with distance
void LightVisibility::SetVisibility(RenderViewport *viewport, double vis)
{

View file

@ -69,8 +69,6 @@ namespace swrenderer
class LightVisibility
{
public:
static LightVisibility *Instance();
void SetVisibility(RenderViewport *viewport, double visibility);
double GetVisibility() const { return CurrentVisibility; }

View file

@ -104,7 +104,7 @@ namespace swrenderer
int savedextralight = Thread->Viewport->viewpoint.extralight;
DVector3 savedpos = Thread->Viewport->viewpoint.Pos;
DRotator savedangles = Thread->Viewport->viewpoint.Angles;
double savedvisibility = LightVisibility::Instance()->GetVisibility();
double savedvisibility = Thread->Light->GetVisibility();
AActor *savedcamera = Thread->Viewport->viewpoint.camera;
sector_t *savedsector = Thread->Viewport->viewpoint.sector;
@ -126,7 +126,7 @@ namespace swrenderer
// Don't let gun flashes brighten the sky box
AActor *sky = port->mSkybox;
Thread->Viewport->viewpoint.extralight = 0;
LightVisibility::Instance()->SetVisibility(Thread->Viewport.get(), sky->args[0] * 0.25f);
Thread->Light->SetVisibility(Thread->Viewport.get(), sky->args[0] * 0.25f);
Thread->Viewport->viewpoint.Pos = sky->InterpolatedPosition(Thread->Viewport->viewpoint.TicFrac);
Thread->Viewport->viewpoint.Angles.Yaw = savedangles.Yaw + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * Thread->Viewport->viewpoint.TicFrac);
@ -139,7 +139,7 @@ namespace swrenderer
case PORTS_PORTAL:
case PORTS_LINKEDPORTAL:
Thread->Viewport->viewpoint.extralight = pl->extralight;
LightVisibility::Instance()->SetVisibility(Thread->Viewport.get(), pl->visibility);
Thread->Light->SetVisibility(Thread->Viewport.get(), pl->visibility);
Thread->Viewport->viewpoint.Pos.X = pl->viewpos.X + port->mDisplacement.X;
Thread->Viewport->viewpoint.Pos.Y = pl->viewpos.Y + port->mDisplacement.Y;
Thread->Viewport->viewpoint.Pos.Z = pl->viewpos.Z;
@ -245,7 +245,7 @@ namespace swrenderer
Thread->Viewport->viewpoint.camera = savedcamera;
Thread->Viewport->viewpoint.sector = savedsector;
Thread->Viewport->viewpoint.Pos = savedpos;
LightVisibility::Instance()->SetVisibility(Thread->Viewport.get(), savedvisibility);
Thread->Light->SetVisibility(Thread->Viewport.get(), savedvisibility);
Thread->Viewport->viewpoint.extralight = savedextralight;
Thread->Viewport->viewpoint.Angles = savedangles;
R_SetViewAngle(Thread->Viewport->viewpoint, Thread->Viewport->viewwindow);
@ -517,7 +517,7 @@ namespace swrenderer
stacked_viewpos = Thread->Viewport->viewpoint.Pos;
stacked_angle = Thread->Viewport->viewpoint.Angles;
stacked_extralight = Thread->Viewport->viewpoint.extralight;
stacked_visibility = LightVisibility::Instance()->GetVisibility();
stacked_visibility = Thread->Light->GetVisibility();
}
void RenderPortal::SetMainPortal()

View file

@ -83,7 +83,7 @@ namespace swrenderer
int height = SCREENHEIGHT;
float trueratio;
ActiveRatio(width, height, &trueratio);
viewport->SetViewport(width, height, trueratio);
viewport->SetViewport(MainThread(), width, height, trueratio);
if (r_clearbuffer != 0)
{
@ -185,6 +185,7 @@ namespace swrenderer
for (int i = 0; i < numThreads; i++)
{
*Threads[i]->Viewport = *MainThread()->Viewport;
*Threads[i]->Light = *MainThread()->Light;
Threads[i]->X1 = viewwidth * i / numThreads;
Threads[i]->X2 = viewwidth * (i + 1) / numThreads;
}
@ -333,7 +334,7 @@ namespace swrenderer
viewwindowx = x;
viewwindowy = y;
viewactive = true;
viewport->SetViewport(width, height, MainThread()->Viewport->viewwindow.WidescreenRatio);
viewport->SetViewport(MainThread(), width, height, MainThread()->Viewport->viewwindow.WidescreenRatio);
RenderActorView(actor, dontmaplines);
@ -343,7 +344,7 @@ namespace swrenderer
float trueratio;
ActiveRatio(width, height, &trueratio);
screen->Lock(true);
viewport->SetViewport(width, height, trueratio);
viewport->SetViewport(MainThread(), width, height, trueratio);
screen->Unlock();
viewactive = savedviewactive;
@ -358,7 +359,7 @@ namespace swrenderer
float trueratio;
ActiveRatio(width, height, &trueratio);
screen->Lock(true);
viewport->SetViewport(SCREENWIDTH, SCREENHEIGHT, trueratio);
viewport->SetViewport(MainThread(), SCREENWIDTH, SCREENHEIGHT, trueratio);
screen->Unlock();
}

View file

@ -204,7 +204,7 @@ namespace swrenderer
vis->floorclip = 0;
vis->foggy = foggy;
vis->Light.SetColormap(tiz * LightVisibility::Instance()->ParticleGlobVis(foggy), shade, map, particle->bright != 0, false, false);
vis->Light.SetColormap(tiz * thread->Light->ParticleGlobVis(foggy), shade, map, particle->bright != 0, false, false);
thread->SpriteList->Push(vis);
}

View file

@ -280,7 +280,7 @@ namespace swrenderer
vis->dynlightcolor = 0;
}
vis->Light.SetColormap(LightVisibility::Instance()->SpriteGlobVis(foggy) / MAX(tz, MINZ), spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack);
vis->Light.SetColormap(thread->Light->SpriteGlobVis(foggy) / MAX(tz, MINZ), spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack);
thread->SpriteList->Push(vis);
}

View file

@ -140,7 +140,7 @@ namespace swrenderer
int spriteshade = LightVisibility::LightLevelToShade(sec->lightlevel + LightVisibility::ActualExtraLight(spr->foggy, thread->Viewport.get()), foggy);
Light.SetColormap(LightVisibility::Instance()->SpriteGlobVis(foggy) / MAX(MINZ, (double)spr->depth), spriteshade, mybasecolormap, isFullBright, invertcolormap, fadeToBlack);
Light.SetColormap(thread->Light->SpriteGlobVis(foggy) / MAX(MINZ, (double)spr->depth), spriteshade, mybasecolormap, isFullBright, invertcolormap, fadeToBlack);
}
}

View file

@ -170,7 +170,7 @@ namespace swrenderer
bool fullbright = !vis->foggy && ((renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT));
bool fadeToBlack = (vis->RenderStyle.Flags & STYLEF_FadeToBlack) != 0;
vis->Light.SetColormap(LightVisibility::Instance()->SpriteGlobVis(foggy) / MAX(tz, MINZ), spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack);
vis->Light.SetColormap(thread->Light->SpriteGlobVis(foggy) / MAX(tz, MINZ), spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack);
thread->SpriteList->Push(vis, true);
}

View file

@ -133,7 +133,7 @@ namespace swrenderer
vis->wallc = wallc;
vis->foggy = foggy;
vis->Light.SetColormap(LightVisibility::Instance()->SpriteGlobVis(foggy) / MAX(tz, MINZ), spriteshade, basecolormap, false, false, false);
vis->Light.SetColormap(thread->Light->SpriteGlobVis(foggy) / MAX(tz, MINZ), spriteshade, basecolormap, false, false, false);
thread->SpriteList->Push(vis);
}
@ -183,7 +183,7 @@ namespace swrenderer
SpriteDrawerArgs drawerargs;
int shade = LightVisibility::LightLevelToShade(spr->sector->lightlevel + LightVisibility::ActualExtraLight(spr->foggy, thread->Viewport.get()), spr->foggy);
double GlobVis = LightVisibility::Instance()->WallGlobVis(foggy);
double GlobVis = thread->Light->WallGlobVis(foggy);
float lightleft = float(GlobVis / spr->wallc.sz1);
float lightstep = float((GlobVis / spr->wallc.sz2 - lightleft) / (spr->wallc.sx2 - spr->wallc.sx1));
float light = lightleft + (x1 - spr->wallc.sx1) * lightstep;

View file

@ -34,9 +34,10 @@ namespace swrenderer
dc_viewport = viewport;
}
void SkyDrawerArgs::SetFrontTexture(RenderViewport *viewport, FTexture *texture, uint32_t column)
void SkyDrawerArgs::SetFrontTexture(RenderThread *thread, FTexture *texture, uint32_t column)
{
if (viewport->RenderTarget->IsBgra())
thread->PrepareTexture(texture);
if (thread->Viewport->RenderTarget->IsBgra())
{
dc_source = (const uint8_t *)texture->GetColumnBgra(column, nullptr);
dc_sourceheight = texture->GetHeight();
@ -48,14 +49,15 @@ namespace swrenderer
}
}
void SkyDrawerArgs::SetBackTexture(RenderViewport *viewport, FTexture *texture, uint32_t column)
void SkyDrawerArgs::SetBackTexture(RenderThread *thread, FTexture *texture, uint32_t column)
{
thread->PrepareTexture(texture);
if (texture == nullptr)
{
dc_source2 = nullptr;
dc_sourceheight2 = 1;
}
else if (viewport->RenderTarget->IsBgra())
else if (thread->Viewport->RenderTarget->IsBgra())
{
dc_source2 = (const uint8_t *)texture->GetColumnBgra(column, nullptr);
dc_sourceheight2 = texture->GetHeight();

View file

@ -15,8 +15,8 @@ namespace swrenderer
public:
void SetDest(RenderViewport *viewport, int x, int y);
void SetCount(int count) { dc_count = count; }
void SetFrontTexture(RenderViewport *viewport, FTexture *texture, uint32_t column);
void SetBackTexture(RenderViewport *viewport, FTexture *texture, uint32_t column);
void SetFrontTexture(RenderThread *thread, FTexture *texture, uint32_t column);
void SetBackTexture(RenderThread *thread, FTexture *texture, uint32_t column);
void SetTextureVPos(uint32_t texturefrac) { dc_texturefrac = texturefrac; }
void SetTextureVStep(uint32_t iscale) { dc_iscale = iscale; }
void SetSolidTop(uint32_t color) { solid_top = color; }

View file

@ -22,8 +22,10 @@ namespace swrenderer
spanfunc = &SWPixelFormatDrawers::DrawSpan;
}
void SpanDrawerArgs::SetTexture(RenderViewport *viewport, FTexture *tex)
void SpanDrawerArgs::SetTexture(RenderThread *thread, FTexture *tex)
{
thread->PrepareTexture(tex);
tex->GetWidth();
ds_xbits = tex->WidthBits;
ds_ybits = tex->HeightBits;
@ -36,7 +38,7 @@ namespace swrenderer
ds_ybits--;
}
ds_source = viewport->RenderTarget->IsBgra() ? (const uint8_t*)tex->GetPixelsBgra() : tex->GetPixels();
ds_source = thread->Viewport->RenderTarget->IsBgra() ? (const uint8_t*)tex->GetPixelsBgra() : tex->GetPixels();
ds_source_mipmapped = tex->Mipmapped() && tex->GetWidth() > 1 && tex->GetHeight() > 1;
}

View file

@ -19,7 +19,7 @@ namespace swrenderer
void SetDestY(RenderViewport *viewport, int y) { ds_viewport = viewport; ds_y = y; }
void SetDestX1(int x) { ds_x1 = x; }
void SetDestX2(int x) { ds_x2 = x; }
void SetTexture(RenderViewport *viewport, FTexture *tex);
void SetTexture(RenderThread *thread, FTexture *tex);
void SetTextureLOD(double lod) { ds_lod = lod; }
void SetTextureUPos(dsfixed_t xfrac) { ds_xfrac = xfrac; }
void SetTextureVPos(dsfixed_t yfrac) { ds_yfrac = yfrac; }

View file

@ -49,7 +49,7 @@ namespace swrenderer
return;
auto viewport = thread->Viewport.get();
// Handle the linear filtered version in a different function to reduce chances of merge conflicts from zdoom.
if (viewport->RenderTarget->IsBgra() && !drawer_needs_pal_input) // To do: add support to R_DrawColumnHoriz_rgba
{
@ -62,6 +62,8 @@ namespace swrenderer
dc_iscale = iscale;
dc_textureheight = tex->GetHeight();
thread->PrepareTexture(tex);
const FTexture::Span *span;
const uint8_t *column;
if (viewport->RenderTarget->IsBgra() && !drawer_needs_pal_input)
@ -132,6 +134,8 @@ namespace swrenderer
dc_x = x;
dc_iscale = iscale;
thread->PrepareTexture(tex);
// Normalize to 0-1 range:
double uv_stepd = FIXED2DBL(dc_iscale);
double v_step = uv_stepd / tex->GetHeight();

View file

@ -48,7 +48,7 @@ namespace swrenderer
{
}
void RenderViewport::SetViewport(int fullWidth, int fullHeight, float trueratio)
void RenderViewport::SetViewport(RenderThread *thread, int fullWidth, int fullHeight, float trueratio)
{
int virtheight, virtwidth, virtwidth2, virtheight2;
@ -101,8 +101,7 @@ namespace swrenderer
InitTextureMapping();
// Reset r_*Visibility vars
LightVisibility *visibility = LightVisibility::Instance();
visibility->SetVisibility(this, visibility->GetVisibility());
thread->Light->SetVisibility(this, thread->Light->GetVisibility());
SetupBuffer();
}

View file

@ -19,13 +19,15 @@
namespace swrenderer
{
class RenderThread;
class RenderViewport
{
public:
RenderViewport();
~RenderViewport();
void SetViewport(int width, int height, float trueratio);
void SetViewport(RenderThread *thread, int width, int height, float trueratio);
void SetupFreelook();
DCanvas *RenderTarget = nullptr;