mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
gl_rasterizer_cache: Refactor to make SurfaceParams members const.
This commit is contained in:
parent
5f57ab1b2a
commit
9f2f819bb6
|
@ -29,6 +29,28 @@ struct FormatTuple {
|
|||
bool compressed;
|
||||
};
|
||||
|
||||
SurfaceParams::SurfaceParams(const Tegra::Texture::FullTextureInfo& config)
|
||||
: addr(config.tic.Address()), is_tiled(config.tic.IsTiled()),
|
||||
block_height(is_tiled ? config.tic.BlockHeight() : 0),
|
||||
pixel_format(PixelFormatFromTextureFormat(config.tic.format)),
|
||||
component_type(ComponentTypeFromTexture(config.tic.r_type.Value())),
|
||||
type(GetFormatType(pixel_format)),
|
||||
width(Common::AlignUp(config.tic.Width(), GetCompressionFactor(pixel_format))),
|
||||
height(Common::AlignUp(config.tic.Height(), GetCompressionFactor(pixel_format))) {
|
||||
|
||||
// TODO(Subv): Different types per component are not supported.
|
||||
ASSERT(config.tic.r_type.Value() == config.tic.g_type.Value() &&
|
||||
config.tic.r_type.Value() == config.tic.b_type.Value() &&
|
||||
config.tic.r_type.Value() == config.tic.a_type.Value());
|
||||
}
|
||||
|
||||
SurfaceParams::SurfaceParams(const Tegra::Engines::Maxwell3D::Regs::RenderTargetConfig& config)
|
||||
: addr(config.Address()), is_tiled(true),
|
||||
block_height(Tegra::Texture::TICEntry::DefaultBlockHeight),
|
||||
pixel_format(PixelFormatFromRenderTargetFormat(config.format)),
|
||||
component_type(ComponentTypeFromRenderTarget(config.format)),
|
||||
type(GetFormatType(pixel_format)), width(config.width), height(config.height) {}
|
||||
|
||||
static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_format_tuples = {{
|
||||
{GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false}, // ABGR8
|
||||
{GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, false}, // B5G6R5
|
||||
|
@ -333,57 +355,20 @@ RasterizerCacheOpenGL::RasterizerCacheOpenGL() {
|
|||
}
|
||||
|
||||
Surface RasterizerCacheOpenGL::GetTextureSurface(const Tegra::Texture::FullTextureInfo& config) {
|
||||
auto& gpu = Core::System::GetInstance().GPU();
|
||||
|
||||
SurfaceParams params;
|
||||
params.addr = config.tic.Address();
|
||||
params.is_tiled = config.tic.IsTiled();
|
||||
params.pixel_format = SurfaceParams::PixelFormatFromTextureFormat(config.tic.format);
|
||||
params.component_type = SurfaceParams::ComponentTypeFromTexture(config.tic.r_type.Value());
|
||||
params.type = SurfaceParams::GetFormatType(params.pixel_format);
|
||||
params.width = Common::AlignUp(config.tic.Width(), params.GetCompressionFactor());
|
||||
params.height = Common::AlignUp(config.tic.Height(), params.GetCompressionFactor());
|
||||
|
||||
if (params.is_tiled) {
|
||||
params.block_height = config.tic.BlockHeight();
|
||||
}
|
||||
|
||||
// TODO(Subv): Different types per component are not supported.
|
||||
ASSERT(config.tic.r_type.Value() == config.tic.g_type.Value() &&
|
||||
config.tic.r_type.Value() == config.tic.b_type.Value() &&
|
||||
config.tic.r_type.Value() == config.tic.a_type.Value());
|
||||
|
||||
return GetSurface(params);
|
||||
return GetSurface(SurfaceParams(config));
|
||||
}
|
||||
|
||||
SurfaceSurfaceRect_Tuple RasterizerCacheOpenGL::GetFramebufferSurfaces(
|
||||
bool using_color_fb, bool using_depth_fb, const MathUtil::Rectangle<s32>& viewport) {
|
||||
const auto& regs = Core::System().GetInstance().GPU().Maxwell3D().regs;
|
||||
const auto& config = regs.rt[0];
|
||||
|
||||
// TODO(bunnei): This is hard corded to use just the first render buffer
|
||||
NGLOG_WARNING(Render_OpenGL, "hard-coded for render target 0!");
|
||||
|
||||
MathUtil::Rectangle<u32> viewport_clamped{
|
||||
static_cast<u32>(std::clamp(viewport.left, 0, static_cast<s32>(config.width))),
|
||||
static_cast<u32>(std::clamp(viewport.top, 0, static_cast<s32>(config.height))),
|
||||
static_cast<u32>(std::clamp(viewport.right, 0, static_cast<s32>(config.width))),
|
||||
static_cast<u32>(std::clamp(viewport.bottom, 0, static_cast<s32>(config.height)))};
|
||||
|
||||
// get color and depth surfaces
|
||||
SurfaceParams color_params;
|
||||
color_params.is_tiled = true;
|
||||
color_params.width = config.width;
|
||||
color_params.height = config.height;
|
||||
// TODO(Subv): Can framebuffers use a different block height?
|
||||
color_params.block_height = Tegra::Texture::TICEntry::DefaultBlockHeight;
|
||||
SurfaceParams color_params(regs.rt[0]);
|
||||
SurfaceParams depth_params = color_params;
|
||||
|
||||
color_params.addr = config.Address();
|
||||
color_params.pixel_format = SurfaceParams::PixelFormatFromRenderTargetFormat(config.format);
|
||||
color_params.component_type = SurfaceParams::ComponentTypeFromRenderTarget(config.format);
|
||||
color_params.type = SurfaceParams::GetFormatType(color_params.pixel_format);
|
||||
|
||||
ASSERT_MSG(!using_depth_fb, "depth buffer is unimplemented");
|
||||
|
||||
MathUtil::Rectangle<u32> color_rect{};
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "common/common_types.h"
|
||||
#include "common/math_util.h"
|
||||
#include "video_core/engines/maxwell_3d.h"
|
||||
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
||||
#include "video_core/textures/texture.h"
|
||||
|
||||
|
@ -83,9 +84,6 @@ struct SurfaceParams {
|
|||
ASSERT(static_cast<size_t>(format) < compression_factor_table.size());
|
||||
return compression_factor_table[static_cast<size_t>(format)];
|
||||
}
|
||||
u32 GetCompressionFactor() const {
|
||||
return GetCompressionFactor(pixel_format);
|
||||
}
|
||||
|
||||
static constexpr u32 GetFormatBpp(PixelFormat format) {
|
||||
if (format == PixelFormat::Invalid)
|
||||
|
@ -238,25 +236,27 @@ struct SurfaceParams {
|
|||
}
|
||||
|
||||
size_t SizeInBytes() const {
|
||||
const u32 compression_factor{GetCompressionFactor()};
|
||||
const u32 compression_factor{GetCompressionFactor(pixel_format)};
|
||||
ASSERT(width % compression_factor == 0);
|
||||
ASSERT(height % compression_factor == 0);
|
||||
return (width / compression_factor) * (height / compression_factor) *
|
||||
GetFormatBpp(pixel_format) / CHAR_BIT;
|
||||
}
|
||||
|
||||
SurfaceParams(const Tegra::Texture::FullTextureInfo& config);
|
||||
SurfaceParams(const Tegra::Engines::Maxwell3D::Regs::RenderTargetConfig& config);
|
||||
|
||||
VAddr GetCpuAddr() const;
|
||||
|
||||
Tegra::GPUVAddr addr;
|
||||
u32 width;
|
||||
u32 height;
|
||||
u32 block_height;
|
||||
bool is_tiled;
|
||||
PixelFormat pixel_format;
|
||||
SurfaceType type;
|
||||
ComponentType component_type;
|
||||
const Tegra::GPUVAddr addr;
|
||||
const bool is_tiled;
|
||||
const u32 block_height;
|
||||
const PixelFormat pixel_format;
|
||||
const ComponentType component_type;
|
||||
const SurfaceType type;
|
||||
const u32 width;
|
||||
const u32 height;
|
||||
};
|
||||
static_assert(std::is_pod<SurfaceParams>::value, "SurfaceParams is not POD");
|
||||
|
||||
class CachedSurface final {
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue