diff --git a/src/video_core/rasterizer_cache/cached_surface.cpp b/src/video_core/rasterizer_cache/cached_surface.cpp index d61671790..440c3bb47 100644 --- a/src/video_core/rasterizer_cache/cached_surface.cpp +++ b/src/video_core/rasterizer_cache/cached_surface.cpp @@ -3,15 +3,15 @@ // Refer to the license.txt file included. #include "common/microprofile.h" -#include "common/texture.h" #include "common/scope_exit.h" +#include "common/texture.h" #include "core/core.h" #include "video_core/rasterizer_cache/cached_surface.h" #include "video_core/rasterizer_cache/morton_swizzle.h" #include "video_core/rasterizer_cache/rasterizer_cache.h" -#include "video_core/renderer_opengl/texture_filters/texture_filterer.h" #include "video_core/renderer_opengl/gl_state.h" #include "video_core/renderer_opengl/texture_downloader_es.h" +#include "video_core/renderer_opengl/texture_filters/texture_filterer.h" namespace OpenGL { @@ -306,8 +306,8 @@ void CachedSurface::UploadGLTexture(Common::Rectangle rect) { if (is_custom) { const auto& tuple = GetFormatTuple(PixelFormat::RGBA8); - unscaled_tex = owner.AllocateSurfaceTexture(tuple, custom_tex_info.width, - custom_tex_info.height); + unscaled_tex = + owner.AllocateSurfaceTexture(tuple, custom_tex_info.width, custom_tex_info.height); } else { unscaled_tex = owner.AllocateSurfaceTexture(tuple, rect.GetWidth(), rect.GetHeight()); } @@ -367,8 +367,7 @@ void CachedSurface::UploadGLTexture(Common::Rectangle rect) { if (!owner.texture_filterer->Filter(unscaled_tex, from_rect, texture, scaled_rect, type)) { const Aspect aspect = ToAspect(type); - runtime.BlitTextures(unscaled_tex, {aspect, from_rect}, - texture, {aspect, scaled_rect}); + runtime.BlitTextures(unscaled_tex, {aspect, from_rect}, texture, {aspect, scaled_rect}); } } @@ -396,7 +395,8 @@ void CachedSurface::DownloadGLTexture(const Common::Rectangle& rect) { // Ensure no bad interactions with GL_PACK_ALIGNMENT ASSERT(stride * GetBytesPerPixel(pixel_format) % 4 == 0); glPixelStorei(GL_PACK_ROW_LENGTH, static_cast(stride)); - const std::size_t buffer_offset = (rect.bottom * stride + rect.left) * GetBytesPerPixel(pixel_format); + const std::size_t buffer_offset = + (rect.bottom * stride + rect.left) * GetBytesPerPixel(pixel_format); // If not 1x scale, blit scaled texture to a new 1x texture and use that to flush const Aspect aspect = ToAspect(type); @@ -408,11 +408,10 @@ void CachedSurface::DownloadGLTexture(const Common::Rectangle& rect) { scaled_rect.bottom *= res_scale; const Common::Rectangle unscaled_tex_rect{0, rect.GetHeight(), rect.GetWidth(), 0}; - auto unscaled_tex = owner.AllocateSurfaceTexture(tuple, rect.GetWidth(), - rect.GetHeight()); + auto unscaled_tex = owner.AllocateSurfaceTexture(tuple, rect.GetWidth(), rect.GetHeight()); // Blit scaled texture to the unscaled one - runtime.BlitTextures(texture, {aspect, scaled_rect}, - unscaled_tex, {aspect, unscaled_tex_rect}); + runtime.BlitTextures(texture, {aspect, scaled_rect}, unscaled_tex, + {aspect, unscaled_tex_rect}); state.texture_units[0].texture_2d = unscaled_tex.handle; state.Apply(); @@ -432,7 +431,8 @@ void CachedSurface::DownloadGLTexture(const Common::Rectangle& rect) { glPixelStorei(GL_PACK_ROW_LENGTH, 0); } -bool CachedSurface::CanFill(const SurfaceParams& dest_surface, SurfaceInterval fill_interval) const { +bool CachedSurface::CanFill(const SurfaceParams& dest_surface, + SurfaceInterval fill_interval) const { if (type == SurfaceType::Fill && IsRegionValid(fill_interval) && boost::icl::first(fill_interval) >= addr && boost::icl::last_next(fill_interval) <= end && // dest_surface is within our fill range @@ -459,7 +459,8 @@ bool CachedSurface::CanFill(const SurfaceParams& dest_surface, SurfaceInterval f return false; } -bool CachedSurface::CanCopy(const SurfaceParams& dest_surface, SurfaceInterval copy_interval) const { +bool CachedSurface::CanCopy(const SurfaceParams& dest_surface, + SurfaceInterval copy_interval) const { SurfaceParams subrect_params = dest_surface.FromInterval(copy_interval); ASSERT(subrect_params.GetInterval() == copy_interval); if (CanSubRect(subrect_params)) diff --git a/src/video_core/rasterizer_cache/cached_surface.h b/src/video_core/rasterizer_cache/cached_surface.h index 466980d68..008cad9a9 100644 --- a/src/video_core/rasterizer_cache/cached_surface.h +++ b/src/video_core/rasterizer_cache/cached_surface.h @@ -17,9 +17,9 @@ namespace OpenGL { */ class SurfaceWatcher { friend class CachedSurface; + public: - explicit SurfaceWatcher(std::weak_ptr&& surface) : - surface(std::move(surface)) {} + explicit SurfaceWatcher(std::weak_ptr&& surface) : surface(std::move(surface)) {} /// Checks whether the surface has been changed. bool IsValid() const { @@ -46,8 +46,8 @@ class RasterizerCacheOpenGL; class CachedSurface : public SurfaceParams, public std::enable_shared_from_this { public: - CachedSurface(SurfaceParams params, RasterizerCacheOpenGL& owner,TextureRuntime& runtime) : - SurfaceParams(params), owner(owner), runtime(runtime) {} + CachedSurface(SurfaceParams params, RasterizerCacheOpenGL& owner, TextureRuntime& runtime) + : SurfaceParams(params), owner(owner), runtime(runtime) {} ~CachedSurface(); /// Read/Write data in 3DS memory to/from gl_buffer diff --git a/src/video_core/rasterizer_cache/pixel_format.h b/src/video_core/rasterizer_cache/pixel_format.h index dd9e28861..218f4321e 100644 --- a/src/video_core/rasterizer_cache/pixel_format.h +++ b/src/video_core/rasterizer_cache/pixel_format.h @@ -5,8 +5,8 @@ #pragma once #include #include "core/hw/gpu.h" -#include "video_core/regs_texturing.h" #include "video_core/regs_framebuffer.h" +#include "video_core/regs_texturing.h" namespace OpenGL { @@ -98,8 +98,7 @@ constexpr PixelFormat PixelFormatFromColorFormat(Pica::FramebufferRegs::ColorFor constexpr PixelFormat PixelFormatFromDepthFormat(Pica::FramebufferRegs::DepthFormat format) { const u32 format_index = static_cast(format); - return (format_index < 4) ? static_cast(format_index + 14) - : PixelFormat::Invalid; + return (format_index < 4) ? static_cast(format_index + 14) : PixelFormat::Invalid; } constexpr PixelFormat PixelFormatFromGPUPixelFormat(GPU::Regs::PixelFormat format) { diff --git a/src/video_core/rasterizer_cache/rasterizer_cache.cpp b/src/video_core/rasterizer_cache/rasterizer_cache.cpp index 8050e82e9..b5dcf93fb 100644 --- a/src/video_core/rasterizer_cache/rasterizer_cache.cpp +++ b/src/video_core/rasterizer_cache/rasterizer_cache.cpp @@ -9,9 +9,9 @@ #include "common/microprofile.h" #include "video_core/pica_state.h" #include "video_core/rasterizer_cache/rasterizer_cache.h" -#include "video_core/renderer_opengl/texture_filters/texture_filterer.h" -#include "video_core/renderer_opengl/texture_downloader_es.h" #include "video_core/renderer_opengl/gl_format_reinterpreter.h" +#include "video_core/renderer_opengl/texture_downloader_es.h" +#include "video_core/renderer_opengl/texture_filters/texture_filterer.h" namespace OpenGL { @@ -75,8 +75,8 @@ static constexpr auto RangeFromInterval(Map& map, const Interval& interval) { } // Allocate an uninitialized texture of appropriate size and format for the surface -OGLTexture RasterizerCacheOpenGL::AllocateSurfaceTexture(const FormatTuple& tuple, - u32 width, u32 height) { +OGLTexture RasterizerCacheOpenGL::AllocateSurfaceTexture(const FormatTuple& tuple, u32 width, + u32 height) { auto recycled_tex = host_texture_recycler.find({tuple, width, height}); if (recycled_tex != host_texture_recycler.end()) { OGLTexture texture = std::move(recycled_tex->second); @@ -116,8 +116,8 @@ void RasterizerCacheOpenGL::CopySurface(const Surface& src_surface, const Surfac } const auto clear_rect = dst_surface->GetScaledSubRect(subrect_params); - const ClearValue clear_value = ToClearValue(aspect, dst_surface->pixel_format, - fill_buffer.data()); + const ClearValue clear_value = + ToClearValue(aspect, dst_surface->pixel_format, fill_buffer.data()); runtime.ClearTexture(dst_surface->texture, {aspect, clear_rect}, clear_value); return; @@ -127,8 +127,8 @@ void RasterizerCacheOpenGL::CopySurface(const Surface& src_surface, const Surfac const auto src_rect = src_surface->GetScaledSubRect(subrect_params); const auto dst_rect = dst_surface->GetScaledSubRect(subrect_params); - runtime.BlitTextures(src_surface->texture, {aspect, src_rect}, - dst_surface->texture, {aspect, dst_rect}); + runtime.BlitTextures(src_surface->texture, {aspect, src_rect}, dst_surface->texture, + {aspect, dst_rect}); return; } @@ -264,8 +264,8 @@ bool RasterizerCacheOpenGL::BlitSurfaces(const Surface& src_surface, dst_surface->InvalidateAllWatcher(); const Aspect aspect = ToAspect(src_surface->type); - return runtime.BlitTextures(src_surface->texture, {aspect, src_rect}, - dst_surface->texture, {aspect, dst_rect}); + return runtime.BlitTextures(src_surface->texture, {aspect, src_rect}, dst_surface->texture, + {aspect, dst_rect}); } return false; @@ -569,8 +569,8 @@ const CachedTextureCube& RasterizerCacheOpenGL::GetTextureCube(const TextureCube const auto src_rect = surface->GetScaledRect(); const auto dst_rect = Common::Rectangle{0, scaled_size, scaled_size, 0}; const Aspect aspect = ToAspect(surface->type); - runtime.BlitTextures(surface->texture, {aspect, src_rect}, - cube.texture, {aspect, dst_rect}); + runtime.BlitTextures(surface->texture, {aspect, src_rect}, cube.texture, + {aspect, dst_rect}); face.watcher->Validate(); } @@ -585,10 +585,13 @@ SurfaceSurfaceRect_Tuple RasterizerCacheOpenGL::GetFramebufferSurfaces( const auto& config = regs.framebuffer.framebuffer; // Update resolution_scale_factor and reset cache if changed - const bool resolution_scale_changed = resolution_scale_factor != VideoCore::GetResolutionScaleFactor(); - const bool texture_filter_changed = VideoCore::g_texture_filter_update_requested.exchange(false) - && texture_filterer->Reset(Settings::values.texture_filter_name, VideoCore::GetResolutionScaleFactor()); - + const bool resolution_scale_changed = + resolution_scale_factor != VideoCore::GetResolutionScaleFactor(); + const bool texture_filter_changed = + VideoCore::g_texture_filter_update_requested.exchange(false) && + texture_filterer->Reset(Settings::values.texture_filter_name, + VideoCore::GetResolutionScaleFactor()); + if (resolution_scale_changed || texture_filter_changed) { resolution_scale_factor = VideoCore::GetResolutionScaleFactor(); FlushAll(); @@ -843,8 +846,10 @@ bool RasterizerCacheOpenGL::IntervalHasInvalidPixelFormat(SurfaceParams& params, params.pixel_format = PixelFormat::Invalid; for (const auto& set : RangeFromInterval(surface_cache, interval)) for (const auto& surface : set.second) - if (surface->pixel_format == PixelFormat::Invalid && surface->type != SurfaceType::Fill) { - LOG_DEBUG(Render_OpenGL, "Surface {:#x} found with invalid pixel format", surface->addr); + if (surface->pixel_format == PixelFormat::Invalid && + surface->type != SurfaceType::Fill) { + LOG_DEBUG(Render_OpenGL, "Surface {:#x} found with invalid pixel format", + surface->addr); return true; } return false; @@ -880,19 +885,19 @@ bool RasterizerCacheOpenGL::ValidateByReinterpretation(const Surface& surface, const Common::Rectangle tmp_rect{0, width, height, 0}; OGLTexture tmp_tex = AllocateSurfaceTexture(tuple, height, width); - reinterpreter->Reinterpret(reinterpret_surface->texture, src_rect, - tmp_tex, tmp_rect); + reinterpreter->Reinterpret(reinterpret_surface->texture, src_rect, tmp_tex, + tmp_rect); - if (!texture_filterer->Filter(tmp_tex, tmp_rect, - surface->texture, dest_rect, type)) { + if (!texture_filterer->Filter(tmp_tex, tmp_rect, surface->texture, dest_rect, + type)) { const Aspect aspect = ToAspect(type); - runtime.BlitTextures(tmp_tex, {aspect, tmp_rect}, - surface->texture, {aspect, dest_rect}); + runtime.BlitTextures(tmp_tex, {aspect, tmp_rect}, surface->texture, + {aspect, dest_rect}); } } else { - reinterpreter->Reinterpret(reinterpret_surface->texture, src_rect, - surface->texture, dest_rect); + reinterpreter->Reinterpret(reinterpret_surface->texture, src_rect, surface->texture, + dest_rect); } return true; @@ -1034,8 +1039,8 @@ Surface RasterizerCacheOpenGL::CreateSurface(const SurfaceParams& params) { // Allocate surface texture const FormatTuple& tuple = GetFormatTuple(surface->pixel_format); - surface->texture = AllocateSurfaceTexture(tuple, surface->GetScaledWidth(), - surface->GetScaledHeight()); + surface->texture = + AllocateSurfaceTexture(tuple, surface->GetScaledWidth(), surface->GetScaledHeight()); return surface; } diff --git a/src/video_core/rasterizer_cache/rasterizer_cache_types.h b/src/video_core/rasterizer_cache/rasterizer_cache_types.h index 9b911dd00..5bfefc983 100644 --- a/src/video_core/rasterizer_cache/rasterizer_cache_types.h +++ b/src/video_core/rasterizer_cache/rasterizer_cache_types.h @@ -20,20 +20,19 @@ using Surface = std::shared_ptr; using SurfaceInterval = boost::icl::right_open_interval; using SurfaceSet = std::set; using SurfaceRegions = boost::icl::interval_set; -using SurfaceMap = boost::icl::interval_map; -using SurfaceCache = boost::icl::interval_map; +using SurfaceMap = + boost::icl::interval_map; +using SurfaceCache = + boost::icl::interval_map; static_assert(std::is_same() && - std::is_same(), + std::is_same(), "Incorrect interval types"); using SurfaceRect_Tuple = std::tuple>; using SurfaceSurfaceRect_Tuple = std::tuple>; using PageMap = boost::icl::interval_map; - } // namespace OpenGL diff --git a/src/video_core/rasterizer_cache/surface_params.cpp b/src/video_core/rasterizer_cache/surface_params.cpp index d5fb3ecdb..90f2776ea 100644 --- a/src/video_core/rasterizer_cache/surface_params.cpp +++ b/src/video_core/rasterizer_cache/surface_params.cpp @@ -14,9 +14,9 @@ SurfaceParams SurfaceParams::FromInterval(SurfaceInterval interval) const { const u32 stride_tiled_bytes = BytesInPixels(stride * tiled_size); PAddr aligned_start = - addr + Common::AlignDown(boost::icl::first(interval) - addr, stride_tiled_bytes); + addr + Common::AlignDown(boost::icl::first(interval) - addr, stride_tiled_bytes); PAddr aligned_end = - addr + Common::AlignUp(boost::icl::last_next(interval) - addr, stride_tiled_bytes); + addr + Common::AlignUp(boost::icl::last_next(interval) - addr, stride_tiled_bytes); if (aligned_end - aligned_start > stride_tiled_bytes) { params.addr = aligned_start; @@ -27,9 +27,9 @@ SurfaceParams SurfaceParams::FromInterval(SurfaceInterval interval) const { const u32 tiled_alignment = BytesInPixels(is_tiled ? 8 * 8 : 1); aligned_start = - addr + Common::AlignDown(boost::icl::first(interval) - addr, tiled_alignment); + addr + Common::AlignDown(boost::icl::first(interval) - addr, tiled_alignment); aligned_end = - addr + Common::AlignUp(boost::icl::last_next(interval) - addr, tiled_alignment); + addr + Common::AlignUp(boost::icl::last_next(interval) - addr, tiled_alignment); params.addr = aligned_start; params.width = PixelsInBytes(aligned_end - aligned_start) / tiled_size; diff --git a/src/video_core/rasterizer_cache/texture_runtime.cpp b/src/video_core/rasterizer_cache/texture_runtime.cpp index b8406bd21..ebbb6955e 100644 --- a/src/video_core/rasterizer_cache/texture_runtime.cpp +++ b/src/video_core/rasterizer_cache/texture_runtime.cpp @@ -39,15 +39,15 @@ void TextureRuntime::ReadTexture(const OGLTexture& tex, Subresource subresource, const u32 level = subresource.level; switch (subresource.aspect) { case Aspect::Color: - glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, - tex.handle, level); - glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, - 0, 0); + glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex.handle, + level); + glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, + 0); break; case Aspect::Depth: glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); - glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, - tex.handle, level); + glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, tex.handle, + level); glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0); break; case Aspect::DepthStencil: @@ -58,8 +58,8 @@ void TextureRuntime::ReadTexture(const OGLTexture& tex, Subresource subresource, } const auto& rect = subresource.region; - glReadPixels(rect.left, rect.bottom, rect.GetWidth(), rect.GetHeight(), - tuple.format, tuple.type, pixels); + glReadPixels(rect.left, rect.bottom, rect.GetWidth(), rect.GetHeight(), tuple.format, + tuple.type, pixels); } bool TextureRuntime::ClearTexture(const OGLTexture& tex, Subresource subresource, @@ -81,10 +81,10 @@ bool TextureRuntime::ClearTexture(const OGLTexture& tex, Subresource subresource const u32 level = subresource.level; switch (subresource.aspect) { case Aspect::Color: - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, - tex.handle, level); - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, - 0, 0); + glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex.handle, + level); + glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, + 0); state.color_mask.red_enabled = true; state.color_mask.green_enabled = true; @@ -96,8 +96,8 @@ bool TextureRuntime::ClearTexture(const OGLTexture& tex, Subresource subresource break; case Aspect::Depth: glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, - tex.handle, level); + glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, tex.handle, + level); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0); state.depth.write_mask = GL_TRUE; @@ -136,9 +136,8 @@ bool TextureRuntime::BlitTextures(const OGLTexture& src_tex, Subresource src_sub state.draw.draw_framebuffer = draw_fbo.handle; state.Apply(); - auto BindAttachment = [src_level = src_subresource.level, - dst_level = dst_subresource.level](GLenum target, u32 src_tex, - u32 dst_tex) -> void { + auto BindAttachment = [src_level = src_subresource.level, dst_level = dst_subresource.level]( + GLenum target, u32 src_tex, u32 dst_tex) -> void { glFramebufferTexture2D(GL_READ_FRAMEBUFFER, target, GL_TEXTURE_2D, src_tex, src_level); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, target, GL_TEXTURE_2D, dst_tex, dst_level); }; @@ -172,8 +171,8 @@ bool TextureRuntime::BlitTextures(const OGLTexture& src_tex, Subresource src_sub const GLenum filter = src_subresource.aspect == Aspect::Color ? GL_LINEAR : GL_NEAREST; const auto& src_rect = src_subresource.region; const auto& dst_rect = dst_subresource.region; - glBlitFramebuffer(src_rect.left, src_rect.bottom, src_rect.right, src_rect.top, - dst_rect.left, dst_rect.bottom, dst_rect.right, dst_rect.top, + glBlitFramebuffer(src_rect.left, src_rect.bottom, src_rect.right, src_rect.top, dst_rect.left, + dst_rect.bottom, dst_rect.right, dst_rect.top, ToBufferMask(src_subresource.aspect), filter); return true; diff --git a/src/video_core/rasterizer_cache/texture_runtime.h b/src/video_core/rasterizer_cache/texture_runtime.h index b14136e2f..bad99cdc9 100644 --- a/src/video_core/rasterizer_cache/texture_runtime.h +++ b/src/video_core/rasterizer_cache/texture_runtime.h @@ -10,11 +10,7 @@ namespace OpenGL { // Describes the type of data a texture holds -enum class Aspect { - Color = 0, - Depth = 1, - DepthStencil = 2 -}; +enum class Aspect { Color = 0, Depth = 1, DepthStencil = 2 }; // A union for both color and depth/stencil clear values union ClearValue { @@ -26,8 +22,8 @@ union ClearValue { }; struct Subresource { - Subresource(Aspect aspect, Common::Rectangle region, u32 level = 0, u32 layer = 0) : - aspect(aspect), region(region), level(level), layer(layer) {} + Subresource(Aspect aspect, Common::Rectangle region, u32 level = 0, u32 layer = 0) + : aspect(aspect), region(region), level(level), layer(layer) {} Aspect aspect; Common::Rectangle region; @@ -47,8 +43,8 @@ public: ~TextureRuntime() = default; // Copies the GPU pixel data to the provided pixels buffer - void ReadTexture(const OGLTexture& tex, Subresource subresource, - const FormatTuple& tuple, u8* pixels); + void ReadTexture(const OGLTexture& tex, Subresource subresource, const FormatTuple& tuple, + u8* pixels); // Fills the rectangle of the texture with the clear value provided bool ClearTexture(const OGLTexture& texture, Subresource subresource, ClearValue value); diff --git a/src/video_core/renderer_opengl/gl_format_reinterpreter.cpp b/src/video_core/renderer_opengl/gl_format_reinterpreter.cpp index 11db7ce6d..437675c46 100644 --- a/src/video_core/renderer_opengl/gl_format_reinterpreter.cpp +++ b/src/video_core/renderer_opengl/gl_format_reinterpreter.cpp @@ -81,8 +81,8 @@ void main() { glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, dst_tex.handle, 0); - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, - 0, 0); + glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, + 0); glUniform2i(dst_size_loc, dst_rect.GetWidth(), dst_rect.GetHeight()); glUniform2i(src_size_loc, src_rect.GetWidth(), src_rect.GetHeight()); @@ -96,7 +96,6 @@ private: OGLVertexArray vao; }; - class ShaderD24S8toRGBA8 final : public FormatReinterpreterBase { public: ShaderD24S8toRGBA8() { @@ -186,7 +185,8 @@ void main() { if (use_texture_view) { temp_tex.Create(); glActiveTexture(GL_TEXTURE1); - glTextureView(temp_tex.handle, GL_TEXTURE_2D, src_tex.handle, GL_DEPTH24_STENCIL8, 0, 1, 0, 1); + glTextureView(temp_tex.handle, GL_TEXTURE_2D, src_tex.handle, GL_DEPTH24_STENCIL8, 0, 1, + 0, 1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); } else if (src_rect.top > temp_rect.top || src_rect.right > temp_rect.right) { @@ -220,8 +220,8 @@ void main() { glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, dst_tex.handle, 0); - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, - 0, 0); + glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, + 0); glUniform2i(dst_size_loc, dst_rect.GetWidth(), dst_rect.GetHeight()); glUniform2i(src_size_loc, src_rect.GetWidth(), src_rect.GetHeight()); diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 64ae0c827..03f4ac559 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -148,8 +148,8 @@ RasterizerOpenGL::RasterizerOpenGL(Frontend::EmuWindow& emu_window) emu_window, VideoCore::g_separable_shader_enabled ? GLAD_GL_ARB_separate_shader_objects : false); } else { - shader_program_manager = std::make_unique( - emu_window, GLAD_GL_ARB_separate_shader_objects); + shader_program_manager = + std::make_unique(emu_window, GLAD_GL_ARB_separate_shader_objects); } #else shader_program_manager = std::make_unique(emu_window, true); @@ -726,12 +726,10 @@ bool RasterizerOpenGL::Draw(bool accelerate, bool is_indexed) { // Making a copy to sample from eliminates this issue and seems to be fairly cheap. temp_tex.Create(); temp_tex.Allocate(GL_TEXTURE_2D, levels, tuple.internal_format, - color_surface->GetScaledWidth(), - color_surface->GetScaledHeight()); + color_surface->GetScaledWidth(), color_surface->GetScaledHeight()); temp_tex.CopyFrom(color_surface->texture, GL_TEXTURE_2D, levels, - color_surface->GetScaledWidth(), - color_surface->GetScaledHeight()); + color_surface->GetScaledWidth(), color_surface->GetScaledHeight()); for (auto& unit : state.texture_units) { if (unit.texture_2d == color_surface->texture.handle) { @@ -1902,11 +1900,9 @@ void RasterizerOpenGL::SyncLightAmbient(int light_index) { void RasterizerOpenGL::SyncLightPosition(int light_index) { const auto& light = Pica::g_state.regs.lighting.light[light_index]; - const Common::Vec3f position = { - Pica::float16::FromRaw(light.x).ToFloat32(), - Pica::float16::FromRaw(light.y).ToFloat32(), - Pica::float16::FromRaw(light.z).ToFloat32() - }; + const Common::Vec3f position = {Pica::float16::FromRaw(light.x).ToFloat32(), + Pica::float16::FromRaw(light.y).ToFloat32(), + Pica::float16::FromRaw(light.z).ToFloat32()}; if (position != uniform_block_data.data.light_src[light_index].position) { uniform_block_data.data.light_src[light_index].position = position; @@ -1916,8 +1912,7 @@ void RasterizerOpenGL::SyncLightPosition(int light_index) { void RasterizerOpenGL::SyncLightSpotDirection(int light_index) { const auto& light = Pica::g_state.regs.lighting.light[light_index]; - const auto spot_direction = Common::Vec3u{light.spot_x, light.spot_y, light.spot_z} - / 2047.0f; + const auto spot_direction = Common::Vec3u{light.spot_x, light.spot_y, light.spot_z} / 2047.0f; if (spot_direction != uniform_block_data.data.light_src[light_index].spot_direction) { uniform_block_data.data.light_src[light_index].spot_direction = spot_direction; @@ -2019,7 +2014,8 @@ void RasterizerOpenGL::SyncAndUploadLUTsLF() { if (new_data != fog_lut_data || invalidate) { fog_lut_data = new_data; - std::memcpy(buffer + bytes_used, new_data.data(), new_data.size() * sizeof(Common::Vec2f)); + std::memcpy(buffer + bytes_used, new_data.data(), + new_data.size() * sizeof(Common::Vec2f)); uniform_block_data.data.fog_lut_offset = static_cast((offset + bytes_used) / sizeof(Common::Vec2f)); uniform_block_data.dirty = true; @@ -2032,9 +2028,10 @@ void RasterizerOpenGL::SyncAndUploadLUTsLF() { } void RasterizerOpenGL::SyncAndUploadLUTs() { - constexpr std::size_t max_size = sizeof(Common::Vec2f) * 128 * 3 + // proctex: noise + color + alpha - sizeof(Common::Vec4f) * 256 + // proctex - sizeof(Common::Vec4f) * 256; // proctex diff + constexpr std::size_t max_size = + sizeof(Common::Vec2f) * 128 * 3 + // proctex: noise + color + alpha + sizeof(Common::Vec4f) * 256 + // proctex + sizeof(Common::Vec4f) * 256; // proctex diff if (!uniform_block_data.proctex_noise_lut_dirty && !uniform_block_data.proctex_color_map_dirty && @@ -2061,7 +2058,8 @@ void RasterizerOpenGL::SyncAndUploadLUTs() { if (new_data != lut_data || invalidate) { lut_data = new_data; - std::memcpy(buffer + bytes_used, new_data.data(), new_data.size() * sizeof(Common::Vec2f)); + std::memcpy(buffer + bytes_used, new_data.data(), + new_data.size() * sizeof(Common::Vec2f)); lut_offset = static_cast((offset + bytes_used) / sizeof(Common::Vec2f)); uniform_block_data.dirty = true; bytes_used += new_data.size() * sizeof(Common::Vec2f); @@ -2102,7 +2100,8 @@ void RasterizerOpenGL::SyncAndUploadLUTs() { if (new_data != proctex_lut_data || invalidate) { proctex_lut_data = new_data; - std::memcpy(buffer + bytes_used, new_data.data(), new_data.size() * sizeof(Common::Vec4f)); + std::memcpy(buffer + bytes_used, new_data.data(), + new_data.size() * sizeof(Common::Vec4f)); uniform_block_data.data.proctex_lut_offset = static_cast((offset + bytes_used) / sizeof(Common::Vec4f)); uniform_block_data.dirty = true; @@ -2124,7 +2123,8 @@ void RasterizerOpenGL::SyncAndUploadLUTs() { if (new_data != proctex_diff_lut_data || invalidate) { proctex_diff_lut_data = new_data; - std::memcpy(buffer + bytes_used, new_data.data(), new_data.size() * sizeof(Common::Vec4f)); + std::memcpy(buffer + bytes_used, new_data.data(), + new_data.size() * sizeof(Common::Vec4f)); uniform_block_data.data.proctex_diff_lut_offset = static_cast((offset + bytes_used) / sizeof(Common::Vec4f)); uniform_block_data.dirty = true; diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index e623f3bdb..f4e4eb8d6 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h @@ -6,10 +6,10 @@ #include "common/vector_math.h" #include "core/hw/gpu.h" #include "video_core/pica_types.h" +#include "video_core/rasterizer_cache/rasterizer_cache.h" #include "video_core/rasterizer_interface.h" #include "video_core/regs_lighting.h" #include "video_core/regs_texturing.h" -#include "video_core/rasterizer_cache/rasterizer_cache.h" #include "video_core/renderer_opengl/gl_shader_manager.h" #include "video_core/renderer_opengl/gl_state.h" #include "video_core/renderer_opengl/gl_stream_buffer.h" @@ -298,7 +298,8 @@ private: OGLTexture texture_buffer_lut_rg; OGLTexture texture_buffer_lut_rgba; - std::array, Pica::LightingRegs::NumLightingSampler> lighting_lut_data{}; + std::array, Pica::LightingRegs::NumLightingSampler> + lighting_lut_data{}; std::array fog_lut_data{}; std::array proctex_noise_lut_data{}; std::array proctex_color_map_data{}; diff --git a/src/video_core/renderer_opengl/gl_resource_manager.cpp b/src/video_core/renderer_opengl/gl_resource_manager.cpp index efd82804d..2deeb9bc4 100644 --- a/src/video_core/renderer_opengl/gl_resource_manager.cpp +++ b/src/video_core/renderer_opengl/gl_resource_manager.cpp @@ -52,8 +52,8 @@ void OGLTexture::Release() { handle = 0; } -void OGLTexture::Allocate(GLenum target, GLsizei levels, GLenum internalformat, - GLsizei width, GLsizei height, GLsizei depth) { +void OGLTexture::Allocate(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, + GLsizei height, GLsizei depth) { GLuint old_tex = OpenGLState::GetCurState().texture_units[0].texture_2d; glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, handle); @@ -83,17 +83,15 @@ void OGLTexture::Allocate(GLenum target, GLsizei levels, GLenum internalformat, glBindTexture(GL_TEXTURE_2D, old_tex); } -void OGLTexture::CopyFrom(const OGLTexture& other, GLenum target, GLsizei levels, - GLsizei width, GLsizei height) { +void OGLTexture::CopyFrom(const OGLTexture& other, GLenum target, GLsizei levels, GLsizei width, + GLsizei height) { GLuint old_tex = OpenGLState::GetCurState().texture_units[0].texture_2d; glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, handle); for (u32 level = 0; level < levels; level++) { - glCopyImageSubData(other.handle, target, level, 0, 0, 0, - handle, target, level, 0, 0, 0, - width >> level, - height >> level, 1); + glCopyImageSubData(other.handle, target, level, 0, 0, 0, handle, target, level, 0, 0, 0, + width >> level, height >> level, 1); } glBindTexture(GL_TEXTURE_2D, old_tex); diff --git a/src/video_core/renderer_opengl/gl_resource_manager.h b/src/video_core/renderer_opengl/gl_resource_manager.h index 9abbd1c5d..b8c8f5bc9 100644 --- a/src/video_core/renderer_opengl/gl_resource_manager.h +++ b/src/video_core/renderer_opengl/gl_resource_manager.h @@ -58,11 +58,11 @@ public: /// Deletes the internal OpenGL resource void Release(); - void Allocate(GLenum target, GLsizei levels, GLenum internalformat, - GLsizei width, GLsizei height = 1, GLsizei depth = 1); + void Allocate(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, + GLsizei height = 1, GLsizei depth = 1); - void CopyFrom(const OGLTexture& other, GLenum target, GLsizei levels, - GLsizei width, GLsizei height); + void CopyFrom(const OGLTexture& other, GLenum target, GLsizei levels, GLsizei width, + GLsizei height); GLuint handle = 0; }; diff --git a/src/video_core/renderer_opengl/gl_shader_manager.cpp b/src/video_core/renderer_opengl/gl_shader_manager.cpp index badc1af34..db42d5d7a 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.cpp +++ b/src/video_core/renderer_opengl/gl_shader_manager.cpp @@ -3,17 +3,17 @@ // Refer to the license.txt file included. #include -#include #include +#include #include -#include #include +#include #include "core/frontend/scope_acquire_context.h" #include "video_core/renderer_opengl/gl_resource_manager.h" #include "video_core/renderer_opengl/gl_shader_disk_cache.h" #include "video_core/renderer_opengl/gl_shader_manager.h" -#include "video_core/renderer_opengl/gl_vars.h" #include "video_core/renderer_opengl/gl_state.h" +#include "video_core/renderer_opengl/gl_vars.h" #include "video_core/video_core.h" namespace OpenGL { diff --git a/src/video_core/renderer_opengl/gl_shader_manager.h b/src/video_core/renderer_opengl/gl_shader_manager.h index eef52383a..e487461ad 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.h +++ b/src/video_core/renderer_opengl/gl_shader_manager.h @@ -20,7 +20,7 @@ class EmuWindow; namespace Pica { struct Regs; struct ShaderRegs; -} +} // namespace Pica namespace Pica::Shader { struct ShaderSetup; diff --git a/src/video_core/renderer_opengl/pica_to_gl.h b/src/video_core/renderer_opengl/pica_to_gl.h index 5a559d72e..e4c14f186 100644 --- a/src/video_core/renderer_opengl/pica_to_gl.h +++ b/src/video_core/renderer_opengl/pica_to_gl.h @@ -232,8 +232,8 @@ inline GLenum StencilOp(Pica::FramebufferRegs::StencilAction action) { } inline Common::Vec4f ColorRGBA8(const u32 color) { - const auto rgba = Common::Vec4u{color >> 0 & 0xFF, color >> 8 & 0xFF, - color >> 16 & 0xFF, color >> 24 & 0xFF}; + const auto rgba = + Common::Vec4u{color >> 0 & 0xFF, color >> 8 & 0xFF, color >> 16 & 0xFF, color >> 24 & 0xFF}; return rgba / 255.0f; } diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 725fc8685..adaba59bd 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -16,8 +16,8 @@ #include "core/tracer/recorder.h" #include "video_core/debug_utils/debug_utils.h" #include "video_core/rasterizer_interface.h" -#include "video_core/renderer_opengl/gl_state.h" #include "video_core/renderer_opengl/gl_shader_util.h" +#include "video_core/renderer_opengl/gl_state.h" #include "video_core/renderer_opengl/gl_vars.h" #include "video_core/renderer_opengl/post_processing_opengl.h" #include "video_core/renderer_opengl/renderer_opengl.h" diff --git a/src/video_core/renderer_opengl/texture_downloader_es.cpp b/src/video_core/renderer_opengl/texture_downloader_es.cpp index fcf5e99bb..49b2c3f88 100644 --- a/src/video_core/renderer_opengl/texture_downloader_es.cpp +++ b/src/video_core/renderer_opengl/texture_downloader_es.cpp @@ -6,12 +6,12 @@ #include #include #include "common/logging/log.h" -#include "video_core/rasterizer_cache/rasterizer_cache_utils.h" -#include "video_core/renderer_opengl/gl_state.h" -#include "video_core/renderer_opengl/texture_downloader_es.h" #include "shaders/depth_to_color.frag" #include "shaders/depth_to_color.vert" #include "shaders/ds_to_color.frag" +#include "video_core/rasterizer_cache/rasterizer_cache_utils.h" +#include "video_core/renderer_opengl/gl_state.h" +#include "video_core/renderer_opengl/texture_downloader_es.h" namespace OpenGL { diff --git a/src/video_core/renderer_opengl/texture_filters/anime4k/anime4k_ultrafast.cpp b/src/video_core/renderer_opengl/texture_filters/anime4k/anime4k_ultrafast.cpp index 0a43d9f27..83168f0a1 100644 --- a/src/video_core/renderer_opengl/texture_filters/anime4k/anime4k_ultrafast.cpp +++ b/src/video_core/renderer_opengl/texture_filters/anime4k/anime4k_ultrafast.cpp @@ -133,8 +133,8 @@ void Anime4kUltrafast::Filter(const OGLTexture& src_tex, Common::Rectangle state.draw.shader_program = refine_program.handle; state.Apply(); - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, - dst_tex.handle, 0); + glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, dst_tex.handle, + 0); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); diff --git a/src/video_core/renderer_opengl/texture_filters/bicubic/bicubic.cpp b/src/video_core/renderer_opengl/texture_filters/bicubic/bicubic.cpp index f1764889d..b9981ad07 100644 --- a/src/video_core/renderer_opengl/texture_filters/bicubic/bicubic.cpp +++ b/src/video_core/renderer_opengl/texture_filters/bicubic/bicubic.cpp @@ -35,8 +35,8 @@ void Bicubic::Filter(const OGLTexture& src_tex, Common::Rectangle src_rect, static_cast(dst_rect.GetHeight())}; state.Apply(); - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, - dst_tex.handle, 0); + glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, dst_tex.handle, + 0); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); diff --git a/src/video_core/renderer_opengl/texture_filters/scale_force/scale_force.cpp b/src/video_core/renderer_opengl/texture_filters/scale_force/scale_force.cpp index 8a5835f5c..483f3d79a 100644 --- a/src/video_core/renderer_opengl/texture_filters/scale_force/scale_force.cpp +++ b/src/video_core/renderer_opengl/texture_filters/scale_force/scale_force.cpp @@ -35,8 +35,8 @@ void ScaleForce::Filter(const OGLTexture& src_tex, Common::Rectangle src_re static_cast(dst_rect.GetHeight())}; state.Apply(); - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, - dst_tex.handle, 0); + glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, dst_tex.handle, + 0); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); diff --git a/src/video_core/renderer_opengl/texture_filters/texture_filter_base.h b/src/video_core/renderer_opengl/texture_filters/texture_filter_base.h index d0858a0c2..9957ee171 100644 --- a/src/video_core/renderer_opengl/texture_filters/texture_filter_base.h +++ b/src/video_core/renderer_opengl/texture_filters/texture_filter_base.h @@ -15,6 +15,7 @@ class OGLTexture; class TextureFilterBase { friend class TextureFilterer; + public: explicit TextureFilterBase(u16 scale_factor) : scale_factor(scale_factor) { draw_fbo.Create(); diff --git a/src/video_core/renderer_opengl/texture_filters/texture_filterer.h b/src/video_core/renderer_opengl/texture_filters/texture_filterer.h index cc8462960..5ef40a4be 100644 --- a/src/video_core/renderer_opengl/texture_filters/texture_filterer.h +++ b/src/video_core/renderer_opengl/texture_filters/texture_filterer.h @@ -27,8 +27,7 @@ public: // Returns true if the texture was able to be filtered bool Filter(const OGLTexture& src_tex, Common::Rectangle src_rect, - const OGLTexture& dst_tex, Common::Rectangle dst_rect, - SurfaceType type); + const OGLTexture& dst_tex, Common::Rectangle dst_rect, SurfaceType type); static std::vector GetFilterNames(); diff --git a/src/video_core/renderer_opengl/texture_filters/xbrz/xbrz_freescale.cpp b/src/video_core/renderer_opengl/texture_filters/xbrz/xbrz_freescale.cpp index 1f0a32343..3849bb2c5 100644 --- a/src/video_core/renderer_opengl/texture_filters/xbrz/xbrz_freescale.cpp +++ b/src/video_core/renderer_opengl/texture_filters/xbrz/xbrz_freescale.cpp @@ -47,8 +47,7 @@ namespace OpenGL { -XbrzFreescale::XbrzFreescale(u16 scale_factor) : - TextureFilterBase(scale_factor) { +XbrzFreescale::XbrzFreescale(u16 scale_factor) : TextureFilterBase(scale_factor) { const OpenGLState cur_state = OpenGLState::GetCurState(); @@ -84,8 +83,8 @@ void XbrzFreescale::Filter(const OGLTexture& src_tex, Common::Rectangle src static_cast(dst_rect.GetHeight())}; state.Apply(); - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, - dst_tex.handle, 0); + glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, dst_tex.handle, + 0); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);