Permalink
Browse files

Fix bug in vulkan init. Add some sanity checks to GL shader cache loa…

…ding.
  • Loading branch information...
hrydgard committed Aug 28, 2017
1 parent 6a0f657 commit 871fa713edb4ad20b34fc5850b0706c343bd2a01
Showing with 19 additions and 15 deletions.
  1. +7 −7 Common/Vulkan/VulkanContext.cpp
  2. +12 −8 GPU/GLES/ShaderManagerGLES.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<LayerProperties> &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);
@@ -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");

0 comments on commit 871fa71

Please sign in to comment.