mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-10-24 02:09:03 +03:00
vulkan_prores: pick the bitstream prefetch depth per device
Same situation as ProRes RAW: with the packet host-mapped, the VLD is bound by fetch latency over the bus. Make GET_BITS_SMEM a specialization constant: 32 lines per invocation on discrete GPUs reading host-mapped packets, 4 otherwise. The 8x8 workgroup makes that 32 KB of shared memory; 64 does not fit, and 40 or 48 measured slower. An integrated GPU loses a third of its speed at 32, so it keeps 4. The depth is clamped to maxComputeSharedMemorySize for 32 KB devices such as MoltenVK. 5.7K ProRes HQ on an RX 6900 XT: 85 -> 120 fps, bit-identical output.
This commit is contained in:
@@ -19,7 +19,9 @@
|
||||
#pragma shader_stage(compute)
|
||||
#extension GL_GOOGLE_include_directive : require
|
||||
|
||||
#define GET_BITS_SMEM 4
|
||||
/* Bitstream prefetch depth in 16-byte lines, set by the host */
|
||||
layout (constant_id = 1) const uint smem_lines = 4;
|
||||
#define GET_BITS_SMEM smem_lines
|
||||
#include "common.glsl"
|
||||
|
||||
layout (constant_id = 0) const bool interlaced = false;
|
||||
|
||||
@@ -374,8 +374,19 @@ static int init_decode_shader(AVCodecContext *avctx, FFVulkanContext *s,
|
||||
AVHWFramesContext *dec_frames_ctx;
|
||||
dec_frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data;
|
||||
|
||||
SPEC_LIST_CREATE(sl, 1, 1*sizeof(uint32_t))
|
||||
/* Discrete GPUs read host-mapped packets over the bus; prefetch more
|
||||
* to hide the latency. 32 lines (32 KB for the 8x8 workgroup) measured
|
||||
* best; integrated GPUs get slower with every extra line. Clamp to the
|
||||
* shared memory limit, leaving 1 KB for the tables. */
|
||||
int smem_lines = 4;
|
||||
if (s->props.properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU &&
|
||||
(s->extensions & FF_VK_EXT_EXTERNAL_HOST_MEMORY)) {
|
||||
uint32_t max_smem = s->props.properties.limits.maxComputeSharedMemorySize;
|
||||
smem_lines = FFMIN(32, (max_smem - 1024) / (8*8*16));
|
||||
}
|
||||
SPEC_LIST_CREATE(sl, 2, 2*sizeof(uint32_t))
|
||||
SPEC_LIST_ADD(sl, 0, 32, interlaced);
|
||||
SPEC_LIST_ADD(sl, 1, 32, smem_lines);
|
||||
|
||||
ff_vk_shader_load(shd,
|
||||
VK_SHADER_STAGE_COMPUTE_BIT, sl,
|
||||
|
||||
Reference in New Issue
Block a user