Skip to content

Commit

Permalink
Minor vulkan updates to match the latest SDK/validator
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed May 14, 2016
1 parent 0541fe3 commit 51bcb02
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 17 deletions.
1 change: 1 addition & 0 deletions GPU/Vulkan/FramebufferVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 7 additions & 5 deletions GPU/Vulkan/TextureCacheVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion GPU/Vulkan/VertexShaderGeneratorVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 2 additions & 6 deletions Windows/GPU/WindowsVulkanContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions ext/native/thin3d/thin3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down
8 changes: 5 additions & 3 deletions ext/native/thin3d/thin3d_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_; }

Expand Down Expand Up @@ -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;
Expand All @@ -567,7 +568,6 @@ class Thin3DVKTexture : public Thin3DTexture {

private:
void Destroy() {
ILOG("texture destroyed: %p", this);
if (vkTex_) {
vkTex_->Destroy();
delete vkTex_;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 51bcb02

Please sign in to comment.