summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Subv2018-04-18 13:54:10 -0500
committerGravatar Subv2018-04-18 14:17:28 -0500
commit5b3fab6766d68ddc00fc342fde3c32d449e82535 (patch)
tree45826bdf98b11dab95886377ed424b89d673b90f /src
parentGPU: Texture format 8 and framebuffer format 0xD5 are actually ABGR8. (diff)
downloadyuzu-5b3fab6766d68ddc00fc342fde3c32d449e82535.tar.gz
yuzu-5b3fab6766d68ddc00fc342fde3c32d449e82535.tar.xz
yuzu-5b3fab6766d68ddc00fc342fde3c32d449e82535.zip
GLCache: Unify texture and framebuffer formats when converting to OpenGL.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp19
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h20
2 files changed, 13 insertions, 26 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index d54ddf643..10e9dc5c2 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -47,26 +47,20 @@ struct FormatTuple {
47 u32 compression_factor; 47 u32 compression_factor;
48}; 48};
49 49
50static constexpr std::array<FormatTuple, 1> fb_format_tuples = {{
51 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, false, 1}, // RGBA8
52}};
53
54static constexpr std::array<FormatTuple, 2> tex_format_tuples = {{ 50static constexpr std::array<FormatTuple, 2> tex_format_tuples = {{
55 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false, 1}, // ABGR8 51 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false, 1}, // ABGR8
56 {GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true, 16}, // DXT1 52 {GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true, 16}, // DXT1
57}}; 53}};
58 54
59static const FormatTuple& GetFormatTuple(PixelFormat pixel_format) { 55static const FormatTuple& GetFormatTuple(PixelFormat pixel_format) {
56 using Tegra::Texture::ComponentType;
60 const SurfaceType type = SurfaceParams::GetFormatType(pixel_format); 57 const SurfaceType type = SurfaceParams::GetFormatType(pixel_format);
61 if (type == SurfaceType::Color) { 58 if (type == SurfaceType::ColorTexture) {
62 ASSERT(static_cast<size_t>(pixel_format) < fb_format_tuples.size()); 59 ASSERT(static_cast<size_t>(pixel_format) < tex_format_tuples.size());
63 return fb_format_tuples[static_cast<unsigned int>(pixel_format)]; 60 return tex_format_tuples[static_cast<unsigned int>(pixel_format)];
64 } else if (type == SurfaceType::Depth || type == SurfaceType::DepthStencil) { 61 } else if (type == SurfaceType::Depth || type == SurfaceType::DepthStencil) {
65 // TODO(Subv): Implement depth formats 62 // TODO(Subv): Implement depth formats
66 ASSERT_MSG(false, "Unimplemented"); 63 ASSERT_MSG(false, "Unimplemented");
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)];
70 } 64 }
71 65
72 UNREACHABLE(); 66 UNREACHABLE();
@@ -180,7 +174,7 @@ static bool BlitTextures(GLuint src_tex, const MathUtil::Rectangle<u32>& src_rec
180 174
181 u32 buffers = 0; 175 u32 buffers = 0;
182 176
183 if (type == SurfaceType::Color || type == SurfaceType::Texture) { 177 if (type == SurfaceType::ColorTexture) {
184 glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, src_tex, 178 glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, src_tex,
185 0); 179 0);
186 glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 180 glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0,
@@ -658,7 +652,7 @@ void CachedSurface::DownloadGLTexture(const MathUtil::Rectangle<u32>& rect, GLui
658 state.draw.read_framebuffer = read_fb_handle; 652 state.draw.read_framebuffer = read_fb_handle;
659 state.Apply(); 653 state.Apply();
660 654
661 if (type == SurfaceType::Color || type == SurfaceType::Texture) { 655 if (type == SurfaceType::ColorTexture) {
662 glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 656 glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
663 texture.handle, 0); 657 texture.handle, 0);
664 glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 658 glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D,
@@ -1300,7 +1294,6 @@ void RasterizerCacheOpenGL::InvalidateRegion(VAddr addr, u64 size, const Surface
1300 const SurfaceInterval invalid_interval(addr, addr + size); 1294 const SurfaceInterval invalid_interval(addr, addr + size);
1301 1295
1302 if (region_owner != nullptr) { 1296 if (region_owner != nullptr) {
1303 ASSERT(region_owner->type != SurfaceType::Texture);
1304 ASSERT(addr >= region_owner->addr && addr + size <= region_owner->end); 1297 ASSERT(addr >= region_owner->addr && addr + size <= region_owner->end);
1305 // Surfaces can't have a gap 1298 // Surfaces can't have a gap
1306 ASSERT(region_owner->width == region_owner->stride); 1299 ASSERT(region_owner->width == region_owner->stride);
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 0f8f14404..434cd2277 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -58,12 +58,11 @@ struct SurfaceParams {
58 }; 58 };
59 59
60 enum class SurfaceType { 60 enum class SurfaceType {
61 Color = 0, 61 ColorTexture = 0,
62 Texture = 1, 62 Depth = 1,
63 Depth = 2, 63 DepthStencil = 2,
64 DepthStencil = 3, 64 Fill = 3,
65 Fill = 4, 65 Invalid = 4,
66 Invalid = 5
67 }; 66 };
68 67
69 static constexpr unsigned int GetFormatBpp(PixelFormat format) { 68 static constexpr unsigned int GetFormatBpp(PixelFormat format) {
@@ -131,8 +130,7 @@ struct SurfaceParams {
131 SurfaceType a_type = GetFormatType(pixel_format_a); 130 SurfaceType a_type = GetFormatType(pixel_format_a);
132 SurfaceType b_type = GetFormatType(pixel_format_b); 131 SurfaceType b_type = GetFormatType(pixel_format_b);
133 132
134 if ((a_type == SurfaceType::Color || a_type == SurfaceType::Texture) && 133 if (a_type == SurfaceType::ColorTexture && b_type == SurfaceType::ColorTexture) {
135 (b_type == SurfaceType::Color || b_type == SurfaceType::Texture)) {
136 return true; 134 return true;
137 } 135 }
138 136
@@ -148,12 +146,8 @@ struct SurfaceParams {
148 } 146 }
149 147
150 static SurfaceType GetFormatType(PixelFormat pixel_format) { 148 static SurfaceType GetFormatType(PixelFormat pixel_format) {
151 if ((unsigned int)pixel_format <= static_cast<unsigned int>(PixelFormat::ABGR8)) {
152 return SurfaceType::Color;
153 }
154
155 if ((unsigned int)pixel_format <= static_cast<unsigned int>(PixelFormat::DXT1)) { 149 if ((unsigned int)pixel_format <= static_cast<unsigned int>(PixelFormat::DXT1)) {
156 return SurfaceType::Texture; 150 return SurfaceType::ColorTexture;
157 } 151 }
158 152
159 // TODO(Subv): Implement the other formats 153 // TODO(Subv): Implement the other formats