Get compiling on win32 (hacks, not final code).

This commit is contained in:
baldurk
2016-02-07 18:39:30 +01:00
parent 5c8df903ef
commit 9b0b6ef3b6
10 changed files with 142 additions and 20 deletions
@@ -0,0 +1,89 @@
/*
* Vulkan
*
* Copyright (C) 2015 LunarG, Inc.
*
* 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.
*
* Authors:
* Courtney Goeltzenleuchter <courtney@lunarg.com>
*/
#include "string.h"
#include "vk_layer_extension_utils.h"
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
/*
* This file contains utility functions for layers
*/
VkResult util_GetExtensionProperties(
const uint32_t count,
const VkExtensionProperties *layer_extensions,
uint32_t* pCount,
VkExtensionProperties* pProperties)
{
uint32_t copy_size;
if (pCount == NULL) {
return VK_ERROR_INVALID_POINTER;
}
if (pProperties == NULL || layer_extensions == NULL) {
*pCount = count;
return VK_SUCCESS;
}
copy_size = *pCount < count ? *pCount : count;
memcpy(pProperties, layer_extensions, copy_size * sizeof(VkExtensionProperties));
*pCount = copy_size;
if (copy_size < count) {
return VK_INCOMPLETE;
}
return VK_SUCCESS;
}
VkResult util_GetLayerProperties(
const uint32_t count,
const VkLayerProperties *layer_properties,
uint32_t* pCount,
VkLayerProperties* pProperties)
{
uint32_t copy_size;
if (pCount == NULL) {
return VK_ERROR_INVALID_POINTER;
}
if (pProperties == NULL || layer_properties == NULL) {
*pCount = count;
return VK_SUCCESS;
}
copy_size = *pCount < count ? *pCount : count;
memcpy(pProperties, layer_properties, copy_size * sizeof(VkLayerProperties));
*pCount = copy_size;
if (copy_size < count) {
return VK_INCOMPLETE;
}
return VK_SUCCESS;
}
@@ -23,7 +23,7 @@
*/
#include <assert.h>
#include <unordered_map>
#include "vk_dispatch_table_helper.h"
#include "../build/layers/vk_dispatch_table_helper.h"
#include "vk_layer.h"
#include "vk_layer_table.h"
static device_table_map tableMap;
@@ -173,7 +173,7 @@ static inline void *loader_aligned_alloc(size_t alignment, size_t size) { return
#include <assert.h>
#include <stdio.h>
#include <io.h>
#include <stdbool.h>
//#include <stdbool.h>
#include <shlwapi.h>
#ifdef __cplusplus
#include <iostream>
@@ -213,7 +213,7 @@ static bool loader_platform_file_exists(const char *path)
static bool loader_platform_is_path_absolute(const char *path)
{
return !PathIsRelative(path);
return !PathIsRelativeA(path);
}
// WIN32 runtime doesn't have dirname().
@@ -267,12 +267,12 @@ static char *loader_platform_basename(char *pathname)
typedef HMODULE loader_platform_dl_handle;
static loader_platform_dl_handle loader_platform_open_library(const char* libPath)
{
return LoadLibrary(libPath);
return LoadLibraryA(libPath);
}
static char * loader_platform_open_library_error(const char* libPath)
{
static char errorMsg[120];
snprintf(errorMsg, 119, "Failed to open dynamic library \"%s\"", libPath);
_snprintf_s(errorMsg, 119, "Failed to open dynamic library \"%s\"", libPath);
return errorMsg;
}
static void loader_platform_close_library(loader_platform_dl_handle library)
@@ -289,7 +289,7 @@ static void * loader_platform_get_proc_address(loader_platform_dl_handle library
static char * loader_platform_get_proc_address_error(const char *name)
{
static char errorMsg[120];
snprintf(errorMsg, 119, "Failed to find function \"%s\" in dynamic library", name);
_snprintf_s(errorMsg, 119, "Failed to find function \"%s\" in dynamic library", name);
return errorMsg;
}
+20 -5
View File
@@ -24,14 +24,14 @@
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "vk_loader_platform.h"
#include "vk_dispatch_table_helper.h"
#include "LoaderAndTools/loader/vk_loader_platform.h"
#include "LoaderAndTools/build/layers/vk_dispatch_table_helper.h"
#include "vk_layer.h"
#include "vk_layer_table.h"
#include "vk_layer_extension_utils.h"
#include "LoaderAndTools/layers/vk_layer_table.h"
#include "LoaderAndTools/layers/vk_layer_extension_utils.h"
// The following is #included again to catch certain OS-specific functions
// being used:
#include "vk_loader_platform.h"
#include "LoaderAndTools/loader/vk_loader_platform.h"
// Renderdoc Includes
@@ -51,6 +51,11 @@
#undef far
#endif
#ifdef WIN32
#undef VK_LAYER_EXPORT
#define VK_LAYER_EXPORT extern "C" __declspec(dllexport)
#endif
// Renderdoc State
WrappedVulkan *shadowVulkan = NULL;
@@ -110,6 +115,11 @@ VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalLayerProperties(
pCount, pProperties);
}
#ifdef WIN32
#undef VK_LAYER_EXPORT
#define VK_LAYER_EXPORT
#endif
// Renderdoc Intercepts
#define HookDefine0(ret, function) \
@@ -184,6 +194,11 @@ DefineHooks();
#undef HookInit
#define HookInit(function) if (!strcmp(pName, STRINGIZE(function))) return (PFN_vkVoidFunction) function;
#ifdef WIN32
#undef VK_LAYER_EXPORT
#define VK_LAYER_EXPORT extern "C" __declspec(dllexport)
#endif
// proc addr routines
VK_LAYER_EXPORT PFN_vkVoidFunction VKAPI vkGetDeviceProcAddr(VkDevice device, const char* pName)
@@ -19,12 +19,17 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="LoaderAndTools\layers\vk_layer_extension_utils.cpp" />
<ClCompile Include="LoaderAndTools\layers\vk_layer_table.cpp" />
<ClCompile Include="rdtrace.cpp" />
<ClCompile Include="vk_common.cpp" />
<ClCompile Include="vk_core.cpp" />
<ClCompile Include="vk_hooks_linux.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vk_hooks_win32.cpp" />
<ClCompile Include="vk_hooks_win32.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vk_info.cpp" />
<ClCompile Include="vk_manager.cpp" />
<ClCompile Include="vk_replay.cpp" />
@@ -11,6 +11,13 @@
<ClCompile Include="vk_hooks_linux.cpp" />
<ClCompile Include="vk_resources.cpp" />
<ClCompile Include="vk_info.cpp" />
<ClCompile Include="rdtrace.cpp" />
<ClCompile Include="LoaderAndTools\layers\vk_layer_table.cpp">
<Filter>ext</Filter>
</ClCompile>
<ClCompile Include="LoaderAndTools\layers\vk_layer_extension_utils.cpp">
<Filter>ext</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="vk_core.h" />
@@ -22,4 +29,9 @@
<ClInclude Include="vk_common.h" />
<ClInclude Include="vk_info.h" />
</ItemGroup>
<ItemGroup>
<Filter Include="ext">
<UniqueIdentifier>{170618b5-5523-497e-a798-4cad26474162}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
+2 -2
View File
@@ -39,8 +39,8 @@
// layer includes
#include "vk_layer.h"
#include "vk_layer_table.h"
#include "vk_layer_extension_utils.h"
#include "LoaderAndTools/layers/vk_layer_table.h"
#include "LoaderAndTools/layers/vk_layer_extension_utils.h"
using std::vector;
using std::list;
+2 -1
View File
@@ -33,5 +33,6 @@
struct VulkanFunctions
{
HookInitVulkan()
HookInitVulkanInstance();
HookInitVulkanDevice();
};
+1 -1
View File
@@ -25,7 +25,7 @@
#include "vk_replay.h"
#include "vk_core.h"
#include "vk_resources.h"
#include "vk_layer_table.h"
#include "LoaderAndTools/layers/vk_layer_table.h"
#include "serialise/string_utils.h"
+4 -4
View File
@@ -44,19 +44,19 @@ using std::string;
// template helpers
template <class T>
struct is_pointer
struct renderdoc_is_pointer
{
enum {value = false};
};
template <class T>
struct is_pointer<T *>
struct renderdoc_is_pointer<T *>
{
enum {value = true};
};
template <class T>
struct is_pointer<const T *>
struct renderdoc_is_pointer<const T *>
{
enum {value = true};
};
@@ -72,7 +72,7 @@ struct ToStr
template<class T>
static string Get(const T &el)
{
return ToStrHelper<is_pointer<T>::value, T>::Get(el);
return ToStrHelper<renderdoc_is_pointer<T>::value, T>::Get(el);
}
};