From 51bcb029217668ab7fa74f00e3d2a1246d547621 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sat, 14 May 2016 16:29:40 +0200 Subject: [PATCH] Minor vulkan updates to match the latest SDK/validator --- GPU/Vulkan/FramebufferVulkan.cpp | 1 + GPU/Vulkan/TextureCacheVulkan.cpp | 12 +++++++----- GPU/Vulkan/VertexShaderGeneratorVulkan.cpp | 2 +- Windows/GPU/WindowsVulkanContext.cpp | 8 ++------ ext/native/thin3d/thin3d.cpp | 6 ++++-- ext/native/thin3d/thin3d_vulkan.cpp | 8 +++++--- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/GPU/Vulkan/FramebufferVulkan.cpp b/GPU/Vulkan/FramebufferVulkan.cpp index 5fefbc7c3ea2..bef4600ff616 100644 --- a/GPU/Vulkan/FramebufferVulkan.cpp +++ b/GPU/Vulkan/FramebufferVulkan.cpp @@ -71,6 +71,7 @@ static const char tex_vs[] = R"(#version 400 layout (location = 0) in vec3 a_position; layout (location = 1) in vec2 a_texcoord0; layout (location = 0) out vec2 v_texcoord0; +out gl_PerVertex { vec4 gl_Position; }; void main() { v_texcoord0 = a_texcoord0; gl_Position = vec4(a_position, 1.0); diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 46629b61a290..d3bb0bc15928 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -858,12 +858,14 @@ void TextureCacheVulkan::ApplyTextureFramebuffer(VkCommandBuffer cmd, TexCacheEn sampler = GetOrCreateSampler(samplerKey); */ - SamplerCacheKey key; - UpdateSamplingParams(*entry, key); - key.mipEnable = false; - sampler = samplerCache_.GetOrCreateSampler(key); + if (entry->vkTex) { + SamplerCacheKey key; + UpdateSamplingParams(*entry, key); + key.mipEnable = false; + sampler = samplerCache_.GetOrCreateSampler(key); - lastBoundTexture = nullptr; + lastBoundTexture = nullptr; + } } bool TextureCacheVulkan::SetOffsetTexture(u32 offset) { diff --git a/GPU/Vulkan/VertexShaderGeneratorVulkan.cpp b/GPU/Vulkan/VertexShaderGeneratorVulkan.cpp index 71af616400c0..2775a83fa8ee 100644 --- a/GPU/Vulkan/VertexShaderGeneratorVulkan.cpp +++ b/GPU/Vulkan/VertexShaderGeneratorVulkan.cpp @@ -223,7 +223,7 @@ bool GenerateVulkanGLSLVertexShader(const ShaderID &id, char *buffer, bool *uses WRITE(p, " return vec4(v.x, v.y, z * v.w, v.w);\n"); WRITE(p, "}\n\n"); } - + WRITE(p, "out gl_PerVertex { vec4 gl_Position; };\n"); WRITE(p, "void main() {\n"); if (!useHWTransform) { diff --git a/Windows/GPU/WindowsVulkanContext.cpp b/Windows/GPU/WindowsVulkanContext.cpp index fb9b27f87985..5aeab2ba3d2e 100644 --- a/Windows/GPU/WindowsVulkanContext.cpp +++ b/Windows/GPU/WindowsVulkanContext.cpp @@ -125,16 +125,12 @@ static VkBool32 VKAPI_CALL Vulkan_Dbg(VkDebugReportFlagsEXT msgFlags, VkDebugRep } message << "[" << pLayerPrefix << "] " << ObjTypeToString(objType) << " Code " << msgCode << " : " << pMsg << "\n"; - // validator or glslang bug (validator #298) - if (msgCode == 15 && startsWith(pMsg, "Shader requires")) - return false; - // layout barrier. TODO: This one I should fix. if (msgCode == 7 && startsWith(pMsg, "Cannot submit cmd buffer")) return false; - // memory free'd while still holding a ref. validator bug? or worrying... - if (msgCode == 6 && startsWith(pMsg, "Attempting to free memory")) + // Another validator bug (vkBindImageMemory false positive) + if (msgCode == 15 && startsWith(pMsg, "In vkBindImageMemory, attempting")) return false; // another validator bug (validator #299) diff --git a/ext/native/thin3d/thin3d.cpp b/ext/native/thin3d/thin3d.cpp index ccc4c216c1b7..677eb122aacf 100644 --- a/ext/native/thin3d/thin3d.cpp +++ b/ext/native/thin3d/thin3d.cpp @@ -84,7 +84,7 @@ static const char * const hlslVsCol = "}\n"; static const char * const vulkan_vsCol = -"#version 140\n" +"#version 400\n" "#extension GL_ARB_separate_shader_objects : enable\n" "#extension GL_ARB_shading_language_420pack : enable\n" "layout (std140, set = 0, binding = 0) uniform bufferVals {\n" @@ -93,6 +93,7 @@ static const char * const vulkan_vsCol = "layout (location = 0) in vec4 pos;\n" "layout (location = 1) in vec4 inColor;\n" "layout (location = 0) out vec4 outColor;\n" +"out gl_PerVertex { vec4 gl_Position; };\n" "void main() {\n" " outColor = inColor;\n" " gl_Position = myBufferVals.WorldViewProj * pos;\n" @@ -125,7 +126,7 @@ static const char * const hlslVsTexCol = "}\n"; static const char * const vulkan_vsTexCol = -"#version 140\n" +"#version 400\n" "#extension GL_ARB_separate_shader_objects : enable\n" "#extension GL_ARB_shading_language_420pack : enable\n" "layout (std140, set = 0, binding = 0) uniform bufferVals {\n" @@ -136,6 +137,7 @@ static const char * const vulkan_vsTexCol = "layout (location = 2) in vec2 inTexCoord;\n" "layout (location = 0) out vec4 outColor;\n" "layout (location = 1) out vec2 outTexCoord;\n" +"out gl_PerVertex { vec4 gl_Position; };\n" "void main() {\n" " outColor = inColor;\n" " outTexCoord = inTexCoord;\n" diff --git a/ext/native/thin3d/thin3d_vulkan.cpp b/ext/native/thin3d/thin3d_vulkan.cpp index 9ae2ed90fa0b..5b5cf1b0841a 100644 --- a/ext/native/thin3d/thin3d_vulkan.cpp +++ b/ext/native/thin3d/thin3d_vulkan.cpp @@ -194,7 +194,9 @@ class Thin3DVKShader : public Thin3DShader { bool Compile(VulkanContext *vulkan, const char *source); const std::string &GetSource() const { return source_; } ~Thin3DVKShader() { - vkDestroyShaderModule(device_, module_, nullptr); + if (module_) { + vkDestroyShaderModule(device_, module_, nullptr); + } } VkShaderModule Get() const { return module_; } @@ -548,7 +550,6 @@ class Thin3DVKTexture : public Thin3DTexture { } bool Create(T3DTextureType type, T3DImageFormat format, int width, int height, int depth, int mipLevels) override { - ILOG("texture created: %p", this); format_ = format; mipLevels_ = mipLevels; width_ = width; @@ -567,7 +568,6 @@ class Thin3DVKTexture : public Thin3DTexture { private: void Destroy() { - ILOG("texture destroyed: %p", this); if (vkTex_) { vkTex_->Destroy(); delete vkTex_; @@ -1012,6 +1012,7 @@ Thin3DShader *Thin3DVKContext::CreateVertexShader(const char *glsl_source, const if (shader->Compile(vulkan_, vulkan_source)) { return shader; } else { + ELOG("Failed to compile shader: %s", vulkan_source); shader->Release(); return nullptr; } @@ -1022,6 +1023,7 @@ Thin3DShader *Thin3DVKContext::CreateFragmentShader(const char *glsl_source, con if (shader->Compile(vulkan_, vulkan_source)) { return shader; } else { + ELOG("Failed to compile shader: %s", vulkan_source); shader->Release(); return nullptr; }