mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
fix(agc): forget a DCC key fill once a refresh sees other keys
StorageTexture::MarkDirty skips the first write's uncompressed key store while the image's filledKeys holds a clear code, and only an upload or clearByKeysFill reset that fill. After a 0001 key fill, a kernel storing 0000 over the keys and a storage write, the refresh of write-watched memory read 0000, the keys the image was uploaded under, so it did not upload again and kept the stale 0001. The write then left the 0000 keys in memory, and a kernel reading them saw the clear colour. StorageTexture::ProvedKeys, the key read of Refresh and the fast revalidation, now forgets the fill when it reads other keys while the image has no results pending. An image with pending results keeps it, since its write-backs treat those results as killed by that fill.
This commit is contained in:
@@ -422,7 +422,7 @@ private:
|
||||
std::vector<std::byte> original;
|
||||
// DCC keys the image content was uploaded under: a fast-cleared surface starts as its clear value.
|
||||
DccKeys uploadedKeys = DccKeys::Uncompressed;
|
||||
DccKeys filledKeys = DccKeys::Uncompressed;
|
||||
mutable DccKeys filledKeys = DccKeys::Uncompressed;
|
||||
mutable DccKeyProof keyProof;
|
||||
struct ForeignKeyProof {
|
||||
std::uint64_t dccAddress = 0;
|
||||
|
||||
@@ -1324,13 +1324,12 @@ bool StorageTexture::Refresh() {
|
||||
}
|
||||
|
||||
DccKeys StorageTexture::ProvedKeys() const {
|
||||
if (descriptor.dccAddress != 0 && uploadedKeys == DccKeys::Uncompressed) {
|
||||
if (const auto keys = WaitForKeyWriters(descriptor, guestBytes)) {
|
||||
keyProof = {};
|
||||
return *keys;
|
||||
}
|
||||
}
|
||||
return ProvedClearKeys(descriptor, guestBytes, keyProof);
|
||||
std::optional<DccKeys> keys;
|
||||
if (descriptor.dccAddress != 0 && uploadedKeys == DccKeys::Uncompressed) keys = WaitForKeyWriters(descriptor, guestBytes);
|
||||
if (keys.has_value()) keyProof = {};
|
||||
else keys = ProvedClearKeys(descriptor, guestBytes, keyProof);
|
||||
if (IsDccClear(filledKeys) && *keys != filledKeys && !anyLayerPending()) filledKeys = DccKeys::Uncompressed;
|
||||
return *keys;
|
||||
}
|
||||
|
||||
bool StorageTexture::ServesKeysAt(std::uint64_t dccAddress) const {
|
||||
|
||||
@@ -268,6 +268,24 @@ void Run(AgcDriver::VulkanDevice& device, std::uint8_t* block) {
|
||||
StorageTexture::FlushPending(surface, SurfaceBytes, nullptr, "test");
|
||||
device.WaitIdle();
|
||||
requireTexels("a first write followed by a kernel's 0000 store over half the keys");
|
||||
fillKeys(0x00, DccKeys::Clear0000);
|
||||
image->Refresh();
|
||||
Require(image->UploadedKeys() == DccKeys::Clear0000 && image->FilledKeys() == DccKeys::Uncompressed, "the refresh after a 0000 key fill did not clear the image");
|
||||
fillKeys(0x40, DccKeys::Clear0001);
|
||||
Require(image->FilledKeys() == DccKeys::Clear0001, "the 0001 key fill over the cleared image was not noted on it");
|
||||
Dispatch(device, ClearKeysCode, clearData);
|
||||
const auto overFill = image->ProvedKeys();
|
||||
std::snprintf(message, sizeof(message), "a key read after a kernel's 0000 store over a 0001 key fill: the keys read %s and the image keeps a %s fill (expected 0000 and none)", AgcDriver::Graphics::DccKeysName(overFill), AgcDriver::Graphics::DccKeysName(image->FilledKeys()));
|
||||
Require(overFill == DccKeys::Clear0000 && image->FilledKeys() == DccKeys::Uncompressed, message);
|
||||
std::memset(copied, 0xaa, KeyBytes);
|
||||
fillKeys(0x40, DccKeys::Clear0001);
|
||||
Dispatch(device, ClearKeysCode, clearData);
|
||||
Dispatch(device, WriteCode, writeData);
|
||||
Dispatch(device, CopyKeysCode, copyData);
|
||||
RequireKeys(copied, 0xff, "a kernel reading the keys after a 0001 key fill, a kernel's 0000 store over them and a write");
|
||||
StorageTexture::FlushPending(surface, SurfaceBytes, nullptr, "test");
|
||||
device.WaitIdle();
|
||||
requireTexels("a write after a 0001 key fill and a kernel's 0000 store over the keys");
|
||||
const auto fill = [&](std::size_t offset, std::size_t bytes, std::uint8_t key) {
|
||||
const std::uint32_t word = key * 0x01010101u;
|
||||
const std::array<std::uint32_t, 4> pattern{word, word, word, word};
|
||||
|
||||
Reference in New Issue
Block a user