test(shader): cover the operand-less decoding of v_nop, v_pipeflush and v_clrexcp

The VOP3 form of v_nop now decodes without operands, and no test looked at
it. agc_vop1_control_decode decodes the three instructions in VOP1 and VOP3
form and checks the opcode, the length, the null destination and the absence
of sources. agc_driver_vop1_control also runs v_nop in both forms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DotDebian
2026-10-02 17:50:53 +02:00
parent e8e5518c04
commit d7d36193db
3 changed files with 51 additions and 4 deletions
+6 -1
View File
@@ -220,6 +220,11 @@ target_link_libraries(agc_dpp_write_tests PRIVATE shader_recompiler_agc_driver l
set_target_properties(agc_dpp_write_tests PROPERTIES CXX_EXTENSIONS OFF)
configure_windows_unwind(agc_dpp_write_tests)
add_test_executable(agc_vop1_control_decode_tests EXCLUDE_FROM_ALL tests/Vop1ControlDecode.cpp)
target_link_libraries(agc_vop1_control_decode_tests PRIVATE shader_recompiler_agc_driver libc)
set_target_properties(agc_vop1_control_decode_tests PROPERTIES CXX_EXTENSIONS OFF)
configure_windows_unwind(agc_vop1_control_decode_tests)
add_test_executable(agc_shader_disk_cache_tests EXCLUDE_FROM_ALL tests/ShaderDiskCache.cpp)
target_include_directories(agc_shader_disk_cache_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(agc_shader_disk_cache_tests PRIVATE shader_recompiler_agc_driver libc)
@@ -411,7 +416,7 @@ foreach(agcExecutionTestSource IN LISTS agcExecutionTestSources)
endforeach()
if(BUILD_TESTING)
foreach(agcTest IN ITEMS agc_driver_tests agc_shader_memory_tests agc_structurizer_tests agc_dpp_write_tests agc_shader_disk_cache_tests agc_shader_control_flow_tests agc_driver_flip_tests agc_driver_pm4_tests agc_driver_graphics_tests ${agcExecutionTests})
foreach(agcTest IN ITEMS agc_driver_tests agc_shader_memory_tests agc_structurizer_tests agc_dpp_write_tests agc_vop1_control_decode_tests agc_shader_disk_cache_tests agc_shader_control_flow_tests agc_driver_flip_tests agc_driver_pm4_tests agc_driver_graphics_tests ${agcExecutionTests})
string(REGEX REPLACE "_tests$" "" agcTestName "${agcTest}")
set_target_properties(${agcTest} PROPERTIES EXCLUDE_FROM_ALL OFF)
add_test(NAME ${agcTestName} COMMAND ${agcTest})
@@ -0,0 +1,42 @@
#include "RdnaDecoder/RdnaInstructionDecoder.hpp"
#include <array>
#include <cstdio>
#include <exception>
#include <vector>
using namespace ShaderRecompiler;
int main() {
const std::vector<std::uint32_t> code{
0x7e000000u, 0x7e003600u, 0x7e008200u,
0xd5800000u, 0x00000000u, 0xd59b0000u, 0x00000000u, 0xd5c10000u, 0x00000000u,
0xbf810000u,
};
constexpr std::array expected{
RdnaOpcode::VNop, RdnaOpcode::VPipeflush, RdnaOpcode::VClrexcp,
RdnaOpcode::VNop, RdnaOpcode::VPipeflush, RdnaOpcode::VClrexcp,
};
try {
const auto decoded = RdnaInstructionDecoder{}.Decode(code);
if (decoded.instructions.size() != expected.size() + 1u) {
std::fprintf(stderr, "decoded %zu instructions, expected %zu\n", decoded.instructions.size(), expected.size() + 1u);
return 1;
}
for (std::size_t index = 0; index < expected.size(); ++index) {
const auto& instruction = decoded.instructions[index];
const auto wordCount = index < 3u ? 1u : 2u;
if (instruction.op != expected[index] || instruction.wordCount != wordCount) {
std::fprintf(stderr, "instruction %zu decodes to the wrong opcode or length\n", index);
return 1;
}
if (instruction.destination.kind != RdnaOperandKind::Null || instruction.sourceCount != 0u) {
std::fprintf(stderr, "instruction %zu decodes with operands\n", index);
return 1;
}
}
return 0;
} catch (const std::exception& error) {
std::fprintf(stderr, "%s\n", error.what());
}
return 1;
}
@@ -20,9 +20,9 @@ constexpr std::uint32_t Stride = 4;
alignas(256) std::array<std::uint32_t, Threads * Stride> Input{};
alignas(256) std::array<std::uint32_t, Threads * Stride> Output{};
alignas(256) constexpr std::array<std::uint32_t, 14> Vop1ControlCode{
0x34020082, 0xe0302000, 0x80000401, 0xbf8c3f70, 0x7e003600, 0x7e008200, 0x4a080881,
0xd59b0000, 0x00000000, 0xd5c10000, 0x00000000, 0xe0702000, 0x80010401, 0xbf810000,
alignas(256) constexpr std::array<std::uint32_t, 17> Vop1ControlCode{
0x34020082, 0xe0302000, 0x80000401, 0xbf8c3f70, 0x7e000000, 0x7e003600, 0x7e008200, 0x4a080881,
0xd5800000, 0x00000000, 0xd59b0000, 0x00000000, 0xd5c10000, 0x00000000, 0xe0702000, 0x80010401, 0xbf810000,
};
std::array<std::uint32_t, 4> BufferDescriptor(const void* data, std::uint32_t count) {