From 7248dd47d5b48564a1ed049bdf392146dca2d72a Mon Sep 17 00:00:00 2001 From: iwubcode Date: Sun, 1 Oct 2017 11:19:29 -0500 Subject: [PATCH] Hybrid XFB: Fix lint errors --- Source/Core/VideoBackends/D3D/Render.cpp | 3 +- Source/Core/VideoBackends/OGL/Render.cpp | 3 +- .../VideoBackends/Software/SWRenderer.cpp | 3 +- Source/Core/VideoBackends/Vulkan/Renderer.cpp | 3 +- Source/Core/VideoCommon/RenderBase.cpp | 4 +- Source/Core/VideoCommon/RenderBase.h | 6 +- Source/Core/VideoCommon/TextureCacheBase.cpp | 72 +++++++++++-------- Source/Core/VideoCommon/TextureCacheBase.h | 22 +++--- 8 files changed, 69 insertions(+), 47 deletions(-) diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index 3f5fce3d10..11bbea61c2 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -608,7 +608,8 @@ void Renderer::SetBlendingState(const BlendingState& state) } // This function has the final picture. We adjust the aspect ratio here. -void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region, u64 ticks, float Gamma) +void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region, u64 ticks, + float Gamma) { ResetAPIState(); diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index 46c9787eb5..2125102fe0 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -1325,7 +1325,8 @@ void Renderer::SetBlendingState(const BlendingState& state) } // This function has the final picture. We adjust the aspect ratio here. -void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region, u64 ticks, float Gamma) +void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region, u64 ticks, + float Gamma) { if (g_ogl_config.bSupportsDebug) { diff --git a/Source/Core/VideoBackends/Software/SWRenderer.cpp b/Source/Core/VideoBackends/Software/SWRenderer.cpp index 3c05068606..4f1fafd989 100644 --- a/Source/Core/VideoBackends/Software/SWRenderer.cpp +++ b/Source/Core/VideoBackends/Software/SWRenderer.cpp @@ -43,7 +43,8 @@ void SWRenderer::RenderText(const std::string& pstr, int left, int top, u32 colo } // Called on the GPU thread -void SWRenderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region, u64 ticks, float Gamma) +void SWRenderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region, u64 ticks, + float Gamma) { OSD::DoCallbacks(OSD::CallbackType::OnFrame); diff --git a/Source/Core/VideoBackends/Vulkan/Renderer.cpp b/Source/Core/VideoBackends/Vulkan/Renderer.cpp index d5d105ff6b..d72f2929c3 100644 --- a/Source/Core/VideoBackends/Vulkan/Renderer.cpp +++ b/Source/Core/VideoBackends/Vulkan/Renderer.cpp @@ -481,7 +481,8 @@ void Renderer::ReinterpretPixelData(unsigned int convtype) BindEFBToStateTracker(); } -void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region, u64 ticks, float Gamma) +void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region, u64 ticks, + float Gamma) { // Pending/batched EFB pokes should be included in the final image. FramebufferManager::GetInstance()->FlushEFBPokes(); diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 1aa7918e96..0db81bb885 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -643,8 +643,8 @@ void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const { constexpr int force_safe_texture_cache_hash = 0; // Get the current XFB from texture cache - auto* xfb_entry = g_texture_cache->GetXFBTexture(xfbAddr, fbStride, fbHeight, TextureFormat::XFB, - force_safe_texture_cache_hash); + auto* xfb_entry = g_texture_cache->GetXFBTexture( + xfbAddr, fbStride, fbHeight, TextureFormat::XFB, force_safe_texture_cache_hash); if (xfb_entry && xfb_entry->id != m_last_xfb_id) { diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index 8abfdb9894..b622372b90 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -131,8 +131,10 @@ public: virtual void BBoxWrite(int index, u16 value) = 0; // Finish up the current frame, print some stats - void Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const EFBRectangle& rc, u64 ticks); - virtual void SwapImpl(AbstractTexture* texture, const EFBRectangle& rc, u64 ticks, float Gamma = 1.0f) = 0; + void Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const EFBRectangle& rc, + u64 ticks); + virtual void SwapImpl(AbstractTexture* texture, const EFBRectangle& rc, u64 ticks, + float Gamma = 1.0f) = 0; PEControl::PixelFormat GetPrevPixelFormat() const { return m_prev_efb_format; } void StorePixelFormat(PEControl::PixelFormat new_format) { m_prev_efb_format = new_format; } diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 2310631b94..32d1e8d7dc 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -650,12 +650,11 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::Load(const u32 stage) return entry; } -TextureCacheBase::TCacheEntry* TextureCacheBase::GetTexture(u32 address, u32 width, u32 height, - const TextureFormat texformat, - const int textureCacheSafetyColorSampleSize, u32 tlutaddr, - TLUTFormat tlutfmt, bool use_mipmaps, - u32 tex_levels, bool from_tmem, u32 tmem_address_even, - u32 tmem_address_odd) +TextureCacheBase::TCacheEntry* +TextureCacheBase::GetTexture(u32 address, u32 width, u32 height, const TextureFormat texformat, + const int textureCacheSafetyColorSampleSize, u32 tlutaddr, + TLUTFormat tlutfmt, bool use_mipmaps, u32 tex_levels, bool from_tmem, + u32 tmem_address_even, u32 tmem_address_odd) { // TexelSizeInNibbles(format) * width * height / 16; const unsigned int bsw = TexDecoder_GetBlockWidthInTexels(texformat); @@ -1169,16 +1168,16 @@ std::optional TextureCacheBase::ComputeTextureInformat tex_info.block_width = TexDecoder_GetBlockWidthInTexels(tex_format); tex_info.block_height = TexDecoder_GetBlockHeightInTexels(tex_format); - tex_info.bytes_per_block = - (tex_info.block_width * tex_info.block_height * TexDecoder_GetTexelSizeInNibbles(tex_format)) - / 2; + tex_info.bytes_per_block = (tex_info.block_width * tex_info.block_height * + TexDecoder_GetTexelSizeInNibbles(tex_format)) / + 2; tex_info.expanded_width = Common::AlignUp(width, tex_info.block_width); tex_info.expanded_height = Common::AlignUp(height, tex_info.block_height); - + tex_info.total_bytes = TexDecoder_GetTextureSizeInBytes(tex_info.expanded_width, tex_info.expanded_height, tex_format); - + tex_info.native_width = width; tex_info.native_height = height; tex_info.native_levels = levels; @@ -1204,8 +1203,8 @@ std::optional TextureCacheBase::ComputeTextureInformat { tex_info.palette_size = TexDecoder_GetPaletteSize(tex_format); tex_info.full_hash = - tex_info.base_hash ^ GetHash64(&texMem[tex_info.tlut_address], tex_info.palette_size, - tex_info.texture_cache_safety_color_sample_size); + tex_info.base_hash ^ GetHash64(&texMem[tex_info.tlut_address], tex_info.palette_size, + tex_info.texture_cache_safety_color_sample_size); } else { @@ -1330,14 +1329,16 @@ bool TextureCacheBase::LoadTextureFromOverlappingTextures(TCacheEntry* entry_to_ // 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->y_scale) != entry_to_update->GetHeight() || - entry->native_width != entry->GetWidth() || (entry->native_height * entry->y_scale) != entry->GetHeight()) + (entry_to_update->native_height * entry_to_update->y_scale) != + entry_to_update->GetHeight() || + entry->native_width != entry->GetWidth() || + (entry->native_height * entry->y_scale) != 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)); + 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)); + g_renderer->EFBToScaledY(entry->native_height * entry->y_scale)); src_x = g_renderer->EFBToScaledX(src_x); src_y = g_renderer->EFBToScaledY(src_y); @@ -1409,7 +1410,8 @@ bool TextureCacheBase::LoadTextureFromOverlappingTextures(TCacheEntry* entry_to_ return updated_entry; } -TextureCacheBase::TCacheEntry* TextureCacheBase::CreateNormalTexture(const TextureLookupInformation& tex_info) +TextureCacheBase::TCacheEntry* +TextureCacheBase::CreateNormalTexture(const TextureLookupInformation& tex_info) { // create the entry/texture TextureConfig config; @@ -1427,7 +1429,8 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::CreateNormalTexture(const Textu textures_by_address.emplace(tex_info.address, entry); if (tex_info.texture_cache_safety_color_sample_size == 0 || - std::max(tex_info.total_bytes, tex_info.palette_size) <= (u32)tex_info.texture_cache_safety_color_sample_size * 8) + std::max(tex_info.total_bytes, tex_info.palette_size) <= + (u32)tex_info.texture_cache_safety_color_sample_size * 8) { entry->textures_by_hash_iter = textures_by_hash.emplace(tex_info.full_hash, entry); } @@ -1450,7 +1453,8 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::CreateNormalTexture(const Textu return entry; } -void TextureCacheBase::LoadTextureFromMemory(TCacheEntry* entry_to_update, const TextureLookupInformation& tex_info) +void TextureCacheBase::LoadTextureFromMemory(TCacheEntry* entry_to_update, + const TextureLookupInformation& tex_info) { // We can decode on the GPU if it is a supported format and the flag is enabled. // Currently we don't decode RGBA8 textures from Tmem, as that would require copying from both @@ -1458,23 +1462,26 @@ void TextureCacheBase::LoadTextureFromMemory(TCacheEntry* entry_to_update, const // there's no conversion between formats. In the future this could be extended with a separate // shader, however. bool decode_on_gpu = g_ActiveConfig.UseGPUTextureDecoding() && - g_texture_cache->SupportsGPUTextureDecode(tex_info.full_format.texfmt, - tex_info.full_format.tlutfmt) && - !(tex_info.from_tmem && tex_info.full_format.texfmt == TextureFormat::RGBA8); + g_texture_cache->SupportsGPUTextureDecode(tex_info.full_format.texfmt, + tex_info.full_format.tlutfmt) && + !(tex_info.from_tmem && tex_info.full_format.texfmt == TextureFormat::RGBA8); LoadTextureLevelZeroFromMemory(entry_to_update, tex_info, decode_on_gpu); } -void TextureCacheBase::LoadTextureLevelZeroFromMemory(TCacheEntry* entry_to_update, const TextureLookupInformation& tex_info, bool decode_on_gpu) +void TextureCacheBase::LoadTextureLevelZeroFromMemory(TCacheEntry* entry_to_update, + const TextureLookupInformation& tex_info, + bool decode_on_gpu) { const u8* tlut = &texMem[tex_info.tlut_address]; if (decode_on_gpu) { u32 row_stride = tex_info.bytes_per_block * (tex_info.expanded_width / tex_info.block_width); - g_texture_cache->DecodeTextureOnGPU(entry_to_update, 0, tex_info.src_data, tex_info.total_bytes, tex_info.full_format.texfmt, tex_info.native_width, - tex_info.native_height, tex_info.expanded_width, tex_info.expanded_height, row_stride, tlut, - tex_info.full_format.tlutfmt); + g_texture_cache->DecodeTextureOnGPU( + entry_to_update, 0, tex_info.src_data, tex_info.total_bytes, tex_info.full_format.texfmt, + tex_info.native_width, tex_info.native_height, tex_info.expanded_width, + tex_info.expanded_height, row_stride, tlut, tex_info.full_format.tlutfmt); } else { @@ -1482,15 +1489,18 @@ void TextureCacheBase::LoadTextureLevelZeroFromMemory(TCacheEntry* entry_to_upda CheckTempSize(decoded_texture_size); if (!(tex_info.full_format.texfmt == TextureFormat::RGBA8 && tex_info.from_tmem)) { - TexDecoder_Decode(temp, tex_info.src_data, tex_info.expanded_width, tex_info.expanded_height, tex_info.full_format.texfmt, tlut, tex_info.full_format.tlutfmt); + TexDecoder_Decode(temp, tex_info.src_data, tex_info.expanded_width, tex_info.expanded_height, + tex_info.full_format.texfmt, tlut, tex_info.full_format.tlutfmt); } else { u8* src_data_gb = &texMem[tex_info.tmem_address_odd]; - TexDecoder_DecodeRGBA8FromTmem(temp, tex_info.src_data, src_data_gb, tex_info.expanded_width, tex_info.expanded_height); + TexDecoder_DecodeRGBA8FromTmem(temp, tex_info.src_data, src_data_gb, tex_info.expanded_width, + tex_info.expanded_height); } - entry_to_update->texture->Load(0, tex_info.native_width, tex_info.native_height, tex_info.expanded_width, temp, decoded_texture_size); + entry_to_update->texture->Load(0, tex_info.native_width, tex_info.native_height, + tex_info.expanded_width, temp, decoded_texture_size); } } diff --git a/Source/Core/VideoCommon/TextureCacheBase.h b/Source/Core/VideoCommon/TextureCacheBase.h index c248f75dd9..696c6ec888 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.h +++ b/Source/Core/VideoCommon/TextureCacheBase.h @@ -97,7 +97,7 @@ struct TextureLookupInformation u32 tmem_address_even = 0; u32 tmem_address_odd = 0; - int texture_cache_safety_color_sample_size = 0; // Default to safe hashing + int texture_cache_safety_color_sample_size = 0; // Default to safe hashing u8* src_data; @@ -132,7 +132,7 @@ public: float gamma = 1.0f; u64 id; - bool reference_changed = false; // used by xfb to determine when a reference xfb changed + bool reference_changed = false; // used by xfb to determine when a reference xfb changed unsigned int native_width, native_height; // Texture dimensions from the GameCube's point of view @@ -234,14 +234,20 @@ public: u32 tmem_address_odd = 0); TCacheEntry* GetXFBTexture(u32 address, u32 width, u32 height, TextureFormat texformat, - int textureCacheSafetyColorSampleSize); - std::optional ComputeTextureInformation(u32 address, u32 width, u32 height, TextureFormat texformat, - int textureCacheSafetyColorSampleSize, bool from_tmem, u32 tmem_address_even, u32 tmem_address_odd, u32 tlutaddr, TLUTFormat tlutfmt, u32 levels); + int textureCacheSafetyColorSampleSize); + std::optional + ComputeTextureInformation(u32 address, u32 width, u32 height, TextureFormat texformat, + int textureCacheSafetyColorSampleSize, bool from_tmem, + u32 tmem_address_even, u32 tmem_address_odd, u32 tlutaddr, + TLUTFormat tlutfmt, u32 levels); TCacheEntry* GetXFBFromCache(const TextureLookupInformation& tex_info); - bool LoadTextureFromOverlappingTextures(TCacheEntry* entry_to_update, const TextureLookupInformation& tex_info); + bool LoadTextureFromOverlappingTextures(TCacheEntry* entry_to_update, + const TextureLookupInformation& tex_info); TCacheEntry* CreateNormalTexture(const TextureLookupInformation& tex_info); - void LoadTextureFromMemory(TCacheEntry* entry_to_update, const TextureLookupInformation& tex_info); - void LoadTextureLevelZeroFromMemory(TCacheEntry* entry_to_update, const TextureLookupInformation& tex_info, bool decode_on_gpu); + void LoadTextureFromMemory(TCacheEntry* entry_to_update, + const TextureLookupInformation& tex_info); + void LoadTextureLevelZeroFromMemory(TCacheEntry* entry_to_update, + const TextureLookupInformation& tex_info, bool decode_on_gpu); virtual void BindTextures(); void CopyRenderTargetToTexture(u32 dstAddr, EFBCopyFormat dstFormat, u32 dstStride, bool is_depth_copy, const EFBRectangle& srcRect, bool isIntensity,