Loading...
Searching...
No Matches
AVHWFrameToQRhi.hpp File Reference

Small inline helpers for the AVFrame opaque → QRhiTexture pattern. More...

Detailed Description

Small inline helpers for the AVFrame opaque → QRhiTexture pattern.

Every hardware decoder in Gfx/Graph/decoders/ follows the same outer shape:

  1. Extract a native API handle from AVFrame::data[*] (per pixfmt).
  2. Do API-specific transformation (CopySubresourceRegion, av_hwframe_map, cuMemcpy2DAsync, CVMetalTextureCacheCreateTextureFromImage, ...).
  3. Wrap the resulting native handle in a non-owning QRhiTexture via newTexture + createFrom.

Steps 1 and 3 are the parts that recur identically across all six decoders. This header standardizes them as inline helpers so the decoders converge on the same shape and any future signature change in QRhi::createFrom is a one-place edit.

Step 2 stays per-decoder — it's irreducibly API-specific.

The decoders themselves (HWD3D11.hpp, HWD3D12.hpp, HWCUDA.hpp, HWVulkan.hpp, HWVAAPI.hpp, HWVideoToolbox.hpp) do not use these helpers yet.

Go to the source code of this file.

Classes

struct  score::gfx::interop::AVFrameD3D11
 D3D11VA: data[0] = ID3D11Texture2D*, data[1] = array index. More...
 

Namespaces

namespace  score
 Base toolkit upon which the software is built.
 
namespace  score::gfx
 Graphics rendering pipeline for ossia score.
 

Functions

std::unique_ptr< QRhiTexture > score::gfx::interop::wrapNativeTexture (QRhi &rhi, QRhiTexture::Format format, QSize size, quint64 nativeHandle, int layout=0, QRhiTexture::Flags flags={}) noexcept
 Wrap a native graphics-API handle in a non-owning QRhiTexture.
 
AVFrameD3D11 score::gfx::interop::avframeD3D11 (const AVFrame &f) noexcept
 
void * score::gfx::interop::avframeD3D12 (const AVFrame &f) noexcept
 D3D12VA: data[0] = AVD3D12VAFrame*.
 
uint64_t score::gfx::interop::avframeCudaPlane (const AVFrame &f, int plane) noexcept
 CUDA (NVDEC): data[plane] = CUdeviceptr cast to uint8_t*.
 
void * score::gfx::interop::avframeVulkanFrame (const AVFrame &f) noexcept
 Vulkan-native: data[0] = AVVkFrame*. After av_hwframe_map(DRM_PRIME) you get a separate AVFrame whose data[0] points to an AVDRMFrameDescriptor.
 
void * score::gfx::interop::avframeDRMDescriptor (const AVFrame &mapped) noexcept
 
void * score::gfx::interop::avframeVideoToolbox (const AVFrame &f) noexcept
 VideoToolbox: data[3] = CVPixelBufferRef.
 

Function Documentation

◆ wrapNativeTexture()

std::unique_ptr< QRhiTexture > score::gfx::interop::wrapNativeTexture ( QRhi &  rhi,
QRhiTexture::Format  format,
QSize  size,
quint64  nativeHandle,
int  layout = 0,
QRhiTexture::Flags  flags = {} 
)
inlinenoexcept

Wrap a native graphics-API handle in a non-owning QRhiTexture.

Parameters
rhithe target QRhi.
formattexture format the consumer will sample with.
sizelogical dimensions.
nativeHandlee.g. (quint64)ID3D11Texture2D*, (quint64)VkImage, (quint64)id<MTLTexture>, (quint64)ID3D12Resource*.
layoutVulkan: VkImageLayout. D3D11/D3D12/Metal: pass 0.
flagsadditional QRhiTexture::Flags (e.g. RenderTarget).

Returns a freshly-created QRhiTexture wrapping nativeHandle. The caller is responsible for the underlying native resource's lifetime — QRhiTexture::createFrom is non-owning.