From b2c1672e108333bb38ae15f6c6677a0f3719896a Mon Sep 17 00:00:00 2001 From: Subv Date: Wed, 18 Apr 2018 13:51:09 -0500 Subject: GPU: Texture format 8 and framebuffer format 0xD5 are actually ABGR8. --- src/video_core/renderer_opengl/gl_rasterizer_cache.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/video_core/renderer_opengl/gl_rasterizer_cache.h') diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 26d6c3061..0f8f14404 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h @@ -52,7 +52,7 @@ enum class ScaleMatch { struct SurfaceParams { enum class PixelFormat { - RGBA8 = 0, + ABGR8 = 0, DXT1 = 1, Invalid = 255, }; @@ -71,7 +71,7 @@ struct SurfaceParams { return 0; constexpr std::array bpp_table = { - 32, // RGBA8 + 32, // ABGR8 64, // DXT1 }; @@ -85,7 +85,7 @@ struct SurfaceParams { static PixelFormat PixelFormatFromRenderTargetFormat(Tegra::RenderTargetFormat format) { switch (format) { case Tegra::RenderTargetFormat::RGBA8_UNORM: - return PixelFormat::RGBA8; + return PixelFormat::ABGR8; default: NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast(format)); UNREACHABLE(); @@ -95,7 +95,7 @@ struct SurfaceParams { static PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat format) { switch (format) { case Tegra::FramebufferConfig::PixelFormat::ABGR8: - return PixelFormat::RGBA8; + return PixelFormat::ABGR8; default: NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast(format)); UNREACHABLE(); @@ -106,7 +106,7 @@ struct SurfaceParams { // TODO(Subv): Properly implement this switch (format) { case Tegra::Texture::TextureFormat::A8R8G8B8: - return PixelFormat::RGBA8; + return PixelFormat::ABGR8; case Tegra::Texture::TextureFormat::DXT1: return PixelFormat::DXT1; default: @@ -118,7 +118,7 @@ struct SurfaceParams { static Tegra::Texture::TextureFormat TextureFormatFromPixelFormat(PixelFormat format) { // TODO(Subv): Properly implement this switch (format) { - case PixelFormat::RGBA8: + case PixelFormat::ABGR8: return Tegra::Texture::TextureFormat::A8R8G8B8; case PixelFormat::DXT1: return Tegra::Texture::TextureFormat::DXT1; @@ -148,7 +148,7 @@ struct SurfaceParams { } static SurfaceType GetFormatType(PixelFormat pixel_format) { - if ((unsigned int)pixel_format <= static_cast(PixelFormat::RGBA8)) { + if ((unsigned int)pixel_format <= static_cast(PixelFormat::ABGR8)) { return SurfaceType::Color; } -- cgit v1.2.3 From 5b3fab6766d68ddc00fc342fde3c32d449e82535 Mon Sep 17 00:00:00 2001 From: Subv Date: Wed, 18 Apr 2018 13:54:10 -0500 Subject: GLCache: Unify texture and framebuffer formats when converting to OpenGL. --- src/video_core/renderer_opengl/gl_rasterizer_cache.h | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'src/video_core/renderer_opengl/gl_rasterizer_cache.h') 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 { }; enum class SurfaceType { - Color = 0, - Texture = 1, - Depth = 2, - DepthStencil = 3, - Fill = 4, - Invalid = 5 + ColorTexture = 0, + Depth = 1, + DepthStencil = 2, + Fill = 3, + Invalid = 4, }; static constexpr unsigned int GetFormatBpp(PixelFormat format) { @@ -131,8 +130,7 @@ struct SurfaceParams { SurfaceType a_type = GetFormatType(pixel_format_a); SurfaceType b_type = GetFormatType(pixel_format_b); - if ((a_type == SurfaceType::Color || a_type == SurfaceType::Texture) && - (b_type == SurfaceType::Color || b_type == SurfaceType::Texture)) { + if (a_type == SurfaceType::ColorTexture && b_type == SurfaceType::ColorTexture) { return true; } @@ -148,12 +146,8 @@ struct SurfaceParams { } static SurfaceType GetFormatType(PixelFormat pixel_format) { - if ((unsigned int)pixel_format <= static_cast(PixelFormat::ABGR8)) { - return SurfaceType::Color; - } - if ((unsigned int)pixel_format <= static_cast(PixelFormat::DXT1)) { - return SurfaceType::Texture; + return SurfaceType::ColorTexture; } // TODO(Subv): Implement the other formats -- cgit v1.2.3 From 43d98ca8fee384c5aef462dd37200477e9de2013 Mon Sep 17 00:00:00 2001 From: Subv Date: Wed, 18 Apr 2018 14:17:05 -0500 Subject: GLCache: Added boilerplate code to make supporting configurable texture component types. For now only the UNORM type is supported. --- .../renderer_opengl/gl_rasterizer_cache.h | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'src/video_core/renderer_opengl/gl_rasterizer_cache.h') diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 434cd2277..0ff0ce90f 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h @@ -57,6 +57,15 @@ struct SurfaceParams { Invalid = 255, }; + enum class ComponentType { + Invalid = 0, + SNorm = 1, + UNorm = 2, + SInt = 3, + UInt = 4, + Float = 5, + }; + enum class SurfaceType { ColorTexture = 0, Depth = 1, @@ -126,6 +135,40 @@ struct SurfaceParams { } } + static ComponentType ComponentTypeFromTexture(Tegra::Texture::ComponentType type) { + // TODO(Subv): Implement more component types + switch (type) { + case Tegra::Texture::ComponentType::UNORM: + return ComponentType::UNorm; + default: + NGLOG_CRITICAL(HW_GPU, "Unimplemented component type={}", static_cast(type)); + UNREACHABLE(); + } + } + + static ComponentType ComponentTypeFromRenderTarget(Tegra::RenderTargetFormat format) { + // TODO(Subv): Implement more render targets + switch (format) { + case Tegra::RenderTargetFormat::RGBA8_UNORM: + case Tegra::RenderTargetFormat::RGB10_A2_UNORM: + return ComponentType::UNorm; + default: + NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast(format)); + UNREACHABLE(); + } + } + + static ComponentType ComponentTypeFromGPUPixelFormat( + Tegra::FramebufferConfig::PixelFormat format) { + switch (format) { + case Tegra::FramebufferConfig::PixelFormat::ABGR8: + return ComponentType::UNorm; + default: + NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast(format)); + UNREACHABLE(); + } + } + static bool CheckFormatsBlittable(PixelFormat pixel_format_a, PixelFormat pixel_format_b) { SurfaceType a_type = GetFormatType(pixel_format_a); SurfaceType b_type = GetFormatType(pixel_format_b); @@ -225,6 +268,7 @@ struct SurfaceParams { bool is_tiled = false; PixelFormat pixel_format = PixelFormat::Invalid; SurfaceType type = SurfaceType::Invalid; + ComponentType component_type = ComponentType::Invalid; }; struct CachedSurface : SurfaceParams { -- cgit v1.2.3