-
-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
graphics: Fix backwards compatibility with integer attributes #463
Conversation
@@ -1332,7 +1334,9 @@ impl RenderingBackend for GlContext { | |||
unsafe { | |||
match attribute.type_ { | |||
GL_INT | GL_UNSIGNED_INT | GL_SHORT | GL_UNSIGNED_SHORT | |||
| GL_UNSIGNED_BYTE | GL_BYTE => { | |||
| GL_UNSIGNED_BYTE | GL_BYTE | |||
if !attribute.gl_pass_as_float => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QQ: why not something like:
match attribute.type_ {
GL_INT | GL_UNSIGNED_INT | GL_SHORT | GL_UNSIGNED_SHORT
| GL_UNSIGNED_BYTE | GL_BYTE
if self.has_integer_attributes() =>
{
glVertexAttribIPointer(
attr_index as GLuint,
attribute.size,
attribute.type_,
attribute.stride,
attribute.offset as *mut _,
)
}
_ => glVertexAttribPointer(
attr_index as GLuint,
attribute.size,
attribute.type_,
GL_FALSE as u8,
attribute.stride,
attribute.offset as *mut _,
),
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx, I agree, a lot better!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, wait, I misread it.
has_integer_attributes
doesn't neccessarily mean we want uvec4 in the shader.
has_integer_attributes
means the backend support glVertexAttribIPointer, gl_pass_as_float
means that the user wants glVertexAttribIPointer to be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you d need gl_pass_as_float
, because the moment it supports integer and the user is passing a byte, it'll convert it. glsl 150 requires opengl 3.2 and above, so that shouldn't affect it. But better test this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not, thats how that whole thing started :)
glsl100 shaders do not receive glVertexAttribIPointer Byte4 as vec4, even on OpenGL4+
929e542
to
e1f2750
Compare
Since a359a34, glVertexAttribIPointer was used for VertexAttribute:Byte*/Short*/etc. While it is a correct behavior, it broke backwards compatibility with glsl100 shaders receiving Byte4 vectors as vec4. This commit makes this feature opt-in: it is possible to pass Byte4 as uvec4, but only if its explicitly required.
triangle_color4b example works, macroquad works, all old miniquad using code should not be affected, so lets merge it and will see how it goes! Feel free to send follow up PRs if it was not, in fact, a good idea :) |
Follow up on #461
I can't really think of any better solution, just added a doc comment over
gl_pass_as_float
.cc @eloraiby @birhburh