aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiers Daniell <pdaniell@nvidia.com>2015-02-24 13:58:47 -0700
committerCourtney Goeltzenleuchter <courtney@LunarG.com>2015-03-02 17:21:10 -0700
commit8254bebed7609fe24902267bea25e3866f2a4bcc (patch)
tree2dbbca6c98ac292f9892cfa823b47b7ce2725b3b
parentf94f9bc3358d29b8cf7c03d753808bbbb61a5a3f (diff)
downloadusermoji-8254bebed7609fe24902267bea25e3866f2a4bcc.tar.xz
Get the trace player to work with Windows
This change modifies many of the generators to use "#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)" to choose between using XCB or WIN32 native.
-rw-r--r--.gitignore5
-rw-r--r--CMakeLists.txt1
-rw-r--r--demos/CMakeLists.txt5
-rw-r--r--demos/Win32/libpngd.libbin697910 -> 0 bytes
-rw-r--r--demos/Win32/zlibd.libbin254048 -> 0 bytes
-rw-r--r--demos/Win64/libpngd.libbin605334 -> 0 bytes
-rw-r--r--demos/Win64/zlibd.libbin234096 -> 0 bytes
-rw-r--r--demos/tri.c2
-rw-r--r--demos/xcb_nvidia.cpp368
-rwxr-xr-xglave-generate.py121
-rw-r--r--include/xglLayer.h10
-rw-r--r--include/xglWsiWinExt.h4
-rw-r--r--loader/CMakeLists.txt2
-rw-r--r--loader/XGL.def4
-rw-r--r--loader/loader_platform.h1
-rwxr-xr-xxgl-generate.py10
-rwxr-xr-xxgl-layer-generate.py10
17 files changed, 88 insertions, 455 deletions
diff --git a/.gitignore b/.gitignore
index 1f4b5373..9b812727 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,6 +26,9 @@ out64/*
demos/Debug/*
demos/tri.dir/Debug/*
demos/tri/Debug/*
+demos/Win32/Debug/*
+demos/xcb_nvidia.dir/*
+libs/Win32/Debug/*
*.pyc
*.vcproj
*.sln
@@ -33,5 +36,3 @@ demos/tri/Debug/*
*.vcxproj
*.sdf
*.filters
-demos/Win32/Debug/*
-demos/xcb_nvidia.dir/*
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9f84d18d..762919a1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -46,5 +46,6 @@ if (NOT WIN32)
add_subdirectory(tests)
endif()
add_subdirectory(layers)
+add_subdirectory(libs)
add_subdirectory(demos)
add_subdirectory(tools/glave)
diff --git a/demos/CMakeLists.txt b/demos/CMakeLists.txt
index 808a8283..4e836728 100644
--- a/demos/CMakeLists.txt
+++ b/demos/CMakeLists.txt
@@ -52,7 +52,6 @@ if(WIN32)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXCB_NVIDIA -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DXCB_NVIDIA -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES")
- add_library(xcb_nvidia STATIC xcb_nvidia.cpp)
set (LIBRARIES ${LIBRARIES} xcb_nvidia)
endif()
@@ -72,9 +71,9 @@ else()
set (LIB_DIR "Win32")
endif()
add_library(libpngd STATIC IMPORTED)
- set_target_properties(libpngd PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/demos/${LIB_DIR}/libpngd.lib)
+ set_target_properties(libpngd PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/libs/${LIB_DIR}/libpngd.lib)
add_library(zlibd STATIC IMPORTED)
- set_target_properties(zlibd PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/demos/${LIB_DIR}/zlibd.lib)
+ set_target_properties(zlibd PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/libs/${LIB_DIR}/zlibd.lib)
add_executable(cube cube.c)
target_link_libraries(cube ${LIBRARIES} libpngd zlibd)
endif()
diff --git a/demos/Win32/libpngd.lib b/demos/Win32/libpngd.lib
deleted file mode 100644
index 8c172e81..00000000
--- a/demos/Win32/libpngd.lib
+++ /dev/null
Binary files differ
diff --git a/demos/Win32/zlibd.lib b/demos/Win32/zlibd.lib
deleted file mode 100644
index 4d3ccad4..00000000
--- a/demos/Win32/zlibd.lib
+++ /dev/null
Binary files differ
diff --git a/demos/Win64/libpngd.lib b/demos/Win64/libpngd.lib
deleted file mode 100644
index 9a9485af..00000000
--- a/demos/Win64/libpngd.lib
+++ /dev/null
Binary files differ
diff --git a/demos/Win64/zlibd.lib b/demos/Win64/zlibd.lib
deleted file mode 100644
index 19e20fef..00000000
--- a/demos/Win64/zlibd.lib
+++ /dev/null
Binary files differ
diff --git a/demos/tri.c b/demos/tri.c
index ae9df190..151d2cd6 100644
--- a/demos/tri.c
+++ b/demos/tri.c
@@ -14,9 +14,7 @@
#define __linux__
#endif
-#if defined(__linux__)
#include <xcb/xcb.h>
-#endif
#include <xgl.h>
#include <xglDbg.h>
#if defined(__linux__)
diff --git a/demos/xcb_nvidia.cpp b/demos/xcb_nvidia.cpp
deleted file mode 100644
index 5a35d937..00000000
--- a/demos/xcb_nvidia.cpp
+++ /dev/null
@@ -1,368 +0,0 @@
-#include <xcb/xcb.h>
-#include <xglWsiX11Ext.h>
-
-#include <Windows.h>
-#include <string>
-#include <deque>
-
-#include <xgl.h>
-
-#include "../loader/loader_platform.h"
-
-typedef void (*xcbCreateWindowType)(uint16_t width, uint16_t height);
-typedef void (*xcbDestroyWindowType)();
-typedef int (*xcbGetMessageType)(MSG * msg);
-typedef BOOL (*xcbPeekMessageType)(MSG * msg);
-typedef XGL_RESULT (*xcbQueuePresentType)(XGL_QUEUE queue, XGL_IMAGE image, XGL_FENCE fence);
-
-struct xcb_connection_t {
- xcb_screen_t screens[1];
- xcb_setup_t setup;
- HMODULE xcbNvidia;
-
- xcbCreateWindowType xcbCreateWindow;
- xcbDestroyWindowType xcbDestroyWindow;
- xcbGetMessageType xcbGetMessage;
- xcbPeekMessageType xcbPeekMessage;
- xcbQueuePresentType xcbQueuePresent;
-};
-
-// XCB id database.
-// FIXME: This is not thread safe.
-uint32_t g_xcbId = 0;
-struct XcbId {
- xcb_connection_t * connection;
-};
-std::deque<XcbId> g_xcbIds;
-
-xcb_connection_t * xcb_connect(const char *displayname, int *screenp)
-{
- std::string xglNvidia = (getenv(DRIVER_PATH_ENV) == NULL) ? "" : getenv(DRIVER_PATH_ENV);
- xglNvidia += "\\xgl_nvidia.dll";
- HMODULE module = LoadLibrary(xglNvidia.c_str());
- if (!module) {
- std::string xglNulldrv = (getenv("XGL_DRIVERS_PATH") == NULL) ? "" : getenv("LIBXGL_DRIVERS_PATH");
- xglNulldrv += "\\xgl_nulldrv.dll";
- module = LoadLibrary(xglNulldrv.c_str());
- }
- if (!module) {
- return 0;
- }
-
- xcb_connection_t * connection = (xcb_connection_t *)calloc(1, sizeof(xcb_connection_t));
- connection->xcbNvidia = module;
-
- connection->xcbCreateWindow = (xcbCreateWindowType)GetProcAddress(module, "xcbCreateWindow");
- connection->xcbDestroyWindow = (xcbDestroyWindowType)GetProcAddress(module, "xcbDestroyWindow");
- connection->xcbGetMessage = (xcbGetMessageType)GetProcAddress(module, "xcbGetMessage");
- connection->xcbPeekMessage = (xcbPeekMessageType)GetProcAddress(module, "xcbPeekMessage");
- connection->xcbQueuePresent = (xcbQueuePresentType)GetProcAddress(module, "xcbQueuePresent");
-
- *screenp = 0;
- return static_cast<xcb_connection_t *>(connection);
-}
-
-void xcb_disconnect(xcb_connection_t *c)
-{
- xcb_connection_t * connection = static_cast<xcb_connection_t *>(c);
- FreeLibrary(connection->xcbNvidia);
- free(connection);
-}
-
-int xcb_flush(xcb_connection_t * c)
-{
- return 0;
-}
-
-static xcb_generic_event_t* TranslateWindowsMsg(MSG * msg)
-{
- switch (msg->message) {
- case WM_PAINT:
- {
- xcb_generic_event_t * event = (xcb_generic_event_t *)calloc(1, sizeof (xcb_generic_event_t));
- event->response_type = XCB_EXPOSE;
- return event;
- }
- break;
- case WM_KEYUP:
- {
- xcb_key_release_event_t * event = (xcb_key_release_event_t *)calloc(1, sizeof (xcb_key_release_event_t));
- event->response_type = XCB_KEY_RELEASE;
-
- // TODO: What's the correct mapping?
- switch (msg->wParam) {
- case VK_ESCAPE:
- event->detail = 0x09;
- break;
- case VK_LEFT:
- event->detail = 0x71;
- break;
- case VK_RIGHT:
- event->detail = 0x72;
- break;
- case VK_SPACE:
- event->detail = 0x41;
- break;
- default:
- event->detail = (xcb_keycode_t)msg->wParam;
- break;
- }
- return (xcb_generic_event_t *)event;
- }
- break;
- case WM_DESTROY:
- {
- xcb_generic_event_t * event = (xcb_generic_event_t *)calloc(1, sizeof (xcb_generic_event_t));
- event->response_type = XCB_DESTROY_NOTIFY;
- return event;
- }
- break;
- default:
- return 0;
- }
-
- return 0;
-}
-
-xcb_generic_event_t* xcb_wait_for_event(xcb_connection_t * c)
-{
- xcb_connection_t * connection = static_cast<xcb_connection_t *>(c);
-
- MSG msg;
- int result = connection->xcbGetMessage(&msg);
- if (result > 0) {
- return TranslateWindowsMsg(&msg);
- } else if (result == 0) {
- xcb_generic_event_t * event = (xcb_generic_event_t *)calloc(1, sizeof (xcb_generic_event_t));
- event->response_type = XCB_DESTROY_NOTIFY;
- return event;
- }
-
- return 0;
-}
-
-xcb_generic_event_t *xcb_poll_for_event(xcb_connection_t *c)
-{
- xcb_connection_t * connection = static_cast<xcb_connection_t *>(c);
-
- MSG msg;
- if (connection->xcbPeekMessage(&msg)) {
- return TranslateWindowsMsg(&msg);
- }
-
- return 0;
-}
-
-uint32_t xcb_generate_id(xcb_connection_t *c)
-{
- // FIXME: THIS IS NOT THREAD SAFE.
- uint32_t id = (uint32_t)g_xcbIds.size();
- XcbId xcbId = { static_cast<xcb_connection_t *>(c) };
- g_xcbIds.push_back(xcbId);
- return id;
-}
-
-xcb_void_cookie_t
-xcb_create_window(xcb_connection_t *c,
- uint8_t depth,
- xcb_window_t wid,
- xcb_window_t parent,
- int16_t x,
- int16_t y,
- uint16_t width,
- uint16_t height,
- uint16_t border_width,
- uint16_t _class,
- xcb_visualid_t visual,
- uint32_t value_mask,
- const uint32_t *value_list)
-{
- xcb_connection_t * connection = static_cast<xcb_connection_t *>(c);
- connection->xcbCreateWindow(width, height);
-
- xcb_void_cookie_t cookie = { };
- return cookie;
-}
-
-xcb_void_cookie_t
-xcb_destroy_window(xcb_connection_t *c,
- xcb_window_t window)
-{
- xcb_connection_t * connection = static_cast<xcb_connection_t *>(c);
- connection->xcbDestroyWindow();
-
- xcb_void_cookie_t cookie = { };
- return cookie;
-}
-
-xcb_intern_atom_cookie_t
-xcb_intern_atom(xcb_connection_t *c,
- uint8_t only_if_exists,
- uint16_t name_len,
- const char *name)
-{
- xcb_intern_atom_cookie_t cookie = { };
- return cookie;
-}
-
-xcb_intern_atom_reply_t *
-xcb_intern_atom_reply(xcb_connection_t *c,
- xcb_intern_atom_cookie_t cookie,
- xcb_generic_error_t **e)
-{
- xcb_intern_atom_reply_t * reply = (xcb_intern_atom_reply_t *)calloc(1, sizeof (xcb_intern_atom_reply_t));
-
- return reply;
-}
-
-xcb_void_cookie_t
-xcb_change_property(xcb_connection_t *c,
- uint8_t mode,
- xcb_window_t window,
- xcb_atom_t property,
- xcb_atom_t type,
- uint8_t format,
- uint32_t data_len,
- const void *data)
-{
- xcb_void_cookie_t cookie = { };
- return cookie;
-}
-
-xcb_void_cookie_t
-xcb_map_window(xcb_connection_t *c,
- xcb_window_t window)
-{
- xcb_void_cookie_t cookie = { };
- return cookie;
-}
-
-const struct xcb_setup_t* xcb_get_setup(xcb_connection_t * c)
-{
- xcb_connection_t * connection = static_cast<xcb_connection_t *>(c);
- return &connection->setup;
-}
-
-#define OFFSET_OF(_struct_, _member_) \
- ( \
- reinterpret_cast<size_t>(&(reinterpret_cast<_struct_ *>(1)->_member_)) - \
- reinterpret_cast<size_t>(reinterpret_cast<_struct_ *>(1)) \
- )
-
-/// Returns a pointer to a struct or class based on the pointer to one of
-/// its members.
-#define STRUCT_PTR_FROM_MEMBER_PTR(_struct_, _member_, _member_ptr_) \
- reinterpret_cast<_struct_ *>( \
- reinterpret_cast<size_t>(_member_ptr_) - \
- OFFSET_OF(_struct_, _member_) \
- )
-
-xcb_screen_iterator_t
-xcb_setup_roots_iterator(const xcb_setup_t *R)
-{
- xcb_connection_t * connection = STRUCT_PTR_FROM_MEMBER_PTR(xcb_connection_t, setup, R);
-
- xcb_screen_iterator_t iterator = { };
- iterator.data = &connection->screens[0];
- return iterator;
-}
-
-void
-xcb_screen_next(xcb_screen_iterator_t *i)
-{
-}
-
-XGL_RESULT XGLAPI xglWsiX11AssociateConnection(
- XGL_PHYSICAL_GPU gpu,
- const XGL_WSI_X11_CONNECTION_INFO* pConnectionInfo)
-{
- return XGL_SUCCESS;
-}
-
-XGL_RESULT XGLAPI xglWsiX11CreatePresentableImage(
- XGL_DEVICE device,
- const XGL_WSI_X11_PRESENTABLE_IMAGE_CREATE_INFO* pCreateInfo,
- XGL_IMAGE* pImage,
- XGL_GPU_MEMORY* pMem)
-{
- XGL_RESULT err;
-
- XGL_IMAGE_CREATE_INFO presentable_image = { XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO };
- presentable_image.imageType = XGL_IMAGE_2D;
- presentable_image.format = pCreateInfo->format;
- presentable_image.extent.width = pCreateInfo->extent.width;
- presentable_image.extent.height = pCreateInfo->extent.height;
- presentable_image.extent.depth = 1;
- presentable_image.mipLevels = 1;
- presentable_image.arraySize = 1;
- presentable_image.samples = 1;
- presentable_image.tiling = XGL_OPTIMAL_TILING;
- presentable_image.usage = XGL_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
- err = xglCreateImage(device, &presentable_image, pImage);
- if (err != XGL_SUCCESS) {
- return err;
- }
-
- uint32_t num_allocations = 0;
- size_t num_alloc_size = sizeof(num_allocations);
- err = xglGetObjectInfo(*pImage, XGL_INFO_TYPE_MEMORY_ALLOCATION_COUNT, &num_alloc_size, &num_allocations);
- if (err != XGL_SUCCESS) {
- xglDestroyObject(*pImage);
- return err;
- }
- if (num_allocations > 1) {
- xglDestroyObject(*pImage);
- return XGL_UNSUPPORTED;
- }
-
- size_t mem_reqs_size = sizeof(XGL_MEMORY_REQUIREMENTS);
- XGL_MEMORY_REQUIREMENTS mem_reqs;
- err = xglGetObjectInfo(*pImage, XGL_INFO_TYPE_MEMORY_REQUIREMENTS, &mem_reqs_size, &mem_reqs);
- if (err != XGL_SUCCESS) {
- xglDestroyObject(*pImage);
- return err;
- }
-
- size_t img_reqs_size = sizeof(XGL_IMAGE_MEMORY_REQUIREMENTS);
- XGL_IMAGE_MEMORY_REQUIREMENTS img_reqs;
- err = xglGetObjectInfo(*pImage, XGL_INFO_TYPE_IMAGE_MEMORY_REQUIREMENTS, &img_reqs_size, &img_reqs);
- if (err != XGL_SUCCESS) {
- xglDestroyObject(*pImage);
- return err;
- }
-
- XGL_MEMORY_ALLOC_IMAGE_INFO img_alloc = { XGL_STRUCTURE_TYPE_MEMORY_ALLOC_IMAGE_INFO };
- img_alloc.usage = img_reqs.usage;
- img_alloc.formatClass = img_reqs.formatClass;
- img_alloc.samples = img_reqs.samples;
- XGL_MEMORY_ALLOC_INFO mem_alloc = { XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO };
- mem_alloc.pNext = &img_alloc;
- mem_alloc.allocationSize = 0,
- mem_alloc.memProps = XGL_MEMORY_PROPERTY_GPU_ONLY,
- mem_alloc.memType = XGL_MEMORY_TYPE_IMAGE,
- mem_alloc.memPriority = XGL_MEMORY_PRIORITY_NORMAL,
- mem_alloc.allocationSize = mem_reqs.size;
- err = xglAllocMemory(device, &mem_alloc, pMem);
- if (err != XGL_SUCCESS) {
- xglDestroyObject(*pImage);
- return err;
- }
-
- err = xglBindObjectMemory(*pImage, 0, *pMem, 0);
- if (err != XGL_SUCCESS) {
- xglFreeMemory(*pMem);
- xglDestroyObject(*pImage);
- return err;
- }
-
- return XGL_SUCCESS;
-}
-
-XGL_RESULT XGLAPI xglWsiX11QueuePresent(
- XGL_QUEUE queue,
- const XGL_WSI_X11_PRESENT_INFO* pPresentInfo,
- XGL_FENCE fence)
-{
- xcb_connection_t * connection = g_xcbIds[pPresentInfo->destWindow].connection;
- return connection->xcbQueuePresent(queue, pPresentInfo->srcImage, fence);
-}
diff --git a/glave-generate.py b/glave-generate.py
index ad82aa3c..1f40af72 100755
--- a/glave-generate.py
+++ b/glave-generate.py
@@ -1845,20 +1845,20 @@ class Subcommand(object):
cd_body.append(' void resize_window(const unsigned int width, const unsigned int height);')
cd_body.append(' void process_event();')
cd_body.append(' // XGL_DEVICE get_device() { return m_dev[m_gpuIdx];}')
- cd_body.append('#if defined(WIN32)')
- cd_body.append(' HWND get_window_handle() { return m_windowHandle; }')
- cd_body.append('#elif defined(PLATFORM_LINUX)')
+ cd_body.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)')
cd_body.append(' xcb_window_t get_window_handle() { return m_XcbWindow; }')
+ cd_body.append('#elif defined(WIN32)')
+ cd_body.append(' HWND get_window_handle() { return m_windowHandle; }')
cd_body.append('#endif')
cd_body.append('private:')
cd_body.append(' XGL_RESULT init_xgl(const unsigned int gpu_idx);')
cd_body.append(' bool m_initedXGL;')
- cd_body.append('#if defined(WIN32)')
- cd_body.append(' HWND m_windowHandle;')
- cd_body.append('#elif defined(PLATFORM_LINUX)')
+ cd_body.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)')
cd_body.append(' XGL_WSI_X11_CONNECTION_INFO m_WsiConnection;')
cd_body.append(' xcb_screen_t *m_pXcbScreen;')
cd_body.append(' xcb_window_t m_XcbWindow;')
+ cd_body.append('#elif defined(WIN32)')
+ cd_body.append(' HWND m_windowHandle;')
cd_body.append('#endif')
cd_body.append(' unsigned int m_windowWidth;')
cd_body.append(' unsigned int m_windowHeight;')
@@ -2164,7 +2164,7 @@ class Subcommand(object):
di_body.append(' m_initedXGL = true;')
di_body.append(' }')
di_body.append('#endif')
- di_body.append('#if defined(PLATFORM_LINUX)')
+ di_body.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)')
di_body.append(' const xcb_setup_t *setup;')
di_body.append(' xcb_screen_iterator_t iter;')
di_body.append(' int scr;')
@@ -2189,19 +2189,19 @@ class Subcommand(object):
ds_body.append(' m_windowWidth(0),')
ds_body.append(' m_windowHeight(0)')
ds_body.append('{')
- ds_body.append('#if defined(WIN32)')
- ds_body.append(' m_windowHandle = NULL;')
- ds_body.append('#elif defined(PLATFORM_LINUX)')
+ ds_body.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)')
ds_body.append(' m_WsiConnection.pConnection = NULL;')
ds_body.append(' m_WsiConnection.root = 0;')
ds_body.append(' m_WsiConnection.provider = 0;')
ds_body.append(' m_pXcbScreen = NULL;')
ds_body.append(' m_XcbWindow = 0;')
+ ds_body.append('#elif defined(WIN32)')
+ ds_body.append(' m_windowHandle = NULL;')
ds_body.append('#endif')
ds_body.append('}')
ds_body.append('xglDisplay::~xglDisplay()')
ds_body.append('{')
- ds_body.append('#ifdef PLATFORM_LINUX')
+ ds_body.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)')
ds_body.append(' if (m_XcbWindow != 0)')
ds_body.append(' {')
ds_body.append(' xcb_destroy_window(m_WsiConnection.pConnection, m_XcbWindow);')
@@ -2234,10 +2234,10 @@ class Subcommand(object):
dw_body.append('#endif')
dw_body.append('int xglDisplay::set_window(glv_window_handle hWindow, unsigned int width, unsigned int height)')
dw_body.append('{')
- dw_body.append('#if defined(WIN32)')
- dw_body.append(' m_windowHandle = hWindow;')
- dw_body.append('#elif defined(PLATFORM_LINUX)')
+ dw_body.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)')
dw_body.append(' m_XcbWindow = hWindow;')
+ dw_body.append('#elif defined(WIN32)')
+ dw_body.append(' m_windowHandle = hWindow;')
dw_body.append('#endif')
dw_body.append(' m_windowWidth = width;')
dw_body.append(' m_windowHeight = height;')
@@ -2245,7 +2245,24 @@ class Subcommand(object):
dw_body.append('}\n')
dw_body.append('int xglDisplay::create_window(const unsigned int width, const unsigned int height)')
dw_body.append('{')
- dw_body.append('#if defined(WIN32)')
+ dw_body.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)\n')
+ dw_body.append(' uint32_t value_mask, value_list[32];')
+ dw_body.append(' m_XcbWindow = xcb_generate_id(m_WsiConnection.pConnection);\n')
+ dw_body.append(' value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;')
+ dw_body.append(' value_list[0] = m_pXcbScreen->black_pixel;')
+ dw_body.append(' value_list[1] = XCB_EVENT_MASK_KEY_RELEASE |')
+ dw_body.append(' XCB_EVENT_MASK_EXPOSURE;\n')
+ dw_body.append(' xcb_create_window(m_WsiConnection.pConnection,')
+ dw_body.append(' XCB_COPY_FROM_PARENT,')
+ dw_body.append(' m_XcbWindow, m_WsiConnection.root,')
+ dw_body.append(' 0, 0, width, height, 0,')
+ dw_body.append(' XCB_WINDOW_CLASS_INPUT_OUTPUT,')
+ dw_body.append(' m_pXcbScreen->root_visual,')
+ dw_body.append(' value_mask, value_list);\n')
+ dw_body.append(' xcb_map_window(m_WsiConnection.pConnection, m_XcbWindow);')
+ dw_body.append(' xcb_flush(m_WsiConnection.pConnection);')
+ dw_body.append(' return 0;')
+ dw_body.append('#elif defined(WIN32)')
dw_body.append(' // Register Window class')
dw_body.append(' WNDCLASSEX wcex = {};')
dw_body.append(' wcex.cbSize = sizeof( WNDCLASSEX);')
@@ -2278,41 +2295,24 @@ class Subcommand(object):
dw_body.append(' return -1;')
dw_body.append(' }')
dw_body.append(' return 0;')
- dw_body.append('#elif defined(PLATFORM_LINUX)\n')
- dw_body.append(' uint32_t value_mask, value_list[32];')
- dw_body.append(' m_XcbWindow = xcb_generate_id(m_WsiConnection.pConnection);\n')
- dw_body.append(' value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;')
- dw_body.append(' value_list[0] = m_pXcbScreen->black_pixel;')
- dw_body.append(' value_list[1] = XCB_EVENT_MASK_KEY_RELEASE |')
- dw_body.append(' XCB_EVENT_MASK_EXPOSURE;\n')
- dw_body.append(' xcb_create_window(m_WsiConnection.pConnection,')
- dw_body.append(' XCB_COPY_FROM_PARENT,')
- dw_body.append(' m_XcbWindow, m_WsiConnection.root,')
- dw_body.append(' 0, 0, width, height, 0,')
- dw_body.append(' XCB_WINDOW_CLASS_INPUT_OUTPUT,')
- dw_body.append(' m_pXcbScreen->root_visual,')
- dw_body.append(' value_mask, value_list);\n')
- dw_body.append(' xcb_map_window(m_WsiConnection.pConnection, m_XcbWindow);')
- dw_body.append(' xcb_flush(m_WsiConnection.pConnection);')
- dw_body.append(' return 0;')
dw_body.append('#endif')
dw_body.append('}\n')
dw_body.append('void xglDisplay::resize_window(const unsigned int width, const unsigned int height)')
dw_body.append('{')
- dw_body.append('#if defined(WIN32)')
+ dw_body.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)')
dw_body.append(' if (width != m_windowWidth || height != m_windowHeight)')
dw_body.append(' {')
- dw_body.append(' SetWindowPos(get_window_handle(), HWND_TOP, 0, 0, width, height, SWP_NOMOVE);')
+ dw_body.append(' uint32_t values[2];')
+ dw_body.append(' values[0] = width;')
+ dw_body.append(' values[1] = height;')
+ dw_body.append(' xcb_configure_window(m_WsiConnection.pConnection, m_XcbWindow, XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values);')
dw_body.append(' m_windowWidth = width;')
dw_body.append(' m_windowHeight = height;')
dw_body.append(' }')
- dw_body.append('#elif defined(PLATFORM_LINUX)')
+ dw_body.append('#elif defined(WIN32)')
dw_body.append(' if (width != m_windowWidth || height != m_windowHeight)')
dw_body.append(' {')
- dw_body.append(' uint32_t values[2];')
- dw_body.append(' values[0] = width;')
- dw_body.append(' values[1] = height;')
- dw_body.append(' xcb_configure_window(m_WsiConnection.pConnection, m_XcbWindow, XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values);')
+ dw_body.append(' SetWindowPos(get_window_handle(), HWND_TOP, 0, 0, width, height, SWP_NOMOVE);')
dw_body.append(' m_windowWidth = width;')
dw_body.append(' m_windowHeight = height;')
dw_body.append(' }')
@@ -3138,32 +3138,31 @@ class Subcommand(object):
def _gen_replay_wsi_associate_connection(self):
wac_body = []
- wac_body.append('#ifdef WIN32')
- wac_body.append(' //TBD')
- wac_body.append(' replayResult = XGL_SUCCESS;')
- wac_body.append('#else')
+ wac_body.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)')
wac_body.append(' //associate with the replayers Wsi connection rather than tracers')
wac_body.append(' replayResult = m_xglFuncs.real_xglWsiX11AssociateConnection(remap(pPacket->gpu), &(m_display->m_WsiConnection));')
+ wac_body.append('#elif defined(WIN32)')
+ wac_body.append(' //TBD')
+ wac_body.append(' replayResult = XGL_SUCCESS;')
wac_body.append('#endif')
return "\n".join(wac_body)
def _gen_replay_wsi_get_msc(self):
wgm_body = []
- wgm_body.append('#ifdef WIN32')
+ wgm_body.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)')
+ wgm_body.append(' xcb_window_t window = m_display->m_XcbWindow;')
+ wgm_body.append(' replayResult = m_xglFuncs.real_xglWsiX11GetMSC(remap(pPacket->device), window, pPacket->crtc, pPacket->pMsc);')
+ wgm_body.append('#elif defined(WIN32)')
wgm_body.append(' //TBD')
wgm_body.append(' replayResult = XGL_SUCCESS;')
wgm_body.append('#else')
- wgm_body.append(' xcb_window_t window = m_display->m_XcbWindow;')
- wgm_body.append(' replayResult = m_xglFuncs.real_xglWsiX11GetMSC(remap(pPacket->device), window, pPacket->crtc, pPacket->pMsc);')
+
wgm_body.append('#endif')
return "\n".join(wgm_body)
def _gen_replay_wsi_create_presentable_image(self):
cpi_body = []
- cpi_body.append('#ifdef WIN32')
- cpi_body.append(' //TBD')
- cpi_body.append(' replayResult = XGL_SUCCESS;')
- cpi_body.append('#else')
+ cpi_body.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)')
cpi_body.append(' XGL_IMAGE img;')
cpi_body.append(' XGL_GPU_MEMORY mem;')
cpi_body.append(' m_display->imageHeight.push_back(pPacket->pCreateInfo->extent.height);')
@@ -3178,15 +3177,15 @@ class Subcommand(object):
cpi_body.append(' m_display->imageHandles.push_back(img);')
cpi_body.append(' m_display->imageMemory.push_back(mem);')
cpi_body.append(' }')
+ cpi_body.append('#elif defined(WIN32)')
+ cpi_body.append(' //TBD')
+ cpi_body.append(' replayResult = XGL_SUCCESS;')
cpi_body.append('#endif')
return "\n".join(cpi_body)
def _gen_replay_wsi_queue_present(self):
wqp_body = []
- wqp_body.append('#ifdef WIN32')
- wqp_body.append(' //TBD')
- wqp_body.append(' replayResult = XGL_SUCCESS;')
- wqp_body.append('#else')
+ wqp_body.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)')
wqp_body.append(' XGL_WSI_X11_PRESENT_INFO pInfo;')
wqp_body.append(' std::vector<int>::iterator it;')
wqp_body.append(' memcpy(&pInfo, pPacket->pPresentInfo, sizeof(XGL_WSI_X11_PRESENT_INFO));')
@@ -3209,6 +3208,9 @@ class Subcommand(object):
wqp_body.append(' }')
wqp_body.append(' }')
wqp_body.append(' }')
+ wqp_body.append('#elif defined(WIN32)')
+ wqp_body.append(' //TBD')
+ wqp_body.append(' replayResult = XGL_SUCCESS;')
wqp_body.append('#endif')
wqp_body.append(' m_display->m_frameNumber++;')
return "\n".join(wqp_body)
@@ -3507,6 +3509,9 @@ class GlavePacketID(Subcommand):
header_txt.append('#include "glvtrace_xgl_xgldbg_structs.h"')
header_txt.append('#include "glvtrace_xgl_xglwsix11ext_structs.h"')
header_txt.append('#include "xgl_enum_string_helper.h"')
+ header_txt.append('#if defined(WIN32)')
+ header_txt.append('#define snprintf _snprintf')
+ header_txt.append('#endif')
header_txt.append('#define SEND_ENTRYPOINT_ID(entrypoint) ;')
header_txt.append('//#define SEND_ENTRYPOINT_ID(entrypoint) glv_TraceInfo(#entrypoint "\\n");\n')
header_txt.append('#define SEND_ENTRYPOINT_PARAMS(entrypoint, ...) ;')
@@ -3545,7 +3550,7 @@ class GlaveWsiHeader(Subcommand):
header_txt = []
header_txt.append('#pragma once\n')
header_txt.append('#include "xgl.h"')
- header_txt.append('#if defined(PLATFORM_LINUX)')
+ header_txt.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)')
header_txt.append('#include "xglWsiX11Ext.h"\n')
header_txt.append('#else')
header_txt.append('#include "xglWsiWinExt.h"')
@@ -3585,7 +3590,7 @@ class GlaveWsiStructs(Subcommand):
def generate_header(self):
header_txt = []
header_txt.append('#pragma once\n')
- header_txt.append('#if defined(PLATFORM_LINUX)')
+ header_txt.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)')
header_txt.append('#include "xglWsiX11Ext.h"')
header_txt.append('#else')
header_txt.append('#include "xglWsiWinExt.h"')
@@ -3657,7 +3662,7 @@ class GlaveReplayHeader(Subcommand):
header_txt.append('#include <map>')
header_txt.append('#include <vector>')
header_txt.append('#include <string>')
- header_txt.append('#if defined(PLATFORM_LINUX)')
+ header_txt.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)')
header_txt.append('#include <xcb/xcb.h>\n')
header_txt.append('#endif')
header_txt.append('#include "glvreplay_window.h"')
@@ -3665,7 +3670,7 @@ class GlaveReplayHeader(Subcommand):
header_txt.append('#include "glv_trace_packet_identifiers.h"\n')
header_txt.append('#include "xgl.h"')
header_txt.append('#include "xglDbg.h"')
- header_txt.append('#if defined(PLATFORM_LINUX)')
+ header_txt.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)')
header_txt.append('#include "xglWsiX11Ext.h"')
header_txt.append('#else')
header_txt.append('#include "xglWsiWinExt.h"')
diff --git a/include/xglLayer.h b/include/xglLayer.h
index fc192571..6a81c90f 100644
--- a/include/xglLayer.h
+++ b/include/xglLayer.h
@@ -6,11 +6,9 @@
#include "xgl.h"
#include "xglDbg.h"
-#if defined(_WIN32)
-#else // WIN32
-// FIXME: NEED WINDOWS EQUIVALENT
+#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)
#include "xglWsiX11Ext.h"
-#endif // WIN32
+#endif
#if defined(__GNUC__) && __GNUC__ >= 4
# define XGL_LAYER_EXPORT __attribute__((visibility("default")))
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
@@ -151,9 +149,7 @@ typedef struct _XGL_LAYER_DISPATCH_TABLE
xglDbgSetDeviceOptionType DbgSetDeviceOption;
xglCmdDbgMarkerBeginType CmdDbgMarkerBegin;
xglCmdDbgMarkerEndType CmdDbgMarkerEnd;
-#if defined(_WIN32)
-// FIXME: NEED WINDOWS EQUIVALENT
-#else // WIN32
+#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)
xglWsiX11AssociateConnectionType WsiX11AssociateConnection;
xglWsiX11GetMSCType WsiX11GetMSC;
xglWsiX11CreatePresentableImageType WsiX11CreatePresentableImage;
diff --git a/include/xglWsiWinExt.h b/include/xglWsiWinExt.h
index 84d3eb13..b93841b1 100644
--- a/include/xglWsiWinExt.h
+++ b/include/xglWsiWinExt.h
@@ -3,10 +3,6 @@
#ifndef __XGLWSIWINEXT_H__
#define __XGLWSIWINEXT_H__
-// This should be moved out of this WSI header file and
-// into a platform-specific file.
-#define snprintf _snprintf
-
// This is just to get windows to build.
// Need to replace with the declarations for Windows wsi.
typedef void XGL_WSI_X11_CONNECTION_INFO;
diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt
index f5f835cd..697d0304 100644
--- a/loader/CMakeLists.txt
+++ b/loader/CMakeLists.txt
@@ -17,7 +17,7 @@ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
if (WIN32)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXGL_PROTOTYPES -D_CRT_SECURE_NO_WARNINGS")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXGL_PROTOTYPES -D_CRT_SECURE_NO_WARNINGS -DXCB_NVIDIA")
add_library(XGL SHARED loader.c loader.h dirent_on_windows.c dispatch.c table_ops.h XGL.def)
set_target_properties(XGL PROPERTIES LINK_FLAGS "/DEF:${PROJECT_SOURCE_DIR}/loader/XGL.def")
diff --git a/loader/XGL.def b/loader/XGL.def
index 6c560ba1..4d1877ea 100644
--- a/loader/XGL.def
+++ b/loader/XGL.def
@@ -148,3 +148,7 @@ EXPORTS
xglDbgSetDeviceOption
xglCmdDbgMarkerBegin
xglCmdDbgMarkerEnd
+ xglWsiX11AssociateConnection
+ xglWsiX11GetMSC
+ xglWsiX11CreatePresentableImage
+ xglWsiX11QueuePresent
diff --git a/loader/loader_platform.h b/loader/loader_platform.h
index 2d878bce..b4f711af 100644
--- a/loader/loader_platform.h
+++ b/loader/loader_platform.h
@@ -135,6 +135,7 @@ static inline void loader_platform_thread_delete_mutex(loader_platform_thread_mu
/* Windows-specific common code: */
// Headers:
+#include <WinSock2.h>
#include <windows.h>
#include <assert.h>
#ifdef __cplusplus
diff --git a/xgl-generate.py b/xgl-generate.py
index 9164cda6..f4dd5485 100755
--- a/xgl-generate.py
+++ b/xgl-generate.py
@@ -121,7 +121,7 @@ class LoaderEntrypointsSubcommand(Subcommand):
if not self._is_dispatchable(proto):
continue
if 'WsiX11AssociateConnection' == proto.name:
- funcs.append("#if !defined(_WIN32)")
+ funcs.append("#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)")
decl = proto.c_func(prefix="xgl", attr="XGLAPI")
stmt = "(*disp)->%s" % proto.c_call()
if proto.name == "CreateDevice":
@@ -265,7 +265,7 @@ class DispatchTableOpsSubcommand(Subcommand):
stmts = []
for proto in self.protos:
if 'WsiX11AssociateConnection' == proto.name:
- stmts.append("#if !defined(_WIN32)")
+ stmts.append("#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)")
if proto.name == "GetProcAddr":
stmts.append("table->%s = gpa; /* direct assignment */" %
proto.name)
@@ -291,7 +291,7 @@ class DispatchTableOpsSubcommand(Subcommand):
lookups = []
for proto in self.protos:
if 'WsiX11AssociateConnection' == proto.name:
- lookups.append("#if !defined(_WIN32)")
+ lookups.append("#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)")
lookups.append("if (!strcmp(name, \"%s\"))" % (proto.name))
lookups.append(" return (void *) table->%s;"
% (proto.name))
@@ -367,7 +367,7 @@ class IcdGetProcAddrSubcommand(IcdDummyEntrypointsSubcommand):
lookups = []
for proto in self.protos:
if 'WsiX11AssociateConnection' == proto.name:
- lookups.append("#if !defined(_WIN32)")
+ lookups.append("#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)")
lookups.append("if (!strcmp(%s, \"%s\"))" %
(gpa_pname, proto.name))
lookups.append(" return (%s) %s%s;" %
@@ -412,7 +412,7 @@ class LayerInterceptProcSubcommand(Subcommand):
continue
if 'WsiX11AssociateConnection' == proto.name:
- lookups.append("#if !defined(_WIN32)")
+ lookups.append("#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)")
lookups.append("if (!strcmp(name, \"%s\"))" % proto.name)
lookups.append(" return (%s) %s%s;" %
(self.gpa.ret, self.prefix, proto.name))
diff --git a/xgl-layer-generate.py b/xgl-layer-generate.py
index ea57f586..aa3832dd 100755
--- a/xgl-layer-generate.py
+++ b/xgl-layer-generate.py
@@ -196,7 +196,7 @@ class Subcommand(object):
ret_val = "XGL_RESULT result = "
stmt = " return result;\n"
if 'WsiX11AssociateConnection' == proto.name:
- funcs.append("#if !defined(_WIN32)")
+ funcs.append("#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)")
if proto.name == "EnumerateLayers":
c_call = proto.c_call().replace("(" + proto.params[0].name, "((XGL_PHYSICAL_GPU)gpuw->nextObject", 1)
funcs.append('%s%s\n'
@@ -370,7 +370,7 @@ class Subcommand(object):
#log_func += '\n fflush(stdout);'
log_func += '\n }'
if 'WsiX11AssociateConnection' == proto.name:
- funcs.append("#if !defined(_WIN32)")
+ funcs.append("#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)")
if proto.name == "EnumerateLayers":
c_call = proto.c_call().replace("(" + proto.params[0].name, "((XGL_PHYSICAL_GPU)gpuw->nextObject", 1)
funcs.append('%s%s\n'
@@ -519,7 +519,7 @@ class Subcommand(object):
log_func += '\n fflush(stdout);'
log_func += '\n free(pTmpStr);\n }'
if 'WsiX11AssociateConnection' == proto.name:
- funcs.append("#if !defined(_WIN32)")
+ funcs.append("#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)")
if proto.name == "EnumerateLayers":
c_call = proto.c_call().replace("(" + proto.params[0].name, "((XGL_PHYSICAL_GPU)gpuw->nextObject", 1)
funcs.append('%s%s\n'
@@ -658,7 +658,7 @@ class Subcommand(object):
ret_val = "XGL_RESULT result = "
stmt = " return result;\n"
if 'WsiX11AssociateConnection' == proto.name:
- funcs.append("#if !defined(_WIN32)")
+ funcs.append("#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)")
if proto.name == "EnumerateLayers":
c_call = proto.c_call().replace("(" + proto.params[0].name, "((XGL_PHYSICAL_GPU)gpuw->nextObject", 1)
funcs.append('%s%s\n'
@@ -767,7 +767,7 @@ class Subcommand(object):
ret_val = "XGL_RESULT result = "
stmt = " return result;\n"
if 'WsiX11AssociateConnection' == proto.name:
- funcs.append("#if !defined(_WIN32)")
+ funcs.append("#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)")
if proto.name == "EnumerateLayers":
c_call = proto.c_call().replace("(" + proto.params[0].name, "((XGL_PHYSICAL_GPU)gpuw->nextObject", 1)
funcs.append('%s%s\n'