Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
manpat committed Oct 3, 2024
1 parent d3560f3 commit 1ece306
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions toybox-gfx/src/resource_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ impl ResourceManager {
impl ResourceManager {
pub fn resolve_draw_pipeline(&mut self, core: &mut core::Core,
vertex_shader: shader::ShaderHandle, fragment_shader: impl Into<Option<shader::ShaderHandle>>)
-> crate::core::ShaderPipelineName
-> core::ShaderPipelineName
{
let fragment_shader = fragment_shader.into();
let key = (vertex_shader, fragment_shader);
Expand All @@ -262,7 +262,7 @@ impl ResourceManager {
}

pub fn resolve_compute_pipeline(&mut self, core: &mut core::Core, compute_shader: shader::ShaderHandle)
-> crate::core::ShaderPipelineName
-> core::ShaderPipelineName
{
if let Some(&name) = self.compute_pipelines.get(&compute_shader) {
return name;
Expand Down
2 changes: 1 addition & 1 deletion toybox-gfx/src/resource_manager/shader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fn reflect_workgroup_size(core: &core::Core, shader_name: ShaderName) -> Option<
let mut workgroup_size = [0i32; 3];

unsafe {
core.gl.GetProgramiv(shader_name.as_raw(), gl::COMPUTE_WORK_GROUP_SIZE, workgroup_size.as_mut_ptr() as *mut i32);
core.gl.GetProgramiv(shader_name.as_raw(), gl::COMPUTE_WORK_GROUP_SIZE, workgroup_size.as_mut_ptr());
}

Some(Vec3i::from(workgroup_size))
Expand Down
11 changes: 6 additions & 5 deletions toybox-gfx/src/upload_heap.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::prelude::*;
use crate::core::{Core, BufferName, BufferRange};
use tracing::instrument;
use std::collections::VecDeque;

pub const UPLOAD_BUFFER_SIZE: usize = 8<<20;

Expand All @@ -13,7 +14,7 @@ pub struct UploadHeap {
buffer_usage_counter: usize,

frame_start_cursor: usize,
locked_ranges: Vec<LockedRange>,
locked_ranges: VecDeque<LockedRange>,

resolved_uploads: Vec<BufferRange>,
}
Expand All @@ -38,7 +39,7 @@ impl UploadHeap {
buffer_usage_counter: 0,

frame_start_cursor: 0,
locked_ranges: Vec::new(),
locked_ranges: VecDeque::new(),

resolved_uploads: Vec::new(),
}
Expand Down Expand Up @@ -88,12 +89,12 @@ impl UploadHeap {
};

// Check if we need to wait for the earliest range to be used.
while let Some(locked_range) = self.locked_ranges.first()
while let Some(locked_range) = self.locked_ranges.front()
&& locked_range.contains_allocation(&allocation)
{
fn fence_ready(result: u32) -> bool { matches!(result, gl::ALREADY_SIGNALED | gl::CONDITION_SATISFIED) }

let range = self.locked_ranges.remove(0);
let range = self.locked_ranges.pop_front().unwrap();

unsafe {
let result = core.gl.ClientWaitSync(range.fence, gl::SYNC_FLUSH_COMMANDS_BIT, 0);
Expand Down Expand Up @@ -144,7 +145,7 @@ impl UploadHeap {
let range_size = self.buffer_cursor.checked_sub(self.frame_start_cursor)
.unwrap_or(UPLOAD_BUFFER_SIZE - self.frame_start_cursor + self.buffer_cursor);

self.locked_ranges.push(LockedRange {
self.locked_ranges.push_back(LockedRange {
fence,
start: self.frame_start_cursor,
size: range_size,
Expand Down

0 comments on commit 1ece306

Please sign in to comment.