Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAssert vertex attr locations exist in GLDevice. #193
Conversation
| }; ck(); | ||
| GLVertexAttr { attr } | ||
| if attr_int == -1 { |
This comment has been minimized.
This comment has been minimized.
toolness
Jun 8, 2019
Author
Contributor
We could wrap this if (and the corresponding one in get_uniform) in a #[cfg(debug_assertions)] if we're concerned about the performance. I figured maybe it'd be OK not to do so since presumably these locations don't have to be looked up too often, but I dunno.
|
One thing I noticed while running Currently this is happening when |
| }; ck(); | ||
| GLVertexAttr { attr } | ||
| if attr_int == -1 { | ||
| panic!("Vertex attribute '{}' does not exist in program", name); |
This comment has been minimized.
This comment has been minimized.
toolness
Jun 8, 2019
Author
Contributor
Oops, I didn't realize that we were actually munging the names before passing them to OpenGL... I'm not sure if it'd be more helpful to panic with the name of the munged or un-munged name here.
|
So we probably shouldn't be checking uniforms, because -1 is a valid uniform location (though it does nothing). However, for attributes we certainly should. I think these checks should be debug mode only |
|
Oh wow, I didn't realize that -1 is a valid uniform location. Cool, I've just modified the PR to only pay attention to vertex attributes, and use |
|
So it turns out this change came for free with some of the Metal work I've been doing, and I cherry-picked it over to master here: dbf02fb This PR is obsolete now, but thanks for letting me know about the issue and putting it together :) |
|
Oh cool, sounds good! |
toolness commentedJun 8, 2019
•
edited
As @benpye discovered in #183 (comment), Pathfinder crashes on systems with Nvidia drivers at least in part because it's looking up locations for vertex attributes that don't exist in some shaders. In the spirit of "crash early, crash often", this PR adds assertions that ensure the vertex attribute
and uniform locationswe return are valid inGLDevice. This doesn't fix any problems, of course, it just makes it easier to be aware of their existence on non-Nvidia systems, and makes them easier to debug.That said, I'm not sure if this actually the best solution: perhaps
Device::get_vertex_attr()andDevice::get_uniform()should actually returnOption-wrapped values, so that code calling it can change its behavior based on whether the attributes/uniforms exist or not? I guess I'm not familiar enough with Pathfinder's codebase to know the best answer. Regardless, no worries if you decide not to merge this.