mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 06:34:10 +00:00
Remove all X11_XCB platform-specific code from RBDoom3BFG
This commit is contained in:
parent
d71eb2bf36
commit
c80d601276
11 changed files with 37 additions and 210 deletions
|
@ -424,17 +424,11 @@ if(USE_VULKAN)
|
|||
|
||||
# Eric: For use with SDL2/Vulkan
|
||||
if(UNIX)
|
||||
# SRS - Currently only Linux and OSX are supported when using the Vulkan SDL platform
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
# SRS - Do nothing here for Linux and OSX since SDL2 is used in place of platform-specific Vulkan
|
||||
add_definitions(-DVULKAN_USE_PLATFORM_SDL)
|
||||
else()
|
||||
find_package(X11_XCB)
|
||||
if(X11_XCB_FOUND)
|
||||
list(APPEND SUBSYSTEMS [X11])
|
||||
include_directories(${X11_XCB_INCLUDE_DIR})
|
||||
add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
|
||||
else()
|
||||
message(FATAL_ERROR "Could not find XCB library!")
|
||||
endif()
|
||||
message(FATAL_ERROR "Unsupported OS for Vulkan SDL platform!")
|
||||
endif()
|
||||
elseif(WIN32)
|
||||
add_definitions(-DVK_USE_PLATFORM_WIN32_KHR)
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
# - Try to find libX11-xcb
|
||||
# Once done this will define
|
||||
#
|
||||
# X11_XCB_FOUND - system has libX11-xcb
|
||||
# X11_XCB_LIBRARIES - Link these to use libX11-xcb
|
||||
# X11_XCB_INCLUDE_DIR - the libX11-xcb include dir
|
||||
# X11_XCB_DEFINITIONS - compiler switches required for using libX11-xcb
|
||||
|
||||
# Copyright (c) 2011 Fredrik Höglund <fredrik@kde.org>
|
||||
# Copyright (c) 2008 Helio Chissini de Castro, <helio@kde.org>
|
||||
# Copyright (c) 2007 Matthias Kretz, <kretz@kde.org>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
IF (NOT WIN32)
|
||||
# use pkg-config to get the directories and then use these values
|
||||
# in the FIND_PATH() and FIND_LIBRARY() calls
|
||||
FIND_PACKAGE(PkgConfig)
|
||||
PKG_CHECK_MODULES(PKG_X11_XCB QUIET x11-xcb)
|
||||
|
||||
SET(X11_XCB_DEFINITIONS ${PKG_X11_XCB_CFLAGS})
|
||||
|
||||
FIND_PATH(X11_XCB_INCLUDE_DIR NAMES X11/Xlib-xcb.h HINTS ${PKG_X11_XCB_INCLUDE_DIRS})
|
||||
FIND_LIBRARY(X11_XCB_LIBRARIES NAMES X11-xcb HINTS ${PKG_X11_XCB_LIBRARY_DIRS})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(X11_XCB DEFAULT_MSG X11_XCB_LIBRARIES X11_XCB_INCLUDE_DIR)
|
||||
|
||||
MARK_AS_ADVANCED(X11_XCB_INCLUDE_DIR X11_XCB_LIBRARIES)
|
||||
ENDIF (NOT WIN32)
|
||||
|
|
@ -113,8 +113,8 @@ void RB_SetVertexColorParms( stageVertexColor_t svc );
|
|||
|
||||
#if defined( USE_VULKAN )
|
||||
|
||||
//SRS - Add OSX case
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
// SRS - Generalized Vulkan SDL platform
|
||||
#if defined(VULKAN_USE_PLATFORM_SDL)
|
||||
#include <SDL.h>
|
||||
#include <SDL_vulkan.h>
|
||||
#endif
|
||||
|
@ -134,8 +134,8 @@ struct gpuInfo_t
|
|||
struct vulkanContext_t
|
||||
{
|
||||
// Eric: If on linux, use this to pass SDL_Window pointer to the SDL_Vulkan_* methods not in sdl_vkimp.cpp file.
|
||||
// SRS - Add OSX case
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
// SRS - Generalized Vulkan SDL platform
|
||||
#if defined(VULKAN_USE_PLATFORM_SDL)
|
||||
SDL_Window* sdlWindow = nullptr;
|
||||
#endif
|
||||
uint64 frameCounter;
|
||||
|
|
|
@ -1287,8 +1287,8 @@ struct glimpParms_t
|
|||
};
|
||||
|
||||
// Eric: If on Linux using Vulkan use the sdl_vkimp.cpp methods
|
||||
// SRS - Add OSX case
|
||||
#if ( defined(__linux__) || defined(__APPLE__) ) && defined(USE_VULKAN)
|
||||
// SRS - Generalized Vulkan SDL platform
|
||||
#if defined(VULKAN_USE_PLATFORM_SDL)
|
||||
#include <vector>
|
||||
|
||||
#define CLAMP(x, lo, hi) ((x) < (lo) ? (lo) : (x) > (hi) ? (hi) : (x))
|
||||
|
|
|
@ -446,8 +446,8 @@ void R_SetNewMode( const bool fullInit )
|
|||
if( fullInit )
|
||||
{
|
||||
// create the context as well as setting up the window
|
||||
// SRS - Add OSX case
|
||||
#if ( defined(__linux__) || defined(__APPLE__) ) && defined(USE_VULKAN)
|
||||
// SRS - Generalized Vulkan SDL platform
|
||||
#if defined(VULKAN_USE_PLATFORM_SDL)
|
||||
if( VKimp_Init( parms ) )
|
||||
#else
|
||||
if( GLimp_Init( parms ) )
|
||||
|
@ -464,8 +464,8 @@ void R_SetNewMode( const bool fullInit )
|
|||
else
|
||||
{
|
||||
// just rebuild the window
|
||||
// SRS - Add OSX case
|
||||
#if ( defined(__linux__) || defined(__APPLE__) ) && defined(USE_VULKAN)
|
||||
// SRS - Generalized Vulkan SDL platform
|
||||
#if defined(VULKAN_USE_PLATFORM_SDL)
|
||||
if( VKimp_SetScreenParms( parms ) )
|
||||
#else
|
||||
if( GLimp_SetScreenParms( parms ) )
|
||||
|
@ -1448,8 +1448,8 @@ void R_SetColorMappings()
|
|||
int inf = idMath::Ftoi( 0xffff * pow( j / 255.0f, invg ) + 0.5f );
|
||||
tr.gammaTable[i] = idMath::ClampInt( 0, 0xFFFF, inf );
|
||||
}
|
||||
// SRS - Add OSX case
|
||||
#if ( defined(__linux__) || defined(__APPLE__) ) && defined(USE_VULKAN)
|
||||
// SRS - Generalized Vulkan SDL platform
|
||||
#if defined(VULKAN_USE_PLATFORM_SDL)
|
||||
VKimp_SetGamma( tr.gammaTable, tr.gammaTable, tr.gammaTable );
|
||||
#else
|
||||
GLimp_SetGamma( tr.gammaTable, tr.gammaTable, tr.gammaTable );
|
||||
|
|
|
@ -65,7 +65,7 @@ idCVar r_vkEnableValidationLayers( "r_vkEnableValidationLayers", "0", CVAR_BOOL
|
|||
|
||||
vulkanContext_t vkcontext;
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR) //_WIN32
|
||||
static const int g_numInstanceExtensions = 2;
|
||||
static const char* g_instanceExtensions[ g_numInstanceExtensions ] =
|
||||
{
|
||||
|
@ -277,7 +277,7 @@ static void CreateVulkanInstance()
|
|||
vkcontext.instanceExtensions.Clear();
|
||||
vkcontext.deviceExtensions.Clear();
|
||||
vkcontext.validationLayers.Clear();
|
||||
#if defined(_WIN32)
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR) //_WIN32
|
||||
for( int i = 0; i < g_numInstanceExtensions; ++i )
|
||||
{
|
||||
vkcontext.instanceExtensions.Append( g_instanceExtensions[ i ] );
|
||||
|
@ -298,8 +298,8 @@ static void CreateVulkanInstance()
|
|||
|
||||
ValidateValidationLayers();
|
||||
}
|
||||
// SRS - Add OSX case
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
// SRS - Generalized Vulkan SDL platform
|
||||
#if defined(VULKAN_USE_PLATFORM_SDL)
|
||||
auto extensions = get_required_extensions( sdlInstanceExtensions, enableLayers );
|
||||
createInfo.enabledExtensionCount = static_cast<uint32_t>( extensions.size() );
|
||||
createInfo.ppEnabledExtensionNames = extensions.data();
|
||||
|
@ -429,13 +429,14 @@ static void EnumeratePhysicalDevices()
|
|||
CreateSurface
|
||||
=============
|
||||
*/
|
||||
// SRS - Is this #include still needed?
|
||||
#ifdef _WIN32
|
||||
#include "../../sys/win32/win_local.h"
|
||||
#endif
|
||||
|
||||
static void CreateSurface()
|
||||
{
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR) // _WIN32
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR) //_WIN32
|
||||
VkWin32SurfaceCreateInfoKHR createInfo = {};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
|
||||
createInfo.hinstance = win32.hInstance;
|
||||
|
@ -443,34 +444,13 @@ static void CreateSurface()
|
|||
|
||||
ID_VK_CHECK( vkCreateWin32SurfaceKHR( vkcontext.instance, &createInfo, NULL, &vkcontext.surface ) );
|
||||
|
||||
#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
|
||||
VkWaylandSurfaceCreateInfoKHR createInfo = {};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
|
||||
createInfo.pNext = NULL;
|
||||
createInfo.display = info.display;
|
||||
createInfo.surface = info.window;
|
||||
|
||||
ID_VK_CHECK( vkCreateWaylandSurfaceKHR( info.inst, &createInfo, NULL, &info.surface ) );
|
||||
|
||||
#else
|
||||
// SRS - Add OSX case
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
// SRS - Generalized Vulkan SDL platform
|
||||
#elif defined(VULKAN_USE_PLATFORM_SDL)
|
||||
if( !SDL_Vulkan_CreateSurface( vkcontext.sdlWindow, vkcontext.instance, &vkcontext.surface ) )
|
||||
{
|
||||
idLib::FatalError( "Error while creating Vulkan surface: %s", SDL_GetError() );
|
||||
}
|
||||
#else // defined(VK_USE_PLATFORM_XCB_KHR)
|
||||
VkXcbSurfaceCreateInfoKHR createInfo = {};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
|
||||
createInfo.pNext = NULL;
|
||||
createInfo.flags = 0;
|
||||
createInfo.connection = info.connection;
|
||||
createInfo.window = info.window;
|
||||
|
||||
ID_VK_CHECK( vkCreateXcbSurfaceKHR( vkcontext.instance, &createInfo, NULL, &vkcontext.surface ) );
|
||||
#endif // UNIX-style platforms
|
||||
|
||||
#endif // _WIN32
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
@ -881,8 +861,8 @@ static VkExtent2D ChooseSurfaceExtent( VkSurfaceCapabilitiesKHR& caps )
|
|||
int width = glConfig.nativeScreenWidth;
|
||||
int height = glConfig.nativeScreenHeight;
|
||||
|
||||
// SRS - Add OSX case
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
// SRS - Generalized Vulkan SDL platform
|
||||
#if defined(VULKAN_USE_PLATFORM_SDL)
|
||||
SDL_Vulkan_GetDrawableSize( vkcontext.sdlWindow, &width, &height );
|
||||
|
||||
width = idMath::ClampInt( caps.minImageExtent.width, caps.maxImageExtent.width, width );
|
||||
|
@ -1174,8 +1154,8 @@ static void CreateRenderTargets()
|
|||
depthOptions.format = FMT_DEPTH;
|
||||
|
||||
// Eric: See if this fixes resizing
|
||||
// SRS - Add OSX case
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
// SRS - Generalized Vulkan SDL platform
|
||||
#if defined(VULKAN_USE_PLATFORM_SDL)
|
||||
gpuInfo_t& gpu = *vkcontext.gpu;
|
||||
VkExtent2D extent = ChooseSurfaceExtent( gpu.surfaceCaps );
|
||||
|
||||
|
@ -1502,8 +1482,8 @@ void idRenderBackend::Init()
|
|||
|
||||
|
||||
// DG: make sure SDL has setup video so getting supported modes in R_SetNewMode() works
|
||||
// SRS - Add OSX case
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
// SRS - Generalized Vulkan SDL platform
|
||||
#if defined(VULKAN_USE_PLATFORM_SDL)
|
||||
VKimp_PreInit();
|
||||
#else
|
||||
GLimp_PreInit();
|
||||
|
@ -1698,8 +1678,8 @@ void idRenderBackend::Shutdown()
|
|||
ClearContext();
|
||||
|
||||
// destroy main window
|
||||
// SRS - Add OSX case
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
// SRS - Generalized Vulkan SDL platform
|
||||
#if defined(VULKAN_USE_PLATFORM_SDL)
|
||||
VKimp_Shutdown();
|
||||
#else
|
||||
GLimp_Shutdown();
|
||||
|
|
|
@ -32,29 +32,14 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
#if defined( USE_VULKAN )
|
||||
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR) //_WIN32
|
||||
#include <Windows.h>
|
||||
#elif defined(VK_USE_PLATFORM_XCB_KHR)
|
||||
#include <xcb/xcb.h>
|
||||
#include <dlfcn.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <dlfcn.h>
|
||||
#include <cstdlib>
|
||||
#endif
|
||||
|
||||
#define USE_AMD_ALLOCATOR
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#if defined(VK_USE_PLATFORM_XCB_KHR)
|
||||
#include <xcb/xcb.h>
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#if defined( USE_AMD_ALLOCATOR )
|
||||
#include "vma.h"
|
||||
#endif
|
||||
|
|
|
@ -54,10 +54,6 @@ static int cmdargc = 0;
|
|||
#include <mcheck.h>
|
||||
#endif
|
||||
|
||||
#if 0 // defined(USE_VULKAN)
|
||||
#include <xcb/xcb.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
==============
|
||||
Sys_EXEPath
|
||||
|
@ -506,67 +502,6 @@ void Sys_ReLaunch()
|
|||
// DG end
|
||||
}
|
||||
|
||||
#if 0 //defined(USE_VULKAN)
|
||||
/* Declare the global posixInfo */
|
||||
posixInfo info;
|
||||
|
||||
static void createWindow( size_t winWidth, size_t winHeight )
|
||||
{
|
||||
/* establish the connection with DISPLAYNAME as NULL,
|
||||
* this will leverage the DISPLAY env var */
|
||||
int screenp = 0; /* which "screen" to use */
|
||||
info.connection = xcb_connect( NULL, &screenp );
|
||||
|
||||
/* Check for errors */
|
||||
int xcbErr = xcb_connection_has_error( info.connection );
|
||||
|
||||
if( xcbErr )
|
||||
{
|
||||
common->Printf( "Failed to connect to X server using XCB." );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
/* Setup the window, iterating through screens */
|
||||
const struct xcb_setup_t* xcbSetup = NULL;
|
||||
xcbSetup = xcb_get_setup( info.connection );
|
||||
|
||||
xcb_screen_iterator_t scrIter = xcb_setup_roots_iterator( xcbSetup );
|
||||
|
||||
for( int screen = screenp; screen > 0; --screen )
|
||||
{
|
||||
xcb_screen_next( &scrIter );
|
||||
}
|
||||
|
||||
info.screen = scrIter.data;
|
||||
|
||||
/* Now generate the xid used for our window */
|
||||
info.window = xcb_generate_id( info.connection );
|
||||
|
||||
/* Register events, creating background pixel */
|
||||
uint32_t eventMask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
|
||||
uint32_t valueList[] = { info.screen->black_pixel, 0 };
|
||||
|
||||
/* Create the window, finally */
|
||||
xcb_create_window( info.connection, XCB_COPY_FROM_PARENT, info.window,
|
||||
info.screen->root, 0, 0, winWidth, winHeight, 0,
|
||||
XCB_WINDOW_CLASS_INPUT_OUTPUT, info.screen->root_visual,
|
||||
eventMask, valueList );
|
||||
|
||||
/* Set some properties, such as the window name, maybe? */
|
||||
xcb_change_property( info.connection, XCB_PROP_MODE_REPLACE,
|
||||
info.window, XCB_ATOM_WM_NAME, XCB_ATOM_STRING,
|
||||
8, 7, "vkRBDoom3BFG" );
|
||||
|
||||
/* map the window to the screen and flush the stream to the server */
|
||||
xcb_map_window( info.connection, info.window );
|
||||
xcb_flush( info.connection );
|
||||
|
||||
glConfig.nativeScreenWidth = winWidth;
|
||||
glConfig.nativeScreenHeight = winHeight;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
===============
|
||||
main
|
||||
|
@ -584,13 +519,6 @@ int main( int argc, const char** argv )
|
|||
Sys_Printf( "memory consistency checking enabled\n" );
|
||||
#endif
|
||||
|
||||
#if 0 // defined(USE_VULKAN)
|
||||
/* Create the window if using Vulkan */
|
||||
xcb_generic_event_t* event;
|
||||
xcb_client_message_event_t* cm;
|
||||
createWindow( 1280, 720 );
|
||||
#endif
|
||||
|
||||
Posix_EarlyInit( );
|
||||
|
||||
if( argc > 1 )
|
||||
|
@ -607,13 +535,6 @@ int main( int argc, const char** argv )
|
|||
|
||||
while( 1 )
|
||||
{
|
||||
#if 0 //defined(USE_VULKAN)
|
||||
/* I'm not 100% sure if intercepting these xcb events interferes with
|
||||
* SDL's input handling or not, but I suspect that it's necessary
|
||||
* to pump some event loop. We'll see */
|
||||
/*event = xcb_wait_for_event(info.connection);
|
||||
free(event); */
|
||||
#endif
|
||||
common->Frame();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,11 +31,6 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
#include <signal.h>
|
||||
|
||||
// SRS - Not used on Linux/macOS since using SDL2
|
||||
#if defined(USE_VULKAN) && defined(VK_USE_PLATFORM_XCB_KHR)
|
||||
#include <xcb/xcb.h>
|
||||
#endif
|
||||
|
||||
extern glconfig_t glConfig;
|
||||
|
||||
void Posix_QueEvent( sysEventType_t type, int value, int value2, int ptrLength, void* ptr );
|
||||
|
@ -75,21 +70,5 @@ enum /*clk_id_t*/ clockid_t { CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_MONOTONIC_R
|
|||
int clock_gettime( /*clk_id_t*/ clockid_t clock, struct timespec* tp ); // SRS - use APPLE clockid_t
|
||||
#endif
|
||||
|
||||
// Eric: Not used on Linux/macOS since using SDL2
|
||||
#if defined(USE_VULKAN) && defined(VK_USE_PLATFORM_XCB_KHR)
|
||||
/* Struct that holds global xcb state for vulkan */
|
||||
typedef struct _posixInfo
|
||||
{
|
||||
xcb_connection_t* connection;
|
||||
xcb_window_t window;
|
||||
xcb_screen_t* screen;
|
||||
xcb_atom_t wmProtocols;
|
||||
xcb_atom_t wmDeleteWin;
|
||||
} posixInfo;
|
||||
|
||||
extern posixInfo info;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -852,8 +852,8 @@ void Sys_GrabMouseCursor( bool grabIt )
|
|||
{
|
||||
flags = GRAB_SETSTATE;
|
||||
}
|
||||
// SRS - Add OSX case
|
||||
#if ( defined(__linux__) || defined(__APPLE__) ) && defined(USE_VULKAN)
|
||||
// SRS - Generalized Vulkan SDL platform
|
||||
#if defined(VULKAN_USE_PLATFORM_SDL)
|
||||
VKimp_GrabInput( flags );
|
||||
#else
|
||||
GLimp_GrabInput( flags );
|
||||
|
|
|
@ -35,8 +35,8 @@ const int GRAB_REENABLE = ( 1 << 1 );
|
|||
const int GRAB_HIDECURSOR = ( 1 << 2 );
|
||||
const int GRAB_SETSTATE = ( 1 << 3 );
|
||||
|
||||
// SRS - Add OSX case
|
||||
#if ( defined(__linux__) || defined(__APPLE__) ) && defined(USE_VULKAN)
|
||||
// SRS - Generalized Vulkan SDL platform
|
||||
#if defined(VULKAN_USE_PLATFORM_SDL)
|
||||
void VKimp_GrabInput( int flags );
|
||||
#else
|
||||
void GLimp_GrabInput( int flags );
|
||||
|
|
Loading…
Reference in a new issue