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.
This commit is contained in:
Piers Daniell 2015-02-24 13:58:47 -07:00 committed by Courtney Goeltzenleuchter
parent 96b14142e9
commit 8054c37fbf
8 changed files with 84 additions and 72 deletions

5
.gitignore vendored
View File

@ -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/*

View File

@ -46,5 +46,6 @@ if (NOT WIN32)
add_subdirectory(tests)
endif()
add_subdirectory(layers)
add_subdirectory(libs)
add_subdirectory(demos)
add_subdirectory(tools/glave)

View File

@ -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,35 +2295,11 @@ 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 (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(' m_windowWidth = width;')
dw_body.append(' m_windowHeight = height;')
dw_body.append(' }')
dw_body.append('#elif defined(PLATFORM_LINUX)')
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(' uint32_t values[2];')
@ -2316,6 +2309,13 @@ class Subcommand(object):
dw_body.append(' m_windowWidth = width;')
dw_body.append(' m_windowHeight = height;')
dw_body.append(' }')
dw_body.append('#elif defined(WIN32)')
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(' m_windowWidth = width;')
dw_body.append(' m_windowHeight = height;')
dw_body.append(' }')
dw_body.append('#endif')
dw_body.append('}\n')
dw_body.append('void xglDisplay::process_event()')
@ -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"')

View File

@ -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")

View File

@ -148,3 +148,7 @@ EXPORTS
xglDbgSetDeviceOption
xglCmdDbgMarkerBegin
xglCmdDbgMarkerEnd
xglWsiX11AssociateConnection
xglWsiX11GetMSC
xglWsiX11CreatePresentableImage
xglWsiX11QueuePresent

View File

@ -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

View File

@ -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))

View File

@ -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'