This commit is contained in:
R2DLiu 2021-11-26 19:48:26 -05:00
commit 9cf53410c7
3 changed files with 33 additions and 38 deletions

View file

@ -27,11 +27,6 @@ static std::mutex ack_mutex;
SlippiNetplayClient* SLIPPI_NETPLAY = nullptr; SlippiNetplayClient* SLIPPI_NETPLAY = nullptr;
static bool IsOnline()
{
return SLIPPI_NETPLAY != nullptr;
}
// called from ---GUI--- thread // called from ---GUI--- thread
SlippiNetplayClient::~SlippiNetplayClient() SlippiNetplayClient::~SlippiNetplayClient()
{ {
@ -66,7 +61,7 @@ SlippiNetplayClient::SlippiNetplayClient(const std::string& address, const u16 r
: m_qos_handle(nullptr), m_qos_flow_id(0) : m_qos_handle(nullptr), m_qos_flow_id(0)
#endif #endif
{ {
WARN_LOG_FMT(SLIPPI_ONLINE, "Initializing Slippi Netplay for port: %d, with host: %s", localPort, WARN_LOG_FMT(SLIPPI_ONLINE, "Initializing Slippi Netplay for port: {}, with host: {}", localPort,
isDecider ? "true" : "false"); isDecider ? "true" : "false");
this->isDecider = isDecider; this->isDecider = isDecider;
@ -291,7 +286,7 @@ unsigned int SlippiNetplayClient::OnData(sf::Packet& packet)
break; break;
default: default:
WARN_LOG_FMT(SLIPPI_ONLINE, "Unknown message received with id : %d", mid); WARN_LOG_FMT(SLIPPI_ONLINE, "Unknown message received with id : {}", mid);
break; break;
} }
@ -422,7 +417,7 @@ void SlippiNetplayClient::ThreadFunc()
break; break;
} }
WARN_LOG_FMT(SLIPPI_ONLINE, "[Netplay] Not yet connected. Res: %d, Type: %d", net, WARN_LOG_FMT(SLIPPI_ONLINE, "[Netplay] Not yet connected. Res: {}, Type: {}", net,
netEvent.type); netEvent.type);
// Time out after enough time has passed // Time out after enough time has passed

View file

@ -207,4 +207,7 @@ private:
extern SlippiNetplayClient* SLIPPI_NETPLAY; // singleton static pointer extern SlippiNetplayClient* SLIPPI_NETPLAY; // singleton static pointer
static bool IsOnline(); inline bool IsOnline()
{
return SLIPPI_NETPLAY != nullptr;
}

View file

@ -1785,7 +1785,10 @@ TextureCacheBase::GetXFBTexture(u32 address, u32 width, u32 height, u32 stride,
TextureCacheBase::TCacheEntry* TextureCacheBase::TCacheEntry*
TextureCacheBase::GetXFBTexture(u32 address, u32 width, u32 height, u32 stride, TextureCacheBase::GetXFBTexture(u32 address, u32 width, u32 height, u32 stride,
MathUtil::Rectangle<int>* display_rect, float gamma, const MathUtil::Rectangle<int>& src_rect, const CopyFilterCoefficients::Values& copy_filter_coefficients, float y_scale, bool clamp_top, bool clamp_bottom) MathUtil::Rectangle<int>* display_rect, float gamma,
const MathUtil::Rectangle<int>& src_rect,
const CopyFilterCoefficients::Values& copy_filter_coefficients,
float y_scale, bool clamp_top, bool clamp_bottom)
{ {
auto filter_coefficients = GetVRAMCopyFilterCoefficients(copy_filter_coefficients); auto filter_coefficients = GetVRAMCopyFilterCoefficients(copy_filter_coefficients);
const u8* src_data = Memory::GetPointer(address); const u8* src_data = Memory::GetPointer(address);
@ -1798,10 +1801,6 @@ TextureCacheBase::GetXFBTexture(u32 address, u32 width, u32 height, u32 stride,
u32 scaled_tex_w = g_renderer->EFBToScaledX(width); u32 scaled_tex_w = g_renderer->EFBToScaledX(width);
u32 scaled_tex_h = g_renderer->EFBToScaledY(height); u32 scaled_tex_h = g_renderer->EFBToScaledY(height);
// Compute total texture size. XFB textures aren't tiled, so this is simple.
const u32 total_size = height * stride;
const u64 hash = Common::GetHash64(src_data, total_size, 0);
TCacheEntry* entry = nullptr; TCacheEntry* entry = nullptr;
const TextureConfig config(scaled_tex_w, scaled_tex_h, 1, g_framebuffer_manager->GetEFBLayers(), const TextureConfig config(scaled_tex_w, scaled_tex_h, 1, g_framebuffer_manager->GetEFBLayers(),
1, AbstractTextureFormat::RGBA8, AbstractTextureFlag_RenderTarget); 1, AbstractTextureFormat::RGBA8, AbstractTextureFlag_RenderTarget);
@ -1826,7 +1825,8 @@ TextureCacheBase::GetXFBTexture(u32 address, u32 width, u32 height, u32 stride,
if (entry) if (entry)
{ {
entry->SetGeneralParameters(address, 0, TexDecoder_GetEFBCopyBaseFormat(EFBCopyFormat::XFB), true); entry->SetGeneralParameters(address, 0, TexDecoder_GetEFBCopyBaseFormat(EFBCopyFormat::XFB),
true);
entry->SetDimensions(width, height, 1); entry->SetDimensions(width, height, 1);
entry->frameCount = FRAMECOUNT_INVALID; entry->frameCount = FRAMECOUNT_INVALID;
entry->should_force_safe_hashing = true; entry->should_force_safe_hashing = true;
@ -1834,7 +1834,6 @@ TextureCacheBase::GetXFBTexture(u32 address, u32 width, u32 height, u32 stride,
entry->may_have_overlapping_textures = false; entry->may_have_overlapping_textures = false;
entry->is_custom_tex = false; entry->is_custom_tex = false;
/////////////////////// ///////////////////////
// Flush EFB pokes first, as they're expected to be included. // Flush EFB pokes first, as they're expected to be included.
g_framebuffer_manager->FlushEFBPokes(); g_framebuffer_manager->FlushEFBPokes();
@ -1842,8 +1841,7 @@ TextureCacheBase::GetXFBTexture(u32 address, u32 width, u32 height, u32 stride,
// Get the pipeline which we will be using. If the compilation failed, this will be null. // Get the pipeline which we will be using. If the compilation failed, this will be null.
const AbstractPipeline* copy_pipeline = const AbstractPipeline* copy_pipeline =
g_shader_cache->GetEFBCopyToVRAMPipeline(TextureConversionShaderGen::GetShaderUid( g_shader_cache->GetEFBCopyToVRAMPipeline(TextureConversionShaderGen::GetShaderUid(
EFBCopyFormat::XFB, false, false, false, EFBCopyFormat::XFB, false, false, false, NeedsCopyFilterInShader(filter_coefficients)));
NeedsCopyFilterInShader(filter_coefficients)));
if (!copy_pipeline) if (!copy_pipeline)
{ {
WARN_LOG(VIDEO, "Skipping EFB copy to VRAM due to missing pipeline."); WARN_LOG(VIDEO, "Skipping EFB copy to VRAM due to missing pipeline.");
@ -1905,8 +1903,7 @@ TextureCacheBase::GetXFBTexture(u32 address, u32 width, u32 height, u32 stride,
{ {
static int xfb_count = 0; static int xfb_count = 0;
entry->texture->Save( entry->texture->Save(
fmt::format("{}xfb_copy_{}.png", File::GetUserPath(D_DUMPTEXTURES_IDX), xfb_count++), fmt::format("{}xfb_copy_{}.png", File::GetUserPath(D_DUMPTEXTURES_IDX), xfb_count++), 0);
0);
} }
u8* dst = Memory::GetPointer(address); u8* dst = Memory::GetPointer(address);
UninitializeXFBMemory(dst, stride, bytes_per_row, num_blocks_y); UninitializeXFBMemory(dst, stride, bytes_per_row, num_blocks_y);
@ -1972,8 +1969,8 @@ TextureCacheBase::GetXFBTexture(u32 address, u32 width, u32 height, u32 stride,
} }
} }
// Even if the copy is deferred, still compute the hash. This way if the copy is used as a texture // Even if the copy is deferred, still compute the hash. This way if the copy is used as a
// in a subsequent draw before it is flushed, it will have the same hash. // texture in a subsequent draw before it is flushed, it will have the same hash.
if (entry) if (entry)
{ {
const u64 entry_hash = entry->CalculateHash(); const u64 entry_hash = entry->CalculateHash();