summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp15
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h16
-rw-r--r--src/video_core/textures/decoders.cpp4
-rw-r--r--src/video_core/textures/texture.h1
4 files changed, 28 insertions, 8 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index 9ccc63090..2a0858eac 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -48,8 +48,9 @@ struct FormatTuple {
48 u32 compression_factor; 48 u32 compression_factor;
49}; 49};
50 50
51static constexpr std::array<FormatTuple, 2> tex_format_tuples = {{ 51static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_format_tuples = {{
52 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false, 1}, // ABGR8 52 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false, 1}, // ABGR8
53 {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, false, 1}, // B5G6R5
53 {GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true, 16}, // DXT1 54 {GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true, 16}, // DXT1
54}}; 55}};
55 56
@@ -117,15 +118,19 @@ void MortonCopy(u32 stride, u32 block_height, u32 height, u8* gl_buffer, VAddr b
117 } 118 }
118} 119}
119 120
120static constexpr std::array<void (*)(u32, u32, u32, u8*, VAddr, VAddr, VAddr), 2> morton_to_gl_fns = 121static constexpr std::array<void (*)(u32, u32, u32, u8*, VAddr, VAddr, VAddr),
121 { 122 SurfaceParams::MaxPixelFormat>
123 morton_to_gl_fns = {
122 MortonCopy<true, PixelFormat::ABGR8>, 124 MortonCopy<true, PixelFormat::ABGR8>,
125 MortonCopy<true, PixelFormat::B5G6R5>,
123 MortonCopy<true, PixelFormat::DXT1>, 126 MortonCopy<true, PixelFormat::DXT1>,
124}; 127};
125 128
126static constexpr std::array<void (*)(u32, u32, u32, u8*, VAddr, VAddr, VAddr), 2> gl_to_morton_fns = 129static constexpr std::array<void (*)(u32, u32, u32, u8*, VAddr, VAddr, VAddr),
127 { 130 SurfaceParams::MaxPixelFormat>
131 gl_to_morton_fns = {
128 MortonCopy<false, PixelFormat::ABGR8>, 132 MortonCopy<false, PixelFormat::ABGR8>,
133 MortonCopy<false, PixelFormat::B5G6R5>,
129 // TODO(Subv): Swizzling the DXT1 format is not yet supported 134 // TODO(Subv): Swizzling the DXT1 format is not yet supported
130 nullptr, 135 nullptr,
131}; 136};
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 0ff0ce90f..23e4d02d8 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -53,10 +53,15 @@ enum class ScaleMatch {
53struct SurfaceParams { 53struct SurfaceParams {
54 enum class PixelFormat { 54 enum class PixelFormat {
55 ABGR8 = 0, 55 ABGR8 = 0,
56 DXT1 = 1, 56 B5G6R5 = 1,
57 DXT1 = 2,
58
59 Max,
57 Invalid = 255, 60 Invalid = 255,
58 }; 61 };
59 62
63 static constexpr size_t MaxPixelFormat = static_cast<size_t>(PixelFormat::Max);
64
60 enum class ComponentType { 65 enum class ComponentType {
61 Invalid = 0, 66 Invalid = 0,
62 SNorm = 1, 67 SNorm = 1,
@@ -78,8 +83,9 @@ struct SurfaceParams {
78 if (format == PixelFormat::Invalid) 83 if (format == PixelFormat::Invalid)
79 return 0; 84 return 0;
80 85
81 constexpr std::array<unsigned int, 2> bpp_table = { 86 constexpr std::array<unsigned int, MaxPixelFormat> bpp_table = {
82 32, // ABGR8 87 32, // ABGR8
88 16, // B5G6R5
83 64, // DXT1 89 64, // DXT1
84 }; 90 };
85 91
@@ -115,6 +121,8 @@ struct SurfaceParams {
115 switch (format) { 121 switch (format) {
116 case Tegra::Texture::TextureFormat::A8R8G8B8: 122 case Tegra::Texture::TextureFormat::A8R8G8B8:
117 return PixelFormat::ABGR8; 123 return PixelFormat::ABGR8;
124 case Tegra::Texture::TextureFormat::B5G6R5:
125 return PixelFormat::B5G6R5;
118 case Tegra::Texture::TextureFormat::DXT1: 126 case Tegra::Texture::TextureFormat::DXT1:
119 return PixelFormat::DXT1; 127 return PixelFormat::DXT1;
120 default: 128 default:
@@ -128,6 +136,8 @@ struct SurfaceParams {
128 switch (format) { 136 switch (format) {
129 case PixelFormat::ABGR8: 137 case PixelFormat::ABGR8:
130 return Tegra::Texture::TextureFormat::A8R8G8B8; 138 return Tegra::Texture::TextureFormat::A8R8G8B8;
139 case PixelFormat::B5G6R5:
140 return Tegra::Texture::TextureFormat::B5G6R5;
131 case PixelFormat::DXT1: 141 case PixelFormat::DXT1:
132 return Tegra::Texture::TextureFormat::DXT1; 142 return Tegra::Texture::TextureFormat::DXT1;
133 default: 143 default:
@@ -189,7 +199,7 @@ struct SurfaceParams {
189 } 199 }
190 200
191 static SurfaceType GetFormatType(PixelFormat pixel_format) { 201 static SurfaceType GetFormatType(PixelFormat pixel_format) {
192 if ((unsigned int)pixel_format <= static_cast<unsigned int>(PixelFormat::DXT1)) { 202 if (static_cast<size_t>(pixel_format) < MaxPixelFormat) {
193 return SurfaceType::ColorTexture; 203 return SurfaceType::ColorTexture;
194 } 204 }
195 205
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp
index 9c2a10d2e..f4c7e40df 100644
--- a/src/video_core/textures/decoders.cpp
+++ b/src/video_core/textures/decoders.cpp
@@ -50,6 +50,8 @@ u32 BytesPerPixel(TextureFormat format) {
50 return 8; 50 return 8;
51 case TextureFormat::A8R8G8B8: 51 case TextureFormat::A8R8G8B8:
52 return 4; 52 return 4;
53 case TextureFormat::B5G6R5:
54 return 2;
53 default: 55 default:
54 UNIMPLEMENTED_MSG("Format not implemented"); 56 UNIMPLEMENTED_MSG("Format not implemented");
55 break; 57 break;
@@ -70,6 +72,7 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width,
70 unswizzled_data.data(), true, block_height); 72 unswizzled_data.data(), true, block_height);
71 break; 73 break;
72 case TextureFormat::A8R8G8B8: 74 case TextureFormat::A8R8G8B8:
75 case TextureFormat::B5G6R5:
73 CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data, 76 CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data,
74 unswizzled_data.data(), true, block_height); 77 unswizzled_data.data(), true, block_height);
75 break; 78 break;
@@ -89,6 +92,7 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat
89 switch (format) { 92 switch (format) {
90 case TextureFormat::DXT1: 93 case TextureFormat::DXT1:
91 case TextureFormat::A8R8G8B8: 94 case TextureFormat::A8R8G8B8:
95 case TextureFormat::B5G6R5:
92 // TODO(Subv): For the time being just forward the same data without any decoding. 96 // TODO(Subv): For the time being just forward the same data without any decoding.
93 rgba_data = texture_data; 97 rgba_data = texture_data;
94 break; 98 break;
diff --git a/src/video_core/textures/texture.h b/src/video_core/textures/texture.h
index 09d2317e0..86e45aa88 100644
--- a/src/video_core/textures/texture.h
+++ b/src/video_core/textures/texture.h
@@ -15,6 +15,7 @@ namespace Texture {
15 15
16enum class TextureFormat : u32 { 16enum class TextureFormat : u32 {
17 A8R8G8B8 = 0x8, 17 A8R8G8B8 = 0x8,
18 B5G6R5 = 0x15,
18 DXT1 = 0x24, 19 DXT1 = 0x24,
19 DXT23 = 0x25, 20 DXT23 = 0x25,
20 DXT45 = 0x26, 21 DXT45 = 0x26,