diff --git a/docs/experiments/compute-indexed-atomic-uav.md b/docs/experiments/compute-indexed-atomic-uav.md new file mode 100644 index 0000000000..11510e6d9f --- /dev/null +++ b/docs/experiments/compute-indexed-atomic-uav.md @@ -0,0 +1,70 @@ +# Indexed atomic UAVs in the direct compute runtime path + +The direct gfx1013 compute translator lowers an indexed `buffer_atomic_*` +(`idxen`) to an `atomicBinOp`/`atomicCompareExchange` on a raw buffer UAV, +reading the view's `{stride, count}` from the constant buffer at +`b(uav register + 1)` and testing the lane index against the count before +multiplying by the stride. That binding, `ComputeViewKind::indexed_atomic_uav`, +previously had no runtime manifest, so `compile_dxil` reported +`compiled, no runtime manifest: UAV kind indexed_atomic_uav` and the dispatch +path never bound it. + +## Contract + +`format_compute_runtime_manifest` publishes the view only as a single +4-byte view: + +```text +uav atomic table +``` + +Any other shape (a descriptor array, or a `required_bytes` other than 4) +stays refused by name as `UAV kind indexed_atomic_uav`. + +The startup dispatch path (`src/startup_stubs/d3d12_compute_dispatch.inl`) +parses that line and builds a root signature with one extra 32-bit-constants +parameter per indexed atomic UAV, after the view table and in UAV order, +with `ShaderRegister = uav register + 1` and two values — the same layout +`NativeComputePipeline` builds. The in-process native translation classifies +the binding as an output the same way, so a program translated in-process +binds identically. + +Binding is token-only: the output must be a slot-19 token view. At dispatch +time the shared `native_buffer_store_view` check derives `{stride, count}` +from that view — structured views need a stride that is a multiple of 4 and +at most 2048 bytes, raw views need `R32_TYPELESS` with no stride, typed views +need `R32_UINT` or `R32_SINT` — and rewrites it to the raw `R32_TYPELESS` +view the atomic operates on. A view that fails that check is refused as +`an indexed atomic output view has an unsupported stride or range`. An +indexed atomic output bound from a hardware descriptor instead of a token is +refused as `an indexed atomic output needs a slot-19 token view`. Multiple +indexed atomic UAVs each get their own root-constants parameter; the +manifest's existing caps (8 UAVs, 32 user-data words) keep the root +signature inside the root-cost budget. + +## Verification + +`startup_compute_indexed_atomic_uav_controls` publishes the synthetic +program through `compile_dxil` and checks the manifest line, with no +`.cs.hlsl` sidecar. `startup_compute_indexed_atomic_uav_warp` and +`_hardware` dispatch it through the stand-in's command list: every lane +adds 1 to the indexed counter at byte index `4 * lane` over +`Dispatch(3, 2, 2)`, so each addressed dword gains 12. Raw, structured +stride-8 and typed `R32_UINT` token views are checked, each with its own +addressed dwords, plus four token shapes and a hardware descriptor that must +each refuse with their own reason and leave the output untouched, and a +native in-process translation of the same program. Every negative-control +view is creatable in D3D12 on its buffer: the 4096-stride view is created on +the 16 MiB + 64 KiB committed buffer, since a view D3D12 rejects at creation +removes the device in slot 19 before the dispatch can refuse it. The +published path needs 32-lane waves too: the published DXIL declares +WaveSize(32), so `CreateComputePipelineState` fails on 4-lane WARP, and +the check probes `--shader-wave32` first and exits 77 without them. The +pure-Python controls (program encoding, table loads, `idxen` atomic, +per-shape expectations, token views, and that every negative view fits its +buffer) run without Windows. + +```powershell +cmake --build --preset dev --target compile_dxil startup_stream_consumer offscreen_check +ctest --preset dev --no-tests=error -R '^startup_compute_indexed_atomic_uav_(controls|warp|hardware)$' --output-on-failure +``` diff --git a/src/direct_compute_cache.cpp b/src/direct_compute_cache.cpp index 613f508c8e..ce9484c124 100644 --- a/src/direct_compute_cache.cpp +++ b/src/direct_compute_cache.cpp @@ -1006,6 +1006,13 @@ std::optional format_compute_runtime_manifest(const NativeComputeSh const char *dimension = b.image_dimension == 2 ? "tex3d" : b.image_dimension == 5 ? "tex2da" : "tex2d"; uav_lines << "uav " << b.shader_register << ' ' << dimension << " float table " << b.root_parameter << ' ' << b.byte_offset << " channels " << channels << '\n'; + } else if (b.kind == ComputeViewKind::indexed_atomic_uav && b.array_count == 1 && + b.required_bytes == 4) { + // One indexed atomic UAV: the runtime binds it from a slot-19 token view and fills the + // {stride, count} root constants the translated program reads at b(register + 1). Any other + // shape stays refused by name below. + uav_lines << "uav " << b.shader_register << " atomic table " << b.root_parameter << ' ' + << b.byte_offset << '\n'; } else if ((b.kind == ComputeViewKind::texture_uav || b.kind == ComputeViewKind::half4_texture_uav) && b.array_count == 1) { const char *tex; diff --git a/src/startup_stubs/d3d12_compute_dispatch.inl b/src/startup_stubs/d3d12_compute_dispatch.inl index e55c9218c4..f9a4d5f971 100644 --- a/src/startup_stubs/d3d12_compute_dispatch.inl +++ b/src/startup_stubs/d3d12_compute_dispatch.inl @@ -6,7 +6,9 @@ // `uav packed_d16_x table ` for a one-component packed D16 store) // named by hardware buffer descriptors or 64-bit root SRV addresses, and textures // (`srv tex1d|tex2d|tex2da|tex3d|texcubearr table ` inputs, `uav tex1d/tex2d/tex2da/tex3d float table channels ` outputs) named -// by the token of a view the title created (device slots 18 and 19). `smp`, `smpl` and `smpc` lines become static samplers. Entry +// by the token of a view the title created (device slots 18 and 19). An indexed buffer atomic +// (`uav atomic table `) is bound only from a slot-19 token view: the view's {stride, count} +// are bound as root constants at b(u + 1), matching the native compute pipeline. `smp`, `smpl` and `smpc` lines become static samplers. Entry // values come from the compute root constants of slots 37 and 39, or from the descriptor a buffer input or output is // bound from: its stride and word 3 (`stride`, `descword3`), and word 3, the upper half of word 1 and the record // count of an output (`uav_descword3`, `uav_stride`, `uav_numrecords`). Any other manifest line makes the translation @@ -43,6 +45,7 @@ struct ComputeTranslation { bool packed_d16_x = false; unsigned scalar_window = 0; bool atomic_uint_texture = false; + bool atomic = false; // an indexed atomic UAV: {stride, count} root constants at b(u + 1) unsigned channels = 4; D3D12_SRV_DIMENSION srv_dimension = D3D12_SRV_DIMENSION_UNKNOWN; unsigned half_buffer_bytes = 0; @@ -171,8 +174,13 @@ bool adapter_reports_shader_model_below_6_6() const char* create_compute_pipeline(ComputeTranslation& tr, const void* code, std::size_t bytes) { // Parameter 0 keeps one constant for a program without entry values: a constants parameter cannot be empty. + // One 32-bit-constants parameter per indexed atomic UAV follows the view table, in UAV order. + std::vector atomic_registers; + for (UINT i = 0; i < tr.uavs.size(); ++i) + if (tr.uavs[i].atomic) atomic_registers.push_back(i); if (FAILED(x2w_startup::create_translated_root(device_of(the_device), static_cast(tr.uds.empty() ? 1 : tr.uds.size()), - static_cast(tr.srvs.size()), tr.samplers, &tr.root, static_cast(tr.uavs.size()), false, tr.heap_srvs))) + static_cast(tr.srvs.size()), tr.samplers, &tr.root, static_cast(tr.uavs.size()), false, tr.heap_srvs, + static_cast(atomic_registers.size()), atomic_registers.data()))) return "root signature creation failed"; D3D12_COMPUTE_PIPELINE_STATE_DESC desc{}; desc.pRootSignature = tr.root.Get(); @@ -286,6 +294,11 @@ const char* load_compute_translation(ComputeTranslation& tr) tr.srvs.push_back({c, d, false, true, a, b, x, y}); else if (std::sscanf(line.c_str(), "uav %u table %d %d%n", &i, &a, &b, &used) == 3 && whole() && i == tr.uavs.size()) tr.uavs.push_back({a, b}); + else if (std::sscanf(line.c_str(), "uav %u atomic table %d %d%n", &i, &a, &b, &used) == 3 && whole() && + i == tr.uavs.size()) { + tr.uavs.push_back({a, b}); + tr.uavs.back().atomic = true; + } else if (std::sscanf(line.c_str(), "uav %u bufhalf table %d %d bytes %u%n", &i, &a, &b, &x, &used) == 4 && whole() && i == tr.uavs.size() && x2w::native_half_buffer_format(x) != DXGI_FORMAT_UNKNOWN) { tr.uavs.push_back({a, b}); @@ -427,7 +440,8 @@ bool translate_compute_natively(ComputeTranslation& tr) // A comparison sample reads its 2D texture through the same kind of view as a plain one. const bool texture_input = (view.kind == Kind::texture_srv || view.kind == Kind::comparison_texture_srv) && view.image_dimension == 1; - const bool output = texture_output || view.kind == Kind::raw_buffer_uav || half_typed; + const bool atomic = view.kind == Kind::indexed_atomic_uav; + const bool output = texture_output || view.kind == Kind::raw_buffer_uav || half_typed || atomic; auto dimension = D3D12_UAV_DIMENSION_UNKNOWN; if (texture_output) { switch (view.image_dimension) { @@ -439,7 +453,7 @@ bool translate_compute_natively(ComputeTranslation& tr) } auto& slots = output ? tr.uavs : tr.srvs; const bool supported = view.kind == Kind::raw_buffer_uav || half_typed || view.kind == Kind::raw_vector_srv || - x2w::accepts_cbv_window(view.kind) || texture_input || + x2w::accepts_cbv_window(view.kind) || texture_input || atomic || dimension != D3D12_UAV_DIMENSION_UNKNOWN; if (!supported || view.array_count != 1 || view.root_parameter >= 16 || view.shader_register != slots.size()) @@ -454,6 +468,7 @@ bool translate_compute_natively(ComputeTranslation& tr) slot.channels = channels; slot.half_typed_bytes = half_typed ? view.required_bytes : 0; slot.packed_d16_x = packed_x; + slot.atomic = atomic; // An MTBUF byte window needs identity channel order, as on the published route (identity_dst_sel). slot.requires_identity_dst_sel = view.requires_identity_dst_sel; if (x2w::accepts_cbv_window(view.kind)) @@ -679,6 +694,9 @@ const char* record_translated_dispatch(Wrapper* self, const TranslatedDispatch& Wrapper* wrapper; std::uint32_t words[8]; // a buffer's descriptor words as it was bound from (a content token is 8), and its stride UINT stride; + // An indexed atomic UAV: the {stride, count} root constants bound at parameter 2 + its UAV index. + UINT atomic_stride = 0, atomic_count = 0; + bool atomic = false; }; static_assert(sizeof(D3D12_SHADER_RESOURCE_VIEW_DESC) >= ViewRecord::srv_desc_bytes); static_assert(sizeof(D3D12_UNORDERED_ACCESS_VIEW_DESC) >= ViewRecord::uav_desc_bytes); @@ -975,6 +993,17 @@ const char* record_translated_dispatch(Wrapper* self, const TranslatedDispatch& if (views[input].resource == token.resource) reason = "an output buffer is also an input"; if (!reason && !retain_with_recording(self, x2w_startup::ComPtr(token.resource))) reason = "an output token's backing could not be retained with the recording"; + // An indexed atomic UAV reads its {stride, count} from root constants at b(u + 1). The shared + // store-view check derives them from the token's view and rewrites it to the raw R32 view the + // atomic operates on; any other shape is refused by that check's name. + x2w::IndexedAtomicView atomic_shape{}; + D3D12_UNORDERED_ACCESS_VIEW_DESC atomic_view{}; + if (!reason && slot.atomic) { + const x2w::ComputeViewBinding binding{x2w::ComputeViewKind::indexed_atomic_uav, 0, 0, 0, 4}; + atomic_view = token.view; + if (!x2w::native_buffer_store_view(binding, atomic_view, token.backing.Width, &atomic_shape)) + reason = "an indexed atomic output view has an unsupported stride or range"; + } if (!tr->logged_token_output || (!reason && !tr->logged_bound_token_output)) { tr->logged_token_output = true; if (!reason) tr->logged_bound_token_output = true; @@ -992,8 +1021,19 @@ const char* record_translated_dispatch(Wrapper* self, const TranslatedDispatch& views[i].described = true; views[i].desc.uav = token.view; } + if (!reason && slot.atomic) { + views[i].described = true; + views[i].desc.uav = atomic_view; + views[i].atomic = true; + views[i].atomic_stride = atomic_shape.stride; + views[i].atomic_count = atomic_shape.count; + } continue; } + if (slot.atomic) { + reason = "an indexed atomic output needs a slot-19 token view"; + break; + } if (slot.half_typed_bytes) { reason = "formatted D16 write needs the original typed buffer view"; break; @@ -1180,6 +1220,14 @@ const char* record_translated_dispatch(Wrapper* self, const TranslatedDispatch& list->SetComputeRootSignature(tr->root.Get()); if (!tr->uds.empty()) list->SetComputeRoot32BitConstants(0, static_cast(tr->uds.size()), values, 0); if (n) list->SetComputeRootDescriptorTable(1, D3D12_GPU_DESCRIPTOR_HANDLE{draw_heap->GetGPUDescriptorHandleForHeapStart().ptr + u64{first} * draw_heap_increment}); + // Indexed atomic UAVs: one {stride, count} pair per atomic output, at parameter 2 + its UAV index, + // matching the root signature create_compute_pipeline built. + UINT atomic_parameter = 2; + for (std::size_t i = inputs; i < count; ++i) { + if (!views[i].atomic) continue; + const UINT pair[2] = {views[i].atomic_stride, views[i].atomic_count}; + list->SetComputeRoot32BitConstants(atomic_parameter++, 2, pair, 0); + } if (dispatch.signature) { require_state(self, dispatch.argument, D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT); list->ExecuteIndirect(dispatch.signature, 1, dispatch.argument, dispatch.offset, nullptr, 0); diff --git a/src/startup_stubs/translated_sampler_bindings.h b/src/startup_stubs/translated_sampler_bindings.h index 658d0a5ecf..255765fbb3 100644 --- a/src/startup_stubs/translated_sampler_bindings.h +++ b/src/startup_stubs/translated_sampler_bindings.h @@ -118,11 +118,15 @@ inline std::vector decode_statics(const TranslatedSam inline UINT sampler_root_parameter(UINT views) { return views ? 2u : 1u; } // Parameter 1, when there are views, is one table: SRVs t0.. first, then UAVs u0.., then bounded resheap SRVs (space 2). +// `atomic` names the UAV registers (one per indexed atomic UAV, in UAV order) that each get a 32-bit-constants +// parameter after the view table: the translated program reads the view's {stride, count} from b(register + 1), +// as NativeComputePipeline binds it. The sampler-heap table, when present, follows those parameters. inline HRESULT create_translated_root(ID3D12Device* device, UINT constants, UINT srvs, const TranslatedSamplers& samplers, ID3D12RootSignature** out, UINT uavs = 0, - bool input_assembler = false, UINT heap_srvs = 0) + bool input_assembler = false, UINT heap_srvs = 0, UINT atomic = 0, + const UINT *atomic_registers = nullptr) { - D3D12_ROOT_PARAMETER parameters[3]{}; + D3D12_ROOT_PARAMETER parameters[11]{}; parameters[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; parameters[0].Constants.Num32BitValues = constants; // A compute program's outputs (u0..) follow its resources in the same table; bounded heap SRVs follow in space 2. @@ -139,6 +143,13 @@ inline HRESULT create_translated_root(ID3D12Device* device, UINT constants, UINT const D3D12_DESCRIPTOR_RANGE sampler_range{ D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, translated_sampler_count, 0, translated_sampler_space, 0}; UINT count = sampler_root_parameter(srvs + uavs + heap_srvs); + for (UINT i = 0; i < atomic; ++i) { + auto ¶m = parameters[count++]; + param.ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; + param.Constants.ShaderRegister = atomic_registers[i] + 1; + param.Constants.RegisterSpace = 0; + param.Constants.Num32BitValues = 2; + } if (samplers.heap) { parameters[count].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; parameters[count].DescriptorTable = {1, &sampler_range}; diff --git a/tests/cmake/startup_compute_indexed_atomic_uav.cmake b/tests/cmake/startup_compute_indexed_atomic_uav.cmake new file mode 100644 index 0000000000..88652b9ee8 --- /dev/null +++ b/tests/cmake/startup_compute_indexed_atomic_uav.cmake @@ -0,0 +1,17 @@ +if(TARGET compile_dxil AND EXISTS "${INTAKE_PYTHON}" + AND EXISTS "${DXC_BIN_DIR}/dxcompiler.dll" AND EXISTS "${DXC_BIN_DIR}/dxil.dll") + add_test(NAME startup_compute_indexed_atomic_uav_controls COMMAND "${INTAKE_PYTHON}" -B + "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_compute_indexed_atomic_uav_check.py" compile + "$" "${DXC_BIN_DIR}") + set_tests_properties(startup_compute_indexed_atomic_uav_controls PROPERTIES TIMEOUT 60) +endif() +if(TARGET compile_dxil AND TARGET startup_stream_consumer AND TARGET offscreen_check AND EXISTS "${INTAKE_PYTHON}" + AND EXISTS "${DXC_BIN_DIR}/dxcompiler.dll" AND EXISTS "${DXC_BIN_DIR}/dxil.dll") + foreach(adapter IN ITEMS warp hardware) + add_test(NAME startup_compute_indexed_atomic_uav_${adapter} COMMAND "${INTAKE_PYTHON}" -B + "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_compute_indexed_atomic_uav_check.py" + "$" "$" "$" + "${DXC_BIN_DIR}" ${adapter}) + set_tests_properties(startup_compute_indexed_atomic_uav_${adapter} PROPERTIES TIMEOUT 180 SKIP_RETURN_CODE 77) + endforeach() +endif() diff --git a/tests/native_compute_manifest_reasons.cpp b/tests/native_compute_manifest_reasons.cpp index b13cae25c3..d2f1e65d98 100644 --- a/tests/native_compute_manifest_reasons.cpp +++ b/tests/native_compute_manifest_reasons.cpp @@ -81,6 +81,14 @@ int main() { p.bindings[0].image_dimension = 1; }}, {"UAV kind typed_buffer_uav", [](auto &p) { p.bindings[1].kind = K::typed_buffer_uav; }}, + {"UAV kind indexed_atomic_uav array", [](auto &p) { + p.bindings[1].kind = K::indexed_atomic_uav; + p.bindings[1].array_count = 2; + }}, + {"UAV kind indexed_atomic_uav", [](auto &p) { + p.bindings[1].kind = K::indexed_atomic_uav; + p.bindings[1].required_bytes = 8; + }}, {"UAV kind packed_d16_x_uav", [](auto &p) { p.bindings[1].kind = K::packed_d16_x_uav; p.bindings[1].required_bytes = 4; @@ -144,6 +152,22 @@ int main() { std::printf(" | got: %s\n", manifest ? manifest->c_str() : reason.c_str()); failures += !ok; } + // An indexed atomic UAV is published only as a single 4-byte view. + { + auto program = base(); + program.bindings[1].kind = K::indexed_atomic_uav; + program.bindings[1].required_bytes = 4; + reason = "unset"; + const auto manifest = format_compute_runtime_manifest(program, &reason); + std::string wanted = expected; + wanted.replace(wanted.find("uav 0 table 1 32\n"), std::strlen("uav 0 table 1 32\n"), + "uav 0 atomic table 1 32\n"); + const bool ok = manifest && *manifest == wanted && reason == "unset"; + std::printf("%s publishes uav 0 atomic table 1 32\n", ok ? "ok " : "FAIL"); + if (!ok) + std::printf(" | got: %s\n", manifest ? manifest->c_str() : reason.c_str()); + failures += !ok; + } { auto program = base(); program.bindings[1].kind = K::packed_d16_x_uav; @@ -159,6 +183,6 @@ int main() { std::printf(" | got: %s\n", manifest ? manifest->c_str() : reason.c_str()); failures += !ok; } - std::printf("%d of %zu manifest reasons wrong\n", failures, std::size(cases) + std::size(published) + 2); + std::printf("%d of %zu manifest reasons wrong\n", failures, std::size(cases) + std::size(published) + 3); return failures ? 1 : 0; } diff --git a/tests/startup_compute_indexed_atomic_uav_check.py b/tests/startup_compute_indexed_atomic_uav_check.py new file mode 100644 index 0000000000..285454fcf4 --- /dev/null +++ b/tests/startup_compute_indexed_atomic_uav_check.py @@ -0,0 +1,271 @@ +"""Publish a synthetic indexed-atomic slot 67 program and check its token-bound output. + +usage: startup_compute_indexed_atomic_uav_check.py + + startup_compute_indexed_atomic_uav_check.py compile + startup_compute_indexed_atomic_uav_check.py + (no arguments: pure-Python controls for the program encoding and expectations) + +The program loads the input descriptor from table byte 0 and the output descriptor from table byte 32 +(the 32-byte record layout the direct compiler reads), then every lane adds 1 to the indexed atomic +counter at byte index 4 * lane. Dispatch(3, 2, 2) runs 12 groups of 32 lanes, so each addressed dword +gains 12. The output is a slot-19 token UAV, bound through the published manifest line +`uav 0 atomic table 1 32`; the dispatch binds the view's {stride, count} as root constants at b1. +Three token shapes are checked, each with its own addressed dwords: + +- raw (stride 1, byte indices): dwords 0-31; +- structured stride 8 (element indices): dwords 0, 8, ..., 248; +- typed R32_UINT (stride 4, element indices): dwords 0, 4, ..., 124. + +Negative controls keep the same published manifest and refuse, each with its own reason and an +untouched output: structured strides 6 and 4096, a typed R16_UINT view, and a view whose first +element is not 16-byte aligned, plus the same output bound from a hardware descriptor instead of +a token. Every negative view is creatable in D3D12 on its buffer (the 1280-byte output buffer, or +the 16 MiB + 64 KiB committed buffer for the 4096-stride view, which needs more than 1280 bytes): +a view D3D12 itself rejects at creation removes the device in slot 19 before the dispatch can +refuse it, so a RAW-flagged view with a non-R32_TYPELESS format and a view past the end of its +buffer are not exercised here. A final native run translates the same program in-process (no +published manifest) and checks the same readback. The check probes +`--shader-wave32` first and exits 77 on adapters without 32-lane waves: +the published DXIL declares WaveSize(32), so pipeline creation fails +there, and the native translator needs them too. Exit 77 also if the +initial probe cannot use the adapter or required heaps. +""" +import struct +import subprocess +import sys +import tempfile +from pathlib import Path + +from native_gather_lod_check import render +from native_scalar_lds_check import sop1 +from startup_compute_buffer_atomics_check import mubuf, v_mov_imm, vop2 +from startup_compute_dispatch_check import dispatch, lines, prepare_case +from startup_compute_translate_check import state_a, write_request +from startup_gfx2hlsl_compute_check import MASK, SENTINEL, TGID_X, TGID_Y, TGID_Z, USER7, WORDS, root_blob +from startup_stream_check import gfx2hlsl as G + +STATE = state_a((32, 1, 1), USER7 | TGID_X | TGID_Y | TGID_Z) +GROUPS = 12 # Dispatch(3, 2, 2) +MANIFEST_LINE = 'uav 0 atomic table 1 32' +NATIVE_LINE = 'translated natively: 2 entry values, 0 inputs, 1 outputs' +NO_WAVES = 'not translated natively: the adapter has no 32-lane waves' +ATOMIC_REASON = 'an indexed atomic output view has an unsupported stride or range' +HARDWARE_REASON = 'an indexed atomic output needs a slot-19 token view' + +RAW, R16_UINT, R32_UINT = 39, 57, 42 # DXGI_FORMAT values +STRIDES = {'raw': 1, 'structured': 8, 'typed': 4} + + +def program(): + code = struct.pack('<2I', sop1(3, 10, 6), sop1(3, 11, 128)) + code += bytes.fromhex('050308f4 000000fa 050408f4 200000fa') # s_load_dwordx4 s[12:15], s[16:19] + code += struct.pack('