Implement vkSetDeviceMemoryPriorityEXT and allow extensions

This commit is contained in:
baldurk
2022-11-03 12:47:13 +00:00
parent 86807180d1
commit 95ade35dab
6 changed files with 95 additions and 3 deletions
+1
View File
@@ -922,6 +922,7 @@ enum class VulkanChunk : uint32_t
vkCmdBeginRendering,
vkCmdEndRendering,
vkCmdSetFragmentShadingRateKHR,
vkSetDeviceMemoryPriorityEXT,
Max,
};
+11
View File
@@ -828,6 +828,10 @@ static const VkExtensionProperties supportedExtensions[] = {
{
VK_AMD_GPU_SHADER_INT16_EXTENSION_NAME, VK_AMD_GPU_SHADER_INT16_SPEC_VERSION,
},
{
VK_AMD_MEMORY_OVERALLOCATION_BEHAVIOR_EXTENSION_NAME,
VK_AMD_MEMORY_OVERALLOCATION_BEHAVIOR_SPEC_VERSION,
},
{
VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME, VK_AMD_MIXED_ATTACHMENT_SAMPLES_SPEC_VERSION,
},
@@ -1007,6 +1011,10 @@ static const VkExtensionProperties supportedExtensions[] = {
{
VK_EXT_MUTABLE_DESCRIPTOR_TYPE_EXTENSION_NAME, VK_EXT_MUTABLE_DESCRIPTOR_TYPE_SPEC_VERSION,
},
{
VK_EXT_PAGEABLE_DEVICE_LOCAL_MEMORY_EXTENSION_NAME,
VK_EXT_PAGEABLE_DEVICE_LOCAL_MEMORY_SPEC_VERSION,
},
{
VK_EXT_PCI_BUS_INFO_EXTENSION_NAME, VK_EXT_PCI_BUS_INFO_SPEC_VERSION,
},
@@ -3655,6 +3663,9 @@ bool WrappedVulkan::ProcessChunk(ReadSerialiser &ser, VulkanChunk chunk)
case VulkanChunk::vkCmdSetFragmentShadingRateKHR:
return Serialise_vkCmdSetFragmentShadingRateKHR(ser, VK_NULL_HANDLE, NULL, NULL);
case VulkanChunk::vkSetDeviceMemoryPriorityEXT:
return Serialise_vkSetDeviceMemoryPriorityEXT(ser, VK_NULL_HANDLE, VK_NULL_HANDLE, 0.0f);
// chunks that are reserved but not yet serialised
case VulkanChunk::vkResetCommandPool:
case VulkanChunk::vkCreateDepthTargetView:
+5
View File
@@ -2587,4 +2587,9 @@ public:
VkResult vkGetPhysicalDeviceFragmentShadingRatesKHR(
VkPhysicalDevice physicalDevice, uint32_t *pFragmentShadingRateCount,
VkPhysicalDeviceFragmentShadingRateKHR *pFragmentShadingRates);
// VK_EXT_pageable_device_local_memory
IMPLEMENT_FUNCTION_SERIALISED(void, vkSetDeviceMemoryPriorityEXT, VkDevice device,
VkDeviceMemory memory, float priority);
};
+7 -2
View File
@@ -542,7 +542,8 @@
DeclExt(EXT_vertex_input_dynamic_state); \
DeclExt(KHR_dynamic_rendering); \
DeclExt(KHR_fragment_shading_rate); \
DeclExt(EXT_attachment_feedback_loop_layout);
DeclExt(EXT_attachment_feedback_loop_layout); \
DeclExt(EXT_pageable_device_local_memory);
// for simplicity and since the check itself is platform agnostic,
// these aren't protected in platform defines
@@ -655,7 +656,8 @@
CheckExt(EXT_vertex_input_dynamic_state, VKXX); \
CheckExt(KHR_dynamic_rendering, VK13); \
CheckExt(KHR_fragment_shading_rate, VKXX); \
CheckExt(EXT_attachment_feedback_loop_layout, VKXX);
CheckExt(EXT_attachment_feedback_loop_layout, VKXX); \
CheckExt(EXT_pageable_device_local_memory, VKXX);
#define HookInitVulkanInstanceExts_PhysDev() \
HookInitExtension(KHR_surface, GetPhysicalDeviceSurfaceSupportKHR); \
@@ -913,6 +915,7 @@
HookInitPromotedExtension(KHR_dynamic_rendering, CmdBeginRendering, KHR); \
HookInitPromotedExtension(KHR_dynamic_rendering, CmdEndRendering, KHR); \
HookInitExtension(KHR_fragment_shading_rate, CmdSetFragmentShadingRateKHR); \
HookInitExtension(EXT_pageable_device_local_memory, SetDeviceMemoryPriorityEXT); \
HookInitExtension_Device_Win32(); \
HookInitExtension_Device_Linux(); \
HookInitExtension_Device_GGP(); \
@@ -1631,6 +1634,8 @@
HookDefine3(VkResult, vkGetPhysicalDeviceFragmentShadingRatesKHR, VkPhysicalDevice, \
physicalDevice, uint32_t *, pFragmentShadingRateCount, \
VkPhysicalDeviceFragmentShadingRateKHR *, pFragmentShadingRates); \
HookDefine3(void, vkSetDeviceMemoryPriorityEXT, VkDevice, device, VkDeviceMemory, memory, float, \
priority); \
HookDefine_Win32(); \
HookDefine_Linux(); \
HookDefine_GGP(); \
+2 -1
View File
@@ -28,7 +28,7 @@
template <>
rdcstr DoStringise(const VulkanChunk &el)
{
RDCCOMPILE_ASSERT((uint32_t)VulkanChunk::Max == 1176, "Chunks changed without updating names");
RDCCOMPILE_ASSERT((uint32_t)VulkanChunk::Max == 1177, "Chunks changed without updating names");
BEGIN_ENUM_STRINGISE(VulkanChunk)
{
@@ -208,6 +208,7 @@ rdcstr DoStringise(const VulkanChunk &el)
STRINGISE_ENUM_CLASS(vkCmdBeginRendering)
STRINGISE_ENUM_CLASS(vkCmdEndRendering)
STRINGISE_ENUM_CLASS(vkCmdSetFragmentShadingRateKHR)
STRINGISE_ENUM_CLASS(vkSetDeviceMemoryPriorityEXT)
STRINGISE_ENUM_CLASS_NAMED(Max, "Max Chunk");
}
END_ENUM_STRINGISE()
@@ -3019,6 +3019,72 @@ VkResult WrappedVulkan::vkBindImageMemory2(VkDevice device, uint32_t bindInfoCou
return ret;
}
template <typename SerialiserType>
bool WrappedVulkan::Serialise_vkSetDeviceMemoryPriorityEXT(SerialiserType &ser, VkDevice device,
VkDeviceMemory memory, float priority)
{
SERIALISE_ELEMENT(device);
SERIALISE_ELEMENT(memory);
SERIALISE_ELEMENT(priority);
SERIALISE_CHECK_READ_ERRORS();
if(IsReplayingAndReading())
{
ObjDisp(device)->SetDeviceMemoryPriorityEXT(Unwrap(device), Unwrap(memory), priority);
AddResourceCurChunk(GetResourceManager()->GetOriginalID(GetResID(memory)));
}
return true;
}
void WrappedVulkan::vkSetDeviceMemoryPriorityEXT(VkDevice device, VkDeviceMemory memory,
float priority)
{
SERIALISE_TIME_CALL(
ObjDisp(device)->SetDeviceMemoryPriorityEXT(Unwrap(device), Unwrap(memory), priority));
// deliberately only serialise this while idle. If we serialised it while active we'd need
// arguably to track the priority to restore it each replay, and there's a high chance that during
// capture the program might start setting priorities in response to the overhead of capturing
if(IsBackgroundCapturing(m_State))
{
Chunk *chunk = NULL;
{
CACHE_THREAD_SERIALISER();
SCOPED_SERIALISE_CHUNK(VulkanChunk::vkSetDeviceMemoryPriorityEXT);
Serialise_vkSetDeviceMemoryPriorityEXT(ser, device, memory, priority);
chunk = scope.Get();
}
VkResourceRecord *r = GetRecord(memory);
// remove any previous memory priority chunks on the tail of the list. Memory records will not
// have anything else in here so this keeps redundancy to a minimum
r->LockChunks();
for(;;)
{
Chunk *end = r->GetLastChunk();
if(end->GetChunkType<VulkanChunk>() == VulkanChunk::vkSetDeviceMemoryPriorityEXT)
{
end->Delete();
r->PopChunk();
continue;
}
break;
}
r->UnlockChunks();
r->AddChunk(chunk);
}
}
INSTANTIATE_FUNCTION_SERIALISED(VkResult, vkAllocateMemory, VkDevice device,
const VkMemoryAllocateInfo *pAllocateInfo,
const VkAllocationCallbacks *pAllocator, VkDeviceMemory *pMemory);
@@ -3055,3 +3121,6 @@ INSTANTIATE_FUNCTION_SERIALISED(VkResult, vkBindBufferMemory2, VkDevice device,
INSTANTIATE_FUNCTION_SERIALISED(VkResult, vkBindImageMemory2, VkDevice device,
uint32_t bindInfoCount, const VkBindImageMemoryInfo *pBindInfos);
INSTANTIATE_FUNCTION_SERIALISED(void, vkSetDeviceMemoryPriorityEXT, VkDevice device,
VkDeviceMemory memory, float priority);