GS: Fix more lambda capture warnings

This commit is contained in:
Stenzek 2023-12-15 23:17:09 +10:00 committed by refractionpcsx2
parent 96831b0970
commit c2bd21922f
9 changed files with 66 additions and 67 deletions

View File

@ -107,7 +107,7 @@ void GSVertexTraceFMM::FindMinMax(GSVertexTrace& vt, const void* vertex, const u
const GSVertex* RESTRICT v = (GSVertex*)vertex;
// Process 2 vertices at a time for increased efficiency
auto processVertices = [&](const GSVertex& v0, const GSVertex& v1, bool finalVertex)
auto processVertices = [&tmin, &tmax, &cmin, &cmax, &pmin, &pmax, n](const GSVertex& v0, const GSVertex& v1, bool finalVertex)
{
if (color)
{

View File

@ -2789,7 +2789,7 @@ void GSTextureCache::InvalidateVideoMem(const GSOffset& off, const GSVector4i& r
// But this causes rects to be too big, especially in WRC games, I don't think there's any need to align them here.
GSVector4i r = rect;
off.loopPages(rect, [&](u32 page)
off.loopPages(rect, [this, &rect, bp, bw, psm, &found, &r](u32 page)
{
auto& list = m_src.m_map[page];
for (auto i = list.begin(); i != list.end();)
@ -4345,7 +4345,8 @@ GSTextureCache::Source* GSTextureCache::CreateMergedSource(GIFRegTEX0 TEX0, GIFR
int page_y = 0;
// Helper to preload a page.
auto preload_page = [&](int dst_x, int dst_y) {
auto preload_page = [&TEXA, scale, &psm, &lm_off, &lmtex, &lmtex_map, &lmtex_mapped,
page_width, page_height, tex_width, tex_height, copy_queue, &copy_count](int dst_x, int dst_y) {
if (!lmtex)
{
lmtex = g_gs_device->CreateTexture(tex_width, tex_height, 1, GSTexture::Format::Color, false);

View File

@ -303,7 +303,7 @@ bool GLContextEGL::CreateContext(const Version& version, EGLContext share_contex
m_config = [this, &configs]() {
const auto found_config = std::find_if(std::begin(configs), std::end(configs),
[&](const auto& check_config) { return CheckConfigSurfaceFormat(check_config); });
[this](const auto& check_config) { return CheckConfigSurfaceFormat(check_config); });
if (found_config == std::end(configs))
{
Console.Warning("No EGL configs matched exactly, using first.");

View File

@ -2310,7 +2310,7 @@ void GSDrawScanlineCodeGenerator2::ColorTFX()
const XYm& f_ga = _f_ga;
const XYm& tmpga = xym2;
auto modulate16_1_rb = [&]
auto modulate16_1_rb = [this]
{
// GSVector4i rb = iip ? rbf : m_local.c.rb;
modulate16(_rb, _f_rb, 1);

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2021 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -14,8 +14,10 @@
*/
#include "PrecompiledHeader.h"
#include "GSRendererSW.h"
#include "GS/Renderers/SW/GSRendererSW.h"
#include "GS/Renderers/SW/GSTextureSW.h"
#include "GS/GSGL.h"
#include "common/StringUtil.h"
MULTI_ISA_UNSHARED_IMPL;
@ -382,7 +384,7 @@ void GSRendererSW::Draw()
return;
}
if (0) if (LOG)
if constexpr (LOG && false)
{
int n = GSUtil::GetVertexCount(PRIM->PRIM);
@ -552,7 +554,7 @@ void GSRendererSW::Queue(GSRingHeap::SharedPtr<GSRasterizerData>& item)
Sync(5);
}
if (LOG)
if constexpr (LOG)
{
GSScanlineGlobalData& gd = ((SharedData*)item.get())->global;
@ -589,7 +591,7 @@ void GSRendererSW::Sync(int reason)
m_rl->Sync();
if (0) if (LOG)
if constexpr (LOG && false)
{
std::string s;
@ -612,7 +614,7 @@ void GSRendererSW::Sync(int reason)
int pixels = m_rl->GetPixels();
if (LOG)
if constexpr (LOG)
{
fprintf(s_fp, "sync n=%d r=%d t=%llu p=%d %c\n", s_n, reason, t, pixels, t > 10000000 ? '*' : ' ');
fflush(s_fp);
@ -623,7 +625,7 @@ void GSRendererSW::Sync(int reason)
void GSRendererSW::InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r)
{
if (LOG)
if constexpr (LOG)
{
fprintf(s_fp, "w %05x %u %u, %d %d %d %d\n", BITBLTBUF.DBP, BITBLTBUF.DBW, BITBLTBUF.DPSM, r.x, r.y, r.z, r.w);
fflush(s_fp);
@ -636,12 +638,11 @@ void GSRendererSW::InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GS
if (!m_rl->IsSynced())
{
pages.loopPagesWithBreak([&](u32 page)
pages.loopPagesWithBreak([this](u32 page)
{
if (m_fzb_pages[page] | m_tex_pages[page])
{
Sync(6);
return false;
}
return true;
@ -653,7 +654,7 @@ void GSRendererSW::InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GS
void GSRendererSW::InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool clut)
{
if (LOG)
if constexpr (LOG)
{
fprintf(s_fp, "%s %05x %u %u, %d %d %d %d\n", clut ? "rp" : "r", BITBLTBUF.SBP, BITBLTBUF.SBW, BITBLTBUF.SPSM, r.x, r.y, r.z, r.w);
fflush(s_fp);
@ -664,12 +665,11 @@ void GSRendererSW::InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const GS
GSOffset off = m_mem.GetOffset(BITBLTBUF.SBP, BITBLTBUF.SBW, BITBLTBUF.SPSM);
GSOffset::PageLooper pages = off.pageLooperForRect(r);
pages.loopPagesWithBreak([&](u32 page)
pages.loopPagesWithBreak([this](u32 page)
{
if (m_fzb_pages[page])
{
Sync(7);
return false;
}
return true;
@ -679,7 +679,7 @@ void GSRendererSW::InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const GS
void GSRendererSW::UsePages(const GSOffset::PageLooper& pages, const int type)
{
pages.loopPages([=](u32 page)
pages.loopPages([this, type](u32 page)
{
switch (type)
{
@ -703,7 +703,7 @@ void GSRendererSW::UsePages(const GSOffset::PageLooper& pages, const int type)
void GSRendererSW::ReleasePages(const GSOffset::PageLooper& pages, const int type)
{
pages.loopPages([=](u32 page)
pages.loopPages([this, type](u32 page)
{
switch (type)
{
@ -727,20 +727,20 @@ void GSRendererSW::ReleasePages(const GSOffset::PageLooper& pages, const int typ
bool GSRendererSW::CheckTargetPages(const GSOffset::PageLooper* fb_pages, const GSOffset::PageLooper* zb_pages, const GSVector4i& r)
{
bool synced = m_rl->IsSynced();
const bool synced = m_rl->IsSynced();
bool fb = fb_pages != NULL;
bool zb = zb_pages != NULL;
const bool fb = (fb_pages != nullptr);
const bool zb = (zb_pages != nullptr);
GSOffset::PageLooper _fb_pages, _zb_pages;
auto requirePages = [&]
const auto requirePages = [this, &fb_pages, &zb_pages, &r, &_fb_pages, &_zb_pages]
{
if (fb_pages == NULL)
if (!fb_pages)
{
_fb_pages = m_context->offset.fb.pageLooperForRect(r);
fb_pages = &_fb_pages;
}
if (zb_pages == NULL)
if (!zb_pages)
{
_zb_pages = m_context->offset.zb.pageLooperForRect(r);
zb_pages = &_zb_pages;
@ -762,10 +762,10 @@ bool GSRendererSW::CheckTargetPages(const GSOffset::PageLooper* fb_pages, const
requirePages();
fb_pages->loopPages([&](u32 i)
fb_pages->loopPages([this, &used](u32 i)
{
u32 row = i >> 5;
u32 col = 1 << (i & 31);
const u32 row = i >> 5;
const u32 col = 1 << (i & 31);
m_fzb_cur_pages[row] |= col;
@ -773,10 +773,10 @@ bool GSRendererSW::CheckTargetPages(const GSOffset::PageLooper* fb_pages, const
used |= m_tex_pages[i];
});
zb_pages->loopPages([&](u32 i)
zb_pages->loopPages([this, &used](u32 i)
{
u32 row = i >> 5;
u32 col = 1 << (i & 31);
const u32 row = i >> 5;
const u32 col = 1 << (i & 31);
m_fzb_cur_pages[row] |= col;
@ -788,7 +788,7 @@ bool GSRendererSW::CheckTargetPages(const GSOffset::PageLooper* fb_pages, const
{
if (used)
{
if (LOG)
if constexpr (LOG)
{
fprintf(s_fp, "syncpoint 0\n");
fflush(s_fp);
@ -804,9 +804,9 @@ bool GSRendererSW::CheckTargetPages(const GSOffset::PageLooper* fb_pages, const
{
// same target, only check new areas and cross-rendering between frame and z-buffer
GSVector4i bbox = m_fzb_bbox.runion(r);
const GSVector4i bbox = m_fzb_bbox.runion(r);
bool check = !m_fzb_bbox.eq(bbox);
const bool check = !m_fzb_bbox.eq(bbox);
m_fzb_bbox = bbox;
@ -818,7 +818,7 @@ bool GSRendererSW::CheckTargetPages(const GSOffset::PageLooper* fb_pages, const
u32 used = 0;
fb_pages->loopPages([&](u32 i)
fb_pages->loopPages([this, &used](u32 i)
{
u32 row = i >> 5;
u32 col = 1 << (i & 31);
@ -831,7 +831,7 @@ bool GSRendererSW::CheckTargetPages(const GSOffset::PageLooper* fb_pages, const
}
});
zb_pages->loopPages([&](u32 i)
zb_pages->loopPages([this, &used](u32 i)
{
u32 row = i >> 5;
u32 col = 1 << (i & 31);
@ -848,7 +848,7 @@ bool GSRendererSW::CheckTargetPages(const GSOffset::PageLooper* fb_pages, const
{
if (used)
{
if (LOG)
if constexpr (LOG)
{
fprintf(s_fp, "syncpoint 1\n");
fflush(s_fp);
@ -866,40 +866,40 @@ bool GSRendererSW::CheckTargetPages(const GSOffset::PageLooper* fb_pages, const
if (fb && !res)
{
fb_pages->loopPagesWithBreak([&](u32 page)
fb_pages->loopPagesWithBreak([this, &res](u32 page)
{
if (m_fzb_pages[page] & 0xffff0000)
{
if (LOG)
if constexpr (LOG)
{
fprintf(s_fp, "syncpoint 2\n");
fflush(s_fp);
}
res = true;
return false;
}
return true;
});
}
if (zb && !res)
{
zb_pages->loopPagesWithBreak([&](u32 page)
zb_pages->loopPagesWithBreak([this, &res](u32 page)
{
if (m_fzb_pages[page] & 0x0000ffff)
{
if (LOG)
if constexpr (LOG)
{
fprintf(s_fp, "syncpoint 3\n");
fflush(s_fp);
}
res = true;
return false;
}
return true;
});
}
@ -918,7 +918,7 @@ bool GSRendererSW::CheckSourcePages(SharedData* sd)
GSOffset::PageLooper pages = sd->m_tex[i].t->m_offset.pageLooperForRect(sd->m_tex[i].r);
bool ret = false;
pages.loopPagesWithBreak([&](u32 pages)
pages.loopPagesWithBreak([this, &ret](u32 pages)
{
// TODO: 8H 4HL 4HH texture at the same place as the render target (24 bit, or 32-bit where the alpha channel is masked, Valkyrie Profile 2)
@ -937,8 +937,6 @@ bool GSRendererSW::CheckSourcePages(SharedData* sd)
return false;
}
#include "GSTextureSW.h"
bool GSRendererSW::GetScanlineGlobalData(SharedData* data)
{
GSScanlineGlobalData& gd = data->global;
@ -1458,7 +1456,7 @@ GSRendererSW::SharedData::~SharedData()
if (global.dimx)
GSRingHeap::free(global.dimx);
if (LOG)
if constexpr (LOG)
{
fprintf(s_fp, "[%d] done t=%lld p=%d | %d %d %d | %08x_%08x\n",
counter,

View File

@ -62,7 +62,7 @@ GSTextureCacheSW::Texture* GSTextureCacheSW::Lookup(const GIFRegTEX0& TEX0, cons
m_textures.insert(t);
t->m_pages.loopPages([&](u32 page)
t->m_pages.loopPages([this, t](u32 page)
{
t->m_erase_it[page] = m_map[page].InsertFront(t);
});
@ -72,7 +72,7 @@ GSTextureCacheSW::Texture* GSTextureCacheSW::Lookup(const GIFRegTEX0& TEX0, cons
void GSTextureCacheSW::InvalidatePages(const GSOffset::PageLooper& pages, u32 psm)
{
pages.loopPages([&](u32 page)
pages.loopPages([this, psm](u32 page)
{
for (Texture* t : m_map[page])
{
@ -115,13 +115,13 @@ void GSTextureCacheSW::IncAge()
{
for (auto i = m_textures.begin(); i != m_textures.end();)
{
Texture* t = *i;
Texture* const t = *i;
if (++t->m_age > 10)
{
i = m_textures.erase(i);
t->m_pages.loopPages([&](u32 page)
t->m_pages.loopPages([this, t](u32 page)
{
m_map[page].EraseIndex(t->m_erase_it[page]);
});
@ -140,11 +140,11 @@ void GSTextureCacheSW::IncAge()
GSTextureCacheSW::Texture::Texture(u32 tw0, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA)
: m_TEX0(TEX0)
, m_TEXA(TEXA)
, m_buff(NULL)
, m_buff(nullptr)
, m_tw(tw0)
, m_age(0)
, m_complete(false)
, m_p2t(NULL)
, m_p2t(nullptr)
{
if (m_tw == 0)
{
@ -179,13 +179,13 @@ void GSTextureCacheSW::Texture::Reset(u32 tw0, const GIFRegTEX0& TEX0, const GIF
if (m_buff && (m_TEX0.TW != TEX0.TW || m_TEX0.TH != TEX0.TH))
{
_aligned_free(m_buff);
m_buff = NULL;
m_buff = nullptr;
}
m_tw = tw0;
m_age = 0;
m_complete = false;
m_p2t = NULL;
m_p2t = nullptr;
m_TEX0 = TEX0;
m_TEXA = TEXA;
@ -234,7 +234,7 @@ bool GSTextureCacheSW::Texture::Update(const GSVector4i& rect)
m_complete = true; // lame, but better than nothing
}
if (m_buff == NULL)
if (!m_buff)
{
const u32 pitch = (1 << m_tw) << shift;
@ -330,7 +330,7 @@ bool GSTextureCacheSW::Texture::Save(const std::string& fn, bool dds) const
GSTexture::GSMap m;
if (t.Map(m, NULL))
if (t.Map(m, nullptr))
{
const GSLocalMemory::psm_t& psm = GSLocalMemory::m_psm[m_TEX0.PSM];

View File

@ -168,9 +168,9 @@ bool GSDeviceVK::SelectInstanceExtensions(ExtensionList* extension_list, const W
res = vkEnumerateInstanceExtensionProperties(nullptr, &extension_count, available_extension_list.data());
pxAssert(res == VK_SUCCESS);
auto SupportsExtension = [&](const char* name, bool required) {
auto SupportsExtension = [&available_extension_list, extension_list](const char* name, bool required) {
if (std::find_if(available_extension_list.begin(), available_extension_list.end(),
[&](const VkExtensionProperties& properties) { return !strcmp(name, properties.extensionName); }) !=
[name](const VkExtensionProperties& properties) { return !strcmp(name, properties.extensionName); }) !=
available_extension_list.end())
{
DevCon.WriteLn("Enabling extension: %s", name);
@ -294,13 +294,13 @@ bool GSDeviceVK::SelectDeviceExtensions(ExtensionList* extension_list, bool enab
m_physical_device, nullptr, &extension_count, available_extension_list.data());
pxAssert(res == VK_SUCCESS);
auto SupportsExtension = [&](const char* name, bool required) {
auto SupportsExtension = [&available_extension_list, extension_list](const char* name, bool required) {
if (std::find_if(available_extension_list.begin(), available_extension_list.end(),
[&](const VkExtensionProperties& properties) { return !strcmp(name, properties.extensionName); }) !=
[name](const VkExtensionProperties& properties) { return !strcmp(name, properties.extensionName); }) !=
available_extension_list.end())
{
if (std::none_of(extension_list->begin(), extension_list->end(),
[&](const char* existing_name) { return (std::strcmp(existing_name, name) == 0); }))
[name](const char* existing_name) { return (std::strcmp(existing_name, name) == 0); }))
{
DevCon.WriteLn("Enabling extension: %s", name);
extension_list->push_back(name);

View File

@ -74,7 +74,7 @@ bool Vulkan::LoadVulkanLibrary()
}
bool required_functions_missing = false;
auto LoadFunction = [&](FARPROC* func_ptr, const char* name, bool is_required) {
auto LoadFunction = [&required_functions_missing](FARPROC* func_ptr, const char* name, bool is_required) {
*func_ptr = GetProcAddress(s_vulkan_module, name);
if (!(*func_ptr) && is_required)
{
@ -163,7 +163,7 @@ bool Vulkan::LoadVulkanLibrary()
}
bool required_functions_missing = false;
auto LoadFunction = [&](void** func_ptr, const char* name, bool is_required) {
auto LoadFunction = [&required_functions_missing](void** func_ptr, const char* name, bool is_required) {
*func_ptr = dlsym(s_vulkan_module, name);
if (!(*func_ptr) && is_required)
{
@ -200,7 +200,7 @@ void Vulkan::UnloadVulkanLibrary()
bool Vulkan::LoadVulkanInstanceFunctions(VkInstance instance)
{
bool required_functions_missing = false;
auto LoadFunction = [&](PFN_vkVoidFunction* func_ptr, const char* name, bool is_required) {
auto LoadFunction = [&required_functions_missing, instance](PFN_vkVoidFunction* func_ptr, const char* name, bool is_required) {
*func_ptr = vkGetInstanceProcAddr(instance, name);
if (!(*func_ptr) && is_required)
{
@ -220,7 +220,7 @@ bool Vulkan::LoadVulkanInstanceFunctions(VkInstance instance)
bool Vulkan::LoadVulkanDeviceFunctions(VkDevice device)
{
bool required_functions_missing = false;
auto LoadFunction = [&](PFN_vkVoidFunction* func_ptr, const char* name, bool is_required) {
auto LoadFunction = [&required_functions_missing, device](PFN_vkVoidFunction* func_ptr, const char* name, bool is_required) {
*func_ptr = vkGetDeviceProcAddr(device, name);
if (!(*func_ptr) && is_required)
{

View File

@ -153,7 +153,7 @@ std::optional<VKShaderCache::SPIRVCodeVector> VKShaderCache::CompileShaderToSPV(
int pass_source_code_length = static_cast<int>(source.size());
shader->setStringsWithLengths(&pass_source_code, &pass_source_code_length, 1);
auto DumpBadShader = [&](const char* msg) {
auto DumpBadShader = [&shader, &source, &program](const char* msg) {
const std::string filename =
Path::Combine(EmuFolders::Logs, fmt::format("pcsx2_bad_shader_{}.txt", s_next_bad_shader_id++));
Console.Error("CompileShaderToSPV: %s, writing to %s", msg, filename.c_str());