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 @@ -41,6 +41,7 @@ class DrawPipeline {
bool Overlaps(std::uint64_t address, std::size_t bytes);
std::optional<std::uint64_t> PendingLabel(std::uint64_t address, std::size_t bytes);
static bool HeldReads(std::uint64_t address, std::size_t bytes);
static std::uint64_t HeldReadQueries();
void ReleaseRunningReads();

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ bool DrawPipeline::HeldReads(std::uint64_t address, std::size_t bytes) {
return false;
}

std::uint64_t DrawPipeline::HeldReadQueries() {
return heldReadQueries.load(std::memory_order_relaxed);
}

void DrawPipeline::ReleaseRunningReads() {
std::lock_guard lock(mutex);
if (!items.empty()) items.front().reads.clear();
Expand Down
12 changes: 12 additions & 0 deletions core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3670,6 +3670,18 @@ bool StorageTexture::pendingUnitInside(std::uint64_t address, std::size_t bytes)
bool StorageTexture::FlushPending(std::uint64_t address, std::size_t bytes, const StorageTexture* except, const char* reason, PublishScope scope, bool* published) {
static_cast<void>(FlushDepthPlanes(address, bytes));
if (published != nullptr) *published = false;
const auto nothingToStore = [&] {
auto& pending = Pending();
if (pending.flushingCount.load(std::memory_order_acquire) != 0) return false;
if (!pending.textures.SurelyClear(address, bytes)) {
std::lock_guard lock(pending.mutex);
const auto* exempt = refreshing;
if (pending.textures.MayOverlap(address, bytes) && std::any_of(pending.textures.begin(), pending.textures.end(), [&](const StorageTexture* texture) { return texture != except && texture != exempt && texture->overlaps(address, bytes) && texture->pendingUnitInside(address, bytes); })) return false;
if (pending.flushingCount.load(std::memory_order_acquire) != 0) return false;
}
return scope == PublishScope::None || !AnyShadowedOverlaps(address, bytes);
};
if (nothingToStore()) return false;
if (AgcDriver::DriverDetail::DrawPipeline::HeldReads(address, bytes)) {
queuedReadHeld.fetch_add(1, std::memory_order_relaxed);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,11 @@ int main() {
AgcDriverWaitIdle_nid_postfix();
Require(AgcDriver::Graphics::StorageTexture::AnyPending(), "queued index read: the image write left no pending result to order against");
Require(IndicesIntact(), "queued index read: the image's results reached guest memory before any consumer asked");
const auto copiedAddress = static_cast<std::uint64_t>(reinterpret_cast<std::uintptr_t>(Copied));
const auto heldQueries = AgcDriver::DriverDetail::DrawPipeline::HeldReadQueries();
Require(!AgcDriver::Graphics::StorageTexture::FlushPending(copiedAddress, PoolBytes), "queued index read: a flush over memory without pending results stored something");
Require(AgcDriver::DriverDetail::DrawPipeline::HeldReadQueries() == heldQueries, "queued index read: a flush with nothing to store asked the draw pipeline for held reads");
Require(IndicesIntact(), "queued index read: a flush over other memory stored the image's results");
GateUntilQueued();
std::fill_n(ColorMemory, ColorBytes, std::byte{0});
Submit(Draw(Vertices.data(), Vertices.size()), "the indexed draw");
Expand Down
Loading