mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-21 06:50:59 +01:00
[core] Use minimum_binding_size terminology in validation. (#9988)
This commit is contained in:
1 parent
de856fc605
commit
b991e6025d
2 files changed
+30
-22
No files matched your search
@@ -4284,7 +4284,7 @@ impl Device {
|
||||
Some(pipeline_layout) => validation::BindingLayoutSource::Provided(pipeline_layout),
|
||||
None => validation::BindingLayoutSource::new_derived(&self.limits),
|
||||
};
|
||||
let mut shader_binding_sizes = FastHashMap::default();
|
||||
let mut minimum_binding_sizes = FastHashMap::default();
|
||||
let mut io = validation::StageIo::default();
|
||||
|
||||
let final_entry_point_name;
|
||||
@@ -4300,7 +4300,7 @@ impl Device {
|
||||
if let Some(interface) = shader_module_state.interface.interface() {
|
||||
io = interface.check_stage(
|
||||
&mut binding_layout_source,
|
||||
&mut shader_binding_sizes,
|
||||
&mut minimum_binding_sizes,
|
||||
&final_entry_point_name,
|
||||
stage,
|
||||
io,
|
||||
@@ -4325,7 +4325,7 @@ impl Device {
|
||||
};
|
||||
|
||||
let late_sized_buffer_groups =
|
||||
Device::make_late_sized_buffer_groups(&shader_binding_sizes, &pipeline_layout);
|
||||
Device::make_late_sized_buffer_groups(&minimum_binding_sizes, &pipeline_layout);
|
||||
|
||||
let cache = match desc.cache {
|
||||
Some(cache) => {
|
||||
@@ -4436,7 +4436,7 @@ impl Device {
|
||||
|
||||
self.check_is_valid()?;
|
||||
|
||||
let mut shader_binding_sizes = FastHashMap::default();
|
||||
let mut minimum_binding_sizes = FastHashMap::default();
|
||||
|
||||
let color_targets = desc
|
||||
.fragment
|
||||
@@ -4897,7 +4897,7 @@ impl Device {
|
||||
io = interface
|
||||
.check_stage(
|
||||
&mut binding_layout_source,
|
||||
&mut shader_binding_sizes,
|
||||
&mut minimum_binding_sizes,
|
||||
&_vertex_entry_point_name,
|
||||
stage,
|
||||
io,
|
||||
@@ -4949,7 +4949,7 @@ impl Device {
|
||||
io = interface
|
||||
.check_stage(
|
||||
&mut binding_layout_source,
|
||||
&mut shader_binding_sizes,
|
||||
&mut minimum_binding_sizes,
|
||||
&_task_entry_point_name,
|
||||
stage,
|
||||
io,
|
||||
@@ -4999,7 +4999,7 @@ impl Device {
|
||||
io = interface
|
||||
.check_stage(
|
||||
&mut binding_layout_source,
|
||||
&mut shader_binding_sizes,
|
||||
&mut minimum_binding_sizes,
|
||||
&_mesh_entry_point_name,
|
||||
stage,
|
||||
io,
|
||||
@@ -5058,7 +5058,7 @@ impl Device {
|
||||
io = interface
|
||||
.check_stage(
|
||||
&mut binding_layout_source,
|
||||
&mut shader_binding_sizes,
|
||||
&mut minimum_binding_sizes,
|
||||
&fragment_entry_point_name,
|
||||
stage,
|
||||
io,
|
||||
@@ -5188,7 +5188,7 @@ impl Device {
|
||||
.flags
|
||||
.contains(wgt::DownlevelFlags::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED)
|
||||
{
|
||||
for (binding, size) in shader_binding_sizes.iter() {
|
||||
for (binding, size) in minimum_binding_sizes.iter() {
|
||||
if size.get() % 16 != 0 {
|
||||
return Err(pipeline::CreateRenderPipelineError::UnalignedShader {
|
||||
binding: binding.binding,
|
||||
@@ -5200,7 +5200,7 @@ impl Device {
|
||||
}
|
||||
|
||||
let late_sized_buffer_groups =
|
||||
Device::make_late_sized_buffer_groups(&shader_binding_sizes, &pipeline_layout);
|
||||
Device::make_late_sized_buffer_groups(&minimum_binding_sizes, &pipeline_layout);
|
||||
|
||||
let cache = match desc.cache {
|
||||
Some(cache) => {
|
||||
|
||||
+20
-12
@@ -26,7 +26,7 @@ pub mod shader_io_deductions;
|
||||
#[derive(Debug)]
|
||||
enum ResourceType {
|
||||
Buffer {
|
||||
size: wgt::BufferSize,
|
||||
minimum_binding_size: wgt::BufferSize,
|
||||
},
|
||||
Texture {
|
||||
dim: naga::ImageDimension,
|
||||
@@ -602,7 +602,9 @@ pub use wgpu_naga_bridge::map_storage_format_to_naga;
|
||||
impl Resource {
|
||||
fn check_binding_use(&self, entry: &BindGroupLayoutEntry) -> Result<(), BindingError> {
|
||||
match self.ty {
|
||||
ResourceType::Buffer { size } => {
|
||||
ResourceType::Buffer {
|
||||
minimum_binding_size,
|
||||
} => {
|
||||
let min_size = match entry.ty {
|
||||
BindingType::Buffer {
|
||||
ty,
|
||||
@@ -635,9 +637,9 @@ impl Resource {
|
||||
}
|
||||
};
|
||||
match min_size {
|
||||
Some(non_zero) if non_zero < size => {
|
||||
Some(non_zero) if non_zero < minimum_binding_size => {
|
||||
return Err(BindingError::WrongBufferSize {
|
||||
buffer_size: size,
|
||||
buffer_size: minimum_binding_size,
|
||||
min_binding_size: non_zero,
|
||||
})
|
||||
}
|
||||
@@ -805,7 +807,9 @@ impl Resource {
|
||||
is_reffed_by_sampler_in_entrypoint: bool,
|
||||
) -> Result<BindingType, BindingError> {
|
||||
Ok(match self.ty {
|
||||
ResourceType::Buffer { size } => BindingType::Buffer {
|
||||
ResourceType::Buffer {
|
||||
minimum_binding_size,
|
||||
} => BindingType::Buffer {
|
||||
ty: match self.class {
|
||||
naga::AddressSpace::Uniform => wgt::BufferBindingType::Uniform,
|
||||
naga::AddressSpace::Storage { access } => wgt::BufferBindingType::Storage {
|
||||
@@ -814,7 +818,7 @@ impl Resource {
|
||||
_ => return Err(BindingError::WrongBufferAddressSpace { space: self.class }),
|
||||
},
|
||||
has_dynamic_offset: false,
|
||||
min_binding_size: Some(size),
|
||||
min_binding_size: Some(minimum_binding_size),
|
||||
},
|
||||
ResourceType::Sampler { comparison } => BindingType::Sampler(if comparison {
|
||||
wgt::SamplerBindingType::Comparison
|
||||
@@ -1278,7 +1282,8 @@ impl Interface {
|
||||
ResourceType::AccelerationStructure { vertex_return }
|
||||
}
|
||||
ref other => ResourceType::Buffer {
|
||||
size: wgt::BufferSize::new(other.size(module.to_ctx()) as u64).unwrap(),
|
||||
minimum_binding_size: wgt::BufferSize::new(other.size(module.to_ctx()) as u64)
|
||||
.unwrap(),
|
||||
},
|
||||
};
|
||||
let handle = resources.append(
|
||||
@@ -1427,7 +1432,7 @@ impl Interface {
|
||||
pub fn check_stage(
|
||||
&self,
|
||||
layouts: &mut BindingLayoutSource,
|
||||
shader_binding_sizes: &mut FastHashMap<naga::ResourceBinding, wgt::BufferSize>,
|
||||
minimum_binding_sizes: &mut FastHashMap<naga::ResourceBinding, wgt::BufferSize>,
|
||||
entry_point_name: &str,
|
||||
shader_stage: ShaderStageForValidation,
|
||||
inputs: StageIo,
|
||||
@@ -1451,13 +1456,16 @@ impl Interface {
|
||||
match layouts {
|
||||
BindingLayoutSource::Provided(pipeline_layout) => {
|
||||
// update the required binding size for this buffer
|
||||
if let ResourceType::Buffer { size } = res.ty {
|
||||
match shader_binding_sizes.entry(res.bind) {
|
||||
if let ResourceType::Buffer {
|
||||
minimum_binding_size,
|
||||
} = res.ty
|
||||
{
|
||||
match minimum_binding_sizes.entry(res.bind) {
|
||||
Entry::Occupied(e) => {
|
||||
*e.into_mut() = size.max(*e.get());
|
||||
*e.into_mut() = minimum_binding_size.max(*e.get());
|
||||
}
|
||||
Entry::Vacant(e) => {
|
||||
e.insert(size);
|
||||
e.insert(minimum_binding_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user