From db6763019d08e8b47b640054595350a21793afd0 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 28 Feb 2019 20:19:37 +1000 Subject: [PATCH 1/3] TextureCache: Fix GPU decoding of XFB copies not falling back to CPU --- Source/Core/VideoCommon/TextureCacheBase.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 3beaeedbf8..19719a2189 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -1593,12 +1593,12 @@ void TextureCacheBase::LoadTextureLevelZeroFromMemory(TCacheEntry* entry_to_upda const u8* tlut = &texMem[tex_info.tlut_address]; if (!decode_on_gpu || - DecodeTextureOnGPU(entry_to_update, 0, tex_info.src_data, tex_info.total_bytes, - tex_info.full_format.texfmt, tex_info.native_width, tex_info.native_height, - tex_info.expanded_width, tex_info.expanded_height, - tex_info.bytes_per_block * - (tex_info.expanded_width / tex_info.block_width), - tlut, tex_info.full_format.tlutfmt)) + !DecodeTextureOnGPU(entry_to_update, 0, tex_info.src_data, tex_info.total_bytes, + tex_info.full_format.texfmt, tex_info.native_width, + tex_info.native_height, tex_info.expanded_width, tex_info.expanded_height, + tex_info.bytes_per_block * + (tex_info.expanded_width / tex_info.block_width), + tlut, tex_info.full_format.tlutfmt)) { size_t decoded_texture_size = tex_info.expanded_width * sizeof(u32) * tex_info.expanded_height; CheckTempSize(decoded_texture_size); From 21d81f99ff9d51cb1dd845260e8655753bf0db4b Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 28 Feb 2019 20:35:17 +1000 Subject: [PATCH 2/3] VideoBackends: Fix GPU decoding of XFB buffers Was using UNORM instead of UINT, resulting in invalid values. --- Source/Core/VideoBackends/D3D/VertexManager.cpp | 2 +- Source/Core/VideoBackends/OGL/VertexManager.cpp | 2 +- Source/Core/VideoBackends/Vulkan/VertexManager.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/VideoBackends/D3D/VertexManager.cpp b/Source/Core/VideoBackends/D3D/VertexManager.cpp index 5159be74de..479f601037 100644 --- a/Source/Core/VideoBackends/D3D/VertexManager.cpp +++ b/Source/Core/VideoBackends/D3D/VertexManager.cpp @@ -108,7 +108,7 @@ bool VertexManager::Initialize() format_mapping = {{ {TEXEL_BUFFER_FORMAT_R8_UINT, DXGI_FORMAT_R8_UINT}, {TEXEL_BUFFER_FORMAT_R16_UINT, DXGI_FORMAT_R16_UINT}, - {TEXEL_BUFFER_FORMAT_RGBA8_UINT, DXGI_FORMAT_R8G8B8A8_UNORM}, + {TEXEL_BUFFER_FORMAT_RGBA8_UINT, DXGI_FORMAT_R8G8B8A8_UINT}, {TEXEL_BUFFER_FORMAT_R32G32_UINT, DXGI_FORMAT_R32G32_UINT}, }}; for (const auto& it : format_mapping) diff --git a/Source/Core/VideoBackends/OGL/VertexManager.cpp b/Source/Core/VideoBackends/OGL/VertexManager.cpp index 543a85dac8..60bac67ee9 100644 --- a/Source/Core/VideoBackends/OGL/VertexManager.cpp +++ b/Source/Core/VideoBackends/OGL/VertexManager.cpp @@ -75,7 +75,7 @@ bool VertexManager::Initialize() format_mapping = {{ {TEXEL_BUFFER_FORMAT_R8_UINT, GL_R8UI}, {TEXEL_BUFFER_FORMAT_R16_UINT, GL_R16UI}, - {TEXEL_BUFFER_FORMAT_RGBA8_UINT, GL_RGBA8}, + {TEXEL_BUFFER_FORMAT_RGBA8_UINT, GL_RGBA8UI}, {TEXEL_BUFFER_FORMAT_R32G32_UINT, GL_RG32UI}, }}; glGenTextures(static_cast(m_texel_buffer_views.size()), m_texel_buffer_views.data()); diff --git a/Source/Core/VideoBackends/Vulkan/VertexManager.cpp b/Source/Core/VideoBackends/Vulkan/VertexManager.cpp index 7fcbf84013..336d3ad480 100644 --- a/Source/Core/VideoBackends/Vulkan/VertexManager.cpp +++ b/Source/Core/VideoBackends/Vulkan/VertexManager.cpp @@ -101,7 +101,7 @@ bool VertexManager::Initialize() format_mapping = {{ {TEXEL_BUFFER_FORMAT_R8_UINT, VK_FORMAT_R8_UINT}, {TEXEL_BUFFER_FORMAT_R16_UINT, VK_FORMAT_R16_UINT}, - {TEXEL_BUFFER_FORMAT_RGBA8_UINT, VK_FORMAT_R8G8B8A8_UNORM}, + {TEXEL_BUFFER_FORMAT_RGBA8_UINT, VK_FORMAT_R8G8B8A8_UINT}, {TEXEL_BUFFER_FORMAT_R32G32_UINT, VK_FORMAT_R32G32_UINT}, }}; for (const auto& it : format_mapping) From 8192c0dd48c9dd5afe835ebc94ed45e477c3b12e Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 28 Feb 2019 20:35:48 +1000 Subject: [PATCH 3/3] TextureConversionShader: Fix XFB decoding shader for D3D D3D has no mix() equivalent with a bool parameter. Compilers should be able to optimize the ternary into a select anyway. --- Source/Core/VideoCommon/TextureConversionShader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/VideoCommon/TextureConversionShader.cpp b/Source/Core/VideoCommon/TextureConversionShader.cpp index 7359c2aea3..da900ff72a 100644 --- a/Source/Core/VideoCommon/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/TextureConversionShader.cpp @@ -1345,7 +1345,7 @@ static const std::map s_decoding_shader_info{ int buffer_pos = int(u_src_offset + (uv.y * u_src_row_stride) + (uv.x / 2u)); float4 yuyv = float4(texelFetch(s_input_buffer, buffer_pos)); - float y = mix(yuyv.r, yuyv.b, (uv.x & 1u) == 1u); + float y = (uv.x & 1u) != 0u ? yuyv.r : yuyv.g; float yComp = 1.164 * (y - 16.0); float uComp = yuyv.g - 128.0;