gfx-rs/wgpu-rs

Black cube with dx11 and inconsistent adapter choice

Closed this issue · 4 comments

Running the cube example with the backend set to dx11 results in the following:
image

For some reason, the examples normally default to using my integrated graphics card, but when I ask it to use dx11 it suddenly decides to use by dedicated graphics card instead... Which could be why it's broken in dx11 but works fine in dx12?

This is the log output:

[0.089639 INFO]()(no module): Initializing the surface...
[0.121227 INFO](Global::new)(no module): DXGI version: Dxgi1_5
[1.503875 INFO](Instance::pick_adapter)(no module): AdapterInfo {
    name: "NVIDIA GeForce GTX 1060",
    vendor: 4318,
    device: 7200,
    device_type: DiscreteGpu,
}
[1.552785 INFO](Instance::pick_adapter)(no module): AdapterInfo {
    name: "Intel(R) UHD Graphics 620",
    vendor: 32902,
    device: 22807,
    device_type: DiscreteGpu,
}
[1.560614 INFO](Instance::pick_adapter)(no module): AdapterInfo {
    name: "Microsoft Basic Render Driver",
    vendor: 5140,
    device: 140,
    device_type: VirtualGpu,
}
[1.562238 INFO](Instance::pick_adapter)(wgpu_core::instance): Adapter Dx11 AdapterInfo { name: "NVIDIA GeForce GTX 1060", vendor: 4318, device: 7200, device_type: DiscreteGpu }
[1.697661 INFO](Adapter::request_device)(no module): feature level=b100=FL11_1
[2.135820 INFO](Adapter::request_device)(wgpu_core::command::allocator): Starting on (internal) thread ThreadId(1)
[2.136430 WARN](Adapter::request_device)(wgpu_core::device::alloc): max_memory_allocation_count is not set by gfx-rs backend
[2.138857 INFO](Device::create_swap_chain)(wgpu_core::device): creating swap chain SwapChainDescriptor { usage: RENDER_ATTACHMENT, format: Bgra8UnormSrgb, width: 1024, height: 768, present_mode: Mailbox }
[2.139270 WARN](Device::create_swap_chain)(wgpu_core::device): Surface does not support present mode: MAILBOX, falling back to FIFO
[2.141952 INFO]()(no module): Initializing the example...
[2.142195 INFO](Device::create_buffer)(wgpu_core::device): Create buffer BufferDescriptor { label: Some("Vertex Buffer"), size: 580, usage: VERTEX, mapped_at_creation: true } with ID PhantomData
[2.143427 INFO](Device::create_buffer)(wgpu_core::device): Created buffer Valid((0, 1, Dx11)) with BufferDescriptor { label: Some("Vertex Buffer"), size: 580, usage: VERTEX, mapped_at_creation: true }
[2.149006 INFO](Device::create_buffer)(wgpu_core::device): Create buffer BufferDescriptor { label: Some("Index Buffer"), size: 76, usage: INDEX, mapped_at_creation: true } with ID PhantomData
[2.149864 INFO](Device::create_buffer)(wgpu_core::device): Created buffer Valid((1, 1, Dx11)) with BufferDescriptor { label: Some("Index Buffer"), size: 76, usage: INDEX, mapped_at_creation: true }
[2.233114 INFO](Device::create_texture)(wgpu_core::device): Created texture Valid((0, 1, Dx11)) with TextureDescriptor { label: None, size: Extent3d { width: 256, height: 256, depth: 1 }, mip_level_count: 1, sample_count: 1, dimension: D2, format: Rgba8UnormSrgb, usage: COPY_DST | SAMPLED }
[2.236367 INFO](Device::create_buffer)(wgpu_core::device): Create buffer BufferDescriptor { label: Some("Uniform Buffer"), size: 68, usage: COPY_DST | UNIFORM, mapped_at_creation: true } with ID PhantomData
[2.237099 INFO](Device::create_buffer)(wgpu_core::device): Created buffer Valid((2, 1, Dx11)) with BufferDescriptor { label: Some("Uniform Buffer"), size: 68, usage: COPY_DST | UNIFORM, mapped_at_creation: true }
[2.238566 WARN](Device::create_shader_module)(no module): Unsupported builtin 4
[2.239999 WARN](Device::create_shader_module)(no module): Unknown decoration ColMajor
[2.240869 WARN](Device::create_shader_module)(no module): Unknown decoration MatrixStride
[2.258217 INFO]()(no module): Entering render loop...
[26.712303 INFO](Buffer::drop)(wgpu_core::device): Buffer (0, 1, Dx11) is dropped
[26.712744 INFO](Buffer::drop)(wgpu_core::device): Buffer (1, 1, Dx11) is dropped
[26.713319 INFO](Buffer::drop)(wgpu_core::device): Buffer (2, 1, Dx11) is dropped
[26.715083 INFO]()(wgpu_core::hub): Dropping Global

So regarding adapter selection: the examples are configured to use the lowest power gpu available, but DX11 incorrectly exposes your integrated card as a discrete one.

What version of windows are you using, and what version of gfx-backend-dx11 is this?

Filed gfx-rs/gfx#3489 for the first issue.

I can reproduce it on my integrated gpu on my laptop, investigating.

Closing, this seems to be resovled.