Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for ext_conservative_rasterization #2508

Merged
merged 27 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5ff9f92
disabled bad validation code
LukeP0WERS Mar 23, 2024
dfa359a
conservative rasterization
LukeP0WERS Mar 25, 2024
fab76e5
validation for conservative_rasterization
LukeP0WERS Mar 26, 2024
b791056
rebuild
LukeP0WERS Mar 26, 2024
8d2b152
extra_primitive_overestimation_size dynamic state
LukeP0WERS Mar 28, 2024
975f684
safety fixed
LukeP0WERS Mar 28, 2024
344e152
set builder state
LukeP0WERS Mar 28, 2024
8fa497e
Merge branch 'vulkano-rs:master' into conservative_rasterization
LukeP0WERS Mar 28, 2024
dc538a4
formatted
LukeP0WERS Mar 28, 2024
03fed2c
Merge branch 'conservative_rasterization' of https://github.com/Luke2…
LukeP0WERS Mar 28, 2024
d0a5290
unfixed fake bug fix
LukeP0WERS Mar 28, 2024
1999355
actually unfixed fake bug fix
LukeP0WERS Mar 28, 2024
7cf1033
fixed bad formatting
LukeP0WERS Mar 28, 2024
6625533
deleted duplicate todo
LukeP0WERS Mar 28, 2024
a0aec98
command buffer documentation
LukeP0WERS Mar 28, 2024
1ef06a5
formatted
LukeP0WERS Mar 28, 2024
5c98f41
add vuid
LukeP0WERS Mar 29, 2024
5ef2c8b
add vuid
LukeP0WERS Mar 29, 2024
66f6af8
more validation
LukeP0WERS Mar 29, 2024
14017c8
Update vulkano/src/pipeline/graphics/mod.rs
LukeP0WERS Mar 29, 2024
5be5599
Update vulkano/src/pipeline/graphics/mod.rs
LukeP0WERS Mar 29, 2024
845ca4c
Update vulkano/src/pipeline/graphics/mod.rs
LukeP0WERS Mar 29, 2024
6498a6e
Update vulkano/src/pipeline/graphics/mod.rs
LukeP0WERS Mar 29, 2024
8063221
put in block
LukeP0WERS Mar 29, 2024
91671dc
add todo
LukeP0WERS Mar 29, 2024
d6b14e1
fixed clippy
LukeP0WERS Mar 29, 2024
29a6c3e
removed redundant checks
LukeP0WERS Mar 29, 2024
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
45 changes: 26 additions & 19 deletions vulkano/src/command_buffer/auto/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::{
pipeline::{
graphics::{
color_blend::LogicOp,
conservative_rasterization::ConservativeRasterizationMode,
depth_stencil::{CompareOp, StencilOps},
input_assembly::PrimitiveTopology,
rasterization::{CullMode, DepthBiasState, FrontFace, LineStipple},
Expand Down Expand Up @@ -1207,6 +1208,9 @@ pub(in crate::command_buffer) struct CommandBufferBuilderState {
pub(in crate::command_buffer) vertex_input: Option<VertexInputState>,
pub(in crate::command_buffer) viewport: HashMap<u32, Viewport>,
pub(in crate::command_buffer) viewport_with_count: Option<SmallVec<[Viewport; 2]>>,
pub(in crate::command_buffer) conservative_rasterization_mode:
Option<ConservativeRasterizationMode>,
pub(in crate::command_buffer) extra_primitive_overestimation_size: Option<f32>,

// Active queries
pub(in crate::command_buffer) queries: HashMap<QueryType, QueryState>,
Expand Down Expand Up @@ -1275,25 +1279,28 @@ impl CommandBufferBuilderState {
// DynamicState::ColorBlendEquation => todo!(),
// DynamicState::ColorWriteMask => todo!(),
// DynamicState::RasterizationStream => todo!(),
// DynamicState::ConservativeRasterizationMode => todo!(),
// DynamicState::ExtraPrimitiveOverestimationSize => todo!(),
// DynamicState::DepthClipEnable => todo!(),
// DynamicState::SampleLocationsEnable => todo!(),
// DynamicState::ColorBlendAdvanced => todo!(),
// DynamicState::ProvokingVertexMode => todo!(),
// DynamicState::LineRasterizationMode => todo!(),
// DynamicState::LineStippleEnable => todo!(),
// DynamicState::DepthClipNegativeOneToOne => todo!(),
// DynamicState::ViewportWScalingEnable => todo!(),
// DynamicState::ViewportSwizzle => todo!(),
// DynamicState::CoverageToColorEnable => todo!(),
// DynamicState::CoverageToColorLocation => todo!(),
// DynamicState::CoverageModulationMode => todo!(),
// DynamicState::CoverageModulationTableEnable => todo!(),
// DynamicState::CoverageModulationTable => todo!(),
// DynamicState::ShadingRateImageEnable => todo!(),
// DynamicState::RepresentativeFragmentTestEnable => todo!(),
// DynamicState::CoverageReductionMode => todo!(),
DynamicState::ConservativeRasterizationMode => {
self.conservative_rasterization_mode = None
}
DynamicState::ExtraPrimitiveOverestimationSize => {
self.extra_primitive_overestimation_size = None
} /* DynamicState::DepthClipEnable => todo!(),
* DynamicState::SampleLocationsEnable => todo!(),
* DynamicState::ColorBlendAdvanced => todo!(),
* DynamicState::ProvokingVertexMode => todo!(),
* DynamicState::LineRasterizationMode => todo!(),
* DynamicState::LineStippleEnable => todo!(),
* DynamicState::DepthClipNegativeOneToOne => todo!(),
* DynamicState::ViewportWScalingEnable => todo!(),
* DynamicState::ViewportSwizzle => todo!(),
* DynamicState::CoverageToColorEnable => todo!(),
* DynamicState::CoverageToColorLocation => todo!(),
* DynamicState::CoverageModulationMode => todo!(),
* DynamicState::CoverageModulationTableEnable => todo!(),
* DynamicState::CoverageModulationTable => todo!(),
* DynamicState::ShadingRateImageEnable => todo!(),
* DynamicState::RepresentativeFragmentTestEnable => todo!(),
* DynamicState::CoverageReductionMode => todo!(), */
}
}
}
Expand Down
226 changes: 226 additions & 0 deletions vulkano/src/command_buffer/commands/dynamic_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::{
pipeline::{
graphics::{
color_blend::LogicOp,
conservative_rasterization::ConservativeRasterizationMode,
depth_stencil::{CompareOp, StencilFaces, StencilOp, StencilOps},
input_assembly::PrimitiveTopology,
rasterization::{CullMode, DepthBiasState, FrontFace, LineStipple},
Expand Down Expand Up @@ -1196,6 +1197,91 @@ impl RecordingCommandBuffer {

self
}

/// Sets the dynamic conservative rasterization mode for future draw calls.
#[inline]
pub fn set_conservative_rasterization_mode(
&mut self,
conservative_rasterization_mode: ConservativeRasterizationMode,
) -> Result<&mut Self, Box<ValidationError>> {
self.validate_set_conservative_rasterization_mode()?;

unsafe {
Ok(self.set_conservative_rasterization_mode_unchecked(conservative_rasterization_mode))
}
}

fn validate_set_conservative_rasterization_mode(&self) -> Result<(), Box<ValidationError>> {
self.inner.validate_set_conservative_rasterization_mode()?;

self.validate_graphics_pipeline_fixed_state(DynamicState::ConservativeRasterizationMode)?;

Ok(())
}

#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
pub unsafe fn set_conservative_rasterization_mode_unchecked(
&mut self,
conservative_rasterization_mode: ConservativeRasterizationMode,
) -> &mut Self {
self.builder_state.conservative_rasterization_mode = Some(conservative_rasterization_mode);

self.add_command(
"set_conservative_rasterization_mode",
Default::default(),
move |out: &mut RawRecordingCommandBuffer| {
out.set_conservative_rasterization_mode_unchecked(conservative_rasterization_mode);
},
);

self
}

/// Sets the dynamic extra primitive overestimation size for future draw calls.
#[inline]
pub fn set_extra_primitive_overestimation_size(
&mut self,
extra_primitive_overestimation_size: f32,
) -> Result<&mut Self, Box<ValidationError>> {
self.validate_set_extra_primitive_overestimation_size()?;

unsafe {
Ok(self.set_extra_primitive_overestimation_size_unchecked(
extra_primitive_overestimation_size,
))
}
}

fn validate_set_extra_primitive_overestimation_size(&self) -> Result<(), Box<ValidationError>> {
self.inner.validate_set_conservative_rasterization_mode()?;

self.validate_graphics_pipeline_fixed_state(
DynamicState::ExtraPrimitiveOverestimationSize,
)?;

Ok(())
}

#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
pub unsafe fn set_extra_primitive_overestimation_size_unchecked(
&mut self,
extra_primitive_overestimation_size: f32,
) -> &mut Self {
self.builder_state.extra_primitive_overestimation_size =
Some(extra_primitive_overestimation_size);

self.add_command(
"set_extra_primitive_overestimation_size",
Default::default(),
move |out: &mut RawRecordingCommandBuffer| {
out.set_extra_primitive_overestimation_size_unchecked(
extra_primitive_overestimation_size,
);
},
);

self
}
}

impl RawRecordingCommandBuffer {
Expand Down Expand Up @@ -3186,4 +3272,144 @@ impl RawRecordingCommandBuffer {

self
}

#[inline]
pub unsafe fn set_conservative_rasterization_mode(
&mut self,
conservative_rasterization_mode: ConservativeRasterizationMode,
) -> Result<&mut Self, Box<ValidationError>> {
self.validate_set_conservative_rasterization_mode()?;

Ok(self.set_conservative_rasterization_mode_unchecked(conservative_rasterization_mode))
}

fn validate_set_conservative_rasterization_mode(&self) -> Result<(), Box<ValidationError>> {
if !(self
.device()
.enabled_features()
.extended_dynamic_state3_conservative_rasterization_mode)
{
return Err(Box::new(ValidationError {
requires_one_of: RequiresOneOf(&[
RequiresAllOf(&[Requires::DeviceFeature(
"extended_dynamic_state3_conservative_rasterization_mode",
)]),
RequiresAllOf(&[Requires::DeviceFeature("shader_object")]),
]),
vuids: &["VUID-vkCmdSetConservativeRasterizationModeEXT-None-09423"],
..Default::default()
}));
}

if !self
.queue_family_properties()
.queue_flags
.intersects(QueueFlags::GRAPHICS)
{
return Err(Box::new(ValidationError {
problem: "the queue family of the command buffer does not support \
graphics operations"
.into(),
vuids: &["VUID-vkCmdSetConservativeRasterizationModeEXT-commandBuffer-cmdpool"],
..Default::default()
}));
}

Ok(())
}

#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
pub unsafe fn set_conservative_rasterization_mode_unchecked(
&mut self,
conservative_rasterization_mode: ConservativeRasterizationMode,
) -> &mut Self {
let fns = self.device().fns();
(fns.ext_extended_dynamic_state3
.cmd_set_conservative_rasterization_mode_ext)(
self.handle(),
conservative_rasterization_mode.into(),
);

self
}

#[inline]
pub unsafe fn set_extra_primitive_overestimation_size(
&mut self,
extra_primitive_overestimation_size: f32,
) -> Result<&mut Self, Box<ValidationError>> {
self.validate_set_extra_primitive_overestimation_size(extra_primitive_overestimation_size)?;

Ok(self
.set_extra_primitive_overestimation_size_unchecked(extra_primitive_overestimation_size))
}

fn validate_set_extra_primitive_overestimation_size(
&self,
extra_primitive_overestimation_size: f32,
) -> Result<(), Box<ValidationError>> {
let properties = self.device().physical_device().properties();

if !(self
.device()
.enabled_features()
.extended_dynamic_state3_extra_primitive_overestimation_size)
{
return Err(Box::new(ValidationError {
requires_one_of: RequiresOneOf(&[
RequiresAllOf(&[Requires::DeviceFeature(
"extended_dynamic_state3_extra_primitive_overestimation_size",
)]),
RequiresAllOf(&[Requires::DeviceFeature("shader_object")]),
]),
vuids: &["VUID-vkCmdSetExtraPrimitiveOverestimationSizeEXT-None-09423"],
..Default::default()
}));
}

if !self
.queue_family_properties()
.queue_flags
.intersects(QueueFlags::GRAPHICS)
{
return Err(Box::new(ValidationError {
problem: "the queue family of the command buffer does not support \
graphics operations"
.into(),
vuids: &["VUID-vkCmdSetExtraPrimitiveOverestimationSizeEXT-commandBuffer-cmdpool"],
..Default::default()
}));
}

if extra_primitive_overestimation_size < 0.0
|| extra_primitive_overestimation_size
> properties.max_extra_primitive_overestimation_size.unwrap()
{
return Err(Box::new(ValidationError {
context: "overestimation size".into(),
problem: "the overestimation size is not in the range of 0.0 to `max_extra_primitive_overestimation_size` inclusive".into(),
vuids: &[
"VUID-vkCmdSetExtraPrimitiveOverestimationSizeEXT-extraPrimitiveOverestimationSize-07428",
],
..Default::default()
}));
}

Ok(())
}

#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
pub unsafe fn set_extra_primitive_overestimation_size_unchecked(
&mut self,
extra_primitive_overestimation_size: f32,
) -> &mut Self {
let fns = self.device().fns();
(fns.ext_extended_dynamic_state3
.cmd_set_extra_primitive_overestimation_size_ext)(
self.handle(),
extra_primitive_overestimation_size,
);

self
}
}
37 changes: 37 additions & 0 deletions vulkano/src/command_buffer/commands/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3216,6 +3216,43 @@ impl RecordingCommandBuffer {
// the viewportCount parameter of
// vkCmdSetViewportWithCountEXT must be 1
}
DynamicState::ConservativeRasterizationMode => {
if self.builder_state.conservative_rasterization_mode.is_none() {
return Err(Box::new(ValidationError {
problem: format!(
"the currently bound graphics pipeline requires the \
`DynamicState::{:?}` dynamic state, but \
this state was either not set, or it was overwritten by a \
more recent `bind_pipeline_graphics` command",
dynamic_state
)
.into(),
vuids: vuids!(vuid_type, "None-07631"),
..Default::default()
LukeP0WERS marked this conversation as resolved.
Show resolved Hide resolved
}));
}
// TODO: VUID-vkCmdDraw-conservativePointAndLineRasterization-07499
}
DynamicState::ExtraPrimitiveOverestimationSize => {
if self
.builder_state
.extra_primitive_overestimation_size
.is_none()
{
return Err(Box::new(ValidationError {
problem: format!(
"the currently bound graphics pipeline requires the \
`DynamicState::{:?}` dynamic state, but \
this state was either not set, or it was overwritten by a \
more recent `bind_pipeline_graphics` command",
dynamic_state
)
.into(),
vuids: vuids!(vuid_type, "None-07632"),
..Default::default()
LukeP0WERS marked this conversation as resolved.
Show resolved Hide resolved
}));
}
}
}
}

Expand Down
Loading
Loading