CMake: Make evdev optional

This commit is contained in:
Connor McLaughlin 2021-02-27 20:53:00 +10:00
parent 47e26b1ad3
commit faa8ed0031
4 changed files with 13 additions and 10 deletions

View file

@ -40,6 +40,7 @@ endif()
if(LINUX AND NOT ANDROID)
option(USE_DRMKMS "Support DRM/KMS OpenGL contexts" OFF)
option(USE_FBDEV "Support FBDev OpenGL contexts" OFF)
option(USE_EVDEV "Support EVDev controller interface" ON)
endif()
# Force EGL when using Wayland
@ -54,7 +55,7 @@ if(ANDROID)
endif()
if(BUILD_NOGUI_FRONTEND)
message(WARNING "Building for Android, disabling NoGUI frontend")
set(BUILD_QT_FRONTEND OFF)
set(BUILD_NOGUI_FRONTEND OFF)
endif()
if(BUILD_QT_FRONTEND)
message(WARNING "Building for Android, disabling Qt frontend")
@ -78,7 +79,7 @@ endif()
# Common include/library directories on Windows.
if(WIN32)
if(WIN32 AND USE_SDL2)
set(SDL2_FOUND TRUE)
set(SDL2_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/dep/msvc/sdl2/include")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
@ -128,6 +129,10 @@ endif()
if(USE_FBDEV)
message(STATUS "FBDev Support enabled")
endif()
if(USE_EVDEV)
message(STATUS "EVDev Support enabled")
find_package(LIBEVDEV REQUIRED)
endif()
# Set _DEBUG macro for Debug builds.
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")

View file

@ -18,9 +18,7 @@ if(USE_SDL2)
target_link_libraries(duckstation-nogui PRIVATE ${SDL2_LIBRARIES})
endif()
if(USE_DRMKMS OR USE_FBDEV)
find_package(LIBEVDEV REQUIRED)
if(USE_EVDEV)
target_sources(duckstation-nogui PRIVATE
vty_host_interface.cpp
vty_host_interface.h

View file

@ -75,7 +75,7 @@ if(SDL2_FOUND)
endif()
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
if(USE_EVDEV)
find_package(LIBEVDEV REQUIRED)
target_compile_definitions(frontend-common PUBLIC "-DWITH_EVDEV=1")
target_include_directories(frontend-common PRIVATE ${LIBEVDEV_INCLUDE_DIRS})

View file

@ -198,7 +198,7 @@ bool OpenGLHostDisplay::BeginSetDisplayPixels(HostDisplayPixelFormat format, u32
const u32 stride = Common::AlignUpPow2(width * pixel_size, 4);
const u32 size_required = stride * height * pixel_size;
if (!m_gl_context->IsGLES())
if (m_use_pbo_for_pixels)
{
const u32 buffer_size = Common::AlignUpPow2(size_required * 2, 4 * 1024 * 1024);
if (!m_display_pixels_texture_pbo || m_display_pixels_texture_pbo->GetSize() < buffer_size)
@ -240,7 +240,7 @@ void OpenGLHostDisplay::EndSetDisplayPixels()
s_display_pixel_format_mapping[static_cast<u32>(m_display_texture_format)];
glBindTexture(GL_TEXTURE_2D, m_display_pixels_texture_id);
if (!m_gl_context->IsGLES())
if (m_use_pbo_for_pixels)
{
m_display_pixels_texture_pbo->Unmap(m_display_pixels_texture_pbo_map_size);
m_display_pixels_texture_pbo->Bind();
@ -393,13 +393,13 @@ bool OpenGLHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_vie
bool OpenGLHostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device,
bool threaded_presentation)
{
m_use_gles2_draw_path = (m_gl_context->IsGLES() && !GLAD_GL_ES_VERSION_3_0);
m_use_gles2_draw_path = (GetRenderAPI() == RenderAPI::OpenGLES && !GLAD_GL_ES_VERSION_3_0);
if (!m_use_gles2_draw_path)
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, reinterpret_cast<GLint*>(&m_uniform_buffer_alignment));
// Doubt GLES2 drivers will support PBOs efficiently.
m_use_pbo_for_pixels = !m_use_gles2_draw_path;
if (m_gl_context->IsGLES())
if (GetRenderAPI() == RenderAPI::OpenGLES)
{
// Adreno seems to corrupt textures through PBOs...
const char* gl_vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR));