#pragma once #include "../internal/gvfg_render_types.h" #include #include #include #include #include namespace gvfg::internal { class SharedScenePipeline { public: SharedScenePipeline() = default; ~SharedScenePipeline() = default; bool initialize(ID3D11Device *d3d, ID3D11DeviceContext *ctx, ID2D1DeviceContext *d2d_ctx, IDWriteFactory *dwrite = nullptr, ID2D1SolidColorBrush *white = nullptr, ID2D1SolidColorBrush *black = nullptr); void shutdown(); bool configurePreview(const gvfg_render_preview_desc_t &desc); void set_source_bit_depth(int bits); int source_bit_depth() const { return preview_source_bit_depth_; } void release_preview_swapchain(); bool create_shaders_and_states(); bool ensure_rt_and_pipeline(int w, int h); uint64_t last_ensure_rt_ns() const { return lastEnsureRtNs_; } uint64_t total_ensure_rt_ns() const { return totalEnsureRtNs_; } uint64_t ensure_rt_calls() const { return ensureRtCalls_; } bool last_ensure_rt_rebuilt() const { return lastEnsureRtRebuilt_; } const char *last_ensure_rt_rebuild_reason() const { return lastEnsureRtReason_; } bool ensure_preview_swapchain(int w, int h); bool preview_swapchain_10bit() const { return preview_swapchain_10bit_; } int preview_swapchain_mode() const { return preview_swapchain_mode_; } bool present_preview(int src_w, int src_h); DXGI_FORMAT preview_backbuffer_format() const; DXGI_FORMAT scene_texture_format() const; DXGI_FORMAT linear_fp16_texture_format() const; bool gpu_overlay_text(const wchar_t *text, int frame_w, int frame_h); bool composite_overlay_to_scene_fp16(int frame_w, int frame_h); bool blit_fp16_to_rgba8(int frame_w, int frame_h); bool upload_argb_frame(const void *data, int frame_w, int frame_h, int src_stride); bool render_uploaded_argb_to_fp16(int frame_w, int frame_h); bool upload_nv12_frame(const uint8_t *y, int stride_y, const uint8_t *uv, int stride_uv, int frame_w, int frame_h); bool upload_p010_frame(const uint8_t *y, int stride_y, const uint8_t *uv, int stride_uv, int frame_w, int frame_h); bool upload_yuy2_frame(const uint8_t *data, int src_stride, int frame_w, int frame_h); bool upload_y210_frame(const uint8_t *data, int src_stride, int frame_w, int frame_h); bool upload_v210_frame(const uint8_t *data, int src_stride, int frame_w, int frame_h); bool render_uploaded_yuv_to_fp16(gvfg_render_pixfmt_t fmt, int frame_w, int frame_h); bool copy_fp16_to_scene(); bool readback_to_frame(int frame_w, int frame_h, uint64_t pts_ns, uint64_t frame_id, gvfg_render_frame_t *out); bool export_scene_rgb10(const wchar_t *base_path, int raw_flags, bool export_tiff, bool export_stats, bool export_gigabyte_raw); ID3D11Device *d3d_ = nullptr; ID3D11DeviceContext *ctx_ = nullptr; ID2D1DeviceContext *d2d_ctx_ = nullptr; Microsoft::WRL::ComPtr rt_fp16_; Microsoft::WRL::ComPtr rtv_fp16_; Microsoft::WRL::ComPtr srv_fp16_; Microsoft::WRL::ComPtr rt_scene_fp16_; Microsoft::WRL::ComPtr rtv_scene_fp16_; Microsoft::WRL::ComPtr srv_scene_fp16_; Microsoft::WRL::ComPtr srv_rgba_; Microsoft::WRL::ComPtr ps_rgba8_to_preview_; Microsoft::WRL::ComPtr rt_rgba_; Microsoft::WRL::ComPtr upload_nv12_; Microsoft::WRL::ComPtr upload_yuy2_packed_; Microsoft::WRL::ComPtr upload_y210_packed_; Microsoft::WRL::ComPtr rtv_rgba_; Microsoft::WRL::ComPtr rt_stage_; Microsoft::WRL::ComPtr rt_scene_stage_fp16_; Microsoft::WRL::ComPtr cs_params_; Microsoft::WRL::ComPtr rt_uav_; Microsoft::WRL::ComPtr vs_; Microsoft::WRL::ComPtr ps_nv12_; Microsoft::WRL::ComPtr ps_p010_; Microsoft::WRL::ComPtr ps_yuy2_; Microsoft::WRL::ComPtr ps_y210_; Microsoft::WRL::ComPtr ps_fp16_to_rgba8_; Microsoft::WRL::ComPtr ps_fp16_to_preview_; Microsoft::WRL::ComPtr ps_composite_overlay_fp16_; Microsoft::WRL::ComPtr il_; Microsoft::WRL::ComPtr vb_; Microsoft::WRL::ComPtr samp_; Microsoft::WRL::ComPtr d2d_bitmap_rt_; Microsoft::WRL::ComPtr dwrite_; Microsoft::WRL::ComPtr d2d_white_; Microsoft::WRL::ComPtr d2d_black_; Microsoft::WRL::ComPtr overlay_rgba_; Microsoft::WRL::ComPtr overlay_rtv_; Microsoft::WRL::ComPtr overlay_srv_; void *preview_hwnd_ = nullptr; bool preview_enabled_ = false; bool preview_use_fp16_ = false; int preview_swapchain_mode_ = GVFG_RENDER_PREVIEW_BITDEPTH_10BIT; int preview_source_bit_depth_ = 0; bool preview_swapchain_10bit_ = false; DXGI_FORMAT preview_swapchain_format_ = DXGI_FORMAT_UNKNOWN; int preview_w_ = 0; int preview_h_ = 0; int rt_w_ = 0; int rt_h_ = 0; uint64_t lastEnsureRtNs_ = 0; uint64_t totalEnsureRtNs_ = 0; uint64_t ensureRtCalls_ = 0; bool lastEnsureRtRebuilt_ = false; const char *lastEnsureRtReason_ = "never"; Microsoft::WRL::ComPtr preview_swapchain_; Microsoft::WRL::ComPtr preview_backbuf_; Microsoft::WRL::ComPtr preview_rtv_; }; }