- removed Accel2D variable and a little bit of locking cruft.

This commit is contained in:
Christoph Oelckers 2018-03-27 17:13:10 +02:00
parent cff5f0e3c7
commit 62f073ef60
21 changed files with 35 additions and 257 deletions

View file

@ -1211,11 +1211,8 @@ void DBaseStatusBar::BlendView (float blend[4])
V_AddBlend (BaseBlendR / 255.f, BaseBlendG / 255.f, BaseBlendB / 255.f, cnt, blend);
V_AddPlayerBlend(CPlayer, blend, 1.0f, 228);
if (screen->Accel2D || (CPlayer->camera != NULL && menuactive == MENU_Off && ConsoleState == c_up))
{
player_t *player = (CPlayer->camera != NULL && CPlayer->camera->player != NULL) ? CPlayer->camera->player : CPlayer;
V_AddBlend (player->BlendR, player->BlendG, player->BlendB, player->BlendA, blend);
}
player_t *player = (CPlayer->camera != NULL && CPlayer->camera->player != NULL) ? CPlayer->camera->player : CPlayer;
V_AddBlend (player->BlendR, player->BlendG, player->BlendB, player->BlendA, blend);
V_SetBlend ((int)(blend[0] * 255.0f), (int)(blend[1] * 255.0f),
(int)(blend[2] * 255.0f), (int)(blend[3] * 256.0f));

View file

@ -100,7 +100,6 @@ OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, int width, int height, int
gl_SetupMenu();
gl_GenerateGlobalBrightmapFromColormap();
DoSetGamma();
Accel2D = true;
}
OpenGLFrameBuffer::~OpenGLFrameBuffer()

View file

@ -157,7 +157,6 @@ OpenGLSWFrameBuffer::OpenGLSWFrameBuffer(void *hMonitor, int width, int height,
In2D = 0;
Palettes = nullptr;
Textures = nullptr;
Accel2D = true;
GatheringWipeScreen = false;
ScreenWipe = nullptr;
InScene = false;
@ -1123,7 +1122,6 @@ bool OpenGLSWFrameBuffer::Lock(bool buffered)
return false;
}
assert(!In2D);
Accel2D = vid_hw2d;
#if 0 // temporarily disabled. Must be fixed later
if (UseMappedMemBuffer)
@ -1209,17 +1207,6 @@ void OpenGLSWFrameBuffer::Update()
return;
}
if (m_Lock != 1)
{
I_FatalError("Framebuffer must have exactly 1 lock to be updated");
if (m_Lock > 0)
{
UpdatePending = true;
--m_Lock;
}
return;
}
if (In2D == 0)
{
DrawRateStuff();
@ -1258,7 +1245,6 @@ void OpenGLSWFrameBuffer::Update()
BlitCycles.Clock();
#endif
m_Lock = 0;
Draw3DPart(In2D <= 1);
if (In2D == 0)
{
@ -1316,10 +1302,6 @@ void OpenGLSWFrameBuffer::Flip()
bool OpenGLSWFrameBuffer::PaintToWindow()
{
if (m_Lock != 0)
{
return false;
}
Draw3DPart(true);
return true;
}
@ -1446,30 +1428,22 @@ void OpenGLSWFrameBuffer::Draw3DPart(bool copy3d)
{
FBVERTEX verts[4];
uint32_t color0, color1;
if (Accel2D)
auto map = swrenderer::CameraLight::Instance()->ShaderColormap();
if (map == nullptr)
{
auto map = swrenderer::CameraLight::Instance()->ShaderColormap();
if (map == nullptr)
{
color0 = 0;
color1 = 0xFFFFFFF;
}
else
{
color0 = ColorValue(map->ColorizeStart[0] / 2, map->ColorizeStart[1] / 2, map->ColorizeStart[2] / 2, 0);
color1 = ColorValue(map->ColorizeEnd[0] / 2, map->ColorizeEnd[1] / 2, map->ColorizeEnd[2] / 2, 1);
if (IsBgra())
SetPixelShader(Shaders[SHADER_SpecialColormap].get());
else
SetPixelShader(Shaders[SHADER_SpecialColormapPal].get());
}
color0 = 0;
color1 = 0xFFFFFFF;
}
else
{
color0 = FlashColor0;
color1 = FlashColor1;
color0 = ColorValue(map->ColorizeStart[0] / 2, map->ColorizeStart[1] / 2, map->ColorizeStart[2] / 2, 0);
color1 = ColorValue(map->ColorizeEnd[0] / 2, map->ColorizeEnd[1] / 2, map->ColorizeEnd[2] / 2, 1);
if (IsBgra())
SetPixelShader(Shaders[SHADER_SpecialColormap].get());
else
SetPixelShader(Shaders[SHADER_SpecialColormapPal].get());
}
CalcFullscreenCoords(verts, Accel2D, color0, color1);
CalcFullscreenCoords(verts, true, color0, color1);
DrawTriangleFans(2, verts);
}
if (IsBgra())
@ -1666,11 +1640,6 @@ void OpenGLSWFrameBuffer::GetScreenshotBuffer(const uint8_t *&buffer, int &pitch
/*
LockedRect lrect;
if (!Accel2D)
{
Super::GetScreenshotBuffer(buffer, pitch, color_type, gamma);
return;
}
buffer = nullptr;
if ((ScreenshotTexture = GetCurrentScreen()) != nullptr)
{
@ -1705,10 +1674,6 @@ void OpenGLSWFrameBuffer::GetScreenshotBuffer(const uint8_t *&buffer, int &pitch
void OpenGLSWFrameBuffer::ReleaseScreenshotBuffer()
{
if (m_Lock > 0)
{
Super::ReleaseScreenshotBuffer();
}
ScreenshotTexture.reset();
}
@ -2071,10 +2036,6 @@ bool OpenGLSWFrameBuffer::OpenGLPal::Update()
bool OpenGLSWFrameBuffer::Begin2D(bool copy3d)
{
Super::Begin2D(copy3d);
if (!Accel2D)
{
return false;
}
if (In2D)
{
return true;
@ -2096,10 +2057,6 @@ bool OpenGLSWFrameBuffer::Begin2D(bool copy3d)
void OpenGLSWFrameBuffer::DrawBlendingRect()
{
if (!In2D || !Accel2D)
{
return;
}
Dim(FlashColor, FlashAmount / 256.f, viewwindowx, viewwindowy, viewwidth, viewheight);
}

View file

@ -122,11 +122,6 @@ private:
bool OpenGLSWFrameBuffer::WipeStartScreen(int type)
{
if (!Accel2D)
{
return Super::WipeStartScreen(type);
}
switch (type)
{
case wipe_Melt:
@ -164,12 +159,6 @@ bool OpenGLSWFrameBuffer::WipeStartScreen(int type)
void OpenGLSWFrameBuffer::WipeEndScreen()
{
if (!Accel2D)
{
Super::WipeEndScreen();
return;
}
// Don't do anything if there is no starting point.
if (InitialWipeScreen == NULL)
{
@ -206,11 +195,6 @@ void OpenGLSWFrameBuffer::WipeEndScreen()
bool OpenGLSWFrameBuffer::WipeDo(int ticks)
{
if (!Accel2D)
{
return Super::WipeDo(ticks);
}
// Sanity checks.
if (InitialWipeScreen == NULL || FinalWipeScreen == NULL)
{
@ -250,11 +234,6 @@ void OpenGLSWFrameBuffer::WipeCleanup()
InitialWipeScreen.reset();
FinalWipeScreen.reset();
GatheringWipeScreen = false;
if (!Accel2D)
{
Super::WipeCleanup();
return;
}
}
//==========================================================================

View file

@ -778,16 +778,6 @@ void M_Drawer (void)
AActor *camera = player->camera;
PalEntry fade = 0;
if (!screen->Accel2D && camera != nullptr && (gamestate == GS_LEVEL || gamestate == GS_TITLELEVEL))
{
if (camera->player != nullptr)
{
player = camera->player;
}
fade = PalEntry (uint8_t(player->BlendA*255), uint8_t(player->BlendR*255), uint8_t(player->BlendG*255), uint8_t(player->BlendB*255));
}
if (CurrentMenu != nullptr && menuactive != MENU_Off)
{
if (GLRenderer)

View file

@ -70,15 +70,6 @@ void PolyRenderer::RenderView(player_t *player)
RenderActorView(player->mo, false);
#if 0
// 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);
}
#endif
Threads.MainThread()->FlushDrawQueue();
DrawerThreads::WaitForWorkers();
}

View file

@ -418,7 +418,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 == screencanvas && (DFrameBuffer *)screen->Accel2D)
if (!noaccel && renderTarget == screencanvas)
{
FRenderStyle style = vis.RenderStyle;
style.CheckFuzz();

View file

@ -791,7 +791,6 @@ CocoaVideo* CocoaVideo::GetInstance()
SDLGLFB::SDLGLFB(void*, const int width, const int height, int, int, const bool fullscreen, bool bgra)
: DFrameBuffer(width, height, bgra)
, m_Lock(0)
, UpdatePending(false)
{
CGGammaValue gammaTable[GAMMA_TABLE_SIZE];
@ -818,28 +817,6 @@ SDLGLFB::~SDLGLFB()
{
}
bool SDLGLFB::Lock(bool buffered)
{
m_Lock++;
Buffer = MemBuffer;
return true;
}
void SDLGLFB::Unlock()
{
if (UpdatePending && 1 == m_Lock)
{
Update();
}
else if (--m_Lock <= 0)
{
m_Lock = 0;
}
}
bool SDLGLFB::IsFullscreen()
{
return CocoaVideo::IsFullscreen();
@ -858,6 +835,7 @@ void SDLGLFB::InitializeState()
{
}
#if 0
bool SDLGLFB::CanUpdate()
{
if (m_Lock != 1)
@ -873,6 +851,7 @@ bool SDLGLFB::CanUpdate()
return true;
}
#endif
void SDLGLFB::SwapBuffers()
{

View file

@ -55,9 +55,6 @@ public:
SDLGLFB(void *hMonitor, int width, int height, int, int, bool fullscreen, bool bgra);
~SDLGLFB();
virtual bool Lock(bool buffered = true);
virtual void Unlock();
virtual bool IsFullscreen();
virtual void SetVSync(bool vsync);
@ -66,7 +63,6 @@ public:
virtual int GetTrueHeight() { return GetClientHeight(); }
protected:
int m_Lock;
bool UpdatePending;
static const uint32_t GAMMA_CHANNEL_SIZE = 256;

View file

@ -374,7 +374,6 @@ SDLGLFB::SDLGLFB (void *, int width, int height, int, int, bool fullscreen, bool
int glveridx = 0;
int i;
m_Lock=0;
UpdatePending = false;
const char *version = Args->CheckValue("-glversion");
@ -447,6 +446,7 @@ void SDLGLFB::InitializeState()
{
}
#if 0
bool SDLGLFB::CanUpdate ()
{
if (m_Lock != 1)
@ -460,6 +460,7 @@ bool SDLGLFB::CanUpdate ()
}
return true;
}
#endif
void SDLGLFB::SetGammaTable(uint16_t *tbl)
{
@ -477,30 +478,6 @@ void SDLGLFB::ResetGammaTable()
}
}
bool SDLGLFB::Lock(bool buffered)
{
m_Lock++;
Buffer = MemBuffer;
return true;
}
bool SDLGLFB::Lock ()
{
return Lock(false);
}
void SDLGLFB::Unlock ()
{
if (UpdatePending && m_Lock == 1)
{
Update ();
}
else if (--m_Lock <= 0)
{
m_Lock = 0;
}
}
bool SDLGLFB::IsFullscreen ()
{
return (SDL_GetWindowFlags (Screen) & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0;

View file

@ -91,7 +91,6 @@ protected:
void UpdateColors ();
int m_Lock;
Uint16 m_origGamma[3][256];
bool m_supportsGamma;
};

View file

@ -69,17 +69,10 @@ namespace swrenderer
if (player->fixedcolormap >= 0 && player->fixedcolormap < (int)SpecialColormaps.Size())
{
realfixedcolormap = &SpecialColormaps[player->fixedcolormap];
if (renderTarget == screen->GetCanvas() && (renderTarget->IsBgra() || ((DFrameBuffer *)screen->Accel2D && r_shadercolormaps)))
{
// Render everything fullbright. The copy to video memory will
// apply the special colormap, so it won't be restricted to the
// palette.
fixedcolormap = &realcolormaps;
}
else
{
fixedcolormap = &SpecialSWColormaps[player->fixedcolormap];
}
// Render everything fullbright. The copy to video memory will
// apply the special colormap, so it won't be restricted to the
// palette.
fixedcolormap = &realcolormaps;
}
else if (player->fixedlightlevel >= 0 && player->fixedlightlevel < NUMCOLORMAPS)
{

View file

@ -884,9 +884,8 @@ namespace swrenderer
void RenderOpaquePass::ClearClip()
{
// clip ceiling to console bottom
fillshort(floorclip, viewwidth, viewheight);
fillshort(ceilingclip, viewwidth, !screen->Accel2D && ConBottom > viewwindowy && !Thread->Viewport->RenderingToCanvas() ? (ConBottom - viewwindowy) : 0);
fillshort(ceilingclip, viewwidth, 0);
}
void RenderOpaquePass::AddSprites(sector_t *sec, int lightlevel, WaterFakeSide fakeside, bool foggy, FDynamicColormap *basecolormap)

View file

@ -117,16 +117,6 @@ namespace swrenderer
RenderActorView(player->mo);
// Apply special colormap if the target cannot do it
#if 0
if (CameraLight::Instance()->ShaderColormap() && viewport->RenderTarget->IsBgra() && !(r_shadercolormaps && screen->Accel2D))
{
auto queue = std::make_shared<DrawerCommandQueue>(MainThread()->FrameMemory.get());
queue->Push<ApplySpecialColormapRGBACommand>(CameraLight::Instance()->ShaderColormap(), screen);
DrawerThreads::Execute(queue);
}
#endif
DrawerWaitCycles.Clock();
DrawerThreads::WaitForWorkers();
DrawerWaitCycles.Unclock();

View file

@ -420,7 +420,7 @@ namespace swrenderer
// 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 && viewport->RenderTarget == screencanvas && (DFrameBuffer *)screen->Accel2D)
if (!noaccel && viewport->RenderTarget == screencanvas)
{
FRenderStyle style = vis.RenderStyle;
style.CheckFuzz();

View file

@ -610,7 +610,6 @@ DFrameBuffer::DFrameBuffer (int width, int height, bool bgra)
Bgra = bgra;
LastMS = LastSec = FrameCount = LastCount = LastTic = 0;
Accel2D = false;
VideoWidth = width;
VideoHeight = height;

View file

@ -279,7 +279,6 @@ protected:
bool ParseDrawTextureTags(FTexture *img, double x, double y, uint32_t tag, T& tags, DrawParms *parms, bool fortext) const;
void DrawTextCommon(FFont *font, int normalcolor, double x, double y, const char *string, DrawParms &parms);
int LockCount = 0;
int Width = 0;
int Height = 0;
bool Bgra = 0;
@ -340,7 +339,6 @@ public:
// Set the rect defining the area affected by blending.
virtual void SetBlendingRect (int x1, int y1, int x2, int y2);
bool Accel2D; // If true, 2D drawing can be accelerated.
virtual bool LegacyHardware() const { return false; } // only for reporting SM1.4 support to the stat collector
// Begin 2D drawing operations. This is like Update, but it doesn't end

View file

@ -241,7 +241,6 @@ D3DFB::D3DFB (UINT adapter, int width, int height, bool bgra, bool fullscreen)
In2D = 0;
Palettes = NULL;
Textures = NULL;
Accel2D = true;
GatheringWipeScreen = false;
ScreenWipe = NULL;
InScene = false;
@ -939,17 +938,6 @@ void D3DFB::Update ()
return;
}
if (LockCount != 1)
{
I_FatalError ("Framebuffer must have exactly 1 lock to be updated");
if (LockCount > 0)
{
UpdatePending = true;
--LockCount;
}
return;
}
if (In2D == 0)
{
DrawRateStuff();
@ -998,7 +986,6 @@ void D3DFB::Update ()
BlitCycles.Reset();
BlitCycles.Clock();
LockCount = 0;
HRESULT hr = D3DDevice->TestCooperativeLevel();
if (FAILED(hr) && (hr != D3DERR_DEVICENOTRESET || !Reset()))
{
@ -1126,10 +1113,6 @@ bool D3DFB::PaintToWindow ()
{
HRESULT hr;
if (LockCount != 0)
{
return false;
}
hr = D3DDevice->TestCooperativeLevel();
if (FAILED(hr))
{
@ -1244,30 +1227,22 @@ void D3DFB::Draw3DPart(bool copy3d)
{
FBVERTEX verts[4];
D3DCOLOR color0, color1;
if (Accel2D)
auto map = swrenderer::CameraLight::Instance()->ShaderColormap();
if (map == NULL)
{
auto map = swrenderer::CameraLight::Instance()->ShaderColormap();
if (map == NULL)
{
color0 = 0;
color1 = 0xFFFFFFF;
}
else
{
color0 = D3DCOLOR_COLORVALUE(map->ColorizeStart[0]/2, map->ColorizeStart[1]/2, map->ColorizeStart[2]/2, 0);
color1 = D3DCOLOR_COLORVALUE(map->ColorizeEnd[0]/2, map->ColorizeEnd[1]/2, map->ColorizeEnd[2]/2, 1);
if (IsBgra())
SetPixelShader(Shaders[SHADER_SpecialColormap]);
else
SetPixelShader(Shaders[SHADER_SpecialColormapPal]);
}
color0 = 0;
color1 = 0xFFFFFFF;
}
else
{
color0 = FlashColor0;
color1 = FlashColor1;
color0 = D3DCOLOR_COLORVALUE(map->ColorizeStart[0]/2, map->ColorizeStart[1]/2, map->ColorizeStart[2]/2, 0);
color1 = D3DCOLOR_COLORVALUE(map->ColorizeEnd[0]/2, map->ColorizeEnd[1]/2, map->ColorizeEnd[2]/2, 1);
if (IsBgra())
SetPixelShader(Shaders[SHADER_SpecialColormap]);
else
SetPixelShader(Shaders[SHADER_SpecialColormapPal]);
}
CalcFullscreenCoords(verts, Accel2D, false, color0, color1);
CalcFullscreenCoords(verts, true, false, color0, color1);
D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(FBVERTEX));
}
if (IsBgra())
@ -1457,11 +1432,6 @@ void D3DFB::GetScreenshotBuffer(const uint8_t *&buffer, int &pitch, ESSType &col
{
D3DLOCKED_RECT lrect;
if (!Accel2D)
{
Super::GetScreenshotBuffer(buffer, pitch, color_type, gamma);
return;
}
buffer = NULL;
if ((ScreenshotTexture = GetCurrentScreen()) != NULL)
{
@ -1495,10 +1465,6 @@ void D3DFB::GetScreenshotBuffer(const uint8_t *&buffer, int &pitch, ESSType &col
void D3DFB::ReleaseScreenshotBuffer()
{
if (LockCount > 0)
{
Super::ReleaseScreenshotBuffer();
}
if (ScreenshotSurface != NULL)
{
ScreenshotSurface->UnlockRect();
@ -1806,10 +1772,6 @@ bool D3DPal::Update()
bool D3DFB::Begin2D(bool copy3d)
{
Super::Begin2D(copy3d);
if (!Accel2D)
{
return false;
}
if (In2D)
{
return true;
@ -1831,10 +1793,6 @@ bool D3DFB::Begin2D(bool copy3d)
void D3DFB::DrawBlendingRect()
{
if (!In2D || !Accel2D)
{
return;
}
Dim(FlashColor, FlashAmount / 256.f, viewwindowx, viewwindowy, viewwidth, viewheight);
}

View file

@ -136,11 +136,6 @@ bool D3DFB::WipeStartScreen(int type)
IDirect3DSurface9 *tsurf;
D3DSURFACE_DESC desc;
if (!Accel2D)
{
return Super::WipeStartScreen(type);
}
switch (type)
{
case wipe_Melt:
@ -200,12 +195,6 @@ bool D3DFB::WipeStartScreen(int type)
void D3DFB::WipeEndScreen()
{
if (!Accel2D)
{
Super::WipeEndScreen();
return;
}
// Don't do anything if there is no starting point.
if (InitialWipeScreen == NULL)
{
@ -254,11 +243,6 @@ void D3DFB::WipeEndScreen()
bool D3DFB::WipeDo(int ticks)
{
if (!Accel2D)
{
return Super::WipeDo(ticks);
}
// Sanity checks.
if (InitialWipeScreen == NULL || FinalWipeScreen == NULL)
{
@ -321,11 +305,6 @@ void D3DFB::WipeCleanup()
SAFE_RELEASE( InitialWipeScreen );
SAFE_RELEASE( FinalWipeScreen );
GatheringWipeScreen = false;
if (!Accel2D)
{
Super::WipeCleanup();
return;
}
}
//==========================================================================

View file

@ -993,7 +993,6 @@ Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, in
m_RefreshHz = refreshHz;
m_Fullscreen = fullscreen;
m_Bgra = bgra;
m_Lock=0;
RECT r;
LONG style, exStyle;

View file

@ -70,7 +70,6 @@ protected:
bool m_supportsGamma;
bool m_Fullscreen, m_Bgra;
int m_Width, m_Height, m_Bits, m_RefreshHz;
int m_Lock;
char m_displayDeviceNameBuffer[32/*CCHDEVICENAME*/]; // do not use windows.h constants here!
char *m_displayDeviceName;
int SwapInterval;