mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-24 15:54:00 +00:00
refactor(dx12): merge PipelineLayoutShared::special_constants_{root_index,cmd_signatures}
into new struct
This commit is contained in:
parent
bbee35b145
commit
fe7fbd4a4a
@ -107,7 +107,13 @@ impl super::CommandEncoder {
|
||||
);
|
||||
}
|
||||
}
|
||||
if let Some(root_index) = self.pass.layout.special_constants_root_index {
|
||||
if let Some(root_index) = self
|
||||
.pass
|
||||
.layout
|
||||
.special_constants
|
||||
.as_ref()
|
||||
.map(|sc| sc.root_index)
|
||||
{
|
||||
let needs_update = match self.pass.root_elements[root_index as usize] {
|
||||
super::RootElement::SpecialConstantBuffer {
|
||||
first_vertex: other_vertex,
|
||||
@ -130,7 +136,13 @@ impl super::CommandEncoder {
|
||||
}
|
||||
|
||||
fn prepare_dispatch(&mut self, count: [u32; 3]) {
|
||||
if let Some(root_index) = self.pass.layout.special_constants_root_index {
|
||||
if let Some(root_index) = self
|
||||
.pass
|
||||
.layout
|
||||
.special_constants
|
||||
.as_ref()
|
||||
.map(|sc| sc.root_index)
|
||||
{
|
||||
let needs_update = match self.pass.root_elements[root_index as usize] {
|
||||
super::RootElement::SpecialConstantBuffer {
|
||||
first_vertex,
|
||||
@ -230,7 +242,7 @@ impl super::CommandEncoder {
|
||||
}
|
||||
|
||||
fn reset_signature(&mut self, layout: &super::PipelineLayoutShared) {
|
||||
if let Some(root_index) = layout.special_constants_root_index {
|
||||
if let Some(root_index) = layout.special_constants.as_ref().map(|sc| sc.root_index) {
|
||||
self.pass.root_elements[root_index as usize] =
|
||||
super::RootElement::SpecialConstantBuffer {
|
||||
first_vertex: 0,
|
||||
@ -1214,8 +1226,9 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
let cmd_signature = &self
|
||||
.pass
|
||||
.layout
|
||||
.special_constants_cmd_signatures
|
||||
.special_constants
|
||||
.as_ref()
|
||||
.map(|sc| &sc.cmd_signatures)
|
||||
.unwrap_or_else(|| &self.shared.cmd_signatures)
|
||||
.dispatch;
|
||||
unsafe {
|
||||
|
@ -1123,9 +1123,7 @@ impl crate::Device for super::Device {
|
||||
}
|
||||
.into_device_result("Root signature creation")?;
|
||||
|
||||
let special_constants_cmd_signatures = if let Some(root_index) =
|
||||
special_constants_root_index
|
||||
{
|
||||
let special_constants = if let Some(root_index) = special_constants_root_index {
|
||||
let constant_indirect_argument_desc = Direct3D12::D3D12_INDIRECT_ARGUMENT_DESC {
|
||||
Type: Direct3D12::D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT,
|
||||
Anonymous: Direct3D12::D3D12_INDIRECT_ARGUMENT_DESC_0 {
|
||||
@ -1153,7 +1151,7 @@ impl crate::Device for super::Device {
|
||||
};
|
||||
size_of_val(&first_vertex) + size_of_val(&first_instance) + size_of_val(&other)
|
||||
};
|
||||
Some(super::CommandSignatures {
|
||||
let cmd_signatures = super::CommandSignatures {
|
||||
draw: Self::create_command_signature(
|
||||
&self.raw,
|
||||
Some(&raw),
|
||||
@ -1193,6 +1191,11 @@ impl crate::Device for super::Device {
|
||||
],
|
||||
0,
|
||||
)?,
|
||||
};
|
||||
|
||||
Some(super::PipelineLayoutSpecialConstants {
|
||||
root_index,
|
||||
cmd_signatures,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
@ -1209,8 +1212,7 @@ impl crate::Device for super::Device {
|
||||
shared: super::PipelineLayoutShared {
|
||||
signature: Some(raw),
|
||||
total_root_elements: parameters.len() as super::RootIndex,
|
||||
special_constants_root_index,
|
||||
special_constants_cmd_signatures,
|
||||
special_constants,
|
||||
root_constant_info,
|
||||
},
|
||||
bind_group_infos,
|
||||
|
@ -685,8 +685,7 @@ impl PassState {
|
||||
layout: PipelineLayoutShared {
|
||||
signature: None,
|
||||
total_root_elements: 0,
|
||||
special_constants_root_index: None,
|
||||
special_constants_cmd_signatures: None,
|
||||
special_constants: None,
|
||||
root_constant_info: None,
|
||||
},
|
||||
root_elements: [RootElement::Empty; MAX_ROOT_ELEMENTS],
|
||||
@ -923,14 +922,22 @@ struct RootConstantInfo {
|
||||
struct PipelineLayoutShared {
|
||||
signature: Option<Direct3D12::ID3D12RootSignature>,
|
||||
total_root_elements: RootIndex,
|
||||
special_constants_root_index: Option<RootIndex>,
|
||||
special_constants_cmd_signatures: Option<CommandSignatures>,
|
||||
special_constants: Option<PipelineLayoutSpecialConstants>,
|
||||
root_constant_info: Option<RootConstantInfo>,
|
||||
}
|
||||
|
||||
unsafe impl Send for PipelineLayoutShared {}
|
||||
unsafe impl Sync for PipelineLayoutShared {}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct PipelineLayoutSpecialConstants {
|
||||
root_index: RootIndex,
|
||||
cmd_signatures: CommandSignatures,
|
||||
}
|
||||
|
||||
unsafe impl Send for PipelineLayoutSpecialConstants {}
|
||||
unsafe impl Sync for PipelineLayoutSpecialConstants {}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PipelineLayout {
|
||||
shared: PipelineLayoutShared,
|
||||
|
Loading…
Reference in New Issue
Block a user