diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7c2038eaa..4f89276c9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -45,7 +45,13 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${warning_flags}")
endif()
-add_definitions(-DRENDERDOC_PLATFORM_LINUX)
+add_definitions(-DRENDERDOC_PLATFORM_POSIX)
+
+if(ANDROID)
+ add_definitions(-DRENDERDOC_PLATFORM_ANDROID)
+elseif(UNIX)
+ add_definitions(-DRENDERDOC_PLATFORM_LINUX)
+endif()
add_subdirectory(renderdoc)
diff --git a/qrenderdoc/qrenderdoc.pro b/qrenderdoc/qrenderdoc.pro
index afed48853..b2aaf2a2a 100644
--- a/qrenderdoc/qrenderdoc.pro
+++ b/qrenderdoc/qrenderdoc.pro
@@ -58,7 +58,7 @@ win32 {
QMAKE_CXXFLAGS += -std=c++11 -Wno-unused-parameter -Wno-reorder
QT += x11extras
- DEFINES += RENDERDOC_PLATFORM_LINUX
+ DEFINES += RENDERDOC_PLATFORM_POSIX RENDERDOC_PLATFORM_LINUX
}
SOURCES += Code/main.cpp \
diff --git a/renderdoc/CMakeLists.txt b/renderdoc/CMakeLists.txt
index b3d267373..31465a73c 100644
--- a/renderdoc/CMakeLists.txt
+++ b/renderdoc/CMakeLists.txt
@@ -126,20 +126,36 @@ set(sources
3rdparty/tinyexr/tinyexr.cpp
3rdparty/tinyexr/tinyexr.h)
-if(UNIX)
+if(ANDROID)
list(APPEND sources
data/embedded_files.h
- os/linux/linux_callstack.cpp
- os/linux/linux_hook.cpp
- os/linux/linux_hook.h
- os/linux/linux_network.cpp
- os/linux/linux_process.cpp
- os/linux/linux_stringio.cpp
- os/linux/linux_threading.cpp
- os/linux/linux_specific.h)
- # linux_libentry must be the last so that library_loaded is called after
+ os/posix/android/android_stringio.cpp
+ os/posix/android/android_callstack.cpp
+ os/posix/posix_hook.cpp
+ os/posix/posix_hook.h
+ os/posix/posix_network.cpp
+ os/posix/posix_process.cpp
+ os/posix/posix_stringio.cpp
+ os/posix/posix_threading.cpp
+ os/posix/posix_specific.h)
+ # posix_libentry must be the last so that library_loaded is called after
# static objects are constructed.
- list(APPEND sources os/linux/linux_libentry.cpp)
+ list(APPEND sources os/posix/posix_libentry.cpp)
+elseif(UNIX)
+ list(APPEND sources
+ data/embedded_files.h
+ os/posix/linux/linux_stringio.cpp
+ os/posix/linux/linux_callstack.cpp
+ os/posix/posix_hook.cpp
+ os/posix/posix_hook.h
+ os/posix/posix_network.cpp
+ os/posix/posix_process.cpp
+ os/posix/posix_stringio.cpp
+ os/posix/posix_threading.cpp
+ os/posix/posix_specific.h)
+ # posix_libentry must be the last so that library_loaded is called after
+ # static objects are constructed.
+ list(APPEND sources os/posix/posix_libentry.cpp)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
diff --git a/renderdoc/api/replay/renderdoc_replay.h b/renderdoc/api/replay/renderdoc_replay.h
index 7d96c5c5c..59eca8205 100644
--- a/renderdoc/api/replay/renderdoc_replay.h
+++ b/renderdoc/api/replay/renderdoc_replay.h
@@ -40,7 +40,7 @@ typedef uint32_t bool32;
#endif
#define RENDERDOC_CC __cdecl
-#elif defined(RENDERDOC_PLATFORM_LINUX)
+#elif defined(RENDERDOC_PLATFORM_POSIX)
#ifdef RENDERDOC_EXPORTS
#define RENDERDOC_API __attribute__ ((visibility ("default")))
diff --git a/renderdoc/driver/gl/gl_common.h b/renderdoc/driver/gl/gl_common.h
index 9352aa2d7..0c9b71b19 100644
--- a/renderdoc/driver/gl/gl_common.h
+++ b/renderdoc/driver/gl/gl_common.h
@@ -47,7 +47,7 @@ struct GLWindowingData
HWND wnd;
};
-#elif defined(RENDERDOC_PLATFORM_LINUX)
+#elif defined(RENDERDOC_PLATFORM_POSIX)
// cheeky way to prevent GL/gl.h from being included, as we want to use
// glcorearb.h from above
#define __gl_h_
diff --git a/renderdoc/driver/vulkan/CMakeLists.txt b/renderdoc/driver/vulkan/CMakeLists.txt
index 463aae96b..8a3d7bcc7 100644
--- a/renderdoc/driver/vulkan/CMakeLists.txt
+++ b/renderdoc/driver/vulkan/CMakeLists.txt
@@ -41,10 +41,10 @@ set(sources
set(definitions ${RDOC_DEFINITIONS})
if(ANDROID)
- list(APPEND sources vk_linux.cpp)
+ list(APPEND sources vk_posix.cpp vk_android.cpp)
list(APPEND definitions PRIVATE -DVK_USE_PLATFORM_ANDROID_KHR)
elseif(UNIX)
- list(APPEND sources vk_linux.cpp)
+ list(APPEND sources vk_posix.cpp vk_linux.cpp)
list(APPEND definitions
PRIVATE -DVK_USE_PLATFORM_XCB_KHR
diff --git a/renderdoc/driver/vulkan/renderdoc_vulkan.vcxproj b/renderdoc/driver/vulkan/renderdoc_vulkan.vcxproj
index 9b82c90f0..68e01d19f 100644
--- a/renderdoc/driver/vulkan/renderdoc_vulkan.vcxproj
+++ b/renderdoc/driver/vulkan/renderdoc_vulkan.vcxproj
@@ -32,9 +32,15 @@
+
+ true
+
true
+
+ true
+
@@ -224,4 +230,4 @@
-
\ No newline at end of file
+
diff --git a/renderdoc/driver/vulkan/renderdoc_vulkan.vcxproj.filters b/renderdoc/driver/vulkan/renderdoc_vulkan.vcxproj.filters
index 893212b53..39342e89b 100644
--- a/renderdoc/driver/vulkan/renderdoc_vulkan.vcxproj.filters
+++ b/renderdoc/driver/vulkan/renderdoc_vulkan.vcxproj.filters
@@ -4,9 +4,6 @@
OS\Win32
-
- OS\Linux
-
Replay
@@ -82,6 +79,15 @@
Replay
+
+ OS\Posix
+
+
+ OS\Posix
+
+
+ OS\Posix
+
@@ -128,9 +134,6 @@
{0ca21de2-97db-4118-afc5-32b4cd80a437}
-
- {c6141a90-0765-4409-afe2-e59d683e5a5e}
-
{538183db-17ae-4e49-87d6-b8dc88bda2d3}
@@ -152,6 +155,9 @@
{9580e52e-f3ab-4ef9-80d1-c673e5f25ef7}
+
+ {c6141a90-0765-4409-afe2-e59d683e5a5e}
+
diff --git a/renderdoc/driver/vulkan/vk_android.cpp b/renderdoc/driver/vulkan/vk_android.cpp
new file mode 100644
index 000000000..330a9172f
--- /dev/null
+++ b/renderdoc/driver/vulkan/vk_android.cpp
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Baldur Karlsson
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ ******************************************************************************/
+
+#include "vk_replay.h"
+#include "vk_core.h"
+
+void VulkanReplay::OutputWindow::SetWindowHandle(void *wn)
+{
+ wnd = (ANativeWindow*) wn;
+}
+
+void VulkanReplay::OutputWindow::CreateSurface(VkInstance inst)
+{
+ VkAndroidSurfaceCreateInfoKHR createInfo;
+
+ createInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
+ createInfo.pNext = NULL;
+ createInfo.flags = 0;
+ createInfo.window = wnd;
+
+ VkResult vkr = ObjDisp(inst)->CreateAndroidSurfaceKHR(Unwrap(inst), &createInfo, NULL, &surface);
+ RDCASSERTEQUAL(vkr, VK_SUCCESS);
+}
+
+void VulkanReplay::GetOutputWindowDimensions(uint64_t id, int32_t &w, int32_t &h)
+{
+}
diff --git a/renderdoc/driver/vulkan/vk_linux.cpp b/renderdoc/driver/vulkan/vk_linux.cpp
index e0f6dd6ee..efde758a7 100644
--- a/renderdoc/driver/vulkan/vk_linux.cpp
+++ b/renderdoc/driver/vulkan/vk_linux.cpp
@@ -1,7 +1,7 @@
/******************************************************************************
* The MIT License (MIT)
*
- * Copyright (c) 2015-2016 Baldur Karlsson
+ * Copyright (c) 2016 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,17 +25,8 @@
#include "vk_replay.h"
#include "vk_core.h"
-struct xcb_connection_t;
-namespace Keyboard
-{
- void UseConnection(xcb_connection_t *conn);
-}
-
void VulkanReplay::OutputWindow::SetWindowHandle(void *wn)
{
-#ifdef ANDROID
- wnd = (ANativeWindow*) wn;
-#else
void **connectionScreenWindow = (void **)wn;
connection = (xcb_connection_t *)connectionScreenWindow[0];
@@ -47,22 +38,10 @@ void VulkanReplay::OutputWindow::SetWindowHandle(void *wn)
while (scr-- > 0) xcb_screen_next(&iter);
screen = iter.data;
-#endif
}
void VulkanReplay::OutputWindow::CreateSurface(VkInstance inst)
{
-#ifdef ANDROID
- VkAndroidSurfaceCreateInfoKHR createInfo;
-
- createInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
- createInfo.pNext = NULL;
- createInfo.flags = 0;
- createInfo.window = wnd;
-
- VkResult vkr = ObjDisp(inst)->CreateAndroidSurfaceKHR(Unwrap(inst), &createInfo, NULL, &surface);
- RDCASSERTEQUAL(vkr, VK_SUCCESS);
-#else
VkXcbSurfaceCreateInfoKHR createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
@@ -73,13 +52,10 @@ void VulkanReplay::OutputWindow::CreateSurface(VkInstance inst)
VkResult vkr = ObjDisp(inst)->CreateXcbSurfaceKHR(Unwrap(inst), &createInfo, NULL, &surface);
RDCASSERTEQUAL(vkr, VK_SUCCESS);
-#endif
}
void VulkanReplay::GetOutputWindowDimensions(uint64_t id, int32_t &w, int32_t &h)
{
-#ifdef ANDROID
-#else
if(id == 0 || m_OutputWindows.find(id) == m_OutputWindows.end())
return;
@@ -92,149 +68,4 @@ void VulkanReplay::GetOutputWindowDimensions(uint64_t id, int32_t &w, int32_t &h
h = (int32_t)geom->height;
free(geom);
-#endif
}
-
-bool VulkanReplay::IsOutputWindowVisible(uint64_t id)
-{
- if(id == 0 || m_OutputWindows.find(id) == m_OutputWindows.end())
- return false;
-
- VULKANNOTIMP("Optimisation missing - output window always returning true");
-
- return true;
-}
-
-void WrappedVulkan::AddRequiredExtensions(bool instance, vector &extensionList)
-{
- bool device = !instance;
-
- // TODO should check if these are present..
-
- if(instance)
- {
- extensionList.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
-
-#if defined(VK_USE_PLATFORM_XCB_KHR)
- extensionList.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME);
-#endif
-
-#if defined(VK_USE_PLATFORM_XLIB_KHR)
- extensionList.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
-#endif
- }
- else if(device)
- {
- extensionList.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
- }
-}
-
-#if defined(VK_USE_PLATFORM_XCB_KHR)
-
-VkBool32 WrappedVulkan::vkGetPhysicalDeviceXcbPresentationSupportKHR(
- VkPhysicalDevice physicalDevice,
- uint32_t queueFamilyIndex,
- xcb_connection_t* connection,
- xcb_visualid_t visual_id)
-{
- return ObjDisp(physicalDevice)->GetPhysicalDeviceXcbPresentationSupportKHR(Unwrap(physicalDevice), queueFamilyIndex, connection, visual_id);
-}
-
-VkResult WrappedVulkan::vkCreateXcbSurfaceKHR(
- VkInstance instance,
- const VkXcbSurfaceCreateInfoKHR* pCreateInfo,
- const VkAllocationCallbacks* pAllocator,
- VkSurfaceKHR* pSurface)
-{
- // should not come in here at all on replay
- RDCASSERT(m_State >= WRITING);
-
- VkResult ret = ObjDisp(instance)->CreateXcbSurfaceKHR(Unwrap(instance), pCreateInfo, pAllocator, pSurface);
-
- if(ret == VK_SUCCESS)
- {
- GetResourceManager()->WrapResource(Unwrap(instance), *pSurface);
-
- WrappedVkSurfaceKHR *wrapped = GetWrapped(*pSurface);
-
- // since there's no point in allocating a full resource record and storing the window
- // handle under there somewhere, we just cast. We won't use the resource record for anything
- wrapped->record = (VkResourceRecord *)(uintptr_t)pCreateInfo->window;
-
- Keyboard::UseConnection(pCreateInfo->connection);
- }
-
- return ret;
-}
-
-#endif
-
-#if defined(VK_USE_PLATFORM_XLIB_KHR)
-
-VkBool32 WrappedVulkan::vkGetPhysicalDeviceXlibPresentationSupportKHR(
- VkPhysicalDevice physicalDevice,
- uint32_t queueFamilyIndex,
- Display* dpy,
- VisualID visualID)
-{
- return ObjDisp(physicalDevice)->GetPhysicalDeviceXlibPresentationSupportKHR(Unwrap(physicalDevice), queueFamilyIndex, dpy, visualID);
-}
-
-VkResult WrappedVulkan::vkCreateXlibSurfaceKHR(
- VkInstance instance,
- const VkXlibSurfaceCreateInfoKHR* pCreateInfo,
- const VkAllocationCallbacks* pAllocator,
- VkSurfaceKHR* pSurface)
-{
- // should not come in here at all on replay
- RDCASSERT(m_State >= WRITING);
-
- VkResult ret = ObjDisp(instance)->CreateXlibSurfaceKHR(Unwrap(instance), pCreateInfo, pAllocator, pSurface);
-
- if(ret == VK_SUCCESS)
- {
- GetResourceManager()->WrapResource(Unwrap(instance), *pSurface);
-
- WrappedVkSurfaceKHR *wrapped = GetWrapped(*pSurface);
-
- // since there's no point in allocating a full resource record and storing the window
- // handle under there somewhere, we just cast. We won't use the resource record for anything
- wrapped->record = (VkResourceRecord *)pCreateInfo->window;
-
- // VKTODOLOW Should support Xlib here
- //Keyboard::UseConnection(pCreateInfo->dpy);
- }
-
- return ret;
-}
-
-#endif
-
-#if defined(VK_USE_PLATFORM_ANDROID_KHR)
-VkResult WrappedVulkan::vkCreateAndroidSurfaceKHR(
- VkInstance instance,
- const VkAndroidSurfaceCreateInfoKHR* pCreateInfo,
- const VkAllocationCallbacks* pAllocator,
- VkSurfaceKHR* pSurface)
-{
- // should not come in here at all on replay
- RDCASSERT(m_State >= WRITING);
-
- VkResult ret = ObjDisp(instance)->CreateAndroidSurfaceKHR(Unwrap(instance), pCreateInfo, pAllocator, pSurface);
-
- if(ret == VK_SUCCESS)
- {
- GetResourceManager()->WrapResource(Unwrap(instance), *pSurface);
-
- WrappedVkSurfaceKHR *wrapped = GetWrapped(*pSurface);
-
- // since there's no point in allocating a full resource record and storing the window
- // handle under there somewhere, we just cast. We won't use the resource record for anything
- wrapped->record = (VkResourceRecord *)(uintptr_t)pCreateInfo->window;
- }
-
- return ret;
-}
-#endif
-
-const char *VulkanLibraryName = "libvulkan.so";
diff --git a/renderdoc/driver/vulkan/vk_posix.cpp b/renderdoc/driver/vulkan/vk_posix.cpp
new file mode 100644
index 000000000..b91a69bb8
--- /dev/null
+++ b/renderdoc/driver/vulkan/vk_posix.cpp
@@ -0,0 +1,176 @@
+/******************************************************************************
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Baldur Karlsson
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ ******************************************************************************/
+
+#include "vk_replay.h"
+#include "vk_core.h"
+
+bool VulkanReplay::IsOutputWindowVisible(uint64_t id)
+{
+ if(id == 0 || m_OutputWindows.find(id) == m_OutputWindows.end())
+ return false;
+
+ VULKANNOTIMP("Optimisation missing - output window always returning true");
+
+ return true;
+}
+
+void WrappedVulkan::AddRequiredExtensions(bool instance, vector &extensionList)
+{
+ bool device = !instance;
+
+ // TODO should check if these are present..
+
+ if(instance)
+ {
+ extensionList.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
+
+#if defined(VK_USE_PLATFORM_XCB_KHR)
+ extensionList.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME);
+#endif
+
+#if defined(VK_USE_PLATFORM_XLIB_KHR)
+ extensionList.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
+#endif
+ }
+ else if(device)
+ {
+ extensionList.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
+ }
+}
+
+#if defined(VK_USE_PLATFORM_XCB_KHR)
+
+VkBool32 WrappedVulkan::vkGetPhysicalDeviceXcbPresentationSupportKHR(
+ VkPhysicalDevice physicalDevice,
+ uint32_t queueFamilyIndex,
+ xcb_connection_t* connection,
+ xcb_visualid_t visual_id)
+{
+ return ObjDisp(physicalDevice)->GetPhysicalDeviceXcbPresentationSupportKHR(Unwrap(physicalDevice), queueFamilyIndex, connection, visual_id);
+}
+
+struct xcb_connection_t;
+namespace Keyboard
+{
+ void UseConnection(xcb_connection_t *conn);
+}
+
+VkResult WrappedVulkan::vkCreateXcbSurfaceKHR(
+ VkInstance instance,
+ const VkXcbSurfaceCreateInfoKHR* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkSurfaceKHR* pSurface)
+{
+ // should not come in here at all on replay
+ RDCASSERT(m_State >= WRITING);
+
+ VkResult ret = ObjDisp(instance)->CreateXcbSurfaceKHR(Unwrap(instance), pCreateInfo, pAllocator, pSurface);
+
+ if(ret == VK_SUCCESS)
+ {
+ GetResourceManager()->WrapResource(Unwrap(instance), *pSurface);
+
+ WrappedVkSurfaceKHR *wrapped = GetWrapped(*pSurface);
+
+ // since there's no point in allocating a full resource record and storing the window
+ // handle under there somewhere, we just cast. We won't use the resource record for anything
+ wrapped->record = (VkResourceRecord *)(uintptr_t)pCreateInfo->window;
+
+ Keyboard::UseConnection(pCreateInfo->connection);
+ }
+
+ return ret;
+}
+
+#endif
+
+#if defined(VK_USE_PLATFORM_XLIB_KHR)
+
+VkBool32 WrappedVulkan::vkGetPhysicalDeviceXlibPresentationSupportKHR(
+ VkPhysicalDevice physicalDevice,
+ uint32_t queueFamilyIndex,
+ Display* dpy,
+ VisualID visualID)
+{
+ return ObjDisp(physicalDevice)->GetPhysicalDeviceXlibPresentationSupportKHR(Unwrap(physicalDevice), queueFamilyIndex, dpy, visualID);
+}
+
+VkResult WrappedVulkan::vkCreateXlibSurfaceKHR(
+ VkInstance instance,
+ const VkXlibSurfaceCreateInfoKHR* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkSurfaceKHR* pSurface)
+{
+ // should not come in here at all on replay
+ RDCASSERT(m_State >= WRITING);
+
+ VkResult ret = ObjDisp(instance)->CreateXlibSurfaceKHR(Unwrap(instance), pCreateInfo, pAllocator, pSurface);
+
+ if(ret == VK_SUCCESS)
+ {
+ GetResourceManager()->WrapResource(Unwrap(instance), *pSurface);
+
+ WrappedVkSurfaceKHR *wrapped = GetWrapped(*pSurface);
+
+ // since there's no point in allocating a full resource record and storing the window
+ // handle under there somewhere, we just cast. We won't use the resource record for anything
+ wrapped->record = (VkResourceRecord *)pCreateInfo->window;
+
+ // VKTODOLOW Should support Xlib here
+ //Keyboard::UseConnection(pCreateInfo->dpy);
+ }
+
+ return ret;
+}
+
+#endif
+
+#if defined(VK_USE_PLATFORM_ANDROID_KHR)
+VkResult WrappedVulkan::vkCreateAndroidSurfaceKHR(
+ VkInstance instance,
+ const VkAndroidSurfaceCreateInfoKHR* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkSurfaceKHR* pSurface)
+{
+ // should not come in here at all on replay
+ RDCASSERT(m_State >= WRITING);
+
+ VkResult ret = ObjDisp(instance)->CreateAndroidSurfaceKHR(Unwrap(instance), pCreateInfo, pAllocator, pSurface);
+
+ if(ret == VK_SUCCESS)
+ {
+ GetResourceManager()->WrapResource(Unwrap(instance), *pSurface);
+
+ WrappedVkSurfaceKHR *wrapped = GetWrapped(*pSurface);
+
+ // since there's no point in allocating a full resource record and storing the window
+ // handle under there somewhere, we just cast. We won't use the resource record for anything
+ wrapped->record = (VkResourceRecord *)(uintptr_t)pCreateInfo->window;
+ }
+
+ return ret;
+}
+#endif
+
+const char *VulkanLibraryName = "libvulkan.so";
diff --git a/renderdoc/driver/vulkan/vk_replay.h b/renderdoc/driver/vulkan/vk_replay.h
index 3c6268ed0..4f4e29d12 100644
--- a/renderdoc/driver/vulkan/vk_replay.h
+++ b/renderdoc/driver/vulkan/vk_replay.h
@@ -36,7 +36,7 @@
#define WINDOW_HANDLE_DECL HWND wnd;
#define NULL_WND_HANDLE NULL
-#elif defined(ANDROID)
+#elif defined(RENDERDOC_PLATFORM_ANDROID)
#define WINDOW_HANDLE_DECL ANativeWindow *wnd;
#define NULL_WND_HANDLE NULL
diff --git a/renderdoc/hooks/hooks.h b/renderdoc/hooks/hooks.h
index c2dd0c329..1315826c8 100644
--- a/renderdoc/hooks/hooks.h
+++ b/renderdoc/hooks/hooks.h
@@ -75,9 +75,9 @@ class Hook
#define HOOKS_END() Win32_IAT_EndHooks()
#define HOOKS_REMOVE() Win32_IAT_RemoveHooks()
-#elif defined(LINUX)
+#elif defined(RENDERDOC_PLATFORM_POSIX)
-#include "os/linux/linux_hook.h"
+#include "os/posix/posix_hook.h"
// just need this for dlsym
#include
diff --git a/renderdoc/os/os_specific.h b/renderdoc/os/os_specific.h
index a6bc324b7..bc4f6c5b0 100644
--- a/renderdoc/os/os_specific.h
+++ b/renderdoc/os/os_specific.h
@@ -330,8 +330,8 @@ namespace Bits
#if defined(RENDERDOC_PLATFORM_WIN32)
#include "win32/win32_specific.h"
-#elif defined(RENDERDOC_PLATFORM_LINUX)
-#include "linux/linux_specific.h"
+#elif defined(RENDERDOC_PLATFORM_POSIX)
+#include "posix/posix_specific.h"
#else
#error Undefined Platform!
#endif
diff --git a/renderdoc/os/posix/android/android_callstack.cpp b/renderdoc/os/posix/android/android_callstack.cpp
new file mode 100644
index 000000000..55d35ad37
--- /dev/null
+++ b/renderdoc/os/posix/android/android_callstack.cpp
@@ -0,0 +1,106 @@
+/******************************************************************************
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Baldur Karlsson
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ ******************************************************************************/
+
+#include "os/os_specific.h"
+
+class AndroidCallstack : public Callstack::Stackwalk
+{
+ public:
+ AndroidCallstack()
+ {
+ RDCEraseEl(addrs);
+ numLevels = 0;
+ }
+ AndroidCallstack(uint64_t *calls, size_t num)
+ {
+ Set(calls, num);
+ }
+ ~AndroidCallstack() {}
+
+ void Set(uint64_t *calls, size_t num)
+ {
+ numLevels = num;
+ for(int i=0; i < numLevels; i++)
+ addrs[i] = calls[i];
+ }
+
+ size_t NumLevels() const { return 0; }
+ const uint64_t *GetAddrs() const { return addrs; }
+ private:
+ AndroidCallstack(const Callstack::Stackwalk &other);
+
+ uint64_t addrs[128];
+ int numLevels;
+};
+
+namespace Callstack
+{
+ void Init()
+ {
+ }
+
+ Stackwalk *Collect()
+ {
+ return new AndroidCallstack();
+ }
+
+ Stackwalk *Create()
+ {
+ return new AndroidCallstack(NULL, 0);
+ }
+
+ bool GetLoadedModules(char *&buf, size_t &size)
+ {
+ if(buf)
+ {
+ buf[0] = 'A';
+ buf[1] = 'N';
+ buf[2] = 'R';
+ buf[3] = 'D';
+ buf[4] = 'C';
+ buf[5] = 'A';
+ buf[6] = 'L';
+ buf[7] = 'L';
+ }
+
+ size += 8;
+
+ return true;
+ }
+
+ class AndroidResolver : public Callstack::StackResolver
+ {
+ public:
+ Callstack::AddressDetails GetAddr(uint64_t addr)
+ {
+ return Callstack::AddressDetails();
+ }
+ };
+
+ StackResolver *MakeResolver(char *moduleDB, size_t DBSize, string pdbSearchPaths, volatile bool *killSignal)
+ {
+ RDCERR("Callstack resolving not supported on Android.");
+ return new AndroidResolver();
+ }
+};
diff --git a/renderdoc/os/posix/android/android_stringio.cpp b/renderdoc/os/posix/android/android_stringio.cpp
new file mode 100644
index 000000000..959bd4df1
--- /dev/null
+++ b/renderdoc/os/posix/android/android_stringio.cpp
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Baldur Karlsson
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ ******************************************************************************/
+
+#include "os/os_specific.h"
+
+typedef int Display;
+
+namespace Keyboard
+{
+ void Init()
+ {
+ }
+
+ void CloneDisplay(Display *dpy) {}
+
+ void AddInputWindow(void *wnd)
+ {
+ }
+
+ void RemoveInputWindow(void *wnd)
+ {
+ }
+
+ bool GetKeyState(int key)
+ {
+ return false;
+ }
+}
+
+namespace FileIO
+{
+ const char *GetTempRootPath()
+ {
+ return "/sdcard";
+ }
+};
+
+namespace StringFormat
+{
+ string Wide2UTF8(const std::wstring &s)
+ {
+ RDCFATAL("Converting wide strings to UTF-8 is not supported on Android!");
+ return "";
+ }
+};
+
diff --git a/renderdoc/os/linux/linux_callstack.cpp b/renderdoc/os/posix/linux/linux_callstack.cpp
similarity index 98%
rename from renderdoc/os/linux/linux_callstack.cpp
rename to renderdoc/os/posix/linux/linux_callstack.cpp
index b95b2645a..5ff38bce6 100644
--- a/renderdoc/os/linux/linux_callstack.cpp
+++ b/renderdoc/os/posix/linux/linux_callstack.cpp
@@ -1,8 +1,7 @@
/******************************************************************************
* The MIT License (MIT)
*
- * Copyright (c) 2015-2016 Baldur Karlsson
- * Copyright (c) 2014 Crytek
+ * Copyright (c) 2016 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,10 +24,7 @@
#include "os/os_specific.h"
-#ifdef ANDROID
-#else
#include
-#endif
#include
#include
@@ -69,11 +65,7 @@ class LinuxCallstack : public Callstack::Stackwalk
{
void *addrs_ptr[ARRAY_COUNT(addrs)];
-#ifdef ANDROID
- numLevels = 0;
-#else
numLevels = backtrace(addrs_ptr, ARRAY_COUNT(addrs));
-#endif
int offs = 0;
// if we want to trim levels of the stack, we can do that here
diff --git a/renderdoc/os/posix/linux/linux_stringio.cpp b/renderdoc/os/posix/linux/linux_stringio.cpp
new file mode 100644
index 000000000..c97f3fc23
--- /dev/null
+++ b/renderdoc/os/posix/linux/linux_stringio.cpp
@@ -0,0 +1,209 @@
+/******************************************************************************
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Baldur Karlsson
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ ******************************************************************************/
+
+
+#include "os/os_specific.h"
+#include "api/app/renderdoc_app.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+#include
+
+#include
+
+#include "serialise/string_utils.h"
+#include "common/threading.h"
+using std::string;
+
+namespace Keyboard
+{
+ void Init()
+ {
+ }
+
+ xcb_connection_t *connection;
+ xcb_key_symbols_t *symbols;
+
+ void CloneDisplay(Display *dpy) {}
+
+ void UseConnection(xcb_connection_t *conn)
+ {
+ connection = conn;
+ symbols = xcb_key_symbols_alloc(conn);
+ }
+
+ void AddInputWindow(void *wnd)
+ {
+ // TODO check against this drawable & parent window being focused in GetKeyState
+ }
+
+ void RemoveInputWindow(void *wnd)
+ {
+ }
+
+ bool GetKeyState(int key)
+ {
+ KeySym ks = 0;
+
+ if(symbols == NULL) return false;
+
+ if(key >= eRENDERDOC_Key_A && key <= eRENDERDOC_Key_Z) ks = key;
+ if(key >= eRENDERDOC_Key_0 && key <= eRENDERDOC_Key_9) ks = key;
+
+ switch(key)
+ {
+ case eRENDERDOC_Key_Divide: ks = XK_KP_Divide; break;
+ case eRENDERDOC_Key_Multiply: ks = XK_KP_Multiply; break;
+ case eRENDERDOC_Key_Subtract: ks = XK_KP_Subtract; break;
+ case eRENDERDOC_Key_Plus: ks = XK_KP_Add; break;
+ case eRENDERDOC_Key_F1: ks = XK_F1; break;
+ case eRENDERDOC_Key_F2: ks = XK_F2; break;
+ case eRENDERDOC_Key_F3: ks = XK_F3; break;
+ case eRENDERDOC_Key_F4: ks = XK_F4; break;
+ case eRENDERDOC_Key_F5: ks = XK_F5; break;
+ case eRENDERDOC_Key_F6: ks = XK_F6; break;
+ case eRENDERDOC_Key_F7: ks = XK_F7; break;
+ case eRENDERDOC_Key_F8: ks = XK_F8; break;
+ case eRENDERDOC_Key_F9: ks = XK_F9; break;
+ case eRENDERDOC_Key_F10: ks = XK_F10; break;
+ case eRENDERDOC_Key_F11: ks = XK_F11; break;
+ case eRENDERDOC_Key_F12: ks = XK_F12; break;
+ case eRENDERDOC_Key_Home: ks = XK_Home; break;
+ case eRENDERDOC_Key_End: ks = XK_End; break;
+ case eRENDERDOC_Key_Insert: ks = XK_Insert; break;
+ case eRENDERDOC_Key_Delete: ks = XK_Delete; break;
+ case eRENDERDOC_Key_PageUp: ks = XK_Prior; break;
+ case eRENDERDOC_Key_PageDn: ks = XK_Next; break;
+ case eRENDERDOC_Key_Backspace: ks = XK_BackSpace; break;
+ case eRENDERDOC_Key_Tab: ks = XK_Tab; break;
+ case eRENDERDOC_Key_PrtScrn: ks = XK_Print; break;
+ case eRENDERDOC_Key_Pause: ks = XK_Pause; break;
+ default:
+ break;
+ }
+
+ if(ks == 0)
+ return false;
+
+ xcb_keycode_t *keyCodes = xcb_key_symbols_get_keycode(symbols, ks);
+
+ if(!keyCodes)
+ return false;
+
+ xcb_query_keymap_cookie_t keymapcookie = xcb_query_keymap(connection);
+ xcb_query_keymap_reply_t *keys = xcb_query_keymap_reply(connection, keymapcookie, NULL);
+
+ bool ret = false;
+
+ if(keys && keyCodes[0] != XCB_NO_SYMBOL)
+ {
+ int byteIdx = (keyCodes[0]/8);
+ int bitMask = 1 << (keyCodes[0]%8);
+
+ ret = (keys->keys[byteIdx] & bitMask) != 0;
+ }
+
+ free(keyCodes);
+ free(keys);
+
+ return ret;
+ }
+}
+
+namespace FileIO
+{
+ const char *GetTempRootPath()
+ {
+ return "/tmp";
+ }
+};
+
+namespace StringFormat
+{
+ // cache iconv_t descriptor to save on iconv_open/iconv_close each time
+ iconv_t iconvWide2UTF8 = (iconv_t)-1;
+
+ // iconv is not thread safe when sharing an iconv_t descriptor
+ // I don't expect much contention but if it happens we could TryLock
+ // before creating a temporary iconv_t, or hold two iconv_ts, or something.
+ Threading::CriticalSection lockWide2UTF8;
+
+ string Wide2UTF8(const std::wstring &s)
+ {
+ // include room for null terminator, assuming unicode input (not ucs)
+ // utf-8 characters can be max 4 bytes.
+ size_t len = (s.length()+1)*4;
+
+ vector charBuffer;
+
+ if(charBuffer.size() < len)
+ charBuffer.resize(len);
+
+ size_t ret;
+
+ {
+ SCOPED_LOCK(lockWide2UTF8);
+
+ if(iconvWide2UTF8 == (iconv_t)-1)
+ iconvWide2UTF8 = iconv_open("UTF-8", "WCHAR_T");
+
+ if(iconvWide2UTF8 == (iconv_t)-1)
+ {
+ RDCERR("Couldn't open iconv for WCHAR_T to UTF-8: %d", errno);
+ return "";
+ }
+
+ char *inbuf = (char *)s.c_str();
+ size_t insize = (s.length()+1)*sizeof(wchar_t); // include null terminator
+ char *outbuf = &charBuffer[0];
+ size_t outsize = len;
+
+ ret = iconv(iconvWide2UTF8, &inbuf, &insize, &outbuf, &outsize);
+ }
+
+ if(ret == (size_t)-1)
+ {
+#if !defined(_RELEASE)
+ RDCWARN("Failed to convert wstring");
+#endif
+ return "";
+ }
+
+ // convert to string from null-terminated string - utf-8 never contains
+ // 0 bytes before the null terminator, and this way we don't care if
+ // charBuffer is larger than the string
+ return string(&charBuffer[0]);
+ }
+};
+
diff --git a/renderdoc/os/linux/linux_hook.cpp b/renderdoc/os/posix/posix_hook.cpp
similarity index 97%
rename from renderdoc/os/linux/linux_hook.cpp
rename to renderdoc/os/posix/posix_hook.cpp
index a6a67efd4..1a23d3f10 100644
--- a/renderdoc/os/linux/linux_hook.cpp
+++ b/renderdoc/os/posix/posix_hook.cpp
@@ -1,7 +1,7 @@
/******************************************************************************
* The MIT License (MIT)
*
- * Copyright (c) 2015-2016 Baldur Karlsson
+ * Copyright (c) 2016 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -24,7 +24,7 @@
#include "os/os_specific.h"
-#include "linux_hook.h"
+#include "posix_hook.h"
#include "serialise/string_utils.h"
#include "common/threading.h"
diff --git a/renderdoc/os/linux/linux_hook.h b/renderdoc/os/posix/posix_hook.h
similarity index 97%
rename from renderdoc/os/linux/linux_hook.h
rename to renderdoc/os/posix/posix_hook.h
index 889893caf..42f2c0a12 100644
--- a/renderdoc/os/linux/linux_hook.h
+++ b/renderdoc/os/posix/posix_hook.h
@@ -1,7 +1,7 @@
/******************************************************************************
* The MIT License (MIT)
*
- * Copyright (c) 2015-2016 Baldur Karlsson
+ * Copyright (c) 2016 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/renderdoc/os/linux/linux_libentry.cpp b/renderdoc/os/posix/posix_libentry.cpp
similarity index 97%
rename from renderdoc/os/linux/linux_libentry.cpp
rename to renderdoc/os/posix/posix_libentry.cpp
index 178e14546..cfabecc25 100644
--- a/renderdoc/os/linux/linux_libentry.cpp
+++ b/renderdoc/os/posix/posix_libentry.cpp
@@ -1,8 +1,7 @@
/******************************************************************************
* The MIT License (MIT)
*
- * Copyright (c) 2015-2016 Baldur Karlsson
- * Copyright (c) 2014 Crytek
+ * Copyright (c) 2016 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/renderdoc/os/linux/linux_network.cpp b/renderdoc/os/posix/posix_network.cpp
similarity index 98%
rename from renderdoc/os/linux/linux_network.cpp
rename to renderdoc/os/posix/posix_network.cpp
index 3708135dd..ebed7a0f7 100644
--- a/renderdoc/os/linux/linux_network.cpp
+++ b/renderdoc/os/posix/posix_network.cpp
@@ -1,8 +1,7 @@
/******************************************************************************
* The MIT License (MIT)
*
- * Copyright (c) 2015-2016 Baldur Karlsson
- * Copyright (c) 2014 Crytek
+ * Copyright (c) 2016 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/renderdoc/os/linux/linux_process.cpp b/renderdoc/os/posix/posix_process.cpp
similarity index 99%
rename from renderdoc/os/linux/linux_process.cpp
rename to renderdoc/os/posix/posix_process.cpp
index 4975fb444..6b160b5e9 100644
--- a/renderdoc/os/linux/linux_process.cpp
+++ b/renderdoc/os/posix/posix_process.cpp
@@ -1,8 +1,7 @@
/******************************************************************************
* The MIT License (MIT)
*
- * Copyright (c) 2015-2016 Baldur Karlsson
- * Copyright (c) 2014 Crytek
+ * Copyright (c) 2016 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/renderdoc/os/linux/linux_specific.h b/renderdoc/os/posix/posix_specific.h
similarity index 96%
rename from renderdoc/os/linux/linux_specific.h
rename to renderdoc/os/posix/posix_specific.h
index 3a7d89d4d..8299fd58c 100644
--- a/renderdoc/os/linux/linux_specific.h
+++ b/renderdoc/os/posix/posix_specific.h
@@ -1,8 +1,7 @@
/******************************************************************************
* The MIT License (MIT)
*
- * Copyright (c) 2015-2016 Baldur Karlsson
- * Copyright (c) 2014 Crytek
+ * Copyright (c) 2016 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/renderdoc/os/linux/linux_stringio.cpp b/renderdoc/os/posix/posix_stringio.cpp
similarity index 57%
rename from renderdoc/os/linux/linux_stringio.cpp
rename to renderdoc/os/posix/posix_stringio.cpp
index 2b140233f..096d14b8a 100644
--- a/renderdoc/os/linux/linux_stringio.cpp
+++ b/renderdoc/os/posix/posix_stringio.cpp
@@ -1,8 +1,7 @@
/******************************************************************************
* The MIT License (MIT)
*
- * Copyright (c) 2015-2016 Baldur Karlsson
- * Copyright (c) 2014 Crytek
+ * Copyright (c) 2016 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -36,22 +35,6 @@
#include
#include
-#ifdef ANDROID
-typedef int Display;
-typedef int xcb_connection_t;
-typedef int xcb_key_symbols_t;
-typedef int KeySym;
-typedef int xcb_keycode_t;
-typedef int *iconv_t;
-#else
-#include
-#include
-
-#include
-
-#include
-#endif
-
// for dladdr
#include
@@ -62,111 +45,11 @@ using std::string;
// gives us an address to identify this so with
static int soLocator=0;
-namespace Keyboard
-{
- void Init()
- {
- }
-
- xcb_connection_t *connection;
- xcb_key_symbols_t *symbols;
-
- void CloneDisplay(Display *dpy) {}
-
- void UseConnection(xcb_connection_t *conn)
- {
- connection = conn;
-#ifdef ANDROID
- symbols = NULL;
-#else
- symbols = xcb_key_symbols_alloc(conn);
-#endif
- }
-
- void AddInputWindow(void *wnd)
- {
- // TODO check against this drawable & parent window being focused in GetKeyState
- }
-
- void RemoveInputWindow(void *wnd)
- {
- }
-
- bool GetKeyState(int key)
- {
-#ifdef ANDROID
- return false;
-#else
- KeySym ks = 0;
-
- if(symbols == NULL) return false;
-
- if(key >= eRENDERDOC_Key_A && key <= eRENDERDOC_Key_Z) ks = key;
- if(key >= eRENDERDOC_Key_0 && key <= eRENDERDOC_Key_9) ks = key;
-
- switch(key)
- {
- case eRENDERDOC_Key_Divide: ks = XK_KP_Divide; break;
- case eRENDERDOC_Key_Multiply: ks = XK_KP_Multiply; break;
- case eRENDERDOC_Key_Subtract: ks = XK_KP_Subtract; break;
- case eRENDERDOC_Key_Plus: ks = XK_KP_Add; break;
- case eRENDERDOC_Key_F1: ks = XK_F1; break;
- case eRENDERDOC_Key_F2: ks = XK_F2; break;
- case eRENDERDOC_Key_F3: ks = XK_F3; break;
- case eRENDERDOC_Key_F4: ks = XK_F4; break;
- case eRENDERDOC_Key_F5: ks = XK_F5; break;
- case eRENDERDOC_Key_F6: ks = XK_F6; break;
- case eRENDERDOC_Key_F7: ks = XK_F7; break;
- case eRENDERDOC_Key_F8: ks = XK_F8; break;
- case eRENDERDOC_Key_F9: ks = XK_F9; break;
- case eRENDERDOC_Key_F10: ks = XK_F10; break;
- case eRENDERDOC_Key_F11: ks = XK_F11; break;
- case eRENDERDOC_Key_F12: ks = XK_F12; break;
- case eRENDERDOC_Key_Home: ks = XK_Home; break;
- case eRENDERDOC_Key_End: ks = XK_End; break;
- case eRENDERDOC_Key_Insert: ks = XK_Insert; break;
- case eRENDERDOC_Key_Delete: ks = XK_Delete; break;
- case eRENDERDOC_Key_PageUp: ks = XK_Prior; break;
- case eRENDERDOC_Key_PageDn: ks = XK_Next; break;
- case eRENDERDOC_Key_Backspace: ks = XK_BackSpace; break;
- case eRENDERDOC_Key_Tab: ks = XK_Tab; break;
- case eRENDERDOC_Key_PrtScrn: ks = XK_Print; break;
- case eRENDERDOC_Key_Pause: ks = XK_Pause; break;
- default:
- break;
- }
-
- if(ks == 0)
- return false;
-
- xcb_keycode_t *keyCodes = xcb_key_symbols_get_keycode(symbols, ks);
-
- if(!keyCodes)
- return false;
-
- xcb_query_keymap_cookie_t keymapcookie = xcb_query_keymap(connection);
- xcb_query_keymap_reply_t *keys = xcb_query_keymap_reply(connection, keymapcookie, NULL);
-
- bool ret = false;
-
- if(keys && keyCodes[0] != XCB_NO_SYMBOL)
- {
- int byteIdx = (keyCodes[0]/8);
- int bitMask = 1 << (keyCodes[0]%8);
-
- ret = (keys->keys[byteIdx] & bitMask) != 0;
- }
-
- free(keyCodes);
- free(keys);
-
- return ret;
-#endif
- }
-}
-
namespace FileIO
{
+ // in posix/.../..._stringio.cpp
+ const char *GetTempRootPath();
+
string GetAppFolderFilename(const string &filename)
{
passwd *pw = getpwuid(getuid());
@@ -283,12 +166,9 @@ namespace FileIO
time_t t = time(NULL);
tm now = *localtime(&t);
-#ifdef ANDROID
-#define BASE_FOLDER "/sdcard"
-#else
-#define BASE_FOLDER "/tmp"
-#endif
- char temp_folder[2048] = { BASE_FOLDER };
+ char temp_folder[2048] = { 0 };
+
+ strcpy(temp_folder, GetTempRootPath());
char *temp_override = getenv("RENDERDOC_TEMP");
if(temp_override && temp_override[0] == '/')
@@ -300,11 +180,11 @@ namespace FileIO
char temp_filename[2048] = {0};
- snprintf(temp_filename, sizeof(temp_filename)-1, BASE_FOLDER "/%s_%04d.%02d.%02d_%02d.%02d.rdc", mod, 1900+now.tm_year, now.tm_mon+1, now.tm_mday, now.tm_hour, now.tm_min);
+ snprintf(temp_filename, sizeof(temp_filename)-1, "%s/%s_%04d.%02d.%02d_%02d.%02d.rdc", GetTempRootPath(), mod, 1900+now.tm_year, now.tm_mon+1, now.tm_mday, now.tm_hour, now.tm_min);
capture_filename = string(temp_filename);
- snprintf(temp_filename, sizeof(temp_filename)-1, BASE_FOLDER "/%s_%04d.%02d.%02d_%02d.%02d.%02d.log", logBaseName, 1900+now.tm_year, now.tm_mon+1, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec);
+ snprintf(temp_filename, sizeof(temp_filename)-1, "%s/%s_%04d.%02d.%02d_%02d.%02d.%02d.log", GetTempRootPath(), logBaseName, 1900+now.tm_year, now.tm_mon+1, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec);
logging_filename = string(temp_filename);
}
@@ -424,65 +304,6 @@ namespace StringFormat
return ret;
}
-
- // cache iconv_t descriptor to save on iconv_open/iconv_close each time
- iconv_t iconvWide2UTF8 = (iconv_t)-1;
-
- // iconv is not thread safe when sharing an iconv_t descriptor
- // I don't expect much contention but if it happens we could TryLock
- // before creating a temporary iconv_t, or hold two iconv_ts, or something.
- Threading::CriticalSection lockWide2UTF8;
-
- string Wide2UTF8(const std::wstring &s)
- {
- // include room for null terminator, assuming unicode input (not ucs)
- // utf-8 characters can be max 4 bytes.
- size_t len = (s.length()+1)*4;
-
- vector charBuffer;
-
- if(charBuffer.size() < len)
- charBuffer.resize(len);
-
- size_t ret;
-
- {
- SCOPED_LOCK(lockWide2UTF8);
-
-#ifdef ANDROID
- ret = -1;
-#else
- if(iconvWide2UTF8 == (iconv_t)-1)
- iconvWide2UTF8 = iconv_open("UTF-8", "WCHAR_T");
-
- if(iconvWide2UTF8 == (iconv_t)-1)
- {
- RDCERR("Couldn't open iconv for WCHAR_T to UTF-8: %d", errno);
- return "";
- }
-
- char *inbuf = (char *)s.c_str();
- size_t insize = (s.length()+1)*sizeof(wchar_t); // include null terminator
- char *outbuf = &charBuffer[0];
- size_t outsize = len;
-
- ret = iconv(iconvWide2UTF8, &inbuf, &insize, &outbuf, &outsize);
-#endif
- }
-
- if(ret == (size_t)-1)
- {
-#if !defined(_RELEASE)
- RDCWARN("Failed to convert wstring");
-#endif
- return "";
- }
-
- // convert to string from null-terminated string - utf-8 never contains
- // 0 bytes before the null terminator, and this way we don't care if
- // charBuffer is larger than the string
- return string(&charBuffer[0]);
- }
};
namespace OSUtility
diff --git a/renderdoc/os/linux/linux_threading.cpp b/renderdoc/os/posix/posix_threading.cpp
similarity index 98%
rename from renderdoc/os/linux/linux_threading.cpp
rename to renderdoc/os/posix/posix_threading.cpp
index 4fc1e1f68..712028eb1 100644
--- a/renderdoc/os/linux/linux_threading.cpp
+++ b/renderdoc/os/posix/posix_threading.cpp
@@ -1,8 +1,7 @@
/******************************************************************************
* The MIT License (MIT)
*
- * Copyright (c) 2015-2016 Baldur Karlsson
- * Copyright (c) 2014 Crytek
+ * Copyright (c) 2016 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/renderdoc/renderdoc.vcxproj b/renderdoc/renderdoc.vcxproj
index 0c2c8a525..7f6c8ba7f 100644
--- a/renderdoc/renderdoc.vcxproj
+++ b/renderdoc/renderdoc.vcxproj
@@ -266,8 +266,13 @@
-
+
+ true
+
+
+ true
+
@@ -293,28 +298,37 @@
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
@@ -415,4 +429,4 @@
-
\ No newline at end of file
+
diff --git a/renderdoc/renderdoc.vcxproj.filters b/renderdoc/renderdoc.vcxproj.filters
index e8ebb828a..63dd34571 100644
--- a/renderdoc/renderdoc.vcxproj.filters
+++ b/renderdoc/renderdoc.vcxproj.filters
@@ -64,15 +64,21 @@
{aadadb32-abbc-45b3-8f86-026eed994ba9}
-
- {5168e1dc-8d41-4aff-b99c-1ffa2af33f95}
-
{3e51a921-b167-4794-937d-e77573a928b8}
{188ad934-e74f-4805-b74b-167f8760fab6}
+
+ {410640a4-ebf0-479a-8d08-ae277e2ded84}
+
+
+ {5168e1dc-8d41-4aff-b99c-1ffa2af33f95}
+
+
+ {16bdcbe1-31de-4732-aaaf-8d77039a26ec}
+
@@ -234,12 +240,15 @@
Common
-
- OS\Linux
-
OS\Win32
+
+ OS\Posix
+
+
+ OS\Posix
+
@@ -341,27 +350,6 @@
OS\Win32
-
- OS\Linux
-
-
- OS\Linux
-
-
- OS\Linux
-
-
- OS\Linux
-
-
- OS\Linux
-
-
- OS\Linux
-
-
- OS\Linux
-
OS\Win32
@@ -371,6 +359,36 @@
Replay
+
+ OS\Posix\Android
+
+
+ OS\Posix\Android
+
+
+ OS\Posix\Linux
+
+
+ OS\Posix\Linux
+
+
+ OS\Posix
+
+
+ OS\Posix
+
+
+ OS\Posix
+
+
+ OS\Posix
+
+
+ OS\Posix
+
+
+ OS\Posix
+