summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/morton.cpp8
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.cpp4
-rw-r--r--src/video_core/renderer_vulkan/maxwell_to_vk.cpp4
-rw-r--r--src/video_core/renderer_vulkan/vk_device.cpp1
-rw-r--r--src/video_core/surface.cpp21
-rw-r--r--src/video_core/surface.h23
-rw-r--r--src/video_core/texture_cache/format_lookup_table.cpp7
7 files changed, 31 insertions, 37 deletions
diff --git a/src/video_core/morton.cpp b/src/video_core/morton.cpp
index 7f239566a..0c3c9f12d 100644
--- a/src/video_core/morton.cpp
+++ b/src/video_core/morton.cpp
@@ -46,6 +46,7 @@ static constexpr ConversionArray morton_to_linear_fns = {
46 MortonCopy<true, PixelFormat::ABGR8I>, 46 MortonCopy<true, PixelFormat::ABGR8I>,
47 MortonCopy<true, PixelFormat::ABGR8UI>, 47 MortonCopy<true, PixelFormat::ABGR8UI>,
48 MortonCopy<true, PixelFormat::B5G6R5U>, 48 MortonCopy<true, PixelFormat::B5G6R5U>,
49 MortonCopy<true, PixelFormat::R5G6B5U>,
49 MortonCopy<true, PixelFormat::B5G5R5A1U>, 50 MortonCopy<true, PixelFormat::B5G5R5A1U>,
50 MortonCopy<true, PixelFormat::A2B10G10R10U>, 51 MortonCopy<true, PixelFormat::A2B10G10R10U>,
51 MortonCopy<true, PixelFormat::A2B10G10R10UI>, 52 MortonCopy<true, PixelFormat::A2B10G10R10UI>,
@@ -64,7 +65,8 @@ static constexpr ConversionArray morton_to_linear_fns = {
64 MortonCopy<true, PixelFormat::DXT1>, 65 MortonCopy<true, PixelFormat::DXT1>,
65 MortonCopy<true, PixelFormat::DXT23>, 66 MortonCopy<true, PixelFormat::DXT23>,
66 MortonCopy<true, PixelFormat::DXT45>, 67 MortonCopy<true, PixelFormat::DXT45>,
67 MortonCopy<true, PixelFormat::DXN1>, 68 MortonCopy<true, PixelFormat::DXN1UNORM>,
69 MortonCopy<true, PixelFormat::DXN1SNORM>,
68 MortonCopy<true, PixelFormat::DXN2UNORM>, 70 MortonCopy<true, PixelFormat::DXN2UNORM>,
69 MortonCopy<true, PixelFormat::DXN2SNORM>, 71 MortonCopy<true, PixelFormat::DXN2SNORM>,
70 MortonCopy<true, PixelFormat::BC7U>, 72 MortonCopy<true, PixelFormat::BC7U>,
@@ -138,6 +140,7 @@ static constexpr ConversionArray linear_to_morton_fns = {
138 MortonCopy<false, PixelFormat::ABGR8I>, 140 MortonCopy<false, PixelFormat::ABGR8I>,
139 MortonCopy<false, PixelFormat::ABGR8UI>, 141 MortonCopy<false, PixelFormat::ABGR8UI>,
140 MortonCopy<false, PixelFormat::B5G6R5U>, 142 MortonCopy<false, PixelFormat::B5G6R5U>,
143 MortonCopy<false, PixelFormat::R5G6B5U>,
141 MortonCopy<false, PixelFormat::B5G5R5A1U>, 144 MortonCopy<false, PixelFormat::B5G5R5A1U>,
142 MortonCopy<false, PixelFormat::A2B10G10R10U>, 145 MortonCopy<false, PixelFormat::A2B10G10R10U>,
143 MortonCopy<false, PixelFormat::A2B10G10R10UI>, 146 MortonCopy<false, PixelFormat::A2B10G10R10UI>,
@@ -156,7 +159,8 @@ static constexpr ConversionArray linear_to_morton_fns = {
156 MortonCopy<false, PixelFormat::DXT1>, 159 MortonCopy<false, PixelFormat::DXT1>,
157 MortonCopy<false, PixelFormat::DXT23>, 160 MortonCopy<false, PixelFormat::DXT23>,
158 MortonCopy<false, PixelFormat::DXT45>, 161 MortonCopy<false, PixelFormat::DXT45>,
159 MortonCopy<false, PixelFormat::DXN1>, 162 MortonCopy<false, PixelFormat::DXN1UNORM>,
163 MortonCopy<false, PixelFormat::DXN1SNORM>,
160 MortonCopy<false, PixelFormat::DXN2UNORM>, 164 MortonCopy<false, PixelFormat::DXN2UNORM>,
161 MortonCopy<false, PixelFormat::DXN2SNORM>, 165 MortonCopy<false, PixelFormat::DXN2SNORM>,
162 MortonCopy<false, PixelFormat::BC7U>, 166 MortonCopy<false, PixelFormat::BC7U>,
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp
index 7f85ceca9..12f54c050 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp
@@ -46,6 +46,7 @@ constexpr std::array<FormatTuple, VideoCore::Surface::MaxPixelFormat> tex_format
46 {GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE}, // ABGR8I 46 {GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE}, // ABGR8I
47 {GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE}, // ABGR8UI 47 {GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE}, // ABGR8UI
48 {GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5}, // B5G6R5U 48 {GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5}, // B5G6R5U
49 {GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV}, // R5G6B5U
49 {GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV}, // B5G5R5A1U 50 {GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV}, // B5G5R5A1U
50 {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV}, // A2B10G10R10U 51 {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV}, // A2B10G10R10U
51 {GL_RGB10_A2UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV}, // A2B10G10R10UI 52 {GL_RGB10_A2UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV}, // A2B10G10R10UI
@@ -64,7 +65,8 @@ constexpr std::array<FormatTuple, VideoCore::Surface::MaxPixelFormat> tex_format
64 {GL_COMPRESSED_RGBA_S3TC_DXT1_EXT}, // DXT1 65 {GL_COMPRESSED_RGBA_S3TC_DXT1_EXT}, // DXT1
65 {GL_COMPRESSED_RGBA_S3TC_DXT3_EXT}, // DXT23 66 {GL_COMPRESSED_RGBA_S3TC_DXT3_EXT}, // DXT23
66 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT}, // DXT45 67 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT}, // DXT45
67 {GL_COMPRESSED_RED_RGTC1}, // DXN1 68 {GL_COMPRESSED_RED_RGTC1}, // DXN1UNORM
69 {GL_COMPRESSED_SIGNED_RED_RGTC1}, // DXN1SNORM
68 {GL_COMPRESSED_RG_RGTC2}, // DXN2UNORM 70 {GL_COMPRESSED_RG_RGTC2}, // DXN2UNORM
69 {GL_COMPRESSED_SIGNED_RG_RGTC2}, // DXN2SNORM 71 {GL_COMPRESSED_SIGNED_RG_RGTC2}, // DXN2SNORM
70 {GL_COMPRESSED_RGBA_BPTC_UNORM}, // BC7U 72 {GL_COMPRESSED_RGBA_BPTC_UNORM}, // BC7U
diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp
index 3cb3b00d9..57c3822c2 100644
--- a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp
+++ b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp
@@ -122,6 +122,7 @@ struct FormatTuple {
122 {VK_FORMAT_A8B8G8R8_SINT_PACK32, Attachable | Storage}, // ABGR8I 122 {VK_FORMAT_A8B8G8R8_SINT_PACK32, Attachable | Storage}, // ABGR8I
123 {VK_FORMAT_A8B8G8R8_UINT_PACK32, Attachable | Storage}, // ABGR8UI 123 {VK_FORMAT_A8B8G8R8_UINT_PACK32, Attachable | Storage}, // ABGR8UI
124 {VK_FORMAT_R5G6B5_UNORM_PACK16, Attachable}, // B5G6R5U 124 {VK_FORMAT_R5G6B5_UNORM_PACK16, Attachable}, // B5G6R5U
125 {VK_FORMAT_B5G6R5_UNORM_PACK16, Attachable}, // R5G6B5U
125 {VK_FORMAT_A1R5G5B5_UNORM_PACK16, Attachable}, // B5G5R5A1U 126 {VK_FORMAT_A1R5G5B5_UNORM_PACK16, Attachable}, // B5G5R5A1U
126 {VK_FORMAT_A2B10G10R10_UNORM_PACK32, Attachable | Storage}, // A2B10G10R10U 127 {VK_FORMAT_A2B10G10R10_UNORM_PACK32, Attachable | Storage}, // A2B10G10R10U
127 {VK_FORMAT_A2B10G10R10_UINT_PACK32, Attachable | Storage}, // A2B10G10R10UI 128 {VK_FORMAT_A2B10G10R10_UINT_PACK32, Attachable | Storage}, // A2B10G10R10UI
@@ -140,7 +141,8 @@ struct FormatTuple {
140 {VK_FORMAT_BC1_RGBA_UNORM_BLOCK}, // DXT1 141 {VK_FORMAT_BC1_RGBA_UNORM_BLOCK}, // DXT1
141 {VK_FORMAT_BC2_UNORM_BLOCK}, // DXT23 142 {VK_FORMAT_BC2_UNORM_BLOCK}, // DXT23
142 {VK_FORMAT_BC3_UNORM_BLOCK}, // DXT45 143 {VK_FORMAT_BC3_UNORM_BLOCK}, // DXT45
143 {VK_FORMAT_BC4_UNORM_BLOCK}, // DXN1 144 {VK_FORMAT_BC4_UNORM_BLOCK}, // DXN1UNORM
145 {VK_FORMAT_BC4_SNORM_BLOCK}, // DXN1SNORM
144 {VK_FORMAT_BC5_UNORM_BLOCK}, // DXN2UNORM 146 {VK_FORMAT_BC5_UNORM_BLOCK}, // DXN2UNORM
145 {VK_FORMAT_BC5_SNORM_BLOCK}, // DXN2SNORM 147 {VK_FORMAT_BC5_SNORM_BLOCK}, // DXN2SNORM
146 {VK_FORMAT_BC7_UNORM_BLOCK}, // BC7U 148 {VK_FORMAT_BC7_UNORM_BLOCK}, // BC7U
diff --git a/src/video_core/renderer_vulkan/vk_device.cpp b/src/video_core/renderer_vulkan/vk_device.cpp
index 2f5621889..71f0ff427 100644
--- a/src/video_core/renderer_vulkan/vk_device.cpp
+++ b/src/video_core/renderer_vulkan/vk_device.cpp
@@ -125,6 +125,7 @@ std::unordered_map<VkFormat, VkFormatProperties> GetFormatProperties(
125 VK_FORMAT_BC2_UNORM_BLOCK, 125 VK_FORMAT_BC2_UNORM_BLOCK,
126 VK_FORMAT_BC3_UNORM_BLOCK, 126 VK_FORMAT_BC3_UNORM_BLOCK,
127 VK_FORMAT_BC4_UNORM_BLOCK, 127 VK_FORMAT_BC4_UNORM_BLOCK,
128 VK_FORMAT_BC4_SNORM_BLOCK,
128 VK_FORMAT_BC5_UNORM_BLOCK, 129 VK_FORMAT_BC5_UNORM_BLOCK,
129 VK_FORMAT_BC5_SNORM_BLOCK, 130 VK_FORMAT_BC5_SNORM_BLOCK,
130 VK_FORMAT_BC7_UNORM_BLOCK, 131 VK_FORMAT_BC7_UNORM_BLOCK,
diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp
index c1c2f2c52..492ab6215 100644
--- a/src/video_core/surface.cpp
+++ b/src/video_core/surface.cpp
@@ -283,25 +283,4 @@ std::pair<u32, u32> GetASTCBlockSize(PixelFormat format) {
283 return {GetDefaultBlockWidth(format), GetDefaultBlockHeight(format)}; 283 return {GetDefaultBlockWidth(format), GetDefaultBlockHeight(format)};
284} 284}
285 285
286bool IsFormatBCn(PixelFormat format) {
287 switch (format) {
288 case PixelFormat::DXT1:
289 case PixelFormat::DXT23:
290 case PixelFormat::DXT45:
291 case PixelFormat::DXN1:
292 case PixelFormat::DXN2SNORM:
293 case PixelFormat::DXN2UNORM:
294 case PixelFormat::BC7U:
295 case PixelFormat::BC6H_UF16:
296 case PixelFormat::BC6H_SF16:
297 case PixelFormat::DXT1_SRGB:
298 case PixelFormat::DXT23_SRGB:
299 case PixelFormat::DXT45_SRGB:
300 case PixelFormat::BC7U_SRGB:
301 return true;
302 default:
303 return false;
304 }
305}
306
307} // namespace VideoCore::Surface 286} // namespace VideoCore::Surface
diff --git a/src/video_core/surface.h b/src/video_core/surface.h
index 9510db2c8..826c5a3ad 100644
--- a/src/video_core/surface.h
+++ b/src/video_core/surface.h
@@ -20,6 +20,7 @@ enum class PixelFormat {
20 ABGR8I, 20 ABGR8I,
21 ABGR8UI, 21 ABGR8UI,
22 B5G6R5U, 22 B5G6R5U,
23 R5G6B5U,
23 B5G5R5A1U, 24 B5G5R5A1U,
24 A2B10G10R10U, 25 A2B10G10R10U,
25 A2B10G10R10UI, 26 A2B10G10R10UI,
@@ -38,7 +39,8 @@ enum class PixelFormat {
38 DXT1, 39 DXT1,
39 DXT23, 40 DXT23,
40 DXT45, 41 DXT45,
41 DXN1, // This is also known as BC4 42 DXN1UNORM, // This is also known as BC4
43 DXN1SNORM,
42 DXN2UNORM, 44 DXN2UNORM,
43 DXN2SNORM, 45 DXN2SNORM,
44 BC7U, 46 BC7U,
@@ -144,6 +146,7 @@ constexpr std::array<u32, MaxPixelFormat> compression_factor_shift_table = {{
144 0, // ABGR8I 146 0, // ABGR8I
145 0, // ABGR8UI 147 0, // ABGR8UI
146 0, // B5G6R5U 148 0, // B5G6R5U
149 0, // R5G6B5U
147 0, // B5G5R5A1U 150 0, // B5G5R5A1U
148 0, // A2B10G10R10U 151 0, // A2B10G10R10U
149 0, // A2B10G10R10UI 152 0, // A2B10G10R10UI
@@ -162,7 +165,8 @@ constexpr std::array<u32, MaxPixelFormat> compression_factor_shift_table = {{
162 2, // DXT1 165 2, // DXT1
163 2, // DXT23 166 2, // DXT23
164 2, // DXT45 167 2, // DXT45
165 2, // DXN1 168 2, // DXN1UNORM
169 2, // DXN1SNORM
166 2, // DXN2UNORM 170 2, // DXN2UNORM
167 2, // DXN2SNORM 171 2, // DXN2SNORM
168 2, // BC7U 172 2, // BC7U
@@ -252,6 +256,7 @@ constexpr std::array<u32, MaxPixelFormat> block_width_table = {{
252 1, // ABGR8I 256 1, // ABGR8I
253 1, // ABGR8UI 257 1, // ABGR8UI
254 1, // B5G6R5U 258 1, // B5G6R5U
259 1, // R5G6B5U
255 1, // B5G5R5A1U 260 1, // B5G5R5A1U
256 1, // A2B10G10R10U 261 1, // A2B10G10R10U
257 1, // A2B10G10R10UI 262 1, // A2B10G10R10UI
@@ -270,7 +275,8 @@ constexpr std::array<u32, MaxPixelFormat> block_width_table = {{
270 4, // DXT1 275 4, // DXT1
271 4, // DXT23 276 4, // DXT23
272 4, // DXT45 277 4, // DXT45
273 4, // DXN1 278 4, // DXN1UNORM
279 4, // DXN1SNORM
274 4, // DXN2UNORM 280 4, // DXN2UNORM
275 4, // DXN2SNORM 281 4, // DXN2SNORM
276 4, // BC7U 282 4, // BC7U
@@ -352,6 +358,7 @@ constexpr std::array<u32, MaxPixelFormat> block_height_table = {{
352 1, // ABGR8I 358 1, // ABGR8I
353 1, // ABGR8UI 359 1, // ABGR8UI
354 1, // B5G6R5U 360 1, // B5G6R5U
361 1, // R5G6B5U
355 1, // B5G5R5A1U 362 1, // B5G5R5A1U
356 1, // A2B10G10R10U 363 1, // A2B10G10R10U
357 1, // A2B10G10R10UI 364 1, // A2B10G10R10UI
@@ -370,7 +377,8 @@ constexpr std::array<u32, MaxPixelFormat> block_height_table = {{
370 4, // DXT1 377 4, // DXT1
371 4, // DXT23 378 4, // DXT23
372 4, // DXT45 379 4, // DXT45
373 4, // DXN1 380 4, // DXN1UNORM
381 4, // DXN1SNORM
374 4, // DXN2UNORM 382 4, // DXN2UNORM
375 4, // DXN2SNORM 383 4, // DXN2SNORM
376 4, // BC7U 384 4, // BC7U
@@ -452,6 +460,7 @@ constexpr std::array<u32, MaxPixelFormat> bpp_table = {{
452 32, // ABGR8I 460 32, // ABGR8I
453 32, // ABGR8UI 461 32, // ABGR8UI
454 16, // B5G6R5U 462 16, // B5G6R5U
463 16, // R5G6B5U
455 16, // B5G5R5A1U 464 16, // B5G5R5A1U
456 32, // A2B10G10R10U 465 32, // A2B10G10R10U
457 32, // A2B10G10R10UI 466 32, // A2B10G10R10UI
@@ -470,7 +479,8 @@ constexpr std::array<u32, MaxPixelFormat> bpp_table = {{
470 64, // DXT1 479 64, // DXT1
471 128, // DXT23 480 128, // DXT23
472 128, // DXT45 481 128, // DXT45
473 64, // DXN1 482 64, // DXN1UNORM
483 64, // DXN1SNORM
474 128, // DXN2UNORM 484 128, // DXN2UNORM
475 128, // DXN2SNORM 485 128, // DXN2SNORM
476 128, // BC7U 486 128, // BC7U
@@ -574,7 +584,4 @@ bool IsPixelFormatSRGB(PixelFormat format);
574 584
575std::pair<u32, u32> GetASTCBlockSize(PixelFormat format); 585std::pair<u32, u32> GetASTCBlockSize(PixelFormat format);
576 586
577/// Returns true if the specified PixelFormat is a BCn format, e.g. DXT or DXN
578bool IsFormatBCn(PixelFormat format);
579
580} // namespace VideoCore::Surface 587} // namespace VideoCore::Surface
diff --git a/src/video_core/texture_cache/format_lookup_table.cpp b/src/video_core/texture_cache/format_lookup_table.cpp
index b7f44ead2..148a3935d 100644
--- a/src/video_core/texture_cache/format_lookup_table.cpp
+++ b/src/video_core/texture_cache/format_lookup_table.cpp
@@ -48,7 +48,7 @@ constexpr std::array<Table, 86> DefinitionTable = {{
48 {TextureFormat::A8R8G8B8, C, SINT, SINT, SINT, SINT, PixelFormat::ABGR8I}, 48 {TextureFormat::A8R8G8B8, C, SINT, SINT, SINT, SINT, PixelFormat::ABGR8I},
49 {TextureFormat::A8R8G8B8, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::RGBA8_SRGB}, 49 {TextureFormat::A8R8G8B8, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::RGBA8_SRGB},
50 50
51 {TextureFormat::B5G6R5, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::B5G6R5U}, 51 {TextureFormat::B5G6R5, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::R5G6B5U},
52 52
53 {TextureFormat::A2B10G10R10, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::A2B10G10R10U}, 53 {TextureFormat::A2B10G10R10, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::A2B10G10R10U},
54 {TextureFormat::A2B10G10R10, C, UINT, UINT, UINT, UINT, PixelFormat::A2B10G10R10UI}, 54 {TextureFormat::A2B10G10R10, C, UINT, UINT, UINT, UINT, PixelFormat::A2B10G10R10UI},
@@ -118,9 +118,8 @@ constexpr std::array<Table, 86> DefinitionTable = {{
118 {TextureFormat::DXT45, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXT45}, 118 {TextureFormat::DXT45, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXT45},
119 {TextureFormat::DXT45, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXT45_SRGB}, 119 {TextureFormat::DXT45, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXT45_SRGB},
120 120
121 // TODO: Use a different pixel format for SNORM 121 {TextureFormat::DXN1, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXN1UNORM},
122 {TextureFormat::DXN1, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXN1}, 122 {TextureFormat::DXN1, C, SNORM, SNORM, SNORM, SNORM, PixelFormat::DXN1SNORM},
123 {TextureFormat::DXN1, C, SNORM, SNORM, SNORM, SNORM, PixelFormat::DXN1},
124 123
125 {TextureFormat::DXN2, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXN2UNORM}, 124 {TextureFormat::DXN2, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXN2UNORM},
126 {TextureFormat::DXN2, C, SNORM, SNORM, SNORM, SNORM, PixelFormat::DXN2SNORM}, 125 {TextureFormat::DXN2, C, SNORM, SNORM, SNORM, SNORM, PixelFormat::DXN2SNORM},