mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Merge #5
5: Add rects length check for clears r=msiglreith a=dati91 Co-authored-by: Attila Dusnoki <attila.dusnoki@h-lab.eu>
This commit is contained in:
@@ -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,
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user