Closed v-fox closed 5 years ago
Intriguing, I'm not sure if I want to quite bump it up to 2048 though. To be honest even 64 commands on a single frame seems a bit excessive but I guess it's not unrealistic with a lot of shaders.. hmm...
I'm also not sure if there's a connection between that sched_hw_submission
number and the number of commands - I'm pretty sure we can queue up as many commands as we want, in theory - the only thing we want to avoid here is users forgetting to flush and then queueing up a gigantic number of commands at the same time?
Maybe we'll bump it up to 256. I'll keep the warning in place (even though it's just that - a warning) so we hear about it if this is the case in the future, again. Thoughts?
Settled on 1024 just arbitrarily. Feel free to suggest any other number if you have a good reason to.
Thanks ! Indeed, there probably no connection and I'm just guessing here. It just that 64 seamed low and it was strange for mpv to trigger the limit. Maybe it was triggered because I used mvtools to get ~73 "decoded" fps, from mpv's point of view, that it then had to process with shaders + 8 frame swap-chain + requested 16-24 of actually pre-decoded frames for mvtools in the first place to smooth out its processing time.
mvtools etc. all happens before the frame ever even reaches the video output, let alone the vulkan backend. I assumed it was just because you had a lot of render passes (custom shaders) but I just realized that this actually doesn't make sense: separate shaders go into the same vulkan command buffer. The only time we actually need to force a separate command to be queued is for transitions between queue families. We issue a flush on every vsync, so how many FPS you're getting shouldn't be relevant.
So it might be the case that this gets triggered iff you have a lot of compute shaders mixed with your graphics shaders? Oh, and one more thing, using mpv interpolation (--interpolation
) also might inflate this number, since it requires essentially rendering multiple frames in a single vsync. If that were the case, we'd expect that warning to only show up after seeks / at the start of playback, rather than getting spammed constantly.
A log would definitely help, if only to make sure there isn't actually an issue we're overlooking here.
mvtools etc. all happens before the frame ever even reaches the video output, let alone the vulkan backend.
And that's exactly what I was talking about: with my mvtools script every <480p video becomes ~73 fps video (not just output, so mpv's own interpolation isn't even used), so mpv now has to run all on all of those frames while keeping giant intermediate frame buffers and then give them out to the compositor one by one. Although, tscale is enabled and used to interpolate in cases when mvtools's output is capped (on >480p sources). As for shaders, I have "opengl/FSRCNNX_x2_8-0-4-1.glsl" and "compute-vulkan/ravu-r4-yuv.hook" which doesn't seem like "a lot" in quantity but is not insignificant in GPU load. Warning was, indeed, only single.
Here's part of mpv --profile=HSF-hq --msg-level=vo=v
with patched shapshot of libplacebo before the ~480p video shows up:
[vo/gpu] Probing for best GPU context.
[vo/gpu/vulkan] Initializing GPU context 'waylandvk'
[vo/gpu/vulkan/libplacebo] Creating vulkan instance with extensions:
[vo/gpu/vulkan/libplacebo] VK_KHR_get_physical_device_properties2
[vo/gpu/vulkan/libplacebo] VK_KHR_external_memory_capabilities
[vo/gpu/vulkan/libplacebo] VK_KHR_external_semaphore_capabilities
[vo/gpu/vulkan/libplacebo] VK_KHR_surface
[vo/gpu/vulkan/libplacebo] VK_KHR_wayland_surface
[vo/gpu/vulkan] Initializing GPU context 'x11vk'
[vo/gpu/vulkan/libplacebo] Creating vulkan instance with extensions:
[vo/gpu/vulkan/libplacebo] VK_KHR_get_physical_device_properties2
[vo/gpu/vulkan/libplacebo] VK_KHR_external_memory_capabilities
[vo/gpu/vulkan/libplacebo] VK_KHR_external_semaphore_capabilities
[vo/gpu/vulkan/libplacebo] VK_KHR_surface
[vo/gpu/vulkan/libplacebo] VK_KHR_xlib_surface
[vo/gpu/x11] X11 opening display: :0
[vo/gpu/x11] X11 running at 3840x1080 (":0" => local display)
[vo/gpu/x11] Detected wm supports NetWM.
[vo/gpu/x11] Detected wm supports FULLSCREEN state.
[vo/gpu/x11] Detected wm supports ABOVE state.
[vo/gpu/x11] Detected wm supports BELOW state.
[vo/gpu/x11] Detected wm supports STAYS_ON_TOP state.
[vo/gpu/x11] Display 0 (DVI-D-0): [0, 0, 1920, 1080] @ 72.924866 FPS
[vo/gpu/x11] Display 1 (HDMI-A-0): [1920, 0, 3840, 1080] @ 71.826321 FPS
[vo/gpu/x11] Current display FPS: 72.924866
[vo/gpu/vulkan/libplacebo] Probing for vulkan devices:
[vo/gpu/vulkan/libplacebo] GPU 0: AMD RADV POLARIS10 (LLVM 8.0.1) (discrete)
[vo/gpu/vulkan/libplacebo] GPU 1: AMD RADV POLARIS10 (LLVM 8.0.1) (discrete)
[vo/gpu/vulkan/libplacebo] Vulkan device properties:
[vo/gpu/vulkan/libplacebo] Device Name: AMD RADV POLARIS10 (LLVM 8.0.1)
[vo/gpu/vulkan/libplacebo] Device ID: 1002:67df
[vo/gpu/vulkan/libplacebo] Driver version: 79699968
[vo/gpu/vulkan/libplacebo] API version: 1.1.107
[vo/gpu/vulkan/libplacebo] Queue families supported by device:
[vo/gpu/vulkan/libplacebo] QF 0: flags 0xf num 1
[vo/gpu/vulkan/libplacebo] QF 1: flags 0xe num 4
[vo/gpu/vulkan/libplacebo] Using graphics queue (QF 0)
[vo/gpu/vulkan/libplacebo] Using async transfer (QF 1)
[vo/gpu/vulkan/libplacebo] Using async compute (QF 1)
[vo/gpu/vulkan/libplacebo] Creating vulkan device with extensions:
[vo/gpu/vulkan/libplacebo] VK_KHR_swapchain
[vo/gpu/vulkan/libplacebo] VK_KHR_push_descriptor
[vo/gpu/vulkan/libplacebo] VK_KHR_external_memory
[vo/gpu/vulkan/libplacebo] VK_KHR_external_memory_fd
[vo/gpu/vulkan/libplacebo] VK_EXT_external_memory_dma_buf
[vo/gpu/vulkan/libplacebo] VK_KHR_external_semaphore
[vo/gpu/vulkan/libplacebo] VK_KHR_external_semaphore_fd
[vo/gpu/vulkan/libplacebo] Initializing SPIR-V compiler 'shaderc'
[vo/gpu/vulkan/libplacebo] Memory heaps supported by device:
[vo/gpu/vulkan/libplacebo] heap 0: flags 0x1 size 8589934592
[vo/gpu/vulkan/libplacebo] heap 1: flags 0x0 size 8589934592
[vo/gpu/vulkan/libplacebo] Memory types supported by device:
[vo/gpu/vulkan/libplacebo] type 0: flags 0x6 heap 1
[vo/gpu/vulkan/libplacebo] type 1: flags 0x7 heap 0
[vo/gpu/vulkan/libplacebo] type 2: flags 0xe heap 1
[vo/gpu/vulkan/libplacebo] Storable format 'rgb32f' has no matching GLSL format qualifier?
[vo/gpu/vulkan/libplacebo] Storable format 'rgb32u' has no matching GLSL format qualifier?
[vo/gpu/vulkan/libplacebo] Storable format 'rgb32i' has no matching GLSL format qualifier?
[vo/gpu/vulkan/libplacebo] Storable format 'bgra4' has no matching GLSL format qualifier?
[vo/gpu/vulkan/libplacebo] Storable format 'bgr565' has no matching GLSL format qualifier?
[vo/gpu/vulkan/libplacebo] Storable format 'bgr5a1' has no matching GLSL format qualifier?
[vo/gpu/vulkan/libplacebo] Storable format 'a1rgb5' has no matching GLSL format qualifier?
[vo/gpu/vulkan/libplacebo] Storable format 'rgba4' has no matching GLSL format qualifier?
[vo/gpu/vulkan/libplacebo] Storable format 'rgb565' has no matching GLSL format qualifier?
[vo/gpu/vulkan/libplacebo] Storable format 'rgb5a1' has no matching GLSL format qualifier?
[vo/gpu/vulkan/libplacebo] GPU information:
[vo/gpu/vulkan/libplacebo] GLSL version: 450 (vulkan)
[vo/gpu/vulkan/libplacebo] Capabilities: 0x3
[vo/gpu/vulkan/libplacebo] Limits:
[vo/gpu/vulkan/libplacebo] max_tex_1d_dim: 16384
[vo/gpu/vulkan/libplacebo] max_tex_2d_dim: 16384
[vo/gpu/vulkan/libplacebo] max_tex_3d_dim: 2048
[vo/gpu/vulkan/libplacebo] max_pushc_size: 128
[vo/gpu/vulkan/libplacebo] max_xfer_size: 18446744073709551615
[vo/gpu/vulkan/libplacebo] max_ubo_size: 4294967295
[vo/gpu/vulkan/libplacebo] max_ssbo_size: 4294967295
[vo/gpu/vulkan/libplacebo] max_buffer_texels: 134217728
[vo/gpu/vulkan/libplacebo] min_gather_offset: -32
[vo/gpu/vulkan/libplacebo] max_gather_offset: 31
[vo/gpu/vulkan/libplacebo] max_shmem_size: 32768
[vo/gpu/vulkan/libplacebo] max_group_threads: 2048
[vo/gpu/vulkan/libplacebo] max_group_size[0]: 2048
[vo/gpu/vulkan/libplacebo] max_group_size[1]: 2048
[vo/gpu/vulkan/libplacebo] max_group_size[2]: 2048
[vo/gpu/vulkan/libplacebo] max_dispatch[0]: 65535
[vo/gpu/vulkan/libplacebo] max_dispatch[1]: 65535
[vo/gpu/vulkan/libplacebo] max_dispatch[2]: 65535
[vo/gpu/vulkan/libplacebo] align_tex_xfer_stride: 128
[vo/gpu/vulkan/libplacebo] align_tex_xfer_offset: 128
[vo/gpu/vulkan/libplacebo] External API interop:
[vo/gpu/vulkan/libplacebo] UUID: 00:00:00:00:01:00:00:00:00:00:00:00:00:00:00:00
[vo/gpu/vulkan/libplacebo] buf export caps: 0x9
[vo/gpu/vulkan/libplacebo] buf import caps: 0x9
[vo/gpu/vulkan/libplacebo] tex export caps: 0x0
[vo/gpu/vulkan/libplacebo] tex import caps: 0x0
[vo/gpu/vulkan/libplacebo] sync export caps: 0x1
[vo/gpu/vulkan/libplacebo] sync import caps: 0x0
[vo/gpu] Testing FBO format rgba16hf
[vo/gpu/vulkan/libplacebo] Allocating 1048576 memory of type 0x7 (id 1) in heap 0
[vo/gpu] Using FBO format rgba16hf.
[vo/gpu/vulkan/libplacebo] Allocating 1048576 memory of type 0x6 (id 0) in heap 1
[vo/gpu] Querying ICC profile...
[vo/gpu] Assuming 72.924866 FPS for display sync.
Using hardware decoding (vaapi-copy).
[autoconvert] Converting nv12 -> yuv422p
[mvtools]: Container fps reported by mpv is 25.0
[mvtools]: Running in realtime with 25.0 / 72.924865 initial src / dst fps
[mvtools]: Reflowing from 25.0 fps to 72.924865 fps with extreme quality
[mvtools]: 16/16 subdivided-in-4 blocks, 5/5: 24/256 search-, 4/4 overlap, 4096 8x8SAD / 16384 λSAD | 2048 λ, 9 DCT, quarter-pixel precision, mask:2 of FlowFPS
[vapoursynth] Frame requested during init! This is unsupported.
[vapoursynth] Returning black dummy frame with 0 duration.
[vapoursynth] Frame requested during init! This is unsupported.
[vapoursynth] Returning black dummy frame with 0 duration.
AO: [jack] 96000Hz stereo 2ch floatp
VO: [gpu] 640x360 yuv422p
[vo/gpu] reconfig to 640x360 yuv422p bt.601/bt.709/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264
[vo/gpu/vulkan/libplacebo] (Re)creating swapchain of size 1152x648
[vo/gpu] Resize: 1152x648
[vo/gpu] Window size: 1152x648 (Borders: l=0 t=0 r=0 b=0)
[vo/gpu] Video source: 640x360 (1:1)
[vo/gpu] Video display: (0, 0) 640x360 -> (0, 0) 1152x648
[vo/gpu] Video scale: 1.800000/1.800000
[vo/gpu] OSD borders: l=0 t=0 r=0 b=0
[vo/gpu] Video borders: l=0 t=0 r=0 b=0
[vo/gpu] Texture for plane 0: 640x360
[vo/gpu] Texture for plane 1: 320x360
[vo/gpu] Texture for plane 2: 320x360
[vo/gpu] Testing FBO format rgba16hf
[vo/gpu] Using FBO format rgba16hf.
[vo/gpu] Querying ICC profile...
[vo/gpu/x11] Retrieving ICC profile for display: 0
[vo/gpu/x11] Using profile /home/fox/.local/share/icc/BenQ GW2270_20171122.icc
[vo/gpu] Testing FBO format rgba16hf
[vo/gpu] Using FBO format rgba16hf.
[vo/gpu/vulkan/libplacebo] Allocating 4194304 memory of type 0x7 (id 1) in heap 0
[vo/gpu/vulkan/libplacebo] Allocating 1048576 memory of type 0x7 (id 1) in heap 0
[vo/gpu/vulkan/libplacebo] Allocating 16777216 memory of type 0x7 (id 1) in heap 0
[vo/gpu/vulkan/libplacebo] Allocating 67108864 memory of type 0x7 (id 1) in heap 0
[vo/gpu] Detected ICC profile contrast: 3000.000000
[vo/gpu/vulkan/libplacebo] Allocating 8388608 memory of type 0x6 (id 0) in heap 1
[vo/gpu] Dither to 8.
[vo/gpu/vulkan/libplacebo] Allocating 1048576 memory of type 0x7 (id 1) in heap 0
In -v -v
log there is about 22 (yes, twenty two) mentions of "compute shader source" with a bunch of weird intermediate "[vo/gpu] Resizing texture" and only single ones for "fragment shader source" and "vertex shader source" during the startup of the video.
I've been fiddling about with mpv's vulkan backend, external upscaling shaders and motion-interpolation but then noticed that mpv produces such warning:
While searching in libplacebo sources I stumbled at this piece of code: https://github.com/haasn/libplacebo/blob/1b96a0fd2cf4386a00c35ca66c96d3df62402d5a/src/vulkan/common.h#L45-L47
I'm using RX580 with
amdgpu sched_hw_submission=1024 sched_jobs=2048
options and I'm pretty sure it has to handle much more than 64, so I patched it with 2048 for both and recompiled together with mpv. Warning seems to be gone and everything seems to be fine.