mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 23:04:07 +00:00
hal: change blend color argument
This commit is contained in:
parent
1f91c5f297
commit
81f31f5555
@ -1206,8 +1206,14 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
}
|
||||
RenderCommand::SetBlendConstant(ref color) => {
|
||||
state.blend_constant = OptionalState::Set;
|
||||
let array = [
|
||||
color.r as f32,
|
||||
color.g as f32,
|
||||
color.b as f32,
|
||||
color.a as f32,
|
||||
];
|
||||
unsafe {
|
||||
raw.set_blend_constants(color);
|
||||
raw.set_blend_constants(&array);
|
||||
}
|
||||
}
|
||||
RenderCommand::SetStencilReference(value) => {
|
||||
|
@ -46,6 +46,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
|
||||
}
|
||||
self.list = Some(list);
|
||||
self.temp.clear();
|
||||
self.has_pass_label = false;
|
||||
Ok(())
|
||||
}
|
||||
unsafe fn discard_encoding(&mut self) {
|
||||
@ -387,8 +388,18 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
|
||||
|
||||
// render
|
||||
|
||||
unsafe fn begin_render_pass(&mut self, desc: &crate::RenderPassDescriptor<super::Api>) {}
|
||||
unsafe fn end_render_pass(&mut self) {}
|
||||
unsafe fn begin_render_pass(&mut self, desc: &crate::RenderPassDescriptor<super::Api>) {
|
||||
if let Some(label) = desc.label {
|
||||
self.begin_debug_marker(label);
|
||||
self.has_pass_label = true;
|
||||
}
|
||||
}
|
||||
unsafe fn end_render_pass(&mut self) {
|
||||
if self.has_pass_label {
|
||||
self.end_debug_marker();
|
||||
self.has_pass_label = false;
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn set_bind_group(
|
||||
&mut self,
|
||||
@ -437,10 +448,32 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
|
||||
binding: crate::BufferBinding<'a, super::Api>,
|
||||
) {
|
||||
}
|
||||
unsafe fn set_viewport(&mut self, rect: &crate::Rect<f32>, depth_range: Range<f32>) {}
|
||||
unsafe fn set_scissor_rect(&mut self, rect: &crate::Rect<u32>) {}
|
||||
unsafe fn set_stencil_reference(&mut self, value: u32) {}
|
||||
unsafe fn set_blend_constants(&mut self, color: &wgt::Color) {}
|
||||
unsafe fn set_viewport(&mut self, rect: &crate::Rect<f32>, depth_range: Range<f32>) {
|
||||
let raw_vp = d3d12::D3D12_VIEWPORT {
|
||||
TopLeftX: rect.x,
|
||||
TopLeftY: rect.y,
|
||||
Width: rect.w,
|
||||
Height: rect.h,
|
||||
MinDepth: depth_range.start,
|
||||
MaxDepth: depth_range.end,
|
||||
};
|
||||
self.list.unwrap().RSSetViewports(1, &raw_vp);
|
||||
}
|
||||
unsafe fn set_scissor_rect(&mut self, rect: &crate::Rect<u32>) {
|
||||
let raw_rect = d3d12::D3D12_RECT {
|
||||
left: rect.x as i32,
|
||||
top: rect.y as i32,
|
||||
right: (rect.x + rect.w) as i32,
|
||||
bottom: (rect.y + rect.h) as i32,
|
||||
};
|
||||
self.list.unwrap().RSSetScissorRects(1, &raw_rect);
|
||||
}
|
||||
unsafe fn set_stencil_reference(&mut self, value: u32) {
|
||||
self.list.unwrap().set_stencil_reference(value);
|
||||
}
|
||||
unsafe fn set_blend_constants(&mut self, color: &[f32; 4]) {
|
||||
self.list.unwrap().set_blend_factor(*color);
|
||||
}
|
||||
|
||||
unsafe fn draw(
|
||||
&mut self,
|
||||
@ -536,8 +569,18 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
|
||||
|
||||
// compute
|
||||
|
||||
unsafe fn begin_compute_pass(&mut self, desc: &crate::ComputePassDescriptor) {}
|
||||
unsafe fn end_compute_pass(&mut self) {}
|
||||
unsafe fn begin_compute_pass(&mut self, desc: &crate::ComputePassDescriptor) {
|
||||
if let Some(label) = desc.label {
|
||||
self.begin_debug_marker(label);
|
||||
self.has_pass_label = true;
|
||||
}
|
||||
}
|
||||
unsafe fn end_compute_pass(&mut self) {
|
||||
if self.has_pass_label {
|
||||
self.end_debug_marker();
|
||||
self.has_pass_label = false;
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn set_compute_pipeline(&mut self, pipeline: &Resource) {}
|
||||
|
||||
|
@ -783,6 +783,7 @@ impl crate::Device<super::Api> for super::Device {
|
||||
shared: Arc::clone(&self.shared),
|
||||
list: None,
|
||||
free_lists: Vec::new(),
|
||||
has_pass_label: false,
|
||||
temp: super::Temp::default(),
|
||||
})
|
||||
}
|
||||
|
@ -228,6 +228,7 @@ pub struct CommandEncoder {
|
||||
shared: Arc<DeviceShared>,
|
||||
list: Option<native::GraphicsCommandList>,
|
||||
free_lists: Vec<native::GraphicsCommandList>,
|
||||
has_pass_label: bool,
|
||||
temp: Temp,
|
||||
}
|
||||
|
||||
|
@ -322,7 +322,7 @@ impl crate::CommandEncoder<Api> for Encoder {
|
||||
unsafe fn set_viewport(&mut self, rect: &crate::Rect<f32>, depth_range: Range<f32>) {}
|
||||
unsafe fn set_scissor_rect(&mut self, rect: &crate::Rect<u32>) {}
|
||||
unsafe fn set_stencil_reference(&mut self, value: u32) {}
|
||||
unsafe fn set_blend_constants(&mut self, color: &wgt::Color) {}
|
||||
unsafe fn set_blend_constants(&mut self, color: &[f32; 4]) {}
|
||||
|
||||
unsafe fn draw(
|
||||
&mut self,
|
||||
|
@ -767,14 +767,8 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
|
||||
self.state.stencil.back.reference = value;
|
||||
self.rebind_stencil_func();
|
||||
}
|
||||
unsafe fn set_blend_constants(&mut self, color: &wgt::Color) {
|
||||
let color = [
|
||||
color.r as f32,
|
||||
color.g as f32,
|
||||
color.b as f32,
|
||||
color.a as f32,
|
||||
];
|
||||
self.cmd_buffer.commands.push(C::SetBlendConstant(color));
|
||||
unsafe fn set_blend_constants(&mut self, color: &[f32; 4]) {
|
||||
self.cmd_buffer.commands.push(C::SetBlendConstant(*color));
|
||||
}
|
||||
|
||||
unsafe fn draw(
|
||||
|
@ -437,7 +437,7 @@ pub trait CommandEncoder<A: Api>: Send + Sync {
|
||||
unsafe fn set_viewport(&mut self, rect: &Rect<f32>, depth_range: Range<f32>);
|
||||
unsafe fn set_scissor_rect(&mut self, rect: &Rect<u32>);
|
||||
unsafe fn set_stencil_reference(&mut self, value: u32);
|
||||
unsafe fn set_blend_constants(&mut self, color: &wgt::Color);
|
||||
unsafe fn set_blend_constants(&mut self, color: &[f32; 4]);
|
||||
|
||||
unsafe fn draw(
|
||||
&mut self,
|
||||
|
@ -673,14 +673,9 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
|
||||
let encoder = self.state.render.as_ref().unwrap();
|
||||
encoder.set_stencil_front_back_reference_value(value, value);
|
||||
}
|
||||
unsafe fn set_blend_constants(&mut self, color: &wgt::Color) {
|
||||
unsafe fn set_blend_constants(&mut self, color: &[f32; 4]) {
|
||||
let encoder = self.state.render.as_ref().unwrap();
|
||||
encoder.set_blend_color(
|
||||
color.r as f32,
|
||||
color.g as f32,
|
||||
color.b as f32,
|
||||
color.a as f32,
|
||||
);
|
||||
encoder.set_blend_color(color[0], color[1], color[2], color[3]);
|
||||
}
|
||||
|
||||
unsafe fn draw(
|
||||
|
@ -568,16 +568,8 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
|
||||
.raw
|
||||
.cmd_set_stencil_reference(self.active, vk::StencilFaceFlags::all(), value);
|
||||
}
|
||||
unsafe fn set_blend_constants(&mut self, color: &wgt::Color) {
|
||||
let vk_constants = [
|
||||
color.r as f32,
|
||||
color.g as f32,
|
||||
color.b as f32,
|
||||
color.a as f32,
|
||||
];
|
||||
self.device
|
||||
.raw
|
||||
.cmd_set_blend_constants(self.active, &vk_constants);
|
||||
unsafe fn set_blend_constants(&mut self, color: &[f32; 4]) {
|
||||
self.device.raw.cmd_set_blend_constants(self.active, color);
|
||||
}
|
||||
|
||||
unsafe fn draw(
|
||||
|
Loading…
Reference in New Issue
Block a user