Add GPU text overlays and streamline SDK conversion paths
- add an internal DirectWrite/Direct2D OSD core for YUY2 and Y210 with configurable position, font size, RGB color, and up to 32 printable ASCII characters - expose per-channel OSD set/clear APIs and blend only the visible overlay rectangle on the GPU while preserving the frame read/release contract and tracking native versus processed buffer ownership - convert native YUY2/Y210 directly to BGRA8, RGB10A2, or NV12 with reusable output resources, avoiding unnecessary FP16 intermediates and scene copies - draw native-size and reduced previews directly to the swapchain and allocate an FP16 intermediate only for enlarged previews while retaining the existing upload queue and format support - bump the SDK version to 1.0.2, fix the installed customer API reference path, update conversion and OSD documentation, and remove the old 0922 SDK archive Validation: git diff --cached --check passed before commit. No SDK rebuild or hardware runtime validation was performed in this commit pass.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
project(gvfg_osd_core LANGUAGES CXX)
|
||||
|
||||
add_library(gvfg_osd_core STATIC
|
||||
include/gvfg_osd.h
|
||||
src/gvfg_osd.cpp
|
||||
)
|
||||
|
||||
set_target_properties(gvfg_osd_core PROPERTIES
|
||||
AUTOMOC OFF
|
||||
AUTOUIC OFF
|
||||
AUTORCC OFF
|
||||
)
|
||||
|
||||
target_include_directories(gvfg_osd_core
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
target_link_libraries(gvfg_osd_core PUBLIC
|
||||
d2d1
|
||||
dwrite
|
||||
windowscodecs
|
||||
ole32
|
||||
)
|
||||
|
||||
if (MSVC)
|
||||
target_compile_options(gvfg_osd_core PRIVATE /utf-8 /EHsc)
|
||||
endif()
|
||||
@@ -0,0 +1,27 @@
|
||||
# GVFG OSD core
|
||||
|
||||
`gvfg_osd_core` is an internal static library that generates a full-frame
|
||||
YUV422 OSD surface when text settings change. It does not capture, process
|
||||
live video frames, communicate with the driver, or present a preview. The
|
||||
library is linked into `gvfg.dll`; it is not installed or shipped as a
|
||||
separate customer DLL.
|
||||
|
||||
The initial API supports:
|
||||
|
||||
- YUY2 and Y210 output
|
||||
- printable ASCII text, up to 32 characters
|
||||
- Arial-preferred font with DirectWrite fallback, configurable pixel size,
|
||||
RGB color, and `(x, y)` position
|
||||
- BT.709 limited-range RGB-to-YUV conversion
|
||||
- an 8-bit coverage mask (`0` transparent, `255` fully covered)
|
||||
|
||||
The caller owns all output memory. Width must be even. YUY2 requires at least
|
||||
`width * 2` bytes per output row; Y210 requires `width * 4`. The mask requires
|
||||
at least `width` bytes per row.
|
||||
|
||||
For live SDK OSD, `GpuOsdProcessor` caches the non-zero mask bounds, aligned
|
||||
to complete YUV422 pixel pairs. Only this rectangle is uploaded, blended,
|
||||
and read back each frame. The SDK preserves the complete native frame with
|
||||
memory copies and replaces the processed rectangle; CPU code does not blend
|
||||
pixels. Text with no visible coverage bypasses processing. The public frame
|
||||
format and read/release contract remain unchanged.
|
||||
@@ -0,0 +1,79 @@
|
||||
#ifndef GVFG_OSD_H
|
||||
#define GVFG_OSD_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define GVFG_OSD_MAX_TEXT_CHARACTERS 32u
|
||||
|
||||
typedef void *gvfg_osd_handle;
|
||||
|
||||
typedef enum gvfg_osd_status_t
|
||||
{
|
||||
GVFG_OSD_OK = 0,
|
||||
GVFG_OSD_EINVAL = -1,
|
||||
GVFG_OSD_ENOMEM = -2,
|
||||
GVFG_OSD_ERENDER = -3
|
||||
} gvfg_osd_status_t;
|
||||
|
||||
typedef enum gvfg_osd_pixel_format_t
|
||||
{
|
||||
GVFG_OSD_PIXFMT_YUY2 = 1,
|
||||
GVFG_OSD_PIXFMT_Y210 = 2
|
||||
} gvfg_osd_pixel_format_t;
|
||||
|
||||
/*
|
||||
* Generates an off-line OSD surface using the Arial system font. Text is
|
||||
* restricted to printable ASCII and at most GVFG_OSD_MAX_TEXT_CHARACTERS
|
||||
* characters. color_rgb is 0xRRGGBB.
|
||||
* Output YUV uses BT.709 limited range. The mask is one coverage byte per
|
||||
* pixel: 0 is transparent and 255 is fully covered.
|
||||
*/
|
||||
typedef struct gvfg_osd_config_t
|
||||
{
|
||||
uint32_t struct_size;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t pixel_format;
|
||||
const char *text;
|
||||
uint32_t text_length;
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
uint32_t font_size_px;
|
||||
uint32_t color_rgb;
|
||||
} gvfg_osd_config_t;
|
||||
|
||||
/* All buffers are caller-owned and are used only for the duration of render. */
|
||||
typedef struct gvfg_osd_output_t
|
||||
{
|
||||
uint32_t struct_size;
|
||||
void *yuv_data;
|
||||
uint64_t yuv_size;
|
||||
uint32_t yuv_stride;
|
||||
void *mask_data;
|
||||
uint64_t mask_size;
|
||||
uint32_t mask_stride;
|
||||
} gvfg_osd_output_t;
|
||||
|
||||
gvfg_osd_status_t gvfg_osd_create(
|
||||
gvfg_osd_handle *out_handle);
|
||||
|
||||
void gvfg_osd_destroy(
|
||||
gvfg_osd_handle handle);
|
||||
|
||||
gvfg_osd_status_t gvfg_osd_render(
|
||||
gvfg_osd_handle handle,
|
||||
const gvfg_osd_config_t *config,
|
||||
const gvfg_osd_output_t *output);
|
||||
|
||||
const char *gvfg_osd_strerror(
|
||||
gvfg_osd_status_t status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,310 @@
|
||||
#include "gvfg_osd.h"
|
||||
|
||||
#include <d2d1.h>
|
||||
#include <dwrite.h>
|
||||
#include <wincodec.h>
|
||||
#include <wrl/client.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <new>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using Microsoft::WRL::ComPtr;
|
||||
|
||||
namespace
|
||||
{
|
||||
struct OsdContext
|
||||
{
|
||||
ComPtr<IWICImagingFactory> wic;
|
||||
ComPtr<ID2D1Factory> d2d;
|
||||
ComPtr<IDWriteFactory> dwrite;
|
||||
bool ownsComInitialization = false;
|
||||
|
||||
~OsdContext()
|
||||
{
|
||||
dwrite.Reset();
|
||||
d2d.Reset();
|
||||
wic.Reset();
|
||||
if (ownsComInitialization)
|
||||
CoUninitialize();
|
||||
}
|
||||
};
|
||||
|
||||
uint8_t clampByte(double value)
|
||||
{
|
||||
return static_cast<uint8_t>(std::clamp(std::lround(value), 0L, 255L));
|
||||
}
|
||||
|
||||
struct Yuv8
|
||||
{
|
||||
uint8_t y;
|
||||
uint8_t u;
|
||||
uint8_t v;
|
||||
};
|
||||
|
||||
Yuv8 rgbToBt709Limited(uint32_t rgb)
|
||||
{
|
||||
const double r = static_cast<double>((rgb >> 16) & 0xffu);
|
||||
const double g = static_cast<double>((rgb >> 8) & 0xffu);
|
||||
const double b = static_cast<double>(rgb & 0xffu);
|
||||
return {
|
||||
clampByte(16.0 + 0.182586 * r + 0.614231 * g + 0.062007 * b),
|
||||
clampByte(128.0 - 0.100644 * r - 0.338572 * g + 0.439216 * b),
|
||||
clampByte(128.0 + 0.439216 * r - 0.398942 * g - 0.040274 * b)};
|
||||
}
|
||||
|
||||
bool checkedImageBytes(uint32_t stride, uint32_t height, uint64_t &bytes)
|
||||
{
|
||||
bytes = static_cast<uint64_t>(stride) * height;
|
||||
return height == 0 || bytes / height == stride;
|
||||
}
|
||||
|
||||
bool validAscii(const char *text, uint32_t length)
|
||||
{
|
||||
if (!text || length == 0 || length > GVFG_OSD_MAX_TEXT_CHARACTERS)
|
||||
return false;
|
||||
for (uint32_t i = 0; i < length; ++i)
|
||||
{
|
||||
const unsigned char c = static_cast<unsigned char>(text[i]);
|
||||
if (c < 0x20 || c > 0x7e)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::wstring widenAscii(const char *text, uint32_t length)
|
||||
{
|
||||
std::wstring result;
|
||||
result.reserve(length);
|
||||
for (uint32_t i = 0; i < length; ++i)
|
||||
result.push_back(static_cast<wchar_t>(static_cast<unsigned char>(text[i])));
|
||||
return result;
|
||||
}
|
||||
|
||||
gvfg_osd_status_t renderMask(OsdContext &context,
|
||||
const gvfg_osd_config_t &config,
|
||||
uint8_t *destination,
|
||||
uint32_t destinationStride)
|
||||
{
|
||||
ComPtr<IWICBitmap> bitmap;
|
||||
HRESULT hr = context.wic->CreateBitmap(config.width, config.height,
|
||||
GUID_WICPixelFormat32bppPBGRA,
|
||||
WICBitmapCacheOnLoad, &bitmap);
|
||||
if (FAILED(hr))
|
||||
return GVFG_OSD_ERENDER;
|
||||
|
||||
D2D1_RENDER_TARGET_PROPERTIES properties = D2D1::RenderTargetProperties(
|
||||
D2D1_RENDER_TARGET_TYPE_SOFTWARE,
|
||||
D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM,
|
||||
D2D1_ALPHA_MODE_PREMULTIPLIED));
|
||||
ComPtr<ID2D1RenderTarget> target;
|
||||
hr = context.d2d->CreateWicBitmapRenderTarget(bitmap.Get(), properties, &target);
|
||||
if (FAILED(hr))
|
||||
return GVFG_OSD_ERENDER;
|
||||
|
||||
const std::wstring text = widenAscii(config.text, config.text_length);
|
||||
|
||||
ComPtr<IDWriteTextFormat> format;
|
||||
hr = context.dwrite->CreateTextFormat(
|
||||
L"Arial", nullptr, DWRITE_FONT_WEIGHT_NORMAL,
|
||||
DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
|
||||
static_cast<float>(config.font_size_px), L"en-us", &format);
|
||||
if (FAILED(hr))
|
||||
return GVFG_OSD_ERENDER;
|
||||
|
||||
ComPtr<ID2D1SolidColorBrush> brush;
|
||||
hr = target->CreateSolidColorBrush(D2D1::ColorF(1.0f, 1.0f, 1.0f, 1.0f), &brush);
|
||||
if (FAILED(hr))
|
||||
return GVFG_OSD_ERENDER;
|
||||
|
||||
target->BeginDraw();
|
||||
target->Clear(D2D1::ColorF(0.0f, 0.0f));
|
||||
const D2D1_RECT_F layout = D2D1::RectF(
|
||||
static_cast<float>(config.x), static_cast<float>(config.y),
|
||||
static_cast<float>(config.width), static_cast<float>(config.height));
|
||||
target->DrawText(text.c_str(), config.text_length, format.Get(), layout,
|
||||
brush.Get(), D2D1_DRAW_TEXT_OPTIONS_CLIP,
|
||||
DWRITE_MEASURING_MODE_NATURAL);
|
||||
hr = target->EndDraw();
|
||||
if (FAILED(hr))
|
||||
return GVFG_OSD_ERENDER;
|
||||
|
||||
WICRect lockRect{0, 0, static_cast<INT>(config.width), static_cast<INT>(config.height)};
|
||||
ComPtr<IWICBitmapLock> lock;
|
||||
hr = bitmap->Lock(&lockRect, WICBitmapLockRead, &lock);
|
||||
if (FAILED(hr))
|
||||
return GVFG_OSD_ERENDER;
|
||||
|
||||
UINT sourceStride = 0;
|
||||
UINT sourceSize = 0;
|
||||
BYTE *source = nullptr;
|
||||
if (FAILED(lock->GetStride(&sourceStride)) ||
|
||||
FAILED(lock->GetDataPointer(&sourceSize, &source)) || !source)
|
||||
return GVFG_OSD_ERENDER;
|
||||
|
||||
for (uint32_t y = 0; y < config.height; ++y)
|
||||
{
|
||||
const uint8_t *sourceRow = source + static_cast<size_t>(y) * sourceStride;
|
||||
uint8_t *destinationRow = destination + static_cast<size_t>(y) * destinationStride;
|
||||
for (uint32_t x = 0; x < config.width; ++x)
|
||||
destinationRow[x] = sourceRow[x * 4u + 3u];
|
||||
}
|
||||
return GVFG_OSD_OK;
|
||||
}
|
||||
|
||||
void writeYuy2(const gvfg_osd_config_t &config,
|
||||
const gvfg_osd_output_t &output,
|
||||
const Yuv8 color)
|
||||
{
|
||||
auto *base = static_cast<uint8_t *>(output.yuv_data);
|
||||
const auto *mask = static_cast<const uint8_t *>(output.mask_data);
|
||||
constexpr Yuv8 black{16, 128, 128};
|
||||
for (uint32_t y = 0; y < config.height; ++y)
|
||||
{
|
||||
uint8_t *row = base + static_cast<size_t>(y) * output.yuv_stride;
|
||||
const uint8_t *maskRow = mask + static_cast<size_t>(y) * output.mask_stride;
|
||||
for (uint32_t x = 0; x < config.width; x += 2)
|
||||
{
|
||||
const bool first = maskRow[x] != 0;
|
||||
const bool second = maskRow[x + 1] != 0;
|
||||
row[x * 2u + 0u] = first ? color.y : black.y;
|
||||
row[x * 2u + 1u] = (first || second) ? color.u : black.u;
|
||||
row[x * 2u + 2u] = second ? color.y : black.y;
|
||||
row[x * 2u + 3u] = (first || second) ? color.v : black.v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void writeY210(const gvfg_osd_config_t &config,
|
||||
const gvfg_osd_output_t &output,
|
||||
const Yuv8 color)
|
||||
{
|
||||
auto *base = static_cast<uint8_t *>(output.yuv_data);
|
||||
const auto *mask = static_cast<const uint8_t *>(output.mask_data);
|
||||
const uint16_t blackY = static_cast<uint16_t>(16u * 4u) << 6u;
|
||||
const uint16_t blackC = static_cast<uint16_t>(128u * 4u) << 6u;
|
||||
const uint16_t colorY = static_cast<uint16_t>(color.y * 4u) << 6u;
|
||||
const uint16_t colorU = static_cast<uint16_t>(color.u * 4u) << 6u;
|
||||
const uint16_t colorV = static_cast<uint16_t>(color.v * 4u) << 6u;
|
||||
for (uint32_t y = 0; y < config.height; ++y)
|
||||
{
|
||||
auto *row = reinterpret_cast<uint16_t *>(base + static_cast<size_t>(y) * output.yuv_stride);
|
||||
const uint8_t *maskRow = mask + static_cast<size_t>(y) * output.mask_stride;
|
||||
for (uint32_t x = 0; x < config.width; x += 2)
|
||||
{
|
||||
const bool first = maskRow[x] != 0;
|
||||
const bool second = maskRow[x + 1] != 0;
|
||||
row[x * 2u + 0u] = first ? colorY : blackY;
|
||||
row[x * 2u + 1u] = (first || second) ? colorU : blackC;
|
||||
row[x * 2u + 2u] = second ? colorY : blackY;
|
||||
row[x * 2u + 3u] = (first || second) ? colorV : blackC;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
extern "C"
|
||||
{
|
||||
gvfg_osd_status_t gvfg_osd_create(gvfg_osd_handle *out_handle)
|
||||
{
|
||||
if (!out_handle)
|
||||
return GVFG_OSD_EINVAL;
|
||||
*out_handle = nullptr;
|
||||
|
||||
auto *context = new (std::nothrow) OsdContext();
|
||||
if (!context)
|
||||
return GVFG_OSD_ENOMEM;
|
||||
|
||||
HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
||||
if (FAILED(hr) && hr != RPC_E_CHANGED_MODE)
|
||||
{
|
||||
delete context;
|
||||
return GVFG_OSD_ERENDER;
|
||||
}
|
||||
context->ownsComInitialization = SUCCEEDED(hr);
|
||||
hr = CoCreateInstance(CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER,
|
||||
IID_PPV_ARGS(&context->wic));
|
||||
if (SUCCEEDED(hr))
|
||||
hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_MULTI_THREADED,
|
||||
context->d2d.ReleaseAndGetAddressOf());
|
||||
if (SUCCEEDED(hr))
|
||||
hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED,
|
||||
__uuidof(IDWriteFactory),
|
||||
reinterpret_cast<IUnknown **>(
|
||||
context->dwrite.ReleaseAndGetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
delete context;
|
||||
return GVFG_OSD_ERENDER;
|
||||
}
|
||||
|
||||
*out_handle = context;
|
||||
return GVFG_OSD_OK;
|
||||
}
|
||||
|
||||
void gvfg_osd_destroy(gvfg_osd_handle handle)
|
||||
{
|
||||
delete static_cast<OsdContext *>(handle);
|
||||
}
|
||||
|
||||
gvfg_osd_status_t gvfg_osd_render(gvfg_osd_handle handle,
|
||||
const gvfg_osd_config_t *config,
|
||||
const gvfg_osd_output_t *output)
|
||||
{
|
||||
if (!handle || !config || !output ||
|
||||
config->struct_size != sizeof(gvfg_osd_config_t) ||
|
||||
output->struct_size != sizeof(gvfg_osd_output_t) ||
|
||||
!validAscii(config->text, config->text_length) ||
|
||||
config->width == 0 || config->height == 0 || (config->width & 1u) != 0 ||
|
||||
config->font_size_px == 0 || !output->yuv_data || !output->mask_data)
|
||||
return GVFG_OSD_EINVAL;
|
||||
|
||||
uint32_t minimumYuvStride = 0;
|
||||
if (config->pixel_format == GVFG_OSD_PIXFMT_YUY2)
|
||||
minimumYuvStride = config->width * 2u;
|
||||
else if (config->pixel_format == GVFG_OSD_PIXFMT_Y210)
|
||||
minimumYuvStride = config->width * 4u;
|
||||
else
|
||||
return GVFG_OSD_EINVAL;
|
||||
|
||||
if (output->yuv_stride < minimumYuvStride || output->mask_stride < config->width)
|
||||
return GVFG_OSD_EINVAL;
|
||||
|
||||
uint64_t requiredYuv = 0;
|
||||
uint64_t requiredMask = 0;
|
||||
if (!checkedImageBytes(output->yuv_stride, config->height, requiredYuv) ||
|
||||
!checkedImageBytes(output->mask_stride, config->height, requiredMask) ||
|
||||
output->yuv_size < requiredYuv || output->mask_size < requiredMask)
|
||||
return GVFG_OSD_EINVAL;
|
||||
|
||||
std::memset(output->mask_data, 0, static_cast<size_t>(requiredMask));
|
||||
const gvfg_osd_status_t maskStatus = renderMask(
|
||||
*static_cast<OsdContext *>(handle), *config,
|
||||
static_cast<uint8_t *>(output->mask_data), output->mask_stride);
|
||||
if (maskStatus != GVFG_OSD_OK)
|
||||
return maskStatus;
|
||||
|
||||
const Yuv8 color = rgbToBt709Limited(config->color_rgb);
|
||||
if (config->pixel_format == GVFG_OSD_PIXFMT_YUY2)
|
||||
writeYuy2(*config, *output, color);
|
||||
else
|
||||
writeY210(*config, *output, color);
|
||||
return GVFG_OSD_OK;
|
||||
}
|
||||
|
||||
const char *gvfg_osd_strerror(gvfg_osd_status_t status)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case GVFG_OSD_OK: return "success";
|
||||
case GVFG_OSD_EINVAL: return "invalid argument";
|
||||
case GVFG_OSD_ENOMEM: return "out of memory";
|
||||
case GVFG_OSD_ERENDER: return "text rendering failed";
|
||||
default: return "unknown gvfg_osd status";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,34 @@
|
||||
# Preview GPU path
|
||||
# Preview GPU conversion paths
|
||||
|
||||
The preview worker now runs:
|
||||
`gvfg_preview.dll` remains independent of `gvfg.dll`. Both targets compile
|
||||
one shared private conversion source, `d3d_conversion_pipeline.cpp`, into
|
||||
their own DLLs. There is no cross-DLL bridge, new public texture API, or
|
||||
runtime SDK dependency in the preview helper.
|
||||
|
||||
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.
|
||||
3. Sample that FP16 target directly into the 8-bit or 10-bit swapchain, preserving aspect ratio.
|
||||
4. Present(0, 0). DXGI handles presentation waits; no application retry loop.
|
||||
CPU-buffer conversion uses dedicated outputs. YUY2/Y210 to NV12 preserves
|
||||
native luma and averages chroma vertically; Y210 codes are reduced to 8 bits.
|
||||
BGRA8 and RGB10A2 use one native RGB draw. No export path requires FP16 or a
|
||||
scene copy. Output targets and staging textures are allocated on demand and
|
||||
reused. Both NV12 plane copies are submitted before either CPU Map.
|
||||
|
||||
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.
|
||||
Preview uploads remain in the existing four slots, with three FIFO pending
|
||||
frames and a 50 ms queue-age limit. Native-size and reduced-size preview draw
|
||||
directly into the swapchain. Reduction interpolates decoded RGB. Enlargement
|
||||
lazily allocates one FP16 target and uses hardware bilinear sampling, avoiding
|
||||
repeated native decoding for each enlarged output sample. All five existing
|
||||
formats retain their color/bit-depth rules. Preview has no CPU readback.
|
||||
|
||||
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.
|
||||
## Verification (2026-10-12)
|
||||
|
||||
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.
|
||||
Rebuilt Release DLLs passed public YUY2/Y210 to BGRA8/RGB10A2/NV12 checks
|
||||
against independent CPU reference values, padded strides, chroma averaging,
|
||||
size/format switching, and odd-NV12 rejection. WARP and hardware tests of the
|
||||
private conversion source passed all five formats, 8/10-bit output, native,
|
||||
reduced and enlarged sizes, and cached/uncached source views. Actual independent
|
||||
preview DLL hidden-HWND tests passed format and precision switches, queue
|
||||
drain, clear and destruction. DLL imports and exports are checked separately.
|
||||
|
||||
Swapchain resize/release unbinds the render target before releasing local references. Preview configuration/resource changes and drawing share the D3D mutex. No GPU mutex is held while subsequently acquiring the renderer mutex in the worker completion path.
|
||||
|
||||
## Validation boundary
|
||||
|
||||
Source checks only in this change: no application/shader build, GPU timing or hardware playback test. These changes remove identifiable work but do not establish a GPU utilization reduction or identify the reported 10-bit startup failure.
|
||||
|
||||
User validation reported after the source change: GPU utilization decreased by approximately 15%. This is a user-reported observation, not an agent-run benchmark; baseline/final readings and whether the difference is relative or in percentage points were not specified. Resolution of the 10-bit startup failure was not reported.
|
||||
|
||||
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.
|
||||
|
||||
Expected preview pacing skips and audio queue evictions are not reported by the Sample. Preview/render failures, frame-ID anomalies, and audio write failures 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.
|
||||
These component tests do not establish long-run capture/recording stability,
|
||||
visible fullscreen behavior, physical monitor scanout, or Task Manager GPU
|
||||
percentages. Previous performance measurements motivated the adaptive scaling
|
||||
choice; this verification does not claim a new utilization benchmark.
|
||||
|
||||
@@ -643,10 +643,9 @@ private:
|
||||
renderFmt = gvfg::internal::GVFG_RENDER_FMT_RGBA16;
|
||||
else if (work.pixelFormat == GVFG_PREVIEW_PIXFMT_DICOM_YBR_FULL_422)
|
||||
renderFmt = gvfg::internal::GVFG_RENDER_FMT_DICOM_YBR_FULL_422;
|
||||
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);
|
||||
presentResult = pipeline_->present_texture(work.texture.Get(), work.view.Get(), renderFmt,
|
||||
work.width, work.height, work.bitDepth);
|
||||
rendered = presentResult != gvfg::internal::GVFG_PREVIEW_PRESENT_FAILED;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -708,7 +707,7 @@ private:
|
||||
desc.swapchain_10bit = gvfg::internal::GVFG_RENDER_PREVIEW_BITDEPTH_AUTO;
|
||||
pipeline_->configurePreview(desc);
|
||||
pipeline_->set_source_bit_depth(sourceBitDepth > 0 ? sourceBitDepth : 8);
|
||||
const bool ready = pipeline_->ensure_rt_and_pipeline(width, height, true) &&
|
||||
const bool ready = pipeline_->ensure_states() &&
|
||||
pipeline_->ensure_preview_swapchain(width, height);
|
||||
return ready;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user