Comments (11)
Size and align 0 are not supported. Should add this to asserts as nd doc.
from rendy.
please don't assert if size is 0. just return an allocation error if possible, or at least do a checked sub and unwrap so it doesn't do weird stuff in release mode; but ideally just return an error and let the client decide if they want to crash the process?
from rendy.
I don't want to add another error variant. Especially since we use error type from gfx-hal
.
Creating buffer of size 0 violates Vulkan API usage already and it typically happens before memory allocation so we already in dangerous waters where anything can happen.
Doing checking sub and unwrapping is much worse than meaningful assert IMHO.
You can't allocate 0
bytes not because of this expression (it can be modified to permit 0
) so unwrapping there will only confuse the user.
from rendy.
ok, agreed assert better than debug overflow unwrap; even better it's caught even farther upstream, but yea.
Is creating a buffer of size 0 in vulkan really a validation error? I would assume it wouldn't care; it should be able to hand out an infinite amount of 0 size buffers ; )
from rendy.
Yes. Creating buffers of size 0 is invalid usage.
from rendy.
I think we can just add asserts in debug mode.
from rendy.
@omni-viral
Shouldn't the assert also be there in release? Since in release it will wrap and a bunch of unexpected things will happen?
from rendy.
If it’s invalid usage for size 0 simple panic with error message is best imho, and then documenting this as a panics condition :)
Asserts are for pre and post condition enforcement and author programmer errors
from rendy.
@m4b std uses asserts for invalid inputs like out of bounds for some Vec
methods etc.
So I'd say assert
is idiomatic way in Rust.
from rendy.
Out of bounds panics with bounds len violation message, last I checked. I’m sure there are asserts in vec but I can’t remember last time an assert violation bubbled up to the user but I could be mistaken.
from rendy.
In any event I mostly care about fixing the debug overflow which wasn’t super helpful wrt tracking down cause, and I don’t really care if it’s a panic or assert, just a better error message. This is effectively a one line fix we’re talking about so maybe we should just add it :)
from rendy.
Related Issues (20)
- Building issues HOT 1
- Issue with triangle example HOT 1
- [Q] How to enable a rendering backend for project? HOT 10
- Can't run triangle example on MAC with metal backend HOT 6
- Issues with the triangle example and vulkan on windows HOT 8
- shader reflection BindingsMismatch if using a binding in one shader not used by other shaders of the same shader program. HOT 1
- Generate vertex tangents for OBJ files HOT 1
- Using LinearAllocator for non-CPU-visible memory HOT 1
- Using DynamicAllocator for large allocations HOT 2
- Image count not supported HOT 2
- Port to gfx-hal-0.5 HOT 2
- MeshBuilder::with_prim_type does nothing HOT 2
- Render pass with no attachments causes subtraction underflow. HOT 1
- missing depth_stencil on SimpleGraphicsPipelineDesc causes crashes HOT 4
- Is this project abandoned? HOT 5
- Add examples folder HOT 2
- PresentMode isn't configurable (aka Rendy forces vsync)
- [MAINTENANCE] post build timings to PRs
- upgrade gfx to 0.6 to fix MacOS
- Unsound type casting in `cast_slice` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rendy.