vulkan UI
This commit is contained in:
parent
f8e142fb06
commit
177f873639
13 changed files with 455 additions and 37 deletions
|
|
@ -70,7 +70,8 @@ const char* const deviceExtensionNames[] = {
|
|||
"VK_EXT_descriptor_heap",
|
||||
"VK_KHR_deferred_host_operations",
|
||||
"VK_KHR_maintenance5",
|
||||
"VK_KHR_shader_untyped_pointers"
|
||||
"VK_KHR_shader_untyped_pointers",
|
||||
"VK_EXT_device_fault"
|
||||
};
|
||||
const char* const layerNames[] = {
|
||||
"VK_LAYER_KHRONOS_validation"
|
||||
|
|
@ -80,6 +81,58 @@ const char* const layerNames[] = {
|
|||
void Device::CheckVkResult(VkResult result) {
|
||||
if (result != VK_SUCCESS)
|
||||
{
|
||||
if(result == VK_ERROR_DEVICE_LOST) {
|
||||
VkDeviceFaultCountsEXT faultCounts = {
|
||||
.sType = VK_STRUCTURE_TYPE_DEVICE_FAULT_COUNTS_EXT,
|
||||
.pNext = NULL,
|
||||
};
|
||||
Device::vkGetDeviceFaultInfoEXT(device, &faultCounts, NULL);
|
||||
|
||||
std::vector<VkDeviceFaultAddressInfoEXT> addressInfos(faultCounts.addressInfoCount);
|
||||
std::vector<VkDeviceFaultVendorInfoEXT> vendorInfos(faultCounts.vendorInfoCount);
|
||||
std::vector<char> vendorBinaryData(faultCounts.vendorBinarySize);
|
||||
|
||||
VkDeviceFaultInfoEXT faultInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_DEVICE_FAULT_INFO_EXT,
|
||||
.pNext = NULL,
|
||||
.pAddressInfos = addressInfos.data(),
|
||||
.pVendorInfos = vendorInfos.data(),
|
||||
.pVendorBinaryData = vendorBinaryData.data(),
|
||||
};
|
||||
Device::vkGetDeviceFaultInfoEXT(device, &faultCounts, &faultInfo);
|
||||
|
||||
std::println("{}", faultInfo.description);
|
||||
|
||||
std::println("{} AddressInfos:", addressInfos.size());
|
||||
for(const VkDeviceFaultAddressInfoEXT& info : addressInfos) {
|
||||
std::println("\t{} {}", static_cast<uint32_t>(info.addressType), info.reportedAddress);
|
||||
}
|
||||
|
||||
std::println("{} vendorInfos:", vendorInfos.size());
|
||||
for(const VkDeviceFaultVendorInfoEXT& info : vendorInfos) {
|
||||
std::println("\t{} {} {}", info.description, info.vendorFaultCode, info.vendorFaultData);
|
||||
}
|
||||
|
||||
if(!vendorBinaryData.empty()) {
|
||||
std::string ext = ".bin";
|
||||
if(vendorBinaryData.size() >= sizeof(VkDeviceFaultVendorBinaryHeaderVersionOneEXT)) {
|
||||
VkDeviceFaultVendorBinaryHeaderVersionOneEXT header;
|
||||
std::memcpy(&header, vendorBinaryData.data(), sizeof(header));
|
||||
if(header.vendorID == 0x10DE) { // NVIDIA
|
||||
ext = ".nv-gpudmp";
|
||||
}
|
||||
}
|
||||
const auto now = std::chrono::system_clock::now();
|
||||
const std::string dumpPath = std::format("gpu_crash_dump-{:%Y%m%d-%H%M%S}{}", now, ext);
|
||||
std::ofstream file(dumpPath, std::ios::binary);
|
||||
if(file.write(vendorBinaryData.data(), vendorBinaryData.size())) {
|
||||
std::println("Vendor binary saved to: {}", std::filesystem::canonical(dumpPath).string());
|
||||
} else {
|
||||
std::println(stderr, "Failed to write vendor binary to: {}", dumpPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw std::runtime_error(string_VkResult(result));
|
||||
}
|
||||
}
|
||||
|
|
@ -603,8 +656,24 @@ void Device::Initialize() {
|
|||
queueCreateInfo.queueCount = 1;
|
||||
queueCreateInfo.pQueuePriorities = &priority;
|
||||
|
||||
VkPhysicalDeviceFaultFeaturesEXT faultFeatures2 = {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FAULT_FEATURES_EXT,
|
||||
};
|
||||
VkPhysicalDeviceFeatures2 features22 = {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2,
|
||||
.pNext = &faultFeatures2,
|
||||
};
|
||||
vkGetPhysicalDeviceFeatures2(physDevice, &features22);
|
||||
|
||||
VkPhysicalDeviceFaultFeaturesEXT faultFeatures = {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FAULT_FEATURES_EXT,
|
||||
.deviceFault = VK_TRUE,
|
||||
.deviceFaultVendorBinary = faultFeatures2.deviceFaultVendorBinary,
|
||||
};
|
||||
|
||||
VkPhysicalDeviceShaderUntypedPointersFeaturesKHR untypedPointersFeatures {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_UNTYPED_POINTERS_FEATURES_KHR,
|
||||
.pNext = &faultFeatures,
|
||||
.shaderUntypedPointers = VK_TRUE,
|
||||
};
|
||||
|
||||
|
|
@ -623,6 +692,7 @@ void Device::Initialize() {
|
|||
VkPhysicalDeviceVulkan12Features features12 {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES,
|
||||
.pNext = &bit16,
|
||||
.shaderFloat16 = VK_TRUE,
|
||||
.runtimeDescriptorArray = VK_TRUE,
|
||||
.bufferDeviceAddress = VK_TRUE
|
||||
};
|
||||
|
|
@ -703,6 +773,7 @@ void Device::Initialize() {
|
|||
vkCmdBindSamplerHeapEXT = reinterpret_cast<PFN_vkCmdBindSamplerHeapEXT>(vkGetInstanceProcAddr(instance, "vkCmdBindSamplerHeapEXT"));
|
||||
vkWriteResourceDescriptorsEXT = reinterpret_cast<PFN_vkWriteResourceDescriptorsEXT>(vkGetInstanceProcAddr(instance, "vkWriteResourceDescriptorsEXT"));
|
||||
vkGetPhysicalDeviceDescriptorSizeEXT = reinterpret_cast<PFN_vkGetPhysicalDeviceDescriptorSizeEXT>(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceDescriptorSizeEXT"));
|
||||
vkGetDeviceFaultInfoEXT = reinterpret_cast<PFN_vkGetDeviceFaultInfoEXT>(vkGetInstanceProcAddr(instance, "vkGetDeviceFaultInfoEXT"));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue