Tidy up handling of windowing data, make it a bit more type safe

This commit is contained in:
baldurk
2018-01-01 13:38:56 +00:00
parent b8bd99a24a
commit 6572cd97f5
40 changed files with 268 additions and 235 deletions
+4
View File
@@ -44,6 +44,10 @@ Logging & Versioning
Maths & Utilities
-----------------
.. autofunction:: renderdoc.CreateWin32WindowingData
.. autofunction:: renderdoc.CreateXlibWindowingData
.. autofunction:: renderdoc.CreateXCBWindowingData
.. autofunction:: renderdoc.CreateAndroidWindowingData
.. autofunction:: renderdoc.InitCamera
.. autofunction:: renderdoc.HalfToFloat
.. autofunction:: renderdoc.FloatToHalf
+6 -16
View File
@@ -1144,33 +1144,23 @@ int CaptureContext::ResourceNameCacheID()
return m_CustomNameCachedID;
}
void *CaptureContext::FillWindowingData(uintptr_t widget)
WindowingData CaptureContext::CreateWindowingData(uintptr_t widget)
{
#if defined(WIN32)
return (void *)widget;
return CreateWin32WindowingData((HWND)widget);
#elif defined(RENDERDOC_PLATFORM_LINUX)
static XCBWindowData xcb;
static XlibWindowData xlib;
if(m_CurWinSystem == WindowingSystem::XCB)
{
xcb.connection = m_XCBConnection;
xcb.window = (xcb_window_t)widget;
return &xcb;
}
return CreateXCBWindowingData(m_XCBConnection, (xcb_window_t)widget);
else
{
xlib.display = m_X11Display;
xlib.window = (Drawable)widget;
return &xlib;
}
return CreateXlibWindowingData(m_X11Display, (Drawable)widget);
#elif defined(RENDERDOC_PLATFORM_APPLE)
return (void *)widget;
WindowingData ret = {WindowingSystem::Unknown};
return ret;
#else
+1 -1
View File
@@ -132,7 +132,7 @@ public:
}
const SDFile &GetStructuredFile() override { return *m_StructuredFile; }
WindowingSystem CurWindowingSystem() override { return m_CurWinSystem; }
void *FillWindowingData(uintptr_t winId) override;
WindowingData CreateWindowingData(uintptr_t winId) override;
const rdcarray<DebugMessage> &DebugMessages() override { return m_DebugMessages; }
int UnreadMessageCount() override { return m_UnreadMessageCount; }
+2 -7
View File
@@ -1296,16 +1296,11 @@ considered out of date
DOCUMENT(R"(Create an opaque pointer suitable for passing to
:meth:`~renderdoc.ReplayController.CreateOutput` or other functions that expect windowing data.
.. note::
This data only stays valid until the next call to FillWindowingData. You should pass it to the
consuming function immediately.
:param int winId: The window ID as returned from ``QWidget.winId()``.
:return: The windowing data.
:rtype: opaque void * pointer.
:rtype: ~renderdoc.WindowingData
)");
virtual void *FillWindowingData(uintptr_t winId) = 0;
virtual WindowingData CreateWindowingData(uintptr_t winId) = 0;
DOCUMENT(R"(Retrieve the current list of debug messages. This includes messages from the capture
as well as messages generated during replay and analysis.
+1 -2
View File
@@ -1362,8 +1362,7 @@ void BufferViewer::OnCaptureLoaded()
WId renderID = ui->render->winId();
m_Ctx.Replay().BlockInvoke([renderID, this](IReplayController *r) {
m_Output = r->CreateOutput(m_Ctx.CurWindowingSystem(), m_Ctx.FillWindowingData(renderID),
ReplayOutputType::Mesh);
m_Output = r->CreateOutput(m_Ctx.CreateWindowingData(renderID), ReplayOutputType::Mesh);
ui->render->setOutput(m_Output);
+2 -4
View File
@@ -2087,11 +2087,9 @@ void MainWindow::on_action_Start_Replay_Loop_triggered()
.arg(tr("nothing")));
}
WindowingSystem winSys = m_Ctx.CurWindowingSystem();
void *winData = m_Ctx.FillWindowingData(popup.winId());
WindowingData winData = m_Ctx.CreateWindowingData(popup.winId());
m_Ctx.Replay().AsyncInvoke(
[winSys, winData, id](IReplayController *r) { r->ReplayLoop(winSys, winData, id); });
m_Ctx.Replay().AsyncInvoke([winData, id](IReplayController *r) { r->ReplayLoop(winData, id); });
RDDialog::show(&popup);
+2 -2
View File
@@ -101,9 +101,9 @@ struct CaptureContextInvoker : ICaptureContext
}
virtual const SDFile &GetStructuredFile() override { return m_Ctx.GetStructuredFile(); }
virtual WindowingSystem CurWindowingSystem() override { return m_Ctx.CurWindowingSystem(); }
virtual void *FillWindowingData(uintptr_t winId) override
virtual WindowingData CreateWindowingData(uintptr_t winId) override
{
return m_Ctx.FillWindowingData(winId);
return m_Ctx.CreateWindowingData(winId);
}
virtual const rdcarray<DebugMessage> &DebugMessages() override { return m_Ctx.DebugMessages(); }
virtual int UnreadMessageCount() override { return m_Ctx.UnreadMessageCount(); }
+5 -9
View File
@@ -1875,15 +1875,13 @@ void TextureViewer::InitResourcePreview(ResourcePreview *prev, ResourceId id, Co
if(m_Ctx.GetTexture(id))
{
m_Ctx.Replay().AsyncInvoke([this, handle, id, typeHint](IReplayController *) {
m_Output->AddThumbnail(m_Ctx.CurWindowingSystem(), m_Ctx.FillWindowingData(handle), id,
typeHint);
m_Output->AddThumbnail(m_Ctx.CreateWindowingData(handle), id, typeHint);
});
}
else
{
m_Ctx.Replay().AsyncInvoke([this, handle](IReplayController *) {
m_Output->AddThumbnail(m_Ctx.CurWindowingSystem(), m_Ctx.FillWindowingData(handle),
ResourceId(), CompType::Typeless);
m_Output->AddThumbnail(m_Ctx.CreateWindowingData(handle), ResourceId(), CompType::Typeless);
});
}
@@ -1900,8 +1898,7 @@ void TextureViewer::InitResourcePreview(ResourcePreview *prev, ResourceId id, Co
WId handle = prev->thumbWinId();
m_Ctx.Replay().AsyncInvoke([this, handle](IReplayController *) {
m_Output->AddThumbnail(m_Ctx.CurWindowingSystem(), m_Ctx.FillWindowingData(handle),
ResourceId(), CompType::Typeless);
m_Output->AddThumbnail(m_Ctx.CreateWindowingData(handle), ResourceId(), CompType::Typeless);
});
}
else
@@ -2445,10 +2442,9 @@ void TextureViewer::OnCaptureLoaded()
: FloatVector();
m_Ctx.Replay().BlockInvoke([renderID, contextID, this](IReplayController *r) {
m_Output = r->CreateOutput(m_Ctx.CurWindowingSystem(), m_Ctx.FillWindowingData(renderID),
ReplayOutputType::Texture);
m_Output = r->CreateOutput(m_Ctx.CreateWindowingData(renderID), ReplayOutputType::Texture);
m_Output->SetPixelContext(m_Ctx.CurWindowingSystem(), m_Ctx.FillWindowingData(contextID));
m_Output->SetPixelContext(m_Ctx.CreateWindowingData(contextID));
ui->render->setOutput(m_Output);
ui->pixelContext->setOutput(m_Output);
+147 -75
View File
@@ -104,59 +104,6 @@
#define RENDERDOC_API RENDERDOC_IMPORT_API
#endif
// windowing structures
#if defined(RENDERDOC_PLATFORM_WIN32)
// Win32 uses HWND
#endif
#if defined(RENDERDOC_WINDOWING_XLIB)
// can't include xlib.h here as it defines a ton of crap like None
// and Bool etc which can interfere with other headers
typedef struct _XDisplay Display;
typedef unsigned long Drawable;
struct XlibWindowData
{
Display *display;
Drawable window;
};
#else
typedef struct _XDisplay Display;
#endif
#if defined(RENDERDOC_WINDOWING_XCB)
struct xcb_connection_t;
typedef uint32_t xcb_window_t;
struct XCBWindowData
{
xcb_connection_t *connection;
xcb_window_t window;
};
#endif
#if defined(RENDERDOC_PLATFORM_ANDROID)
// android uses ANativeWindow*
#endif
DOCUMENT(R"(Internal structure used for initialising environment in a replay application.)");
struct GlobalEnvironment
{
DOCUMENT("The handle to the X display to use internally. If left ``NULL``, one will be opened.");
Display *xlibDisplay = NULL;
};
// needs to be declared up here for reference in basic_types
extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_FreeArrayMem(const void *mem);
@@ -311,23 +258,23 @@ DOCUMENT(R"(Specifies a windowing system to use for creating an output window.
.. data:: Unknown
No windowing data is passed and no native window will be output to.
No windowing data is passed and no native window is described.
.. data:: Win32
The windowing data refers to a Win32 ``HWND`` handle.
The windowing data refers to a Win32 window. See :func:`CreateWin32WindowingData`.
.. data:: Xlib
The windowing data refers to an Xlib pair of ``Display *`` and ``Drawable``.
The windowing data refers to an Xlib window. See :func:`CreateXLibWindowingData`.
.. data:: XCB
The windowing data refers to an XCB pair of ``xcb_connection_t *`` and ``xcb_window_t``.
The windowing data refers to an XCB window. See :func:`CreateXCBWindowingData`.
.. data:: Android
The windowing data refers to an Android ``ANativeWindow *``.
The windowing data refers to an Android window. See :func:`CreateAndroidWindowingData`.
)");
enum class WindowingSystem : uint32_t
{
@@ -340,6 +287,140 @@ enum class WindowingSystem : uint32_t
DECLARE_REFLECTION_ENUM(WindowingSystem);
// typedef the window data structs so this will compile on all platforms without system headers. We
// only actually need the real definitions when we're using the data, otherwise it's mostly opaque
// pointers or integers.
// Win32
typedef struct HWND__ *HWND;
// xlib
typedef struct _XDisplay Display;
typedef unsigned long Drawable;
// xcb
struct xcb_connection_t;
typedef uint32_t xcb_window_t;
// android
struct ANativeWindow;
// for swig bindings treat the windowing data struct as completely opaque
#if defined(SWIG)
struct WindowingData;
#else
struct WindowingData
{
WindowingSystem system;
union
{
struct
{
HWND window;
} win32;
struct
{
Display *display;
Drawable window;
} xlib;
struct
{
xcb_connection_t *connection;
xcb_window_t window;
} xcb;
struct
{
ANativeWindow *window;
} android;
};
};
DECLARE_REFLECTION_ENUM(WindowingData);
#endif
DOCUMENT(R"(Create a :class:`WindowingData` for a Win32 ``HWND`` handle.
:param HWND window: The native ``HWND`` handle for this window.
:return: A :class:`WindowingData` corresponding to the given window.
:rtype: WindowingData
)");
inline const WindowingData CreateWin32WindowingData(HWND window)
{
WindowingData ret = {};
ret.system = WindowingSystem::Win32;
ret.win32.window = window;
return ret;
}
DOCUMENT(R"(Create a :class:`WindowingData` for an Xlib ``Drawable`` handle.
:param Display display: The ``Display`` connection used for this window.
:param Drawable window: The native ``Drawable`` handle for this window.
:return: A :class:`WindowingData` corresponding to the given window.
:rtype: WindowingData
)");
inline const WindowingData CreateXlibWindowingData(Display *display, Drawable window)
{
WindowingData ret = {};
ret.system = WindowingSystem::Xlib;
ret.xlib.display = display;
ret.xlib.window = window;
return ret;
}
DOCUMENT(R"(Create a :class:`WindowingData` for an XCB ``xcb_window_t`` handle.
:param xcb_connection_t connection: The ``xcb_connection_t`` connection used for this window.
:param xcb_window_t window: The native ``xcb_window_t`` handle for this window.
:return: A :class:`WindowingData` corresponding to the given window.
:rtype: WindowingData
)");
inline const WindowingData CreateXCBWindowingData(xcb_connection_t *connection, xcb_window_t window)
{
WindowingData ret = {};
ret.system = WindowingSystem::XCB;
ret.xcb.connection = connection;
ret.xcb.window = window;
return ret;
}
DOCUMENT(R"(Create a :class:`WindowingData` for an Android ``ANativeWindow`` handle.
:param ANativeWindow window: The native ``ANativeWindow`` handle for this window.
:return: A :class:`WindowingData` corresponding to the given window.
:rtype: WindowingData
)");
inline const WindowingData CreateAndroidWindowingData(ANativeWindow *window)
{
WindowingData ret = {};
ret.system = WindowingSystem::Android;
ret.android.window = window;
return ret;
}
DOCUMENT(R"(Internal structure used for initialising environment in a replay application.)");
struct GlobalEnvironment
{
DOCUMENT("The handle to the X display to use internally. If left ``NULL``, one will be opened.");
Display *xlibDisplay = NULL;
};
#ifdef RENDERDOC_EXPORTS
struct ResourceId;
@@ -441,15 +522,12 @@ you can call this function multiple times to just change the texture.
Should only be called for texture outputs.
:param WindowingSystem system: The type of native window handle data being provided.
:param data: The native window data, in a format defined by the system.
:type data: opaque void * pointer.
:param WindowingData window: A :class:`WindowingData` describing the native window.
:param ResourceId textureId: The texture ID to display in the thumbnail preview.
:return: A boolean indicating if the thumbnail was successfully created.
:rtype: ``bool``
)");
virtual bool AddThumbnail(WindowingSystem system, void *data, ResourceId textureId,
CompType typeHint) = 0;
virtual bool AddThumbnail(WindowingData window, ResourceId textureId, CompType typeHint) = 0;
DOCUMENT(R"(Render to the window handle specified when the output was created.
@@ -464,13 +542,11 @@ fixed high zoom value and a fixed position, see :meth:`SetPixelContextLocation`.
Should only be called for texture outputs.
:param WindowingSystem system: The type of native window handle data being provided.
:param data: The native window data, in a format defined by the system.
:type data: opaque void * pointer.
:param WindowingData window: A :class:`WindowingData` describing the native window.
:return: A boolean indicating if the pixel context was successfully configured.
:rtype: ``bool``
)");
virtual bool SetPixelContext(WindowingSystem system, void *data) = 0;
virtual bool SetPixelContext(WindowingData window) = 0;
DOCUMENT(R"(Sets the pixel that the pixel context should be centred on.
@@ -592,14 +668,12 @@ struct IReplayController
DOCUMENT(R"(Creates a replay output of the given type to the given native window
:param WindowingSystem system: The type of native window handle data being provided
:param data: The native window data, in a format defined by the system
:type data: opaque void * pointer
:param WindowingData window: A :class:`WindowingData` describing the native window.
:param ReplayOutputType type: What type of output to create
:return: A handle to the created output, or ``None`` on failure
:rtype: ReplayOutput
)");
virtual IReplayOutput *CreateOutput(WindowingSystem system, void *data, ReplayOutputType type) = 0;
virtual IReplayOutput *CreateOutput(WindowingData window, ReplayOutputType type) = 0;
DOCUMENT("Shutdown and destroy the current interface and all outputs that have been created.");
virtual void Shutdown() = 0;
@@ -610,12 +684,10 @@ displaying the selected texture in a default unscaled manner to the given output
The function won't return until :meth:`CancelReplayLoop` is called. Since this function is blocking, that
function must be called from another thread.
:param WindowingSystem system: The type of native window handle data being provided
:param data: The native window data, in a format defined by the system
:type data: opaque void * pointer
:param WindowingData window: A :class:`WindowingData` describing the native window.
:param ResourceId texid: The id of the texture to display.
)");
virtual void ReplayLoop(WindowingSystem system, void *data, ResourceId texid) = 0;
virtual void ReplayLoop(WindowingData window, ResourceId texid) = 0;
DOCUMENT("Cancels a replay loop begun in :meth:`ReplayLoop`. Does nothing if no loop is active.");
virtual void CancelReplayLoop() = 0;
+2 -2
View File
@@ -74,9 +74,9 @@ public:
{
return m_Proxy->GetSupportedWindowSystems();
}
uint64_t MakeOutputWindow(WindowingSystem system, void *data, bool depth)
uint64_t MakeOutputWindow(WindowingData window, bool depth)
{
return m_Proxy->MakeOutputWindow(system, data, depth);
return m_Proxy->MakeOutputWindow(window, depth);
}
void DestroyOutputWindow(uint64_t id) { m_Proxy->DestroyOutputWindow(id); }
bool CheckResizeOutputWindow(uint64_t id) { return m_Proxy->CheckResizeOutputWindow(id); }
+2 -2
View File
@@ -137,10 +137,10 @@ public:
return m_Proxy->GetSupportedWindowSystems();
return vector<WindowingSystem>();
}
uint64_t MakeOutputWindow(WindowingSystem system, void *data, bool depth)
uint64_t MakeOutputWindow(WindowingData window, bool depth)
{
if(m_Proxy)
return m_Proxy->MakeOutputWindow(system, data, depth);
return m_Proxy->MakeOutputWindow(window, depth);
return 0;
}
void DestroyOutputWindow(uint64_t id)
+3 -3
View File
@@ -1562,12 +1562,12 @@ void D3D11DebugManager::OutputWindow::MakeDSV()
}
}
uint64_t D3D11DebugManager::MakeOutputWindow(WindowingSystem system, void *data, bool depth)
uint64_t D3D11DebugManager::MakeOutputWindow(WindowingData window, bool depth)
{
RDCASSERT(system == WindowingSystem::Win32, system);
RDCASSERT(window.system == WindowingSystem::Win32, window.system);
OutputWindow outw;
outw.wnd = (HWND)data;
outw.wnd = window.win32.window;
outw.dev = m_WrappedDevice;
DXGI_SWAP_CHAIN_DESC swapDesc;
+1 -1
View File
@@ -108,7 +108,7 @@ public:
D3D11DebugManager(WrappedID3D11Device *wrapper);
~D3D11DebugManager();
uint64_t MakeOutputWindow(WindowingSystem system, void *data, bool depth);
uint64_t MakeOutputWindow(WindowingData window, bool depth);
void DestroyOutputWindow(uint64_t id);
bool CheckResizeOutputWindow(uint64_t id);
void GetOutputWindowDimensions(uint64_t id, int32_t &w, int32_t &h);
+2 -2
View File
@@ -1297,9 +1297,9 @@ vector<uint32_t> D3D11Replay::GetPassEvents(uint32_t eventId)
return passEvents;
}
uint64_t D3D11Replay::MakeOutputWindow(WindowingSystem system, void *data, bool depth)
uint64_t D3D11Replay::MakeOutputWindow(WindowingData window, bool depth)
{
return m_pDevice->GetDebugManager()->MakeOutputWindow(system, data, depth);
return m_pDevice->GetDebugManager()->MakeOutputWindow(window, depth);
}
void D3D11Replay::DestroyOutputWindow(uint64_t id)
+1 -1
View File
@@ -90,7 +90,7 @@ public:
return ret;
}
uint64_t MakeOutputWindow(WindowingSystem system, void *data, bool depth);
uint64_t MakeOutputWindow(WindowingData window, bool depth);
void DestroyOutputWindow(uint64_t id);
bool CheckResizeOutputWindow(uint64_t id);
void GetOutputWindowDimensions(uint64_t id, int32_t &w, int32_t &h);
+3 -3
View File
@@ -1973,12 +1973,12 @@ void D3D12DebugManager::OutputWindow::MakeDSV()
}
}
uint64_t D3D12DebugManager::MakeOutputWindow(WindowingSystem system, void *data, bool depth)
uint64_t D3D12DebugManager::MakeOutputWindow(WindowingData window, bool depth)
{
RDCASSERT(system == WindowingSystem::Win32, system);
RDCASSERT(window.system == WindowingSystem::Win32, window.system);
OutputWindow outw;
outw.wnd = (HWND)data;
outw.wnd = window.win32.window;
outw.dev = m_WrappedDevice;
DXGI_SWAP_CHAIN_DESC swapDesc;
+1 -1
View File
@@ -41,7 +41,7 @@ public:
D3D12DebugManager(WrappedID3D12Device *wrapper);
~D3D12DebugManager();
uint64_t MakeOutputWindow(WindowingSystem system, void *data, bool depth);
uint64_t MakeOutputWindow(WindowingData window, bool depth);
void DestroyOutputWindow(uint64_t id);
bool CheckResizeOutputWindow(uint64_t id);
void GetOutputWindowDimensions(uint64_t id, int32_t &w, int32_t &h);
+2 -2
View File
@@ -1494,9 +1494,9 @@ uint32_t D3D12Replay::PickVertex(uint32_t eventId, const MeshDisplay &cfg, uint3
return m_pDevice->GetDebugManager()->PickVertex(eventId, cfg, x, y);
}
uint64_t D3D12Replay::MakeOutputWindow(WindowingSystem system, void *data, bool depth)
uint64_t D3D12Replay::MakeOutputWindow(WindowingData window, bool depth)
{
return m_pDevice->GetDebugManager()->MakeOutputWindow(system, data, depth);
return m_pDevice->GetDebugManager()->MakeOutputWindow(window, depth);
}
void D3D12Replay::DestroyOutputWindow(uint64_t id)
+1 -1
View File
@@ -88,7 +88,7 @@ public:
return ret;
}
uint64_t MakeOutputWindow(WindowingSystem system, void *data, bool depth);
uint64_t MakeOutputWindow(WindowingData window, bool depth);
void DestroyOutputWindow(uint64_t id);
bool CheckResizeOutputWindow(uint64_t id);
void GetOutputWindowDimensions(uint64_t id, int32_t &w, int32_t &h);
+1 -1
View File
@@ -196,7 +196,7 @@ struct GLPlatform
virtual void SwapBuffers(GLWindowingData context) = 0;
virtual void GetOutputWindowDimensions(GLWindowingData context, int32_t &w, int32_t &h) = 0;
virtual bool IsOutputWindowVisible(GLWindowingData context) = 0;
virtual GLWindowingData MakeOutputWindow(WindowingSystem system, void *data, bool depth,
virtual GLWindowingData MakeOutputWindow(WindowingData window, bool depth,
GLWindowingData share_context) = 0;
// for 'backwards compatible' overlay rendering
+2 -1
View File
@@ -250,7 +250,8 @@ void GLReplay::InitDebugData()
RenderDoc::Inst().SetProgress(LoadProgress::DebugManagerInit, 0.0f);
{
uint64_t id = MakeOutputWindow(WindowingSystem::Unknown, NULL, true);
WindowingData window = {WindowingSystem::Unknown};
uint64_t id = MakeOutputWindow(window, true);
m_DebugID = id;
m_DebugCtx = &m_OutputWindows[id];
+1 -2
View File
@@ -64,8 +64,7 @@ public:
RDCUNIMPLEMENTED("IsOutputWindowVisible");
return true;
}
virtual GLWindowingData MakeOutputWindow(WindowingSystem system, void *data, bool depth,
GLWindowingData share_context)
virtual GLWindowingData MakeOutputWindow(WindowingData window, GLWindowingData share_context)
{
RDCUNIMPLEMENTED("MakeOutputWindow");
return GLWindowingData();
+6 -12
View File
@@ -154,22 +154,16 @@ public:
}
bool IsOutputWindowVisible(GLWindowingData context) { return true; }
GLWindowingData MakeOutputWindow(WindowingSystem system, void *data, bool depth,
GLWindowingData share_context)
GLWindowingData MakeOutputWindow(WindowingData window, bool depth, GLWindowingData share_context)
{
EGLNativeWindowType window = 0;
EGLNativeWindowType win = 0;
switch(system)
switch(window.system)
{
#if ENABLED(RDOC_ANDROID)
case WindowingSystem::Android: window = (EGLNativeWindowType)data; break;
case WindowingSystem::Android: win = window.android.window; break;
#elif ENABLED(RDOC_LINUX)
case WindowingSystem::Xlib:
{
XlibWindowData *xlib = (XlibWindowData *)data;
window = (EGLNativeWindowType)xlib->window;
break;
}
case WindowingSystem::Xlib: win = window.xlib.window; break;
#endif
case WindowingSystem::Unknown:
// allow WindowingSystem::Unknown so that internally we can create a window-less context
@@ -180,7 +174,7 @@ public:
EGLDisplay eglDisplay = real.GetDisplay(EGL_DEFAULT_DISPLAY);
RDCASSERT(eglDisplay);
return CreateWindowingData(real, eglDisplay, share_context.ctx, window);
return CreateWindowingData(real, eglDisplay, share_context.ctx, win);
}
bool DrawQuads(float width, float height, const std::vector<Vec4f> &vertices);
+5 -8
View File
@@ -220,28 +220,25 @@ public:
return true;
}
GLWindowingData MakeOutputWindow(WindowingSystem system, void *data, bool depth,
GLWindowingData share_context)
GLWindowingData MakeOutputWindow(WindowingData window, bool depth, GLWindowingData share_context)
{
GLWindowingData ret;
Display *dpy = NULL;
Drawable draw = 0;
if(system == WindowingSystem::Xlib)
if(window.system == WindowingSystem::Xlib)
{
#if ENABLED(RDOC_XLIB)
XlibWindowData *xlib = (XlibWindowData *)data;
dpy = xlib->display;
draw = xlib->window;
dpy = window.xlib.display;
draw = window.xlib.window;
#else
RDCERR(
"Xlib windowing system data passed in, but support is not compiled in. GL must have xlib "
"support compiled in");
#endif
}
else if(system == WindowingSystem::Unknown)
else if(window.system == WindowingSystem::Unknown)
{
// allow WindowingSystem::Unknown so that internally we can create a window-less context
dpy = RenderDoc::Inst().GetGlobalEnvironment().xlibDisplay;
+4 -3
View File
@@ -698,14 +698,15 @@ public:
return (IsWindowVisible(context.wnd) == TRUE);
}
GLWindowingData GLPlatform::MakeOutputWindow(WindowingSystem system, void *data, bool depth,
GLWindowingData GLPlatform::MakeOutputWindow(WindowingData window, bool depth,
GLWindowingData share_context)
{
GLWindowingData ret;
RDCASSERT(system == WindowingSystem::Win32 || system == WindowingSystem::Unknown, system);
RDCASSERT(window.system == WindowingSystem::Win32 || window.system == WindowingSystem::Unknown,
window.system);
HWND w = (HWND)data;
HWND w = window.win32.window;
if(w == NULL)
w = CreateWindowEx(WS_EX_CLIENTEDGE, L"renderdocGLclass", L"", WS_OVERLAPPEDWINDOW,
+3 -3
View File
@@ -3266,9 +3266,9 @@ void GLReplay::CloseReplayContext()
m_pDriver->m_Platform.DeleteReplayContext(m_ReplayCtx);
}
uint64_t GLReplay::MakeOutputWindow(WindowingSystem system, void *data, bool depth)
uint64_t GLReplay::MakeOutputWindow(WindowingData window, bool depth)
{
OutputWindow win = m_pDriver->m_Platform.MakeOutputWindow(system, data, depth, m_ReplayCtx);
OutputWindow win = m_pDriver->m_Platform.MakeOutputWindow(window, depth, m_ReplayCtx);
if(!win.wnd)
return 0;
@@ -3330,7 +3330,7 @@ class GLDummyPlatform : public GLPlatform
virtual void SwapBuffers(GLWindowingData context) {}
virtual void GetOutputWindowDimensions(GLWindowingData context, int32_t &w, int32_t &h) {}
virtual bool IsOutputWindowVisible(GLWindowingData context) { return false; }
virtual GLWindowingData MakeOutputWindow(WindowingSystem system, void *data, bool depth,
virtual GLWindowingData MakeOutputWindow(WindowingData window, bool depth,
GLWindowingData share_context)
{
return GLWindowingData();
+1 -1
View File
@@ -139,7 +139,7 @@ public:
return ret;
}
uint64_t MakeOutputWindow(WindowingSystem system, void *data, bool depth);
uint64_t MakeOutputWindow(WindowingData window, bool depth);
void DestroyOutputWindow(uint64_t id);
bool CheckResizeOutputWindow(uint64_t id);
void GetOutputWindowDimensions(uint64_t id, int32_t &w, int32_t &h);
+3 -4
View File
@@ -25,11 +25,10 @@
#include "vk_core.h"
#include "vk_replay.h"
void VulkanReplay::OutputWindow::SetWindowHandle(WindowingSystem system, void *data)
void VulkanReplay::OutputWindow::SetWindowHandle(WindowingData window)
{
RDCASSERT(system == WindowingSystem::Android, system);
wnd = (ANativeWindow *)data;
m_WindowSystem = system;
RDCASSERT(window.system == WindowingSystem::Android, window.system);
wnd = window.android.window;
}
void VulkanReplay::OutputWindow::CreateSurface(VkInstance inst)
+1 -2
View File
@@ -25,10 +25,9 @@
#include "vk_core.h"
#include "vk_replay.h"
void VulkanReplay::OutputWindow::SetWindowHandle(WindowingSystem system, void *data)
void VulkanReplay::OutputWindow::SetWindowHandle(WindowingData window)
{
RDCUNIMPLEMENTED("SetWindowHandle");
m_WindowSystem = system;
}
void VulkanReplay::OutputWindow::CreateSurface(VkInstance inst)
+8 -12
View File
@@ -33,31 +33,27 @@
#include "vk_core.h"
#include "vk_replay.h"
void VulkanReplay::OutputWindow::SetWindowHandle(WindowingSystem system, void *data)
void VulkanReplay::OutputWindow::SetWindowHandle(WindowingData window)
{
m_WindowSystem = system;
#if ENABLED(RDOC_XLIB)
if(system == WindowingSystem::Xlib)
if(window.system == WindowingSystem::Xlib)
{
XlibWindowData *xdata = (XlibWindowData *)data;
xlib.display = xdata->display;
xlib.window = xdata->window;
xlib.display = window.xlib.display;
xlib.window = window.xlib.window;
return;
}
#endif
#if ENABLED(RDOC_XCB)
if(system == WindowingSystem::XCB)
if(window.system == WindowingSystem::XCB)
{
XCBWindowData *xdata = (XCBWindowData *)data;
xcb.connection = xdata->connection;
xcb.window = xdata->window;
xcb.connection = window.xcb.connection;
xcb.window = window.xcb.window;
return;
}
#endif
RDCERR("Unrecognised/unsupported window system %d", system);
RDCERR("Unrecognised/unsupported window system %d", window.system);
}
void VulkanReplay::OutputWindow::CreateSurface(VkInstance inst)
+4 -3
View File
@@ -2893,15 +2893,16 @@ vector<WindowingSystem> VulkanReplay::GetSupportedWindowSystems()
return m_pDriver->m_SupportedWindowSystems;
}
uint64_t VulkanReplay::MakeOutputWindow(WindowingSystem system, void *data, bool depth)
uint64_t VulkanReplay::MakeOutputWindow(WindowingData window, bool depth)
{
uint64_t id = m_OutputWinID;
m_OutputWinID++;
m_OutputWindows[id].SetWindowHandle(system, data);
m_OutputWindows[id].m_WindowSystem = window.system;
m_OutputWindows[id].SetWindowHandle(window);
m_OutputWindows[id].m_ResourceManager = GetResourceManager();
if(system != WindowingSystem::Unknown)
if(window.system != WindowingSystem::Unknown)
{
int32_t w, h;
GetOutputWindowDimensions(id, w, h);
+2 -2
View File
@@ -171,7 +171,7 @@ public:
vector<WindowingSystem> GetSupportedWindowSystems();
uint64_t MakeOutputWindow(WindowingSystem system, void *data, bool depth);
uint64_t MakeOutputWindow(WindowingData window, bool depth);
void DestroyOutputWindow(uint64_t id);
bool CheckResizeOutputWindow(uint64_t id);
void GetOutputWindowDimensions(uint64_t id, int32_t &w, int32_t &h);
@@ -287,7 +287,7 @@ private:
// implemented in vk_replay_platform.cpp
void CreateSurface(VkInstance inst);
void SetWindowHandle(WindowingSystem system, void *data);
void SetWindowHandle(WindowingData window);
WindowingSystem m_WindowSystem;
+3 -4
View File
@@ -27,11 +27,10 @@
static int dllLocator = 0;
void VulkanReplay::OutputWindow::SetWindowHandle(WindowingSystem system, void *data)
void VulkanReplay::OutputWindow::SetWindowHandle(WindowingData window)
{
RDCASSERT(system == WindowingSystem::Win32, system);
wnd = (HWND)data;
m_WindowSystem = system;
RDCASSERT(window.system == WindowingSystem::Win32, window.system);
wnd = window.win32.window;
}
void VulkanReplay::OutputWindow::CreateSurface(VkInstance inst)
+4 -4
View File
@@ -1393,9 +1393,9 @@ rdcarray<WindowingSystem> ReplayController::GetSupportedWindowSystems()
return m_pDevice->GetSupportedWindowSystems();
}
void ReplayController::ReplayLoop(WindowingSystem system, void *data, ResourceId texid)
void ReplayController::ReplayLoop(WindowingData window, ResourceId texid)
{
ReplayOutput *output = CreateOutput(system, data, ReplayOutputType::Texture);
ReplayOutput *output = CreateOutput(window, ReplayOutputType::Texture);
TextureDisplay d;
d.resourceId = texid;
@@ -1445,9 +1445,9 @@ void ReplayController::CancelReplayLoop()
Threading::Sleep(1);
}
ReplayOutput *ReplayController::CreateOutput(WindowingSystem system, void *data, ReplayOutputType type)
ReplayOutput *ReplayController::CreateOutput(WindowingData window, ReplayOutputType type)
{
ReplayOutput *out = new ReplayOutput(this, system, data, type);
ReplayOutput *out = new ReplayOutput(this, window, type);
m_Outputs.push_back(out);
+5 -5
View File
@@ -42,12 +42,12 @@ public:
void SetMeshDisplay(const MeshDisplay &o);
void ClearThumbnails();
bool AddThumbnail(WindowingSystem system, void *data, ResourceId texID, CompType typeHint);
bool AddThumbnail(WindowingData window, ResourceId texID, CompType typeHint);
void Display();
ReplayOutputType GetType() { return m_Type; }
bool SetPixelContext(WindowingSystem system, void *data);
bool SetPixelContext(WindowingData window);
void SetPixelContextLocation(uint32_t x, uint32_t y);
void DisablePixelContext();
@@ -61,7 +61,7 @@ public:
rdcpair<uint32_t, uint32_t> PickVertex(uint32_t eventId, uint32_t x, uint32_t y);
private:
ReplayOutput(ReplayController *parent, WindowingSystem system, void *data, ReplayOutputType type);
ReplayOutput(ReplayController *parent, WindowingData window, ReplayOutputType type);
virtual ~ReplayOutput();
void SetFrameEvent(int eventId);
@@ -193,10 +193,10 @@ public:
rdcarray<WindowingSystem> GetSupportedWindowSystems();
void ReplayLoop(WindowingSystem system, void *data, ResourceId texid);
void ReplayLoop(WindowingData window, ResourceId texid);
void CancelReplayLoop();
ReplayOutput *CreateOutput(WindowingSystem, void *data, ReplayOutputType type);
ReplayOutput *CreateOutput(WindowingData window, ReplayOutputType type);
void ShutdownOutput(IReplayOutput *output);
void Shutdown();
+1 -1
View File
@@ -174,7 +174,7 @@ public:
virtual vector<WindowingSystem> GetSupportedWindowSystems() = 0;
virtual uint64_t MakeOutputWindow(WindowingSystem system, void *data, bool depth) = 0;
virtual uint64_t MakeOutputWindow(WindowingData window, bool depth) = 0;
virtual void DestroyOutputWindow(uint64_t id) = 0;
virtual bool CheckResizeOutputWindow(uint64_t id) = 0;
virtual void GetOutputWindowDimensions(uint64_t id, int32_t &w, int32_t &h) = 0;
+19 -21
View File
@@ -28,23 +28,23 @@
#include "strings/string_utils.h"
#include "replay_controller.h"
static uint64_t GetHandle(WindowingSystem system, void *data)
static uint64_t GetHandle(WindowingData window)
{
#if ENABLED(RDOC_LINUX)
if(system == WindowingSystem::Xlib)
if(window.system == WindowingSystem::Xlib)
{
#if ENABLED(RDOC_XLIB)
return (uint64_t)((XlibWindowData *)data)->window;
return (uint64_t)window.xlib.window;
#else
RDCERR("Xlib windowing system data passed in, but support is not compiled in");
#endif
}
if(system == WindowingSystem::XCB)
if(window.system == WindowingSystem::XCB)
{
#if ENABLED(RDOC_XCB)
return (uint64_t)((XCBWindowData *)data)->window;
return (uint64_t)window.xcb.window;
#else
RDCERR("XCB windowing system data passed in, but support is not compiled in");
#endif
@@ -56,21 +56,20 @@ static uint64_t GetHandle(WindowingSystem system, void *data)
#elif ENABLED(RDOC_WIN32)
RDCASSERT(system == WindowingSystem::Win32);
return (uint64_t)data; // HWND
RDCASSERT(window.system == WindowingSystem::Win32);
return (uint64_t)window.win32.window; // HWND
#elif ENABLED(RDOC_ANDROID)
RDCASSERT(system == WindowingSystem::Android);
return (uint64_t)data; // ANativeWindow *
RDCASSERT(window.system == WindowingSystem::Android);
return (uint64_t)window.android.window; // ANativeWindow *
#else
RDCFATAL("No windowing data defined for this platform! Must be implemented for replay outputs");
#endif
}
ReplayOutput::ReplayOutput(ReplayController *parent, WindowingSystem system, void *data,
ReplayOutputType type)
ReplayOutput::ReplayOutput(ReplayController *parent, WindowingData window, ReplayOutputType type)
{
m_pRenderer = parent;
@@ -96,8 +95,8 @@ ReplayOutput::ReplayOutput(ReplayController *parent, WindowingSystem system, voi
m_Type = type;
if(system != WindowingSystem::Unknown)
m_MainOutput.outputID = m_pDevice->MakeOutputWindow(system, data, type == ReplayOutputType::Mesh);
if(window.system != WindowingSystem::Unknown)
m_MainOutput.outputID = m_pDevice->MakeOutputWindow(window, type == ReplayOutputType::Mesh);
else
m_MainOutput.outputID = 0;
m_MainOutput.texture = ResourceId();
@@ -226,9 +225,9 @@ void ReplayOutput::ClearThumbnails()
m_Thumbnails.clear();
}
bool ReplayOutput::SetPixelContext(WindowingSystem system, void *data)
bool ReplayOutput::SetPixelContext(WindowingData window)
{
m_PixelContext.outputID = m_pDevice->MakeOutputWindow(system, data, false);
m_PixelContext.outputID = m_pDevice->MakeOutputWindow(window, false);
m_PixelContext.texture = ResourceId();
m_PixelContext.depthMode = false;
@@ -237,12 +236,11 @@ bool ReplayOutput::SetPixelContext(WindowingSystem system, void *data)
return m_PixelContext.outputID != 0;
}
bool ReplayOutput::AddThumbnail(WindowingSystem system, void *data, ResourceId texID,
CompType typeHint)
bool ReplayOutput::AddThumbnail(WindowingData window, ResourceId texID, CompType typeHint)
{
OutputPair p;
RDCASSERT(data);
RDCASSERT(window.system != WindowingSystem::Unknown);
bool depthMode = false;
@@ -258,7 +256,7 @@ bool ReplayOutput::AddThumbnail(WindowingSystem system, void *data, ResourceId t
for(size_t i = 0; i < m_Thumbnails.size(); i++)
{
if(m_Thumbnails[i].wndHandle == GetHandle(system, data))
if(m_Thumbnails[i].wndHandle == GetHandle(window))
{
m_Thumbnails[i].texture = texID;
@@ -272,8 +270,8 @@ bool ReplayOutput::AddThumbnail(WindowingSystem system, void *data, ResourceId t
}
}
p.wndHandle = GetHandle(system, data);
p.outputID = m_pDevice->MakeOutputWindow(system, data, false);
p.wndHandle = GetHandle(window);
p.outputID = m_pDevice->MakeOutputWindow(window, false);
p.texture = texID;
p.depthMode = depthMode;
p.typeHint = typeHint;
+1 -1
View File
@@ -64,7 +64,7 @@ void DisplayRendererPreview(IReplayController *renderer, TextureDisplay &display
pthread_mutex_lock(&m_DrawLock.lock);
IReplayOutput *out = renderer->CreateOutput(WindowingSystem::Android, connectionScreenWindow,
IReplayOutput *out = renderer->CreateOutput(CreateAndroidWindowingData(connectionScreenWindow),
ReplayOutputType::Texture);
out->SetTextureDisplay(displayCfg);
+4 -10
View File
@@ -282,19 +282,13 @@ void DisplayRendererPreview(IReplayController *renderer, TextureDisplay &display
// prefer xcb
if(xcb)
{
XCBWindowData windowData;
windowData.connection = connection;
windowData.window = window;
out = renderer->CreateOutput(WindowingSystem::XCB, &windowData, ReplayOutputType::Texture);
out = renderer->CreateOutput(CreateXCBWindowingData(connection, window),
ReplayOutputType::Texture);
}
else if(xlib)
{
XlibWindowData windowData;
windowData.display = display;
windowData.window = (Drawable)window; // safe to cast types
out = renderer->CreateOutput(WindowingSystem::Xlib, &windowData, ReplayOutputType::Texture);
out = renderer->CreateOutput(CreateXlibWindowingData(display, (Drawable)window),
ReplayOutputType::Texture);
}
else
{
+2 -1
View File
@@ -144,7 +144,8 @@ void DisplayRendererPreview(IReplayController *renderer, TextureDisplay &display
ShowWindow(wnd, SW_SHOW);
UpdateWindow(wnd);
IReplayOutput *out = renderer->CreateOutput(WindowingSystem::Win32, wnd, ReplayOutputType::Texture);
IReplayOutput *out =
renderer->CreateOutput(CreateWin32WindowingData(wnd), ReplayOutputType::Texture);
out->SetTextureDisplay(displayCfg);