Skip to content

Commit

Permalink
Remove sgldxumd and clean up inconsistencies
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaivel committed Jul 8, 2024
1 parent 755f2fc commit c7354d9
Show file tree
Hide file tree
Showing 19 changed files with 136 additions and 782 deletions.
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5.0)
project(sharedgl VERSION 0.7.0 LANGUAGES C CXX)
project(sharedgl VERSION 0.7.0 LANGUAGES C)

include_directories(${CMAKE_SOURCE_DIR}/inc)

Expand All @@ -10,7 +10,6 @@ IF(WIN32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gz")
ELSE()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -march=native")
ENDIF(WIN32)

file(GLOB GLOBBED_SERVER_SOURCES CONFIGURE_DEPENDS "src/server/*.c" "src/network/*.c")
Expand All @@ -22,8 +21,6 @@ IF(UNIX)
ELSEIF(WIN32)
file(GLOB GLOBBED_CLIENT_SOURCES CONFIGURE_DEPENDS "src/client/winmain.c" "src/client/pb.c" "src/client/spinlock.c" "src/client/glimpl.c" "src/network/*.c")
file(GLOB GLOBBED_CLIENT_P_SOURCES CONFIGURE_DEPENDS "src/client/platform/windrv.c")

file(GLOB GLOBBED_DXUMD_SOURCES CONFIGURE_DEPENDS "src/sgldxumd/*.cpp")
ENDIF(UNIX)

# server
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ usage: sglrenderer [-h] [-v] [-o] [-n] [-x] [-g MAJOR.MINOR] [-r WIDTHxHEIGHT] [
options:
-h display help information
-v display virtual machine arguments
-o enables fps overlay on clients (shows server side fps)
-o enables fps overlay on clients
-n enable networking instead of shared memory
-x remove shared memory file
-g [MAJOR.MINOR] report specific opengl version (default: 4.4)
Expand Down
4 changes: 2 additions & 2 deletions inc/client/platform/windrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#ifndef _WINDRV_H_
#define _WINDRV_H_

void WinDrvSetModuleAddress(HMODULE module);
void WinDrvSetVflip(BOOL flip);
void windrv_set_module_address(HMODULE module);
void windrv_set_vflip(BOOL flip);

#endif
#endif
8 changes: 0 additions & 8 deletions inc/sgldxumd/device.hpp

This file was deleted.

6 changes: 0 additions & 6 deletions inc/sgldxumd/dxgi.hpp

This file was deleted.

22 changes: 0 additions & 22 deletions inc/sgldxumd/sgldxumd.hpp

This file was deleted.

98 changes: 49 additions & 49 deletions src/client/pb.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,32 @@ DEFINE_GUID(GUID_DEVINTERFACE_IVSHMEM,
#define IVSHMEM_CACHE_CACHED 1
#define IVSHMEM_CACHE_WRITECOMBINED 2

typedef struct IVSHMEM_MMAP_CONFIG {
BYTE CacheMode;
} IVSHMEM_MMAP_CONFIG, *PIVSHMEM_MMAP_CONFIG;

typedef struct IVSHMEM_MMAP {
WORD PeerID;
DWORD64 Size;
PVOID Pointer;
WORD Vectors;
} IVSHMEM_MMAP, *PIVSHMEM_MMAP;

#define IOCTL_IVSHMEM_REQUEST_SIZE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_IVSHMEM_REQUEST_MMAP CTL_CODE(FILE_DEVICE_UNKNOWN, 0x802, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_IVSHMEM_RELEASE_MMAP CTL_CODE(FILE_DEVICE_UNKNOWN, 0x803, METHOD_BUFFERED, FILE_ANY_ACCESS)

HANDLE Handle;
struct ivshmem_mmap_config {
BYTE cache_mode;
};

struct ivshmem_mmap {
WORD peer_id;
DWORD64 size;
PVOID pointer;
WORD vectors;
};

static HANDLE ivshmem_handle;
#endif

void *ptr;
void *base;
int *cur;
static void *ptr;
static void *base;
static int *cur;

void *in_base;
int *in_cur;
static void *in_base;
static int *in_cur;

struct pb_net_hooks net_hooks = { NULL };
static struct pb_net_hooks net_hooks = { NULL };

#ifndef _WIN32
void pb_set(int fd)
Expand All @@ -71,58 +71,58 @@ void pb_set(int fd)
#else
void pb_set(void)
{
HDEVINFO DeviceInfoSet;
PSP_DEVICE_INTERFACE_DETAIL_DATA InfData;
SP_DEVICE_INTERFACE_DATA DeviceInterfaceData;
DWORD64 Size;
IVSHMEM_MMAP_CONFIG Config;
IVSHMEM_MMAP Map;
DWORD RequestSize;
HDEVINFO device_info;
PSP_DEVICE_INTERFACE_DETAIL_DATA inf_data;
SP_DEVICE_INTERFACE_DATA dev_data;
DWORD64 size;
struct ivshmem_mmap_config config;
struct ivshmem_mmap map;
DWORD request_size;

DeviceInfoSet = SetupDiGetClassDevs(NULL, NULL, NULL, DIGCF_PRESENT | DIGCF_ALLCLASSES | DIGCF_DEVICEINTERFACE);
ZeroMemory(&DeviceInterfaceData, sizeof(SP_DEVICE_INTERFACE_DATA));
DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
device_info = SetupDiGetClassDevs(NULL, NULL, NULL, DIGCF_PRESENT | DIGCF_ALLCLASSES | DIGCF_DEVICEINTERFACE);
ZeroMemory(&dev_data, sizeof(SP_DEVICE_INTERFACE_DATA));
dev_data.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);

if (SetupDiEnumDeviceInterfaces(DeviceInfoSet, NULL, &GUID_DEVINTERFACE_IVSHMEM, 0, &DeviceInterfaceData) == FALSE)
if (SetupDiEnumDeviceInterfaces(device_info, NULL, &GUID_DEVINTERFACE_IVSHMEM, 0, &dev_data) == FALSE)
return;

SetupDiGetDeviceInterfaceDetail(DeviceInfoSet, &DeviceInterfaceData, NULL, 0, &RequestSize, NULL);
if (!RequestSize)
SetupDiGetDeviceInterfaceDetail(device_info, &dev_data, NULL, 0, &request_size, NULL);
if (!request_size)
return;

InfData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)(malloc(RequestSize));
ZeroMemory(InfData, RequestSize);
InfData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
if (!SetupDiGetDeviceInterfaceDetail(DeviceInfoSet, &DeviceInterfaceData, InfData, RequestSize, NULL, NULL))
inf_data = (PSP_DEVICE_INTERFACE_DETAIL_DATA)(malloc(request_size));
ZeroMemory(inf_data, request_size);
inf_data->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
if (!SetupDiGetDeviceInterfaceDetail(device_info, &dev_data, inf_data, request_size, NULL, NULL))
return;

Handle = CreateFile(InfData->DevicePath, 0, 0, NULL, OPEN_EXISTING, 0, 0);
if (Handle == INVALID_HANDLE_VALUE)
ivshmem_handle = CreateFile(inf_data->DevicePath, 0, 0, NULL, OPEN_EXISTING, 0, 0);
if (ivshmem_handle == INVALID_HANDLE_VALUE)
return;

if (InfData)
free(InfData);
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
if (inf_data)
free(inf_data);
SetupDiDestroyDeviceInfoList(device_info);

if (!DeviceIoControl(Handle, IOCTL_IVSHMEM_REQUEST_SIZE, NULL, 0, &Size, sizeof(UINT64), NULL, NULL))
if (!DeviceIoControl(ivshmem_handle, IOCTL_IVSHMEM_REQUEST_SIZE, NULL, 0, &size, sizeof(UINT64), NULL, NULL))
return;

Config.CacheMode = IVSHMEM_CACHE_WRITECOMBINED;
ZeroMemory(&Map, sizeof(IVSHMEM_MMAP));
if (!DeviceIoControl(Handle, IOCTL_IVSHMEM_REQUEST_MMAP, &Config, sizeof(IVSHMEM_MMAP_CONFIG), &Map, sizeof(IVSHMEM_MMAP), NULL, NULL))
config.cache_mode = IVSHMEM_CACHE_WRITECOMBINED;
ZeroMemory(&map, sizeof(struct ivshmem_mmap));
if (!DeviceIoControl(ivshmem_handle, IOCTL_IVSHMEM_REQUEST_MMAP, &config, sizeof(struct ivshmem_mmap_config), &map, sizeof(struct ivshmem_mmap), NULL, NULL))
return;

ptr = Map.Pointer;
base = (PVOID)((DWORD64)Map.Pointer + (DWORD64)0x1000);
ptr = map.pointer;
base = (PVOID)((DWORD64)map.pointer + (DWORD64)0x1000);

in_base = VirtualAlloc(NULL, Map.Size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
in_base = VirtualAlloc(NULL, map.size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
in_cur = in_base;
}

void pb_unset(void)
{
DeviceIoControl(Handle, IOCTL_IVSHMEM_RELEASE_MMAP, NULL, 0, NULL, 0, NULL, NULL);
CloseHandle(Handle);
DeviceIoControl(ivshmem_handle, IOCTL_IVSHMEM_RELEASE_MMAP, NULL, 0, NULL, 0, NULL, NULL);
CloseHandle(ivshmem_handle);
}
#endif

Expand Down
11 changes: 5 additions & 6 deletions src/client/platform/glx.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,23 @@ static int n_valid_fb_configs;

static struct glx_fb_config fb_configs[1729] = { 0 };

int fb_valid_color_sizes[] = {
static int fb_valid_color_sizes[] = {
0, 1, 8, 16, 24, 32
};

int fb_valid_render_types[] = {
static int fb_valid_render_types[] = {
GLX_RGBA_BIT, GLX_COLOR_INDEX_BIT
};

int fb_valid_doublebuffer_types[] = {
static int fb_valid_doublebuffer_types[] = {
False, True
};

int fb_valid_drawable_types[] = {
static int fb_valid_drawable_types[] = {
GLX_WINDOW_BIT
};

int fb_valid_visual_types[] = {
static int fb_valid_visual_types[] = {
GLX_TRUE_COLOR, GLX_DIRECT_COLOR, GLX_PSEUDO_COLOR, GLX_STATIC_COLOR, GLX_GRAY_SCALE, GLX_STATIC_GRAY
};

Expand Down Expand Up @@ -435,5 +435,4 @@ void glximpl_init()
}

glx_generate_fb_configs();
// fprintf(stderr, "glximpl_init: n_valid_fb_configs = %d\n", n_valid_fb_configs);
}
Loading

0 comments on commit c7354d9

Please sign in to comment.