Gfx: Error creating empty vertex buffer with DX11 backend

Created on 31 Aug 2018  路  4Comments  路  Source: gfx-rs/gfx

  • GFX version: 0.17.1
  • OS: Windows 10
  • GPU: Geforce GTX 660

See this example program: https://github.com/djcsdy/gfx-dx11-empty-vertex-buffer/blob/master/src/main.rs

factory.create_vertex_buffer::<Vertex>(&[Vertex { pos: [0.0, 0.0] }]); is ok, but factory.create_vertex_buffer::<Vertex>(&[]); panics with CreationError::Other.

I believe this is because ID3D11Device::CreateBuffer fails when attempting to create an empty buffer, but that behaviour is not documented by Microsoft and I haven鈥檛 double checked.

This is preventing me from using conrod in conjunction with gfx-rs and DX11, because one of the first things conrod does on startup is to create an empty vertex buffer.

FWIW, the OpenGL backend has a specific workaround for the same problem.

pre-ll DirectX-11 blocker easy Windows ready for work bug high

All 4 comments

Thanks for the issue! Sounds like we need a similar workaround for DX11.

FWIW it looks like conrod doesn鈥檛 work with gfx-rs and DX11 anyway, because its shaders are written in GLSL and AIUI gfx-rs 0.17 doesn鈥檛 translate shaders like the newer LL builds do.

I used this hack to get past the immediate problem. It is similar in principle to the workaround used for OpenGL. I haven鈥檛 tested this except to show that it allows conrod to get a bit further along the startup process, and then panic when creating shaders. I don鈥檛 know enough about Direct3D to know if this workaround should work in practice, but feel free to borrow it if it鈥檚 of any use to you.

Fixed, I used your OpenGL "hack" djcsdy, and it went successful through all the tests.

We'd need to back-port the PR on v0.17 branch and bump the patch version of DX11 backend in order to publish an update.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mjadczak picture mjadczak  路  4Comments

norru picture norru  路  4Comments

Michael-Lfx picture Michael-Lfx  路  5Comments

grovesNL picture grovesNL  路  3Comments

clevijoki picture clevijoki  路  3Comments