Intel vulkan driver present problem on nvidia optimus systems
Hi, i hope this is the right place to open this issue, if not, i'm sorry.
System information
System: Host: pop-os Kernel: 5.11.0-7612-generic x86_64 bits: 64 compiler: gcc v: 10.2.0 Desktop: N/A wm: gnome-shell
dm: GDM3 Distro: Pop!_OS 20.10 base: Ubuntu 20.10 Groovy
CPU: Info: Dual Core model: Intel Core i5-4200M bits: 64 type: MT MCP arch: Haswell rev: 3 L2 cache: 3072 KiB
flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 19953
Speed: 2394 MHz min/max: 800/3100 MHz Core speeds (MHz): 1: 1023 2: 799 3: 798 4: 799
Graphics: Device-1: Intel 4th Gen Core Processor Integrated Graphics vendor: Acer Incorporated ALI driver: i915 v: kernel
bus ID: 00:02.0 chip ID: 8086:0416
Device-2: NVIDIA GM107M [GeForce GTX 850M] vendor: Acer Incorporated ALI driver: nvidia v: 460.67 bus ID: 01:00.0
chip ID: 10de:1391
Device-3: Sunplus Innovation HD WebCam type: USB driver: uvcvideo bus ID: 3-5:3 chip ID: 1bcf:2c55
Display: x11 server: X.Org 1.20.9 compositor: gnome-shell driver: modesetting,nvidia unloaded: fbdev,nouveau,vesa
resolution: 1600x900~60Hz s-dpi: 96
OpenGL: renderer: GeForce GTX 850M/PCIe/SSE2 v: 4.6.0 NVIDIA 460.67 direct render: Yes
Describe the issue
When an optimus system is in "nvidia only" mode and an application try to use the intel gpu, nothing is drawed on the surface.
If i have understood correctly, when an optimus system is in "nvidia only" mode, both nvidia and intel gpus are active, but all the drawing is done by the nvidia gpu against the intel gpu framebuffer, of which it takes the control. So in this mode the intel gpu cannot present, but still it can do compute operations (and maybe offscreen rendering operations too, i have done some tests about this long time ago, but i don't remember if i was able to get them working).
The problem is that the intel vulkan driver report to the applications that it can present, while it couldn't (in "nvidia only" mode).
Indeed on the intel part of vulkaninfo
report i got:
VkQueueFamilyProperties:
========================
queueProperties[0]:
-------------------
minImageTransferGranularity = (1,1,1)
queueCount = 1
queueFlags = QUEUE_GRAPHICS | QUEUE_COMPUTE | QUEUE_TRANSFER
timestampValidBits = 36
present support = true <------------- Here
The problem can be easily reproduced with the vkcube
program, that will open a black window on the screen without drawing nothing on it. Seems it is not enabled to report the underlying error, but using another application, the "quad" example on Gfx library, i got this additional info:
MESA-INTEL: warning: Haswell Vulkan support is incomplete
AdapterInfo { name: "Intel(R) HD Graphics 4600 (HSW GT2)", vendor: 32902, device: 1046, device_type: IntegratedGpu }
AdapterInfo { name: "llvmpipe (LLVM 11.0.0, 256 bits)", vendor: 65541, device: 0, device_type: Cpu }
AdapterInfo { name: "GeForce GTX 850M", vendor: 4318, device: 5009, device_type: DiscreteGpu }
Memory types: [MemoryType { properties: DEVICE_LOCAL | CPU_VISIBLE | COHERENT | CPU_CACHED, heap_index: 0 }]
formats: Some([Bgra8Srgb, Bgra8Unorm])
SwapchainConfig { present_mode: MAILBOX, composite_alpha_mode: INHERIT, format: Bgra8Srgb, extent: Extent2D { width: 1024, height: 768 }, image_count: 3, image_layers: 1, image_usage: COLOR_ATTACHMENT }
[2021-04-22T15:20:40Z ERROR winit::platform_impl::platform] X11 error: XError {
description: "BadDrawable (invalid Pixmap or Window parameter)",
error_code: 9,
request_code: 149,
minor_code: 4,
}
[2021-04-22T15:20:40Z ERROR winit::platform_impl::platform] X11 error: XError {
description: "BadDrawable (invalid Pixmap or Window parameter)",
error_code: 9,
request_code: 149,
minor_code: 4,
}
[2021-04-22T15:20:40Z ERROR winit::platform_impl::platform] X11 error: XError {
description: "BadDrawable (invalid Pixmap or Window parameter)",
error_code: 9,
request_code: 149,
minor_code: 4,
}
[2021-04-22T15:20:40Z ERROR winit::platform_impl::platform] X11 error: XError {
description: "BadDrawable (invalid Pixmap or Window parameter)",
error_code: 9,
request_code: 149,
minor_code: 4,
}
[2021-04-22T15:20:40Z ERROR winit::platform_impl::platform] X11 error: XError {
description: "BadDrawable (invalid Pixmap or Window parameter)",
error_code: 9,
request_code: 149,
minor_code: 4,
}
This issue is triggered on a lot of applications since most of them will pick as their only device the first that can draw and present. On optimus systems, the intel gpu is picked because it is enumerated before the nvidia one, causing the issue.
This problem can be avoided limiting the available devices to the application by setting the VK_ICD_FILENAMES
to just the nvidia icd json file (on my system VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json
), but it is a temporary fix.
Regression
As far as i remember, i got this kind of error for long, but at that time i didn't realize what the cause could be (effectively i thought it was due to my bad vulkan programming).
I hope i have reported enough info about the problem, if not, just ask and i will add all the additional logs you need.
Thanks for the attention and the dedicated time, Have a good day