Refine GVFG preview pacing and error reporting
- Replace non-blocking Present retries with Present(0, 0), allowing DXGI to wait for presentation dependencies on the dedicated preview worker. - Change preview admission from newest-frame replacement to bounded FIFO delivery with three pending/upload reservations and one presenting slot. - Expire queued preview frames after 50 ms before GPU processing and skip new preview submissions only when the bounded slot capacity is full. - Track queue order and queue age without retaining SDK-owned frame memory; capture continues releasing each SDK frame after the synchronous upload. - Service only synchronous Windows sent messages while waiting for preview mutexes, worker shutdown, idle drain, and capture-thread join to avoid an HWND-owner/DXGI deadlock without dispatching queued application callbacks. - Preserve internal preview pacing and audio queue counters while removing expected busy, expired, and audio-eviction reports from the normal UI log. - Reserve delivery error logs for preview/render failures, video or audio frame-ID anomalies, audio write failures, and final accounting mismatches. - Remove the normal stop summary and the audio queue-drop field from the status display so expected pacing adjustments are not presented as faults. - Update the public preview comments and diagnostic documentation for the FIFO capacity, queue-age boundary, blocking Present behavior, and log policy. - Keep the capture SDK, driver interfaces, frame ownership, GPU conversion precision, and public delivery-statistics structure unchanged. Validation: - User testing reported approximately 18% GPU utilization for one 1920x1080 Y210 10-bit preview channel. This was not independently benchmarked. - A user-provided long-run log contained 13,715,695 received video frames with no preview render failures; periodic preview skips matched the confirmed 60.000 FPS versus 59.94 Hz pacing difference. - The same log showed periodic audio playback-queue eviction without audio frame-ID gaps or write failures; this is retained as internal diagnostic accounting rather than reported as a source-delivery error. - Static source review and git diff --check passed. No application, shader, or driver build was performed by the agent, and runtime deadlock behavior has not been independently reproduced or validated.
This commit is contained in:
@@ -5,11 +5,11 @@ The preview worker now runs:
|
|||||||
1. Execute the upload slot's command list (the SDK frame was already released by the caller).
|
1. Execute the upload slot's command list (the SDK frame was already released by the caller).
|
||||||
2. Convert packed YUY2/Y210 into a full-resolution FP16 target.
|
2. Convert packed YUY2/Y210 into a full-resolution FP16 target.
|
||||||
3. Sample that FP16 target directly into the 8-bit or 10-bit swapchain, preserving aspect ratio.
|
3. Sample that FP16 target directly into the 8-bit or 10-bit swapchain, preserving aspect ratio.
|
||||||
4. Present. Startup retries repeat only Present, not the draw.
|
4. Present(0, 0). DXGI handles presentation waits; no application retry loop.
|
||||||
|
|
||||||
Compared with the previous preview, this removes one full-frame FP16 CopyResource per image. The 8-bit path also removes an intermediate BGRA8 draw and quantizes only at the swapchain. FP16 precision and the requested swapchain bit depth remain; no capture-frame decimation was added. Scaled 8-bit output may differ slightly because rounding now occurs after scaling instead of before it.
|
Compared with the previous preview, this removes one full-frame FP16 CopyResource per image. The 8-bit path also removes an intermediate BGRA8 draw and quantizes only at the swapchain. FP16 precision and the requested swapchain bit depth remain; no capture-frame decimation was added. Scaled 8-bit output may differ slightly because rounding now occurs after scaling instead of before it.
|
||||||
|
|
||||||
Each of the three upload slots owns its SRV; the worker no longer creates an SRV for every preview frame. YUY2/Y210 shaders use one packed texture load per output pixel. The old ProcAmp settings were fixed at neutral, so unused neighbor sharpness reads and neutral color adjustments were removed; BT.709 coefficients, packing, Y210 word shifts and odd-tail chroma behavior remain. Constant-buffer data updates only when source dimensions change, but its binding is restored each draw.
|
Each of the four upload slots owns its SRV; the worker no longer creates an SRV for every preview frame. YUY2/Y210 shaders use one packed texture load per output pixel. The old ProcAmp settings were fixed at neutral, so unused neighbor sharpness reads and neutral color adjustments were removed; BT.709 coefficients, packing, Y210 word shifts and odd-tail chroma behavior remain. Constant-buffer data updates only when source dimensions change, but its binding is restored each draw.
|
||||||
|
|
||||||
Preview-only resource initialization allocates only the FP16 conversion target, omitting scene, BGRA8 export, RGB10 export and NV12 planes. Export conversion still uses the default full resource path; no public capture or buffer API signature changed. Export shaders are not compiled for preview-only initialization.
|
Preview-only resource initialization allocates only the FP16 conversion target, omitting scene, BGRA8 export, RGB10 export and NV12 planes. Export conversion still uses the default full resource path; no public capture or buffer API signature changed. Export shaders are not compiled for preview-only initialization.
|
||||||
|
|
||||||
@@ -24,3 +24,7 @@ User validation reported after the source change: GPU utilization decreased by a
|
|||||||
Build the preview DLL with the changed shared pipeline source. If distributing the SDK GPU buffer converter, rebuild that DLL too because it shares the shader source. Keep the APP and preview DLL from the same delivery-statistics API revision.
|
Build the preview DLL with the changed shared pipeline source. If distributing the SDK GPU buffer converter, rebuild that DLL too because it shares the shader source. Keep the APP and preview DLL from the same delivery-statistics API revision.
|
||||||
|
|
||||||
On the target Ryzen 7 7700 system, compare identical resolution/FPS/window size and input formats before/after. Check 8-bit and 10-bit colors (including gradients), resize/fullscreen, repeated Start/Stop, Present skip counts and GPU engine utilization. Also verify public BGRA8/RGB10A2/NV12 buffer conversion if shipping its rebuilt DLL. Capture HRESULT details if 10-bit still fails; do not infer insufficient GPU capacity solely from utilization.
|
On the target Ryzen 7 7700 system, compare identical resolution/FPS/window size and input formats before/after. Check 8-bit and 10-bit colors (including gradients), resize/fullscreen, repeated Start/Stop, Present skip counts and GPU engine utilization. Also verify public BGRA8/RGB10A2/NV12 buffer conversion if shipping its rebuilt DLL. Capture HRESULT details if 10-bit still fails; do not infer insufficient GPU capacity solely from utilization.
|
||||||
|
|
||||||
|
Expected preview pacing skips and audio queue evictions remain internal counters and are not logged. Preview/render failures, frame-ID anomalies, audio write failures, and delivery-accounting mismatches are logged as errors, aggregated at most once per five seconds. Mutex/drain/join waits service synchronous Windows sent messages without dispatching queued application input. Blocking Present still has no application timeout; device hangs and window transitions require hardware validation.
|
||||||
|
|
||||||
|
Preview queue policy: three pending/upload-reserved slots plus one presenting slot. Consume in enqueue order, keep frames within a 50 ms queue-age limit, and skip incoming frames only when capacity is full. Expired queued frames are counted in the existing replaced field (APP label: expired). This is not a 50 ms bound on blocking Present or physical scanout.
|
||||||
|
|||||||
@@ -67,9 +67,9 @@ typedef struct
|
|||||||
/*
|
/*
|
||||||
* Preview presentation statistics.
|
* Preview presentation statistics.
|
||||||
*
|
*
|
||||||
* present_fps counts only frames accepted by DXGI Present. A frame skipped
|
* present_fps counts only frames accepted by DXGI Present, not physical
|
||||||
* because the non-blocking swapchain is busy is excluded. The rate uses
|
* scanout. The rate uses successful presents from the most recent five
|
||||||
* successful presents from the most recent five seconds.
|
* seconds. Pending preview replacements are excluded from this rate.
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -87,7 +87,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
uint64_t submitted;
|
uint64_t submitted;
|
||||||
uint64_t presented;
|
uint64_t presented;
|
||||||
uint64_t replaced;
|
uint64_t replaced; /* Queued frames discarded after the 50 ms age limit. */
|
||||||
uint64_t busy;
|
uint64_t busy;
|
||||||
uint64_t failed;
|
uint64_t failed;
|
||||||
uint64_t cancelled;
|
uint64_t cancelled;
|
||||||
@@ -133,8 +133,10 @@ GVFG_PREVIEW_API gvfg_preview_status_t gvfg_preview_prepare(
|
|||||||
*
|
*
|
||||||
* The frame memory remains owned by the caller and must remain valid until
|
* The frame memory remains owned by the caller and must remain valid until
|
||||||
* this function returns. GPU conversion and Present continue on the internal
|
* this function returns. GPU conversion and Present continue on the internal
|
||||||
* preview worker. If preview falls behind, an older queued preview frame may
|
* preview worker. Up to three pending frames are retained in FIFO order.
|
||||||
* be replaced; capture ownership and capture-frame delivery are unaffected.
|
* Frames waiting longer than 50 ms are discarded; if the queue is full,
|
||||||
|
* the incoming frame is skipped. No SDK frame is retained for queueing.
|
||||||
|
* The age limit excludes time spent rendering or waiting inside Present.
|
||||||
*/
|
*/
|
||||||
GVFG_PREVIEW_API gvfg_preview_status_t gvfg_preview_render_frame(
|
GVFG_PREVIEW_API gvfg_preview_status_t gvfg_preview_render_frame(
|
||||||
gvfg_preview_handle handle,
|
gvfg_preview_handle handle,
|
||||||
|
|||||||
@@ -20,6 +20,30 @@
|
|||||||
|
|
||||||
using Microsoft::WRL::ComPtr;
|
using Microsoft::WRL::ComPtr;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
constexpr size_t kMaxPendingFrames = 3;
|
||||||
|
constexpr size_t kUploadSlotCount = kMaxPendingFrames + 1;
|
||||||
|
constexpr auto kMaxQueueAge = std::chrono::milliseconds(50);
|
||||||
|
// Blocking DXGI calls may send synchronous messages to the HWND owner.
|
||||||
|
// Service only sent messages while waiting; do not dispatch queued input,
|
||||||
|
// timers or application callbacks into Start/Stop recursively.
|
||||||
|
void serviceWindowMessages()
|
||||||
|
{
|
||||||
|
MsgWaitForMultipleObjectsEx(0, nullptr, 1, QS_SENDMESSAGE, MWMO_INPUTAVAILABLE);
|
||||||
|
MSG message{};
|
||||||
|
PeekMessageW(&message, nullptr, 0, 0, PM_NOREMOVE | PM_QS_SENDMESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_lock<std::mutex> lockWithWindowMessages(std::mutex &mutex)
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> lock(mutex, std::defer_lock);
|
||||||
|
while (!lock.try_lock())
|
||||||
|
serviceWindowMessages();
|
||||||
|
return lock;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class PreviewRenderer
|
class PreviewRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -28,10 +52,9 @@ public:
|
|||||||
|
|
||||||
bool configure(void *hwnd)
|
bool configure(void *hwnd)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
auto lock = lockWithWindowMessages(mutex_);
|
||||||
std::lock_guard<std::mutex> d3dLock(d3dMutex_);
|
auto d3dLock = lockWithWindowMessages(d3dMutex_);
|
||||||
resetPresentStats();
|
resetPresentStats();
|
||||||
startupPresentRetries_ = 8;
|
|
||||||
hwnd_ = hwnd;
|
hwnd_ = hwnd;
|
||||||
configured_ = hwnd_ != nullptr;
|
configured_ = hwnd_ != nullptr;
|
||||||
if (configured_ && ensureDevice())
|
if (configured_ && ensureDevice())
|
||||||
@@ -58,7 +81,7 @@ public:
|
|||||||
|
|
||||||
bool render(const gvfg_preview_frame_t &frame)
|
bool render(const gvfg_preview_frame_t &frame)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(mutex_);
|
auto lock = lockWithWindowMessages(mutex_);
|
||||||
if (!configured_ || !hwnd_ || !frame.data || frame.width <= 0 || frame.height <= 0)
|
if (!configured_ || !hwnd_ || !frame.data || frame.width <= 0 || frame.height <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -69,12 +92,15 @@ public:
|
|||||||
!ensureUploadSlotsLocked(frame.width, frame.height, frame.pixel_format))
|
!ensureUploadSlotsLocked(frame.width, frame.height, frame.pixel_format))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
discardExpiredLocked();
|
||||||
|
size_t pending = 0;
|
||||||
|
for (const auto &slot : slots_)
|
||||||
|
if (slot.state == SlotState::Pending || slot.state == SlotState::Uploading)
|
||||||
|
++pending;
|
||||||
size_t slotIndex = slots_.size();
|
size_t slotIndex = slots_.size();
|
||||||
for (size_t i = 0; i < slots_.size(); ++i)
|
for (size_t i = 0; i < slots_.size(); ++i)
|
||||||
if (slots_[i].state == SlotState::Free) { slotIndex = i; break; }
|
if (pending < kMaxPendingFrames && slots_[i].state == SlotState::Free)
|
||||||
if (slotIndex == slots_.size())
|
{ slotIndex = i; break; }
|
||||||
for (size_t i = 0; i < slots_.size(); ++i)
|
|
||||||
if (slots_[i].state == SlotState::Pending) { slotIndex = i; break; }
|
|
||||||
if (slotIndex == slots_.size())
|
if (slotIndex == slots_.size())
|
||||||
{
|
{
|
||||||
++skippedSubmits_;
|
++skippedSubmits_;
|
||||||
@@ -86,13 +112,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
UploadSlot &slot = slots_[slotIndex];
|
UploadSlot &slot = slots_[slotIndex];
|
||||||
if (slot.state == SlotState::Pending)
|
|
||||||
{
|
|
||||||
slot.commands.Reset();
|
|
||||||
++skippedSubmits_;
|
|
||||||
++delivery_.replaced;
|
|
||||||
}
|
|
||||||
slot.state = SlotState::Uploading;
|
slot.state = SlotState::Uploading;
|
||||||
|
slot.generation = clearGeneration_.load(std::memory_order_acquire);
|
||||||
ID3D11DeviceContext *deferred = slot.deferred.Get();
|
ID3D11DeviceContext *deferred = slot.deferred.Get();
|
||||||
ID3D11Texture2D *texture = slot.texture.Get();
|
ID3D11Texture2D *texture = slot.texture.Get();
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
@@ -124,14 +145,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
for (UploadSlot &other : slots_)
|
|
||||||
if (&other != &slot && other.state == SlotState::Pending)
|
|
||||||
{
|
|
||||||
other.commands.Reset();
|
|
||||||
other.state = SlotState::Free;
|
|
||||||
++skippedSubmits_;
|
|
||||||
++delivery_.replaced;
|
|
||||||
}
|
|
||||||
++delivery_.submitted;
|
++delivery_.submitted;
|
||||||
slot.commands = commands;
|
slot.commands = commands;
|
||||||
slot.width = frame.width;
|
slot.width = frame.width;
|
||||||
@@ -139,7 +152,8 @@ public:
|
|||||||
slot.bitDepth = sourceBitDepth;
|
slot.bitDepth = sourceBitDepth;
|
||||||
slot.pixelFormat = frame.pixel_format;
|
slot.pixelFormat = frame.pixel_format;
|
||||||
slot.frameId = frame.frame_id;
|
slot.frameId = frame.frame_id;
|
||||||
slot.generation = clearGeneration_.load(std::memory_order_acquire);
|
slot.queuedAt = std::chrono::steady_clock::now();
|
||||||
|
slot.queueOrder = ++queueOrder_;
|
||||||
slot.state = SlotState::Pending;
|
slot.state = SlotState::Pending;
|
||||||
workerCv_.notify_one();
|
workerCv_.notify_one();
|
||||||
return true;
|
return true;
|
||||||
@@ -147,7 +161,7 @@ public:
|
|||||||
|
|
||||||
bool prepare(int width, int height, int sourceBitDepth)
|
bool prepare(int width, int height, int sourceBitDepth)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
auto lock = lockWithWindowMessages(mutex_);
|
||||||
if (!configured_ || !hwnd_ || width <= 0 || height <= 0)
|
if (!configured_ || !hwnd_ || width <= 0 || height <= 0)
|
||||||
return false;
|
return false;
|
||||||
return ensureDevice() &&
|
return ensureDevice() &&
|
||||||
@@ -158,7 +172,7 @@ public:
|
|||||||
{
|
{
|
||||||
clearGeneration_.fetch_add(1, std::memory_order_acq_rel);
|
clearGeneration_.fetch_add(1, std::memory_order_acq_rel);
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
auto lock = lockWithWindowMessages(mutex_);
|
||||||
if (!configured_ || !pipeline_)
|
if (!configured_ || !pipeline_)
|
||||||
return false;
|
return false;
|
||||||
for (UploadSlot &slot : slots_)
|
for (UploadSlot &slot : slots_)
|
||||||
@@ -172,7 +186,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::lock_guard<std::mutex> d3dLock(d3dMutex_);
|
auto d3dLock = lockWithWindowMessages(d3dMutex_);
|
||||||
const bool cleared = pipeline_->clear_preview_black();
|
const bool cleared = pipeline_->clear_preview_black();
|
||||||
if (cleared)
|
if (cleared)
|
||||||
clearActiveInfo();
|
clearActiveInfo();
|
||||||
@@ -182,14 +196,18 @@ public:
|
|||||||
void shutdown()
|
void shutdown()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
auto lock = lockWithWindowMessages(mutex_);
|
||||||
workerStopping_ = true;
|
workerStopping_ = true;
|
||||||
workerCv_.notify_all();
|
workerCv_.notify_all();
|
||||||
}
|
}
|
||||||
if (worker_.joinable())
|
if (worker_.joinable())
|
||||||
|
{
|
||||||
|
while (WaitForSingleObject(worker_.native_handle(), 0) == WAIT_TIMEOUT)
|
||||||
|
serviceWindowMessages();
|
||||||
worker_.join();
|
worker_.join();
|
||||||
|
}
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
auto lock = lockWithWindowMessages(mutex_);
|
||||||
if (pipeline_)
|
if (pipeline_)
|
||||||
pipeline_->release_preview_swapchain();
|
pipeline_->release_preview_swapchain();
|
||||||
for (UploadSlot &slot : slots_)
|
for (UploadSlot &slot : slots_)
|
||||||
@@ -245,7 +263,7 @@ public:
|
|||||||
|
|
||||||
void getStats(gvfg_preview_stats_t &stats) const
|
void getStats(gvfg_preview_stats_t &stats) const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
auto lock = lockWithWindowMessages(mutex_);
|
||||||
stats.presented_frames = presentedFrames_;
|
stats.presented_frames = presentedFrames_;
|
||||||
stats.skipped_presents = skippedPresents_ + skippedSubmits_;
|
stats.skipped_presents = skippedPresents_ + skippedSubmits_;
|
||||||
stats.present_fps = active_.load(std::memory_order_relaxed)
|
stats.present_fps = active_.load(std::memory_order_relaxed)
|
||||||
@@ -255,7 +273,7 @@ public:
|
|||||||
|
|
||||||
void getDeliveryStats(gvfg_preview_delivery_stats_t &stats) const
|
void getDeliveryStats(gvfg_preview_delivery_stats_t &stats) const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
auto lock = lockWithWindowMessages(mutex_);
|
||||||
stats = delivery_;
|
stats = delivery_;
|
||||||
stats.in_flight = stats.submitted - stats.presented - stats.replaced -
|
stats.in_flight = stats.submitted - stats.presented - stats.replaced -
|
||||||
stats.busy - stats.failed - stats.cancelled;
|
stats.busy - stats.failed - stats.cancelled;
|
||||||
@@ -263,13 +281,25 @@ public:
|
|||||||
|
|
||||||
bool waitIdle(uint32_t timeoutMs)
|
bool waitIdle(uint32_t timeoutMs)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(mutex_);
|
const auto deadline = std::chrono::steady_clock::now() + std::chrono::milliseconds(timeoutMs);
|
||||||
return workerCv_.wait_for(lock, std::chrono::milliseconds(timeoutMs), [this] {
|
for (;;)
|
||||||
for (const auto &slot : slots_)
|
{
|
||||||
if (slot.state != SlotState::Free)
|
std::unique_lock<std::mutex> lock(mutex_, std::try_to_lock);
|
||||||
return false;
|
bool idle = lock.owns_lock();
|
||||||
return true;
|
if (idle)
|
||||||
});
|
{
|
||||||
|
for (const auto &slot : slots_)
|
||||||
|
if (slot.state != SlotState::Free)
|
||||||
|
idle = false;
|
||||||
|
}
|
||||||
|
if (idle)
|
||||||
|
return true;
|
||||||
|
if (lock.owns_lock())
|
||||||
|
lock.unlock();
|
||||||
|
if (std::chrono::steady_clock::now() >= deadline)
|
||||||
|
return false;
|
||||||
|
serviceWindowMessages();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -288,8 +318,23 @@ private:
|
|||||||
int pixelFormat = -1;
|
int pixelFormat = -1;
|
||||||
uint64_t frameId = 0;
|
uint64_t frameId = 0;
|
||||||
uint64_t generation = 0;
|
uint64_t generation = 0;
|
||||||
|
std::chrono::steady_clock::time_point queuedAt{};
|
||||||
|
uint64_t queueOrder = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void discardExpiredLocked()
|
||||||
|
{
|
||||||
|
const auto now = std::chrono::steady_clock::now();
|
||||||
|
for (auto &slot : slots_)
|
||||||
|
if (slot.state == SlotState::Pending && now - slot.queuedAt > kMaxQueueAge)
|
||||||
|
{
|
||||||
|
slot.commands.Reset();
|
||||||
|
slot.state = SlotState::Free;
|
||||||
|
++skippedSubmits_;
|
||||||
|
++delivery_.replaced; // Retired queued frame: expired, not latest-frame replacement.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct D3DState
|
struct D3DState
|
||||||
{
|
{
|
||||||
ComPtr<ID3D11Device> device;
|
ComPtr<ID3D11Device> device;
|
||||||
@@ -478,7 +523,7 @@ private:
|
|||||||
? DXGI_FORMAT_R16G16B16A16_UINT
|
? DXGI_FORMAT_R16G16B16A16_UINT
|
||||||
: DXGI_FORMAT_R8G8B8A8_UINT;
|
: DXGI_FORMAT_R8G8B8A8_UINT;
|
||||||
const UINT textureWidth = static_cast<UINT>((width + 1) / 2);
|
const UINT textureWidth = static_cast<UINT>((width + 1) / 2);
|
||||||
std::array<UploadSlot, 3> replacement{};
|
std::array<UploadSlot, kUploadSlotCount> replacement{};
|
||||||
for (UploadSlot &slot : replacement)
|
for (UploadSlot &slot : replacement)
|
||||||
{
|
{
|
||||||
if (FAILED(d3d_->device->CreateDeferredContext(0, &slot.deferred)))
|
if (FAILED(d3d_->device->CreateDeferredContext(0, &slot.deferred)))
|
||||||
@@ -515,7 +560,7 @@ private:
|
|||||||
size_t selected = slots_.size();
|
size_t selected = slots_.size();
|
||||||
UploadSlot work;
|
UploadSlot work;
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(mutex_);
|
auto lock = lockWithWindowMessages(mutex_);
|
||||||
workerCv_.wait(lock, [this] {
|
workerCv_.wait(lock, [this] {
|
||||||
if (workerStopping_)
|
if (workerStopping_)
|
||||||
return true;
|
return true;
|
||||||
@@ -526,77 +571,55 @@ private:
|
|||||||
});
|
});
|
||||||
if (workerStopping_)
|
if (workerStopping_)
|
||||||
break;
|
break;
|
||||||
|
discardExpiredLocked();
|
||||||
for (size_t i = 0; i < slots_.size(); ++i)
|
for (size_t i = 0; i < slots_.size(); ++i)
|
||||||
if (slots_[i].state == SlotState::Pending &&
|
if (slots_[i].state == SlotState::Pending &&
|
||||||
(selected == slots_.size() || slots_[i].frameId > slots_[selected].frameId))
|
(selected == slots_.size() || slots_[i].queueOrder < slots_[selected].queueOrder))
|
||||||
selected = i;
|
selected = i;
|
||||||
for (size_t i = 0; i < slots_.size(); ++i)
|
if (selected == slots_.size())
|
||||||
if (i != selected && slots_[i].state == SlotState::Pending)
|
continue;
|
||||||
{
|
|
||||||
slots_[i].commands.Reset();
|
|
||||||
slots_[i].state = SlotState::Free;
|
|
||||||
++skippedSubmits_;
|
|
||||||
++delivery_.replaced;
|
|
||||||
}
|
|
||||||
slots_[selected].state = SlotState::Presenting;
|
slots_[selected].state = SlotState::Presenting;
|
||||||
work = slots_[selected];
|
work = slots_[selected];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ready = false;
|
bool ready = false;
|
||||||
unsigned startupRetries = 0;
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
auto lock = lockWithWindowMessages(mutex_);
|
||||||
ready = configured_ && !workerStopping_ &&
|
ready = configured_ && !workerStopping_ &&
|
||||||
ensurePipeline(work.width, work.height, work.bitDepth);
|
ensurePipeline(work.width, work.height, work.bitDepth);
|
||||||
if (ready)
|
|
||||||
{
|
|
||||||
startupRetries = startupPresentRetries_;
|
|
||||||
startupPresentRetries_ = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
bool rendered = false;
|
bool rendered = false;
|
||||||
|
bool expired = false;
|
||||||
gvfg::internal::gvfg_preview_present_result_t presentResult =
|
gvfg::internal::gvfg_preview_present_result_t presentResult =
|
||||||
gvfg::internal::GVFG_PREVIEW_PRESENT_FAILED;
|
gvfg::internal::GVFG_PREVIEW_PRESENT_FAILED;
|
||||||
if (ready)
|
if (ready)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> d3dLock(d3dMutex_);
|
auto d3dLock = lockWithWindowMessages(d3dMutex_);
|
||||||
if (work.generation == clearGeneration_.load(std::memory_order_acquire))
|
if (work.generation == clearGeneration_.load(std::memory_order_acquire))
|
||||||
{
|
{
|
||||||
d3d_->context->ExecuteCommandList(work.commands.Get(), FALSE);
|
expired = std::chrono::steady_clock::now() - work.queuedAt > kMaxQueueAge;
|
||||||
const gvfg::internal::gvfg_render_pixfmt_t renderFmt =
|
if (!expired)
|
||||||
work.pixelFormat == GVFG_PREVIEW_PIXFMT_Y210
|
|
||||||
? gvfg::internal::GVFG_RENDER_FMT_Y210
|
|
||||||
: gvfg::internal::GVFG_RENDER_FMT_YUY2;
|
|
||||||
rendered = pipeline_->render_texture_to_fp16(work.texture.Get(), renderFmt,
|
|
||||||
work.width, work.height, work.view.Get());
|
|
||||||
if (rendered)
|
|
||||||
{
|
{
|
||||||
presentResult = pipeline_->present_preview(work.width, work.height);
|
d3d_->context->ExecuteCommandList(work.commands.Get(), FALSE);
|
||||||
const auto retryDeadline = std::chrono::steady_clock::now() +
|
const gvfg::internal::gvfg_render_pixfmt_t renderFmt =
|
||||||
std::chrono::milliseconds(16);
|
work.pixelFormat == GVFG_PREVIEW_PIXFMT_Y210
|
||||||
// Retry the same uploaded image only on the first presentation
|
? gvfg::internal::GVFG_RENDER_FMT_Y210
|
||||||
// after attach. Keep normal playback non-blocking. These waits
|
: gvfg::internal::GVFG_RENDER_FMT_YUY2;
|
||||||
// run on the preview worker, never while holding an SDK frame.
|
rendered = pipeline_->render_texture_to_fp16(work.texture.Get(), renderFmt,
|
||||||
while (presentResult == gvfg::internal::GVFG_PREVIEW_PRESENT_SKIPPED &&
|
work.width, work.height, work.view.Get());
|
||||||
startupRetries > 0 && std::chrono::steady_clock::now() < retryDeadline)
|
if (rendered)
|
||||||
{
|
presentResult = pipeline_->present_preview(work.width, work.height);
|
||||||
--startupRetries;
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(2));
|
|
||||||
if (work.generation != clearGeneration_.load(std::memory_order_acquire))
|
|
||||||
{
|
|
||||||
presentResult = gvfg::internal::GVFG_PREVIEW_PRESENT_FAILED;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (std::chrono::steady_clock::now() >= retryDeadline)
|
|
||||||
break;
|
|
||||||
presentResult = pipeline_->retry_preview_present();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
auto lock = lockWithWindowMessages(mutex_);
|
||||||
if (ready && rendered &&
|
if (expired)
|
||||||
|
{
|
||||||
|
++skippedSubmits_;
|
||||||
|
++delivery_.replaced;
|
||||||
|
}
|
||||||
|
else if (ready && rendered &&
|
||||||
presentResult != gvfg::internal::GVFG_PREVIEW_PRESENT_FAILED)
|
presentResult != gvfg::internal::GVFG_PREVIEW_PRESENT_FAILED)
|
||||||
{
|
{
|
||||||
recordPresentResult(presentResult);
|
recordPresentResult(presentResult);
|
||||||
@@ -634,7 +657,7 @@ private:
|
|||||||
|
|
||||||
bool ensurePipeline(int width, int height, int sourceBitDepth)
|
bool ensurePipeline(int width, int height, int sourceBitDepth)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> d3dLock(d3dMutex_);
|
auto d3dLock = lockWithWindowMessages(d3dMutex_);
|
||||||
if (!pipeline_)
|
if (!pipeline_)
|
||||||
pipeline_ = std::make_unique<gvfg::internal::D3DPreviewPipeline>();
|
pipeline_ = std::make_unique<gvfg::internal::D3DPreviewPipeline>();
|
||||||
|
|
||||||
@@ -669,8 +692,8 @@ private:
|
|||||||
uint64_t skippedPresents_ = 0;
|
uint64_t skippedPresents_ = 0;
|
||||||
uint64_t skippedSubmits_ = 0;
|
uint64_t skippedSubmits_ = 0;
|
||||||
gvfg_preview_delivery_stats_t delivery_{};
|
gvfg_preview_delivery_stats_t delivery_{};
|
||||||
unsigned startupPresentRetries_ = 0; // Protected by mutex_; rearmed on attach.
|
uint64_t queueOrder_ = 0;
|
||||||
std::array<UploadSlot, 3> slots_{};
|
std::array<UploadSlot, kUploadSlotCount> slots_{};
|
||||||
std::thread worker_;
|
std::thread worker_;
|
||||||
std::condition_variable workerCv_;
|
std::condition_variable workerCv_;
|
||||||
bool workerStarted_ = false;
|
bool workerStarted_ = false;
|
||||||
|
|||||||
@@ -1,21 +1,20 @@
|
|||||||
# 關鍵交付 Log
|
# 關鍵交付 Log
|
||||||
|
|
||||||
畫面保留原本狀態,不顯示完整交付統計,也不增加設定控制。正常運行不定期列印診斷快照。
|
畫面保留原本狀態,不顯示完整交付統計,也不增加設定控制。正常的預覽與音訊佇列取捨不輸出 Log。
|
||||||
|
|
||||||
- `Video issue`:預覽累計丟棄與原因。`replaced` 是舊影像被替換,`busy` 是無空槽/DXGI 忙碌跳過,`failed` 是提交或渲染失敗。
|
- 預覽排隊逾時或容量不足是顯示節拍取捨,不輸出 Log。只有提交/渲染失敗或序號異常增加時,才記錄 `ERROR preview delivery`。
|
||||||
- busy 發生時附上 `present`/`slots` 分類累計數與 `last_frame_id`,可確認忙碌來源。
|
- Audio 播放佇列滿而淘汰舊 PCM 區塊不輸出 Log。只有序號異常或寫入失敗時,才記錄 `ERROR audio delivery`。
|
||||||
- `Audio issue`:累計丟棄區塊/毫秒數、最長寫入停滯、最長收音間隔,以及最近丟棄 ID/時間。
|
|
||||||
- 序號缺口、倒退/重複、音訊失敗位元組僅在有異常時附上。
|
- 序號缺口、倒退/重複、音訊失敗位元組僅在有異常時附上。
|
||||||
- 異常最多每 5 秒彙整一次;累計數不漏計,最近 ID 不代表列出每個遺失區塊。Stop 會補記尚未輸出的異常。
|
- 錯誤最多每 5 秒彙整一次;Stop 會補記尚未輸出的錯誤。
|
||||||
- Stop 留一行 `Summary`。資料去向核對正常時不另外印訊息,只有不一致才印 `ERROR delivery accounting mismatch`。正常停止清掉的待處理資料不算運行丟失。
|
- Stop 不列印正常統計摘要。只有資料去向核對不一致時才印 `ERROR delivery accounting mismatch`。正常停止清掉的待處理資料不算運行錯誤。
|
||||||
|
|
||||||
## 拿到 Log 後怎麼處理
|
## 拿到 Log 後怎麼處理
|
||||||
|
|
||||||
Video 若以 replaced/busy 為主,查預覽/GPU 負載;failed 則查提交和渲染錯誤。APP 持續讀取並釋放每張影像,沒有新增預覽降頻行為。
|
`ERROR preview delivery` 表示提交/渲染失敗或 frame ID 異常,需查 Preview API、GPU 與來源序號。APP 持續讀取並釋放每張影像,沒有新增預覽降頻行為。
|
||||||
|
|
||||||
啟動/重新 attach 預覽後,第一次呈現若 DXGI 回報忙碌,預覽執行緒會保留同一張已上傳的影像,每次等待 2 ms 再試,最多 8 次,且到達 16 ms 重試期限後不再發起重試(排程或呼叫本身可能使實際時間超過期限)。只有最終仍忙碌才計一次 preview drop;成功不算丟棄。平常呈現不重試,不清掉既有計數。等待不持有 SDK frame,但仍可能讓後續預覽影像被替換,替換照常計數。
|
預覽使用 Present(0, 0),讓 DXGI 等待呈現相依條件,不做外部重試。SyncInterval 仍為 0,並非每張都保證顯示。預覽改成 FIFO,最多保留 3 張待處理影像(包含正在上傳的容量保留),另有 1 個處理中槽位,共 4 個 GPU 槽。60 FPS 下 3 張約 50 ms;這不是刻意等滿 50 ms 才顯示。從上傳完成入列開始計時,等待超過 50 ms 的影像才丟棄(expired);容量滿時跳過新影像(busy),不替換仍在期限內的舊影像。50 ms 是開始處理前的等待期限,不含 GPU 執行/DXGI Present 等待,不保證端到端延遲或實體螢幕逐張呈現。Stop/關閉/鎖等待只處理 Windows 同步送達的視窗訊息,避免 DXGI 等待 UI 而 UI 又等待 worker;不處理一般排隊輸入或 Qt callbacks。
|
||||||
|
|
||||||
Audio 保留原本最多 10 個 PCM 區塊的播放佇列(`kMaxQueuedAudioFrames`);滿時丟掉最舊區塊,再加入新區塊。毫秒數只用來表示實際丟失的音訊長度,不控制容量。若偶發丟棄,先根據 Log 的寫入停滯/收音間隔查原因,再決定是否需要調整;最長收音間隔包含正常區塊間隔,不能直接當成丟失時間。
|
Audio 保留原本最多 10 個 PCM 區塊的播放佇列(`kMaxQueuedAudioFrames`);滿時丟掉最舊區塊,再加入新區塊。丟棄區塊、停滯與收音間隔仍保留為內部診斷計數,但不顯示在一般 Log;audio frame 不保證與 video frame 等長。
|
||||||
|
|
||||||
播放 write 失敗,或持續回傳 0、兩秒沒有進展,會記錄原因並停止通道;檢查音效裝置後重新 Start。此檢查無法中斷本身永不返回的 write 呼叫。
|
播放 write 失敗,或持續回傳 0、兩秒沒有進展,會記錄原因並停止通道;檢查音效裝置後重新 Start。此檢查無法中斷本身永不返回的 write 呼叫。
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,11 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#ifndef NOMINMAX
|
||||||
|
#define NOMINMAX
|
||||||
|
#endif
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
constexpr bool kChannel1UiVisible = false;
|
constexpr bool kChannel1UiVisible = false;
|
||||||
@@ -791,12 +796,11 @@ void MainWindow::updateSignalStatus(bool queryHardware)
|
|||||||
.arg(zeroCopy ? QStringLiteral("Zero-copy") : QStringLiteral("Copy"));
|
.arg(zeroCopy ? QStringLiteral("Zero-copy") : QStringLiteral("Copy"));
|
||||||
if (channel.audioEnabled)
|
if (channel.audioEnabled)
|
||||||
{
|
{
|
||||||
statusLines << QStringLiteral("CH%1 Audio | %2 Hz %3 ch %4-bit | queue_drops=%5")
|
statusLines << QStringLiteral("CH%1 Audio | %2 Hz %3 ch %4-bit")
|
||||||
.arg(channelIndex)
|
.arg(channelIndex)
|
||||||
.arg(channel.audioFormat.sample_rate)
|
.arg(channel.audioFormat.sample_rate)
|
||||||
.arg(channel.audioFormat.channels)
|
.arg(channel.audioFormat.channels)
|
||||||
.arg(channel.audioFormat.bits_per_sample)
|
.arg(channel.audioFormat.bits_per_sample);
|
||||||
.arg(static_cast<qulonglong>(channel.audioQueueDrops.load(std::memory_order_relaxed)));
|
|
||||||
}
|
}
|
||||||
statusLines << QStringLiteral("CH%1 Preview | %2 FPS | %3")
|
statusLines << QStringLiteral("CH%1 Preview | %2 FPS | %3")
|
||||||
.arg(channelIndex)
|
.arg(channelIndex)
|
||||||
@@ -1041,38 +1045,22 @@ void MainWindow::logDeliveryStatus(int channelIndex, bool finalSnapshot)
|
|||||||
const bool previewOk = c.previewHandle &&
|
const bool previewOk = c.previewHandle &&
|
||||||
gvfg_preview_get_delivery_stats(c.previewHandle, &p) == GVFG_PREVIEW_OK;
|
gvfg_preview_get_delivery_stats(c.previewHandle, &p) == GVFG_PREVIEW_OK;
|
||||||
const auto &b = c.previewBaseline;
|
const auto &b = c.previewBaseline;
|
||||||
const uint64_t replaced = previewOk ? p.replaced - b.replaced : 0;
|
|
||||||
const uint64_t busy = previewOk ? p.busy - b.busy : 0;
|
|
||||||
const uint64_t failed = (previewOk ? p.failed - b.failed : 0) + c.videoFailed.load();
|
const uint64_t failed = (previewOk ? p.failed - b.failed : 0) + c.videoFailed.load();
|
||||||
const uint64_t videoDrops = replaced + busy + failed;
|
const uint64_t videoIssues = failed + c.videoIdGaps.load() + c.videoIdResets.load();
|
||||||
const uint64_t videoIssues = videoDrops + c.videoIdGaps.load() + c.videoIdResets.load();
|
|
||||||
|
|
||||||
uint64_t audioIssues, audioDrops, audioGaps, audioResets, audioFailed, lastDropId;
|
uint64_t audioIssues, audioGaps, audioResets, audioFailed;
|
||||||
double droppedMs, writeStallMs, readGapMs;
|
|
||||||
bool audioAccounted;
|
bool audioAccounted;
|
||||||
qint64 lastDropTime;
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(c.audioQueueMutex);
|
std::lock_guard<std::mutex> lock(c.audioQueueMutex);
|
||||||
const double bytesPerSecond = static_cast<double>(c.audioFormat.sample_rate) *
|
|
||||||
c.audioFormat.channels * (c.audioFormat.bits_per_sample / 8);
|
|
||||||
droppedMs = bytesPerSecond > 0 ? c.audioDroppedBytes * 1000.0 / bytesPerSecond : 0;
|
|
||||||
audioDrops = c.audioQueueDrops.load();
|
|
||||||
audioGaps = c.audioIdGaps;
|
audioGaps = c.audioIdGaps;
|
||||||
audioResets = c.audioIdResets;
|
audioResets = c.audioIdResets;
|
||||||
audioFailed = c.audioFailedBytes;
|
audioFailed = c.audioFailedBytes;
|
||||||
audioIssues = audioDrops + audioGaps + audioResets + c.audioFailedBytes;
|
audioIssues = audioGaps + audioResets + audioFailed;
|
||||||
writeStallMs = c.audioMaxWriteStallMs;
|
|
||||||
readGapMs = c.audioMaxReadGapMs;
|
|
||||||
lastDropId = c.audioLastDropId;
|
|
||||||
lastDropTime = c.audioLastDropTimeMs;
|
|
||||||
audioAccounted = c.audioQueuedBytes == 0 && c.audioReceivedBytes ==
|
audioAccounted = c.audioQueuedBytes == 0 && c.audioReceivedBytes ==
|
||||||
c.audioAcceptedBytes + c.audioDroppedBytes + c.audioCancelledBytes + c.audioFailedBytes;
|
c.audioAcceptedBytes + c.audioDroppedBytes + c.audioCancelledBytes + c.audioFailedBytes;
|
||||||
}
|
}
|
||||||
if (finalSnapshot)
|
if (finalSnapshot)
|
||||||
{
|
{
|
||||||
appendLog(QStringLiteral("CH%1 Summary | video_received=%2 preview_drops=%3 | audio_drops=%4 (%5 ms)")
|
|
||||||
.arg(channelIndex).arg(count(c.videoReceived.load())).arg(count(videoDrops))
|
|
||||||
.arg(count(audioDrops)).arg(droppedMs, 0, 'f', 1));
|
|
||||||
const bool videoAccounted = previewOk && c.videoReceived.load() ==
|
const bool videoAccounted = previewOk && c.videoReceived.load() ==
|
||||||
c.videoSubmitted.load() + c.videoFailed.load() &&
|
c.videoSubmitted.load() + c.videoFailed.load() &&
|
||||||
c.videoSubmitted.load() == p.submitted - b.submitted;
|
c.videoSubmitted.load() == p.submitted - b.submitted;
|
||||||
@@ -1084,27 +1072,15 @@ void MainWindow::logDeliveryStatus(int channelIndex, bool finalSnapshot)
|
|||||||
// Also flush any changes since the last aggregate when stopping.
|
// Also flush any changes since the last aggregate when stopping.
|
||||||
if (videoIssues != c.lastLoggedVideoIssues)
|
if (videoIssues != c.lastLoggedVideoIssues)
|
||||||
{
|
{
|
||||||
QString message = QStringLiteral("CH%1 Video issue +%2 | preview_drops=%3 (replaced=%4 busy=%5 failed=%6)")
|
QString message = QStringLiteral("CH%1 ERROR preview delivery | failed=%2 id_gaps=%3 reset_or_duplicate=%4")
|
||||||
.arg(channelIndex).arg(count(videoIssues - c.lastLoggedVideoIssues)).arg(count(videoDrops))
|
.arg(channelIndex).arg(count(failed)).arg(count(c.videoIdGaps.load()))
|
||||||
.arg(count(replaced)).arg(count(busy)).arg(count(failed));
|
.arg(count(c.videoIdResets.load()));
|
||||||
if (busy)
|
|
||||||
message += QStringLiteral(" | busy_reason: present=%1 slots=%2 last_frame_id=%3")
|
|
||||||
.arg(count(p.present_busy - b.present_busy)).arg(count(p.slots_busy - b.slots_busy))
|
|
||||||
.arg(count(p.last_busy_id));
|
|
||||||
if (c.videoIdGaps.load() || c.videoIdResets.load())
|
|
||||||
message += QStringLiteral(" | id_gaps=%1 reset_or_duplicate=%2")
|
|
||||||
.arg(count(c.videoIdGaps.load())).arg(count(c.videoIdResets.load()));
|
|
||||||
appendLog(message);
|
appendLog(message);
|
||||||
}
|
}
|
||||||
if (audioIssues != c.lastLoggedAudioIssues)
|
if (audioIssues != c.lastLoggedAudioIssues)
|
||||||
{
|
{
|
||||||
QString message = QStringLiteral("CH%1 Audio issue | drops=%2 (%3 ms) max_write_stall=%4 ms max_read_gap=%5 ms last_drop=%6@%7")
|
QString message = QStringLiteral("CH%1 ERROR audio delivery | id_gaps=%2 reset_or_duplicate=%3 failed_bytes=%4")
|
||||||
.arg(channelIndex).arg(count(audioDrops)).arg(droppedMs, 0, 'f', 1)
|
.arg(channelIndex).arg(count(audioGaps)).arg(count(audioResets)).arg(count(audioFailed));
|
||||||
.arg(writeStallMs, 0, 'f', 1).arg(readGapMs, 0, 'f', 1).arg(count(lastDropId))
|
|
||||||
.arg(lastDropTime ? QDateTime::fromMSecsSinceEpoch(lastDropTime).toString(QStringLiteral("HH:mm:ss.zzz")) : QStringLiteral("--"));
|
|
||||||
if (audioGaps || audioResets || audioFailed)
|
|
||||||
message += QStringLiteral(" | id_gaps=%1 reset_or_duplicate=%2 failed_bytes=%3")
|
|
||||||
.arg(count(audioGaps)).arg(count(audioResets)).arg(count(audioFailed));
|
|
||||||
appendLog(message);
|
appendLog(message);
|
||||||
}
|
}
|
||||||
if (finalSnapshot || videoIssues != c.lastLoggedVideoIssues || audioIssues != c.lastLoggedAudioIssues)
|
if (finalSnapshot || videoIssues != c.lastLoggedVideoIssues || audioIssues != c.lastLoggedAudioIssues)
|
||||||
@@ -1327,7 +1303,17 @@ void MainWindow::captureReadLoop(int channelIndex)
|
|||||||
void MainWindow::joinCaptureThread(int channel)
|
void MainWindow::joinCaptureThread(int channel)
|
||||||
{
|
{
|
||||||
if (channels_[channel].captureThread.joinable())
|
if (channels_[channel].captureThread.joinable())
|
||||||
|
{
|
||||||
|
// The capture worker can wait behind preview resource updates. Keep
|
||||||
|
// DXGI's synchronous HWND messages flowing while joining it.
|
||||||
|
while (WaitForSingleObject(channels_[channel].captureThread.native_handle(), 0) == WAIT_TIMEOUT)
|
||||||
|
{
|
||||||
|
MsgWaitForMultipleObjectsEx(0, nullptr, 1, QS_SENDMESSAGE, MWMO_INPUTAVAILABLE);
|
||||||
|
MSG message{};
|
||||||
|
PeekMessageW(&message, nullptr, 0, 0, PM_NOREMOVE | PM_QS_SENDMESSAGE);
|
||||||
|
}
|
||||||
channels_[channel].captureThread.join();
|
channels_[channel].captureThread.join();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::audioReadLoop(int channelIndex)
|
void MainWindow::audioReadLoop(int channelIndex)
|
||||||
|
|||||||
@@ -1327,28 +1327,8 @@ gvfg_preview_present_result_t D3DPreviewPipeline::present_preview(int src_w, int
|
|||||||
ID3D11ShaderResourceView *nullSrv[1] = {nullptr};
|
ID3D11ShaderResourceView *nullSrv[1] = {nullptr};
|
||||||
ctx_->PSSetShaderResources(0, 1, nullSrv);
|
ctx_->PSSetShaderResources(0, 1, nullSrv);
|
||||||
|
|
||||||
return retry_preview_present();
|
// Let DXGI wait for presentation dependencies; no application retry loop.
|
||||||
}
|
HRESULT hr = preview_swapchain_->Present(0, 0);
|
||||||
|
|
||||||
gvfg_preview_present_result_t D3DPreviewPipeline::retry_preview_present()
|
|
||||||
{
|
|
||||||
if (!preview_swapchain_)
|
|
||||||
return GVFG_PREVIEW_PRESENT_FAILED;
|
|
||||||
HRESULT hr = preview_swapchain_->Present(0, DXGI_PRESENT_DO_NOT_WAIT);
|
|
||||||
if (hr == DXGI_ERROR_WAS_STILL_DRAWING)
|
|
||||||
{
|
|
||||||
static uint64_t s_presentBusyCount = 0;
|
|
||||||
++s_presentBusyCount;
|
|
||||||
if (s_presentBusyCount <= 5 || (s_presentBusyCount % 60) == 0)
|
|
||||||
{
|
|
||||||
char warn[256] = {};
|
|
||||||
std::snprintf(warn, sizeof(warn),
|
|
||||||
"[SharedScene] preview present skipped: swapchain busy count=%llu",
|
|
||||||
static_cast<unsigned long long>(s_presentBusyCount));
|
|
||||||
ssp_log_text(warn);
|
|
||||||
}
|
|
||||||
return GVFG_PREVIEW_PRESENT_SKIPPED;
|
|
||||||
}
|
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
char err[256] = {};
|
char err[256] = {};
|
||||||
|
|||||||
@@ -53,8 +53,6 @@ public:
|
|||||||
bool ensure_preview_swapchain(int w, int h);
|
bool ensure_preview_swapchain(int w, int h);
|
||||||
bool preview_swapchain_10bit() const { return preview_swapchain_10bit_; }
|
bool preview_swapchain_10bit() const { return preview_swapchain_10bit_; }
|
||||||
gvfg_preview_present_result_t present_preview(int src_w, int src_h);
|
gvfg_preview_present_result_t present_preview(int src_w, int src_h);
|
||||||
// Retry a busy Present while the caller retains exclusive context access.
|
|
||||||
gvfg_preview_present_result_t retry_preview_present();
|
|
||||||
bool clear_preview_black();
|
bool clear_preview_black();
|
||||||
DXGI_FORMAT preview_backbuffer_format() const;
|
DXGI_FORMAT preview_backbuffer_format() const;
|
||||||
DXGI_FORMAT scene_texture_format() const;
|
DXGI_FORMAT scene_texture_format() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user