Devsh-Graphics-Programming / Nabla

Vulkan, OptiX and CUDA Interoperation Modular Rendering Library and Framework for PC/Linux/Android
http://devsh.eu
Apache License 2.0
493 stars 59 forks source link

IUtilities to handle streaming buffer allocation failure #765

Open Erfan-Ahmadi opened 4 weeks ago

Erfan-Ahmadi commented 4 weeks ago

IUtilities is a great tool heavily relied on in certain examples and extensions that require uploads and download of data through staging buffers.

The constructor currently proceeds as if the allocations for upstreaming and downstreaming buffers are going to succeed. although the 64MB defaults for download and upload seem reasonable. some applications might want to use multiple IUtilites and thus certainly possible for the allocations to fail.

There are 2 issues with this:

  1. Constructors can't fail: This means IUtilities needs to have a static create function and follow the pattern we use for failable constructions. Assertion is wrong here because we can recover from device allocation failure.

  2. Handling allocation failure My suggestion is to return error codes to user clarifying the reason for failure so they can IUtilities::create again with better and more reasonable parameters. (maybe they want to reduce size by 10% until they succeed).