diff --git a/Common/Vulkan/VulkanContext.cpp b/Common/Vulkan/VulkanContext.cpp index b6cb846d24..b1a0064045 100644 --- a/Common/Vulkan/VulkanContext.cpp +++ b/Common/Vulkan/VulkanContext.cpp @@ -136,13 +136,6 @@ VkResult VulkanContext::CreateInstance(const char *app_name, int app_ver, uint32 // init_error_ = "Failed to validate instance layers"; // return; } - - GetDeviceLayerProperties(); - if (!CheckLayers(device_layer_properties_, device_layer_names_)) { - WLOG("CheckLayers failed (2)"); - // init_error_ = "Failed to validate device layers"; - // return; - } return VK_SUCCESS; } @@ -534,6 +527,13 @@ bool VulkanContext::CheckLayers(const std::vector &layer_props, void VulkanContext::ChooseDevice(int physical_device) { physical_device_ = physical_device; + GetDeviceLayerProperties(); + if (!CheckLayers(device_layer_properties_, device_layer_names_)) { + WLOG("CheckLayers failed (2)"); + // init_error_ = "Failed to validate device layers"; + // return; + } + vkGetPhysicalDeviceQueueFamilyProperties(physical_devices_[physical_device_], &queue_count, nullptr); assert(queue_count >= 1); diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 7b1e447633..c6ebda7579 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -1009,21 +1009,25 @@ void ShaderManagerGLES::LoadAndPrecompile(const std::string &filename) { time_update(); double start = time_now_d(); + // Sanity check the file contents + if (header.numFragmentShaders > 1000 || header.numVertexShaders > 1000 || header.numLinkedPrograms > 1000) + return; + for (int i = 0; i < header.numVertexShaders; i++) { ShaderID id; if (!f.ReadArray(&id, 1)) { ERROR_LOG(G3D, "Truncated shader cache file, aborting."); return; } - Shader *vs = CompileVertexShader(id); - if (vs->Failed()) { - // Give up on using the cache, just bail. We can't safely create the fallback shaders here - // without trying to deduce the vertType from the VSID. - ERROR_LOG(G3D, "Failed to compile a vertex shader loading from cache. Skipping rest of shader cache."); - delete vs; - return; - } if (!vsCache_.Get(id)) { + Shader *vs = CompileVertexShader(id); + if (vs->Failed()) { + // Give up on using the cache, just bail. We can't safely create the fallback shaders here + // without trying to deduce the vertType from the VSID. + ERROR_LOG(G3D, "Failed to compile a vertex shader loading from cache. Skipping rest of shader cache."); + delete vs; + return; + } vsCache_.Insert(id, vs); } else { WARN_LOG(G3D, "Duplicate vertex shader found in GL shader cache, ignoring");