summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Subv2018-03-26 21:46:11 -0500
committerGravatar James Rowe2018-04-06 20:40:24 -0600
commitb305646c44385833edccb067456e3a0ba4fd3161 (patch)
tree2f2d85c700a5d993157f6535a9729f81cac8c900 /src
parentGL: Create the sampler objects when starting up the GL rasterizer. (diff)
downloadyuzu-b305646c44385833edccb067456e3a0ba4fd3161.tar.gz
yuzu-b305646c44385833edccb067456e3a0ba4fd3161.tar.xz
yuzu-b305646c44385833edccb067456e3a0ba4fd3161.zip
RasterizerCache: Remove 3DS-specific pixel formats.
We're only left with RGB8 and DXT1 for now. More will be added as they are needed.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp14
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h89
2 files changed, 32 insertions, 71 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index 4fd7cdf6a..cfe06391a 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -92,19 +92,9 @@ static void MortonCopyTile(u32 stride, u8* tile_buffer, u8* gl_buffer) {
92 u8* tile_ptr = tile_buffer + VideoCore::MortonInterleave(x, y) * bytes_per_pixel; 92 u8* tile_ptr = tile_buffer + VideoCore::MortonInterleave(x, y) * bytes_per_pixel;
93 u8* gl_ptr = gl_buffer + ((7 - y) * stride + x) * gl_bytes_per_pixel; 93 u8* gl_ptr = gl_buffer + ((7 - y) * stride + x) * gl_bytes_per_pixel;
94 if (morton_to_gl) { 94 if (morton_to_gl) {
95 if (format == PixelFormat::D24S8) { 95 std::memcpy(gl_ptr, tile_ptr, bytes_per_pixel);
96 gl_ptr[0] = tile_ptr[3];
97 std::memcpy(gl_ptr + 1, tile_ptr, 3);
98 } else {
99 std::memcpy(gl_ptr, tile_ptr, bytes_per_pixel);
100 }
101 } else { 96 } else {
102 if (format == PixelFormat::D24S8) { 97 std::memcpy(tile_ptr, gl_ptr, bytes_per_pixel);
103 std::memcpy(tile_ptr, gl_ptr + 1, 3);
104 tile_ptr[3] = gl_ptr[0];
105 } else {
106 std::memcpy(tile_ptr, gl_ptr, bytes_per_pixel);
107 }
108 } 98 }
109 } 99 }
110 } 100 }
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 37b1dae80..06524fc59 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -24,6 +24,7 @@
24#include "common/math_util.h" 24#include "common/math_util.h"
25#include "video_core/gpu.h" 25#include "video_core/gpu.h"
26#include "video_core/renderer_opengl/gl_resource_manager.h" 26#include "video_core/renderer_opengl/gl_resource_manager.h"
27#include "video_core/textures/texture.h"
27 28
28struct CachedSurface; 29struct CachedSurface;
29using Surface = std::shared_ptr<CachedSurface>; 30using Surface = std::shared_ptr<CachedSurface>;
@@ -51,30 +52,8 @@ enum class ScaleMatch {
51 52
52struct SurfaceParams { 53struct SurfaceParams {
53 enum class PixelFormat { 54 enum class PixelFormat {
54 // First 5 formats are shared between textures and color buffers
55 RGBA8 = 0, 55 RGBA8 = 0,
56 RGB8 = 1, 56 DXT1 = 1,
57 RGB5A1 = 2,
58 RGB565 = 3,
59 RGBA4 = 4,
60
61 // Texture-only formats
62 IA8 = 5,
63 RG8 = 6,
64 I8 = 7,
65 A8 = 8,
66 IA4 = 9,
67 I4 = 10,
68 A4 = 11,
69 ETC1 = 12,
70 ETC1A4 = 13,
71
72 // Depth buffer-only formats
73 D16 = 14,
74 // gap
75 D24 = 16,
76 D24S8 = 17,
77
78 Invalid = 255, 57 Invalid = 255,
79 }; 58 };
80 59
@@ -88,28 +67,15 @@ struct SurfaceParams {
88 }; 67 };
89 68
90 static constexpr unsigned int GetFormatBpp(PixelFormat format) { 69 static constexpr unsigned int GetFormatBpp(PixelFormat format) {
91 constexpr std::array<unsigned int, 18> bpp_table = { 70 if (format == PixelFormat::Invalid)
71 return 0;
72
73 constexpr std::array<unsigned int, 2> bpp_table = {
92 32, // RGBA8 74 32, // RGBA8
93 24, // RGB8 75 64, // DXT1
94 16, // RGB5A1
95 16, // RGB565
96 16, // RGBA4
97 16, // IA8
98 16, // RG8
99 8, // I8
100 8, // A8
101 8, // IA4
102 4, // I4
103 4, // A4
104 4, // ETC1
105 8, // ETC1A4
106 16, // D16
107 0,
108 24, // D24
109 32, // D24S8
110 }; 76 };
111 77
112 assert(static_cast<size_t>(format) < bpp_table.size()); 78 ASSERT(static_cast<size_t>(format) < bpp_table.size());
113 return bpp_table[static_cast<size_t>(format)]; 79 return bpp_table[static_cast<size_t>(format)];
114 } 80 }
115 unsigned int GetFormatBpp() const { 81 unsigned int GetFormatBpp() const {
@@ -134,6 +100,18 @@ struct SurfaceParams {
134 } 100 }
135 } 101 }
136 102
103 static PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format) {
104 // TODO(Subv): Properly implement this
105 switch (format) {
106 case Tegra::Texture::TextureFormat::A8R8G8B8:
107 return PixelFormat::RGBA8;
108 case Tegra::Texture::TextureFormat::DXT1:
109 return PixelFormat::DXT1;
110 default:
111 UNREACHABLE();
112 }
113 }
114
137 static bool CheckFormatsBlittable(PixelFormat pixel_format_a, PixelFormat pixel_format_b) { 115 static bool CheckFormatsBlittable(PixelFormat pixel_format_a, PixelFormat pixel_format_b) {
138 SurfaceType a_type = GetFormatType(pixel_format_a); 116 SurfaceType a_type = GetFormatType(pixel_format_a);
139 SurfaceType b_type = GetFormatType(pixel_format_b); 117 SurfaceType b_type = GetFormatType(pixel_format_b);
@@ -154,22 +132,17 @@ struct SurfaceParams {
154 return false; 132 return false;
155 } 133 }
156 134
157 static constexpr SurfaceType GetFormatType(PixelFormat pixel_format) { 135 static SurfaceType GetFormatType(PixelFormat pixel_format) {
158 if ((unsigned int)pixel_format < 5) { 136 if ((unsigned int)pixel_format <= static_cast<unsigned int>(PixelFormat::RGBA8)) {
159 return SurfaceType::Color; 137 return SurfaceType::Color;
160 } 138 }
161 139
162 if ((unsigned int)pixel_format < 14) { 140 if ((unsigned int)pixel_format <= static_cast<unsigned int>(PixelFormat::DXT1)) {
163 return SurfaceType::Texture; 141 return SurfaceType::Texture;
164 } 142 }
165 143
166 if (pixel_format == PixelFormat::D16 || pixel_format == PixelFormat::D24) { 144 // TODO(Subv): Implement the other formats
167 return SurfaceType::Depth; 145 ASSERT(false);
168 }
169
170 if (pixel_format == PixelFormat::D24S8) {
171 return SurfaceType::DepthStencil;
172 }
173 146
174 return SurfaceType::Invalid; 147 return SurfaceType::Invalid;
175 } 148 }
@@ -265,12 +238,10 @@ struct CachedSurface : SurfaceParams {
265 OGLTexture texture; 238 OGLTexture texture;
266 239
267 static constexpr unsigned int GetGLBytesPerPixel(PixelFormat format) { 240 static constexpr unsigned int GetGLBytesPerPixel(PixelFormat format) {
268 // OpenGL needs 4 bpp alignment for D24 since using GL_UNSIGNED_INT as type 241 if (format == PixelFormat::Invalid)
269 return format == PixelFormat::Invalid 242 return 0;
270 ? 0 243
271 : (format == PixelFormat::D24 || GetFormatType(format) == SurfaceType::Texture) 244 return SurfaceParams::GetFormatBpp(format) / 8;
272 ? 4
273 : SurfaceParams::GetFormatBpp(format) / 8;
274 } 245 }
275 246
276 std::unique_ptr<u8[]> gl_buffer; 247 std::unique_ptr<u8[]> gl_buffer;
@@ -313,7 +284,7 @@ public:
313 bool load_if_create); 284 bool load_if_create);
314 285
315 /// Get a surface based on the texture configuration 286 /// Get a surface based on the texture configuration
316 Surface GetTextureSurface(const void* config); 287 Surface GetTextureSurface(const Tegra::Texture::FullTextureInfo& config);
317 288
318 /// Get the color and depth surfaces based on the framebuffer configuration 289 /// Get the color and depth surfaces based on the framebuffer configuration
319 SurfaceSurfaceRect_Tuple GetFramebufferSurfaces(bool using_color_fb, bool using_depth_fb, 290 SurfaceSurfaceRect_Tuple GetFramebufferSurfaces(bool using_color_fb, bool using_depth_fb,