renderer_vulkan: Fix pipeline cache crashes

This commit is contained in:
emufan4568
2022-10-10 20:36:43 +03:00
committed by GPUCode
parent 9991b9b12b
commit 628d70e112
2 changed files with 3 additions and 2 deletions

View File

@ -534,12 +534,13 @@ void PipelineCache::LoadDiskCache() {
instance.GetVendorID(), instance.GetDeviceID()); instance.GetVendorID(), instance.GetDeviceID());
vk::PipelineCacheCreateInfo cache_info = {.initialDataSize = 0, .pInitialData = nullptr}; vk::PipelineCacheCreateInfo cache_info = {.initialDataSize = 0, .pInitialData = nullptr};
std::vector<u8> cache_data;
FileUtil::IOFile cache_file{cache_file_path, "r"}; FileUtil::IOFile cache_file{cache_file_path, "r"};
if (cache_file.IsOpen()) { if (cache_file.IsOpen()) {
LOG_INFO(Render_Vulkan, "Loading pipeline cache"); LOG_INFO(Render_Vulkan, "Loading pipeline cache");
const u32 cache_file_size = cache_file.GetSize(); const u32 cache_file_size = cache_file.GetSize();
auto cache_data = std::vector<u8>(cache_file_size); cache_data.resize(cache_file_size);
if (cache_file.ReadBytes(cache_data.data(), cache_file_size)) { if (cache_file.ReadBytes(cache_data.data(), cache_file_size)) {
if (!IsCacheValid(cache_data.data(), cache_file_size)) { if (!IsCacheValid(cache_data.data(), cache_file_size)) {
LOG_WARNING(Render_Vulkan, "Pipeline cache provided invalid, deleting"); LOG_WARNING(Render_Vulkan, "Pipeline cache provided invalid, deleting");

View File

@ -439,7 +439,7 @@ void RasterizerVulkan::SetupVertexArray(u32 vs_input_size, u32 vs_input_index_mi
// Loop one more time to find unused attributes and assign them to the default one // Loop one more time to find unused attributes and assign them to the default one
// This needs to happen because i = 2 might be assigned to location = 3 so the loop // This needs to happen because i = 2 might be assigned to location = 3 so the loop
// above would skip setting it // above would skip setting it
for (std::size_t i = 0; i < 16; i++) { for (u32 i = 0; i < 16; i++) {
// If the attribute is just disabled, shove the default attribute to avoid // If the attribute is just disabled, shove the default attribute to avoid
// errors if the shader ever decides to use it. The pipeline cache can discard // errors if the shader ever decides to use it. The pipeline cache can discard
// this if needed since it has access to the usage mask from the code generator // this if needed since it has access to the usage mask from the code generator