- Core simulator:
framework/(spirv_simulator.cpp/.hpp,util.*, opcode helpers, exceptions). - CLI entry points:
main.cpp(simulator) andmain_opcode_checker.cpp(opcode utility). - Build scaffolding: root
CMakeLists.txtpluscmake/modules andexternal/vendored deps. - Tests:
test/(gtest/gmock suites and harness) and sample shaders intest_shaders/. - Generated artifacts live in
build/(not committed).
- C++20, 4-space indentation, braces on new lines for control blocks as in existing sources.
- Keep header guards/
#pragma once, grouped includes, and minimal headers in headers. - Types/classes use PascalCase (
SPIRVSimulator); functions/methods are PascalCase; variables and struct fields are lower_snake_case. - Mirror existing patterns in
framework/spirv_simulator.*andtest/testing_common.*; prefer standard library utilities and assertions already in use.
- The SPIRV simulator implements the SPIRV specification and parses SPIRV code to extract information about pointers and memory usage.
- Do not run compilation or tests as part of code reviews.
- Opcodes are handled in the c++ files
framework/spirv_simulator.cppandframework/spirv_simulator.hpp, and the classSPIRVSimulator - Each Opcode has a function handler of the form
void Op_<name>(const Instruction&); - Build with
make -j - Run tests with
ctest --output-on-failure
Minimal function implementation:
void SPIRVSimulator::Op_<name>(const Instruction& instruction)
{
/*
Op<name>
Some explanation goes here
*/
assert(instruction.opcode == spv::Op::Op<name>);
uint32_t type_id = instruction.words[1];
// do more work here
}- Framework: gtest + gmock (
TEST,TEST_P). - Place new cases in the closest suite under
test/(usemisc_test.cppas the fallback if no other suite fits) - Build with
make -j. Fix any errors shown. - Run tests with
ctest --output-on-failure. Fix any errors shown. - When adding opcodes, include positive/edge cases and pointer/descriptor coverage where applicable.
- For shader-driven scenarios, place inputs in
test_shaders/and reference them via./spirv_simulatorin tests.
- For performance runs, make sure you build in release mode (made with
-DCMAKE_BUILD_TYPE=Release, eg in abuild_releasefolder). - Performance can be measured like this:
taskset 1 perf stat -r 100 build_release/spirv_simulator test_shaders/aztec_ruins_shader_4.spv