FNA-XNA / FNA3D

FNA3D - 3D Graphics Library for FNA
http://fna-xna.github.io/
Other
267 stars 44 forks source link

Vulkan: Fix errors on iOS/tvOS simulator and older Apple devices #191

Closed TheSpydog closed 6 months ago

TheSpydog commented 6 months ago

I noticed when testing on Apple simulators that our Vulkan driver would error out in two different places -- when requesting the occlusionQueryPrecise device feature, and when using a non-zero base vertex in vkCmdDrawIndexed. This patch addresses both scenarios, allowing games to be tested via simulator.

I chose to make occlusionQueryPrecise optional because it's such a niche feature that we can live without it on low-end machines. I don't know of a single XNA game that actually uses occlusion queries, but even if there is such a game, it's highly likely they just check if the PixelCount is > 0 (which is what the examples in the XNA documentation do). That should still work even without precise occlusion queries.

For base vertex, I followed the OpenGL driver's strategy of adjusting the offset the vertex buffer in ApplyVertexBufferBindings. This works from my testing, but this is the part I feel the least confident about. I especially don't love that it adds a couple conditionals, but I'm not sure there's a way around that.

thatcosmonaut commented 6 months ago

Looks good to me, the conditionals are unfortunate but I think having a functioning Apple workflow is a worthy tradeoff.