Skip to content

Commit

Permalink
Add rects length check for clears
Browse files Browse the repository at this point in the history
  • Loading branch information
Attila Dusnoki committed Nov 6, 2018
1 parent 6369df2 commit 4a938bd
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/command_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use com::WeakPtr;
use resource::DiscardRegion;
use std::mem;
use std::{mem, ptr};
use winapi::um::d3d12;
use {
CommandAllocator, CpuDescriptor, DescriptorHeap, Format, GpuAddress, GpuDescriptor, IndexCount,
Expand Down Expand Up @@ -96,21 +96,33 @@ impl GraphicsCommandList {
stencil: u8,
rects: &[Rect],
) {
let num_rects = rects.len() as _;
let rects = if num_rects > 0 {
rects.as_ptr()
} else {
ptr::null()
};
unsafe {
self.ClearDepthStencilView(
dsv,
flags.bits(),
depth,
stencil,
rects.len() as _,
rects.as_ptr(),
num_rects,
rects,
);
}
}

pub fn clear_render_target_view(&self, rtv: CpuDescriptor, color: [f32; 4], rects: &[Rect]) {
let num_rects = rects.len() as _;
let rects = if num_rects > 0 {
rects.as_ptr()
} else {
ptr::null()
};
unsafe {
self.ClearRenderTargetView(rtv, &color, rects.len() as _, rects.as_ptr());
self.ClearRenderTargetView(rtv, &color, num_rects, rects);
}
}

Expand Down

0 comments on commit 4a938bd

Please sign in to comment.