summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_rasterizer_cache.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-04-24 05:45:47 +0200
committerbunnei <bunneidev@gmail.com>2018-04-25 04:31:46 +0200
commitbc0f1896fc1092bdc66fb66f977163de08672f01 (patch)
tree8ad416a2de1336c68edeb3f155964c7649aef106 /src/video_core/renderer_opengl/gl_rasterizer_cache.h
parentgl_rasterizer_cache: Update to be based on GPU addresses, not CPU addresses. (diff)
downloadyuzu-bc0f1896fc1092bdc66fb66f977163de08672f01.tar
yuzu-bc0f1896fc1092bdc66fb66f977163de08672f01.tar.gz
yuzu-bc0f1896fc1092bdc66fb66f977163de08672f01.tar.bz2
yuzu-bc0f1896fc1092bdc66fb66f977163de08672f01.tar.lz
yuzu-bc0f1896fc1092bdc66fb66f977163de08672f01.tar.xz
yuzu-bc0f1896fc1092bdc66fb66f977163de08672f01.tar.zst
yuzu-bc0f1896fc1092bdc66fb66f977163de08672f01.zip
Diffstat (limited to 'src/video_core/renderer_opengl/gl_rasterizer_cache.h')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h52
1 files changed, 48 insertions, 4 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 5f77f4e61..08858bab4 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -84,23 +84,49 @@ struct SurfaceParams {
Invalid = 4,
};
- static constexpr unsigned int GetFormatBpp(PixelFormat format) {
+ /**
+ * Gets the compression factor for the specified PixelFormat. This applies to just the
+ * "compressed width" and "compressed height", not the overall compression factor of a
+ * compressed image. This is used for maintaining proper surface sizes for compressed texture
+ * formats.
+ */
+ static constexpr u32 GetCompresssionFactor(PixelFormat format) {
if (format == PixelFormat::Invalid)
return 0;
- constexpr std::array<unsigned int, MaxPixelFormat> bpp_table = {
+ constexpr std::array<u32, MaxPixelFormat> compression_factor_table = {{
+ 1, // ABGR8
+ 1, // B5G6R5
+ 1, // A2B10G10R10
+ 4, // DXT1
+ 4, // DXT23
+ 4, // DXT45
+ }};
+
+ ASSERT(static_cast<size_t>(format) < compression_factor_table.size());
+ return compression_factor_table[static_cast<size_t>(format)];
+ }
+ u32 GetCompresssionFactor() const {
+ return GetCompresssionFactor(pixel_format);
+ }
+
+ static constexpr u32 GetFormatBpp(PixelFormat format) {
+ if (format == PixelFormat::Invalid)
+ return 0;
+
+ constexpr std::array<u32, MaxPixelFormat> bpp_table = {{
32, // ABGR8
16, // B5G6R5
32, // A2B10G10R10
64, // DXT1
128, // DXT23
128, // DXT45
- };
+ }};
ASSERT(static_cast<size_t>(format) < bpp_table.size());
return bpp_table[static_cast<size_t>(format)];
}
- unsigned int GetFormatBpp() const {
+ u32 GetFormatBpp() const {
return GetFormatBpp(pixel_format);
}
@@ -255,6 +281,24 @@ struct SurfaceParams {
// Returns the region of the biggest valid rectange within interval
SurfaceInterval GetCopyableInterval(const Surface& src_surface) const;
+ /**
+ * Gets the actual width (in pixels) of the surface. This is provided because `width` is used
+ * for tracking the surface region in memory, which may be compressed for certain formats. In
+ * this scenario, `width` is actually the compressed width.
+ */
+ u32 GetActualWidth() const {
+ return width * GetCompresssionFactor();
+ }
+
+ /**
+ * Gets the actual height (in pixels) of the surface. This is provided because `height` is used
+ * for tracking the surface region in memory, which may be compressed for certain formats. In
+ * this scenario, `height` is actually the compressed height.
+ */
+ u32 GetActualHeight() const {
+ return height * GetCompresssionFactor();
+ }
+
u32 GetScaledWidth() const {
return width * res_scale;
}