mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-15 20:05:47 -04:00
Build: Make OpenGL/Vulkan renderers optional
And disabled on Windows/arm64.
This commit is contained in:
@ -40,12 +40,8 @@ add_library(core
|
||||
gpu_commands.cpp
|
||||
gpu_hw.cpp
|
||||
gpu_hw.h
|
||||
gpu_hw_opengl.cpp
|
||||
gpu_hw_opengl.h
|
||||
gpu_hw_shadergen.cpp
|
||||
gpu_hw_shadergen.h
|
||||
gpu_hw_vulkan.cpp
|
||||
gpu_hw_vulkan.h
|
||||
gpu_sw.cpp
|
||||
gpu_sw.h
|
||||
gpu_sw_backend.cpp
|
||||
@ -121,7 +117,7 @@ set(RECOMPILER_SRCS
|
||||
target_include_directories(core PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
target_include_directories(core PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
target_link_libraries(core PUBLIC Threads::Threads common util zlib)
|
||||
target_link_libraries(core PRIVATE glad stb xxhash imgui rapidjson tinyxml2)
|
||||
target_link_libraries(core PRIVATE stb xxhash imgui rapidjson tinyxml2)
|
||||
|
||||
if(WIN32)
|
||||
target_sources(core PRIVATE
|
||||
@ -133,6 +129,21 @@ if(WIN32)
|
||||
target_link_libraries(core PRIVATE winmm.lib)
|
||||
endif()
|
||||
|
||||
if(ENABLE_OPENGL)
|
||||
target_sources(core PRIVATE
|
||||
gpu_hw_opengl.cpp
|
||||
gpu_hw_opengl.h
|
||||
)
|
||||
target_link_libraries(core PRIVATE glad)
|
||||
endif()
|
||||
|
||||
if(ENABLE_VULKAN)
|
||||
target_sources(core PRIVATE
|
||||
gpu_hw_vulkan.cpp
|
||||
gpu_hw_vulkan.h
|
||||
)
|
||||
endif()
|
||||
|
||||
if(${CPU_ARCH} STREQUAL "x64")
|
||||
target_include_directories(core PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../../dep/xbyak/xbyak")
|
||||
target_compile_definitions(core PUBLIC "WITH_RECOMPILER=1" "WITH_MMAP_FASTMEM=1")
|
||||
|
@ -38,7 +38,9 @@
|
||||
<ClCompile Include="gpu_hw_d3d11.cpp" />
|
||||
<ClCompile Include="gpu_hw_d3d12.cpp" />
|
||||
<ClCompile Include="gpu_hw_shadergen.cpp" />
|
||||
<ClCompile Include="gpu_hw_vulkan.cpp" />
|
||||
<ClCompile Include="gpu_hw_vulkan.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="gpu_sw.cpp" />
|
||||
<ClCompile Include="gpu_sw_backend.cpp" />
|
||||
<ClCompile Include="gte.cpp" />
|
||||
@ -46,7 +48,9 @@
|
||||
<ClCompile Include="gdb_protocol.cpp" />
|
||||
<ClCompile Include="gpu.cpp" />
|
||||
<ClCompile Include="gpu_hw.cpp" />
|
||||
<ClCompile Include="gpu_hw_opengl.cpp" />
|
||||
<ClCompile Include="gpu_hw_opengl.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="host.cpp" />
|
||||
<ClCompile Include="host_display.cpp" />
|
||||
<ClCompile Include="host_interface_progress_callback.cpp" />
|
||||
@ -104,7 +108,9 @@
|
||||
<ClInclude Include="gpu_hw_d3d11.h" />
|
||||
<ClInclude Include="gpu_hw_d3d12.h" />
|
||||
<ClInclude Include="gpu_hw_shadergen.h" />
|
||||
<ClInclude Include="gpu_hw_vulkan.h" />
|
||||
<ClInclude Include="gpu_hw_vulkan.h">
|
||||
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="gpu_sw.h" />
|
||||
<ClInclude Include="gpu_sw_backend.h" />
|
||||
<ClInclude Include="gpu_types.h" />
|
||||
@ -114,7 +120,9 @@
|
||||
<ClInclude Include="gdb_protocol.h" />
|
||||
<ClInclude Include="gpu.h" />
|
||||
<ClInclude Include="gpu_hw.h" />
|
||||
<ClInclude Include="gpu_hw_opengl.h" />
|
||||
<ClInclude Include="gpu_hw_opengl.h">
|
||||
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="gte_types.h" />
|
||||
<ClInclude Include="host.h" />
|
||||
<ClInclude Include="host_display.h" />
|
||||
|
@ -150,17 +150,23 @@ public:
|
||||
float ComputeVerticalFrequency() const;
|
||||
float GetDisplayAspectRatio() const;
|
||||
|
||||
#ifdef _WIN32
|
||||
// gpu_hw_d3d11.cpp
|
||||
static std::unique_ptr<GPU> CreateHardwareD3D11Renderer();
|
||||
|
||||
// gpu_hw_d3d12.cpp
|
||||
static std::unique_ptr<GPU> CreateHardwareD3D12Renderer();
|
||||
#endif
|
||||
|
||||
#ifdef WITH_OPENGL
|
||||
// gpu_hw_opengl.cpp
|
||||
static std::unique_ptr<GPU> CreateHardwareOpenGLRenderer();
|
||||
#endif
|
||||
|
||||
#ifdef WITH_VULKAN
|
||||
// gpu_hw_vulkan.cpp
|
||||
static std::unique_ptr<GPU> CreateHardwareVulkanRenderer();
|
||||
#endif
|
||||
|
||||
// gpu_sw.cpp
|
||||
static std::unique_ptr<GPU> CreateSoftwareRenderer();
|
||||
|
@ -805,12 +805,23 @@ static constexpr auto s_gpu_renderer_names = make_array(
|
||||
#ifdef _WIN32
|
||||
"D3D11", "D3D12",
|
||||
#endif
|
||||
"Vulkan", "OpenGL", "Software");
|
||||
#ifdef WITH_VULKAN
|
||||
"Vulkan",
|
||||
#endif
|
||||
#ifdef WITH_OPENGL
|
||||
"OpenGL",
|
||||
#endif
|
||||
"Software");
|
||||
static constexpr auto s_gpu_renderer_display_names = make_array(
|
||||
#ifdef _WIN32
|
||||
TRANSLATABLE("GPURenderer", "Hardware (D3D11)"), TRANSLATABLE("GPURenderer", "Hardware (D3D12)"),
|
||||
#endif
|
||||
TRANSLATABLE("GPURenderer", "Hardware (Vulkan)"), TRANSLATABLE("GPURenderer", "Hardware (OpenGL)"),
|
||||
#ifdef WITH_VULKAN
|
||||
TRANSLATABLE("GPURenderer", "Hardware (Vulkan)"),
|
||||
#endif
|
||||
#ifdef WITH_OPENGL
|
||||
TRANSLATABLE("GPURenderer", "Hardware (OpenGL)"),
|
||||
#endif
|
||||
TRANSLATABLE("GPURenderer", "Software"));
|
||||
|
||||
std::optional<GPURenderer> Settings::ParseRendererName(const char* str)
|
||||
|
@ -358,10 +358,16 @@ struct Settings
|
||||
static const char* GetMultitapModeDisplayName(MultitapMode mode);
|
||||
|
||||
// Default to D3D11 on Windows as it's more performant and at this point, less buggy.
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && defined(_M_ARM64)
|
||||
static constexpr GPURenderer DEFAULT_GPU_RENDERER = GPURenderer::HardwareD3D12;
|
||||
#elif defined(_WIN32)
|
||||
static constexpr GPURenderer DEFAULT_GPU_RENDERER = GPURenderer::HardwareD3D11;
|
||||
#else
|
||||
#elif defined(WITH_OPENGL)
|
||||
static constexpr GPURenderer DEFAULT_GPU_RENDERER = GPURenderer::HardwareOpenGL;
|
||||
#elif defined(WITH_VULKAN)
|
||||
static constexpr GPURenderer DEFAULT_GPU_RENDERER = GPURenderer::HardwareVulkan;
|
||||
#else
|
||||
static constexpr GPURenderer DEFAULT_GPU_RENDERER = GPURenderer::Software;
|
||||
#endif
|
||||
static constexpr GPUTextureFilter DEFAULT_GPU_TEXTURE_FILTER = GPUTextureFilter::Nearest;
|
||||
static constexpr GPUDownsampleMode DEFAULT_GPU_DOWNSAMPLE_MODE = GPUDownsampleMode::Disabled;
|
||||
|
@ -1,9 +1,13 @@
|
||||
#include "shadergen.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/gl/loader.h"
|
||||
#include "common/log.h"
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WITH_OPENGL
|
||||
#include "common/gl/loader.h"
|
||||
#endif
|
||||
|
||||
Log_SetChannel(ShaderGen);
|
||||
|
||||
ShaderGen::ShaderGen(HostDisplay::RenderAPI render_api, bool supports_dual_source_blend)
|
||||
@ -11,14 +15,16 @@ ShaderGen::ShaderGen(HostDisplay::RenderAPI render_api, bool supports_dual_sourc
|
||||
m_glsl(render_api != HostDisplay::RenderAPI::D3D11 && render_api != HostDisplay::RenderAPI::D3D12),
|
||||
m_supports_dual_source_blend(supports_dual_source_blend), m_use_glsl_interface_blocks(false)
|
||||
{
|
||||
#if defined(WITH_OPENGL) || defined(WITH_VULKAN)
|
||||
if (m_glsl)
|
||||
{
|
||||
#ifdef WITH_OPENGL
|
||||
if (m_render_api == HostDisplay::RenderAPI::OpenGL || m_render_api == HostDisplay::RenderAPI::OpenGLES)
|
||||
SetGLSLVersionString();
|
||||
|
||||
m_use_glsl_interface_blocks = (IsVulkan() || GLAD_GL_ES_VERSION_3_2 || GLAD_GL_VERSION_3_2);
|
||||
m_use_glsl_binding_layout = (IsVulkan() || UseGLSLBindingLayout());
|
||||
|
||||
|
||||
if (m_render_api == HostDisplay::RenderAPI::OpenGL)
|
||||
{
|
||||
// SSAA with interface blocks is broken on AMD's OpenGL driver.
|
||||
@ -26,16 +32,25 @@ ShaderGen::ShaderGen(HostDisplay::RenderAPI render_api, bool supports_dual_sourc
|
||||
if (std::strcmp(gl_vendor, "ATI Technologies Inc.") == 0)
|
||||
m_use_glsl_interface_blocks = false;
|
||||
}
|
||||
#else
|
||||
m_use_glsl_interface_blocks = true;
|
||||
m_use_glsl_binding_layout = true;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ShaderGen::~ShaderGen() = default;
|
||||
|
||||
bool ShaderGen::UseGLSLBindingLayout()
|
||||
{
|
||||
#ifdef WITH_OPENGL
|
||||
return (GLAD_GL_ES_VERSION_3_1 || GLAD_GL_VERSION_4_3 ||
|
||||
(GLAD_GL_ARB_explicit_attrib_location && GLAD_GL_ARB_explicit_uniform_location &&
|
||||
GLAD_GL_ARB_shading_language_420pack));
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ShaderGen::DefineMacro(std::stringstream& ss, const char* name, bool enabled)
|
||||
@ -43,6 +58,7 @@ void ShaderGen::DefineMacro(std::stringstream& ss, const char* name, bool enable
|
||||
ss << "#define " << name << " " << BoolToUInt32(enabled) << "\n";
|
||||
}
|
||||
|
||||
#ifdef WITH_OPENGL
|
||||
void ShaderGen::SetGLSLVersionString()
|
||||
{
|
||||
const char* glsl_version = reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||
@ -85,6 +101,7 @@ void ShaderGen::SetGLSLVersionString()
|
||||
(glsl_es && major_version >= 3) ? " es" : "");
|
||||
m_glsl_version_string = buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
void ShaderGen::WriteHeader(std::stringstream& ss)
|
||||
{
|
||||
@ -93,6 +110,7 @@ void ShaderGen::WriteHeader(std::stringstream& ss)
|
||||
else if (m_render_api == HostDisplay::RenderAPI::Vulkan)
|
||||
ss << "#version 450 core\n\n";
|
||||
|
||||
#ifdef WITH_OPENGL
|
||||
// Extension enabling for OpenGL.
|
||||
if (m_render_api == HostDisplay::RenderAPI::OpenGLES)
|
||||
{
|
||||
@ -130,6 +148,7 @@ void ShaderGen::WriteHeader(std::stringstream& ss)
|
||||
if (!GLAD_GL_VERSION_4_3 && !GLAD_GL_ES_VERSION_3_1 && GLAD_GL_ARB_shader_storage_buffer_object)
|
||||
ss << "#extension GL_ARB_shader_storage_buffer_object : require\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
DefineMacro(ss, "API_OPENGL", m_render_api == HostDisplay::RenderAPI::OpenGL);
|
||||
DefineMacro(ss, "API_OPENGL_ES", m_render_api == HostDisplay::RenderAPI::OpenGLES);
|
||||
@ -137,6 +156,7 @@ void ShaderGen::WriteHeader(std::stringstream& ss)
|
||||
DefineMacro(ss, "API_D3D12", m_render_api == HostDisplay::RenderAPI::D3D12);
|
||||
DefineMacro(ss, "API_VULKAN", m_render_api == HostDisplay::RenderAPI::Vulkan);
|
||||
|
||||
#ifdef WITH_OPENGL
|
||||
if (m_render_api == HostDisplay::RenderAPI::OpenGLES)
|
||||
{
|
||||
ss << "precision highp float;\n";
|
||||
@ -151,6 +171,7 @@ void ShaderGen::WriteHeader(std::stringstream& ss)
|
||||
|
||||
ss << "\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
if (m_glsl)
|
||||
{
|
||||
@ -315,7 +336,12 @@ void ShaderGen::DeclareTextureBuffer(std::stringstream& ss, const char* name, u3
|
||||
const char* ShaderGen::GetInterpolationQualifier(bool interface_block, bool centroid_interpolation,
|
||||
bool sample_interpolation, bool is_out) const
|
||||
{
|
||||
if (m_glsl && interface_block && (!IsVulkan() && !GLAD_GL_ARB_shading_language_420pack))
|
||||
#ifdef WITH_OPENGL
|
||||
const bool shading_language_420pack = GLAD_GL_ARB_shading_language_420pack;
|
||||
#else
|
||||
const bool shading_language_420pack = false;
|
||||
#endif
|
||||
if (m_glsl && interface_block && (!IsVulkan() && !shading_language_420pack))
|
||||
{
|
||||
return (sample_interpolation ? (is_out ? "sample out " : "sample in ") :
|
||||
(centroid_interpolation ? (is_out ? "centroid out " : "centroid in ") : ""));
|
||||
|
@ -24,7 +24,10 @@ protected:
|
||||
const char* GetInterpolationQualifier(bool interface_block, bool centroid_interpolation, bool sample_interpolation,
|
||||
bool is_out) const;
|
||||
|
||||
#ifdef WITH_OPENGL
|
||||
void SetGLSLVersionString();
|
||||
#endif
|
||||
|
||||
void DefineMacro(std::stringstream& ss, const char* name, bool enabled);
|
||||
void WriteHeader(std::stringstream& ss);
|
||||
void WriteUniformBufferDeclaration(std::stringstream& ss, bool push_constant_on_vulkan);
|
||||
|
@ -1457,13 +1457,17 @@ bool System::CreateGPU(GPURenderer renderer)
|
||||
{
|
||||
switch (renderer)
|
||||
{
|
||||
#ifdef WITH_OPENGL
|
||||
case GPURenderer::HardwareOpenGL:
|
||||
g_gpu = GPU::CreateHardwareOpenGLRenderer();
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef WITH_VULKAN
|
||||
case GPURenderer::HardwareVulkan:
|
||||
g_gpu = GPU::CreateHardwareVulkanRenderer();
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
case GPURenderer::HardwareD3D11:
|
||||
|
@ -58,8 +58,12 @@ enum class GPURenderer : u8
|
||||
HardwareD3D11,
|
||||
HardwareD3D12,
|
||||
#endif
|
||||
#ifdef WITH_VULKAN
|
||||
HardwareVulkan,
|
||||
#endif
|
||||
#ifdef WITH_OPENGL
|
||||
HardwareOpenGL,
|
||||
#endif
|
||||
Software,
|
||||
Count
|
||||
};
|
||||
|
Reference in New Issue
Block a user