- removed the Softpoly backend.

Its only relevant use case has been to use the software renderer on hardware not capable of OpenGL 3.3, but a large chunk of that can now be serviced with GLES.
In addition it has ceased further development and has not received any of the recent 2D render features which further reduces its viability.
This commit is contained in:
Christoph Oelckers 2022-07-28 10:31:56 +02:00
commit 93e934c8d0
58 changed files with 25 additions and 7282 deletions

View file

@ -60,9 +60,6 @@
#ifdef HAVE_VULKAN
#include "vulkan/system/vk_framebuffer.h"
#endif
#ifdef HAVE_SOFTPOLY
#include "poly_framebuffer.h"
#endif
extern bool ToggleFullscreen;
@ -101,7 +98,6 @@ extern bool ToggleFullscreen;
EXTERN_CVAR(Bool, vid_hidpi)
EXTERN_CVAR(Int, vid_defwidth)
EXTERN_CVAR(Int, vid_defheight)
EXTERN_CVAR(Int, vid_preferbackend)
EXTERN_CVAR(Bool, vk_debug)
CVAR(Bool, mvk_debug, false, 0)
@ -376,7 +372,7 @@ class CocoaVideo : public IVideo
public:
CocoaVideo()
{
ms_isVulkanEnabled = vid_preferbackend == 1 && NSAppKitVersionNumber >= 1404; // NSAppKitVersionNumber10_11
ms_isVulkanEnabled = V_GetBackend() == 1 && NSAppKitVersionNumber >= 1404; // NSAppKitVersionNumber10_11
}
~CocoaVideo()
@ -450,23 +446,12 @@ public:
else
#endif
#ifdef HAVE_SOFTPOLY
if (vid_preferbackend == 2)
{
SetupOpenGLView(ms_window, OpenGLProfile::Legacy);
fb = new PolyFrameBuffer(nullptr, vid_fullscreen);
}
else
#endif
{
SetupOpenGLView(ms_window, OpenGLProfile::Core);
}
SetupOpenGLView(ms_window, OpenGLProfile::Core);
if (fb == nullptr)
{
#ifdef HAVE_GLES2
if( (Args->CheckParm ("-gles2_renderer")) || (vid_preferbackend == 3) )
if(V_GetBackend() == 2)
fb = new OpenGLESRenderer::OpenGLFrameBuffer(0, vid_fullscreen);
else
#endif

View file

@ -58,10 +58,6 @@
#include "vulkan/system/vk_framebuffer.h"
#endif
#ifdef HAVE_SOFTPOLY
#include "poly_framebuffer.h"
#endif
// MACROS ------------------------------------------------------------------
#if defined HAVE_VULKAN
@ -81,7 +77,6 @@ EXTERN_CVAR (Int, vid_adapter)
EXTERN_CVAR (Int, vid_displaybits)
EXTERN_CVAR (Int, vid_defwidth)
EXTERN_CVAR (Int, vid_defheight)
EXTERN_CVAR (Int, vid_preferbackend)
EXTERN_CVAR (Bool, cl_capfps)
// PUBLIC DATA DEFINITIONS -------------------------------------------------
@ -233,157 +228,6 @@ bool I_CreateVulkanSurface(VkInstance instance, VkSurfaceKHR *surface)
}
#endif
#ifdef HAVE_SOFTPOLY
namespace
{
SDL_Renderer* polyrendertarget = nullptr;
SDL_Texture* polytexture = nullptr;
int polytexturew = 0;
int polytextureh = 0;
bool polyvsync = false;
bool polyfirstinit = true;
}
void I_PolyPresentInit()
{
assert(Priv::softpolyEnabled);
assert(Priv::window != nullptr);
if (strcmp(vid_sdl_render_driver, "") != 0)
{
SDL_SetHint(SDL_HINT_RENDER_DRIVER, vid_sdl_render_driver);
}
}
uint8_t *I_PolyPresentLock(int w, int h, bool vsync, int &pitch)
{
// When vsync changes we need to reinitialize
if (polyrendertarget && polyvsync != vsync)
{
I_PolyPresentDeinit();
}
if (!polyrendertarget)
{
polyvsync = vsync;
polyrendertarget = SDL_CreateRenderer(Priv::window, -1, vsync ? SDL_RENDERER_PRESENTVSYNC : 0);
if (!polyrendertarget)
{
I_FatalError("Could not create render target for softpoly: %s\n", SDL_GetError());
}
// Tell the user which render driver is being used, but don't repeat
// outselves if we're just changing vsync.
if (polyfirstinit)
{
polyfirstinit = false;
SDL_RendererInfo rendererInfo;
if (SDL_GetRendererInfo(polyrendertarget, &rendererInfo) == 0)
{
Printf("Using render driver %s\n", rendererInfo.name);
}
else
{
Printf("Failed to query render driver\n");
}
}
// Mask color
SDL_SetRenderDrawColor(polyrendertarget, 0, 0, 0, 255);
}
if (!polytexture || polytexturew != w || polytextureh != h)
{
if (polytexture)
{
SDL_DestroyTexture(polytexture);
polytexture = nullptr;
polytexturew = polytextureh = 0;
}
if ((polytexture = SDL_CreateTexture(polyrendertarget, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, w, h)) == nullptr)
I_Error("Failed to create %dx%d render target texture.", w, h);
polytexturew = w;
polytextureh = h;
}
uint8_t* pixels;
SDL_LockTexture(polytexture, nullptr, (void**)&pixels, &pitch);
return pixels;
}
void I_PolyPresentUnlock(int x, int y, int width, int height)
{
SDL_UnlockTexture(polytexture);
int ClientWidth, ClientHeight;
SDL_GetRendererOutputSize(polyrendertarget, &ClientWidth, &ClientHeight);
SDL_Rect clearrects[4];
int count = 0;
if (y > 0)
{
clearrects[count].x = 0;
clearrects[count].y = 0;
clearrects[count].w = ClientWidth;
clearrects[count].h = y;
count++;
}
if (y + height < ClientHeight)
{
clearrects[count].x = 0;
clearrects[count].y = y + height;
clearrects[count].w = ClientWidth;
clearrects[count].h = ClientHeight - clearrects[count].y;
count++;
}
if (x > 0)
{
clearrects[count].x = 0;
clearrects[count].y = y;
clearrects[count].w = x;
clearrects[count].h = height;
count++;
}
if (x + width < ClientWidth)
{
clearrects[count].x = x + width;
clearrects[count].y = y;
clearrects[count].w = ClientWidth - clearrects[count].x;
clearrects[count].h = height;
count++;
}
if (count > 0)
SDL_RenderFillRects(polyrendertarget, clearrects, count);
SDL_Rect dstrect;
dstrect.x = x;
dstrect.y = y;
dstrect.w = width;
dstrect.h = height;
SDL_RenderCopy(polyrendertarget, polytexture, nullptr, &dstrect);
SDL_RenderPresent(polyrendertarget);
}
void I_PolyPresentDeinit()
{
if (polytexture)
{
SDL_DestroyTexture(polytexture);
polytexture = nullptr;
}
if (polyrendertarget)
{
SDL_DestroyRenderer(polyrendertarget);
polyrendertarget = nullptr;
}
}
#endif
SDLVideo::SDLVideo ()
{
@ -399,11 +243,8 @@ SDLVideo::SDLVideo ()
I_FatalError("Only SDL 2.0.6 or later is supported.");
}
#ifdef HAVE_SOFTPOLY
Priv::softpolyEnabled = vid_preferbackend == 2;
#endif
#ifdef HAVE_VULKAN
Priv::vulkanEnabled = vid_preferbackend == 1;
Priv::vulkanEnabled = V_GetBackend() == 1;
if (Priv::vulkanEnabled)
{
@ -415,16 +256,6 @@ SDLVideo::SDLVideo ()
}
}
#endif
#ifdef HAVE_SOFTPOLY
if (Priv::softpolyEnabled)
{
Priv::CreateWindow(SDL_WINDOW_HIDDEN);
if (Priv::window == nullptr)
{
I_FatalError("Could not create SoftPoly window:\n%s\n",SDL_GetError());
}
}
#endif
}
SDLVideo::~SDLVideo ()
@ -461,16 +292,10 @@ DFrameBuffer *SDLVideo::CreateFrameBuffer ()
}
#endif
#ifdef HAVE_SOFTPOLY
if (Priv::softpolyEnabled)
{
fb = new PolyFrameBuffer(nullptr, vid_fullscreen);
}
#endif
if (fb == nullptr)
{
#ifdef HAVE_GLES2
if( (Args->CheckParm ("-gles2_renderer")) || (vid_preferbackend == 3) )
if (V_GetBackend() == 2)
fb = new OpenGLESRenderer::OpenGLFrameBuffer(0, vid_fullscreen);
else
#endif
@ -503,16 +328,6 @@ int SystemBaseFrameBuffer::GetClientWidth()
{
int width = 0;
#ifdef HAVE_SOFTPOLY
if (Priv::softpolyEnabled)
{
if (polyrendertarget)
SDL_GetRendererOutputSize(polyrendertarget, &width, nullptr);
else
SDL_GetWindowSize(Priv::window, &width, nullptr);
return width;
}
#endif
#ifdef HAVE_VULKAN
assert(Priv::vulkanEnabled);
@ -526,17 +341,6 @@ int SystemBaseFrameBuffer::GetClientHeight()
{
int height = 0;
#ifdef HAVE_SOFTPOLY
if (Priv::softpolyEnabled)
{
if (polyrendertarget)
SDL_GetRendererOutputSize(polyrendertarget, nullptr, &height);
else
SDL_GetWindowSize(Priv::window, nullptr, &height);
return height;
}
#endif
#ifdef HAVE_VULKAN
assert(Priv::vulkanEnabled);
SDL_Vulkan_GetDrawableSize(Priv::window, nullptr, &height);

View file

@ -44,9 +44,6 @@
#include "version.h"
#include "printf.h"
#include "win32glvideo.h"
#ifdef HAVE_SOFTPOLY
#include "win32polyvideo.h"
#endif
#ifdef HAVE_VULKAN
#include "win32vulkanvideo.h"
#endif
@ -54,8 +51,6 @@
#include "i_system.h"
#include "i_mainwindow.h"
EXTERN_CVAR(Int, vid_preferbackend)
IVideo *Video;
// do not include GL headers here, only declare the necessary functions.
@ -130,15 +125,8 @@ void I_InitGraphics ()
// are the active app. Huh?
}
#ifdef HAVE_SOFTPOLY
if (vid_preferbackend == 2)
{
Video = new Win32PolyVideo();
}
else
#endif
#ifdef HAVE_VULKAN
if (vid_preferbackend == 1)
if (V_GetBackend() == 1)
{
// first try Vulkan, if that fails OpenGL
try
@ -157,10 +145,6 @@ void I_InitGraphics ()
Video = new Win32GLVideo();
}
#ifdef HAVE_SOFTPOLY
if (Video == NULL)
Video = new Win32PolyVideo();
#endif
// we somehow STILL don't have a display!!
if (Video == NULL)
I_FatalError ("Failed to initialize display");

View file

@ -447,12 +447,10 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa
vid_fullscreen = SendDlgItemMessage( hDlg, IDC_WELCOME_FULLSCREEN, BM_GETCHECK, 0, 0 ) == BST_CHECKED;
#ifdef HAVE_GLES2
if (SendDlgItemMessage(hDlg, IDC_WELCOME_VULKAN4, BM_GETCHECK, 0, 0) == BST_CHECKED)
vid_preferbackend = 3;
vid_preferbackend = 2;
else
#endif
if (SendDlgItemMessage(hDlg, IDC_WELCOME_VULKAN3, BM_GETCHECK, 0, 0) == BST_CHECKED)
vid_preferbackend = 2;
else if (SendDlgItemMessage(hDlg, IDC_WELCOME_VULKAN2, BM_GETCHECK, 0, 0) == BST_CHECKED)
if (SendDlgItemMessage(hDlg, IDC_WELCOME_VULKAN2, BM_GETCHECK, 0, 0) == BST_CHECKED)
vid_preferbackend = 1;
else if (SendDlgItemMessage(hDlg, IDC_WELCOME_VULKAN1, BM_GETCHECK, 0, 0) == BST_CHECKED)
vid_preferbackend = 0;

View file

@ -65,7 +65,6 @@ PROC zd_wglGetProcAddress(LPCSTR name);
}
EXTERN_CVAR(Int, vid_adapter)
EXTERN_CVAR(Int, vid_preferbackend)
EXTERN_CVAR(Bool, vid_hdr)
CUSTOM_CVAR(Bool, gl_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
@ -110,7 +109,7 @@ DFrameBuffer *Win32GLVideo::CreateFrameBuffer()
SystemGLFrameBuffer *fb;
#ifdef HAVE_GLES2
if ((Args->CheckParm("-gles2_renderer")) || (vid_preferbackend == 3) )
if (V_GetBackend() == 2)
fb = new OpenGLESRenderer::OpenGLFrameBuffer(m_hMonitor, vid_fullscreen);
else
#endif

View file

@ -1,198 +0,0 @@
#include <assert.h>
#include "hardware.h"
#include "engineerrors.h"
#include <Windows.h>
#include "i_mainwindow.h"
#ifdef HAVE_SOFTPOLY
EXTERN_CVAR(Bool, vid_vsync)
bool ViewportLinearScale();
#include <d3d9.h>
#pragma comment(lib, "d3d9.lib")
#ifndef D3DPRESENT_FORCEIMMEDIATE
#define D3DPRESENT_FORCEIMMEDIATE 0x00000100L // MinGW
#endif
namespace
{
int SrcWidth = 0;
int SrcHeight = 0;
int ClientWidth = 0;
int ClientHeight = 0;
bool CurrentVSync = false;
IDirect3D9Ex *d3d9 = nullptr;
IDirect3DDevice9Ex *device = nullptr;
IDirect3DSurface9* surface = nullptr;
}
void I_PolyPresentInit()
{
Direct3DCreate9Ex(D3D_SDK_VERSION, &d3d9);
if (!d3d9)
{
I_FatalError("Direct3DCreate9 failed");
}
RECT rect = {};
GetClientRect(mainwindow.GetHandle(), &rect);
ClientWidth = rect.right;
ClientHeight = rect.bottom;
D3DPRESENT_PARAMETERS pp = {};
pp.Windowed = true;
pp.SwapEffect = D3DSWAPEFFECT_FLIPEX;
pp.BackBufferWidth = ClientWidth;
pp.BackBufferHeight = ClientHeight;
pp.BackBufferCount = 1;
pp.hDeviceWindow = mainwindow.GetHandle();
pp.PresentationInterval = CurrentVSync ? D3DPRESENT_INTERVAL_DEFAULT : D3DPRESENT_INTERVAL_IMMEDIATE;
HRESULT result = d3d9->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, mainwindow.GetHandle(), D3DCREATE_HARDWARE_VERTEXPROCESSING, &pp, nullptr, &device);
if (FAILED(result))
{
I_FatalError("IDirect3D9.CreateDevice failed");
}
}
uint8_t *I_PolyPresentLock(int w, int h, bool vsync, int &pitch)
{
HRESULT result;
RECT rect = {};
GetClientRect(mainwindow.GetHandle(), &rect);
if (rect.right != ClientWidth || rect.bottom != ClientHeight || CurrentVSync != vsync)
{
if (surface)
{
surface->Release();
surface = nullptr;
}
CurrentVSync = vsync;
ClientWidth = rect.right;
ClientHeight = rect.bottom;
D3DPRESENT_PARAMETERS pp = {};
pp.Windowed = true;
pp.SwapEffect = D3DSWAPEFFECT_FLIPEX;
pp.BackBufferWidth = ClientWidth;
pp.BackBufferHeight = ClientHeight;
pp.BackBufferCount = 1;
pp.hDeviceWindow = mainwindow.GetHandle();
pp.PresentationInterval = CurrentVSync ? D3DPRESENT_INTERVAL_DEFAULT : D3DPRESENT_INTERVAL_IMMEDIATE;
device->Reset(&pp);
}
if (SrcWidth != w || SrcHeight != h || !surface)
{
if (surface)
{
surface->Release();
surface = nullptr;
}
SrcWidth = w;
SrcHeight = h;
result = device->CreateOffscreenPlainSurface(SrcWidth, SrcHeight, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surface, 0);
if (FAILED(result))
{
I_FatalError("IDirect3DDevice9.CreateOffscreenPlainSurface failed");
}
}
D3DLOCKED_RECT lockrect = {};
result = surface->LockRect(&lockrect, nullptr, D3DLOCK_DISCARD);
if (FAILED(result))
{
pitch = 0;
return nullptr;
}
pitch = lockrect.Pitch;
return (uint8_t*)lockrect.pBits;
}
void I_PolyPresentUnlock(int x, int y, int width, int height)
{
surface->UnlockRect();
IDirect3DSurface9 *backbuffer = nullptr;
HRESULT result = device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
if (FAILED(result))
return;
result = device->BeginScene();
if (SUCCEEDED(result))
{
int count = 0;
D3DRECT clearrects[4];
if (y > 0)
{
clearrects[count].x1 = 0;
clearrects[count].y1 = 0;
clearrects[count].x2 = ClientWidth;
clearrects[count].y2 = y;
count++;
}
if (y + height < ClientHeight)
{
clearrects[count].x1 = 0;
clearrects[count].y1 = y + height;
clearrects[count].x2 = ClientWidth;
clearrects[count].y2 = ClientHeight;
count++;
}
if (x > 0)
{
clearrects[count].x1 = 0;
clearrects[count].y1 = y;
clearrects[count].x2 = x;
clearrects[count].y2 = y + height;
count++;
}
if (x + width < ClientWidth)
{
clearrects[count].x1 = x + width;
clearrects[count].y1 = y;
clearrects[count].x2 = ClientWidth;
clearrects[count].y2 = y + height;
count++;
}
if (count > 0)
device->Clear(count, clearrects, D3DCLEAR_TARGET, 0, 0.0f, 0);
RECT srcrect = {}, dstrect = {};
srcrect.right = SrcWidth;
srcrect.bottom = SrcHeight;
dstrect.left = x;
dstrect.top = y;
dstrect.right = x + width;
dstrect.bottom = y + height;
if (ViewportLinearScale())
device->StretchRect(surface, &srcrect, backbuffer, &dstrect, D3DTEXF_LINEAR);
else
device->StretchRect(surface, &srcrect, backbuffer, &dstrect, D3DTEXF_POINT);
result = device->EndScene();
if (SUCCEEDED(result))
device->PresentEx(nullptr, nullptr, 0, nullptr, CurrentVSync ? 0 : D3DPRESENT_FORCEIMMEDIATE);
}
backbuffer->Release();
}
void I_PolyPresentDeinit()
{
if (surface) surface->Release();
if (device) device->Release();
if (d3d9) d3d9->Release();
}
#endif

View file

@ -1,21 +0,0 @@
#pragma once
#include "win32basevideo.h"
#include "c_cvars.h"
#include "poly_framebuffer.h"
EXTERN_CVAR(Bool, vid_fullscreen)
class Win32PolyVideo : public Win32BaseVideo
{
public:
void Shutdown() override
{
}
DFrameBuffer *CreateFrameBuffer() override
{
auto fb = new PolyFrameBuffer(m_hMonitor, vid_fullscreen);
return fb;
}
};