Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/victory-gpu/src/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,9 @@ impl State {
first: u32,
first_instance: u32,
) {
if vertices == 0 || instances == 0 {
return;
}
#[cfg(feature = "diagnostics")]
self.trace("draw", vertices, first);
// Rectangles: completed by the pipeline's geometry shader, else
Expand Down Expand Up @@ -1664,6 +1667,9 @@ impl State {
base: i32,
first_instance: u32,
) {
if indices == 0 || instances == 0 {
return;
}
#[cfg(feature = "diagnostics")]
self.trace("indexed", indices, first);
let rects = self.topology == RECTANGLES && !self.completes_rectangles();
Expand Down
44 changes: 44 additions & 0 deletions crates/victory-gpu/src/pipeline/make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,50 @@ mod tests {
WAITING.fetch_sub(3, Ordering::Relaxed);
}

/// An empty draw must not move its graphics pipeline onto the demand queue.
#[test]
fn zero_count_draws_do_not_request_graphics_pipelines() {
use crate::object::{S_OK, This, slot};

let Some(host) = crate::host::host() else {
return;
};
let list = host.new_list().unwrap();
let demanded = |indexed: bool, count, instances| {
// A new pipeline per draw isolates each use bit. The empty stage
// list makes demand measurable independently of shader build time.
let mut pipeline = std::ptr::null();
assert_eq!(
crate::pipeline::hand_out(
Vec::new(),
Some(Box::default()),
&crate::pipeline::PIPELINE_IIDS[0],
&mut pipeline,
),
S_OK
);
let mut state = crate::draw::State::default();
state.set_pipeline(pipeline);
if indexed {
state.draw_indexed(&list, count, instances, 0, 0, 0);
} else {
state.draw(&list, count, instances, 0, 0);
}
let requested = crate::pipeline::pipeline(pipeline)
.host
.used
.load(Ordering::Relaxed);
slot::<extern "system" fn(This) -> u32>(pipeline, 0x10)(pipeline);
requested
};
let cases = [(0, 1), (3, 0), (3, 1)];
let observed = [false, true].map(|indexed| {
cases.map(|(count, instances)| demanded(indexed, count, instances))
});
list.close();
assert_eq!(observed, [[false, false, true]; 2]);
}

/// A first use queues the pipeline and, within the budget, gets the
/// worker's answer (here: no host pipeline for no shaders).
#[test]
Expand Down