test(shader): cover 64-bit scalar bit-count ops
This commit is contained in:
parent
7d40a57d18
commit
51c5e00ba9
|
|
@ -625,6 +625,14 @@ if(BUILD_TESTING)
|
|||
set_tests_properties(scalar_saveexec PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
add_test_executable(scalar_bitcount64_tests ${LIBS_INCLUDE_DIR}/tests/ScalarBitCount64.cpp)
|
||||
target_link_libraries(scalar_bitcount64_tests PRIVATE shader_recompiler_agc_driver libc)
|
||||
configure_windows_unwind(scalar_bitcount64_tests)
|
||||
add_test(NAME scalar_bitcount64 COMMAND scalar_bitcount64_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(scalar_bitcount64 PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
add_test_executable(image_sample_gather_tests ${LIBS_INCLUDE_DIR}/tests/ImageSampleGather.cpp)
|
||||
target_link_libraries(image_sample_gather_tests PRIVATE shader_recompiler_agc_driver libc)
|
||||
configure_windows_unwind(image_sample_gather_tests)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
#include "Translation/TranslationContext.hpp"
|
||||
#include "RdnaDecoder/RdnaScalarOpDecoder.hpp"
|
||||
#include <array>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace ShaderRecompiler;
|
||||
static void Require(bool value) { if (!value) throw std::runtime_error("scalar bit-count regression"); }
|
||||
static void Check(std::uint32_t encoding, RdnaOpcode opcode, IrOpcode expected) {
|
||||
const std::array<std::uint32_t, 1> code{0x80000000u | (10u << 16u) | (encoding << 8u) | 12u};
|
||||
const RdnaInstruction instruction = DecodeRdnaSop1(0u, code, 0u);
|
||||
Require(instruction.op == opcode);
|
||||
Require(instruction.family == RdnaInstructionFamily::SOP1);
|
||||
Require(IsScalarAluOpcode(instruction.op));
|
||||
IrProgram program;
|
||||
auto& block = program.CreateBlock();
|
||||
program.SetEntryBlock(block);
|
||||
TranslationContext context(program, block, 256);
|
||||
context.TranslateInstruction(instruction);
|
||||
bool found = false;
|
||||
for (auto* value : block.Instructions()) found = found || value->Opcode() == expected;
|
||||
Require(found);
|
||||
}
|
||||
int main() {
|
||||
Check(0x0eu, RdnaOpcode::SBcnt0I32B64, IrOpcode::BitCount32);
|
||||
Check(0x12u, RdnaOpcode::SFf0I32B64, IrOpcode::FindILsb32);
|
||||
}
|
||||
Loading…
Reference in New Issue