Hybrid XFB: Fix lint errors

This commit is contained in:
iwubcode 2017-10-01 11:19:29 -05:00
parent f8c2806830
commit 7248dd47d5
8 changed files with 69 additions and 47 deletions

View File

@ -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();

View File

@ -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)
{

View File

@ -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);

View File

@ -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();

View File

@ -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)
{

View File

@ -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; }

View File

@ -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<TextureLookupInformation> 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<TextureLookupInformation> 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);
}
}

View File

@ -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<TextureLookupInformation> 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<TextureLookupInformation>
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,