r/cpp 1d ago

Make APIs that fail gracefully rather that fallback silently · Mathieu Ropert

https://mropert.github.io/2026/09/02/implicit_vs_explicit_api/
52 Upvotes

6 comments sorted by

17

u/Ok_Independence_9841 1d ago

API design is hard. Vulkan is hard. Error handling is hard. Vulkan API, error handling design, is...

At some point I'll get around to implementing a Vulkan backend for my port of the ThorVG renderer. When I do I'll try to remember what I learned here.

6

u/Ameisen vemips, avr, rendering, systems 1d ago

Before Win10/D3D12 fully came out but after information about it and APIs were available, I made a D3D12-like frontend API but with D3D11 as the backend, to make porting easier.

It actually outperformed idiomatic D3D11...

5

u/Leading-Carrot-5983 1d ago

Better access patterns? Or why?

3

u/Ameisen vemips, avr, rendering, systems 1d ago

I'm not 100% sure. My assumption was that since I was emulating command streams, the data ended up packed nicely before submission - so in that case, yes, better access patterns.

It's also possible that since I was trying to emulate how D3D12 handled state, I was causing less flushing of state by handling it closer to how the hardware actually expected it rather than what idiomatic D3D11 preferred.

1

u/shadowndacorner 15h ago

In what way was it D3D12-like? Writing commands into command buffers and binding PSOs rather than fine grained state, but without the manual sync?

2

u/n1ghtyunso 1d ago

sounds like something that indeed should be fixed.
Did someone open issues with vk-bootstrap around this?