gl: fix ubo binding

This commit is contained in:
chyyran 2022-11-19 02:28:22 -05:00
parent 3aee36a361
commit 83dc63ffe0
3 changed files with 15 additions and 12 deletions

View file

@ -177,14 +177,15 @@ impl FilterPass {
self.build_semantics(parent, mvp, frame_count, frame_direction, fb_size, viewport, original, source);
// shader_gl3:1514
if !self.ubo_location.vertex == gl::INVALID_INDEX && !self.ubo_location.fragment == gl::INVALID_INDEX {
if self.ubo_location.vertex != gl::INVALID_INDEX && self.ubo_location.fragment != gl::INVALID_INDEX {
if let (Some(ubo), Some(ring)) = (&self.reflection.ubo, &mut self.ubo_ring) {
let size = ubo.size;
let buffer = ring.current();
unsafe {
gl::BindBuffer(gl::UNIFORM_BUFFER, *buffer);
gl::BufferSubData(gl::UNIFORM_BUFFER, 0, size as GLsizeiptr, self.uniform_buffer.as_ptr().cast());
gl::BufferSubData(gl::UNIFORM_BUFFER, 0, size as GLsizeiptr,
self.uniform_buffer.as_ptr().cast());
gl::BindBuffer(gl::UNIFORM_BUFFER, 0);
if self.ubo_location.vertex != gl::INVALID_INDEX {
@ -256,11 +257,12 @@ impl FilterPass {
-1.0, -1.0, 0.0, 1.0
]);
let mvp_size = mvp.len() * std::mem::size_of::<f32>();
let (buffer, offset) = match variable.offset {
MemberOffset::Ubo(offset) => (&mut self.uniform_buffer, offset),
MemberOffset::PushConstant(offset) => (&mut self.push_buffer, offset)
};
FilterPass::build_mvp(&mut buffer[offset..][..mvp.len() * std::mem::size_of::<f32>()], mvp)
FilterPass::build_mvp(&mut buffer[offset..][..mvp_size], mvp)
}
if let Some(variable) = self.reflection.meta.variable_meta.get(&VariableSemantics::Output) {

View file

@ -336,6 +336,7 @@ void main()
// eprintln!("[core] rendered texture is {rendered_texture}");
// do offscreen passes
unsafe {
filter.frame(0, &Viewport {
x: 0,
@ -346,7 +347,7 @@ void main()
}
}, GlImage {
handle: rendered_texture,
format: gl::RGBA,
format: gl::RGBA8,
size: Size {
width: WIDTH,
height: HEIGHT

View file

@ -425,10 +425,10 @@ impl FilterChain {
// how much info do we actually need?
pub fn frame(&mut self, count: u32, vp: &Viewport, input: GlImage, clear: bool) {
//
// unsafe {
// gl::BindFramebuffer(gl::FRAMEBUFFER, 0);
// gl::BindVertexArray(self.quad_vao);
// }
unsafe {
gl::BindFramebuffer(gl::FRAMEBUFFER, 0);
gl::BindVertexArray(self.quad_vao);
}
// todo: copy framebuffer
// shader_gl3: 2067
@ -450,10 +450,10 @@ impl FilterChain {
}
// unsafe {
// gl::BindFramebuffer(gl::FRAMEBUFFER, 0);
// gl::BindVertexArray(0);
// }
unsafe {
gl::BindFramebuffer(gl::FRAMEBUFFER, 0);
gl::BindVertexArray(0);
}
// todo: deal with the mess that is frame history
}