summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Subv2018-03-26 21:48:05 -0500
committerGravatar James Rowe2018-04-06 20:44:42 -0600
commit73eaef9c05891fe2d1d6af184d3256b9027d1158 (patch)
treec6d0b47b4741c79cccb12990b6c5c7a28104daba /src
parentRasterizerCache: Remove 3DS-specific pixel formats. (diff)
downloadyuzu-73eaef9c05891fe2d1d6af184d3256b9027d1158.tar.gz
yuzu-73eaef9c05891fe2d1d6af184d3256b9027d1158.tar.xz
yuzu-73eaef9c05891fe2d1d6af184d3256b9027d1158.zip
GL: Remove remaining references to 3DS-specific pixel formats
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp105
1 files changed, 22 insertions, 83 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index cfe06391a..fe9c76917 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -30,6 +30,7 @@
30#include "video_core/engines/maxwell_3d.h" 30#include "video_core/engines/maxwell_3d.h"
31#include "video_core/renderer_opengl/gl_rasterizer_cache.h" 31#include "video_core/renderer_opengl/gl_rasterizer_cache.h"
32#include "video_core/renderer_opengl/gl_state.h" 32#include "video_core/renderer_opengl/gl_state.h"
33#include "video_core/textures/decoders.h"
33#include "video_core/utils.h" 34#include "video_core/utils.h"
34#include "video_core/video_core.h" 35#include "video_core/video_core.h"
35 36
@@ -40,36 +41,36 @@ struct FormatTuple {
40 GLint internal_format; 41 GLint internal_format;
41 GLenum format; 42 GLenum format;
42 GLenum type; 43 GLenum type;
44 bool compressed;
45 // How many pixels in the original texture are equivalent to one pixel in the compressed
46 // texture.
47 u32 compression_factor;
43}; 48};
44 49
45static constexpr std::array<FormatTuple, 5> fb_format_tuples = {{ 50static constexpr std::array<FormatTuple, 1> fb_format_tuples = {{
46 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8}, // RGBA8 51 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, false, 1}, // RGBA8
47 {GL_RGB8, GL_BGR, GL_UNSIGNED_BYTE}, // RGB8
48 {GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1}, // RGB5A1
49 {GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5}, // RGB565
50 {GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4}, // RGBA4
51}}; 52}};
52 53
53static constexpr std::array<FormatTuple, 4> depth_format_tuples = {{ 54static constexpr std::array<FormatTuple, 2> tex_format_tuples = {{
54 {GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT}, // D16 55 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, false, 1}, // RGBA8
55 {}, 56 {GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true, 16}, // DXT1
56 {GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT}, // D24
57 {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8}, // D24S8
58}}; 57}};
59 58
60static constexpr FormatTuple tex_tuple = {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE};
61
62static const FormatTuple& GetFormatTuple(PixelFormat pixel_format) { 59static const FormatTuple& GetFormatTuple(PixelFormat pixel_format) {
63 const SurfaceType type = SurfaceParams::GetFormatType(pixel_format); 60 const SurfaceType type = SurfaceParams::GetFormatType(pixel_format);
64 if (type == SurfaceType::Color) { 61 if (type == SurfaceType::Color) {
65 ASSERT(static_cast<size_t>(pixel_format) < fb_format_tuples.size()); 62 ASSERT(static_cast<size_t>(pixel_format) < fb_format_tuples.size());
66 return fb_format_tuples[static_cast<unsigned int>(pixel_format)]; 63 return fb_format_tuples[static_cast<unsigned int>(pixel_format)];
67 } else if (type == SurfaceType::Depth || type == SurfaceType::DepthStencil) { 64 } else if (type == SurfaceType::Depth || type == SurfaceType::DepthStencil) {
68 size_t tuple_idx = static_cast<size_t>(pixel_format) - 14; 65 // TODO(Subv): Implement depth formats
69 ASSERT(tuple_idx < depth_format_tuples.size()); 66 ASSERT_MSG(false, "Unimplemented");
70 return depth_format_tuples[tuple_idx]; 67 } else if (type == SurfaceType::Texture) {
68 ASSERT(static_cast<size_t>(pixel_format) < tex_format_tuples.size());
69 return tex_format_tuples[static_cast<unsigned int>(pixel_format)];
71 } 70 }
72 return tex_tuple; 71
72 UNREACHABLE();
73 return {};
73} 74}
74 75
75template <typename Map, typename Interval> 76template <typename Map, typename Interval>
@@ -112,46 +113,14 @@ static void MortonCopy(u32 stride, u32 height, u8* gl_buffer, VAddr base, VAddr
112 Memory::GetPointer(base), gl_buffer, morton_to_gl); 113 Memory::GetPointer(base), gl_buffer, morton_to_gl);
113} 114}
114 115
115static constexpr std::array<void (*)(u32, u32, u8*, VAddr, VAddr, VAddr), 18> morton_to_gl_fns = { 116static constexpr std::array<void (*)(u32, u32, u8*, VAddr, VAddr, VAddr), 2> morton_to_gl_fns = {
116 MortonCopy<true, PixelFormat::RGBA8>, 117 MortonCopy<true, PixelFormat::RGBA8>,
117 nullptr, 118 MortonCopy<true, PixelFormat::DXT1>,
118 nullptr,
119 nullptr,
120 nullptr,
121 nullptr,
122 nullptr,
123 nullptr,
124 nullptr,
125 nullptr,
126 nullptr,
127 nullptr,
128 nullptr,
129 nullptr,
130 nullptr,
131 nullptr,
132 nullptr,
133 nullptr,
134}; 119};
135 120
136static constexpr std::array<void (*)(u32, u32, u8*, VAddr, VAddr, VAddr), 18> gl_to_morton_fns = { 121static constexpr std::array<void (*)(u32, u32, u8*, VAddr, VAddr, VAddr), 2> gl_to_morton_fns = {
137 MortonCopy<false, PixelFormat::RGBA8>, 122 MortonCopy<false, PixelFormat::RGBA8>,
138 nullptr, 123 MortonCopy<false, PixelFormat::DXT1>,
139 nullptr,
140 nullptr,
141 nullptr,
142 nullptr,
143 nullptr,
144 nullptr,
145 nullptr,
146 nullptr,
147 nullptr,
148 nullptr,
149 nullptr,
150 nullptr,
151 nullptr,
152 nullptr,
153 nullptr,
154 nullptr,
155}; 124};
156 125
157// Allocate an uninitialized texture of appropriate size and format for the surface 126// Allocate an uninitialized texture of appropriate size and format for the surface
@@ -944,15 +913,6 @@ Surface RasterizerCacheOpenGL::GetSurface(const SurfaceParams& params, ScaleMatc
944 if (expandable != nullptr && expandable->res_scale > target_res_scale) { 913 if (expandable != nullptr && expandable->res_scale > target_res_scale) {
945 target_res_scale = expandable->res_scale; 914 target_res_scale = expandable->res_scale;
946 } 915 }
947 // Keep res_scale when reinterpreting d24s8 -> rgba8
948 if (params.pixel_format == PixelFormat::RGBA8) {
949 find_params.pixel_format = PixelFormat::D24S8;
950 expandable = FindMatch<MatchFlags::Expand | MatchFlags::Invalid>(
951 surface_cache, find_params, match_res_scale);
952 if (expandable != nullptr && expandable->res_scale > target_res_scale) {
953 target_res_scale = expandable->res_scale;
954 }
955 }
956 } 916 }
957 SurfaceParams new_params = params; 917 SurfaceParams new_params = params;
958 new_params.res_scale = target_res_scale; 918 new_params.res_scale = target_res_scale;
@@ -1230,27 +1190,6 @@ void RasterizerCacheOpenGL::ValidateSurface(const Surface& surface, VAddr addr,
1230 continue; 1190 continue;
1231 } 1191 }
1232 1192
1233 // D24S8 to RGBA8
1234 if (surface->pixel_format == PixelFormat::RGBA8) {
1235 params.pixel_format = PixelFormat::D24S8;
1236 Surface reinterpret_surface =
1237 FindMatch<MatchFlags::Copy>(surface_cache, params, ScaleMatch::Ignore, interval);
1238 if (reinterpret_surface != nullptr) {
1239 ASSERT(reinterpret_surface->pixel_format == PixelFormat::D24S8);
1240
1241 SurfaceInterval convert_interval = params.GetCopyableInterval(reinterpret_surface);
1242 SurfaceParams convert_params = surface->FromInterval(convert_interval);
1243 auto src_rect = reinterpret_surface->GetScaledSubRect(convert_params);
1244 auto dest_rect = surface->GetScaledSubRect(convert_params);
1245
1246 ConvertD24S8toABGR(reinterpret_surface->texture.handle, src_rect,
1247 surface->texture.handle, dest_rect);
1248
1249 surface->invalid_regions.erase(convert_interval);
1250 continue;
1251 }
1252 }
1253
1254 // Load data from Switch memory 1193 // Load data from Switch memory
1255 FlushRegion(params.addr, params.size); 1194 FlushRegion(params.addr, params.size);
1256 surface->LoadGLBuffer(params.addr, params.end); 1195 surface->LoadGLBuffer(params.addr, params.end);