Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,12 @@ void decideImportWatch(const Context& context, HostImports& state) {
#endif
}

#ifdef _WIN32
bool settlesPrivateImports(const Context& context, const HostImports& state) {
return state.watchPrivateImports && context.settleQueue != VK_NULL_HANDLE && context.settleQueueMutex != nullptr;
}
#endif

struct ImportWatching {
bool settled = false;
bool hostPointer = false;
Expand All @@ -1666,7 +1672,7 @@ struct ImportWatching {
ImportWatching importWatching(const Context& context, HostImports& state, bool alias, bool writable, std::uint64_t bytes) {
decideImportWatch(context, state);
#ifdef _WIN32
const bool settled = !alias && state.watchPrivateImports && writable && bytes >= PrivateSettleFloorBytes();
const bool settled = !alias && settlesPrivateImports(context, state) && writable && bytes >= PrivateSettleFloorBytes();
const bool watched = alias || !state.unwatchImports || settled;
return {settled, watched, watched};
#else
Expand Down Expand Up @@ -2761,7 +2767,7 @@ const HostImport* importRunAt(const Context& context, HostImports& state, Import
entry.lastUse = ++state.useCounter;
state.pendingImports.insert(base);
#ifdef _WIN32
if (deferredSettles.load(std::memory_order_relaxed) && entry.alias == nullptr && state.watchPrivateImports && writable) {
if (deferredSettles.load(std::memory_order_relaxed) && entry.alias == nullptr && settlesPrivateImports(context, state) && writable) {
if (entry.unwatched) {
state.pendingSettles.insert_or_assign(base, PendingSettle{});
state.settleWanted.push_back(base);
Expand Down
21 changes: 21 additions & 0 deletions core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2703,6 +2703,27 @@ bool deferredSettleTests(const Device& device) {
unregisterRange(pair);
HostImportFor(context, pairAddress, pairBytes);
}
{
constexpr std::size_t pairBytes = 2 * unit;
void* pair = AllocateWatched(pairBytes, unit);
struct ReleasePair {
void* pair;
~ReleasePair() { ReleaseWatched(pair, pairBytes); }
} releasePair{pair};
const auto pairAddress = reinterpret_cast<std::uint64_t>(pair);
auto queueless = context;
queueless.settleQueue = VK_NULL_HANDLE;
queueless.settleQueueMutex = nullptr;
const auto settledBefore = HostImportsSettled();
const auto submittedBefore = HostImportSettles().submitted;
registerRange(pair, pairBytes);
const auto* pairImport = HostImportFor(queueless, pairAddress, pairBytes);
Require(pairImport != nullptr && pairImport->unwatched && !Watched(pairAddress, pairBytes), "(d) a 128 KiB import through a context with no settle queue was not left compared");
HostImportFor(queueless, pairAddress, pairBytes);
Require(HostImportsSettled() == settledBefore && HostImportSettles().submitted == submittedBefore, "(d) an import through a context with no settle queue was settled");
unregisterRange(pair);
HostImportFor(queueless, pairAddress, pairBytes);
}
const auto address = reinterpret_cast<std::uint64_t>(small);
std::memset(small, 0x11, unit);
registerRange(small, unit);
Expand Down
5 changes: 5 additions & 0 deletions docs/dev/debt/changes/agc-settle-without-settle-queue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# libSceAgcDriver

## add Functional

- [Host import watch decision outlives its device](../../../core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp) (libSceAgcDriver) - `decideImportWatch` keeps its decision under the `VkDevice` handle and `ClearHostImports` does not drop it, so a device created at the handle of a destroyed one inherits that device's decision without a probe of its own. A context with no settle queue does not settle under an inherited decision; the inherited choice between watching and comparing, and the dma-buf selection on Linux, are still taken as they are. Seen on Windows with AMD 26.11.2, where the bare device of `agc_driver_native_multisample_depth` got the handle of the last driver device in 12 of 40 runs