mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
Merge pull request #1288 from Celegans12/fix/agc-dcc-filled-keys-refresh
fix(agc): forget a DCC key fill once a refresh sees other keys
This commit is contained in:
@@ -427,7 +427,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;
|
||||
|
||||
@@ -1435,13 +1435,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