mirror of
https://github.com/cemu-project/Cemu.git
synced 2026-07-09 17:14:47 -06:00
Reduce amount of #ifdefs
This commit is contained in:
parent
55e0dbae20
commit
6d27e9525a
@ -197,6 +197,7 @@ endif()
|
||||
if (ENABLE_VULKAN)
|
||||
include_directories("dependencies/Vulkan-Headers/include")
|
||||
add_compile_definitions(ENABLE_VULKAN)
|
||||
add_compile_definitions(VK_NO_PROTOTYPES)
|
||||
endif()
|
||||
|
||||
if (ENABLE_OPENGL)
|
||||
|
||||
@ -41,10 +41,6 @@ elseif(UNIX)
|
||||
add_compile_options(-Wno-multichar -Wno-invalid-offsetof -Wno-switch -Wno-ignored-attributes -Wno-deprecated-enum-enum-conversion)
|
||||
endif()
|
||||
|
||||
if (ENABLE_VULKAN)
|
||||
add_compile_definitions(VK_NO_PROTOTYPES)
|
||||
endif()
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
# on msvc we can reuse the PCH from CemuCommon, on other platforms it's not straight forward to reuse the PCH so we opt out of it
|
||||
|
||||
@ -9,11 +9,9 @@
|
||||
#ifdef ENABLE_VULKAN
|
||||
#include "Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h"
|
||||
#endif
|
||||
#include "Cafe/OS/libs/gx2/GX2.h" // todo - remove dependency
|
||||
#include "Cafe/GraphicPack/GraphicPack2.h"
|
||||
#include "HW/Latte/Core/Latte.h"
|
||||
#include "HW/Latte/Renderer/Renderer.h"
|
||||
#include "util/helpers/StringParser.h"
|
||||
#include "config/ActiveSettings.h"
|
||||
#include "Cafe/GameProfile/GameProfile.h"
|
||||
#include "util/containers/flat_hash_map.hpp"
|
||||
@ -687,11 +685,17 @@ uint64 LatteSHRC_CalcPSAuxHash(LatteDecompilerShader* pixelShader, uint32* conte
|
||||
return auxHash;
|
||||
}
|
||||
|
||||
void InitUniformLayoutFromDecompiler(
|
||||
static void InitUniformLayoutFromDecompiler(
|
||||
LatteDecompilerShader* shader,
|
||||
const LatteDecompilerOutput_t& decompilerOutput
|
||||
)
|
||||
{
|
||||
if (g_renderer->GetType() == RendererAPI::OpenGL)
|
||||
{
|
||||
// hack - for OpenGL these are retrieved in _prepareSeparableUniforms()
|
||||
shader->uniform.count_uniformRegister = decompilerOutput.uniformOffsetsGL.count_uniformRegister;
|
||||
return;
|
||||
}
|
||||
const auto& offsets = decompilerOutput.uniformOffsetsVK;
|
||||
|
||||
shader->uniform.loc_remapped = offsets.offset_remapped;
|
||||
@ -731,24 +735,17 @@ LatteDecompilerShader* LatteShader_CreateShaderFromDecompilerOutput(LatteDecompi
|
||||
LatteDecompilerShader* shader = decompilerOutput.shader;
|
||||
shader->baseHash = baseHash;
|
||||
// copy resource mapping
|
||||
// HACK
|
||||
switch (g_renderer->GetType())
|
||||
{
|
||||
#ifdef ENABLE_OPENGL
|
||||
case RendererAPI::OpenGL:
|
||||
shader->resourceMapping = decompilerOutput.resourceMappingGL;
|
||||
break;
|
||||
#endif
|
||||
#ifdef ENABLE_VULKAN
|
||||
case RendererAPI::Vulkan:
|
||||
shader->resourceMapping = decompilerOutput.resourceMappingVK;
|
||||
break;
|
||||
#endif
|
||||
#ifdef ENABLE_METAL
|
||||
case RendererAPI::Metal:
|
||||
shader->resourceMapping = decompilerOutput.resourceMappingMTL;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
// copy texture info
|
||||
shader->textureUnitMask2 = decompilerOutput.textureUnitMask;
|
||||
@ -756,26 +753,7 @@ LatteDecompilerShader* LatteShader_CreateShaderFromDecompilerOutput(LatteDecompi
|
||||
shader->streamoutBufferWriteMask = decompilerOutput.streamoutBufferWriteMask;
|
||||
shader->hasStreamoutBufferWrite = decompilerOutput.streamoutBufferWriteMask.any();
|
||||
// copy uniform offsets
|
||||
// for OpenGL these are retrieved in _prepareSeparableUniforms()
|
||||
// HACK
|
||||
switch (g_renderer->GetType())
|
||||
{
|
||||
#ifdef ENABLE_OPENGL
|
||||
case RendererAPI::OpenGL:
|
||||
shader->uniform.count_uniformRegister = decompilerOutput.uniformOffsetsGL.count_uniformRegister;
|
||||
break;
|
||||
#endif
|
||||
#ifdef ENABLE_VULKAN
|
||||
case RendererAPI::Vulkan:
|
||||
InitUniformLayoutFromDecompiler(shader, decompilerOutput);
|
||||
break;
|
||||
#endif
|
||||
#ifdef ENABLE_METAL
|
||||
case RendererAPI::Metal:
|
||||
InitUniformLayoutFromDecompiler(shader, decompilerOutput);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
InitUniformLayoutFromDecompiler(shader, decompilerOutput);
|
||||
// calculate aux hash
|
||||
if (calculateAuxHash)
|
||||
{
|
||||
|
||||
@ -396,11 +396,9 @@ void LatteShaderCache_Load()
|
||||
fs::path pathGeneric;
|
||||
switch(g_renderer->GetType())
|
||||
{
|
||||
#ifdef ENABLE_METAL
|
||||
case RendererAPI::Metal:
|
||||
pathGeneric = ActiveSettings::GetCachePath("shaderCache/transferable/{:016x}_mtlshaders.bin", cacheTitleId);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
pathGeneric = ActiveSettings::GetCachePath("shaderCache/transferable/{:016x}_shaders.bin", cacheTitleId);
|
||||
break;
|
||||
|
||||
@ -1,14 +1,7 @@
|
||||
#include "Cafe/HW/Latte/Core/Latte.h"
|
||||
#include "Cafe/HW/Latte/Core/LatteDraw.h"
|
||||
#include "Cafe/HW/Latte/Core/LattePerformanceMonitor.h"
|
||||
|
||||
#include "Common/GLInclude/GLInclude.h"
|
||||
|
||||
#include "Cafe/HW/Latte/Renderer/Renderer.h"
|
||||
#include "Cafe/HW/Latte/Core/LatteTexture.h"
|
||||
#ifdef ENABLE_OPENGL
|
||||
#include "Cafe/HW/Latte/Renderer/OpenGL/LatteTextureViewGL.h"
|
||||
#endif
|
||||
|
||||
#define LOG_READBACK_TIME
|
||||
|
||||
|
||||
@ -1071,22 +1071,16 @@ void _LatteDecompiler_Process(LatteDecompilerShaderContext* shaderContext, uint8
|
||||
// emit code
|
||||
if (shaderContext->shader->hasError == false)
|
||||
{
|
||||
switch(g_renderer->GetType())
|
||||
if (g_renderer->GetType() == RendererAPI::OpenGL || g_renderer->GetType() == RendererAPI::Vulkan)
|
||||
{
|
||||
#ifdef ENABLE_OPENGL
|
||||
case RendererAPI::OpenGL:
|
||||
LatteDecompiler_emitGLSLShader(shaderContext, shaderContext->shader);
|
||||
break;
|
||||
#endif
|
||||
#ifdef ENABLE_VULKAN
|
||||
case RendererAPI::Vulkan:
|
||||
LatteDecompiler_emitGLSLShader(shaderContext, shaderContext->shader);
|
||||
break;
|
||||
#if defined(ENABLE_OPENGL) || defined(ENABLE_VULKAN)
|
||||
LatteDecompiler_emitGLSLShader(shaderContext, shaderContext->shader);
|
||||
#endif
|
||||
}
|
||||
if (g_renderer->GetType() == RendererAPI::Metal)
|
||||
{
|
||||
#ifdef ENABLE_METAL
|
||||
case RendererAPI::Metal:
|
||||
LatteDecompiler_emitMSLShader(shaderContext, shaderContext->shader);
|
||||
break;
|
||||
LatteDecompiler_emitMSLShader(shaderContext, shaderContext->shader);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
#include "Cafe/HW/Latte/Renderer/RendererOuputShader.h"
|
||||
#include "Cafe/HW/Latte/Renderer/Renderer.h"
|
||||
#include "Cafe/HW/Latte/Core/Latte.h"
|
||||
#ifdef ENABLE_OPENGL
|
||||
#include "Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h"
|
||||
#endif
|
||||
#include "config/ActiveSettings.h"
|
||||
|
||||
const std::string RendererOutputShader::s_copy_shader_source =
|
||||
|
||||
@ -65,12 +65,12 @@ struct GraphicPackEntry
|
||||
bool enabled = true;
|
||||
};
|
||||
|
||||
#define GRAPHIC_API_COUNT 3
|
||||
enum GraphicAPI
|
||||
{
|
||||
kOpenGL = 0,
|
||||
kVulkan,
|
||||
kMetal,
|
||||
COUNT
|
||||
};
|
||||
|
||||
enum AudioChannels
|
||||
|
||||
@ -357,7 +357,7 @@ wxPanel* GeneralSettings2::AddGraphicsPage(wxNotebook* notebook)
|
||||
row->Add(new wxStaticText(box, wxID_ANY, _("Graphics API")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
|
||||
|
||||
sint32 api_size = 0;
|
||||
wxString choices[GRAPHIC_API_COUNT];
|
||||
wxString choices[size_t(GraphicAPI::COUNT)];
|
||||
|
||||
#ifdef ENABLE_OPENGL
|
||||
choices[api_size++] = "OpenGL";
|
||||
|
||||
@ -3,9 +3,6 @@
|
||||
#include "wxCemuConfig.h"
|
||||
#include "wxgui/wxgui.h"
|
||||
#include "wxgui/MainWindow.h"
|
||||
|
||||
#include <wx/mstream.h>
|
||||
|
||||
#include "wxgui/GameUpdateWindow.h"
|
||||
#include "wxgui/PadViewFrame.h"
|
||||
#include "wxgui/windows/TextureRelationViewer/TextureRelationWindow.h"
|
||||
@ -16,9 +13,11 @@
|
||||
#endif
|
||||
#ifdef ENABLE_VULKAN
|
||||
#include "wxgui/canvas/VulkanCanvas.h"
|
||||
#include "Cafe/HW/Latte/Renderer/Vulkan/VsyncDriver.h"
|
||||
#endif
|
||||
#ifdef ENABLE_METAL
|
||||
#include "wxgui/canvas/MetalCanvas.h"
|
||||
#include "Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h"
|
||||
#endif
|
||||
#include "Cafe/OS/libs/nfc/nfc.h"
|
||||
#include "Cafe/OS/libs/swkbd/swkbd.h"
|
||||
@ -46,9 +45,6 @@
|
||||
#include "wxgui/DownloadGraphicPacksWindow.h"
|
||||
#include "wxgui/GettingStartedDialog.h"
|
||||
#include "wxgui/helpers/wxHelpers.h"
|
||||
#ifdef ENABLE_VULKAN
|
||||
#include "Cafe/HW/Latte/Renderer/Vulkan/VsyncDriver.h"
|
||||
#endif
|
||||
#include "wxgui/input/InputSettings2.h"
|
||||
#include "wxgui/input/HotkeySettings.h"
|
||||
#include "input/InputManager.h"
|
||||
@ -72,10 +68,6 @@
|
||||
#include "gamemode_client.h"
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_METAL
|
||||
#include "Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h"
|
||||
#endif
|
||||
|
||||
#include "Cafe/TitleList/TitleInfo.h"
|
||||
#include "Cafe/TitleList/TitleList.h"
|
||||
#include "wxHelper.h"
|
||||
@ -1613,28 +1605,20 @@ void MainWindow::CreateCanvas()
|
||||
this->GetSizer()->Add(m_game_panel, 1, wxEXPAND);
|
||||
|
||||
// create canvas
|
||||
switch (ActiveSettings::GetGraphicsAPI())
|
||||
{
|
||||
case kOpenGL:
|
||||
#ifdef ENABLE_OPENGL
|
||||
#ifdef ENABLE_OPENGL
|
||||
if (ActiveSettings::GetGraphicsAPI() == kOpenGL)
|
||||
m_render_canvas = GLCanvas_Create(m_game_panel, wxSize(1280, 720), true);
|
||||
break;
|
||||
#endif
|
||||
case kVulkan:
|
||||
#ifdef ENABLE_VULKAN
|
||||
#endif
|
||||
#ifdef ENABLE_VULKAN
|
||||
if (ActiveSettings::GetGraphicsAPI() == kVulkan)
|
||||
m_render_canvas = new VulkanCanvas(m_game_panel, wxSize(1280, 720), true);
|
||||
break;
|
||||
#endif
|
||||
case kMetal:
|
||||
#ifdef ENABLE_METAL
|
||||
#endif
|
||||
#ifdef ENABLE_METAL
|
||||
if (ActiveSettings::GetGraphicsAPI() == kMetal)
|
||||
m_render_canvas = new MetalCanvas(m_game_panel, wxSize(1280, 720), true);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
cemu_assert(false && "Invalid graphics API selected");
|
||||
break;
|
||||
}
|
||||
|
||||
#endif
|
||||
if (!m_render_canvas)
|
||||
cemu_assert(false && "Failed to create canvas or invalid graphics API selected");
|
||||
cemu_assert(m_render_canvas != nullptr);
|
||||
|
||||
// mouse events
|
||||
|
||||
@ -79,22 +79,18 @@ void PadViewFrame::InitializeRenderCanvas()
|
||||
{
|
||||
auto sizer = new wxBoxSizer(wxVERTICAL);
|
||||
{
|
||||
#ifdef ENABLE_VULKAN
|
||||
if (ActiveSettings::GetGraphicsAPI() == kVulkan)
|
||||
{
|
||||
#ifdef ENABLE_VULKAN
|
||||
m_render_canvas = new VulkanCanvas(this, wxSize(854, 480), false);
|
||||
#endif
|
||||
}
|
||||
else if (ActiveSettings::GetGraphicsAPI() == kOpenGL)
|
||||
{
|
||||
#ifdef ENABLE_OPENGL
|
||||
#endif
|
||||
#ifdef ENABLE_OPENGL
|
||||
if (ActiveSettings::GetGraphicsAPI() == kOpenGL)
|
||||
m_render_canvas = GLCanvas_Create(this, wxSize(854, 480), false);
|
||||
#endif
|
||||
}
|
||||
#ifdef ENABLE_METAL
|
||||
else
|
||||
m_render_canvas = new MetalCanvas(this, wxSize(854, 480), false);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENABLE_METAL
|
||||
if (ActiveSettings::GetGraphicsAPI() == kMetal)
|
||||
m_render_canvas = new MetalCanvas(this, wxSize(854, 480), false);
|
||||
#endif
|
||||
sizer->Add(m_render_canvas, 1, wxEXPAND, 0, nullptr);
|
||||
}
|
||||
cemu_assert(m_render_canvas != nullptr);
|
||||
|
||||
@ -95,22 +95,16 @@ void WindowSystem::UpdateWindowTitles(bool isIdle, bool isLoading, double fps)
|
||||
{
|
||||
switch (g_renderer->GetType())
|
||||
{
|
||||
#ifdef ENABLE_OPENGL
|
||||
case RendererAPI::OpenGL:
|
||||
renderer = "[OpenGL]";
|
||||
break;
|
||||
#endif
|
||||
#ifdef ENABLE_VULKAN
|
||||
case RendererAPI::Vulkan:
|
||||
renderer = "[Vulkan]";
|
||||
break;
|
||||
#endif
|
||||
#ifdef ENABLE_METAL
|
||||
case RendererAPI::Metal:
|
||||
renderer = "[Metal]";
|
||||
break;
|
||||
#endif
|
||||
default:;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
15
src/main.cpp
15
src/main.cpp
@ -65,10 +65,10 @@ void _putenvSafe(const char* c)
|
||||
_putenv(s->c_str());
|
||||
}
|
||||
|
||||
#ifdef ENABLE_OPENGL
|
||||
void reconfigureGLDrivers()
|
||||
{
|
||||
// reconfigure GL drivers to store
|
||||
#ifdef ENABLE_OPENGL
|
||||
// reconfigure GL drivers to store
|
||||
const fs::path nvCacheDir = ActiveSettings::GetCachePath("shaderCache/driver/nvidia/");
|
||||
|
||||
std::error_code err;
|
||||
@ -84,17 +84,16 @@ void reconfigureGLDrivers()
|
||||
_putenvSafe(nvCacheDirEnvOption.c_str());
|
||||
#endif
|
||||
_putenvSafe("__GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1");
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VULKAN
|
||||
void reconfigureVkDrivers()
|
||||
{
|
||||
#ifdef ENABLE_VULKAN
|
||||
_putenvSafe("DISABLE_LAYER_AMD_SWITCHABLE_GRAPHICS_1=1");
|
||||
_putenvSafe("DISABLE_VK_LAYER_VALVE_steam_fossilize_1=1");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void WindowsInitCwd()
|
||||
{
|
||||
@ -113,12 +112,8 @@ void WindowsInitCwd()
|
||||
|
||||
void CemuCommonInit()
|
||||
{
|
||||
#ifdef ENABLE_OPENGL
|
||||
reconfigureGLDrivers();
|
||||
#endif
|
||||
#ifdef ENABLE_VULKAN
|
||||
reconfigureVkDrivers();
|
||||
#endif
|
||||
// crypto init
|
||||
AES128_init();
|
||||
// init PPC timer
|
||||
|
||||
Loading…
Reference in New Issue
Block a user