Miscallenious fixes to gl backend and qt frontend (#6834)

* renderer_gl: Make rasterizer normal class member

* It doesn't need to be heap allocated anymore

* gl_rasterizer: Remove default_texture

* It's unused

* gl_rasterizer: General cleanup

* gl_rasterizer: Lower case lambdas

* Match style with review comments from vulkan backend

* rasterizer_cache: Prevent memory leak

* Since the switch from shared_ptr these surfaces were no longer being destroyed properly. Use our garbage collector for that purpose to destroy it safely for both backends

* rasterizer_cache: Make temp copy of old surface

* The custom surface would override the memory region of the old region resulting in garbage data, this ensures the custom surface is constructed correctly

* citra_qt: Manually create dialog tabs

* Allows for custom constructors which is very useful. While at it, global state is now eliminated from configuration

* citra_qt: Eliminate global system usage

* core: Remove global system usage in memory and HIO

* citra_qt: Use qOverload

* tests: Run clang format

* gl_texture_runtime: Fix surface scaling
This commit is contained in:
GPUCode 2023-08-02 01:40:39 +03:00 committed by GitHub
parent 970f2284d8
commit 88ea66053e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
73 changed files with 594 additions and 555 deletions

View file

@ -503,26 +503,27 @@ SurfaceId RasterizerCache<T>::GetTextureSurface(const Pica::Texture::TextureInfo
const u32 min_width = info.width >> max_level;
const u32 min_height = info.height >> max_level;
if (min_width % 8 != 0 || min_height % 8 != 0) {
if (min_width % 4 == 0 && min_height % 4 == 0) {
const auto [src_surface_id, rect] = GetSurfaceSubRect(params, ScaleMatch::Ignore, true);
Surface& src_surface = slot_surfaces[src_surface_id];
params.res_scale = src_surface.res_scale;
SurfaceId tmp_surface_id = CreateSurface(params);
Surface& tmp_surface = slot_surfaces[tmp_surface_id];
const TextureBlit blit = {
.src_level = src_surface.LevelOf(params.addr),
.dst_level = 0,
.src_rect = rect,
.dst_rect = tmp_surface.GetScaledRect(),
};
runtime.BlitTextures(src_surface, tmp_surface, blit);
return tmp_surface_id;
if (min_width % 4 != 0 || min_height % 4 != 0) {
LOG_CRITICAL(HW_GPU, "Texture size ({}x{}) is not multiple of 4", min_width,
min_height);
return NULL_SURFACE_ID;
}
const auto [src_surface_id, rect] = GetSurfaceSubRect(params, ScaleMatch::Ignore, true);
Surface& src_surface = slot_surfaces[src_surface_id];
LOG_CRITICAL(HW_GPU, "Texture size ({}x{}) is not multiple of 4", min_width, min_height);
return NULL_SURFACE_ID;
params.res_scale = src_surface.res_scale;
SurfaceId tmp_surface_id = CreateSurface(params);
Surface& tmp_surface = slot_surfaces[tmp_surface_id];
sentenced.emplace_back(tmp_surface_id, frame_tick);
const TextureBlit blit = {
.src_level = src_surface.LevelOf(params.addr),
.dst_level = 0,
.src_rect = rect,
.dst_rect = tmp_surface.GetScaledRect(),
};
runtime.BlitTextures(src_surface, tmp_surface, blit);
return tmp_surface_id;
}
if (info.width != (min_width << max_level) || info.height != (min_height << max_level)) {
LOG_CRITICAL(HW_GPU, "Texture size ({}x{}) does not support required mipmap level ({})",
@ -1054,8 +1055,9 @@ bool RasterizerCache<T>::UploadCustomSurface(SurfaceId surface_id, SurfaceInterv
ASSERT_MSG(True(surface.flags & SurfaceFlagBits::Custom),
"Surface is not suitable for custom upload, aborting!");
if (!surface.IsCustom()) {
const SurfaceBase old_surface{surface};
const SurfaceId old_id =
slot_surfaces.swap_and_insert(surface_id, runtime, surface, material);
slot_surfaces.swap_and_insert(surface_id, runtime, old_surface, material);
sentenced.emplace_back(old_id, frame_tick);
}
surface.UploadCustom(material, level);

View file

@ -105,7 +105,7 @@ SurfaceInterval SurfaceBase::GetCopyableInterval(const SurfaceParams& params) co
return result;
}
Extent SurfaceBase::RealExtent(bool scaled) {
Extent SurfaceBase::RealExtent(bool scaled) const {
const bool is_custom = IsCustom();
u32 real_width = width;
u32 real_height = height;

View file

@ -41,7 +41,7 @@ public:
ClearValue MakeClearValue(PAddr copy_addr, PixelFormat dst_format);
/// Returns the internal surface extent.
Extent RealExtent(bool scaled = true);
Extent RealExtent(bool scaled = true) const;
/// Returns true if the surface contains a custom material with a normal map.
bool HasNormalMap() const noexcept;

View file

@ -73,12 +73,12 @@ public:
return height * res_scale;
}
[[nodiscard]] Common::Rectangle<u32> GetRect() const noexcept {
return {0, height, width, 0};
[[nodiscard]] Common::Rectangle<u32> GetRect(u32 level = 0) const noexcept {
return {0, height >> level, width >> level, 0};
}
[[nodiscard]] Common::Rectangle<u32> GetScaledRect() const noexcept {
return {0, GetScaledHeight(), GetScaledWidth(), 0};
[[nodiscard]] Common::Rectangle<u32> GetScaledRect(u32 level = 0) const noexcept {
return {0, GetScaledHeight() >> level, GetScaledWidth() >> level, 0};
}
[[nodiscard]] u32 PixelsInBytes(u32 size) const noexcept {