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
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ struct HostImports {
std::map<std::uint64_t, ImportFailure> failedJoins;
std::map<std::uint64_t, std::uint64_t> sparseRunEnds;
std::map<std::uint64_t, std::uint32_t> sparseRunJoins;
std::set<std::pair<std::uint64_t, std::size_t>> importedAtMap;
std::map<std::pair<std::uint64_t, std::uint64_t>, ImportFailure> failedBlocks;
std::map<std::pair<std::uint64_t, std::uint64_t>, ImportRefusal> refusals;
std::map<std::pair<std::uint64_t, std::uint64_t>, EvictingRefusal> evictingRefusals;
Expand Down Expand Up @@ -1991,6 +1992,7 @@ void refreshImports(const Context& context, HostImports& state, const GuestAlloc
state.reportNoted = 0;
state.sparseRunEnds.clear();
state.sparseRunJoins.clear();
state.importedAtMap.clear();
state.device = context.device;
state.destroyBuffer = context.Function<PFN_vkDestroyBuffer>("vkDestroyBuffer");
state.freeMemory = context.Function<PFN_vkFreeMemory>("vkFreeMemory");
Expand Down Expand Up @@ -3119,6 +3121,7 @@ void ClearHostImports(VkDevice device) {
auto& state = Imports();
std::lock_guard lock(state.mutex);
state.parked.erase(device);
state.importedAtMap.clear();
#ifdef _WIN32
if (device == state.device) drainSettles(state);
#endif
Expand Down Expand Up @@ -3545,6 +3548,7 @@ bool ImportMappedRanges(const Context& context, const GuestAllocations::Mapped&
const std::array<std::pair<std::uint64_t, std::uint64_t>, 1> span{{{run.base, run.base + run.bytes}}};
if (wouldRetireImport(state, run) || StorageTexture::AnyPendingOverlaps(span)) return false;
}
if (!state.importedAtMap.emplace(range->address, range->bytes).second && findImport(state, range->address, range->address + range->bytes) == nullptr) continue;
importAllocation(context, state, range->address, current, ImportRequester::Map, 0, false);
} catch (const std::exception& error) {
std::fprintf(stderr, "[gpu] import of GPU memory mapped at 0x%llx+0x%zx failed: %s\n", static_cast<unsigned long long>(range->address), range->bytes, error.what());
Expand Down
6 changes: 5 additions & 1 deletion core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,8 +840,10 @@ void importMappedFailureGenerationTests(const Context& context) {
{
std::lock_guard gpu(AgcDriver::GuestMemory::GpuMutex());
Require(ImportMappedRanges(range.importing, mapped, GuestAllocations::GuestAllocationsGeneration_nid_postfix(), true), "the replacement owner map import was deferred");
Require(probe.calls.size() == 2u, "a replacement owner did not retry its predecessor's failed import");
Require(probe.calls.size() == 1u, "a replacement owner was imported again at map instead of on first use");
}
HostImportFor(range.importing, range.First(), range.bytes);
Require(probe.calls.size() == 2u, "a replacement owner did not retry its predecessor's failed import on first use");
ClearHostImports(context.device);
}

Expand Down Expand Up @@ -979,6 +981,7 @@ void importNeighbouringEdgesTests(const Context& context) {
// A range mapped while the imports are at the budget is refused at map time without retiring an import: the map
// observer holds no GPU lock, so it must not evict (before, it evicted the least recently used import to fit).
void importAtMapOverBudgetTests(const Context& context) {
ClearHostImports(context.device);
constexpr std::size_t bytes = 65536;
auto importing = context;
importing.hostImportAlignment = bytes;
Expand Down Expand Up @@ -1023,6 +1026,7 @@ void importAtMapOverBudgetTests(const Context& context) {
}

void importRequesterTests(const Context& context, const BdaTestAccess& access) {
ClearHostImports(context.device);
constexpr std::size_t piece = 65536;
constexpr std::size_t pieces = 8;
auto* block = static_cast<std::uint8_t*>(::operator new(pieces * piece, std::align_val_t{piece}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,13 @@ int main() {
remapped.Unregister();
remapped.Register();
Import(*device, remapped.Ranges());
Require(Imported(handle, remapped.Address(), AllocationBytes), "host import at map: a range mapped again was not imported");
Require(!Imported(handle, remapped.Address(), AllocationBytes), "host import at map: a range mapped again was imported at map instead of on first use");
{
std::lock_guard lock(AgcDriver::GuestMemory::GpuMutex());
const std::array<std::uint32_t, 4> pattern{9u, 10u, 11u, 12u};
Require(device->FillBuffer(remapped.Address(), BlockBytes, pattern), "host import at map: the first use of a range mapped again was not imported");
device->WaitIdle();
}
GuestAllocation gone;
const auto goneRanges = gone.Ranges();
gone.Unregister();
Expand Down
Loading