fix(shader): avoid mixing ir block ids with metadata indices

This commit is contained in:
boykopovar
2026-09-23 13:57:22 +03:00
parent bbde0f4680
commit b1722c06e3
2 changed files with 30 additions and 14 deletions
+6 -6
View File
@@ -8,14 +8,14 @@ Releases will be published after the first full successful launch of at least on
## Status
Execution reaches `_start`, stack unwinding and exception handling tables are built. All unimplemented functions throw std::runtime_error. `what()` is printed to stderr and the process terminates.
Audio output and video output initialization pass.
Reaches the `main` function with render loop (deep call chain, ~64KB stack frame function) - init and shader loading from disk fully complete.
Execution reaches `_start`, [stack unwinding](core/libs/prx/libc/src/exception/Unwind.cpp) and exception handling tables are built, reaches main. Unsupported or unexpected states strictly throw `std::runtime_error`. `what()` is printed to stderr and the process terminates.
A standalone [SPIR-V triangle test](core/libs/prx/libSceAgcDriver/tests/Visual.cpp) passes GPU readback checks and presents a frame through the [libSceAgcDriver](core/libs/prx/libSceAgcDriver).
The [shader recompiler](core/shader/recompiler/Recompiler.cpp) successfully produces validated via [Spirv-Tools](3rdparty/SPIRV-Tools) SPIR-V. The first application draw currently stops in [libSceAgcDriver](core/libs/prx/libSceAgcDriver), where support for shaders using textures is not implemented.
The [shader recompiler](core/shader/recompiler/Recompiler.cpp) successfully produces validated via [Spirv-Tools](3rdparty/SPIRV-Tools) SPIR-V.
The application reaches the render loop and **successfully presents its first frame**: the application logo is visible on screen.
Current exception: `AGC graphics: unsupported primitive type 17`.
Now: `libSceAgcDriver: TextureDetiler not implemented`.
## Build
@@ -33,21 +33,37 @@ void EmitKillIfPixelValidMaskInactive(SpirvEmitterState& state) {
}
const IrBlock* TargetBlock(const IrProgram& program, std::uint32_t id) {
for (const IrBlock* block : program.BlockOrder()) {
if (block != nullptr && block->Id() == id) {
return block;
const auto& blocks = program.BlockOrder();
const auto& blockInfo = program.Metadata().blockInfo;
if (blocks.size() != blockInfo.size()) {
throw std::runtime_error("SPIR-V control flow block metadata is inconsistent");
}
for (std::size_t index = 0; index < blockInfo.size(); index++) {
if (blockInfo[index].id == id) {
if (blocks[index] == nullptr) {
throw std::runtime_error("SPIR-V control flow target block is null");
}
return blocks[index];
}
}
return nullptr;
throw std::runtime_error("SPIR-V control flow target block is missing");
}
const BlockInfo* BlockInfoFor(const IrProgram& program, const IrBlock* block) {
for (const BlockInfo& info : program.Metadata().blockInfo) {
if (info.id == block->Id()) {
return &info;
const auto& blocks = program.BlockOrder();
const auto& blockInfo = program.Metadata().blockInfo;
if (blocks.size() != blockInfo.size()) {
throw std::runtime_error("SPIR-V control flow block metadata is inconsistent");
}
if (block == nullptr) {
throw std::runtime_error("SPIR-V control flow block is null");
}
for (std::size_t index = 0; index < blocks.size(); index++) {
if (blocks[index] == block) {
return &blockInfo[index];
}
}
return nullptr;
throw std::runtime_error("SPIR-V control flow block has no metadata");
}
void EmitReturnTerminator(SpirvValueEmitContext& ctx) {