mirror of
https://github.com/libretro/parallel-gx1.git
synced 2026-11-10 17:26:25 -10:00
- CommandProcessor: the FIFO registers shared by the CPU and GPU threads are retro_atomic words, read and written through LoadReg and StoreReg; MMIO's LowPart/HighPart take those words. - Fifo: the video buffer write and seen pointers, the sync ticks and the stop request. - PerfQueryBase: the query count and results sit behind base-class helpers that every backend (Metal too) uses instead of touching the atomics. - Custom assets: the loader's memory delta and an asset's last load time are 64-bit words; Present's swap flag is an int. - D3D's input layout, Vulkan's waiting_for_submit. - InputCommon: a NumericSetting's value and the Wiimote and Android rumble levels are kept as their bits in a 64-bit word; the ControllerInterface flags, counter and aspect ratio are int words. - CachedBlob's fill position and stop flag. UICommon/GameFileCache is deleted: only the Android app's game list used it, and that is not part of the core.
69 lines
1.9 KiB
C++
69 lines
1.9 KiB
C++
// Copyright 2023 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include "VideoCommon/Assets/CustomAsset.h"
|
|
|
|
#include <utility>
|
|
|
|
namespace VideoCommon
|
|
{
|
|
CustomAsset::CustomAsset(std::shared_ptr<CustomAssetLibrary> library,
|
|
CustomAssetLibrary::AssetID asset_id, u64 asset_handle)
|
|
: m_owning_library(std::move(library)), m_asset_id(std::move(asset_id)), m_handle(asset_handle)
|
|
{
|
|
}
|
|
|
|
quiesce_t* CustomAsset::DataQuiesce()
|
|
{
|
|
static quiesce_t s_quiesce;
|
|
return &s_quiesce;
|
|
}
|
|
|
|
std::size_t CustomAsset::Load()
|
|
{
|
|
if (!retro_atomic_cas_int(&m_busy, 0, 1))
|
|
return 0;
|
|
// The load time needs to come from before the data is actually read.
|
|
// Using a time point from after the read marks the asset as more up-to-date than it actually is,
|
|
// and has potential to race (and not be updated) if a change happens immediately after load.
|
|
const auto load_time = ClockType::now();
|
|
|
|
const auto load_information = LoadImpl(m_asset_id);
|
|
if (load_information.bytes_loaded > 0)
|
|
{
|
|
m_bytes_loaded = load_information.bytes_loaded;
|
|
retro_atomic_store_release_64(&m_last_loaded_time, load_time.time_since_epoch().count());
|
|
retro_atomic_store_release_int(&m_busy, 0);
|
|
return load_information.bytes_loaded;
|
|
}
|
|
retro_atomic_store_release_int(&m_busy, 0);
|
|
return 0;
|
|
}
|
|
|
|
std::size_t CustomAsset::Unload()
|
|
{
|
|
if (!retro_atomic_cas_int(&m_busy, 0, 1))
|
|
return 0;
|
|
UnloadImpl();
|
|
const std::size_t unloaded = std::exchange(m_bytes_loaded, 0);
|
|
retro_atomic_store_release_int(&m_busy, 0);
|
|
return unloaded;
|
|
}
|
|
|
|
CustomAsset::TimeType CustomAsset::GetLastLoadedTime() const
|
|
{
|
|
return TimeType(ClockType::duration(retro_atomic_load_acquire_64(&m_last_loaded_time)));
|
|
}
|
|
|
|
std::size_t CustomAsset::GetHandle() const
|
|
{
|
|
return m_handle;
|
|
}
|
|
|
|
const CustomAssetLibrary::AssetID& CustomAsset::GetAssetId() const
|
|
{
|
|
return m_asset_id;
|
|
}
|
|
|
|
} // namespace VideoCommon
|