mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-24 12:56:53 +02:00
shader: track buffer liveness and offsets by resource count
Co-authored-by: fxpw <fxpw@outlook.com>
This commit is contained in:
@@ -18,7 +18,7 @@ namespace {
|
||||
}
|
||||
|
||||
void ValidateNativeProgram(const IR::Program& program, bool lds_storage) {
|
||||
uint64_t live_buffers = 0;
|
||||
std::vector<bool> live_buffers(program.info.buffers.size());
|
||||
bool uses_lds = false;
|
||||
bool uses_gds = false;
|
||||
const auto uses_mapping = [](const auto& resource) {
|
||||
@@ -85,12 +85,12 @@ void ValidateNativeProgram(const IR::Program& program, bool lds_storage) {
|
||||
if (memory.resource >= program.info.buffers.size()) {
|
||||
Fail(program, "typed shader contains an invalid buffer resource");
|
||||
}
|
||||
live_buffers |= uint64_t{1} << memory.resource;
|
||||
live_buffers[memory.resource] = true;
|
||||
for (const auto child: program.info.buffers[memory.resource].indirect_resources) {
|
||||
if (child >= program.info.buffers.size()) {
|
||||
Fail(program, "typed shader contains an invalid indirect buffer resource");
|
||||
}
|
||||
live_buffers |= uint64_t{1} << child;
|
||||
live_buffers[child] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,8 +149,9 @@ void ValidateNativeProgram(const IR::Program& program, bool lds_storage) {
|
||||
std::array<uint32_t, static_cast<size_t>(Kind::Count)> expected {};
|
||||
auto& buffer_count = expected[static_cast<size_t>(Kind::Buffers)];
|
||||
for (uint32_t index = 0; index < program.info.buffers.size(); ++index) {
|
||||
const auto slot = (live_buffers & (uint64_t{1} << index)) != 0 ? buffer_count++ : UINT32_MAX;
|
||||
if (program.info.buffers[index].descriptor_index != slot) {
|
||||
const auto slot = live_buffers[index] ? buffer_count++ : UINT32_MAX;
|
||||
if (program.info.buffers[index].live != live_buffers[index] ||
|
||||
program.info.buffers[index].descriptor_index != slot) {
|
||||
Fail(program, "native buffer descriptor index does not match shader topology");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user