From 7909860d16118f3db5006ccd379c1dae27eb5a1b Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Thu, 30 Apr 2020 12:17:02 -0400 Subject: texture: Implement R8G8UI - Used by The Walking Dead: The Final Season --- src/video_core/gpu.h | 1 + src/video_core/morton.cpp | 2 + .../renderer_opengl/gl_texture_cache.cpp | 1 + src/video_core/renderer_vulkan/maxwell_to_vk.cpp | 1 + src/video_core/renderer_vulkan/vk_device.cpp | 1 + src/video_core/surface.cpp | 2 + src/video_core/surface.h | 79 ++++++++++++---------- .../texture_cache/format_lookup_table.cpp | 3 +- 8 files changed, 52 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index dd51c95b7..a1b4c305c 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h @@ -68,6 +68,7 @@ enum class RenderTargetFormat : u32 { BGR5A1_UNORM = 0xE9, RG8_UNORM = 0xEA, RG8_SNORM = 0xEB, + RG8_UINT = 0xED, R16_UNORM = 0xEE, R16_SNORM = 0xEF, R16_SINT = 0xF0, diff --git a/src/video_core/morton.cpp b/src/video_core/morton.cpp index 6d522c318..836b25c1d 100644 --- a/src/video_core/morton.cpp +++ b/src/video_core/morton.cpp @@ -83,6 +83,7 @@ static constexpr ConversionArray morton_to_linear_fns = { MortonCopy, MortonCopy, MortonCopy, + MortonCopy, MortonCopy, MortonCopy, MortonCopy, @@ -166,6 +167,7 @@ static constexpr ConversionArray linear_to_morton_fns = { MortonCopy, MortonCopy, MortonCopy, + MortonCopy, MortonCopy, MortonCopy, MortonCopy, diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index 2729d1265..94fbd2a22 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp @@ -83,6 +83,7 @@ constexpr std::array tex_format {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV}, // RGBA8_SRGB {GL_RG8, GL_RG, GL_UNSIGNED_BYTE}, // RG8U {GL_RG8_SNORM, GL_RG, GL_BYTE}, // RG8S + {GL_RG8UI, GL_RG_INTEGER, GL_UNSIGNED_INT}, // RG8UI {GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT}, // RG32UI {GL_RGB16F, GL_RGBA, GL_HALF_FLOAT}, // RGBX16F {GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT}, // R32UI diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp index 8681b821f..cd652dcc9 100644 --- a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp +++ b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp @@ -160,6 +160,7 @@ struct FormatTuple { {VK_FORMAT_R8G8B8A8_SRGB, Attachable}, // RGBA8_SRGB {VK_FORMAT_R8G8_UNORM, Attachable | Storage}, // RG8U {VK_FORMAT_R8G8_SNORM, Attachable | Storage}, // RG8S + {VK_FORMAT_R8G8_UINT, Attachable | Storage}, // RG8UI {VK_FORMAT_R32G32_UINT, Attachable | Storage}, // RG32UI {VK_FORMAT_UNDEFINED}, // RGBX16F {VK_FORMAT_R32_UINT, Attachable | Storage}, // R32UI diff --git a/src/video_core/renderer_vulkan/vk_device.cpp b/src/video_core/renderer_vulkan/vk_device.cpp index e90c76492..83e25a467 100644 --- a/src/video_core/renderer_vulkan/vk_device.cpp +++ b/src/video_core/renderer_vulkan/vk_device.cpp @@ -95,6 +95,7 @@ std::unordered_map GetFormatProperties( VK_FORMAT_R8G8B8A8_SRGB, VK_FORMAT_R8G8_UNORM, VK_FORMAT_R8G8_SNORM, + VK_FORMAT_R8G8_UINT, VK_FORMAT_R8_UNORM, VK_FORMAT_R8_UINT, VK_FORMAT_B10G11R11_UFLOAT_PACK32, diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp index cc7181229..bbe93903c 100644 --- a/src/video_core/surface.cpp +++ b/src/video_core/surface.cpp @@ -145,6 +145,8 @@ PixelFormat PixelFormatFromRenderTargetFormat(Tegra::RenderTargetFormat format) return PixelFormat::RG8U; case Tegra::RenderTargetFormat::RG8_SNORM: return PixelFormat::RG8S; + case Tegra::RenderTargetFormat::RG8_UINT: + return PixelFormat::RG8UI; case Tegra::RenderTargetFormat::R16_FLOAT: return PixelFormat::R16F; case Tegra::RenderTargetFormat::R16_UNORM: diff --git a/src/video_core/surface.h b/src/video_core/surface.h index e0acd44d3..6da6a1b97 100644 --- a/src/video_core/surface.h +++ b/src/video_core/surface.h @@ -57,51 +57,52 @@ enum class PixelFormat { RGBA8_SRGB = 39, RG8U = 40, RG8S = 41, - RG32UI = 42, - RGBX16F = 43, - R32UI = 44, - R32I = 45, - ASTC_2D_8X8 = 46, - ASTC_2D_8X5 = 47, - ASTC_2D_5X4 = 48, - BGRA8_SRGB = 49, - DXT1_SRGB = 50, - DXT23_SRGB = 51, - DXT45_SRGB = 52, - BC7U_SRGB = 53, - R4G4B4A4U = 54, - ASTC_2D_4X4_SRGB = 55, - ASTC_2D_8X8_SRGB = 56, - ASTC_2D_8X5_SRGB = 57, - ASTC_2D_5X4_SRGB = 58, - ASTC_2D_5X5 = 59, - ASTC_2D_5X5_SRGB = 60, - ASTC_2D_10X8 = 61, - ASTC_2D_10X8_SRGB = 62, - ASTC_2D_6X6 = 63, - ASTC_2D_6X6_SRGB = 64, - ASTC_2D_10X10 = 65, - ASTC_2D_10X10_SRGB = 66, - ASTC_2D_12X12 = 67, - ASTC_2D_12X12_SRGB = 68, - ASTC_2D_8X6 = 69, - ASTC_2D_8X6_SRGB = 70, - ASTC_2D_6X5 = 71, - ASTC_2D_6X5_SRGB = 72, - E5B9G9R9F = 73, + RG8UI = 42, + RG32UI = 43, + RGBX16F = 44, + R32UI = 45, + R32I = 46, + ASTC_2D_8X8 = 47, + ASTC_2D_8X5 = 48, + ASTC_2D_5X4 = 49, + BGRA8_SRGB = 50, + DXT1_SRGB = 51, + DXT23_SRGB = 52, + DXT45_SRGB = 53, + BC7U_SRGB = 54, + R4G4B4A4U = 55, + ASTC_2D_4X4_SRGB = 56, + ASTC_2D_8X8_SRGB = 57, + ASTC_2D_8X5_SRGB = 58, + ASTC_2D_5X4_SRGB = 59, + ASTC_2D_5X5 = 60, + ASTC_2D_5X5_SRGB = 61, + ASTC_2D_10X8 = 62, + ASTC_2D_10X8_SRGB = 63, + ASTC_2D_6X6 = 64, + ASTC_2D_6X6_SRGB = 65, + ASTC_2D_10X10 = 66, + ASTC_2D_10X10_SRGB = 67, + ASTC_2D_12X12 = 68, + ASTC_2D_12X12_SRGB = 69, + ASTC_2D_8X6 = 70, + ASTC_2D_8X6_SRGB = 71, + ASTC_2D_6X5 = 72, + ASTC_2D_6X5_SRGB = 73, + E5B9G9R9F = 74, MaxColorFormat, // Depth formats - Z32F = 74, - Z16 = 75, + Z32F = 75, + Z16 = 76, MaxDepthFormat, // DepthStencil formats - Z24S8 = 76, - S8Z24 = 77, - Z32FS8 = 78, + Z24S8 = 77, + S8Z24 = 78, + Z32FS8 = 79, MaxDepthStencilFormat, @@ -171,6 +172,7 @@ constexpr std::array compression_factor_shift_table = {{ 0, // RGBA8_SRGB 0, // RG8U 0, // RG8S + 0, // RG8UI 0, // RG32UI 0, // RGBX16F 0, // R32UI @@ -269,6 +271,7 @@ constexpr std::array block_width_table = {{ 1, // RGBA8_SRGB 1, // RG8U 1, // RG8S + 1, // RG8UI 1, // RG32UI 1, // RGBX16F 1, // R32UI @@ -359,6 +362,7 @@ constexpr std::array block_height_table = {{ 1, // RGBA8_SRGB 1, // RG8U 1, // RG8S + 1, // RG8UI 1, // RG32UI 1, // RGBX16F 1, // R32UI @@ -449,6 +453,7 @@ constexpr std::array bpp_table = {{ 32, // RGBA8_SRGB 16, // RG8U 16, // RG8S + 16, // RG8UI 64, // RG32UI 64, // RGBX16F 32, // R32UI diff --git a/src/video_core/texture_cache/format_lookup_table.cpp b/src/video_core/texture_cache/format_lookup_table.cpp index 25d2ee2e8..7032e0059 100644 --- a/src/video_core/texture_cache/format_lookup_table.cpp +++ b/src/video_core/texture_cache/format_lookup_table.cpp @@ -41,7 +41,7 @@ struct Table { ComponentType alpha_component; bool is_srgb; }; -constexpr std::array DefinitionTable = {{ +constexpr std::array DefinitionTable = {{ {TextureFormat::A8R8G8B8, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::ABGR8U}, {TextureFormat::A8R8G8B8, C, SNORM, SNORM, SNORM, SNORM, PixelFormat::ABGR8S}, {TextureFormat::A8R8G8B8, C, UINT, UINT, UINT, UINT, PixelFormat::ABGR8UI}, @@ -60,6 +60,7 @@ constexpr std::array DefinitionTable = {{ {TextureFormat::G8R8, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::RG8U}, {TextureFormat::G8R8, C, SNORM, SNORM, SNORM, SNORM, PixelFormat::RG8S}, + {TextureFormat::G8R8, C, UINT, UINT, UINT, UINT, PixelFormat::RG8UI}, {TextureFormat::R16_G16_B16_A16, C, SNORM, SNORM, SNORM, SNORM, PixelFormat::RGBA16S}, {TextureFormat::R16_G16_B16_A16, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::RGBA16U}, -- cgit v1.2.3