diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 63 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 26 |
2 files changed, 37 insertions, 52 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 5fb099d8d..779ab5ab4 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -29,6 +29,28 @@ struct FormatTuple { | |||
| 29 | bool compressed; | 29 | bool compressed; |
| 30 | }; | 30 | }; |
| 31 | 31 | ||
| 32 | SurfaceParams::SurfaceParams(const Tegra::Texture::FullTextureInfo& config) | ||
| 33 | : addr(config.tic.Address()), is_tiled(config.tic.IsTiled()), | ||
| 34 | block_height(is_tiled ? config.tic.BlockHeight() : 0), | ||
| 35 | pixel_format(PixelFormatFromTextureFormat(config.tic.format)), | ||
| 36 | component_type(ComponentTypeFromTexture(config.tic.r_type.Value())), | ||
| 37 | type(GetFormatType(pixel_format)), | ||
| 38 | width(Common::AlignUp(config.tic.Width(), GetCompressionFactor(pixel_format))), | ||
| 39 | height(Common::AlignUp(config.tic.Height(), GetCompressionFactor(pixel_format))) { | ||
| 40 | |||
| 41 | // TODO(Subv): Different types per component are not supported. | ||
| 42 | ASSERT(config.tic.r_type.Value() == config.tic.g_type.Value() && | ||
| 43 | config.tic.r_type.Value() == config.tic.b_type.Value() && | ||
| 44 | config.tic.r_type.Value() == config.tic.a_type.Value()); | ||
| 45 | } | ||
| 46 | |||
| 47 | SurfaceParams::SurfaceParams(const Tegra::Engines::Maxwell3D::Regs::RenderTargetConfig& config) | ||
| 48 | : addr(config.Address()), is_tiled(true), | ||
| 49 | block_height(Tegra::Texture::TICEntry::DefaultBlockHeight), | ||
| 50 | pixel_format(PixelFormatFromRenderTargetFormat(config.format)), | ||
| 51 | component_type(ComponentTypeFromRenderTarget(config.format)), | ||
| 52 | type(GetFormatType(pixel_format)), width(config.width), height(config.height) {} | ||
| 53 | |||
| 32 | static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_format_tuples = {{ | 54 | static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_format_tuples = {{ |
| 33 | {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false}, // ABGR8 | 55 | {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false}, // ABGR8 |
| 34 | {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, false}, // B5G6R5 | 56 | {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, false}, // B5G6R5 |
| @@ -333,57 +355,20 @@ RasterizerCacheOpenGL::RasterizerCacheOpenGL() { | |||
| 333 | } | 355 | } |
| 334 | 356 | ||
| 335 | Surface RasterizerCacheOpenGL::GetTextureSurface(const Tegra::Texture::FullTextureInfo& config) { | 357 | Surface RasterizerCacheOpenGL::GetTextureSurface(const Tegra::Texture::FullTextureInfo& config) { |
| 336 | auto& gpu = Core::System::GetInstance().GPU(); | 358 | return GetSurface(SurfaceParams(config)); |
| 337 | |||
| 338 | SurfaceParams params; | ||
| 339 | params.addr = config.tic.Address(); | ||
| 340 | params.is_tiled = config.tic.IsTiled(); | ||
| 341 | params.pixel_format = SurfaceParams::PixelFormatFromTextureFormat(config.tic.format); | ||
| 342 | params.component_type = SurfaceParams::ComponentTypeFromTexture(config.tic.r_type.Value()); | ||
| 343 | params.type = SurfaceParams::GetFormatType(params.pixel_format); | ||
| 344 | params.width = Common::AlignUp(config.tic.Width(), params.GetCompressionFactor()); | ||
| 345 | params.height = Common::AlignUp(config.tic.Height(), params.GetCompressionFactor()); | ||
| 346 | |||
| 347 | if (params.is_tiled) { | ||
| 348 | params.block_height = config.tic.BlockHeight(); | ||
| 349 | } | ||
| 350 | |||
| 351 | // TODO(Subv): Different types per component are not supported. | ||
| 352 | ASSERT(config.tic.r_type.Value() == config.tic.g_type.Value() && | ||
| 353 | config.tic.r_type.Value() == config.tic.b_type.Value() && | ||
| 354 | config.tic.r_type.Value() == config.tic.a_type.Value()); | ||
| 355 | |||
| 356 | return GetSurface(params); | ||
| 357 | } | 359 | } |
| 358 | 360 | ||
| 359 | SurfaceSurfaceRect_Tuple RasterizerCacheOpenGL::GetFramebufferSurfaces( | 361 | SurfaceSurfaceRect_Tuple RasterizerCacheOpenGL::GetFramebufferSurfaces( |
| 360 | bool using_color_fb, bool using_depth_fb, const MathUtil::Rectangle<s32>& viewport) { | 362 | bool using_color_fb, bool using_depth_fb, const MathUtil::Rectangle<s32>& viewport) { |
| 361 | const auto& regs = Core::System().GetInstance().GPU().Maxwell3D().regs; | 363 | const auto& regs = Core::System().GetInstance().GPU().Maxwell3D().regs; |
| 362 | const auto& config = regs.rt[0]; | ||
| 363 | 364 | ||
| 364 | // TODO(bunnei): This is hard corded to use just the first render buffer | 365 | // TODO(bunnei): This is hard corded to use just the first render buffer |
| 365 | NGLOG_WARNING(Render_OpenGL, "hard-coded for render target 0!"); | 366 | NGLOG_WARNING(Render_OpenGL, "hard-coded for render target 0!"); |
| 366 | 367 | ||
| 367 | MathUtil::Rectangle<u32> viewport_clamped{ | ||
| 368 | static_cast<u32>(std::clamp(viewport.left, 0, static_cast<s32>(config.width))), | ||
| 369 | static_cast<u32>(std::clamp(viewport.top, 0, static_cast<s32>(config.height))), | ||
| 370 | static_cast<u32>(std::clamp(viewport.right, 0, static_cast<s32>(config.width))), | ||
| 371 | static_cast<u32>(std::clamp(viewport.bottom, 0, static_cast<s32>(config.height)))}; | ||
| 372 | |||
| 373 | // get color and depth surfaces | 368 | // get color and depth surfaces |
| 374 | SurfaceParams color_params; | 369 | SurfaceParams color_params(regs.rt[0]); |
| 375 | color_params.is_tiled = true; | ||
| 376 | color_params.width = config.width; | ||
| 377 | color_params.height = config.height; | ||
| 378 | // TODO(Subv): Can framebuffers use a different block height? | ||
| 379 | color_params.block_height = Tegra::Texture::TICEntry::DefaultBlockHeight; | ||
| 380 | SurfaceParams depth_params = color_params; | 370 | SurfaceParams depth_params = color_params; |
| 381 | 371 | ||
| 382 | color_params.addr = config.Address(); | ||
| 383 | color_params.pixel_format = SurfaceParams::PixelFormatFromRenderTargetFormat(config.format); | ||
| 384 | color_params.component_type = SurfaceParams::ComponentTypeFromRenderTarget(config.format); | ||
| 385 | color_params.type = SurfaceParams::GetFormatType(color_params.pixel_format); | ||
| 386 | |||
| 387 | ASSERT_MSG(!using_depth_fb, "depth buffer is unimplemented"); | 372 | ASSERT_MSG(!using_depth_fb, "depth buffer is unimplemented"); |
| 388 | 373 | ||
| 389 | MathUtil::Rectangle<u32> color_rect{}; | 374 | MathUtil::Rectangle<u32> color_rect{}; |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index ca9945df4..9878bf9bf 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "common/math_util.h" | 12 | #include "common/math_util.h" |
| 13 | #include "video_core/engines/maxwell_3d.h" | ||
| 13 | #include "video_core/renderer_opengl/gl_resource_manager.h" | 14 | #include "video_core/renderer_opengl/gl_resource_manager.h" |
| 14 | #include "video_core/textures/texture.h" | 15 | #include "video_core/textures/texture.h" |
| 15 | 16 | ||
| @@ -83,9 +84,6 @@ struct SurfaceParams { | |||
| 83 | ASSERT(static_cast<size_t>(format) < compression_factor_table.size()); | 84 | ASSERT(static_cast<size_t>(format) < compression_factor_table.size()); |
| 84 | return compression_factor_table[static_cast<size_t>(format)]; | 85 | return compression_factor_table[static_cast<size_t>(format)]; |
| 85 | } | 86 | } |
| 86 | u32 GetCompressionFactor() const { | ||
| 87 | return GetCompressionFactor(pixel_format); | ||
| 88 | } | ||
| 89 | 87 | ||
| 90 | static constexpr u32 GetFormatBpp(PixelFormat format) { | 88 | static constexpr u32 GetFormatBpp(PixelFormat format) { |
| 91 | if (format == PixelFormat::Invalid) | 89 | if (format == PixelFormat::Invalid) |
| @@ -238,25 +236,27 @@ struct SurfaceParams { | |||
| 238 | } | 236 | } |
| 239 | 237 | ||
| 240 | size_t SizeInBytes() const { | 238 | size_t SizeInBytes() const { |
| 241 | const u32 compression_factor{GetCompressionFactor()}; | 239 | const u32 compression_factor{GetCompressionFactor(pixel_format)}; |
| 242 | ASSERT(width % compression_factor == 0); | 240 | ASSERT(width % compression_factor == 0); |
| 243 | ASSERT(height % compression_factor == 0); | 241 | ASSERT(height % compression_factor == 0); |
| 244 | return (width / compression_factor) * (height / compression_factor) * | 242 | return (width / compression_factor) * (height / compression_factor) * |
| 245 | GetFormatBpp(pixel_format) / CHAR_BIT; | 243 | GetFormatBpp(pixel_format) / CHAR_BIT; |
| 246 | } | 244 | } |
| 247 | 245 | ||
| 246 | SurfaceParams(const Tegra::Texture::FullTextureInfo& config); | ||
| 247 | SurfaceParams(const Tegra::Engines::Maxwell3D::Regs::RenderTargetConfig& config); | ||
| 248 | |||
| 248 | VAddr GetCpuAddr() const; | 249 | VAddr GetCpuAddr() const; |
| 249 | 250 | ||
| 250 | Tegra::GPUVAddr addr; | 251 | const Tegra::GPUVAddr addr; |
| 251 | u32 width; | 252 | const bool is_tiled; |
| 252 | u32 height; | 253 | const u32 block_height; |
| 253 | u32 block_height; | 254 | const PixelFormat pixel_format; |
| 254 | bool is_tiled; | 255 | const ComponentType component_type; |
| 255 | PixelFormat pixel_format; | 256 | const SurfaceType type; |
| 256 | SurfaceType type; | 257 | const u32 width; |
| 257 | ComponentType component_type; | 258 | const u32 height; |
| 258 | }; | 259 | }; |
| 259 | static_assert(std::is_pod<SurfaceParams>::value, "SurfaceParams is not POD"); | ||
| 260 | 260 | ||
| 261 | class CachedSurface final { | 261 | class CachedSurface final { |
| 262 | public: | 262 | public: |