ACMX 2.139.0
Dual-Backend Real-Time GPU Video Synthesis
Loading...
Searching...
No Matches
interface_client_windows_tests.cpp
Go to the documentation of this file.
3
4#include <algorithm>
5#include <cstring>
6#include <iostream>
7
8int main() {
9#ifdef _WIN32
10 HANDLE mutex = ::CreateMutexW(nullptr, FALSE, acmxvk::ipc::SHADER_SELECTION_MUTEX_NAME_WINDOWS);
11 if (mutex == nullptr) {
12 std::cerr << "CreateMutexW failed: " << ::GetLastError() << '\n';
13 return 1;
14 }
15
16 HANDLE mapping = ::CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, static_cast<DWORD>(sizeof(acmxvk::ipc::ShaderSelectionData)), acmxvk::ipc::SHADER_SELECTION_MAPPING_NAME_WINDOWS);
17 if (mapping == nullptr) {
18 std::cerr << "CreateFileMappingW failed: " << ::GetLastError() << '\n';
19 ::CloseHandle(mutex);
20 return 1;
21 }
22
23 void *view = ::MapViewOfFile(mapping, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(acmxvk::ipc::ShaderSelectionData));
24 if (view == nullptr) {
25 std::cerr << "MapViewOfFile failed: " << ::GetLastError() << '\n';
26 ::CloseHandle(mapping);
27 ::CloseHandle(mutex);
28 return 1;
29 }
30
31 auto *selection = static_cast<acmxvk::ipc::ShaderSelectionData *>(view);
32 {
33 acmxvk::ipc::InterfaceLock lock(mutex);
34 if (!lock) {
35 std::cerr << "Could not lock test mapping\n";
36 ::UnmapViewOfFile(view);
37 ::CloseHandle(mapping);
38 ::CloseHandle(mutex);
39 return 1;
40 }
42 selection->sequence = 42;
43 selection->shader_pass_enabled = 1;
44 selection->shader_pass_count = 2;
45 std::strcpy(selection->selected_shader_name, "selected.frag.spv");
46 std::strcpy(selection->shader_pass_names[0], "first.comp.spv");
47 std::strcpy(selection->shader_pass_names[1], "second.frag.spv");
48 selection->custom_uniform_count = 1;
49 std::strcpy(selection->custom_uniform_names[0], "slider1");
50 selection->custom_uniform_values[0] = 0.75F;
51 selection->audio_file_sequence = 7;
52 std::strcpy(selection->audio_file_path, "C:/audio/test.wav");
53 selection->audio_pass_through = 1;
54 selection->dream_enabled = 1;
55 selection->dream_fp16 = 1;
56 selection->dream_gpu_filter_first = 1;
57 selection->dream_iterations = 3;
58 selection->dream_maximum_dimension = 768;
59 selection->dream_channel = 12;
60 selection->dream_octaves = 2;
61 selection->dream_jitter = 4;
62 selection->dream_smoothing = 2;
63 selection->dream_strength = 0.125F;
64 selection->dream_feedback = 0.8F;
65 selection->dream_zoom = 1.02F;
66 selection->dream_rotation = -0.25F;
67 selection->dream_octave_scale = 1.6F;
68 std::strcpy(selection->dream_model_path, "C:/models/dream.pt");
69 std::strcpy(selection->dream_layer, "relu4_2");
70 }
71
74 const bool opened = client.open();
75 const bool read = opened && client.read(state);
76 const bool valid = read && state.sequence == 42 && state.selected_shader_name == "selected.frag.spv" && state.multipass.enabled && state.multipass.shader_names.size() == 2 && state.multipass.shader_names[0] == "first.comp.spv" && state.multipass.shader_names[1] == "second.frag.spv" && state.uniform_values.size() == 1 && state.uniform_values[0].name == "slider1" && state.uniform_values[0].value == 0.75F && state.audio_file.request_sequence == 7 && state.audio_file.path == "C:/audio/test.wav" && state.audio_file.pass_through && state.deep_dream.enabled && state.deep_dream.fp16 && state.deep_dream.gpu_filter_first && state.deep_dream.iterations == 3 && state.deep_dream.maximum_dimension == 768 && state.deep_dream.channel == 12 && state.deep_dream.octaves == 2 && state.deep_dream.jitter == 4 && state.deep_dream.smoothing == 2 && state.deep_dream.strength == 0.125F && state.deep_dream.feedback == 0.8F && state.deep_dream.zoom == 1.02F && state.deep_dream.rotation == -0.25F &&
77 state.deep_dream.octave_scale == 1.6F && state.deep_dream.model_path == "C:/models/dream.pt" && state.deep_dream.layer == "relu4_2";
78
79 client.close();
80 ::UnmapViewOfFile(view);
81 ::CloseHandle(mapping);
82 ::CloseHandle(mutex);
83 if (!valid) {
84 std::cerr << "Windows interface-control round trip failed\n";
85 return 1;
86 }
87 std::cout << "ACMXVK Windows interface-control test passed\n";
88#endif
89 return 0;
90}
int main(int argc, char **argv)
Application entry point.
bool read(InterfaceState &state) const
std::vector< std::string > shader_names
std::vector< InterfaceUniformValue > uniform_values
InterfaceAudioFileState audio_file
InterfaceMultipassState multipass
InterfaceDeepDreamState deep_dream