diff --git a/Source/Core/Core/Config/GraphicsSettings.cpp b/Source/Core/Core/Config/GraphicsSettings.cpp index d4b85972f6..f95e44a92a 100644 --- a/Source/Core/Core/Config/GraphicsSettings.cpp +++ b/Source/Core/Core/Config/GraphicsSettings.cpp @@ -43,7 +43,7 @@ const ConfigInfo GFX_CONVERT_HIRES_TEXTURES{{System::GFX, "Settings", "Con const ConfigInfo GFX_CACHE_HIRES_TEXTURES{{System::GFX, "Settings", "CacheHiresTextures"}, false}; const ConfigInfo GFX_DUMP_EFB_TARGET{{System::GFX, "Settings", "DumpEFBTarget"}, false}; -const ConfigInfo GFX_DUMP_XFB_TARGET{ { System::GFX, "Settings", "DumpXFBTarget" }, false }; +const ConfigInfo GFX_DUMP_XFB_TARGET{{System::GFX, "Settings", "DumpXFBTarget"}, false}; const ConfigInfo GFX_DUMP_FRAMES_AS_IMAGES{{System::GFX, "Settings", "DumpFramesAsImages"}, false}; const ConfigInfo GFX_FREE_LOOK{{System::GFX, "Settings", "FreeLook"}, false}; diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index 0f5f783e5b..84c6a82c35 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -28,17 +28,17 @@ bool IsSettingSaveable(const Config::ConfigLocation& config_location) // Graphics.Settings Config::GFX_WIDESCREEN_HACK.location, Config::GFX_ASPECT_RATIO.location, - Config::GFX_CROP.location, - Config::GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES.location, Config::GFX_SHOW_FPS.location, - Config::GFX_SHOW_NETPLAY_PING.location, Config::GFX_SHOW_NETPLAY_MESSAGES.location, - Config::GFX_LOG_RENDER_TIME_TO_FILE.location, Config::GFX_OVERLAY_STATS.location, - Config::GFX_OVERLAY_PROJ_STATS.location, Config::GFX_DUMP_TEXTURES.location, - Config::GFX_HIRES_TEXTURES.location, Config::GFX_CONVERT_HIRES_TEXTURES.location, - Config::GFX_CACHE_HIRES_TEXTURES.location, Config::GFX_DUMP_EFB_TARGET.location, - Config::GFX_DUMP_FRAMES_AS_IMAGES.location, Config::GFX_FREE_LOOK.location, - Config::GFX_USE_FFV1.location, Config::GFX_DUMP_FORMAT.location, - Config::GFX_DUMP_CODEC.location, Config::GFX_DUMP_PATH.location, - Config::GFX_BITRATE_KBPS.location, Config::GFX_INTERNAL_RESOLUTION_FRAME_DUMPS.location, + Config::GFX_CROP.location, Config::GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES.location, + Config::GFX_SHOW_FPS.location, Config::GFX_SHOW_NETPLAY_PING.location, + Config::GFX_SHOW_NETPLAY_MESSAGES.location, Config::GFX_LOG_RENDER_TIME_TO_FILE.location, + Config::GFX_OVERLAY_STATS.location, Config::GFX_OVERLAY_PROJ_STATS.location, + Config::GFX_DUMP_TEXTURES.location, Config::GFX_HIRES_TEXTURES.location, + Config::GFX_CONVERT_HIRES_TEXTURES.location, Config::GFX_CACHE_HIRES_TEXTURES.location, + Config::GFX_DUMP_EFB_TARGET.location, Config::GFX_DUMP_FRAMES_AS_IMAGES.location, + Config::GFX_FREE_LOOK.location, Config::GFX_USE_FFV1.location, + Config::GFX_DUMP_FORMAT.location, Config::GFX_DUMP_CODEC.location, + Config::GFX_DUMP_PATH.location, Config::GFX_BITRATE_KBPS.location, + Config::GFX_INTERNAL_RESOLUTION_FRAME_DUMPS.location, Config::GFX_ENABLE_GPU_TEXTURE_DECODING.location, Config::GFX_ENABLE_PIXEL_LIGHTING.location, Config::GFX_FAST_DEPTH_CALC.location, Config::GFX_MSAA.location, Config::GFX_SSAA.location, Config::GFX_EFB_SCALE.location, Config::GFX_TEXFMT_OVERLAY_ENABLE.location, @@ -73,8 +73,7 @@ bool IsSettingSaveable(const Config::ConfigLocation& config_location) Config::GFX_HACK_EFB_ACCESS_ENABLE.location, Config::GFX_HACK_BBOX_ENABLE.location, Config::GFX_HACK_BBOX_PREFER_STENCIL_IMPLEMENTATION.location, Config::GFX_HACK_FORCE_PROGRESSIVE.location, Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM.location, - Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM.location, - Config::GFX_HACK_IMMEDIATE_XFB.location, + Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM.location, Config::GFX_HACK_IMMEDIATE_XFB.location, Config::GFX_HACK_COPY_EFB_ENABLED.location, Config::GFX_HACK_EFB_EMULATE_FORMAT_CHANGES.location, Config::GFX_HACK_VERTEX_ROUDING.location, diff --git a/Source/Core/Core/ConfigLoaders/MovieConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/MovieConfigLoader.cpp index 046bcf6631..3585df4cc3 100644 --- a/Source/Core/Core/ConfigLoaders/MovieConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/MovieConfigLoader.cpp @@ -39,7 +39,6 @@ static void LoadFromDTM(Config::Layer* config_layer, Movie::DTMHeader* dtm) else config_layer->Set(Config::MAIN_GC_LANGUAGE, static_cast(dtm->language)); - config_layer->Set(Config::GFX_HACK_EFB_ACCESS_ENABLE, dtm->bEFBAccessEnable); config_layer->Set(Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM, dtm->bSkipEFBCopyToRam); config_layer->Set(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM, dtm->bSkipXFBCopyToRam); diff --git a/Source/Core/Core/HW/VideoInterface.cpp b/Source/Core/Core/HW/VideoInterface.cpp index c8ec4a3d0b..46575ed2de 100644 --- a/Source/Core/Core/HW/VideoInterface.cpp +++ b/Source/Core/Core/HW/VideoInterface.cpp @@ -799,9 +799,9 @@ void FakeVIUpdate(u32 xfb_address, u32 fb_width, u32 fb_height) m_VBlankTimingEven.PSB = 4; m_PictureConfiguration.WPL = fb_width / 16; m_PictureConfiguration.STD = fb_stride / 16; - + UpdateParameters(); - + u32 total_halflines = GetHalfLinesPerEvenField() + GetHalfLinesPerOddField(); if ((s_half_line_count - s_even_field_first_hl) % total_halflines < diff --git a/Source/Core/DolphinQt2/Config/Graphics/HacksWidget.cpp b/Source/Core/DolphinQt2/Config/Graphics/HacksWidget.cpp index ec2e4809c5..ad30644749 100644 --- a/Source/Core/DolphinQt2/Config/Graphics/HacksWidget.cpp +++ b/Source/Core/DolphinQt2/Config/Graphics/HacksWidget.cpp @@ -69,8 +69,7 @@ void HacksWidget::CreateWidgets() m_store_xfb_copies = new GraphicsBool(tr("Store XFB Copies to Texture Only"), Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM); - m_immediate_xfb = new GraphicsBool(tr("Immediately Present XFB"), - Config::GFX_HACK_IMMEDIATE_XFB); + m_immediate_xfb = new GraphicsBool(tr("Immediately Present XFB"), Config::GFX_HACK_IMMEDIATE_XFB); xfb_layout->addWidget(m_store_xfb_copies, 1, 0); @@ -171,15 +170,18 @@ void HacksWidget::AddDescriptions() "from RAM.\nLower accuracies cause in-game text to appear garbled in certain " "games.\n\nIf unsure, use the rightmost value."); - static const char* TR_STORE_XFB_TO_TEXTURE_DESCRIPTION = QT_TR_NOOP( + static const char* TR_STORE_XFB_TO_TEXTURE_DESCRIPTION = QT_TR_NOOP( "Stores XFB Copies exclusively on the GPU, bypassing system memory. Causes graphical defects " - "in a small number of games that need to readback from memory.\n\nEnabled = XFB Copies to Texture\nDisabled = XFB Copies to RAM " + "in a small number of games that need to readback from memory.\n\nEnabled = XFB Copies to " + "Texture\nDisabled = XFB Copies to RAM " "(and Texture)\n\nIf unsure, leave this checked."); - static const char* TR_IMMEDIATE_XFB_DESCRIPTION = QT_TR_NOOP( - "Displays the XFB copies as soon as they are created, without waiting for scanout. Can cause graphical defects " - "in some games if the game doesn't expect all XFB copies to be displayed. However, turning this setting on reduces latency." - "\n\nIf unsure, leave this unchecked."); + static const char* TR_IMMEDIATE_XFB_DESCRIPTION = + QT_TR_NOOP("Displays the XFB copies as soon as they are created, without waiting for " + "scanout. Can cause graphical defects " + "in some games if the game doesn't expect all XFB copies to be displayed. " + "However, turning this setting on reduces latency." + "\n\nIf unsure, leave this unchecked."); static const char* TR_GPU_DECODING_DESCRIPTION = QT_TR_NOOP("Enables texture decoding using the GPU instead of the CPU. This may result in " diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 97c0f38ec9..1f89306a13 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -1496,7 +1496,7 @@ void CFrame::ParseHotkeys() OSDChoice = 6; // Toggle immediate present of xfb Config::SetCurrent(Config::GFX_HACK_IMMEDIATE_XFB, - !Config::Get(Config::GFX_HACK_IMMEDIATE_XFB)); + !Config::Get(Config::GFX_HACK_IMMEDIATE_XFB)); } if (IsHotkey(HK_TOGGLE_FOG)) { diff --git a/Source/Core/DolphinWX/VideoConfigDiag.cpp b/Source/Core/DolphinWX/VideoConfigDiag.cpp index 07dcfb9cd2..7a760422a2 100644 --- a/Source/Core/DolphinWX/VideoConfigDiag.cpp +++ b/Source/Core/DolphinWX/VideoConfigDiag.cpp @@ -202,13 +202,16 @@ static wxString skip_efb_copy_to_ram_desc = wxTRANSLATE( "in a small number of games.\n\nEnabled = EFB Copies to Texture\nDisabled = EFB Copies to RAM " "(and Texture)\n\nIf unsure, leave this checked."); static wxString skip_xfb_copy_to_ram_desc = wxTRANSLATE( - "Stores XFB Copies exclusively on the GPU, bypassing system memory. Causes graphical defects " - "in a small number of games that need to readback from memory.\n\nEnabled = XFB Copies to Texture\nDisabled = XFB Copies to RAM " - "(and Texture)\n\nIf unsure, leave this checked."); -static wxString immediate_xfb_desc = wxTRANSLATE( - "Displays the XFB copies as soon as they are created, without waiting for scanout. Can cause graphical defects " - "in some games if the game doesn't expect all XFB copies to be displayed. However, turning this setting on reduces latency." - "\n\nIf unsure, leave this unchecked."); + "Stores XFB Copies exclusively on the GPU, bypassing system memory. Causes graphical defects " + "in a small number of games that need to readback from memory.\n\nEnabled = XFB Copies to " + "Texture\nDisabled = XFB Copies to RAM " + "(and Texture)\n\nIf unsure, leave this checked."); +static wxString immediate_xfb_desc = + wxTRANSLATE("Displays the XFB copies as soon as they are created, without waiting for scanout. " + "Can cause graphical defects " + "in some games if the game doesn't expect all XFB copies to be displayed. However, " + "turning this setting on reduces latency." + "\n\nIf unsure, leave this unchecked."); static wxString stc_desc = wxTRANSLATE("The \"Safe\" setting eliminates the likelihood of the GPU missing texture updates " "from RAM.\nLower accuracies cause in-game text to appear garbled in certain " @@ -248,7 +251,7 @@ static wxString cache_hires_textures_desc = static wxString dump_efb_desc = wxTRANSLATE( "Dump the contents of EFB copies to User/Dump/Textures/.\n\nIf unsure, leave this unchecked."); static wxString dump_xfb_desc = wxTRANSLATE( - "Dump the contents of XFB copies to User/Dump/Textures/.\n\nIf unsure, leave this unchecked."); + "Dump the contents of XFB copies to User/Dump/Textures/.\n\nIf unsure, leave this unchecked."); static wxString internal_resolution_frame_dumping_desc = wxTRANSLATE( "Create frame dumps and screenshots at the internal resolution of the renderer, rather than " "the size of the window it is displayed within. If the aspect ratio is widescreen, the output " @@ -779,21 +782,21 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string& title) szr_hacks->Add(szr_safetex, 0, wxEXPAND | wxLEFT | wxRIGHT, space5); } - // - XFB + // - XFB { wxStaticBoxSizer* const group_xfb = new wxStaticBoxSizer(wxVERTICAL, page_hacks, _("External Frame Buffer (XFB)")); group_xfb->Add(CreateCheckBox(page_hacks, _("Store XFB Copies to Texture Only"), - wxGetTranslation(skip_xfb_copy_to_ram_desc), - Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM), - 0, wxLEFT | wxRIGHT, space5); + wxGetTranslation(skip_xfb_copy_to_ram_desc), + Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM), + 0, wxLEFT | wxRIGHT, space5); group_xfb->AddSpacer(space5); group_xfb->Add(CreateCheckBox(page_hacks, _("Immediately Present XFB"), - wxGetTranslation(immediate_xfb_desc), - Config::GFX_HACK_IMMEDIATE_XFB), - 0, wxLEFT | wxRIGHT, space5); + wxGetTranslation(immediate_xfb_desc), + Config::GFX_HACK_IMMEDIATE_XFB), + 0, wxLEFT | wxRIGHT, space5); group_xfb->AddSpacer(space5); szr_hacks->AddSpacer(space5); @@ -885,8 +888,9 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string& title) szr_utility->Add(CreateCheckBox(page_advanced, _("Dump EFB Target"), wxGetTranslation(dump_efb_desc), Config::GFX_DUMP_EFB_TARGET)); - szr_utility->Add(CreateCheckBox(page_advanced, _("Dump XFB Target"), - wxGetTranslation(dump_xfb_desc), Config::GFX_DUMP_XFB_TARGET)); + szr_utility->Add(CreateCheckBox(page_advanced, _("Dump XFB Target"), + wxGetTranslation(dump_xfb_desc), + Config::GFX_DUMP_XFB_TARGET)); szr_utility->Add(CreateCheckBox(page_advanced, _("Free Look"), wxGetTranslation(free_look_desc), Config::GFX_FREE_LOOK)); #if defined(HAVE_FFMPEG) diff --git a/Source/Core/VideoBackends/D3D/DXTexture.cpp b/Source/Core/VideoBackends/D3D/DXTexture.cpp index e4bc024568..5f7a4e39eb 100644 --- a/Source/Core/VideoBackends/D3D/DXTexture.cpp +++ b/Source/Core/VideoBackends/D3D/DXTexture.cpp @@ -157,7 +157,7 @@ void DXTexture::Unmap() { if (!m_staging_texture) return; - + D3D::context->Unmap(m_staging_texture, 0); } diff --git a/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp b/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp index 2aafb299bf..4fcce4ef03 100644 --- a/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp +++ b/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp @@ -46,8 +46,8 @@ void PSTextureEncoder::Init() // TODO: This Texture is overly large and parts of it are unused // EFB2RAM copies use max (EFB_WIDTH * 4) by (EFB_HEIGHT / 4) // XFB2RAM copies use max (EFB_WIDTH / 2) by (EFB_HEIGHT) - D3D11_TEXTURE2D_DESC t2dd = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_B8G8R8A8_UNORM, EFB_WIDTH * 4, - 1024, 1, 1, D3D11_BIND_RENDER_TARGET); + D3D11_TEXTURE2D_DESC t2dd = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_B8G8R8A8_UNORM, EFB_WIDTH * 4, 1024, + 1, 1, D3D11_BIND_RENDER_TARGET); hr = D3D::device->CreateTexture2D(&t2dd, nullptr, &m_out); CHECK(SUCCEEDED(hr), "create efb encode output texture"); D3D::SetDebugObjectName(m_out, "efb encoder output texture"); diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index 18aec69490..82e5772b15 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -39,8 +39,8 @@ #include "VideoCommon/RenderState.h" #include "VideoCommon/SamplerCommon.h" #include "VideoCommon/VideoBackendBase.h" -#include "VideoCommon/VideoConfig.h" #include "VideoCommon/VideoCommon.h" +#include "VideoCommon/VideoConfig.h" #include "VideoCommon/XFMemory.h" namespace DX11 @@ -626,8 +626,8 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& rc, u64 ti auto* xfb_texture = static_cast(texture); TargetRectangle source_rc = xfb_texture->GetConfig().GetRect(); - BlitScreen(source_rc, targetRc, xfb_texture->GetRawTexIdentifier(), xfb_texture->GetConfig().width, - xfb_texture->GetConfig().height, Gamma); + BlitScreen(source_rc, targetRc, xfb_texture->GetRawTexIdentifier(), + xfb_texture->GetConfig().width, xfb_texture->GetConfig().height, Gamma); // Reset viewport for drawing text D3D11_VIEWPORT vp = diff --git a/Source/Core/VideoBackends/OGL/PostProcessing.cpp b/Source/Core/VideoBackends/OGL/PostProcessing.cpp index 08e0d36c6e..bf34e2a54c 100644 --- a/Source/Core/VideoBackends/OGL/PostProcessing.cpp +++ b/Source/Core/VideoBackends/OGL/PostProcessing.cpp @@ -25,7 +25,7 @@ static const char s_vertex_shader[] = "out vec2 uv0;\n" "void main(void) {\n" " vec2 rawpos = vec2(gl_VertexID&1, gl_VertexID&2);\n" " gl_Position = vec4(rawpos*2.0-1.0, 0.0, 1.0);\n" - " uv0 = vec2(mix(src_rect.xy, src_rect.zw, rawpos));\n" + " uv0 = vec2(mix(src_rect.xy, src_rect.zw, rawpos));\n" "}\n"; OpenGLPostProcessing::OpenGLPostProcessing() : m_initialized(false) diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index 655b69cb4e..05aaef66c4 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -1353,7 +1353,8 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& rc, u64 ti // Copy the framebuffer to screen. glBindFramebuffer(GL_FRAMEBUFFER, 0); - BlitScreen(sourceRc, flipped_trc, xfb_texture->GetRawTexIdentifier(), xfb_texture->GetConfig().width, xfb_texture->GetConfig().height); + BlitScreen(sourceRc, flipped_trc, xfb_texture->GetRawTexIdentifier(), + xfb_texture->GetConfig().width, xfb_texture->GetConfig().height); // Finish up the current frame, print some stats diff --git a/Source/Core/VideoBackends/OGL/Render.h b/Source/Core/VideoBackends/OGL/Render.h index 78d680fbd2..725cc7a639 100644 --- a/Source/Core/VideoBackends/OGL/Render.h +++ b/Source/Core/VideoBackends/OGL/Render.h @@ -111,7 +111,8 @@ private: void UpdateEFBCache(EFBAccessType type, u32 cacheRectIdx, const EFBRectangle& efbPixelRc, const TargetRectangle& targetPixelRc, const void* data); - void DrawEFB(GLuint framebuffer, const TargetRectangle& target_rc, const TargetRectangle& source_rc); + void DrawEFB(GLuint framebuffer, const TargetRectangle& target_rc, + const TargetRectangle& source_rc); void BlitScreen(TargetRectangle src, TargetRectangle dst, GLuint src_texture, int src_width, int src_height); diff --git a/Source/Core/VideoBackends/OGL/TextureCache.cpp b/Source/Core/VideoBackends/OGL/TextureCache.cpp index 997b53f74b..aa2c60976b 100644 --- a/Source/Core/VideoBackends/OGL/TextureCache.cpp +++ b/Source/Core/VideoBackends/OGL/TextureCache.cpp @@ -388,10 +388,10 @@ void main() void TextureCache::CreateTextureDecodingResources() { static const GLenum gl_view_types[TextureConversionShader::BUFFER_FORMAT_COUNT] = { - GL_R8UI, // BUFFER_FORMAT_R8_UINT - GL_R16UI, // BUFFER_FORMAT_R16_UINT - GL_RG32UI, // BUFFER_FORMAT_R32G32_UINT - GL_RGBA8UI, // BUFFER_FORMAT_RGBA8_UINT + GL_R8UI, // BUFFER_FORMAT_R8_UINT + GL_R16UI, // BUFFER_FORMAT_R16_UINT + GL_RG32UI, // BUFFER_FORMAT_R32G32_UINT + GL_RGBA8UI, // BUFFER_FORMAT_RGBA8_UINT }; glGenTextures(TextureConversionShader::BUFFER_FORMAT_COUNT, diff --git a/Source/Core/VideoBackends/Software/CopyRegion.h b/Source/Core/VideoBackends/Software/CopyRegion.h index 5f3c1bac83..987ec77951 100644 --- a/Source/Core/VideoBackends/Software/CopyRegion.h +++ b/Source/Core/VideoBackends/Software/CopyRegion.h @@ -22,9 +22,9 @@ void copy_region(const T* const source, const MathUtil::Rectangle& srcrect, int destination_y = i + dstrect.top; int destination_offset = (destination_y * dstrect.GetWidth()) + destination_x; - double src_x = std::round(destination_x*x_ratio) + srcrect.left; - double src_y = std::round(destination_y*y_ratio) + srcrect.top; - int src_offset = static_cast((src_y*srcrect.GetWidth()) + src_x); + double src_x = std::round(destination_x * x_ratio) + srcrect.left; + double src_y = std::round(destination_y * y_ratio) + srcrect.top; + int src_offset = static_cast((src_y * srcrect.GetWidth()) + src_x); destination[destination_offset] = source[src_offset]; } diff --git a/Source/Core/VideoBackends/Software/EfbCopy.cpp b/Source/Core/VideoBackends/Software/EfbCopy.cpp index 7a69bb4881..bba64ee7c1 100644 --- a/Source/Core/VideoBackends/Software/EfbCopy.cpp +++ b/Source/Core/VideoBackends/Software/EfbCopy.cpp @@ -14,7 +14,6 @@ namespace EfbCopy { - void ClearEfb() { u32 clearColor = (bpmem.clearcolorAR & 0xff) << 24 | bpmem.clearcolorGB << 8 | @@ -34,5 +33,4 @@ void ClearEfb() } } } - } diff --git a/Source/Core/VideoBackends/Software/EfbInterface.cpp b/Source/Core/VideoBackends/Software/EfbInterface.cpp index 2ca20b3997..e667a7e584 100644 --- a/Source/Core/VideoBackends/Software/EfbInterface.cpp +++ b/Source/Core/VideoBackends/Software/EfbInterface.cpp @@ -497,7 +497,8 @@ u8* GetPixelPointer(u16 x, u16 y, bool depth) return &efb[GetColorOffset(x, y)]; } -void EncodeXFB(yuv422_packed* xfb_in_ram, u32 memory_stride, const EFBRectangle& source_rect, float y_scale) +void EncodeXFB(yuv422_packed* xfb_in_ram, u32 memory_stride, const EFBRectangle& source_rect, + float y_scale) { if (!xfb_in_ram) { @@ -543,8 +544,7 @@ void EncodeXFB(yuv422_packed* xfb_in_ram, u32 memory_stride, const EFBRectangle& src_ptr[x].Y = scanline[i].Y + 16; // we mix our color differences in 10 bit space so it will round more accurately // U[i] = 1/4 * U[i-1] + 1/2 * U[i] + 1/4 * U[i+1] - src_ptr[x].UV = - 128 + ((scanline[i - 1].U + (scanline[i].U << 1) + scanline[i + 1].U) >> 2); + src_ptr[x].UV = 128 + ((scanline[i - 1].U + (scanline[i].U << 1) + scanline[i + 1].U) >> 2); // YV pixel src_ptr[x + 1].Y = scanline[i + 1].Y + 16; @@ -556,7 +556,9 @@ void EncodeXFB(yuv422_packed* xfb_in_ram, u32 memory_stride, const EFBRectangle& } // Apply y scaling and copy to the xfb memory location - SW::copy_region(source.data(), source_rect, xfb_in_ram, EFBRectangle{ source_rect.left, source_rect.top, source_rect.right, static_cast(static_cast(source_rect.bottom) * y_scale) }); + SW::copy_region(source.data(), source_rect, xfb_in_ram, + EFBRectangle{source_rect.left, source_rect.top, source_rect.right, + static_cast(static_cast(source_rect.bottom) * y_scale)}); } bool ZCompare(u16 x, u16 y, u32 z) diff --git a/Source/Core/VideoBackends/Software/EfbInterface.h b/Source/Core/VideoBackends/Software/EfbInterface.h index c13b21ac4a..24baf37689 100644 --- a/Source/Core/VideoBackends/Software/EfbInterface.h +++ b/Source/Core/VideoBackends/Software/EfbInterface.h @@ -57,7 +57,8 @@ u32 GetDepth(u16 x, u16 y); u8* GetPixelPointer(u16 x, u16 y, bool depth); -void EncodeXFB(yuv422_packed* xfb_in_ram, u32 memory_stride, const EFBRectangle& source_rect, float y_scale); +void EncodeXFB(yuv422_packed* xfb_in_ram, u32 memory_stride, const EFBRectangle& source_rect, + float y_scale); extern u32 perf_values[PQ_NUM_MEMBERS]; inline void IncPerfCounterQuadCount(PerfQueryType type) diff --git a/Source/Core/VideoBackends/Software/SWOGLWindow.cpp b/Source/Core/VideoBackends/Software/SWOGLWindow.cpp index 372f15322e..bead74872d 100644 --- a/Source/Core/VideoBackends/Software/SWOGLWindow.cpp +++ b/Source/Core/VideoBackends/Software/SWOGLWindow.cpp @@ -92,7 +92,7 @@ void SWOGLWindow::PrintText(const std::string& text, int x, int y, u32 color) void SWOGLWindow::ShowImage(AbstractTexture* image, float aspect) { - SW::SWTexture * sw_image = static_cast(image); + SW::SWTexture* sw_image = static_cast(image); GLInterface->Update(); // just updates the render window position and the backbuffer size GLsizei glWidth = (GLsizei)GLInterface->GetBackBufferWidth(); diff --git a/Source/Core/VideoBackends/Software/SWOGLWindow.h b/Source/Core/VideoBackends/Software/SWOGLWindow.h index 63f0bd82b7..68fbcc133e 100644 --- a/Source/Core/VideoBackends/Software/SWOGLWindow.h +++ b/Source/Core/VideoBackends/Software/SWOGLWindow.h @@ -31,7 +31,6 @@ public: private: SWOGLWindow() {} - struct TextData { std::string text; diff --git a/Source/Core/VideoBackends/Software/SWTexture.cpp b/Source/Core/VideoBackends/Software/SWTexture.cpp index e2752fe0c7..b42f3d4e21 100644 --- a/Source/Core/VideoBackends/Software/SWTexture.cpp +++ b/Source/Core/VideoBackends/Software/SWTexture.cpp @@ -10,7 +10,6 @@ namespace SW { - SWTexture::SWTexture(const TextureConfig& tex_config) : AbstractTexture(tex_config) { } @@ -23,11 +22,12 @@ void SWTexture::CopyRectangleFromTexture(const AbstractTexture* source, const MathUtil::Rectangle& srcrect, const MathUtil::Rectangle& dstrect) { - const SWTexture * software_source_texture = static_cast(source); + const SWTexture* software_source_texture = static_cast(source); if (srcrect.GetWidth() == dstrect.GetWidth() && srcrect.GetHeight() == dstrect.GetHeight()) { - m_data.assign(software_source_texture->GetData(), software_source_texture->GetData() + m_data.size()); + m_data.assign(software_source_texture->GetData(), + software_source_texture->GetData() + m_data.size()); } else { @@ -53,8 +53,8 @@ u8* SWTexture::GetData() std::optional SWTexture::MapFullImpl() { - return AbstractTexture::RawTextureInfo{ GetData(), - m_config.width * 4, m_config.width, m_config.height }; + return AbstractTexture::RawTextureInfo{GetData(), m_config.width * 4, m_config.width, + m_config.height}; } } // namespace SW diff --git a/Source/Core/VideoBackends/Software/SWTexture.h b/Source/Core/VideoBackends/Software/SWTexture.h index 7f130b39e9..fa7fea5308 100644 --- a/Source/Core/VideoBackends/Software/SWTexture.h +++ b/Source/Core/VideoBackends/Software/SWTexture.h @@ -30,7 +30,6 @@ public: u8* GetData(); private: - std::optional MapFullImpl() override; std::vector m_data; diff --git a/Source/Core/VideoBackends/Software/TextureCache.h b/Source/Core/VideoBackends/Software/TextureCache.h index ec46101b70..3573d36ebb 100644 --- a/Source/Core/VideoBackends/Software/TextureCache.h +++ b/Source/Core/VideoBackends/Software/TextureCache.h @@ -7,23 +7,21 @@ namespace SW { - class TextureCache : public TextureCacheBase { public: bool CompileShaders() override { return true; } void DeleteShaders() override {} void ConvertTexture(TCacheEntry* entry, TCacheEntry* unconverted, const void* palette, - TLUTFormat format) override + TLUTFormat format) override { } void CopyEFB(u8* dst, const EFBCopyParams& params, u32 native_width, u32 bytes_per_row, u32 num_blocks_y, u32 memory_stride, const EFBRectangle& src_rect, bool scale_by_half) override { - TextureEncoder::Encode(dst, params, native_width, bytes_per_row, - num_blocks_y, memory_stride, src_rect, - scale_by_half); + TextureEncoder::Encode(dst, params, native_width, bytes_per_row, num_blocks_y, memory_stride, + src_rect, scale_by_half); } private: @@ -31,7 +29,7 @@ private: { return std::make_unique(config); } - + void CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy, const EFBRectangle& src_rect, bool scale_by_half, unsigned int cbuf_id, const float* colmat) override { @@ -39,4 +37,4 @@ private: } }; -} // namespace SW +} // namespace SW diff --git a/Source/Core/VideoBackends/Software/TextureEncoder.cpp b/Source/Core/VideoBackends/Software/TextureEncoder.cpp index bceb567524..52a709d04e 100644 --- a/Source/Core/VideoBackends/Software/TextureEncoder.cpp +++ b/Source/Core/VideoBackends/Software/TextureEncoder.cpp @@ -1419,63 +1419,63 @@ static void EncodeZ24halfscale(u8* dst, const u8* src, EFBCopyFormat format) namespace { - void EncodeEfbCopy(u8* dst, const EFBCopyParams& params, u32 native_width, u32 bytes_per_row, - u32 num_blocks_y, u32 memory_stride, const EFBRectangle& src_rect, - bool scale_by_half) - { - const u8* src = - EfbInterface::GetPixelPointer(src_rect.left, src_rect.top, params.depth); - - if (scale_by_half) - { - switch (params.efb_format) - { - case PEControl::RGBA6_Z24: - EncodeRGBA6halfscale(dst, src, params.copy_format, params.yuv); - break; - case PEControl::RGB8_Z24: - EncodeRGB8halfscale(dst, src, params.copy_format, params.yuv); - break; - case PEControl::RGB565_Z16: - EncodeRGB8halfscale(dst, src, params.copy_format, params.yuv); - break; - case PEControl::Z24: - EncodeZ24halfscale(dst, src, params.copy_format); - break; - } - } - else - { - switch (params.efb_format) - { - case PEControl::RGBA6_Z24: - EncodeRGBA6(dst, src, params.copy_format, params.yuv); - break; - case PEControl::RGB8_Z24: - EncodeRGB8(dst, src, params.copy_format, params.yuv); - break; - case PEControl::RGB565_Z16: - EncodeRGB8(dst, src, params.copy_format, params.yuv); - break; - case PEControl::Z24: - EncodeZ24(dst, src, params.copy_format); - break; - } - } - } -} - -void Encode(u8* dst, const EFBCopyParams& params, u32 native_width, u32 bytes_per_row, - u32 num_blocks_y, u32 memory_stride, const EFBRectangle& src_rect, - bool scale_by_half) +void EncodeEfbCopy(u8* dst, const EFBCopyParams& params, u32 native_width, u32 bytes_per_row, + u32 num_blocks_y, u32 memory_stride, const EFBRectangle& src_rect, + bool scale_by_half) { - if (params.copy_format == EFBCopyFormat::XFB) + const u8* src = EfbInterface::GetPixelPointer(src_rect.left, src_rect.top, params.depth); + + if (scale_by_half) { - EfbInterface::EncodeXFB(reinterpret_cast(dst), native_width, src_rect, params.y_scale); + switch (params.efb_format) + { + case PEControl::RGBA6_Z24: + EncodeRGBA6halfscale(dst, src, params.copy_format, params.yuv); + break; + case PEControl::RGB8_Z24: + EncodeRGB8halfscale(dst, src, params.copy_format, params.yuv); + break; + case PEControl::RGB565_Z16: + EncodeRGB8halfscale(dst, src, params.copy_format, params.yuv); + break; + case PEControl::Z24: + EncodeZ24halfscale(dst, src, params.copy_format); + break; + } } else { - EncodeEfbCopy(dst, params, native_width, bytes_per_row, num_blocks_y, memory_stride, src_rect, scale_by_half); + switch (params.efb_format) + { + case PEControl::RGBA6_Z24: + EncodeRGBA6(dst, src, params.copy_format, params.yuv); + break; + case PEControl::RGB8_Z24: + EncodeRGB8(dst, src, params.copy_format, params.yuv); + break; + case PEControl::RGB565_Z16: + EncodeRGB8(dst, src, params.copy_format, params.yuv); + break; + case PEControl::Z24: + EncodeZ24(dst, src, params.copy_format); + break; + } + } +} +} + +void Encode(u8* dst, const EFBCopyParams& params, u32 native_width, u32 bytes_per_row, + u32 num_blocks_y, u32 memory_stride, const EFBRectangle& src_rect, bool scale_by_half) +{ + if (params.copy_format == EFBCopyFormat::XFB) + { + EfbInterface::EncodeXFB(reinterpret_cast(dst), native_width, + src_rect, params.y_scale); + } + else + { + EncodeEfbCopy(dst, params, native_width, bytes_per_row, num_blocks_y, memory_stride, src_rect, + scale_by_half); } } } diff --git a/Source/Core/VideoBackends/Software/TextureEncoder.h b/Source/Core/VideoBackends/Software/TextureEncoder.h index ca816b92bd..ec21c97c42 100644 --- a/Source/Core/VideoBackends/Software/TextureEncoder.h +++ b/Source/Core/VideoBackends/Software/TextureEncoder.h @@ -12,6 +12,5 @@ struct EFBCopyParams; namespace TextureEncoder { void Encode(u8* dst, const EFBCopyParams& params, u32 native_width, u32 bytes_per_row, - u32 num_blocks_y, u32 memory_stride, const EFBRectangle& src_rect, - bool scale_by_half); + u32 num_blocks_y, u32 memory_stride, const EFBRectangle& src_rect, bool scale_by_half); } diff --git a/Source/Core/VideoBackends/Vulkan/TextureConverter.cpp b/Source/Core/VideoBackends/Vulkan/TextureConverter.cpp index b646a59fa8..b8ac91d06b 100644 --- a/Source/Core/VideoBackends/Vulkan/TextureConverter.cpp +++ b/Source/Core/VideoBackends/Vulkan/TextureConverter.cpp @@ -33,14 +33,14 @@ namespace Vulkan { - namespace - { - struct EFBEncodeParams - { - std::array position_uniform; - float y_scale; - }; - } +namespace +{ +struct EFBEncodeParams +{ + std::array position_uniform; + float y_scale; +}; +} TextureConverter::TextureConverter() { } @@ -265,8 +265,8 @@ void TextureConverter::EncodeTextureToMemory(VkImageView src_texture, u8* dest_p // We also linear filtering for both box filtering and downsampling higher resolutions to 1x // TODO: This only produces perfect downsampling for 2x IR, other resolutions will need more // complex down filtering to average all pixels and produce the correct result. - bool linear_filter = (scale_by_half && !params.depth) || g_renderer->GetEFBScale() != 1 || - params.y_scale > 1.0f; + bool linear_filter = + (scale_by_half && !params.depth) || g_renderer->GetEFBScale() != 1 || params.y_scale > 1.0f; draw.SetPSSampler(0, src_texture, linear_filter ? g_object_cache->GetLinearSampler() : g_object_cache->GetPointSampler()); @@ -580,7 +580,7 @@ bool TextureConverter::CreateTexelBuffer() m_texel_buffer_view_r16_uint = CreateTexelBufferView(VK_FORMAT_R16_UINT); m_texel_buffer_view_r32g32_uint = CreateTexelBufferView(VK_FORMAT_R32G32_UINT); m_texel_buffer_view_rgba8_unorm = CreateTexelBufferView(VK_FORMAT_R8G8B8A8_UNORM); - m_texel_buffer_view_rgba8_uint= CreateTexelBufferView(VK_FORMAT_R8G8B8A8_UINT); + m_texel_buffer_view_rgba8_uint = CreateTexelBufferView(VK_FORMAT_R8G8B8A8_UINT); return m_texel_buffer_view_r8_uint != VK_NULL_HANDLE && m_texel_buffer_view_r16_uint != VK_NULL_HANDLE && m_texel_buffer_view_r32g32_uint != VK_NULL_HANDLE && diff --git a/Source/Core/VideoBackends/Vulkan/VKTexture.cpp b/Source/Core/VideoBackends/Vulkan/VKTexture.cpp index c06778be52..cbb6e0c063 100644 --- a/Source/Core/VideoBackends/Vulkan/VKTexture.cpp +++ b/Source/Core/VideoBackends/Vulkan/VKTexture.cpp @@ -133,8 +133,8 @@ std::optional VKTexture::MapRegionImpl(u32 leve // Copy to download buffer. m_staging_texture->CopyFromImage(g_command_buffer_mgr->GetCurrentCommandBuffer(), - m_texture->GetImage(), VK_IMAGE_ASPECT_COLOR_BIT, x, y, width, - height, level, 0); + m_texture->GetImage(), VK_IMAGE_ASPECT_COLOR_BIT, x, y, width, + height, level, 0); // Restore original state of texture. m_texture->TransitionToLayout(g_command_buffer_mgr->GetCurrentCommandBuffer(), diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp index bdba7468a8..93de3aabe5 100644 --- a/Source/Core/VideoCommon/BPStructs.cpp +++ b/Source/Core/VideoCommon/BPStructs.cpp @@ -261,8 +261,8 @@ static void BPWritten(const BPCmd& bp) bool is_depth_copy = bpmem.zcontrol.pixel_format == PEControl::Z24; g_texture_cache->CopyRenderTargetToTexture(destAddr, EFBCopyFormat::XFB, destStride, - is_depth_copy, srcRect, false, - false, yScale, s_gammaLUT[PE_copy.gamma]); + is_depth_copy, srcRect, false, false, yScale, + s_gammaLUT[PE_copy.gamma]); // This stays in to signal end of a "frame" g_renderer->RenderToXFB(destAddr, srcRect, destStride, height, s_gammaLUT[PE_copy.gamma]); diff --git a/Source/Core/VideoCommon/FramebufferManagerBase.cpp b/Source/Core/VideoCommon/FramebufferManagerBase.cpp index 5e95cff805..1df2960b1a 100644 --- a/Source/Core/VideoCommon/FramebufferManagerBase.cpp +++ b/Source/Core/VideoCommon/FramebufferManagerBase.cpp @@ -17,4 +17,3 @@ std::unique_ptr g_framebuffer_manager; unsigned int FramebufferManagerBase::m_EFBLayers = 1; FramebufferManagerBase::~FramebufferManagerBase() = default; - diff --git a/Source/Core/VideoCommon/FramebufferManagerBase.h b/Source/Core/VideoCommon/FramebufferManagerBase.h index 2d725fa346..5e645dc7f7 100644 --- a/Source/Core/VideoCommon/FramebufferManagerBase.h +++ b/Source/Core/VideoCommon/FramebufferManagerBase.h @@ -23,9 +23,7 @@ public: virtual ~FramebufferManagerBase(); static unsigned int GetEFBLayers() { return m_EFBLayers; } - protected: - static unsigned int m_EFBLayers; }; diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index b87ec7ded5..ba909a22b3 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -42,8 +42,8 @@ #include "Core/Host.h" #include "Core/Movie.h" -#include "VideoCommon/AbstractTexture.h" #include "VideoCommon/AVIDump.h" +#include "VideoCommon/AbstractTexture.h" #include "VideoCommon/BPMemory.h" #include "VideoCommon/CPMemory.h" #include "VideoCommon/CommandProcessor.h" @@ -336,7 +336,8 @@ void Renderer::DrawDebugText() "Speed Limit: Unlimited" : StringFromFormat("Speed Limit: %li%%", std::lround(SConfig::GetInstance().m_EmulationSpeed * 100.f)), - std::string("Copy XFB: ") + xfbcopy_text + (g_ActiveConfig.bImmediateXFB ? " (Immediate)" : ""), + std::string("Copy XFB: ") + xfbcopy_text + + (g_ActiveConfig.bImmediateXFB ? " (Immediate)" : ""), }; enum @@ -691,7 +692,8 @@ bool Renderer::IsFrameDumping() void Renderer::UpdateFrameDumpTexture(float horizontal_scale) { int target_width, target_height; - std::tie(target_width, target_height) = CalculateOutputDimensions(m_last_xfb_texture->GetConfig().width, m_last_xfb_texture->GetConfig().height); + std::tie(target_width, target_height) = CalculateOutputDimensions( + m_last_xfb_texture->GetConfig().width, m_last_xfb_texture->GetConfig().height); if (m_dump_texture == nullptr || m_dump_texture->GetConfig().width != static_cast(target_width) || m_dump_texture->GetConfig().height != static_cast(target_height)) @@ -720,7 +722,7 @@ void Renderer::ShutdownFrameDumping() void Renderer::DumpFrameData(const u8* data, int w, int h, int stride, const AVIDump::Frame& state) { - m_frame_dump_config = FrameDumpConfig{ m_last_xfb_texture, data, w, h, stride, state }; + m_frame_dump_config = FrameDumpConfig{m_last_xfb_texture, data, w, h, stride, state}; if (!m_frame_dump_thread_running.IsSet()) { diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index 871939d7ab..ef2560825c 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -208,7 +208,7 @@ private: AVIDump::Frame state; } m_frame_dump_config; - AbstractTexture * m_last_xfb_texture; + AbstractTexture* m_last_xfb_texture; u64 m_last_xfb_id = 0; std::unique_ptr m_dump_texture; diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 3a86f4e94c..0c5574ac4a 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -376,16 +376,17 @@ TextureCacheBase::DoPartialTextureUpdates(TCacheEntry* entry_to_update, u8* pale u32 copy_width = std::min(entry->native_width - src_x, entry_to_update->native_width - dst_x); u32 copy_height = - std::min((entry->native_height * entry->y_scale) - src_y, (entry_to_update->native_height * entry_to_update->y_scale) - dst_y); + std::min((entry->native_height * entry->y_scale) - src_y, + (entry_to_update->native_height * entry_to_update->y_scale) - dst_y); // If one of the textures is scaled, scale both with the current efb scaling factor if (entry_to_update->native_width != entry_to_update->GetWidth() || entry_to_update->native_height != entry_to_update->GetHeight() || entry->native_width != entry->GetWidth() || entry->native_height != entry->GetHeight()) { - ScaleTextureCacheEntryTo(entry_to_update, - g_renderer->EFBToScaledX(entry_to_update->native_width), - g_renderer->EFBToScaledY(entry_to_update->native_height * entry_to_update->y_scale)); + ScaleTextureCacheEntryTo( + entry_to_update, g_renderer->EFBToScaledX(entry_to_update->native_width), + g_renderer->EFBToScaledY(entry_to_update->native_height * entry_to_update->y_scale)); ScaleTextureCacheEntryTo(entry, g_renderer->EFBToScaledX(entry->native_width), g_renderer->EFBToScaledY(entry->native_height * entry->y_scale)); @@ -632,18 +633,18 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::Load(const u32 stage) auto entry = GetTexture(address, width, height, texformat, g_ActiveConfig.iSafeTextureCache_ColorSamples, tlutaddr, tlutfmt, - use_mipmaps, tex_levels, from_tmem, tmem_address_even, - tmem_address_odd); + use_mipmaps, tex_levels, from_tmem, tmem_address_even, tmem_address_odd); if (!entry) return nullptr; - + entry->frameCount = FRAMECOUNT_INVALID; bound_textures[stage] = entry; GFX_DEBUGGER_PAUSE_AT(NEXT_TEXTURE_CHANGE, true); - // We need to keep track of invalided textures until they have actually been replaced or re-loaded + // We need to keep track of invalided textures until they have actually been replaced or + // re-loaded valid_bind_points.set(stage); return entry; @@ -728,8 +729,8 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::GetTexture(u32 address, u32 wid if (isPaletteTexture) { palette_size = TexDecoder_GetPaletteSize(texformat); - full_hash = base_hash ^ GetHash64(&texMem[tlutaddr], palette_size, - textureCacheSafetyColorSampleSize); + full_hash = + base_hash ^ GetHash64(&texMem[tlutaddr], palette_size, textureCacheSafetyColorSampleSize); } else { @@ -794,7 +795,8 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::GetTexture(u32 address, u32 wid // Do not load strided EFB copies, they are not meant to be used directly. // Also do not directly load EFB copies, which were partly overwritten. - if (entry->IsCopy() && entry->native_width == nativeW && static_cast(entry->native_height * entry->y_scale) == nativeH && + if (entry->IsCopy() && entry->native_width == nativeW && + static_cast(entry->native_height * entry->y_scale) == nativeH && entry->memory_stride == entry->BytesPerRow() && !entry->may_have_overlapping_textures) { // EFB copies have slightly different rules as EFB copy formats have different @@ -829,7 +831,7 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::GetTexture(u32 address, u32 wid else { // For normal textures, all texture parameters need to match - if (!entry->IsCopy() && entry->hash == full_hash && entry->format == full_format && + if (!entry->IsCopy() && entry->hash == full_hash && entry->format == full_format && entry->native_levels >= tex_levels && entry->native_width == nativeW && entry->native_height == nativeH) { @@ -871,8 +873,7 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::GetTexture(u32 address, u32 wid // Example: Tales of Symphonia (GC) uses over 500 small textures in menus, but only around 70 // different ones if (textureCacheSafetyColorSampleSize == 0 || - std::max(texture_size, palette_size) <= - (u32)textureCacheSafetyColorSampleSize * 8) + std::max(texture_size, palette_size) <= (u32)textureCacheSafetyColorSampleSize * 8) { auto hash_range = textures_by_hash.equal_range(full_hash); TexHashCache::iterator hash_iter = hash_range.first; @@ -961,9 +962,9 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::GetTexture(u32 address, u32 wid if (decode_on_gpu) { u32 row_stride = bytes_per_block * (expandedWidth / bsw); - g_texture_cache->DecodeTextureOnGPU( - entry, 0, src_data, texture_size, texformat, width, height, - expandedWidth, expandedHeight, row_stride, tlut, tlutfmt); + g_texture_cache->DecodeTextureOnGPU(entry, 0, src_data, texture_size, texformat, width, + height, expandedWidth, expandedHeight, row_stride, tlut, + tlutfmt); } else { @@ -989,13 +990,11 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::GetTexture(u32 address, u32 wid dst_buffer = temp; if (!(texformat == TextureFormat::RGBA8 && from_tmem)) { - TexDecoder_Decode(dst_buffer, src_data, expandedWidth, expandedHeight, texformat, tlut, - tlutfmt); + TexDecoder_Decode(dst_buffer, src_data, expandedWidth, expandedHeight, texformat, tlut, tlutfmt); } else { - u8* src_data_gb = - &texMem[tmem_address_odd]; + u8* src_data_gb = &texMem[tmem_address_odd]; TexDecoder_DecodeRGBA8FromTmem(dst_buffer, src_data, src_data_gb, expandedWidth, expandedHeight); } @@ -1009,8 +1008,7 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::GetTexture(u32 address, u32 wid iter = textures_by_address.emplace(address, entry); if (textureCacheSafetyColorSampleSize == 0 || - std::max(texture_size, palette_size) <= - (u32)textureCacheSafetyColorSampleSize * 8) + std::max(texture_size, palette_size) <= (u32)textureCacheSafetyColorSampleSize * 8) { entry->textures_by_hash_iter = textures_by_hash.emplace(full_hash, entry); } @@ -1180,8 +1178,9 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, EFBCopyFormat dstF unsigned int cbufid = UINT_MAX; PEControl::PixelFormat srcFormat = bpmem.zcontrol.pixel_format; bool efbHasAlpha = srcFormat == PEControl::RGBA6_Z24; - - bool copy_to_ram = !g_ActiveConfig.bSkipEFBCopyToRam || g_ActiveConfig.backend_info.bForceCopyToRam; + + bool copy_to_ram = + !g_ActiveConfig.bSkipEFBCopyToRam || g_ActiveConfig.backend_info.bForceCopyToRam; bool copy_to_vram = g_ActiveConfig.backend_info.bSupportsCopyToVram; bool is_xfb_copy = false; @@ -1418,7 +1417,8 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, EFBCopyFormat dstF ColorMask[3] = 0.0f; fConstAdd[3] = 1.0f; cbufid = 30; // just re-use the RGBX8 cbufid from above - copy_to_ram = !g_ActiveConfig.bSkipXFBCopyToRam || g_ActiveConfig.backend_info.bForceCopyToRam; + copy_to_ram = + !g_ActiveConfig.bSkipXFBCopyToRam || g_ActiveConfig.backend_info.bForceCopyToRam; is_xfb_copy = true; break; @@ -1587,7 +1587,7 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, EFBCopyFormat dstF 0); } - if (g_ActiveConfig.bDumpXFBTarget && is_xfb_copy) + if (g_ActiveConfig.bDumpXFBTarget && is_xfb_copy) { static int xfb_count = 0; entry->texture->Save(StringFromFormat("%sxfb_frame_%i.png", diff --git a/Source/Core/VideoCommon/TextureCacheBase.h b/Source/Core/VideoCommon/TextureCacheBase.h index 114127a8da..a6aea52e9e 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.h +++ b/Source/Core/VideoCommon/TextureCacheBase.h @@ -46,7 +46,8 @@ struct EFBCopyParams { EFBCopyParams(PEControl::PixelFormat efb_format_, EFBCopyFormat copy_format_, bool depth_, bool yuv_, float y_scale_) - : efb_format(efb_format_), copy_format(copy_format_), depth(depth_), yuv(yuv_), y_scale(y_scale_) + : efb_format(efb_format_), copy_format(copy_format_), depth(depth_), yuv(yuv_), + y_scale(y_scale_) { } @@ -111,7 +112,8 @@ public: ~TCacheEntry(); - void SetGeneralParameters(u32 _addr, u32 _size, TextureAndTLUTFormat _format, bool force_safe_hashing) + void SetGeneralParameters(u32 _addr, u32 _size, TextureAndTLUTFormat _format, + bool force_safe_hashing) { addr = _addr; size_in_bytes = _size; @@ -150,7 +152,6 @@ public: bool IsEfbCopy() const { return is_efb_copy; } bool IsCopy() const { return is_xfb_copy || is_efb_copy; } - u32 NumBlocksY() const; u32 BytesPerRow() const; @@ -186,7 +187,7 @@ public: static bool IsValidBindPoint(u32 i) { return valid_bind_points.test(i); } TCacheEntry* GetTexture(u32 address, u32 width, u32 height, const TextureFormat texformat, const int textureCacheSafetyColorSampleSize, u32 tlutaddr = 0, - TLUTFormat tlutfmt = TLUTFormat::IA8, bool use_mipmaps = false, + TLUTFormat tlutfmt = TLUTFormat::IA8, bool use_mipmaps = false, u32 tex_levels = 1, bool from_tmem = false, u32 tmem_address_even = 0, u32 tmem_address_odd = 0); virtual void BindTextures(); diff --git a/Source/Core/VideoCommon/TextureConversionShader.cpp b/Source/Core/VideoCommon/TextureConversionShader.cpp index 1f608651ca..ad31c2bf9f 100644 --- a/Source/Core/VideoCommon/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/TextureConversionShader.cpp @@ -64,7 +64,8 @@ static void WriteSwizzler(char*& p, EFBCopyFormat format, APIType ApiType) // left, top, of source rectangle within source texture // width of the destination rectangle, scale_factor (1 or 2) if (ApiType == APIType::Vulkan) - WRITE(p, "layout(std140, push_constant) uniform PCBlock { int4 position; float y_scale; } PC;\n"); + WRITE(p, + "layout(std140, push_constant) uniform PCBlock { int4 position; float y_scale; } PC;\n"); else { WRITE(p, "uniform int4 position;\n"); @@ -154,7 +155,7 @@ static void WriteSwizzler(char*& p, EFBCopyFormat format, APIType ApiType) // pixel) WRITE(p, " uv0 += float2(position.xy);\n"); // move to copied rect WRITE(p, " uv0 /= float2(%d, %d);\n", EFB_WIDTH, EFB_HEIGHT); // normalize to [0:1] - WRITE(p, " uv0 /= float2(1, y_scale);\n"); // apply the y scaling + WRITE(p, " uv0 /= float2(1, y_scale);\n"); // apply the y scaling if (ApiType == APIType::OpenGL) // ogl has to flip up and down { WRITE(p, " uv0.y = 1.0-uv0.y;\n"); @@ -666,22 +667,22 @@ static void WriteZ24Encoder(char*& p, APIType ApiType, const EFBCopyParams& para static void WriteXFBEncoder(char*& p, APIType ApiType, const EFBCopyParams& params) { WriteSwizzler(p, EFBCopyFormat::XFB, ApiType); - + WRITE(p, " float3 y_const = float3(0.257, 0.504, 0.098);\n"); WRITE(p, " float3 u_const = float3(-0.148, -0.291, 0.439);\n"); WRITE(p, " float3 v_const = float3(0.439, -0.368, -0.071);\n"); WRITE(p, " float3 color0;\n"); WRITE(p, " float3 color1;\n"); - + WriteSampleColor(p, "rgb", "color0", 0, ApiType, params); WriteSampleColor(p, "rgb", "color1", 1, ApiType, params); WRITE(p, " float3 average = (color0 + color1) * 0.5;\n"); - + WRITE(p, " ocol0.b = dot(color0, y_const) + 0.0625;\n"); WRITE(p, " ocol0.g = dot(average, u_const) + 0.5;\n"); WRITE(p, " ocol0.r = dot(color1, y_const) + 0.0625;\n"); WRITE(p, " ocol0.a = dot(average, v_const) + 0.5;\n"); - + WriteEncoderEnd(p); } @@ -1264,11 +1265,11 @@ static const std::map s_decoding_shader_info{ } )"}}, - // We do the inverse BT.601 conversion for YCbCr to RGB - // http://www.equasys.de/colorconversion.html#YCbCr-RGBColorFormatConversion - { TextureFormat::XFB, - { BUFFER_FORMAT_RGBA8_UINT, 0, 8, 8, false, - R"( + // We do the inverse BT.601 conversion for YCbCr to RGB + // http://www.equasys.de/colorconversion.html#YCbCr-RGBColorFormatConversion + {TextureFormat::XFB, + {BUFFER_FORMAT_RGBA8_UINT, 0, 8, 8, false, + R"( layout(local_size_x = 8, local_size_y = 8) in; void main() diff --git a/Source/Core/VideoCommon/TextureDecoder_Common.cpp b/Source/Core/VideoCommon/TextureDecoder_Common.cpp index 4351a819c0..9dd9f5850c 100644 --- a/Source/Core/VideoCommon/TextureDecoder_Common.cpp +++ b/Source/Core/VideoCommon/TextureDecoder_Common.cpp @@ -3,8 +3,8 @@ // Refer to the license.txt file included. #include -#include #include +#include #include "Common/CommonTypes.h" #include "Common/MathUtil.h" diff --git a/Source/Core/VideoCommon/TextureDecoder_x64.cpp b/Source/Core/VideoCommon/TextureDecoder_x64.cpp index b31d3692f0..e11a58a8c6 100644 --- a/Source/Core/VideoCommon/TextureDecoder_x64.cpp +++ b/Source/Core/VideoCommon/TextureDecoder_x64.cpp @@ -1486,7 +1486,7 @@ void _TexDecoder_DecodeImpl(u32* dst, const u8* src, int width, int height, Text case TextureFormat::CMPR: TexDecoder_DecodeImpl_CMPR(dst, src, width, height, texformat, tlut, tlutfmt, Wsteps4, Wsteps8); break; - + case TextureFormat::XFB: { for (int y = 0; y < height; y += 1) diff --git a/Source/Core/VideoCommon/VideoCommon.h b/Source/Core/VideoCommon/VideoCommon.h index 5a397084f1..4bd5f59209 100644 --- a/Source/Core/VideoCommon/VideoCommon.h +++ b/Source/Core/VideoCommon/VideoCommon.h @@ -55,7 +55,7 @@ struct TargetRectangle : public MathUtil::Rectangle return (RECT*)this; } #endif - TargetRectangle(const MathUtil::Rectangle &other) : MathUtil::Rectangle(other) {} + TargetRectangle(const MathUtil::Rectangle& other) : MathUtil::Rectangle(other) {} TargetRectangle() = default; }; diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index 8779c785d6..03f8a7368c 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -223,7 +223,7 @@ struct VideoConfig final bool bSupportsGPUTextureDecoding; bool bSupportsST3CTextures; bool bSupportsCopyToVram; - bool bForceCopyToRam; // Needed by Software Renderer + bool bForceCopyToRam; // Needed by Software Renderer bool bSupportsBitfield; // Needed by UberShaders, so must stay in VideoCommon bool bSupportsDynamicSamplerIndexing; // Needed by UberShaders, so must stay in VideoCommon bool bSupportsBPTCTextures;