upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/test/active_input_test.cpp
diff options
context:
space:
mode:
authorJan Trencansky <jan.trencansky@protonmail.com>2026-11-24 21:44:23 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-24 21:44:23 -0500
commitb8563e949ed389fff20be91c73687a70b5213469 (patch)
treed69c6817854ce0a14a67ff1fd0f1c39dec68a91f /runtime/test/active_input_test.cpp
parent00fc23b9a9eeb1a75f1fec2b58024bea15c26663 (diff)
parent7ae1dd3de34f1542242bc8ccfc80d9b97d20cc01 (diff)
Merge main into D3D-448-GRAPHICS (#974)
main already lays graphics root arguments out in the console layout (from s8, one dword per table: #939's graphics-root-layout patch in #984's form, pack_stage(Stage::Pixel), RootArgumentLayout::graphics_console, graphics_arguments_end, LEONIDA_GRAPHICS_STAGE_LAYOUT=0 for pack()). That form stays. What this pull request adds beyond it is carried onto it: the mesh-shader root window (translator, index "root_window", mesh_ok, the two refusals) and its tests. Its own graphics spill handling (Spill::block) and LEONIDA_GRAPHICS_ROOT_LAYOUT=pc are not carried: main keeps pack()'s s0 layout for a graphics signature past s31, and its switch does what =pc did. Conflicts: - runtime/src/root_signature.h, root_signature.cpp: main's pack_stage (compute spill array, spill_dword); the Spill enum, first_spilled and spilled_dwords dropped. The header keeps the PR's evidence note, with Stage::Pixel. - runtime/shims/d3d12_com.h: main's comment and members, with the mesh window described; mesh_ok added (false by default, set only for a console-layout signature that Stage::Mesh also places); the PR's second graphics_console dropped. - runtime/shims/d3d12_vulkan_device.cpp (CreateRootSignature): main's pixel/packed form; the PR's Stage::Mesh pack and its log line added, mesh_ok = pixel.ok && mesh.ok. The mesh-shader refusal without "root_window" (no conflict) stays. - runtime/shims/d3d12_com.cpp: DispatchMesh keeps main's any_nonempty_viewport() and graphics_user_data() after the PR's mesh_ok check; address() keeps main's comment. The PR's kNoSgpr guard in constants()/address() stays, reworded: in main a spilled compute parameter has first_sgpr kNoSgpr, and kNoSgpr + offset wrapped round to s0. - runtime/src/shader_library.h: both (main's wave64_graphics, the PR's root_window). - runtime/test/d3d12_mesh_test.cpp: main's mesh shader-kind byte on both containers (also the PR's ms_old); the PR's two-parameter signature replaces main's 25-dword padding onto the s0 layout; both test blocks kept (the PR's window refusals, main's DISPATCH_MESH command signature), each in its own scope. The =pc case is dropped (main's switch is read once per process). - runtime/CMakeLists.txt (no conflict): the mesh test uses ps_draw.spv again; the ps_draw_s0.spv rule is gone. - runtime/test/glsl/ps_draw.frag, vs_depth.vert, vs_draw.vert, vs_draw_int.vert, ps_depth_write.frag and runtime/test/shaders/ps_m15, ps_m2, ps_m2_array, ps_m2_literal, ps_m2_uoff, ps_m3, ps_m3_post, ps_m3_query, vs_m15, vs_m3 (.asm): main's (the same s8 rewrite done twice); ps_draw.frag's mesh-test note updated. - runtime/test/root_signature_test.cpp (no conflict): the Spill::block cases dropped, the window cases kept. - docs/design.md: main's rows (loop guard, direct resource heap) and the PR's user-data row. - docs/d3d12_vulkan.md (no conflict): section 3.5 and the CreateRootSignature bullet rewritten for main's form. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/test/active_input_test.cpp')
-rw-r--r--runtime/test/active_input_test.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/runtime/test/active_input_test.cpp b/runtime/test/active_input_test.cpp
index 11c628320..64b7f1b86 100644
--- a/runtime/test/active_input_test.cpp
+++ b/runtime/test/active_input_test.cpp
@@ -4,6 +4,7 @@
4#include "../src/active_input.h" 4#include "../src/active_input.h"
5 5
6#include <cstdio> 6#include <cstdio>
7#include <limits>
7#include <iterator> 8#include <iterator>
8#include <string_view> 9#include <string_view>
9 10
@@ -201,6 +202,41 @@ int test_forced() {
201 return 0; 202 return 0;
202} 203}
203 204
205int test_out_of_order_timestamp_and_non_finite_axes() {
206 ActiveInputTracker t(InputFamily::Xbox);
207 EXPECT(t.observe(1, InputFamily::PlayStation5, InputSample{}, 1000000) == InputEdge::None);
208 EXPECT(t.observe(2, InputFamily::Keyboard, InputSample{}, 1000000) == InputEdge::None);
209
210 InputSample press;
211 press.buttons = 1;
212 EXPECT(t.observe(1, InputFamily::PlayStation5, press, 2000000) == InputEdge::Button);
213 EXPECT(t.active() == InputFamily::PlayStation5 && t.generation() == 1);
214
215 // An earlier timestamp must not underflow (time_us - changed_at_) and bypass min_switch_us.
216 EXPECT(t.observe(2, InputFamily::Keyboard, press, 1999000) == InputEdge::None);
217 EXPECT(t.active() == InputFamily::PlayStation5 && t.generation() == 1);
218
219 // Non-finite stick/trigger samples (NaN baseline or Inf deflection) must not trigger a family switch.
220 const float nan = std::numeric_limits<float>::quiet_NaN();
221 const float inf = std::numeric_limits<float>::infinity();
222 ActiveInputTracker t2(InputFamily::Xbox);
223 InputSample nan_stick;
224 nan_stick.left_x = nan;
225 EXPECT(t2.observe(3, InputFamily::PlayStation5, nan_stick, 1000000) == InputEdge::None);
226 InputSample deflected;
227 deflected.left_x = 0.9f;
228 EXPECT(t2.observe(3, InputFamily::PlayStation5, deflected, 2000000) == InputEdge::None);
229 EXPECT(t2.active() == InputFamily::Xbox && t2.generation() == 0);
230
231 ActiveInputTracker t3(InputFamily::Xbox);
232 EXPECT(t3.observe(4, InputFamily::PlayStation5, InputSample{}, 1000000) == InputEdge::None);
233 InputSample inf_trig;
234 inf_trig.left_trigger = inf;
235 EXPECT(t3.observe(4, InputFamily::PlayStation5, inf_trig, 2000000) == InputEdge::None);
236 EXPECT(t3.active() == InputFamily::Xbox && t3.generation() == 0);
237 return 0;
238}
239
204int test_names() { 240int test_names() {
205 EXPECT(std::string_view(input_family_name(InputFamily::PlayStation5)) == "PlayStation 5"); 241 EXPECT(std::string_view(input_family_name(InputFamily::PlayStation5)) == "PlayStation 5");
206 EXPECT(std::string_view(input_family_name(InputFamily::Keyboard)) == "keyboard and mouse"); 242 EXPECT(std::string_view(input_family_name(InputFamily::Keyboard)) == "keyboard and mouse");
@@ -222,6 +258,7 @@ int main() {
222 {"one family, held input", test_same_family_and_holds}, 258 {"one family, held input", test_same_family_and_holds},
223 {"reconnect", test_reconnect}, 259 {"reconnect", test_reconnect},
224 {"forced family", test_forced}, 260 {"forced family", test_forced},
261 {"out-of-order timestamp and non-finite axes", test_out_of_order_timestamp_and_non_finite_axes},
225 {"names", test_names}, 262 {"names", test_names},
226 }; 263 };
227 int failures = 0; 264 int failures = 0;