mirror of
https://github.com/Inori/GPCS4.git
synced 2024-06-02 11:28:07 -04:00
add vulkan function loader
This commit is contained in:
parent
a01d404d48
commit
3e2034ed1b
|
@ -126,7 +126,6 @@
|
|||
<ClInclude Include="Graphics\Violet\VltConstantState.h" />
|
||||
<ClInclude Include="Graphics\Violet\VltContext.h" />
|
||||
<ClInclude Include="Graphics\Violet\VltContextState.h" />
|
||||
<ClInclude Include="Graphics\Violet\VltDebugUtil.h" />
|
||||
<ClInclude Include="Graphics\Violet\VltDescriptor.h" />
|
||||
<ClInclude Include="Graphics\Violet\VltDevice.h" />
|
||||
<ClInclude Include="Graphics\Violet\VltDeviceFilter.h" />
|
||||
|
@ -147,6 +146,7 @@
|
|||
</ClInclude>
|
||||
<ClInclude Include="Graphics\Violet\VltLifetime.h" />
|
||||
<ClInclude Include="Graphics\Violet\VltLimit.h" />
|
||||
<ClInclude Include="Graphics\Violet\VltLoader.h" />
|
||||
<ClInclude Include="Graphics\Violet\VltLog.h" />
|
||||
<ClInclude Include="Graphics\Violet\VltMemory.h" />
|
||||
<ClInclude Include="Graphics\Violet\VltObject.h" />
|
||||
|
@ -387,7 +387,6 @@
|
|||
<ClCompile Include="Graphics\Violet\VltCmdList.cpp" />
|
||||
<ClCompile Include="Graphics\Violet\VltCompute.cpp" />
|
||||
<ClCompile Include="Graphics\Violet\VltContext.cpp" />
|
||||
<ClCompile Include="Graphics\Violet\VltDebugUtil.cpp" />
|
||||
<ClCompile Include="Graphics\Violet\VltDescriptor.cpp" />
|
||||
<ClCompile Include="Graphics\Violet\VltDevice.cpp" />
|
||||
<ClCompile Include="Graphics\Violet\VltDeviceFilter.cpp" />
|
||||
|
@ -405,6 +404,7 @@
|
|||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Graphics\Violet\VltLifetime.cpp" />
|
||||
<ClCompile Include="Graphics\Violet\VltLoader.cpp" />
|
||||
<ClCompile Include="Graphics\Violet\VltLog.cpp" />
|
||||
<ClCompile Include="Graphics\Violet\VltMemory.cpp" />
|
||||
<ClCompile Include="Graphics\Violet\VltPipeLayout.cpp" />
|
||||
|
|
|
@ -730,9 +730,6 @@
|
|||
<ClInclude Include="Graphics\Violet\VltCmdList.h">
|
||||
<Filter>Source Files\Graphics\Violet</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Graphics\Violet\VltDebugUtil.h">
|
||||
<Filter>Source Files\Graphics\Violet</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Graphics\Violet\VltResource.h">
|
||||
<Filter>Source Files\Graphics\Violet</Filter>
|
||||
</ClInclude>
|
||||
|
@ -988,6 +985,9 @@
|
|||
<ClInclude Include="Graphics\Violet\VltRenderPass.h">
|
||||
<Filter>Source Files\Graphics\Violet</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Graphics\Violet\VltLoader.h">
|
||||
<Filter>Source Files\Graphics\Violet</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Loader\EbootObject.cpp">
|
||||
|
@ -1527,9 +1527,6 @@
|
|||
<ClCompile Include="Graphics\Violet\VltCmdList.cpp">
|
||||
<Filter>Source Files\Graphics\Violet</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Graphics\Violet\VltDebugUtil.cpp">
|
||||
<Filter>Source Files\Graphics\Violet</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Graphics\Violet\VltResource.cpp">
|
||||
<Filter>Source Files\Graphics\Violet</Filter>
|
||||
</ClCompile>
|
||||
|
@ -1734,6 +1731,9 @@
|
|||
<ClCompile Include="Graphics\Gnm\GnmSamplerCache.cpp">
|
||||
<Filter>Source Files\Graphics\Gnm</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Graphics\Violet\VltLoader.cpp">
|
||||
<Filter>Source Files\Graphics\Violet</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="Emulator\TLSStub.asm">
|
||||
|
|
|
@ -979,7 +979,6 @@ namespace sce::Gnm
|
|||
|
||||
auto shader = getShader(ctx.code);
|
||||
auto& resTable = shader.getResources();
|
||||
|
||||
|
||||
if (shader.name().find("1C3E9BEC02B89E0E") != std::string::npos)
|
||||
{
|
||||
|
|
|
@ -19,8 +19,7 @@ namespace sce::Gnm
|
|||
std::atomic<size_t> GnmResourceFactory::s_objectId = 0;
|
||||
|
||||
GnmResourceFactory::GnmResourceFactory(VltDevice* device) :
|
||||
m_device(device),
|
||||
m_debugUtil(device)
|
||||
m_device(device)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -43,11 +42,20 @@ namespace sce::Gnm
|
|||
// NOTE: this slice count is only valid if the array view hasn't changed since initialization!
|
||||
imgInfo.numLayers = depthTarget->getLastArraySliceIndex() - depthTarget->getBaseArraySliceIndex() + 1;
|
||||
imgInfo.mipLevels = 1;
|
||||
imgInfo.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||
imgInfo.stages = VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
|
||||
imgInfo.access = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
||||
imgInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
|
||||
imgInfo.layout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
|
||||
|
||||
imgInfo.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
|
||||
VK_IMAGE_USAGE_TRANSFER_DST_BIT |
|
||||
VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||
|
||||
imgInfo.stages = VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT |
|
||||
VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT |
|
||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
|
||||
|
||||
imgInfo.access = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
||||
VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
||||
|
||||
imgInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
|
||||
imgInfo.layout = optimizeLayout(imgInfo.usage);
|
||||
|
||||
VltImageViewCreateInfo viewInfo;
|
||||
viewInfo.type = VK_IMAGE_VIEW_TYPE_2D;
|
||||
|
@ -83,12 +91,12 @@ namespace sce::Gnm
|
|||
nameInfo.objectType = VK_OBJECT_TYPE_IMAGE;
|
||||
nameInfo.pObjectName = imageName.c_str();
|
||||
nameInfo.objectHandle = (uint64_t)depthImage.image->handle();
|
||||
m_debugUtil.setObjectName(&nameInfo);
|
||||
setObjectName(&nameInfo);
|
||||
|
||||
nameInfo.objectType = VK_OBJECT_TYPE_IMAGE_VIEW;
|
||||
nameInfo.pObjectName = viewName.c_str();
|
||||
nameInfo.objectHandle = (uint64_t)depthImage.imageView->handle();
|
||||
m_debugUtil.setObjectName(&nameInfo);
|
||||
setObjectName(&nameInfo);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -153,12 +161,12 @@ namespace sce::Gnm
|
|||
nameInfo.objectType = VK_OBJECT_TYPE_IMAGE;
|
||||
nameInfo.pObjectName = imageName.c_str();
|
||||
nameInfo.objectHandle = (uint64_t)targetImage.image->handle();
|
||||
m_debugUtil.setObjectName(&nameInfo);
|
||||
setObjectName(&nameInfo);
|
||||
|
||||
nameInfo.objectType = VK_OBJECT_TYPE_IMAGE_VIEW;
|
||||
nameInfo.pObjectName = viewName.c_str();
|
||||
nameInfo.objectHandle = (uint64_t)targetImage.imageView->handle();
|
||||
m_debugUtil.setObjectName(&nameInfo);
|
||||
setObjectName(&nameInfo);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -189,7 +197,7 @@ namespace sce::Gnm
|
|||
nameInfo.objectType = VK_OBJECT_TYPE_BUFFER;
|
||||
nameInfo.pObjectName = bufferName.c_str();
|
||||
nameInfo.objectHandle = (uint64_t)sceBuffer.buffer->getSliceHandle().handle;
|
||||
m_debugUtil.setObjectName(&nameInfo);
|
||||
setObjectName(&nameInfo);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -246,11 +254,6 @@ namespace sce::Gnm
|
|||
sceTexture.imageView = m_device->createImageView(sceTexture.image, viewInfo);
|
||||
sceTexture.texture = *tsharp;
|
||||
|
||||
if (s_objectId == 196)
|
||||
{
|
||||
__debugbreak();
|
||||
}
|
||||
|
||||
// Set debug name
|
||||
auto imageName = fmt::format("Texture_{}_{}",
|
||||
s_objectId++,
|
||||
|
@ -265,12 +268,12 @@ namespace sce::Gnm
|
|||
nameInfo.objectType = VK_OBJECT_TYPE_IMAGE;
|
||||
nameInfo.pObjectName = imageName.c_str();
|
||||
nameInfo.objectHandle = (uint64_t)sceTexture.image->handle();
|
||||
m_debugUtil.setObjectName(&nameInfo);
|
||||
setObjectName(&nameInfo);
|
||||
|
||||
nameInfo.objectType = VK_OBJECT_TYPE_IMAGE_VIEW;
|
||||
nameInfo.pObjectName = viewName.c_str();
|
||||
nameInfo.objectHandle = (uint64_t)sceTexture.imageView->handle();
|
||||
m_debugUtil.setObjectName(&nameInfo);
|
||||
setObjectName(&nameInfo);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -328,7 +331,7 @@ namespace sce::Gnm
|
|||
nameInfo.objectType = VK_OBJECT_TYPE_SAMPLER;
|
||||
nameInfo.pObjectName = samplerName.c_str();
|
||||
nameInfo.objectHandle = (uint64_t)result->handle();
|
||||
m_debugUtil.setObjectName(&nameInfo);
|
||||
setObjectName(&nameInfo);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -406,4 +409,9 @@ namespace sce::Gnm
|
|||
return result;
|
||||
}
|
||||
|
||||
void GnmResourceFactory::setObjectName(VkDebugUtilsObjectNameInfoEXT* nameInfo)
|
||||
{
|
||||
m_device->vkd()->vkSetDebugUtilsObjectNameEXT(m_device->handle(), nameInfo);
|
||||
}
|
||||
|
||||
} // namespace sce::Gnm
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
#include "GnmCommon.h"
|
||||
#include "GnmSamplerCache.h"
|
||||
#include "Violet/VltDebugUtil.h"
|
||||
|
||||
|
||||
#include <atomic>
|
||||
|
||||
|
@ -82,10 +80,12 @@ namespace sce
|
|||
|
||||
VkComponentMapping calculateSwizzle(DataFormat format);
|
||||
|
||||
inline void setObjectName(
|
||||
VkDebugUtilsObjectNameInfoEXT* nameInfo);
|
||||
|
||||
private:
|
||||
vlt::VltDevice* m_device;
|
||||
vlt::VltDebugUtil m_debugUtil;
|
||||
GnmSamplerCache m_samplerCache;
|
||||
vlt::VltDevice* m_device;
|
||||
GnmSamplerCache m_samplerCache;
|
||||
|
||||
static std::atomic_size_t s_objectId;
|
||||
};
|
||||
|
|
|
@ -145,7 +145,7 @@ namespace sce
|
|||
|
||||
submitPresent(displayBufferIndex);
|
||||
|
||||
downloadResource();
|
||||
//downloadResource();
|
||||
// clear resource tracker every frame
|
||||
cleanupFrame();
|
||||
|
||||
|
|
|
@ -544,8 +544,9 @@ namespace sce::vlt
|
|||
if (vr != VK_SUCCESS)
|
||||
Logger::exception("DxvkAdapter: Failed to create device");
|
||||
|
||||
Rc<VltDevice> result = new VltDevice(
|
||||
instance, this, device, devExtensions, requestFeatures);
|
||||
Rc<VltDevice> result = new VltDevice(instance, this,
|
||||
new vk::DeviceFn(true, instance->handle(), device),
|
||||
devExtensions, requestFeatures);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,7 @@ namespace sce::vlt
|
|||
m_device(device),
|
||||
m_queueType(queueType),
|
||||
m_cmdBuffersUsed(0),
|
||||
m_descriptorPoolTracker(device),
|
||||
m_debug(device)
|
||||
m_descriptorPoolTracker(device)
|
||||
{
|
||||
const auto& execQueue = m_queueType == VltQueueType::Graphics
|
||||
? m_device->queues().graphics
|
||||
|
@ -276,17 +275,17 @@ namespace sce::vlt
|
|||
|
||||
void VltCommandList::cmdBeginDebugUtilsLabel(VkDebugUtilsLabelEXT* labelInfo)
|
||||
{
|
||||
m_debug.cmdBeginDebugUtilsLabel(m_execBuffer, labelInfo);
|
||||
m_device->vkd()->vkCmdBeginDebugUtilsLabelEXT(m_execBuffer, labelInfo);
|
||||
}
|
||||
|
||||
void VltCommandList::cmdEndDebugUtilsLabel()
|
||||
{
|
||||
m_debug.cmdEndDebugUtilsLabel(m_execBuffer);
|
||||
m_device->vkd()->vkCmdEndDebugUtilsLabelEXT(m_execBuffer);
|
||||
}
|
||||
|
||||
void VltCommandList::cmdInsertDebugUtilsLabel(VkDebugUtilsLabelEXT* labelInfo)
|
||||
{
|
||||
m_debug.cmdInsertDebugUtilsLabel(m_execBuffer, labelInfo);
|
||||
m_device->vkd()->vkCmdInsertDebugUtilsLabelEXT(m_execBuffer, labelInfo);
|
||||
}
|
||||
|
||||
VkSemaphoreSubmitInfo VltCommandList::populateSemaphoreSubmit(
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "VltCommon.h"
|
||||
#include "VltDebugUtil.h"
|
||||
#include "VltLifetime.h"
|
||||
#include "VltSignal.h"
|
||||
#include "VltGpuEvent.h"
|
||||
|
@ -874,8 +873,6 @@ namespace sce::vlt
|
|||
VltGpuEventTracker m_gpuEventTracker;
|
||||
VltSemaphoreTracker m_semaphoreTracker;
|
||||
//DxvkGpuQueryTracker m_gpuQueryTracker;
|
||||
|
||||
VltDebugUtil m_debug;
|
||||
};
|
||||
|
||||
} // namespace sce::vlt
|
|
@ -1,71 +0,0 @@
|
|||
#include "VltDebugUtil.h"
|
||||
|
||||
#include "VltDevice.h"
|
||||
|
||||
namespace sce::vlt
|
||||
{
|
||||
PFN_vkSetDebugUtilsObjectNameEXT VltDebugUtil::pfnSetDebugUtilsObjectNameEXT = VK_NULL_HANDLE;
|
||||
PFN_vkSetDebugUtilsObjectTagEXT VltDebugUtil::pfnSetDebugUtilsObjectTagEXT = VK_NULL_HANDLE;
|
||||
|
||||
PFN_vkCmdInsertDebugUtilsLabelEXT VltDebugUtil::pfnCmdInsertDebugUtilsLabelEXT = VK_NULL_HANDLE;
|
||||
PFN_vkCmdEndDebugUtilsLabelEXT VltDebugUtil::pfnCmdEndDebugUtilsLabelEXT = VK_NULL_HANDLE;
|
||||
PFN_vkCmdBeginDebugUtilsLabelEXT VltDebugUtil::pfnCmdBeginDebugUtilsLabelEXT = VK_NULL_HANDLE;
|
||||
|
||||
VltDebugUtil::VltDebugUtil(VltDevice* device) :
|
||||
m_device(device)
|
||||
{
|
||||
#ifdef VLT_DEBUG_LABEL
|
||||
setupDebugFunctions();
|
||||
#endif // VLT_DEBUG_LABEL
|
||||
}
|
||||
|
||||
VltDebugUtil::~VltDebugUtil()
|
||||
{
|
||||
}
|
||||
|
||||
void VltDebugUtil::setupDebugFunctions()
|
||||
{
|
||||
pfnSetDebugUtilsObjectNameEXT = reinterpret_cast<PFN_vkSetDebugUtilsObjectNameEXT>(vkGetDeviceProcAddr(m_device->handle(), "vkSetDebugUtilsObjectNameEXT"));
|
||||
pfnSetDebugUtilsObjectTagEXT = reinterpret_cast<PFN_vkSetDebugUtilsObjectTagEXT>(vkGetDeviceProcAddr(m_device->handle(), "vkSetDebugUtilsObjectTagEXT"));
|
||||
|
||||
pfnCmdBeginDebugUtilsLabelEXT = reinterpret_cast<PFN_vkCmdBeginDebugUtilsLabelEXT>(vkGetDeviceProcAddr(m_device->handle(), "vkCmdBeginDebugUtilsLabelEXT"));
|
||||
pfnCmdEndDebugUtilsLabelEXT = reinterpret_cast<PFN_vkCmdEndDebugUtilsLabelEXT>(vkGetDeviceProcAddr(m_device->handle(), "vkCmdEndDebugUtilsLabelEXT"));
|
||||
pfnCmdInsertDebugUtilsLabelEXT = reinterpret_cast<PFN_vkCmdInsertDebugUtilsLabelEXT>(vkGetDeviceProcAddr(m_device->handle(), "vkCmdInsertDebugUtilsLabelEXT"));
|
||||
}
|
||||
|
||||
void VltDebugUtil::setObjectName(VkDebugUtilsObjectNameInfoEXT* nameInfo)
|
||||
{
|
||||
#ifdef VLT_DEBUG_LABEL
|
||||
pfnSetDebugUtilsObjectNameEXT(m_device->handle(), nameInfo);
|
||||
#endif // VLT_DEBUG_LABEL
|
||||
}
|
||||
|
||||
void VltDebugUtil::setObjectTag(VkDebugUtilsObjectTagInfoEXT* tagInfo)
|
||||
{
|
||||
#ifdef VLT_DEBUG_LABEL
|
||||
pfnSetDebugUtilsObjectTagEXT(m_device->handle(), tagInfo);
|
||||
#endif // VLT_DEBUG_LABEL
|
||||
}
|
||||
|
||||
void VltDebugUtil::cmdBeginDebugUtilsLabel(VkCommandBuffer command, VkDebugUtilsLabelEXT* labelInfo)
|
||||
{
|
||||
#ifdef VLT_DEBUG_LABEL
|
||||
pfnCmdBeginDebugUtilsLabelEXT(command, labelInfo);
|
||||
#endif // VLT_DEBUG_LABEL
|
||||
}
|
||||
|
||||
void VltDebugUtil::cmdEndDebugUtilsLabel(VkCommandBuffer command)
|
||||
{
|
||||
#ifdef VLT_DEBUG_LABEL
|
||||
pfnCmdEndDebugUtilsLabelEXT(command);
|
||||
#endif // VLT_DEBUG_LABEL
|
||||
}
|
||||
|
||||
void VltDebugUtil::cmdInsertDebugUtilsLabel(VkCommandBuffer command, VkDebugUtilsLabelEXT* labelInfo)
|
||||
{
|
||||
#ifdef VLT_DEBUG_LABEL
|
||||
pfnCmdInsertDebugUtilsLabelEXT(command, labelInfo);
|
||||
#endif // VLT_DEBUG_LABEL
|
||||
}
|
||||
|
||||
} // namespace sce::vlt
|
|
@ -1,43 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "VltCommon.h"
|
||||
|
||||
namespace sce::vlt
|
||||
{
|
||||
class VltDevice;
|
||||
|
||||
class VltDebugUtil
|
||||
{
|
||||
public:
|
||||
VltDebugUtil(VltDevice* device);
|
||||
~VltDebugUtil();
|
||||
|
||||
void setObjectName(
|
||||
VkDebugUtilsObjectNameInfoEXT* nameInfo);
|
||||
|
||||
void setObjectTag(
|
||||
VkDebugUtilsObjectTagInfoEXT* tagInfo);
|
||||
|
||||
void cmdBeginDebugUtilsLabel(
|
||||
VkCommandBuffer command, VkDebugUtilsLabelEXT* labelInfo);
|
||||
|
||||
void cmdEndDebugUtilsLabel(
|
||||
VkCommandBuffer command);
|
||||
|
||||
void cmdInsertDebugUtilsLabel(
|
||||
VkCommandBuffer command, VkDebugUtilsLabelEXT* labelInfo);
|
||||
|
||||
private:
|
||||
void setupDebugFunctions();
|
||||
|
||||
private:
|
||||
VltDevice* m_device;
|
||||
|
||||
static PFN_vkSetDebugUtilsObjectNameEXT pfnSetDebugUtilsObjectNameEXT;
|
||||
static PFN_vkSetDebugUtilsObjectTagEXT pfnSetDebugUtilsObjectTagEXT;
|
||||
|
||||
static PFN_vkCmdBeginDebugUtilsLabelEXT pfnCmdBeginDebugUtilsLabelEXT;
|
||||
static PFN_vkCmdEndDebugUtilsLabelEXT pfnCmdEndDebugUtilsLabelEXT;
|
||||
static PFN_vkCmdInsertDebugUtilsLabelEXT pfnCmdInsertDebugUtilsLabelEXT;
|
||||
};
|
||||
} // namespace sce::vlt
|
|
@ -13,10 +13,10 @@ namespace sce::vlt
|
|||
VltDevice::VltDevice(
|
||||
const Rc<VltInstance>& instance,
|
||||
const Rc<VltAdapter>& adapter,
|
||||
VkDevice device,
|
||||
const Rc<vk::DeviceFn>& vkd,
|
||||
const VltDeviceExtensions& extensions,
|
||||
const VltDeviceFeatures& features) :
|
||||
m_device(device),
|
||||
m_vkd(vkd),
|
||||
m_instance(instance),
|
||||
m_adapter(adapter),
|
||||
m_extensions(extensions),
|
||||
|
@ -74,7 +74,7 @@ namespace sce::vlt
|
|||
|
||||
void VltDevice::waitForIdle()
|
||||
{
|
||||
if (vkDeviceWaitIdle(m_device) != VK_SUCCESS)
|
||||
if (vkDeviceWaitIdle(m_vkd->device()) != VK_SUCCESS)
|
||||
Logger::err("DxvkDevice: waitForIdle: Operation failed");
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ namespace sce::vlt
|
|||
uint32_t index) const
|
||||
{
|
||||
VkQueue queue = VK_NULL_HANDLE;
|
||||
vkGetDeviceQueue(m_device, family, index, &queue);
|
||||
vkGetDeviceQueue(m_vkd->device(), family, index, &queue);
|
||||
return VltDeviceQueue{ queue, family, index };
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "VltCommon.h"
|
||||
#include "VltLoader.h"
|
||||
#include "UtilSync.h"
|
||||
#include "VltInstance.h"
|
||||
#include "VltAdapter.h"
|
||||
|
@ -64,19 +65,28 @@ namespace sce::vlt
|
|||
VltDevice(
|
||||
const Rc<VltInstance>& instance,
|
||||
const Rc<VltAdapter>& adapter,
|
||||
VkDevice device,
|
||||
const Rc<vk::DeviceFn>& vkd,
|
||||
const VltDeviceExtensions& extensions,
|
||||
const VltDeviceFeatures& features);
|
||||
|
||||
~VltDevice();
|
||||
|
||||
/**
|
||||
* \brief Vulkan device functions
|
||||
* \returns Vulkan device functions
|
||||
*/
|
||||
Rc<vk::DeviceFn> vkd() const
|
||||
{
|
||||
return m_vkd;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Logical device handle
|
||||
* \returns The device handle
|
||||
*/
|
||||
VkDevice handle() const
|
||||
{
|
||||
return m_device;
|
||||
return m_vkd->device();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -359,8 +369,7 @@ namespace sce::vlt
|
|||
uint32_t index) const;
|
||||
|
||||
private:
|
||||
VkDevice m_device;
|
||||
|
||||
Rc<vk::DeviceFn> m_vkd;
|
||||
Rc<VltInstance> m_instance;
|
||||
Rc<VltAdapter> m_adapter;
|
||||
VltDeviceExtensions m_extensions;
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace sce::vlt
|
|||
{
|
||||
VltInstance::VltInstance()
|
||||
{
|
||||
m_instance = this->createInstance();
|
||||
m_vki = new vk::InstanceFn(true, this->createInstance());
|
||||
m_adapters = this->queryAdapters();
|
||||
}
|
||||
|
||||
|
@ -22,15 +22,9 @@ namespace sce::vlt
|
|||
{
|
||||
if (m_debugMessenger != VK_NULL_HANDLE)
|
||||
{
|
||||
DestroyDebugUtilsMessengerEXT(m_instance, m_debugMessenger, nullptr);
|
||||
destroyDebugUtilsMessengerEXT(m_vki->instance(), m_debugMessenger, nullptr);
|
||||
m_debugMessenger = nullptr;
|
||||
}
|
||||
|
||||
if (m_instance != VK_NULL_HANDLE)
|
||||
{
|
||||
vkDestroyInstance(m_instance, nullptr);
|
||||
m_instance = VK_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
Rc<VltAdapter> VltInstance::enumAdapters(uint32_t index) const
|
||||
|
@ -134,7 +128,7 @@ namespace sce::vlt
|
|||
Logger::exception("DxvkInstance::createInstance: Failed to create Vulkan 1.3 instance");
|
||||
|
||||
#ifdef VLT_VALIDATION_AND_DEBUG
|
||||
status = CreateDebugUtilsMessengerEXT(result, &debugInfo, nullptr, &m_debugMessenger);
|
||||
status = createDebugUtilsMessengerEXT(result, &debugInfo, nullptr, &m_debugMessenger);
|
||||
if (status != VK_SUCCESS)
|
||||
Logger::exception("DxvkInstance::createInstance: Failed to create debug messenger.");
|
||||
#endif // VLT_VALIDATION_AND_DEBUG
|
||||
|
@ -146,11 +140,11 @@ namespace sce::vlt
|
|||
std::vector<Rc<VltAdapter>> VltInstance::queryAdapters()
|
||||
{
|
||||
uint32_t numAdapters = 0;
|
||||
if (vkEnumeratePhysicalDevices(m_instance, &numAdapters, nullptr) != VK_SUCCESS)
|
||||
if (vkEnumeratePhysicalDevices(m_vki->instance(), &numAdapters, nullptr) != VK_SUCCESS)
|
||||
Logger::exception("DxvkInstance::enumAdapters: Failed to enumerate adapters");
|
||||
|
||||
std::vector<VkPhysicalDevice> adapters(numAdapters);
|
||||
if (vkEnumeratePhysicalDevices(m_instance, &numAdapters, adapters.data()) != VK_SUCCESS)
|
||||
if (vkEnumeratePhysicalDevices(m_vki->instance(), &numAdapters, adapters.data()) != VK_SUCCESS)
|
||||
Logger::exception("DxvkInstance::enumAdapters: Failed to enumerate adapters");
|
||||
|
||||
std::vector<VkPhysicalDeviceProperties> deviceProperties(numAdapters);
|
||||
|
@ -211,7 +205,11 @@ namespace sce::vlt
|
|||
Logger::info(util::str::formatex(" ", names.name(i)));
|
||||
}
|
||||
|
||||
VkResult VltInstance::CreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pDebugMessenger)
|
||||
VkResult VltInstance::createDebugUtilsMessengerEXT(
|
||||
VkInstance instance,
|
||||
const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkDebugUtilsMessengerEXT* pDebugMessenger)
|
||||
{
|
||||
auto func = (PFN_vkCreateDebugUtilsMessengerEXT)vkGetInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT");
|
||||
if (func != nullptr)
|
||||
|
@ -224,7 +222,10 @@ namespace sce::vlt
|
|||
}
|
||||
}
|
||||
|
||||
void VltInstance::DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks* pAllocator)
|
||||
void VltInstance::destroyDebugUtilsMessengerEXT(
|
||||
VkInstance instance,
|
||||
VkDebugUtilsMessengerEXT debugMessenger,
|
||||
const VkAllocationCallbacks* pAllocator)
|
||||
{
|
||||
auto func = (PFN_vkDestroyDebugUtilsMessengerEXT)vkGetInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT");
|
||||
if (func != nullptr)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "VltCommon.h"
|
||||
#include "VltLoader.h"
|
||||
#include "VltExtension.h"
|
||||
|
||||
|
||||
|
@ -28,7 +29,7 @@ namespace sce::vlt
|
|||
*/
|
||||
VkInstance handle()
|
||||
{
|
||||
return m_instance;
|
||||
return m_vki->instance();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,13 +72,12 @@ namespace sce::vlt
|
|||
|
||||
static void logNameList(const VltNameList& names);
|
||||
|
||||
VkResult CreateDebugUtilsMessengerEXT(
|
||||
VkResult createDebugUtilsMessengerEXT(
|
||||
VkInstance instance,
|
||||
const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkDebugUtilsMessengerEXT* pDebugMessenger);
|
||||
|
||||
void DestroyDebugUtilsMessengerEXT(
|
||||
void destroyDebugUtilsMessengerEXT(
|
||||
VkInstance instance,
|
||||
VkDebugUtilsMessengerEXT debugMessenger,
|
||||
const VkAllocationCallbacks* pAllocator);
|
||||
|
@ -89,7 +89,7 @@ namespace sce::vlt
|
|||
void* pUserData);
|
||||
|
||||
private:
|
||||
VkInstance m_instance = VK_NULL_HANDLE;
|
||||
Rc<vk::InstanceFn> m_vki;
|
||||
VltInstanceExtensions m_extensions;
|
||||
|
||||
std::vector<Rc<VltAdapter>> m_adapters;
|
||||
|
|
46
GPCS4/Graphics/Violet/VltLoader.cpp
Normal file
46
GPCS4/Graphics/Violet/VltLoader.cpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
#include "VltLoader.h"
|
||||
|
||||
namespace sce::vlt::vk
|
||||
{
|
||||
InstanceLoader::InstanceLoader(bool owned, VkInstance instance) :
|
||||
m_instance(instance), m_owned(owned)
|
||||
{
|
||||
}
|
||||
|
||||
PFN_vkVoidFunction InstanceLoader::sym(const char* name) const
|
||||
{
|
||||
return vkGetInstanceProcAddr(m_instance, name);
|
||||
}
|
||||
|
||||
DeviceLoader::DeviceLoader(bool owned, VkInstance instance, VkDevice device) :
|
||||
m_getDeviceProcAddr(reinterpret_cast<PFN_vkGetDeviceProcAddr>(
|
||||
vkGetInstanceProcAddr(instance, "vkGetDeviceProcAddr"))),
|
||||
m_device(device), m_owned(owned)
|
||||
{
|
||||
}
|
||||
|
||||
PFN_vkVoidFunction DeviceLoader::sym(const char* name) const
|
||||
{
|
||||
return m_getDeviceProcAddr(m_device, name);
|
||||
}
|
||||
|
||||
InstanceFn::InstanceFn(bool owned, VkInstance instance) :
|
||||
InstanceLoader(owned, instance)
|
||||
{
|
||||
}
|
||||
InstanceFn::~InstanceFn()
|
||||
{
|
||||
if (m_owned)
|
||||
vkDestroyInstance(m_instance, nullptr);
|
||||
}
|
||||
|
||||
DeviceFn::DeviceFn(bool owned, VkInstance instance, VkDevice device) :
|
||||
DeviceLoader(owned, instance, device)
|
||||
{
|
||||
}
|
||||
DeviceFn::~DeviceFn()
|
||||
{
|
||||
if (m_owned)
|
||||
vkDestroyDevice(m_device, nullptr);
|
||||
}
|
||||
} // namespace sce::vlt
|
201
GPCS4/Graphics/Violet/VltLoader.h
Normal file
201
GPCS4/Graphics/Violet/VltLoader.h
Normal file
|
@ -0,0 +1,201 @@
|
|||
#pragma once
|
||||
|
||||
#include "VltCommon.h"
|
||||
|
||||
#define VULKAN_FN(name) \
|
||||
::PFN_ ## name name = reinterpret_cast<::PFN_ ## name>(sym(#name))
|
||||
|
||||
namespace sce::vlt::vk
|
||||
{
|
||||
/**
|
||||
* \brief Vulkan instance loader
|
||||
*
|
||||
* Loads Vulkan functions that can be
|
||||
* called for a specific instance.
|
||||
*/
|
||||
struct InstanceLoader : public RcObject
|
||||
{
|
||||
InstanceLoader(bool owned, VkInstance instance);
|
||||
PFN_vkVoidFunction sym(const char* name) const;
|
||||
VkInstance instance() const
|
||||
{
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
protected:
|
||||
const VkInstance m_instance;
|
||||
const bool m_owned;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Vulkan device loader
|
||||
*
|
||||
* Loads Vulkan functions for a
|
||||
* specific device.
|
||||
*/
|
||||
struct DeviceLoader : public RcObject
|
||||
{
|
||||
DeviceLoader(bool owned, VkInstance instance, VkDevice device);
|
||||
PFN_vkVoidFunction sym(const char* name) const;
|
||||
VkDevice device() const
|
||||
{
|
||||
return m_device;
|
||||
}
|
||||
|
||||
protected:
|
||||
const PFN_vkGetDeviceProcAddr m_getDeviceProcAddr;
|
||||
const VkDevice m_device;
|
||||
const bool m_owned;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Vulkan instance functions
|
||||
*
|
||||
* Vulkan functions for a given instance that
|
||||
* are independent of any Vulkan devices.
|
||||
*/
|
||||
struct InstanceFn : InstanceLoader
|
||||
{
|
||||
InstanceFn(bool owned, VkInstance instance);
|
||||
~InstanceFn();
|
||||
|
||||
#ifdef VK_KHR_get_surface_capabilities2
|
||||
VULKAN_FN(vkGetPhysicalDeviceSurfaceCapabilities2KHR);
|
||||
VULKAN_FN(vkGetPhysicalDeviceSurfaceFormats2KHR);
|
||||
#endif
|
||||
|
||||
#ifdef VK_KHR_surface
|
||||
VULKAN_FN(vkDestroySurfaceKHR);
|
||||
|
||||
VULKAN_FN(vkGetPhysicalDeviceSurfaceSupportKHR);
|
||||
VULKAN_FN(vkGetPhysicalDeviceSurfaceCapabilitiesKHR);
|
||||
VULKAN_FN(vkGetPhysicalDeviceSurfaceFormatsKHR);
|
||||
VULKAN_FN(vkGetPhysicalDeviceSurfacePresentModesKHR);
|
||||
#endif
|
||||
|
||||
#ifdef VK_EXT_debug_report
|
||||
VULKAN_FN(vkCreateDebugReportCallbackEXT);
|
||||
VULKAN_FN(vkDestroyDebugReportCallbackEXT);
|
||||
VULKAN_FN(vkDebugReportMessageEXT);
|
||||
#endif
|
||||
|
||||
#ifdef VK_EXT_full_screen_exclusive
|
||||
VULKAN_FN(vkGetPhysicalDeviceSurfacePresentModes2EXT);
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Vulkan device functions
|
||||
*
|
||||
* Vulkan functions for a specific Vulkan device.
|
||||
* This ensures that no slow dispatch code is executed.
|
||||
*/
|
||||
struct DeviceFn : DeviceLoader
|
||||
{
|
||||
DeviceFn(bool owned, VkInstance instance, VkDevice device);
|
||||
~DeviceFn();
|
||||
|
||||
#ifdef VK_KHR_create_renderpass2
|
||||
VULKAN_FN(vkCreateRenderPass2KHR);
|
||||
VULKAN_FN(vkCmdBeginRenderPass2KHR);
|
||||
VULKAN_FN(vkCmdNextSubpass2KHR);
|
||||
VULKAN_FN(vkCmdEndRenderPass2KHR);
|
||||
#endif
|
||||
|
||||
#ifdef VK_KHR_draw_indirect_count
|
||||
VULKAN_FN(vkCmdDrawIndirectCountKHR);
|
||||
VULKAN_FN(vkCmdDrawIndexedIndirectCountKHR);
|
||||
#endif
|
||||
|
||||
#ifdef VK_KHR_swapchain
|
||||
VULKAN_FN(vkCreateSwapchainKHR);
|
||||
VULKAN_FN(vkDestroySwapchainKHR);
|
||||
VULKAN_FN(vkGetSwapchainImagesKHR);
|
||||
VULKAN_FN(vkAcquireNextImageKHR);
|
||||
VULKAN_FN(vkQueuePresentKHR);
|
||||
#endif
|
||||
|
||||
#ifdef VK_EXT_conditional_rendering
|
||||
VULKAN_FN(vkCmdBeginConditionalRenderingEXT);
|
||||
VULKAN_FN(vkCmdEndConditionalRenderingEXT);
|
||||
#endif
|
||||
|
||||
#ifdef VK_EXT_extended_dynamic_state
|
||||
VULKAN_FN(vkCmdBindVertexBuffers2EXT);
|
||||
VULKAN_FN(vkCmdSetCullModeEXT);
|
||||
VULKAN_FN(vkCmdSetDepthBoundsTestEnableEXT);
|
||||
VULKAN_FN(vkCmdSetDepthCompareOpEXT);
|
||||
VULKAN_FN(vkCmdSetDepthTestEnableEXT);
|
||||
VULKAN_FN(vkCmdSetDepthWriteEnableEXT);
|
||||
VULKAN_FN(vkCmdSetFrontFaceEXT);
|
||||
VULKAN_FN(vkCmdSetPrimitiveTopologyEXT);
|
||||
VULKAN_FN(vkCmdSetScissorWithCountEXT);
|
||||
VULKAN_FN(vkCmdSetStencilOpEXT);
|
||||
VULKAN_FN(vkCmdSetStencilTestEnableEXT);
|
||||
VULKAN_FN(vkCmdSetViewportWithCountEXT);
|
||||
#endif
|
||||
|
||||
#ifdef VK_EXT_full_screen_exclusive
|
||||
VULKAN_FN(vkAcquireFullScreenExclusiveModeEXT);
|
||||
VULKAN_FN(vkReleaseFullScreenExclusiveModeEXT);
|
||||
VULKAN_FN(vkGetDeviceGroupSurfacePresentModes2EXT);
|
||||
#endif
|
||||
|
||||
#ifdef VK_EXT_host_query_reset
|
||||
VULKAN_FN(vkResetQueryPoolEXT);
|
||||
#endif
|
||||
|
||||
#ifdef VK_EXT_shader_module_identifier
|
||||
VULKAN_FN(vkGetShaderModuleCreateInfoIdentifierEXT);
|
||||
VULKAN_FN(vkGetShaderModuleIdentifierEXT);
|
||||
#endif
|
||||
|
||||
#ifdef VK_EXT_transform_feedback
|
||||
VULKAN_FN(vkCmdBindTransformFeedbackBuffersEXT);
|
||||
VULKAN_FN(vkCmdBeginTransformFeedbackEXT);
|
||||
VULKAN_FN(vkCmdEndTransformFeedbackEXT);
|
||||
VULKAN_FN(vkCmdDrawIndirectByteCountEXT);
|
||||
VULKAN_FN(vkCmdBeginQueryIndexedEXT);
|
||||
VULKAN_FN(vkCmdEndQueryIndexedEXT);
|
||||
#endif
|
||||
|
||||
#ifdef VK_NVX_image_view_handle
|
||||
VULKAN_FN(vkGetImageViewHandleNVX);
|
||||
VULKAN_FN(vkGetImageViewAddressNVX);
|
||||
#endif
|
||||
|
||||
#ifdef VK_NVX_binary_import
|
||||
VULKAN_FN(vkCreateCuModuleNVX);
|
||||
VULKAN_FN(vkCreateCuFunctionNVX);
|
||||
VULKAN_FN(vkDestroyCuModuleNVX);
|
||||
VULKAN_FN(vkDestroyCuFunctionNVX);
|
||||
VULKAN_FN(vkCmdCuLaunchKernelNVX);
|
||||
#endif
|
||||
|
||||
#ifdef VK_KHR_buffer_device_address
|
||||
VULKAN_FN(vkGetBufferDeviceAddressKHR);
|
||||
#endif
|
||||
|
||||
#ifdef VK_KHR_dynamic_rendering
|
||||
VULKAN_FN(vkCmdBeginRenderingKHR);
|
||||
VULKAN_FN(vkCmdEndRenderingKHR);
|
||||
#endif
|
||||
|
||||
#ifdef VK_KHR_external_memory_win32
|
||||
VULKAN_FN(vkGetMemoryWin32HandleKHR);
|
||||
VULKAN_FN(vkGetMemoryWin32HandlePropertiesKHR);
|
||||
#endif
|
||||
|
||||
#ifdef VK_EXT_debug_utils
|
||||
VULKAN_FN(vkCmdBeginDebugUtilsLabelEXT);
|
||||
VULKAN_FN(vkCmdEndDebugUtilsLabelEXT);
|
||||
VULKAN_FN(vkCmdInsertDebugUtilsLabelEXT);
|
||||
VULKAN_FN(vkCreateDebugUtilsMessengerEXT);
|
||||
VULKAN_FN(vkDestroyDebugUtilsMessengerEXT);
|
||||
VULKAN_FN(vkSetDebugUtilsObjectNameEXT);
|
||||
VULKAN_FN(vkSetDebugUtilsObjectTagEXT);
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace sce::vlt
|
Loading…
Reference in a new issue