Permalink
Browse files

GPU: Remove duplicate BACKEND constants.

  • Loading branch information...
unknownbrackets committed Dec 26, 2017
1 parent 4657397 commit d6da758ed3b51cfea456a49f79fd03327a94d284
View
@@ -484,20 +484,20 @@ static int DefaultGPUBackend() {
#if PPSSPP_PLATFORM(WINDOWS) || PPSSPP_PLATFORM(ANDROID)
// Where supported, let's use Vulkan.
if (VulkanMayBeAvailable()) {
return GPU_BACKEND_VULKAN;
return (int)GPUBackend::VULKAN;
}
#endif
#if PPSSPP_PLATFORM(WINDOWS)
// If no Vulkan, use Direct3D 11 on Windows 8+ (most importantly 10.)
if (DoesVersionMatchWindows(6, 2, 0, 0, true)) {
return GPU_BACKEND_DIRECT3D11;
return (int)GPUBackend::DIRECT3D11;
}
#endif
return GPU_BACKEND_OPENGL;
return (int)GPUBackend::OPENGL;
}
static bool DefaultVertexCache() {
return DefaultGPUBackend() == GPU_BACKEND_OPENGL;
return DefaultGPUBackend() == (int)GPUBackend::OPENGL;
}
static ConfigSetting graphicsSettings[] = {
View
@@ -57,12 +57,6 @@ enum class GPUBackend {
DIRECT3D11 = 2,
VULKAN = 3,
};
enum {
GPU_BACKEND_OPENGL = (int)GPUBackend::OPENGL,
GPU_BACKEND_DIRECT3D9 = (int)GPUBackend::DIRECT3D9,
GPU_BACKEND_DIRECT3D11 = (int)GPUBackend::DIRECT3D11,
GPU_BACKEND_VULKAN = (int)GPUBackend::VULKAN,
};
enum AudioBackendType {
AUDIO_BACKEND_AUTO,
@@ -1928,7 +1928,7 @@ bool FramebufferManagerCommon::GetFramebuffer(u32 fb_address, int fb_stride, GEB
}
// TODO: Maybe should handle flipY inside CopyFramebufferToMemorySync somehow?
bool flipY = (g_Config.iGPUBackend == GPU_BACKEND_OPENGL && !useBufferedRendering_) ? true : false;
bool flipY = (GetGPUBackend() == GPUBackend::OPENGL && !useBufferedRendering_) ? true : false;
buffer.Allocate(w, h, GE_FORMAT_8888, flipY, true);
bool retval = draw_->CopyFramebufferToMemorySync(bound, Draw::FB_COLOR_BIT, 0, 0, w, h, Draw::DataFormat::R8G8B8A8_UNORM, buffer.GetData(), w);
gpuStats.numReadbacks++;
@@ -1960,7 +1960,7 @@ bool FramebufferManagerCommon::GetDepthbuffer(u32 fb_address, int fb_stride, u32
h = std::min(h, PSP_CoreParameter().pixelHeight);
}
bool flipY = (g_Config.iGPUBackend == GPU_BACKEND_OPENGL && !useBufferedRendering_) ? true : false;
bool flipY = (GetGPUBackend() == GPUBackend::OPENGL && !useBufferedRendering_) ? true : false;
if (gstate_c.Supports(GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT)) {
buffer.Allocate(w, h, GPU_DBG_FORMAT_FLOAT_DIV_256, flipY);
} else {
@@ -1994,7 +1994,7 @@ bool FramebufferManagerCommon::GetStencilbuffer(u32 fb_address, int fb_stride, G
h = std::min(h, PSP_CoreParameter().pixelHeight);
}
bool flipY = (g_Config.iGPUBackend == GPU_BACKEND_OPENGL && !useBufferedRendering_) ? true : false;
bool flipY = (GetGPUBackend() == GPUBackend::OPENGL && !useBufferedRendering_) ? true : false;
// No need to free on failure, the caller/destructor will do that. Usually this is a reused buffer, anyway.
buffer.Allocate(w, h, GPU_DBG_FORMAT_8BIT, flipY);
bool retval = draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_STENCIL_BIT, 0, 0, w,h, Draw::DataFormat::S8, buffer.GetData(), w);
@@ -783,7 +783,7 @@ bool TextureCacheD3D11::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level
// TODO: Centralize.
if (nextTexture_->framebuffer) {
VirtualFramebuffer *vfb = nextTexture_->framebuffer;
bool flipY = g_Config.iGPUBackend == GPU_BACKEND_OPENGL && g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
bool flipY = GetGPUBackend() == GPUBackend::OPENGL && g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
buffer.Allocate(vfb->bufferWidth, vfb->bufferHeight, GPU_DBG_FORMAT_8888, flipY);
bool retval = draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_COLOR_BIT, 0, 0, vfb->bufferWidth, vfb->bufferHeight, Draw::DataFormat::R8G8B8A8_UNORM, buffer.GetData(), vfb->bufferWidth);
// Vulkan requires us to re-apply all dynamic state for each command buffer, and the above will cause us to start a new cmdbuf.
@@ -792,7 +792,7 @@ bool TextureCacheVulkan::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int leve
// TODO: Centralize?
if (nextTexture_->framebuffer) {
VirtualFramebuffer *vfb = nextTexture_->framebuffer;
bool flipY = g_Config.iGPUBackend == GPU_BACKEND_OPENGL && g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
bool flipY = GetGPUBackend() == GPUBackend::OPENGL && g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
buffer.Allocate(vfb->bufferWidth, vfb->bufferHeight, GPU_DBG_FORMAT_8888, flipY);
bool retval = draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_COLOR_BIT, 0, 0, vfb->bufferWidth, vfb->bufferHeight, Draw::DataFormat::R8G8B8A8_UNORM, buffer.GetData(), vfb->bufferWidth);
// Vulkan requires us to re-apply all dynamic state for each command buffer, and the above will cause us to start a new cmdbuf.
View
@@ -865,17 +865,18 @@ int main(int argc, char *argv[]) {
GraphicsContext *graphicsContext = nullptr;
SDL_Window *window = nullptr;
std::string error_message;
if (g_Config.iGPUBackend == GPU_BACKEND_OPENGL) {
if (g_Config.iGPUBackend == (int)GPUBackend::OPENGL) {
SDLGLGraphicsContext *ctx = new SDLGLGraphicsContext();
if (ctx->Init(window, x, y, mode, &error_message) != 0) {
printf("GL init error '%s'\n", error_message.c_str());
}
graphicsContext = ctx;
} else if (g_Config.iGPUBackend == GPU_BACKEND_VULKAN) {
} else if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN) {
SDLVulkanGraphicsContext *ctx = new SDLVulkanGraphicsContext();
if (!ctx->Init(window, x, y, mode, &error_message)) {
printf("Vulkan init error '%s' - falling back to GL\n", error_message.c_str());
g_Config.iGPUBackend = GPU_BACKEND_OPENGL;
g_Config.iGPUBackend = (int)GPUBackend::OPENGL;
SetGPUBackend((GPUBackend)g_Config.iGPUBackend);
delete ctx;
SDLGLGraphicsContext *glctx = new SDLGLGraphicsContext();
glctx->Init(window, x, y, mode, &error_message);
View
@@ -391,15 +391,15 @@ void SystemInfoScreen::CreateViews() {
deviceSpecs->Add(new InfoItem(si->T("Vendor (detected)"), vendor));
deviceSpecs->Add(new InfoItem(si->T("Driver Version"), draw->GetInfoString(InfoField::DRIVER)));
#ifdef _WIN32
if (g_Config.iGPUBackend != GPU_BACKEND_VULKAN)
if (GetGPUBackend() != GPUBackend::VULKAN)
deviceSpecs->Add(new InfoItem(si->T("Driver Version"), System_GetProperty(SYSPROP_GPUDRIVER_VERSION)));
#if !PPSSPP_PLATFORM(UWP)
if (GetGPUBackend() == GPUBackend::DIRECT3D9) {
deviceSpecs->Add(new InfoItem(si->T("D3DX Version"), StringFromFormat("%d", GetD3DXVersion())));
}
#endif
#endif
if (g_Config.iGPUBackend == GPU_BACKEND_OPENGL) {
if (GetGPUBackend() == GPUBackend::OPENGL) {
deviceSpecs->Add(new InfoItem(si->T("Core Context"), gl_extensions.IsCoreContext ? si->T("Yes") : si->T("No")));
}
deviceSpecs->Add(new ItemHeader(si->T("OS Information")));
@@ -510,7 +510,7 @@ void SystemInfoScreen::CreateViews() {
gpuExtensions->SetSpacing(0);
gpuExtensionsScroll->Add(gpuExtensions);
if (g_Config.iGPUBackend == GPU_BACKEND_OPENGL) {
if (GetGPUBackend() == GPUBackend::OPENGL) {
tabHolder->AddTab(si->T("OGL Extensions"), gpuExtensionsScroll);
if (!gl_extensions.IsGLES) {
@@ -547,7 +547,7 @@ void SystemInfoScreen::CreateViews() {
eglExtensions->Add(new TextView(extension, new LayoutParams(FILL_PARENT, WRAP_CONTENT)))->SetFocusable(true);
}
}
} else if (g_Config.iGPUBackend == GPU_BACKEND_VULKAN) {
} else if (GetGPUBackend() == GPUBackend::VULKAN) {
tabHolder->AddTab(si->T("Vulkan Features"), gpuExtensionsScroll);
gpuExtensions->Add(new ItemHeader(si->T("Vulkan Features")));
View
@@ -106,11 +106,11 @@ bool CheckSupportInstancedTessellationGLES() {
}
bool IsBackendSupportHWTess() {
switch (g_Config.iGPUBackend) {
case GPU_BACKEND_OPENGL:
switch (GetGPUBackend()) {
case GPUBackend::OPENGL:
return CheckSupportInstancedTessellationGLES();
case GPU_BACKEND_VULKAN:
case GPU_BACKEND_DIRECT3D11:
case GPUBackend::VULKAN:
case GPUBackend::DIRECT3D11:
return true;
}
return false;
@@ -180,7 +180,7 @@ void GameSettingsScreen::CreateViews() {
graphicsSettings->Add(new ItemHeader(gr->T("Rendering Mode")));
static const char *renderingBackend[] = { "OpenGL", "Direct3D 9", "Direct3D 11", "Vulkan" };
PopupMultiChoice *renderingBackendChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iGPUBackend, gr->T("Backend"), renderingBackend, GPU_BACKEND_OPENGL, ARRAY_SIZE(renderingBackend), gr->GetName(), screenManager()));
PopupMultiChoice *renderingBackendChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iGPUBackend, gr->T("Backend"), renderingBackend, (int)GPUBackend::OPENGL, ARRAY_SIZE(renderingBackend), gr->GetName(), screenManager()));
renderingBackendChoice->OnChoice.Handle(this, &GameSettingsScreen::OnRenderingBackend);
#if !PPSSPP_PLATFORM(WINDOWS)
renderingBackendChoice->HideChoice(1); // D3D9
@@ -252,7 +252,7 @@ void GameSettingsScreen::CreateViews() {
graphicsSettings->Add(new ItemHeader(gr->T("Features")));
// Hide postprocess option on unsupported backends to avoid confusion.
if (g_Config.iGPUBackend != GPU_BACKEND_DIRECT3D9) {
if (GetGPUBackend() != GPUBackend::DIRECT3D9) {
I18NCategory *ps = GetI18NCategory("PostShaders");
postProcChoice_ = graphicsSettings->Add(new ChoiceWithValueDisplay(&g_Config.sPostShaderName, gr->T("Postprocessing Shader"), ps->GetName()));
postProcChoice_->OnClick.Handle(this, &GameSettingsScreen::OnPostProcShader);
View
@@ -106,19 +106,19 @@ void EmuThreadFunc() {
const char *defaultErrorOpenGL = "Failed initializing graphics. Try upgrading your graphics drivers.\n\nWould you like to try switching to DirectX 9?\n\nError message:";
const char *defaultErrorDirect3D9 = "Failed initializing graphics. Try upgrading your graphics drivers and directx 9 runtime.\n\nWould you like to try switching to OpenGL?\n\nError message:";
const char *genericError;
int nextBackend = GPU_BACKEND_DIRECT3D9;
GPUBackend nextBackend = GPUBackend::DIRECT3D9;
switch (g_Config.iGPUBackend) {
case GPU_BACKEND_DIRECT3D9:
nextBackend = GPU_BACKEND_OPENGL;
case (int)GPUBackend::DIRECT3D9:
nextBackend = GPUBackend::OPENGL;
genericError = err->T("GenericDirect3D9Error", defaultErrorDirect3D9);
break;
case GPU_BACKEND_VULKAN:
nextBackend = GPU_BACKEND_OPENGL;
case (int)GPUBackend::VULKAN:
nextBackend = GPUBackend::OPENGL;
genericError = err->T("GenericVulkanError", defaultErrorVulkan);
break;
case GPU_BACKEND_OPENGL:
case (int)GPUBackend::OPENGL:
default:
nextBackend = GPU_BACKEND_DIRECT3D9;
nextBackend = GPUBackend::DIRECT3D9;
genericError = err->T("GenericOpenGLError", defaultErrorOpenGL);
break;
}
@@ -129,7 +129,7 @@ void EmuThreadFunc() {
if (yes) {
// Change the config to the alternative and restart.
g_Config.iGPUBackend = nextBackend;
g_Config.iGPUBackend = (int)nextBackend;
g_Config.Save();
W32Util::ExitAndRestart();
@@ -113,7 +113,7 @@ bool D3D11Context::Init(HINSTANCE hInst, HWND wnd, std::string *error_message) {
bool yes = IDYES == MessageBox(hWnd_, error.c_str(), title.c_str(), MB_ICONERROR | MB_YESNO);
if (yes) {
// Change the config to D3D and restart.
g_Config.iGPUBackend = GPU_BACKEND_DIRECT3D9;
g_Config.iGPUBackend = (int)GPUBackend::DIRECT3D9;
g_Config.Save();
W32Util::ExitAndRestart();
@@ -243,7 +243,7 @@ bool WindowsGLContext::Init(HINSTANCE hInst, HWND window, std::string *error_mes
if (yes) {
// Change the config to D3D and restart.
g_Config.iGPUBackend = GPU_BACKEND_DIRECT3D9;
g_Config.iGPUBackend = (int)GPUBackend::DIRECT3D9;
g_Config.Save();
W32Util::ExitAndRestart();
View
@@ -195,7 +195,7 @@ namespace MainWindow {
const char *translatedShaderName = nullptr;
availableShaders.clear();
if (g_Config.iGPUBackend == GPU_BACKEND_DIRECT3D9) {
if (GetGPUBackend() == GPUBackend::DIRECT3D9) {
translatedShaderName = ps->T("Not available in Direct3D9 backend");
AppendMenu(shaderMenu, MF_STRING | MF_BYPOSITION | MF_GRAYED, item++, ConvertUTF8ToWString(translatedShaderName).c_str());
} else {
@@ -767,22 +767,22 @@ namespace MainWindow {
break;
case ID_OPTIONS_DIRECT3D9:
g_Config.iGPUBackend = GPU_BACKEND_DIRECT3D9;
g_Config.iGPUBackend = (int)GPUBackend::DIRECT3D9;
RestartApp();
break;
case ID_OPTIONS_DIRECT3D11:
g_Config.iGPUBackend = GPU_BACKEND_DIRECT3D11;
g_Config.iGPUBackend = (int)GPUBackend::DIRECT3D11;
RestartApp();
break;
case ID_OPTIONS_OPENGL:
g_Config.iGPUBackend = GPU_BACKEND_OPENGL;
g_Config.iGPUBackend = (int)GPUBackend::OPENGL;
RestartApp();
break;
case ID_OPTIONS_VULKAN:
g_Config.iGPUBackend = GPU_BACKEND_VULKAN;
g_Config.iGPUBackend = (int)GPUBackend::VULKAN;
RestartApp();
break;
@@ -1244,8 +1244,8 @@ namespace MainWindow {
CheckMenuItem(menu, savestateSlot[i], MF_BYCOMMAND | ((i == g_Config.iCurrentStateSlot) ? MF_CHECKED : MF_UNCHECKED));
}
switch (g_Config.iGPUBackend) {
case GPU_BACKEND_DIRECT3D9:
switch (GetGPUBackend()) {
case GPUBackend::DIRECT3D9:
EnableMenuItem(menu, ID_OPTIONS_DIRECT3D9, MF_GRAYED);
EnableMenuItem(menu, ID_OPTIONS_DIRECT3D11, MF_ENABLED);
EnableMenuItem(menu, ID_OPTIONS_OPENGL, MF_ENABLED);
@@ -1255,7 +1255,7 @@ namespace MainWindow {
CheckMenuItem(menu, ID_OPTIONS_OPENGL, MF_UNCHECKED);
CheckMenuItem(menu, ID_OPTIONS_VULKAN, MF_UNCHECKED);
break;
case GPU_BACKEND_OPENGL:
case GPUBackend::OPENGL:
EnableMenuItem(menu, ID_OPTIONS_DIRECT3D9, MF_ENABLED);
EnableMenuItem(menu, ID_OPTIONS_DIRECT3D11, MF_ENABLED);
EnableMenuItem(menu, ID_OPTIONS_OPENGL, MF_GRAYED);
@@ -1265,7 +1265,7 @@ namespace MainWindow {
CheckMenuItem(menu, ID_OPTIONS_OPENGL, MF_CHECKED);
CheckMenuItem(menu, ID_OPTIONS_VULKAN, MF_UNCHECKED);
break;
case GPU_BACKEND_VULKAN:
case GPUBackend::VULKAN:
EnableMenuItem(menu, ID_OPTIONS_DIRECT3D9, MF_ENABLED);
EnableMenuItem(menu, ID_OPTIONS_DIRECT3D11, MF_ENABLED);
EnableMenuItem(menu, ID_OPTIONS_OPENGL, MF_ENABLED);
@@ -1275,7 +1275,7 @@ namespace MainWindow {
CheckMenuItem(menu, ID_OPTIONS_OPENGL, MF_UNCHECKED);
CheckMenuItem(menu, ID_OPTIONS_VULKAN, MF_CHECKED);
break;
case GPU_BACKEND_DIRECT3D11:
case GPUBackend::DIRECT3D11:
EnableMenuItem(menu, ID_OPTIONS_DIRECT3D9, MF_ENABLED);
EnableMenuItem(menu, ID_OPTIONS_DIRECT3D11, MF_GRAYED);
EnableMenuItem(menu, ID_OPTIONS_OPENGL, MF_ENABLED);
View
@@ -114,16 +114,16 @@ void WindowsHost::UpdateConsolePosition() {
bool WindowsHost::InitGraphics(std::string *error_message, GraphicsContext **ctx) {
WindowsGraphicsContext *graphicsContext = nullptr;
switch (g_Config.iGPUBackend) {
case GPU_BACKEND_OPENGL:
case (int)GPUBackend::OPENGL:
graphicsContext = new WindowsGLContext();
break;
case GPU_BACKEND_DIRECT3D9:
case (int)GPUBackend::DIRECT3D9:
graphicsContext = new D3D9Context();
break;
case GPU_BACKEND_DIRECT3D11:
case (int)GPUBackend::DIRECT3D11:
graphicsContext = new D3D11Context();
break;
case GPU_BACKEND_VULKAN:
case (int)GPUBackend::VULKAN:
graphicsContext = new WindowsVulkanContext();
break;
default:
View
@@ -466,19 +466,19 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
// such as "software-gles", "software-d3d9", and "software-d3d11", or something similar.
// For now, software rendering force-activates OpenGL.
if (restOfOption == L"directx9") {
g_Config.iGPUBackend = GPU_BACKEND_DIRECT3D9;
g_Config.iGPUBackend = (int)GPUBackend::DIRECT3D9;
g_Config.bSoftwareRendering = false;
} else if (restOfOption == L"directx11") {
g_Config.iGPUBackend = GPU_BACKEND_DIRECT3D11;
g_Config.iGPUBackend = (int)GPUBackend::DIRECT3D11;
g_Config.bSoftwareRendering = false;
} else if (restOfOption == L"gles") {
g_Config.iGPUBackend = GPU_BACKEND_OPENGL;
g_Config.iGPUBackend = (int)GPUBackend::OPENGL;
g_Config.bSoftwareRendering = false;
} else if (restOfOption == L"vulkan") {
g_Config.iGPUBackend = GPU_BACKEND_VULKAN;
g_Config.iGPUBackend = (int)GPUBackend::VULKAN;
g_Config.bSoftwareRendering = false;
} else if (restOfOption == L"software") {
g_Config.iGPUBackend = GPU_BACKEND_OPENGL;
g_Config.iGPUBackend = (int)GPUBackend::OPENGL;
g_Config.bSoftwareRendering = true;
}
}
@@ -1125,7 +1125,7 @@ extern "C" bool JNICALL Java_org_ppsspp_ppsspp_NativeActivity_runEGLRenderLoop(J
retry:
bool vulkan = g_Config.iGPUBackend == GPU_BACKEND_VULKAN;
bool vulkan = g_Config.iGPUBackend == (int)GPUBackend::VULKAN;
int tries = 0;
AndroidGraphicsContext *graphicsContext;
@@ -1140,8 +1140,8 @@ extern "C" bool JNICALL Java_org_ppsspp_ppsspp_NativeActivity_runEGLRenderLoop(J
if (!exitRenderLoop && (vulkan && tries < 2)) {
ILOG("Trying again, this time with OpenGL.");
g_Config.iGPUBackend = GPU_BACKEND_OPENGL;
SetGPUBackend((GPUBackend)g_Config.iGPUBackend); // Wait, why do we need a separate enum here?
g_Config.iGPUBackend = (int)GPUBackend::OPENGL;
SetGPUBackend((GPUBackend)g_Config.iGPUBackend);
tries++;
goto retry;
}

0 comments on commit d6da758

Please sign in to comment.