From 78d5fff2fe87e8d9ecd6a99e7c6d5f6dcffe40e4 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sat, 9 Jan 2016 21:54:57 +0100 Subject: [PATCH] More texture work --- GPU/Vulkan/GPU_Vulkan.cpp | 2 +- GPU/Vulkan/ShaderManagerVulkan.h | 3 ++- GPU/Vulkan/TextureCacheVulkan.cpp | 22 ++++++++++++++-------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 2410bb1322..426b004252 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -320,7 +320,7 @@ static const CommandTableEntry commandTable[] = { { GE_CMD_BOUNDINGBOX, FLAG_EXECUTE, 0, &GPU_Vulkan::Execute_BoundingBox }, // + FLUSHBEFORE when we implement... or not, do we need to? // Changing the vertex type requires us to flush. - { GE_CMD_VERTEXTYPE, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_Vulkan::Execute_VertexType }, + { GE_CMD_VERTEXTYPE, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_PROJMATRIX, &GPU_Vulkan::Execute_VertexType }, { GE_CMD_BEZIER, FLAG_FLUSHBEFORE | FLAG_EXECUTE, 0, &GPU_Vulkan::Execute_Bezier }, { GE_CMD_SPLINE, FLAG_FLUSHBEFORE | FLAG_EXECUTE, 0, &GPU_Vulkan::Execute_Spline }, diff --git a/GPU/Vulkan/ShaderManagerVulkan.h b/GPU/Vulkan/ShaderManagerVulkan.h index 82b0d0e600..0c3eb7385a 100644 --- a/GPU/Vulkan/ShaderManagerVulkan.h +++ b/GPU/Vulkan/ShaderManagerVulkan.h @@ -34,6 +34,7 @@ void ConvertProjMatrixToVulkan(Matrix4x4 & in); // Pretty much full. Will need more bits for more fine grained dirty tracking for lights. enum { DIRTY_PROJMATRIX = (1 << 0), + // 1 << 1 is free DIRTY_FOGCOLOR = (1 << 2), DIRTY_FOGCOEF = (1 << 3), DIRTY_TEXENV = (1 << 4), @@ -58,7 +59,7 @@ enum { DIRTY_DEPTHRANGE = (1 << 20), DIRTY_WORLDMATRIX = (1 << 21), - DIRTY_VIEWMATRIX = (1 << 22), // Maybe we'll fold this into projmatrix eventually + DIRTY_VIEWMATRIX = (1 << 22), DIRTY_TEXMATRIX = (1 << 23), DIRTY_BONEMATRIX0 = (1 << 24), DIRTY_BONEMATRIX1 = (1 << 25), diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index b988398a3f..900f169890 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -1281,6 +1281,7 @@ void TextureCacheVulkan::SetTexture() { lastBoundTexture = nullptr; } delete entry->vkTex; + entry->vkTex = nullptr; } } // Clear the reliable bit if set. @@ -1363,10 +1364,6 @@ void TextureCacheVulkan::SetTexture() { return; } - entry->vkTex = new CachedTextureVulkan(); - - lastBoundTexture = entry->vkTex; - // Adjust maxLevel to actually present levels.. bool badMipSizes = false; for (u32 i = 0; i <= maxLevel; i++) { @@ -1443,9 +1440,17 @@ void TextureCacheVulkan::SetTexture() { } // Ready or not, here I go... - entry->vkTex->texture_ = new VulkanTexture(); - VulkanTexture *image = entry->vkTex->texture_; - image->Create(vulkan_, w, h, dstFmt); + if (replaceImages) { + if (!entry->vkTex) { + DebugBreak(); + } + } else { + entry->vkTex = new CachedTextureVulkan(); + entry->vkTex->texture_ = new VulkanTexture(); + VulkanTexture *image = entry->vkTex->texture_; + image->Create(vulkan_, w, h, dstFmt); + } + lastBoundTexture = entry->vkTex; // GLES2 doesn't have support for a "Max lod" which is critical as PSP games often // don't specify mips all the way down. As a result, we either need to manually generate @@ -1453,6 +1458,7 @@ void TextureCacheVulkan::SetTexture() { // be as good quality as the game's own (might even be better in some cases though). // Always load base level texture here + LoadTextureLevel(*entry, 0, replaceImages, scaleFactor, dstFmt); // Mipmapping only enable when texture scaling disable @@ -1790,7 +1796,7 @@ void TextureCacheVulkan::LoadTextureLevel(TexCacheEntry &entry, int level, bool if (replaceImages) { // TODO: No support for texture shadows - DebugBreak(); + // DebugBreak(); } PROFILE_THIS_SCOPE("loadtex");