mirror of
https://github.com/PancakeTAS/lsfg-vk.git
synced 2025-10-30 07:01:10 +00:00
fix validation headers and potential amd issues
This commit is contained in:
parent
794fbcf28c
commit
0d125a115d
4 changed files with 37 additions and 2 deletions
|
|
@ -25,6 +25,11 @@ namespace Layer {
|
||||||
VkDevice device,
|
VkDevice device,
|
||||||
const VkAllocationCallbacks* pAllocator);
|
const VkAllocationCallbacks* pAllocator);
|
||||||
|
|
||||||
|
/// Call to the original vkSetDeviceLoaderData function.
|
||||||
|
VkResult ovkSetDeviceLoaderData(
|
||||||
|
VkDevice device,
|
||||||
|
void* object);
|
||||||
|
|
||||||
/// Call to the original vkGetInstanceProcAddr function.
|
/// Call to the original vkGetInstanceProcAddr function.
|
||||||
PFN_vkVoidFunction ovkGetInstanceProcAddr(
|
PFN_vkVoidFunction ovkGetInstanceProcAddr(
|
||||||
VkInstance instance,
|
VkInstance instance,
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ namespace {
|
||||||
PFN_vkCreateDevice next_vkCreateDevice{};
|
PFN_vkCreateDevice next_vkCreateDevice{};
|
||||||
PFN_vkDestroyDevice next_vkDestroyDevice{};
|
PFN_vkDestroyDevice next_vkDestroyDevice{};
|
||||||
|
|
||||||
|
PFN_vkSetDeviceLoaderData next_vSetDeviceLoaderData{};
|
||||||
|
|
||||||
PFN_vkGetInstanceProcAddr next_vkGetInstanceProcAddr{};
|
PFN_vkGetInstanceProcAddr next_vkGetInstanceProcAddr{};
|
||||||
PFN_vkGetDeviceProcAddr next_vkGetDeviceProcAddr{};
|
PFN_vkGetDeviceProcAddr next_vkGetDeviceProcAddr{};
|
||||||
|
|
||||||
|
|
@ -152,11 +154,28 @@ namespace {
|
||||||
return VK_ERROR_INITIALIZATION_FAILED;
|
return VK_ERROR_INITIALIZATION_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// advance link info (i don't really know what this does)
|
next_vkGetDeviceProcAddr = layerDesc->u.pLayerInfo->pfnNextGetDeviceProcAddr;;
|
||||||
next_vkGetDeviceProcAddr = layerDesc->u.pLayerInfo->pfnNextGetDeviceProcAddr;
|
|
||||||
Log::debug("layer", "Next device proc addr: {:x}",
|
Log::debug("layer", "Next device proc addr: {:x}",
|
||||||
reinterpret_cast<uintptr_t>(next_vkGetDeviceProcAddr));
|
reinterpret_cast<uintptr_t>(next_vkGetDeviceProcAddr));
|
||||||
|
|
||||||
|
// find second layer creation info
|
||||||
|
auto* layerDesc2 = const_cast<VkLayerDeviceCreateInfo*>(
|
||||||
|
reinterpret_cast<const VkLayerDeviceCreateInfo*>(pCreateInfo->pNext));
|
||||||
|
while (layerDesc2 && (layerDesc2->sType != VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO
|
||||||
|
|| layerDesc2->function != VK_LOADER_DATA_CALLBACK)) {
|
||||||
|
layerDesc2 = const_cast<VkLayerDeviceCreateInfo*>(
|
||||||
|
reinterpret_cast<const VkLayerDeviceCreateInfo*>(layerDesc2->pNext));
|
||||||
|
}
|
||||||
|
if (!layerDesc2) {
|
||||||
|
Log::error("layer", "No layer creation info found in pNext chain");
|
||||||
|
return VK_ERROR_INITIALIZATION_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
next_vSetDeviceLoaderData = layerDesc2->u.pfnSetDeviceLoaderData;
|
||||||
|
Log::debug("layer", "Next device loader data: {:x}",
|
||||||
|
reinterpret_cast<uintptr_t>(next_vSetDeviceLoaderData));
|
||||||
|
|
||||||
|
// advance link info (i don't really know what this does)
|
||||||
layerDesc->u.pLayerInfo = layerDesc->u.pLayerInfo->pNext;
|
layerDesc->u.pLayerInfo = layerDesc->u.pLayerInfo->pNext;
|
||||||
|
|
||||||
// create device
|
// create device
|
||||||
|
|
@ -317,6 +336,12 @@ void Layer::ovkDestroyDevice(
|
||||||
reinterpret_cast<uintptr_t>(device));
|
reinterpret_cast<uintptr_t>(device));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VkResult Layer::ovkSetDeviceLoaderData(VkDevice device, void* object) {
|
||||||
|
Log::debug("vulkan", "vkSetDeviceLoaderData called for object {:x}",
|
||||||
|
reinterpret_cast<uintptr_t>(object));
|
||||||
|
return next_vSetDeviceLoaderData(device, object);
|
||||||
|
}
|
||||||
|
|
||||||
PFN_vkVoidFunction Layer::ovkGetInstanceProcAddr(
|
PFN_vkVoidFunction Layer::ovkGetInstanceProcAddr(
|
||||||
VkInstance instance,
|
VkInstance instance,
|
||||||
const char* pName) {
|
const char* pName) {
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ CommandBuffer::CommandBuffer(VkDevice device, const CommandPool& pool) {
|
||||||
auto res = Layer::ovkAllocateCommandBuffers(device, &desc, &commandBufferHandle);
|
auto res = Layer::ovkAllocateCommandBuffers(device, &desc, &commandBufferHandle);
|
||||||
if (res != VK_SUCCESS || commandBufferHandle == VK_NULL_HANDLE)
|
if (res != VK_SUCCESS || commandBufferHandle == VK_NULL_HANDLE)
|
||||||
throw LSFG::vulkan_error(res, "Unable to allocate command buffer");
|
throw LSFG::vulkan_error(res, "Unable to allocate command buffer");
|
||||||
|
res = Layer::ovkSetDeviceLoaderData(device, commandBufferHandle);
|
||||||
|
|
||||||
// store command buffer in shared ptr
|
// store command buffer in shared ptr
|
||||||
this->state = std::make_shared<CommandBufferState>(CommandBufferState::Empty);
|
this->state = std::make_shared<CommandBufferState>(CommandBufferState::Empty);
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,10 @@ std::pair<uint32_t, VkQueue> Utils::findQueue(VkDevice device, VkPhysicalDevice
|
||||||
VkQueue queue{};
|
VkQueue queue{};
|
||||||
Layer::ovkGetDeviceQueue(device, *idx, 0, &queue);
|
Layer::ovkGetDeviceQueue(device, *idx, 0, &queue);
|
||||||
|
|
||||||
|
auto res = Layer::ovkSetDeviceLoaderData(device, queue);
|
||||||
|
if (res != VK_SUCCESS)
|
||||||
|
throw LSFG::vulkan_error(res, "Unable to set device loader data for queue");
|
||||||
|
|
||||||
return { *idx, queue };
|
return { *idx, queue };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue