1#ifndef ACMXVK_MAIN_WINDOW_HPP
2#define ACMXVK_MAIN_WINDOW_HPP
4#include <mxvk/mxvk.hpp>
5#include <mxvk/mxvk_abstract_model.hpp>
6#include <mxvk/mxvk_cv.hpp>
7#ifdef MXVK_WITH_FFMPEG_CAPTURE
8#include <mxvk/mxvk_ff_capture.hpp>
19#ifdef ACMXVK_WITH_CUDA
25#ifdef ACMXVK_WITH_DEEP_DREAM
39#ifdef ACMXVK_WITH_MXVK_CUDA
40#include <opencv2/core/cuda.hpp>
41#include <opencv2/cudaarithm.hpp>
43#include <opencv2/core.hpp>
44#include <opencv2/imgproc.hpp>
45#include <opencv2/videoio.hpp>
47#include <glm/ext/matrix_clip_space.hpp>
48#include <glm/ext/matrix_transform.hpp>
55#include <condition_variable>
71#include <unordered_map>
72#include <unordered_set>
89 std::uint32_t image_index)
override;
91 VkCommandBuffer command_buffer, std::uint32_t image_index,
92 VkImageView texture_view,
93 [[maybe_unused]] VkExtent2D texture_extent)
override;
95 std::uint32_t image_index, VkImageView texture_view);
120#ifdef MXVK_WITH_FFMPEG_CAPTURE
121 mxvk::VK_FF_Capture ffmpeg_capture;
122 std::vector<std::uint8_t> ffmpeg_rgba;
123 std::vector<std::uint16_t> ffmpeg_rgba16;
124 bool using_ffmpeg_capture =
false;
125 bool ffmpeg_seek_repeat_logged =
false;
126#ifdef ACMXVK_WITH_MXVK_CUDA
127 cv::cuda::Stream ffmpeg_cuda_stream;
158 std::numeric_limits<std::size_t>::max();
265 std::chrono::steady_clock::now();
267 std::chrono::steady_clock::now();
269 std::chrono::steady_clock::now();
286 std::chrono::steady_clock::now()};
298 std::chrono::steady_clock::time_point
previous_frame{std::chrono::steady_clock::now()};
308 std::numeric_limits<std::uint64_t>::max();
311#ifdef ACMXVK_WITH_CUDA
312 std::unique_ptr<gpu::FilterEngine> gpu_filter_engine;
314#ifdef ACMXVK_WITH_DNN
315 std::unique_ptr<dnn::EdgeDetector> edge_detector;
316 std::unique_ptr<dnn::HumanSegmenter> human_segmenter;
317 std::unique_ptr<dnn::GenericOnnxProcessor> generic_onnx_processor;
319#ifdef ACMXVK_WITH_DEEP_DREAM
320 std::unique_ptr<dream::Model> deep_dream_model;
322#ifdef ACMXVK_WITH_MXVK_CUDA
323 cv::cuda::GpuMat cuda_input_rgba;
324 cv::cuda::GpuMat cuda_dream_rgba;
325 cv::cuda::GpuMat cuda_rotated_rgba;
326 cv::cuda::GpuMat cuda_rotation_transpose;
327 cv::Mat cuda_input_fallback_rgba;
328 cv::Mat cuda_history_fallback_rgba;
329 cv::Mat cuda_model_fallback_rgba;
330 bool cuda_input_path_logged =
false;
331 bool cuda_input_fallback_logged =
false;
332 bool cuda_history_fallback_logged =
false;
333 bool cuda_model_fallback_logged =
false;
369 std::chrono::steady_clock::time_point now);
390 [[nodiscard]]
bool setMidiUniform(std::size_t uniform_index,
int value,
391 std::string_view label);
413 std::string_view source);
434 const std::string &requested_name);
436 const std::vector<InterfaceUniformValue> &uniform_values);
443 [[nodiscard]]
const std::vector<fs::path> *
activePasses()
const;
447 [[nodiscard]]
static std::string
formatHudTime(
double seconds_value);
453 std::uint64_t *frame_index =
nullptr)
const;
479 uint32_t height)
override;
482 uint32_t height)
override;
484 std::vector<std::uint8_t> &rgba,
485 const std::vector<std::uint16_t> *rgba16, uint32_t width,
521#ifdef ACMXVK_WITH_MXVK_CUDA
522 void updateModelTextureCuda(
const cv::cuda::GpuMat &rgba,
523 cv::cuda::Stream &source_stream);
524 void updateCudaHistoryFrame(
const cv::cuda::GpuMat &rgba,
525 cv::cuda::Stream &source_stream);
526 void updateFilteredCudaHistoryFrame();
527 void initializeCudaHistory(
const cv::cuda::GpuMat &rgba,
528 cv::cuda::Stream &source_stream,
531 cv::cuda::Stream &source_stream);
532#ifdef ACMXVK_WITH_DEEP_DREAM
533 [[nodiscard]]
bool readCudaDeepDreamFrame();
535 [[nodiscard]]
const cv::cuda::GpuMat &
536 rotateCudaFrame(
const cv::cuda::GpuMat &rgba,
537 cv::cuda::Stream &source_stream);
std::chrono::steady_clock::duration source_playback_paused_duration
bool render_pacing_started
std::unordered_map< std::string, fs::path > shader_reload_overrides
std::unique_ptr< midi::MidiInput > midi_input
std::unique_ptr< audio::FileAudioSource > file_audio_source
float model_rotation_y_degrees
fs::path shader_library_directory
InterfaceClient interface_client
void configureMidiMappings()
void requestSnapshot(SnapshotFormat format)
bool shader_history_required
mxvk::ModelFragmentUniforms model_fragment_uniforms
std::uint64_t previous_autopilot_video_frame
void updateCrossfade(const std::chrono::steady_clock::time_point now)
std::chrono::steady_clock::time_point hud_session_start
bool async_camera_initial_wait_completed
bool model_video_timeline_initialized
fs::path resolvedShaderPath(const fs::path &shader) const
std::uint64_t hud_fps_frame_count
void queueRuntimeHud(int &y, int line_height)
std::mt19937 autopilot_rng
std::vector< mxvk::VK_Sprite * > post_process_sprites
double camera_last_logged_fps
bool random_dream_timeline_initialized
void paceMaximizedRendering()
std::uint64_t output_frame_count
int camera_reported_width
void event(SDL_Event &event) override
bool shader_spectrum_history_required
void setSourcePlaybackClockPaused(bool paused)
std::chrono::steady_clock::time_point source_playback_clock_start
std::chrono::steady_clock::time_point source_playback_pause_start
bool model_mouse_dragging
mxvk::VK_Sprite * crossfade_previous_sprite
bool recording_frame_has_pts
void adjustAudioSensitivity(float amount)
float model_wave_direction_y
std::chrono::steady_clock::time_point camera_fps_last_tick
bool legacy_alpha_increasing
void cycleCrossfade(int direction)
float audio_warmup_envelope
void adjustModelScale(float amount)
double crossfade_start_video_timeline
void dispatchMidiAction(int action)
const std::vector< fs::path > * activePasses() const
void updateHumanOverlayTexture()
float model_rotation_z_degrees
bool mediaClockSeconds(double &seconds) const
double previous_random_dream_timeline
std::vector< float > custom_uniform_values
bool hdr_input_precision_enabled
void onSwapchainRecreated() override
std::chrono::steady_clock::time_point audio_warmup_last_tick
std::string activePassDescription() const
bool media_clock_sync_logged
double hudVideoPositionSeconds() const
fs::path model_effect_shader
std::chrono::steady_clock::time_point window_title_last_update
std::deque< ReadbackRequest > readback_requests
MainWindow(Options options)
std::uint64_t generated_frame_count
std::uint64_t png_frame_count
float model_camera_distance
void applyCustomUniformOverrides()
float model_camera_movement_speed
void onRecordPostProcessingTexture(VkCommandBuffer command_buffer, std::uint32_t image_index, VkImageView texture_view, VkExtent2D texture_extent) override
void apply_interface_gpu_filter_state(const InterfaceGpuFilterState &requested, bool announce)
void apply_interface_audio_file_state(const InterfaceAudioFileState &requested)
int history_delay_counter
void updateCameraHistory()
double camera_reported_fps
fs::path shader_manifest_path
std::vector< MidiKnobState > midi_knob_states
void apply_interface_shader_reload(const InterfaceReloadState &requested)
bool crossfade_uses_video_timeline
void updateWindowTitle(bool force=false)
bool continuousReadbackEnabled() const
void applyDnnEffects(cv::Mat &rgba)
std::array< int, 4 > midi_slider_uniform_indices
std::string_view activeShaderRole() const
float updateAudioWarmup(std::chrono::steady_clock::time_point now)
float model_wave_audio_step
fs::path directModelFragmentShader() const
std::uint64_t recording_frame_pts
int preview_overlay_font_size
mxvk::VK_Sprite * frame_sprite
void handleFrameReadback(std::vector< std::uint8_t > &rgba, const std::vector< std::uint16_t > *rgba16, uint32_t width, uint32_t height)
fs::path png_output_directory
std::chrono::steady_clock::time_point interface_next_connect_attempt
bool audio_warmup_started
std::uint64_t observed_midi_drops
void onRecordCustomRendering(VkCommandBuffer command_buffer, std::uint32_t image_index) override
bool readLatestCameraFrame()
void onFrameReadbackRgba16(std::vector< std::uint16_t > &rgba, uint32_t width, uint32_t height) override
bool readTrackedInputFrame()
bool isMidiModelAction(int action) const
bool isMidiMappingSupported(const midi::MidiMapping &mapping) const
void selectGpuFilter(int direction)
bool model_scale_oscillation_active
void apply_interface_deep_dream_state(const InterfaceDeepDreamState &requested, bool announce)
void resolveConfiguredResourcePaths()
bool spectrumHistoryEnabledForShaders() const
std::uint64_t next_clock_output_frame
std::chrono::steady_clock::time_point crossfade_start_time
bool camera_recording_clock_logged
float model_view_rotation_degrees
static std::string formatHudTime(double seconds_value)
bool applyMidiCc(const midi::MidiMessage &message)
void startMediaTimelineIfReady()
bool video_shader_timeline_initialized
void updateRandomDreamSettings()
void apply_interface_overlay_state(const InterfaceOverlayState &requested, bool announce)
std::chrono::steady_clock::time_point previous_frame
bool initial_frame_pending
double previous_video_shader_timeline
void apply_interface_playback_state(const InterfacePlaybackState &requested, bool announce)
std::chrono::steady_clock::time_point hud_fps_last_tick
int autopilot_interval_frames
static bool usesMidiDeltaDirection(const midi::MidiMapping &mapping)
bool async_camera_frame_uploaded
std::string hudVideoTimeString() const
int headless_progress_last_percent
bool autopilot_random_crossfade
bool readHostRgba(cv::Mat &rgba)
void toggleAutopilot(bool sequential)
bool audioSourceOpen() const
float model_pitch_degrees
std::uint32_t interface_last_reload_sequence
bool hdr_transfer_processing_enabled
void recordModel(VkCommandBuffer command_buffer, std::uint32_t image_index, VkImageView texture_view)
void applyShaderPipeline()
bool hdr_cuda_filter_bypass_logged
void logSelectedPlaylistNode(std::string_view action) const
std::unique_ptr< audio::AudioEngine > audio_engine
double video_duration_seconds
bool hdr_dream_compatibility_logged
std::vector< MidiCcMapping > midi_cc_mappings
bool spectrum_scale_by_sensitivity
mxvk::VK_Sprite * human_overlay_sprite
bool historyCacheEnabled() const
bool headless_shutdown_logged
void apply_interface_uniform_values(const std::vector< InterfaceUniformValue > &uniform_values)
std::vector< fs::path > activeShaderPipeline() const
std::size_t crossfade_shader_index
std::chrono::steady_clock::time_point next_render_tick
void stepShaderTime(double amount)
std::uint64_t previous_model_video_frame
bool source_playback_clock_paused
double camera_delivered_fps
VideoHdrInfo video_hdr_info
std::uint64_t frame_count
void updateCameraFrameRate()
void initializeGpuFilters()
void onFrameReadbackScheduled() override
bool hostPreprocessingEnabled() const
float model_wave_amplitude_z
double hudWallElapsedSeconds() const
std::string activePlaylistDescription() const
bool autopilot_sequential
void handleDeepDreamRuntimeError(std::string_view message)
int camera_reported_height
SnapshotFormat pending_snapshot_format
void startLiveAudioRecordingIfNeeded()
std::string hudElapsedTimeString() const
std::pair< int, int > source_dimensions()
void apply_interface_multipass_state(const InterfaceMultipassState &requested)
std::uint64_t camera_fps_frame_count
void initializeDeepDream()
static std::string captureFourccName(double value)
float model_wave_direction_z
void uploadCustomUniforms()
void initializeHistory(const cv::Mat &rgba)
float model_scale_oscillation_phase
float model_wave_direction_x
std::uint32_t spectrumBinCount() const
std::size_t playlist_index
void applyDeepDreamEffect(cv::Mat &rgba)
std::chrono::steady_clock::time_point camera_history_next_update
bool handleCaptureEnd(bool discard=false)
bool source_frame_received
void configureRenderResolution()
std::uint32_t interface_last_audio_file_sequence
void adjustTimeSpeed(double amount)
void uploadInputFrame(const cv::Mat &rgba)
SDL_Keycode midiActionKey(int action) const
float model_camera_rotation_speed
bool autopilot_video_timeline_initialized
bool readClockedVideoFrame(double clock_seconds)
bool currentVideoTimeline(double &timeline, std::uint64_t *frame_index=nullptr) const
float model_rotation_speed
void updateShaderUniforms(int width, int height)
LatestCameraFrame latest_camera_frame
std::chrono::steady_clock::time_point headless_progress_last_emit
bool headless_progress_complete
std::vector< fs::path > configured_passes
bool applyMidiMap(const midi::MidiMessage &message)
void maybeRandomizeCrossfade()
bool spectrumTextureEnabledForShaders() const
std::vector< midi::MidiMapping > midi_action_mappings
void apply_interface_shader_selection(const std::string &requested_name)
bool isMidiSliderMapping(const midi::MidiMapping &mapping) const
bool hdr_dnn_compatibility_logged
void resetAutopilotInterval()
bool video_shader_clock_logged
cv::Mat human_overlay_rgba
bool interface_connection_warning_reported
void recordShaderResources(const mxvk::ShaderModuleInfo &module_info, std::string_view source)
float model_rotation_x_degrees
bool camera_history_clock_started
bool dream_processing_logged
void sync_interface_control()
fs::path generate_output_directory
void initializeOverlayFont()
std::vector< PlaylistNode > playlist
bool model_texture_prepass_active
static std::string clipOverlayText(std::string text)
static constexpr std::uint32_t COMPATIBILITY_SPECTRUM_BIN_COUNT
bool setMidiUniform(std::size_t uniform_index, int value, std::string_view label)
std::uint64_t snapshot_count
std::uint64_t autopilotFrameAdvance()
mxvk::VKAbstractModel input_model
void emitHeadlessProgress(bool complete)
std::chrono::steady_clock::time_point compatibility_clock_start
std::vector< fs::path > shaders
void onFrameReadback(std::vector< std::uint8_t > &rgba, uint32_t width, uint32_t height) override
bool shader_spectrum_required
std::vector< ShaderManifest::CustomUniform > custom_uniforms
bool hdr_input_upload_logged
void updateHudFrameRate()
std::uint32_t interface_last_sequence
void start_requested_audio_recording()
std::string_view midiActionName(int action) const
void updateHistoryFrame(const cv::Mat &rgba)
cv::Mat latest_camera_history_rgba
bool media_timeline_started
std::size_t crossfade_post_process_index
std::mt19937 random_dream_rng
void initialize_interface_control()
std::uint64_t video_source_frame_count
std::chrono::steady_clock::time_point model_last_render_time
std::string currentShader() const
SnapshotWriter snapshot_writer
void dispatchMidiModelAction(int action)
void selectShader(int direction)
void printCustomUniforms() const
float model_wave_amplitude_y
std::uint64_t decoded_video_frame_count
std::uint64_t random_dream_period
void selectPlaylistNode(int direction)
float model_wave_amplitude_x
void request_headless_shutdown(int signal_number) noexcept
std::size_t uniform_index
SnapshotFormat snapshot_format
std::string watermark_text