Fix incorrect streamout buffer index in GS + refactor various code (#258)

This commit is contained in:
Herman Semenov 2022-09-17 04:45:18 +03:00 committed by GitHub
parent 4a3d02db55
commit 03f5967408
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 70 additions and 92 deletions

View File

@ -577,7 +577,7 @@ namespace CafeSystem
const auto file = fsc_open(rpxPath.c_str(), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &status);
if (file)
{
_pathToExecutable = rpxPath;
_pathToExecutable = std::move(rpxPath);
fsc_close(file);
}
}

View File

@ -143,7 +143,7 @@ sint32 fsc_mount(std::string_view mountPath, std::string_view targetPath, fscDev
}
node->device = fscDevice;
node->ctx = ctx;
node->deviceTargetPath = targetPathWithSlash;
node->deviceTargetPath = std::move(targetPathWithSlash);
fscLeave();
return FSC_STATUS_OK;
}

View File

@ -1020,9 +1020,9 @@ bool GraphicPack2::Deactivate()
m_upscaling_shader_ud.reset();
m_downscaling_shader_ud.reset();
m_output_shader_source = "";
m_upscaling_shader_source = "";
m_downscaling_shader_source = "";
m_output_shader_source.clear();
m_upscaling_shader_source.clear();
m_downscaling_shader_source.clear();
if (HasCustomVSyncFrequency())
{

View File

@ -101,7 +101,7 @@ namespace Espresso
struct BOField
{
BOField() {};
BOField() = default;
BOField(uint8 bo) : bo(bo) {};
bool conditionInverted() const

View File

@ -10,7 +10,7 @@ class PPCFunctionBoundaryTracker
public:
struct PPCRange_t
{
PPCRange_t() {};
PPCRange_t() = default;
PPCRange_t(uint32 _startAddress) : startAddress(_startAddress) {};
uint32 startAddress{};

View File

@ -197,7 +197,7 @@ struct raLivenessLocation_t
bool isRead;
bool isWrite;
raLivenessLocation_t() {};
raLivenessLocation_t() = default;
raLivenessLocation_t(sint32 index, bool isRead, bool isWrite)
: index(index), isRead(isRead), isWrite(isWrite) {};

View File

@ -29,7 +29,7 @@ class IntervalTree2
struct InternalRange
{
InternalRange() {};
InternalRange() = default;
InternalRange(TRangeData _rangeBegin, TRangeData _rangeEnd) : rangeBegin(_rangeBegin), rangeEnd(_rangeEnd) { cemu_assert_debug(_rangeBegin < _rangeEnd); };
TRangeData rangeBegin;

View File

@ -208,7 +208,7 @@ LatteParsedGSCopyShader* LatteGSCopyShaderParser_parse(uint8* programData, uint3
uint32 bufferIndex;
if (cf_inst23_7 == GPU7_CF_INST_MEM_STREAM0_WRITE)
bufferIndex = 0;
else if (cf_inst23_7 == GPU7_CF_INST_MEM_STREAM0_WRITE)
else if (cf_inst23_7 == GPU7_CF_INST_MEM_STREAM1_WRITE)
bufferIndex = 1;
else
cemu_assert_debug(false);

View File

@ -493,6 +493,7 @@ bool LatteMRT::UpdateCurrentFBO()
sint32 colorAttachmentWidth;
sint32 colorAttachmentHeight;
LatteTexture_getSize(colorAttachmentView->baseTexture, &colorAttachmentWidth, &colorAttachmentHeight, nullptr, colorAttachmentView->firstMip);
// set effective size

View File

@ -609,7 +609,7 @@ void LatteShaderCache_loadOrCompileSeparableShader(LatteDecompilerShader* shader
bool LatteShaderCache_readSeparableVertexShader(MemStreamReader& streamReader, uint8 version)
{
std::unique_ptr<LatteContextRegister> lcr(new LatteContextRegister());
auto lcr = std::make_unique<LatteContextRegister>();
if (version != 1)
return false;
uint64 shaderBaseHash = streamReader.readBE<uint64>();
@ -658,7 +658,7 @@ bool LatteShaderCache_readSeparableGeometryShader(MemStreamReader& streamReader,
{
if (version != 1)
return false;
std::unique_ptr<LatteContextRegister> lcr(new LatteContextRegister());
auto lcr = std::make_unique<LatteContextRegister>();
uint64 shaderBaseHash = streamReader.readBE<uint64>();
uint64 shaderAuxHash = streamReader.readBE<uint64>();
uint32 vsRingParameterCount = streamReader.readBE<uint16>();
@ -698,7 +698,7 @@ bool LatteShaderCache_readSeparablePixelShader(MemStreamReader& streamReader, ui
{
if (version != 1)
return false;
std::unique_ptr<LatteContextRegister> lcr(new LatteContextRegister());
auto lcr = std::make_unique<LatteContextRegister>();
uint64 shaderBaseHash = streamReader.readBE<uint64>();
uint64 shaderAuxHash = streamReader.readBE<uint64>();
bool usesGeometryShader = streamReader.readBE<uint8>() != 0;

View File

@ -214,6 +214,10 @@ void VulkanPipelineStableCache::LoadPipelineFromCache(std::span<uint8> fileData)
if (!DeserializePipeline(streamReader, *cachedPipeline))
{
// failed to deserialize
s_spinlockSharedInternal.acquire();
delete lcr;
delete cachedPipeline;
s_spinlockSharedInternal.release();
return;
}
// restored register view from compacted state

View File

@ -3,7 +3,7 @@
struct VulkanPipelineHash
{
VulkanPipelineHash() {};
VulkanPipelineHash() = default;
VulkanPipelineHash(uint64 h0, uint64 h1) : h0(h0), h1(h1) {};
uint64 h0;

View File

@ -243,6 +243,7 @@ bool RPLLoader_ProcessHeaders(std::string_view moduleName, uint8* rplData, uint3
if (fileinfoSection->sectionSize < sizeof(RPLFileInfoData))
{
cemuLog_force("RPLLoader: FILEINFO section size is below expected size");
delete rplLoaderContext;
return false;
}
@ -1963,7 +1964,7 @@ void RPLLoader_AddDependency(const char* name)
if (rplLoader_currentTlsModuleIndex == 0x7FFF)
cemuLog_force("RPLLoader: Exhausted TLS module indices pool");
// convert name to path/filename if it isn't already one
if (strstr(name, "."))
if (strchr(name, '.'))
{
strcpy_s(newDependency->filepath, name);
}

View File

@ -10,7 +10,7 @@ template <typename T>
class PPCConcurrentQueue
{
public:
PPCConcurrentQueue() {}
PPCConcurrentQueue() = default;
PPCConcurrentQueue(const PPCConcurrentQueue&) = delete;
PPCConcurrentQueue& operator=(const PPCConcurrentQueue&) = delete;

View File

@ -54,9 +54,7 @@ namespace coreinit
{
}
~OSHostThread()
{
}
~OSHostThread() = default;
OSThread_t* m_thread;
Fiber m_fiber;
@ -1223,7 +1221,7 @@ namespace coreinit
{
struct DeallocatorQueueEntry
{
DeallocatorQueueEntry() {};
DeallocatorQueueEntry() = default;
DeallocatorQueueEntry(OSThread_t* thread, MEMPTR<void> stack, MEMPTR<void> deallocatorFunc) : thread(thread), stack(stack), deallocatorFunc(deallocatorFunc) {};
OSThread_t* thread{};

View File

@ -835,8 +835,11 @@ namespace H264
auto asyncTask = std::async(std::launch::async, _async_H264DECEnd, executeDoneEvent.GetPointer(), session, ctx, &results);
coreinit::OSWaitEvent(executeDoneEvent);
_ReleaseDecoderSession(session);
if (!results.empty())
{
for (auto& itr : results)
H264DoFrameOutputCallback(ctx, itr);
}
return H264DEC_STATUS::SUCCESS;
}

View File

@ -72,7 +72,6 @@ void MetaInfo::ParseDirectory(const fs::path& filename)
bool MetaInfo::ParseFile(const fs::path& filename)
{
const auto extension = filename.extension();
if (filename.filename() != "meta.xml")
return false;

View File

@ -287,7 +287,6 @@ void TitleInfo::CalcUID()
m_uid = 0;
return;
}
std::error_code ec;
// get absolute normalized path
fs::path normalizedPath;
if (m_fullPath.is_relative())

View File

@ -78,9 +78,9 @@ void CafeTitleList::LoadCacheFile()
cacheEntry.titleVersion = titleVersion;
cacheEntry.titleDataFormat = format;
cacheEntry.region = region;
cacheEntry.titleName = name;
cacheEntry.titleName = std::move(name);
cacheEntry.path = _utf8ToPath(path);
cacheEntry.subPath = sub_path;
cacheEntry.subPath = std::move(sub_path);
cacheEntry.group_id = group_id;
cacheEntry.app_type = app_type;
@ -482,7 +482,7 @@ void CafeTitleList::AddTitle(TitleInfo* titleInfo)
}
}
sTLList.emplace_back(titleInfo);
sTLMap.insert(std::pair(titleInfo->GetAppTitleId(), titleInfo));
sTLMap.emplace(titleInfo->GetAppTitleId(), titleInfo);
// send out notification
CafeTitleListCallbackEvent evt;
evt.eventType = CafeTitleListCallbackEvent::TYPE::TITLE_DISCOVERED;

View File

@ -287,7 +287,10 @@ uint8* _fileCache_compressFileData(const uint8* fileData, uint32 fileSize, sint3
Bytef* compressedData = (Bytef*)malloc(4 + compressedLen);
int zret = compress2(compressedData + 4, &compressedLen, uncompressedInput, uncompressedLen, 4); // level 4 has good compression to performance ratio
if (zret != Z_OK)
{
free(compressedData);
return nullptr;
}
compressedData[0] = ((uint32)fileSize >> 24) & 0xFF;
compressedData[1] = ((uint32)fileSize >> 16) & 0xFF;
compressedData[2] = ((uint32)fileSize >> 8) & 0xFF;

View File

@ -967,7 +967,7 @@ void DownloadManager::setPackageError(Package* package, std::string errorMsg)
if (package->state.hasError)
return; // dont overwrite already set error message
package->state.hasError = true;
package->state.errorMsg = errorMsg;
package->state.errorMsg = std::move(errorMsg);
reportPackageStatus(package);
}
@ -1216,7 +1216,6 @@ void DownloadManager::asyncPackageDownloadContentFile(Package* package, uint16 i
void DownloadManager::asyncPackageVerifyFile(Package* package, uint16 index, bool isCheckState)
{
uint8 tmdContentHash[32];
std::string filePathStr;
// get titleId, contentId and file path
std::unique_lock<std::recursive_mutex> _l(m_mutex);
uint64 titleId = package->titleId;

View File

@ -446,7 +446,7 @@ public:
std::unique_lock<std::recursive_mutex> _l(m_mutex);
m_packageList.clear();
m_statusCode = DLMGR_STATUS_CODE::UNINITIALIZED;
m_statusMessage = "";
m_statusMessage.clear();
}
private:

View File

@ -355,7 +355,6 @@ namespace NAPI
std::string_view host = tokenNode.child_value("host");
std::string_view nex_password = tokenNode.child_value("nex_password");
std::string_view pid = tokenNode.child_value("pid");
std::string_view port = tokenNode.child_value("port");
std::string_view token = tokenNode.child_value("token");

View File

@ -360,7 +360,7 @@ namespace NAPI
// ticketVersion starts at 0 and increments every time the ticket is updated (e.g. for AOC content, when purchasing additional DLC packages)
const char* tivValue = tivNode.child_value();
const char* tivValueEnd = tivValue + strlen(tivValue);
const char* tivValueSeparator = std::strstr(tivValue, ".");
const char* tivValueSeparator = std::strchr(tivValue, '.');
if (tivValueSeparator == nullptr)
tivValueSeparator = tivValueEnd;

View File

@ -739,7 +739,7 @@ nexService* nex_establishSecureConnection(uint32 authServerIp, uint16 authServer
return nullptr;
}
// auth info
std::unique_ptr<authServerInfo_t> authServerInfo(new authServerInfo_t);
auto authServerInfo = std::make_unique<authServerInfo_t>();
// decrypt ticket
RC4Ctx_t rc4Ticket;
RC4_initCtx(&rc4Ticket, kerberosKey, 16);

View File

@ -7,10 +7,7 @@
class nexGameKey : public nexType
{
public:
nexGameKey()
{
}
nexGameKey() = default;
nexGameKey(uint64 titleId, uint16 ukn)
{
@ -175,10 +172,9 @@ public:
}
nexPrincipalBasicInfo(uint32 principalId, char* nnid, const nexMiiV2& mii)
: principalId(principalId), mii(mii)
{
this->principalId = principalId;
strcpy(this->nnid, nnid);
this->mii = mii;
}
nexPrincipalBasicInfo(nexPacketBuffer* pb)
@ -218,10 +214,8 @@ public:
}
nexNNAInfo(uint8 countryCode, uint8 countrySubCode, const nexPrincipalBasicInfo& principalBasicInfo)
: countryCode(countryCode), countrySubCode(countrySubCode), principalInfo(principalBasicInfo)
{
this->countryCode = countryCode;
this->countrySubCode = countrySubCode;
this->principalInfo = principalBasicInfo;
}
nexNNAInfo(nexPacketBuffer* pb)
@ -250,10 +244,7 @@ public:
class nexPrincipalPreference : public nexType
{
public:
nexPrincipalPreference()
{
}
nexPrincipalPreference() = default;
nexPrincipalPreference(uint8 ukn0, uint8 ukn1, uint8 ukn2)
{

View File

@ -222,7 +222,7 @@ public:
if (this->currentIndex + bufferLength > this->size)
{
readOutOfBounds = true;
outputStr = std::string("");
outputStr.clear();
return 0;
}
sint32 copiedLength = bufferLength;

View File

@ -43,7 +43,7 @@ class FileStream
void writeLine(const char* str);
~FileStream();
FileStream() {};
FileStream() = default;
private:
FileStream(HANDLE hFile);

View File

@ -557,7 +557,7 @@ void CemuConfig::SetGameListCustomName(uint64 titleId, std::string customName)
return;
gameEntry = CreateGameEntry(titleId);
}
gameEntry->custom_name = customName;
gameEntry->custom_name = std::move(customName);
}
void CemuConfig::AddRecentlyLaunchedFile(std::wstring_view file)

View File

@ -168,7 +168,6 @@ GameProfileWindow::GameProfileWindow(wxWindow* parent, uint64_t title_id)
{
profile_sizer->Add(new wxStaticText(panel, wxID_ANY, fmt::format("{} {}", _("Controller").ToStdString(), (i + 1))), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
wxArrayString m_controller_profileChoices;
m_controller_profile[i] = new wxComboBox(panel, wxID_ANY,"", wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_DROPDOWN| wxCB_READONLY);
m_controller_profile[i]->SetMinSize(wxSize(250, -1));
m_controller_profile[i]->Bind(wxEVT_COMBOBOX_DROPDOWN, &GameProfileWindow::OnControllerProfileDropdown, this);

View File

@ -213,7 +213,6 @@ void GameUpdateWindow::ThreadWork()
create_directories(targetDir);
}
const auto target_path = fs::path(m_target_path);
for (auto& path : m_source_paths)
{
if (m_thread_state == ThreadCanceled)

View File

@ -843,7 +843,7 @@ void GeneralSettings2::StoreConfig()
config.tv_volume = m_tv_volume->GetValue();
config.pad_volume = m_pad_volume->GetValue();
config.tv_device = L"";
config.tv_device.clear();
const auto tv_device = m_tv_device->GetSelection();
if (tv_device != wxNOT_FOUND && tv_device != 0 && m_tv_device->HasClientObjectData())
{
@ -852,7 +852,7 @@ void GeneralSettings2::StoreConfig()
config.tv_device = device_description->GetDescription()->GetIdentifier();
}
config.pad_device = L"";
config.pad_device.clear();
const auto pad_device = m_pad_device->GetSelection();
if (pad_device != wxNOT_FOUND && pad_device != 0 && m_pad_device->HasClientObjectData())
{

View File

@ -343,7 +343,7 @@ void wxTitleManagerList::OnConvertToCompressedFormat(uint64 titleId)
if (!GetConfig().game_paths.empty())
defaultDir = GetConfig().game_paths.front();
// get the short name, which we will use as a suggested default file name
std::string defaultFileName = shortName;
std::string defaultFileName = std::move(shortName);
boost::replace_all(defaultFileName, "/", "");
boost::replace_all(defaultFileName, "\\", "");
@ -474,7 +474,7 @@ void wxTitleManagerList::OnConvertToCompressedFormat(uint64 titleId)
{
std::string temporaryMountPath = TitleInfo::GetUniqueTempMountingPath();
titleInfo->Mount(temporaryMountPath.c_str(), "", FSC_PRIORITY_BASE);
bool r = RecursivelyAddFiles(fmt::format("{:016x}_v{}/", titleInfo->GetAppTitleId(), titleInfo->GetAppTitleVersion()), temporaryMountPath.c_str());
bool r = RecursivelyAddFiles(fmt::format("{:016x}_v{}/", titleInfo->GetAppTitleId(), titleInfo->GetAppTitleVersion()), temporaryMountPath);
titleInfo->Unmount(temporaryMountPath.c_str());
return r;
}

View File

@ -251,7 +251,7 @@ void DumpCtrl::GoToAddressDialog()
m_lastGotoOffset = result;
CenterOffset(result);
}
catch (const std::exception ex)
catch (const std::exception& ex)
{
wxMessageBox(ex.what(), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this);
}

View File

@ -36,7 +36,7 @@ SymbolListCtrl::SymbolListCtrl(wxWindow* parent, const wxWindowID& id, const wxP
Bind(wxEVT_LIST_ITEM_ACTIVATED, &SymbolListCtrl::OnLeftDClick, this);
Bind(wxEVT_LIST_ITEM_RIGHT_CLICK, &SymbolListCtrl::OnRightClick, this);
m_list_filter = "";
m_list_filter.Clear();
OnGameLoaded();
@ -65,7 +65,7 @@ void SymbolListCtrl::OnGameLoaded()
new_entry.first->second.searchName += new_entry.first->second.libName;
new_entry.first->second.searchName.MakeLower();
if (m_list_filter == "")
if (m_list_filter.IsEmpty())
new_entry.first->second.visible = true;
else if (new_entry.first->second.searchName.Contains(m_list_filter))
new_entry.first->second.visible = true;
@ -149,7 +149,7 @@ void SymbolListCtrl::ChangeListFilter(std::string filter)
size_t visible_entries = m_data.size();
for (auto& [address, symbol] : m_data)
{
if (m_list_filter == "")
if (m_list_filter.IsEmpty())
symbol.visible = true;
else if (symbol.searchName.Contains(m_list_filter))
symbol.visible = true;

View File

@ -11,7 +11,7 @@ public:
void ChangeListFilter(std::string filter);
private:
struct SymbolItem {
SymbolItem() {}
SymbolItem() = default;
SymbolItem(wxString name, wxString libName, wxString searchName, bool visible) : name(name), libName(libName), searchName(searchName), visible(visible) {}

View File

@ -568,8 +568,6 @@ void InputSettings2::on_profile_text_changed(wxCommandEvent& event)
auto& page_data = get_current_page_data();
const auto selection = page_data.m_emulated_controller->GetStringSelection();
// load_bttn, save_bttn, delete_bttn, profile_status
const auto text = event.GetString();
const auto text_str = from_wxString(text);

View File

@ -189,7 +189,7 @@ public:
// update provider if settings are different from default provider
void update_provider(std::shared_ptr<TProvider> provider)
{
m_provider = provider;
m_provider = std::move(provider);
}
protected:

View File

@ -104,9 +104,7 @@ struct Quat
class MotionSample
{
public:
MotionSample()
{
}
MotionSample() = default;
MotionSample(float acc[3], float accAcceleration, float gyro[3], float orientation[3],
float quaternion[4]

View File

@ -289,7 +289,7 @@ namespace ZpIR
// IR register constant definition stored in basic block
struct IRRegConstDef
{
IRRegConstDef() {};
IRRegConstDef() = default;
// todo - support for constants with more than one element?
IRRegConstDef& setU32(uint32 v) { value_u32 = v; type = DataType::U32; return *this; };
@ -513,7 +513,7 @@ namespace ZpIR
LOC_TYPE_ATTRIBUTE = 3,
};
public:
ShaderImportLocation() {}
ShaderImportLocation() = default;
ShaderImportLocation(LocationSymbolName loc)
{
uint64 v = (uint64)loc;
@ -598,7 +598,7 @@ namespace ZpIR
LOC_TYPE_OUTPUT = 2,
};
public:
ShaderExportLocation() {}
ShaderExportLocation() = default;
ShaderExportLocation(LocationSymbolName loc)
{
uint64 v = (uint64)loc;

View File

@ -12,9 +12,7 @@ class DualStringBuffer
public:
DualStringBuffer() : m_offsetBegin(N / 2), m_offsetEnd(N / 2) { }
~DualStringBuffer()
{
}
~DualStringBuffer() = default;
static_assert(sizeof(char) == sizeof(uint8));

View File

@ -15,7 +15,7 @@ class IntervalBucketContainer
public:
IntervalBucketContainer() {};
IntervalBucketContainer() = default;
// range is defined as inclusive rangeStart and exclusive rangeEnd
void addRange(TAddr rangeStart, TAddr rangeEnd, TData* data)

View File

@ -13,10 +13,7 @@ public:
size_t lastIterationIndex;
}rangeEntry_t;
RangeStore()
{
}
RangeStore() = default;
size_t getBucket(_ADDR addr)
{

View File

@ -6,7 +6,7 @@ template<size_t N>
class SmallBitset
{
public:
SmallBitset() {};
SmallBitset() = default;
static_assert(N <= 32);
bool test(size_t index) const

View File

@ -166,9 +166,7 @@ namespace ska
: distance_from_desired(distance_from_desired)
{
}
~sherwood_v3_entry()
{
}
~sherwood_v3_entry() = default;
static sherwood_v3_entry* empty_default_table()
{
static sherwood_v3_entry result[min_lookups] = { {}, {}, {}, {special_end_value} };
@ -297,9 +295,7 @@ namespace ska
using pointer = value_type*;
using const_pointer = const value_type*;
sherwood_v3_table()
{
}
sherwood_v3_table() = default;
explicit sherwood_v3_table(size_type bucket_count, const ArgumentHash& hash = ArgumentHash(), const ArgumentEqual& equal = ArgumentEqual(), const ArgumentAlloc& alloc = ArgumentAlloc())
: EntryAlloc(alloc), Hasher(hash), Equal(equal)
{
@ -1324,9 +1320,7 @@ namespace ska
using mapped_type = V;
using Table::Table;
flat_hash_map()
{
}
flat_hash_map() = default;
inline V& operator[](const K& key)
{
@ -1442,9 +1436,7 @@ namespace ska
using key_type = T;
using Table::Table;
flat_hash_set()
{
}
flat_hash_set() = default;
template<typename... Args>
std::pair<typename Table::iterator, bool> emplace(Args &&... args)