From f7e6e1834f7e90d505d8ec484b9073e1d11af8a9 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Fri, 17 Jan 2025 15:27:42 -0600 Subject: [PATCH 01/84] Initial(untested commit), vulkan and gles only supported --- wgpu-hal/src/empty.rs | 33 +++++ wgpu-hal/src/gles/command.rs | 26 ++++ wgpu-hal/src/gles/device.rs | 10 ++ wgpu-hal/src/lib.rs | 59 ++++++++- wgpu-hal/src/vulkan/adapter.rs | 71 ++++++++++ wgpu-hal/src/vulkan/command.rs | 64 +++++++++ wgpu-hal/src/vulkan/device.rs | 232 +++++++++++++++++++++++++++++++++ wgpu-hal/src/vulkan/mod.rs | 1 + wgpu-types/src/lib.rs | 3 + 9 files changed, 498 insertions(+), 1 deletion(-) diff --git a/wgpu-hal/src/empty.rs b/wgpu-hal/src/empty.rs index dd1e183ed2d..c319252e161 100644 --- a/wgpu-hal/src/empty.rs +++ b/wgpu-hal/src/empty.rs @@ -243,6 +243,16 @@ impl crate::Device for Context { ) -> Result { Ok(Resource) } + unsafe fn create_mesh_pipeline( + &self, + desc: &crate::MeshPipelineDescriptor< + ::PipelineLayout, + ::ShaderModule, + ::PipelineCache, + >, + ) -> Result { + Ok(Resource) + } unsafe fn destroy_render_pipeline(&self, pipeline: Resource) {} unsafe fn create_compute_pipeline( &self, @@ -452,6 +462,13 @@ impl crate::CommandEncoder for Encoder { instance_count: u32, ) { } + unsafe fn draw_mesh_tasks( + &mut self, + group_count_x: u32, + group_count_y: u32, + group_count_z: u32, + ) { + } unsafe fn draw_indirect( &mut self, buffer: &Resource, @@ -466,6 +483,13 @@ impl crate::CommandEncoder for Encoder { draw_count: u32, ) { } + unsafe fn draw_mesh_tasks_indirect( + &mut self, + buffer: &::Buffer, + offset: wgt::BufferAddress, + draw_count: u32, + ) { + } unsafe fn draw_indirect_count( &mut self, buffer: &Resource, @@ -484,6 +508,15 @@ impl crate::CommandEncoder for Encoder { max_count: u32, ) { } + unsafe fn draw_mesh_tasks_indirect_count( + &mut self, + buffer: &::Buffer, + offset: wgt::BufferAddress, + count_buffer: &::Buffer, + count_offset: wgt::BufferAddress, + max_count: u32, + ) { + } // compute diff --git a/wgpu-hal/src/gles/command.rs b/wgpu-hal/src/gles/command.rs index 0f495b48346..8db5b560cc6 100644 --- a/wgpu-hal/src/gles/command.rs +++ b/wgpu-hal/src/gles/command.rs @@ -1078,6 +1078,14 @@ impl crate::CommandEncoder for super::CommandEncoder { first_instance_location: self.state.first_instance_location.clone(), }); } + unsafe fn draw_mesh_tasks( + &mut self, + _group_count_x: u32, + _group_count_y: u32, + _group_count_z: u32, + ) { + unreachable!() + } unsafe fn draw_indirect( &mut self, buffer: &super::Buffer, @@ -1121,6 +1129,14 @@ impl crate::CommandEncoder for super::CommandEncoder { }); } } + unsafe fn draw_mesh_tasks_indirect( + &mut self, + _buffer: &::Buffer, + _offset: wgt::BufferAddress, + _draw_count: u32, + ) { + unreachable!() + } unsafe fn draw_indirect_count( &mut self, _buffer: &super::Buffer, @@ -1141,6 +1157,16 @@ impl crate::CommandEncoder for super::CommandEncoder { ) { unreachable!() } + unsafe fn draw_mesh_tasks_indirect_count( + &mut self, + _buffer: &::Buffer, + _offset: wgt::BufferAddress, + _count_buffer: &::Buffer, + _count_offset: wgt::BufferAddress, + _max_count: u32, + ) { + unreachable!() + } // compute diff --git a/wgpu-hal/src/gles/device.rs b/wgpu-hal/src/gles/device.rs index 0df95686985..8e5fb76cc05 100644 --- a/wgpu-hal/src/gles/device.rs +++ b/wgpu-hal/src/gles/device.rs @@ -1415,6 +1415,16 @@ impl crate::Device for super::Device { alpha_to_coverage_enabled: desc.multisample.alpha_to_coverage_enabled, }) } + unsafe fn create_mesh_pipeline( + &self, + _desc: &crate::MeshPipelineDescriptor< + ::PipelineLayout, + ::ShaderModule, + ::PipelineCache, + >, + ) -> Result<::RenderPipeline, crate::PipelineError> { + unreachable!() + } unsafe fn destroy_render_pipeline(&self, pipeline: super::RenderPipeline) { // If the pipeline only has 2 strong references remaining, they're `pipeline` and `program_cache` diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index 4cc0ef80bdd..75a111100bd 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -289,7 +289,8 @@ use wgt::WasmNotSendSync; // - Vertex + Fragment // - Compute -pub const MAX_CONCURRENT_SHADER_STAGES: usize = 2; +// Task + Mesh + Fragment +pub const MAX_CONCURRENT_SHADER_STAGES: usize = 3; pub const MAX_ANISOTROPY: u8 = 16; pub const MAX_BIND_GROUPS: usize = 8; pub const MAX_VERTEX_BUFFERS: usize = 16; @@ -884,6 +885,14 @@ pub trait Device: WasmNotSendSync { ::PipelineCache, >, ) -> Result<::RenderPipeline, PipelineError>; + unsafe fn create_mesh_pipeline( + &self, + desc: &MeshPipelineDescriptor< + ::PipelineLayout, + ::ShaderModule, + ::PipelineCache, + >, + ) -> Result<::RenderPipeline, PipelineError>; unsafe fn destroy_render_pipeline(&self, pipeline: ::RenderPipeline); #[allow(clippy::type_complexity)] @@ -1433,6 +1442,26 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug { count_offset: wgt::BufferAddress, max_count: u32, ); + unsafe fn draw_mesh_tasks( + &mut self, + group_count_x: u32, + group_count_y: u32, + group_count_z: u32, + ); + unsafe fn draw_mesh_tasks_indirect( + &mut self, + buffer: &::Buffer, + offset: wgt::BufferAddress, + draw_count: u32, + ); + unsafe fn draw_mesh_tasks_indirect_count( + &mut self, + buffer: &::Buffer, + offset: wgt::BufferAddress, + count_buffer: &::Buffer, + count_offset: wgt::BufferAddress, + max_count: u32, + ); // compute passes @@ -2214,6 +2243,34 @@ pub struct RenderPipelineDescriptor< /// The cache which will be used and filled when compiling this pipeline pub cache: Option<&'a Pc>, } +// TODO: redesign this struct +pub struct MeshPipelineDescriptor< + 'a, + Pl: DynPipelineLayout + ?Sized, + M: DynShaderModule + ?Sized, + Pc: DynPipelineCache + ?Sized, +> { + pub label: Label<'a>, + /// The layout of bind groups for this pipeline. + pub layout: &'a Pl, + pub task_stage: Option>, + pub mesh_stage: ProgrammableStage<'a, M>, + /// The properties of the pipeline at the primitive assembly and rasterization level. + pub primitive: wgt::PrimitiveState, + /// The effect of draw calls on the depth and stencil aspects of the output target, if any. + pub depth_stencil: Option, + /// The multi-sampling properties of the pipeline. + pub multisample: wgt::MultisampleState, + /// The fragment stage for this pipeline. + pub fragment_stage: Option>, + /// The effect of draw calls on the color aspect of the output target. + pub color_targets: &'a [Option], + /// If the pipeline will be used with a multiview render pass, this indicates how many array + /// layers the attachments will have. + pub multiview: Option, + /// The cache which will be used and filled when compiling this pipeline + pub cache: Option<&'a Pc>, +} #[derive(Debug, Clone)] pub struct SurfaceConfiguration { diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index fd190fc34ab..3dba2b4ae94 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -117,6 +117,8 @@ pub struct PhysicalDeviceFeatures { /// Features provided by `VK_EXT_subgroup_size_control`, promoted to Vulkan 1.3. subgroup_size_control: Option>, + mesh_shader: Option>, + maintenance4: Option>, } impl PhysicalDeviceFeatures { @@ -172,6 +174,12 @@ impl PhysicalDeviceFeatures { if let Some(ref mut feature) = self.subgroup_size_control { info = info.push_next(feature); } + if let Some(ref mut feature) = self.mesh_shader { + info = info.push_next(feature); + } + if let Some(ref mut feature) = self.maintenance4 { + info = info.push_next(feature); + } info } @@ -481,6 +489,24 @@ impl PhysicalDeviceFeatures { } else { None }, + mesh_shader: if enabled_extensions.contains(&ext::mesh_shader::NAME) { + let needed = requested_features.contains(wgt::Features::MESH_SHADER); + let multiview = requested_features.contains(wgt::Features::MULTIVIEW); + Some( + vk::PhysicalDeviceMeshShaderFeaturesEXT::default() + .mesh_shader(needed) + .task_shader(needed) + .multiview_mesh_shader(needed && multiview), + ) + } else { + None + }, + maintenance4: if enabled_extensions.contains(&khr::maintenance4::NAME) { + let needed = requested_features.contains(wgt::Features::MESH_SHADER); + Some(vk::PhysicalDeviceMaintenance4FeaturesKHR::default().maintenance4(needed)) + } else { + None + }, } } @@ -811,6 +837,11 @@ impl PhysicalDeviceFeatures { caps.supports_extension(khr::external_memory_win32::NAME), ); + features.set( + F::MESH_SHADER, + caps.supports_extension(ext::mesh_shader::NAME), + ); + (features, dl_flags) } } @@ -872,6 +903,9 @@ pub struct PhysicalDeviceProperties { /// `VK_EXT_robustness2` extension. robustness2: Option>, + /// This may be used at some point + _mesh_shader: Option>, + /// The device API version. /// /// Which is the version of Vulkan supported for device-level functionality. @@ -973,6 +1007,10 @@ impl PhysicalDeviceProperties { } } + if requested_features.intersects(wgt::Features::MESH_SHADER) { + extensions.push(khr::spirv_1_4::NAME); + } + //extensions.push(khr::sampler_mirror_clamp_to_edge::NAME); //extensions.push(ext::sampler_filter_minmax::NAME); } @@ -987,6 +1025,10 @@ impl PhysicalDeviceProperties { if requested_features.contains(wgt::Features::SUBGROUP) { extensions.push(ext::subgroup_size_control::NAME); } + + if requested_features.intersects(wgt::Features::MESH_SHADER) { + extensions.push(khr::maintenance4::NAME); + } } // Optional `VK_KHR_swapchain_mutable_format` @@ -1061,6 +1103,10 @@ impl PhysicalDeviceProperties { extensions.push(google::display_timing::NAME); } + if requested_features.contains(wgt::Features::MESH_SHADER) { + extensions.push(ext::mesh_shader::NAME); + } + extensions } @@ -1222,6 +1268,8 @@ impl super::InstanceShared { let supports_acceleration_structure = capabilities.supports_extension(khr::acceleration_structure::NAME); + let supports_mesh_shader = capabilities.supports_extension(ext::mesh_shader::NAME); + let mut properties2 = vk::PhysicalDeviceProperties2KHR::default(); if supports_maintenance3 { let next = capabilities @@ -1272,6 +1320,13 @@ impl super::InstanceShared { properties2 = properties2.push_next(next); } + if supports_mesh_shader { + let next = capabilities + ._mesh_shader + .insert(vk::PhysicalDeviceMeshShaderPropertiesEXT::default()); + properties2 = properties2.push_next(next); + } + unsafe { get_device_properties.get_physical_device_properties2(phd, &mut properties2) }; @@ -1418,6 +1473,13 @@ impl super::InstanceShared { features2 = features2.push_next(next); } + if capabilities.supports_extension(ext::mesh_shader::NAME) { + let next = features + .mesh_shader + .insert(vk::PhysicalDeviceMeshShaderFeaturesEXT::default()); + features2 = features2.push_next(next); + } + unsafe { get_device_properties.get_physical_device_features2(phd, &mut features2) }; features2.features } else { @@ -1786,6 +1848,14 @@ impl super::Adapter { } else { None }; + let mesh_shading_fns = if enabled_extensions.contains(&ext::mesh_shader::NAME) { + Some(ext::mesh_shader::Device::new( + &self.instance.raw, + &raw_device, + )) + } else { + None + }; let naga_options = { use naga::back::spv; @@ -1959,6 +2029,7 @@ impl super::Adapter { draw_indirect_count: indirect_count_fn, timeline_semaphore: timeline_semaphore_fn, ray_tracing: ray_tracing_fns, + mesh_shading: mesh_shading_fns, }, pipeline_cache_validation_key, vendor_id: self.phd_capabilities.properties.vendor_id, diff --git a/wgpu-hal/src/vulkan/command.rs b/wgpu-hal/src/vulkan/command.rs index 8c6c5281feb..7f44cb2adf5 100644 --- a/wgpu-hal/src/vulkan/command.rs +++ b/wgpu-hal/src/vulkan/command.rs @@ -1011,6 +1011,21 @@ impl crate::CommandEncoder for super::CommandEncoder { ) }; } + unsafe fn draw_mesh_tasks( + &mut self, + group_count_x: u32, + group_count_y: u32, + group_count_z: u32, + ) { + match self.device.extension_fns.mesh_shading { + Some(ref t) => { + unsafe { + t.cmd_draw_mesh_tasks(self.active, group_count_x, group_count_y, group_count_z); + }; + } + None => panic!("Feature `MESH_SHADING` not enabled"), + } + } unsafe fn draw_indirect( &mut self, buffer: &super::Buffer, @@ -1043,6 +1058,27 @@ impl crate::CommandEncoder for super::CommandEncoder { ) }; } + unsafe fn draw_mesh_tasks_indirect( + &mut self, + buffer: &::Buffer, + offset: wgt::BufferAddress, + draw_count: u32, + ) { + match self.device.extension_fns.mesh_shading { + Some(ref t) => { + unsafe { + t.cmd_draw_mesh_tasks_indirect( + self.active, + buffer.raw, + offset, + draw_count, + size_of::() as u32, + ); + }; + } + None => panic!("Feature `MESH_SHADING` not enabled"), + } + } unsafe fn draw_indirect_count( &mut self, buffer: &super::Buffer, @@ -1095,6 +1131,34 @@ impl crate::CommandEncoder for super::CommandEncoder { None => panic!("Feature `DRAW_INDIRECT_COUNT` not enabled"), } } + unsafe fn draw_mesh_tasks_indirect_count( + &mut self, + buffer: &::Buffer, + offset: wgt::BufferAddress, + count_buffer: &super::Buffer, + count_offset: wgt::BufferAddress, + max_count: u32, + ) { + if self.device.extension_fns.draw_indirect_count.is_none() { + panic!("Feature `DRAW_INDIRECT_COUNT` not enabled"); + } + match self.device.extension_fns.mesh_shading { + Some(ref t) => { + unsafe { + t.cmd_draw_mesh_tasks_indirect_count( + self.active, + buffer.raw, + offset, + count_buffer.raw, + count_offset, + max_count, + size_of::() as u32, + ); + }; + } + None => panic!("Feature `MESH_SHADING` not enabled"), + } + } // compute diff --git a/wgpu-hal/src/vulkan/device.rs b/wgpu-hal/src/vulkan/device.rs index 03fa9c0c59f..a3657fdfef1 100644 --- a/wgpu-hal/src/vulkan/device.rs +++ b/wgpu-hal/src/vulkan/device.rs @@ -2107,6 +2107,238 @@ impl crate::Device for super::Device { Ok(super::RenderPipeline { raw }) } + unsafe fn create_mesh_pipeline( + &self, + desc: &crate::MeshPipelineDescriptor< + ::PipelineLayout, + ::ShaderModule, + ::PipelineCache, + >, + ) -> Result<::RenderPipeline, crate::PipelineError> { + let dynamic_states = [ + vk::DynamicState::VIEWPORT, + vk::DynamicState::SCISSOR, + vk::DynamicState::BLEND_CONSTANTS, + vk::DynamicState::STENCIL_REFERENCE, + ]; + let mut compatible_rp_key = super::RenderPassKey { + sample_count: desc.multisample.count, + multiview: desc.multiview, + ..Default::default() + }; + let mut stages = ArrayVec::<_, { crate::MAX_CONCURRENT_SHADER_STAGES }>::new(); + + let vk_input_assembly = vk::PipelineInputAssemblyStateCreateInfo::default() + .topology(conv::map_topology(desc.primitive.topology)) + .primitive_restart_enable(desc.primitive.strip_index_format.is_some()); + + let compiled_ts = match desc.task_stage { + Some(ref stage) => { + // TODO: add proper naga stages + let compiled = self.compile_stage( + stage, + naga::ShaderStage::Compute, + &desc.layout.binding_arrays, + )?; + stages.push(compiled.create_info); + Some(compiled) + } + None => None, + }; + + // TODO: add proper naga stages + let compiled_ms = self.compile_stage( + &desc.mesh_stage, + naga::ShaderStage::Compute, + &desc.layout.binding_arrays, + )?; + stages.push(compiled_ms.create_info); + let compiled_fs = match desc.fragment_stage { + Some(ref stage) => { + let compiled = self.compile_stage( + stage, + naga::ShaderStage::Fragment, + &desc.layout.binding_arrays, + )?; + stages.push(compiled.create_info); + Some(compiled) + } + None => None, + }; + + let mut vk_rasterization = vk::PipelineRasterizationStateCreateInfo::default() + .polygon_mode(conv::map_polygon_mode(desc.primitive.polygon_mode)) + .front_face(conv::map_front_face(desc.primitive.front_face)) + .line_width(1.0) + .depth_clamp_enable(desc.primitive.unclipped_depth); + if let Some(face) = desc.primitive.cull_mode { + vk_rasterization = vk_rasterization.cull_mode(conv::map_cull_face(face)) + } + let mut vk_rasterization_conservative_state = + vk::PipelineRasterizationConservativeStateCreateInfoEXT::default() + .conservative_rasterization_mode( + vk::ConservativeRasterizationModeEXT::OVERESTIMATE, + ); + if desc.primitive.conservative { + vk_rasterization = vk_rasterization.push_next(&mut vk_rasterization_conservative_state); + } + + let mut vk_depth_stencil = vk::PipelineDepthStencilStateCreateInfo::default(); + if let Some(ref ds) = desc.depth_stencil { + let vk_format = self.shared.private_caps.map_texture_format(ds.format); + let vk_layout = if ds.is_read_only(desc.primitive.cull_mode) { + vk::ImageLayout::DEPTH_STENCIL_READ_ONLY_OPTIMAL + } else { + vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL + }; + compatible_rp_key.depth_stencil = Some(super::DepthStencilAttachmentKey { + base: super::AttachmentKey::compatible(vk_format, vk_layout), + stencil_ops: crate::AttachmentOps::all(), + }); + + if ds.is_depth_enabled() { + vk_depth_stencil = vk_depth_stencil + .depth_test_enable(true) + .depth_write_enable(ds.depth_write_enabled) + .depth_compare_op(conv::map_comparison(ds.depth_compare)); + } + if ds.stencil.is_enabled() { + let s = &ds.stencil; + let front = conv::map_stencil_face(&s.front, s.read_mask, s.write_mask); + let back = conv::map_stencil_face(&s.back, s.read_mask, s.write_mask); + vk_depth_stencil = vk_depth_stencil + .stencil_test_enable(true) + .front(front) + .back(back); + } + + if ds.bias.is_enabled() { + vk_rasterization = vk_rasterization + .depth_bias_enable(true) + .depth_bias_constant_factor(ds.bias.constant as f32) + .depth_bias_clamp(ds.bias.clamp) + .depth_bias_slope_factor(ds.bias.slope_scale); + } + } + + let vk_viewport = vk::PipelineViewportStateCreateInfo::default() + .flags(vk::PipelineViewportStateCreateFlags::empty()) + .scissor_count(1) + .viewport_count(1); + + let vk_sample_mask = [ + desc.multisample.mask as u32, + (desc.multisample.mask >> 32) as u32, + ]; + let vk_multisample = vk::PipelineMultisampleStateCreateInfo::default() + .rasterization_samples(vk::SampleCountFlags::from_raw(desc.multisample.count)) + .alpha_to_coverage_enable(desc.multisample.alpha_to_coverage_enabled) + .sample_mask(&vk_sample_mask); + + let mut vk_attachments = Vec::with_capacity(desc.color_targets.len()); + for cat in desc.color_targets { + let (key, attarchment) = if let Some(cat) = cat.as_ref() { + let mut vk_attachment = vk::PipelineColorBlendAttachmentState::default() + .color_write_mask(vk::ColorComponentFlags::from_raw(cat.write_mask.bits())); + if let Some(ref blend) = cat.blend { + let (color_op, color_src, color_dst) = conv::map_blend_component(&blend.color); + let (alpha_op, alpha_src, alpha_dst) = conv::map_blend_component(&blend.alpha); + vk_attachment = vk_attachment + .blend_enable(true) + .color_blend_op(color_op) + .src_color_blend_factor(color_src) + .dst_color_blend_factor(color_dst) + .alpha_blend_op(alpha_op) + .src_alpha_blend_factor(alpha_src) + .dst_alpha_blend_factor(alpha_dst); + } + + let vk_format = self.shared.private_caps.map_texture_format(cat.format); + ( + Some(super::ColorAttachmentKey { + base: super::AttachmentKey::compatible( + vk_format, + vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL, + ), + resolve: None, + }), + vk_attachment, + ) + } else { + (None, vk::PipelineColorBlendAttachmentState::default()) + }; + + compatible_rp_key.colors.push(key); + vk_attachments.push(attarchment); + } + + let vk_color_blend = + vk::PipelineColorBlendStateCreateInfo::default().attachments(&vk_attachments); + + let vk_dynamic_state = + vk::PipelineDynamicStateCreateInfo::default().dynamic_states(&dynamic_states); + + let raw_pass = self + .shared + .make_render_pass(compatible_rp_key) + .map_err(crate::DeviceError::from)?; + + let vk_infos = [{ + vk::GraphicsPipelineCreateInfo::default() + .layout(desc.layout.raw) + .stages(&stages) + .input_assembly_state(&vk_input_assembly) + .rasterization_state(&vk_rasterization) + .viewport_state(&vk_viewport) + .multisample_state(&vk_multisample) + .depth_stencil_state(&vk_depth_stencil) + .color_blend_state(&vk_color_blend) + .dynamic_state(&vk_dynamic_state) + .render_pass(raw_pass) + }]; + + let pipeline_cache = desc + .cache + .map(|it| it.raw) + .unwrap_or(vk::PipelineCache::null()); + + let mut raw_vec = { + profiling::scope!("vkCreateGraphicsPipelines"); + unsafe { + self.shared + .raw + .create_graphics_pipelines(pipeline_cache, &vk_infos, None) + .map_err(|(_, e)| super::map_pipeline_err(e)) + }? + }; + + let raw = raw_vec.pop().unwrap(); + if let Some(label) = desc.label { + unsafe { self.shared.set_object_name(raw, label) }; + } + + if let Some(CompiledStage { + temp_raw_module: Some(raw_module), + .. + }) = compiled_ts + { + unsafe { self.shared.raw.destroy_shader_module(raw_module, None) }; + } + if let Some(raw_module) = compiled_ms.temp_raw_module { + unsafe { self.shared.raw.destroy_shader_module(raw_module, None) }; + } + if let Some(CompiledStage { + temp_raw_module: Some(raw_module), + .. + }) = compiled_fs + { + unsafe { self.shared.raw.destroy_shader_module(raw_module, None) }; + } + + self.counters.render_pipelines.add(1); + + Ok(super::RenderPipeline { raw }) + } unsafe fn destroy_render_pipeline(&self, pipeline: super::RenderPipeline) { unsafe { self.shared.raw.destroy_pipeline(pipeline.raw, None) }; diff --git a/wgpu-hal/src/vulkan/mod.rs b/wgpu-hal/src/vulkan/mod.rs index 31a893e56e0..1e31c557bf5 100644 --- a/wgpu-hal/src/vulkan/mod.rs +++ b/wgpu-hal/src/vulkan/mod.rs @@ -480,6 +480,7 @@ struct DeviceExtensionFunctions { draw_indirect_count: Option, timeline_semaphore: Option>, ray_tracing: Option, + mesh_shading: Option, } struct RayTracingDeviceExtensionFunctions { diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 7813c36c654..41688c352e2 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -476,6 +476,9 @@ bitflags::bitflags! { /// This is a web and native feature. const FLOAT32_FILTERABLE = 1 << 11; + /// TODO: REMOVE THIS + const MESH_SHADER = 1 << 15; + // Bits 12-18 available for webgpu features. Should you chose to use some of them for // for native features, don't forget to update `all_webgpu_mask` and `all_native_mask` // accordingly. From 4e5772b6470630654f365fc37ccbe47c4a898223 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Fri, 17 Jan 2025 18:38:11 -0600 Subject: [PATCH 02/84] Maybe fixed compiles for metal and dx12 --- wgpu-hal/src/dx12/command.rs | 26 ++++++++++++++++++++++++++ wgpu-hal/src/dx12/device.rs | 12 ++++++++++++ wgpu-hal/src/metal/command.rs | 29 +++++++++++++++++++++++++++++ wgpu-hal/src/metal/device.rs | 11 +++++++++++ 4 files changed, 78 insertions(+) diff --git a/wgpu-hal/src/dx12/command.rs b/wgpu-hal/src/dx12/command.rs index 99cee37373c..f42bff3c5c8 100644 --- a/wgpu-hal/src/dx12/command.rs +++ b/wgpu-hal/src/dx12/command.rs @@ -1107,6 +1107,14 @@ impl crate::CommandEncoder for super::CommandEncoder { ) } } + unsafe fn draw_mesh_tasks( + &mut self, + _group_count_x: u32, + _group_count_y: u32, + _group_count_z: u32, + ) { + unreachable!() + } unsafe fn draw_indirect( &mut self, buffer: &super::Buffer, @@ -1143,6 +1151,14 @@ impl crate::CommandEncoder for super::CommandEncoder { ) } } + unsafe fn draw_mesh_tasks_indirect( + &mut self, + _buffer: &::Buffer, + _offset: wgt::BufferAddress, + _draw_count: u32, + ) { + unreachable!() + } unsafe fn draw_indirect_count( &mut self, buffer: &super::Buffer, @@ -1183,6 +1199,16 @@ impl crate::CommandEncoder for super::CommandEncoder { ) } } + unsafe fn draw_mesh_tasks_indirect_count( + &mut self, + _buffer: &::Buffer, + _offset: wgt::BufferAddress, + _count_buffer: &::Buffer, + _count_offset: wgt::BufferAddress, + _max_count: u32, + ) { + unreachable!() + } // compute diff --git a/wgpu-hal/src/dx12/device.rs b/wgpu-hal/src/dx12/device.rs index b9a825845aa..be400d01685 100644 --- a/wgpu-hal/src/dx12/device.rs +++ b/wgpu-hal/src/dx12/device.rs @@ -1685,6 +1685,18 @@ impl crate::Device for super::Device { vertex_strides, }) } + + unsafe fn create_mesh_pipeline( + &self, + _desc: &crate::MeshPipelineDescriptor< + ::PipelineLayout, + ::ShaderModule, + ::PipelineCache, + >, + ) -> Result<::RenderPipeline, crate::PipelineError> { + unreachable!() + } + unsafe fn destroy_render_pipeline(&self, _pipeline: super::RenderPipeline) { self.counters.render_pipelines.sub(1); } diff --git a/wgpu-hal/src/metal/command.rs b/wgpu-hal/src/metal/command.rs index a66349cbf40..9fe4e61f6f1 100644 --- a/wgpu-hal/src/metal/command.rs +++ b/wgpu-hal/src/metal/command.rs @@ -1087,6 +1087,15 @@ impl crate::CommandEncoder for super::CommandEncoder { } } + unsafe fn draw_mesh_tasks( + &mut self, + _group_count_x: u32, + _group_count_y: u32, + _group_count_z: u32, + ) { + unreachable!() + } + unsafe fn draw_indirect( &mut self, buffer: &super::Buffer, @@ -1121,6 +1130,15 @@ impl crate::CommandEncoder for super::CommandEncoder { } } + unsafe fn draw_mesh_tasks_indirect( + &mut self, + _buffer: &::Buffer, + _offset: wgt::BufferAddress, + _draw_count: u32, + ) { + unreachable!() + } + unsafe fn draw_indirect_count( &mut self, _buffer: &super::Buffer, @@ -1142,6 +1160,17 @@ impl crate::CommandEncoder for super::CommandEncoder { //TODO } + unsafe fn draw_mesh_tasks_indirect_count( + &mut self, + _buffer: &::Buffer, + _offset: wgt::BufferAddress, + _count_buffer: &::Buffer, + _count_offset: wgt::BufferAddress, + _max_count: u32, + ) { + unreachable!() + } + // compute unsafe fn begin_compute_pass(&mut self, desc: &crate::ComputePassDescriptor) { diff --git a/wgpu-hal/src/metal/device.rs b/wgpu-hal/src/metal/device.rs index b2e514b4a37..b54cd782136 100644 --- a/wgpu-hal/src/metal/device.rs +++ b/wgpu-hal/src/metal/device.rs @@ -1270,6 +1270,17 @@ impl crate::Device for super::Device { }) } + unsafe fn create_mesh_pipeline( + &self, + _desc: &crate::MeshPipelineDescriptor< + ::PipelineLayout, + ::ShaderModule, + ::PipelineCache, + >, + ) -> Result<::RenderPipeline, crate::PipelineError> { + unreachable!() + } + unsafe fn destroy_render_pipeline(&self, _pipeline: super::RenderPipeline) { self.counters.render_pipelines.sub(1); } From ab83fa760380074a70e5dd63e4a434da1059b39a Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Fri, 17 Jan 2025 19:38:50 -0600 Subject: [PATCH 03/84] Hopefully fixed compiles for other backends and updated to functional(?) vulkan thing --- wgpu-hal/src/dynamic/command.rs | 61 +++++++++++++++++++++++++++++++++ wgpu-hal/src/dynamic/device.rs | 42 ++++++++++++++++++++--- wgpu-hal/src/vulkan/device.rs | 6 ++-- 3 files changed, 103 insertions(+), 6 deletions(-) diff --git a/wgpu-hal/src/dynamic/command.rs b/wgpu-hal/src/dynamic/command.rs index 4ecdf74723d..1734609426a 100644 --- a/wgpu-hal/src/dynamic/command.rs +++ b/wgpu-hal/src/dynamic/command.rs @@ -129,6 +129,12 @@ pub trait DynCommandEncoder: DynResource + std::fmt::Debug { first_instance: u32, instance_count: u32, ); + unsafe fn draw_mesh_tasks( + &mut self, + group_count_x: u32, + group_count_y: u32, + group_count_z: u32, + ); unsafe fn draw_indirect( &mut self, buffer: &dyn DynBuffer, @@ -141,6 +147,12 @@ pub trait DynCommandEncoder: DynResource + std::fmt::Debug { offset: wgt::BufferAddress, draw_count: u32, ); + unsafe fn draw_mesh_tasks_indirect( + &mut self, + buffer: &dyn DynBuffer, + offset: wgt::BufferAddress, + draw_count: u32, + ); unsafe fn draw_indirect_count( &mut self, buffer: &dyn DynBuffer, @@ -157,6 +169,14 @@ pub trait DynCommandEncoder: DynResource + std::fmt::Debug { count_offset: wgt::BufferAddress, max_count: u32, ); + unsafe fn draw_mesh_tasks_indirect_count( + &mut self, + buffer: &dyn DynBuffer, + offset: wgt::BufferAddress, + count_buffer: &dyn DynBuffer, + count_offset: wgt::BufferAddress, + max_count: u32, + ); unsafe fn begin_compute_pass(&mut self, desc: &ComputePassDescriptor); unsafe fn end_compute_pass(&mut self); @@ -460,6 +480,15 @@ impl DynCommandEncoder for C { }; } + unsafe fn draw_mesh_tasks( + &mut self, + group_count_x: u32, + group_count_y: u32, + group_count_z: u32, + ) { + unsafe { C::draw_mesh_tasks(self, group_count_x, group_count_y, group_count_z) }; + } + unsafe fn draw_indirect( &mut self, buffer: &dyn DynBuffer, @@ -480,6 +509,16 @@ impl DynCommandEncoder for C { unsafe { C::draw_indexed_indirect(self, buffer, offset, draw_count) }; } + unsafe fn draw_mesh_tasks_indirect( + &mut self, + buffer: &dyn DynBuffer, + offset: wgt::BufferAddress, + draw_count: u32, + ) { + let buffer = buffer.expect_downcast_ref(); + unsafe { C::draw_mesh_tasks_indirect(self, buffer, offset, draw_count) }; + } + unsafe fn draw_indirect_count( &mut self, buffer: &dyn DynBuffer, @@ -517,6 +556,28 @@ impl DynCommandEncoder for C { }; } + unsafe fn draw_mesh_tasks_indirect_count( + &mut self, + buffer: &dyn DynBuffer, + offset: wgt::BufferAddress, + count_buffer: &dyn DynBuffer, + count_offset: wgt::BufferAddress, + max_count: u32, + ) { + let buffer = buffer.expect_downcast_ref(); + let count_buffer = count_buffer.expect_downcast_ref(); + unsafe { + C::draw_mesh_tasks_indirect_count( + self, + buffer, + offset, + count_buffer, + count_offset, + max_count, + ) + }; + } + unsafe fn begin_compute_pass(&mut self, desc: &ComputePassDescriptor) { let desc = ComputePassDescriptor { label: desc.label, diff --git a/wgpu-hal/src/dynamic/device.rs b/wgpu-hal/src/dynamic/device.rs index 9366270bcfe..6189480839e 100644 --- a/wgpu-hal/src/dynamic/device.rs +++ b/wgpu-hal/src/dynamic/device.rs @@ -2,10 +2,10 @@ use crate::{ AccelerationStructureBuildSizes, AccelerationStructureDescriptor, Api, BindGroupDescriptor, BindGroupLayoutDescriptor, BufferDescriptor, BufferMapping, CommandEncoderDescriptor, ComputePipelineDescriptor, Device, DeviceError, FenceValue, - GetAccelerationStructureBuildSizesDescriptor, Label, MemoryRange, PipelineCacheDescriptor, - PipelineCacheError, PipelineError, PipelineLayoutDescriptor, RenderPipelineDescriptor, - SamplerDescriptor, ShaderError, ShaderInput, ShaderModuleDescriptor, TextureDescriptor, - TextureViewDescriptor, TlasInstance, + GetAccelerationStructureBuildSizesDescriptor, Label, MemoryRange, MeshPipelineDescriptor, + PipelineCacheDescriptor, PipelineCacheError, PipelineError, PipelineLayoutDescriptor, + RenderPipelineDescriptor, SamplerDescriptor, ShaderError, ShaderInput, ShaderModuleDescriptor, + TextureDescriptor, TextureViewDescriptor, TlasInstance, }; use super::{ @@ -98,6 +98,14 @@ pub trait DynDevice: DynResource { dyn DynPipelineCache, >, ) -> Result, PipelineError>; + unsafe fn create_mesh_pipeline( + &self, + desc: &MeshPipelineDescriptor< + dyn DynPipelineLayout, + dyn DynShaderModule, + dyn DynPipelineCache, + >, + ) -> Result, PipelineError>; unsafe fn destroy_render_pipeline(&self, pipeline: Box); unsafe fn create_compute_pipeline( @@ -391,6 +399,32 @@ impl DynDevice for D { .map(|b| -> Box { Box::new(b) }) } + unsafe fn create_mesh_pipeline( + &self, + desc: &MeshPipelineDescriptor< + dyn DynPipelineLayout, + dyn DynShaderModule, + dyn DynPipelineCache, + >, + ) -> Result, PipelineError> { + let desc = MeshPipelineDescriptor { + label: desc.label, + layout: desc.layout.expect_downcast_ref(), + task_stage: desc.task_stage.clone().map(|f| f.expect_downcast()), + mesh_stage: desc.mesh_stage.clone().expect_downcast(), + primitive: desc.primitive, + depth_stencil: desc.depth_stencil.clone(), + multisample: desc.multisample, + fragment_stage: desc.fragment_stage.clone().map(|f| f.expect_downcast()), + color_targets: desc.color_targets, + multiview: desc.multiview, + cache: desc.cache.map(|c| c.expect_downcast_ref()), + }; + + unsafe { D::create_mesh_pipeline(self, &desc) } + .map(|b| -> Box { Box::new(b) }) + } + unsafe fn destroy_render_pipeline(&self, pipeline: Box) { unsafe { D::destroy_render_pipeline(self, pipeline.unbox()) }; } diff --git a/wgpu-hal/src/vulkan/device.rs b/wgpu-hal/src/vulkan/device.rs index a3657fdfef1..39275e31336 100644 --- a/wgpu-hal/src/vulkan/device.rs +++ b/wgpu-hal/src/vulkan/device.rs @@ -2135,11 +2135,12 @@ impl crate::Device for super::Device { let compiled_ts = match desc.task_stage { Some(ref stage) => { // TODO: add proper naga stages - let compiled = self.compile_stage( + let mut compiled = self.compile_stage( stage, naga::ShaderStage::Compute, &desc.layout.binding_arrays, )?; + compiled.create_info.stage = vk::ShaderStageFlags::TASK_EXT; stages.push(compiled.create_info); Some(compiled) } @@ -2147,11 +2148,12 @@ impl crate::Device for super::Device { }; // TODO: add proper naga stages - let compiled_ms = self.compile_stage( + let mut compiled_ms = self.compile_stage( &desc.mesh_stage, naga::ShaderStage::Compute, &desc.layout.binding_arrays, )?; + compiled_ms.create_info.stage = vk::ShaderStageFlags::MESH_EXT; stages.push(compiled_ms.create_info); let compiled_fs = match desc.fragment_stage { Some(ref stage) => { From 06d3f52af88a0a5f86295f21b00abab7376cde77 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Fri, 17 Jan 2025 19:49:29 -0600 Subject: [PATCH 04/84] Fixed the clippy warning --- wgpu-hal/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index 75a111100bd..a759b48740c 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -885,6 +885,7 @@ pub trait Device: WasmNotSendSync { ::PipelineCache, >, ) -> Result<::RenderPipeline, PipelineError>; + #[allow(clippy::type_complexity)] unsafe fn create_mesh_pipeline( &self, desc: &MeshPipelineDescriptor< From 8b67893ed64b43e65f4902bd6f3a19852ae74ce4 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Fri, 17 Jan 2025 22:33:39 -0600 Subject: [PATCH 05/84] Initial naga changes and outline --- naga/src/back/dot/mod.rs | 15 +++++ naga/src/back/glsl/mod.rs | 38 ++++++++++- naga/src/back/hlsl/conv.rs | 3 + naga/src/back/hlsl/mod.rs | 2 + naga/src/back/hlsl/writer.rs | 25 ++++++- naga/src/back/msl/mod.rs | 3 + naga/src/back/msl/writer.rs | 19 +++++- naga/src/back/pipeline_constants.rs | 12 ++++ naga/src/back/spv/block.rs | 16 +++++ naga/src/back/spv/helpers.rs | 1 + naga/src/back/spv/writer.rs | 51 ++++++++++++++ naga/src/back/wgsl/writer.rs | 32 ++++++++- naga/src/compact/statements.rs | 24 +++++++ naga/src/front/glsl/functions.rs | 2 + naga/src/front/spv/function.rs | 2 + naga/src/front/spv/mod.rs | 1 + naga/src/front/wgsl/lower/mod.rs | 2 + .../wgsl/parse/directive/enable_extension.rs | 25 +++++-- naga/src/lib.rs | 67 +++++++++++++++++-- naga/src/proc/mod.rs | 2 + naga/src/proc/terminator.rs | 12 +++- naga/src/valid/analyzer.rs | 26 ++++++- naga/src/valid/function.rs | 28 ++++++++ naga/src/valid/handles.rs | 16 +++++ naga/src/valid/interface.rs | 56 +++++++++++++--- naga/src/valid/mod.rs | 2 + naga/src/valid/type.rs | 9 ++- naga/tests/snapshots.rs | 2 + wgpu-core/src/validation.rs | 2 + wgpu-hal/src/auxil/mod.rs | 2 + wgpu-hal/src/gles/device.rs | 2 + wgpu-hal/src/vulkan/device.rs | 10 ++- wgpu-types/src/lib.rs | 4 ++ 33 files changed, 474 insertions(+), 39 deletions(-) diff --git a/naga/src/back/dot/mod.rs b/naga/src/back/dot/mod.rs index e44e8d8eae6..4661105be13 100644 --- a/naga/src/back/dot/mod.rs +++ b/naga/src/back/dot/mod.rs @@ -296,6 +296,21 @@ impl StatementGraph { crate::RayQueryFunction::Terminate => "RayQueryTerminate", } } + S::MeshFunction(crate::MeshFunction::EmitMeshTasks { group_size }) => { + self.dependencies.push((id, group_size[0], "group_count_x")); + self.dependencies.push((id, group_size[1], "group_count_y")); + self.dependencies.push((id, group_size[2], "group_count_z")); + "EmitMeshTasks" + } + S::MeshFunction(crate::MeshFunction::SetMeshOutputs { + vertex_count, + primitive_count, + }) => { + self.dependencies.push((id, vertex_count, "vertex_count")); + self.dependencies + .push((id, primitive_count, "primitive_count")); + "SetMeshOutputs" + } S::SubgroupBallot { result, predicate } => { if let Some(predicate) = predicate { self.dependencies.push((id, predicate, "predicate")); diff --git a/naga/src/back/glsl/mod.rs b/naga/src/back/glsl/mod.rs index b058ae5ee8f..d4d8ef60e83 100644 --- a/naga/src/back/glsl/mod.rs +++ b/naga/src/back/glsl/mod.rs @@ -112,7 +112,8 @@ impl crate::AddressSpace { | crate::AddressSpace::Uniform | crate::AddressSpace::Storage { .. } | crate::AddressSpace::Handle - | crate::AddressSpace::PushConstant => false, + | crate::AddressSpace::PushConstant + | crate::AddressSpace::TaskPayload => false, } } } @@ -442,6 +443,8 @@ impl fmt::Display for VaryingName<'_> { (ShaderStage::Vertex, true) | (ShaderStage::Fragment, false) => "vs2fs", // fragment to pipeline (ShaderStage::Fragment, true) => "fs2p", + // TODO: figure out what this is and work on it + (ShaderStage::Mesh | ShaderStage::Task, _) => unimplemented!(), }; write!(f, "_{prefix}_location{location}",) } @@ -458,6 +461,8 @@ impl ShaderStage { ShaderStage::Compute => "cs", ShaderStage::Fragment => "fs", ShaderStage::Vertex => "vs", + ShaderStage::Task => "ts", + ShaderStage::Mesh => "ms", } } } @@ -1199,6 +1204,9 @@ impl<'a, W: Write> Writer<'a, W> { crate::AddressSpace::Storage { .. } => { self.write_interface_block(handle, global)?; } + crate::AddressSpace::TaskPayload => { + self.write_interface_block(handle, global)?; + } // A global variable in the `Function` address space is a // contradiction in terms. crate::AddressSpace::Function => unreachable!(), @@ -1507,9 +1515,12 @@ impl<'a, W: Write> Writer<'a, W> { // We ignore all interpolation and auxiliary modifiers that aren't used in fragment // shaders' input globals or vertex shaders' output globals. let emit_interpolation_and_auxiliary = match self.entry_point.stage { + // TODO: make this more nuanced for mesh and fragment shaders which can have per primitive and per vertex data ShaderStage::Vertex => output, ShaderStage::Fragment => !output, ShaderStage::Compute => false, + ShaderStage::Task => false, + ShaderStage::Mesh => unimplemented!(), }; // Write the I/O locations, if allowed @@ -2487,6 +2498,25 @@ impl<'a, W: Write> Writer<'a, W> { self.write_image_atomic(ctx, image, coordinate, array_index, fun, value)? } Statement::RayQuery { .. } => unreachable!(), + Statement::MeshFunction(crate::MeshFunction::EmitMeshTasks { group_size }) => { + write!(self.out, "{level}EmitMeshTasksEXT(")?; + self.write_expr(group_size[0], ctx)?; + for &g in &group_size[1..] { + write!(self.out, ", ")?; + self.write_expr(g, ctx)?; + } + write!(self.out, ");")?; + } + Statement::MeshFunction(crate::MeshFunction::SetMeshOutputs { + vertex_count, + primitive_count, + }) => { + write!(self.out, "{level}SetMeshOutputsEXT(")?; + self.write_expr(vertex_count, ctx)?; + write!(self.out, ", ")?; + self.write_expr(primitive_count, ctx)?; + write!(self.out, ");")?; + } Statement::SubgroupBallot { result, predicate } => { write!(self.out, "{level}")?; let res_name = Baked(result).to_string(); @@ -4862,6 +4892,11 @@ const fn glsl_built_in(built_in: crate::BuiltIn, options: VaryingOptions) -> &'s Bi::SubgroupId => "gl_SubgroupID", Bi::SubgroupSize => "gl_SubgroupSize", Bi::SubgroupInvocationId => "gl_SubgroupInvocationID", + // mesh + // TODO: figure out how to map these to glsl things as glsl treats them as arrays + Bi::CullPrimitive | Bi::PointIndices | Bi::LineIndices | Bi::TriangleIndices => { + unimplemented!() + } } } @@ -4877,6 +4912,7 @@ const fn glsl_storage_qualifier(space: crate::AddressSpace) -> Option<&'static s As::Handle => Some("uniform"), As::WorkGroup => Some("shared"), As::PushConstant => Some("uniform"), + As::TaskPayload => Some("taskPayloadSharedEXT"), } } diff --git a/naga/src/back/hlsl/conv.rs b/naga/src/back/hlsl/conv.rs index 9573fce2a8d..83e42a8a319 100644 --- a/naga/src/back/hlsl/conv.rs +++ b/naga/src/back/hlsl/conv.rs @@ -183,6 +183,9 @@ impl crate::BuiltIn { Self::PointSize | Self::ViewIndex | Self::PointCoord | Self::DrawID => { return Err(Error::Custom(format!("Unsupported builtin {self:?}"))) } + Self::CullPrimitive => "SV_CullPrimitive", + // TODO: make this work + Self::PointIndices | Self::LineIndices | Self::TriangleIndices => unimplemented!(), }) } } diff --git a/naga/src/back/hlsl/mod.rs b/naga/src/back/hlsl/mod.rs index dcce866baca..bf81e020754 100644 --- a/naga/src/back/hlsl/mod.rs +++ b/naga/src/back/hlsl/mod.rs @@ -164,6 +164,8 @@ impl crate::ShaderStage { Self::Vertex => "vs", Self::Fragment => "ps", Self::Compute => "cs", + Self::Task => "ts", + Self::Mesh => "ms", } } } diff --git a/naga/src/back/hlsl/writer.rs b/naga/src/back/hlsl/writer.rs index b5df1357665..24b2a54de05 100644 --- a/naga/src/back/hlsl/writer.rs +++ b/naga/src/back/hlsl/writer.rs @@ -822,7 +822,8 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { self.write_type(module, global.ty)?; "" } - crate::AddressSpace::WorkGroup => { + // TODO: verify this is correct + crate::AddressSpace::WorkGroup | crate::AddressSpace::TaskPayload => { write!(self.out, "groupshared ")?; self.write_type(module, global.ty)?; "" @@ -2297,6 +2298,25 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { writeln!(self.out, ".Abort();")?; } }, + Statement::MeshFunction(crate::MeshFunction::EmitMeshTasks { group_size }) => { + write!(self.out, "{level}DispatchMesh(")?; + self.write_expr(module, group_size[0], func_ctx)?; + for &g in &group_size[1..] { + write!(self.out, ", ")?; + self.write_expr(module, g, func_ctx)?; + } + write!(self.out, ");")?; + } + Statement::MeshFunction(crate::MeshFunction::SetMeshOutputs { + vertex_count, + primitive_count, + }) => { + write!(self.out, "{level}SetMeshOutputCounts(")?; + self.write_expr(module, vertex_count, func_ctx)?; + write!(self.out, ", ")?; + self.write_expr(module, primitive_count, func_ctx)?; + write!(self.out, ");")?; + } Statement::SubgroupBallot { result, predicate } => { write!(self.out, "{level}")?; let name = Baked(result).to_string(); @@ -2679,7 +2699,8 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { crate::AddressSpace::Function | crate::AddressSpace::Private | crate::AddressSpace::WorkGroup - | crate::AddressSpace::PushConstant, + | crate::AddressSpace::PushConstant + | crate::AddressSpace::TaskPayload, ) | None => true, Some(crate::AddressSpace::Uniform) => false, // TODO: needs checks for dynamic uniform buffers, see https://github.com/gfx-rs/wgpu/issues/4483 diff --git a/naga/src/back/msl/mod.rs b/naga/src/back/msl/mod.rs index 28e99acc5fd..15845a517a8 100644 --- a/naga/src/back/msl/mod.rs +++ b/naga/src/back/msl/mod.rs @@ -598,6 +598,9 @@ impl ResolvedBinding { Bi::CullDistance | Bi::ViewIndex | Bi::DrawID => { return Err(Error::UnsupportedBuiltIn(built_in)) } + Bi::CullPrimitive => "primitive_culled", + // TODO: figure out how to make this written as a function call + Bi::PointIndices | Bi::LineIndices | Bi::TriangleIndices => unimplemented!(), }; write!(out, "{name}")?; } diff --git a/naga/src/back/msl/writer.rs b/naga/src/back/msl/writer.rs index 4589d39892a..4703a242677 100644 --- a/naga/src/back/msl/writer.rs +++ b/naga/src/back/msl/writer.rs @@ -493,7 +493,8 @@ impl crate::AddressSpace { | Self::Private | Self::WorkGroup | Self::PushConstant - | Self::Handle => true, + | Self::Handle + | Self::TaskPayload => true, Self::Function => false, } } @@ -506,6 +507,8 @@ impl crate::AddressSpace { // may end up with "const" even if the binding is read-write, // and that should be OK. Self::Storage { .. } => true, + // TODO: investigate this more + Self::TaskPayload => true, // These should always be read-write. Self::Private | Self::WorkGroup => false, // These translate to `constant` address space, no need for qualifiers. @@ -522,6 +525,7 @@ impl crate::AddressSpace { Self::Storage { .. } => Some("device"), Self::Private | Self::Function => Some("thread"), Self::WorkGroup => Some("threadgroup"), + Self::TaskPayload => Some("object_data"), } } } @@ -3399,6 +3403,13 @@ impl Writer { } } } + // TODO: write emitters for these + crate::Statement::MeshFunction(crate::MeshFunction::EmitMeshTasks { .. }) => { + unimplemented!() + } + crate::Statement::MeshFunction(crate::MeshFunction::SetMeshOutputs { .. }) => { + unimplemented!() + } crate::Statement::SubgroupBallot { result, predicate } => { write!(self.out, "{level}")?; let name = self.namer.call(""); @@ -5153,6 +5164,8 @@ template LocationMode::Uniform, false, ), + // TODO: figure out what the location mode stuff means and stuff + crate::ShaderStage::Task | crate::ShaderStage::Mesh => unimplemented!(), }; // Should this entry point be modified to do vertex pulling? @@ -5216,6 +5229,10 @@ template break; } } + crate::AddressSpace::TaskPayload => { + // TODO: figure this out + unimplemented!() + } crate::AddressSpace::Function | crate::AddressSpace::Private | crate::AddressSpace::WorkGroup => {} diff --git a/naga/src/back/pipeline_constants.rs b/naga/src/back/pipeline_constants.rs index 420b5acf4fb..dbd05244c50 100644 --- a/naga/src/back/pipeline_constants.rs +++ b/naga/src/back/pipeline_constants.rs @@ -823,6 +823,18 @@ fn adjust_stmt(new_pos: &HandleVec>, stmt: &mut S crate::RayQueryFunction::Terminate => {} } } + Statement::MeshFunction(crate::MeshFunction::EmitMeshTasks { ref mut group_size }) => { + for g in group_size { + adjust(g); + } + } + Statement::MeshFunction(crate::MeshFunction::SetMeshOutputs { + ref mut vertex_count, + ref mut primitive_count, + }) => { + adjust(vertex_count); + adjust(primitive_count); + } Statement::Break | Statement::Continue | Statement::Kill | Statement::Barrier(_) => {} } } diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 1e87e2e6d1e..c15f9265fbd 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -2997,6 +2997,22 @@ impl BlockContext<'_> { Statement::RayQuery { query, ref fun } => { self.write_ray_query_function(query, fun, &mut block); } + Statement::MeshFunction(crate::MeshFunction::EmitMeshTasks { group_size }) => { + let mut ins = Instruction::new(spirv::Op::EmitMeshTasksEXT); + for g in group_size { + ins.add_operand(self.cached[g]); + } + // TODO: make this also add the payload as an optional parameter + block.body.push(ins); + } + Statement::MeshFunction(crate::MeshFunction::SetMeshOutputs { + vertex_count, + primitive_count, + }) => { + let mut ins = Instruction::new(spirv::Op::SetMeshOutputsEXT); + ins.operands = vec![self.cached[vertex_count], self.cached[primitive_count]]; + block.body.push(ins); + } Statement::SubgroupBallot { result, ref predicate, diff --git a/naga/src/back/spv/helpers.rs b/naga/src/back/spv/helpers.rs index 63144abc028..774d8407741 100644 --- a/naga/src/back/spv/helpers.rs +++ b/naga/src/back/spv/helpers.rs @@ -48,6 +48,7 @@ pub(super) const fn map_storage_class(space: crate::AddressSpace) -> spirv::Stor crate::AddressSpace::Uniform => spirv::StorageClass::Uniform, crate::AddressSpace::WorkGroup => spirv::StorageClass::Workgroup, crate::AddressSpace::PushConstant => spirv::StorageClass::PushConstant, + crate::AddressSpace::TaskPayload => spirv::StorageClass::TaskPayloadWorkgroupEXT, } } diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 0361b5a2137..b7a9187e446 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -764,6 +764,53 @@ impl Writer { .to_words(&mut self.logical_layout.execution_modes); spirv::ExecutionModel::GLCompute } + crate::ShaderStage::Task => { + let execution_mode = spirv::ExecutionMode::LocalSize; + //self.check(execution_mode.required_capabilities())?; + Instruction::execution_mode( + function_id, + execution_mode, + &entry_point.workgroup_size, + ) + .to_words(&mut self.logical_layout.execution_modes); + spirv::ExecutionModel::TaskEXT + } + crate::ShaderStage::Mesh => { + let execution_mode = spirv::ExecutionMode::LocalSize; + //self.check(execution_mode.required_capabilities())?; + Instruction::execution_mode( + function_id, + execution_mode, + &entry_point.workgroup_size, + ) + .to_words(&mut self.logical_layout.execution_modes); + let mesh_info = entry_point.mesh_info.as_ref().unwrap(); + Instruction::execution_mode( + function_id, + match mesh_info.topology { + crate::MeshOutputTopology::Points => spirv::ExecutionMode::OutputPoints, + crate::MeshOutputTopology::Lines => spirv::ExecutionMode::OutputLinesEXT, + crate::MeshOutputTopology::Triangles => { + spirv::ExecutionMode::OutputTrianglesEXT + } + }, + &[], + ) + .to_words(&mut self.logical_layout.execution_modes); + Instruction::execution_mode( + function_id, + spirv::ExecutionMode::OutputVertices, + std::slice::from_ref(&mesh_info.max_vertices), + ) + .to_words(&mut self.logical_layout.execution_modes); + Instruction::execution_mode( + function_id, + spirv::ExecutionMode::OutputPrimitivesEXT, + std::slice::from_ref(&mesh_info.max_primitives), + ) + .to_words(&mut self.logical_layout.execution_modes); + spirv::ExecutionModel::MeshEXT + } }; //self.check(exec_model.required_capabilities())?; @@ -1610,6 +1657,10 @@ impl Writer { )?; BuiltIn::SubgroupLocalInvocationId } + Bi::CullPrimitive => BuiltIn::CullPrimitiveEXT, + Bi::PointIndices => BuiltIn::PrimitivePointIndicesEXT, + Bi::LineIndices => BuiltIn::PrimitiveLineIndicesEXT, + Bi::TriangleIndices => BuiltIn::PrimitiveTriangleIndicesEXT, }; self.decorate(id, Decoration::BuiltIn, &[built_in as u32]); diff --git a/naga/src/back/wgsl/writer.rs b/naga/src/back/wgsl/writer.rs index a7cd8f95c9b..17cd29c9146 100644 --- a/naga/src/back/wgsl/writer.rs +++ b/naga/src/back/wgsl/writer.rs @@ -183,8 +183,8 @@ impl Writer { for (index, ep) in module.entry_points.iter().enumerate() { let attributes = match ep.stage { ShaderStage::Vertex | ShaderStage::Fragment => vec![Attribute::Stage(ep.stage)], - ShaderStage::Compute => vec![ - Attribute::Stage(ShaderStage::Compute), + ShaderStage::Compute | ShaderStage::Mesh | ShaderStage::Task => vec![ + Attribute::Stage(ep.stage), Attribute::WorkGroupSize(ep.workgroup_size), ], }; @@ -228,6 +228,8 @@ impl Writer { ShaderStage::Compute => "ComputeOutput", ShaderStage::Fragment => "FragmentOutput", ShaderStage::Vertex => "VertexOutput", + ShaderStage::Task => "TaskOutput", + ShaderStage::Mesh => "MeshOutput", }; write!(self.out, "{name}")?; @@ -350,6 +352,8 @@ impl Writer { ShaderStage::Vertex => "vertex", ShaderStage::Fragment => "fragment", ShaderStage::Compute => "compute", + ShaderStage::Task => "task", + ShaderStage::Mesh => "mesh", }; write!(self.out, "@{stage_str} ")?; } @@ -975,6 +979,25 @@ impl Writer { } } Statement::RayQuery { .. } => unreachable!(), + Statement::MeshFunction(crate::MeshFunction::EmitMeshTasks { group_size }) => { + write!(self.out, "{level}emitMeshTasks(")?; + self.write_expr(module, group_size[0], func_ctx)?; + for &a in &group_size[1..] { + write!(self.out, ", ")?; + self.write_expr(module, a, func_ctx)?; + } + writeln!(self.out, ");")?; + } + Statement::MeshFunction(crate::MeshFunction::SetMeshOutputs { + vertex_count, + primitive_count, + }) => { + write!(self.out, "{level}setMeshOutputs(")?; + self.write_expr(module, vertex_count, func_ctx)?; + write!(self.out, ", ")?; + self.write_expr(module, primitive_count, func_ctx)?; + writeln!(self.out, ");")?; + } Statement::SubgroupBallot { result, predicate } => { write!(self.out, "{level}")?; let res_name = Baked(result).to_string(); @@ -1999,6 +2022,10 @@ fn builtin_str(built_in: crate::BuiltIn) -> Result<&'static str, Error> { | Bi::PointCoord | Bi::WorkGroupSize | Bi::DrawID => return Err(Error::Custom(format!("Unsupported builtin {built_in:?}"))), + Bi::CullPrimitive => "cull_primitive", + Bi::PointIndices => "point_indices", + Bi::LineIndices => "line_indices", + Bi::TriangleIndices => "triangle_indices", }) } @@ -2144,6 +2171,7 @@ const fn address_space_str( As::WorkGroup => "workgroup", As::Handle => return (None, None), As::Function => "function", + As::TaskPayload => "task_payload", }), None, ) diff --git a/naga/src/compact/statements.rs b/naga/src/compact/statements.rs index 596f9d4067f..e801db661b4 100644 --- a/naga/src/compact/statements.rs +++ b/naga/src/compact/statements.rs @@ -113,6 +113,18 @@ impl FunctionTracer<'_> { self.expressions_used.insert(query); self.trace_ray_query_function(fun); } + St::MeshFunction(crate::MeshFunction::EmitMeshTasks { group_size }) => { + for g in group_size { + self.expressions_used.insert(g); + } + } + St::MeshFunction(crate::MeshFunction::SetMeshOutputs { + vertex_count, + primitive_count, + }) => { + self.expressions_used.insert(vertex_count); + self.expressions_used.insert(primitive_count); + } St::SubgroupBallot { result, predicate } => { if let Some(predicate) = predicate { self.expressions_used.insert(predicate); @@ -315,6 +327,18 @@ impl FunctionMap { adjust(query); self.adjust_ray_query_function(fun); } + St::MeshFunction(crate::MeshFunction::EmitMeshTasks { ref mut group_size }) => { + for g in group_size { + adjust(g); + } + } + St::MeshFunction(crate::MeshFunction::SetMeshOutputs { + ref mut vertex_count, + ref mut primitive_count, + }) => { + adjust(vertex_count); + adjust(primitive_count); + } St::SubgroupBallot { ref mut result, ref mut predicate, diff --git a/naga/src/front/glsl/functions.rs b/naga/src/front/glsl/functions.rs index 0d05c5433c7..1baaea44ca7 100644 --- a/naga/src/front/glsl/functions.rs +++ b/naga/src/front/glsl/functions.rs @@ -1374,6 +1374,8 @@ impl Frontend { result: ty.map(|ty| FunctionResult { ty, binding: None }), ..Default::default() }, + mesh_info: None, + task_payload: None, }); Ok(()) diff --git a/naga/src/front/spv/function.rs b/naga/src/front/spv/function.rs index b780cbe775e..0d862d6e2cf 100644 --- a/naga/src/front/spv/function.rs +++ b/naga/src/front/spv/function.rs @@ -570,6 +570,8 @@ impl> super::Frontend { workgroup_size: ep.workgroup_size, workgroup_size_overrides: None, function, + mesh_info: None, + task_payload: None, }); Ok(()) diff --git a/naga/src/front/spv/mod.rs b/naga/src/front/spv/mod.rs index b8087fc8b0f..c654d17ffcb 100644 --- a/naga/src/front/spv/mod.rs +++ b/naga/src/front/spv/mod.rs @@ -4492,6 +4492,7 @@ impl> Frontend { | S::Atomic { .. } | S::ImageAtomic { .. } | S::RayQuery { .. } + | S::MeshFunction(..) | S::SubgroupBallot { .. } | S::SubgroupCollectiveOperation { .. } | S::SubgroupGather { .. } => {} diff --git a/naga/src/front/wgsl/lower/mod.rs b/naga/src/front/wgsl/lower/mod.rs index eb6f9199304..a9aab719b19 100644 --- a/naga/src/front/wgsl/lower/mod.rs +++ b/naga/src/front/wgsl/lower/mod.rs @@ -1346,6 +1346,8 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { workgroup_size, workgroup_size_overrides, function, + mesh_info: None, + task_payload: None, }); Ok(LoweredGlobalDecl::EntryPoint) } else { diff --git a/naga/src/front/wgsl/parse/directive/enable_extension.rs b/naga/src/front/wgsl/parse/directive/enable_extension.rs index 147ec0b5e04..72198ce43e7 100644 --- a/naga/src/front/wgsl/parse/directive/enable_extension.rs +++ b/naga/src/front/wgsl/parse/directive/enable_extension.rs @@ -5,24 +5,30 @@ use crate::{front::wgsl::error::Error, Span}; /// Tracks the status of every enable-extension known to Naga. #[derive(Clone, Debug, Eq, PartialEq)] -pub struct EnableExtensions {} +pub struct EnableExtensions { + mesh_shader: bool, +} impl EnableExtensions { pub(crate) const fn empty() -> Self { - Self {} + Self { mesh_shader: false } } /// Add an enable-extension to the set requested by a module. #[allow(unreachable_code)] pub(crate) fn add(&mut self, ext: ImplementedEnableExtension) { - let _field: &mut bool = match ext {}; + let _field: &mut bool = match ext { + ImplementedEnableExtension::MeshShader => &mut self.mesh_shader, + }; *_field = true; } /// Query whether an enable-extension tracked here has been requested. #[allow(unused)] pub(crate) const fn contains(&self, ext: ImplementedEnableExtension) -> bool { - match ext {} + match ext { + ImplementedEnableExtension::MeshShader => self.mesh_shader, + } } } @@ -46,6 +52,7 @@ impl EnableExtension { const F16: &'static str = "f16"; const CLIP_DISTANCES: &'static str = "clip_distances"; const DUAL_SOURCE_BLENDING: &'static str = "dual_source_blending"; + const MESH_SHADER: &'static str = "mesh_shading"; /// Convert from a sentinel word in WGSL into its associated [`EnableExtension`], if possible. pub(crate) fn from_ident(word: &str, span: Span) -> Result> { @@ -57,6 +64,7 @@ impl EnableExtension { Self::DUAL_SOURCE_BLENDING => { Self::Unimplemented(UnimplementedEnableExtension::DualSourceBlending) } + Self::MESH_SHADER => Self::Implemented(ImplementedEnableExtension::MeshShader), _ => return Err(Error::UnknownEnableExtension(span, word)), }) } @@ -64,7 +72,9 @@ impl EnableExtension { /// Maps this [`EnableExtension`] into the sentinel word associated with it in WGSL. pub const fn to_ident(self) -> &'static str { match self { - Self::Implemented(kind) => match kind {}, + Self::Implemented(kind) => match kind { + ImplementedEnableExtension::MeshShader => Self::MESH_SHADER, + }, Self::Unimplemented(kind) => match kind { UnimplementedEnableExtension::F16 => Self::F16, UnimplementedEnableExtension::ClipDistances => Self::CLIP_DISTANCES, @@ -76,7 +86,10 @@ impl EnableExtension { /// A variant of [`EnableExtension::Implemented`]. #[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)] -pub enum ImplementedEnableExtension {} +pub enum ImplementedEnableExtension { + /// Enables the `mesh_shader` extension, native only + MeshShader, +} /// A variant of [`EnableExtension::Unimplemented`]. #[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)] diff --git a/naga/src/lib.rs b/naga/src/lib.rs index ddf78f1b686..59a12bba757 100644 --- a/naga/src/lib.rs +++ b/naga/src/lib.rs @@ -363,6 +363,17 @@ pub enum ShaderStage { Vertex, Fragment, Compute, + Task, + Mesh, +} +impl ShaderStage { + // TODO: make more things respect this + pub const fn compute_like(self) -> bool { + match self { + Self::Vertex | Self::Fragment => false, + Self::Compute | Self::Task | Self::Mesh => true, + } + } } /// Addressing space of variables. @@ -385,6 +396,8 @@ pub enum AddressSpace { Handle, /// Push constants. PushConstant, + /// Task shader to mesh shader payload + TaskPayload, } /// Built-in inputs and outputs. @@ -395,7 +408,7 @@ pub enum AddressSpace { pub enum BuiltIn { Position { invariant: bool }, ViewIndex, - // vertex + // vertex (and often mesh) BaseInstance, BaseVertex, ClipDistance, @@ -408,10 +421,10 @@ pub enum BuiltIn { FragDepth, PointCoord, FrontFacing, - PrimitiveIndex, + PrimitiveIndex, // Also for mesh output SampleIndex, SampleMask, - // compute + // compute (and task/mesh) GlobalInvocationId, LocalInvocationId, LocalInvocationIndex, @@ -423,6 +436,11 @@ pub enum BuiltIn { SubgroupId, SubgroupSize, SubgroupInvocationId, + // mesh + CullPrimitive, + PointIndices, + LineIndices, + TriangleIndices, } /// Number of bytes per scalar. @@ -1774,6 +1792,20 @@ pub enum RayQueryFunction { Terminate, } +/// A function provided by task or mesh shaders +#[derive(Clone, Debug, Copy)] +#[cfg_attr(feature = "serialize", derive(Serialize))] +#[cfg_attr(feature = "deserialize", derive(Deserialize))] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +pub enum MeshFunction { + EmitMeshTasks { + group_size: [Handle; 3], + }, + SetMeshOutputs { + vertex_count: Handle, + primitive_count: Handle, + }, +} //TODO: consider removing `Clone`. It's not valid to clone `Statement::Emit` anyway. /// Instructions which make up an executable block. @@ -1896,7 +1928,9 @@ pub enum Statement { /// [`Loop`] statement. /// /// [`Loop`]: Statement::Loop - Return { value: Option> }, + Return { + value: Option>, + }, /// Aborts the current shader execution. /// @@ -2097,6 +2131,7 @@ pub enum Statement { /// The specific operation we're performing on `query`. fun: RayQueryFunction, }, + MeshFunction(MeshFunction), /// Calculate a bitmask using a boolean from each active thread in the subgroup SubgroupBallot { /// The [`SubgroupBallotResult`] expression representing this load's result. @@ -2202,6 +2237,27 @@ pub struct Function { /// validation. pub diagnostic_filter_leaf: Option>, } +#[derive(Debug, Clone)] +#[cfg_attr(feature = "serialize", derive(Serialize))] +#[cfg_attr(feature = "deserialize", derive(Deserialize))] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +pub enum MeshOutputTopology { + Points, + Lines, + Triangles, +} +#[derive(Debug, Clone)] +#[cfg_attr(feature = "serialize", derive(Serialize))] +#[cfg_attr(feature = "deserialize", derive(Deserialize))] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +pub struct MeshStageInfo { + topology: MeshOutputTopology, + // Should this be an expression or what? Not clear + max_vertices: u32, + max_primitives: u32, + vertex_output_type: Handle, + primitive_output_type: Option>, +} /// The main function for a pipeline stage. /// @@ -2262,6 +2318,9 @@ pub struct EntryPoint { pub workgroup_size_overrides: Option<[Option>; 3]>, /// The entrance function. pub function: Function, + /// The information relating to a mesh shader + pub mesh_info: Option, + pub task_payload: Option>, } /// Return types predeclared for the frexp, modf, and atomicCompareExchangeWeak built-in functions. diff --git a/naga/src/proc/mod.rs b/naga/src/proc/mod.rs index fafac8cb300..ab22358ebd3 100644 --- a/naga/src/proc/mod.rs +++ b/naga/src/proc/mod.rs @@ -421,6 +421,8 @@ impl super::AddressSpace { crate::AddressSpace::Storage { access } => access, crate::AddressSpace::Handle => Sa::LOAD, crate::AddressSpace::PushConstant => Sa::LOAD, + // TODO: change this to reflect the different accesses by shader stage + crate::AddressSpace::TaskPayload => Sa::LOAD | Sa::STORE, } } } diff --git a/naga/src/proc/terminator.rs b/naga/src/proc/terminator.rs index 19c37294ec2..9cfcba88b4e 100644 --- a/naga/src/proc/terminator.rs +++ b/naga/src/proc/terminator.rs @@ -28,7 +28,14 @@ pub fn ensure_block_returns(block: &mut crate::Block) { } } } - Some(&mut (S::Emit(_) | S::Break | S::Continue | S::Return { .. } | S::Kill)) => (), + Some( + &mut (S::Emit(_) + | S::Break + | S::Continue + | S::Return { .. } + | S::Kill + | S::MeshFunction(crate::MeshFunction::EmitMeshTasks { .. })), + ) => (), Some( &mut (S::Loop { .. } | S::Store { .. } @@ -41,7 +48,8 @@ pub fn ensure_block_returns(block: &mut crate::Block) { | S::SubgroupBallot { .. } | S::SubgroupCollectiveOperation { .. } | S::SubgroupGather { .. } - | S::Barrier(_)), + | S::Barrier(_) + | S::MeshFunction(crate::MeshFunction::SetMeshOutputs { .. })), ) | None => block.push(S::Return { value: None }, Default::default()), } diff --git a/naga/src/valid/analyzer.rs b/naga/src/valid/analyzer.rs index 8417bf77be7..88d5ab794e6 100644 --- a/naga/src/valid/analyzer.rs +++ b/naga/src/valid/analyzer.rs @@ -629,7 +629,8 @@ impl FunctionInfo { // local data is non-uniform As::Function | As::Private => false, // workgroup memory is exclusively accessed by the group - As::WorkGroup => true, + // task payload memory is very similar to workgroup memory + As::WorkGroup | As::TaskPayload => true, // uniform data As::Uniform | As::PushConstant => true, // storage data is only uniform when read-only @@ -1090,6 +1091,29 @@ impl FunctionInfo { } FunctionUniformity::new() } + S::MeshFunction(func) => match func { + crate::MeshFunction::EmitMeshTasks { group_size } => { + for g in group_size { + let _ = self.add_ref(g); + } + // TODO: reexamine this + FunctionUniformity { + result: Uniformity { + non_uniform_result: None, + requirements: UniformityRequirements::WORK_GROUP_BARRIER, + }, + exit: ExitFlags::MAY_KILL, + } + } + crate::MeshFunction::SetMeshOutputs { + vertex_count, + primitive_count, + } => { + let _ = self.add_ref(vertex_count); + let _ = self.add_ref(primitive_count); + FunctionUniformity::new() + } + }, S::SubgroupBallot { result: _, predicate, diff --git a/naga/src/valid/function.rs b/naga/src/valid/function.rs index a910be992cf..f3e91aa2db0 100644 --- a/naga/src/valid/function.rs +++ b/naga/src/valid/function.rs @@ -198,6 +198,8 @@ pub enum FunctionError { EmitResult(Handle), #[error("Expression not visited by the appropriate statement")] UnvisitedExpression(Handle), + #[error("U32 {0:?} is not a matching expression")] + InvalidMeshFunctionType(Handle), } bitflags::bitflags! { @@ -1463,6 +1465,32 @@ impl super::Validator { crate::RayQueryFunction::Terminate => {} } } + S::MeshFunction(func) => { + // TODO: ensure this is the last statement executed + let ensure_correct = + |e: Handle| -> Result<(), WithSpan> { + let t = context.resolve_type(e, &self.valid_expression_set)?; + match *t { + Ti::Scalar(crate::Scalar::U32) => Ok(()), + _ => Err(FunctionError::InvalidMeshFunctionType(e) + .with_span_static(span, "invalid u32")), + } + }; + match func { + crate::MeshFunction::EmitMeshTasks { group_size } => { + for g in group_size { + ensure_correct(g)?; + } + } + crate::MeshFunction::SetMeshOutputs { + vertex_count, + primitive_count, + } => { + ensure_correct(vertex_count)?; + ensure_correct(primitive_count)?; + } + } + } S::SubgroupBallot { result, predicate } => { stages &= self.subgroup_stages; if !self.capabilities.contains(super::Capabilities::SUBGROUP) { diff --git a/naga/src/valid/handles.rs b/naga/src/valid/handles.rs index 260d442c791..068a599e13d 100644 --- a/naga/src/valid/handles.rs +++ b/naga/src/valid/handles.rs @@ -711,6 +711,22 @@ impl super::Validator { } Ok(()) } + crate::Statement::MeshFunction(func) => match func { + crate::MeshFunction::EmitMeshTasks { group_size } => { + for g in group_size { + validate_expr(g)?; + } + Ok(()) + } + crate::MeshFunction::SetMeshOutputs { + vertex_count, + primitive_count, + } => { + validate_expr(vertex_count)?; + validate_expr(primitive_count)?; + Ok(()) + } + }, crate::Statement::SubgroupBallot { result, predicate } => { validate_expr_opt(predicate)?; validate_expr(result)?; diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index 08bdda03293..648ce7b4a08 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -228,9 +228,9 @@ impl VaryingContext<'_> { ), Bi::Position { .. } => ( match self.stage { - St::Vertex => self.output, + St::Vertex | St::Mesh => self.output, St::Fragment => !self.output, - St::Compute => false, + St::Compute | St::Task => false, }, *ty_inner == Ti::Vector { @@ -240,8 +240,8 @@ impl VaryingContext<'_> { ), Bi::ViewIndex => ( match self.stage { - St::Vertex | St::Fragment => !self.output, - St::Compute => false, + St::Vertex | St::Fragment | St::Mesh => !self.output, + St::Compute | St::Task => false, }, *ty_inner == Ti::Scalar(crate::Scalar::I32), ), @@ -266,7 +266,7 @@ impl VaryingContext<'_> { *ty_inner == Ti::Scalar(crate::Scalar::U32), ), Bi::LocalInvocationIndex => ( - self.stage == St::Compute && !self.output, + self.stage.compute_like() && !self.output, *ty_inner == Ti::Scalar(crate::Scalar::U32), ), Bi::GlobalInvocationId @@ -274,7 +274,7 @@ impl VaryingContext<'_> { | Bi::WorkGroupId | Bi::WorkGroupSize | Bi::NumWorkGroups => ( - self.stage == St::Compute && !self.output, + self.stage.compute_like() && !self.output, *ty_inner == Ti::Vector { size: Vs::Tri, @@ -282,16 +282,40 @@ impl VaryingContext<'_> { }, ), Bi::NumSubgroups | Bi::SubgroupId => ( - self.stage == St::Compute && !self.output, + self.stage.compute_like() && !self.output, *ty_inner == Ti::Scalar(crate::Scalar::U32), ), Bi::SubgroupSize | Bi::SubgroupInvocationId => ( match self.stage { - St::Compute | St::Fragment => !self.output, + St::Compute | St::Fragment | St::Task | St::Mesh => !self.output, St::Vertex => false, }, *ty_inner == Ti::Scalar(crate::Scalar::U32), ), + Bi::CullPrimitive => ( + self.stage == St::Mesh && self.output, + *ty_inner == Ti::Scalar(crate::Scalar::BOOL), + ), + Bi::PointIndices => ( + self.stage == St::Mesh && self.output, + *ty_inner == Ti::Scalar(crate::Scalar::U32), + ), + Bi::LineIndices => ( + self.stage == St::Mesh && self.output, + *ty_inner + == Ti::Vector { + size: Vs::Bi, + scalar: crate::Scalar::U32, + }, + ), + Bi::TriangleIndices => ( + self.stage == St::Mesh && self.output, + *ty_inner + == Ti::Vector { + size: Vs::Tri, + scalar: crate::Scalar::U32, + }, + ), }; if !visible { @@ -376,10 +400,12 @@ impl VaryingContext<'_> { } } + // TODO: update this to reflect the fact that per-primitive outputs aren't interpolated for fragment and mesh stages let needs_interpolation = match self.stage { crate::ShaderStage::Vertex => self.output, crate::ShaderStage::Fragment => !self.output, - crate::ShaderStage::Compute => false, + crate::ShaderStage::Compute | crate::ShaderStage::Task => false, + crate::ShaderStage::Mesh => self.output, }; // It doesn't make sense to specify a sampling when `interpolation` is `Flat`, but @@ -562,7 +588,10 @@ impl super::Validator { TypeFlags::CONSTRUCTIBLE | TypeFlags::CREATION_RESOLVED, false, ), - crate::AddressSpace::WorkGroup => (TypeFlags::DATA | TypeFlags::SIZED, false), + // TODO: investigate how TaskPayload compares + crate::AddressSpace::WorkGroup | crate::AddressSpace::TaskPayload => { + (TypeFlags::DATA | TypeFlags::SIZED, false) + } crate::AddressSpace::PushConstant => { if !self.capabilities.contains(Capabilities::PUSH_CONSTANT) { return Err(GlobalVariableError::UnsupportedCapability( @@ -658,6 +687,8 @@ impl super::Validator { crate::ShaderStage::Vertex => ShaderStages::VERTEX, crate::ShaderStage::Fragment => ShaderStages::FRAGMENT, crate::ShaderStage::Compute => ShaderStages::COMPUTE, + crate::ShaderStage::Mesh => ShaderStages::MESH, + crate::ShaderStage::Task => ShaderStages::TASK, }; if !info.available_stages.contains(stage_bit) { @@ -761,7 +792,10 @@ impl super::Validator { } => storage_usage(access), _ => GlobalUse::READ | GlobalUse::QUERY, }, - crate::AddressSpace::Private | crate::AddressSpace::WorkGroup => { + // TODO: update this to reflect the nuance around taskpayload(writable in task stage, readable in mesh stage) + crate::AddressSpace::Private + | crate::AddressSpace::WorkGroup + | crate::AddressSpace::TaskPayload => { GlobalUse::READ | GlobalUse::WRITE | GlobalUse::QUERY } crate::AddressSpace::PushConstant => GlobalUse::READ, diff --git a/naga/src/valid/mod.rs b/naga/src/valid/mod.rs index 906d4493622..0311fb8fb59 100644 --- a/naga/src/valid/mod.rs +++ b/naga/src/valid/mod.rs @@ -225,6 +225,8 @@ bitflags::bitflags! { const VERTEX = 0x1; const FRAGMENT = 0x2; const COMPUTE = 0x4; + const MESH = 0x8; + const TASK = 0x10; } } diff --git a/naga/src/valid/type.rs b/naga/src/valid/type.rs index 8c6825b842e..fa7a32f962a 100644 --- a/naga/src/valid/type.rs +++ b/naga/src/valid/type.rs @@ -208,9 +208,12 @@ const fn ptr_space_argument_flag(space: crate::AddressSpace) -> TypeFlags { use crate::AddressSpace as As; match space { As::Function | As::Private => TypeFlags::ARGUMENT, - As::Uniform | As::Storage { .. } | As::Handle | As::PushConstant | As::WorkGroup => { - TypeFlags::empty() - } + As::Uniform + | As::Storage { .. } + | As::Handle + | As::PushConstant + | As::WorkGroup + | As::TaskPayload => TypeFlags::empty(), } } diff --git a/naga/tests/snapshots.rs b/naga/tests/snapshots.rs index 691878959d5..22742989a99 100644 --- a/naga/tests/snapshots.rs +++ b/naga/tests/snapshots.rs @@ -637,6 +637,8 @@ fn write_output_hlsl( naga::ShaderStage::Vertex => &mut config.vertex, naga::ShaderStage::Fragment => &mut config.fragment, naga::ShaderStage::Compute => &mut config.compute, + // TODO: add these tests + naga::ShaderStage::Task | naga::ShaderStage::Mesh => todo!(), } .push(hlsl_snapshots::ConfigItem { entry_point: name.clone(), diff --git a/wgpu-core/src/validation.rs b/wgpu-core/src/validation.rs index 17c42ecf4e2..71e0490e7e9 100644 --- a/wgpu-core/src/validation.rs +++ b/wgpu-core/src/validation.rs @@ -1226,6 +1226,8 @@ impl Interface { ) } naga::ShaderStage::Compute => (false, 0), + // TODO: add validation for these + naga::ShaderStage::Task | naga::ShaderStage::Mesh => todo!(), }; if compatible { Ok(num_components) diff --git a/wgpu-hal/src/auxil/mod.rs b/wgpu-hal/src/auxil/mod.rs index 81358c596fd..9f73ebb0adf 100644 --- a/wgpu-hal/src/auxil/mod.rs +++ b/wgpu-hal/src/auxil/mod.rs @@ -51,6 +51,8 @@ pub fn map_naga_stage(stage: naga::ShaderStage) -> wgt::ShaderStages { naga::ShaderStage::Vertex => wgt::ShaderStages::VERTEX, naga::ShaderStage::Fragment => wgt::ShaderStages::FRAGMENT, naga::ShaderStage::Compute => wgt::ShaderStages::COMPUTE, + naga::ShaderStage::Task => wgt::ShaderStages::TASK, + naga::ShaderStage::Mesh => wgt::ShaderStages::MESH, } } diff --git a/wgpu-hal/src/gles/device.rs b/wgpu-hal/src/gles/device.rs index 8e5fb76cc05..9a40dd8b0f0 100644 --- a/wgpu-hal/src/gles/device.rs +++ b/wgpu-hal/src/gles/device.rs @@ -99,6 +99,7 @@ impl CompilationContext<'_> { unsafe { gl.bind_frag_data_location(program, location.location, &name) } } naga::ShaderStage::Compute => {} + naga::ShaderStage::Task | naga::ShaderStage::Mesh => unreachable!(), } } @@ -170,6 +171,7 @@ impl super::Device { naga::ShaderStage::Vertex => glow::VERTEX_SHADER, naga::ShaderStage::Fragment => glow::FRAGMENT_SHADER, naga::ShaderStage::Compute => glow::COMPUTE_SHADER, + naga::ShaderStage::Task | naga::ShaderStage::Mesh => unreachable!(), }; let raw = unsafe { gl.create_shader(target) }.unwrap(); diff --git a/wgpu-hal/src/vulkan/device.rs b/wgpu-hal/src/vulkan/device.rs index 39275e31336..22c10053f27 100644 --- a/wgpu-hal/src/vulkan/device.rs +++ b/wgpu-hal/src/vulkan/device.rs @@ -2135,12 +2135,11 @@ impl crate::Device for super::Device { let compiled_ts = match desc.task_stage { Some(ref stage) => { // TODO: add proper naga stages - let mut compiled = self.compile_stage( + let compiled = self.compile_stage( stage, - naga::ShaderStage::Compute, + naga::ShaderStage::Task, &desc.layout.binding_arrays, )?; - compiled.create_info.stage = vk::ShaderStageFlags::TASK_EXT; stages.push(compiled.create_info); Some(compiled) } @@ -2148,12 +2147,11 @@ impl crate::Device for super::Device { }; // TODO: add proper naga stages - let mut compiled_ms = self.compile_stage( + let compiled_ms = self.compile_stage( &desc.mesh_stage, - naga::ShaderStage::Compute, + naga::ShaderStage::Mesh, &desc.layout.binding_arrays, )?; - compiled_ms.create_info.stage = vk::ShaderStageFlags::MESH_EXT; stages.push(compiled_ms.create_info); let compiled_fs = match desc.fragment_stage { Some(ref stage) => { diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 41688c352e2..f8f0ccdb39f 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -1919,6 +1919,10 @@ bitflags::bitflags! { const COMPUTE = 1 << 2; /// Binding is visible from the vertex and fragment shaders of a render pipeline. const VERTEX_FRAGMENT = Self::VERTEX.bits() | Self::FRAGMENT.bits(); + /// Binding is visible from the task shader of a mesh shader pipeline + const TASK = 1 << 3; + /// Binding is visible from the mesh shader of a mesh shader pipeline + const MESH = 1 << 4; } } From 441e64fb853c2eafa4aeeb1a75db3cba84af4787 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Fri, 17 Jan 2025 22:49:48 -0600 Subject: [PATCH 06/84] Fixed minor issue --- wgpu-hal/src/vulkan/conv.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wgpu-hal/src/vulkan/conv.rs b/wgpu-hal/src/vulkan/conv.rs index e72d28d72ab..074ca202012 100644 --- a/wgpu-hal/src/vulkan/conv.rs +++ b/wgpu-hal/src/vulkan/conv.rs @@ -747,6 +747,12 @@ pub fn map_shader_stage(stage: wgt::ShaderStages) -> vk::ShaderStageFlags { if stage.contains(wgt::ShaderStages::COMPUTE) { flags |= vk::ShaderStageFlags::COMPUTE; } + if stage.contains(wgt::ShaderStages::TASK) { + flags |= vk::ShaderStageFlags::TASK_EXT; + } + if stage.contains(wgt::ShaderStages::MESH) { + flags |= vk::ShaderStageFlags::MESH_EXT; + } flags } From 5a66eab5b85b46ac3c9730886be299c56dcb6033 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 8 Feb 2025 18:17:55 -0600 Subject: [PATCH 07/84] Fixed silly documentation mistake --- wgpu-types/src/features.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wgpu-types/src/features.rs b/wgpu-types/src/features.rs index e6c146a3fe2..d039e276402 100644 --- a/wgpu-types/src/features.rs +++ b/wgpu-types/src/features.rs @@ -1124,10 +1124,9 @@ bitflags_array! { /// Enables mesh shaders and task shaders in mesh shader pipelines. /// /// Supported platforms: - /// - Vulkan (with VK_EXT_mesh_shader) + /// - Vulkan (with [VK_EXT_mesh_shader](https://registry.khronos.org/vulkan/specs/latest/man/html/VK_EXT_mesh_shader.html)) /// /// This is a native only feature. - /// [VK_EXT_mesh_shader]: https://registry.khronos.org/vulkan/specs/latest/man/html/VK_EXT_mesh_shader.html const MESH_SHADER = 1 << 46; } From a9d6ae305c76305aebe0e9490a557e063e2ef058 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sun, 9 Feb 2025 10:47:45 -0600 Subject: [PATCH 08/84] Hopefully fixed some issues in CI --- naga/src/lib.rs | 1 + wgpu-hal/src/metal/mod.rs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/naga/src/lib.rs b/naga/src/lib.rs index 409193c1632..624e0680957 100644 --- a/naga/src/lib.rs +++ b/naga/src/lib.rs @@ -2268,6 +2268,7 @@ pub enum MeshOutputTopology { #[cfg_attr(feature = "serialize", derive(Serialize))] #[cfg_attr(feature = "deserialize", derive(Deserialize))] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[allow(dead_code)] pub struct MeshStageInfo { topology: MeshOutputTopology, // Should this be an expression or what? Not clear diff --git a/wgpu-hal/src/metal/mod.rs b/wgpu-hal/src/metal/mod.rs index 8a3ff41bbeb..895c678e22f 100644 --- a/wgpu-hal/src/metal/mod.rs +++ b/wgpu-hal/src/metal/mod.rs @@ -586,6 +586,9 @@ struct MultiStageData { vs: T, fs: T, cs: T, + // TODO: work on this for metal + /*ts: T, + ms: T,*/ } const NAGA_STAGES: MultiStageData = MultiStageData { @@ -601,6 +604,7 @@ impl ops::Index for MultiStageData { naga::ShaderStage::Vertex => &self.vs, naga::ShaderStage::Fragment => &self.fs, naga::ShaderStage::Compute => &self.cs, + naga::ShaderStage::Task | naga::ShaderStage::Mesh => unreachable!(), } } } From a6b80190f7ba77e03025b62a0291937d93f3f3c1 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sun, 9 Feb 2025 13:46:25 -0600 Subject: [PATCH 09/84] Automatic changes caused by tests --- naga/tests/out/analysis/access.info.ron | 36 +++++++++---------- naga/tests/out/analysis/collatz.info.ron | 4 +-- naga/tests/out/analysis/overrides.info.ron | 2 +- naga/tests/out/analysis/shadow.info.ron | 6 ++-- .../out/analysis/storage-textures.info.ron | 4 +-- naga/tests/out/ir/access.compact.ron | 8 +++++ naga/tests/out/ir/access.ron | 8 +++++ naga/tests/out/ir/collatz.compact.ron | 2 ++ naga/tests/out/ir/collatz.ron | 2 ++ naga/tests/out/ir/fetch_depth.compact.ron | 2 ++ naga/tests/out/ir/fetch_depth.ron | 2 ++ naga/tests/out/ir/index-by-value.compact.ron | 2 ++ naga/tests/out/ir/index-by-value.ron | 2 ++ naga/tests/out/ir/must-use.compact.ron | 2 ++ naga/tests/out/ir/must-use.ron | 2 ++ ...ides-atomicCompareExchangeWeak.compact.ron | 2 ++ .../overrides-atomicCompareExchangeWeak.ron | 2 ++ .../out/ir/overrides-ray-query.compact.ron | 2 ++ naga/tests/out/ir/overrides-ray-query.ron | 2 ++ naga/tests/out/ir/overrides.compact.ron | 2 ++ naga/tests/out/ir/overrides.ron | 2 ++ naga/tests/out/ir/shadow.compact.ron | 2 ++ naga/tests/out/ir/shadow.ron | 2 ++ naga/tests/out/ir/spec-constants.compact.ron | 2 ++ naga/tests/out/ir/spec-constants.ron | 2 ++ .../tests/out/ir/storage-textures.compact.ron | 4 +++ naga/tests/out/ir/storage-textures.ron | 4 +++ 27 files changed, 86 insertions(+), 26 deletions(-) diff --git a/naga/tests/out/analysis/access.info.ron b/naga/tests/out/analysis/access.info.ron index c8a31bad2aa..7574589bbcf 100644 --- a/naga/tests/out/analysis/access.info.ron +++ b/naga/tests/out/analysis/access.info.ron @@ -42,7 +42,7 @@ functions: [ ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: None, requirements: (""), @@ -1200,7 +1200,7 @@ ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: None, requirements: (""), @@ -2526,7 +2526,7 @@ ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: Some(0), requirements: (""), @@ -2566,7 +2566,7 @@ ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: Some(0), requirements: (""), @@ -2615,7 +2615,7 @@ ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: None, requirements: (""), @@ -2658,7 +2658,7 @@ ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: None, requirements: (""), @@ -2752,7 +2752,7 @@ ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: Some(0), requirements: (""), @@ -2804,7 +2804,7 @@ ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: None, requirements: (""), @@ -2859,7 +2859,7 @@ ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: Some(0), requirements: (""), @@ -2911,7 +2911,7 @@ ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: None, requirements: (""), @@ -2966,7 +2966,7 @@ ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: Some(2), requirements: (""), @@ -3039,7 +3039,7 @@ ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: Some(2), requirements: (""), @@ -3115,7 +3115,7 @@ ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: None, requirements: (""), @@ -3215,7 +3215,7 @@ ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: Some(1), requirements: (""), @@ -3413,7 +3413,7 @@ entry_points: [ ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: Some(0), requirements: (""), @@ -4087,7 +4087,7 @@ ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: None, requirements: (""), @@ -4539,7 +4539,7 @@ ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: None, requirements: (""), @@ -4660,7 +4660,7 @@ ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: Some(0), requirements: (""), diff --git a/naga/tests/out/analysis/collatz.info.ron b/naga/tests/out/analysis/collatz.info.ron index 7ec5799d758..219e016f8d7 100644 --- a/naga/tests/out/analysis/collatz.info.ron +++ b/naga/tests/out/analysis/collatz.info.ron @@ -8,7 +8,7 @@ functions: [ ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: Some(3), requirements: (""), @@ -280,7 +280,7 @@ entry_points: [ ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: Some(3), requirements: (""), diff --git a/naga/tests/out/analysis/overrides.info.ron b/naga/tests/out/analysis/overrides.info.ron index fcc8a9cf1ba..ba6200e3b1c 100644 --- a/naga/tests/out/analysis/overrides.info.ron +++ b/naga/tests/out/analysis/overrides.info.ron @@ -8,7 +8,7 @@ entry_points: [ ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: None, requirements: (""), diff --git a/naga/tests/out/analysis/shadow.info.ron b/naga/tests/out/analysis/shadow.info.ron index 3d6841fdd4c..1494646f035 100644 --- a/naga/tests/out/analysis/shadow.info.ron +++ b/naga/tests/out/analysis/shadow.info.ron @@ -18,7 +18,7 @@ functions: [ ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: Some(0), requirements: (""), @@ -416,7 +416,7 @@ ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: Some(0), requirements: (""), @@ -1578,7 +1578,7 @@ entry_points: [ ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: Some(0), requirements: (""), diff --git a/naga/tests/out/analysis/storage-textures.info.ron b/naga/tests/out/analysis/storage-textures.info.ron index fbbf7206c33..8bb298a6450 100644 --- a/naga/tests/out/analysis/storage-textures.info.ron +++ b/naga/tests/out/analysis/storage-textures.info.ron @@ -11,7 +11,7 @@ entry_points: [ ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: None, requirements: (""), @@ -187,7 +187,7 @@ ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: None, requirements: (""), diff --git a/naga/tests/out/ir/access.compact.ron b/naga/tests/out/ir/access.compact.ron index 53ba1a3c9b4..0806211e63f 100644 --- a/naga/tests/out/ir/access.compact.ron +++ b/naga/tests/out/ir/access.compact.ron @@ -2509,6 +2509,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ( name: "foo_frag", @@ -2702,6 +2704,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ( name: "assign_through_ptr", @@ -2785,6 +2789,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ( name: "assign_to_ptr_components", @@ -2850,6 +2856,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/access.ron b/naga/tests/out/ir/access.ron index 53ba1a3c9b4..0806211e63f 100644 --- a/naga/tests/out/ir/access.ron +++ b/naga/tests/out/ir/access.ron @@ -2509,6 +2509,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ( name: "foo_frag", @@ -2702,6 +2704,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ( name: "assign_through_ptr", @@ -2785,6 +2789,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ( name: "assign_to_ptr_components", @@ -2850,6 +2856,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/collatz.compact.ron b/naga/tests/out/ir/collatz.compact.ron index 6a7aebe5442..d0a29652470 100644 --- a/naga/tests/out/ir/collatz.compact.ron +++ b/naga/tests/out/ir/collatz.compact.ron @@ -331,6 +331,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/collatz.ron b/naga/tests/out/ir/collatz.ron index 6a7aebe5442..d0a29652470 100644 --- a/naga/tests/out/ir/collatz.ron +++ b/naga/tests/out/ir/collatz.ron @@ -331,6 +331,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/fetch_depth.compact.ron b/naga/tests/out/ir/fetch_depth.compact.ron index f10ccb94f7f..a176a3edd1e 100644 --- a/naga/tests/out/ir/fetch_depth.compact.ron +++ b/naga/tests/out/ir/fetch_depth.compact.ron @@ -193,6 +193,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/fetch_depth.ron b/naga/tests/out/ir/fetch_depth.ron index d25e046d57a..eaff8251297 100644 --- a/naga/tests/out/ir/fetch_depth.ron +++ b/naga/tests/out/ir/fetch_depth.ron @@ -263,6 +263,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/index-by-value.compact.ron b/naga/tests/out/ir/index-by-value.compact.ron index 93a98214262..d625cfe2391 100644 --- a/naga/tests/out/ir/index-by-value.compact.ron +++ b/naga/tests/out/ir/index-by-value.compact.ron @@ -372,6 +372,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/index-by-value.ron b/naga/tests/out/ir/index-by-value.ron index 93a98214262..d625cfe2391 100644 --- a/naga/tests/out/ir/index-by-value.ron +++ b/naga/tests/out/ir/index-by-value.ron @@ -372,6 +372,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/must-use.compact.ron b/naga/tests/out/ir/must-use.compact.ron index 3d51cb0c952..7a3799a8bec 100644 --- a/naga/tests/out/ir/must-use.compact.ron +++ b/naga/tests/out/ir/must-use.compact.ron @@ -174,6 +174,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/must-use.ron b/naga/tests/out/ir/must-use.ron index 3d51cb0c952..7a3799a8bec 100644 --- a/naga/tests/out/ir/must-use.ron +++ b/naga/tests/out/ir/must-use.ron @@ -174,6 +174,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/overrides-atomicCompareExchangeWeak.compact.ron b/naga/tests/out/ir/overrides-atomicCompareExchangeWeak.compact.ron index 56be2f8ab67..656a2f2c156 100644 --- a/naga/tests/out/ir/overrides-atomicCompareExchangeWeak.compact.ron +++ b/naga/tests/out/ir/overrides-atomicCompareExchangeWeak.compact.ron @@ -125,6 +125,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/overrides-atomicCompareExchangeWeak.ron b/naga/tests/out/ir/overrides-atomicCompareExchangeWeak.ron index 56be2f8ab67..656a2f2c156 100644 --- a/naga/tests/out/ir/overrides-atomicCompareExchangeWeak.ron +++ b/naga/tests/out/ir/overrides-atomicCompareExchangeWeak.ron @@ -125,6 +125,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/overrides-ray-query.compact.ron b/naga/tests/out/ir/overrides-ray-query.compact.ron index 10cad83538b..23f9039452e 100644 --- a/naga/tests/out/ir/overrides-ray-query.compact.ron +++ b/naga/tests/out/ir/overrides-ray-query.compact.ron @@ -256,6 +256,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/overrides-ray-query.ron b/naga/tests/out/ir/overrides-ray-query.ron index 10cad83538b..23f9039452e 100644 --- a/naga/tests/out/ir/overrides-ray-query.ron +++ b/naga/tests/out/ir/overrides-ray-query.ron @@ -256,6 +256,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/overrides.compact.ron b/naga/tests/out/ir/overrides.compact.ron index 00c57fa4345..18e77e51b81 100644 --- a/naga/tests/out/ir/overrides.compact.ron +++ b/naga/tests/out/ir/overrides.compact.ron @@ -210,6 +210,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/overrides.ron b/naga/tests/out/ir/overrides.ron index 00c57fa4345..18e77e51b81 100644 --- a/naga/tests/out/ir/overrides.ron +++ b/naga/tests/out/ir/overrides.ron @@ -210,6 +210,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/shadow.compact.ron b/naga/tests/out/ir/shadow.compact.ron index 24b46745151..882af0fbebd 100644 --- a/naga/tests/out/ir/shadow.compact.ron +++ b/naga/tests/out/ir/shadow.compact.ron @@ -1028,6 +1028,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/shadow.ron b/naga/tests/out/ir/shadow.ron index 386b9d36b0c..586f5d7900c 100644 --- a/naga/tests/out/ir/shadow.ron +++ b/naga/tests/out/ir/shadow.ron @@ -1306,6 +1306,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/spec-constants.compact.ron b/naga/tests/out/ir/spec-constants.compact.ron index cde31172251..ff33d53f9f6 100644 --- a/naga/tests/out/ir/spec-constants.compact.ron +++ b/naga/tests/out/ir/spec-constants.compact.ron @@ -610,6 +610,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/spec-constants.ron b/naga/tests/out/ir/spec-constants.ron index fa4139a1dab..16e338e820c 100644 --- a/naga/tests/out/ir/spec-constants.ron +++ b/naga/tests/out/ir/spec-constants.ron @@ -716,6 +716,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/storage-textures.compact.ron b/naga/tests/out/ir/storage-textures.compact.ron index 3f2f06439c9..487010047e1 100644 --- a/naga/tests/out/ir/storage-textures.compact.ron +++ b/naga/tests/out/ir/storage-textures.compact.ron @@ -215,6 +215,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ( name: "csStore", @@ -312,6 +314,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/storage-textures.ron b/naga/tests/out/ir/storage-textures.ron index 3f2f06439c9..487010047e1 100644 --- a/naga/tests/out/ir/storage-textures.ron +++ b/naga/tests/out/ir/storage-textures.ron @@ -215,6 +215,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ( name: "csStore", @@ -312,6 +314,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], From 4840189c4332b7e93a9f302d569562af57ef74bd Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Wed, 12 Feb 2025 21:36:40 -0600 Subject: [PATCH 10/84] Fixed issue with multiview feature --- wgpu-hal/src/vulkan/adapter.rs | 31 +++++++++++++++++++++---------- wgpu-hal/src/vulkan/mod.rs | 2 +- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index 40cd3a9ef8e..1e7bcac042a 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -117,8 +117,12 @@ pub struct PhysicalDeviceFeatures { /// Features provided by `VK_EXT_subgroup_size_control`, promoted to Vulkan 1.3. subgroup_size_control: Option>, - mesh_shader: Option>, + + /// Features proved by `VK_KHR_maintenance4`, needed for mesh shaders maintenance4: Option>, + + /// Features proved by `VK_EXT_mesh_shader` + mesh_shader: Option>, } impl PhysicalDeviceFeatures { @@ -143,6 +147,9 @@ impl PhysicalDeviceFeatures { if let Some(ref mut feature) = self.robustness2 { info = info.push_next(feature); } + if let Some(ref mut feature) = self.multiview { + info = info.push_next(feature); + } if let Some(ref mut feature) = self.astc_hdr { info = info.push_next(feature); } @@ -174,10 +181,10 @@ impl PhysicalDeviceFeatures { if let Some(ref mut feature) = self.subgroup_size_control { info = info.push_next(feature); } - if let Some(ref mut feature) = self.mesh_shader { + if let Some(ref mut feature) = self.maintenance4 { info = info.push_next(feature); } - if let Some(ref mut feature) = self.maintenance4 { + if let Some(ref mut feature) = self.mesh_shader { info = info.push_next(feature); } info @@ -210,12 +217,14 @@ impl PhysicalDeviceFeatures { /// [`add_to_device_create`]: PhysicalDeviceFeatures::add_to_device_create /// [`Adapter::required_device_extensions`]: super::Adapter::required_device_extensions fn from_extensions_and_requested_features( - device_api_version: u32, + phd_capabilities: &PhysicalDeviceProperties, + phd_features: &PhysicalDeviceFeatures, enabled_extensions: &[&'static CStr], requested_features: wgt::Features, downlevel_flags: wgt::DownlevelFlags, private_caps: &super::PrivateCapabilities, ) -> Self { + let device_api_version = phd_capabilities.device_api_version; let needs_sampled_image_non_uniform = requested_features.contains( wgt::Features::TEXTURE_BINDING_ARRAY | wgt::Features::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING, @@ -496,7 +505,11 @@ impl PhysicalDeviceFeatures { vk::PhysicalDeviceMeshShaderFeaturesEXT::default() .mesh_shader(needed) .task_shader(needed) - .multiview_mesh_shader(needed && multiview), + .multiview_mesh_shader( + needed + && multiview + && phd_features.mesh_shader.unwrap().multiview_mesh_shader == 1, + ), ) } else { None @@ -836,12 +849,10 @@ impl PhysicalDeviceFeatures { F::VULKAN_EXTERNAL_MEMORY_WIN32, caps.supports_extension(khr::external_memory_win32::NAME), ); - features.set( F::MESH_SHADER, caps.supports_extension(ext::mesh_shader::NAME), ); - (features, dl_flags) } } @@ -1539,7 +1550,6 @@ impl super::Instance { }, backend: wgt::Backend::Vulkan, }; - let (available_features, downlevel_flags) = phd_features.to_wgpu(&self.shared.raw, phd, &phd_capabilities); let mut workarounds = super::Workarounds::empty(); @@ -1694,7 +1704,7 @@ impl super::Instance { | vk::MemoryPropertyFlags::HOST_CACHED | vk::MemoryPropertyFlags::LAZILY_ALLOCATED, phd_capabilities, - //phd_features, + phd_features, downlevel_flags, private_caps, workarounds, @@ -1759,7 +1769,8 @@ impl super::Adapter { features: wgt::Features, ) -> PhysicalDeviceFeatures { PhysicalDeviceFeatures::from_extensions_and_requested_features( - self.phd_capabilities.device_api_version, + &self.phd_capabilities, + &self.phd_features, enabled_extensions, features, self.downlevel_flags, diff --git a/wgpu-hal/src/vulkan/mod.rs b/wgpu-hal/src/vulkan/mod.rs index 42e10804305..8f54c4d45a0 100644 --- a/wgpu-hal/src/vulkan/mod.rs +++ b/wgpu-hal/src/vulkan/mod.rs @@ -460,7 +460,7 @@ pub struct Adapter { //queue_families: Vec, known_memory_flags: vk::MemoryPropertyFlags, phd_capabilities: adapter::PhysicalDeviceProperties, - //phd_features: adapter::PhysicalDeviceFeatures, + phd_features: adapter::PhysicalDeviceFeatures, downlevel_flags: wgt::DownlevelFlags, private_caps: PrivateCapabilities, workarounds: Workarounds, From 6f4f8cfedd1763e1747052f2ad1b26617b44a9d4 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Wed, 12 Feb 2025 23:02:59 -0600 Subject: [PATCH 11/84] CI will hate this one - made some changes based on discussion of proposal, left a lot of todo!()'s --- naga/src/back/dot/mod.rs | 10 ++++------ naga/src/back/glsl/mod.rs | 14 ++++---------- naga/src/back/hlsl/conv.rs | 2 +- naga/src/back/hlsl/writer.rs | 12 +++--------- naga/src/back/msl/mod.rs | 2 +- naga/src/back/msl/writer.rs | 7 ++++--- naga/src/back/pipeline_constants.rs | 8 +++----- naga/src/back/spv/block.rs | 12 ++++-------- naga/src/back/spv/writer.rs | 2 -- naga/src/back/wgsl/writer.rs | 13 +++---------- naga/src/compact/statements.rs | 18 ++++++++---------- naga/src/lib.rs | 15 +++++++++------ naga/src/valid/analyzer.rs | 19 ++++++------------- naga/src/valid/function.rs | 11 ++++++----- naga/src/valid/handles.rs | 12 ++++++------ naga/src/valid/interface.rs | 4 ---- 16 files changed, 62 insertions(+), 99 deletions(-) diff --git a/naga/src/back/dot/mod.rs b/naga/src/back/dot/mod.rs index 4661105be13..81fd951caa5 100644 --- a/naga/src/back/dot/mod.rs +++ b/naga/src/back/dot/mod.rs @@ -296,12 +296,6 @@ impl StatementGraph { crate::RayQueryFunction::Terminate => "RayQueryTerminate", } } - S::MeshFunction(crate::MeshFunction::EmitMeshTasks { group_size }) => { - self.dependencies.push((id, group_size[0], "group_count_x")); - self.dependencies.push((id, group_size[1], "group_count_y")); - self.dependencies.push((id, group_size[2], "group_count_z")); - "EmitMeshTasks" - } S::MeshFunction(crate::MeshFunction::SetMeshOutputs { vertex_count, primitive_count, @@ -311,6 +305,10 @@ impl StatementGraph { .push((id, primitive_count, "primitive_count")); "SetMeshOutputs" } + S::MeshFunction( + crate::MeshFunction::SetVertex { .. } + | crate::MeshFunction::SetPrimitive { .. }, + ) => todo!(), S::SubgroupBallot { result, predicate } => { if let Some(predicate) = predicate { self.dependencies.push((id, predicate, "predicate")); diff --git a/naga/src/back/glsl/mod.rs b/naga/src/back/glsl/mod.rs index 2bd4d299799..42e82621aee 100644 --- a/naga/src/back/glsl/mod.rs +++ b/naga/src/back/glsl/mod.rs @@ -2499,15 +2499,6 @@ impl<'a, W: Write> Writer<'a, W> { self.write_image_atomic(ctx, image, coordinate, array_index, fun, value)? } Statement::RayQuery { .. } => unreachable!(), - Statement::MeshFunction(crate::MeshFunction::EmitMeshTasks { group_size }) => { - write!(self.out, "{level}EmitMeshTasksEXT(")?; - self.write_expr(group_size[0], ctx)?; - for &g in &group_size[1..] { - write!(self.out, ", ")?; - self.write_expr(g, ctx)?; - } - write!(self.out, ");")?; - } Statement::MeshFunction(crate::MeshFunction::SetMeshOutputs { vertex_count, primitive_count, @@ -2518,6 +2509,9 @@ impl<'a, W: Write> Writer<'a, W> { self.write_expr(primitive_count, ctx)?; write!(self.out, ");")?; } + Statement::MeshFunction( + crate::MeshFunction::SetVertex { .. } | crate::MeshFunction::SetPrimitive { .. }, + ) => todo!(), Statement::SubgroupBallot { result, predicate } => { write!(self.out, "{level}")?; let res_name = Baked(result).to_string(); @@ -4894,7 +4888,7 @@ const fn glsl_built_in(built_in: crate::BuiltIn, options: VaryingOptions) -> &'s Bi::SubgroupInvocationId => "gl_SubgroupInvocationID", // mesh // TODO: figure out how to map these to glsl things as glsl treats them as arrays - Bi::CullPrimitive | Bi::PointIndices | Bi::LineIndices | Bi::TriangleIndices => { + Bi::CullPrimitive | Bi::LineIndices | Bi::TriangleIndices => { unimplemented!() } } diff --git a/naga/src/back/hlsl/conv.rs b/naga/src/back/hlsl/conv.rs index 6030c838eac..316957569f3 100644 --- a/naga/src/back/hlsl/conv.rs +++ b/naga/src/back/hlsl/conv.rs @@ -185,7 +185,7 @@ impl crate::BuiltIn { } Self::CullPrimitive => "SV_CullPrimitive", // TODO: make this work - Self::PointIndices | Self::LineIndices | Self::TriangleIndices => unimplemented!(), + Self::LineIndices | Self::TriangleIndices => unimplemented!(), }) } } diff --git a/naga/src/back/hlsl/writer.rs b/naga/src/back/hlsl/writer.rs index e0cc71260bf..5cef57c09a2 100644 --- a/naga/src/back/hlsl/writer.rs +++ b/naga/src/back/hlsl/writer.rs @@ -2458,15 +2458,6 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { writeln!(self.out, ".Abort();")?; } }, - Statement::MeshFunction(crate::MeshFunction::EmitMeshTasks { group_size }) => { - write!(self.out, "{level}DispatchMesh(")?; - self.write_expr(module, group_size[0], func_ctx)?; - for &g in &group_size[1..] { - write!(self.out, ", ")?; - self.write_expr(module, g, func_ctx)?; - } - write!(self.out, ");")?; - } Statement::MeshFunction(crate::MeshFunction::SetMeshOutputs { vertex_count, primitive_count, @@ -2477,6 +2468,9 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { self.write_expr(module, primitive_count, func_ctx)?; write!(self.out, ");")?; } + Statement::MeshFunction( + crate::MeshFunction::SetVertex { .. } | crate::MeshFunction::SetPrimitive { .. }, + ) => todo!(), Statement::SubgroupBallot { result, predicate } => { write!(self.out, "{level}")?; let name = Baked(result).to_string(); diff --git a/naga/src/back/msl/mod.rs b/naga/src/back/msl/mod.rs index 7c0f3101f32..078b82e0e96 100644 --- a/naga/src/back/msl/mod.rs +++ b/naga/src/back/msl/mod.rs @@ -602,7 +602,7 @@ impl ResolvedBinding { } Bi::CullPrimitive => "primitive_culled", // TODO: figure out how to make this written as a function call - Bi::PointIndices | Bi::LineIndices | Bi::TriangleIndices => unimplemented!(), + Bi::LineIndices | Bi::TriangleIndices => unimplemented!(), }; write!(out, "{name}")?; } diff --git a/naga/src/back/msl/writer.rs b/naga/src/back/msl/writer.rs index 51d7b93a8c7..0066da52eed 100644 --- a/naga/src/back/msl/writer.rs +++ b/naga/src/back/msl/writer.rs @@ -3524,12 +3524,13 @@ impl Writer { } } // TODO: write emitters for these - crate::Statement::MeshFunction(crate::MeshFunction::EmitMeshTasks { .. }) => { - unimplemented!() - } crate::Statement::MeshFunction(crate::MeshFunction::SetMeshOutputs { .. }) => { unimplemented!() } + crate::Statement::MeshFunction( + crate::MeshFunction::SetVertex { .. } + | crate::MeshFunction::SetPrimitive { .. }, + ) => todo!(), crate::Statement::SubgroupBallot { result, predicate } => { write!(self.out, "{level}")?; let name = self.namer.call(""); diff --git a/naga/src/back/pipeline_constants.rs b/naga/src/back/pipeline_constants.rs index b302f56cd27..9508a8457e6 100644 --- a/naga/src/back/pipeline_constants.rs +++ b/naga/src/back/pipeline_constants.rs @@ -824,11 +824,6 @@ fn adjust_stmt(new_pos: &HandleVec>, stmt: &mut S crate::RayQueryFunction::Terminate => {} } } - Statement::MeshFunction(crate::MeshFunction::EmitMeshTasks { ref mut group_size }) => { - for g in group_size { - adjust(g); - } - } Statement::MeshFunction(crate::MeshFunction::SetMeshOutputs { ref mut vertex_count, ref mut primitive_count, @@ -836,6 +831,9 @@ fn adjust_stmt(new_pos: &HandleVec>, stmt: &mut S adjust(vertex_count); adjust(primitive_count); } + Statement::MeshFunction( + crate::MeshFunction::SetVertex { .. } | crate::MeshFunction::SetPrimitive { .. }, + ) => todo!(), Statement::Break | Statement::Continue | Statement::Kill | Statement::Barrier(_) => {} } } diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index c15f9265fbd..f3705d74add 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -2997,14 +2997,6 @@ impl BlockContext<'_> { Statement::RayQuery { query, ref fun } => { self.write_ray_query_function(query, fun, &mut block); } - Statement::MeshFunction(crate::MeshFunction::EmitMeshTasks { group_size }) => { - let mut ins = Instruction::new(spirv::Op::EmitMeshTasksEXT); - for g in group_size { - ins.add_operand(self.cached[g]); - } - // TODO: make this also add the payload as an optional parameter - block.body.push(ins); - } Statement::MeshFunction(crate::MeshFunction::SetMeshOutputs { vertex_count, primitive_count, @@ -3013,6 +3005,10 @@ impl BlockContext<'_> { ins.operands = vec![self.cached[vertex_count], self.cached[primitive_count]]; block.body.push(ins); } + Statement::MeshFunction( + crate::MeshFunction::SetVertex { .. } + | crate::MeshFunction::SetPrimitive { .. }, + ) => todo!(), Statement::SubgroupBallot { result, ref predicate, diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 1d74a610f92..f6301df444d 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -792,7 +792,6 @@ impl Writer { Instruction::execution_mode( function_id, match mesh_info.topology { - crate::MeshOutputTopology::Points => spirv::ExecutionMode::OutputPoints, crate::MeshOutputTopology::Lines => spirv::ExecutionMode::OutputLinesEXT, crate::MeshOutputTopology::Triangles => { spirv::ExecutionMode::OutputTrianglesEXT @@ -1662,7 +1661,6 @@ impl Writer { BuiltIn::SubgroupLocalInvocationId } Bi::CullPrimitive => BuiltIn::CullPrimitiveEXT, - Bi::PointIndices => BuiltIn::PrimitivePointIndicesEXT, Bi::LineIndices => BuiltIn::PrimitiveLineIndicesEXT, Bi::TriangleIndices => BuiltIn::PrimitiveTriangleIndicesEXT, }; diff --git a/naga/src/back/wgsl/writer.rs b/naga/src/back/wgsl/writer.rs index 17cd29c9146..e8ea8a60250 100644 --- a/naga/src/back/wgsl/writer.rs +++ b/naga/src/back/wgsl/writer.rs @@ -979,15 +979,6 @@ impl Writer { } } Statement::RayQuery { .. } => unreachable!(), - Statement::MeshFunction(crate::MeshFunction::EmitMeshTasks { group_size }) => { - write!(self.out, "{level}emitMeshTasks(")?; - self.write_expr(module, group_size[0], func_ctx)?; - for &a in &group_size[1..] { - write!(self.out, ", ")?; - self.write_expr(module, a, func_ctx)?; - } - writeln!(self.out, ");")?; - } Statement::MeshFunction(crate::MeshFunction::SetMeshOutputs { vertex_count, primitive_count, @@ -998,6 +989,9 @@ impl Writer { self.write_expr(module, primitive_count, func_ctx)?; writeln!(self.out, ");")?; } + Statement::MeshFunction( + crate::MeshFunction::SetVertex { .. } | crate::MeshFunction::SetPrimitive { .. }, + ) => todo!(), Statement::SubgroupBallot { result, predicate } => { write!(self.out, "{level}")?; let res_name = Baked(result).to_string(); @@ -2023,7 +2017,6 @@ fn builtin_str(built_in: crate::BuiltIn) -> Result<&'static str, Error> { | Bi::WorkGroupSize | Bi::DrawID => return Err(Error::Custom(format!("Unsupported builtin {built_in:?}"))), Bi::CullPrimitive => "cull_primitive", - Bi::PointIndices => "point_indices", Bi::LineIndices => "line_indices", Bi::TriangleIndices => "triangle_indices", }) diff --git a/naga/src/compact/statements.rs b/naga/src/compact/statements.rs index e801db661b4..6b8af3ac159 100644 --- a/naga/src/compact/statements.rs +++ b/naga/src/compact/statements.rs @@ -113,11 +113,6 @@ impl FunctionTracer<'_> { self.expressions_used.insert(query); self.trace_ray_query_function(fun); } - St::MeshFunction(crate::MeshFunction::EmitMeshTasks { group_size }) => { - for g in group_size { - self.expressions_used.insert(g); - } - } St::MeshFunction(crate::MeshFunction::SetMeshOutputs { vertex_count, primitive_count, @@ -125,6 +120,10 @@ impl FunctionTracer<'_> { self.expressions_used.insert(vertex_count); self.expressions_used.insert(primitive_count); } + St::MeshFunction( + crate::MeshFunction::SetPrimitive { .. } + | crate::MeshFunction::SetVertex { .. }, + ) => todo!(), St::SubgroupBallot { result, predicate } => { if let Some(predicate) = predicate { self.expressions_used.insert(predicate); @@ -327,11 +326,10 @@ impl FunctionMap { adjust(query); self.adjust_ray_query_function(fun); } - St::MeshFunction(crate::MeshFunction::EmitMeshTasks { ref mut group_size }) => { - for g in group_size { - adjust(g); - } - } + St::MeshFunction( + crate::MeshFunction::SetVertex { .. } + | crate::MeshFunction::SetPrimitive { .. }, + ) => todo!(), St::MeshFunction(crate::MeshFunction::SetMeshOutputs { ref mut vertex_count, ref mut primitive_count, diff --git a/naga/src/lib.rs b/naga/src/lib.rs index 624e0680957..944316c14cd 100644 --- a/naga/src/lib.rs +++ b/naga/src/lib.rs @@ -445,7 +445,6 @@ pub enum BuiltIn { SubgroupInvocationId, // mesh CullPrimitive, - PointIndices, LineIndices, TriangleIndices, } @@ -1805,13 +1804,18 @@ pub enum RayQueryFunction { #[cfg_attr(feature = "deserialize", derive(Deserialize))] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] pub enum MeshFunction { - EmitMeshTasks { - group_size: [Handle; 3], - }, SetMeshOutputs { vertex_count: Handle, primitive_count: Handle, }, + SetVertex { + index: Handle, + value: Handle, + }, + SetPrimitive { + index: Handle, + value: Handle, + }, } //TODO: consider removing `Clone`. It's not valid to clone `Statement::Emit` anyway. @@ -2260,7 +2264,6 @@ pub struct Function { #[cfg_attr(feature = "deserialize", derive(Deserialize))] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] pub enum MeshOutputTopology { - Points, Lines, Triangles, } @@ -2275,7 +2278,7 @@ pub struct MeshStageInfo { max_vertices: u32, max_primitives: u32, vertex_output_type: Handle, - primitive_output_type: Option>, + primitive_output_type: Handle, } /// The main function for a pipeline stage. diff --git a/naga/src/valid/analyzer.rs b/naga/src/valid/analyzer.rs index 88d5ab794e6..d3613bdcc54 100644 --- a/naga/src/valid/analyzer.rs +++ b/naga/src/valid/analyzer.rs @@ -1092,19 +1092,6 @@ impl FunctionInfo { FunctionUniformity::new() } S::MeshFunction(func) => match func { - crate::MeshFunction::EmitMeshTasks { group_size } => { - for g in group_size { - let _ = self.add_ref(g); - } - // TODO: reexamine this - FunctionUniformity { - result: Uniformity { - non_uniform_result: None, - requirements: UniformityRequirements::WORK_GROUP_BARRIER, - }, - exit: ExitFlags::MAY_KILL, - } - } crate::MeshFunction::SetMeshOutputs { vertex_count, primitive_count, @@ -1113,6 +1100,12 @@ impl FunctionInfo { let _ = self.add_ref(primitive_count); FunctionUniformity::new() } + crate::MeshFunction::SetVertex { index, value } => { + todo!() + } + crate::MeshFunction::SetPrimitive { index, value } => { + todo!() + } }, S::SubgroupBallot { result: _, diff --git a/naga/src/valid/function.rs b/naga/src/valid/function.rs index 3a2131e8279..694e53faa61 100644 --- a/naga/src/valid/function.rs +++ b/naga/src/valid/function.rs @@ -1504,11 +1504,6 @@ impl super::Validator { } }; match func { - crate::MeshFunction::EmitMeshTasks { group_size } => { - for g in group_size { - ensure_correct(g)?; - } - } crate::MeshFunction::SetMeshOutputs { vertex_count, primitive_count, @@ -1516,6 +1511,12 @@ impl super::Validator { ensure_correct(vertex_count)?; ensure_correct(primitive_count)?; } + crate::MeshFunction::SetVertex { index, value } => { + todo!() + } + crate::MeshFunction::SetPrimitive { index, value } => { + todo!() + } } } S::SubgroupBallot { result, predicate } => { diff --git a/naga/src/valid/handles.rs b/naga/src/valid/handles.rs index 74f544b7390..1cedee4575d 100644 --- a/naga/src/valid/handles.rs +++ b/naga/src/valid/handles.rs @@ -712,12 +712,6 @@ impl super::Validator { Ok(()) } crate::Statement::MeshFunction(func) => match func { - crate::MeshFunction::EmitMeshTasks { group_size } => { - for g in group_size { - validate_expr(g)?; - } - Ok(()) - } crate::MeshFunction::SetMeshOutputs { vertex_count, primitive_count, @@ -726,6 +720,12 @@ impl super::Validator { validate_expr(primitive_count)?; Ok(()) } + crate::MeshFunction::SetVertex { index, value } => { + todo!() + } + crate::MeshFunction::SetPrimitive { index, value } => { + todo!() + } }, crate::Statement::SubgroupBallot { result, predicate } => { validate_expr_opt(predicate)?; diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index e941fef24c4..d53205b5fb3 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -296,10 +296,6 @@ impl VaryingContext<'_> { self.stage == St::Mesh && self.output, *ty_inner == Ti::Scalar(crate::Scalar::BOOL), ), - Bi::PointIndices => ( - self.stage == St::Mesh && self.output, - *ty_inner == Ti::Scalar(crate::Scalar::U32), - ), Bi::LineIndices => ( self.stage == St::Mesh && self.output, *ty_inner From e7ec2a7daa7f7411f3adb9809d927951ab5d0137 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Wed, 12 Feb 2025 23:15:03 -0600 Subject: [PATCH 12/84] Made CI slightly less angry --- naga/src/back/dot/mod.rs | 14 ++++++++++---- naga/src/back/glsl/mod.rs | 2 +- naga/src/back/hlsl/writer.rs | 2 +- naga/src/back/msl/writer.rs | 2 +- naga/src/back/pipeline_constants.rs | 14 ++++++++++++-- naga/src/back/spv/block.rs | 5 ++++- naga/src/back/wgsl/writer.rs | 17 ++++++++++++++--- naga/src/compact/statements.rs | 26 +++++++++++++++++++------- naga/src/valid/analyzer.rs | 11 ++++++----- naga/src/valid/function.rs | 9 ++++----- naga/src/valid/handles.rs | 10 +++++----- 11 files changed, 77 insertions(+), 35 deletions(-) diff --git a/naga/src/back/dot/mod.rs b/naga/src/back/dot/mod.rs index 81fd951caa5..35cc6c3673b 100644 --- a/naga/src/back/dot/mod.rs +++ b/naga/src/back/dot/mod.rs @@ -305,10 +305,16 @@ impl StatementGraph { .push((id, primitive_count, "primitive_count")); "SetMeshOutputs" } - S::MeshFunction( - crate::MeshFunction::SetVertex { .. } - | crate::MeshFunction::SetPrimitive { .. }, - ) => todo!(), + S::MeshFunction(crate::MeshFunction::SetVertex { index, value }) => { + self.dependencies.push((id, index, "index")); + self.dependencies.push((id, value, "value")); + "SetVertex" + } + S::MeshFunction(crate::MeshFunction::SetPrimitive { index, value }) => { + self.dependencies.push((id, index, "index")); + self.dependencies.push((id, value, "value")); + "SetPrimitive" + } S::SubgroupBallot { result, predicate } => { if let Some(predicate) = predicate { self.dependencies.push((id, predicate, "predicate")); diff --git a/naga/src/back/glsl/mod.rs b/naga/src/back/glsl/mod.rs index 42e82621aee..5d2887288d5 100644 --- a/naga/src/back/glsl/mod.rs +++ b/naga/src/back/glsl/mod.rs @@ -2511,7 +2511,7 @@ impl<'a, W: Write> Writer<'a, W> { } Statement::MeshFunction( crate::MeshFunction::SetVertex { .. } | crate::MeshFunction::SetPrimitive { .. }, - ) => todo!(), + ) => unimplemented!(), Statement::SubgroupBallot { result, predicate } => { write!(self.out, "{level}")?; let res_name = Baked(result).to_string(); diff --git a/naga/src/back/hlsl/writer.rs b/naga/src/back/hlsl/writer.rs index 5cef57c09a2..99b9f33b71c 100644 --- a/naga/src/back/hlsl/writer.rs +++ b/naga/src/back/hlsl/writer.rs @@ -2470,7 +2470,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { } Statement::MeshFunction( crate::MeshFunction::SetVertex { .. } | crate::MeshFunction::SetPrimitive { .. }, - ) => todo!(), + ) => unimplemented!(), Statement::SubgroupBallot { result, predicate } => { write!(self.out, "{level}")?; let name = Baked(result).to_string(); diff --git a/naga/src/back/msl/writer.rs b/naga/src/back/msl/writer.rs index 0066da52eed..aa3abb46fec 100644 --- a/naga/src/back/msl/writer.rs +++ b/naga/src/back/msl/writer.rs @@ -3530,7 +3530,7 @@ impl Writer { crate::Statement::MeshFunction( crate::MeshFunction::SetVertex { .. } | crate::MeshFunction::SetPrimitive { .. }, - ) => todo!(), + ) => unimplemented!(), crate::Statement::SubgroupBallot { result, predicate } => { write!(self.out, "{level}")?; let name = self.namer.call(""); diff --git a/naga/src/back/pipeline_constants.rs b/naga/src/back/pipeline_constants.rs index 9508a8457e6..df1a3b6bead 100644 --- a/naga/src/back/pipeline_constants.rs +++ b/naga/src/back/pipeline_constants.rs @@ -832,8 +832,18 @@ fn adjust_stmt(new_pos: &HandleVec>, stmt: &mut S adjust(primitive_count); } Statement::MeshFunction( - crate::MeshFunction::SetVertex { .. } | crate::MeshFunction::SetPrimitive { .. }, - ) => todo!(), + crate::MeshFunction::SetVertex { + ref mut index, + ref mut value, + } + | crate::MeshFunction::SetPrimitive { + ref mut index, + ref mut value, + }, + ) => { + adjust(index); + adjust(value); + } Statement::Break | Statement::Continue | Statement::Kill | Statement::Barrier(_) => {} } } diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index f3705d74add..3bc6ba9c462 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -3008,7 +3008,10 @@ impl BlockContext<'_> { Statement::MeshFunction( crate::MeshFunction::SetVertex { .. } | crate::MeshFunction::SetPrimitive { .. }, - ) => todo!(), + ) => { + // TODO: work on this + unimplemented!(); + } Statement::SubgroupBallot { result, ref predicate, diff --git a/naga/src/back/wgsl/writer.rs b/naga/src/back/wgsl/writer.rs index e8ea8a60250..e646b3130d0 100644 --- a/naga/src/back/wgsl/writer.rs +++ b/naga/src/back/wgsl/writer.rs @@ -989,9 +989,20 @@ impl Writer { self.write_expr(module, primitive_count, func_ctx)?; writeln!(self.out, ");")?; } - Statement::MeshFunction( - crate::MeshFunction::SetVertex { .. } | crate::MeshFunction::SetPrimitive { .. }, - ) => todo!(), + Statement::MeshFunction(crate::MeshFunction::SetVertex { index, value }) => { + write!(self.out, "{level}setVertex(")?; + self.write_expr(module, index, func_ctx)?; + write!(self.out, ", ")?; + self.write_expr(module, value, func_ctx)?; + writeln!(self.out, ");")?; + } + Statement::MeshFunction(crate::MeshFunction::SetPrimitive { index, value }) => { + write!(self.out, "{level}setPrimitive(")?; + self.write_expr(module, index, func_ctx)?; + write!(self.out, ", ")?; + self.write_expr(module, value, func_ctx)?; + writeln!(self.out, ");")?; + } Statement::SubgroupBallot { result, predicate } => { write!(self.out, "{level}")?; let res_name = Baked(result).to_string(); diff --git a/naga/src/compact/statements.rs b/naga/src/compact/statements.rs index 6b8af3ac159..2519db38eda 100644 --- a/naga/src/compact/statements.rs +++ b/naga/src/compact/statements.rs @@ -121,9 +121,12 @@ impl FunctionTracer<'_> { self.expressions_used.insert(primitive_count); } St::MeshFunction( - crate::MeshFunction::SetPrimitive { .. } - | crate::MeshFunction::SetVertex { .. }, - ) => todo!(), + crate::MeshFunction::SetPrimitive { index, value } + | crate::MeshFunction::SetVertex { index, value }, + ) => { + self.expressions_used.insert(index); + self.expressions_used.insert(value); + } St::SubgroupBallot { result, predicate } => { if let Some(predicate) = predicate { self.expressions_used.insert(predicate); @@ -326,10 +329,6 @@ impl FunctionMap { adjust(query); self.adjust_ray_query_function(fun); } - St::MeshFunction( - crate::MeshFunction::SetVertex { .. } - | crate::MeshFunction::SetPrimitive { .. }, - ) => todo!(), St::MeshFunction(crate::MeshFunction::SetMeshOutputs { ref mut vertex_count, ref mut primitive_count, @@ -337,6 +336,19 @@ impl FunctionMap { adjust(vertex_count); adjust(primitive_count); } + St::MeshFunction( + crate::MeshFunction::SetVertex { + ref mut index, + ref mut value, + } + | crate::MeshFunction::SetPrimitive { + ref mut index, + ref mut value, + }, + ) => { + adjust(index); + adjust(value); + } St::SubgroupBallot { ref mut result, ref mut predicate, diff --git a/naga/src/valid/analyzer.rs b/naga/src/valid/analyzer.rs index d3613bdcc54..4d2b915346b 100644 --- a/naga/src/valid/analyzer.rs +++ b/naga/src/valid/analyzer.rs @@ -1092,6 +1092,7 @@ impl FunctionInfo { FunctionUniformity::new() } S::MeshFunction(func) => match func { + // TODO: double check all of this uniformity stuff. I frankly don't fully understand all of it. crate::MeshFunction::SetMeshOutputs { vertex_count, primitive_count, @@ -1100,11 +1101,11 @@ impl FunctionInfo { let _ = self.add_ref(primitive_count); FunctionUniformity::new() } - crate::MeshFunction::SetVertex { index, value } => { - todo!() - } - crate::MeshFunction::SetPrimitive { index, value } => { - todo!() + crate::MeshFunction::SetVertex { index, value } + | crate::MeshFunction::SetPrimitive { index, value } => { + let _ = self.add_ref(index); + let _ = self.add_ref(value); + FunctionUniformity::new() } }, S::SubgroupBallot { diff --git a/naga/src/valid/function.rs b/naga/src/valid/function.rs index 694e53faa61..5f469488ba1 100644 --- a/naga/src/valid/function.rs +++ b/naga/src/valid/function.rs @@ -1511,11 +1511,10 @@ impl super::Validator { ensure_correct(vertex_count)?; ensure_correct(primitive_count)?; } - crate::MeshFunction::SetVertex { index, value } => { - todo!() - } - crate::MeshFunction::SetPrimitive { index, value } => { - todo!() + crate::MeshFunction::SetVertex { index, value } + | crate::MeshFunction::SetPrimitive { index, value } => { + ensure_correct(index)?; + ensure_correct(value)?; } } } diff --git a/naga/src/valid/handles.rs b/naga/src/valid/handles.rs index 1cedee4575d..f6d4b7f6175 100644 --- a/naga/src/valid/handles.rs +++ b/naga/src/valid/handles.rs @@ -720,11 +720,11 @@ impl super::Validator { validate_expr(primitive_count)?; Ok(()) } - crate::MeshFunction::SetVertex { index, value } => { - todo!() - } - crate::MeshFunction::SetPrimitive { index, value } => { - todo!() + crate::MeshFunction::SetVertex { index, value } + | crate::MeshFunction::SetPrimitive { index, value } => { + validate_expr(index)?; + validate_expr(value)?; + Ok(()) } }, crate::Statement::SubgroupBallot { result, predicate } => { From 6c2c9acb44c9638fe7abdfc263a6b341f43f1c0e Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated <85136135+SupaMaggie70Incorporated@users.noreply.github.com> Date: Thu, 13 Feb 2025 08:09:24 -0600 Subject: [PATCH 13/84] Dummy commit for dummy CI The CI pooped itself, hopefully this fixes that. Will probably be undone either way. From 88acd6534091754dd95b03fcbe96efe82212996f Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Mon, 7 Jul 2025 11:06:00 -0500 Subject: [PATCH 14/84] Tried to undo cargo.lock changes --- Cargo.lock | 1734 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 1182 insertions(+), 552 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 32cb544494c..5f75584314f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "ab_glyph" -version = "0.2.29" +version = "0.2.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3672c180e71eeaaac3a541fbbc5f5ad4def8b747c595ad30d674e43049f7b0" +checksum = "1e0f4f6fbdc5ee39f2ede9f5f3ec79477271a6d6a2baff22310d51736bda6cea" dependencies = [ "ab_glyph_rasterizer", "owned_ttf_parser", @@ -14,9 +14,9 @@ dependencies = [ [[package]] name = "ab_glyph_rasterizer" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" +checksum = "b2187590a23ab1e3df8681afdf0987c48504d80291f002fcdb651f0ef5e25169" [[package]] name = "addr2line" @@ -35,18 +35,18 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "adler2" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "ahash" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" dependencies = [ "cfg-if", - "getrandom", + "getrandom 0.3.3", "once_cell", "version_check", "zerocopy", @@ -74,7 +74,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee91c0c2905bae44f84bfa4e044536541df26b7703fd0888deeb9060fcc44289" dependencies = [ "android-properties", - "bitflags 2.8.0", + "bitflags 2.9.1", "cc", "cesu8", "jni", @@ -95,7 +95,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef6978589202a00cd7e118380c448a08b6ed394c3a8df3a430d0898e3a42d046" dependencies = [ "android-properties", - "bitflags 2.8.0", + "bitflags 2.9.1", "cc", "cesu8", "jni", @@ -132,9 +132,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.18" +version = "0.6.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933" dependencies = [ "anstyle", "anstyle-parse", @@ -147,44 +147,44 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" +checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" [[package]] name = "anstyle-parse" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9" dependencies = [ "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.7" +version = "3.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" +checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882" dependencies = [ "anstyle", - "once_cell", + "once_cell_polyfill", "windows-sys 0.59.0", ] [[package]] name = "anyhow" -version = "1.0.95" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "approx" @@ -268,9 +268,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.86" +version = "0.1.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644dd749086bf3771a2fbc5f256fdb982d53f011c7d5d560304eafeecebce79d" +checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" dependencies = [ "proc-macro2", "quote", @@ -285,9 +285,9 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "az" @@ -297,14 +297,14 @@ checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973" [[package]] name = "backtrace" -version = "0.3.74" +version = "0.3.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" dependencies = [ "addr2line", "cfg-if", "libc", - "miniz_oxide 0.8.3", + "miniz_oxide 0.8.9", "object", "rustc-demangle", "windows-targets 0.52.6", @@ -312,9 +312,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.7" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64-simd" @@ -350,7 +350,7 @@ version = "0.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f49d8fed880d473ea71efb9bf597651e77201bdd4893efe54c9e5d65ae04ce6f" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "cexpr", "clang-sys", "itertools 0.13.0", @@ -402,9 +402,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.8.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" dependencies = [ "arbitrary", "serde", @@ -458,24 +458,24 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.17.0" +version = "3.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" [[package]] name = "bytemuck" -version = "1.21.0" +version = "1.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" +checksum = "5c76a5792e44e4abe34d3abf15636779261d45a7450612059293d1d2cfc63422" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.8.1" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fa76293b4f7bb636ab88fd78228235b5248b4d05cc589aed610f954af5d7c7a" +checksum = "7ecc273b49b3205b83d648f0690daa588925572cc5063745bfe547fe7ec8e1a1" dependencies = [ "proc-macro2", "quote", @@ -483,16 +483,16 @@ dependencies = [ ] [[package]] -name = "byteorder" -version = "1.5.0" +name = "byteorder-lite" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" [[package]] name = "bytes" -version = "1.9.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "calloop" @@ -500,10 +500,10 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fba7adb4dd5aa98e5553510223000e7148f621165ec5f9acd7113f6ca4995298" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "log", "polling", - "rustix", + "rustix 0.38.44", "slab", "thiserror 1.0.69", ] @@ -514,10 +514,10 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b99da2f8558ca23c71f4fd15dc57c906239752dd27ff3c00a1d56b685b7cbfec" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "log", "polling", - "rustix", + "rustix 0.38.44", "slab", "thiserror 1.0.69", ] @@ -529,7 +529,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02" dependencies = [ "calloop 0.12.4", - "rustix", + "rustix 0.38.44", "wayland-backend", "wayland-client", ] @@ -541,11 +541,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95a66a987056935f7efce4ab5668920b5d0dac4a7c99991a67395f13702ddd20" dependencies = [ "calloop 0.13.0", - "rustix", + "rustix 0.38.44", "wayland-backend", "wayland-client", ] +[[package]] +name = "camino" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0da45bc31171d8d6960122e222a67740df867c1dd53b4d51caa297084c185cab" +dependencies = [ + "serde", +] + [[package]] name = "capacity_builder" version = "0.1.3" @@ -575,6 +584,46 @@ dependencies = [ "syn", ] +[[package]] +name = "cargo-platform" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84982c6c0ae343635a3a4ee6dedef965513735c8b183caa7289fa6e27399ebd4" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-util-schemas" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e63d2780ac94487eb9f1fea7b0d56300abc9eb488800854ca217f102f5caccca" +dependencies = [ + "semver 1.0.26", + "serde", + "serde-untagged", + "serde-value", + "thiserror 1.0.69", + "toml", + "unicode-xid", + "url", +] + +[[package]] +name = "cargo_metadata" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f7835cfc6135093070e95eb2b53e5d9b5c403dc3a6be6040ee026270aa82502" +dependencies = [ + "camino", + "cargo-platform", + "cargo-util-schemas", + "semver 1.0.26", + "serde", + "serde_json", + "thiserror 2.0.12", +] + [[package]] name = "cast" version = "0.3.0" @@ -583,9 +632,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.11" +version = "1.2.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4730490333d58093109dc02c23174c3f4d490998c3fed3cc8e82d57afedb9cf" +checksum = "d487aa071b5f64da6f19a3e848e3578944b726ee5a4854b82172f02aa876bfdc" dependencies = [ "jobserver", "libc", @@ -609,9 +658,9 @@ dependencies = [ [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" [[package]] name = "cfg_aliases" @@ -674,9 +723,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.27" +version = "4.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "769b0145982b4b48713e01ec42d61614425f27b7058bda7180a3a41f30104796" +checksum = "40b6887a1d8685cebccf115538db5c0efe625ccac9696ad45c409d96566e910f" dependencies = [ "clap_builder", "clap_derive", @@ -684,9 +733,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.27" +version = "4.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b26884eb4b57140e4d2d93652abfa49498b938b3c9179f9fc487b0acc3edad7" +checksum = "e0c66c08ce9f0c698cbce5c0279d0bb6ac936d8674174fe48f736533b964f59e" dependencies = [ "anstream", "anstyle", @@ -696,9 +745,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.24" +version = "4.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c" +checksum = "d2c7947ae4cc3d851207c1adb5b5e260ff0cca11446b1d6d1423788e442257ce" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -708,31 +757,26 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" +checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" [[package]] name = "codespan-reporting" -version = "0.11.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +checksum = "fe6d2e5af09e8c8ad56c969f2157a3d4238cebc7c55f0a517728c38f7b200f81" dependencies = [ + "serde", "termcolor", "unicode-width", ] -[[package]] -name = "color_quant" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" - [[package]] name = "colorchoice" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" [[package]] name = "combine" @@ -753,6 +797,19 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "console" +version = "0.15.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8" +dependencies = [ + "encode_unicode", + "libc", + "once_cell", + "unicode-width", + "windows-sys 0.59.0", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -795,6 +852,16 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -808,8 +875,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" dependencies = [ "bitflags 1.3.2", - "core-foundation", - "core-graphics-types", + "core-foundation 0.9.4", + "core-graphics-types 0.1.3", "foreign-types", "libc", ] @@ -821,7 +888,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" dependencies = [ "bitflags 1.3.2", - "core-foundation", + "core-foundation 0.9.4", + "libc", +] + +[[package]] +name = "core-graphics-types" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" +dependencies = [ + "bitflags 2.9.1", + "core-foundation 0.10.1", "libc", ] @@ -836,25 +914,22 @@ dependencies = [ [[package]] name = "criterion" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" +checksum = "3bf7af66b0989381bd0be551bd7cc91912a655a58c6918420c9527b1fd8b4679" dependencies = [ "anes", "cast", "ciborium", "clap", "criterion-plot", - "is-terminal", - "itertools 0.10.5", + "itertools 0.13.0", "num-traits", - "once_cell", "oorandom", "plotters", "rayon", "regex", "serde", - "serde_derive", "serde_json", "tinytemplate", "walkdir", @@ -897,23 +972,29 @@ checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crunchy" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" [[package]] name = "ctor" -version = "0.2.9" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a2785755761f3ddc1492979ce1e48d2c00d09311c39e4466429188f3dd6501" +checksum = "a4735f265ba6a1188052ca32d461028a7d1125868be18e287e756019da7607b5" dependencies = [ - "quote", - "syn", + "ctor-proc-macro", + "dtor", ] +[[package]] +name = "ctor-proc-macro" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f211af61d8efdd104f96e57adf5e426ba1bc3ed7a4ead616e15e5881fd79c4d" + [[package]] name = "cts_runner" -version = "0.1.0" +version = "25.0.0" dependencies = [ "deno_console", "deno_core", @@ -921,21 +1002,22 @@ dependencies = [ "deno_web", "deno_webgpu", "deno_webidl", + "env_logger", "termcolor", "tokio", ] [[package]] name = "cursor-icon" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991" +checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f" [[package]] name = "data-encoding" -version = "2.7.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e60eed09d8c01d3cee5b7d30acb059b76614c918fa0f992e0dd6eeb10daad6f" +checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476" [[package]] name = "debugid" @@ -949,18 +1031,18 @@ dependencies = [ [[package]] name = "deno_console" -version = "0.190.0" +version = "0.192.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94352b8d75c288a26ef748ad0ddae07e181109374a02c547850f96eef76b5389" +checksum = "ca40d9ecd49a0320c058eff8ad8b53c83b1b743e3087001afe2e14ec50197d34" dependencies = [ "deno_core", ] [[package]] name = "deno_core" -version = "0.336.0" +version = "0.338.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdd50476c4325d5fa52bb906804a1e35b127d2a1dcf674e3447b53dcf25525bf" +checksum = "113f3f08bd5daf99f1a7876c0f99cd8c3c609439fa0b808311ec856a253e95f0" dependencies = [ "anyhow", "az", @@ -988,7 +1070,7 @@ dependencies = [ "smallvec", "sourcemap", "static_assertions", - "thiserror 2.0.11", + "thiserror 2.0.12", "tokio", "url", "v8", @@ -1028,9 +1110,9 @@ dependencies = [ [[package]] name = "deno_ops" -version = "0.212.0" +version = "0.214.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2d328067139909aa81522a5d90f119368b541fbddd73ab630e4d9f777865f0d" +checksum = "6ad885bf882be535f7714c713042129acba6f31a8efb5e6b2298f6e40cab9b16" dependencies = [ "indexmap", "proc-macro-rules", @@ -1040,27 +1122,27 @@ dependencies = [ "strum 0.25.0", "strum_macros 0.25.3", "syn", - "thiserror 2.0.11", + "thiserror 2.0.12", ] [[package]] name = "deno_path_util" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c87b8996966ae1b13ee9c20219b1d10fc53905b9570faae6adfa34614fd15224" +checksum = "c238a664a0a6f1ce0ff2b73c6854811526d00f442a12f878cb8555b23fe13aa3" dependencies = [ "deno_error", "percent-encoding", "sys_traits", - "thiserror 2.0.11", + "thiserror 2.0.12", "url", ] [[package]] name = "deno_permissions" -version = "0.49.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf879dff0b3de4dbcb78d6dda3a55e711369d5b9f479270a82853ef106c4176" +checksum = "a1ff15740ddc4626cc7f5d66a113e0f825073476d1e83af9fa693426516d07b7" dependencies = [ "capacity_builder 0.5.0", "deno_core", @@ -1073,16 +1155,16 @@ dependencies = [ "once_cell", "percent-encoding", "serde", - "thiserror 2.0.11", - "which", + "thiserror 2.0.12", + "which 6.0.3", "winapi", ] [[package]] name = "deno_terminal" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daef12499e89ee99e51ad6000a91f600d3937fb028ad4918af76810c5bc9e0d5" +checksum = "23f71c27009e0141dedd315f1dfa3ebb0a6ca4acce7c080fac576ea415a465f6" dependencies = [ "once_cell", "termcolor", @@ -1090,32 +1172,32 @@ dependencies = [ [[package]] name = "deno_unsync" -version = "0.4.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d774fd83f26b24f0805a6ab8b26834a0d06ceac0db517b769b1e4633c96a2057" +checksum = "6742a724e8becb372a74c650a1aefb8924a5b8107f7d75b3848763ea24b27a87" dependencies = [ - "futures", + "futures-util", "parking_lot", "tokio", ] [[package]] name = "deno_url" -version = "0.190.0" +version = "0.192.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d79e743ad841f7826d46c6944580f5ba665fe9ab4c31a68c4eed8b5a78225da3" +checksum = "36a705094c7fbbb01338e89c12367da939cf831dd5b202e3a521f75a614a6082" dependencies = [ "deno_core", "deno_error", - "thiserror 2.0.11", + "thiserror 2.0.12", "urlpattern", ] [[package]] name = "deno_web" -version = "0.221.0" +version = "0.224.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8041ba73bb2f238c61b5e4ed341d2fe1f9464a71115a240ab3390480b3c10e12" +checksum = "0ae1ba442b2c4b6116eb75e6e46968840693f2036d035bd45421c4a9beda6186" dependencies = [ "async-trait", "base64-simd 0.8.0", @@ -1127,7 +1209,7 @@ dependencies = [ "flate2", "futures", "serde", - "thiserror 2.0.11", + "thiserror 2.0.12", "tokio", "uuid", ] @@ -1143,7 +1225,7 @@ dependencies = [ "raw-window-handle 0.6.2", "serde", "serde_json", - "thiserror 2.0.11", + "thiserror 2.0.12", "tokio", "wgpu-core", "wgpu-types", @@ -1151,9 +1233,9 @@ dependencies = [ [[package]] name = "deno_webidl" -version = "0.190.0" +version = "0.192.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4ff81a990196bf3a80fe5d339b4eb8b411ef17634d60d399a63bae6e71a37c9" +checksum = "30d2d820d865651e0ce4eca898176577c8693bf2694af32545ab4b9ffb9934fa" dependencies = [ "deno_core", ] @@ -1203,9 +1285,9 @@ dependencies = [ [[package]] name = "document-features" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6969eaabd2421f8a2775cfd2471a2b634372b4a25d41e3bd647b79912850a0" +checksum = "95249b50c6c185bee49034bcb378a49dc2b5dff0be90ff6616d31d64febab05d" dependencies = [ "litrs", ] @@ -1218,48 +1300,69 @@ checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" [[package]] name = "dpi" -version = "0.1.1" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76" + +[[package]] +name = "dtor" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97cbdf2ad6846025e8e25df05171abfb30e3ababa12ee0a0e44b9bbe570633a8" +dependencies = [ + "dtor-proc-macro", +] + +[[package]] +name = "dtor-proc-macro" +version = "0.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f25c0e292a7ca6d6498557ff1df68f32c99850012b6ea401cf8daf771f22ff53" +checksum = "7454e41ff9012c00d53cf7f475c5e3afa3b91b7c90568495495e8d9bf47a1055" [[package]] name = "either" -version = "1.13.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "encase" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0a05902cf601ed11d564128448097b98ebe3c6574bd7b6a653a3d56d54aa020" +checksum = "6257b506d94265d4ec55a02fc6fe8a7311c1718e99cd5d2fc63c76674a94c801" dependencies = [ "const_panic", "encase_derive", "glam", - "thiserror 1.0.69", + "thiserror 2.0.12", ] [[package]] name = "encase_derive" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "181d475b694e2dd56ae919ce7699d344d1fd259292d590c723a50d1189a2ea85" +checksum = "71a9aa6b6a1caf2d2e04e4adcee9c8466e86cd84129bd8e9d15bad2b003396af" dependencies = [ "encase_derive_impl", ] [[package]] name = "encase_derive_impl" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f97b51c5cc57ef7c5f7a0c57c250251c49ee4c28f819f87ac32f4aceabc36792" +checksum = "a0a79c61182bf68a5dff807c3feb93d5348310afdb3fbe4c907db0e1696f500f" dependencies = [ "proc-macro2", "quote", "syn", ] +[[package]] +name = "encode_unicode" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" + [[package]] name = "encoding_rs" version = "0.8.33" @@ -1279,33 +1382,49 @@ dependencies = [ "regex", ] +[[package]] +name = "env_home" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f84e12ccf0a7ddc17a6c41c93326024c42920d7ee630d04950e6926645c0fe" + [[package]] name = "env_logger" -version = "0.11.6" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcaee3d8e3cfc3fd92428d477bc97fc29ec8716d180c0d74c643bb26166660e0" +checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f" dependencies = [ "anstream", "anstyle", "env_filter", - "humantime", + "jiff", "log", ] [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "erased-serde" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "e004d887f51fcb9fef17317a2f3525c887d8aa3f4f50fed920816a688284a5b7" +dependencies = [ + "serde", + "typeid", +] [[package]] name = "errno" -version = "0.3.10" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -1352,12 +1471,12 @@ checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" [[package]] name = "flate2" -version = "1.0.35" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" +checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" dependencies = [ "crc32fast", - "miniz_oxide 0.8.3", + "miniz_oxide 0.8.9", ] [[package]] @@ -1368,10 +1487,16 @@ checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" dependencies = [ "futures-core", "futures-sink", - "nanorand", + "nanorand 0.7.0", "spin", ] +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + [[package]] name = "foreign-types" version = "0.5.0" @@ -1534,15 +1659,16 @@ dependencies = [ [[package]] name = "generator" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc6bd114ceda131d3b1d665eba35788690ad37f5916457286b32ab6fd3c438dd" +checksum = "d18470a76cb7f8ff746cf1f7470914f900252ec36bbc40b569d74b1258446827" dependencies = [ + "cc", "cfg-if", "libc", "log", "rustversion", - "windows", + "windows 0.61.3", ] [[package]] @@ -1557,17 +1683,29 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" dependencies = [ "cfg-if", "js-sys", "libc", - "wasi", + "wasi 0.11.1+wasi-snapshot-preview1", "wasm-bindgen", ] +[[package]] +name = "getrandom" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", +] + [[package]] name = "gimli" version = "0.31.1" @@ -1587,9 +1725,9 @@ dependencies = [ [[package]] name = "glam" -version = "0.29.2" +version = "0.30.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc46dd3ec48fdd8e693a98d2b8bafae273a2d54c1de02a2a7e3d57d501f39677" +checksum = "50a99dbe56b72736564cfa4b85bf9a33079f16ae8b74983ab06af3b1a3696b11" dependencies = [ "bytemuck", ] @@ -1618,10 +1756,10 @@ version = "0.31.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18fcd4ae4e86d991ad1300b8f57166e5be0c95ef1f63f3f5b827f8a164548746" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "cfg_aliases 0.1.1", "cgl", - "core-foundation", + "core-foundation 0.9.4", "dispatch", "glutin_egl_sys", "glutin_wgl_sys 0.5.0", @@ -1681,7 +1819,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "gpu-alloc-types", ] @@ -1691,7 +1829,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", ] [[package]] @@ -1703,16 +1841,16 @@ dependencies = [ "log", "presser", "thiserror 1.0.69", - "windows", + "windows 0.58.0", ] [[package]] name = "gpu-descriptor" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c08c1f623a8d0b722b8b99f821eb0ba672a1618f0d3b16ddbee1cedd2dd8557" +checksum = "b89c83349105e3732062a895becfc71a8f921bb71ecbbdd8ff99263e3b53a0ca" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "gpu-descriptor-types", "hashbrown", ] @@ -1723,7 +1861,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdf242682df893b86f33a73828fb09ca4b2d3bb6cc95249707fc684d27484b91" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", ] [[package]] @@ -1737,22 +1875,27 @@ dependencies = [ [[package]] name = "half" -version = "2.4.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" +checksum = "459196ed295495a68f7d7fe1d84f6c4b7ff0e21fe3017b2f283c6fac3ad803c9" dependencies = [ + "arbitrary", + "bytemuck", "cfg-if", "crunchy", + "num-traits", + "serde", ] [[package]] name = "hashbrown" -version = "0.14.5" +version = "0.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" dependencies = [ - "ahash", "allocator-api2", + "equivalent", + "foldhash", "serde", ] @@ -1770,9 +1913,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" -version = "0.4.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" [[package]] name = "hexf-parse" @@ -1782,7 +1925,7 @@ checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" [[package]] name = "hlsl-snapshots" -version = "0.1.0" +version = "25.0.0" dependencies = [ "anyhow", "nanoserde", @@ -1797,12 +1940,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "icrate" version = "0.0.4" @@ -1816,21 +1953,22 @@ dependencies = [ [[package]] name = "icu_collections" -version = "1.5.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47" dependencies = [ "displaydoc", + "potential_utf", "yoke", "zerofrom", "zerovec", ] [[package]] -name = "icu_locid" -version = "1.5.0" +name = "icu_locale_core" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a" dependencies = [ "displaydoc", "litemap", @@ -1839,31 +1977,11 @@ dependencies = [ "zerovec", ] -[[package]] -name = "icu_locid_transform" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_locid_transform_data", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_locid_transform_data" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" - [[package]] name = "icu_normalizer" -version = "1.5.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979" dependencies = [ "displaydoc", "icu_collections", @@ -1871,67 +1989,54 @@ dependencies = [ "icu_properties", "icu_provider", "smallvec", - "utf16_iter", - "utf8_iter", - "write16", "zerovec", ] [[package]] name = "icu_normalizer_data" -version = "1.5.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" +checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3" [[package]] name = "icu_properties" -version = "1.5.1" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +checksum = "016c619c1eeb94efb86809b015c58f479963de65bdb6253345c1a1276f22e32b" dependencies = [ "displaydoc", "icu_collections", - "icu_locid_transform", + "icu_locale_core", "icu_properties_data", "icu_provider", - "tinystr", + "potential_utf", + "zerotrie", "zerovec", ] [[package]] name = "icu_properties_data" -version = "1.5.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" +checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632" [[package]] name = "icu_provider" -version = "1.5.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af" dependencies = [ "displaydoc", - "icu_locid", - "icu_provider_macros", + "icu_locale_core", "stable_deref_trait", "tinystr", "writeable", "yoke", "zerofrom", + "zerotrie", "zerovec", ] -[[package]] -name = "icu_provider_macros" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "idna" version = "1.0.3" @@ -1945,9 +2050,9 @@ dependencies = [ [[package]] name = "idna_adapter" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" dependencies = [ "icu_normalizer", "icu_properties", @@ -1961,22 +2066,21 @@ checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" [[package]] name = "image" -version = "0.24.9" +version = "0.25.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" +checksum = "db35664ce6b9810857a38a906215e75a9c879f0696556a39f59c62829710251a" dependencies = [ "bytemuck", - "byteorder", - "color_quant", + "byteorder-lite", "num-traits", "png", ] [[package]] name = "indexmap" -version = "2.5.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" dependencies = [ "arbitrary", "equivalent", @@ -1985,14 +2089,16 @@ dependencies = [ ] [[package]] -name = "is-terminal" -version = "0.4.15" +name = "indicatif" +version = "0.17.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19b23d53f35ce9f56aebc7d1bb4e6ac1e9c0db7ac85c8d1760c04379edced37" +checksum = "183b3088984b400f4cfac3620d5e076c84da5364016b4f49473de574b2586235" dependencies = [ - "hermit-abi", - "libc", - "windows-sys 0.59.0", + "console", + "number_prefix", + "portable-atomic", + "unicode-width", + "web-time 1.1.0", ] [[package]] @@ -2019,11 +2125,44 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + [[package]] name = "itoa" -version = "1.0.14" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "jiff" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be1f93b8b1eb69c77f24bbb0afdf66f54b632ee39af40ca21c4365a1d7347e49" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde", +] + +[[package]] +name = "jiff-static" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +checksum = "03343451ff899767262ec32146f6d559dd759fdadf42ff0e227c7c48f72594b4" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "jni" @@ -2049,10 +2188,11 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "jobserver" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a" dependencies = [ + "getrandom 0.3.3", "libc", ] @@ -2085,11 +2225,11 @@ checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" [[package]] name = "ktx2" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87d65e08a9ec02e409d27a0139eaa6b9756b4d81fe7cde71f6941a83730ce838" +checksum = "ff7f53bdf698e7aa7ec916411bbdc8078135da11b66db5182675b2227f6c0d07" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.9.1", ] [[package]] @@ -2100,9 +2240,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.169" +version = "0.2.174" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" [[package]] name = "libfuzzer-sys" @@ -2117,23 +2257,29 @@ dependencies = [ [[package]] name = "libloading" -version = "0.8.6" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" +checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" dependencies = [ "cfg-if", - "windows-targets 0.52.6", + "windows-targets 0.53.2", ] +[[package]] +name = "libm" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" + [[package]] name = "libredox" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +checksum = "1580801010e535496706ba011c15f8532df6b42297d2e471fec38ceadd8c0638" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "libc", - "redox_syscall 0.5.8", + "redox_syscall 0.5.13", ] [[package]] @@ -2154,11 +2300,17 @@ version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" +[[package]] +name = "linux-raw-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + [[package]] name = "litemap" -version = "0.7.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" +checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" [[package]] name = "litrs" @@ -2168,7 +2320,7 @@ checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" [[package]] name = "lock-analyzer" -version = "24.0.0" +version = "25.0.0" dependencies = [ "anyhow", "ron", @@ -2177,9 +2329,9 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" dependencies = [ "autocfg", "scopeguard", @@ -2187,9 +2339,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.25" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "loom" @@ -2230,9 +2382,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "memmap2" @@ -2254,13 +2406,13 @@ dependencies = [ [[package]] name = "metal" -version = "0.31.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f569fb946490b5743ad69813cb19629130ce9374034abe31614a36402d18f99e" +checksum = "00c15a6f673ff72ddcc22394663290f870fb224c1bfce55734a75c414150e605" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "block", - "core-graphics-types", + "core-graphics-types 0.2.0", "foreign-types", "log", "objc", @@ -2294,9 +2446,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.8.3" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ "adler2", "simd-adler32", @@ -2304,49 +2456,55 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" dependencies = [ "libc", - "wasi", - "windows-sys 0.52.0", + "wasi 0.11.1+wasi-snapshot-preview1", + "windows-sys 0.59.0", ] [[package]] name = "naga" -version = "24.0.0" +version = "25.0.0" dependencies = [ "arbitrary", "arrayvec", "bit-set 0.8.0", - "bitflags 2.8.0", + "bitflags 2.9.1", + "cfg-if", "cfg_aliases 0.2.1", "codespan-reporting", "diff", "env_logger", + "half", "hashbrown", "hexf-parse", "hlsl-snapshots", "indexmap", - "itertools 0.13.0", + "itertools 0.14.0", + "libm", "log", - "petgraph 0.7.1", + "num-traits", + "once_cell", + "petgraph 0.8.2", "pp-rs", "ron", "rspirv", "rustc-hash", "serde", "spirv 0.3.0+sdk-1.3.268.0", - "strum 0.26.3", - "termcolor", - "thiserror 2.0.11", - "unicode-xid", + "strum 0.27.1", + "thiserror 2.0.12", + "toml", + "unicode-ident", + "walkdir", ] [[package]] name = "naga-cli" -version = "24.0.0" +version = "25.0.0" dependencies = [ "anyhow", "argh", @@ -2359,7 +2517,7 @@ dependencies = [ [[package]] name = "naga-fuzz" -version = "0.0.0" +version = "25.0.0" dependencies = [ "arbitrary", "cfg_aliases 0.2.1", @@ -2367,29 +2525,52 @@ dependencies = [ "naga", ] +[[package]] +name = "naga-xtask" +version = "0.1.0" +dependencies = [ + "anyhow", + "env_logger", + "glob", + "hlsl-snapshots", + "indicatif", + "jobserver", + "log", + "num_cpus", + "pico-args", + "shell-words", + "which 8.0.0", +] + [[package]] name = "nanorand" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" dependencies = [ - "getrandom", + "getrandom 0.2.16", ] +[[package]] +name = "nanorand" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e3d189da485332e96ba8a5ef646a311871abd7915bf06ac848a9117f19cf6e4" + [[package]] name = "nanoserde" -version = "0.1.37" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de9cf844ab1e25a0353525bd74cb889843a6215fa4a0d156fd446f4857a1b99" +checksum = "a36fb3a748a4c9736ed7aeb5f2dfc99665247f1ce306abbddb2bf0ba2ac530a4" dependencies = [ "nanoserde-derive", ] [[package]] name = "nanoserde-derive" -version = "0.1.22" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e943b2c21337b7e3ec6678500687cdc741b7639ad457f234693352075c082204" +checksum = "a846cbc04412cf509efcd8f3694b114fc700a035fb5a37f21517f9fb019f1ebc" [[package]] name = "ndk" @@ -2397,7 +2578,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "jni-sys", "log", "ndk-sys 0.5.0+25.2.9519653", @@ -2413,7 +2594,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "jni-sys", "log", "ndk-sys 0.6.0+11769913", @@ -2504,22 +2685,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", + "libm", +] + +[[package]] +name = "num_cpus" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" +dependencies = [ + "hermit-abi", + "libc", ] [[package]] name = "num_enum" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179" +checksum = "a973b4e44ce6cad84ce69d797acf9a044532e4184c4f267913d1b546a0727b7a" dependencies = [ "num_enum_derive", + "rustversion", ] [[package]] name = "num_enum_derive" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" +checksum = "77e878c846a8abae00dd069496dbe8751b16ac1c3d6bd2a7283a938e8228f90d" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2527,6 +2720,12 @@ dependencies = [ "syn", ] +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + [[package]] name = "nv-flip" version = "0.1.2" @@ -2592,7 +2791,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "block2 0.5.1", "libc", "objc2 0.5.2", @@ -2608,7 +2807,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "block2 0.5.1", "objc2 0.5.2", "objc2-core-location", @@ -2632,7 +2831,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation", @@ -2680,7 +2879,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "block2 0.5.1", "dispatch", "libc", @@ -2705,7 +2904,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation", @@ -2717,7 +2916,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation", @@ -2740,7 +2939,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "block2 0.5.1", "objc2 0.5.2", "objc2-cloud-kit", @@ -2772,7 +2971,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "block2 0.5.1", "objc2 0.5.2", "objc2-core-location", @@ -2790,15 +2989,21 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.3" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" [[package]] name = "oorandom" -version = "11.1.4" +version = "11.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" +checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" [[package]] name = "orbclient" @@ -2811,9 +3016,18 @@ dependencies = [ [[package]] name = "ordered-float" -version = "4.6.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951" +checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" +dependencies = [ + "num-traits", +] + +[[package]] +name = "ordered-float" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2c1f9f56e534ac6a9b8a4600bdf0f530fb393b5f393e7b4d03489c3cf0c3f01" dependencies = [ "num-traits", ] @@ -2853,9 +3067,9 @@ checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" [[package]] name = "parking_lot" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" dependencies = [ "lock_api", "parking_lot_core", @@ -2863,15 +3077,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.10" +version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" dependencies = [ "backtrace", "cfg-if", "libc", "petgraph 0.6.5", - "redox_syscall 0.5.8", + "redox_syscall 0.5.13", "smallvec", "thread-id", "windows-targets 0.52.6", @@ -2901,11 +3115,12 @@ dependencies = [ [[package]] name = "petgraph" -version = "0.7.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" +checksum = "54acf3a685220b533e437e264e4d932cfbdc4cc7ec0cd232ed73c08d03b8a7ca" dependencies = [ "fixedbitset 0.5.7", + "hashbrown", "indexmap", ] @@ -2917,18 +3132,18 @@ checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" [[package]] name = "pin-project" -version = "1.1.8" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e2ec53ad785f4d35dac0adea7f7dc6f1bb277ad84a680c7afefeae05d1f5916" +checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.8" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56a66c0c55993aa927429d0f8a0abfd74f084e4d9c192cffed01e418d83eefb" +checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", @@ -2949,13 +3164,13 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "player" -version = "24.0.0" +version = "25.0.0" dependencies = [ "env_logger", "log", @@ -3005,20 +3220,20 @@ dependencies = [ "crc32fast", "fdeflate", "flate2", - "miniz_oxide 0.8.3", + "miniz_oxide 0.8.9", ] [[package]] name = "polling" -version = "3.7.4" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a604568c3202727d1507653cb121dbd627a58684eb09a820fd746bee38b4442f" +checksum = "b53a684391ad002dd6a596ceb6c74fd004fdce75f4be2e3f615068abbea5fd50" dependencies = [ "cfg-if", "concurrent-queue", "hermit-abi", "pin-project-lite", - "rustix", + "rustix 1.0.7", "tracing", "windows-sys 0.59.0", ] @@ -3028,6 +3243,44 @@ name = "pollster" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f3a9f18d041e6d0e102a0a46750538147e5e8992d3b4873aaafee2520b00ce3" +dependencies = [ + "pollster-macro", +] + +[[package]] +name = "pollster-macro" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac5da421106a50887c5b51d20806867db377fbb86bacf478ee0500a912e0c113" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "portable-atomic" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" + +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "potential_utf" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5a7c30837279ca13e7c867e9e40053bc68740f988cb07f7ca6df43cc734b585" +dependencies = [ + "zerovec", +] [[package]] name = "pp-rs" @@ -3046,9 +3299,9 @@ checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" [[package]] name = "prettyplease" -version = "0.2.29" +version = "0.2.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6924ced06e1f7dfe3fa48d57b9f74f55d8915f5036121bef647ef4b204895fac" +checksum = "061c1221631e079b26479d25bbf2275bfe5917ae8419cd7e34f13bfc2aa7539a" dependencies = [ "proc-macro2", "syn", @@ -3056,9 +3309,9 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" +checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" dependencies = [ "toml_edit", ] @@ -3088,37 +3341,43 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.93" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] [[package]] name = "profiling" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afbdc74edc00b6f6a218ca6a5364d6226a259d4b8ea1af4a0ea063f27e179f4d" +checksum = "3eb8486b569e12e2c32ad3e204dbaba5e4b5b216e9367044f25f1dba42341773" [[package]] name = "quick-xml" -version = "0.37.2" +version = "0.37.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "165859e9e55f79d67b96c5d96f4e88b6f2695a1972849c15a6a3f5c59fc2c003" +checksum = "331e97a1af0bf59823e6eadffe373d7b27f485be8748f71471c662c1f269b7fb" dependencies = [ "memchr", ] [[package]] name = "quote" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + [[package]] name = "radium" version = "0.7.0" @@ -3207,11 +3466,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.8" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" +checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", ] [[package]] @@ -3246,6 +3505,12 @@ dependencies = [ "regex-syntax 0.8.5", ] +[[package]] +name = "regex-lite" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" + [[package]] name = "regex-syntax" version = "0.6.29" @@ -3266,14 +3531,15 @@ checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" [[package]] name = "ron" -version = "0.8.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" +checksum = "beceb6f7bf81c73e73aeef6dd1356d9a1b2b4909e1f0fc3e59b034f9572d7b7f" dependencies = [ "base64", - "bitflags 2.8.0", + "bitflags 2.9.1", "serde", "serde_derive", + "unicode-ident", ] [[package]] @@ -3293,9 +3559,9 @@ checksum = "a157657054ffe556d8858504af8a672a054a6e0bd9e8ee531059100c0fa11bb2" [[package]] name = "rustc-demangle" -version = "0.1.24" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f" [[package]] name = "rustc-hash" @@ -3309,7 +3575,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" dependencies = [ - "semver", + "semver 0.9.0", ] [[package]] @@ -3318,24 +3584,37 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "errno", "libc", - "linux-raw-sys", + "linux-raw-sys 0.4.15", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustix" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" +dependencies = [ + "bitflags 2.9.1", + "errno", + "libc", + "linux-raw-sys 0.9.4", "windows-sys 0.59.0", ] [[package]] name = "rustversion" -version = "1.0.19" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" +checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" [[package]] name = "ryu" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "same-file" @@ -3393,6 +3672,15 @@ dependencies = [ "semver-parser", ] +[[package]] +name = "semver" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" +dependencies = [ + "serde", +] + [[package]] name = "semver-parser" version = "0.7.0" @@ -3401,18 +3689,39 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.217" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] +[[package]] +name = "serde-untagged" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "299d9c19d7d466db4ab10addd5703e4c615dec2a5a16dbbafe191045e87ee66e" +dependencies = [ + "erased-serde", + "serde", + "typeid", +] + +[[package]] +name = "serde-value" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" +dependencies = [ + "ordered-float 2.10.1", + "serde", +] + [[package]] name = "serde_derive" -version = "1.0.217" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", @@ -3421,9 +3730,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.138" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "indexmap", "itoa", @@ -3434,24 +3743,24 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.8" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" dependencies = [ "serde", ] [[package]] name = "serde_v8" -version = "0.245.0" +version = "0.247.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "945f93c91e0c7e4799b5fefff076756141aae92e262c4dc4833310dd3d2d845e" +checksum = "12bbfafb7b707cbed49d1eaf48f4aa41b5ff57f813d1a80f77244e6e2fa4507e" dependencies = [ "deno_error", "num-bigint", "serde", "smallvec", - "thiserror 2.0.11", + "thiserror 2.0.12", "v8", ] @@ -3464,6 +3773,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shell-words" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" + [[package]] name = "shlex" version = "1.3.0" @@ -3472,9 +3787,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.2" +version = "1.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" dependencies = [ "libc", ] @@ -3496,12 +3811,9 @@ checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" [[package]] name = "slab" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] +checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d" [[package]] name = "slotmap" @@ -3514,9 +3826,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.2" +version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "smithay-client-toolkit" @@ -3524,14 +3836,14 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "922fd3eeab3bd820d76537ce8f582b1cf951eceb5475c28500c7457d9d17f53a" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "calloop 0.12.4", "calloop-wayland-source 0.2.0", "cursor-icon", "libc", "log", "memmap2", - "rustix", + "rustix 0.38.44", "thiserror 1.0.69", "wayland-backend", "wayland-client", @@ -3549,21 +3861,21 @@ version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "calloop 0.13.0", "calloop-wayland-source 0.3.0", "cursor-icon", "libc", "log", "memmap2", - "rustix", + "rustix 0.38.44", "thiserror 1.0.69", "wayland-backend", "wayland-client", "wayland-csd-frame", "wayland-cursor", - "wayland-protocols 0.32.5", - "wayland-protocols-wlr 0.3.5", + "wayland-protocols 0.32.8", + "wayland-protocols-wlr 0.3.8", "wayland-scanner", "xkeysym", ] @@ -3579,9 +3891,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.8" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" dependencies = [ "libc", "windows-sys 0.52.0", @@ -3629,7 +3941,7 @@ version = "0.3.0+sdk-1.3.268.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "serde", ] @@ -3674,11 +3986,11 @@ dependencies = [ [[package]] name = "strum" -version = "0.26.3" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +checksum = "f64def088c51c9510a8579e3c5d67c65349dcf755e5479ad3d010aa6454e2c32" dependencies = [ - "strum_macros 0.26.4", + "strum_macros 0.27.1", ] [[package]] @@ -3696,9 +4008,9 @@ dependencies = [ [[package]] name = "strum_macros" -version = "0.26.4" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +checksum = "c77a8c5abcaf0f9ce05d62342b7d298c346515365c36b673df4ebe3ced01fde8" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -3709,9 +4021,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.98" +version = "2.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" dependencies = [ "proc-macro2", "quote", @@ -3720,9 +4032,9 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", @@ -3731,9 +4043,23 @@ dependencies = [ [[package]] name = "sys_traits" -version = "0.1.8" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "638f0e61b5134e56b2abdf4c704fd44672603f15ca09013f314649056f3fee4d" +checksum = "dc4707edf3196e8037ee45018d1bb1bfb233b0e4fc440fa3d3f25bc69bfdaf26" +dependencies = [ + "sys_traits_macros", +] + +[[package]] +name = "sys_traits_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "181f22127402abcf8ee5c83ccd5b408933fec36a6095cf82cda545634692657e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "tap" @@ -3743,9 +4069,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-triple" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a4d50cdb458045afc8131fd91b64904da29548bcb63c7236e0844936c13078" +checksum = "1ac9aa371f599d22256307c24a9d748c041e548cbf599f35d890f9d365361790" [[package]] name = "termcolor" @@ -3767,11 +4093,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ - "thiserror-impl 2.0.11", + "thiserror-impl 2.0.12", ] [[package]] @@ -3787,9 +4113,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", @@ -3808,12 +4134,11 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.1.8" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" dependencies = [ "cfg-if", - "once_cell", ] [[package]] @@ -3843,9 +4168,9 @@ dependencies = [ [[package]] name = "tinystr" -version = "0.7.6" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b" dependencies = [ "displaydoc", "zerovec", @@ -3863,9 +4188,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.43.0" +version = "1.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" +checksum = "75ef51a33ef1da925cea3e4eb122833cb377c61439ca401b770f54902b806779" dependencies = [ "backtrace", "bytes", @@ -3892,9 +4217,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.19" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" dependencies = [ "serde", "serde_spanned", @@ -3904,26 +4229,33 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.8" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.23" +version = "0.22.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02a8b472d1a3d7c18e2d61a489aee3453fd9031c33e4f55bd533f4a7adca1bee" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", + "toml_write", "winnow", ] +[[package]] +name = "toml_write" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" + [[package]] name = "tracing" version = "0.1.41" @@ -3936,9 +4268,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.33" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" dependencies = [ "once_cell", "valuable", @@ -3975,9 +4307,9 @@ dependencies = [ [[package]] name = "tracy-client" -version = "0.17.6" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73202d787346a5418f8222eddb5a00f29ea47caf3c7d38a8f2f69f8455fa7c7e" +checksum = "ef54005d3d760186fd662dad4b7bb27ecd5531cdef54d1573ebd3f20a9205ed7" dependencies = [ "loom", "once_cell", @@ -3986,9 +4318,9 @@ dependencies = [ [[package]] name = "tracy-client-sys" -version = "0.24.3" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69fff37da548239c3bf9e64a12193d261e8b22b660991c6fd2df057c168f435f" +checksum = "5f9612d9503675b07b244922ea6f6f3cdd88c43add1b3498084613fc88cdf69d" dependencies = [ "cc", "windows-targets 0.52.6", @@ -3996,9 +4328,9 @@ dependencies = [ [[package]] name = "trybuild" -version = "1.0.103" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b812699e0c4f813b872b373a4471717d9eb550da14b311058a4d9cf4173cbca6" +checksum = "1c9bf9513a2f4aeef5fdac8677d7d349c79fdbcc03b9c86da6e9d254f1e43be2" dependencies = [ "glob", "serde", @@ -4015,6 +4347,12 @@ version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" +[[package]] +name = "typeid" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" + [[package]] name = "unic-char-property" version = "0.9.0" @@ -4064,9 +4402,9 @@ checksum = "2f322b60f6b9736017344fa0635d64be2f458fbc04eef65f6be22976dd1ffd5b" [[package]] name = "unicode-ident" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "unicode-segmentation" @@ -4076,9 +4414,9 @@ checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" -version = "0.1.14" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +checksum = "4a1a07cc7db3810833284e8d372ccdc6da29741639ecc70c9ec107df0fa6154c" [[package]] name = "unicode-xid" @@ -4110,12 +4448,6 @@ dependencies = [ "url", ] -[[package]] -name = "utf16_iter" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" - [[package]] name = "utf8_iter" version = "1.0.4" @@ -4130,29 +4462,31 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.12.1" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3758f5e68192bb96cc8f9b7e2c2cfdabb435499a28499a42f8f984092adad4b" +checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d" dependencies = [ - "getrandom", + "getrandom 0.3.3", + "js-sys", "serde", + "wasm-bindgen", ] [[package]] name = "v8" -version = "130.0.7" +version = "134.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a511192602f7b435b0a241c1947aa743eb7717f20a9195f4b5e8ed1952e01db1" +checksum = "21c7a224a7eaf3f98c1bad772fbaee56394dce185ef7b19a2e0ca5e3d274165d" dependencies = [ "bindgen", - "bitflags 2.8.0", + "bitflags 2.9.1", "fslock", "gzip-header", "home", "miniz_oxide 0.7.4", "once_cell", "paste", - "which", + "which 6.0.3", ] [[package]] @@ -4185,9 +4519,18 @@ dependencies = [ [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] [[package]] name = "wasm-bindgen" @@ -4291,18 +4634,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eeee3bdea6257cc36d756fa745a70f9d393571e47d69e0ed97581676a5369ca" dependencies = [ "deno_error", - "thiserror 2.0.11", + "thiserror 2.0.12", ] [[package]] name = "wayland-backend" -version = "0.3.8" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7208998eaa3870dad37ec8836979581506e0c5c64c20c9e79e9d2a10d6f47bf" +checksum = "fe770181423e5fc79d3e2a7f4410b7799d5aab1de4372853de3c6aa13ca24121" dependencies = [ "cc", "downcast-rs", - "rustix", + "rustix 0.38.44", "scoped-tls", "smallvec", "wayland-sys", @@ -4310,12 +4653,12 @@ dependencies = [ [[package]] name = "wayland-client" -version = "0.31.7" +version = "0.31.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b66249d3fc69f76fd74c82cc319300faa554e9d865dab1f7cd66cc20db10b280" +checksum = "978fa7c67b0847dbd6a9f350ca2569174974cd4082737054dbb7fbb79d7d9a61" dependencies = [ - "bitflags 2.8.0", - "rustix", + "bitflags 2.9.1", + "rustix 0.38.44", "wayland-backend", "wayland-scanner", ] @@ -4326,18 +4669,18 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "cursor-icon", "wayland-backend", ] [[package]] name = "wayland-cursor" -version = "0.31.7" +version = "0.31.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b08bc3aafdb0035e7fe0fdf17ba0c09c268732707dca4ae098f60cb28c9e4c" +checksum = "a65317158dec28d00416cb16705934070aef4f8393353d41126c54264ae0f182" dependencies = [ - "rustix", + "rustix 0.38.44", "wayland-client", "xcursor", ] @@ -4348,7 +4691,7 @@ version = "0.31.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f81f365b8b4a97f422ac0e8737c438024b5951734506b0e1d775c73030561f4" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "wayland-backend", "wayland-client", "wayland-scanner", @@ -4356,11 +4699,11 @@ dependencies = [ [[package]] name = "wayland-protocols" -version = "0.32.5" +version = "0.32.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cd0ade57c4e6e9a8952741325c30bf82f4246885dca8bf561898b86d0c1f58e" +checksum = "779075454e1e9a521794fed15886323ea0feda3f8b0fc1390f5398141310422a" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "wayland-backend", "wayland-client", "wayland-scanner", @@ -4372,7 +4715,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23803551115ff9ea9bce586860c5c5a971e360825a0309264102a9495a5ff479" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "wayland-backend", "wayland-client", "wayland-protocols 0.31.2", @@ -4381,14 +4724,14 @@ dependencies = [ [[package]] name = "wayland-protocols-plasma" -version = "0.3.5" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b31cab548ee68c7eb155517f2212049dc151f7cd7910c2b66abfd31c3ee12bd" +checksum = "4fd38cdad69b56ace413c6bcc1fbf5acc5e2ef4af9d5f8f1f9570c0c83eae175" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "wayland-backend", "wayland-client", - "wayland-protocols 0.32.5", + "wayland-protocols 0.32.8", "wayland-scanner", ] @@ -4398,7 +4741,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad1f61b76b6c2d8742e10f9ba5c3737f6530b4c243132c2a2ccc8aa96fe25cd6" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "wayland-backend", "wayland-client", "wayland-protocols 0.31.2", @@ -4407,14 +4750,14 @@ dependencies = [ [[package]] name = "wayland-protocols-wlr" -version = "0.3.5" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "782e12f6cd923c3c316130d56205ebab53f55d6666b7faddfad36cecaeeb4022" +checksum = "1cb6cdc73399c0e06504c437fe3cf886f25568dd5454473d565085b36d6a8bbf" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "wayland-backend", "wayland-client", - "wayland-protocols 0.32.5", + "wayland-protocols 0.32.8", "wayland-scanner", ] @@ -4473,10 +4816,12 @@ dependencies = [ [[package]] name = "wgpu" -version = "24.0.0" +version = "25.0.0" dependencies = [ "arrayvec", - "bitflags 2.8.0", + "bitflags 2.9.1", + "bytemuck", + "cfg-if", "cfg_aliases 0.2.1", "document-features", "hashbrown", @@ -4484,9 +4829,9 @@ dependencies = [ "log", "naga", "parking_lot", + "portable-atomic", "profiling", "raw-window-handle 0.6.2", - "serde", "smallvec", "static_assertions", "wasm-bindgen", @@ -4499,13 +4844,13 @@ dependencies = [ [[package]] name = "wgpu-benchmark" -version = "24.0.0" +version = "25.0.0" dependencies = [ "bincode", "bytemuck", "criterion", "naga", - "nanorand", + "nanorand 0.8.0", "pollster", "profiling", "rayon", @@ -4515,11 +4860,12 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "24.0.0" +version = "25.0.0" dependencies = [ "arrayvec", + "bit-set 0.8.0", "bit-vec 0.8.0", - "bitflags 2.8.0", + "bitflags 2.9.1", "bytemuck", "cfg_aliases 0.2.1", "document-features", @@ -4529,17 +4875,50 @@ dependencies = [ "naga", "once_cell", "parking_lot", + "portable-atomic", "profiling", "raw-window-handle 0.6.2", "ron", "rustc-hash", "serde", "smallvec", - "thiserror 2.0.11", + "thiserror 2.0.12", + "wgpu-core-deps-apple", + "wgpu-core-deps-emscripten", + "wgpu-core-deps-wasm", + "wgpu-core-deps-windows-linux-android", "wgpu-hal", "wgpu-types", ] +[[package]] +name = "wgpu-core-deps-apple" +version = "25.0.0" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-core-deps-emscripten" +version = "25.0.0" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-core-deps-wasm" +version = "25.0.0" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-core-deps-windows-linux-android" +version = "25.0.0" +dependencies = [ + "wgpu-hal", +] + [[package]] name = "wgpu-example-01-hello-compute" version = "0.0.0" @@ -4557,12 +4936,20 @@ dependencies = [ "env_logger", "pollster", "wgpu", - "winit 0.30.8", + "winit 0.30.11", +] + +[[package]] +name = "wgpu-example-custom-backend" +version = "0.0.0" +dependencies = [ + "pollster", + "wgpu", ] [[package]] name = "wgpu-examples" -version = "24.0.0" +version = "25.0.0" dependencies = [ "bytemuck", "cfg-if", @@ -4572,11 +4959,10 @@ dependencies = [ "env_logger", "fern", "flume", - "getrandom", "glam", "ktx2", "log", - "nanorand", + "nanorand 0.8.0", "noise", "obj", "png", @@ -4588,23 +4974,24 @@ dependencies = [ "web-time 1.1.0", "wgpu", "wgpu-test", + "wgpu-types", "winit 0.29.15", ] [[package]] name = "wgpu-hal" -version = "24.0.0" +version = "25.0.0" dependencies = [ "android_system_properties", "arrayvec", "ash", "bit-set 0.8.0", - "bitflags 2.8.0", + "bitflags 2.9.1", "block", "bytemuck", "cfg-if", "cfg_aliases 0.2.1", - "core-graphics-types", + "core-graphics-types 0.2.0", "env_logger", "glam", "glow", @@ -4623,11 +5010,12 @@ dependencies = [ "mach-dxcompiler-rs", "metal", "naga", - "ndk-sys 0.5.0+25.2.9519653", + "ndk-sys 0.6.0+11769913", "objc", - "once_cell", - "ordered-float", + "ordered-float 5.0.0", "parking_lot", + "portable-atomic", + "portable-atomic-util", "profiling", "range-alloc", "raw-window-handle 0.5.2", @@ -4635,21 +5023,21 @@ dependencies = [ "renderdoc-sys", "rustc-hash", "smallvec", - "thiserror 2.0.11", + "thiserror 2.0.12", "wasm-bindgen", "web-sys", "wgpu-types", - "windows", - "windows-core", + "windows 0.58.0", + "windows-core 0.58.0", "winit 0.29.15", ] [[package]] name = "wgpu-info" -version = "24.0.0" +version = "25.0.0" dependencies = [ "anyhow", - "bitflags 2.8.0", + "bitflags 2.9.1", "env_logger", "hashbrown", "pico-args", @@ -4660,7 +5048,7 @@ dependencies = [ [[package]] name = "wgpu-macros" -version = "24.0.0" +version = "25.0.0" dependencies = [ "heck 0.5.0", "quote", @@ -4669,24 +5057,27 @@ dependencies = [ [[package]] name = "wgpu-test" -version = "24.0.0" +version = "25.0.0" dependencies = [ "anyhow", "approx", "arrayvec", - "bitflags 2.8.0", + "bitflags 2.9.1", "bytemuck", + "cargo_metadata", "cfg-if", "console_log", "ctor", "env_logger", "futures-lite", "glam", + "half", "image", - "itertools 0.13.0", + "itertools 0.14.0", "js-sys", "libtest-mimic", "log", + "nanorand 0.8.0", "nv-flip", "parking_lot", "png", @@ -4694,28 +5085,43 @@ dependencies = [ "profiling", "serde", "serde_json", - "strum 0.26.3", + "strum 0.27.1", "trybuild", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-test", "web-sys", "wgpu", + "wgpu-hal", "wgpu-macros", ] [[package]] name = "wgpu-types" -version = "24.0.0" +version = "25.0.0" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", + "bytemuck", "js-sys", "log", "serde", "serde_json", + "thiserror 2.0.12", "web-sys", ] +[[package]] +name = "wgpu-xtask" +version = "0.1.0" +dependencies = [ + "anyhow", + "env_logger", + "log", + "pico-args", + "regex-lite", + "xshell", +] + [[package]] name = "which" version = "6.0.3" @@ -4724,7 +5130,18 @@ checksum = "b4ee928febd44d98f2f459a4a79bd4d928591333a494a10a868418ac1b39cf1f" dependencies = [ "either", "home", - "rustix", + "rustix 0.38.44", + "winsafe", +] + +[[package]] +name = "which" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fabb953106c3c8eea8306e4393700d7657561cb43122571b172bbfb7c7ba1d" +dependencies = [ + "env_home", + "rustix 1.0.7", "winsafe", ] @@ -4765,23 +5182,69 @@ version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" dependencies = [ - "windows-core", + "windows-core 0.58.0", "windows-targets 0.52.6", ] +[[package]] +name = "windows" +version = "0.61.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" +dependencies = [ + "windows-collections", + "windows-core 0.61.2", + "windows-future", + "windows-link", + "windows-numerics", +] + +[[package]] +name = "windows-collections" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" +dependencies = [ + "windows-core 0.61.2", +] + [[package]] name = "windows-core" version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" dependencies = [ - "windows-implement", - "windows-interface", - "windows-result", - "windows-strings", + "windows-implement 0.58.0", + "windows-interface 0.58.0", + "windows-result 0.2.0", + "windows-strings 0.1.0", "windows-targets 0.52.6", ] +[[package]] +name = "windows-core" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +dependencies = [ + "windows-implement 0.60.0", + "windows-interface 0.59.1", + "windows-link", + "windows-result 0.3.4", + "windows-strings 0.4.2", +] + +[[package]] +name = "windows-future" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" +dependencies = [ + "windows-core 0.61.2", + "windows-link", + "windows-threading", +] + [[package]] name = "windows-implement" version = "0.58.0" @@ -4793,6 +5256,17 @@ dependencies = [ "syn", ] +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "windows-interface" version = "0.58.0" @@ -4804,6 +5278,33 @@ dependencies = [ "syn", ] +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[package]] +name = "windows-numerics" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" +dependencies = [ + "windows-core 0.61.2", + "windows-link", +] + [[package]] name = "windows-result" version = "0.2.0" @@ -4813,16 +5314,34 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link", +] + [[package]] name = "windows-strings" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" dependencies = [ - "windows-result", + "windows-result 0.2.0", "windows-targets 0.52.6", ] +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link", +] + [[package]] name = "windows-sys" version = "0.45.0" @@ -4859,6 +5378,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.2", +] + [[package]] name = "windows-targets" version = "0.42.2" @@ -4898,13 +5426,38 @@ dependencies = [ "windows_aarch64_gnullvm 0.52.6", "windows_aarch64_msvc 0.52.6", "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm", + "windows_i686_gnullvm 0.52.6", "windows_i686_msvc 0.52.6", "windows_x86_64_gnu 0.52.6", "windows_x86_64_gnullvm 0.52.6", "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows-targets" +version = "0.53.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c66f69fcc9ce11da9966ddb31a40968cad001c5bedeb5c2b82ede4253ab48aef" +dependencies = [ + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", +] + +[[package]] +name = "windows-threading" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6" +dependencies = [ + "windows-link", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" @@ -4923,6 +5476,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + [[package]] name = "windows_aarch64_msvc" version = "0.42.2" @@ -4941,6 +5500,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + [[package]] name = "windows_i686_gnu" version = "0.42.2" @@ -4959,12 +5524,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + [[package]] name = "windows_i686_msvc" version = "0.42.2" @@ -4983,6 +5560,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + [[package]] name = "windows_x86_64_gnu" version = "0.42.2" @@ -5001,6 +5584,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" @@ -5019,6 +5608,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + [[package]] name = "windows_x86_64_msvc" version = "0.42.2" @@ -5037,6 +5632,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + [[package]] name = "winit" version = "0.29.15" @@ -5046,11 +5647,11 @@ dependencies = [ "ahash", "android-activity 0.5.2", "atomic-waker", - "bitflags 2.8.0", + "bitflags 2.9.1", "bytemuck", "calloop 0.12.4", "cfg_aliases 0.1.1", - "core-foundation", + "core-foundation 0.9.4", "core-graphics", "cursor-icon", "icrate", @@ -5067,7 +5668,7 @@ dependencies = [ "raw-window-handle 0.5.2", "raw-window-handle 0.6.2", "redox_syscall 0.3.5", - "rustix", + "rustix 0.38.44", "sctk-adwaita 0.8.3", "smithay-client-toolkit 0.18.1", "smol_str", @@ -5088,20 +5689,20 @@ dependencies = [ [[package]] name = "winit" -version = "0.30.8" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5d74280aabb958072864bff6cfbcf9025cf8bfacdde5e32b5e12920ef703b0f" +checksum = "a4409c10174df8779dc29a4788cac85ed84024ccbc1743b776b21a520ee1aaf4" dependencies = [ "ahash", "android-activity 0.6.0", "atomic-waker", - "bitflags 2.8.0", + "bitflags 2.9.1", "block2 0.5.1", "bytemuck", "calloop 0.13.0", "cfg_aliases 0.2.1", "concurrent-queue", - "core-foundation", + "core-foundation 0.9.4", "core-graphics", "cursor-icon", "dpi", @@ -5118,7 +5719,7 @@ dependencies = [ "pin-project", "raw-window-handle 0.6.2", "redox_syscall 0.4.1", - "rustix", + "rustix 0.38.44", "sctk-adwaita 0.10.1", "smithay-client-toolkit 0.19.2", "smol_str", @@ -5128,8 +5729,8 @@ dependencies = [ "wasm-bindgen-futures", "wayland-backend", "wayland-client", - "wayland-protocols 0.32.5", - "wayland-protocols-plasma 0.3.5", + "wayland-protocols 0.32.8", + "wayland-protocols-plasma 0.3.8", "web-sys", "web-time 1.1.0", "windows-sys 0.52.0", @@ -5140,9 +5741,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.7.0" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e49d2d35d3fad69b39b94139037ecfb4f359f08958b9c11e7315ce770462419" +checksum = "74c7b26e3480b707944fc872477815d29a8e429d2f93a1ce000f5fa84a15cbcd" dependencies = [ "memchr", ] @@ -5154,16 +5755,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" [[package]] -name = "write16" -version = "1.0.0" +name = "wit-bindgen-rt" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags 2.9.1", +] [[package]] name = "writeable" -version = "0.5.5" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" +checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" [[package]] name = "wyz" @@ -5196,7 +5800,7 @@ dependencies = [ "libc", "libloading", "once_cell", - "rustix", + "rustix 0.38.44", "x11rb-protocol", ] @@ -5208,9 +5812,9 @@ checksum = "ec107c4503ea0b4a98ef47356329af139c0a4f7750e621cf2973cd3385ebcb3d" [[package]] name = "xcursor" -version = "0.3.8" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ef33da6b1660b4ddbfb3aef0ade110c8b8a781a3b6382fa5f2b5b040fd55f61" +checksum = "bec9e4a500ca8864c5b47b8b482a73d62e4237670e5b5f1d6b9e3cae50f28f2b" [[package]] name = "xkbcommon-dl" @@ -5218,7 +5822,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.1", "dlib", "log", "once_cell", @@ -5233,15 +5837,30 @@ checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56" [[package]] name = "xml-rs" -version = "0.8.25" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a62ce76d9b56901b19a74f19431b0d8b3bc7ca4ad685a746dfd78ca8f4fc6bda" + +[[package]] +name = "xshell" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e7290c623014758632efe00737145b6867b66292c42167f2ec381eb566a373d" +dependencies = [ + "xshell-macros", +] + +[[package]] +name = "xshell-macros" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5b940ebc25896e71dd073bad2dbaa2abfe97b0a391415e22ad1326d9c54e3c4" +checksum = "32ac00cd3f8ec9c1d33fb3e7958a82df6989c42d747bd326c822b1d625283547" [[package]] name = "yoke" -version = "0.7.5" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc" dependencies = [ "serde", "stable_deref_trait", @@ -5251,9 +5870,9 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.7.5" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" dependencies = [ "proc-macro2", "quote", @@ -5263,18 +5882,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.35" +version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.35" +version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" dependencies = [ "proc-macro2", "quote", @@ -5283,18 +5902,18 @@ dependencies = [ [[package]] name = "zerofrom" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", @@ -5302,11 +5921,22 @@ dependencies = [ "synstructure", ] +[[package]] +name = "zerotrie" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + [[package]] name = "zerovec" -version = "0.10.4" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +checksum = "4a05eb080e015ba39cc9e23bbe5e7fb04d5fb040350f99f34e338d5fdd294428" dependencies = [ "yoke", "zerofrom", @@ -5315,9 +5945,9 @@ dependencies = [ [[package]] name = "zerovec-derive" -version = "0.10.3" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" dependencies = [ "proc-macro2", "quote", From 8c6e887b67b60bc4e94b6cde907844dca6a1b225 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Mon, 7 Jul 2025 12:33:56 -0500 Subject: [PATCH 15/84] Dusted off this ancient PR --- naga/src/back/pipeline_constants.rs | 1 - naga/src/back/spv/block.rs | 3 +- naga/src/back/spv/writer.rs | 4 +- naga/src/back/wgsl/writer.rs | 1 - naga/src/common/wgsl/to_wgsl.rs | 6 +- .../wgsl/parse/directive/enable_extension.rs | 10 +- naga/src/ir/mod.rs | 71 +- naga/src/lib.rs | 2235 ----------------- naga/src/proc/terminator.rs | 1 + naga/src/valid/function.rs | 3 +- naga/src/valid/interface.rs | 1 - 11 files changed, 80 insertions(+), 2256 deletions(-) diff --git a/naga/src/back/pipeline_constants.rs b/naga/src/back/pipeline_constants.rs index 057bc0f0e28..85a1afe0d42 100644 --- a/naga/src/back/pipeline_constants.rs +++ b/naga/src/back/pipeline_constants.rs @@ -855,7 +855,6 @@ fn adjust_stmt(new_pos: &HandleVec>, stmt: &mut S adjust(index); adjust(value); } - Statement::Break | Statement::Continue | Statement::Kill | Statement::Barrier(_) => {} Statement::Break | Statement::Continue | Statement::Kill diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index f8c0c331324..ccad1f540ea 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -3631,7 +3631,8 @@ impl BlockContext<'_> { primitive_count, }) => { let mut ins = Instruction::new(spirv::Op::SetMeshOutputsEXT); - ins.operands = vec![self.cached[vertex_count], self.cached[primitive_count]]; + ins.operands = + alloc::vec![self.cached[vertex_count], self.cached[primitive_count]]; block.body.push(ins); } Statement::MeshFunction( diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 56e0a301b23..c4a9da3514d 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -1211,13 +1211,13 @@ impl Writer { Instruction::execution_mode( function_id, spirv::ExecutionMode::OutputVertices, - std::slice::from_ref(&mesh_info.max_vertices), + core::slice::from_ref(&mesh_info.max_vertices), ) .to_words(&mut self.logical_layout.execution_modes); Instruction::execution_mode( function_id, spirv::ExecutionMode::OutputPrimitivesEXT, - std::slice::from_ref(&mesh_info.max_primitives), + core::slice::from_ref(&mesh_info.max_primitives), ) .to_words(&mut self.logical_layout.execution_modes); spirv::ExecutionModel::MeshEXT diff --git a/naga/src/back/wgsl/writer.rs b/naga/src/back/wgsl/writer.rs index 1d206454c6a..b6979a04b5d 100644 --- a/naga/src/back/wgsl/writer.rs +++ b/naga/src/back/wgsl/writer.rs @@ -190,7 +190,6 @@ impl Writer { Attribute::Stage(ep.stage), Attribute::WorkGroupSize(ep.workgroup_size), ], - ShaderStage::Task | ShaderStage::Mesh => unreachable!(), }; self.write_attributes(&attributes)?; diff --git a/naga/src/common/wgsl/to_wgsl.rs b/naga/src/common/wgsl/to_wgsl.rs index 035c4eafb32..f85d90ed232 100644 --- a/naga/src/common/wgsl/to_wgsl.rs +++ b/naga/src/common/wgsl/to_wgsl.rs @@ -188,7 +188,10 @@ impl TryToWgsl for crate::BuiltIn { | Bi::PointSize | Bi::DrawID | Bi::PointCoord - | Bi::WorkGroupSize => return None, + | Bi::WorkGroupSize + | Bi::CullPrimitive + | Bi::TriangleIndices + | Bi::LineIndices => return None, }) } } @@ -352,6 +355,7 @@ pub const fn address_space_str( As::WorkGroup => "workgroup", As::Handle => return (None, None), As::Function => "function", + As::TaskPayload => return (None, None), }), None, ) diff --git a/naga/src/front/wgsl/parse/directive/enable_extension.rs b/naga/src/front/wgsl/parse/directive/enable_extension.rs index 2d3da113bf7..5df212286aa 100644 --- a/naga/src/front/wgsl/parse/directive/enable_extension.rs +++ b/naga/src/front/wgsl/parse/directive/enable_extension.rs @@ -86,7 +86,6 @@ impl EnableExtension { Self::Implemented(ImplementedEnableExtension::DualSourceBlending) } Self::MESH_SHADER => Self::Implemented(ImplementedEnableExtension::MeshShader), - _ => return Err(Error::UnknownEnableExtension(span, word)), Self::SUBGROUPS => Self::Unimplemented(UnimplementedEnableExtension::Subgroups), _ => return Err(Box::new(Error::UnknownEnableExtension(span, word))), }) @@ -111,13 +110,6 @@ impl EnableExtension { /// A variant of [`EnableExtension::Implemented`]. #[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)] pub enum ImplementedEnableExtension { - /// Enables the `mesh_shader` extension, native only - MeshShader, -} - -/// A variant of [`EnableExtension::Unimplemented`]. -#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)] -pub enum UnimplementedEnableExtension { /// Enables `f16`/`half` primitive support in all shader languages. /// /// In the WGSL standard, this corresponds to [`enable f16;`]. @@ -136,6 +128,8 @@ pub enum UnimplementedEnableExtension { /// /// [`enable clip_distances;`]: https://www.w3.org/TR/WGSL/#extension-clip_distances ClipDistances, + /// Enables the `mesh_shader` extension, native only + MeshShader, } /// A variant of [`EnableExtension::Unimplemented`]. diff --git a/naga/src/ir/mod.rs b/naga/src/ir/mod.rs index 943dbc2458b..6c4b8720c5f 100644 --- a/naga/src/ir/mod.rs +++ b/naga/src/ir/mod.rs @@ -329,6 +329,16 @@ pub enum ShaderStage { Mesh, } +impl ShaderStage { + // TODO: make more things respect this + pub const fn compute_like(self) -> bool { + match self { + Self::Vertex | Self::Fragment => false, + Self::Compute | Self::Task | Self::Mesh => true, + } + } +} + /// Addressing space of variables. #[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] #[cfg_attr(feature = "serialize", derive(Serialize))] @@ -349,6 +359,8 @@ pub enum AddressSpace { Handle, /// Push constants. PushConstant, + /// Task shader to mesh shader payload + TaskPayload, } /// Built-in inputs and outputs. @@ -359,7 +371,7 @@ pub enum AddressSpace { pub enum BuiltIn { Position { invariant: bool }, ViewIndex, - // vertex + // vertex (and often mesh) BaseInstance, BaseVertex, ClipDistance, @@ -372,10 +384,10 @@ pub enum BuiltIn { FragDepth, PointCoord, FrontFacing, - PrimitiveIndex, + PrimitiveIndex, // Also for mesh output SampleIndex, SampleMask, - // compute + // compute (and task/mesh) GlobalInvocationId, LocalInvocationId, LocalInvocationIndex, @@ -387,6 +399,10 @@ pub enum BuiltIn { SubgroupId, SubgroupSize, SubgroupInvocationId, + // mesh + CullPrimitive, + LineIndices, + TriangleIndices, } /// Number of bytes per scalar. @@ -1907,7 +1923,9 @@ pub enum Statement { /// [`Loop`] statement. /// /// [`Loop`]: Statement::Loop - Return { value: Option> }, + Return { + value: Option>, + }, /// Aborts the current shader execution. /// @@ -2113,6 +2131,7 @@ pub enum Statement { /// The specific operation we're performing on `query`. fun: RayQueryFunction, }, + MeshFunction(MeshFunction), /// Calculate a bitmask using a boolean from each active thread in the subgroup SubgroupBallot { /// The [`SubgroupBallotResult`] expression representing this load's result. @@ -2286,6 +2305,9 @@ pub struct EntryPoint { pub workgroup_size_overrides: Option<[Option>; 3]>, /// The entrance function. pub function: Function, + /// The information relating to a mesh shader + pub mesh_info: Option, + pub task_payload: Option>, } /// Return types predeclared for the frexp, modf, and atomicCompareExchangeWeak built-in functions. @@ -2505,3 +2527,44 @@ pub struct Module { /// Doc comments. pub doc_comments: Option>, } + +#[derive(Debug, Clone)] +#[cfg_attr(feature = "serialize", derive(Serialize))] +#[cfg_attr(feature = "deserialize", derive(Deserialize))] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +pub enum MeshOutputTopology { + Lines, + Triangles, +} +#[derive(Debug, Clone)] +#[cfg_attr(feature = "serialize", derive(Serialize))] +#[cfg_attr(feature = "deserialize", derive(Deserialize))] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[allow(dead_code)] +pub struct MeshStageInfo { + pub topology: MeshOutputTopology, + // Should this be an expression or what? Not clear + pub max_vertices: u32, + pub max_primitives: u32, + pub vertex_output_type: Handle, + pub primitive_output_type: Handle, +} + +#[derive(Debug, Clone, Copy)] +#[cfg_attr(feature = "serialize", derive(Serialize))] +#[cfg_attr(feature = "deserialize", derive(Deserialize))] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +pub enum MeshFunction { + SetMeshOutputs { + vertex_count: Handle, + primitive_count: Handle, + }, + SetVertex { + index: Handle, + value: Handle, + }, + SetPrimitive { + index: Handle, + value: Handle, + }, +} diff --git a/naga/src/lib.rs b/naga/src/lib.rs index 9e5a1904d46..bdd5345c312 100644 --- a/naga/src/lib.rs +++ b/naga/src/lib.rs @@ -158,2238 +158,3 @@ pub type FastIndexMap = /// Map of expressions that have associated variable names pub(crate) type NamedExpressions = FastIndexMap, String>; - -/// Early fragment tests. -/// -/// In a standard situation, if a driver determines that it is possible to switch on early depth test, it will. -/// -/// Typical situations when early depth test is switched off: -/// - Calling `discard` in a shader. -/// - Writing to the depth buffer, unless ConservativeDepth is enabled. -/// -/// To use in a shader: -/// - GLSL: `layout(early_fragment_tests) in;` -/// - HLSL: `Attribute earlydepthstencil` -/// - SPIR-V: `ExecutionMode EarlyFragmentTests` -/// - WGSL: `@early_depth_test` -/// -/// For more, see: -/// - -/// - -/// - -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub struct EarlyDepthTest { - pub conservative: Option, -} - -/// Enables adjusting depth without disabling early Z. -/// -/// To use in a shader: -/// - GLSL: `layout (depth_) out float gl_FragDepth;` -/// - `depth_any` option behaves as if the layout qualifier was not present. -/// - HLSL: `SV_DepthGreaterEqual`/`SV_DepthLessEqual`/`SV_Depth` -/// - SPIR-V: `ExecutionMode Depth` -/// - WGSL: `@early_depth_test(greater_equal/less_equal/unchanged)` -/// -/// For more, see: -/// - -/// - -/// - -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum ConservativeDepth { - /// Shader may rewrite depth only with a value greater than calculated. - GreaterEqual, - - /// Shader may rewrite depth smaller than one that would have been written without the modification. - LessEqual, - - /// Shader may not rewrite depth value. - Unchanged, -} - -/// Stage of the programmable pipeline. -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -#[allow(missing_docs)] // The names are self evident -pub enum ShaderStage { - Vertex, - Fragment, - Compute, - Task, - Mesh, -} -impl ShaderStage { - // TODO: make more things respect this - pub const fn compute_like(self) -> bool { - match self { - Self::Vertex | Self::Fragment => false, - Self::Compute | Self::Task | Self::Mesh => true, - } - } -} - -/// Addressing space of variables. -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum AddressSpace { - /// Function locals. - Function, - /// Private data, per invocation, mutable. - Private, - /// Workgroup shared data, mutable. - WorkGroup, - /// Uniform buffer data. - Uniform, - /// Storage buffer data, potentially mutable. - Storage { access: StorageAccess }, - /// Opaque handles, such as samplers and images. - Handle, - /// Push constants. - PushConstant, - /// Task shader to mesh shader payload - TaskPayload, -} - -/// Built-in inputs and outputs. -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum BuiltIn { - Position { invariant: bool }, - ViewIndex, - // vertex (and often mesh) - BaseInstance, - BaseVertex, - ClipDistance, - CullDistance, - InstanceIndex, - PointSize, - VertexIndex, - DrawID, - // fragment - FragDepth, - PointCoord, - FrontFacing, - PrimitiveIndex, // Also for mesh output - SampleIndex, - SampleMask, - // compute (and task/mesh) - GlobalInvocationId, - LocalInvocationId, - LocalInvocationIndex, - WorkGroupId, - WorkGroupSize, - NumWorkGroups, - // subgroup - NumSubgroups, - SubgroupId, - SubgroupSize, - SubgroupInvocationId, - // mesh - CullPrimitive, - LineIndices, - TriangleIndices, -} - -/// Number of bytes per scalar. -pub type Bytes = u8; - -/// Number of components in a vector. -#[repr(u8)] -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum VectorSize { - /// 2D vector - Bi = 2, - /// 3D vector - Tri = 3, - /// 4D vector - Quad = 4, -} - -impl VectorSize { - const MAX: usize = Self::Quad as u8 as usize; -} - -/// Primitive type for a scalar. -#[repr(u8)] -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum ScalarKind { - /// Signed integer type. - Sint, - /// Unsigned integer type. - Uint, - /// Floating point type. - Float, - /// Boolean type. - Bool, - - /// WGSL abstract integer type. - /// - /// These are forbidden by validation, and should never reach backends. - AbstractInt, - - /// Abstract floating-point type. - /// - /// These are forbidden by validation, and should never reach backends. - AbstractFloat, -} - -/// Characteristics of a scalar type. -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub struct Scalar { - /// How the value's bits are to be interpreted. - pub kind: ScalarKind, - - /// This size of the value in bytes. - pub width: Bytes, -} - -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum PendingArraySize { - Expression(Handle), - Override(Handle), -} - -/// Size of an array. -#[repr(u8)] -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum ArraySize { - /// The array size is constant. - Constant(std::num::NonZeroU32), - /// The array size is an override-expression. - Pending(PendingArraySize), - /// The array size can change at runtime. - Dynamic, -} - -/// The interpolation qualifier of a binding or struct field. -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum Interpolation { - /// The value will be interpolated in a perspective-correct fashion. - /// Also known as "smooth" in glsl. - Perspective, - /// Indicates that linear, non-perspective, correct - /// interpolation must be used. - /// Also known as "no_perspective" in glsl. - Linear, - /// Indicates that no interpolation will be performed. - Flat, -} - -/// The sampling qualifiers of a binding or struct field. -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum Sampling { - /// Interpolate the value at the center of the pixel. - Center, - - /// Interpolate the value at a point that lies within all samples covered by - /// the fragment within the current primitive. In multisampling, use a - /// single value for all samples in the primitive. - Centroid, - - /// Interpolate the value at each sample location. In multisampling, invoke - /// the fragment shader once per sample. - Sample, - - /// Use the value provided by the first vertex of the current primitive. - First, - - /// Use the value provided by the first or last vertex of the current primitive. The exact - /// choice is implementation-dependent. - Either, -} - -/// Member of a user-defined structure. -// Clone is used only for error reporting and is not intended for end users -#[derive(Clone, Debug, Eq, Hash, PartialEq)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub struct StructMember { - pub name: Option, - /// Type of the field. - pub ty: Handle, - /// For I/O structs, defines the binding. - pub binding: Option, - /// Offset from the beginning from the struct. - pub offset: u32, -} - -/// The number of dimensions an image has. -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum ImageDimension { - /// 1D image - D1, - /// 2D image - D2, - /// 3D image - D3, - /// Cube map - Cube, -} - -bitflags::bitflags! { - /// Flags describing an image. - #[cfg_attr(feature = "serialize", derive(Serialize))] - #[cfg_attr(feature = "deserialize", derive(Deserialize))] - #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] - #[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] - pub struct StorageAccess: u32 { - /// Storage can be used as a source for load ops. - const LOAD = 0x1; - /// Storage can be used as a target for store ops. - const STORE = 0x2; - /// Storage can be used as a target for atomic ops. - const ATOMIC = 0x4; - } -} - -/// Image storage format. -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum StorageFormat { - // 8-bit formats - R8Unorm, - R8Snorm, - R8Uint, - R8Sint, - - // 16-bit formats - R16Uint, - R16Sint, - R16Float, - Rg8Unorm, - Rg8Snorm, - Rg8Uint, - Rg8Sint, - - // 32-bit formats - R32Uint, - R32Sint, - R32Float, - Rg16Uint, - Rg16Sint, - Rg16Float, - Rgba8Unorm, - Rgba8Snorm, - Rgba8Uint, - Rgba8Sint, - Bgra8Unorm, - - // Packed 32-bit formats - Rgb10a2Uint, - Rgb10a2Unorm, - Rg11b10Ufloat, - - // 64-bit formats - R64Uint, - Rg32Uint, - Rg32Sint, - Rg32Float, - Rgba16Uint, - Rgba16Sint, - Rgba16Float, - - // 128-bit formats - Rgba32Uint, - Rgba32Sint, - Rgba32Float, - - // Normalized 16-bit per channel formats - R16Unorm, - R16Snorm, - Rg16Unorm, - Rg16Snorm, - Rgba16Unorm, - Rgba16Snorm, -} - -/// Sub-class of the image type. -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum ImageClass { - /// Regular sampled image. - Sampled { - /// Kind of values to sample. - kind: ScalarKind, - /// Multi-sampled image. - /// - /// A multi-sampled image holds several samples per texel. Multi-sampled - /// images cannot have mipmaps. - multi: bool, - }, - /// Depth comparison image. - Depth { - /// Multi-sampled depth image. - multi: bool, - }, - /// Storage image. - Storage { - format: StorageFormat, - access: StorageAccess, - }, -} - -/// A data type declared in the module. -#[derive(Clone, Debug, Eq, Hash, PartialEq)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub struct Type { - /// The name of the type, if any. - pub name: Option, - /// Inner structure that depends on the kind of the type. - pub inner: TypeInner, -} - -/// Enum with additional information, depending on the kind of type. -#[derive(Clone, Debug, Eq, Hash, PartialEq)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum TypeInner { - /// Number of integral or floating-point kind. - Scalar(Scalar), - /// Vector of numbers. - Vector { size: VectorSize, scalar: Scalar }, - /// Matrix of numbers. - Matrix { - columns: VectorSize, - rows: VectorSize, - scalar: Scalar, - }, - /// Atomic scalar. - Atomic(Scalar), - /// Pointer to another type. - /// - /// Pointers to scalars and vectors should be treated as equivalent to - /// [`ValuePointer`] types. Use the [`TypeInner::equivalent`] method to - /// compare types in a way that treats pointers correctly. - /// - /// ## Pointers to non-`SIZED` types - /// - /// The `base` type of a pointer may be a non-[`SIZED`] type like a - /// dynamically-sized [`Array`], or a [`Struct`] whose last member is a - /// dynamically sized array. Such pointers occur as the types of - /// [`GlobalVariable`] or [`AccessIndex`] expressions referring to - /// dynamically-sized arrays. - /// - /// However, among pointers to non-`SIZED` types, only pointers to `Struct`s - /// are [`DATA`]. Pointers to dynamically sized `Array`s cannot be passed as - /// arguments, stored in variables, or held in arrays or structures. Their - /// only use is as the types of `AccessIndex` expressions. - /// - /// [`SIZED`]: valid::TypeFlags::SIZED - /// [`DATA`]: valid::TypeFlags::DATA - /// [`Array`]: TypeInner::Array - /// [`Struct`]: TypeInner::Struct - /// [`ValuePointer`]: TypeInner::ValuePointer - /// [`GlobalVariable`]: Expression::GlobalVariable - /// [`AccessIndex`]: Expression::AccessIndex - Pointer { - base: Handle, - space: AddressSpace, - }, - - /// Pointer to a scalar or vector. - /// - /// A `ValuePointer` type is equivalent to a `Pointer` whose `base` is a - /// `Scalar` or `Vector` type. This is for use in [`TypeResolution::Value`] - /// variants; see the documentation for [`TypeResolution`] for details. - /// - /// Use the [`TypeInner::equivalent`] method to compare types that could be - /// pointers, to ensure that `Pointer` and `ValuePointer` types are - /// recognized as equivalent. - /// - /// [`TypeResolution`]: proc::TypeResolution - /// [`TypeResolution::Value`]: proc::TypeResolution::Value - ValuePointer { - size: Option, - scalar: Scalar, - space: AddressSpace, - }, - - /// Homogeneous list of elements. - /// - /// The `base` type must be a [`SIZED`], [`DATA`] type. - /// - /// ## Dynamically sized arrays - /// - /// An `Array` is [`SIZED`] unless its `size` is [`Dynamic`]. - /// Dynamically-sized arrays may only appear in a few situations: - /// - /// - They may appear as the type of a [`GlobalVariable`], or as the last - /// member of a [`Struct`]. - /// - /// - They may appear as the base type of a [`Pointer`]. An - /// [`AccessIndex`] expression referring to a struct's final - /// unsized array member would have such a pointer type. However, such - /// pointer types may only appear as the types of such intermediate - /// expressions. They are not [`DATA`], and cannot be stored in - /// variables, held in arrays or structs, or passed as parameters. - /// - /// [`SIZED`]: crate::valid::TypeFlags::SIZED - /// [`DATA`]: crate::valid::TypeFlags::DATA - /// [`Dynamic`]: ArraySize::Dynamic - /// [`Struct`]: TypeInner::Struct - /// [`Pointer`]: TypeInner::Pointer - /// [`AccessIndex`]: Expression::AccessIndex - Array { - base: Handle, - size: ArraySize, - stride: u32, - }, - - /// User-defined structure. - /// - /// There must always be at least one member. - /// - /// A `Struct` type is [`DATA`], and the types of its members must be - /// `DATA` as well. - /// - /// Member types must be [`SIZED`], except for the final member of a - /// struct, which may be a dynamically sized [`Array`]. The - /// `Struct` type itself is `SIZED` when all its members are `SIZED`. - /// - /// [`DATA`]: crate::valid::TypeFlags::DATA - /// [`SIZED`]: crate::valid::TypeFlags::SIZED - /// [`Array`]: TypeInner::Array - Struct { - members: Vec, - //TODO: should this be unaligned? - span: u32, - }, - /// Possibly multidimensional array of texels. - Image { - dim: ImageDimension, - arrayed: bool, - //TODO: consider moving `multisampled: bool` out - class: ImageClass, - }, - /// Can be used to sample values from images. - Sampler { comparison: bool }, - - /// Opaque object representing an acceleration structure of geometry. - AccelerationStructure, - - /// Locally used handle for ray queries. - RayQuery, - - /// Array of bindings. - /// - /// A `BindingArray` represents an array where each element draws its value - /// from a separate bound resource. The array's element type `base` may be - /// [`Image`], [`Sampler`], or any type that would be permitted for a global - /// in the [`Uniform`] or [`Storage`] address spaces. Only global variables - /// may be binding arrays; on the host side, their values are provided by - /// [`TextureViewArray`], [`SamplerArray`], or [`BufferArray`] - /// bindings. - /// - /// Since each element comes from a distinct resource, a binding array of - /// images could have images of varying sizes (but not varying dimensions; - /// they must all have the same `Image` type). Or, a binding array of - /// buffers could have elements that are dynamically sized arrays, each with - /// a different length. - /// - /// Binding arrays are in the same address spaces as their underlying type. - /// As such, referring to an array of images produces an [`Image`] value - /// directly (as opposed to a pointer). The only operation permitted on - /// `BindingArray` values is indexing, which works transparently: indexing - /// a binding array of samplers yields a [`Sampler`], indexing a pointer to the - /// binding array of storage buffers produces a pointer to the storage struct. - /// - /// Unlike textures and samplers, binding arrays are not [`ARGUMENT`], so - /// they cannot be passed as arguments to functions. - /// - /// Naga's WGSL front end supports binding arrays with the type syntax - /// `binding_array`. - /// - /// [`Image`]: TypeInner::Image - /// [`Sampler`]: TypeInner::Sampler - /// [`Uniform`]: AddressSpace::Uniform - /// [`Storage`]: AddressSpace::Storage - /// [`TextureViewArray`]: https://docs.rs/wgpu/latest/wgpu/enum.BindingResource.html#variant.TextureViewArray - /// [`SamplerArray`]: https://docs.rs/wgpu/latest/wgpu/enum.BindingResource.html#variant.SamplerArray - /// [`BufferArray`]: https://docs.rs/wgpu/latest/wgpu/enum.BindingResource.html#variant.BufferArray - /// [`DATA`]: crate::valid::TypeFlags::DATA - /// [`ARGUMENT`]: crate::valid::TypeFlags::ARGUMENT - /// [naga#1864]: https://github.com/gfx-rs/naga/issues/1864 - BindingArray { base: Handle, size: ArraySize }, -} - -#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum Literal { - /// May not be NaN or infinity. - F64(f64), - /// May not be NaN or infinity. - F32(f32), - U32(u32), - I32(i32), - U64(u64), - I64(i64), - Bool(bool), - AbstractInt(i64), - AbstractFloat(f64), -} - -/// Pipeline-overridable constant. -#[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub struct Override { - pub name: Option, - /// Pipeline Constant ID. - pub id: Option, - pub ty: Handle, - - /// The default value of the pipeline-overridable constant. - /// - /// This [`Handle`] refers to [`Module::global_expressions`], not - /// any [`Function::expressions`] arena. - pub init: Option>, -} - -/// Constant value. -#[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub struct Constant { - pub name: Option, - pub ty: Handle, - - /// The value of the constant. - /// - /// This [`Handle`] refers to [`Module::global_expressions`], not - /// any [`Function::expressions`] arena. - pub init: Handle, -} - -/// Describes how an input/output variable is to be bound. -#[derive(Clone, Debug, Eq, PartialEq, Hash)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum Binding { - /// Built-in shader variable. - BuiltIn(BuiltIn), - - /// Indexed location. - /// - /// Values passed from the [`Vertex`] stage to the [`Fragment`] stage must - /// have their `interpolation` defaulted (i.e. not `None`) by the front end - /// as appropriate for that language. - /// - /// For other stages, we permit interpolations even though they're ignored. - /// When a front end is parsing a struct type, it usually doesn't know what - /// stages will be using it for IO, so it's easiest if it can apply the - /// defaults to anything with a `Location` binding, just in case. - /// - /// For anything other than floating-point scalars and vectors, the - /// interpolation must be `Flat`. - /// - /// [`Vertex`]: crate::ShaderStage::Vertex - /// [`Fragment`]: crate::ShaderStage::Fragment - Location { - location: u32, - /// Indicates the 2nd input to the blender when dual-source blending. - second_blend_source: bool, - interpolation: Option, - sampling: Option, - }, -} - -/// Pipeline binding information for global resources. -#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub struct ResourceBinding { - /// The bind group index. - pub group: u32, - /// Binding number within the group. - pub binding: u32, -} - -/// Variable defined at module level. -#[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub struct GlobalVariable { - /// Name of the variable, if any. - pub name: Option, - /// How this variable is to be stored. - pub space: AddressSpace, - /// For resources, defines the binding point. - pub binding: Option, - /// The type of this variable. - pub ty: Handle, - /// Initial value for this variable. - /// - /// This refers to an [`Expression`] in [`Module::global_expressions`]. - pub init: Option>, -} - -/// Variable defined at function level. -#[derive(Clone, Debug)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub struct LocalVariable { - /// Name of the variable, if any. - pub name: Option, - /// The type of this variable. - pub ty: Handle, - /// Initial value for this variable. - /// - /// This handle refers to an expression in this `LocalVariable`'s function's - /// [`expressions`] arena, but it is required to be an evaluated override - /// expression. - /// - /// [`expressions`]: Function::expressions - pub init: Option>, -} - -/// Operation that can be applied on a single value. -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum UnaryOperator { - Negate, - LogicalNot, - BitwiseNot, -} - -/// Operation that can be applied on two values. -/// -/// ## Arithmetic type rules -/// -/// The arithmetic operations `Add`, `Subtract`, `Multiply`, `Divide`, and -/// `Modulo` can all be applied to [`Scalar`] types other than [`Bool`], or -/// [`Vector`]s thereof. Both operands must have the same type. -/// -/// `Add` and `Subtract` can also be applied to [`Matrix`] values. Both operands -/// must have the same type. -/// -/// `Multiply` supports additional cases: -/// -/// - A [`Matrix`] or [`Vector`] can be multiplied by a scalar [`Float`], -/// either on the left or the right. -/// -/// - A [`Matrix`] on the left can be multiplied by a [`Vector`] on the right -/// if the matrix has as many columns as the vector has components (`matCxR -/// * VecC`). -/// -/// - A [`Vector`] on the left can be multiplied by a [`Matrix`] on the right -/// if the matrix has as many rows as the vector has components (`VecR * -/// matCxR`). -/// -/// - Two matrices can be multiplied if the left operand has as many columns -/// as the right operand has rows (`matNxR * matCxN`). -/// -/// In all the above `Multiply` cases, the byte widths of the underlying scalar -/// types of both operands must be the same. -/// -/// Note that `Multiply` supports mixed vector and scalar operations directly, -/// whereas the other arithmetic operations require an explicit [`Splat`] for -/// mixed-type use. -/// -/// [`Scalar`]: TypeInner::Scalar -/// [`Vector`]: TypeInner::Vector -/// [`Matrix`]: TypeInner::Matrix -/// [`Float`]: ScalarKind::Float -/// [`Bool`]: ScalarKind::Bool -/// [`Splat`]: Expression::Splat -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum BinaryOperator { - Add, - Subtract, - Multiply, - Divide, - /// Equivalent of the WGSL's `%` operator or SPIR-V's `OpFRem` - Modulo, - Equal, - NotEqual, - Less, - LessEqual, - Greater, - GreaterEqual, - And, - ExclusiveOr, - InclusiveOr, - LogicalAnd, - LogicalOr, - ShiftLeft, - /// Right shift carries the sign of signed integers only. - ShiftRight, -} - -/// Function on an atomic value. -/// -/// Note: these do not include load/store, which use the existing -/// [`Expression::Load`] and [`Statement::Store`]. -/// -/// All `Handle` values here refer to an expression in -/// [`Function::expressions`]. -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum AtomicFunction { - Add, - Subtract, - And, - ExclusiveOr, - InclusiveOr, - Min, - Max, - Exchange { compare: Option> }, -} - -/// Hint at which precision to compute a derivative. -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum DerivativeControl { - Coarse, - Fine, - None, -} - -/// Axis on which to compute a derivative. -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum DerivativeAxis { - X, - Y, - Width, -} - -/// Built-in shader function for testing relation between values. -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum RelationalFunction { - All, - Any, - IsNan, - IsInf, -} - -/// Built-in shader function for math. -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum MathFunction { - // comparison - Abs, - Min, - Max, - Clamp, - Saturate, - // trigonometry - Cos, - Cosh, - Sin, - Sinh, - Tan, - Tanh, - Acos, - Asin, - Atan, - Atan2, - Asinh, - Acosh, - Atanh, - Radians, - Degrees, - // decomposition - Ceil, - Floor, - Round, - Fract, - Trunc, - Modf, - Frexp, - Ldexp, - // exponent - Exp, - Exp2, - Log, - Log2, - Pow, - // geometry - Dot, - Outer, - Cross, - Distance, - Length, - Normalize, - FaceForward, - Reflect, - Refract, - // computational - Sign, - Fma, - Mix, - Step, - SmoothStep, - Sqrt, - InverseSqrt, - Inverse, - Transpose, - Determinant, - QuantizeToF16, - // bits - CountTrailingZeros, - CountLeadingZeros, - CountOneBits, - ReverseBits, - ExtractBits, - InsertBits, - FirstTrailingBit, - FirstLeadingBit, - // data packing - Pack4x8snorm, - Pack4x8unorm, - Pack2x16snorm, - Pack2x16unorm, - Pack2x16float, - Pack4xI8, - Pack4xU8, - // data unpacking - Unpack4x8snorm, - Unpack4x8unorm, - Unpack2x16snorm, - Unpack2x16unorm, - Unpack2x16float, - Unpack4xI8, - Unpack4xU8, -} - -/// Sampling modifier to control the level of detail. -/// -/// All `Handle` values here refer to an expression in -/// [`Function::expressions`]. -#[derive(Clone, Copy, Debug, PartialEq)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum SampleLevel { - Auto, - Zero, - Exact(Handle), - Bias(Handle), - Gradient { - x: Handle, - y: Handle, - }, -} - -/// Type of an image query. -/// -/// All `Handle` values here refer to an expression in -/// [`Function::expressions`]. -#[derive(Clone, Copy, Debug, PartialEq)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum ImageQuery { - /// Get the size at the specified level. - /// - /// The return value is a `u32` for 1D images, and a `vecN` - /// for an image with dimensions N > 2. - Size { - /// If `None`, the base level is considered. - level: Option>, - }, - /// Get the number of mipmap levels, a `u32`. - NumLevels, - /// Get the number of array layers, a `u32`. - NumLayers, - /// Get the number of samples, a `u32`. - NumSamples, -} - -/// Component selection for a vector swizzle. -#[repr(u8)] -#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum SwizzleComponent { - X = 0, - Y = 1, - Z = 2, - W = 3, -} - -/// The specific behavior of a [`SubgroupGather`] statement. -/// -/// All `Handle` values here refer to an expression in -/// [`Function::expressions`]. -/// -/// [`SubgroupGather`]: Statement::SubgroupGather -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum GatherMode { - /// All gather from the active lane with the smallest index - BroadcastFirst, - /// All gather from the same lane at the index given by the expression - Broadcast(Handle), - /// Each gathers from a different lane at the index given by the expression - Shuffle(Handle), - /// Each gathers from their lane plus the shift given by the expression - ShuffleDown(Handle), - /// Each gathers from their lane minus the shift given by the expression - ShuffleUp(Handle), - /// Each gathers from their lane xored with the given by the expression - ShuffleXor(Handle), -} - -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum SubgroupOperation { - All = 0, - Any = 1, - Add = 2, - Mul = 3, - Min = 4, - Max = 5, - And = 6, - Or = 7, - Xor = 8, -} - -#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum CollectiveOperation { - Reduce = 0, - InclusiveScan = 1, - ExclusiveScan = 2, -} - -bitflags::bitflags! { - /// Memory barrier flags. - #[cfg_attr(feature = "serialize", derive(Serialize))] - #[cfg_attr(feature = "deserialize", derive(Deserialize))] - #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] - #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] - pub struct Barrier: u32 { - /// Barrier affects all [`AddressSpace::Storage`] accesses. - const STORAGE = 1 << 0; - /// Barrier affects all [`AddressSpace::WorkGroup`] accesses. - const WORK_GROUP = 1 << 1; - /// Barrier synchronizes execution across all invocations within a subgroup that execute this instruction. - const SUB_GROUP = 1 << 2; - } -} - -/// An expression that can be evaluated to obtain a value. -/// -/// This is a Single Static Assignment (SSA) scheme similar to SPIR-V. -/// -/// When an `Expression` variant holds `Handle` fields, they refer -/// to another expression in the same arena, unless explicitly noted otherwise. -/// One `Arena` may only refer to a different arena indirectly, via -/// [`Constant`] or [`Override`] expressions, which hold handles for their -/// respective types. -/// -/// [`Constant`]: Expression::Constant -/// [`Override`]: Expression::Override -#[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum Expression { - /// Literal. - Literal(Literal), - /// Constant value. - Constant(Handle), - /// Pipeline-overridable constant. - Override(Handle), - /// Zero value of a type. - ZeroValue(Handle), - /// Composite expression. - Compose { - ty: Handle, - components: Vec>, - }, - - /// Array access with a computed index. - /// - /// ## Typing rules - /// - /// The `base` operand must be some composite type: [`Vector`], [`Matrix`], - /// [`Array`], a [`Pointer`] to one of those, or a [`ValuePointer`] with a - /// `size`. - /// - /// The `index` operand must be an integer, signed or unsigned. - /// - /// Indexing a [`Vector`] or [`Array`] produces a value of its element type. - /// Indexing a [`Matrix`] produces a [`Vector`]. - /// - /// Indexing a [`Pointer`] to any of the above produces a pointer to the - /// element/component type, in the same [`space`]. In the case of [`Array`], - /// the result is an actual [`Pointer`], but for vectors and matrices, there - /// may not be any type in the arena representing the component's type, so - /// those produce [`ValuePointer`] types equivalent to the appropriate - /// [`Pointer`]. - /// - /// ## Dynamic indexing restrictions - /// - /// To accommodate restrictions in some of the shader languages that Naga - /// targets, it is not permitted to subscript a matrix with a dynamically - /// computed index unless that matrix appears behind a pointer. In other - /// words, if the inner type of `base` is [`Matrix`], then `index` must be a - /// constant. But if the type of `base` is a [`Pointer`] to an matrix, then - /// the index may be any expression of integer type. - /// - /// You can use the [`Expression::is_dynamic_index`] method to determine - /// whether a given index expression requires matrix base operands to be - /// behind a pointer. - /// - /// (It would be simpler to always require the use of `AccessIndex` when - /// subscripting matrices that are not behind pointers, but to accommodate - /// existing front ends, Naga also permits `Access`, with a restricted - /// `index`.) - /// - /// [`Vector`]: TypeInner::Vector - /// [`Matrix`]: TypeInner::Matrix - /// [`Array`]: TypeInner::Array - /// [`Pointer`]: TypeInner::Pointer - /// [`space`]: TypeInner::Pointer::space - /// [`ValuePointer`]: TypeInner::ValuePointer - /// [`Float`]: ScalarKind::Float - Access { - base: Handle, - index: Handle, - }, - /// Access the same types as [`Access`], plus [`Struct`] with a known index. - /// - /// [`Access`]: Expression::Access - /// [`Struct`]: TypeInner::Struct - AccessIndex { - base: Handle, - index: u32, - }, - /// Splat scalar into a vector. - Splat { - size: VectorSize, - value: Handle, - }, - /// Vector swizzle. - Swizzle { - size: VectorSize, - vector: Handle, - pattern: [SwizzleComponent; 4], - }, - - /// Reference a function parameter, by its index. - /// - /// A `FunctionArgument` expression evaluates to a pointer to the argument's - /// value. You must use a [`Load`] expression to retrieve its value, or a - /// [`Store`] statement to assign it a new value. - /// - /// [`Load`]: Expression::Load - /// [`Store`]: Statement::Store - FunctionArgument(u32), - - /// Reference a global variable. - /// - /// If the given `GlobalVariable`'s [`space`] is [`AddressSpace::Handle`], - /// then the variable stores some opaque type like a sampler or an image, - /// and a `GlobalVariable` expression referring to it produces the - /// variable's value directly. - /// - /// For any other address space, a `GlobalVariable` expression produces a - /// pointer to the variable's value. You must use a [`Load`] expression to - /// retrieve its value, or a [`Store`] statement to assign it a new value. - /// - /// [`space`]: GlobalVariable::space - /// [`Load`]: Expression::Load - /// [`Store`]: Statement::Store - GlobalVariable(Handle), - - /// Reference a local variable. - /// - /// A `LocalVariable` expression evaluates to a pointer to the variable's value. - /// You must use a [`Load`](Expression::Load) expression to retrieve its value, - /// or a [`Store`](Statement::Store) statement to assign it a new value. - LocalVariable(Handle), - - /// Load a value indirectly. - /// - /// For [`TypeInner::Atomic`] the result is a corresponding scalar. - /// For other types behind the `pointer`, the result is `T`. - Load { pointer: Handle }, - /// Sample a point from a sampled or a depth image. - ImageSample { - image: Handle, - sampler: Handle, - /// If Some(), this operation is a gather operation - /// on the selected component. - gather: Option, - coordinate: Handle, - array_index: Option>, - /// This refers to an expression in [`Module::global_expressions`]. - offset: Option>, - level: SampleLevel, - depth_ref: Option>, - }, - - /// Load a texel from an image. - /// - /// For most images, this returns a four-element vector of the same - /// [`ScalarKind`] as the image. If the format of the image does not have - /// four components, default values are provided: the first three components - /// (typically R, G, and B) default to zero, and the final component - /// (typically alpha) defaults to one. - /// - /// However, if the image's [`class`] is [`Depth`], then this returns a - /// [`Float`] scalar value. - /// - /// [`ScalarKind`]: ScalarKind - /// [`class`]: TypeInner::Image::class - /// [`Depth`]: ImageClass::Depth - /// [`Float`]: ScalarKind::Float - ImageLoad { - /// The image to load a texel from. This must have type [`Image`]. (This - /// will necessarily be a [`GlobalVariable`] or [`FunctionArgument`] - /// expression, since no other expressions are allowed to have that - /// type.) - /// - /// [`Image`]: TypeInner::Image - /// [`GlobalVariable`]: Expression::GlobalVariable - /// [`FunctionArgument`]: Expression::FunctionArgument - image: Handle, - - /// The coordinate of the texel we wish to load. This must be a scalar - /// for [`D1`] images, a [`Bi`] vector for [`D2`] images, and a [`Tri`] - /// vector for [`D3`] images. (Array indices, sample indices, and - /// explicit level-of-detail values are supplied separately.) Its - /// component type must be [`Sint`]. - /// - /// [`D1`]: ImageDimension::D1 - /// [`D2`]: ImageDimension::D2 - /// [`D3`]: ImageDimension::D3 - /// [`Bi`]: VectorSize::Bi - /// [`Tri`]: VectorSize::Tri - /// [`Sint`]: ScalarKind::Sint - coordinate: Handle, - - /// The index into an arrayed image. If the [`arrayed`] flag in - /// `image`'s type is `true`, then this must be `Some(expr)`, where - /// `expr` is a [`Sint`] scalar. Otherwise, it must be `None`. - /// - /// [`arrayed`]: TypeInner::Image::arrayed - /// [`Sint`]: ScalarKind::Sint - array_index: Option>, - - /// A sample index, for multisampled [`Sampled`] and [`Depth`] images. - /// - /// [`Sampled`]: ImageClass::Sampled - /// [`Depth`]: ImageClass::Depth - sample: Option>, - - /// A level of detail, for mipmapped images. - /// - /// This must be present when accessing non-multisampled - /// [`Sampled`] and [`Depth`] images, even if only the - /// full-resolution level is present (in which case the only - /// valid level is zero). - /// - /// [`Sampled`]: ImageClass::Sampled - /// [`Depth`]: ImageClass::Depth - level: Option>, - }, - - /// Query information from an image. - ImageQuery { - image: Handle, - query: ImageQuery, - }, - /// Apply an unary operator. - Unary { - op: UnaryOperator, - expr: Handle, - }, - /// Apply a binary operator. - Binary { - op: BinaryOperator, - left: Handle, - right: Handle, - }, - /// Select between two values based on a condition. - /// - /// Note that, because expressions have no side effects, it is unobservable - /// whether the non-selected branch is evaluated. - Select { - /// Boolean expression - condition: Handle, - accept: Handle, - reject: Handle, - }, - /// Compute the derivative on an axis. - Derivative { - axis: DerivativeAxis, - ctrl: DerivativeControl, - expr: Handle, - }, - /// Call a relational function. - Relational { - fun: RelationalFunction, - argument: Handle, - }, - /// Call a math function - Math { - fun: MathFunction, - arg: Handle, - arg1: Option>, - arg2: Option>, - arg3: Option>, - }, - /// Cast a simple type to another kind. - As { - /// Source expression, which can only be a scalar or a vector. - expr: Handle, - /// Target scalar kind. - kind: ScalarKind, - /// If provided, converts to the specified byte width. - /// Otherwise, bitcast. - convert: Option, - }, - /// Result of calling another function. - CallResult(Handle), - - /// Result of an atomic operation. - /// - /// This expression must be referred to by the [`result`] field of exactly one - /// [`Atomic`][stmt] statement somewhere in the same function. Let `T` be the - /// scalar type contained by the [`Atomic`][type] value that the statement - /// operates on. - /// - /// If `comparison` is `false`, then `ty` must be the scalar type `T`. - /// - /// If `comparison` is `true`, then `ty` must be a [`Struct`] with two members: - /// - /// - A member named `old_value`, whose type is `T`, and - /// - /// - A member named `exchanged`, of type [`BOOL`]. - /// - /// [`result`]: Statement::Atomic::result - /// [stmt]: Statement::Atomic - /// [type]: TypeInner::Atomic - /// [`Struct`]: TypeInner::Struct - /// [`BOOL`]: Scalar::BOOL - AtomicResult { ty: Handle, comparison: bool }, - - /// Result of a [`WorkGroupUniformLoad`] statement. - /// - /// [`WorkGroupUniformLoad`]: Statement::WorkGroupUniformLoad - WorkGroupUniformLoadResult { - /// The type of the result - ty: Handle, - }, - /// Get the length of an array. - /// The expression must resolve to a pointer to an array with a dynamic size. - /// - /// This doesn't match the semantics of spirv's `OpArrayLength`, which must be passed - /// a pointer to a structure containing a runtime array in its' last field. - ArrayLength(Handle), - - /// Result of a [`Proceed`] [`RayQuery`] statement. - /// - /// [`Proceed`]: RayQueryFunction::Proceed - /// [`RayQuery`]: Statement::RayQuery - RayQueryProceedResult, - - /// Return an intersection found by `query`. - /// - /// If `committed` is true, return the committed result available when - RayQueryGetIntersection { - query: Handle, - committed: bool, - }, - /// Result of a [`SubgroupBallot`] statement. - /// - /// [`SubgroupBallot`]: Statement::SubgroupBallot - SubgroupBallotResult, - /// Result of a [`SubgroupCollectiveOperation`] or [`SubgroupGather`] statement. - /// - /// [`SubgroupCollectiveOperation`]: Statement::SubgroupCollectiveOperation - /// [`SubgroupGather`]: Statement::SubgroupGather - SubgroupOperationResult { ty: Handle }, -} - -pub use block::Block; - -/// The value of the switch case. -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum SwitchValue { - I32(i32), - U32(u32), - Default, -} - -/// A case for a switch statement. -// Clone is used only for error reporting and is not intended for end users -#[derive(Clone, Debug)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub struct SwitchCase { - /// Value, upon which the case is considered true. - pub value: SwitchValue, - /// Body of the case. - pub body: Block, - /// If true, the control flow continues to the next case in the list, - /// or default. - pub fall_through: bool, -} - -/// An operation that a [`RayQuery` statement] applies to its [`query`] operand. -/// -/// [`RayQuery` statement]: Statement::RayQuery -/// [`query`]: Statement::RayQuery::query -#[derive(Clone, Debug)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum RayQueryFunction { - /// Initialize the `RayQuery` object. - Initialize { - /// The acceleration structure within which this query should search for hits. - /// - /// The expression must be an [`AccelerationStructure`]. - /// - /// [`AccelerationStructure`]: TypeInner::AccelerationStructure - acceleration_structure: Handle, - - #[allow(rustdoc::private_intra_doc_links)] - /// A struct of detailed parameters for the ray query. - /// - /// This expression should have the struct type given in - /// [`SpecialTypes::ray_desc`]. This is available in the WGSL - /// front end as the `RayDesc` type. - descriptor: Handle, - }, - - /// Start or continue the query given by the statement's [`query`] operand. - /// - /// After executing this statement, the `result` expression is a - /// [`Bool`] scalar indicating whether there are more intersection - /// candidates to consider. - /// - /// [`query`]: Statement::RayQuery::query - /// [`Bool`]: ScalarKind::Bool - Proceed { - result: Handle, - }, - - /// Add a candidate generated intersection to be included - /// in the determination of the closest hit for a ray query. - GenerateIntersection { - hit_t: Handle, - }, - - /// Confirm a triangle intersection to be included in the determination of - /// the closest hit for a ray query. - ConfirmIntersection, - - Terminate, -} -/// A function provided by task or mesh shaders -#[derive(Clone, Debug, Copy)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum MeshFunction { - SetMeshOutputs { - vertex_count: Handle, - primitive_count: Handle, - }, - SetVertex { - index: Handle, - value: Handle, - }, - SetPrimitive { - index: Handle, - value: Handle, - }, -} - -//TODO: consider removing `Clone`. It's not valid to clone `Statement::Emit` anyway. -/// Instructions which make up an executable block. -/// -/// `Handle` and `Range` values in `Statement` variants -/// refer to expressions in [`Function::expressions`], unless otherwise noted. -// Clone is used only for error reporting and is not intended for end users -#[derive(Clone, Debug)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum Statement { - /// Emit a range of expressions, visible to all statements that follow in this block. - /// - /// See the [module-level documentation][emit] for details. - /// - /// [emit]: index.html#expression-evaluation-time - Emit(Range), - /// A block containing more statements, to be executed sequentially. - Block(Block), - /// Conditionally executes one of two blocks, based on the value of the condition. - /// - /// Naga IR does not have "phi" instructions. If you need to use - /// values computed in an `accept` or `reject` block after the `If`, - /// store them in a [`LocalVariable`]. - If { - condition: Handle, //bool - accept: Block, - reject: Block, - }, - /// Conditionally executes one of multiple blocks, based on the value of the selector. - /// - /// Each case must have a distinct [`value`], exactly one of which must be - /// [`Default`]. The `Default` may appear at any position, and covers all - /// values not explicitly appearing in other cases. A `Default` appearing in - /// the midst of the list of cases does not shadow the cases that follow. - /// - /// Some backend languages don't support fallthrough (HLSL due to FXC, - /// WGSL), and may translate fallthrough cases in the IR by duplicating - /// code. However, all backend languages do support cases selected by - /// multiple values, like `case 1: case 2: case 3: { ... }`. This is - /// represented in the IR as a series of fallthrough cases with empty - /// bodies, except for the last. - /// - /// Naga IR does not have "phi" instructions. If you need to use - /// values computed in a [`SwitchCase::body`] block after the `Switch`, - /// store them in a [`LocalVariable`]. - /// - /// [`value`]: SwitchCase::value - /// [`body`]: SwitchCase::body - /// [`Default`]: SwitchValue::Default - Switch { - selector: Handle, - cases: Vec, - }, - - /// Executes a block repeatedly. - /// - /// Each iteration of the loop executes the `body` block, followed by the - /// `continuing` block. - /// - /// Executing a [`Break`], [`Return`] or [`Kill`] statement exits the loop. - /// - /// A [`Continue`] statement in `body` jumps to the `continuing` block. The - /// `continuing` block is meant to be used to represent structures like the - /// third expression of a C-style `for` loop head, to which `continue` - /// statements in the loop's body jump. - /// - /// The `continuing` block and its substatements must not contain `Return` - /// or `Kill` statements, or any `Break` or `Continue` statements targeting - /// this loop. (It may have `Break` and `Continue` statements targeting - /// loops or switches nested within the `continuing` block.) Expressions - /// emitted in `body` are in scope in `continuing`. - /// - /// If present, `break_if` is an expression which is evaluated after the - /// continuing block. Expressions emitted in `body` or `continuing` are - /// considered to be in scope. If the expression's value is true, control - /// continues after the `Loop` statement, rather than branching back to the - /// top of body as usual. The `break_if` expression corresponds to a "break - /// if" statement in WGSL, or a loop whose back edge is an - /// `OpBranchConditional` instruction in SPIR-V. - /// - /// Naga IR does not have "phi" instructions. If you need to use - /// values computed in a `body` or `continuing` block after the - /// `Loop`, store them in a [`LocalVariable`]. - /// - /// [`Break`]: Statement::Break - /// [`Continue`]: Statement::Continue - /// [`Kill`]: Statement::Kill - /// [`Return`]: Statement::Return - /// [`break if`]: Self::Loop::break_if - Loop { - body: Block, - continuing: Block, - break_if: Option>, - }, - - /// Exits the innermost enclosing [`Loop`] or [`Switch`]. - /// - /// A `Break` statement may only appear within a [`Loop`] or [`Switch`] - /// statement. It may not break out of a [`Loop`] from within the loop's - /// `continuing` block. - /// - /// [`Loop`]: Statement::Loop - /// [`Switch`]: Statement::Switch - Break, - - /// Skips to the `continuing` block of the innermost enclosing [`Loop`]. - /// - /// A `Continue` statement may only appear within the `body` block of the - /// innermost enclosing [`Loop`] statement. It must not appear within that - /// loop's `continuing` block. - /// - /// [`Loop`]: Statement::Loop - Continue, - - /// Returns from the function (possibly with a value). - /// - /// `Return` statements are forbidden within the `continuing` block of a - /// [`Loop`] statement. - /// - /// [`Loop`]: Statement::Loop - Return { - value: Option>, - }, - - /// Aborts the current shader execution. - /// - /// `Kill` statements are forbidden within the `continuing` block of a - /// [`Loop`] statement. - /// - /// [`Loop`]: Statement::Loop - Kill, - - /// Synchronize invocations within the work group. - /// The `Barrier` flags control which memory accesses should be synchronized. - /// If empty, this becomes purely an execution barrier. - Barrier(Barrier), - /// Stores a value at an address. - /// - /// For [`TypeInner::Atomic`] type behind the pointer, the value - /// has to be a corresponding scalar. - /// For other types behind the `pointer`, the value is `T`. - /// - /// This statement is a barrier for any operations on the - /// `Expression::LocalVariable` or `Expression::GlobalVariable` - /// that is the destination of an access chain, started - /// from the `pointer`. - Store { - pointer: Handle, - value: Handle, - }, - /// Stores a texel value to an image. - /// - /// The `image`, `coordinate`, and `array_index` fields have the same - /// meanings as the corresponding operands of an [`ImageLoad`] expression; - /// see that documentation for details. Storing into multisampled images or - /// images with mipmaps is not supported, so there are no `level` or - /// `sample` operands. - /// - /// This statement is a barrier for any operations on the corresponding - /// [`Expression::GlobalVariable`] for this image. - /// - /// [`ImageLoad`]: Expression::ImageLoad - ImageStore { - image: Handle, - coordinate: Handle, - array_index: Option>, - value: Handle, - }, - /// Atomic function. - Atomic { - /// Pointer to an atomic value. - /// - /// This must be a [`Pointer`] to an [`Atomic`] value. The atomic's - /// scalar type may be [`I32`] or [`U32`]. - /// - /// If [`SHADER_INT64_ATOMIC_MIN_MAX`] or [`SHADER_INT64_ATOMIC_ALL_OPS`] are - /// enabled, this may also be [`I64`] or [`U64`]. - /// - /// If [`SHADER_FLOAT32_ATOMIC`] is enabled, this may be [`F32`]. - /// - /// [`Pointer`]: TypeInner::Pointer - /// [`Atomic`]: TypeInner::Atomic - /// [`I32`]: Scalar::I32 - /// [`U32`]: Scalar::U32 - /// [`SHADER_INT64_ATOMIC_MIN_MAX`]: crate::valid::Capabilities::SHADER_INT64_ATOMIC_MIN_MAX - /// [`SHADER_INT64_ATOMIC_ALL_OPS`]: crate::valid::Capabilities::SHADER_INT64_ATOMIC_ALL_OPS - /// [`SHADER_FLOAT32_ATOMIC`]: crate::valid::Capabilities::SHADER_FLOAT32_ATOMIC - /// [`I64`]: Scalar::I64 - /// [`U64`]: Scalar::U64 - /// [`F32`]: Scalar::F32 - pointer: Handle, - - /// Function to run on the atomic value. - /// - /// If [`pointer`] refers to a 64-bit atomic value, then: - /// - /// - The [`SHADER_INT64_ATOMIC_ALL_OPS`] capability allows any [`AtomicFunction`] - /// value here. - /// - /// - The [`SHADER_INT64_ATOMIC_MIN_MAX`] capability allows - /// [`AtomicFunction::Min`] and [`AtomicFunction::Max`] - /// in the [`Storage`] address space here. - /// - /// - If neither of those capabilities are present, then 64-bit scalar - /// atomics are not allowed. - /// - /// If [`pointer`] refers to a 32-bit floating-point atomic value, then: - /// - /// - The [`SHADER_FLOAT32_ATOMIC`] capability allows [`AtomicFunction::Add`], - /// [`AtomicFunction::Subtract`], and [`AtomicFunction::Exchange { compare: None }`] - /// in the [`Storage`] address space here. - /// - /// [`AtomicFunction::Exchange { compare: None }`]: AtomicFunction::Exchange - /// [`pointer`]: Statement::Atomic::pointer - /// [`Storage`]: AddressSpace::Storage - /// [`SHADER_INT64_ATOMIC_MIN_MAX`]: crate::valid::Capabilities::SHADER_INT64_ATOMIC_MIN_MAX - /// [`SHADER_INT64_ATOMIC_ALL_OPS`]: crate::valid::Capabilities::SHADER_INT64_ATOMIC_ALL_OPS - /// [`SHADER_FLOAT32_ATOMIC`]: crate::valid::Capabilities::SHADER_FLOAT32_ATOMIC - fun: AtomicFunction, - - /// Value to use in the function. - /// - /// This must be a scalar of the same type as [`pointer`]'s atomic's scalar type. - /// - /// [`pointer`]: Statement::Atomic::pointer - value: Handle, - - /// [`AtomicResult`] expression representing this function's result. - /// - /// If [`fun`] is [`Exchange { compare: None }`], this must be `Some`, - /// as otherwise that operation would be equivalent to a simple [`Store`] - /// to the atomic. - /// - /// Otherwise, this may be `None` if the return value of the operation is not needed. - /// - /// If `pointer` refers to a 64-bit atomic value, [`SHADER_INT64_ATOMIC_MIN_MAX`] - /// is enabled, and [`SHADER_INT64_ATOMIC_ALL_OPS`] is not, this must be `None`. - /// - /// [`AtomicResult`]: crate::Expression::AtomicResult - /// [`fun`]: Statement::Atomic::fun - /// [`Store`]: Statement::Store - /// [`Exchange { compare: None }`]: AtomicFunction::Exchange - /// [`SHADER_INT64_ATOMIC_MIN_MAX`]: crate::valid::Capabilities::SHADER_INT64_ATOMIC_MIN_MAX - /// [`SHADER_INT64_ATOMIC_ALL_OPS`]: crate::valid::Capabilities::SHADER_INT64_ATOMIC_ALL_OPS - result: Option>, - }, - /// Performs an atomic operation on a texel value of an image. - /// - /// Doing atomics on images with mipmaps is not supported, so there is no - /// `level` operand. - ImageAtomic { - /// The image to perform an atomic operation on. This must have type - /// [`Image`]. (This will necessarily be a [`GlobalVariable`] or - /// [`FunctionArgument`] expression, since no other expressions are - /// allowed to have that type.) - /// - /// [`Image`]: TypeInner::Image - /// [`GlobalVariable`]: Expression::GlobalVariable - /// [`FunctionArgument`]: Expression::FunctionArgument - image: Handle, - - /// The coordinate of the texel we wish to load. This must be a scalar - /// for [`D1`] images, a [`Bi`] vector for [`D2`] images, and a [`Tri`] - /// vector for [`D3`] images. (Array indices, sample indices, and - /// explicit level-of-detail values are supplied separately.) Its - /// component type must be [`Sint`]. - /// - /// [`D1`]: ImageDimension::D1 - /// [`D2`]: ImageDimension::D2 - /// [`D3`]: ImageDimension::D3 - /// [`Bi`]: VectorSize::Bi - /// [`Tri`]: VectorSize::Tri - /// [`Sint`]: ScalarKind::Sint - coordinate: Handle, - - /// The index into an arrayed image. If the [`arrayed`] flag in - /// `image`'s type is `true`, then this must be `Some(expr)`, where - /// `expr` is a [`Sint`] scalar. Otherwise, it must be `None`. - /// - /// [`arrayed`]: TypeInner::Image::arrayed - /// [`Sint`]: ScalarKind::Sint - array_index: Option>, - - /// The kind of atomic operation to perform on the texel. - fun: AtomicFunction, - - /// The value with which to perform the atomic operation. - value: Handle, - }, - /// Load uniformly from a uniform pointer in the workgroup address space. - /// - /// Corresponds to the [`workgroupUniformLoad`](https://www.w3.org/TR/WGSL/#workgroupUniformLoad-builtin) - /// built-in function of wgsl, and has the same barrier semantics - WorkGroupUniformLoad { - /// This must be of type [`Pointer`] in the [`WorkGroup`] address space - /// - /// [`Pointer`]: TypeInner::Pointer - /// [`WorkGroup`]: AddressSpace::WorkGroup - pointer: Handle, - /// The [`WorkGroupUniformLoadResult`] expression representing this load's result. - /// - /// [`WorkGroupUniformLoadResult`]: Expression::WorkGroupUniformLoadResult - result: Handle, - }, - /// Calls a function. - /// - /// If the `result` is `Some`, the corresponding expression has to be - /// `Expression::CallResult`, and this statement serves as a barrier for any - /// operations on that expression. - Call { - function: Handle, - arguments: Vec>, - result: Option>, - }, - RayQuery { - /// The [`RayQuery`] object this statement operates on. - /// - /// [`RayQuery`]: TypeInner::RayQuery - query: Handle, - - /// The specific operation we're performing on `query`. - fun: RayQueryFunction, - }, - MeshFunction(MeshFunction), - /// Calculate a bitmask using a boolean from each active thread in the subgroup - SubgroupBallot { - /// The [`SubgroupBallotResult`] expression representing this load's result. - /// - /// [`SubgroupBallotResult`]: Expression::SubgroupBallotResult - result: Handle, - /// The value from this thread to store in the ballot - predicate: Option>, - }, - /// Gather a value from another active thread in the subgroup - SubgroupGather { - /// Specifies which thread to gather from - mode: GatherMode, - /// The value to broadcast over - argument: Handle, - /// The [`SubgroupOperationResult`] expression representing this load's result. - /// - /// [`SubgroupOperationResult`]: Expression::SubgroupOperationResult - result: Handle, - }, - /// Compute a collective operation across all active threads in the subgroup - SubgroupCollectiveOperation { - /// What operation to compute - op: SubgroupOperation, - /// How to combine the results - collective_op: CollectiveOperation, - /// The value to compute over - argument: Handle, - /// The [`SubgroupOperationResult`] expression representing this load's result. - /// - /// [`SubgroupOperationResult`]: Expression::SubgroupOperationResult - result: Handle, - }, -} - -/// A function argument. -#[derive(Clone, Debug)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub struct FunctionArgument { - /// Name of the argument, if any. - pub name: Option, - /// Type of the argument. - pub ty: Handle, - /// For entry points, an argument has to have a binding - /// unless it's a structure. - pub binding: Option, -} - -/// A function result. -#[derive(Clone, Debug)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub struct FunctionResult { - /// Type of the result. - pub ty: Handle, - /// For entry points, the result has to have a binding - /// unless it's a structure. - pub binding: Option, -} - -/// A function defined in the module. -#[derive(Debug, Default, Clone)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub struct Function { - /// Name of the function, if any. - pub name: Option, - /// Information about function argument. - pub arguments: Vec, - /// The result of this function, if any. - pub result: Option, - /// Local variables defined and used in the function. - pub local_variables: Arena, - /// Expressions used inside this function. - /// - /// Unless explicitly stated otherwise, if an [`Expression`] is in this - /// arena, then its subexpressions are in this arena too. In other words, - /// every `Handle` in this arena refers to an [`Expression`] in - /// this arena too. - /// - /// The main ways this arena refers to [`Module::global_expressions`] are: - /// - /// - [`Constant`], [`Override`], and [`GlobalVariable`] expressions hold - /// handles for their respective types, whose initializer expressions are - /// in [`Module::global_expressions`]. - /// - /// - Various expressions hold [`Type`] handles, and [`Type`]s may refer to - /// global expressions, for things like array lengths. - /// - /// - [`Expression::ImageSample::offset`] refers to an expression in - /// [`Module::global_expressions`]. - /// - /// An [`Expression`] must occur before all other [`Expression`]s that use - /// its value. - /// - /// [`Constant`]: Expression::Constant - /// [`Override`]: Expression::Override - /// [`GlobalVariable`]: Expression::GlobalVariable - pub expressions: Arena, - /// Map of expressions that have associated variable names - pub named_expressions: NamedExpressions, - /// Block of instructions comprising the body of the function. - pub body: Block, - /// The leaf of all diagnostic filter rules tree (stored in [`Module::diagnostic_filters`]) - /// parsed on this function. - /// - /// In WGSL, this corresponds to `@diagnostic(…)` attributes. - /// - /// See [`DiagnosticFilterNode`] for details on how the tree is represented and used in - /// validation. - pub diagnostic_filter_leaf: Option>, -} -#[derive(Debug, Clone)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum MeshOutputTopology { - Lines, - Triangles, -} -#[derive(Debug, Clone)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -#[allow(dead_code)] -pub struct MeshStageInfo { - topology: MeshOutputTopology, - // Should this be an expression or what? Not clear - max_vertices: u32, - max_primitives: u32, - vertex_output_type: Handle, - primitive_output_type: Handle, -} - -/// The main function for a pipeline stage. -/// -/// An [`EntryPoint`] is a [`Function`] that serves as the main function for a -/// graphics or compute pipeline stage. For example, an `EntryPoint` whose -/// [`stage`] is [`ShaderStage::Vertex`] can serve as a graphics pipeline's -/// vertex shader. -/// -/// Since an entry point is called directly by the graphics or compute pipeline, -/// not by other WGSL functions, you must specify what the pipeline should pass -/// as the entry point's arguments, and what values it will return. For example, -/// a vertex shader needs a vertex's attributes as its arguments, but if it's -/// used for instanced draw calls, it will also want to know the instance id. -/// The vertex shader's return value will usually include an output vertex -/// position, and possibly other attributes to be interpolated and passed along -/// to a fragment shader. -/// -/// To specify this, the arguments and result of an `EntryPoint`'s [`function`] -/// must each have a [`Binding`], or be structs whose members all have -/// `Binding`s. This associates every value passed to or returned from the entry -/// point with either a [`BuiltIn`] or a [`Location`]: -/// -/// - A [`BuiltIn`] has special semantics, usually specific to its pipeline -/// stage. For example, the result of a vertex shader can include a -/// [`BuiltIn::Position`] value, which determines the position of a vertex -/// of a rendered primitive. Or, a compute shader might take an argument -/// whose binding is [`BuiltIn::WorkGroupSize`], through which the compute -/// pipeline would pass the number of invocations in your workgroup. -/// -/// - A [`Location`] indicates user-defined IO to be passed from one pipeline -/// stage to the next. For example, a vertex shader might also produce a -/// `uv` texture location as a user-defined IO value. -/// -/// In other words, the pipeline stage's input and output interface are -/// determined by the bindings of the arguments and result of the `EntryPoint`'s -/// [`function`]. -/// -/// [`Function`]: crate::Function -/// [`Location`]: Binding::Location -/// [`function`]: EntryPoint::function -/// [`stage`]: EntryPoint::stage -#[derive(Debug, Clone)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub struct EntryPoint { - /// Name of this entry point, visible externally. - /// - /// Entry point names for a given `stage` must be distinct within a module. - pub name: String, - /// Shader stage. - pub stage: ShaderStage, - /// Early depth test for fragment stages. - pub early_depth_test: Option, - /// Workgroup size for compute stages - pub workgroup_size: [u32; 3], - /// Override expressions for workgroup size in the global_expressions arena - pub workgroup_size_overrides: Option<[Option>; 3]>, - /// The entrance function. - pub function: Function, - /// The information relating to a mesh shader - pub mesh_info: Option, - pub task_payload: Option>, -} - -/// Return types predeclared for the frexp, modf, and atomicCompareExchangeWeak built-in functions. -/// -/// These cannot be spelled in WGSL source. -/// -/// Stored in [`SpecialTypes::predeclared_types`] and created by [`Module::generate_predeclared_type`]. -#[derive(Debug, PartialEq, Eq, Hash, Clone)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum PredeclaredType { - AtomicCompareExchangeWeakResult(Scalar), - ModfResult { - size: Option, - scalar: Scalar, - }, - FrexpResult { - size: Option, - scalar: Scalar, - }, -} - -/// Set of special types that can be optionally generated by the frontends. -#[derive(Debug, Default, Clone)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub struct SpecialTypes { - /// Type for `RayDesc`. - /// - /// Call [`Module::generate_ray_desc_type`] to populate this if - /// needed and return the handle. - pub ray_desc: Option>, - - /// Type for `RayIntersection`. - /// - /// Call [`Module::generate_ray_intersection_type`] to populate - /// this if needed and return the handle. - pub ray_intersection: Option>, - - /// Types for predeclared wgsl types instantiated on demand. - /// - /// Call [`Module::generate_predeclared_type`] to populate this if - /// needed and return the handle. - pub predeclared_types: FastIndexMap>, -} - -bitflags::bitflags! { - /// Ray flags used when casting rays. - /// Matching vulkan constants can be found in - /// https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/KHR/ray_common/ray_flags_section.txt - #[cfg_attr(feature = "serialize", derive(Serialize))] - #[cfg_attr(feature = "deserialize", derive(Deserialize))] - #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] - #[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] - pub struct RayFlag: u32 { - /// Force all intersections to be treated as opaque. - const FORCE_OPAQUE = 0x1; - /// Force all intersections to be treated as non-opaque. - const FORCE_NO_OPAQUE = 0x2; - /// Stop traversal after the first hit. - const TERMINATE_ON_FIRST_HIT = 0x4; - /// Don't execute the closest hit shader. - const SKIP_CLOSEST_HIT_SHADER = 0x8; - /// Cull back facing geometry. - const CULL_BACK_FACING = 0x10; - /// Cull front facing geometry. - const CULL_FRONT_FACING = 0x20; - /// Cull opaque geometry. - const CULL_OPAQUE = 0x40; - /// Cull non-opaque geometry. - const CULL_NO_OPAQUE = 0x80; - /// Skip triangular geometry. - const SKIP_TRIANGLES = 0x100; - /// Skip axis-aligned bounding boxes. - const SKIP_AABBS = 0x200; - } -} - -/// Type of a ray query intersection. -/// Matching vulkan constants can be found in -/// -/// but the actual values are different for candidate intersections. -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] -pub enum RayQueryIntersection { - /// No intersection found. - /// Matches `RayQueryCommittedIntersectionNoneKHR`. - #[default] - None = 0, - /// Intersecting with triangles. - /// Matches `RayQueryCommittedIntersectionTriangleKHR` and `RayQueryCandidateIntersectionTriangleKHR`. - Triangle = 1, - /// Intersecting with generated primitives. - /// Matches `RayQueryCommittedIntersectionGeneratedKHR`. - Generated = 2, - /// Intersecting with Axis Aligned Bounding Boxes. - /// Matches `RayQueryCandidateIntersectionAABBKHR`. - Aabb = 3, -} - -/// Shader module. -/// -/// A module is a set of constants, global variables and functions, as well as -/// the types required to define them. -/// -/// Some functions are marked as entry points, to be used in a certain shader stage. -/// -/// To create a new module, use the `Default` implementation. -/// Alternatively, you can load an existing shader using one of the [available front ends][front]. -/// -/// When finished, you can export modules using one of the [available backends][back]. -/// -/// ## Module arenas -/// -/// Most module contents are stored in [`Arena`]s. In a valid module, arena -/// elements only refer to prior arena elements. That is, whenever an element in -/// some `Arena` contains a `Handle` referring to another element the same -/// arena, the handle's referent always precedes the element containing the -/// handle. -/// -/// The elements of [`Module::types`] may refer to [`Expression`]s in -/// [`Module::global_expressions`], and those expressions may in turn refer back -/// to [`Type`]s in [`Module::types`]. In a valid module, there exists an order -/// in which all types and global expressions can be visited such that: -/// -/// - types and expressions are visited in the order in which they appear in -/// their arenas, and -/// -/// - every element refers only to previously visited elements. -/// -/// This implies that the graph of types and global expressions is acyclic. -/// (However, it is a stronger condition: there are cycle-free arrangements of -/// types and expressions for which an order like the one described above does -/// not exist. Modules arranged in such a way are not valid.) -#[derive(Debug, Default, Clone)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub struct Module { - /// Arena for the types defined in this module. - /// - /// See the [`Module`] docs for more details about this field. - pub types: UniqueArena, - /// Dictionary of special type handles. - pub special_types: SpecialTypes, - /// Arena for the constants defined in this module. - pub constants: Arena, - /// Arena for the pipeline-overridable constants defined in this module. - pub overrides: Arena, - /// Arena for the global variables defined in this module. - pub global_variables: Arena, - /// [Constant expressions] and [override expressions] used by this module. - /// - /// If an expression is in this arena, then its subexpressions are in this - /// arena too. In other words, every `Handle` in this arena - /// refers to an [`Expression`] in this arena too. - /// - /// See the [`Module`] docs for more details about this field. - /// - /// [Constant expressions]: index.html#constant-expressions - /// [override expressions]: index.html#override-expressions - pub global_expressions: Arena, - /// Arena for the functions defined in this module. - /// - /// Each function must appear in this arena strictly before all its callers. - /// Recursion is not supported. - pub functions: Arena, - /// Entry points. - pub entry_points: Vec, - /// Arena for all diagnostic filter rules parsed in this module, including those in functions - /// and statements. - /// - /// This arena contains elements of a _tree_ of diagnostic filter rules. When nodes are built - /// by a front-end, they refer to a parent scope - pub diagnostic_filters: Arena, - /// The leaf of all diagnostic filter rules tree parsed from directives in this module. - /// - /// In WGSL, this corresponds to `diagnostic(…);` directives. - /// - /// See [`DiagnosticFilterNode`] for details on how the tree is represented and used in - /// validation. - pub diagnostic_filter_leaf: Option>, -} diff --git a/naga/src/proc/terminator.rs b/naga/src/proc/terminator.rs index b29ccb054a3..f76d4c06a3b 100644 --- a/naga/src/proc/terminator.rs +++ b/naga/src/proc/terminator.rs @@ -36,6 +36,7 @@ pub fn ensure_block_returns(block: &mut crate::Block) { | S::ImageStore { .. } | S::Call { .. } | S::RayQuery { .. } + | S::MeshFunction(..) | S::Atomic { .. } | S::ImageAtomic { .. } | S::WorkGroupUniformLoad { .. } diff --git a/naga/src/valid/function.rs b/naga/src/valid/function.rs index 8166a1ab824..1d8913a204e 100644 --- a/naga/src/valid/function.rs +++ b/naga/src/valid/function.rs @@ -1546,8 +1546,7 @@ impl super::Validator { // TODO: ensure this is the last statement executed let ensure_correct = |e: Handle| -> Result<(), WithSpan> { - let t = context.resolve_type(e, &self.valid_expression_set)?; - match *t { + match *context.resolve_type_inner(e, &self.valid_expression_set)? { Ti::Scalar(crate::Scalar::U32) => Ok(()), _ => Err(FunctionError::InvalidMeshFunctionType(e) .with_span_static(span, "invalid u32")), diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index be033e006d9..7d297f3ba70 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -298,7 +298,6 @@ impl VaryingContext<'_> { match self.stage { St::Compute | St::Fragment | St::Task | St::Mesh => !self.output, St::Vertex => false, - St::Task | St::Mesh => unreachable!(), }, *ty_inner == Ti::Scalar(crate::Scalar::U32), ), From 53f28910cb9c3a06bc0253e0c0f855a2a24b0ed3 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Mon, 7 Jul 2025 12:48:03 -0500 Subject: [PATCH 16/84] Updated naga snapshots --- naga/tests/out/analysis/wgsl-access.info.ron | 4 ++-- naga/tests/out/ir/wgsl-const_assert.compact.ron | 2 ++ naga/tests/out/ir/wgsl-const_assert.ron | 2 ++ naga/tests/out/ir/wgsl-diagnostic-filter.compact.ron | 2 ++ naga/tests/out/ir/wgsl-diagnostic-filter.ron | 2 ++ naga/tests/out/ir/wgsl-local-const.compact.ron | 2 ++ naga/tests/out/ir/wgsl-local-const.ron | 2 ++ .../out/ir/wgsl-template-list-trailing-comma.compact.ron | 2 ++ naga/tests/out/ir/wgsl-template-list-trailing-comma.ron | 2 ++ naga/tests/out/ir/wgsl-types_with_comments.compact.ron | 2 ++ naga/tests/out/ir/wgsl-types_with_comments.ron | 2 ++ 11 files changed, 22 insertions(+), 2 deletions(-) diff --git a/naga/tests/out/analysis/wgsl-access.info.ron b/naga/tests/out/analysis/wgsl-access.info.ron index c107e74998c..c22cd768f2e 100644 --- a/naga/tests/out/analysis/wgsl-access.info.ron +++ b/naga/tests/out/analysis/wgsl-access.info.ron @@ -2873,7 +2873,7 @@ ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: Some(0), requirements: (""), @@ -3151,7 +3151,7 @@ ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), uniformity: ( non_uniform_result: Some(2), requirements: (""), diff --git a/naga/tests/out/ir/wgsl-const_assert.compact.ron b/naga/tests/out/ir/wgsl-const_assert.compact.ron index c10c9f97d32..4ddf3e8c78a 100644 --- a/naga/tests/out/ir/wgsl-const_assert.compact.ron +++ b/naga/tests/out/ir/wgsl-const_assert.compact.ron @@ -32,6 +32,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/wgsl-const_assert.ron b/naga/tests/out/ir/wgsl-const_assert.ron index c10c9f97d32..4ddf3e8c78a 100644 --- a/naga/tests/out/ir/wgsl-const_assert.ron +++ b/naga/tests/out/ir/wgsl-const_assert.ron @@ -32,6 +32,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/wgsl-diagnostic-filter.compact.ron b/naga/tests/out/ir/wgsl-diagnostic-filter.compact.ron index dc4d2defdbd..e3ab7162dbb 100644 --- a/naga/tests/out/ir/wgsl-diagnostic-filter.compact.ron +++ b/naga/tests/out/ir/wgsl-diagnostic-filter.compact.ron @@ -71,6 +71,8 @@ ], diagnostic_filter_leaf: Some(0), ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [ diff --git a/naga/tests/out/ir/wgsl-diagnostic-filter.ron b/naga/tests/out/ir/wgsl-diagnostic-filter.ron index dc4d2defdbd..e3ab7162dbb 100644 --- a/naga/tests/out/ir/wgsl-diagnostic-filter.ron +++ b/naga/tests/out/ir/wgsl-diagnostic-filter.ron @@ -71,6 +71,8 @@ ], diagnostic_filter_leaf: Some(0), ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [ diff --git a/naga/tests/out/ir/wgsl-local-const.compact.ron b/naga/tests/out/ir/wgsl-local-const.compact.ron index 8bce0bb0084..769d1844f67 100644 --- a/naga/tests/out/ir/wgsl-local-const.compact.ron +++ b/naga/tests/out/ir/wgsl-local-const.compact.ron @@ -98,6 +98,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/wgsl-local-const.ron b/naga/tests/out/ir/wgsl-local-const.ron index 8bce0bb0084..769d1844f67 100644 --- a/naga/tests/out/ir/wgsl-local-const.ron +++ b/naga/tests/out/ir/wgsl-local-const.ron @@ -98,6 +98,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/wgsl-template-list-trailing-comma.compact.ron b/naga/tests/out/ir/wgsl-template-list-trailing-comma.compact.ron index 67ec4ffb52d..0ba087d362f 100644 --- a/naga/tests/out/ir/wgsl-template-list-trailing-comma.compact.ron +++ b/naga/tests/out/ir/wgsl-template-list-trailing-comma.compact.ron @@ -188,6 +188,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/wgsl-template-list-trailing-comma.ron b/naga/tests/out/ir/wgsl-template-list-trailing-comma.ron index 67ec4ffb52d..0ba087d362f 100644 --- a/naga/tests/out/ir/wgsl-template-list-trailing-comma.ron +++ b/naga/tests/out/ir/wgsl-template-list-trailing-comma.ron @@ -188,6 +188,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/wgsl-types_with_comments.compact.ron b/naga/tests/out/ir/wgsl-types_with_comments.compact.ron index dde1bd367b0..05e0f1b38dd 100644 --- a/naga/tests/out/ir/wgsl-types_with_comments.compact.ron +++ b/naga/tests/out/ir/wgsl-types_with_comments.compact.ron @@ -114,6 +114,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/wgsl-types_with_comments.ron b/naga/tests/out/ir/wgsl-types_with_comments.ron index 3a23c49c4f2..84612852d6b 100644 --- a/naga/tests/out/ir/wgsl-types_with_comments.ron +++ b/naga/tests/out/ir/wgsl-types_with_comments.ron @@ -170,6 +170,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], From f71ff9b46068339fa1fea44d68e2d7eebec44887 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Mon, 7 Jul 2025 13:40:55 -0500 Subject: [PATCH 17/84] A little more work --- naga/src/front/wgsl/parse/conv.rs | 4 ++ naga/src/front/wgsl/parse/mod.rs | 37 ++++++++++++++-- naga/tests/in/wgsl/mesh-shader.toml | 18 ++++++++ naga/tests/in/wgsl/mesh-shader.wgsl | 65 +++++++++++++++++++++++++++++ 4 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 naga/tests/in/wgsl/mesh-shader.toml create mode 100644 naga/tests/in/wgsl/mesh-shader.wgsl diff --git a/naga/src/front/wgsl/parse/conv.rs b/naga/src/front/wgsl/parse/conv.rs index cbc485fb24a..5f63f2b0c31 100644 --- a/naga/src/front/wgsl/parse/conv.rs +++ b/naga/src/front/wgsl/parse/conv.rs @@ -49,6 +49,10 @@ pub fn map_built_in( "subgroup_id" => crate::BuiltIn::SubgroupId, "subgroup_size" => crate::BuiltIn::SubgroupSize, "subgroup_invocation_id" => crate::BuiltIn::SubgroupInvocationId, + // mesh + "cull_primitive" => crate::BuiltIn::CullPrimitive, + "line_indices" => crate::BuiltIn::LineIndices, + "triangle_indices" => crate::BuiltIn::TriangleIndices, _ => return Err(Box::new(Error::UnknownBuiltin(span))), }; match built_in { diff --git a/naga/src/front/wgsl/parse/mod.rs b/naga/src/front/wgsl/parse/mod.rs index 892930b4301..7a3980ff41d 100644 --- a/naga/src/front/wgsl/parse/mod.rs +++ b/naga/src/front/wgsl/parse/mod.rs @@ -2778,12 +2778,15 @@ impl Parser { // read attributes let mut binding = None; let mut stage = ParsedAttribute::default(); - let mut compute_span = Span::new(0, 0); + let mut compute_like_span = Span::new(0, 0); let mut workgroup_size = ParsedAttribute::default(); let mut early_depth_test = ParsedAttribute::default(); let (mut bind_index, mut bind_group) = (ParsedAttribute::default(), ParsedAttribute::default()); let mut id = ParsedAttribute::default(); + let mut payload = ParsedAttribute::default(); + let mut vertex_output = ParsedAttribute::default(); + let mut primitive_output = ParsedAttribute::default(); let mut must_use: ParsedAttribute = ParsedAttribute::default(); @@ -2842,7 +2845,33 @@ impl Parser { } "compute" => { stage.set(ShaderStage::Compute, name_span)?; - compute_span = name_span; + compute_like_span = name_span; + } + "task" => { + stage.set(ShaderStage::Task, name_span)?; + compute_like_span = name_span; + } + "mesh" => { + stage.set(ShaderStage::Mesh, name_span)?; + compute_like_span = name_span; + } + "payload" => { + lexer.expect(Token::Paren('('))?; + payload.set(lexer.next_ident_with_span()?, name_span)?; + lexer.expect(Token::Paren(')'))?; + } + "vertex_output" | "primitive_output" => { + lexer.expect(Token::Paren('('))?; + let type_ident = lexer.next_ident_with_span()?; + lexer.expect(Token::Separator(','))?; + let max_output = self.general_expression(lexer, &mut ctx)?; + let end_span = lexer.expect_span(Token::Paren(')'))?; + let total_span = name_span.until(&end_span); + if name == "vertex_output" { + vertex_output.set((type_ident, max_output), total_span)?; + } else if name == "primitive_output" { + primitive_output.set((type_ident, max_output), total_span)?; + } } "workgroup_size" => { lexer.expect(Token::Paren('('))?; @@ -3008,8 +3037,8 @@ impl Parser { )?; Some(ast::GlobalDeclKind::Fn(ast::Function { entry_point: if let Some(stage) = stage.value { - if stage == ShaderStage::Compute && workgroup_size.value.is_none() { - return Err(Box::new(Error::MissingWorkgroupSize(compute_span))); + if stage.compute_like() && workgroup_size.value.is_none() { + return Err(Box::new(Error::MissingWorkgroupSize(compute_like_span))); } Some(ast::EntryPoint { stage, diff --git a/naga/tests/in/wgsl/mesh-shader.toml b/naga/tests/in/wgsl/mesh-shader.toml new file mode 100644 index 00000000000..bbbea9c3f05 --- /dev/null +++ b/naga/tests/in/wgsl/mesh-shader.toml @@ -0,0 +1,18 @@ +# Stolen from ray-query.toml + +god_mode = true +targets = "SPIRV | METAL | HLSL" + +[msl] +fake_missing_bindings = true +lang_version = [2, 4] +spirv_cross_compatibility = false +zero_initialize_workgroup_memory = false + +[hlsl] +shader_model = "V6_5" +fake_missing_bindings = true +zero_initialize_workgroup_memory = true + +[spv] +version = [1, 4] diff --git a/naga/tests/in/wgsl/mesh-shader.wgsl b/naga/tests/in/wgsl/mesh-shader.wgsl new file mode 100644 index 00000000000..64d9ad09b14 --- /dev/null +++ b/naga/tests/in/wgsl/mesh-shader.wgsl @@ -0,0 +1,65 @@ +enable mesh_shading; + +const positions = array( + vec4(0.,-1.,0.,1.), + vec4(-1.,1.,0.,1.), + vec4(1.,1.,0.,1.) +); +const colors = array( + vec4(0.,1.,0.,1.), + vec4(0.,0.,1.,1.), + vec4(1.,0.,0.,1.) +); +struct TaskPayload { + colorMask: vec4, + visible: bool, +} +var taskPayload: TaskPayload; +var workgroupData: f32; +struct VertexOutput { + @builtin(position) position: vec4, + @location(0) color: vec4, +} +struct PrimitiveOutput { + @builtin(triangle_indices) index: vec3, + @builtin(cull_primitive) cull: bool, + @location(1) colorMask: vec4, +} +@task +@payload(taskPayload) +@workgroup_size(1) +fn ts_main() -> vec3 { + workgroupData = 1.0; + taskPayload.colorMask = vec4(1.0, 1.0, 0.0, 1.0); + taskPayload.visible = true; + return vec3(3, 1, 1); +} +@mesh +@payload(taskPayload) +@vertex_output(VertexOutput, 3) @primitive_output(PrimitiveOutput, 1) +@workgroup_size(1) +fn ms_main(@builtin(local_invocation_index) index: u32, @builtin(global_invocation_id) id: vec3) { + setMeshOutputs(3u, 1u); + workgroupData = 2.0; + setVertex(0, VertexOutput { + position: positions[0], + color: colors[0] * taskPayload.colorMask, + }); + setVertex(1, VertexOutput { + position: positions[1], + color: colors[1] * taskPayload.colorMask, + }); + setVertex(2, VertexOutput { + position: positions[2], + color: colors[2] * taskPayload.colorMask, + }); + setPrimitive(0, PrimitiveOutput { + index: vec3(0, 1, 2), + cull: !taskPayload.visible, + colorMask: vec4(1.0, 0.0, 1.0, 1.0), + }); +} +@fragment +fn fs_main(vertex: VertexOutput, primitive: @builtin(primitive) PrimitiveOutput) -> @location(0) vec4 { + return vertex.color * primitive.colorMask; +} \ No newline at end of file From 145699ca0e4f41f33dd46b349cb131e465a33d38 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Mon, 7 Jul 2025 13:50:14 -0500 Subject: [PATCH 18/84] Worked a little more --- naga/tests/in/wgsl/mesh-shader.wgsl | 41 ++++++++++++++++------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/naga/tests/in/wgsl/mesh-shader.wgsl b/naga/tests/in/wgsl/mesh-shader.wgsl index 64d9ad09b14..3558fbb28af 100644 --- a/naga/tests/in/wgsl/mesh-shader.wgsl +++ b/naga/tests/in/wgsl/mesh-shader.wgsl @@ -25,6 +25,9 @@ struct PrimitiveOutput { @builtin(cull_primitive) cull: bool, @location(1) colorMask: vec4, } +struct PrimitiveInput { + @location(1) colorMask: vec4, +} @task @payload(taskPayload) @workgroup_size(1) @@ -41,25 +44,27 @@ fn ts_main() -> vec3 { fn ms_main(@builtin(local_invocation_index) index: u32, @builtin(global_invocation_id) id: vec3) { setMeshOutputs(3u, 1u); workgroupData = 2.0; - setVertex(0, VertexOutput { - position: positions[0], - color: colors[0] * taskPayload.colorMask, - }); - setVertex(1, VertexOutput { - position: positions[1], - color: colors[1] * taskPayload.colorMask, - }); - setVertex(2, VertexOutput { - position: positions[2], - color: colors[2] * taskPayload.colorMask, - }); - setPrimitive(0, PrimitiveOutput { - index: vec3(0, 1, 2), - cull: !taskPayload.visible, - colorMask: vec4(1.0, 0.0, 1.0, 1.0), - }); + var v: VertexOutput; + + v.position = positions[0]; + v.color = colors[0] * taskPayload.colorMask; + setVertex(0, v); + + v.position = positions[1]; + v.color = colors[1] * taskPayload.colorMask; + setVertex(1, v); + + v.position = positions[2]; + v.color = colors[2] * taskPayload.colorMask; + setVertex(2, v); + + var p: PrimitiveOutput; + p.index = vec3(0, 1, 2); + p.cull = !taskPayload.visible; + p.colorMask = vec4(1.0, 0.0, 1.0, 1.0); + setPrimitive(0, p); } @fragment -fn fs_main(vertex: VertexOutput, primitive: @builtin(primitive) PrimitiveOutput) -> @location(0) vec4 { +fn fs_main(vertex: VertexOutput, primitive: PrimitiveInput) -> @location(0) vec4 { return vertex.color * primitive.colorMask; } \ No newline at end of file From c6e0450a906ecc2e2eff054e96001f028aa3dc88 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Mon, 7 Jul 2025 18:52:02 -0500 Subject: [PATCH 19/84] Now (almost) parses! --- naga/src/back/glsl/mod.rs | 2 +- naga/src/back/hlsl/conv.rs | 1 + naga/src/back/hlsl/writer.rs | 2 +- naga/src/back/msl/mod.rs | 1 + naga/src/back/msl/writer.rs | 2 +- naga/src/back/spv/writer.rs | 1 + naga/src/common/wgsl/to_wgsl.rs | 3 +- naga/src/front/glsl/mod.rs | 2 +- naga/src/front/spv/mod.rs | 2 ++ naga/src/front/wgsl/lower/mod.rs | 51 +++++++++++++++++++++++++++++ naga/src/front/wgsl/parse/conv.rs | 1 + naga/src/ir/mod.rs | 1 + naga/src/valid/function.rs | 39 +++++++++++++--------- naga/src/valid/interface.rs | 10 +++++- naga/tests/in/wgsl/mesh-shader.wgsl | 15 ++++++--- wgpu-core/src/validation.rs | 2 +- 16 files changed, 108 insertions(+), 27 deletions(-) diff --git a/naga/src/back/glsl/mod.rs b/naga/src/back/glsl/mod.rs index fdfeba7cc29..65bdcc392be 100644 --- a/naga/src/back/glsl/mod.rs +++ b/naga/src/back/glsl/mod.rs @@ -5262,7 +5262,7 @@ const fn glsl_built_in(built_in: crate::BuiltIn, options: VaryingOptions) -> &'s Bi::SubgroupInvocationId => "gl_SubgroupInvocationID", // mesh // TODO: figure out how to map these to glsl things as glsl treats them as arrays - Bi::CullPrimitive | Bi::LineIndices | Bi::TriangleIndices => { + Bi::CullPrimitive | Bi::LineIndices | Bi::TriangleIndices | Bi::MeshTaskSize => { unimplemented!() } } diff --git a/naga/src/back/hlsl/conv.rs b/naga/src/back/hlsl/conv.rs index 32d6bc1e35b..7b71de99053 100644 --- a/naga/src/back/hlsl/conv.rs +++ b/naga/src/back/hlsl/conv.rs @@ -186,6 +186,7 @@ impl crate::BuiltIn { Self::CullPrimitive => "SV_CullPrimitive", // TODO: make this work Self::LineIndices | Self::TriangleIndices => unimplemented!(), + Self::MeshTaskSize => unreachable!(), }) } } diff --git a/naga/src/back/hlsl/writer.rs b/naga/src/back/hlsl/writer.rs index d9f48168c6f..0df2dcfa1ff 100644 --- a/naga/src/back/hlsl/writer.rs +++ b/naga/src/back/hlsl/writer.rs @@ -490,7 +490,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { self.write_wrapped_functions(module, &ctx)?; - if ep.stage == ShaderStage::Compute { + if ep.stage.compute_like() { // HLSL is calling workgroup size "num threads" let num_threads = ep.workgroup_size; writeln!( diff --git a/naga/src/back/msl/mod.rs b/naga/src/back/msl/mod.rs index d40b15e0d80..03565f6018b 100644 --- a/naga/src/back/msl/mod.rs +++ b/naga/src/back/msl/mod.rs @@ -654,6 +654,7 @@ impl ResolvedBinding { Bi::CullPrimitive => "primitive_culled", // TODO: figure out how to make this written as a function call Bi::LineIndices | Bi::TriangleIndices => unimplemented!(), + Bi::MeshTaskSize => unreachable!(), }; write!(out, "{name}")?; } diff --git a/naga/src/back/msl/writer.rs b/naga/src/back/msl/writer.rs index 1890d6d081b..f823cf6b2f7 100644 --- a/naga/src/back/msl/writer.rs +++ b/naga/src/back/msl/writer.rs @@ -7174,7 +7174,7 @@ mod workgroup_mem_init { fun_info: &valid::FunctionInfo, ) -> bool { options.zero_initialize_workgroup_memory - && ep.stage == crate::ShaderStage::Compute + && ep.stage.compute_like() && module.global_variables.iter().any(|(handle, var)| { !fun_info[handle].is_empty() && var.space == crate::AddressSpace::WorkGroup }) diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index c4a9da3514d..46b2f152428 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -2123,6 +2123,7 @@ impl Writer { Bi::CullPrimitive => BuiltIn::CullPrimitiveEXT, Bi::LineIndices => BuiltIn::PrimitiveLineIndicesEXT, Bi::TriangleIndices => BuiltIn::PrimitiveTriangleIndicesEXT, + Bi::MeshTaskSize => unreachable!(), }; self.decorate(id, Decoration::BuiltIn, &[built_in as u32]); diff --git a/naga/src/common/wgsl/to_wgsl.rs b/naga/src/common/wgsl/to_wgsl.rs index f85d90ed232..9a1402ec5fc 100644 --- a/naga/src/common/wgsl/to_wgsl.rs +++ b/naga/src/common/wgsl/to_wgsl.rs @@ -191,7 +191,8 @@ impl TryToWgsl for crate::BuiltIn { | Bi::WorkGroupSize | Bi::CullPrimitive | Bi::TriangleIndices - | Bi::LineIndices => return None, + | Bi::LineIndices + | Bi::MeshTaskSize => return None, }) } } diff --git a/naga/src/front/glsl/mod.rs b/naga/src/front/glsl/mod.rs index 876add46a1c..e5eda6b3ad9 100644 --- a/naga/src/front/glsl/mod.rs +++ b/naga/src/front/glsl/mod.rs @@ -107,7 +107,7 @@ impl ShaderMetadata { self.version = 0; self.profile = Profile::Core; self.stage = stage; - self.workgroup_size = [u32::from(stage == ShaderStage::Compute); 3]; + self.workgroup_size = [u32::from(stage.compute_like()); 3]; self.early_fragment_tests = false; self.extensions.clear(); } diff --git a/naga/src/front/spv/mod.rs b/naga/src/front/spv/mod.rs index a4e70aa8d28..a6c6f244993 100644 --- a/naga/src/front/spv/mod.rs +++ b/naga/src/front/spv/mod.rs @@ -4896,6 +4896,8 @@ impl> Frontend { spirv::ExecutionModel::Vertex => crate::ShaderStage::Vertex, spirv::ExecutionModel::Fragment => crate::ShaderStage::Fragment, spirv::ExecutionModel::GLCompute => crate::ShaderStage::Compute, + spirv::ExecutionModel::TaskEXT => crate::ShaderStage::Task, + spirv::ExecutionModel::MeshEXT => crate::ShaderStage::Mesh, _ => return Err(Error::UnsupportedExecutionModel(exec_model as u32)), }, name, diff --git a/naga/src/front/wgsl/lower/mod.rs b/naga/src/front/wgsl/lower/mod.rs index 98628baddb2..df1e3c9c05a 100644 --- a/naga/src/front/wgsl/lower/mod.rs +++ b/naga/src/front/wgsl/lower/mod.rs @@ -3132,6 +3132,57 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { ); return Ok(Some(result)); } + + "setMeshOutputs" | "setVertex" | "setPrimitive" => { + let mut args = ctx.prepare_args(arguments, 2, span); + let arg1 = self.expression(args.next()?, ctx)?; + let arg2 = self.expression(args.next()?, ctx)?; + let mut convert_to_u32 = + |expr: Handle| -> Result> { + let goal_inner = crate::TypeInner::Scalar(crate::Scalar::U32); + match goal_inner.scalar_for_conversions(&ctx.module.types) { + Some(goal_scalar) => { + let arg_span = ctx.get_expression_span(expr); + ctx.try_automatic_conversion_for_leaf_scalar( + expr, + goal_scalar, + arg_span, + ) + } + // No conversion is necessary. + None => Ok(expr), + } + }; + let arg1 = convert_to_u32(arg1)?; + let arg2 = if function.name == "setMeshOutputs" { + convert_to_u32(arg2)? + } else { + arg2 + }; + args.finish()?; + + let rctx = ctx.runtime_expression_ctx(span)?; + rctx.block.push( + crate::Statement::MeshFunction(match function.name { + "setMeshOutputs" => crate::MeshFunction::SetMeshOutputs { + vertex_count: arg1, + primitive_count: arg2, + }, + "setVertex" => crate::MeshFunction::SetVertex { + index: arg1, + value: arg2, + }, + "setPrimitive" => crate::MeshFunction::SetPrimitive { + index: arg1, + value: arg2, + }, + _ => unreachable!(), + }), + span, + ); + + return Ok(None); + } _ => { return Err(Box::new(Error::UnknownIdent(function.span, function.name))) } diff --git a/naga/src/front/wgsl/parse/conv.rs b/naga/src/front/wgsl/parse/conv.rs index 5f63f2b0c31..a5dfdc07520 100644 --- a/naga/src/front/wgsl/parse/conv.rs +++ b/naga/src/front/wgsl/parse/conv.rs @@ -53,6 +53,7 @@ pub fn map_built_in( "cull_primitive" => crate::BuiltIn::CullPrimitive, "line_indices" => crate::BuiltIn::LineIndices, "triangle_indices" => crate::BuiltIn::TriangleIndices, + "mesh_task_size" => crate::BuiltIn::MeshTaskSize, _ => return Err(Box::new(Error::UnknownBuiltin(span))), }; match built_in { diff --git a/naga/src/ir/mod.rs b/naga/src/ir/mod.rs index 6c4b8720c5f..98ea6019c52 100644 --- a/naga/src/ir/mod.rs +++ b/naga/src/ir/mod.rs @@ -400,6 +400,7 @@ pub enum BuiltIn { SubgroupSize, SubgroupInvocationId, // mesh + MeshTaskSize, CullPrimitive, LineIndices, TriangleIndices, diff --git a/naga/src/valid/function.rs b/naga/src/valid/function.rs index 1d8913a204e..0d993d0c2ee 100644 --- a/naga/src/valid/function.rs +++ b/naga/src/valid/function.rs @@ -217,8 +217,8 @@ pub enum FunctionError { EmitResult(Handle), #[error("Expression not visited by the appropriate statement")] UnvisitedExpression(Handle), - #[error("U32 {0:?} is not a matching expression")] - InvalidMeshFunctionType(Handle), + #[error("Expression {0:?} should be u32, but isn't")] + InvalidMeshFunctionCall(Handle), } bitflags::bitflags! { @@ -1543,27 +1543,36 @@ impl super::Validator { } } S::MeshFunction(func) => { - // TODO: ensure this is the last statement executed - let ensure_correct = - |e: Handle| -> Result<(), WithSpan> { - match *context.resolve_type_inner(e, &self.valid_expression_set)? { - Ti::Scalar(crate::Scalar::U32) => Ok(()), - _ => Err(FunctionError::InvalidMeshFunctionType(e) - .with_span_static(span, "invalid u32")), + let ensure_u32 = + |expr: Handle| -> Result<(), WithSpan> { + let u32_ty = TypeResolution::Value(Ti::Scalar(crate::Scalar::U32)); + let ty = context + .resolve_type_impl(expr, &self.valid_expression_set) + .map_err_inner(|source| { + FunctionError::Expression { + source, + handle: expr, + } + .with_span_handle(expr, context.expressions) + })?; + if !context.compare_types(&u32_ty, ty) { + return Err(FunctionError::InvalidMeshFunctionCall(expr) + .with_span_handle(expr, context.expressions)); } + Ok(()) }; match func { crate::MeshFunction::SetMeshOutputs { vertex_count, primitive_count, } => { - ensure_correct(vertex_count)?; - ensure_correct(primitive_count)?; + ensure_u32(vertex_count)?; + ensure_u32(primitive_count)?; } - crate::MeshFunction::SetVertex { index, value } - | crate::MeshFunction::SetPrimitive { index, value } => { - ensure_correct(index)?; - ensure_correct(value)?; + crate::MeshFunction::SetVertex { index, value: _ } + | crate::MeshFunction::SetPrimitive { index, value: _ } => { + ensure_u32(index)?; + // TODO: ensure it is correct for the value } } } diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index 7d297f3ba70..ecbddc32963 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -321,6 +321,14 @@ impl VaryingContext<'_> { scalar: crate::Scalar::U32, }, ), + Bi::MeshTaskSize => ( + self.stage == St::Task && self.output, + *ty_inner + == Ti::Vector { + size: Vs::Tri, + scalar: crate::Scalar::U32, + }, + ), }; if !visible { @@ -693,7 +701,7 @@ impl super::Validator { } } - if ep.stage == crate::ShaderStage::Compute { + if ep.stage.compute_like() { if ep .workgroup_size .iter() diff --git a/naga/tests/in/wgsl/mesh-shader.wgsl b/naga/tests/in/wgsl/mesh-shader.wgsl index 3558fbb28af..0020bc823e7 100644 --- a/naga/tests/in/wgsl/mesh-shader.wgsl +++ b/naga/tests/in/wgsl/mesh-shader.wgsl @@ -21,17 +21,20 @@ struct VertexOutput { @location(0) color: vec4, } struct PrimitiveOutput { - @builtin(triangle_indices) index: vec3, + @builtin(triangle_indices) index: vec3, @builtin(cull_primitive) cull: bool, @location(1) colorMask: vec4, } struct PrimitiveInput { @location(1) colorMask: vec4, +} +fn test_function(input: u32) { + } @task @payload(taskPayload) @workgroup_size(1) -fn ts_main() -> vec3 { +fn ts_main() -> @builtin(mesh_task_size) vec3 { workgroupData = 1.0; taskPayload.colorMask = vec4(1.0, 1.0, 0.0, 1.0); taskPayload.visible = true; @@ -46,23 +49,25 @@ fn ms_main(@builtin(local_invocation_index) index: u32, @builtin(global_invocati workgroupData = 2.0; var v: VertexOutput; + test_function(1); + v.position = positions[0]; v.color = colors[0] * taskPayload.colorMask; setVertex(0, v); v.position = positions[1]; v.color = colors[1] * taskPayload.colorMask; - setVertex(1, v); + setVertex(1u, v); v.position = positions[2]; v.color = colors[2] * taskPayload.colorMask; - setVertex(2, v); + setVertex(2u, v); var p: PrimitiveOutput; p.index = vec3(0, 1, 2); p.cull = !taskPayload.visible; p.colorMask = vec4(1.0, 0.0, 1.0, 1.0); - setPrimitive(0, p); + setPrimitive(0u, p); } @fragment fn fs_main(vertex: VertexOutput, primitive: PrimitiveInput) -> @location(0) vec4 { diff --git a/wgpu-core/src/validation.rs b/wgpu-core/src/validation.rs index 566c96fe174..b5342f3e352 100644 --- a/wgpu-core/src/validation.rs +++ b/wgpu-core/src/validation.rs @@ -1222,7 +1222,7 @@ impl Interface { } // check workgroup size limits - if shader_stage == naga::ShaderStage::Compute { + if shader_stage.compute_like() { let max_workgroup_size_limits = [ self.limits.max_compute_workgroup_size_x, self.limits.max_compute_workgroup_size_y, From de03c4a640f76a2126497a27a5a2a58c7ec8e79f Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Wed, 9 Jul 2025 15:18:05 -0500 Subject: [PATCH 20/84] Updated wgsl file to not specify unsigned integer literals. Will work on auto interpreting that later --- naga/tests/in/wgsl/mesh-shader.wgsl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/naga/tests/in/wgsl/mesh-shader.wgsl b/naga/tests/in/wgsl/mesh-shader.wgsl index 0020bc823e7..753c32214a2 100644 --- a/naga/tests/in/wgsl/mesh-shader.wgsl +++ b/naga/tests/in/wgsl/mesh-shader.wgsl @@ -45,7 +45,7 @@ fn ts_main() -> @builtin(mesh_task_size) vec3 { @vertex_output(VertexOutput, 3) @primitive_output(PrimitiveOutput, 1) @workgroup_size(1) fn ms_main(@builtin(local_invocation_index) index: u32, @builtin(global_invocation_id) id: vec3) { - setMeshOutputs(3u, 1u); + setMeshOutputs(3, 1); workgroupData = 2.0; var v: VertexOutput; @@ -57,17 +57,17 @@ fn ms_main(@builtin(local_invocation_index) index: u32, @builtin(global_invocati v.position = positions[1]; v.color = colors[1] * taskPayload.colorMask; - setVertex(1u, v); + setVertex(1, v); v.position = positions[2]; v.color = colors[2] * taskPayload.colorMask; - setVertex(2u, v); + setVertex(2, v); var p: PrimitiveOutput; p.index = vec3(0, 1, 2); p.cull = !taskPayload.visible; p.colorMask = vec4(1.0, 0.0, 1.0, 1.0); - setPrimitive(0u, p); + setPrimitive(0, p); } @fragment fn fs_main(vertex: VertexOutput, primitive: PrimitiveInput) -> @location(0) vec4 { From 7884781c34d62702f09d4b4e916422271c2ada5d Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 12:13:32 -0500 Subject: [PATCH 21/84] Added more stuff to naga IR and a tiny bit of validation --- naga/src/back/spv/writer.rs | 1 + naga/src/front/wgsl/error.rs | 34 +++++++ naga/src/front/wgsl/lower/mod.rs | 164 +++++++++++++++++++++++++------ naga/src/front/wgsl/parse/ast.rs | 10 ++ naga/src/front/wgsl/parse/mod.rs | 34 ++++++- naga/src/ir/mod.rs | 7 +- naga/src/valid/interface.rs | 15 +++ wgpu-hal/src/metal/mod.rs | 3 - 8 files changed, 228 insertions(+), 40 deletions(-) diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 46b2f152428..fd451082f7e 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -1200,6 +1200,7 @@ impl Writer { Instruction::execution_mode( function_id, match mesh_info.topology { + crate::MeshOutputTopology::Points => spirv::ExecutionMode::OutputPoints, crate::MeshOutputTopology::Lines => spirv::ExecutionMode::OutputLinesEXT, crate::MeshOutputTopology::Triangles => { spirv::ExecutionMode::OutputTrianglesEXT diff --git a/naga/src/front/wgsl/error.rs b/naga/src/front/wgsl/error.rs index 1123caff6a3..edb2d808692 100644 --- a/naga/src/front/wgsl/error.rs +++ b/naga/src/front/wgsl/error.rs @@ -409,6 +409,19 @@ pub(crate) enum Error<'a> { accept_span: Span, accept_type: String, }, + MissingMeshShaderInfo { + mesh_attribute_span: Span, + }, + OneMeshShaderAttribute { + attribute_span: Span, + }, + ExpectedGlobalVariable { + name_span: Span, + }, + MeshPrimitiveNoDefinedTopology { + attribute_span: Span, + struct_span: Span, + }, } impl From for Error<'_> { @@ -1370,6 +1383,27 @@ impl<'a> Error<'a> { ], notes: vec![], }, + Error::MissingMeshShaderInfo { mesh_attribute_span} => ParseError { + message: "mesh shader entry point is missing @vertex_output or @primitive_output".into(), + labels: vec![(mesh_attribute_span, "mesh shader entry declared here".into())], + notes: vec![], + }, + Error::OneMeshShaderAttribute { attribute_span } => ParseError { + message: "only one of @vertex_output or @primitive_output was given".into(), + labels: vec![(attribute_span, "only one of @vertex_output or @primitive_output is provided".into())], + notes: vec![], + }, + Error::ExpectedGlobalVariable { name_span } => ParseError { + message: "expected global variable".to_string(), + // TODO: I would like to also include the global declaration span + labels: vec![(name_span, "variable used here".into())], + notes: vec![], + }, + Error::MeshPrimitiveNoDefinedTopology { struct_span, attribute_span } => ParseError { + message: "mesh primitive struct must have exactly one of point indices, line indicies, or triangle indices".to_string(), + labels: vec![(attribute_span, "primitive type declared here".into()), (struct_span, "primitive struct declared here".into())], + notes: vec![] + }, } } } diff --git a/naga/src/front/wgsl/lower/mod.rs b/naga/src/front/wgsl/lower/mod.rs index df1e3c9c05a..ebea293fd22 100644 --- a/naga/src/front/wgsl/lower/mod.rs +++ b/naga/src/front/wgsl/lower/mod.rs @@ -1479,47 +1479,147 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { .collect(); if let Some(ref entry) = f.entry_point { - let workgroup_size_info = if let Some(workgroup_size) = entry.workgroup_size { - // TODO: replace with try_map once stabilized - let mut workgroup_size_out = [1; 3]; - let mut workgroup_size_overrides_out = [None; 3]; - for (i, size) in workgroup_size.into_iter().enumerate() { - if let Some(size_expr) = size { - match self.const_u32(size_expr, &mut ctx.as_const()) { - Ok(value) => { - workgroup_size_out[i] = value.0; - } - Err(err) => { - if let Error::ConstantEvaluatorError(ref ty, _) = *err { - match **ty { - proc::ConstantEvaluatorError::OverrideExpr => { - workgroup_size_overrides_out[i] = - Some(self.workgroup_size_override( - size_expr, - &mut ctx.as_override(), - )?); - } - _ => { - return Err(err); + let (workgroup_size, workgroup_size_overrides) = + if let Some(workgroup_size) = entry.workgroup_size { + // TODO: replace with try_map once stabilized + let mut workgroup_size_out = [1; 3]; + let mut workgroup_size_overrides_out = [None; 3]; + for (i, size) in workgroup_size.into_iter().enumerate() { + if let Some(size_expr) = size { + match self.const_u32(size_expr, &mut ctx.as_const()) { + Ok(value) => { + workgroup_size_out[i] = value.0; + } + Err(err) => { + if let Error::ConstantEvaluatorError(ref ty, _) = *err { + match **ty { + proc::ConstantEvaluatorError::OverrideExpr => { + workgroup_size_overrides_out[i] = + Some(self.workgroup_size_override( + size_expr, + &mut ctx.as_override(), + )?); + } + _ => { + return Err(err); + } } + } else { + return Err(err); } - } else { - return Err(err); } } } } - } - if workgroup_size_overrides_out.iter().all(|x| x.is_none()) { - (workgroup_size_out, None) + if workgroup_size_overrides_out.iter().all(|x| x.is_none()) { + (workgroup_size_out, None) + } else { + (workgroup_size_out, Some(workgroup_size_overrides_out)) + } } else { - (workgroup_size_out, Some(workgroup_size_overrides_out)) + ([0; 3], None) + }; + + let mesh_info = if let Some(mesh_info) = entry.mesh_shader_info { + let mut const_u32 = |expr| match self.const_u32(expr, &mut ctx.as_const()) { + Ok(value) => Ok((value.0, None)), + Err(err) => { + if let Error::ConstantEvaluatorError(ref ty, _) = *err { + match **ty { + proc::ConstantEvaluatorError::OverrideExpr => Ok(( + 0, + Some( + // This is dubious but it seems the code isn't workgroup size specifc + self.workgroup_size_override(expr, &mut ctx.as_override())?, + ), + )), + _ => Err(err), + } + } else { + Err(err) + } + } + }; + let (max_vertices, max_vertices_override) = const_u32(mesh_info.vertex_count)?; + let (max_primitives, max_primitives_override) = + const_u32(mesh_info.primitive_count)?; + let vertex_output_type = + self.resolve_ast_type(mesh_info.vertex_type.0, &mut ctx.as_const())?; + let primitive_output_type = + self.resolve_ast_type(mesh_info.primitive_type.0, &mut ctx.as_const())?; + + let mut topology = None; + let struct_span = ctx.module.types.get_span(primitive_output_type); + match &ctx.module.types[primitive_output_type].inner { + &ir::TypeInner::Struct { + ref members, + span: _, + } => { + for member in members { + let out_topology = match member.binding { + Some(ir::Binding::BuiltIn(ir::BuiltIn::TriangleIndices)) => { + Some(ir::MeshOutputTopology::Triangles) + } + Some(ir::Binding::BuiltIn(ir::BuiltIn::LineIndices)) => { + Some(ir::MeshOutputTopology::Lines) + } + _ => None, + }; + if out_topology.is_some() { + if topology.is_some() { + return Err(Box::new(Error::MeshPrimitiveNoDefinedTopology { + attribute_span: mesh_info.primitive_type.1, + struct_span, + })); + } + topology = out_topology; + } + } + } + _ => { + return Err(Box::new(Error::MeshPrimitiveNoDefinedTopology { + attribute_span: mesh_info.primitive_type.1, + struct_span, + })) + } } + let topology = if let Some(t) = topology { + t + } else { + return Err(Box::new(Error::MeshPrimitiveNoDefinedTopology { + attribute_span: mesh_info.primitive_type.1, + struct_span, + })); + }; + + Some(ir::MeshStageInfo { + max_vertices, + max_vertices_override, + max_primitives, + max_primitives_override, + + vertex_output_type, + primitive_output_type, + topology, + }) + } else { + None + }; + + let task_payload = if let Some((var_name, var_span)) = entry.task_payload { + Some(match ctx.globals.get(var_name) { + Some(&LoweredGlobalDecl::Var(handle)) => handle, + Some(_) => { + return Err(Box::new(Error::ExpectedGlobalVariable { + name_span: var_span, + })) + } + None => return Err(Box::new(Error::UnknownIdent(var_span, var_name))), + }) } else { - ([0; 3], None) + None }; - let (workgroup_size, workgroup_size_overrides) = workgroup_size_info; ctx.module.entry_points.push(ir::EntryPoint { name: f.name.name.to_string(), stage: entry.stage, @@ -1527,8 +1627,8 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { workgroup_size, workgroup_size_overrides, function, - mesh_info: None, - task_payload: None, + mesh_info, + task_payload, }); Ok(LoweredGlobalDecl::EntryPoint( ctx.module.entry_points.len() - 1, diff --git a/naga/src/front/wgsl/parse/ast.rs b/naga/src/front/wgsl/parse/ast.rs index 345e9c4c486..dd69264d3d2 100644 --- a/naga/src/front/wgsl/parse/ast.rs +++ b/naga/src/front/wgsl/parse/ast.rs @@ -128,6 +128,16 @@ pub struct EntryPoint<'a> { pub stage: crate::ShaderStage, pub early_depth_test: Option, pub workgroup_size: Option<[Option>>; 3]>, + pub mesh_shader_info: Option>, + pub task_payload: Option<(&'a str, Span)>, +} + +#[derive(Debug, Clone, Copy)] +pub struct EntryPointMeshShaderInfo<'a> { + pub vertex_count: Handle>, + pub primitive_count: Handle>, + pub vertex_type: (Handle>, Span), + pub primitive_type: (Handle>, Span), } #[cfg(doc)] diff --git a/naga/src/front/wgsl/parse/mod.rs b/naga/src/front/wgsl/parse/mod.rs index 7a3980ff41d..1a7c66e15de 100644 --- a/naga/src/front/wgsl/parse/mod.rs +++ b/naga/src/front/wgsl/parse/mod.rs @@ -2862,15 +2862,17 @@ impl Parser { } "vertex_output" | "primitive_output" => { lexer.expect(Token::Paren('('))?; - let type_ident = lexer.next_ident_with_span()?; + let type_span = lexer.peek().1; + let typ = self.type_decl(lexer, &mut ctx)?; + let type_span = lexer.span_from(type_span.to_range().unwrap().start); lexer.expect(Token::Separator(','))?; let max_output = self.general_expression(lexer, &mut ctx)?; let end_span = lexer.expect_span(Token::Paren(')'))?; let total_span = name_span.until(&end_span); if name == "vertex_output" { - vertex_output.set((type_ident, max_output), total_span)?; + vertex_output.set((typ, type_span, max_output), total_span)?; } else if name == "primitive_output" { - primitive_output.set((type_ident, max_output), total_span)?; + primitive_output.set((typ, type_span, max_output), total_span)?; } } "workgroup_size" => { @@ -3040,10 +3042,36 @@ impl Parser { if stage.compute_like() && workgroup_size.value.is_none() { return Err(Box::new(Error::MissingWorkgroupSize(compute_like_span))); } + if stage == ShaderStage::Mesh + && (vertex_output.value.is_none() || primitive_output.value.is_none()) + { + return Err(Box::new(Error::MissingMeshShaderInfo { + mesh_attribute_span: compute_like_span, + })); + } + let mesh_shader_info = match (vertex_output.value, primitive_output.value) { + (Some(vertex_output), Some(primitive_output)) => { + Some(ast::EntryPointMeshShaderInfo { + vertex_count: vertex_output.2, + primitive_count: primitive_output.2, + vertex_type: (vertex_output.0, vertex_output.1), + primitive_type: (primitive_output.0, primitive_output.1), + }) + } + (None, None) => None, + (Some(v), None) | (None, Some(v)) => { + return Err(Box::new(Error::OneMeshShaderAttribute { + attribute_span: v.1, + })) + } + }; + Some(ast::EntryPoint { stage, early_depth_test: early_depth_test.value, workgroup_size: workgroup_size.value, + mesh_shader_info, + task_payload: payload.value, }) } else { None diff --git a/naga/src/ir/mod.rs b/naga/src/ir/mod.rs index 98ea6019c52..df769852d61 100644 --- a/naga/src/ir/mod.rs +++ b/naga/src/ir/mod.rs @@ -2529,11 +2529,12 @@ pub struct Module { pub doc_comments: Option>, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Copy)] #[cfg_attr(feature = "serialize", derive(Serialize))] #[cfg_attr(feature = "deserialize", derive(Deserialize))] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] pub enum MeshOutputTopology { + Points, Lines, Triangles, } @@ -2543,10 +2544,12 @@ pub enum MeshOutputTopology { #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[allow(dead_code)] pub struct MeshStageInfo { + /// Should be Some by the time it passes validation pub topology: MeshOutputTopology, - // Should this be an expression or what? Not clear pub max_vertices: u32, + pub max_vertices_override: Option>, pub max_primitives: u32, + pub max_primitives_override: Option>, pub vertex_output_type: Handle, pub primitive_output_type: Handle, } diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index ecbddc32963..1cf123b3f36 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -123,6 +123,10 @@ pub enum EntryPointError { InvalidIntegerInterpolation { location: u32 }, #[error(transparent)] Function(#[from] FunctionError), + #[error("Non mesh shader entry point cannot have mesh shader attributes")] + UnexpectedMeshShaderAttributes, + #[error("Non mesh/task shader entry point cannot have task payload attribute")] + UnexpectedTaskPayload, } fn storage_usage(access: crate::StorageAccess) -> GlobalUse { @@ -713,6 +717,17 @@ impl super::Validator { return Err(EntryPointError::UnexpectedWorkgroupSize.with_span()); } + if ep.stage != crate::ShaderStage::Mesh && ep.mesh_info.is_some() { + return Err(EntryPointError::UnexpectedMeshShaderAttributes.with_span()); + } + + if ep.stage != crate::ShaderStage::Task + && ep.stage != crate::ShaderStage::Mesh + && ep.task_payload.is_some() + { + return Err(EntryPointError::UnexpectedTaskPayload.with_span()); + } + let mut info = self .validate_function(&ep.function, module, mod_info, true) .map_err(WithSpan::into_other)?; diff --git a/wgpu-hal/src/metal/mod.rs b/wgpu-hal/src/metal/mod.rs index b3f82257b92..b5ae1dd5d5d 100644 --- a/wgpu-hal/src/metal/mod.rs +++ b/wgpu-hal/src/metal/mod.rs @@ -602,9 +602,6 @@ struct MultiStageData { vs: T, fs: T, cs: T, - // TODO: work on this for metal - /*ts: T, - ms: T,*/ } const NAGA_STAGES: MultiStageData = MultiStageData { From defa58b0f3a239844d3591e87d45125db021a3e1 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 12:22:59 -0500 Subject: [PATCH 22/84] Fixed some typos lol --- naga/src/front/wgsl/error.rs | 2 +- naga/src/front/wgsl/lower/mod.rs | 2 +- naga/src/front/wgsl/parse/mod.rs | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/naga/src/front/wgsl/error.rs b/naga/src/front/wgsl/error.rs index edb2d808692..c2a6c23c6ce 100644 --- a/naga/src/front/wgsl/error.rs +++ b/naga/src/front/wgsl/error.rs @@ -1400,7 +1400,7 @@ impl<'a> Error<'a> { notes: vec![], }, Error::MeshPrimitiveNoDefinedTopology { struct_span, attribute_span } => ParseError { - message: "mesh primitive struct must have exactly one of point indices, line indicies, or triangle indices".to_string(), + message: "mesh primitive struct must have exactly one of point indices, line indices, or triangle indices".to_string(), labels: vec![(attribute_span, "primitive type declared here".into()), (struct_span, "primitive struct declared here".into())], notes: vec![] }, diff --git a/naga/src/front/wgsl/lower/mod.rs b/naga/src/front/wgsl/lower/mod.rs index ebea293fd22..c0962ed89ba 100644 --- a/naga/src/front/wgsl/lower/mod.rs +++ b/naga/src/front/wgsl/lower/mod.rs @@ -1529,7 +1529,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { proc::ConstantEvaluatorError::OverrideExpr => Ok(( 0, Some( - // This is dubious but it seems the code isn't workgroup size specifc + // This is dubious but it seems the code isn't workgroup size specific self.workgroup_size_override(expr, &mut ctx.as_override())?, ), )), diff --git a/naga/src/front/wgsl/parse/mod.rs b/naga/src/front/wgsl/parse/mod.rs index 1a7c66e15de..ba281a06d2f 100644 --- a/naga/src/front/wgsl/parse/mod.rs +++ b/naga/src/front/wgsl/parse/mod.rs @@ -2863,16 +2863,16 @@ impl Parser { "vertex_output" | "primitive_output" => { lexer.expect(Token::Paren('('))?; let type_span = lexer.peek().1; - let typ = self.type_decl(lexer, &mut ctx)?; + let r#type = self.type_decl(lexer, &mut ctx)?; let type_span = lexer.span_from(type_span.to_range().unwrap().start); lexer.expect(Token::Separator(','))?; let max_output = self.general_expression(lexer, &mut ctx)?; let end_span = lexer.expect_span(Token::Paren(')'))?; let total_span = name_span.until(&end_span); if name == "vertex_output" { - vertex_output.set((typ, type_span, max_output), total_span)?; + vertex_output.set((r#type, type_span, max_output), total_span)?; } else if name == "primitive_output" { - primitive_output.set((typ, type_span, max_output), total_span)?; + primitive_output.set((r#type, type_span, max_output), total_span)?; } } "workgroup_size" => { From d5f1770aaa43270c92a299271c9afca40433d579 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 12:25:24 -0500 Subject: [PATCH 23/84] Added changelog entry --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c27699365fb..a50398cf186 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,9 @@ We have merged the acceleration structure feature into the `RayQuery` feature. T By @Vecvec in [#7913](https://github.com/gfx-rs/wgpu/pull/7913). +### Naga +- Added mesh shader support to naga with `WGSL` frontend and `SPIR-V` backend. By @SupaMaggie70Incorporated in [#7930](https://github.com/gfx-rs/wgpu/pull/7930). + ## v26.0.1 (2025-07-10) ### Bug Fixes From 7e7850e3e7133f9e6a1fad43b7e77d05fe06a345 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 12:51:17 -0500 Subject: [PATCH 24/84] Added task_payload storage class parsing to wgsl, validation for it, etc --- docs/api-specs/mesh_shading.md | 6 +++--- naga/src/front/wgsl/parse/conv.rs | 1 + naga/src/valid/interface.rs | 14 +++++++++----- naga/tests/in/wgsl/mesh-shader.wgsl | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/docs/api-specs/mesh_shading.md b/docs/api-specs/mesh_shading.md index 8c979890b78..86ac26be95e 100644 --- a/docs/api-specs/mesh_shading.md +++ b/docs/api-specs/mesh_shading.md @@ -80,12 +80,12 @@ This shader stage can be selected by marking a function with `@task`. Task shade The output of this determines how many workgroups of mesh shaders will be dispatched. Once dispatched, global id variables will be local to the task shader workgroup dispatch, and mesh shaders won't know the position of their dispatch among all mesh shader dispatches unless this is passed through the payload. The output may be zero to skip dispatching any mesh shader workgroups for the task shader workgroup. -If task shaders are marked with `@payload(someVar)`, where `someVar` is global variable declared like `var someVar: `, task shaders may write to `someVar`. This payload is passed to the mesh shader workgroup that is invoked. The mesh shader can skip declaring `@payload` to ignore this input. +If task shaders are marked with `@payload(someVar)`, where `someVar` is global variable declared like `var someVar: `, task shaders may use `someVar` as if it is a read-write workgroup storage variable. This payload is passed to the mesh shader workgroup that is invoked. The mesh shader can skip declaring `@payload` to ignore this input. ### Mesh shader This shader stage can be selected by marking a function with `@mesh`. Mesh shaders must not return anything. -Mesh shaders can be marked with `@payload(someVar)` similar to task shaders. Unlike task shaders, mesh shaders cannot write to this workgroup memory. Declaring `@payload` in a pipeline with no task shader, in a pipeline with a task shader that doesn't declare `@payload`, or in a task shader with an `@payload` that is statically sized and smaller than the mesh shader payload is illegal. +Mesh shaders can be marked with `@payload(someVar)` similar to task shaders. Unlike task shaders, mesh shaders cannot write to this memory. Declaring `@payload` in a pipeline with no task shader, in a pipeline with a task shader that doesn't declare `@payload`, or in a task shader with an `@payload` that is statically sized and smaller than the mesh shader payload is illegal. Mesh shaders must be marked with `@vertex_output(OutputType, numOutputs)`, where `numOutputs` is the maximum number of vertices to be output by a mesh shader, and `OutputType` is the data associated with vertices, similar to a standard vertex shader output. @@ -128,7 +128,7 @@ struct TaskPayload { colorMask: vec4, visible: bool, } -var taskPayload: TaskPayload; +var taskPayload: TaskPayload; var workgroupData: f32; struct VertexOutput { @builtin(position) position: vec4, diff --git a/naga/src/front/wgsl/parse/conv.rs b/naga/src/front/wgsl/parse/conv.rs index a5dfdc07520..3568b134aef 100644 --- a/naga/src/front/wgsl/parse/conv.rs +++ b/naga/src/front/wgsl/parse/conv.rs @@ -16,6 +16,7 @@ pub fn map_address_space(word: &str, span: Span) -> Result<'_, crate::AddressSpa }), "push_constant" => Ok(crate::AddressSpace::PushConstant), "function" => Ok(crate::AddressSpace::Function), + "task_payload" => Ok(crate::AddressSpace::TaskPayload), _ => Err(Box::new(Error::UnknownAddressSpace(span))), } } diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index 1cf123b3f36..58d0f085e32 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -127,6 +127,8 @@ pub enum EntryPointError { UnexpectedMeshShaderAttributes, #[error("Non mesh/task shader entry point cannot have task payload attribute")] UnexpectedTaskPayload, + #[error("Task payload must be declared with `var`")] + TaskPayloadWrongAddressSpace, } fn storage_usage(access: crate::StorageAccess) -> GlobalUse { @@ -721,11 +723,13 @@ impl super::Validator { return Err(EntryPointError::UnexpectedMeshShaderAttributes.with_span()); } - if ep.stage != crate::ShaderStage::Task - && ep.stage != crate::ShaderStage::Mesh - && ep.task_payload.is_some() - { - return Err(EntryPointError::UnexpectedTaskPayload.with_span()); + if let Some(handle) = ep.task_payload { + if ep.stage != crate::ShaderStage::Task && ep.stage != crate::ShaderStage::Mesh { + return Err(EntryPointError::UnexpectedTaskPayload.with_span()); + } + if module.global_variables[handle].space != crate::AddressSpace::TaskPayload { + return Err(EntryPointError::TaskPayloadWrongAddressSpace.with_span()); + } } let mut info = self diff --git a/naga/tests/in/wgsl/mesh-shader.wgsl b/naga/tests/in/wgsl/mesh-shader.wgsl index 753c32214a2..47ab353c922 100644 --- a/naga/tests/in/wgsl/mesh-shader.wgsl +++ b/naga/tests/in/wgsl/mesh-shader.wgsl @@ -14,7 +14,7 @@ struct TaskPayload { colorMask: vec4, visible: bool, } -var taskPayload: TaskPayload; +var taskPayload: TaskPayload; var workgroupData: f32; struct VertexOutput { @builtin(position) position: vec4, From 9fd01d5ecf6f0dce4f87fd675f105283882b6647 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 14:07:36 -0500 Subject: [PATCH 25/84] Added output type validation --- naga/src/valid/analyzer.rs | 82 +++++++++++++++++++++++++++++++++++-- naga/src/valid/function.rs | 6 +++ naga/src/valid/interface.rs | 40 +++++++++++++++++- 3 files changed, 123 insertions(+), 5 deletions(-) diff --git a/naga/src/valid/analyzer.rs b/naga/src/valid/analyzer.rs index d2a6844aee8..3f405e2bd57 100644 --- a/naga/src/valid/analyzer.rs +++ b/naga/src/valid/analyzer.rs @@ -85,6 +85,16 @@ struct FunctionUniformity { exit: ExitFlags, } +/// Mesh shader related characteristics of a function. +#[derive(Debug, Clone, Default)] +#[cfg_attr(feature = "serialize", derive(serde::Serialize))] +#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] +#[cfg_attr(test, derive(PartialEq))] +pub struct FunctionMeshShaderInfo { + pub vertex_type: Option<(Handle, Handle)>, + pub primitive_type: Option<(Handle, Handle)>, +} + impl ops::BitOr for FunctionUniformity { type Output = Self; fn bitor(self, other: Self) -> Self { @@ -302,6 +312,8 @@ pub struct FunctionInfo { /// See [`DiagnosticFilterNode`] for details on how the tree is represented and used in /// validation. diagnostic_filter_leaf: Option>, + + pub mesh_shader_info: FunctionMeshShaderInfo, } impl FunctionInfo { @@ -482,6 +494,8 @@ impl FunctionInfo { *mine |= *other; } + self.try_update_mesh_info(&callee.mesh_shader_info)?; + Ok(FunctionUniformity { result: callee.uniformity.clone(), exit: if callee.may_kill { @@ -1114,9 +1128,9 @@ impl FunctionInfo { } FunctionUniformity::new() } - S::MeshFunction(func) => match func { + S::MeshFunction(func) => match &func { // TODO: double check all of this uniformity stuff. I frankly don't fully understand all of it. - crate::MeshFunction::SetMeshOutputs { + &crate::MeshFunction::SetMeshOutputs { vertex_count, primitive_count, } => { @@ -1124,10 +1138,21 @@ impl FunctionInfo { let _ = self.add_ref(primitive_count); FunctionUniformity::new() } - crate::MeshFunction::SetVertex { index, value } - | crate::MeshFunction::SetPrimitive { index, value } => { + &crate::MeshFunction::SetVertex { index, value } + | &crate::MeshFunction::SetPrimitive { index, value } => { let _ = self.add_ref(index); let _ = self.add_ref(value); + let ty = + self.expressions[value.index()].ty.clone().handle().ok_or( + FunctionError::InvalidMeshShaderOutputType(value).with_span(), + )?; + + if matches!(func, crate::MeshFunction::SetVertex { .. }) { + self.try_update_mesh_vertex_type(ty, value)?; + } else { + self.try_update_mesh_primitive_type(ty, value)?; + }; + FunctionUniformity::new() } }, @@ -1176,6 +1201,53 @@ impl FunctionInfo { } Ok(combined_uniformity) } + + fn try_update_mesh_vertex_type( + &mut self, + ty: Handle, + value: Handle, + ) -> Result<(), WithSpan> { + if let &Some(ref existing) = &self.mesh_shader_info.vertex_type { + if existing.0 != ty { + return Err( + FunctionError::ConflictingMeshOutputTypes(existing.1, value).with_span() + ); + } + } else { + self.mesh_shader_info.vertex_type = Some((ty, value)); + } + Ok(()) + } + + fn try_update_mesh_primitive_type( + &mut self, + ty: Handle, + value: Handle, + ) -> Result<(), WithSpan> { + if let &Some(ref existing) = &self.mesh_shader_info.primitive_type { + if existing.0 != ty { + return Err( + FunctionError::ConflictingMeshOutputTypes(existing.1, value).with_span() + ); + } + } else { + self.mesh_shader_info.primitive_type = Some((ty, value)); + } + Ok(()) + } + + fn try_update_mesh_info( + &mut self, + other: &FunctionMeshShaderInfo, + ) -> Result<(), WithSpan> { + if let &Some(ref other_vertex) = &other.vertex_type { + self.try_update_mesh_vertex_type(other_vertex.0, other_vertex.1)?; + } + if let &Some(ref other_primitive) = &other.vertex_type { + self.try_update_mesh_primitive_type(other_primitive.0, other_primitive.1)?; + } + Ok(()) + } } impl ModuleInfo { @@ -1211,6 +1283,7 @@ impl ModuleInfo { sampling: crate::FastHashSet::default(), dual_source_blending: false, diagnostic_filter_leaf: fun.diagnostic_filter_leaf, + mesh_shader_info: FunctionMeshShaderInfo::default(), }; let resolve_context = ResolveContext::with_locals(module, &fun.local_variables, &fun.arguments); @@ -1344,6 +1417,7 @@ fn uniform_control_flow() { sampling: crate::FastHashSet::default(), dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: FunctionMeshShaderInfo::default(), }; let resolve_context = ResolveContext { constants: &Arena::new(), diff --git a/naga/src/valid/function.rs b/naga/src/valid/function.rs index 0d993d0c2ee..d873edf09bf 100644 --- a/naga/src/valid/function.rs +++ b/naga/src/valid/function.rs @@ -219,6 +219,12 @@ pub enum FunctionError { UnvisitedExpression(Handle), #[error("Expression {0:?} should be u32, but isn't")] InvalidMeshFunctionCall(Handle), + #[error("Mesh output types differ from {0:?} to {1:?}")] + ConflictingMeshOutputTypes(Handle, Handle), + #[error("Task payload variables differ from {0:?} to {1:?}")] + ConflictingTaskPayloadVariables(Handle, Handle), + #[error("Mesh shader output at {0:?} is not a user-defined struct")] + InvalidMeshShaderOutputType(Handle), } bitflags::bitflags! { diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index 58d0f085e32..6d93b0a4b36 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -129,6 +129,12 @@ pub enum EntryPointError { UnexpectedTaskPayload, #[error("Task payload must be declared with `var`")] TaskPayloadWrongAddressSpace, + #[error("For a task payload to be used, it must be declared with @payload")] + WrongTaskPayloadUsed, + #[error("A function can only set vertex and primitive types that correspond to the mesh shader attributes")] + WrongMeshOutputType, + #[error("Only mesh shader entry points can write to mesh output vertices and primitives")] + UnexpectedMeshShaderOutput, } fn storage_usage(access: crate::StorageAccess) -> GlobalUse { @@ -821,6 +827,18 @@ impl super::Validator { continue; } + if var.space == crate::AddressSpace::TaskPayload { + if let Some(task_payload) = ep.task_payload { + if task_payload != var_handle { + return Err(EntryPointError::TaskPayloadWrongAddressSpace + .with_span_handle(var_handle, &module.global_variables)); + } + } else { + return Err(EntryPointError::WrongTaskPayloadUsed + .with_span_handle(var_handle, &module.global_variables)); + } + } + let allowed_usage = match var.space { crate::AddressSpace::Function => unreachable!(), crate::AddressSpace::Uniform => GlobalUse::READ | GlobalUse::QUERY, @@ -843,7 +861,13 @@ impl super::Validator { crate::AddressSpace::Private | crate::AddressSpace::WorkGroup | crate::AddressSpace::TaskPayload => { - GlobalUse::READ | GlobalUse::WRITE | GlobalUse::QUERY + GlobalUse::READ + | GlobalUse::QUERY + | if ep.stage == crate::ShaderStage::Task { + GlobalUse::WRITE + } else { + GlobalUse::empty() + } } crate::AddressSpace::PushConstant => GlobalUse::READ, }; @@ -868,6 +892,20 @@ impl super::Validator { } } + if let &Some(ref mesh_info) = &ep.mesh_info { + // Technically it is allowed to not output anything + if let Some(used_vertex_type) = info.mesh_shader_info.vertex_type { + if used_vertex_type.0 != mesh_info.vertex_output_type { + return Err(EntryPointError::WrongTaskPayloadUsed + .with_span_handle(used_vertex_type.0, &module.types)); + } + } + } else if info.mesh_shader_info.vertex_type.is_some() + || info.mesh_shader_info.primitive_type.is_some() + { + return Err(EntryPointError::UnexpectedMeshShaderOutput.with_span()); + } + Ok(info) } } From bb9532443a0a0e8dc74f926cb28cb772535bffbd Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 14:33:18 -0500 Subject: [PATCH 26/84] Tried to fix u32 casting --- naga/src/front/wgsl/lower/mod.rs | 37 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/naga/src/front/wgsl/lower/mod.rs b/naga/src/front/wgsl/lower/mod.rs index c0962ed89ba..bd6437bc2df 100644 --- a/naga/src/front/wgsl/lower/mod.rs +++ b/naga/src/front/wgsl/lower/mod.rs @@ -3235,31 +3235,32 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { "setMeshOutputs" | "setVertex" | "setPrimitive" => { let mut args = ctx.prepare_args(arguments, 2, span); + let arg1 = self.expression(args.next()?, ctx)?; let arg2 = self.expression(args.next()?, ctx)?; - let mut convert_to_u32 = - |expr: Handle| -> Result> { - let goal_inner = crate::TypeInner::Scalar(crate::Scalar::U32); - match goal_inner.scalar_for_conversions(&ctx.module.types) { - Some(goal_scalar) => { - let arg_span = ctx.get_expression_span(expr); - ctx.try_automatic_conversion_for_leaf_scalar( - expr, - goal_scalar, - arg_span, - ) - } - // No conversion is necessary. - None => Ok(expr), + args.finish()?; + + let mut const_u32 = |expr| -> Result> { + let goal_inner = ir::TypeInner::Scalar(ir::Scalar::U32); + Ok(match goal_inner.scalar_for_conversions(&ctx.module.types) { + Some(goal_scalar) => { + let arg_span = ctx.get_expression_span(expr); + ctx.try_automatic_conversion_for_leaf_scalar( + expr, + goal_scalar, + arg_span, + )? } - }; - let arg1 = convert_to_u32(arg1)?; + // No conversion is necessary. + None => expr, + }) + }; + let arg1 = const_u32(arg1)?; let arg2 = if function.name == "setMeshOutputs" { - convert_to_u32(arg2)? + const_u32(arg2)? } else { arg2 }; - args.finish()?; let rctx = ctx.runtime_expression_ctx(span)?; rctx.block.push( From aff163f115872095ac7169bda9383da6090ea067 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 15:16:05 -0500 Subject: [PATCH 27/84] Attempted to fix u32 to i32 automatic conversion issue --- naga/src/front/wgsl/lower/mod.rs | 36 ++++++++++++++------------------ 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/naga/src/front/wgsl/lower/mod.rs b/naga/src/front/wgsl/lower/mod.rs index bd6437bc2df..4bb3c44afbc 100644 --- a/naga/src/front/wgsl/lower/mod.rs +++ b/naga/src/front/wgsl/lower/mod.rs @@ -3235,31 +3235,27 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { "setMeshOutputs" | "setVertex" | "setPrimitive" => { let mut args = ctx.prepare_args(arguments, 2, span); - - let arg1 = self.expression(args.next()?, ctx)?; - let arg2 = self.expression(args.next()?, ctx)?; + let arg1 = args.next()?; + let arg2 = args.next()?; args.finish()?; - let mut const_u32 = |expr| -> Result> { - let goal_inner = ir::TypeInner::Scalar(ir::Scalar::U32); - Ok(match goal_inner.scalar_for_conversions(&ctx.module.types) { - Some(goal_scalar) => { - let arg_span = ctx.get_expression_span(expr); - ctx.try_automatic_conversion_for_leaf_scalar( - expr, - goal_scalar, - arg_span, - )? - } - // No conversion is necessary. - None => expr, - }) + let mut cast_u32 = |arg| { + // Try to convert abstract values to the known argument types + let expr = self.expression_for_abstract(arg, ctx)?; + let goal_ty = + ctx.ensure_type_exists(ir::TypeInner::Scalar(ir::Scalar::U32)); + ctx.try_automatic_conversions( + expr, + &proc::TypeResolution::Handle(goal_ty), + ctx.ast_expressions.get_span(arg), + ) }; - let arg1 = const_u32(arg1)?; + + let arg1 = cast_u32(arg1)?; let arg2 = if function.name == "setMeshOutputs" { - const_u32(arg2)? + cast_u32(arg2)? } else { - arg2 + self.expression(arg2, ctx)? }; let rctx = ctx.runtime_expression_ctx(span)?; From 4612795b63df1ec7c1a8bc0615ad9d01d55e87c5 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 15:18:28 -0500 Subject: [PATCH 28/84] Fixed stupid naga validation bug --- naga/src/valid/interface.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index 6d93b0a4b36..6ccac6c21c9 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -858,9 +858,10 @@ impl super::Validator { _ => GlobalUse::READ | GlobalUse::QUERY, }, // TODO: update this to reflect the nuance around taskpayload(writable in task stage, readable in mesh stage) - crate::AddressSpace::Private - | crate::AddressSpace::WorkGroup - | crate::AddressSpace::TaskPayload => { + crate::AddressSpace::Private | crate::AddressSpace::WorkGroup => { + GlobalUse::READ | GlobalUse::WRITE | GlobalUse::QUERY + } + crate::AddressSpace::TaskPayload => { GlobalUse::READ | GlobalUse::QUERY | if ep.stage == crate::ShaderStage::Task { From 8de0f04e93300426a387dbc766649d030d3ef558 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 15:19:33 -0500 Subject: [PATCH 29/84] Updated snapshots --- naga/tests/out/analysis/spv-shadow.info.ron | 12 ++++++++++++ naga/tests/out/analysis/wgsl-collatz.info.ron | 8 ++++++++ naga/tests/out/analysis/wgsl-overrides.info.ron | 4 ++++ 3 files changed, 24 insertions(+) diff --git a/naga/tests/out/analysis/spv-shadow.info.ron b/naga/tests/out/analysis/spv-shadow.info.ron index 381f841d5d9..b08a28438ed 100644 --- a/naga/tests/out/analysis/spv-shadow.info.ron +++ b/naga/tests/out/analysis/spv-shadow.info.ron @@ -413,6 +413,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), @@ -1591,6 +1595,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ], entry_points: [ @@ -1685,6 +1693,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ], const_expression_types: [ diff --git a/naga/tests/out/analysis/wgsl-collatz.info.ron b/naga/tests/out/analysis/wgsl-collatz.info.ron index 219e016f8d7..2796f544510 100644 --- a/naga/tests/out/analysis/wgsl-collatz.info.ron +++ b/naga/tests/out/analysis/wgsl-collatz.info.ron @@ -275,6 +275,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ], entry_points: [ @@ -430,6 +434,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ], const_expression_types: [], diff --git a/naga/tests/out/analysis/wgsl-overrides.info.ron b/naga/tests/out/analysis/wgsl-overrides.info.ron index 92e99112e53..a76c9c89c9b 100644 --- a/naga/tests/out/analysis/wgsl-overrides.info.ron +++ b/naga/tests/out/analysis/wgsl-overrides.info.ron @@ -201,6 +201,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ], const_expression_types: [ From ac3901f0a5f138e60ec405566ae557ec3d7bd6bd Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 15:29:36 -0500 Subject: [PATCH 30/84] Tried to clarify mesh validation errors --- naga/src/valid/interface.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index 6ccac6c21c9..e339589d1b1 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -820,6 +820,13 @@ impl super::Validator { } } + if let Some(task_payload) = ep.task_payload { + if module.global_variables[task_payload].space != crate::AddressSpace::TaskPayload { + return Err(EntryPointError::TaskPayloadWrongAddressSpace + .with_span_handle(task_payload, &module.global_variables)); + } + } + self.ep_resource_bindings.clear(); for (var_handle, var) in module.global_variables.iter() { let usage = info[var_handle]; @@ -828,12 +835,7 @@ impl super::Validator { } if var.space == crate::AddressSpace::TaskPayload { - if let Some(task_payload) = ep.task_payload { - if task_payload != var_handle { - return Err(EntryPointError::TaskPayloadWrongAddressSpace - .with_span_handle(var_handle, &module.global_variables)); - } - } else { + if ep.task_payload != Some(var_handle) { return Err(EntryPointError::WrongTaskPayloadUsed .with_span_handle(var_handle, &module.global_variables)); } @@ -897,7 +899,7 @@ impl super::Validator { // Technically it is allowed to not output anything if let Some(used_vertex_type) = info.mesh_shader_info.vertex_type { if used_vertex_type.0 != mesh_info.vertex_output_type { - return Err(EntryPointError::WrongTaskPayloadUsed + return Err(EntryPointError::WrongMeshOutputType .with_span_handle(used_vertex_type.0, &module.types)); } } From 000052abd9068873327198151a8b78f954b2c36c Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 16:03:43 -0500 Subject: [PATCH 31/84] Made it adjust mesh shader metadata during compaction --- naga/src/compact/mod.rs | 41 +++++++++++++++++++++++++++++ naga/src/valid/interface.rs | 2 +- naga/tests/in/wgsl/mesh-shader.wgsl | 4 --- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/naga/src/compact/mod.rs b/naga/src/compact/mod.rs index c7b7bfb46d8..c0a63e1087f 100644 --- a/naga/src/compact/mod.rs +++ b/naga/src/compact/mod.rs @@ -221,6 +221,30 @@ pub fn compact(module: &mut crate::Module, keep_unused: KeepUnused) { } } + for entry in &module.entry_points { + if let Some(task_payload) = entry.task_payload { + module_tracer.global_variables_used.insert(task_payload); + } + if let Some(ref mesh_info) = entry.mesh_info { + module_tracer + .types_used + .insert(mesh_info.vertex_output_type); + module_tracer + .types_used + .insert(mesh_info.primitive_output_type); + if let Some(max_vertices_override) = mesh_info.max_vertices_override { + module_tracer + .global_expressions_used + .insert(max_vertices_override); + } + if let Some(max_primitives_override) = mesh_info.max_primitives_override { + module_tracer + .global_expressions_used + .insert(max_primitives_override); + } + } + } + module_tracer.type_expression_tandem(); // Now that we know what is used and what is never touched, @@ -342,6 +366,23 @@ pub fn compact(module: &mut crate::Module, keep_unused: KeepUnused) { &module_map, &mut reused_named_expressions, ); + if let Some(ref mut task_payload) = entry.task_payload { + module_map.globals.adjust(task_payload); + } + if let Some(ref mut mesh_info) = entry.mesh_info { + module_map.types.adjust(&mut mesh_info.vertex_output_type); + module_map + .types + .adjust(&mut mesh_info.primitive_output_type); + if let Some(ref mut max_vertices_override) = mesh_info.max_vertices_override { + module_map.global_expressions.adjust(max_vertices_override); + } + if let Some(ref mut max_primitives_override) = mesh_info.max_primitives_override { + module_map + .global_expressions + .adjust(max_primitives_override); + } + } } } diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index e339589d1b1..8e1683a1588 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -900,7 +900,7 @@ impl super::Validator { if let Some(used_vertex_type) = info.mesh_shader_info.vertex_type { if used_vertex_type.0 != mesh_info.vertex_output_type { return Err(EntryPointError::WrongMeshOutputType - .with_span_handle(used_vertex_type.0, &module.types)); + .with_span_handle(mesh_info.vertex_output_type, &module.types)); } } } else if info.mesh_shader_info.vertex_type.is_some() diff --git a/naga/tests/in/wgsl/mesh-shader.wgsl b/naga/tests/in/wgsl/mesh-shader.wgsl index 47ab353c922..6e8fe3f05f9 100644 --- a/naga/tests/in/wgsl/mesh-shader.wgsl +++ b/naga/tests/in/wgsl/mesh-shader.wgsl @@ -28,9 +28,7 @@ struct PrimitiveOutput { struct PrimitiveInput { @location(1) colorMask: vec4, } -fn test_function(input: u32) { -} @task @payload(taskPayload) @workgroup_size(1) @@ -49,8 +47,6 @@ fn ms_main(@builtin(local_invocation_index) index: u32, @builtin(global_invocati workgroupData = 2.0; var v: VertexOutput; - test_function(1); - v.position = positions[0]; v.color = colors[0] * taskPayload.colorMask; setVertex(0, v); From fe3a8326a1f6204c76c64b842cf9aaa6d9c64a09 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 16:20:12 -0500 Subject: [PATCH 32/84] Added more validation for the output type of entry points --- naga/src/valid/interface.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index 8e1683a1588..562b1948368 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -135,6 +135,10 @@ pub enum EntryPointError { WrongMeshOutputType, #[error("Only mesh shader entry points can write to mesh output vertices and primitives")] UnexpectedMeshShaderOutput, + #[error("Mesh shader entry point cannot have a return type")] + UnexpectedMeshShaderEntryResult, + #[error("Task shader entry point must return @builtin(mesh_task_size) vec3")] + WrongTaskShaderEntryResult, } fn storage_usage(access: crate::StorageAccess) -> GlobalUse { @@ -798,11 +802,21 @@ impl super::Validator { { return Err(EntryPointError::MissingVertexOutputPosition.with_span()); } + if ep.stage == crate::ShaderStage::Mesh { + return Err(EntryPointError::UnexpectedMeshShaderEntryResult.with_span()); + } + if ep.stage == crate::ShaderStage::Task { + if fr.binding != Some(crate::Binding::BuiltIn(crate::BuiltIn::MeshTaskSize)) { + return Err(EntryPointError::WrongTaskShaderEntryResult.with_span()); + } + } if !self.blend_src_mask.is_empty() { info.dual_source_blending = true; } } else if ep.stage == crate::ShaderStage::Vertex { return Err(EntryPointError::MissingVertexOutputPosition.with_span()); + } else if ep.stage == crate::ShaderStage::Task { + return Err(EntryPointError::WrongTaskShaderEntryResult.with_span()); } { From 62fa6275cb25e4e30b887caebf1c62aaf7b07bf3 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 16:23:40 -0500 Subject: [PATCH 33/84] Made it allow @mesh_task_size declared in a struct for task output --- naga/src/valid/interface.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index 562b1948368..33249358f2e 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -805,10 +805,10 @@ impl super::Validator { if ep.stage == crate::ShaderStage::Mesh { return Err(EntryPointError::UnexpectedMeshShaderEntryResult.with_span()); } - if ep.stage == crate::ShaderStage::Task { - if fr.binding != Some(crate::Binding::BuiltIn(crate::BuiltIn::MeshTaskSize)) { - return Err(EntryPointError::WrongTaskShaderEntryResult.with_span()); - } + if ep.stage == crate::ShaderStage::Task + && !result_built_ins.contains(&crate::BuiltIn::MeshTaskSize) + { + return Err(EntryPointError::WrongTaskShaderEntryResult.with_span()); } if !self.blend_src_mask.is_empty() { info.dual_source_blending = true; From 37743588d899b540dc634b02ecb6513a4247aa9b Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 16:27:17 -0500 Subject: [PATCH 34/84] Smartified the task output checking --- naga/src/valid/interface.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index 33249358f2e..b0bb0ea47c3 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -802,11 +802,16 @@ impl super::Validator { { return Err(EntryPointError::MissingVertexOutputPosition.with_span()); } - if ep.stage == crate::ShaderStage::Mesh { + if ep.stage == crate::ShaderStage::Mesh + && (!result_built_ins.is_empty() || !self.location_mask.is_empty()) + { return Err(EntryPointError::UnexpectedMeshShaderEntryResult.with_span()); } + // Cannot have any other built-ins or @location outputs as those are per-vertex or per-primitive if ep.stage == crate::ShaderStage::Task - && !result_built_ins.contains(&crate::BuiltIn::MeshTaskSize) + && (!result_built_ins.contains(&crate::BuiltIn::MeshTaskSize) + || result_built_ins.len() != 1 + || !self.location_mask.is_empty()) { return Err(EntryPointError::WrongTaskShaderEntryResult.with_span()); } From 8adf8c6dc4ec12ff7caf9e41d33ec33510e89132 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 17:15:15 -0500 Subject: [PATCH 35/84] A little more work for SPIRV writing and added back point index builtin --- naga/src/back/glsl/mod.rs | 6 +++++- naga/src/back/hlsl/conv.rs | 2 +- naga/src/back/msl/mod.rs | 2 +- naga/src/back/spv/writer.rs | 9 +++++++++ naga/src/common/wgsl/to_wgsl.rs | 3 ++- naga/src/front/wgsl/parse/conv.rs | 1 + naga/src/ir/mod.rs | 1 + naga/src/valid/interface.rs | 4 ++++ 8 files changed, 24 insertions(+), 4 deletions(-) diff --git a/naga/src/back/glsl/mod.rs b/naga/src/back/glsl/mod.rs index 65bdcc392be..d45949b4cef 100644 --- a/naga/src/back/glsl/mod.rs +++ b/naga/src/back/glsl/mod.rs @@ -5262,7 +5262,11 @@ const fn glsl_built_in(built_in: crate::BuiltIn, options: VaryingOptions) -> &'s Bi::SubgroupInvocationId => "gl_SubgroupInvocationID", // mesh // TODO: figure out how to map these to glsl things as glsl treats them as arrays - Bi::CullPrimitive | Bi::LineIndices | Bi::TriangleIndices | Bi::MeshTaskSize => { + Bi::CullPrimitive + | Bi::PointIndex + | Bi::LineIndices + | Bi::TriangleIndices + | Bi::MeshTaskSize => { unimplemented!() } } diff --git a/naga/src/back/hlsl/conv.rs b/naga/src/back/hlsl/conv.rs index 7b71de99053..dbf7bea93fb 100644 --- a/naga/src/back/hlsl/conv.rs +++ b/naga/src/back/hlsl/conv.rs @@ -185,7 +185,7 @@ impl crate::BuiltIn { } Self::CullPrimitive => "SV_CullPrimitive", // TODO: make this work - Self::LineIndices | Self::TriangleIndices => unimplemented!(), + Self::PointIndex | Self::LineIndices | Self::TriangleIndices => unimplemented!(), Self::MeshTaskSize => unreachable!(), }) } diff --git a/naga/src/back/msl/mod.rs b/naga/src/back/msl/mod.rs index 03565f6018b..5acc26c1ec6 100644 --- a/naga/src/back/msl/mod.rs +++ b/naga/src/back/msl/mod.rs @@ -653,7 +653,7 @@ impl ResolvedBinding { } Bi::CullPrimitive => "primitive_culled", // TODO: figure out how to make this written as a function call - Bi::LineIndices | Bi::TriangleIndices => unimplemented!(), + Bi::PointIndex | Bi::LineIndices | Bi::TriangleIndices => unimplemented!(), Bi::MeshTaskSize => unreachable!(), }; write!(out, "{name}")?; diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index fd451082f7e..98429850b25 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -2122,6 +2122,7 @@ impl Writer { BuiltIn::SubgroupLocalInvocationId } Bi::CullPrimitive => BuiltIn::CullPrimitiveEXT, + Bi::PointIndex => BuiltIn::PrimitivePointIndicesEXT, Bi::LineIndices => BuiltIn::PrimitiveLineIndicesEXT, Bi::TriangleIndices => BuiltIn::PrimitiveTriangleIndicesEXT, Bi::MeshTaskSize => unreachable!(), @@ -2426,6 +2427,9 @@ impl Writer { let mut has_ray_query = ir_module.special_types.ray_desc.is_some() | ir_module.special_types.ray_intersection.is_some(); let has_vertex_return = ir_module.special_types.ray_vertex_return.is_some(); + let has_mesh_shaders = ir_module.entry_points.iter().any(|entry| { + entry.stage == crate::ShaderStage::Mesh || entry.stage == crate::ShaderStage::Task + }); for (_, &crate::Type { ref inner, .. }) in ir_module.types.iter() { // spirv does not know whether these have vertex return - that is done by us @@ -2453,6 +2457,11 @@ impl Writer { Instruction::extension("SPV_KHR_ray_tracing_position_fetch") .to_words(&mut self.logical_layout.extensions); } + if has_mesh_shaders { + Instruction::extension("SPV_EXT_mesh_shader") + .to_words(&mut self.logical_layout.extensions); + self.require_any("Mesh Shaders", &[spirv::Capability::MeshShadingEXT])?; + } Instruction::type_void(self.void_type).to_words(&mut self.logical_layout.declarations); Instruction::ext_inst_import(self.gl450_ext_inst_id, "GLSL.std.450") .to_words(&mut self.logical_layout.ext_inst_imports); diff --git a/naga/src/common/wgsl/to_wgsl.rs b/naga/src/common/wgsl/to_wgsl.rs index 9a1402ec5fc..dc891aa5a3f 100644 --- a/naga/src/common/wgsl/to_wgsl.rs +++ b/naga/src/common/wgsl/to_wgsl.rs @@ -192,7 +192,8 @@ impl TryToWgsl for crate::BuiltIn { | Bi::CullPrimitive | Bi::TriangleIndices | Bi::LineIndices - | Bi::MeshTaskSize => return None, + | Bi::MeshTaskSize + | Bi::PointIndex => return None, }) } } diff --git a/naga/src/front/wgsl/parse/conv.rs b/naga/src/front/wgsl/parse/conv.rs index 3568b134aef..b75d104afbd 100644 --- a/naga/src/front/wgsl/parse/conv.rs +++ b/naga/src/front/wgsl/parse/conv.rs @@ -52,6 +52,7 @@ pub fn map_built_in( "subgroup_invocation_id" => crate::BuiltIn::SubgroupInvocationId, // mesh "cull_primitive" => crate::BuiltIn::CullPrimitive, + "point_index" => crate::BuiltIn::PointIndex, "line_indices" => crate::BuiltIn::LineIndices, "triangle_indices" => crate::BuiltIn::TriangleIndices, "mesh_task_size" => crate::BuiltIn::MeshTaskSize, diff --git a/naga/src/ir/mod.rs b/naga/src/ir/mod.rs index df769852d61..5e226ae4638 100644 --- a/naga/src/ir/mod.rs +++ b/naga/src/ir/mod.rs @@ -402,6 +402,7 @@ pub enum BuiltIn { // mesh MeshTaskSize, CullPrimitive, + PointIndex, LineIndices, TriangleIndices, } diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index b0bb0ea47c3..92a22eb3c7f 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -321,6 +321,10 @@ impl VaryingContext<'_> { self.stage == St::Mesh && self.output, *ty_inner == Ti::Scalar(crate::Scalar::BOOL), ), + Bi::PointIndex => ( + self.stage == St::Mesh && self.output, + *ty_inner == Ti::Scalar(crate::Scalar::U32), + ), Bi::LineIndices => ( self.stage == St::Mesh && self.output, *ty_inner From 75d42bd3b9d6bc495c903f5113fc9ba4dbeb0382 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 20:15:11 -0500 Subject: [PATCH 36/84] Now it can (almost) compile a task shader! --- naga/src/back/spv/block.rs | 30 +++++++++++++++++++++++++++--- naga/src/back/spv/mod.rs | 1 + naga/src/back/spv/writer.rs | 13 ++++++++++++- naga/src/compact/mod.rs | 3 +++ 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index ccad1f540ea..47bc22e74c5 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -221,6 +221,7 @@ impl Writer { ir_result: &crate::FunctionResult, result_members: &[ResultMember], body: &mut Vec, + task_payload: Option, ) -> Result<(), Error> { for (index, res_member) in result_members.iter().enumerate() { let member_value_id = match ir_result.binding { @@ -231,7 +232,7 @@ impl Writer { res_member.type_id, member_value_id, value_id, - &[index as u32], + &[index as Word], )); member_value_id } @@ -250,6 +251,26 @@ impl Writer { { self.write_epilogue_frag_depth_clamp(res_member.id, body)?; } + Some(crate::BuiltIn::MeshTaskSize) => { + let values = [self.id_gen.next(), self.id_gen.next(), self.id_gen.next()]; + for (i, &value) in values.iter().enumerate() { + let mut instruction = Instruction::new(spirv::Op::CompositeExtract); + instruction.add_operand(self.get_u32_type_id()); + instruction.add_operand(value); + instruction.add_operand(member_value_id); + instruction.add_operand(i as u32); + body.push(instruction); + // Use OpCompositeExtract to save the component of the vec3 + } + let mut instruction = Instruction::new(spirv::Op::EmitMeshTasksEXT); + for id in values { + instruction.add_operand(id); + } + if let Some(task_payload) = task_payload { + instruction.add_operand(task_payload); + } + body.push(instruction); + } _ => {} } } @@ -3215,8 +3236,10 @@ impl BlockContext<'_> { ); return Ok(BlockExitDisposition::Discarded); } - Statement::Return { value: Some(value) } => { - let value_id = self.cached[value]; + Statement::Return { + value: Some(output), + } => { + let value_id = self.cached[output]; let instruction = match self.function.entry_point_context { // If this is an entry point, and we need to return anything, // let's instead store the output variables and return `void`. @@ -3226,6 +3249,7 @@ impl BlockContext<'_> { self.ir_function.result.as_ref().unwrap(), &context.results, &mut block.body, + context.task_payload, )?; Instruction::return_void() } diff --git a/naga/src/back/spv/mod.rs b/naga/src/back/spv/mod.rs index 2dcd95957d7..21ad16b9f6c 100644 --- a/naga/src/back/spv/mod.rs +++ b/naga/src/back/spv/mod.rs @@ -142,6 +142,7 @@ struct ResultMember { struct EntryPointContext { argument_ids: Vec, results: Vec, + task_payload: Option, } #[derive(Default)] diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 98429850b25..872736ccaa0 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -22,6 +22,7 @@ use crate::{ struct FunctionInterface<'a> { varying_ids: &'a mut Vec, stage: crate::ShaderStage, + task_payload: Option>, } impl Function { @@ -699,6 +700,11 @@ impl Writer { let mut ep_context = EntryPointContext { argument_ids: Vec::new(), results: Vec::new(), + task_payload: if let Some(ref i) = interface { + i.task_payload.map(|a| self.global_variables[a].var_id) + } else { + None + }, }; let mut local_invocation_id = None; @@ -831,6 +837,9 @@ impl Writer { let type_id = self.get_handle_type_id(member.ty); let name = member.name.as_deref(); let binding = member.binding.as_ref().unwrap(); + if binding.to_built_in() == Some(crate::BuiltIn::MeshTaskSize) { + continue; + } has_point_size |= *binding == crate::Binding::BuiltIn(crate::BuiltIn::PointSize); let varying_id = self.write_varying( @@ -1113,6 +1122,7 @@ impl Writer { Some(FunctionInterface { varying_ids: &mut interface_ids, stage: entry_point.stage, + task_payload: entry_point.task_payload, }), debug_info, )?; @@ -2125,7 +2135,8 @@ impl Writer { Bi::PointIndex => BuiltIn::PrimitivePointIndicesEXT, Bi::LineIndices => BuiltIn::PrimitiveLineIndicesEXT, Bi::TriangleIndices => BuiltIn::PrimitiveTriangleIndicesEXT, - Bi::MeshTaskSize => unreachable!(), + // No decoration, this EmitMeshTasksEXT is called at function return + Bi::MeshTaskSize => return Ok(id), }; self.decorate(id, Decoration::BuiltIn, &[built_in as u32]); diff --git a/naga/src/compact/mod.rs b/naga/src/compact/mod.rs index c0a63e1087f..2bc80f52ef3 100644 --- a/naga/src/compact/mod.rs +++ b/naga/src/compact/mod.rs @@ -243,6 +243,9 @@ pub fn compact(module: &mut crate::Module, keep_unused: KeepUnused) { .insert(max_primitives_override); } } + if entry.stage == crate::ShaderStage::Task || entry.stage == crate::ShaderStage::Mesh { + // TODO: make sure u32 is preserved + } } module_tracer.type_expression_tandem(); From 611992d3235b5c0b6271047dc18927a1b0e92787 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 21:12:43 -0500 Subject: [PATCH 37/84] Task shaders can now be written properly!!!! --- naga/src/back/spv/writer.rs | 27 ++++++++++++++++++++++----- naga/src/valid/analyzer.rs | 8 ++++++++ naga/src/valid/interface.rs | 15 +++++++++++---- 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 872736ccaa0..199f49e815b 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -811,7 +811,13 @@ impl Writer { Some(ref result) => { if let Some(ref mut iface) = interface { let mut has_point_size = false; - let class = spirv::StorageClass::Output; + let class = if result.binding + == Some(crate::Binding::BuiltIn(crate::BuiltIn::MeshTaskSize)) + { + spirv::StorageClass::Private + } else { + spirv::StorageClass::Output + }; if let Some(ref binding) = result.binding { has_point_size |= *binding == crate::Binding::BuiltIn(crate::BuiltIn::PointSize); @@ -824,7 +830,9 @@ impl Writer { result.ty, binding, )?; - iface.varying_ids.push(varying_id); + if class != spirv::StorageClass::Private { + iface.varying_ids.push(varying_id); + } ep_context.results.push(ResultMember { id: varying_id, type_id, @@ -850,7 +858,9 @@ impl Writer { member.ty, binding, )?; - iface.varying_ids.push(varying_id); + if class != spirv::StorageClass::Private { + iface.varying_ids.push(varying_id); + } ep_context.results.push(ResultMember { id: varying_id, type_id, @@ -890,6 +900,13 @@ impl Writer { None => self.void_type, }; + if let Some(ref mut i) = interface { + if let Some(task_payload) = i.task_payload { + i.varying_ids + .push(self.global_variables[task_payload].var_id); + } + } + let lookup_function_type = LookupFunctionType { parameter_type_ids, return_type_id, @@ -923,10 +940,10 @@ impl Writer { continue; } - let mut gv = self.global_variables[handle].clone(); + let mut gv: GlobalVariable = self.global_variables[handle].clone(); if let Some(ref mut iface) = interface { // Have to include global variables in the interface - if self.physical_layout.version >= 0x10400 { + if self.physical_layout.version >= 0x10400 && iface.task_payload != Some(handle) { iface.varying_ids.push(gv.var_id); } } diff --git a/naga/src/valid/analyzer.rs b/naga/src/valid/analyzer.rs index 3f405e2bd57..101ea046487 100644 --- a/naga/src/valid/analyzer.rs +++ b/naga/src/valid/analyzer.rs @@ -384,6 +384,14 @@ impl FunctionInfo { info.uniformity.non_uniform_result } + pub fn insert_global_use( + &mut self, + global_use: GlobalUse, + global: Handle, + ) { + self.global_uses[global.index()] |= global_use; + } + /// Record a use of `expr` for its value. /// /// This is used for almost all expression references. Anything diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index 92a22eb3c7f..59a4ed653aa 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -737,6 +737,10 @@ impl super::Validator { return Err(EntryPointError::UnexpectedMeshShaderAttributes.with_span()); } + let mut info = self + .validate_function(&ep.function, module, mod_info, true) + .map_err(WithSpan::into_other)?; + if let Some(handle) = ep.task_payload { if ep.stage != crate::ShaderStage::Task && ep.stage != crate::ShaderStage::Mesh { return Err(EntryPointError::UnexpectedTaskPayload.with_span()); @@ -744,12 +748,15 @@ impl super::Validator { if module.global_variables[handle].space != crate::AddressSpace::TaskPayload { return Err(EntryPointError::TaskPayloadWrongAddressSpace.with_span()); } + // Make sure that this is always present in the outputted shader + let uses = if ep.stage == crate::ShaderStage::Mesh { + GlobalUse::READ + } else { + GlobalUse::READ | GlobalUse::WRITE + }; + info.insert_global_use(uses, handle); } - let mut info = self - .validate_function(&ep.function, module, mod_info, true) - .map_err(WithSpan::into_other)?; - { use super::ShaderStages; From 74e835229c1102c9958809f76e5a850c02e4ac0e Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 21:27:00 -0500 Subject: [PATCH 38/84] Cleaned up task shader writing --- naga/src/back/spv/block.rs | 4 ++- naga/src/back/spv/writer.rs | 60 ++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 47bc22e74c5..c9b5c0163cc 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -238,7 +238,9 @@ impl Writer { } }; - body.push(Instruction::store(res_member.id, member_value_id, None)); + if res_member.built_in != Some(crate::BuiltIn::MeshTaskSize) { + body.push(Instruction::store(res_member.id, member_value_id, None)) + } match res_member.built_in { Some(crate::BuiltIn::Position { .. }) diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 199f49e815b..0eaa06c4463 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -811,28 +811,26 @@ impl Writer { Some(ref result) => { if let Some(ref mut iface) = interface { let mut has_point_size = false; - let class = if result.binding - == Some(crate::Binding::BuiltIn(crate::BuiltIn::MeshTaskSize)) - { - spirv::StorageClass::Private - } else { - spirv::StorageClass::Output - }; + let class = spirv::StorageClass::Output; if let Some(ref binding) = result.binding { has_point_size |= *binding == crate::Binding::BuiltIn(crate::BuiltIn::PointSize); let type_id = self.get_handle_type_id(result.ty); - let varying_id = self.write_varying( - ir_module, - iface.stage, - class, - None, - result.ty, - binding, - )?; - if class != spirv::StorageClass::Private { - iface.varying_ids.push(varying_id); - } + let varying_id = + if *binding == crate::Binding::BuiltIn(crate::BuiltIn::MeshTaskSize) { + 0 + } else { + let varying_id = self.write_varying( + ir_module, + iface.stage, + class, + None, + result.ty, + binding, + )?; + iface.varying_ids.push(varying_id); + varying_id + }; ep_context.results.push(ResultMember { id: varying_id, type_id, @@ -850,17 +848,23 @@ impl Writer { } has_point_size |= *binding == crate::Binding::BuiltIn(crate::BuiltIn::PointSize); - let varying_id = self.write_varying( - ir_module, - iface.stage, - class, - name, - member.ty, - binding, - )?; - if class != spirv::StorageClass::Private { + let varying_id = if *binding + == crate::Binding::BuiltIn(crate::BuiltIn::MeshTaskSize) + { + 0 + } else { + let varying_id = self.write_varying( + ir_module, + iface.stage, + class, + name, + result.ty, + binding, + )?; iface.varying_ids.push(varying_id); - } + varying_id + }; + iface.varying_ids.push(varying_id); ep_context.results.push(ResultMember { id: varying_id, type_id, From 7ed6e47e638b28ef21e099d0a47190ecc6dc97e1 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 21:47:48 -0500 Subject: [PATCH 39/84] More minor fixes to task shader and made it require SPIR-V 1.4 --- naga/src/back/spv/block.rs | 79 +++++++++++++++++++++---------------- naga/src/back/spv/mod.rs | 2 + naga/src/back/spv/writer.rs | 4 ++ 3 files changed, 51 insertions(+), 34 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index c9b5c0163cc..ce08f65293a 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -222,8 +222,11 @@ impl Writer { result_members: &[ResultMember], body: &mut Vec, task_payload: Option, - ) -> Result<(), Error> { + ) -> Result { for (index, res_member) in result_members.iter().enumerate() { + if res_member.built_in == Some(crate::BuiltIn::MeshTaskSize) { + continue; + } let member_value_id = match ir_result.binding { Some(_) => value_id, None => { @@ -238,9 +241,7 @@ impl Writer { } }; - if res_member.built_in != Some(crate::BuiltIn::MeshTaskSize) { - body.push(Instruction::store(res_member.id, member_value_id, None)) - } + body.push(Instruction::store(res_member.id, member_value_id, None)); match res_member.built_in { Some(crate::BuiltIn::Position { .. }) @@ -253,30 +254,43 @@ impl Writer { { self.write_epilogue_frag_depth_clamp(res_member.id, body)?; } - Some(crate::BuiltIn::MeshTaskSize) => { - let values = [self.id_gen.next(), self.id_gen.next(), self.id_gen.next()]; - for (i, &value) in values.iter().enumerate() { - let mut instruction = Instruction::new(spirv::Op::CompositeExtract); - instruction.add_operand(self.get_u32_type_id()); - instruction.add_operand(value); - instruction.add_operand(member_value_id); - instruction.add_operand(i as u32); - body.push(instruction); - // Use OpCompositeExtract to save the component of the vec3 - } - let mut instruction = Instruction::new(spirv::Op::EmitMeshTasksEXT); - for id in values { - instruction.add_operand(id); - } - if let Some(task_payload) = task_payload { - instruction.add_operand(task_payload); - } + _ => {} + } + } + // MeshTaskSize must be called write before exiting + for (index, res_member) in result_members.iter().enumerate() { + let member_value_id = { + let member_value_id = self.id_gen.next(); + body.push(Instruction::composite_extract( + res_member.type_id, + member_value_id, + value_id, + &[index as Word], + )); + member_value_id + }; + if res_member.built_in == Some(crate::BuiltIn::MeshTaskSize) { + let values = [self.id_gen.next(), self.id_gen.next(), self.id_gen.next()]; + for (i, &value) in values.iter().enumerate() { + let mut instruction = Instruction::new(spirv::Op::CompositeExtract); + instruction.add_operand(self.get_u32_type_id()); + instruction.add_operand(value); + instruction.add_operand(member_value_id); + instruction.add_operand(i as u32); body.push(instruction); + // Use OpCompositeExtract to save the component of the vec3 } - _ => {} + let mut instruction = Instruction::new(spirv::Op::EmitMeshTasksEXT); + for id in values { + instruction.add_operand(id); + } + if let Some(task_payload) = task_payload { + instruction.add_operand(task_payload); + } + return Ok(instruction); } } - Ok(()) + Ok(Instruction::return_void()) } } @@ -3245,16 +3259,13 @@ impl BlockContext<'_> { let instruction = match self.function.entry_point_context { // If this is an entry point, and we need to return anything, // let's instead store the output variables and return `void`. - Some(ref context) => { - self.writer.write_entry_point_return( - value_id, - self.ir_function.result.as_ref().unwrap(), - &context.results, - &mut block.body, - context.task_payload, - )?; - Instruction::return_void() - } + Some(ref context) => self.writer.write_entry_point_return( + value_id, + self.ir_function.result.as_ref().unwrap(), + &context.results, + &mut block.body, + context.task_payload, + )?, None => Instruction::return_value(value_id), }; self.function.consume(block, instruction); diff --git a/naga/src/back/spv/mod.rs b/naga/src/back/spv/mod.rs index 21ad16b9f6c..82ca3255e31 100644 --- a/naga/src/back/spv/mod.rs +++ b/naga/src/back/spv/mod.rs @@ -78,6 +78,8 @@ pub enum Error { Override, #[error(transparent)] ResolveArraySizeError(#[from] crate::proc::ResolveArraySizeError), + #[error("module requires SPIRV-{0}.{1}, which isn't supported")] + SpirvVersionTooLow(u8, u8), } #[derive(Default)] diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 0eaa06c4463..abfa2b5439e 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -2493,6 +2493,10 @@ impl Writer { Instruction::extension("SPV_EXT_mesh_shader") .to_words(&mut self.logical_layout.extensions); self.require_any("Mesh Shaders", &[spirv::Capability::MeshShadingEXT])?; + let lang_version = self.lang_version(); + if lang_version.0 <= 1 && lang_version.1 < 4 { + return Err(Error::SpirvVersionTooLow(1, 4)); + } } Instruction::type_void(self.void_type).to_words(&mut self.logical_layout.declarations); Instruction::ext_inst_import(self.gl450_ext_inst_id, "GLSL.std.450") From 5bb4c3fa55d156b626132ecc853a158f6ec3bd96 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 22:02:08 -0500 Subject: [PATCH 40/84] Now also passes spirv-val --- naga-cli/src/bin/naga.rs | 25 +++++++++++++++++++++++++ naga/src/back/spv/block.rs | 33 +++++++++++++++++++-------------- 2 files changed, 44 insertions(+), 14 deletions(-) diff --git a/naga-cli/src/bin/naga.rs b/naga-cli/src/bin/naga.rs index c32d52a8397..39b8cd7f4ac 100644 --- a/naga-cli/src/bin/naga.rs +++ b/naga-cli/src/bin/naga.rs @@ -64,6 +64,12 @@ struct Args { #[argh(option)] shader_model: Option, + /// the SPIR-V version to use if targetting SPIR-V + /// + /// For example, 1.0, 1.4, etc + #[argh(option)] + spirv_version: Option, + /// the shader stage, for example 'frag', 'vert', or 'compute'. /// if the shader stage is unspecified it will be derived from /// the file extension. @@ -189,6 +195,22 @@ impl FromStr for ShaderModelArg { } } +#[derive(Debug, Clone)] +struct SpirvVersionArg(u8, u8); + +impl FromStr for SpirvVersionArg { + type Err = String; + + fn from_str(s: &str) -> Result { + let dot = s + .find(".") + .ok_or_else(|| "Missing dot separator".to_owned())?; + let major = s[..dot].parse::().map_err(|e| e.to_string())?; + let minor = s[dot + 1..].parse::().map_err(|e| e.to_string())?; + Ok(Self(major, minor)) + } +} + /// Newtype so we can implement [`FromStr`] for `ShaderSource`. #[derive(Debug, Clone, Copy)] struct ShaderStage(naga::ShaderStage); @@ -465,6 +487,9 @@ fn run() -> anyhow::Result<()> { if let Some(ref version) = args.metal_version { params.msl.lang_version = version.0; } + if let Some(ref version) = args.spirv_version { + params.spv_out.lang_version = (version.0, version.1); + } params.keep_coordinate_space = args.keep_coordinate_space; params.dot.cfg_only = args.dot_cfg_only; diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index ce08f65293a..a84155fc8b9 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -259,24 +259,29 @@ impl Writer { } // MeshTaskSize must be called write before exiting for (index, res_member) in result_members.iter().enumerate() { - let member_value_id = { - let member_value_id = self.id_gen.next(); - body.push(Instruction::composite_extract( - res_member.type_id, - member_value_id, - value_id, - &[index as Word], - )); - member_value_id + let member_value_id = match ir_result.binding { + Some(_) => value_id, + None => { + let member_value_id = self.id_gen.next(); + body.push(Instruction::composite_extract( + res_member.type_id, + member_value_id, + value_id, + &[index as Word], + )); + member_value_id + } }; + if res_member.built_in == Some(crate::BuiltIn::MeshTaskSize) { let values = [self.id_gen.next(), self.id_gen.next(), self.id_gen.next()]; for (i, &value) in values.iter().enumerate() { - let mut instruction = Instruction::new(spirv::Op::CompositeExtract); - instruction.add_operand(self.get_u32_type_id()); - instruction.add_operand(value); - instruction.add_operand(member_value_id); - instruction.add_operand(i as u32); + let instruction = Instruction::composite_extract( + self.get_u32_type_id(), + value, + member_value_id, + &[i as Word], + ); body.push(instruction); // Use OpCompositeExtract to save the component of the vec3 } From 2976b7834ac58e258652e9efe65114672efc981d Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 12 Jul 2025 22:03:16 -0500 Subject: [PATCH 41/84] Fixed silly typo that CI noticed --- naga-cli/src/bin/naga.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/naga-cli/src/bin/naga.rs b/naga-cli/src/bin/naga.rs index 39b8cd7f4ac..f73f2094370 100644 --- a/naga-cli/src/bin/naga.rs +++ b/naga-cli/src/bin/naga.rs @@ -64,7 +64,7 @@ struct Args { #[argh(option)] shader_model: Option, - /// the SPIR-V version to use if targetting SPIR-V + /// the SPIR-V version to use if targeting SPIR-V /// /// For example, 1.0, 1.4, etc #[argh(option)] From 2174592ccb8bff83e6197bac63f1313376331964 Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Sat, 12 Jul 2025 20:12:03 -0700 Subject: [PATCH 42/84] Updated snapshots --- .../analysis/wgsl-storage-textures.info.ron | 8 + .../spv/wgsl-6438-conflicting-idents.spvasm | 72 +- naga/tests/out/spv/wgsl-clip-distances.spvasm | 47 +- .../spv/wgsl-debug-symbol-large-source.spvasm | 666 +++++++++--------- .../out/spv/wgsl-debug-symbol-terrain.spvasm | 666 +++++++++--------- naga/tests/out/spv/wgsl-dualsource.spvasm | 8 +- .../out/spv/wgsl-interface.fragment.spvasm | 60 +- .../out/spv/wgsl-interface.vertex.spvasm | 18 +- .../out/spv/wgsl-interpolate_compat.spvasm | 426 +++++------ naga/tests/out/spv/wgsl-quad.spvasm | 134 ++-- naga/tests/out/spv/wgsl-shadow.spvasm | 573 +++++++-------- naga/tests/out/spv/wgsl-skybox.spvasm | 172 ++--- 12 files changed, 1449 insertions(+), 1401 deletions(-) diff --git a/naga/tests/out/analysis/wgsl-storage-textures.info.ron b/naga/tests/out/analysis/wgsl-storage-textures.info.ron index 8bb298a6450..35b5a7e320c 100644 --- a/naga/tests/out/analysis/wgsl-storage-textures.info.ron +++ b/naga/tests/out/analysis/wgsl-storage-textures.info.ron @@ -184,6 +184,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), @@ -396,6 +400,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ], const_expression_types: [], diff --git a/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm b/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm index 589eeb34624..f7f7a8a2ef4 100644 --- a/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm +++ b/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm @@ -1,19 +1,19 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 36 +; Bound: 38 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %15 "vs" %8 %11 %13 -OpEntryPoint Fragment %33 "fs" %32 -OpExecutionMode %33 OriginUpperLeft +OpEntryPoint Vertex %14 "vs" %8 %11 %11 %13 %13 +OpEntryPoint Fragment %35 "fs" %33 +OpExecutionMode %35 OriginUpperLeft OpMemberDecorate %6 0 Offset 0 OpMemberDecorate %6 1 Offset 16 OpDecorate %8 Location 0 OpDecorate %11 BuiltIn Position OpDecorate %13 Location 0 -OpDecorate %32 Location 0 +OpDecorate %33 Location 0 %2 = OpTypeVoid %4 = OpTypeFloat 32 %3 = OpTypeVector %4 4 @@ -21,40 +21,42 @@ OpDecorate %32 Location 0 %6 = OpTypeStruct %3 %5 %9 = OpTypePointer Input %5 %8 = OpVariable %9 Input -%12 = OpTypePointer Output %3 +%12 = OpTypePointer Output %6 %11 = OpVariable %12 Output -%14 = OpTypePointer Output %5 -%13 = OpVariable %14 Output -%16 = OpTypeFunction %2 -%17 = OpConstant %4 0.0 -%18 = OpConstant %4 1.0 -%20 = OpTypePointer Function %6 -%21 = OpConstantNull %6 -%23 = OpTypePointer Function %3 -%26 = OpTypeInt 32 0 -%25 = OpConstant %26 0 -%32 = OpVariable %12 Output -%34 = OpConstantComposite %3 %18 %17 %17 %18 -%15 = OpFunction %2 None %16 +%13 = OpVariable %12 Output +%15 = OpTypeFunction %2 +%16 = OpConstant %4 0.0 +%17 = OpConstant %4 1.0 +%19 = OpTypePointer Function %6 +%20 = OpConstantNull %6 +%22 = OpTypePointer Function %3 +%25 = OpTypeInt 32 0 +%24 = OpConstant %25 0 +%34 = OpTypePointer Output %3 +%33 = OpVariable %34 Output +%36 = OpConstantComposite %3 %17 %16 %16 %17 +%14 = OpFunction %2 None %15 %7 = OpLabel -%19 = OpVariable %20 Function %21 +%18 = OpVariable %19 Function %20 %10 = OpLoad %5 %8 -OpBranch %22 -%22 = OpLabel -%24 = OpCompositeConstruct %3 %10 %17 %18 -%27 = OpAccessChain %23 %19 %25 -OpStore %27 %24 -%28 = OpLoad %6 %19 -%29 = OpCompositeExtract %3 %28 0 -OpStore %11 %29 -%30 = OpCompositeExtract %5 %28 1 -OpStore %13 %30 +OpBranch %21 +%21 = OpLabel +%23 = OpCompositeConstruct %3 %10 %16 %17 +%26 = OpAccessChain %22 %18 %24 +OpStore %26 %23 +%27 = OpLoad %6 %18 +%28 = OpCompositeExtract %3 %27 0 +OpStore %11 %28 +%29 = OpCompositeExtract %5 %27 1 +OpStore %13 %29 +%30 = OpCompositeExtract %3 %27 0 +%31 = OpCompositeExtract %5 %27 1 OpReturn OpFunctionEnd -%33 = OpFunction %2 None %16 -%31 = OpLabel -OpBranch %35 -%35 = OpLabel -OpStore %32 %34 +%35 = OpFunction %2 None %15 +%32 = OpLabel +OpBranch %37 +%37 = OpLabel +OpStore %33 %36 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-clip-distances.spvasm b/naga/tests/out/spv/wgsl-clip-distances.spvasm index 24deba3c706..92ba74820e8 100644 --- a/naga/tests/out/spv/wgsl-clip-distances.spvasm +++ b/naga/tests/out/spv/wgsl-clip-distances.spvasm @@ -1,12 +1,12 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 28 +; Bound: 29 OpCapability Shader OpCapability ClipDistance %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %14 "main" %10 %12 +OpEntryPoint Vertex %13 "main" %10 %10 %12 %12 OpDecorate %5 ArrayStride 4 OpMemberDecorate %8 0 Offset 0 OpMemberDecorate %8 1 Offset 16 @@ -19,28 +19,29 @@ OpDecorate %12 BuiltIn ClipDistance %6 = OpConstant %7 1 %5 = OpTypeArray %3 %6 %8 = OpTypeStruct %4 %5 -%11 = OpTypePointer Output %4 +%11 = OpTypePointer Output %8 %10 = OpVariable %11 Output -%13 = OpTypePointer Output %5 -%12 = OpVariable %13 Output -%15 = OpTypeFunction %2 -%16 = OpConstant %3 0.5 -%18 = OpTypePointer Function %8 -%19 = OpConstantNull %8 -%21 = OpTypePointer Function %5 -%22 = OpTypePointer Function %3 -%23 = OpConstant %7 0 -%14 = OpFunction %2 None %15 +%12 = OpVariable %11 Output +%14 = OpTypeFunction %2 +%15 = OpConstant %3 0.5 +%17 = OpTypePointer Function %8 +%18 = OpConstantNull %8 +%20 = OpTypePointer Function %5 +%21 = OpTypePointer Function %3 +%22 = OpConstant %7 0 +%13 = OpFunction %2 None %14 %9 = OpLabel -%17 = OpVariable %18 Function %19 -OpBranch %20 -%20 = OpLabel -%24 = OpAccessChain %22 %17 %6 %23 -OpStore %24 %16 -%25 = OpLoad %8 %17 -%26 = OpCompositeExtract %4 %25 0 -OpStore %10 %26 -%27 = OpCompositeExtract %5 %25 1 -OpStore %12 %27 +%16 = OpVariable %17 Function %18 +OpBranch %19 +%19 = OpLabel +%23 = OpAccessChain %21 %16 %6 %22 +OpStore %23 %15 +%24 = OpLoad %8 %16 +%25 = OpCompositeExtract %4 %24 0 +OpStore %10 %25 +%26 = OpCompositeExtract %5 %24 1 +OpStore %12 %26 +%27 = OpCompositeExtract %4 %24 0 +%28 = OpCompositeExtract %5 %24 1 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm b/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm index f1db8e611ed..4e190a78a86 100644 --- a/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm +++ b/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm @@ -1,19 +1,19 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 682 +; Bound: 690 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %367 "gen_terrain_compute" %364 -OpEntryPoint Vertex %444 "gen_terrain_vertex" %435 %438 %440 %442 -OpEntryPoint Fragment %495 "gen_terrain_fragment" %485 %487 %490 %493 %494 -OpEntryPoint Vertex %590 "vs_main" %581 %584 %586 %587 %589 -OpEntryPoint Fragment %615 "fs_main" %608 %610 %612 %614 +OpEntryPoint Vertex %442 "gen_terrain_vertex" %435 %438 %438 %440 %440 %441 %441 +OpEntryPoint Fragment %497 "gen_terrain_fragment" %486 %488 %491 %494 %494 %496 %496 +OpEntryPoint Vertex %594 "vs_main" %585 %588 %590 %590 %592 %592 %593 %593 +OpEntryPoint Fragment %623 "fs_main" %615 %617 %619 %621 OpExecutionMode %367 LocalSize 64 1 1 -OpExecutionMode %495 OriginUpperLeft -OpExecutionMode %615 OriginUpperLeft +OpExecutionMode %497 OriginUpperLeft +OpExecutionMode %623 OriginUpperLeft %3 = OpString "debug-symbol-large-source.wgsl" OpSource Unknown 0 %3 "//This is a test 这是测试 これはテストだ 테스트입니다 This is a test 这是测试 これはテストだ 테스트입니다 This is a test 这是测试 これはテストだ 테스트입니다 //This is a test 这是测试 これはテストだ 테스트입니다 This is a test 这是测试 これはテストだ 테스트입니다 This is a test 这是测试 これはテストだ 테스트입니다 @@ -7567,27 +7567,27 @@ OpName %429 "rhs" OpName %435 "vindex" OpName %438 "index" OpName %440 "position" -OpName %442 "uv" -OpName %444 "gen_terrain_vertex" -OpName %485 "index" -OpName %487 "position" -OpName %490 "uv" -OpName %493 "vert_component" -OpName %494 "index" -OpName %495 "gen_terrain_fragment" -OpName %498 "vert_component" -OpName %499 "index" -OpName %581 "position" -OpName %584 "normal" -OpName %586 "clip_position" -OpName %587 "normal" -OpName %589 "world_pos" -OpName %590 "vs_main" -OpName %608 "clip_position" -OpName %610 "normal" -OpName %612 "world_pos" -OpName %615 "fs_main" -OpName %629 "color" +OpName %441 "uv" +OpName %442 "gen_terrain_vertex" +OpName %486 "index" +OpName %488 "position" +OpName %491 "uv" +OpName %494 "vert_component" +OpName %496 "index" +OpName %497 "gen_terrain_fragment" +OpName %500 "vert_component" +OpName %501 "index" +OpName %585 "position" +OpName %588 "normal" +OpName %590 "clip_position" +OpName %592 "normal" +OpName %593 "world_pos" +OpName %594 "vs_main" +OpName %615 "clip_position" +OpName %617 "normal" +OpName %619 "world_pos" +OpName %623 "fs_main" +OpName %637 "color" OpMemberDecorate %13 0 Offset 0 OpMemberDecorate %13 1 Offset 8 OpMemberDecorate %13 2 Offset 16 @@ -7651,22 +7651,22 @@ OpDecorate %435 BuiltIn VertexIndex OpDecorate %438 Location 0 OpDecorate %438 Flat OpDecorate %440 BuiltIn Position -OpDecorate %442 Location 1 -OpDecorate %485 Location 0 -OpDecorate %485 Flat -OpDecorate %487 BuiltIn FragCoord -OpDecorate %490 Location 1 -OpDecorate %493 Location 0 -OpDecorate %494 Location 1 -OpDecorate %581 Location 0 -OpDecorate %584 Location 1 -OpDecorate %586 BuiltIn Position -OpDecorate %587 Location 0 -OpDecorate %589 Location 1 -OpDecorate %608 BuiltIn FragCoord -OpDecorate %610 Location 0 -OpDecorate %612 Location 1 -OpDecorate %614 Location 0 +OpDecorate %441 Location 1 +OpDecorate %486 Location 0 +OpDecorate %486 Flat +OpDecorate %488 BuiltIn FragCoord +OpDecorate %491 Location 1 +OpDecorate %494 Location 0 +OpDecorate %496 Location 1 +OpDecorate %585 Location 0 +OpDecorate %588 Location 1 +OpDecorate %590 BuiltIn Position +OpDecorate %592 Location 0 +OpDecorate %593 Location 1 +OpDecorate %615 BuiltIn FragCoord +OpDecorate %617 Location 0 +OpDecorate %619 Location 1 +OpDecorate %621 Location 0 %2 = OpTypeVoid %4 = OpTypeFloat 32 %5 = OpTypeVector %4 3 @@ -7799,47 +7799,47 @@ OpDecorate %614 Location 0 %415 = OpTypePointer StorageBuffer %8 %436 = OpTypePointer Input %8 %435 = OpVariable %436 Input -%439 = OpTypePointer Output %8 +%439 = OpTypePointer Output %21 %438 = OpVariable %439 Output -%441 = OpTypePointer Output %7 -%440 = OpVariable %441 Output -%443 = OpTypePointer Output %6 -%442 = OpVariable %443 Output -%445 = OpTypePointer Uniform %20 -%447 = OpConstant %4 -1.0 -%448 = OpConstantComposite %6 %447 %447 -%473 = OpConstant %4 4294967000.0 -%485 = OpVariable %436 Input -%488 = OpTypePointer Input %7 -%487 = OpVariable %488 Input -%491 = OpTypePointer Input %6 -%490 = OpVariable %491 Input -%493 = OpVariable %439 Output -%494 = OpVariable %439 Output -%497 = OpConstant %4 6.0 -%582 = OpTypePointer Input %5 -%581 = OpVariable %582 Input -%584 = OpVariable %582 Input -%586 = OpVariable %441 Output -%588 = OpTypePointer Output %5 -%587 = OpVariable %588 Output -%589 = OpVariable %588 Output -%591 = OpTypePointer Uniform %24 -%594 = OpTypePointer Uniform %23 -%608 = OpVariable %488 Input -%610 = OpVariable %582 Input -%612 = OpVariable %582 Input -%614 = OpVariable %441 Output -%617 = OpTypePointer Uniform %25 -%623 = OpConstantComposite %6 %56 %81 -%624 = OpConstantComposite %5 %286 %286 %286 -%625 = OpConstant %4 0.7 -%626 = OpConstantComposite %5 %78 %286 %625 -%627 = OpConstant %4 0.2 -%628 = OpConstantComposite %5 %627 %627 %627 -%630 = OpConstantNull %5 -%646 = OpTypePointer Uniform %5 -%655 = OpTypePointer Uniform %7 +%440 = OpVariable %439 Output +%441 = OpVariable %439 Output +%443 = OpTypePointer Uniform %20 +%445 = OpConstant %4 -1.0 +%446 = OpConstantComposite %6 %445 %445 +%471 = OpConstant %4 4294967000.0 +%486 = OpVariable %436 Input +%489 = OpTypePointer Input %7 +%488 = OpVariable %489 Input +%492 = OpTypePointer Input %6 +%491 = OpVariable %492 Input +%495 = OpTypePointer Output %22 +%494 = OpVariable %495 Output +%496 = OpVariable %495 Output +%499 = OpConstant %4 6.0 +%586 = OpTypePointer Input %5 +%585 = OpVariable %586 Input +%588 = OpVariable %586 Input +%591 = OpTypePointer Output %26 +%590 = OpVariable %591 Output +%592 = OpVariable %591 Output +%593 = OpVariable %591 Output +%595 = OpTypePointer Uniform %24 +%598 = OpTypePointer Uniform %23 +%615 = OpVariable %489 Input +%617 = OpVariable %586 Input +%619 = OpVariable %586 Input +%622 = OpTypePointer Output %7 +%621 = OpVariable %622 Output +%625 = OpTypePointer Uniform %25 +%631 = OpConstantComposite %6 %56 %81 +%632 = OpConstantComposite %5 %286 %286 %286 +%633 = OpConstant %4 0.7 +%634 = OpConstantComposite %5 %78 %286 %633 +%635 = OpConstant %4 0.2 +%636 = OpConstantComposite %5 %635 %635 %635 +%638 = OpConstantNull %5 +%654 = OpTypePointer Uniform %5 +%663 = OpTypePointer Uniform %7 %53 = OpFunction %5 None %54 %52 = OpFunctionParameter %5 %51 = OpLabel @@ -8351,339 +8351,347 @@ OpFunctionEnd %433 = OpUMod %8 %428 %432 OpReturnValue %433 OpFunctionEnd -%444 = OpFunction %2 None %368 +%442 = OpFunction %2 None %368 %434 = OpLabel %437 = OpLoad %8 %435 -%446 = OpAccessChain %445 %36 %135 -OpBranch %449 -%449 = OpLabel +%444 = OpAccessChain %443 %36 %135 +OpBranch %447 +%447 = OpLabel OpLine %3 7304 19 -%450 = OpIAdd %8 %437 %372 +%448 = OpIAdd %8 %437 %372 OpLine %3 7304 18 -%451 = OpFunctionCall %8 %313 %450 %373 +%449 = OpFunctionCall %8 %313 %448 %373 OpLine %3 7304 13 -%452 = OpFunctionCall %8 %427 %451 %372 -%453 = OpConvertUToF %4 %452 +%450 = OpFunctionCall %8 %427 %449 %372 +%451 = OpConvertUToF %4 %450 OpLine %3 7305 19 -%454 = OpIAdd %8 %437 %126 +%452 = OpIAdd %8 %437 %126 OpLine %3 7305 18 -%455 = OpFunctionCall %8 %313 %454 %373 +%453 = OpFunctionCall %8 %313 %452 %373 OpLine %3 7305 13 -%456 = OpFunctionCall %8 %427 %455 %372 -%457 = OpConvertUToF %4 %456 +%454 = OpFunctionCall %8 %427 %453 %372 +%455 = OpConvertUToF %4 %454 OpLine %3 7306 14 -%458 = OpCompositeConstruct %6 %453 %457 +%456 = OpCompositeConstruct %6 %451 %455 OpLine %3 7308 30 -%459 = OpVectorTimesScalar %6 %458 %81 +%457 = OpVectorTimesScalar %6 %456 %81 OpLine %3 7308 30 -%460 = OpFAdd %6 %448 %459 +%458 = OpFAdd %6 %446 %457 OpLine %3 7308 20 -%461 = OpCompositeConstruct %7 %460 %74 %56 +%459 = OpCompositeConstruct %7 %458 %74 %56 OpLine %3 7311 21 -%462 = OpCompositeExtract %4 %458 0 +%460 = OpCompositeExtract %4 %456 0 OpLine %3 7311 21 -%463 = OpAccessChain %393 %446 %373 -%464 = OpLoad %8 %463 -%465 = OpConvertUToF %4 %464 -%466 = OpFMul %4 %462 %465 -%467 = OpCompositeExtract %4 %458 1 +%461 = OpAccessChain %393 %444 %373 +%462 = OpLoad %8 %461 +%463 = OpConvertUToF %4 %462 +%464 = OpFMul %4 %460 %463 +%465 = OpCompositeExtract %4 %456 1 OpLine %3 7311 17 -%468 = OpAccessChain %393 %446 %373 -%469 = OpLoad %8 %468 -%470 = OpConvertUToF %4 %469 -%471 = OpFMul %4 %467 %470 -%472 = OpFAdd %4 %466 %471 -%474 = OpExtInst %4 %1 FClamp %472 %74 %473 -%475 = OpConvertFToU %8 %474 +%466 = OpAccessChain %393 %444 %373 +%467 = OpLoad %8 %466 +%468 = OpConvertUToF %4 %467 +%469 = OpFMul %4 %465 %468 +%470 = OpFAdd %4 %464 %469 +%472 = OpExtInst %4 %1 FClamp %470 %74 %471 +%473 = OpConvertFToU %8 %472 OpLine %3 7311 17 -%476 = OpAccessChain %393 %446 %374 -%477 = OpLoad %8 %476 -%478 = OpIAdd %8 %475 %477 +%474 = OpAccessChain %393 %444 %374 +%475 = OpLoad %8 %474 +%476 = OpIAdd %8 %473 %475 OpLine %3 7313 12 -%479 = OpCompositeConstruct %21 %478 %461 %458 -%480 = OpCompositeExtract %8 %479 0 -OpStore %438 %480 -%481 = OpCompositeExtract %7 %479 1 -OpStore %440 %481 -%482 = OpCompositeExtract %6 %479 2 -OpStore %442 %482 +%477 = OpCompositeConstruct %21 %476 %459 %456 +%478 = OpCompositeExtract %8 %477 0 +OpStore %438 %478 +%479 = OpCompositeExtract %7 %477 1 +OpStore %440 %479 +%480 = OpCompositeExtract %6 %477 2 +OpStore %441 %480 +%481 = OpCompositeExtract %8 %477 0 +%482 = OpCompositeExtract %7 %477 1 +%483 = OpCompositeExtract %6 %477 2 OpReturn OpFunctionEnd -%495 = OpFunction %2 None %368 -%483 = OpLabel -%498 = OpVariable %125 Function %74 -%499 = OpVariable %217 Function %135 -%486 = OpLoad %8 %485 -%489 = OpLoad %7 %487 -%492 = OpLoad %6 %490 -%484 = OpCompositeConstruct %21 %486 %489 %492 -%496 = OpAccessChain %445 %36 %135 -OpBranch %500 -%500 = OpLabel +%497 = OpFunction %2 None %368 +%484 = OpLabel +%500 = OpVariable %125 Function %74 +%501 = OpVariable %217 Function %135 +%487 = OpLoad %8 %486 +%490 = OpLoad %7 %488 +%493 = OpLoad %6 %491 +%485 = OpCompositeConstruct %21 %487 %490 %493 +%498 = OpAccessChain %443 %36 %135 +OpBranch %502 +%502 = OpLabel OpLine %3 7324 17 -%501 = OpCompositeExtract %6 %484 2 -%502 = OpCompositeExtract %4 %501 0 +%503 = OpCompositeExtract %6 %485 2 +%504 = OpCompositeExtract %4 %503 0 OpLine %3 7324 17 -%503 = OpAccessChain %393 %496 %373 -%504 = OpLoad %8 %503 -%505 = OpConvertUToF %4 %504 -%506 = OpFMul %4 %502 %505 -%507 = OpCompositeExtract %6 %484 2 -%508 = OpCompositeExtract %4 %507 1 +%505 = OpAccessChain %393 %498 %373 +%506 = OpLoad %8 %505 +%507 = OpConvertUToF %4 %506 +%508 = OpFMul %4 %504 %507 +%509 = OpCompositeExtract %6 %485 2 +%510 = OpCompositeExtract %4 %509 1 OpLine %3 7324 70 -%509 = OpAccessChain %393 %496 %373 -%510 = OpLoad %8 %509 -OpLine %3 7324 13 -%511 = OpAccessChain %393 %496 %373 +%511 = OpAccessChain %393 %498 %373 %512 = OpLoad %8 %511 -%513 = OpIMul %8 %510 %512 -%514 = OpConvertUToF %4 %513 -%515 = OpFMul %4 %508 %514 -%516 = OpFAdd %4 %506 %515 -%517 = OpExtInst %4 %1 FClamp %516 %74 %473 -%518 = OpConvertFToU %8 %517 OpLine %3 7324 13 -%519 = OpAccessChain %393 %496 %374 -%520 = OpLoad %8 %519 -%521 = OpIAdd %8 %518 %520 +%513 = OpAccessChain %393 %498 %373 +%514 = OpLoad %8 %513 +%515 = OpIMul %8 %512 %514 +%516 = OpConvertUToF %4 %515 +%517 = OpFMul %4 %510 %516 +%518 = OpFAdd %4 %508 %517 +%519 = OpExtInst %4 %1 FClamp %518 %74 %471 +%520 = OpConvertFToU %8 %519 +OpLine %3 7324 13 +%521 = OpAccessChain %393 %498 %374 +%522 = OpLoad %8 %521 +%523 = OpIAdd %8 %520 %522 OpLine %3 7325 32 -%522 = OpConvertUToF %4 %521 +%524 = OpConvertUToF %4 %523 OpLine %3 7325 22 -%523 = OpFDiv %4 %522 %497 -%524 = OpExtInst %4 %1 Floor %523 -%525 = OpExtInst %4 %1 FClamp %524 %74 %473 -%526 = OpConvertFToU %8 %525 +%525 = OpFDiv %4 %524 %499 +%526 = OpExtInst %4 %1 Floor %525 +%527 = OpExtInst %4 %1 FClamp %526 %74 %471 +%528 = OpConvertFToU %8 %527 OpLine %3 7326 22 -%527 = OpFunctionCall %8 %427 %521 %371 +%529 = OpFunctionCall %8 %427 %523 %371 OpLine %3 7328 36 -%528 = OpAccessChain %377 %496 %135 -%529 = OpLoad %10 %528 +%530 = OpAccessChain %377 %498 %135 +%531 = OpLoad %10 %530 OpLine %3 7328 57 -%530 = OpAccessChain %380 %496 %126 -%531 = OpLoad %11 %530 +%532 = OpAccessChain %380 %498 %126 +%533 = OpLoad %11 %532 OpLine %3 7328 13 -%532 = OpFunctionCall %6 %325 %526 %529 %531 +%534 = OpFunctionCall %6 %325 %528 %531 %533 OpLine %3 7329 31 -%533 = OpAccessChain %386 %496 %372 -%534 = OpLoad %6 %533 +%535 = OpAccessChain %386 %498 %372 +%536 = OpLoad %6 %535 OpLine %3 7329 13 -%535 = OpFunctionCall %14 %284 %532 %534 +%537 = OpFunctionCall %14 %284 %534 %536 OpLine %3 7333 5 -OpSelectionMerge %536 None -OpSwitch %527 %543 0 %537 1 %538 2 %539 3 %540 4 %541 5 %542 -%537 = OpLabel +OpSelectionMerge %538 None +OpSwitch %529 %545 0 %539 1 %540 2 %541 3 %542 4 %543 5 %544 +%539 = OpLabel OpLine %3 7334 37 -%544 = OpCompositeExtract %5 %535 0 -%545 = OpCompositeExtract %4 %544 0 +%546 = OpCompositeExtract %5 %537 0 +%547 = OpCompositeExtract %4 %546 0 OpLine %3 7334 20 -OpStore %498 %545 -OpBranch %536 -%538 = OpLabel +OpStore %500 %547 +OpBranch %538 +%540 = OpLabel OpLine %3 7335 37 -%546 = OpCompositeExtract %5 %535 0 -%547 = OpCompositeExtract %4 %546 1 +%548 = OpCompositeExtract %5 %537 0 +%549 = OpCompositeExtract %4 %548 1 OpLine %3 7335 20 -OpStore %498 %547 -OpBranch %536 -%539 = OpLabel +OpStore %500 %549 +OpBranch %538 +%541 = OpLabel OpLine %3 7336 37 -%548 = OpCompositeExtract %5 %535 0 -%549 = OpCompositeExtract %4 %548 2 +%550 = OpCompositeExtract %5 %537 0 +%551 = OpCompositeExtract %4 %550 2 OpLine %3 7336 20 -OpStore %498 %549 -OpBranch %536 -%540 = OpLabel +OpStore %500 %551 +OpBranch %538 +%542 = OpLabel OpLine %3 7337 37 -%550 = OpCompositeExtract %5 %535 1 -%551 = OpCompositeExtract %4 %550 0 +%552 = OpCompositeExtract %5 %537 1 +%553 = OpCompositeExtract %4 %552 0 OpLine %3 7337 20 -OpStore %498 %551 -OpBranch %536 -%541 = OpLabel +OpStore %500 %553 +OpBranch %538 +%543 = OpLabel OpLine %3 7338 37 -%552 = OpCompositeExtract %5 %535 1 -%553 = OpCompositeExtract %4 %552 1 +%554 = OpCompositeExtract %5 %537 1 +%555 = OpCompositeExtract %4 %554 1 OpLine %3 7338 20 -OpStore %498 %553 -OpBranch %536 -%542 = OpLabel +OpStore %500 %555 +OpBranch %538 +%544 = OpLabel OpLine %3 7339 37 -%554 = OpCompositeExtract %5 %535 1 -%555 = OpCompositeExtract %4 %554 2 +%556 = OpCompositeExtract %5 %537 1 +%557 = OpCompositeExtract %4 %556 2 OpLine %3 7339 20 -OpStore %498 %555 -OpBranch %536 -%543 = OpLabel -OpBranch %536 -%536 = OpLabel +OpStore %500 %557 +OpBranch %538 +%545 = OpLabel +OpBranch %538 +%538 = OpLabel OpLine %3 7343 15 -%556 = OpAccessChain %393 %496 %135 %135 -%557 = OpLoad %8 %556 -%558 = OpFunctionCall %8 %313 %526 %557 -%559 = OpIAdd %8 %526 %558 +%558 = OpAccessChain %393 %498 %135 %135 +%559 = OpLoad %8 %558 +%560 = OpFunctionCall %8 %313 %528 %559 +%561 = OpIAdd %8 %528 %560 OpLine %3 7344 15 -%560 = OpIAdd %8 %559 %126 +%562 = OpIAdd %8 %561 %126 OpLine %3 7345 15 -%561 = OpAccessChain %393 %496 %135 %135 -%562 = OpLoad %8 %561 -%563 = OpIAdd %8 %559 %562 +%563 = OpAccessChain %393 %498 %135 %135 +%564 = OpLoad %8 %563 +%565 = OpIAdd %8 %561 %564 OpLine %3 7345 15 -%564 = OpIAdd %8 %563 %126 +%566 = OpIAdd %8 %565 %126 OpLine %3 7346 15 -%565 = OpIAdd %8 %564 %126 +%567 = OpIAdd %8 %566 %126 OpLine %3 7349 5 -OpSelectionMerge %566 None -OpSwitch %527 %571 0 %567 3 %567 2 %568 4 %568 1 %569 5 %570 -%567 = OpLabel +OpSelectionMerge %568 None +OpSwitch %529 %573 0 %569 3 %569 2 %570 4 %570 1 %571 5 %572 +%569 = OpLabel OpLine %3 7350 24 -OpStore %499 %559 -OpBranch %566 -%568 = OpLabel +OpStore %501 %561 +OpBranch %568 +%570 = OpLabel OpLine %3 7351 24 -OpStore %499 %565 -OpBranch %566 -%569 = OpLabel +OpStore %501 %567 +OpBranch %568 +%571 = OpLabel OpLine %3 7352 20 -OpStore %499 %564 -OpBranch %566 -%570 = OpLabel +OpStore %501 %566 +OpBranch %568 +%572 = OpLabel OpLine %3 7353 20 -OpStore %499 %560 -OpBranch %566 -%571 = OpLabel -OpBranch %566 -%566 = OpLabel +OpStore %501 %562 +OpBranch %568 +%573 = OpLabel +OpBranch %568 +%568 = OpLabel OpLine %3 7356 13 -%572 = OpCompositeExtract %8 %484 0 +%574 = OpCompositeExtract %8 %485 0 OpLine %3 7356 5 -OpStore %499 %572 +OpStore %501 %574 OpLine %3 7365 27 -%573 = OpLoad %4 %498 -%574 = OpBitcast %8 %573 +%575 = OpLoad %4 %500 +%576 = OpBitcast %8 %575 OpLine %3 7366 12 -%575 = OpLoad %8 %499 -%576 = OpCompositeConstruct %22 %574 %575 -%577 = OpCompositeExtract %8 %576 0 -OpStore %493 %577 -%578 = OpCompositeExtract %8 %576 1 -OpStore %494 %578 +%577 = OpLoad %8 %501 +%578 = OpCompositeConstruct %22 %576 %577 +%579 = OpCompositeExtract %8 %578 0 +OpStore %494 %579 +%580 = OpCompositeExtract %8 %578 1 +OpStore %496 %580 +%581 = OpCompositeExtract %8 %578 0 +%582 = OpCompositeExtract %8 %578 1 OpReturn OpFunctionEnd -%590 = OpFunction %2 None %368 -%579 = OpLabel -%583 = OpLoad %5 %581 -%585 = OpLoad %5 %584 -%580 = OpCompositeConstruct %14 %583 %585 -%592 = OpAccessChain %591 %39 %135 -OpBranch %593 -%593 = OpLabel +%594 = OpFunction %2 None %368 +%583 = OpLabel +%587 = OpLoad %5 %585 +%589 = OpLoad %5 %588 +%584 = OpCompositeConstruct %14 %587 %589 +%596 = OpAccessChain %595 %39 %135 +OpBranch %597 +%597 = OpLabel OpLine %3 7397 25 -%595 = OpAccessChain %594 %592 %126 -%596 = OpLoad %23 %595 -%597 = OpCompositeExtract %5 %580 0 +%599 = OpAccessChain %598 %596 %126 +%600 = OpLoad %23 %599 +%601 = OpCompositeExtract %5 %584 0 OpLine %3 7397 25 -%598 = OpCompositeConstruct %7 %597 %56 -%599 = OpMatrixTimesVector %7 %596 %598 +%602 = OpCompositeConstruct %7 %601 %56 +%603 = OpMatrixTimesVector %7 %600 %602 OpLine %3 7398 18 -%600 = OpCompositeExtract %5 %580 1 +%604 = OpCompositeExtract %5 %584 1 OpLine %3 7399 12 -%601 = OpCompositeExtract %5 %580 0 -%602 = OpCompositeConstruct %26 %599 %600 %601 -%603 = OpCompositeExtract %7 %602 0 -OpStore %586 %603 -%604 = OpCompositeExtract %5 %602 1 -OpStore %587 %604 -%605 = OpCompositeExtract %5 %602 2 -OpStore %589 %605 +%605 = OpCompositeExtract %5 %584 0 +%606 = OpCompositeConstruct %26 %603 %604 %605 +%607 = OpCompositeExtract %7 %606 0 +OpStore %590 %607 +%608 = OpCompositeExtract %5 %606 1 +OpStore %592 %608 +%609 = OpCompositeExtract %5 %606 2 +OpStore %593 %609 +%610 = OpCompositeExtract %7 %606 0 +%611 = OpCompositeExtract %5 %606 1 +%612 = OpCompositeExtract %5 %606 2 OpReturn OpFunctionEnd -%615 = OpFunction %2 None %368 -%606 = OpLabel -%629 = OpVariable %95 Function %630 -%609 = OpLoad %7 %608 -%611 = OpLoad %5 %610 -%613 = OpLoad %5 %612 -%607 = OpCompositeConstruct %26 %609 %611 %613 -%616 = OpAccessChain %591 %39 %135 -%618 = OpAccessChain %617 %42 %135 -%619 = OpLoad %27 %45 -%620 = OpLoad %28 %47 -%621 = OpLoad %27 %49 -%622 = OpLoad %28 %50 -OpBranch %631 -%631 = OpLabel +%623 = OpFunction %2 None %368 +%613 = OpLabel +%637 = OpVariable %95 Function %638 +%616 = OpLoad %7 %615 +%618 = OpLoad %5 %617 +%620 = OpLoad %5 %619 +%614 = OpCompositeConstruct %26 %616 %618 %620 +%624 = OpAccessChain %595 %39 %135 +%626 = OpAccessChain %625 %42 %135 +%627 = OpLoad %27 %45 +%628 = OpLoad %28 %47 +%629 = OpLoad %27 %49 +%630 = OpLoad %28 %50 +OpBranch %639 +%639 = OpLabel OpLine %3 7426 13 OpLine %3 7426 13 OpLine %3 7426 5 -%632 = OpFunctionCall %5 %342 %623 +%640 = OpFunctionCall %5 %342 %631 OpLine %3 7428 28 OpLine %3 7428 17 -%633 = OpCompositeExtract %5 %607 2 -%634 = OpExtInst %5 %1 Fract %633 -%635 = OpExtInst %5 %1 SmoothStep %80 %624 %634 +%641 = OpCompositeExtract %5 %614 2 +%642 = OpExtInst %5 %1 Fract %641 +%643 = OpExtInst %5 %1 SmoothStep %80 %632 %642 OpLine %3 7428 5 -OpStore %629 %635 +OpStore %637 %643 OpLine %3 7429 17 OpLine %3 7429 13 -%636 = OpAccessChain %125 %629 %135 -%637 = OpLoad %4 %636 -%638 = OpAccessChain %125 %629 %126 -%639 = OpLoad %4 %638 -%640 = OpFMul %4 %637 %639 -%641 = OpAccessChain %125 %629 %372 -%642 = OpLoad %4 %641 -%643 = OpFMul %4 %640 %642 -%644 = OpCompositeConstruct %5 %643 %643 %643 -%645 = OpExtInst %5 %1 FMix %626 %628 %644 +%644 = OpAccessChain %125 %637 %135 +%645 = OpLoad %4 %644 +%646 = OpAccessChain %125 %637 %126 +%647 = OpLoad %4 %646 +%648 = OpFMul %4 %645 %647 +%649 = OpAccessChain %125 %637 %372 +%650 = OpLoad %4 %649 +%651 = OpFMul %4 %648 %650 +%652 = OpCompositeConstruct %5 %651 %651 %651 +%653 = OpExtInst %5 %1 FMix %634 %636 %652 OpLine %3 7429 5 -OpStore %629 %645 +OpStore %637 %653 OpLine %3 7432 25 -%647 = OpAccessChain %646 %618 %126 -%648 = OpLoad %5 %647 -%649 = OpVectorTimesScalar %5 %648 %286 +%655 = OpAccessChain %654 %626 %126 +%656 = OpLoad %5 %655 +%657 = OpVectorTimesScalar %5 %656 %286 OpLine %3 7434 21 -%650 = OpAccessChain %646 %618 %135 -%651 = OpLoad %5 %650 -%652 = OpCompositeExtract %5 %607 2 -%653 = OpFSub %5 %651 %652 -%654 = OpExtInst %5 %1 Normalize %653 +%658 = OpAccessChain %654 %626 %135 +%659 = OpLoad %5 %658 +%660 = OpCompositeExtract %5 %614 2 +%661 = OpFSub %5 %659 %660 +%662 = OpExtInst %5 %1 Normalize %661 OpLine %3 7435 20 -%656 = OpAccessChain %655 %616 %135 -%657 = OpLoad %7 %656 -%658 = OpVectorShuffle %5 %657 %657 0 1 2 -%659 = OpCompositeExtract %5 %607 2 -%660 = OpFSub %5 %658 %659 -%661 = OpExtInst %5 %1 Normalize %660 +%664 = OpAccessChain %663 %624 %135 +%665 = OpLoad %7 %664 +%666 = OpVectorShuffle %5 %665 %665 0 1 2 +%667 = OpCompositeExtract %5 %614 2 +%668 = OpFSub %5 %666 %667 +%669 = OpExtInst %5 %1 Normalize %668 OpLine %3 7436 20 -%662 = OpFAdd %5 %661 %654 -%663 = OpExtInst %5 %1 Normalize %662 +%670 = OpFAdd %5 %669 %662 +%671 = OpExtInst %5 %1 Normalize %670 OpLine %3 7438 32 -%664 = OpCompositeExtract %5 %607 1 -%665 = OpDot %4 %664 %654 +%672 = OpCompositeExtract %5 %614 1 +%673 = OpDot %4 %672 %662 OpLine %3 7438 28 -%666 = OpExtInst %4 %1 FMax %665 %74 +%674 = OpExtInst %4 %1 FMax %673 %74 OpLine %3 7439 25 -%667 = OpAccessChain %646 %618 %126 -%668 = OpLoad %5 %667 -%669 = OpVectorTimesScalar %5 %668 %666 +%675 = OpAccessChain %654 %626 %126 +%676 = OpLoad %5 %675 +%677 = OpVectorTimesScalar %5 %676 %674 OpLine %3 7441 37 -%670 = OpCompositeExtract %5 %607 1 -%671 = OpDot %4 %670 %663 +%678 = OpCompositeExtract %5 %614 1 +%679 = OpDot %4 %678 %671 OpLine %3 7441 33 -%672 = OpExtInst %4 %1 FMax %671 %74 +%680 = OpExtInst %4 %1 FMax %679 %74 OpLine %3 7441 29 -%673 = OpExtInst %4 %1 Pow %672 %345 +%681 = OpExtInst %4 %1 Pow %680 %345 OpLine %3 7442 26 -%674 = OpAccessChain %646 %618 %126 -%675 = OpLoad %5 %674 -%676 = OpVectorTimesScalar %5 %675 %673 +%682 = OpAccessChain %654 %626 %126 +%683 = OpLoad %5 %682 +%684 = OpVectorTimesScalar %5 %683 %681 OpLine %3 7444 18 -%677 = OpFAdd %5 %649 %669 -%678 = OpFAdd %5 %677 %676 -%679 = OpLoad %5 %629 -%680 = OpFMul %5 %678 %679 +%685 = OpFAdd %5 %657 %677 +%686 = OpFAdd %5 %685 %684 +%687 = OpLoad %5 %637 +%688 = OpFMul %5 %686 %687 OpLine %3 7446 12 -%681 = OpCompositeConstruct %7 %680 %56 -OpStore %614 %681 +%689 = OpCompositeConstruct %7 %688 %56 +OpStore %621 %689 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm b/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm index 69f08bcdb62..64e89a55d85 100644 --- a/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm +++ b/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm @@ -1,19 +1,19 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 682 +; Bound: 690 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %367 "gen_terrain_compute" %364 -OpEntryPoint Vertex %444 "gen_terrain_vertex" %435 %438 %440 %442 -OpEntryPoint Fragment %495 "gen_terrain_fragment" %485 %487 %490 %493 %494 -OpEntryPoint Vertex %590 "vs_main" %581 %584 %586 %587 %589 -OpEntryPoint Fragment %615 "fs_main" %608 %610 %612 %614 +OpEntryPoint Vertex %442 "gen_terrain_vertex" %435 %438 %438 %440 %440 %441 %441 +OpEntryPoint Fragment %497 "gen_terrain_fragment" %486 %488 %491 %494 %494 %496 %496 +OpEntryPoint Vertex %594 "vs_main" %585 %588 %590 %590 %592 %592 %593 %593 +OpEntryPoint Fragment %623 "fs_main" %615 %617 %619 %621 OpExecutionMode %367 LocalSize 64 1 1 -OpExecutionMode %495 OriginUpperLeft -OpExecutionMode %615 OriginUpperLeft +OpExecutionMode %497 OriginUpperLeft +OpExecutionMode %623 OriginUpperLeft %3 = OpString "debug-symbol-terrain.wgsl" OpSource Unknown 0 %3 "// Taken from https://github.com/sotrh/learn-wgpu/blob/11820796f5e1dbce42fb1119f04ddeb4b167d2a0/code/intermediate/tutorial13-terrain/src/terrain.wgsl // ============================ @@ -402,27 +402,27 @@ OpName %429 "rhs" OpName %435 "vindex" OpName %438 "index" OpName %440 "position" -OpName %442 "uv" -OpName %444 "gen_terrain_vertex" -OpName %485 "index" -OpName %487 "position" -OpName %490 "uv" -OpName %493 "vert_component" -OpName %494 "index" -OpName %495 "gen_terrain_fragment" -OpName %498 "vert_component" -OpName %499 "index" -OpName %581 "position" -OpName %584 "normal" -OpName %586 "clip_position" -OpName %587 "normal" -OpName %589 "world_pos" -OpName %590 "vs_main" -OpName %608 "clip_position" -OpName %610 "normal" -OpName %612 "world_pos" -OpName %615 "fs_main" -OpName %629 "color" +OpName %441 "uv" +OpName %442 "gen_terrain_vertex" +OpName %486 "index" +OpName %488 "position" +OpName %491 "uv" +OpName %494 "vert_component" +OpName %496 "index" +OpName %497 "gen_terrain_fragment" +OpName %500 "vert_component" +OpName %501 "index" +OpName %585 "position" +OpName %588 "normal" +OpName %590 "clip_position" +OpName %592 "normal" +OpName %593 "world_pos" +OpName %594 "vs_main" +OpName %615 "clip_position" +OpName %617 "normal" +OpName %619 "world_pos" +OpName %623 "fs_main" +OpName %637 "color" OpMemberDecorate %13 0 Offset 0 OpMemberDecorate %13 1 Offset 8 OpMemberDecorate %13 2 Offset 16 @@ -486,22 +486,22 @@ OpDecorate %435 BuiltIn VertexIndex OpDecorate %438 Location 0 OpDecorate %438 Flat OpDecorate %440 BuiltIn Position -OpDecorate %442 Location 1 -OpDecorate %485 Location 0 -OpDecorate %485 Flat -OpDecorate %487 BuiltIn FragCoord -OpDecorate %490 Location 1 -OpDecorate %493 Location 0 -OpDecorate %494 Location 1 -OpDecorate %581 Location 0 -OpDecorate %584 Location 1 -OpDecorate %586 BuiltIn Position -OpDecorate %587 Location 0 -OpDecorate %589 Location 1 -OpDecorate %608 BuiltIn FragCoord -OpDecorate %610 Location 0 -OpDecorate %612 Location 1 -OpDecorate %614 Location 0 +OpDecorate %441 Location 1 +OpDecorate %486 Location 0 +OpDecorate %486 Flat +OpDecorate %488 BuiltIn FragCoord +OpDecorate %491 Location 1 +OpDecorate %494 Location 0 +OpDecorate %496 Location 1 +OpDecorate %585 Location 0 +OpDecorate %588 Location 1 +OpDecorate %590 BuiltIn Position +OpDecorate %592 Location 0 +OpDecorate %593 Location 1 +OpDecorate %615 BuiltIn FragCoord +OpDecorate %617 Location 0 +OpDecorate %619 Location 1 +OpDecorate %621 Location 0 %2 = OpTypeVoid %4 = OpTypeFloat 32 %5 = OpTypeVector %4 3 @@ -634,47 +634,47 @@ OpDecorate %614 Location 0 %415 = OpTypePointer StorageBuffer %8 %436 = OpTypePointer Input %8 %435 = OpVariable %436 Input -%439 = OpTypePointer Output %8 +%439 = OpTypePointer Output %21 %438 = OpVariable %439 Output -%441 = OpTypePointer Output %7 -%440 = OpVariable %441 Output -%443 = OpTypePointer Output %6 -%442 = OpVariable %443 Output -%445 = OpTypePointer Uniform %20 -%447 = OpConstant %4 -1.0 -%448 = OpConstantComposite %6 %447 %447 -%473 = OpConstant %4 4294967000.0 -%485 = OpVariable %436 Input -%488 = OpTypePointer Input %7 -%487 = OpVariable %488 Input -%491 = OpTypePointer Input %6 -%490 = OpVariable %491 Input -%493 = OpVariable %439 Output -%494 = OpVariable %439 Output -%497 = OpConstant %4 6.0 -%582 = OpTypePointer Input %5 -%581 = OpVariable %582 Input -%584 = OpVariable %582 Input -%586 = OpVariable %441 Output -%588 = OpTypePointer Output %5 -%587 = OpVariable %588 Output -%589 = OpVariable %588 Output -%591 = OpTypePointer Uniform %24 -%594 = OpTypePointer Uniform %23 -%608 = OpVariable %488 Input -%610 = OpVariable %582 Input -%612 = OpVariable %582 Input -%614 = OpVariable %441 Output -%617 = OpTypePointer Uniform %25 -%623 = OpConstantComposite %6 %56 %81 -%624 = OpConstantComposite %5 %286 %286 %286 -%625 = OpConstant %4 0.7 -%626 = OpConstantComposite %5 %78 %286 %625 -%627 = OpConstant %4 0.2 -%628 = OpConstantComposite %5 %627 %627 %627 -%630 = OpConstantNull %5 -%646 = OpTypePointer Uniform %5 -%655 = OpTypePointer Uniform %7 +%440 = OpVariable %439 Output +%441 = OpVariable %439 Output +%443 = OpTypePointer Uniform %20 +%445 = OpConstant %4 -1.0 +%446 = OpConstantComposite %6 %445 %445 +%471 = OpConstant %4 4294967000.0 +%486 = OpVariable %436 Input +%489 = OpTypePointer Input %7 +%488 = OpVariable %489 Input +%492 = OpTypePointer Input %6 +%491 = OpVariable %492 Input +%495 = OpTypePointer Output %22 +%494 = OpVariable %495 Output +%496 = OpVariable %495 Output +%499 = OpConstant %4 6.0 +%586 = OpTypePointer Input %5 +%585 = OpVariable %586 Input +%588 = OpVariable %586 Input +%591 = OpTypePointer Output %26 +%590 = OpVariable %591 Output +%592 = OpVariable %591 Output +%593 = OpVariable %591 Output +%595 = OpTypePointer Uniform %24 +%598 = OpTypePointer Uniform %23 +%615 = OpVariable %489 Input +%617 = OpVariable %586 Input +%619 = OpVariable %586 Input +%622 = OpTypePointer Output %7 +%621 = OpVariable %622 Output +%625 = OpTypePointer Uniform %25 +%631 = OpConstantComposite %6 %56 %81 +%632 = OpConstantComposite %5 %286 %286 %286 +%633 = OpConstant %4 0.7 +%634 = OpConstantComposite %5 %78 %286 %633 +%635 = OpConstant %4 0.2 +%636 = OpConstantComposite %5 %635 %635 %635 +%638 = OpConstantNull %5 +%654 = OpTypePointer Uniform %5 +%663 = OpTypePointer Uniform %7 %53 = OpFunction %5 None %54 %52 = OpFunctionParameter %5 %51 = OpLabel @@ -1186,339 +1186,347 @@ OpFunctionEnd %433 = OpUMod %8 %428 %432 OpReturnValue %433 OpFunctionEnd -%444 = OpFunction %2 None %368 +%442 = OpFunction %2 None %368 %434 = OpLabel %437 = OpLoad %8 %435 -%446 = OpAccessChain %445 %36 %135 -OpBranch %449 -%449 = OpLabel +%444 = OpAccessChain %443 %36 %135 +OpBranch %447 +%447 = OpLabel OpLine %3 161 19 -%450 = OpIAdd %8 %437 %372 +%448 = OpIAdd %8 %437 %372 OpLine %3 161 18 -%451 = OpFunctionCall %8 %313 %450 %373 +%449 = OpFunctionCall %8 %313 %448 %373 OpLine %3 161 13 -%452 = OpFunctionCall %8 %427 %451 %372 -%453 = OpConvertUToF %4 %452 +%450 = OpFunctionCall %8 %427 %449 %372 +%451 = OpConvertUToF %4 %450 OpLine %3 162 19 -%454 = OpIAdd %8 %437 %126 +%452 = OpIAdd %8 %437 %126 OpLine %3 162 18 -%455 = OpFunctionCall %8 %313 %454 %373 +%453 = OpFunctionCall %8 %313 %452 %373 OpLine %3 162 13 -%456 = OpFunctionCall %8 %427 %455 %372 -%457 = OpConvertUToF %4 %456 +%454 = OpFunctionCall %8 %427 %453 %372 +%455 = OpConvertUToF %4 %454 OpLine %3 163 14 -%458 = OpCompositeConstruct %6 %453 %457 +%456 = OpCompositeConstruct %6 %451 %455 OpLine %3 165 30 -%459 = OpVectorTimesScalar %6 %458 %81 +%457 = OpVectorTimesScalar %6 %456 %81 OpLine %3 165 30 -%460 = OpFAdd %6 %448 %459 +%458 = OpFAdd %6 %446 %457 OpLine %3 165 20 -%461 = OpCompositeConstruct %7 %460 %74 %56 +%459 = OpCompositeConstruct %7 %458 %74 %56 OpLine %3 168 21 -%462 = OpCompositeExtract %4 %458 0 +%460 = OpCompositeExtract %4 %456 0 OpLine %3 168 21 -%463 = OpAccessChain %393 %446 %373 -%464 = OpLoad %8 %463 -%465 = OpConvertUToF %4 %464 -%466 = OpFMul %4 %462 %465 -%467 = OpCompositeExtract %4 %458 1 +%461 = OpAccessChain %393 %444 %373 +%462 = OpLoad %8 %461 +%463 = OpConvertUToF %4 %462 +%464 = OpFMul %4 %460 %463 +%465 = OpCompositeExtract %4 %456 1 OpLine %3 168 17 -%468 = OpAccessChain %393 %446 %373 -%469 = OpLoad %8 %468 -%470 = OpConvertUToF %4 %469 -%471 = OpFMul %4 %467 %470 -%472 = OpFAdd %4 %466 %471 -%474 = OpExtInst %4 %1 FClamp %472 %74 %473 -%475 = OpConvertFToU %8 %474 +%466 = OpAccessChain %393 %444 %373 +%467 = OpLoad %8 %466 +%468 = OpConvertUToF %4 %467 +%469 = OpFMul %4 %465 %468 +%470 = OpFAdd %4 %464 %469 +%472 = OpExtInst %4 %1 FClamp %470 %74 %471 +%473 = OpConvertFToU %8 %472 OpLine %3 168 17 -%476 = OpAccessChain %393 %446 %374 -%477 = OpLoad %8 %476 -%478 = OpIAdd %8 %475 %477 +%474 = OpAccessChain %393 %444 %374 +%475 = OpLoad %8 %474 +%476 = OpIAdd %8 %473 %475 OpLine %3 170 12 -%479 = OpCompositeConstruct %21 %478 %461 %458 -%480 = OpCompositeExtract %8 %479 0 -OpStore %438 %480 -%481 = OpCompositeExtract %7 %479 1 -OpStore %440 %481 -%482 = OpCompositeExtract %6 %479 2 -OpStore %442 %482 +%477 = OpCompositeConstruct %21 %476 %459 %456 +%478 = OpCompositeExtract %8 %477 0 +OpStore %438 %478 +%479 = OpCompositeExtract %7 %477 1 +OpStore %440 %479 +%480 = OpCompositeExtract %6 %477 2 +OpStore %441 %480 +%481 = OpCompositeExtract %8 %477 0 +%482 = OpCompositeExtract %7 %477 1 +%483 = OpCompositeExtract %6 %477 2 OpReturn OpFunctionEnd -%495 = OpFunction %2 None %368 -%483 = OpLabel -%498 = OpVariable %125 Function %74 -%499 = OpVariable %217 Function %135 -%486 = OpLoad %8 %485 -%489 = OpLoad %7 %487 -%492 = OpLoad %6 %490 -%484 = OpCompositeConstruct %21 %486 %489 %492 -%496 = OpAccessChain %445 %36 %135 -OpBranch %500 -%500 = OpLabel +%497 = OpFunction %2 None %368 +%484 = OpLabel +%500 = OpVariable %125 Function %74 +%501 = OpVariable %217 Function %135 +%487 = OpLoad %8 %486 +%490 = OpLoad %7 %488 +%493 = OpLoad %6 %491 +%485 = OpCompositeConstruct %21 %487 %490 %493 +%498 = OpAccessChain %443 %36 %135 +OpBranch %502 +%502 = OpLabel OpLine %3 181 17 -%501 = OpCompositeExtract %6 %484 2 -%502 = OpCompositeExtract %4 %501 0 +%503 = OpCompositeExtract %6 %485 2 +%504 = OpCompositeExtract %4 %503 0 OpLine %3 181 17 -%503 = OpAccessChain %393 %496 %373 -%504 = OpLoad %8 %503 -%505 = OpConvertUToF %4 %504 -%506 = OpFMul %4 %502 %505 -%507 = OpCompositeExtract %6 %484 2 -%508 = OpCompositeExtract %4 %507 1 +%505 = OpAccessChain %393 %498 %373 +%506 = OpLoad %8 %505 +%507 = OpConvertUToF %4 %506 +%508 = OpFMul %4 %504 %507 +%509 = OpCompositeExtract %6 %485 2 +%510 = OpCompositeExtract %4 %509 1 OpLine %3 181 70 -%509 = OpAccessChain %393 %496 %373 -%510 = OpLoad %8 %509 -OpLine %3 181 13 -%511 = OpAccessChain %393 %496 %373 +%511 = OpAccessChain %393 %498 %373 %512 = OpLoad %8 %511 -%513 = OpIMul %8 %510 %512 -%514 = OpConvertUToF %4 %513 -%515 = OpFMul %4 %508 %514 -%516 = OpFAdd %4 %506 %515 -%517 = OpExtInst %4 %1 FClamp %516 %74 %473 -%518 = OpConvertFToU %8 %517 OpLine %3 181 13 -%519 = OpAccessChain %393 %496 %374 -%520 = OpLoad %8 %519 -%521 = OpIAdd %8 %518 %520 +%513 = OpAccessChain %393 %498 %373 +%514 = OpLoad %8 %513 +%515 = OpIMul %8 %512 %514 +%516 = OpConvertUToF %4 %515 +%517 = OpFMul %4 %510 %516 +%518 = OpFAdd %4 %508 %517 +%519 = OpExtInst %4 %1 FClamp %518 %74 %471 +%520 = OpConvertFToU %8 %519 +OpLine %3 181 13 +%521 = OpAccessChain %393 %498 %374 +%522 = OpLoad %8 %521 +%523 = OpIAdd %8 %520 %522 OpLine %3 182 32 -%522 = OpConvertUToF %4 %521 +%524 = OpConvertUToF %4 %523 OpLine %3 182 22 -%523 = OpFDiv %4 %522 %497 -%524 = OpExtInst %4 %1 Floor %523 -%525 = OpExtInst %4 %1 FClamp %524 %74 %473 -%526 = OpConvertFToU %8 %525 +%525 = OpFDiv %4 %524 %499 +%526 = OpExtInst %4 %1 Floor %525 +%527 = OpExtInst %4 %1 FClamp %526 %74 %471 +%528 = OpConvertFToU %8 %527 OpLine %3 183 22 -%527 = OpFunctionCall %8 %427 %521 %371 +%529 = OpFunctionCall %8 %427 %523 %371 OpLine %3 185 36 -%528 = OpAccessChain %377 %496 %135 -%529 = OpLoad %10 %528 +%530 = OpAccessChain %377 %498 %135 +%531 = OpLoad %10 %530 OpLine %3 185 57 -%530 = OpAccessChain %380 %496 %126 -%531 = OpLoad %11 %530 +%532 = OpAccessChain %380 %498 %126 +%533 = OpLoad %11 %532 OpLine %3 185 13 -%532 = OpFunctionCall %6 %325 %526 %529 %531 +%534 = OpFunctionCall %6 %325 %528 %531 %533 OpLine %3 186 31 -%533 = OpAccessChain %386 %496 %372 -%534 = OpLoad %6 %533 +%535 = OpAccessChain %386 %498 %372 +%536 = OpLoad %6 %535 OpLine %3 186 13 -%535 = OpFunctionCall %14 %284 %532 %534 +%537 = OpFunctionCall %14 %284 %534 %536 OpLine %3 190 5 -OpSelectionMerge %536 None -OpSwitch %527 %543 0 %537 1 %538 2 %539 3 %540 4 %541 5 %542 -%537 = OpLabel +OpSelectionMerge %538 None +OpSwitch %529 %545 0 %539 1 %540 2 %541 3 %542 4 %543 5 %544 +%539 = OpLabel OpLine %3 191 37 -%544 = OpCompositeExtract %5 %535 0 -%545 = OpCompositeExtract %4 %544 0 +%546 = OpCompositeExtract %5 %537 0 +%547 = OpCompositeExtract %4 %546 0 OpLine %3 191 20 -OpStore %498 %545 -OpBranch %536 -%538 = OpLabel +OpStore %500 %547 +OpBranch %538 +%540 = OpLabel OpLine %3 192 37 -%546 = OpCompositeExtract %5 %535 0 -%547 = OpCompositeExtract %4 %546 1 +%548 = OpCompositeExtract %5 %537 0 +%549 = OpCompositeExtract %4 %548 1 OpLine %3 192 20 -OpStore %498 %547 -OpBranch %536 -%539 = OpLabel +OpStore %500 %549 +OpBranch %538 +%541 = OpLabel OpLine %3 193 37 -%548 = OpCompositeExtract %5 %535 0 -%549 = OpCompositeExtract %4 %548 2 +%550 = OpCompositeExtract %5 %537 0 +%551 = OpCompositeExtract %4 %550 2 OpLine %3 193 20 -OpStore %498 %549 -OpBranch %536 -%540 = OpLabel +OpStore %500 %551 +OpBranch %538 +%542 = OpLabel OpLine %3 194 37 -%550 = OpCompositeExtract %5 %535 1 -%551 = OpCompositeExtract %4 %550 0 +%552 = OpCompositeExtract %5 %537 1 +%553 = OpCompositeExtract %4 %552 0 OpLine %3 194 20 -OpStore %498 %551 -OpBranch %536 -%541 = OpLabel +OpStore %500 %553 +OpBranch %538 +%543 = OpLabel OpLine %3 195 37 -%552 = OpCompositeExtract %5 %535 1 -%553 = OpCompositeExtract %4 %552 1 +%554 = OpCompositeExtract %5 %537 1 +%555 = OpCompositeExtract %4 %554 1 OpLine %3 195 20 -OpStore %498 %553 -OpBranch %536 -%542 = OpLabel +OpStore %500 %555 +OpBranch %538 +%544 = OpLabel OpLine %3 196 37 -%554 = OpCompositeExtract %5 %535 1 -%555 = OpCompositeExtract %4 %554 2 +%556 = OpCompositeExtract %5 %537 1 +%557 = OpCompositeExtract %4 %556 2 OpLine %3 196 20 -OpStore %498 %555 -OpBranch %536 -%543 = OpLabel -OpBranch %536 -%536 = OpLabel +OpStore %500 %557 +OpBranch %538 +%545 = OpLabel +OpBranch %538 +%538 = OpLabel OpLine %3 200 15 -%556 = OpAccessChain %393 %496 %135 %135 -%557 = OpLoad %8 %556 -%558 = OpFunctionCall %8 %313 %526 %557 -%559 = OpIAdd %8 %526 %558 +%558 = OpAccessChain %393 %498 %135 %135 +%559 = OpLoad %8 %558 +%560 = OpFunctionCall %8 %313 %528 %559 +%561 = OpIAdd %8 %528 %560 OpLine %3 201 15 -%560 = OpIAdd %8 %559 %126 +%562 = OpIAdd %8 %561 %126 OpLine %3 202 15 -%561 = OpAccessChain %393 %496 %135 %135 -%562 = OpLoad %8 %561 -%563 = OpIAdd %8 %559 %562 +%563 = OpAccessChain %393 %498 %135 %135 +%564 = OpLoad %8 %563 +%565 = OpIAdd %8 %561 %564 OpLine %3 202 15 -%564 = OpIAdd %8 %563 %126 +%566 = OpIAdd %8 %565 %126 OpLine %3 203 15 -%565 = OpIAdd %8 %564 %126 +%567 = OpIAdd %8 %566 %126 OpLine %3 206 5 -OpSelectionMerge %566 None -OpSwitch %527 %571 0 %567 3 %567 2 %568 4 %568 1 %569 5 %570 -%567 = OpLabel +OpSelectionMerge %568 None +OpSwitch %529 %573 0 %569 3 %569 2 %570 4 %570 1 %571 5 %572 +%569 = OpLabel OpLine %3 207 24 -OpStore %499 %559 -OpBranch %566 -%568 = OpLabel +OpStore %501 %561 +OpBranch %568 +%570 = OpLabel OpLine %3 208 24 -OpStore %499 %565 -OpBranch %566 -%569 = OpLabel +OpStore %501 %567 +OpBranch %568 +%571 = OpLabel OpLine %3 209 20 -OpStore %499 %564 -OpBranch %566 -%570 = OpLabel +OpStore %501 %566 +OpBranch %568 +%572 = OpLabel OpLine %3 210 20 -OpStore %499 %560 -OpBranch %566 -%571 = OpLabel -OpBranch %566 -%566 = OpLabel +OpStore %501 %562 +OpBranch %568 +%573 = OpLabel +OpBranch %568 +%568 = OpLabel OpLine %3 213 13 -%572 = OpCompositeExtract %8 %484 0 +%574 = OpCompositeExtract %8 %485 0 OpLine %3 213 5 -OpStore %499 %572 +OpStore %501 %574 OpLine %3 222 27 -%573 = OpLoad %4 %498 -%574 = OpBitcast %8 %573 +%575 = OpLoad %4 %500 +%576 = OpBitcast %8 %575 OpLine %3 223 12 -%575 = OpLoad %8 %499 -%576 = OpCompositeConstruct %22 %574 %575 -%577 = OpCompositeExtract %8 %576 0 -OpStore %493 %577 -%578 = OpCompositeExtract %8 %576 1 -OpStore %494 %578 +%577 = OpLoad %8 %501 +%578 = OpCompositeConstruct %22 %576 %577 +%579 = OpCompositeExtract %8 %578 0 +OpStore %494 %579 +%580 = OpCompositeExtract %8 %578 1 +OpStore %496 %580 +%581 = OpCompositeExtract %8 %578 0 +%582 = OpCompositeExtract %8 %578 1 OpReturn OpFunctionEnd -%590 = OpFunction %2 None %368 -%579 = OpLabel -%583 = OpLoad %5 %581 -%585 = OpLoad %5 %584 -%580 = OpCompositeConstruct %14 %583 %585 -%592 = OpAccessChain %591 %39 %135 -OpBranch %593 -%593 = OpLabel +%594 = OpFunction %2 None %368 +%583 = OpLabel +%587 = OpLoad %5 %585 +%589 = OpLoad %5 %588 +%584 = OpCompositeConstruct %14 %587 %589 +%596 = OpAccessChain %595 %39 %135 +OpBranch %597 +%597 = OpLabel OpLine %3 254 25 -%595 = OpAccessChain %594 %592 %126 -%596 = OpLoad %23 %595 -%597 = OpCompositeExtract %5 %580 0 +%599 = OpAccessChain %598 %596 %126 +%600 = OpLoad %23 %599 +%601 = OpCompositeExtract %5 %584 0 OpLine %3 254 25 -%598 = OpCompositeConstruct %7 %597 %56 -%599 = OpMatrixTimesVector %7 %596 %598 +%602 = OpCompositeConstruct %7 %601 %56 +%603 = OpMatrixTimesVector %7 %600 %602 OpLine %3 255 18 -%600 = OpCompositeExtract %5 %580 1 +%604 = OpCompositeExtract %5 %584 1 OpLine %3 256 12 -%601 = OpCompositeExtract %5 %580 0 -%602 = OpCompositeConstruct %26 %599 %600 %601 -%603 = OpCompositeExtract %7 %602 0 -OpStore %586 %603 -%604 = OpCompositeExtract %5 %602 1 -OpStore %587 %604 -%605 = OpCompositeExtract %5 %602 2 -OpStore %589 %605 +%605 = OpCompositeExtract %5 %584 0 +%606 = OpCompositeConstruct %26 %603 %604 %605 +%607 = OpCompositeExtract %7 %606 0 +OpStore %590 %607 +%608 = OpCompositeExtract %5 %606 1 +OpStore %592 %608 +%609 = OpCompositeExtract %5 %606 2 +OpStore %593 %609 +%610 = OpCompositeExtract %7 %606 0 +%611 = OpCompositeExtract %5 %606 1 +%612 = OpCompositeExtract %5 %606 2 OpReturn OpFunctionEnd -%615 = OpFunction %2 None %368 -%606 = OpLabel -%629 = OpVariable %95 Function %630 -%609 = OpLoad %7 %608 -%611 = OpLoad %5 %610 -%613 = OpLoad %5 %612 -%607 = OpCompositeConstruct %26 %609 %611 %613 -%616 = OpAccessChain %591 %39 %135 -%618 = OpAccessChain %617 %42 %135 -%619 = OpLoad %27 %45 -%620 = OpLoad %28 %47 -%621 = OpLoad %27 %49 -%622 = OpLoad %28 %50 -OpBranch %631 -%631 = OpLabel +%623 = OpFunction %2 None %368 +%613 = OpLabel +%637 = OpVariable %95 Function %638 +%616 = OpLoad %7 %615 +%618 = OpLoad %5 %617 +%620 = OpLoad %5 %619 +%614 = OpCompositeConstruct %26 %616 %618 %620 +%624 = OpAccessChain %595 %39 %135 +%626 = OpAccessChain %625 %42 %135 +%627 = OpLoad %27 %45 +%628 = OpLoad %28 %47 +%629 = OpLoad %27 %49 +%630 = OpLoad %28 %50 +OpBranch %639 +%639 = OpLabel OpLine %3 283 13 OpLine %3 283 13 OpLine %3 283 5 -%632 = OpFunctionCall %5 %342 %623 +%640 = OpFunctionCall %5 %342 %631 OpLine %3 285 28 OpLine %3 285 17 -%633 = OpCompositeExtract %5 %607 2 -%634 = OpExtInst %5 %1 Fract %633 -%635 = OpExtInst %5 %1 SmoothStep %80 %624 %634 +%641 = OpCompositeExtract %5 %614 2 +%642 = OpExtInst %5 %1 Fract %641 +%643 = OpExtInst %5 %1 SmoothStep %80 %632 %642 OpLine %3 285 5 -OpStore %629 %635 +OpStore %637 %643 OpLine %3 286 17 OpLine %3 286 13 -%636 = OpAccessChain %125 %629 %135 -%637 = OpLoad %4 %636 -%638 = OpAccessChain %125 %629 %126 -%639 = OpLoad %4 %638 -%640 = OpFMul %4 %637 %639 -%641 = OpAccessChain %125 %629 %372 -%642 = OpLoad %4 %641 -%643 = OpFMul %4 %640 %642 -%644 = OpCompositeConstruct %5 %643 %643 %643 -%645 = OpExtInst %5 %1 FMix %626 %628 %644 +%644 = OpAccessChain %125 %637 %135 +%645 = OpLoad %4 %644 +%646 = OpAccessChain %125 %637 %126 +%647 = OpLoad %4 %646 +%648 = OpFMul %4 %645 %647 +%649 = OpAccessChain %125 %637 %372 +%650 = OpLoad %4 %649 +%651 = OpFMul %4 %648 %650 +%652 = OpCompositeConstruct %5 %651 %651 %651 +%653 = OpExtInst %5 %1 FMix %634 %636 %652 OpLine %3 286 5 -OpStore %629 %645 +OpStore %637 %653 OpLine %3 289 25 -%647 = OpAccessChain %646 %618 %126 -%648 = OpLoad %5 %647 -%649 = OpVectorTimesScalar %5 %648 %286 +%655 = OpAccessChain %654 %626 %126 +%656 = OpLoad %5 %655 +%657 = OpVectorTimesScalar %5 %656 %286 OpLine %3 291 21 -%650 = OpAccessChain %646 %618 %135 -%651 = OpLoad %5 %650 -%652 = OpCompositeExtract %5 %607 2 -%653 = OpFSub %5 %651 %652 -%654 = OpExtInst %5 %1 Normalize %653 +%658 = OpAccessChain %654 %626 %135 +%659 = OpLoad %5 %658 +%660 = OpCompositeExtract %5 %614 2 +%661 = OpFSub %5 %659 %660 +%662 = OpExtInst %5 %1 Normalize %661 OpLine %3 292 20 -%656 = OpAccessChain %655 %616 %135 -%657 = OpLoad %7 %656 -%658 = OpVectorShuffle %5 %657 %657 0 1 2 -%659 = OpCompositeExtract %5 %607 2 -%660 = OpFSub %5 %658 %659 -%661 = OpExtInst %5 %1 Normalize %660 +%664 = OpAccessChain %663 %624 %135 +%665 = OpLoad %7 %664 +%666 = OpVectorShuffle %5 %665 %665 0 1 2 +%667 = OpCompositeExtract %5 %614 2 +%668 = OpFSub %5 %666 %667 +%669 = OpExtInst %5 %1 Normalize %668 OpLine %3 293 20 -%662 = OpFAdd %5 %661 %654 -%663 = OpExtInst %5 %1 Normalize %662 +%670 = OpFAdd %5 %669 %662 +%671 = OpExtInst %5 %1 Normalize %670 OpLine %3 295 32 -%664 = OpCompositeExtract %5 %607 1 -%665 = OpDot %4 %664 %654 +%672 = OpCompositeExtract %5 %614 1 +%673 = OpDot %4 %672 %662 OpLine %3 295 28 -%666 = OpExtInst %4 %1 FMax %665 %74 +%674 = OpExtInst %4 %1 FMax %673 %74 OpLine %3 296 25 -%667 = OpAccessChain %646 %618 %126 -%668 = OpLoad %5 %667 -%669 = OpVectorTimesScalar %5 %668 %666 +%675 = OpAccessChain %654 %626 %126 +%676 = OpLoad %5 %675 +%677 = OpVectorTimesScalar %5 %676 %674 OpLine %3 298 37 -%670 = OpCompositeExtract %5 %607 1 -%671 = OpDot %4 %670 %663 +%678 = OpCompositeExtract %5 %614 1 +%679 = OpDot %4 %678 %671 OpLine %3 298 33 -%672 = OpExtInst %4 %1 FMax %671 %74 +%680 = OpExtInst %4 %1 FMax %679 %74 OpLine %3 298 29 -%673 = OpExtInst %4 %1 Pow %672 %345 +%681 = OpExtInst %4 %1 Pow %680 %345 OpLine %3 299 26 -%674 = OpAccessChain %646 %618 %126 -%675 = OpLoad %5 %674 -%676 = OpVectorTimesScalar %5 %675 %673 +%682 = OpAccessChain %654 %626 %126 +%683 = OpLoad %5 %682 +%684 = OpVectorTimesScalar %5 %683 %681 OpLine %3 301 18 -%677 = OpFAdd %5 %649 %669 -%678 = OpFAdd %5 %677 %676 -%679 = OpLoad %5 %629 -%680 = OpFMul %5 %678 %679 +%685 = OpFAdd %5 %657 %677 +%686 = OpFAdd %5 %685 %684 +%687 = OpLoad %5 %637 +%688 = OpFMul %5 %686 %687 OpLine %3 303 12 -%681 = OpCompositeConstruct %7 %680 %56 -OpStore %614 %681 +%689 = OpCompositeConstruct %7 %688 %56 +OpStore %621 %689 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-dualsource.spvasm b/naga/tests/out/spv/wgsl-dualsource.spvasm index f6d5a4e34e2..bd9a608c326 100644 --- a/naga/tests/out/spv/wgsl-dualsource.spvasm +++ b/naga/tests/out/spv/wgsl-dualsource.spvasm @@ -1,11 +1,11 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 26 +; Bound: 28 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %10 "main" %7 %9 +OpEntryPoint Fragment %10 "main" %7 %7 %9 %9 OpExecutionMode %10 OriginUpperLeft OpMemberDecorate %5 0 Offset 0 OpMemberDecorate %5 1 Offset 16 @@ -17,7 +17,7 @@ OpDecorate %9 Index 1 %4 = OpTypeFloat 32 %3 = OpTypeVector %4 4 %5 = OpTypeStruct %3 %3 -%8 = OpTypePointer Output %3 +%8 = OpTypePointer Output %5 %7 = OpVariable %8 Output %9 = OpVariable %8 Output %11 = OpTypeFunction %2 @@ -40,5 +40,7 @@ OpBranch %23 OpStore %7 %24 %25 = OpCompositeExtract %3 %22 1 OpStore %9 %25 +%26 = OpCompositeExtract %3 %22 0 +%27 = OpCompositeExtract %3 %22 1 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-interface.fragment.spvasm b/naga/tests/out/spv/wgsl-interface.fragment.spvasm index 891b10d863d..8805b2d1e96 100644 --- a/naga/tests/out/spv/wgsl-interface.fragment.spvasm +++ b/naga/tests/out/spv/wgsl-interface.fragment.spvasm @@ -1,14 +1,14 @@ ; SPIR-V ; Version: 1.0 ; Generator: rspirv -; Bound: 50 +; Bound: 52 OpCapability Shader OpCapability SampleRateShading %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %35 "fragment" %16 %19 %22 %25 %28 %30 %32 %34 -OpExecutionMode %35 OriginUpperLeft -OpExecutionMode %35 DepthReplacing +OpEntryPoint Fragment %34 "fragment" %16 %19 %22 %25 %28 %30 %30 %32 %32 %33 %33 +OpExecutionMode %34 OriginUpperLeft +OpExecutionMode %34 DepthReplacing OpMemberDecorate %5 0 Offset 0 OpMemberDecorate %5 1 Offset 16 OpMemberDecorate %7 0 Offset 0 @@ -28,7 +28,7 @@ OpDecorate %28 BuiltIn SampleMask OpDecorate %28 Flat OpDecorate %30 BuiltIn FragDepth OpDecorate %32 BuiltIn SampleMask -OpDecorate %34 Location 0 +OpDecorate %33 Location 0 %2 = OpTypeVoid %3 = OpTypeFloat 32 %4 = OpTypeVector %3 4 @@ -50,15 +50,14 @@ OpDecorate %34 Location 0 %26 = OpTypePointer Input %6 %25 = OpVariable %26 Input %28 = OpVariable %26 Input -%31 = OpTypePointer Output %3 +%31 = OpTypePointer Output %7 %30 = OpVariable %31 Output -%33 = OpTypePointer Output %6 -%32 = OpVariable %33 Output -%34 = OpVariable %31 Output -%36 = OpTypeFunction %2 -%37 = OpConstant %3 0.0 -%38 = OpConstant %3 1.0 -%35 = OpFunction %2 None %36 +%32 = OpVariable %31 Output +%33 = OpVariable %31 Output +%35 = OpTypeFunction %2 +%36 = OpConstant %3 0.0 +%37 = OpConstant %3 1.0 +%34 = OpFunction %2 None %35 %14 = OpLabel %18 = OpLoad %4 %16 %21 = OpLoad %3 %19 @@ -66,21 +65,24 @@ OpDecorate %34 Location 0 %24 = OpLoad %8 %22 %27 = OpLoad %6 %25 %29 = OpLoad %6 %28 -OpBranch %39 -%39 = OpLabel -%40 = OpShiftLeftLogical %6 %10 %27 -%41 = OpBitwiseAnd %6 %29 %40 -%42 = OpSelect %3 %24 %38 %37 -%43 = OpCompositeExtract %3 %15 1 -%44 = OpCompositeConstruct %7 %43 %41 %42 -%45 = OpCompositeExtract %3 %44 0 -OpStore %30 %45 -%46 = OpLoad %3 %30 -%47 = OpExtInst %3 %1 FClamp %46 %37 %38 -OpStore %30 %47 -%48 = OpCompositeExtract %6 %44 1 -OpStore %32 %48 -%49 = OpCompositeExtract %3 %44 2 -OpStore %34 %49 +OpBranch %38 +%38 = OpLabel +%39 = OpShiftLeftLogical %6 %10 %27 +%40 = OpBitwiseAnd %6 %29 %39 +%41 = OpSelect %3 %24 %37 %36 +%42 = OpCompositeExtract %3 %15 1 +%43 = OpCompositeConstruct %7 %42 %40 %41 +%44 = OpCompositeExtract %3 %43 0 +OpStore %30 %44 +%45 = OpLoad %3 %30 +%46 = OpExtInst %3 %1 FClamp %45 %36 %37 +OpStore %30 %46 +%47 = OpCompositeExtract %6 %43 1 +OpStore %32 %47 +%48 = OpCompositeExtract %3 %43 2 +OpStore %33 %48 +%49 = OpCompositeExtract %3 %43 0 +%50 = OpCompositeExtract %6 %43 1 +%51 = OpCompositeExtract %3 %43 2 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-interface.vertex.spvasm b/naga/tests/out/spv/wgsl-interface.vertex.spvasm index 63ca57fa7d6..20fc20a4cc1 100644 --- a/naga/tests/out/spv/wgsl-interface.vertex.spvasm +++ b/naga/tests/out/spv/wgsl-interface.vertex.spvasm @@ -1,11 +1,11 @@ ; SPIR-V ; Version: 1.0 ; Generator: rspirv -; Bound: 38 +; Bound: 40 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %28 "vertex" %15 %18 %20 %22 %24 %26 +OpEntryPoint Vertex %28 "vertex" %15 %18 %20 %22 %22 %24 %24 %25 OpMemberDecorate %5 0 Offset 0 OpMemberDecorate %5 1 Offset 16 OpMemberDecorate %7 0 Offset 0 @@ -20,7 +20,7 @@ OpDecorate %20 Location 10 OpDecorate %22 Invariant OpDecorate %22 BuiltIn Position OpDecorate %24 Location 1 -OpDecorate %26 BuiltIn PointSize +OpDecorate %25 BuiltIn PointSize %2 = OpTypeVoid %3 = OpTypeFloat 32 %4 = OpTypeVector %3 4 @@ -37,11 +37,11 @@ OpDecorate %26 BuiltIn PointSize %15 = OpVariable %16 Input %18 = OpVariable %16 Input %20 = OpVariable %16 Input -%23 = OpTypePointer Output %4 +%23 = OpTypePointer Output %5 %22 = OpVariable %23 Output -%25 = OpTypePointer Output %3 -%24 = OpVariable %25 Output -%26 = OpVariable %25 Output +%24 = OpVariable %23 Output +%26 = OpTypePointer Output %3 +%25 = OpVariable %26 Output %27 = OpConstant %3 1.0 %29 = OpTypeFunction %2 %30 = OpConstantComposite %4 %27 %27 %27 %27 @@ -50,7 +50,7 @@ OpDecorate %26 BuiltIn PointSize %17 = OpLoad %6 %15 %19 = OpLoad %6 %18 %21 = OpLoad %6 %20 -OpStore %26 %27 +OpStore %25 %27 OpBranch %31 %31 = OpLabel %32 = OpIAdd %6 %17 %19 @@ -61,5 +61,7 @@ OpBranch %31 OpStore %22 %36 %37 = OpCompositeExtract %3 %35 1 OpStore %24 %37 +%38 = OpCompositeExtract %4 %35 0 +%39 = OpCompositeExtract %3 %35 1 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-interpolate_compat.spvasm b/naga/tests/out/spv/wgsl-interpolate_compat.spvasm index f6c72a053ef..47952c88d8e 100644 --- a/naga/tests/out/spv/wgsl-interpolate_compat.spvasm +++ b/naga/tests/out/spv/wgsl-interpolate_compat.spvasm @@ -1,14 +1,14 @@ ; SPIR-V ; Version: 1.0 ; Generator: rspirv -; Bound: 133 +; Bound: 141 OpCapability Shader OpCapability SampleRateShading %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %29 "vert_main" %11 %13 %15 %16 %18 %20 %22 %23 %24 %25 %26 %27 -OpEntryPoint Fragment %131 "frag_main" %104 %107 %110 %112 %115 %118 %121 %123 %125 %127 %129 -OpExecutionMode %131 OriginUpperLeft +OpEntryPoint Vertex %26 "vert_main" %11 %11 %13 %13 %14 %14 %15 %15 %16 %16 %17 %17 %18 %18 %19 %19 %20 %20 %21 %21 %22 %22 %23 +OpEntryPoint Fragment %139 "frag_main" %112 %115 %118 %120 %123 %126 %129 %131 %133 %135 %137 +OpExecutionMode %139 OriginUpperLeft %3 = OpString "interpolate_compat.wgsl" OpSource Unknown 0 %3 "// NOTE: This is basically the same as `interpolate.wgsl`, except for the removal of // `@interpolate(flat, first)`, which is unsupported in GLSL and `compat`. @@ -68,29 +68,29 @@ OpMemberName %9 10 "perspective_center" OpName %9 "FragmentInput" OpName %11 "position" OpName %13 "_flat" -OpName %15 "flat_either" -OpName %16 "_linear" -OpName %18 "linear_centroid" -OpName %20 "linear_sample" -OpName %22 "linear_center" -OpName %23 "perspective" -OpName %24 "perspective_centroid" -OpName %25 "perspective_sample" -OpName %26 "perspective_center" -OpName %29 "vert_main" -OpName %58 "out" -OpName %104 "position" -OpName %107 "_flat" -OpName %110 "flat_either" -OpName %112 "_linear" -OpName %115 "linear_centroid" -OpName %118 "linear_sample" -OpName %121 "linear_center" -OpName %123 "perspective" -OpName %125 "perspective_centroid" -OpName %127 "perspective_sample" -OpName %129 "perspective_center" -OpName %131 "frag_main" +OpName %14 "flat_either" +OpName %15 "_linear" +OpName %16 "linear_centroid" +OpName %17 "linear_sample" +OpName %18 "linear_center" +OpName %19 "perspective" +OpName %20 "perspective_centroid" +OpName %21 "perspective_sample" +OpName %22 "perspective_center" +OpName %26 "vert_main" +OpName %55 "out" +OpName %112 "position" +OpName %115 "_flat" +OpName %118 "flat_either" +OpName %120 "_linear" +OpName %123 "linear_centroid" +OpName %126 "linear_sample" +OpName %129 "linear_center" +OpName %131 "perspective" +OpName %133 "perspective_centroid" +OpName %135 "perspective_sample" +OpName %137 "perspective_center" +OpName %139 "frag_main" OpMemberDecorate %9 0 Offset 0 OpMemberDecorate %9 1 Offset 16 OpMemberDecorate %9 2 Offset 20 @@ -105,46 +105,46 @@ OpMemberDecorate %9 10 Offset 104 OpDecorate %11 BuiltIn Position OpDecorate %13 Location 0 OpDecorate %13 Flat -OpDecorate %15 Location 2 -OpDecorate %15 Flat -OpDecorate %16 Location 3 +OpDecorate %14 Location 2 +OpDecorate %14 Flat +OpDecorate %15 Location 3 +OpDecorate %15 NoPerspective +OpDecorate %16 Location 4 OpDecorate %16 NoPerspective -OpDecorate %18 Location 4 +OpDecorate %16 Centroid +OpDecorate %17 Location 6 +OpDecorate %17 NoPerspective +OpDecorate %17 Sample +OpDecorate %18 Location 7 OpDecorate %18 NoPerspective -OpDecorate %18 Centroid -OpDecorate %20 Location 6 -OpDecorate %20 NoPerspective -OpDecorate %20 Sample -OpDecorate %22 Location 7 -OpDecorate %22 NoPerspective -OpDecorate %23 Location 8 -OpDecorate %24 Location 9 -OpDecorate %24 Centroid -OpDecorate %25 Location 10 -OpDecorate %25 Sample -OpDecorate %26 Location 11 -OpDecorate %27 BuiltIn PointSize -OpDecorate %104 BuiltIn FragCoord -OpDecorate %107 Location 0 -OpDecorate %107 Flat -OpDecorate %110 Location 2 -OpDecorate %110 Flat -OpDecorate %112 Location 3 -OpDecorate %112 NoPerspective -OpDecorate %115 Location 4 -OpDecorate %115 NoPerspective -OpDecorate %115 Centroid -OpDecorate %118 Location 6 -OpDecorate %118 NoPerspective -OpDecorate %118 Sample -OpDecorate %121 Location 7 -OpDecorate %121 NoPerspective -OpDecorate %123 Location 8 -OpDecorate %125 Location 9 -OpDecorate %125 Centroid -OpDecorate %127 Location 10 -OpDecorate %127 Sample -OpDecorate %129 Location 11 +OpDecorate %19 Location 8 +OpDecorate %20 Location 9 +OpDecorate %20 Centroid +OpDecorate %21 Location 10 +OpDecorate %21 Sample +OpDecorate %22 Location 11 +OpDecorate %23 BuiltIn PointSize +OpDecorate %112 BuiltIn FragCoord +OpDecorate %115 Location 0 +OpDecorate %115 Flat +OpDecorate %118 Location 2 +OpDecorate %118 Flat +OpDecorate %120 Location 3 +OpDecorate %120 NoPerspective +OpDecorate %123 Location 4 +OpDecorate %123 NoPerspective +OpDecorate %123 Centroid +OpDecorate %126 Location 6 +OpDecorate %126 NoPerspective +OpDecorate %126 Sample +OpDecorate %129 Location 7 +OpDecorate %129 NoPerspective +OpDecorate %131 Location 8 +OpDecorate %133 Location 9 +OpDecorate %133 Centroid +OpDecorate %135 Location 10 +OpDecorate %135 Sample +OpDecorate %137 Location 11 %2 = OpTypeVoid %4 = OpTypeFloat 32 %5 = OpTypeVector %4 4 @@ -152,184 +152,192 @@ OpDecorate %129 Location 11 %7 = OpTypeVector %4 2 %8 = OpTypeVector %4 3 %9 = OpTypeStruct %5 %6 %6 %4 %7 %8 %8 %5 %4 %4 %4 -%12 = OpTypePointer Output %5 +%12 = OpTypePointer Output %9 %11 = OpVariable %12 Output -%14 = OpTypePointer Output %6 -%13 = OpVariable %14 Output -%15 = OpVariable %14 Output -%17 = OpTypePointer Output %4 -%16 = OpVariable %17 Output -%19 = OpTypePointer Output %7 -%18 = OpVariable %19 Output -%21 = OpTypePointer Output %8 -%20 = OpVariable %21 Output -%22 = OpVariable %21 Output -%23 = OpVariable %12 Output -%24 = OpVariable %17 Output -%25 = OpVariable %17 Output -%26 = OpVariable %17 Output -%27 = OpVariable %17 Output -%28 = OpConstant %4 1.0 -%30 = OpTypeFunction %2 -%31 = OpConstant %4 2.0 -%32 = OpConstant %4 4.0 -%33 = OpConstant %4 5.0 -%34 = OpConstant %4 6.0 -%35 = OpConstantComposite %5 %31 %32 %33 %34 -%36 = OpConstant %6 8 -%37 = OpConstant %6 10 -%38 = OpConstant %4 27.0 -%39 = OpConstant %4 64.0 -%40 = OpConstant %4 125.0 -%41 = OpConstantComposite %7 %39 %40 -%42 = OpConstant %4 216.0 -%43 = OpConstant %4 343.0 -%44 = OpConstant %4 512.0 -%45 = OpConstantComposite %8 %42 %43 %44 -%46 = OpConstant %4 255.0 -%47 = OpConstant %4 511.0 -%48 = OpConstant %4 1024.0 -%49 = OpConstantComposite %8 %46 %47 %48 -%50 = OpConstant %4 729.0 -%51 = OpConstant %4 1000.0 -%52 = OpConstant %4 1331.0 -%53 = OpConstant %4 1728.0 -%54 = OpConstantComposite %5 %50 %51 %52 %53 -%55 = OpConstant %4 2197.0 -%56 = OpConstant %4 2744.0 -%57 = OpConstant %4 2812.0 -%59 = OpTypePointer Function %9 -%60 = OpConstantNull %9 -%62 = OpTypePointer Function %5 -%63 = OpConstant %6 0 -%65 = OpTypePointer Function %6 -%66 = OpConstant %6 1 -%68 = OpConstant %6 2 -%70 = OpTypePointer Function %4 -%71 = OpConstant %6 3 -%73 = OpTypePointer Function %7 -%74 = OpConstant %6 4 -%76 = OpTypePointer Function %8 -%77 = OpConstant %6 5 -%79 = OpConstant %6 6 -%81 = OpConstant %6 7 -%84 = OpConstant %6 9 -%105 = OpTypePointer Input %5 -%104 = OpVariable %105 Input -%108 = OpTypePointer Input %6 -%107 = OpVariable %108 Input -%110 = OpVariable %108 Input -%113 = OpTypePointer Input %4 +%13 = OpVariable %12 Output +%14 = OpVariable %12 Output +%15 = OpVariable %12 Output +%16 = OpVariable %12 Output +%17 = OpVariable %12 Output +%18 = OpVariable %12 Output +%19 = OpVariable %12 Output +%20 = OpVariable %12 Output +%21 = OpVariable %12 Output +%22 = OpVariable %12 Output +%24 = OpTypePointer Output %4 +%23 = OpVariable %24 Output +%25 = OpConstant %4 1.0 +%27 = OpTypeFunction %2 +%28 = OpConstant %4 2.0 +%29 = OpConstant %4 4.0 +%30 = OpConstant %4 5.0 +%31 = OpConstant %4 6.0 +%32 = OpConstantComposite %5 %28 %29 %30 %31 +%33 = OpConstant %6 8 +%34 = OpConstant %6 10 +%35 = OpConstant %4 27.0 +%36 = OpConstant %4 64.0 +%37 = OpConstant %4 125.0 +%38 = OpConstantComposite %7 %36 %37 +%39 = OpConstant %4 216.0 +%40 = OpConstant %4 343.0 +%41 = OpConstant %4 512.0 +%42 = OpConstantComposite %8 %39 %40 %41 +%43 = OpConstant %4 255.0 +%44 = OpConstant %4 511.0 +%45 = OpConstant %4 1024.0 +%46 = OpConstantComposite %8 %43 %44 %45 +%47 = OpConstant %4 729.0 +%48 = OpConstant %4 1000.0 +%49 = OpConstant %4 1331.0 +%50 = OpConstant %4 1728.0 +%51 = OpConstantComposite %5 %47 %48 %49 %50 +%52 = OpConstant %4 2197.0 +%53 = OpConstant %4 2744.0 +%54 = OpConstant %4 2812.0 +%56 = OpTypePointer Function %9 +%57 = OpConstantNull %9 +%59 = OpTypePointer Function %5 +%60 = OpConstant %6 0 +%62 = OpTypePointer Function %6 +%63 = OpConstant %6 1 +%65 = OpConstant %6 2 +%67 = OpTypePointer Function %4 +%68 = OpConstant %6 3 +%70 = OpTypePointer Function %7 +%71 = OpConstant %6 4 +%73 = OpTypePointer Function %8 +%74 = OpConstant %6 5 +%76 = OpConstant %6 6 +%78 = OpConstant %6 7 +%81 = OpConstant %6 9 +%113 = OpTypePointer Input %5 %112 = OpVariable %113 Input -%116 = OpTypePointer Input %7 +%116 = OpTypePointer Input %6 %115 = OpVariable %116 Input -%119 = OpTypePointer Input %8 -%118 = OpVariable %119 Input -%121 = OpVariable %119 Input -%123 = OpVariable %105 Input -%125 = OpVariable %113 Input -%127 = OpVariable %113 Input -%129 = OpVariable %113 Input -%29 = OpFunction %2 None %30 +%118 = OpVariable %116 Input +%121 = OpTypePointer Input %4 +%120 = OpVariable %121 Input +%124 = OpTypePointer Input %7 +%123 = OpVariable %124 Input +%127 = OpTypePointer Input %8 +%126 = OpVariable %127 Input +%129 = OpVariable %127 Input +%131 = OpVariable %113 Input +%133 = OpVariable %121 Input +%135 = OpVariable %121 Input +%137 = OpVariable %121 Input +%26 = OpFunction %2 None %27 %10 = OpLabel -%58 = OpVariable %59 Function %60 -OpStore %27 %28 -OpBranch %61 -%61 = OpLabel +%55 = OpVariable %56 Function %57 +OpStore %23 %25 +OpBranch %58 +%58 = OpLabel OpLine %3 26 4 OpLine %3 26 19 OpLine %3 26 4 -%64 = OpAccessChain %62 %58 %63 -OpStore %64 %35 +%61 = OpAccessChain %59 %55 %60 +OpStore %61 %32 OpLine %3 27 4 OpLine %3 27 4 -%67 = OpAccessChain %65 %58 %66 -OpStore %67 %36 +%64 = OpAccessChain %62 %55 %63 +OpStore %64 %33 OpLine %3 29 4 OpLine %3 29 4 -%69 = OpAccessChain %65 %58 %68 -OpStore %69 %37 +%66 = OpAccessChain %62 %55 %65 +OpStore %66 %34 OpLine %3 30 4 OpLine %3 30 4 -%72 = OpAccessChain %70 %58 %71 -OpStore %72 %38 +%69 = OpAccessChain %67 %55 %68 +OpStore %69 %35 OpLine %3 31 4 OpLine %3 31 26 OpLine %3 31 4 -%75 = OpAccessChain %73 %58 %74 -OpStore %75 %41 +%72 = OpAccessChain %70 %55 %71 +OpStore %72 %38 OpLine %3 32 4 OpLine %3 32 24 OpLine %3 32 4 -%78 = OpAccessChain %76 %58 %77 -OpStore %78 %45 +%75 = OpAccessChain %73 %55 %74 +OpStore %75 %42 OpLine %3 33 4 OpLine %3 33 24 OpLine %3 33 4 -%80 = OpAccessChain %76 %58 %79 -OpStore %80 %49 +%77 = OpAccessChain %73 %55 %76 +OpStore %77 %46 OpLine %3 34 4 OpLine %3 34 22 OpLine %3 34 4 -%82 = OpAccessChain %62 %58 %81 -OpStore %82 %54 +%79 = OpAccessChain %59 %55 %78 +OpStore %79 %51 OpLine %3 35 4 OpLine %3 35 4 -%83 = OpAccessChain %70 %58 %36 -OpStore %83 %55 +%80 = OpAccessChain %67 %55 %33 +OpStore %80 %52 OpLine %3 36 4 OpLine %3 36 4 -%85 = OpAccessChain %70 %58 %84 -OpStore %85 %56 +%82 = OpAccessChain %67 %55 %81 +OpStore %82 %53 OpLine %3 37 4 OpLine %3 37 4 -%86 = OpAccessChain %70 %58 %37 -OpStore %86 %57 +%83 = OpAccessChain %67 %55 %34 +OpStore %83 %54 OpLine %3 1 1 -%87 = OpLoad %9 %58 -%88 = OpCompositeExtract %5 %87 0 -OpStore %11 %88 -%89 = OpAccessChain %17 %11 %66 -%90 = OpLoad %4 %89 -%91 = OpFNegate %4 %90 -OpStore %89 %91 -%92 = OpCompositeExtract %6 %87 1 -OpStore %13 %92 -%93 = OpCompositeExtract %6 %87 2 -OpStore %15 %93 -%94 = OpCompositeExtract %4 %87 3 -OpStore %16 %94 -%95 = OpCompositeExtract %7 %87 4 -OpStore %18 %95 -%96 = OpCompositeExtract %8 %87 5 +%84 = OpLoad %9 %55 +%85 = OpCompositeExtract %5 %84 0 +OpStore %11 %85 +%86 = OpAccessChain %24 %11 %63 +%87 = OpLoad %4 %86 +%88 = OpFNegate %4 %87 +OpStore %86 %88 +%89 = OpCompositeExtract %6 %84 1 +OpStore %13 %89 +%90 = OpCompositeExtract %6 %84 2 +OpStore %14 %90 +%91 = OpCompositeExtract %4 %84 3 +OpStore %15 %91 +%92 = OpCompositeExtract %7 %84 4 +OpStore %16 %92 +%93 = OpCompositeExtract %8 %84 5 +OpStore %17 %93 +%94 = OpCompositeExtract %8 %84 6 +OpStore %18 %94 +%95 = OpCompositeExtract %5 %84 7 +OpStore %19 %95 +%96 = OpCompositeExtract %4 %84 8 OpStore %20 %96 -%97 = OpCompositeExtract %8 %87 6 -OpStore %22 %97 -%98 = OpCompositeExtract %5 %87 7 -OpStore %23 %98 -%99 = OpCompositeExtract %4 %87 8 -OpStore %24 %99 -%100 = OpCompositeExtract %4 %87 9 -OpStore %25 %100 -%101 = OpCompositeExtract %4 %87 10 -OpStore %26 %101 +%97 = OpCompositeExtract %4 %84 9 +OpStore %21 %97 +%98 = OpCompositeExtract %4 %84 10 +OpStore %22 %98 +%99 = OpCompositeExtract %5 %84 0 +%100 = OpCompositeExtract %6 %84 1 +%101 = OpCompositeExtract %6 %84 2 +%102 = OpCompositeExtract %4 %84 3 +%103 = OpCompositeExtract %7 %84 4 +%104 = OpCompositeExtract %8 %84 5 +%105 = OpCompositeExtract %8 %84 6 +%106 = OpCompositeExtract %5 %84 7 +%107 = OpCompositeExtract %4 %84 8 +%108 = OpCompositeExtract %4 %84 9 +%109 = OpCompositeExtract %4 %84 10 OpReturn OpFunctionEnd -%131 = OpFunction %2 None %30 -%102 = OpLabel -%106 = OpLoad %5 %104 -%109 = OpLoad %6 %107 -%111 = OpLoad %6 %110 -%114 = OpLoad %4 %112 -%117 = OpLoad %7 %115 -%120 = OpLoad %8 %118 -%122 = OpLoad %8 %121 -%124 = OpLoad %5 %123 -%126 = OpLoad %4 %125 -%128 = OpLoad %4 %127 -%130 = OpLoad %4 %129 -%103 = OpCompositeConstruct %9 %106 %109 %111 %114 %117 %120 %122 %124 %126 %128 %130 -OpBranch %132 -%132 = OpLabel +%139 = OpFunction %2 None %27 +%110 = OpLabel +%114 = OpLoad %5 %112 +%117 = OpLoad %6 %115 +%119 = OpLoad %6 %118 +%122 = OpLoad %4 %120 +%125 = OpLoad %7 %123 +%128 = OpLoad %8 %126 +%130 = OpLoad %8 %129 +%132 = OpLoad %5 %131 +%134 = OpLoad %4 %133 +%136 = OpLoad %4 %135 +%138 = OpLoad %4 %137 +%111 = OpCompositeConstruct %9 %114 %117 %119 %122 %125 %128 %130 %132 %134 %136 %138 +OpBranch %140 +%140 = OpLabel OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-quad.spvasm b/naga/tests/out/spv/wgsl-quad.spvasm index a3532fb16e0..a59ef6ec14a 100644 --- a/naga/tests/out/spv/wgsl-quad.spvasm +++ b/naga/tests/out/spv/wgsl-quad.spvasm @@ -1,15 +1,15 @@ ; SPIR-V ; Version: 1.0 ; Generator: rspirv -; Bound: 65 +; Bound: 67 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %25 "vert_main" %16 %19 %21 %23 -OpEntryPoint Fragment %45 "frag_main" %42 %44 -OpEntryPoint Fragment %61 "fs_extra" %60 -OpExecutionMode %45 OriginUpperLeft -OpExecutionMode %61 OriginUpperLeft +OpEntryPoint Vertex %24 "vert_main" %16 %19 %21 %21 %23 %23 +OpEntryPoint Fragment %47 "frag_main" %43 %45 +OpEntryPoint Fragment %63 "fs_extra" %62 +OpExecutionMode %47 OriginUpperLeft +OpExecutionMode %63 OriginUpperLeft %3 = OpString "quad.wgsl" OpSource Unknown 0 %3 "// vertex const c_scale: f32 = 1.2; @@ -60,10 +60,10 @@ OpName %16 "pos" OpName %19 "uv" OpName %21 "uv" OpName %23 "position" -OpName %25 "vert_main" -OpName %42 "uv" -OpName %45 "frag_main" -OpName %61 "fs_extra" +OpName %24 "vert_main" +OpName %43 "uv" +OpName %47 "frag_main" +OpName %63 "fs_extra" OpMemberDecorate %7 0 Offset 0 OpMemberDecorate %7 1 Offset 16 OpDecorate %11 DescriptorSet 0 @@ -74,9 +74,9 @@ OpDecorate %16 Location 0 OpDecorate %19 Location 1 OpDecorate %21 Location 0 OpDecorate %23 BuiltIn Position -OpDecorate %42 Location 0 -OpDecorate %44 Location 0 -OpDecorate %60 Location 0 +OpDecorate %43 Location 0 +OpDecorate %45 Location 0 +OpDecorate %62 Location 0 %2 = OpTypeVoid %4 = OpTypeFloat 32 %5 = OpTypeVector %4 2 @@ -92,75 +92,77 @@ OpDecorate %60 Location 0 %17 = OpTypePointer Input %5 %16 = OpVariable %17 Input %19 = OpVariable %17 Input -%22 = OpTypePointer Output %5 +%22 = OpTypePointer Output %7 %21 = OpVariable %22 Output -%24 = OpTypePointer Output %6 -%23 = OpVariable %24 Output -%26 = OpTypeFunction %2 -%27 = OpConstant %4 0.0 -%28 = OpConstant %4 1.0 -%35 = OpTypePointer Output %4 -%37 = OpTypeInt 32 0 -%36 = OpConstant %37 1 -%42 = OpVariable %17 Input -%44 = OpVariable %24 Output -%49 = OpTypeSampledImage %8 -%53 = OpTypeBool -%60 = OpVariable %24 Output -%62 = OpConstant %4 0.5 -%63 = OpConstantComposite %6 %27 %62 %27 %62 -%25 = OpFunction %2 None %26 +%23 = OpVariable %22 Output +%25 = OpTypeFunction %2 +%26 = OpConstant %4 0.0 +%27 = OpConstant %4 1.0 +%34 = OpTypePointer Output %4 +%36 = OpTypeInt 32 0 +%35 = OpConstant %36 1 +%43 = OpVariable %17 Input +%46 = OpTypePointer Output %6 +%45 = OpVariable %46 Output +%51 = OpTypeSampledImage %8 +%55 = OpTypeBool +%62 = OpVariable %46 Output +%64 = OpConstant %4 0.5 +%65 = OpConstantComposite %6 %26 %64 %26 %64 +%24 = OpFunction %2 None %25 %15 = OpLabel %18 = OpLoad %5 %16 %20 = OpLoad %5 %19 -OpBranch %29 -%29 = OpLabel +OpBranch %28 +%28 = OpLabel OpLine %3 14 37 -%30 = OpVectorTimesScalar %5 %18 %10 +%29 = OpVectorTimesScalar %5 %18 %10 OpLine %3 14 10 -%31 = OpCompositeConstruct %6 %30 %27 %28 -%32 = OpCompositeConstruct %7 %20 %31 -%33 = OpCompositeExtract %5 %32 0 -OpStore %21 %33 -%34 = OpCompositeExtract %6 %32 1 -OpStore %23 %34 -%38 = OpAccessChain %35 %23 %36 -%39 = OpLoad %4 %38 -%40 = OpFNegate %4 %39 -OpStore %38 %40 +%30 = OpCompositeConstruct %6 %29 %26 %27 +%31 = OpCompositeConstruct %7 %20 %30 +%32 = OpCompositeExtract %5 %31 0 +OpStore %21 %32 +%33 = OpCompositeExtract %6 %31 1 +OpStore %23 %33 +%37 = OpAccessChain %34 %23 %35 +%38 = OpLoad %4 %37 +%39 = OpFNegate %4 %38 +OpStore %37 %39 +%40 = OpCompositeExtract %5 %31 0 +%41 = OpCompositeExtract %6 %31 1 OpReturn OpFunctionEnd -%45 = OpFunction %2 None %26 -%41 = OpLabel -%43 = OpLoad %5 %42 -%46 = OpLoad %8 %11 -%47 = OpLoad %9 %13 -OpBranch %48 -%48 = OpLabel +%47 = OpFunction %2 None %25 +%42 = OpLabel +%44 = OpLoad %5 %43 +%48 = OpLoad %8 %11 +%49 = OpLoad %9 %13 +OpBranch %50 +%50 = OpLabel OpLine %3 23 15 -%50 = OpSampledImage %49 %46 %47 -%51 = OpImageSampleImplicitLod %6 %50 %43 +%52 = OpSampledImage %51 %48 %49 +%53 = OpImageSampleImplicitLod %6 %52 %44 OpLine %3 24 6 -%52 = OpCompositeExtract %4 %51 3 +%54 = OpCompositeExtract %4 %53 3 OpLine %3 24 6 -%54 = OpFOrdEqual %53 %52 %27 +%56 = OpFOrdEqual %55 %54 %26 OpLine %3 24 3 -OpSelectionMerge %55 None -OpBranchConditional %54 %56 %55 -%56 = OpLabel +OpSelectionMerge %57 None +OpBranchConditional %56 %58 %57 +%58 = OpLabel OpKill -%55 = OpLabel +%57 = OpLabel OpLine %3 29 23 -%57 = OpCompositeExtract %4 %51 3 -%58 = OpVectorTimesScalar %6 %51 %57 -OpStore %44 %58 +%59 = OpCompositeExtract %4 %53 3 +%60 = OpVectorTimesScalar %6 %53 %59 +OpStore %45 %60 OpReturn OpFunctionEnd -%61 = OpFunction %2 None %26 -%59 = OpLabel -OpBranch %64 -%64 = OpLabel +%63 = OpFunction %2 None %25 +%61 = OpLabel +OpBranch %66 +%66 = OpLabel OpLine %3 37 12 -OpStore %60 %63 +OpStore %62 %65 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-shadow.spvasm b/naga/tests/out/spv/wgsl-shadow.spvasm index ea131ae6d03..88725da133a 100644 --- a/naga/tests/out/spv/wgsl-shadow.spvasm +++ b/naga/tests/out/spv/wgsl-shadow.spvasm @@ -1,16 +1,16 @@ ; SPIR-V ; Version: 1.2 ; Generator: rspirv -; Bound: 294 +; Bound: 297 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %85 "vs_main" %75 %78 %80 %82 %84 -OpEntryPoint Fragment %143 "fs_main" %134 %137 %140 %142 -OpEntryPoint Fragment %228 "fs_main_without_storage" %221 %223 %225 %227 -OpExecutionMode %143 OriginUpperLeft -OpExecutionMode %228 OriginUpperLeft +OpEntryPoint Vertex %84 "vs_main" %75 %78 %80 %80 %82 %82 %83 %83 +OpEntryPoint Fragment %146 "fs_main" %136 %139 %142 %144 +OpEntryPoint Fragment %231 "fs_main_without_storage" %224 %226 %228 %230 +OpExecutionMode %146 OriginUpperLeft +OpExecutionMode %231 OriginUpperLeft %3 = OpString "shadow.wgsl" OpSource Unknown 0 %3 "struct Globals { view_proj: mat4x4, @@ -159,23 +159,23 @@ OpName %75 "position" OpName %78 "normal" OpName %80 "proj_position" OpName %82 "world_normal" -OpName %84 "world_position" -OpName %85 "vs_main" -OpName %92 "out" -OpName %134 "proj_position" -OpName %137 "world_normal" -OpName %140 "world_position" -OpName %143 "fs_main" -OpName %150 "color" -OpName %151 "i" -OpName %166 "loop_bound" -OpName %221 "proj_position" -OpName %223 "world_normal" -OpName %225 "world_position" -OpName %228 "fs_main_without_storage" -OpName %235 "color" -OpName %236 "i" -OpName %244 "loop_bound" +OpName %83 "world_position" +OpName %84 "vs_main" +OpName %91 "out" +OpName %136 "proj_position" +OpName %139 "world_normal" +OpName %142 "world_position" +OpName %146 "fs_main" +OpName %153 "color" +OpName %154 "i" +OpName %169 "loop_bound" +OpName %224 "proj_position" +OpName %226 "world_normal" +OpName %228 "world_position" +OpName %231 "fs_main_without_storage" +OpName %238 "color" +OpName %239 "i" +OpName %247 "loop_bound" OpMemberDecorate %9 0 Offset 0 OpMemberDecorate %9 0 ColMajor OpMemberDecorate %9 0 MatrixStride 16 @@ -219,15 +219,15 @@ OpDecorate %75 Location 0 OpDecorate %78 Location 1 OpDecorate %80 BuiltIn Position OpDecorate %82 Location 0 -OpDecorate %84 Location 1 -OpDecorate %134 BuiltIn FragCoord -OpDecorate %137 Location 0 -OpDecorate %140 Location 1 -OpDecorate %142 Location 0 -OpDecorate %221 BuiltIn FragCoord -OpDecorate %223 Location 0 -OpDecorate %225 Location 1 -OpDecorate %227 Location 0 +OpDecorate %83 Location 1 +OpDecorate %136 BuiltIn FragCoord +OpDecorate %139 Location 0 +OpDecorate %142 Location 1 +OpDecorate %144 Location 0 +OpDecorate %224 BuiltIn FragCoord +OpDecorate %226 Location 0 +OpDecorate %228 Location 1 +OpDecorate %230 Location 0 %2 = OpTypeVoid %4 = OpTypeFloat 32 %6 = OpTypeVector %4 4 @@ -278,48 +278,48 @@ OpDecorate %227 Location 0 %76 = OpTypePointer Input %13 %75 = OpVariable %76 Input %78 = OpVariable %76 Input -%81 = OpTypePointer Output %6 +%81 = OpTypePointer Output %12 %80 = OpVariable %81 Output -%83 = OpTypePointer Output %11 -%82 = OpVariable %83 Output -%84 = OpVariable %81 Output -%86 = OpTypeFunction %2 -%87 = OpTypePointer Uniform %9 -%88 = OpConstant %7 0 -%90 = OpTypePointer Uniform %10 -%93 = OpTypePointer Function %12 -%94 = OpConstantNull %12 -%96 = OpTypePointer Uniform %5 -%103 = OpTypePointer Function %11 -%111 = OpTypeVector %14 3 -%115 = OpConstant %7 1 -%117 = OpTypePointer Function %6 -%118 = OpConstant %7 2 -%126 = OpTypePointer Output %4 -%135 = OpTypePointer Input %6 -%134 = OpVariable %135 Input -%138 = OpTypePointer Input %11 -%137 = OpVariable %138 Input -%140 = OpVariable %135 Input -%142 = OpVariable %81 Output -%146 = OpTypePointer StorageBuffer %17 -%152 = OpTypePointer Function %7 -%160 = OpTypeVector %7 2 -%161 = OpTypePointer Function %160 -%162 = OpTypeVector %56 2 -%163 = OpConstantComposite %160 %88 %88 -%164 = OpConstant %7 4294967295 -%165 = OpConstantComposite %160 %164 %164 -%178 = OpTypePointer Uniform %8 -%179 = OpTypePointer Uniform %7 -%189 = OpTypePointer StorageBuffer %16 -%215 = OpTypePointer Uniform %6 -%221 = OpVariable %135 Input -%223 = OpVariable %138 Input -%225 = OpVariable %135 Input -%227 = OpVariable %81 Output -%231 = OpTypePointer Uniform %18 -%265 = OpTypePointer Uniform %16 +%82 = OpVariable %81 Output +%83 = OpVariable %81 Output +%85 = OpTypeFunction %2 +%86 = OpTypePointer Uniform %9 +%87 = OpConstant %7 0 +%89 = OpTypePointer Uniform %10 +%92 = OpTypePointer Function %12 +%93 = OpConstantNull %12 +%95 = OpTypePointer Uniform %5 +%102 = OpTypePointer Function %11 +%110 = OpTypeVector %14 3 +%114 = OpConstant %7 1 +%116 = OpTypePointer Function %6 +%117 = OpConstant %7 2 +%125 = OpTypePointer Output %4 +%137 = OpTypePointer Input %6 +%136 = OpVariable %137 Input +%140 = OpTypePointer Input %11 +%139 = OpVariable %140 Input +%142 = OpVariable %137 Input +%145 = OpTypePointer Output %6 +%144 = OpVariable %145 Output +%149 = OpTypePointer StorageBuffer %17 +%155 = OpTypePointer Function %7 +%163 = OpTypeVector %7 2 +%164 = OpTypePointer Function %163 +%165 = OpTypeVector %56 2 +%166 = OpConstantComposite %163 %87 %87 +%167 = OpConstant %7 4294967295 +%168 = OpConstantComposite %163 %167 %167 +%181 = OpTypePointer Uniform %8 +%182 = OpTypePointer Uniform %7 +%192 = OpTypePointer StorageBuffer %16 +%218 = OpTypePointer Uniform %6 +%224 = OpVariable %137 Input +%226 = OpVariable %140 Input +%228 = OpVariable %137 Input +%230 = OpVariable %145 Output +%234 = OpTypePointer Uniform %18 +%268 = OpTypePointer Uniform %16 %44 = OpFunction %4 None %45 %42 = OpFunctionParameter %7 %43 = OpFunctionParameter %6 @@ -359,279 +359,282 @@ OpLine %3 77 12 %73 = OpImageSampleDrefExplicitLod %4 %72 %71 %68 Lod %48 OpReturnValue %73 OpFunctionEnd -%85 = OpFunction %2 None %86 +%84 = OpFunction %2 None %85 %74 = OpLabel -%92 = OpVariable %93 Function %94 +%91 = OpVariable %92 Function %93 %77 = OpLoad %13 %75 %79 = OpLoad %13 %78 -%89 = OpAccessChain %87 %25 %88 -%91 = OpAccessChain %90 %28 %88 -OpBranch %95 -%95 = OpLabel +%88 = OpAccessChain %86 %25 %87 +%90 = OpAccessChain %89 %28 %87 +OpBranch %94 +%94 = OpLabel OpLine %3 37 13 -%97 = OpAccessChain %96 %91 %88 -%98 = OpLoad %5 %97 +%96 = OpAccessChain %95 %90 %87 +%97 = OpLoad %5 %96 OpLine %3 38 21 -%99 = OpAccessChain %96 %91 %88 -%100 = OpLoad %5 %99 -%101 = OpConvertSToF %6 %77 -%102 = OpMatrixTimesVector %6 %100 %101 +%98 = OpAccessChain %95 %90 %87 +%99 = OpLoad %5 %98 +%100 = OpConvertSToF %6 %77 +%101 = OpMatrixTimesVector %6 %99 %100 OpLine %3 40 5 OpLine %3 40 36 -%104 = OpCompositeExtract %6 %98 0 -%105 = OpVectorShuffle %11 %104 %104 0 1 2 +%103 = OpCompositeExtract %6 %97 0 +%104 = OpVectorShuffle %11 %103 %103 0 1 2 OpLine %3 40 46 -%106 = OpCompositeExtract %6 %98 1 -%107 = OpVectorShuffle %11 %106 %106 0 1 2 +%105 = OpCompositeExtract %6 %97 1 +%106 = OpVectorShuffle %11 %105 %105 0 1 2 OpLine %3 40 24 -%108 = OpCompositeExtract %6 %98 2 -%109 = OpVectorShuffle %11 %108 %108 0 1 2 -%110 = OpCompositeConstruct %15 %105 %107 %109 -%112 = OpVectorShuffle %111 %79 %79 0 1 2 -%113 = OpConvertSToF %11 %112 -%114 = OpMatrixTimesVector %11 %110 %113 +%107 = OpCompositeExtract %6 %97 2 +%108 = OpVectorShuffle %11 %107 %107 0 1 2 +%109 = OpCompositeConstruct %15 %104 %106 %108 +%111 = OpVectorShuffle %110 %79 %79 0 1 2 +%112 = OpConvertSToF %11 %111 +%113 = OpMatrixTimesVector %11 %109 %112 OpLine %3 40 5 -%116 = OpAccessChain %103 %92 %115 -OpStore %116 %114 +%115 = OpAccessChain %102 %91 %114 +OpStore %115 %113 OpLine %3 41 5 OpLine %3 41 5 -%119 = OpAccessChain %117 %92 %118 -OpStore %119 %102 +%118 = OpAccessChain %116 %91 %117 +OpStore %118 %101 OpLine %3 42 5 OpLine %3 42 25 -%120 = OpAccessChain %96 %89 %88 -%121 = OpLoad %5 %120 -%122 = OpMatrixTimesVector %6 %121 %102 +%119 = OpAccessChain %95 %88 %87 +%120 = OpLoad %5 %119 +%121 = OpMatrixTimesVector %6 %120 %101 OpLine %3 42 5 -%123 = OpAccessChain %117 %92 %88 -OpStore %123 %122 +%122 = OpAccessChain %116 %91 %87 +OpStore %122 %121 OpLine %3 1 1 -%124 = OpLoad %12 %92 -%125 = OpCompositeExtract %6 %124 0 -OpStore %80 %125 -%127 = OpAccessChain %126 %80 %115 -%128 = OpLoad %4 %127 -%129 = OpFNegate %4 %128 -OpStore %127 %129 -%130 = OpCompositeExtract %11 %124 1 -OpStore %82 %130 -%131 = OpCompositeExtract %6 %124 2 -OpStore %84 %131 +%123 = OpLoad %12 %91 +%124 = OpCompositeExtract %6 %123 0 +OpStore %80 %124 +%126 = OpAccessChain %125 %80 %114 +%127 = OpLoad %4 %126 +%128 = OpFNegate %4 %127 +OpStore %126 %128 +%129 = OpCompositeExtract %11 %123 1 +OpStore %82 %129 +%130 = OpCompositeExtract %6 %123 2 +OpStore %83 %130 +%131 = OpCompositeExtract %6 %123 0 +%132 = OpCompositeExtract %11 %123 1 +%133 = OpCompositeExtract %6 %123 2 OpReturn OpFunctionEnd -%143 = OpFunction %2 None %86 -%132 = OpLabel -%150 = OpVariable %103 Function %24 -%151 = OpVariable %152 Function %88 -%166 = OpVariable %161 Function %165 -%136 = OpLoad %6 %134 -%139 = OpLoad %11 %137 -%141 = OpLoad %6 %140 -%133 = OpCompositeConstruct %12 %136 %139 %141 -%144 = OpAccessChain %87 %25 %88 -%145 = OpAccessChain %90 %28 %88 -%147 = OpAccessChain %146 %31 %88 -%148 = OpLoad %20 %37 -%149 = OpLoad %21 %39 -OpBranch %153 -%153 = OpLabel -OpLine %3 85 18 -%154 = OpCompositeExtract %11 %133 1 -%155 = OpExtInst %11 %1 Normalize %154 +%146 = OpFunction %2 None %85 +%134 = OpLabel +%153 = OpVariable %102 Function %24 +%154 = OpVariable %155 Function %87 +%169 = OpVariable %164 Function %168 +%138 = OpLoad %6 %136 +%141 = OpLoad %11 %139 +%143 = OpLoad %6 %142 +%135 = OpCompositeConstruct %12 %138 %141 %143 +%147 = OpAccessChain %86 %25 %87 +%148 = OpAccessChain %89 %28 %87 +%150 = OpAccessChain %149 %31 %87 +%151 = OpLoad %20 %37 +%152 = OpLoad %21 %39 OpBranch %156 %156 = OpLabel +OpLine %3 85 18 +%157 = OpCompositeExtract %11 %135 1 +%158 = OpExtInst %11 %1 Normalize %157 +OpBranch %159 +%159 = OpLabel OpLine %3 88 5 -OpLoopMerge %157 %159 None -OpBranch %167 -%167 = OpLabel -%168 = OpLoad %160 %166 -%169 = OpIEqual %162 %163 %168 -%170 = OpAll %56 %169 -OpSelectionMerge %171 None -OpBranchConditional %170 %157 %171 -%171 = OpLabel -%172 = OpCompositeExtract %7 %168 1 -%173 = OpIEqual %56 %172 %88 -%174 = OpSelect %7 %173 %115 %88 -%175 = OpCompositeConstruct %160 %174 %115 -%176 = OpISub %160 %168 %175 -OpStore %166 %176 -OpBranch %158 -%158 = OpLabel +OpLoopMerge %160 %162 None +OpBranch %170 +%170 = OpLabel +%171 = OpLoad %163 %169 +%172 = OpIEqual %165 %166 %171 +%173 = OpAll %56 %172 +OpSelectionMerge %174 None +OpBranchConditional %173 %160 %174 +%174 = OpLabel +%175 = OpCompositeExtract %7 %171 1 +%176 = OpIEqual %56 %175 %87 +%177 = OpSelect %7 %176 %114 %87 +%178 = OpCompositeConstruct %163 %177 %114 +%179 = OpISub %163 %171 %178 +OpStore %169 %179 +OpBranch %161 +%161 = OpLabel OpLine %3 1 1 -%177 = OpLoad %7 %151 +%180 = OpLoad %7 %154 OpLine %3 88 29 -%180 = OpAccessChain %179 %144 %115 %88 -%181 = OpLoad %7 %180 +%183 = OpAccessChain %182 %147 %114 %87 +%184 = OpLoad %7 %183 OpLine %3 88 21 -%182 = OpExtInst %7 %1 UMin %181 %19 -%183 = OpULessThan %56 %177 %182 +%185 = OpExtInst %7 %1 UMin %184 %19 +%186 = OpULessThan %56 %180 %185 OpLine %3 88 20 -OpSelectionMerge %184 None -OpBranchConditional %183 %184 %185 -%185 = OpLabel -OpBranch %157 -%184 = OpLabel -OpBranch %186 -%186 = OpLabel +OpSelectionMerge %187 None +OpBranchConditional %186 %187 %188 +%188 = OpLabel +OpBranch %160 +%187 = OpLabel +OpBranch %189 +%189 = OpLabel OpLine %3 89 21 -%188 = OpLoad %7 %151 -%190 = OpAccessChain %189 %147 %188 -%191 = OpLoad %16 %190 +%191 = OpLoad %7 %154 +%193 = OpAccessChain %192 %150 %191 +%194 = OpLoad %16 %193 OpLine %3 91 38 -%192 = OpLoad %7 %151 -%193 = OpCompositeExtract %5 %191 0 -%194 = OpCompositeExtract %6 %133 2 -%195 = OpMatrixTimesVector %6 %193 %194 +%195 = OpLoad %7 %154 +%196 = OpCompositeExtract %5 %194 0 +%197 = OpCompositeExtract %6 %135 2 +%198 = OpMatrixTimesVector %6 %196 %197 OpLine %3 91 22 -%196 = OpFunctionCall %4 %44 %192 %195 +%199 = OpFunctionCall %4 %44 %195 %198 OpLine %3 93 25 -%197 = OpCompositeExtract %6 %191 1 -%198 = OpVectorShuffle %11 %197 %197 0 1 2 -%199 = OpCompositeExtract %6 %133 2 -%200 = OpVectorShuffle %11 %199 %199 0 1 2 -%201 = OpFSub %11 %198 %200 -%202 = OpExtInst %11 %1 Normalize %201 +%200 = OpCompositeExtract %6 %194 1 +%201 = OpVectorShuffle %11 %200 %200 0 1 2 +%202 = OpCompositeExtract %6 %135 2 +%203 = OpVectorShuffle %11 %202 %202 0 1 2 +%204 = OpFSub %11 %201 %203 +%205 = OpExtInst %11 %1 Normalize %204 OpLine %3 94 32 -%203 = OpDot %4 %155 %202 +%206 = OpDot %4 %158 %205 OpLine %3 94 23 -%204 = OpExtInst %4 %1 FMax %48 %203 +%207 = OpExtInst %4 %1 FMax %48 %206 OpLine %3 96 9 -%205 = OpFMul %4 %196 %204 -%206 = OpCompositeExtract %6 %191 2 -%207 = OpVectorShuffle %11 %206 %206 0 1 2 -%208 = OpVectorTimesScalar %11 %207 %205 -%209 = OpLoad %11 %150 -%210 = OpFAdd %11 %209 %208 +%208 = OpFMul %4 %199 %207 +%209 = OpCompositeExtract %6 %194 2 +%210 = OpVectorShuffle %11 %209 %209 0 1 2 +%211 = OpVectorTimesScalar %11 %210 %208 +%212 = OpLoad %11 %153 +%213 = OpFAdd %11 %212 %211 OpLine %3 96 9 -OpStore %150 %210 -OpBranch %187 -%187 = OpLabel -OpBranch %159 -%159 = OpLabel +OpStore %153 %213 +OpBranch %190 +%190 = OpLabel +OpBranch %162 +%162 = OpLabel OpLine %3 88 68 -%211 = OpLoad %7 %151 -%212 = OpIAdd %7 %211 %115 +%214 = OpLoad %7 %154 +%215 = OpIAdd %7 %214 %114 OpLine %3 88 68 -OpStore %151 %212 -OpBranch %156 -%157 = OpLabel +OpStore %154 %215 +OpBranch %159 +%160 = OpLabel OpLine %3 1 1 -%213 = OpLoad %11 %150 +%216 = OpLoad %11 %153 OpLine %3 99 12 -%214 = OpCompositeConstruct %6 %213 %49 +%217 = OpCompositeConstruct %6 %216 %49 OpLine %3 99 12 -%216 = OpAccessChain %215 %145 %115 -%217 = OpLoad %6 %216 -%218 = OpFMul %6 %214 %217 -OpStore %142 %218 +%219 = OpAccessChain %218 %148 %114 +%220 = OpLoad %6 %219 +%221 = OpFMul %6 %217 %220 +OpStore %144 %221 OpReturn OpFunctionEnd -%228 = OpFunction %2 None %86 -%219 = OpLabel -%235 = OpVariable %103 Function %24 -%236 = OpVariable %152 Function %88 -%244 = OpVariable %161 Function %165 -%222 = OpLoad %6 %221 -%224 = OpLoad %11 %223 -%226 = OpLoad %6 %225 -%220 = OpCompositeConstruct %12 %222 %224 %226 -%229 = OpAccessChain %87 %25 %88 -%230 = OpAccessChain %90 %28 %88 -%232 = OpAccessChain %231 %34 %88 -%233 = OpLoad %20 %37 -%234 = OpLoad %21 %39 -OpBranch %237 -%237 = OpLabel -OpLine %3 105 18 -%238 = OpCompositeExtract %11 %220 1 -%239 = OpExtInst %11 %1 Normalize %238 +%231 = OpFunction %2 None %85 +%222 = OpLabel +%238 = OpVariable %102 Function %24 +%239 = OpVariable %155 Function %87 +%247 = OpVariable %164 Function %168 +%225 = OpLoad %6 %224 +%227 = OpLoad %11 %226 +%229 = OpLoad %6 %228 +%223 = OpCompositeConstruct %12 %225 %227 %229 +%232 = OpAccessChain %86 %25 %87 +%233 = OpAccessChain %89 %28 %87 +%235 = OpAccessChain %234 %34 %87 +%236 = OpLoad %20 %37 +%237 = OpLoad %21 %39 OpBranch %240 %240 = OpLabel +OpLine %3 105 18 +%241 = OpCompositeExtract %11 %223 1 +%242 = OpExtInst %11 %1 Normalize %241 +OpBranch %243 +%243 = OpLabel OpLine %3 107 5 -OpLoopMerge %241 %243 None +OpLoopMerge %244 %246 None +OpBranch %248 +%248 = OpLabel +%249 = OpLoad %163 %247 +%250 = OpIEqual %165 %166 %249 +%251 = OpAll %56 %250 +OpSelectionMerge %252 None +OpBranchConditional %251 %244 %252 +%252 = OpLabel +%253 = OpCompositeExtract %7 %249 1 +%254 = OpIEqual %56 %253 %87 +%255 = OpSelect %7 %254 %114 %87 +%256 = OpCompositeConstruct %163 %255 %114 +%257 = OpISub %163 %249 %256 +OpStore %247 %257 OpBranch %245 %245 = OpLabel -%246 = OpLoad %160 %244 -%247 = OpIEqual %162 %163 %246 -%248 = OpAll %56 %247 -OpSelectionMerge %249 None -OpBranchConditional %248 %241 %249 -%249 = OpLabel -%250 = OpCompositeExtract %7 %246 1 -%251 = OpIEqual %56 %250 %88 -%252 = OpSelect %7 %251 %115 %88 -%253 = OpCompositeConstruct %160 %252 %115 -%254 = OpISub %160 %246 %253 -OpStore %244 %254 -OpBranch %242 -%242 = OpLabel OpLine %3 1 1 -%255 = OpLoad %7 %236 +%258 = OpLoad %7 %239 OpLine %3 107 29 -%256 = OpAccessChain %179 %229 %115 %88 -%257 = OpLoad %7 %256 +%259 = OpAccessChain %182 %232 %114 %87 +%260 = OpLoad %7 %259 OpLine %3 107 21 -%258 = OpExtInst %7 %1 UMin %257 %19 -%259 = OpULessThan %56 %255 %258 +%261 = OpExtInst %7 %1 UMin %260 %19 +%262 = OpULessThan %56 %258 %261 OpLine %3 107 20 -OpSelectionMerge %260 None -OpBranchConditional %259 %260 %261 -%261 = OpLabel -OpBranch %241 -%260 = OpLabel -OpBranch %262 -%262 = OpLabel +OpSelectionMerge %263 None +OpBranchConditional %262 %263 %264 +%264 = OpLabel +OpBranch %244 +%263 = OpLabel +OpBranch %265 +%265 = OpLabel OpLine %3 110 21 -%264 = OpLoad %7 %236 -%266 = OpAccessChain %265 %232 %264 -%267 = OpLoad %16 %266 +%267 = OpLoad %7 %239 +%269 = OpAccessChain %268 %235 %267 +%270 = OpLoad %16 %269 OpLine %3 111 38 -%268 = OpLoad %7 %236 -%269 = OpCompositeExtract %5 %267 0 -%270 = OpCompositeExtract %6 %220 2 -%271 = OpMatrixTimesVector %6 %269 %270 +%271 = OpLoad %7 %239 +%272 = OpCompositeExtract %5 %270 0 +%273 = OpCompositeExtract %6 %223 2 +%274 = OpMatrixTimesVector %6 %272 %273 OpLine %3 111 22 -%272 = OpFunctionCall %4 %44 %268 %271 +%275 = OpFunctionCall %4 %44 %271 %274 OpLine %3 112 25 -%273 = OpCompositeExtract %6 %267 1 -%274 = OpVectorShuffle %11 %273 %273 0 1 2 -%275 = OpCompositeExtract %6 %220 2 -%276 = OpVectorShuffle %11 %275 %275 0 1 2 -%277 = OpFSub %11 %274 %276 -%278 = OpExtInst %11 %1 Normalize %277 +%276 = OpCompositeExtract %6 %270 1 +%277 = OpVectorShuffle %11 %276 %276 0 1 2 +%278 = OpCompositeExtract %6 %223 2 +%279 = OpVectorShuffle %11 %278 %278 0 1 2 +%280 = OpFSub %11 %277 %279 +%281 = OpExtInst %11 %1 Normalize %280 OpLine %3 113 32 -%279 = OpDot %4 %239 %278 +%282 = OpDot %4 %242 %281 OpLine %3 113 23 -%280 = OpExtInst %4 %1 FMax %48 %279 +%283 = OpExtInst %4 %1 FMax %48 %282 OpLine %3 114 9 -%281 = OpFMul %4 %272 %280 -%282 = OpCompositeExtract %6 %267 2 -%283 = OpVectorShuffle %11 %282 %282 0 1 2 -%284 = OpVectorTimesScalar %11 %283 %281 -%285 = OpLoad %11 %235 -%286 = OpFAdd %11 %285 %284 +%284 = OpFMul %4 %275 %283 +%285 = OpCompositeExtract %6 %270 2 +%286 = OpVectorShuffle %11 %285 %285 0 1 2 +%287 = OpVectorTimesScalar %11 %286 %284 +%288 = OpLoad %11 %238 +%289 = OpFAdd %11 %288 %287 OpLine %3 114 9 -OpStore %235 %286 -OpBranch %263 -%263 = OpLabel -OpBranch %243 -%243 = OpLabel +OpStore %238 %289 +OpBranch %266 +%266 = OpLabel +OpBranch %246 +%246 = OpLabel OpLine %3 107 68 -%287 = OpLoad %7 %236 -%288 = OpIAdd %7 %287 %115 +%290 = OpLoad %7 %239 +%291 = OpIAdd %7 %290 %114 OpLine %3 107 68 -OpStore %236 %288 -OpBranch %240 -%241 = OpLabel +OpStore %239 %291 +OpBranch %243 +%244 = OpLabel OpLine %3 1 1 -%289 = OpLoad %11 %235 +%292 = OpLoad %11 %238 OpLine %3 116 12 -%290 = OpCompositeConstruct %6 %289 %49 +%293 = OpCompositeConstruct %6 %292 %49 OpLine %3 116 12 -%291 = OpAccessChain %215 %230 %115 -%292 = OpLoad %6 %291 -%293 = OpFMul %6 %290 %292 -OpStore %227 %293 +%294 = OpAccessChain %218 %233 %114 +%295 = OpLoad %6 %294 +%296 = OpFMul %6 %293 %295 +OpStore %230 %296 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-skybox.spvasm b/naga/tests/out/spv/wgsl-skybox.spvasm index 7bc7b30f6da..be26cc2aa94 100644 --- a/naga/tests/out/spv/wgsl-skybox.spvasm +++ b/naga/tests/out/spv/wgsl-skybox.spvasm @@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.0 ; Generator: rspirv -; Bound: 114 +; Bound: 116 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %46 "vs_main" %39 %42 %44 -OpEntryPoint Fragment %106 "fs_main" %99 %102 %105 -OpExecutionMode %106 OriginUpperLeft +OpEntryPoint Vertex %45 "vs_main" %39 %42 %42 %44 %44 +OpEntryPoint Fragment %108 "fs_main" %100 %103 %106 +OpExecutionMode %108 OriginUpperLeft OpMemberDecorate %6 0 Offset 0 OpMemberDecorate %6 1 Offset 16 OpMemberDecorate %8 0 Offset 0 @@ -27,9 +27,9 @@ OpDecorate %19 Binding 2 OpDecorate %39 BuiltIn VertexIndex OpDecorate %42 BuiltIn Position OpDecorate %44 Location 0 -OpDecorate %99 BuiltIn FragCoord -OpDecorate %102 Location 0 -OpDecorate %105 Location 0 +OpDecorate %100 BuiltIn FragCoord +OpDecorate %103 Location 0 +OpDecorate %106 Location 0 %2 = OpTypeVoid %4 = OpTypeFloat 32 %3 = OpTypeVector %4 4 @@ -57,30 +57,30 @@ OpDecorate %105 Location 0 %35 = OpConstant %10 1 %40 = OpTypePointer Input %9 %39 = OpVariable %40 Input -%43 = OpTypePointer Output %3 +%43 = OpTypePointer Output %6 %42 = OpVariable %43 Output -%45 = OpTypePointer Output %5 -%44 = OpVariable %45 Output -%47 = OpTypeFunction %2 -%48 = OpTypePointer Uniform %8 -%49 = OpConstant %9 0 -%51 = OpConstant %10 2 -%52 = OpConstant %4 4.0 -%53 = OpConstant %4 1.0 -%54 = OpConstant %4 0.0 -%56 = OpTypePointer Function %10 -%57 = OpConstantNull %10 -%59 = OpConstantNull %10 -%74 = OpTypePointer Uniform %7 -%75 = OpTypePointer Uniform %3 -%76 = OpConstant %9 1 -%83 = OpConstant %9 2 -%100 = OpTypePointer Input %3 -%99 = OpVariable %100 Input -%103 = OpTypePointer Input %5 -%102 = OpVariable %103 Input -%105 = OpVariable %43 Output -%111 = OpTypeSampledImage %12 +%44 = OpVariable %43 Output +%46 = OpTypeFunction %2 +%47 = OpTypePointer Uniform %8 +%48 = OpConstant %9 0 +%50 = OpConstant %10 2 +%51 = OpConstant %4 4.0 +%52 = OpConstant %4 1.0 +%53 = OpConstant %4 0.0 +%55 = OpTypePointer Function %10 +%56 = OpConstantNull %10 +%58 = OpConstantNull %10 +%73 = OpTypePointer Uniform %7 +%74 = OpTypePointer Uniform %3 +%75 = OpConstant %9 1 +%82 = OpConstant %9 2 +%101 = OpTypePointer Input %3 +%100 = OpVariable %101 Input +%104 = OpTypePointer Input %5 +%103 = OpVariable %104 Input +%107 = OpTypePointer Output %3 +%106 = OpVariable %107 Output +%113 = OpTypeSampledImage %12 %21 = OpFunction %10 None %22 %23 = OpFunctionParameter %10 %24 = OpFunctionParameter %10 @@ -94,64 +94,66 @@ OpDecorate %105 Location 0 %37 = OpSDiv %10 %23 %36 OpReturnValue %37 OpFunctionEnd -%46 = OpFunction %2 None %47 +%45 = OpFunction %2 None %46 %38 = OpLabel -%55 = OpVariable %56 Function %57 -%58 = OpVariable %56 Function %59 +%54 = OpVariable %55 Function %56 +%57 = OpVariable %55 Function %58 %41 = OpLoad %9 %39 -%50 = OpAccessChain %48 %14 %49 -OpBranch %60 -%60 = OpLabel -%61 = OpBitcast %10 %41 -%62 = OpFunctionCall %10 %21 %61 %51 -OpStore %55 %62 -%63 = OpBitcast %10 %41 -%64 = OpBitwiseAnd %10 %63 %35 -OpStore %58 %64 -%65 = OpLoad %10 %55 -%66 = OpConvertSToF %4 %65 -%67 = OpFMul %4 %66 %52 -%68 = OpFSub %4 %67 %53 -%69 = OpLoad %10 %58 -%70 = OpConvertSToF %4 %69 -%71 = OpFMul %4 %70 %52 -%72 = OpFSub %4 %71 %53 -%73 = OpCompositeConstruct %3 %68 %72 %54 %53 -%77 = OpAccessChain %75 %50 %76 %49 -%78 = OpLoad %3 %77 -%79 = OpVectorShuffle %5 %78 %78 0 1 2 -%80 = OpAccessChain %75 %50 %76 %76 -%81 = OpLoad %3 %80 -%82 = OpVectorShuffle %5 %81 %81 0 1 2 -%84 = OpAccessChain %75 %50 %76 %83 -%85 = OpLoad %3 %84 -%86 = OpVectorShuffle %5 %85 %85 0 1 2 -%87 = OpCompositeConstruct %11 %79 %82 %86 -%88 = OpTranspose %11 %87 -%89 = OpAccessChain %74 %50 %49 -%90 = OpLoad %7 %89 -%91 = OpMatrixTimesVector %3 %90 %73 -%92 = OpVectorShuffle %5 %91 %91 0 1 2 -%93 = OpMatrixTimesVector %5 %88 %92 -%94 = OpCompositeConstruct %6 %73 %93 -%95 = OpCompositeExtract %3 %94 0 -OpStore %42 %95 -%96 = OpCompositeExtract %5 %94 1 -OpStore %44 %96 +%49 = OpAccessChain %47 %14 %48 +OpBranch %59 +%59 = OpLabel +%60 = OpBitcast %10 %41 +%61 = OpFunctionCall %10 %21 %60 %50 +OpStore %54 %61 +%62 = OpBitcast %10 %41 +%63 = OpBitwiseAnd %10 %62 %35 +OpStore %57 %63 +%64 = OpLoad %10 %54 +%65 = OpConvertSToF %4 %64 +%66 = OpFMul %4 %65 %51 +%67 = OpFSub %4 %66 %52 +%68 = OpLoad %10 %57 +%69 = OpConvertSToF %4 %68 +%70 = OpFMul %4 %69 %51 +%71 = OpFSub %4 %70 %52 +%72 = OpCompositeConstruct %3 %67 %71 %53 %52 +%76 = OpAccessChain %74 %49 %75 %48 +%77 = OpLoad %3 %76 +%78 = OpVectorShuffle %5 %77 %77 0 1 2 +%79 = OpAccessChain %74 %49 %75 %75 +%80 = OpLoad %3 %79 +%81 = OpVectorShuffle %5 %80 %80 0 1 2 +%83 = OpAccessChain %74 %49 %75 %82 +%84 = OpLoad %3 %83 +%85 = OpVectorShuffle %5 %84 %84 0 1 2 +%86 = OpCompositeConstruct %11 %78 %81 %85 +%87 = OpTranspose %11 %86 +%88 = OpAccessChain %73 %49 %48 +%89 = OpLoad %7 %88 +%90 = OpMatrixTimesVector %3 %89 %72 +%91 = OpVectorShuffle %5 %90 %90 0 1 2 +%92 = OpMatrixTimesVector %5 %87 %91 +%93 = OpCompositeConstruct %6 %72 %92 +%94 = OpCompositeExtract %3 %93 0 +OpStore %42 %94 +%95 = OpCompositeExtract %5 %93 1 +OpStore %44 %95 +%96 = OpCompositeExtract %3 %93 0 +%97 = OpCompositeExtract %5 %93 1 OpReturn OpFunctionEnd -%106 = OpFunction %2 None %47 -%97 = OpLabel -%101 = OpLoad %3 %99 -%104 = OpLoad %5 %102 -%98 = OpCompositeConstruct %6 %101 %104 -%107 = OpLoad %12 %17 -%108 = OpLoad %13 %19 -OpBranch %109 -%109 = OpLabel -%110 = OpCompositeExtract %5 %98 1 -%112 = OpSampledImage %111 %107 %108 -%113 = OpImageSampleImplicitLod %3 %112 %110 -OpStore %105 %113 +%108 = OpFunction %2 None %46 +%98 = OpLabel +%102 = OpLoad %3 %100 +%105 = OpLoad %5 %103 +%99 = OpCompositeConstruct %6 %102 %105 +%109 = OpLoad %12 %17 +%110 = OpLoad %13 %19 +OpBranch %111 +%111 = OpLabel +%112 = OpCompositeExtract %5 %99 1 +%114 = OpSampledImage %113 %109 %110 +%115 = OpImageSampleImplicitLod %3 %114 %112 +OpStore %106 %115 OpReturn OpFunctionEnd \ No newline at end of file From 2e6f11ca30aa2ee852ee794dc1737e6f5a356519 Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Sat, 12 Jul 2025 20:30:42 -0700 Subject: [PATCH 43/84] Attempted to make a small adjustment to SPIR-V writing --- naga/src/back/spv/block.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index a84155fc8b9..150160412c8 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -259,21 +259,21 @@ impl Writer { } // MeshTaskSize must be called write before exiting for (index, res_member) in result_members.iter().enumerate() { - let member_value_id = match ir_result.binding { - Some(_) => value_id, - None => { - let member_value_id = self.id_gen.next(); - body.push(Instruction::composite_extract( - res_member.type_id, - member_value_id, - value_id, - &[index as Word], - )); - member_value_id - } - }; - if res_member.built_in == Some(crate::BuiltIn::MeshTaskSize) { + let member_value_id = match ir_result.binding { + Some(_) => value_id, + None => { + let member_value_id = self.id_gen.next(); + body.push(Instruction::composite_extract( + res_member.type_id, + member_value_id, + value_id, + &[index as Word], + )); + member_value_id + } + }; + let values = [self.id_gen.next(), self.id_gen.next(), self.id_gen.next()]; for (i, &value) in values.iter().enumerate() { let instruction = Instruction::composite_extract( From 784dd807705dab4dfdc7f294056c2709c8761e95 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sun, 13 Jul 2025 19:10:47 -0500 Subject: [PATCH 44/84] A lot more progress made --- naga/src/back/pipeline_constants.rs | 25 +++ naga/src/back/spv/block.rs | 44 ++++- naga/src/back/spv/helpers.rs | 12 ++ naga/src/back/spv/mod.rs | 26 +++ naga/src/back/spv/writer.rs | 263 +++++++++++++++++++++++++--- naga/src/front/wgsl/lower/mod.rs | 6 + naga/src/valid/interface.rs | 23 +++ 7 files changed, 367 insertions(+), 32 deletions(-) diff --git a/naga/src/back/pipeline_constants.rs b/naga/src/back/pipeline_constants.rs index 85a1afe0d42..c009082a3c9 100644 --- a/naga/src/back/pipeline_constants.rs +++ b/naga/src/back/pipeline_constants.rs @@ -39,6 +39,8 @@ pub enum PipelineConstantError { ValidationError(#[from] WithSpan), #[error("workgroup_size override isn't strictly positive")] NegativeWorkgroupSize, + #[error("max vertices or max primitives is negative")] + NegativeMeshOutputMax, } /// Compact `module` and replace all overrides with constants. @@ -243,6 +245,7 @@ pub fn process_overrides<'a>( for ep in entry_points.iter_mut() { process_function(&mut module, &override_map, &mut layouter, &mut ep.function)?; process_workgroup_size_override(&mut module, &adjusted_global_expressions, ep)?; + process_mesh_shader_overrides(&mut module, &adjusted_global_expressions, ep)?; } module.entry_points = entry_points; module.overrides = overrides; @@ -296,6 +299,28 @@ fn process_workgroup_size_override( Ok(()) } +fn process_mesh_shader_overrides( + module: &mut Module, + adjusted_global_expressions: &HandleVec>, + ep: &mut crate::EntryPoint, +) -> Result<(), PipelineConstantError> { + if let Some(ref mut mesh_info) = ep.mesh_info { + if let Some(r#override) = mesh_info.max_vertices_override { + mesh_info.max_vertices = module + .to_ctx() + .eval_expr_to_u32(adjusted_global_expressions[r#override]) + .map_err(|_| PipelineConstantError::NegativeWorkgroupSize)?; + } + if let Some(r#override) = mesh_info.max_primitives_override { + mesh_info.max_primitives = module + .to_ctx() + .eval_expr_to_u32(adjusted_global_expressions[r#override]) + .map_err(|_| PipelineConstantError::NegativeWorkgroupSize)?; + } + } + Ok(()) +} + /// Add a [`Constant`] to `module` for the override `old_h`. /// /// Add the new `Constant` to `override_map` and `adjusted_constant_initializers`. diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 150160412c8..0f47acdd4e9 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -3673,16 +3673,48 @@ impl BlockContext<'_> { primitive_count, }) => { let mut ins = Instruction::new(spirv::Op::SetMeshOutputsEXT); - ins.operands = - alloc::vec![self.cached[vertex_count], self.cached[primitive_count]]; + ins.add_operand(self.cached[vertex_count]); + ins.add_operand(self.cached[primitive_count]); block.body.push(ins); } Statement::MeshFunction( - crate::MeshFunction::SetVertex { .. } - | crate::MeshFunction::SetPrimitive { .. }, + crate::MeshFunction::SetVertex { index, value } + | crate::MeshFunction::SetPrimitive { index, value }, ) => { - // TODO: work on this - unimplemented!(); + self.writer + .require_any("mesh shaders", &[spirv::Capability::MeshShadingEXT])?; + self.writer.use_extension("SPV_EXT_mesh_shader"); + let lang_version = self.writer.lang_version(); + if lang_version.0 <= 1 && lang_version.1 < 4 { + return Err(Error::SpirvVersionTooLow(1, 4)); + } + let is_prim = matches!( + *statement, + Statement::MeshFunction(crate::MeshFunction::SetPrimitive { .. }) + ); + let type_handle = if is_prim { + self.fun_info.mesh_shader_info.primitive_type.unwrap().0 + } else { + self.fun_info.mesh_shader_info.vertex_type.unwrap().0 + }; + let info = self.writer.mesh_shader_output_variable( + self.ir_module, + type_handle, + is_prim, + 0, + )?; + + let var_ptr = self.gen_id(); + block.body.push(Instruction::access_chain( + info.ptr_type, + var_ptr, + info.var_id, + &[self.cached[index]], + )); + + block + .body + .push(Instruction::store(var_ptr, self.cached[value], None)); } Statement::SubgroupBallot { result, diff --git a/naga/src/back/spv/helpers.rs b/naga/src/back/spv/helpers.rs index 00611f7efa9..1a99c3e5475 100644 --- a/naga/src/back/spv/helpers.rs +++ b/naga/src/back/spv/helpers.rs @@ -1,5 +1,6 @@ use alloc::{vec, vec::Vec}; +use arrayvec::ArrayVec; use spirv::Word; use crate::{Handle, UniqueArena}; @@ -151,3 +152,14 @@ impl StrUnstable for str { } } } + +pub enum BindingDecorations { + BuiltIn(spirv::BuiltIn, ArrayVec), + Location { + location: Word, + others: ArrayVec, + /// If this is `Some`, use Decoration::Index with blend_src as an operand + blend_src: Option, + }, + None, +} diff --git a/naga/src/back/spv/mod.rs b/naga/src/back/spv/mod.rs index 82ca3255e31..aff78b37119 100644 --- a/naga/src/back/spv/mod.rs +++ b/naga/src/back/spv/mod.rs @@ -773,6 +773,8 @@ pub struct Writer { ray_get_committed_intersection_function: Option, ray_get_candidate_intersection_function: Option, + + mesh_state: WriteMeshInfo, } bitflags::bitflags! { @@ -910,3 +912,27 @@ pub fn write_vec( )?; Ok(words) } + +/// The outputs of a mesh shader must be stored in global variables. These outputs are determined by the attributes on +/// the entry point, but other functions may also set these outputs. A single module might have multiple such global +/// variables, but each function will only end up using one and will have to look up the global variable for its type, +/// not its entry point. Therefore the variables must be associated with types and not entry points. +pub struct WriteMeshInfo { + pub vertex_outputs_by_type: crate::FastHashMap, MeshOutputInfo>, + pub primitive_outputs_by_type: crate::FastHashMap, MeshOutputInfo>, +} + +#[derive(Clone, Copy)] +pub struct MeshOutputInfo { + /// The index of the word that specifies the length of the global variable array. This is very hacky lol + /// We want to allow the same global variable to be used across entry points of the same output type + /// so that they can reuse functions that might set vertices/indices. So we make the array the largest + /// of the max output sizes among all the entry points! It will default to zero, so that if an unused function + /// tries to write to it, the function can still be valid if it is never called. + pub index_of_length_decl: usize, + pub inner_type: Word, + pub array_type: Word, + pub ptr_type: Word, + pub array_ptr_type: Word, + pub var_id: Word, +} diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index abfa2b5439e..6ee63a40843 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -1,5 +1,6 @@ use alloc::{string::String, vec, vec::Vec}; +use arrayvec::ArrayVec; use hashbrown::hash_map::Entry; use spirv::Word; @@ -13,7 +14,7 @@ use super::{ }; use crate::{ arena::{Handle, HandleVec, UniqueArena}, - back::spv::{BindingInfo, WrappedFunction}, + back::spv::{helpers::BindingDecorations, BindingInfo, WrappedFunction}, path_like::PathLike, proc::{Alignment, TypeResolution}, valid::{FunctionInfo, ModuleInfo}, @@ -23,6 +24,7 @@ struct FunctionInterface<'a> { varying_ids: &'a mut Vec, stage: crate::ShaderStage, task_payload: Option>, + mesh_info: Option, } impl Function { @@ -93,6 +95,10 @@ impl Writer { temp_list: Vec::new(), ray_get_committed_intersection_function: None, ray_get_candidate_intersection_function: None, + mesh_state: super::WriteMeshInfo { + vertex_outputs_by_type: crate::FastHashMap::default(), + primitive_outputs_by_type: crate::FastHashMap::default(), + }, }) } @@ -152,6 +158,12 @@ impl Writer { temp_list: take(&mut self.temp_list).recycle(), ray_get_candidate_intersection_function: None, ray_get_committed_intersection_function: None, + + mesh_state: super::WriteMeshInfo { + vertex_outputs_by_type: take(&mut self.mesh_state.vertex_outputs_by_type).recycle(), + primitive_outputs_by_type: take(&mut self.mesh_state.primitive_outputs_by_type) + .recycle(), + }, }; *self = fresh; @@ -848,11 +860,7 @@ impl Writer { } has_point_size |= *binding == crate::Binding::BuiltIn(crate::BuiltIn::PointSize); - let varying_id = if *binding - == crate::Binding::BuiltIn(crate::BuiltIn::MeshTaskSize) - { - 0 - } else { + let varying_id = { let varying_id = self.write_varying( ir_module, iface.stage, @@ -904,11 +912,26 @@ impl Writer { None => self.void_type, }; - if let Some(ref mut i) = interface { - if let Some(task_payload) = i.task_payload { - i.varying_ids + if let Some(ref mut iface) = interface { + if let Some(task_payload) = iface.task_payload { + iface + .varying_ids .push(self.global_variables[task_payload].var_id); } + if let Some(ref mesh_info) = iface.mesh_info { + self.mesh_shader_output_variable( + ir_module, + mesh_info.vertex_output_type, + false, + mesh_info.max_vertices, + )?; + self.mesh_shader_output_variable( + ir_module, + mesh_info.primitive_output_type, + true, + mesh_info.max_primitives, + )?; + } } let lookup_function_type = LookupFunctionType { @@ -1144,6 +1167,7 @@ impl Writer { varying_ids: &mut interface_ids, stage: entry_point.stage, task_payload: entry_point.task_payload, + mesh_info: entry_point.mesh_info.clone(), }), debug_info, )?; @@ -1995,8 +2019,99 @@ impl Writer { } } - use spirv::{BuiltIn, Decoration}; + let binding = self.map_binding(ir_module, stage, class, ty, binding)?; + + match binding { + BindingDecorations::None => (), + BindingDecorations::BuiltIn(bi, others) => { + self.decorate(id, spirv::Decoration::BuiltIn, &[bi as u32]); + for other in others { + self.decorate(id, other, &[]); + } + } + BindingDecorations::Location { + location, + others, + blend_src, + } => { + self.decorate(id, spirv::Decoration::Location, &[location]); + for other in others { + self.decorate(id, other, &[]); + } + if let Some(blend_src) = blend_src { + self.decorate(id, spirv::Decoration::Index, &[blend_src]); + } + } + } + + Ok(id) + } + + pub fn write_binding_struct_member( + &mut self, + struct_id: Word, + member_idx: Word, + binding_info: BindingDecorations, + ) { + match binding_info { + BindingDecorations::None => (), + BindingDecorations::BuiltIn(bi, others) => { + self.annotations.push(Instruction::member_decorate( + struct_id, + member_idx, + spirv::Decoration::BuiltIn, + &[bi as Word], + )); + for other in others { + self.annotations.push(Instruction::member_decorate( + struct_id, + member_idx, + other, + &[], + )); + } + } + BindingDecorations::Location { + location, + others, + blend_src, + } => { + self.annotations.push(Instruction::member_decorate( + struct_id, + member_idx, + spirv::Decoration::Location, + &[location], + )); + for other in others { + self.annotations.push(Instruction::member_decorate( + struct_id, + member_idx, + other, + &[], + )); + } + if let Some(blend_src) = blend_src { + self.annotations.push(Instruction::member_decorate( + struct_id, + member_idx, + spirv::Decoration::Index, + &[blend_src], + )); + } + } + } + } + pub fn map_binding( + &mut self, + ir_module: &crate::Module, + stage: crate::ShaderStage, + class: spirv::StorageClass, + ty: Handle, + binding: &crate::Binding, + ) -> Result { + use spirv::BuiltIn; + use spirv::Decoration; match *binding { crate::Binding::Location { location, @@ -2004,7 +2119,7 @@ impl Writer { sampling, blend_src, } => { - self.decorate(id, Decoration::Location, &[location]); + let mut others = ArrayVec::new(); let no_decorations = // VUID-StandaloneSpirv-Flat-06202 @@ -2021,10 +2136,10 @@ impl Writer { // Perspective-correct interpolation is the default in SPIR-V. None | Some(crate::Interpolation::Perspective) => (), Some(crate::Interpolation::Flat) => { - self.decorate(id, Decoration::Flat, &[]); + others.push(Decoration::Flat); } Some(crate::Interpolation::Linear) => { - self.decorate(id, Decoration::NoPerspective, &[]); + others.push(Decoration::NoPerspective); } } match sampling { @@ -2036,27 +2151,30 @@ impl Writer { | crate::Sampling::Either, ) => (), Some(crate::Sampling::Centroid) => { - self.decorate(id, Decoration::Centroid, &[]); + others.push(Decoration::Centroid); } Some(crate::Sampling::Sample) => { self.require_any( "per-sample interpolation", &[spirv::Capability::SampleRateShading], )?; - self.decorate(id, Decoration::Sample, &[]); + others.push(Decoration::Sample); } } } - if let Some(blend_src) = blend_src { - self.decorate(id, Decoration::Index, &[blend_src]); - } + Ok(BindingDecorations::Location { + location, + others, + blend_src, + }) } crate::Binding::BuiltIn(built_in) => { use crate::BuiltIn as Bi; + let mut others = ArrayVec::new(); let built_in = match built_in { Bi::Position { invariant } => { if invariant { - self.decorate(id, Decoration::Invariant, &[]); + others.push(Decoration::Invariant); } if class == spirv::StorageClass::Output { @@ -2157,11 +2275,9 @@ impl Writer { Bi::LineIndices => BuiltIn::PrimitiveLineIndicesEXT, Bi::TriangleIndices => BuiltIn::PrimitiveTriangleIndicesEXT, // No decoration, this EmitMeshTasksEXT is called at function return - Bi::MeshTaskSize => return Ok(id), + Bi::MeshTaskSize => return Ok(BindingDecorations::None), }; - self.decorate(id, Decoration::BuiltIn, &[built_in as u32]); - use crate::ScalarKind as Sk; // Per the Vulkan spec, `VUID-StandaloneSpirv-Flat-04744`: @@ -2185,13 +2301,109 @@ impl Writer { }; if is_flat { - self.decorate(id, Decoration::Flat, &[]); + others.push(Decoration::Flat); } } + Ok(BindingDecorations::BuiltIn(built_in, others)) } } + } - Ok(id) + /// Returns the id of the variable, and the type of the array + pub fn mesh_shader_output_variable( + &mut self, + ir_module: &crate::Module, + output_type: Handle, + is_primitive: bool, + array_len: Word, + ) -> Result { + let type_id = self.get_handle_type_id(output_type); + let ptr_type_id = self.get_handle_pointer_type_id(output_type, spirv::StorageClass::Output); + let u32_type_id = self.get_u32_type_id(); + let entry = if is_primitive { + self.mesh_state.primitive_outputs_by_type.entry(output_type) + } else { + self.mesh_state.vertex_outputs_by_type.entry(output_type) + }; + let out = match entry { + Entry::Occupied(value) => { + // This is the hacky part lol. We want to make sure the array size is the largest max output + // of any of the entry points. + let val = *value.get(); + let len_ref = &mut self.logical_layout.declarations[val.index_of_length_decl]; + *len_ref = (*len_ref).max(array_len); + val + } + Entry::Vacant(entry) => { + // We write the literal, and avoid caching as it might change lol + let len_value_id = self.id_gen.next(); + Instruction::constant_32bit(u32_type_id, len_value_id, array_len) + .to_words(&mut self.logical_layout.declarations); + // This is the best part + let len_literal_idx = self.logical_layout.declarations.len() - 1; + + // We generate the array and pointer types here, even if they weren't in the module's type arena + let array_type_id = self.id_gen.next(); + Instruction::type_array(array_type_id, type_id, len_value_id) + .to_words(&mut self.logical_layout.declarations); + let array_ptr_type_id = self.id_gen.next(); + Instruction::type_pointer( + array_ptr_type_id, + spirv::StorageClass::Output, + array_type_id, + ) + .to_words(&mut self.logical_layout.declarations); + + // Create the actual variable + let var_id = self.id_gen.next(); + if self.flags.contains(WriterFlags::DEBUG) { + if let Some(ref name) = ir_module.types[output_type].name { + self.debugs.push(Instruction::name(var_id, name)); + } + } + Instruction::variable(array_ptr_type_id, var_id, spirv::StorageClass::Output, None) + .to_words(&mut self.logical_layout.declarations); + if is_primitive { + Instruction::decorate(var_id, spirv::Decoration::PerPrimitiveEXT, &[]) + .to_words(&mut self.logical_layout.annotations); + } + + let info = super::MeshOutputInfo { + index_of_length_decl: len_literal_idx, + array_type: array_type_id, + var_id, + inner_type: type_id, + ptr_type: ptr_type_id, + array_ptr_type: array_ptr_type_id, + }; + entry.insert(info); + + if let crate::TypeInner::Struct { ref members, .. } = + ir_module.types[output_type].inner + { + for (idx, member) in members.iter().enumerate() { + if member.binding.is_none() { + continue; + } + let binding = self.map_binding( + ir_module, + crate::ShaderStage::Mesh, + spirv::StorageClass::Output, + member.ty, + member.binding.as_ref().unwrap(), + )?; + self.write_binding_struct_member(type_id, idx as Word, binding); + } + } else { + unreachable!("Mesh output type isn't a struct"); + } + self.decorate(type_id, spirv::Decoration::Block, &[]); + + info + } + }; + + Ok(out) } fn write_global_variable( @@ -2490,8 +2702,7 @@ impl Writer { .to_words(&mut self.logical_layout.extensions); } if has_mesh_shaders { - Instruction::extension("SPV_EXT_mesh_shader") - .to_words(&mut self.logical_layout.extensions); + self.use_extension("SPV_EXT_mesh_shader"); self.require_any("Mesh Shaders", &[spirv::Capability::MeshShadingEXT])?; let lang_version = self.lang_version(); if lang_version.0 <= 1 && lang_version.1 < 4 { diff --git a/naga/src/front/wgsl/lower/mod.rs b/naga/src/front/wgsl/lower/mod.rs index 4bb3c44afbc..9a64e33ad7f 100644 --- a/naga/src/front/wgsl/lower/mod.rs +++ b/naga/src/front/wgsl/lower/mod.rs @@ -3259,6 +3259,11 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { }; let rctx = ctx.runtime_expression_ctx(span)?; + + // TODO: fix this + // Emit all previous expressions, even if not used directly + rctx.block + .extend(rctx.emitter.finish(&rctx.function.expressions)); rctx.block.push( crate::Statement::MeshFunction(match function.name { "setMeshOutputs" => crate::MeshFunction::SetMeshOutputs { @@ -3277,6 +3282,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { }), span, ); + rctx.emitter.start(&rctx.function.expressions); return Ok(None); } diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index 59a4ed653aa..1d243435b49 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -139,6 +139,8 @@ pub enum EntryPointError { UnexpectedMeshShaderEntryResult, #[error("Task shader entry point must return @builtin(mesh_task_size) vec3")] WrongTaskShaderEntryResult, + #[error("Mesh output type must be a user-defined struct")] + InvalidMeshOutputType, } fn storage_usage(access: crate::StorageAccess) -> GlobalUse { @@ -933,6 +935,27 @@ impl super::Validator { .with_span_handle(mesh_info.vertex_output_type, &module.types)); } } + if let Some(used_primitive_type) = info.mesh_shader_info.primitive_type { + if used_primitive_type.0 != mesh_info.primitive_output_type { + return Err(EntryPointError::WrongMeshOutputType + .with_span_handle(mesh_info.primitive_output_type, &module.types)); + } + } + + if !matches!( + module.types[mesh_info.vertex_output_type].inner, + crate::TypeInner::Struct { .. } + ) { + return Err(EntryPointError::InvalidMeshOutputType + .with_span_handle(mesh_info.vertex_output_type, &module.types)); + } + if !matches!( + module.types[mesh_info.primitive_output_type].inner, + crate::TypeInner::Struct { .. } + ) { + return Err(EntryPointError::InvalidMeshOutputType + .with_span_handle(mesh_info.primitive_output_type, &module.types)); + } } else if info.mesh_shader_info.vertex_type.is_some() || info.mesh_shader_info.primitive_type.is_some() { From cef766ad8d7833d8af5c939152890f8694645654 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Mon, 14 Jul 2025 00:46:21 -0500 Subject: [PATCH 45/84] HAHAHAH YEASSS --- naga/src/back/spv/block.rs | 44 +++++++--- naga/src/back/spv/mod.rs | 13 ++- naga/src/back/spv/writer.rs | 170 +++++++++++++++++++++++++++++++++--- 3 files changed, 200 insertions(+), 27 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 0f47acdd4e9..908ce960bdc 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -3704,17 +3704,41 @@ impl BlockContext<'_> { 0, )?; - let var_ptr = self.gen_id(); - block.body.push(Instruction::access_chain( - info.ptr_type, - var_ptr, - info.var_id, - &[self.cached[index]], - )); + let mut builtin_idx = 0; + let mut location_idx = 0; + for (i, member) in info.fields.iter().enumerate() { + let member_ty = self.writer.get_handle_type_id(member.ty); + let (array, idx) = match member.binding { + Some(crate::Binding::BuiltIn(_)) => { + builtin_idx += 1; + (info.builtin_output.unwrap(), builtin_idx - 1) + } + Some(crate::Binding::Location { .. }) => { + location_idx += 1; + (info.location_output.unwrap(), location_idx - 1) + } + None => continue, + }; - block - .body - .push(Instruction::store(var_ptr, self.cached[value], None)); + let idx_const = self.writer.get_constant_scalar(crate::Literal::U32(idx)); + let in_value_id = self.gen_id(); + block.body.push(Instruction::composite_extract( + member_ty, + in_value_id, + self.cached[value], + &[i as Word], + )); + let out_ptr_id = self.gen_id(); + block.body.push(Instruction::access_chain( + self.get_pointer_type_id(member_ty, spirv::StorageClass::Output), + out_ptr_id, + array.var_id, + &[self.cached[index], idx_const], + )); + block + .body + .push(Instruction::store(out_ptr_id, in_value_id, None)); + } } Statement::SubgroupBallot { result, diff --git a/naga/src/back/spv/mod.rs b/naga/src/back/spv/mod.rs index aff78b37119..fd48d64b38e 100644 --- a/naga/src/back/spv/mod.rs +++ b/naga/src/back/spv/mod.rs @@ -922,7 +922,7 @@ pub struct WriteMeshInfo { pub primitive_outputs_by_type: crate::FastHashMap, MeshOutputInfo>, } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MeshOutputInfo { /// The index of the word that specifies the length of the global variable array. This is very hacky lol /// We want to allow the same global variable to be used across entry points of the same output type @@ -930,9 +930,16 @@ pub struct MeshOutputInfo { /// of the max output sizes among all the entry points! It will default to zero, so that if an unused function /// tries to write to it, the function can still be valid if it is never called. pub index_of_length_decl: usize, + pub inner_type: Word, + // Structs with elements with layout can't have elements with builtins, and vice versa. + // Therefore, we separate it into 2 structs and whatnot + pub builtin_output: Option, + pub location_output: Option, + pub fields: Vec, +} +#[derive(Clone, Copy)] +pub struct MeshOutputArrayInfo { pub inner_type: Word, pub array_type: Word, - pub ptr_type: Word, - pub array_ptr_type: Word, pub var_id: Word, } diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 6ee63a40843..d8ed7e09292 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -919,18 +919,30 @@ impl Writer { .push(self.global_variables[task_payload].var_id); } if let Some(ref mesh_info) = iface.mesh_info { - self.mesh_shader_output_variable( + let vert_info = self.mesh_shader_output_variable( ir_module, mesh_info.vertex_output_type, false, mesh_info.max_vertices, )?; - self.mesh_shader_output_variable( + let prim_info = self.mesh_shader_output_variable( ir_module, mesh_info.primitive_output_type, true, mesh_info.max_primitives, )?; + + for info in [ + &vert_info.location_output, + &vert_info.builtin_output, + &prim_info.location_output, + &prim_info.builtin_output, + ] + .into_iter() + .flatten() + { + iface.varying_ids.push(info.var_id); + } } } @@ -2317,33 +2329,163 @@ impl Writer { is_primitive: bool, array_len: Word, ) -> Result { - let type_id = self.get_handle_type_id(output_type); - let ptr_type_id = self.get_handle_pointer_type_id(output_type, spirv::StorageClass::Output); - let u32_type_id = self.get_u32_type_id(); let entry = if is_primitive { - self.mesh_state.primitive_outputs_by_type.entry(output_type) + self.mesh_state.primitive_outputs_by_type.get(&output_type) } else { - self.mesh_state.vertex_outputs_by_type.entry(output_type) + self.mesh_state.vertex_outputs_by_type.get(&output_type) }; + // We need mutable access to `self` let out = match entry { - Entry::Occupied(value) => { + Some(value) => { // This is the hacky part lol. We want to make sure the array size is the largest max output - // of any of the entry points. - let val = *value.get(); + // of any of the entry points.get + let val = value.clone(); let len_ref = &mut self.logical_layout.declarations[val.index_of_length_decl]; *len_ref = (*len_ref).max(array_len); val } - Entry::Vacant(entry) => { + None => { // We write the literal, and avoid caching as it might change lol let len_value_id = self.id_gen.next(); - Instruction::constant_32bit(u32_type_id, len_value_id, array_len) + let main_type_id = self.get_handle_type_id(output_type); + Instruction::constant_32bit(self.get_u32_type_id(), len_value_id, array_len) .to_words(&mut self.logical_layout.declarations); // This is the best part let len_literal_idx = self.logical_layout.declarations.len() - 1; + let main_ty_ir = &ir_module.types[output_type]; + let struct_members = match main_ty_ir.inner { + crate::TypeInner::Struct { ref members, .. } => members.clone(), + _ => unreachable!("Mesh output type isn't a struct"), + }; + + let (location_type_id, builtin_type_id) = { + let mut location_type_id = None; + let mut builtin_type_id = None; + let mut location_ins = Instruction::type_struct(0, &[]); + let mut builtin_ins = Instruction::type_struct(0, &[]); + for member in &struct_members { + let binding = if let &Some(ref b) = &member.binding { + b + } else { + continue; + }; + let (subset_type_id, member_idx) = + if matches!(binding, &crate::Binding::Location { .. }) { + if location_type_id.is_none() { + location_type_id = Some(self.id_gen.next()); + location_ins.result_id = location_type_id; + } + location_ins.add_operand(self.get_handle_type_id(member.ty)); + (location_type_id.unwrap(), location_ins.operands.len() - 1) + } else if matches!(binding, &crate::Binding::BuiltIn(..)) { + if builtin_type_id.is_none() { + builtin_type_id = Some(self.id_gen.next()); + builtin_ins.result_id = builtin_type_id; + } + builtin_ins.add_operand(self.get_handle_type_id(member.ty)); + (builtin_type_id.unwrap(), builtin_ins.operands.len() - 1) + } else { + unreachable!() + }; + // TODO: update the offset + self.decorate_struct_member( + subset_type_id, + member_idx, + member, + &ir_module.types, + )?; + let binding = self.map_binding( + ir_module, + crate::ShaderStage::Mesh, + spirv::StorageClass::Output, + member.ty, + member.binding.as_ref().unwrap(), + )?; + self.write_binding_struct_member( + subset_type_id, + member_idx as Word, + binding, + ); + } + if let Some(location_type_id) = location_type_id { + location_ins.result_id = Some(location_type_id); + location_ins.to_words(&mut self.logical_layout.declarations); + self.decorate(location_type_id, spirv::Decoration::Block, &[]); + if self.flags.contains(WriterFlags::DEBUG) { + if let Some(ref name) = main_ty_ir.name { + let mut n = String::new(); + n.push_str("__"); + n.push_str(name); + n.push_str("_LocationOutputs"); + self.debugs.push(Instruction::name(location_type_id, &n)); + } + } + } + if let Some(builtin_type_id) = builtin_type_id { + builtin_ins.result_id = Some(builtin_type_id); + builtin_ins.to_words(&mut self.logical_layout.declarations); + self.decorate(builtin_type_id, spirv::Decoration::Block, &[]); + if self.flags.contains(WriterFlags::DEBUG) { + if let Some(ref name) = main_ty_ir.name { + let mut n = String::new(); + n.push_str("__"); + n.push_str(name); + n.push_str("_BuiltinOutputs"); + self.debugs.push(Instruction::name(builtin_type_id, &n)); + } + } + } + (location_type_id, builtin_type_id) + }; + + let mut to_array_info = |base_id| { + let array_type = self.id_gen.next(); + Instruction::type_array(array_type, base_id, len_value_id) + .to_words(&mut self.logical_layout.declarations); + let var_id = self.id_gen.next(); + Instruction::variable( + self.get_pointer_type_id(array_type, spirv::StorageClass::Output), + var_id, + spirv::StorageClass::Output, + None, + ) + .to_words(&mut self.logical_layout.declarations); + + if is_primitive { + self.decorate(var_id, spirv::Decoration::PerPrimitiveEXT, &[]); + } + + super::MeshOutputArrayInfo { + inner_type: base_id, + array_type, + var_id, + } + }; + + let location_output = location_type_id.map(&mut to_array_info); + let builtin_output = builtin_type_id.map(to_array_info); + + let info = super::MeshOutputInfo { + inner_type: main_type_id, + index_of_length_decl: len_literal_idx, + fields: struct_members, + builtin_output, + location_output, + }; + if is_primitive { + self.mesh_state + .primitive_outputs_by_type + .insert(output_type, info.clone()); + } else { + self.mesh_state + .vertex_outputs_by_type + .insert(output_type, info.clone()); + }; + info + // We generate the array and pointer types here, even if they weren't in the module's type arena - let array_type_id = self.id_gen.next(); + /*let array_type_id = self.id_gen.next(); Instruction::type_array(array_type_id, type_id, len_value_id) .to_words(&mut self.logical_layout.declarations); let array_ptr_type_id = self.id_gen.next(); @@ -2399,7 +2541,7 @@ impl Writer { } self.decorate(type_id, spirv::Decoration::Block, &[]); - info + info*/ } }; From 072391f85319154df8fba16eee40a1c6828682d4 Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Sun, 13 Jul 2025 23:02:42 -0700 Subject: [PATCH 46/84] Updated snapshots --- .../spv/wgsl-6438-conflicting-idents.spvasm | 26 +- naga/tests/out/spv/wgsl-clip-distances.spvasm | 4 +- .../spv/wgsl-debug-symbol-large-source.spvasm | 562 +++++++++--------- .../out/spv/wgsl-debug-symbol-terrain.spvasm | 562 +++++++++--------- naga/tests/out/spv/wgsl-dualsource.spvasm | 4 +- .../out/spv/wgsl-interface.fragment.spvasm | 7 +- .../out/spv/wgsl-interface.vertex.spvasm | 6 +- .../wgsl-interface.vertex_two_structs.spvasm | 2 +- .../out/spv/wgsl-interpolate_compat.spvasm | 141 ++--- naga/tests/out/spv/wgsl-quad.spvasm | 84 ++- naga/tests/out/spv/wgsl-shadow.spvasm | 445 +++++++------- naga/tests/out/spv/wgsl-skybox.spvasm | 54 +- 12 files changed, 926 insertions(+), 971 deletions(-) diff --git a/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm b/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm index f7f7a8a2ef4..4d306c2a056 100644 --- a/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm +++ b/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm @@ -1,19 +1,19 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 38 +; Bound: 36 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %14 "vs" %8 %11 %11 %13 %13 -OpEntryPoint Fragment %35 "fs" %33 -OpExecutionMode %35 OriginUpperLeft +OpEntryPoint Fragment %33 "fs" %31 +OpExecutionMode %33 OriginUpperLeft OpMemberDecorate %6 0 Offset 0 OpMemberDecorate %6 1 Offset 16 OpDecorate %8 Location 0 OpDecorate %11 BuiltIn Position OpDecorate %13 Location 0 -OpDecorate %33 Location 0 +OpDecorate %31 Location 0 %2 = OpTypeVoid %4 = OpTypeFloat 32 %3 = OpTypeVector %4 4 @@ -32,9 +32,9 @@ OpDecorate %33 Location 0 %22 = OpTypePointer Function %3 %25 = OpTypeInt 32 0 %24 = OpConstant %25 0 -%34 = OpTypePointer Output %3 -%33 = OpVariable %34 Output -%36 = OpConstantComposite %3 %17 %16 %16 %17 +%32 = OpTypePointer Output %3 +%31 = OpVariable %32 Output +%34 = OpConstantComposite %3 %17 %16 %16 %17 %14 = OpFunction %2 None %15 %7 = OpLabel %18 = OpVariable %19 Function %20 @@ -49,14 +49,12 @@ OpStore %26 %23 OpStore %11 %28 %29 = OpCompositeExtract %5 %27 1 OpStore %13 %29 -%30 = OpCompositeExtract %3 %27 0 -%31 = OpCompositeExtract %5 %27 1 OpReturn OpFunctionEnd -%35 = OpFunction %2 None %15 -%32 = OpLabel -OpBranch %37 -%37 = OpLabel -OpStore %33 %36 +%33 = OpFunction %2 None %15 +%30 = OpLabel +OpBranch %35 +%35 = OpLabel +OpStore %31 %34 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-clip-distances.spvasm b/naga/tests/out/spv/wgsl-clip-distances.spvasm index 92ba74820e8..9f400a70bf9 100644 --- a/naga/tests/out/spv/wgsl-clip-distances.spvasm +++ b/naga/tests/out/spv/wgsl-clip-distances.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 29 +; Bound: 27 OpCapability Shader OpCapability ClipDistance %1 = OpExtInstImport "GLSL.std.450" @@ -41,7 +41,5 @@ OpStore %23 %15 OpStore %10 %25 %26 = OpCompositeExtract %5 %24 1 OpStore %12 %26 -%27 = OpCompositeExtract %4 %24 0 -%28 = OpCompositeExtract %5 %24 1 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm b/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm index 4e190a78a86..bb2b9a534b9 100644 --- a/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm +++ b/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm @@ -1,19 +1,19 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 690 +; Bound: 682 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %367 "gen_terrain_compute" %364 OpEntryPoint Vertex %442 "gen_terrain_vertex" %435 %438 %438 %440 %440 %441 %441 -OpEntryPoint Fragment %497 "gen_terrain_fragment" %486 %488 %491 %494 %494 %496 %496 -OpEntryPoint Vertex %594 "vs_main" %585 %588 %590 %590 %592 %592 %593 %593 -OpEntryPoint Fragment %623 "fs_main" %615 %617 %619 %621 +OpEntryPoint Fragment %494 "gen_terrain_fragment" %483 %485 %488 %491 %491 %493 %493 +OpEntryPoint Vertex %589 "vs_main" %580 %583 %585 %585 %587 %587 %588 %588 +OpEntryPoint Fragment %615 "fs_main" %607 %609 %611 %613 OpExecutionMode %367 LocalSize 64 1 1 -OpExecutionMode %497 OriginUpperLeft -OpExecutionMode %623 OriginUpperLeft +OpExecutionMode %494 OriginUpperLeft +OpExecutionMode %615 OriginUpperLeft %3 = OpString "debug-symbol-large-source.wgsl" OpSource Unknown 0 %3 "//This is a test 这是测试 これはテストだ 테스트입니다 This is a test 这是测试 これはテストだ 테스트입니다 This is a test 这是测试 これはテストだ 테스트입니다 //This is a test 这是测试 これはテストだ 테스트입니다 This is a test 这是测试 これはテストだ 테스트입니다 This is a test 这是测试 これはテストだ 테스트입니다 @@ -7569,25 +7569,25 @@ OpName %438 "index" OpName %440 "position" OpName %441 "uv" OpName %442 "gen_terrain_vertex" -OpName %486 "index" -OpName %488 "position" -OpName %491 "uv" -OpName %494 "vert_component" -OpName %496 "index" -OpName %497 "gen_terrain_fragment" -OpName %500 "vert_component" -OpName %501 "index" -OpName %585 "position" -OpName %588 "normal" -OpName %590 "clip_position" -OpName %592 "normal" -OpName %593 "world_pos" -OpName %594 "vs_main" -OpName %615 "clip_position" -OpName %617 "normal" -OpName %619 "world_pos" -OpName %623 "fs_main" -OpName %637 "color" +OpName %483 "index" +OpName %485 "position" +OpName %488 "uv" +OpName %491 "vert_component" +OpName %493 "index" +OpName %494 "gen_terrain_fragment" +OpName %497 "vert_component" +OpName %498 "index" +OpName %580 "position" +OpName %583 "normal" +OpName %585 "clip_position" +OpName %587 "normal" +OpName %588 "world_pos" +OpName %589 "vs_main" +OpName %607 "clip_position" +OpName %609 "normal" +OpName %611 "world_pos" +OpName %615 "fs_main" +OpName %629 "color" OpMemberDecorate %13 0 Offset 0 OpMemberDecorate %13 1 Offset 8 OpMemberDecorate %13 2 Offset 16 @@ -7652,21 +7652,21 @@ OpDecorate %438 Location 0 OpDecorate %438 Flat OpDecorate %440 BuiltIn Position OpDecorate %441 Location 1 -OpDecorate %486 Location 0 -OpDecorate %486 Flat -OpDecorate %488 BuiltIn FragCoord -OpDecorate %491 Location 1 -OpDecorate %494 Location 0 -OpDecorate %496 Location 1 -OpDecorate %585 Location 0 +OpDecorate %483 Location 0 +OpDecorate %483 Flat +OpDecorate %485 BuiltIn FragCoord +OpDecorate %488 Location 1 +OpDecorate %491 Location 0 +OpDecorate %493 Location 1 +OpDecorate %580 Location 0 +OpDecorate %583 Location 1 +OpDecorate %585 BuiltIn Position +OpDecorate %587 Location 0 OpDecorate %588 Location 1 -OpDecorate %590 BuiltIn Position -OpDecorate %592 Location 0 -OpDecorate %593 Location 1 -OpDecorate %615 BuiltIn FragCoord -OpDecorate %617 Location 0 -OpDecorate %619 Location 1 -OpDecorate %621 Location 0 +OpDecorate %607 BuiltIn FragCoord +OpDecorate %609 Location 0 +OpDecorate %611 Location 1 +OpDecorate %613 Location 0 %2 = OpTypeVoid %4 = OpTypeFloat 32 %5 = OpTypeVector %4 3 @@ -7807,39 +7807,39 @@ OpDecorate %621 Location 0 %445 = OpConstant %4 -1.0 %446 = OpConstantComposite %6 %445 %445 %471 = OpConstant %4 4294967000.0 -%486 = OpVariable %436 Input -%489 = OpTypePointer Input %7 +%483 = OpVariable %436 Input +%486 = OpTypePointer Input %7 +%485 = OpVariable %486 Input +%489 = OpTypePointer Input %6 %488 = OpVariable %489 Input -%492 = OpTypePointer Input %6 -%491 = OpVariable %492 Input -%495 = OpTypePointer Output %22 -%494 = OpVariable %495 Output -%496 = OpVariable %495 Output -%499 = OpConstant %4 6.0 -%586 = OpTypePointer Input %5 -%585 = OpVariable %586 Input -%588 = OpVariable %586 Input -%591 = OpTypePointer Output %26 -%590 = OpVariable %591 Output -%592 = OpVariable %591 Output -%593 = OpVariable %591 Output -%595 = OpTypePointer Uniform %24 -%598 = OpTypePointer Uniform %23 -%615 = OpVariable %489 Input -%617 = OpVariable %586 Input -%619 = OpVariable %586 Input -%622 = OpTypePointer Output %7 -%621 = OpVariable %622 Output -%625 = OpTypePointer Uniform %25 -%631 = OpConstantComposite %6 %56 %81 -%632 = OpConstantComposite %5 %286 %286 %286 -%633 = OpConstant %4 0.7 -%634 = OpConstantComposite %5 %78 %286 %633 -%635 = OpConstant %4 0.2 -%636 = OpConstantComposite %5 %635 %635 %635 -%638 = OpConstantNull %5 -%654 = OpTypePointer Uniform %5 -%663 = OpTypePointer Uniform %7 +%492 = OpTypePointer Output %22 +%491 = OpVariable %492 Output +%493 = OpVariable %492 Output +%496 = OpConstant %4 6.0 +%581 = OpTypePointer Input %5 +%580 = OpVariable %581 Input +%583 = OpVariable %581 Input +%586 = OpTypePointer Output %26 +%585 = OpVariable %586 Output +%587 = OpVariable %586 Output +%588 = OpVariable %586 Output +%590 = OpTypePointer Uniform %24 +%593 = OpTypePointer Uniform %23 +%607 = OpVariable %486 Input +%609 = OpVariable %581 Input +%611 = OpVariable %581 Input +%614 = OpTypePointer Output %7 +%613 = OpVariable %614 Output +%617 = OpTypePointer Uniform %25 +%623 = OpConstantComposite %6 %56 %81 +%624 = OpConstantComposite %5 %286 %286 %286 +%625 = OpConstant %4 0.7 +%626 = OpConstantComposite %5 %78 %286 %625 +%627 = OpConstant %4 0.2 +%628 = OpConstantComposite %5 %627 %627 %627 +%630 = OpConstantNull %5 +%646 = OpTypePointer Uniform %5 +%655 = OpTypePointer Uniform %7 %53 = OpFunction %5 None %54 %52 = OpFunctionParameter %5 %51 = OpLabel @@ -8407,291 +8407,283 @@ OpStore %438 %478 OpStore %440 %479 %480 = OpCompositeExtract %6 %477 2 OpStore %441 %480 -%481 = OpCompositeExtract %8 %477 0 -%482 = OpCompositeExtract %7 %477 1 -%483 = OpCompositeExtract %6 %477 2 OpReturn OpFunctionEnd -%497 = OpFunction %2 None %368 -%484 = OpLabel -%500 = OpVariable %125 Function %74 -%501 = OpVariable %217 Function %135 -%487 = OpLoad %8 %486 -%490 = OpLoad %7 %488 -%493 = OpLoad %6 %491 -%485 = OpCompositeConstruct %21 %487 %490 %493 -%498 = OpAccessChain %443 %36 %135 -OpBranch %502 -%502 = OpLabel +%494 = OpFunction %2 None %368 +%481 = OpLabel +%497 = OpVariable %125 Function %74 +%498 = OpVariable %217 Function %135 +%484 = OpLoad %8 %483 +%487 = OpLoad %7 %485 +%490 = OpLoad %6 %488 +%482 = OpCompositeConstruct %21 %484 %487 %490 +%495 = OpAccessChain %443 %36 %135 +OpBranch %499 +%499 = OpLabel OpLine %3 7324 17 -%503 = OpCompositeExtract %6 %485 2 -%504 = OpCompositeExtract %4 %503 0 +%500 = OpCompositeExtract %6 %482 2 +%501 = OpCompositeExtract %4 %500 0 OpLine %3 7324 17 -%505 = OpAccessChain %393 %498 %373 -%506 = OpLoad %8 %505 -%507 = OpConvertUToF %4 %506 -%508 = OpFMul %4 %504 %507 -%509 = OpCompositeExtract %6 %485 2 -%510 = OpCompositeExtract %4 %509 1 +%502 = OpAccessChain %393 %495 %373 +%503 = OpLoad %8 %502 +%504 = OpConvertUToF %4 %503 +%505 = OpFMul %4 %501 %504 +%506 = OpCompositeExtract %6 %482 2 +%507 = OpCompositeExtract %4 %506 1 OpLine %3 7324 70 -%511 = OpAccessChain %393 %498 %373 -%512 = OpLoad %8 %511 +%508 = OpAccessChain %393 %495 %373 +%509 = OpLoad %8 %508 OpLine %3 7324 13 -%513 = OpAccessChain %393 %498 %373 -%514 = OpLoad %8 %513 -%515 = OpIMul %8 %512 %514 -%516 = OpConvertUToF %4 %515 -%517 = OpFMul %4 %510 %516 -%518 = OpFAdd %4 %508 %517 -%519 = OpExtInst %4 %1 FClamp %518 %74 %471 -%520 = OpConvertFToU %8 %519 +%510 = OpAccessChain %393 %495 %373 +%511 = OpLoad %8 %510 +%512 = OpIMul %8 %509 %511 +%513 = OpConvertUToF %4 %512 +%514 = OpFMul %4 %507 %513 +%515 = OpFAdd %4 %505 %514 +%516 = OpExtInst %4 %1 FClamp %515 %74 %471 +%517 = OpConvertFToU %8 %516 OpLine %3 7324 13 -%521 = OpAccessChain %393 %498 %374 -%522 = OpLoad %8 %521 -%523 = OpIAdd %8 %520 %522 +%518 = OpAccessChain %393 %495 %374 +%519 = OpLoad %8 %518 +%520 = OpIAdd %8 %517 %519 OpLine %3 7325 32 -%524 = OpConvertUToF %4 %523 +%521 = OpConvertUToF %4 %520 OpLine %3 7325 22 -%525 = OpFDiv %4 %524 %499 -%526 = OpExtInst %4 %1 Floor %525 -%527 = OpExtInst %4 %1 FClamp %526 %74 %471 -%528 = OpConvertFToU %8 %527 +%522 = OpFDiv %4 %521 %496 +%523 = OpExtInst %4 %1 Floor %522 +%524 = OpExtInst %4 %1 FClamp %523 %74 %471 +%525 = OpConvertFToU %8 %524 OpLine %3 7326 22 -%529 = OpFunctionCall %8 %427 %523 %371 +%526 = OpFunctionCall %8 %427 %520 %371 OpLine %3 7328 36 -%530 = OpAccessChain %377 %498 %135 -%531 = OpLoad %10 %530 +%527 = OpAccessChain %377 %495 %135 +%528 = OpLoad %10 %527 OpLine %3 7328 57 -%532 = OpAccessChain %380 %498 %126 -%533 = OpLoad %11 %532 +%529 = OpAccessChain %380 %495 %126 +%530 = OpLoad %11 %529 OpLine %3 7328 13 -%534 = OpFunctionCall %6 %325 %528 %531 %533 +%531 = OpFunctionCall %6 %325 %525 %528 %530 OpLine %3 7329 31 -%535 = OpAccessChain %386 %498 %372 -%536 = OpLoad %6 %535 +%532 = OpAccessChain %386 %495 %372 +%533 = OpLoad %6 %532 OpLine %3 7329 13 -%537 = OpFunctionCall %14 %284 %534 %536 +%534 = OpFunctionCall %14 %284 %531 %533 OpLine %3 7333 5 -OpSelectionMerge %538 None -OpSwitch %529 %545 0 %539 1 %540 2 %541 3 %542 4 %543 5 %544 -%539 = OpLabel +OpSelectionMerge %535 None +OpSwitch %526 %542 0 %536 1 %537 2 %538 3 %539 4 %540 5 %541 +%536 = OpLabel OpLine %3 7334 37 -%546 = OpCompositeExtract %5 %537 0 -%547 = OpCompositeExtract %4 %546 0 +%543 = OpCompositeExtract %5 %534 0 +%544 = OpCompositeExtract %4 %543 0 OpLine %3 7334 20 -OpStore %500 %547 -OpBranch %538 -%540 = OpLabel +OpStore %497 %544 +OpBranch %535 +%537 = OpLabel OpLine %3 7335 37 -%548 = OpCompositeExtract %5 %537 0 -%549 = OpCompositeExtract %4 %548 1 +%545 = OpCompositeExtract %5 %534 0 +%546 = OpCompositeExtract %4 %545 1 OpLine %3 7335 20 -OpStore %500 %549 -OpBranch %538 -%541 = OpLabel +OpStore %497 %546 +OpBranch %535 +%538 = OpLabel OpLine %3 7336 37 -%550 = OpCompositeExtract %5 %537 0 -%551 = OpCompositeExtract %4 %550 2 +%547 = OpCompositeExtract %5 %534 0 +%548 = OpCompositeExtract %4 %547 2 OpLine %3 7336 20 -OpStore %500 %551 -OpBranch %538 -%542 = OpLabel +OpStore %497 %548 +OpBranch %535 +%539 = OpLabel OpLine %3 7337 37 -%552 = OpCompositeExtract %5 %537 1 -%553 = OpCompositeExtract %4 %552 0 +%549 = OpCompositeExtract %5 %534 1 +%550 = OpCompositeExtract %4 %549 0 OpLine %3 7337 20 -OpStore %500 %553 -OpBranch %538 -%543 = OpLabel +OpStore %497 %550 +OpBranch %535 +%540 = OpLabel OpLine %3 7338 37 -%554 = OpCompositeExtract %5 %537 1 -%555 = OpCompositeExtract %4 %554 1 +%551 = OpCompositeExtract %5 %534 1 +%552 = OpCompositeExtract %4 %551 1 OpLine %3 7338 20 -OpStore %500 %555 -OpBranch %538 -%544 = OpLabel +OpStore %497 %552 +OpBranch %535 +%541 = OpLabel OpLine %3 7339 37 -%556 = OpCompositeExtract %5 %537 1 -%557 = OpCompositeExtract %4 %556 2 +%553 = OpCompositeExtract %5 %534 1 +%554 = OpCompositeExtract %4 %553 2 OpLine %3 7339 20 -OpStore %500 %557 -OpBranch %538 -%545 = OpLabel -OpBranch %538 -%538 = OpLabel +OpStore %497 %554 +OpBranch %535 +%542 = OpLabel +OpBranch %535 +%535 = OpLabel OpLine %3 7343 15 -%558 = OpAccessChain %393 %498 %135 %135 -%559 = OpLoad %8 %558 -%560 = OpFunctionCall %8 %313 %528 %559 -%561 = OpIAdd %8 %528 %560 +%555 = OpAccessChain %393 %495 %135 %135 +%556 = OpLoad %8 %555 +%557 = OpFunctionCall %8 %313 %525 %556 +%558 = OpIAdd %8 %525 %557 OpLine %3 7344 15 -%562 = OpIAdd %8 %561 %126 +%559 = OpIAdd %8 %558 %126 OpLine %3 7345 15 -%563 = OpAccessChain %393 %498 %135 %135 -%564 = OpLoad %8 %563 -%565 = OpIAdd %8 %561 %564 +%560 = OpAccessChain %393 %495 %135 %135 +%561 = OpLoad %8 %560 +%562 = OpIAdd %8 %558 %561 OpLine %3 7345 15 -%566 = OpIAdd %8 %565 %126 +%563 = OpIAdd %8 %562 %126 OpLine %3 7346 15 -%567 = OpIAdd %8 %566 %126 +%564 = OpIAdd %8 %563 %126 OpLine %3 7349 5 -OpSelectionMerge %568 None -OpSwitch %529 %573 0 %569 3 %569 2 %570 4 %570 1 %571 5 %572 -%569 = OpLabel +OpSelectionMerge %565 None +OpSwitch %526 %570 0 %566 3 %566 2 %567 4 %567 1 %568 5 %569 +%566 = OpLabel OpLine %3 7350 24 -OpStore %501 %561 -OpBranch %568 -%570 = OpLabel +OpStore %498 %558 +OpBranch %565 +%567 = OpLabel OpLine %3 7351 24 -OpStore %501 %567 -OpBranch %568 -%571 = OpLabel +OpStore %498 %564 +OpBranch %565 +%568 = OpLabel OpLine %3 7352 20 -OpStore %501 %566 -OpBranch %568 -%572 = OpLabel +OpStore %498 %563 +OpBranch %565 +%569 = OpLabel OpLine %3 7353 20 -OpStore %501 %562 -OpBranch %568 -%573 = OpLabel -OpBranch %568 -%568 = OpLabel +OpStore %498 %559 +OpBranch %565 +%570 = OpLabel +OpBranch %565 +%565 = OpLabel OpLine %3 7356 13 -%574 = OpCompositeExtract %8 %485 0 +%571 = OpCompositeExtract %8 %482 0 OpLine %3 7356 5 -OpStore %501 %574 +OpStore %498 %571 OpLine %3 7365 27 -%575 = OpLoad %4 %500 -%576 = OpBitcast %8 %575 +%572 = OpLoad %4 %497 +%573 = OpBitcast %8 %572 OpLine %3 7366 12 -%577 = OpLoad %8 %501 -%578 = OpCompositeConstruct %22 %576 %577 -%579 = OpCompositeExtract %8 %578 0 -OpStore %494 %579 -%580 = OpCompositeExtract %8 %578 1 -OpStore %496 %580 -%581 = OpCompositeExtract %8 %578 0 -%582 = OpCompositeExtract %8 %578 1 +%574 = OpLoad %8 %498 +%575 = OpCompositeConstruct %22 %573 %574 +%576 = OpCompositeExtract %8 %575 0 +OpStore %491 %576 +%577 = OpCompositeExtract %8 %575 1 +OpStore %493 %577 OpReturn OpFunctionEnd -%594 = OpFunction %2 None %368 -%583 = OpLabel -%587 = OpLoad %5 %585 -%589 = OpLoad %5 %588 -%584 = OpCompositeConstruct %14 %587 %589 -%596 = OpAccessChain %595 %39 %135 -OpBranch %597 -%597 = OpLabel +%589 = OpFunction %2 None %368 +%578 = OpLabel +%582 = OpLoad %5 %580 +%584 = OpLoad %5 %583 +%579 = OpCompositeConstruct %14 %582 %584 +%591 = OpAccessChain %590 %39 %135 +OpBranch %592 +%592 = OpLabel OpLine %3 7397 25 -%599 = OpAccessChain %598 %596 %126 -%600 = OpLoad %23 %599 -%601 = OpCompositeExtract %5 %584 0 +%594 = OpAccessChain %593 %591 %126 +%595 = OpLoad %23 %594 +%596 = OpCompositeExtract %5 %579 0 OpLine %3 7397 25 -%602 = OpCompositeConstruct %7 %601 %56 -%603 = OpMatrixTimesVector %7 %600 %602 +%597 = OpCompositeConstruct %7 %596 %56 +%598 = OpMatrixTimesVector %7 %595 %597 OpLine %3 7398 18 -%604 = OpCompositeExtract %5 %584 1 +%599 = OpCompositeExtract %5 %579 1 OpLine %3 7399 12 -%605 = OpCompositeExtract %5 %584 0 -%606 = OpCompositeConstruct %26 %603 %604 %605 -%607 = OpCompositeExtract %7 %606 0 -OpStore %590 %607 -%608 = OpCompositeExtract %5 %606 1 -OpStore %592 %608 -%609 = OpCompositeExtract %5 %606 2 -OpStore %593 %609 -%610 = OpCompositeExtract %7 %606 0 -%611 = OpCompositeExtract %5 %606 1 -%612 = OpCompositeExtract %5 %606 2 +%600 = OpCompositeExtract %5 %579 0 +%601 = OpCompositeConstruct %26 %598 %599 %600 +%602 = OpCompositeExtract %7 %601 0 +OpStore %585 %602 +%603 = OpCompositeExtract %5 %601 1 +OpStore %587 %603 +%604 = OpCompositeExtract %5 %601 2 +OpStore %588 %604 OpReturn OpFunctionEnd -%623 = OpFunction %2 None %368 -%613 = OpLabel -%637 = OpVariable %95 Function %638 -%616 = OpLoad %7 %615 -%618 = OpLoad %5 %617 -%620 = OpLoad %5 %619 -%614 = OpCompositeConstruct %26 %616 %618 %620 -%624 = OpAccessChain %595 %39 %135 -%626 = OpAccessChain %625 %42 %135 -%627 = OpLoad %27 %45 -%628 = OpLoad %28 %47 -%629 = OpLoad %27 %49 -%630 = OpLoad %28 %50 -OpBranch %639 -%639 = OpLabel +%615 = OpFunction %2 None %368 +%605 = OpLabel +%629 = OpVariable %95 Function %630 +%608 = OpLoad %7 %607 +%610 = OpLoad %5 %609 +%612 = OpLoad %5 %611 +%606 = OpCompositeConstruct %26 %608 %610 %612 +%616 = OpAccessChain %590 %39 %135 +%618 = OpAccessChain %617 %42 %135 +%619 = OpLoad %27 %45 +%620 = OpLoad %28 %47 +%621 = OpLoad %27 %49 +%622 = OpLoad %28 %50 +OpBranch %631 +%631 = OpLabel OpLine %3 7426 13 OpLine %3 7426 13 OpLine %3 7426 5 -%640 = OpFunctionCall %5 %342 %631 +%632 = OpFunctionCall %5 %342 %623 OpLine %3 7428 28 OpLine %3 7428 17 -%641 = OpCompositeExtract %5 %614 2 -%642 = OpExtInst %5 %1 Fract %641 -%643 = OpExtInst %5 %1 SmoothStep %80 %632 %642 +%633 = OpCompositeExtract %5 %606 2 +%634 = OpExtInst %5 %1 Fract %633 +%635 = OpExtInst %5 %1 SmoothStep %80 %624 %634 OpLine %3 7428 5 -OpStore %637 %643 +OpStore %629 %635 OpLine %3 7429 17 OpLine %3 7429 13 -%644 = OpAccessChain %125 %637 %135 -%645 = OpLoad %4 %644 -%646 = OpAccessChain %125 %637 %126 -%647 = OpLoad %4 %646 -%648 = OpFMul %4 %645 %647 -%649 = OpAccessChain %125 %637 %372 -%650 = OpLoad %4 %649 -%651 = OpFMul %4 %648 %650 -%652 = OpCompositeConstruct %5 %651 %651 %651 -%653 = OpExtInst %5 %1 FMix %634 %636 %652 +%636 = OpAccessChain %125 %629 %135 +%637 = OpLoad %4 %636 +%638 = OpAccessChain %125 %629 %126 +%639 = OpLoad %4 %638 +%640 = OpFMul %4 %637 %639 +%641 = OpAccessChain %125 %629 %372 +%642 = OpLoad %4 %641 +%643 = OpFMul %4 %640 %642 +%644 = OpCompositeConstruct %5 %643 %643 %643 +%645 = OpExtInst %5 %1 FMix %626 %628 %644 OpLine %3 7429 5 -OpStore %637 %653 +OpStore %629 %645 OpLine %3 7432 25 -%655 = OpAccessChain %654 %626 %126 -%656 = OpLoad %5 %655 -%657 = OpVectorTimesScalar %5 %656 %286 +%647 = OpAccessChain %646 %618 %126 +%648 = OpLoad %5 %647 +%649 = OpVectorTimesScalar %5 %648 %286 OpLine %3 7434 21 -%658 = OpAccessChain %654 %626 %135 -%659 = OpLoad %5 %658 -%660 = OpCompositeExtract %5 %614 2 -%661 = OpFSub %5 %659 %660 -%662 = OpExtInst %5 %1 Normalize %661 +%650 = OpAccessChain %646 %618 %135 +%651 = OpLoad %5 %650 +%652 = OpCompositeExtract %5 %606 2 +%653 = OpFSub %5 %651 %652 +%654 = OpExtInst %5 %1 Normalize %653 OpLine %3 7435 20 -%664 = OpAccessChain %663 %624 %135 -%665 = OpLoad %7 %664 -%666 = OpVectorShuffle %5 %665 %665 0 1 2 -%667 = OpCompositeExtract %5 %614 2 -%668 = OpFSub %5 %666 %667 -%669 = OpExtInst %5 %1 Normalize %668 +%656 = OpAccessChain %655 %616 %135 +%657 = OpLoad %7 %656 +%658 = OpVectorShuffle %5 %657 %657 0 1 2 +%659 = OpCompositeExtract %5 %606 2 +%660 = OpFSub %5 %658 %659 +%661 = OpExtInst %5 %1 Normalize %660 OpLine %3 7436 20 -%670 = OpFAdd %5 %669 %662 -%671 = OpExtInst %5 %1 Normalize %670 +%662 = OpFAdd %5 %661 %654 +%663 = OpExtInst %5 %1 Normalize %662 OpLine %3 7438 32 -%672 = OpCompositeExtract %5 %614 1 -%673 = OpDot %4 %672 %662 +%664 = OpCompositeExtract %5 %606 1 +%665 = OpDot %4 %664 %654 OpLine %3 7438 28 -%674 = OpExtInst %4 %1 FMax %673 %74 +%666 = OpExtInst %4 %1 FMax %665 %74 OpLine %3 7439 25 -%675 = OpAccessChain %654 %626 %126 -%676 = OpLoad %5 %675 -%677 = OpVectorTimesScalar %5 %676 %674 +%667 = OpAccessChain %646 %618 %126 +%668 = OpLoad %5 %667 +%669 = OpVectorTimesScalar %5 %668 %666 OpLine %3 7441 37 -%678 = OpCompositeExtract %5 %614 1 -%679 = OpDot %4 %678 %671 +%670 = OpCompositeExtract %5 %606 1 +%671 = OpDot %4 %670 %663 OpLine %3 7441 33 -%680 = OpExtInst %4 %1 FMax %679 %74 +%672 = OpExtInst %4 %1 FMax %671 %74 OpLine %3 7441 29 -%681 = OpExtInst %4 %1 Pow %680 %345 +%673 = OpExtInst %4 %1 Pow %672 %345 OpLine %3 7442 26 -%682 = OpAccessChain %654 %626 %126 -%683 = OpLoad %5 %682 -%684 = OpVectorTimesScalar %5 %683 %681 +%674 = OpAccessChain %646 %618 %126 +%675 = OpLoad %5 %674 +%676 = OpVectorTimesScalar %5 %675 %673 OpLine %3 7444 18 -%685 = OpFAdd %5 %657 %677 -%686 = OpFAdd %5 %685 %684 -%687 = OpLoad %5 %637 -%688 = OpFMul %5 %686 %687 +%677 = OpFAdd %5 %649 %669 +%678 = OpFAdd %5 %677 %676 +%679 = OpLoad %5 %629 +%680 = OpFMul %5 %678 %679 OpLine %3 7446 12 -%689 = OpCompositeConstruct %7 %688 %56 -OpStore %621 %689 +%681 = OpCompositeConstruct %7 %680 %56 +OpStore %613 %681 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm b/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm index 64e89a55d85..d68a0128dd8 100644 --- a/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm +++ b/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm @@ -1,19 +1,19 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 690 +; Bound: 682 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %367 "gen_terrain_compute" %364 OpEntryPoint Vertex %442 "gen_terrain_vertex" %435 %438 %438 %440 %440 %441 %441 -OpEntryPoint Fragment %497 "gen_terrain_fragment" %486 %488 %491 %494 %494 %496 %496 -OpEntryPoint Vertex %594 "vs_main" %585 %588 %590 %590 %592 %592 %593 %593 -OpEntryPoint Fragment %623 "fs_main" %615 %617 %619 %621 +OpEntryPoint Fragment %494 "gen_terrain_fragment" %483 %485 %488 %491 %491 %493 %493 +OpEntryPoint Vertex %589 "vs_main" %580 %583 %585 %585 %587 %587 %588 %588 +OpEntryPoint Fragment %615 "fs_main" %607 %609 %611 %613 OpExecutionMode %367 LocalSize 64 1 1 -OpExecutionMode %497 OriginUpperLeft -OpExecutionMode %623 OriginUpperLeft +OpExecutionMode %494 OriginUpperLeft +OpExecutionMode %615 OriginUpperLeft %3 = OpString "debug-symbol-terrain.wgsl" OpSource Unknown 0 %3 "// Taken from https://github.com/sotrh/learn-wgpu/blob/11820796f5e1dbce42fb1119f04ddeb4b167d2a0/code/intermediate/tutorial13-terrain/src/terrain.wgsl // ============================ @@ -404,25 +404,25 @@ OpName %438 "index" OpName %440 "position" OpName %441 "uv" OpName %442 "gen_terrain_vertex" -OpName %486 "index" -OpName %488 "position" -OpName %491 "uv" -OpName %494 "vert_component" -OpName %496 "index" -OpName %497 "gen_terrain_fragment" -OpName %500 "vert_component" -OpName %501 "index" -OpName %585 "position" -OpName %588 "normal" -OpName %590 "clip_position" -OpName %592 "normal" -OpName %593 "world_pos" -OpName %594 "vs_main" -OpName %615 "clip_position" -OpName %617 "normal" -OpName %619 "world_pos" -OpName %623 "fs_main" -OpName %637 "color" +OpName %483 "index" +OpName %485 "position" +OpName %488 "uv" +OpName %491 "vert_component" +OpName %493 "index" +OpName %494 "gen_terrain_fragment" +OpName %497 "vert_component" +OpName %498 "index" +OpName %580 "position" +OpName %583 "normal" +OpName %585 "clip_position" +OpName %587 "normal" +OpName %588 "world_pos" +OpName %589 "vs_main" +OpName %607 "clip_position" +OpName %609 "normal" +OpName %611 "world_pos" +OpName %615 "fs_main" +OpName %629 "color" OpMemberDecorate %13 0 Offset 0 OpMemberDecorate %13 1 Offset 8 OpMemberDecorate %13 2 Offset 16 @@ -487,21 +487,21 @@ OpDecorate %438 Location 0 OpDecorate %438 Flat OpDecorate %440 BuiltIn Position OpDecorate %441 Location 1 -OpDecorate %486 Location 0 -OpDecorate %486 Flat -OpDecorate %488 BuiltIn FragCoord -OpDecorate %491 Location 1 -OpDecorate %494 Location 0 -OpDecorate %496 Location 1 -OpDecorate %585 Location 0 +OpDecorate %483 Location 0 +OpDecorate %483 Flat +OpDecorate %485 BuiltIn FragCoord +OpDecorate %488 Location 1 +OpDecorate %491 Location 0 +OpDecorate %493 Location 1 +OpDecorate %580 Location 0 +OpDecorate %583 Location 1 +OpDecorate %585 BuiltIn Position +OpDecorate %587 Location 0 OpDecorate %588 Location 1 -OpDecorate %590 BuiltIn Position -OpDecorate %592 Location 0 -OpDecorate %593 Location 1 -OpDecorate %615 BuiltIn FragCoord -OpDecorate %617 Location 0 -OpDecorate %619 Location 1 -OpDecorate %621 Location 0 +OpDecorate %607 BuiltIn FragCoord +OpDecorate %609 Location 0 +OpDecorate %611 Location 1 +OpDecorate %613 Location 0 %2 = OpTypeVoid %4 = OpTypeFloat 32 %5 = OpTypeVector %4 3 @@ -642,39 +642,39 @@ OpDecorate %621 Location 0 %445 = OpConstant %4 -1.0 %446 = OpConstantComposite %6 %445 %445 %471 = OpConstant %4 4294967000.0 -%486 = OpVariable %436 Input -%489 = OpTypePointer Input %7 +%483 = OpVariable %436 Input +%486 = OpTypePointer Input %7 +%485 = OpVariable %486 Input +%489 = OpTypePointer Input %6 %488 = OpVariable %489 Input -%492 = OpTypePointer Input %6 -%491 = OpVariable %492 Input -%495 = OpTypePointer Output %22 -%494 = OpVariable %495 Output -%496 = OpVariable %495 Output -%499 = OpConstant %4 6.0 -%586 = OpTypePointer Input %5 -%585 = OpVariable %586 Input -%588 = OpVariable %586 Input -%591 = OpTypePointer Output %26 -%590 = OpVariable %591 Output -%592 = OpVariable %591 Output -%593 = OpVariable %591 Output -%595 = OpTypePointer Uniform %24 -%598 = OpTypePointer Uniform %23 -%615 = OpVariable %489 Input -%617 = OpVariable %586 Input -%619 = OpVariable %586 Input -%622 = OpTypePointer Output %7 -%621 = OpVariable %622 Output -%625 = OpTypePointer Uniform %25 -%631 = OpConstantComposite %6 %56 %81 -%632 = OpConstantComposite %5 %286 %286 %286 -%633 = OpConstant %4 0.7 -%634 = OpConstantComposite %5 %78 %286 %633 -%635 = OpConstant %4 0.2 -%636 = OpConstantComposite %5 %635 %635 %635 -%638 = OpConstantNull %5 -%654 = OpTypePointer Uniform %5 -%663 = OpTypePointer Uniform %7 +%492 = OpTypePointer Output %22 +%491 = OpVariable %492 Output +%493 = OpVariable %492 Output +%496 = OpConstant %4 6.0 +%581 = OpTypePointer Input %5 +%580 = OpVariable %581 Input +%583 = OpVariable %581 Input +%586 = OpTypePointer Output %26 +%585 = OpVariable %586 Output +%587 = OpVariable %586 Output +%588 = OpVariable %586 Output +%590 = OpTypePointer Uniform %24 +%593 = OpTypePointer Uniform %23 +%607 = OpVariable %486 Input +%609 = OpVariable %581 Input +%611 = OpVariable %581 Input +%614 = OpTypePointer Output %7 +%613 = OpVariable %614 Output +%617 = OpTypePointer Uniform %25 +%623 = OpConstantComposite %6 %56 %81 +%624 = OpConstantComposite %5 %286 %286 %286 +%625 = OpConstant %4 0.7 +%626 = OpConstantComposite %5 %78 %286 %625 +%627 = OpConstant %4 0.2 +%628 = OpConstantComposite %5 %627 %627 %627 +%630 = OpConstantNull %5 +%646 = OpTypePointer Uniform %5 +%655 = OpTypePointer Uniform %7 %53 = OpFunction %5 None %54 %52 = OpFunctionParameter %5 %51 = OpLabel @@ -1242,291 +1242,283 @@ OpStore %438 %478 OpStore %440 %479 %480 = OpCompositeExtract %6 %477 2 OpStore %441 %480 -%481 = OpCompositeExtract %8 %477 0 -%482 = OpCompositeExtract %7 %477 1 -%483 = OpCompositeExtract %6 %477 2 OpReturn OpFunctionEnd -%497 = OpFunction %2 None %368 -%484 = OpLabel -%500 = OpVariable %125 Function %74 -%501 = OpVariable %217 Function %135 -%487 = OpLoad %8 %486 -%490 = OpLoad %7 %488 -%493 = OpLoad %6 %491 -%485 = OpCompositeConstruct %21 %487 %490 %493 -%498 = OpAccessChain %443 %36 %135 -OpBranch %502 -%502 = OpLabel +%494 = OpFunction %2 None %368 +%481 = OpLabel +%497 = OpVariable %125 Function %74 +%498 = OpVariable %217 Function %135 +%484 = OpLoad %8 %483 +%487 = OpLoad %7 %485 +%490 = OpLoad %6 %488 +%482 = OpCompositeConstruct %21 %484 %487 %490 +%495 = OpAccessChain %443 %36 %135 +OpBranch %499 +%499 = OpLabel OpLine %3 181 17 -%503 = OpCompositeExtract %6 %485 2 -%504 = OpCompositeExtract %4 %503 0 +%500 = OpCompositeExtract %6 %482 2 +%501 = OpCompositeExtract %4 %500 0 OpLine %3 181 17 -%505 = OpAccessChain %393 %498 %373 -%506 = OpLoad %8 %505 -%507 = OpConvertUToF %4 %506 -%508 = OpFMul %4 %504 %507 -%509 = OpCompositeExtract %6 %485 2 -%510 = OpCompositeExtract %4 %509 1 +%502 = OpAccessChain %393 %495 %373 +%503 = OpLoad %8 %502 +%504 = OpConvertUToF %4 %503 +%505 = OpFMul %4 %501 %504 +%506 = OpCompositeExtract %6 %482 2 +%507 = OpCompositeExtract %4 %506 1 OpLine %3 181 70 -%511 = OpAccessChain %393 %498 %373 -%512 = OpLoad %8 %511 +%508 = OpAccessChain %393 %495 %373 +%509 = OpLoad %8 %508 OpLine %3 181 13 -%513 = OpAccessChain %393 %498 %373 -%514 = OpLoad %8 %513 -%515 = OpIMul %8 %512 %514 -%516 = OpConvertUToF %4 %515 -%517 = OpFMul %4 %510 %516 -%518 = OpFAdd %4 %508 %517 -%519 = OpExtInst %4 %1 FClamp %518 %74 %471 -%520 = OpConvertFToU %8 %519 +%510 = OpAccessChain %393 %495 %373 +%511 = OpLoad %8 %510 +%512 = OpIMul %8 %509 %511 +%513 = OpConvertUToF %4 %512 +%514 = OpFMul %4 %507 %513 +%515 = OpFAdd %4 %505 %514 +%516 = OpExtInst %4 %1 FClamp %515 %74 %471 +%517 = OpConvertFToU %8 %516 OpLine %3 181 13 -%521 = OpAccessChain %393 %498 %374 -%522 = OpLoad %8 %521 -%523 = OpIAdd %8 %520 %522 +%518 = OpAccessChain %393 %495 %374 +%519 = OpLoad %8 %518 +%520 = OpIAdd %8 %517 %519 OpLine %3 182 32 -%524 = OpConvertUToF %4 %523 +%521 = OpConvertUToF %4 %520 OpLine %3 182 22 -%525 = OpFDiv %4 %524 %499 -%526 = OpExtInst %4 %1 Floor %525 -%527 = OpExtInst %4 %1 FClamp %526 %74 %471 -%528 = OpConvertFToU %8 %527 +%522 = OpFDiv %4 %521 %496 +%523 = OpExtInst %4 %1 Floor %522 +%524 = OpExtInst %4 %1 FClamp %523 %74 %471 +%525 = OpConvertFToU %8 %524 OpLine %3 183 22 -%529 = OpFunctionCall %8 %427 %523 %371 +%526 = OpFunctionCall %8 %427 %520 %371 OpLine %3 185 36 -%530 = OpAccessChain %377 %498 %135 -%531 = OpLoad %10 %530 +%527 = OpAccessChain %377 %495 %135 +%528 = OpLoad %10 %527 OpLine %3 185 57 -%532 = OpAccessChain %380 %498 %126 -%533 = OpLoad %11 %532 +%529 = OpAccessChain %380 %495 %126 +%530 = OpLoad %11 %529 OpLine %3 185 13 -%534 = OpFunctionCall %6 %325 %528 %531 %533 +%531 = OpFunctionCall %6 %325 %525 %528 %530 OpLine %3 186 31 -%535 = OpAccessChain %386 %498 %372 -%536 = OpLoad %6 %535 +%532 = OpAccessChain %386 %495 %372 +%533 = OpLoad %6 %532 OpLine %3 186 13 -%537 = OpFunctionCall %14 %284 %534 %536 +%534 = OpFunctionCall %14 %284 %531 %533 OpLine %3 190 5 -OpSelectionMerge %538 None -OpSwitch %529 %545 0 %539 1 %540 2 %541 3 %542 4 %543 5 %544 -%539 = OpLabel +OpSelectionMerge %535 None +OpSwitch %526 %542 0 %536 1 %537 2 %538 3 %539 4 %540 5 %541 +%536 = OpLabel OpLine %3 191 37 -%546 = OpCompositeExtract %5 %537 0 -%547 = OpCompositeExtract %4 %546 0 +%543 = OpCompositeExtract %5 %534 0 +%544 = OpCompositeExtract %4 %543 0 OpLine %3 191 20 -OpStore %500 %547 -OpBranch %538 -%540 = OpLabel +OpStore %497 %544 +OpBranch %535 +%537 = OpLabel OpLine %3 192 37 -%548 = OpCompositeExtract %5 %537 0 -%549 = OpCompositeExtract %4 %548 1 +%545 = OpCompositeExtract %5 %534 0 +%546 = OpCompositeExtract %4 %545 1 OpLine %3 192 20 -OpStore %500 %549 -OpBranch %538 -%541 = OpLabel +OpStore %497 %546 +OpBranch %535 +%538 = OpLabel OpLine %3 193 37 -%550 = OpCompositeExtract %5 %537 0 -%551 = OpCompositeExtract %4 %550 2 +%547 = OpCompositeExtract %5 %534 0 +%548 = OpCompositeExtract %4 %547 2 OpLine %3 193 20 -OpStore %500 %551 -OpBranch %538 -%542 = OpLabel +OpStore %497 %548 +OpBranch %535 +%539 = OpLabel OpLine %3 194 37 -%552 = OpCompositeExtract %5 %537 1 -%553 = OpCompositeExtract %4 %552 0 +%549 = OpCompositeExtract %5 %534 1 +%550 = OpCompositeExtract %4 %549 0 OpLine %3 194 20 -OpStore %500 %553 -OpBranch %538 -%543 = OpLabel +OpStore %497 %550 +OpBranch %535 +%540 = OpLabel OpLine %3 195 37 -%554 = OpCompositeExtract %5 %537 1 -%555 = OpCompositeExtract %4 %554 1 +%551 = OpCompositeExtract %5 %534 1 +%552 = OpCompositeExtract %4 %551 1 OpLine %3 195 20 -OpStore %500 %555 -OpBranch %538 -%544 = OpLabel +OpStore %497 %552 +OpBranch %535 +%541 = OpLabel OpLine %3 196 37 -%556 = OpCompositeExtract %5 %537 1 -%557 = OpCompositeExtract %4 %556 2 +%553 = OpCompositeExtract %5 %534 1 +%554 = OpCompositeExtract %4 %553 2 OpLine %3 196 20 -OpStore %500 %557 -OpBranch %538 -%545 = OpLabel -OpBranch %538 -%538 = OpLabel +OpStore %497 %554 +OpBranch %535 +%542 = OpLabel +OpBranch %535 +%535 = OpLabel OpLine %3 200 15 -%558 = OpAccessChain %393 %498 %135 %135 -%559 = OpLoad %8 %558 -%560 = OpFunctionCall %8 %313 %528 %559 -%561 = OpIAdd %8 %528 %560 +%555 = OpAccessChain %393 %495 %135 %135 +%556 = OpLoad %8 %555 +%557 = OpFunctionCall %8 %313 %525 %556 +%558 = OpIAdd %8 %525 %557 OpLine %3 201 15 -%562 = OpIAdd %8 %561 %126 +%559 = OpIAdd %8 %558 %126 OpLine %3 202 15 -%563 = OpAccessChain %393 %498 %135 %135 -%564 = OpLoad %8 %563 -%565 = OpIAdd %8 %561 %564 +%560 = OpAccessChain %393 %495 %135 %135 +%561 = OpLoad %8 %560 +%562 = OpIAdd %8 %558 %561 OpLine %3 202 15 -%566 = OpIAdd %8 %565 %126 +%563 = OpIAdd %8 %562 %126 OpLine %3 203 15 -%567 = OpIAdd %8 %566 %126 +%564 = OpIAdd %8 %563 %126 OpLine %3 206 5 -OpSelectionMerge %568 None -OpSwitch %529 %573 0 %569 3 %569 2 %570 4 %570 1 %571 5 %572 -%569 = OpLabel +OpSelectionMerge %565 None +OpSwitch %526 %570 0 %566 3 %566 2 %567 4 %567 1 %568 5 %569 +%566 = OpLabel OpLine %3 207 24 -OpStore %501 %561 -OpBranch %568 -%570 = OpLabel +OpStore %498 %558 +OpBranch %565 +%567 = OpLabel OpLine %3 208 24 -OpStore %501 %567 -OpBranch %568 -%571 = OpLabel +OpStore %498 %564 +OpBranch %565 +%568 = OpLabel OpLine %3 209 20 -OpStore %501 %566 -OpBranch %568 -%572 = OpLabel +OpStore %498 %563 +OpBranch %565 +%569 = OpLabel OpLine %3 210 20 -OpStore %501 %562 -OpBranch %568 -%573 = OpLabel -OpBranch %568 -%568 = OpLabel +OpStore %498 %559 +OpBranch %565 +%570 = OpLabel +OpBranch %565 +%565 = OpLabel OpLine %3 213 13 -%574 = OpCompositeExtract %8 %485 0 +%571 = OpCompositeExtract %8 %482 0 OpLine %3 213 5 -OpStore %501 %574 +OpStore %498 %571 OpLine %3 222 27 -%575 = OpLoad %4 %500 -%576 = OpBitcast %8 %575 +%572 = OpLoad %4 %497 +%573 = OpBitcast %8 %572 OpLine %3 223 12 -%577 = OpLoad %8 %501 -%578 = OpCompositeConstruct %22 %576 %577 -%579 = OpCompositeExtract %8 %578 0 -OpStore %494 %579 -%580 = OpCompositeExtract %8 %578 1 -OpStore %496 %580 -%581 = OpCompositeExtract %8 %578 0 -%582 = OpCompositeExtract %8 %578 1 +%574 = OpLoad %8 %498 +%575 = OpCompositeConstruct %22 %573 %574 +%576 = OpCompositeExtract %8 %575 0 +OpStore %491 %576 +%577 = OpCompositeExtract %8 %575 1 +OpStore %493 %577 OpReturn OpFunctionEnd -%594 = OpFunction %2 None %368 -%583 = OpLabel -%587 = OpLoad %5 %585 -%589 = OpLoad %5 %588 -%584 = OpCompositeConstruct %14 %587 %589 -%596 = OpAccessChain %595 %39 %135 -OpBranch %597 -%597 = OpLabel +%589 = OpFunction %2 None %368 +%578 = OpLabel +%582 = OpLoad %5 %580 +%584 = OpLoad %5 %583 +%579 = OpCompositeConstruct %14 %582 %584 +%591 = OpAccessChain %590 %39 %135 +OpBranch %592 +%592 = OpLabel OpLine %3 254 25 -%599 = OpAccessChain %598 %596 %126 -%600 = OpLoad %23 %599 -%601 = OpCompositeExtract %5 %584 0 +%594 = OpAccessChain %593 %591 %126 +%595 = OpLoad %23 %594 +%596 = OpCompositeExtract %5 %579 0 OpLine %3 254 25 -%602 = OpCompositeConstruct %7 %601 %56 -%603 = OpMatrixTimesVector %7 %600 %602 +%597 = OpCompositeConstruct %7 %596 %56 +%598 = OpMatrixTimesVector %7 %595 %597 OpLine %3 255 18 -%604 = OpCompositeExtract %5 %584 1 +%599 = OpCompositeExtract %5 %579 1 OpLine %3 256 12 -%605 = OpCompositeExtract %5 %584 0 -%606 = OpCompositeConstruct %26 %603 %604 %605 -%607 = OpCompositeExtract %7 %606 0 -OpStore %590 %607 -%608 = OpCompositeExtract %5 %606 1 -OpStore %592 %608 -%609 = OpCompositeExtract %5 %606 2 -OpStore %593 %609 -%610 = OpCompositeExtract %7 %606 0 -%611 = OpCompositeExtract %5 %606 1 -%612 = OpCompositeExtract %5 %606 2 +%600 = OpCompositeExtract %5 %579 0 +%601 = OpCompositeConstruct %26 %598 %599 %600 +%602 = OpCompositeExtract %7 %601 0 +OpStore %585 %602 +%603 = OpCompositeExtract %5 %601 1 +OpStore %587 %603 +%604 = OpCompositeExtract %5 %601 2 +OpStore %588 %604 OpReturn OpFunctionEnd -%623 = OpFunction %2 None %368 -%613 = OpLabel -%637 = OpVariable %95 Function %638 -%616 = OpLoad %7 %615 -%618 = OpLoad %5 %617 -%620 = OpLoad %5 %619 -%614 = OpCompositeConstruct %26 %616 %618 %620 -%624 = OpAccessChain %595 %39 %135 -%626 = OpAccessChain %625 %42 %135 -%627 = OpLoad %27 %45 -%628 = OpLoad %28 %47 -%629 = OpLoad %27 %49 -%630 = OpLoad %28 %50 -OpBranch %639 -%639 = OpLabel +%615 = OpFunction %2 None %368 +%605 = OpLabel +%629 = OpVariable %95 Function %630 +%608 = OpLoad %7 %607 +%610 = OpLoad %5 %609 +%612 = OpLoad %5 %611 +%606 = OpCompositeConstruct %26 %608 %610 %612 +%616 = OpAccessChain %590 %39 %135 +%618 = OpAccessChain %617 %42 %135 +%619 = OpLoad %27 %45 +%620 = OpLoad %28 %47 +%621 = OpLoad %27 %49 +%622 = OpLoad %28 %50 +OpBranch %631 +%631 = OpLabel OpLine %3 283 13 OpLine %3 283 13 OpLine %3 283 5 -%640 = OpFunctionCall %5 %342 %631 +%632 = OpFunctionCall %5 %342 %623 OpLine %3 285 28 OpLine %3 285 17 -%641 = OpCompositeExtract %5 %614 2 -%642 = OpExtInst %5 %1 Fract %641 -%643 = OpExtInst %5 %1 SmoothStep %80 %632 %642 +%633 = OpCompositeExtract %5 %606 2 +%634 = OpExtInst %5 %1 Fract %633 +%635 = OpExtInst %5 %1 SmoothStep %80 %624 %634 OpLine %3 285 5 -OpStore %637 %643 +OpStore %629 %635 OpLine %3 286 17 OpLine %3 286 13 -%644 = OpAccessChain %125 %637 %135 -%645 = OpLoad %4 %644 -%646 = OpAccessChain %125 %637 %126 -%647 = OpLoad %4 %646 -%648 = OpFMul %4 %645 %647 -%649 = OpAccessChain %125 %637 %372 -%650 = OpLoad %4 %649 -%651 = OpFMul %4 %648 %650 -%652 = OpCompositeConstruct %5 %651 %651 %651 -%653 = OpExtInst %5 %1 FMix %634 %636 %652 +%636 = OpAccessChain %125 %629 %135 +%637 = OpLoad %4 %636 +%638 = OpAccessChain %125 %629 %126 +%639 = OpLoad %4 %638 +%640 = OpFMul %4 %637 %639 +%641 = OpAccessChain %125 %629 %372 +%642 = OpLoad %4 %641 +%643 = OpFMul %4 %640 %642 +%644 = OpCompositeConstruct %5 %643 %643 %643 +%645 = OpExtInst %5 %1 FMix %626 %628 %644 OpLine %3 286 5 -OpStore %637 %653 +OpStore %629 %645 OpLine %3 289 25 -%655 = OpAccessChain %654 %626 %126 -%656 = OpLoad %5 %655 -%657 = OpVectorTimesScalar %5 %656 %286 +%647 = OpAccessChain %646 %618 %126 +%648 = OpLoad %5 %647 +%649 = OpVectorTimesScalar %5 %648 %286 OpLine %3 291 21 -%658 = OpAccessChain %654 %626 %135 -%659 = OpLoad %5 %658 -%660 = OpCompositeExtract %5 %614 2 -%661 = OpFSub %5 %659 %660 -%662 = OpExtInst %5 %1 Normalize %661 +%650 = OpAccessChain %646 %618 %135 +%651 = OpLoad %5 %650 +%652 = OpCompositeExtract %5 %606 2 +%653 = OpFSub %5 %651 %652 +%654 = OpExtInst %5 %1 Normalize %653 OpLine %3 292 20 -%664 = OpAccessChain %663 %624 %135 -%665 = OpLoad %7 %664 -%666 = OpVectorShuffle %5 %665 %665 0 1 2 -%667 = OpCompositeExtract %5 %614 2 -%668 = OpFSub %5 %666 %667 -%669 = OpExtInst %5 %1 Normalize %668 +%656 = OpAccessChain %655 %616 %135 +%657 = OpLoad %7 %656 +%658 = OpVectorShuffle %5 %657 %657 0 1 2 +%659 = OpCompositeExtract %5 %606 2 +%660 = OpFSub %5 %658 %659 +%661 = OpExtInst %5 %1 Normalize %660 OpLine %3 293 20 -%670 = OpFAdd %5 %669 %662 -%671 = OpExtInst %5 %1 Normalize %670 +%662 = OpFAdd %5 %661 %654 +%663 = OpExtInst %5 %1 Normalize %662 OpLine %3 295 32 -%672 = OpCompositeExtract %5 %614 1 -%673 = OpDot %4 %672 %662 +%664 = OpCompositeExtract %5 %606 1 +%665 = OpDot %4 %664 %654 OpLine %3 295 28 -%674 = OpExtInst %4 %1 FMax %673 %74 +%666 = OpExtInst %4 %1 FMax %665 %74 OpLine %3 296 25 -%675 = OpAccessChain %654 %626 %126 -%676 = OpLoad %5 %675 -%677 = OpVectorTimesScalar %5 %676 %674 +%667 = OpAccessChain %646 %618 %126 +%668 = OpLoad %5 %667 +%669 = OpVectorTimesScalar %5 %668 %666 OpLine %3 298 37 -%678 = OpCompositeExtract %5 %614 1 -%679 = OpDot %4 %678 %671 +%670 = OpCompositeExtract %5 %606 1 +%671 = OpDot %4 %670 %663 OpLine %3 298 33 -%680 = OpExtInst %4 %1 FMax %679 %74 +%672 = OpExtInst %4 %1 FMax %671 %74 OpLine %3 298 29 -%681 = OpExtInst %4 %1 Pow %680 %345 +%673 = OpExtInst %4 %1 Pow %672 %345 OpLine %3 299 26 -%682 = OpAccessChain %654 %626 %126 -%683 = OpLoad %5 %682 -%684 = OpVectorTimesScalar %5 %683 %681 +%674 = OpAccessChain %646 %618 %126 +%675 = OpLoad %5 %674 +%676 = OpVectorTimesScalar %5 %675 %673 OpLine %3 301 18 -%685 = OpFAdd %5 %657 %677 -%686 = OpFAdd %5 %685 %684 -%687 = OpLoad %5 %637 -%688 = OpFMul %5 %686 %687 +%677 = OpFAdd %5 %649 %669 +%678 = OpFAdd %5 %677 %676 +%679 = OpLoad %5 %629 +%680 = OpFMul %5 %678 %679 OpLine %3 303 12 -%689 = OpCompositeConstruct %7 %688 %56 -OpStore %621 %689 +%681 = OpCompositeConstruct %7 %680 %56 +OpStore %613 %681 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-dualsource.spvasm b/naga/tests/out/spv/wgsl-dualsource.spvasm index bd9a608c326..0626a9f877e 100644 --- a/naga/tests/out/spv/wgsl-dualsource.spvasm +++ b/naga/tests/out/spv/wgsl-dualsource.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 28 +; Bound: 26 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -40,7 +40,5 @@ OpBranch %23 OpStore %7 %24 %25 = OpCompositeExtract %3 %22 1 OpStore %9 %25 -%26 = OpCompositeExtract %3 %22 0 -%27 = OpCompositeExtract %3 %22 1 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-interface.fragment.spvasm b/naga/tests/out/spv/wgsl-interface.fragment.spvasm index 8805b2d1e96..629c1ec8257 100644 --- a/naga/tests/out/spv/wgsl-interface.fragment.spvasm +++ b/naga/tests/out/spv/wgsl-interface.fragment.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.0 ; Generator: rspirv -; Bound: 52 +; Bound: 49 OpCapability Shader OpCapability SampleRateShading %1 = OpExtInstImport "GLSL.std.450" @@ -17,8 +17,8 @@ OpMemberDecorate %7 2 Offset 8 OpDecorate %9 ArrayStride 4 OpMemberDecorate %12 0 Offset 0 OpMemberDecorate %13 0 Offset 0 -OpDecorate %16 Invariant OpDecorate %16 BuiltIn FragCoord +OpDecorate %16 Invariant OpDecorate %19 Location 1 OpDecorate %22 BuiltIn FrontFacing OpDecorate %22 Flat @@ -81,8 +81,5 @@ OpStore %30 %46 OpStore %32 %47 %48 = OpCompositeExtract %3 %43 2 OpStore %33 %48 -%49 = OpCompositeExtract %3 %43 0 -%50 = OpCompositeExtract %6 %43 1 -%51 = OpCompositeExtract %3 %43 2 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-interface.vertex.spvasm b/naga/tests/out/spv/wgsl-interface.vertex.spvasm index 20fc20a4cc1..885fd0434b6 100644 --- a/naga/tests/out/spv/wgsl-interface.vertex.spvasm +++ b/naga/tests/out/spv/wgsl-interface.vertex.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.0 ; Generator: rspirv -; Bound: 40 +; Bound: 38 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -17,8 +17,8 @@ OpMemberDecorate %13 0 Offset 0 OpDecorate %15 BuiltIn VertexIndex OpDecorate %18 BuiltIn InstanceIndex OpDecorate %20 Location 10 -OpDecorate %22 Invariant OpDecorate %22 BuiltIn Position +OpDecorate %22 Invariant OpDecorate %24 Location 1 OpDecorate %25 BuiltIn PointSize %2 = OpTypeVoid @@ -61,7 +61,5 @@ OpBranch %31 OpStore %22 %36 %37 = OpCompositeExtract %3 %35 1 OpStore %24 %37 -%38 = OpCompositeExtract %4 %35 0 -%39 = OpCompositeExtract %3 %35 1 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-interface.vertex_two_structs.spvasm b/naga/tests/out/spv/wgsl-interface.vertex_two_structs.spvasm index cad89cc551a..870d1f31929 100644 --- a/naga/tests/out/spv/wgsl-interface.vertex_two_structs.spvasm +++ b/naga/tests/out/spv/wgsl-interface.vertex_two_structs.spvasm @@ -16,8 +16,8 @@ OpMemberDecorate %12 0 Offset 0 OpMemberDecorate %13 0 Offset 0 OpDecorate %16 BuiltIn VertexIndex OpDecorate %20 BuiltIn InstanceIndex -OpDecorate %22 Invariant OpDecorate %22 BuiltIn Position +OpDecorate %22 Invariant OpDecorate %24 BuiltIn PointSize %2 = OpTypeVoid %3 = OpTypeFloat 32 diff --git a/naga/tests/out/spv/wgsl-interpolate_compat.spvasm b/naga/tests/out/spv/wgsl-interpolate_compat.spvasm index 47952c88d8e..7ead0a93ede 100644 --- a/naga/tests/out/spv/wgsl-interpolate_compat.spvasm +++ b/naga/tests/out/spv/wgsl-interpolate_compat.spvasm @@ -1,14 +1,14 @@ ; SPIR-V ; Version: 1.0 ; Generator: rspirv -; Bound: 141 +; Bound: 130 OpCapability Shader OpCapability SampleRateShading %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %26 "vert_main" %11 %11 %13 %13 %14 %14 %15 %15 %16 %16 %17 %17 %18 %18 %19 %19 %20 %20 %21 %21 %22 %22 %23 -OpEntryPoint Fragment %139 "frag_main" %112 %115 %118 %120 %123 %126 %129 %131 %133 %135 %137 -OpExecutionMode %139 OriginUpperLeft +OpEntryPoint Fragment %128 "frag_main" %101 %104 %107 %109 %112 %115 %118 %120 %122 %124 %126 +OpExecutionMode %128 OriginUpperLeft %3 = OpString "interpolate_compat.wgsl" OpSource Unknown 0 %3 "// NOTE: This is basically the same as `interpolate.wgsl`, except for the removal of // `@interpolate(flat, first)`, which is unsupported in GLSL and `compat`. @@ -79,18 +79,18 @@ OpName %21 "perspective_sample" OpName %22 "perspective_center" OpName %26 "vert_main" OpName %55 "out" -OpName %112 "position" -OpName %115 "_flat" -OpName %118 "flat_either" -OpName %120 "_linear" -OpName %123 "linear_centroid" -OpName %126 "linear_sample" -OpName %129 "linear_center" -OpName %131 "perspective" -OpName %133 "perspective_centroid" -OpName %135 "perspective_sample" -OpName %137 "perspective_center" -OpName %139 "frag_main" +OpName %101 "position" +OpName %104 "_flat" +OpName %107 "flat_either" +OpName %109 "_linear" +OpName %112 "linear_centroid" +OpName %115 "linear_sample" +OpName %118 "linear_center" +OpName %120 "perspective" +OpName %122 "perspective_centroid" +OpName %124 "perspective_sample" +OpName %126 "perspective_center" +OpName %128 "frag_main" OpMemberDecorate %9 0 Offset 0 OpMemberDecorate %9 1 Offset 16 OpMemberDecorate %9 2 Offset 20 @@ -124,27 +124,27 @@ OpDecorate %21 Location 10 OpDecorate %21 Sample OpDecorate %22 Location 11 OpDecorate %23 BuiltIn PointSize -OpDecorate %112 BuiltIn FragCoord -OpDecorate %115 Location 0 -OpDecorate %115 Flat -OpDecorate %118 Location 2 -OpDecorate %118 Flat -OpDecorate %120 Location 3 -OpDecorate %120 NoPerspective -OpDecorate %123 Location 4 -OpDecorate %123 NoPerspective -OpDecorate %123 Centroid -OpDecorate %126 Location 6 -OpDecorate %126 NoPerspective -OpDecorate %126 Sample -OpDecorate %129 Location 7 -OpDecorate %129 NoPerspective -OpDecorate %131 Location 8 -OpDecorate %133 Location 9 -OpDecorate %133 Centroid -OpDecorate %135 Location 10 -OpDecorate %135 Sample -OpDecorate %137 Location 11 +OpDecorate %101 BuiltIn FragCoord +OpDecorate %104 Location 0 +OpDecorate %104 Flat +OpDecorate %107 Location 2 +OpDecorate %107 Flat +OpDecorate %109 Location 3 +OpDecorate %109 NoPerspective +OpDecorate %112 Location 4 +OpDecorate %112 NoPerspective +OpDecorate %112 Centroid +OpDecorate %115 Location 6 +OpDecorate %115 NoPerspective +OpDecorate %115 Sample +OpDecorate %118 Location 7 +OpDecorate %118 NoPerspective +OpDecorate %120 Location 8 +OpDecorate %122 Location 9 +OpDecorate %122 Centroid +OpDecorate %124 Location 10 +OpDecorate %124 Sample +OpDecorate %126 Location 11 %2 = OpTypeVoid %4 = OpTypeFloat 32 %5 = OpTypeVector %4 4 @@ -211,22 +211,22 @@ OpDecorate %137 Location 11 %76 = OpConstant %6 6 %78 = OpConstant %6 7 %81 = OpConstant %6 9 -%113 = OpTypePointer Input %5 +%102 = OpTypePointer Input %5 +%101 = OpVariable %102 Input +%105 = OpTypePointer Input %6 +%104 = OpVariable %105 Input +%107 = OpVariable %105 Input +%110 = OpTypePointer Input %4 +%109 = OpVariable %110 Input +%113 = OpTypePointer Input %7 %112 = OpVariable %113 Input -%116 = OpTypePointer Input %6 +%116 = OpTypePointer Input %8 %115 = OpVariable %116 Input %118 = OpVariable %116 Input -%121 = OpTypePointer Input %4 -%120 = OpVariable %121 Input -%124 = OpTypePointer Input %7 -%123 = OpVariable %124 Input -%127 = OpTypePointer Input %8 -%126 = OpVariable %127 Input -%129 = OpVariable %127 Input -%131 = OpVariable %113 Input -%133 = OpVariable %121 Input -%135 = OpVariable %121 Input -%137 = OpVariable %121 Input +%120 = OpVariable %102 Input +%122 = OpVariable %110 Input +%124 = OpVariable %110 Input +%126 = OpVariable %110 Input %26 = OpFunction %2 None %27 %10 = OpLabel %55 = OpVariable %56 Function %57 @@ -310,34 +310,23 @@ OpStore %20 %96 OpStore %21 %97 %98 = OpCompositeExtract %4 %84 10 OpStore %22 %98 -%99 = OpCompositeExtract %5 %84 0 -%100 = OpCompositeExtract %6 %84 1 -%101 = OpCompositeExtract %6 %84 2 -%102 = OpCompositeExtract %4 %84 3 -%103 = OpCompositeExtract %7 %84 4 -%104 = OpCompositeExtract %8 %84 5 -%105 = OpCompositeExtract %8 %84 6 -%106 = OpCompositeExtract %5 %84 7 -%107 = OpCompositeExtract %4 %84 8 -%108 = OpCompositeExtract %4 %84 9 -%109 = OpCompositeExtract %4 %84 10 OpReturn OpFunctionEnd -%139 = OpFunction %2 None %27 -%110 = OpLabel -%114 = OpLoad %5 %112 -%117 = OpLoad %6 %115 -%119 = OpLoad %6 %118 -%122 = OpLoad %4 %120 -%125 = OpLoad %7 %123 -%128 = OpLoad %8 %126 -%130 = OpLoad %8 %129 -%132 = OpLoad %5 %131 -%134 = OpLoad %4 %133 -%136 = OpLoad %4 %135 -%138 = OpLoad %4 %137 -%111 = OpCompositeConstruct %9 %114 %117 %119 %122 %125 %128 %130 %132 %134 %136 %138 -OpBranch %140 -%140 = OpLabel +%128 = OpFunction %2 None %27 +%99 = OpLabel +%103 = OpLoad %5 %101 +%106 = OpLoad %6 %104 +%108 = OpLoad %6 %107 +%111 = OpLoad %4 %109 +%114 = OpLoad %7 %112 +%117 = OpLoad %8 %115 +%119 = OpLoad %8 %118 +%121 = OpLoad %5 %120 +%123 = OpLoad %4 %122 +%125 = OpLoad %4 %124 +%127 = OpLoad %4 %126 +%100 = OpCompositeConstruct %9 %103 %106 %108 %111 %114 %117 %119 %121 %123 %125 %127 +OpBranch %129 +%129 = OpLabel OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-quad.spvasm b/naga/tests/out/spv/wgsl-quad.spvasm index a59ef6ec14a..64677c3b2f9 100644 --- a/naga/tests/out/spv/wgsl-quad.spvasm +++ b/naga/tests/out/spv/wgsl-quad.spvasm @@ -1,15 +1,15 @@ ; SPIR-V ; Version: 1.0 ; Generator: rspirv -; Bound: 67 +; Bound: 65 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %24 "vert_main" %16 %19 %21 %21 %23 %23 -OpEntryPoint Fragment %47 "frag_main" %43 %45 -OpEntryPoint Fragment %63 "fs_extra" %62 -OpExecutionMode %47 OriginUpperLeft -OpExecutionMode %63 OriginUpperLeft +OpEntryPoint Fragment %45 "frag_main" %41 %43 +OpEntryPoint Fragment %61 "fs_extra" %60 +OpExecutionMode %45 OriginUpperLeft +OpExecutionMode %61 OriginUpperLeft %3 = OpString "quad.wgsl" OpSource Unknown 0 %3 "// vertex const c_scale: f32 = 1.2; @@ -61,9 +61,9 @@ OpName %19 "uv" OpName %21 "uv" OpName %23 "position" OpName %24 "vert_main" -OpName %43 "uv" -OpName %47 "frag_main" -OpName %63 "fs_extra" +OpName %41 "uv" +OpName %45 "frag_main" +OpName %61 "fs_extra" OpMemberDecorate %7 0 Offset 0 OpMemberDecorate %7 1 Offset 16 OpDecorate %11 DescriptorSet 0 @@ -74,9 +74,9 @@ OpDecorate %16 Location 0 OpDecorate %19 Location 1 OpDecorate %21 Location 0 OpDecorate %23 BuiltIn Position +OpDecorate %41 Location 0 OpDecorate %43 Location 0 -OpDecorate %45 Location 0 -OpDecorate %62 Location 0 +OpDecorate %60 Location 0 %2 = OpTypeVoid %4 = OpTypeFloat 32 %5 = OpTypeVector %4 2 @@ -101,14 +101,14 @@ OpDecorate %62 Location 0 %34 = OpTypePointer Output %4 %36 = OpTypeInt 32 0 %35 = OpConstant %36 1 -%43 = OpVariable %17 Input -%46 = OpTypePointer Output %6 -%45 = OpVariable %46 Output -%51 = OpTypeSampledImage %8 -%55 = OpTypeBool -%62 = OpVariable %46 Output -%64 = OpConstant %4 0.5 -%65 = OpConstantComposite %6 %26 %64 %26 %64 +%41 = OpVariable %17 Input +%44 = OpTypePointer Output %6 +%43 = OpVariable %44 Output +%49 = OpTypeSampledImage %8 +%53 = OpTypeBool +%60 = OpVariable %44 Output +%62 = OpConstant %4 0.5 +%63 = OpConstantComposite %6 %26 %62 %26 %62 %24 = OpFunction %2 None %25 %15 = OpLabel %18 = OpLoad %5 %16 @@ -128,41 +128,39 @@ OpStore %23 %33 %38 = OpLoad %4 %37 %39 = OpFNegate %4 %38 OpStore %37 %39 -%40 = OpCompositeExtract %5 %31 0 -%41 = OpCompositeExtract %6 %31 1 OpReturn OpFunctionEnd -%47 = OpFunction %2 None %25 -%42 = OpLabel -%44 = OpLoad %5 %43 -%48 = OpLoad %8 %11 -%49 = OpLoad %9 %13 -OpBranch %50 -%50 = OpLabel +%45 = OpFunction %2 None %25 +%40 = OpLabel +%42 = OpLoad %5 %41 +%46 = OpLoad %8 %11 +%47 = OpLoad %9 %13 +OpBranch %48 +%48 = OpLabel OpLine %3 23 15 -%52 = OpSampledImage %51 %48 %49 -%53 = OpImageSampleImplicitLod %6 %52 %44 +%50 = OpSampledImage %49 %46 %47 +%51 = OpImageSampleImplicitLod %6 %50 %42 OpLine %3 24 6 -%54 = OpCompositeExtract %4 %53 3 +%52 = OpCompositeExtract %4 %51 3 OpLine %3 24 6 -%56 = OpFOrdEqual %55 %54 %26 +%54 = OpFOrdEqual %53 %52 %26 OpLine %3 24 3 -OpSelectionMerge %57 None -OpBranchConditional %56 %58 %57 -%58 = OpLabel +OpSelectionMerge %55 None +OpBranchConditional %54 %56 %55 +%56 = OpLabel OpKill -%57 = OpLabel +%55 = OpLabel OpLine %3 29 23 -%59 = OpCompositeExtract %4 %53 3 -%60 = OpVectorTimesScalar %6 %53 %59 -OpStore %45 %60 +%57 = OpCompositeExtract %4 %51 3 +%58 = OpVectorTimesScalar %6 %51 %57 +OpStore %43 %58 OpReturn OpFunctionEnd -%63 = OpFunction %2 None %25 -%61 = OpLabel -OpBranch %66 -%66 = OpLabel +%61 = OpFunction %2 None %25 +%59 = OpLabel +OpBranch %64 +%64 = OpLabel OpLine %3 37 12 -OpStore %62 %65 +OpStore %60 %63 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-shadow.spvasm b/naga/tests/out/spv/wgsl-shadow.spvasm index 88725da133a..b0736171ef5 100644 --- a/naga/tests/out/spv/wgsl-shadow.spvasm +++ b/naga/tests/out/spv/wgsl-shadow.spvasm @@ -1,16 +1,16 @@ ; SPIR-V ; Version: 1.2 ; Generator: rspirv -; Bound: 297 +; Bound: 294 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %84 "vs_main" %75 %78 %80 %80 %82 %82 %83 %83 -OpEntryPoint Fragment %146 "fs_main" %136 %139 %142 %144 -OpEntryPoint Fragment %231 "fs_main_without_storage" %224 %226 %228 %230 -OpExecutionMode %146 OriginUpperLeft -OpExecutionMode %231 OriginUpperLeft +OpEntryPoint Fragment %143 "fs_main" %133 %136 %139 %141 +OpEntryPoint Fragment %228 "fs_main_without_storage" %221 %223 %225 %227 +OpExecutionMode %143 OriginUpperLeft +OpExecutionMode %228 OriginUpperLeft %3 = OpString "shadow.wgsl" OpSource Unknown 0 %3 "struct Globals { view_proj: mat4x4, @@ -162,20 +162,20 @@ OpName %82 "world_normal" OpName %83 "world_position" OpName %84 "vs_main" OpName %91 "out" -OpName %136 "proj_position" -OpName %139 "world_normal" -OpName %142 "world_position" -OpName %146 "fs_main" -OpName %153 "color" -OpName %154 "i" -OpName %169 "loop_bound" -OpName %224 "proj_position" -OpName %226 "world_normal" -OpName %228 "world_position" -OpName %231 "fs_main_without_storage" -OpName %238 "color" -OpName %239 "i" -OpName %247 "loop_bound" +OpName %133 "proj_position" +OpName %136 "world_normal" +OpName %139 "world_position" +OpName %143 "fs_main" +OpName %150 "color" +OpName %151 "i" +OpName %166 "loop_bound" +OpName %221 "proj_position" +OpName %223 "world_normal" +OpName %225 "world_position" +OpName %228 "fs_main_without_storage" +OpName %235 "color" +OpName %236 "i" +OpName %244 "loop_bound" OpMemberDecorate %9 0 Offset 0 OpMemberDecorate %9 0 ColMajor OpMemberDecorate %9 0 MatrixStride 16 @@ -220,14 +220,14 @@ OpDecorate %78 Location 1 OpDecorate %80 BuiltIn Position OpDecorate %82 Location 0 OpDecorate %83 Location 1 -OpDecorate %136 BuiltIn FragCoord -OpDecorate %139 Location 0 -OpDecorate %142 Location 1 -OpDecorate %144 Location 0 -OpDecorate %224 BuiltIn FragCoord -OpDecorate %226 Location 0 -OpDecorate %228 Location 1 -OpDecorate %230 Location 0 +OpDecorate %133 BuiltIn FragCoord +OpDecorate %136 Location 0 +OpDecorate %139 Location 1 +OpDecorate %141 Location 0 +OpDecorate %221 BuiltIn FragCoord +OpDecorate %223 Location 0 +OpDecorate %225 Location 1 +OpDecorate %227 Location 0 %2 = OpTypeVoid %4 = OpTypeFloat 32 %6 = OpTypeVector %4 4 @@ -295,31 +295,31 @@ OpDecorate %230 Location 0 %116 = OpTypePointer Function %6 %117 = OpConstant %7 2 %125 = OpTypePointer Output %4 -%137 = OpTypePointer Input %6 +%134 = OpTypePointer Input %6 +%133 = OpVariable %134 Input +%137 = OpTypePointer Input %11 %136 = OpVariable %137 Input -%140 = OpTypePointer Input %11 -%139 = OpVariable %140 Input -%142 = OpVariable %137 Input -%145 = OpTypePointer Output %6 -%144 = OpVariable %145 Output -%149 = OpTypePointer StorageBuffer %17 -%155 = OpTypePointer Function %7 -%163 = OpTypeVector %7 2 -%164 = OpTypePointer Function %163 -%165 = OpTypeVector %56 2 -%166 = OpConstantComposite %163 %87 %87 -%167 = OpConstant %7 4294967295 -%168 = OpConstantComposite %163 %167 %167 -%181 = OpTypePointer Uniform %8 -%182 = OpTypePointer Uniform %7 -%192 = OpTypePointer StorageBuffer %16 -%218 = OpTypePointer Uniform %6 -%224 = OpVariable %137 Input -%226 = OpVariable %140 Input -%228 = OpVariable %137 Input -%230 = OpVariable %145 Output -%234 = OpTypePointer Uniform %18 -%268 = OpTypePointer Uniform %16 +%139 = OpVariable %134 Input +%142 = OpTypePointer Output %6 +%141 = OpVariable %142 Output +%146 = OpTypePointer StorageBuffer %17 +%152 = OpTypePointer Function %7 +%160 = OpTypeVector %7 2 +%161 = OpTypePointer Function %160 +%162 = OpTypeVector %56 2 +%163 = OpConstantComposite %160 %87 %87 +%164 = OpConstant %7 4294967295 +%165 = OpConstantComposite %160 %164 %164 +%178 = OpTypePointer Uniform %8 +%179 = OpTypePointer Uniform %7 +%189 = OpTypePointer StorageBuffer %16 +%215 = OpTypePointer Uniform %6 +%221 = OpVariable %134 Input +%223 = OpVariable %137 Input +%225 = OpVariable %134 Input +%227 = OpVariable %142 Output +%231 = OpTypePointer Uniform %18 +%265 = OpTypePointer Uniform %16 %44 = OpFunction %4 None %45 %42 = OpFunctionParameter %7 %43 = OpFunctionParameter %6 @@ -417,224 +417,221 @@ OpStore %126 %128 OpStore %82 %129 %130 = OpCompositeExtract %6 %123 2 OpStore %83 %130 -%131 = OpCompositeExtract %6 %123 0 -%132 = OpCompositeExtract %11 %123 1 -%133 = OpCompositeExtract %6 %123 2 OpReturn OpFunctionEnd -%146 = OpFunction %2 None %85 -%134 = OpLabel -%153 = OpVariable %102 Function %24 -%154 = OpVariable %155 Function %87 -%169 = OpVariable %164 Function %168 -%138 = OpLoad %6 %136 -%141 = OpLoad %11 %139 -%143 = OpLoad %6 %142 -%135 = OpCompositeConstruct %12 %138 %141 %143 -%147 = OpAccessChain %86 %25 %87 -%148 = OpAccessChain %89 %28 %87 -%150 = OpAccessChain %149 %31 %87 -%151 = OpLoad %20 %37 -%152 = OpLoad %21 %39 +%143 = OpFunction %2 None %85 +%131 = OpLabel +%150 = OpVariable %102 Function %24 +%151 = OpVariable %152 Function %87 +%166 = OpVariable %161 Function %165 +%135 = OpLoad %6 %133 +%138 = OpLoad %11 %136 +%140 = OpLoad %6 %139 +%132 = OpCompositeConstruct %12 %135 %138 %140 +%144 = OpAccessChain %86 %25 %87 +%145 = OpAccessChain %89 %28 %87 +%147 = OpAccessChain %146 %31 %87 +%148 = OpLoad %20 %37 +%149 = OpLoad %21 %39 +OpBranch %153 +%153 = OpLabel +OpLine %3 85 18 +%154 = OpCompositeExtract %11 %132 1 +%155 = OpExtInst %11 %1 Normalize %154 OpBranch %156 %156 = OpLabel -OpLine %3 85 18 -%157 = OpCompositeExtract %11 %135 1 -%158 = OpExtInst %11 %1 Normalize %157 -OpBranch %159 -%159 = OpLabel OpLine %3 88 5 -OpLoopMerge %160 %162 None -OpBranch %170 -%170 = OpLabel -%171 = OpLoad %163 %169 -%172 = OpIEqual %165 %166 %171 -%173 = OpAll %56 %172 -OpSelectionMerge %174 None -OpBranchConditional %173 %160 %174 -%174 = OpLabel -%175 = OpCompositeExtract %7 %171 1 -%176 = OpIEqual %56 %175 %87 -%177 = OpSelect %7 %176 %114 %87 -%178 = OpCompositeConstruct %163 %177 %114 -%179 = OpISub %163 %171 %178 -OpStore %169 %179 -OpBranch %161 -%161 = OpLabel +OpLoopMerge %157 %159 None +OpBranch %167 +%167 = OpLabel +%168 = OpLoad %160 %166 +%169 = OpIEqual %162 %163 %168 +%170 = OpAll %56 %169 +OpSelectionMerge %171 None +OpBranchConditional %170 %157 %171 +%171 = OpLabel +%172 = OpCompositeExtract %7 %168 1 +%173 = OpIEqual %56 %172 %87 +%174 = OpSelect %7 %173 %114 %87 +%175 = OpCompositeConstruct %160 %174 %114 +%176 = OpISub %160 %168 %175 +OpStore %166 %176 +OpBranch %158 +%158 = OpLabel OpLine %3 1 1 -%180 = OpLoad %7 %154 +%177 = OpLoad %7 %151 OpLine %3 88 29 -%183 = OpAccessChain %182 %147 %114 %87 -%184 = OpLoad %7 %183 +%180 = OpAccessChain %179 %144 %114 %87 +%181 = OpLoad %7 %180 OpLine %3 88 21 -%185 = OpExtInst %7 %1 UMin %184 %19 -%186 = OpULessThan %56 %180 %185 +%182 = OpExtInst %7 %1 UMin %181 %19 +%183 = OpULessThan %56 %177 %182 OpLine %3 88 20 -OpSelectionMerge %187 None -OpBranchConditional %186 %187 %188 -%188 = OpLabel -OpBranch %160 -%187 = OpLabel -OpBranch %189 -%189 = OpLabel +OpSelectionMerge %184 None +OpBranchConditional %183 %184 %185 +%185 = OpLabel +OpBranch %157 +%184 = OpLabel +OpBranch %186 +%186 = OpLabel OpLine %3 89 21 -%191 = OpLoad %7 %154 -%193 = OpAccessChain %192 %150 %191 -%194 = OpLoad %16 %193 +%188 = OpLoad %7 %151 +%190 = OpAccessChain %189 %147 %188 +%191 = OpLoad %16 %190 OpLine %3 91 38 -%195 = OpLoad %7 %154 -%196 = OpCompositeExtract %5 %194 0 -%197 = OpCompositeExtract %6 %135 2 -%198 = OpMatrixTimesVector %6 %196 %197 +%192 = OpLoad %7 %151 +%193 = OpCompositeExtract %5 %191 0 +%194 = OpCompositeExtract %6 %132 2 +%195 = OpMatrixTimesVector %6 %193 %194 OpLine %3 91 22 -%199 = OpFunctionCall %4 %44 %195 %198 +%196 = OpFunctionCall %4 %44 %192 %195 OpLine %3 93 25 -%200 = OpCompositeExtract %6 %194 1 -%201 = OpVectorShuffle %11 %200 %200 0 1 2 -%202 = OpCompositeExtract %6 %135 2 -%203 = OpVectorShuffle %11 %202 %202 0 1 2 -%204 = OpFSub %11 %201 %203 -%205 = OpExtInst %11 %1 Normalize %204 +%197 = OpCompositeExtract %6 %191 1 +%198 = OpVectorShuffle %11 %197 %197 0 1 2 +%199 = OpCompositeExtract %6 %132 2 +%200 = OpVectorShuffle %11 %199 %199 0 1 2 +%201 = OpFSub %11 %198 %200 +%202 = OpExtInst %11 %1 Normalize %201 OpLine %3 94 32 -%206 = OpDot %4 %158 %205 +%203 = OpDot %4 %155 %202 OpLine %3 94 23 -%207 = OpExtInst %4 %1 FMax %48 %206 +%204 = OpExtInst %4 %1 FMax %48 %203 OpLine %3 96 9 -%208 = OpFMul %4 %199 %207 -%209 = OpCompositeExtract %6 %194 2 -%210 = OpVectorShuffle %11 %209 %209 0 1 2 -%211 = OpVectorTimesScalar %11 %210 %208 -%212 = OpLoad %11 %153 -%213 = OpFAdd %11 %212 %211 +%205 = OpFMul %4 %196 %204 +%206 = OpCompositeExtract %6 %191 2 +%207 = OpVectorShuffle %11 %206 %206 0 1 2 +%208 = OpVectorTimesScalar %11 %207 %205 +%209 = OpLoad %11 %150 +%210 = OpFAdd %11 %209 %208 OpLine %3 96 9 -OpStore %153 %213 -OpBranch %190 -%190 = OpLabel -OpBranch %162 -%162 = OpLabel +OpStore %150 %210 +OpBranch %187 +%187 = OpLabel +OpBranch %159 +%159 = OpLabel OpLine %3 88 68 -%214 = OpLoad %7 %154 -%215 = OpIAdd %7 %214 %114 +%211 = OpLoad %7 %151 +%212 = OpIAdd %7 %211 %114 OpLine %3 88 68 -OpStore %154 %215 -OpBranch %159 -%160 = OpLabel +OpStore %151 %212 +OpBranch %156 +%157 = OpLabel OpLine %3 1 1 -%216 = OpLoad %11 %153 +%213 = OpLoad %11 %150 OpLine %3 99 12 -%217 = OpCompositeConstruct %6 %216 %49 +%214 = OpCompositeConstruct %6 %213 %49 OpLine %3 99 12 -%219 = OpAccessChain %218 %148 %114 -%220 = OpLoad %6 %219 -%221 = OpFMul %6 %217 %220 -OpStore %144 %221 +%216 = OpAccessChain %215 %145 %114 +%217 = OpLoad %6 %216 +%218 = OpFMul %6 %214 %217 +OpStore %141 %218 OpReturn OpFunctionEnd -%231 = OpFunction %2 None %85 -%222 = OpLabel -%238 = OpVariable %102 Function %24 -%239 = OpVariable %155 Function %87 -%247 = OpVariable %164 Function %168 -%225 = OpLoad %6 %224 -%227 = OpLoad %11 %226 -%229 = OpLoad %6 %228 -%223 = OpCompositeConstruct %12 %225 %227 %229 -%232 = OpAccessChain %86 %25 %87 -%233 = OpAccessChain %89 %28 %87 -%235 = OpAccessChain %234 %34 %87 -%236 = OpLoad %20 %37 -%237 = OpLoad %21 %39 +%228 = OpFunction %2 None %85 +%219 = OpLabel +%235 = OpVariable %102 Function %24 +%236 = OpVariable %152 Function %87 +%244 = OpVariable %161 Function %165 +%222 = OpLoad %6 %221 +%224 = OpLoad %11 %223 +%226 = OpLoad %6 %225 +%220 = OpCompositeConstruct %12 %222 %224 %226 +%229 = OpAccessChain %86 %25 %87 +%230 = OpAccessChain %89 %28 %87 +%232 = OpAccessChain %231 %34 %87 +%233 = OpLoad %20 %37 +%234 = OpLoad %21 %39 +OpBranch %237 +%237 = OpLabel +OpLine %3 105 18 +%238 = OpCompositeExtract %11 %220 1 +%239 = OpExtInst %11 %1 Normalize %238 OpBranch %240 %240 = OpLabel -OpLine %3 105 18 -%241 = OpCompositeExtract %11 %223 1 -%242 = OpExtInst %11 %1 Normalize %241 -OpBranch %243 -%243 = OpLabel OpLine %3 107 5 -OpLoopMerge %244 %246 None -OpBranch %248 -%248 = OpLabel -%249 = OpLoad %163 %247 -%250 = OpIEqual %165 %166 %249 -%251 = OpAll %56 %250 -OpSelectionMerge %252 None -OpBranchConditional %251 %244 %252 -%252 = OpLabel -%253 = OpCompositeExtract %7 %249 1 -%254 = OpIEqual %56 %253 %87 -%255 = OpSelect %7 %254 %114 %87 -%256 = OpCompositeConstruct %163 %255 %114 -%257 = OpISub %163 %249 %256 -OpStore %247 %257 +OpLoopMerge %241 %243 None OpBranch %245 %245 = OpLabel +%246 = OpLoad %160 %244 +%247 = OpIEqual %162 %163 %246 +%248 = OpAll %56 %247 +OpSelectionMerge %249 None +OpBranchConditional %248 %241 %249 +%249 = OpLabel +%250 = OpCompositeExtract %7 %246 1 +%251 = OpIEqual %56 %250 %87 +%252 = OpSelect %7 %251 %114 %87 +%253 = OpCompositeConstruct %160 %252 %114 +%254 = OpISub %160 %246 %253 +OpStore %244 %254 +OpBranch %242 +%242 = OpLabel OpLine %3 1 1 -%258 = OpLoad %7 %239 +%255 = OpLoad %7 %236 OpLine %3 107 29 -%259 = OpAccessChain %182 %232 %114 %87 -%260 = OpLoad %7 %259 +%256 = OpAccessChain %179 %229 %114 %87 +%257 = OpLoad %7 %256 OpLine %3 107 21 -%261 = OpExtInst %7 %1 UMin %260 %19 -%262 = OpULessThan %56 %258 %261 +%258 = OpExtInst %7 %1 UMin %257 %19 +%259 = OpULessThan %56 %255 %258 OpLine %3 107 20 -OpSelectionMerge %263 None -OpBranchConditional %262 %263 %264 -%264 = OpLabel -OpBranch %244 -%263 = OpLabel -OpBranch %265 -%265 = OpLabel +OpSelectionMerge %260 None +OpBranchConditional %259 %260 %261 +%261 = OpLabel +OpBranch %241 +%260 = OpLabel +OpBranch %262 +%262 = OpLabel OpLine %3 110 21 -%267 = OpLoad %7 %239 -%269 = OpAccessChain %268 %235 %267 -%270 = OpLoad %16 %269 +%264 = OpLoad %7 %236 +%266 = OpAccessChain %265 %232 %264 +%267 = OpLoad %16 %266 OpLine %3 111 38 -%271 = OpLoad %7 %239 -%272 = OpCompositeExtract %5 %270 0 -%273 = OpCompositeExtract %6 %223 2 -%274 = OpMatrixTimesVector %6 %272 %273 +%268 = OpLoad %7 %236 +%269 = OpCompositeExtract %5 %267 0 +%270 = OpCompositeExtract %6 %220 2 +%271 = OpMatrixTimesVector %6 %269 %270 OpLine %3 111 22 -%275 = OpFunctionCall %4 %44 %271 %274 +%272 = OpFunctionCall %4 %44 %268 %271 OpLine %3 112 25 -%276 = OpCompositeExtract %6 %270 1 -%277 = OpVectorShuffle %11 %276 %276 0 1 2 -%278 = OpCompositeExtract %6 %223 2 -%279 = OpVectorShuffle %11 %278 %278 0 1 2 -%280 = OpFSub %11 %277 %279 -%281 = OpExtInst %11 %1 Normalize %280 +%273 = OpCompositeExtract %6 %267 1 +%274 = OpVectorShuffle %11 %273 %273 0 1 2 +%275 = OpCompositeExtract %6 %220 2 +%276 = OpVectorShuffle %11 %275 %275 0 1 2 +%277 = OpFSub %11 %274 %276 +%278 = OpExtInst %11 %1 Normalize %277 OpLine %3 113 32 -%282 = OpDot %4 %242 %281 +%279 = OpDot %4 %239 %278 OpLine %3 113 23 -%283 = OpExtInst %4 %1 FMax %48 %282 +%280 = OpExtInst %4 %1 FMax %48 %279 OpLine %3 114 9 -%284 = OpFMul %4 %275 %283 -%285 = OpCompositeExtract %6 %270 2 -%286 = OpVectorShuffle %11 %285 %285 0 1 2 -%287 = OpVectorTimesScalar %11 %286 %284 -%288 = OpLoad %11 %238 -%289 = OpFAdd %11 %288 %287 +%281 = OpFMul %4 %272 %280 +%282 = OpCompositeExtract %6 %267 2 +%283 = OpVectorShuffle %11 %282 %282 0 1 2 +%284 = OpVectorTimesScalar %11 %283 %281 +%285 = OpLoad %11 %235 +%286 = OpFAdd %11 %285 %284 OpLine %3 114 9 -OpStore %238 %289 -OpBranch %266 -%266 = OpLabel -OpBranch %246 -%246 = OpLabel +OpStore %235 %286 +OpBranch %263 +%263 = OpLabel +OpBranch %243 +%243 = OpLabel OpLine %3 107 68 -%290 = OpLoad %7 %239 -%291 = OpIAdd %7 %290 %114 +%287 = OpLoad %7 %236 +%288 = OpIAdd %7 %287 %114 OpLine %3 107 68 -OpStore %239 %291 -OpBranch %243 -%244 = OpLabel +OpStore %236 %288 +OpBranch %240 +%241 = OpLabel OpLine %3 1 1 -%292 = OpLoad %11 %238 +%289 = OpLoad %11 %235 OpLine %3 116 12 -%293 = OpCompositeConstruct %6 %292 %49 +%290 = OpCompositeConstruct %6 %289 %49 OpLine %3 116 12 -%294 = OpAccessChain %218 %233 %114 -%295 = OpLoad %6 %294 -%296 = OpFMul %6 %293 %295 -OpStore %230 %296 +%291 = OpAccessChain %215 %230 %114 +%292 = OpLoad %6 %291 +%293 = OpFMul %6 %290 %292 +OpStore %227 %293 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-skybox.spvasm b/naga/tests/out/spv/wgsl-skybox.spvasm index be26cc2aa94..722f5cf974a 100644 --- a/naga/tests/out/spv/wgsl-skybox.spvasm +++ b/naga/tests/out/spv/wgsl-skybox.spvasm @@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.0 ; Generator: rspirv -; Bound: 116 +; Bound: 114 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %45 "vs_main" %39 %42 %42 %44 %44 -OpEntryPoint Fragment %108 "fs_main" %100 %103 %106 -OpExecutionMode %108 OriginUpperLeft +OpEntryPoint Fragment %106 "fs_main" %98 %101 %104 +OpExecutionMode %106 OriginUpperLeft OpMemberDecorate %6 0 Offset 0 OpMemberDecorate %6 1 Offset 16 OpMemberDecorate %8 0 Offset 0 @@ -27,9 +27,9 @@ OpDecorate %19 Binding 2 OpDecorate %39 BuiltIn VertexIndex OpDecorate %42 BuiltIn Position OpDecorate %44 Location 0 -OpDecorate %100 BuiltIn FragCoord -OpDecorate %103 Location 0 -OpDecorate %106 Location 0 +OpDecorate %98 BuiltIn FragCoord +OpDecorate %101 Location 0 +OpDecorate %104 Location 0 %2 = OpTypeVoid %4 = OpTypeFloat 32 %3 = OpTypeVector %4 4 @@ -74,13 +74,13 @@ OpDecorate %106 Location 0 %74 = OpTypePointer Uniform %3 %75 = OpConstant %9 1 %82 = OpConstant %9 2 -%101 = OpTypePointer Input %3 -%100 = OpVariable %101 Input -%104 = OpTypePointer Input %5 -%103 = OpVariable %104 Input -%107 = OpTypePointer Output %3 -%106 = OpVariable %107 Output -%113 = OpTypeSampledImage %12 +%99 = OpTypePointer Input %3 +%98 = OpVariable %99 Input +%102 = OpTypePointer Input %5 +%101 = OpVariable %102 Input +%105 = OpTypePointer Output %3 +%104 = OpVariable %105 Output +%111 = OpTypeSampledImage %12 %21 = OpFunction %10 None %22 %23 = OpFunctionParameter %10 %24 = OpFunctionParameter %10 @@ -138,22 +138,20 @@ OpStore %57 %63 OpStore %42 %94 %95 = OpCompositeExtract %5 %93 1 OpStore %44 %95 -%96 = OpCompositeExtract %3 %93 0 -%97 = OpCompositeExtract %5 %93 1 OpReturn OpFunctionEnd -%108 = OpFunction %2 None %46 -%98 = OpLabel -%102 = OpLoad %3 %100 -%105 = OpLoad %5 %103 -%99 = OpCompositeConstruct %6 %102 %105 -%109 = OpLoad %12 %17 -%110 = OpLoad %13 %19 -OpBranch %111 -%111 = OpLabel -%112 = OpCompositeExtract %5 %99 1 -%114 = OpSampledImage %113 %109 %110 -%115 = OpImageSampleImplicitLod %3 %114 %112 -OpStore %106 %115 +%106 = OpFunction %2 None %46 +%96 = OpLabel +%100 = OpLoad %3 %98 +%103 = OpLoad %5 %101 +%97 = OpCompositeConstruct %6 %100 %103 +%107 = OpLoad %12 %17 +%108 = OpLoad %13 %19 +OpBranch %109 +%109 = OpLabel +%110 = OpCompositeExtract %5 %97 1 +%112 = OpSampledImage %111 %107 %108 +%113 = OpImageSampleImplicitLod %3 %112 %110 +OpStore %104 %113 OpReturn OpFunctionEnd \ No newline at end of file From 23946cd3410f2c7cb440da54d508a1e792f0a7d8 Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Sun, 13 Jul 2025 23:42:55 -0700 Subject: [PATCH 47/84] Updated mesh shading spec, also to include @per_primitive attribute --- docs/api-specs/mesh_shading.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/api-specs/mesh_shading.md b/docs/api-specs/mesh_shading.md index 86ac26be95e..864bbfb9537 100644 --- a/docs/api-specs/mesh_shading.md +++ b/docs/api-specs/mesh_shading.md @@ -87,12 +87,14 @@ This shader stage can be selected by marking a function with `@mesh`. Mesh shade Mesh shaders can be marked with `@payload(someVar)` similar to task shaders. Unlike task shaders, mesh shaders cannot write to this memory. Declaring `@payload` in a pipeline with no task shader, in a pipeline with a task shader that doesn't declare `@payload`, or in a task shader with an `@payload` that is statically sized and smaller than the mesh shader payload is illegal. -Mesh shaders must be marked with `@vertex_output(OutputType, numOutputs)`, where `numOutputs` is the maximum number of vertices to be output by a mesh shader, and `OutputType` is the data associated with vertices, similar to a standard vertex shader output. +Mesh shaders must be marked with `@vertex_output(OutputType, numOutputs)`, where `numOutputs` is the maximum number of vertices to be output by a mesh shader, and `OutputType` is the data associated with vertices, similar to a standard vertex shader output, and must be a struct. Mesh shaders must also be marked with `@primitive_output(OutputType, numOutputs)`, which is similar to `@vertex_output` except it describes the primitive outputs. ### Mesh shader outputs +Vertex outputs from mesh shaders function identically to outputs of vertex shaders, and as such must have a field with `@builtin(position)`. + Primitive outputs from mesh shaders have some additional builtins they can set. These include `@builtin(cull_primitive)`, which must be a boolean value. If this is set to true, then the primitive is skipped during rendering. Mesh shader primitive outputs must also specify exactly one of `@builtin(triangle_indices)`, `@builtin(line_indices)`, or `@builtin(point_index)`. This determines the output topology of the mesh shader, and must match the output topology of the pipeline descriptor the mesh shader is used with. These must be of type `vec3`, `vec2`, and `u32` respectively. When setting this, each of the indices must be less than the number of vertices declared in `setMeshOutputs`. @@ -105,7 +107,9 @@ The mesh shader can write to vertices using the `setVertex(idx: u32, vertex: Ver ### Fragment shader -Fragment shaders may now be passed the primitive info from a mesh shader the same was as they are passed vertex inputs, for example `fn fs_main(vertex: VertexOutput, primitive: PrimitiveOutput)`. The primitive state is part of the fragment input and must match the output of the mesh shader in the pipeline. +Fragment shaders can access vertex output data normally. They can also access primitive output data, provided the input is decorated with `@per_primitive`. The `@per_primitive` attribute can be applied to a value directly, such as `@per_primitive @location(1) value: vec4`, to a struct such as `@per_primitive primitive_input: PrimitiveInput` where `PrimitiveInput` is a struct containing fields decorated with `@location` and `@builtin`, or to members of a struct that are themselves decorated with `@location` or `@builtin`. + +The primitive state is part of the fragment input and must match the output of the mesh shader in the pipeline. Using `@per_primitive` also requires enabling the mesh shader extension. ### Full example @@ -142,9 +146,7 @@ struct PrimitiveOutput { struct PrimitiveInput { @location(1) colorMask: vec4, } -fn test_function(input: u32) { -} @task @payload(taskPayload) @workgroup_size(1) @@ -163,8 +165,6 @@ fn ms_main(@builtin(local_invocation_index) index: u32, @builtin(global_invocati workgroupData = 2.0; var v: VertexOutput; - test_function(1); - v.position = positions[0]; v.color = colors[0] * taskPayload.colorMask; setVertex(0, v); From 471300e494275a95e65a81bb75d67a445437db9d Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Sun, 13 Jul 2025 23:43:56 -0700 Subject: [PATCH 48/84] Final tweaks to the spec --- docs/api-specs/mesh_shading.md | 4 ++-- naga/tests/in/wgsl/mesh-shader.wgsl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/api-specs/mesh_shading.md b/docs/api-specs/mesh_shading.md index 864bbfb9537..4e8042f2176 100644 --- a/docs/api-specs/mesh_shading.md +++ b/docs/api-specs/mesh_shading.md @@ -107,7 +107,7 @@ The mesh shader can write to vertices using the `setVertex(idx: u32, vertex: Ver ### Fragment shader -Fragment shaders can access vertex output data normally. They can also access primitive output data, provided the input is decorated with `@per_primitive`. The `@per_primitive` attribute can be applied to a value directly, such as `@per_primitive @location(1) value: vec4`, to a struct such as `@per_primitive primitive_input: PrimitiveInput` where `PrimitiveInput` is a struct containing fields decorated with `@location` and `@builtin`, or to members of a struct that are themselves decorated with `@location` or `@builtin`. +Fragment shaders can access vertex output data as if it is from a vertex shader. They can also access primitive output data, provided the input is decorated with `@per_primitive`. The `@per_primitive` attribute can be applied to a value directly, such as `@per_primitive @location(1) value: vec4`, to a struct such as `@per_primitive primitive_input: PrimitiveInput` where `PrimitiveInput` is a struct containing fields decorated with `@location` and `@builtin`, or to members of a struct that are themselves decorated with `@location` or `@builtin`. The primitive state is part of the fragment input and must match the output of the mesh shader in the pipeline. Using `@per_primitive` also requires enabling the mesh shader extension. @@ -184,7 +184,7 @@ fn ms_main(@builtin(local_invocation_index) index: u32, @builtin(global_invocati setPrimitive(0, p); } @fragment -fn fs_main(vertex: VertexOutput, primitive: PrimitiveInput) -> @location(0) vec4 { +fn fs_main(vertex: VertexOutput, @per_primitive primitive: PrimitiveInput) -> @location(0) vec4 { return vertex.color * primitive.colorMask; } ``` \ No newline at end of file diff --git a/naga/tests/in/wgsl/mesh-shader.wgsl b/naga/tests/in/wgsl/mesh-shader.wgsl index 6e8fe3f05f9..f12c2ad5c69 100644 --- a/naga/tests/in/wgsl/mesh-shader.wgsl +++ b/naga/tests/in/wgsl/mesh-shader.wgsl @@ -66,6 +66,6 @@ fn ms_main(@builtin(local_invocation_index) index: u32, @builtin(global_invocati setPrimitive(0, p); } @fragment -fn fs_main(vertex: VertexOutput, primitive: PrimitiveInput) -> @location(0) vec4 { +fn fs_main(vertex: VertexOutput, @per_primitive primitive: PrimitiveInput) -> @location(0) vec4 { return vertex.color * primitive.colorMask; } \ No newline at end of file From 44f71b18b9f74ed80398cbc52ae24532204f1381 Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Mon, 14 Jul 2025 02:46:42 -0500 Subject: [PATCH 49/84] Small tweaks --- naga/src/back/spv/block.rs | 8 ++-- naga/src/back/spv/writer.rs | 83 ++++++++----------------------------- naga/src/proc/mod.rs | 3 +- naga/src/valid/interface.rs | 3 +- 4 files changed, 23 insertions(+), 74 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 908ce960bdc..46d0caf288c 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -235,7 +235,7 @@ impl Writer { res_member.type_id, member_value_id, value_id, - &[index as Word], + &[index as u32], )); member_value_id } @@ -3257,10 +3257,8 @@ impl BlockContext<'_> { ); return Ok(BlockExitDisposition::Discarded); } - Statement::Return { - value: Some(output), - } => { - let value_id = self.cached[output]; + Statement::Return { value: Some(value) } => { + let value_id = self.cached[value]; let instruction = match self.function.entry_point_context { // If this is an entry point, and we need to return anything, // let's instead store the output variables and return `void`. diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index d8ed7e09292..94f2f9c261d 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -855,12 +855,13 @@ impl Writer { let type_id = self.get_handle_type_id(member.ty); let name = member.name.as_deref(); let binding = member.binding.as_ref().unwrap(); - if binding.to_built_in() == Some(crate::BuiltIn::MeshTaskSize) { - continue; - } has_point_size |= *binding == crate::Binding::BuiltIn(crate::BuiltIn::PointSize); - let varying_id = { + let varying_id = if *binding + == crate::Binding::BuiltIn(crate::BuiltIn::MeshTaskSize) + { + 0 + } else { let varying_id = self.write_varying( ir_module, iface.stage, @@ -872,7 +873,6 @@ impl Writer { iface.varying_ids.push(varying_id); varying_id }; - iface.varying_ids.push(varying_id); ep_context.results.push(ResultMember { id: varying_id, type_id, @@ -979,7 +979,7 @@ impl Writer { continue; } - let mut gv: GlobalVariable = self.global_variables[handle].clone(); + let mut gv = self.global_variables[handle].clone(); if let Some(ref mut iface) = interface { // Have to include global variables in the interface if self.physical_layout.version >= 0x10400 && iface.task_payload != Some(handle) { @@ -2483,65 +2483,6 @@ impl Writer { .insert(output_type, info.clone()); }; info - - // We generate the array and pointer types here, even if they weren't in the module's type arena - /*let array_type_id = self.id_gen.next(); - Instruction::type_array(array_type_id, type_id, len_value_id) - .to_words(&mut self.logical_layout.declarations); - let array_ptr_type_id = self.id_gen.next(); - Instruction::type_pointer( - array_ptr_type_id, - spirv::StorageClass::Output, - array_type_id, - ) - .to_words(&mut self.logical_layout.declarations); - - // Create the actual variable - let var_id = self.id_gen.next(); - if self.flags.contains(WriterFlags::DEBUG) { - if let Some(ref name) = ir_module.types[output_type].name { - self.debugs.push(Instruction::name(var_id, name)); - } - } - Instruction::variable(array_ptr_type_id, var_id, spirv::StorageClass::Output, None) - .to_words(&mut self.logical_layout.declarations); - if is_primitive { - Instruction::decorate(var_id, spirv::Decoration::PerPrimitiveEXT, &[]) - .to_words(&mut self.logical_layout.annotations); - } - - let info = super::MeshOutputInfo { - index_of_length_decl: len_literal_idx, - array_type: array_type_id, - var_id, - inner_type: type_id, - ptr_type: ptr_type_id, - array_ptr_type: array_ptr_type_id, - }; - entry.insert(info); - - if let crate::TypeInner::Struct { ref members, .. } = - ir_module.types[output_type].inner - { - for (idx, member) in members.iter().enumerate() { - if member.binding.is_none() { - continue; - } - let binding = self.map_binding( - ir_module, - crate::ShaderStage::Mesh, - spirv::StorageClass::Output, - member.ty, - member.binding.as_ref().unwrap(), - )?; - self.write_binding_struct_member(type_id, idx as Word, binding); - } - } else { - unreachable!("Mesh output type isn't a struct"); - } - self.decorate(type_id, spirv::Decoration::Block, &[]); - - info*/ } }; @@ -2813,9 +2754,19 @@ impl Writer { let mut has_ray_query = ir_module.special_types.ray_desc.is_some() | ir_module.special_types.ray_intersection.is_some(); let has_vertex_return = ir_module.special_types.ray_vertex_return.is_some(); + // Ways mesh shaders are required: + // * Mesh entry point used + // * Mesh function like setVertex used outside mesh entry point, this is handled elsewhere + // * Task payload global variable + // * Fragment shader with per primitive data (currently unhandle by naga in general) + + // TODO: check for that last condition let has_mesh_shaders = ir_module.entry_points.iter().any(|entry| { entry.stage == crate::ShaderStage::Mesh || entry.stage == crate::ShaderStage::Task - }); + }) || ir_module + .global_variables + .iter() + .any(|gvar| gvar.1.space == crate::AddressSpace::TaskPayload); for (_, &crate::Type { ref inner, .. }) in ir_module.types.iter() { // spirv does not know whether these have vertex return - that is done by us diff --git a/naga/src/proc/mod.rs b/naga/src/proc/mod.rs index f2487f393ba..686f2a5dd69 100644 --- a/naga/src/proc/mod.rs +++ b/naga/src/proc/mod.rs @@ -177,7 +177,8 @@ impl super::AddressSpace { crate::AddressSpace::Storage { access } => access, crate::AddressSpace::Handle => Sa::LOAD, crate::AddressSpace::PushConstant => Sa::LOAD, - // TODO: change this to reflect the different accesses by shader stage + // TaskPayload isn't always writable, but this is checked for elsewhere, + // when not using multiple payloads and matching the entry payload is checked. crate::AddressSpace::TaskPayload => Sa::LOAD | Sa::STORE, } } diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index 1d243435b49..e57c72e6094 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -644,7 +644,6 @@ impl super::Validator { TypeFlags::CONSTRUCTIBLE | TypeFlags::CREATION_RESOLVED, false, ), - // TODO: investigate how TaskPayload compares crate::AddressSpace::WorkGroup | crate::AddressSpace::TaskPayload => { (TypeFlags::DATA | TypeFlags::SIZED, false) } @@ -891,7 +890,6 @@ impl super::Validator { } => storage_usage(access), _ => GlobalUse::READ | GlobalUse::QUERY, }, - // TODO: update this to reflect the nuance around taskpayload(writable in task stage, readable in mesh stage) crate::AddressSpace::Private | crate::AddressSpace::WorkGroup => { GlobalUse::READ | GlobalUse::WRITE | GlobalUse::QUERY } @@ -929,6 +927,7 @@ impl super::Validator { if let &Some(ref mesh_info) = &ep.mesh_info { // Technically it is allowed to not output anything + // TODO: check that only the allowed builtins are used here if let Some(used_vertex_type) = info.mesh_shader_info.vertex_type { if used_vertex_type.0 != mesh_info.vertex_output_type { return Err(EntryPointError::WrongMeshOutputType From c7a728c89d3b441084ef7e43e10777b76781ea8d Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Mon, 14 Jul 2025 03:04:28 -0500 Subject: [PATCH 50/84] A few more small tweaks --- naga/src/back/hlsl/conv.rs | 1 - naga/src/back/hlsl/writer.rs | 4 ++-- naga/src/back/msl/writer.rs | 5 +---- naga/src/back/wgsl/writer.rs | 3 ++- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/naga/src/back/hlsl/conv.rs b/naga/src/back/hlsl/conv.rs index dbf7bea93fb..d6ccc5ec6e4 100644 --- a/naga/src/back/hlsl/conv.rs +++ b/naga/src/back/hlsl/conv.rs @@ -184,7 +184,6 @@ impl crate::BuiltIn { return Err(Error::Custom(format!("Unsupported builtin {self:?}"))) } Self::CullPrimitive => "SV_CullPrimitive", - // TODO: make this work Self::PointIndex | Self::LineIndices | Self::TriangleIndices => unimplemented!(), Self::MeshTaskSize => unreachable!(), }) diff --git a/naga/src/back/hlsl/writer.rs b/naga/src/back/hlsl/writer.rs index c943f6eefee..13a2790ce7f 100644 --- a/naga/src/back/hlsl/writer.rs +++ b/naga/src/back/hlsl/writer.rs @@ -936,12 +936,12 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { self.write_type(module, global.ty)?; "" } - // TODO: verify this is correct - crate::AddressSpace::WorkGroup | crate::AddressSpace::TaskPayload => { + crate::AddressSpace::WorkGroup => { write!(self.out, "groupshared ")?; self.write_type(module, global.ty)?; "" } + crate::AddressSpace::TaskPayload => unimplemented!(), crate::AddressSpace::Uniform => { // constant buffer declarations are expected to be inlined, e.g. // `cbuffer foo: register(b0) { field1: type1; }` diff --git a/naga/src/back/msl/writer.rs b/naga/src/back/msl/writer.rs index f823cf6b2f7..bb8b52079a8 100644 --- a/naga/src/back/msl/writer.rs +++ b/naga/src/back/msl/writer.rs @@ -591,8 +591,7 @@ impl crate::AddressSpace { // may end up with "const" even if the binding is read-write, // and that should be OK. Self::Storage { .. } => true, - // TODO: investigate this more - Self::TaskPayload => true, + Self::TaskPayload => unimplemented!(), // These should always be read-write. Self::Private | Self::WorkGroup => false, // These translate to `constant` address space, no need for qualifiers. @@ -6180,7 +6179,6 @@ template LocationMode::Uniform, false, ), - // TODO: figure out what the location mode stuff means and stuff crate::ShaderStage::Task | crate::ShaderStage::Mesh => unimplemented!(), }; @@ -6245,7 +6243,6 @@ template } } crate::AddressSpace::TaskPayload => { - // TODO: figure this out unimplemented!() } crate::AddressSpace::Function diff --git a/naga/src/back/wgsl/writer.rs b/naga/src/back/wgsl/writer.rs index b6979a04b5d..7a41d9fe611 100644 --- a/naga/src/back/wgsl/writer.rs +++ b/naga/src/back/wgsl/writer.rs @@ -186,10 +186,11 @@ impl Writer { for (index, ep) in module.entry_points.iter().enumerate() { let attributes = match ep.stage { ShaderStage::Vertex | ShaderStage::Fragment => vec![Attribute::Stage(ep.stage)], - ShaderStage::Compute | ShaderStage::Mesh | ShaderStage::Task => vec![ + ShaderStage::Compute => vec![ Attribute::Stage(ep.stage), Attribute::WorkGroupSize(ep.workgroup_size), ], + ShaderStage::Mesh | ShaderStage::Task => unreachable!(), }; self.write_attributes(&attributes)?; From a5f30c8292606a30ab0751a8441a8983c9ae189f Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Mon, 14 Jul 2025 03:20:10 -0500 Subject: [PATCH 51/84] More nitpicky tweaks, next focus is actually addressing the problem in spirv writing --- naga/src/back/glsl/mod.rs | 19 +++++-------------- naga/src/back/wgsl/writer.rs | 27 ++------------------------- naga/src/compact/mod.rs | 14 +++++++++++++- 3 files changed, 20 insertions(+), 40 deletions(-) diff --git a/naga/src/back/glsl/mod.rs b/naga/src/back/glsl/mod.rs index d45949b4cef..83c5f5d4e8e 100644 --- a/naga/src/back/glsl/mod.rs +++ b/naga/src/back/glsl/mod.rs @@ -1670,7 +1670,6 @@ impl<'a, W: Write> Writer<'a, W> { // We ignore all interpolation and auxiliary modifiers that aren't used in fragment // shaders' input globals or vertex shaders' output globals. let emit_interpolation_and_auxiliary = match self.entry_point.stage { - // TODO: make this more nuanced for mesh and fragment shaders which can have per primitive and per vertex data ShaderStage::Vertex => output, ShaderStage::Fragment => !output, ShaderStage::Compute => false, @@ -2673,19 +2672,11 @@ impl<'a, W: Write> Writer<'a, W> { self.write_image_atomic(ctx, image, coordinate, array_index, fun, value)? } Statement::RayQuery { .. } => unreachable!(), - Statement::MeshFunction(crate::MeshFunction::SetMeshOutputs { - vertex_count, - primitive_count, - }) => { - write!(self.out, "{level}SetMeshOutputsEXT(")?; - self.write_expr(vertex_count, ctx)?; - write!(self.out, ", ")?; - self.write_expr(primitive_count, ctx)?; - write!(self.out, ");")?; - } Statement::MeshFunction( - crate::MeshFunction::SetVertex { .. } | crate::MeshFunction::SetPrimitive { .. }, - ) => unimplemented!(), + crate::MeshFunction::SetMeshOutputs { .. } + | crate::MeshFunction::SetVertex { .. } + | crate::MeshFunction::SetPrimitive { .. }, + ) => unreachable!(), Statement::SubgroupBallot { result, predicate } => { write!(self.out, "{level}")?; let res_name = Baked(result).to_string(); @@ -5284,7 +5275,7 @@ const fn glsl_storage_qualifier(space: crate::AddressSpace) -> Option<&'static s As::Handle => Some("uniform"), As::WorkGroup => Some("shared"), As::PushConstant => Some("uniform"), - As::TaskPayload => Some("taskPayloadSharedEXT"), + As::TaskPayload => unreachable!(), } } diff --git a/naga/src/back/wgsl/writer.rs b/naga/src/back/wgsl/writer.rs index 7a41d9fe611..278d7e43269 100644 --- a/naga/src/back/wgsl/writer.rs +++ b/naga/src/back/wgsl/writer.rs @@ -187,7 +187,7 @@ impl Writer { let attributes = match ep.stage { ShaderStage::Vertex | ShaderStage::Fragment => vec![Attribute::Stage(ep.stage)], ShaderStage::Compute => vec![ - Attribute::Stage(ep.stage), + Attribute::Stage(ShaderStage::Compute), Attribute::WorkGroupSize(ep.workgroup_size), ], ShaderStage::Mesh | ShaderStage::Task => unreachable!(), @@ -839,30 +839,7 @@ impl Writer { } } Statement::RayQuery { .. } => unreachable!(), - Statement::MeshFunction(crate::MeshFunction::SetMeshOutputs { - vertex_count, - primitive_count, - }) => { - write!(self.out, "{level}setMeshOutputs(")?; - self.write_expr(module, vertex_count, func_ctx)?; - write!(self.out, ", ")?; - self.write_expr(module, primitive_count, func_ctx)?; - writeln!(self.out, ");")?; - } - Statement::MeshFunction(crate::MeshFunction::SetVertex { index, value }) => { - write!(self.out, "{level}setVertex(")?; - self.write_expr(module, index, func_ctx)?; - write!(self.out, ", ")?; - self.write_expr(module, value, func_ctx)?; - writeln!(self.out, ");")?; - } - Statement::MeshFunction(crate::MeshFunction::SetPrimitive { index, value }) => { - write!(self.out, "{level}setPrimitive(")?; - self.write_expr(module, index, func_ctx)?; - write!(self.out, ", ")?; - self.write_expr(module, value, func_ctx)?; - writeln!(self.out, ");")?; - } + Statement::MeshFunction(..) => unreachable!(), Statement::SubgroupBallot { result, predicate } => { write!(self.out, "{level}")?; let res_name = Baked(result).to_string(); diff --git a/naga/src/compact/mod.rs b/naga/src/compact/mod.rs index 2bc80f52ef3..66d59f0246e 100644 --- a/naga/src/compact/mod.rs +++ b/naga/src/compact/mod.rs @@ -244,7 +244,19 @@ pub fn compact(module: &mut crate::Module, keep_unused: KeepUnused) { } } if entry.stage == crate::ShaderStage::Task || entry.stage == crate::ShaderStage::Mesh { - // TODO: make sure u32 is preserved + // u32 should always be there if the module is valid, as it is e.g. the type of some expressions + let u32_type = module + .types + .iter() + .find_map(|tuple| { + if tuple.1.inner == crate::TypeInner::Scalar(crate::Scalar::U32) { + Some(tuple.0) + } else { + None + } + }) + .unwrap(); + module_tracer.types_used.insert(u32_type); } } From 6df6e11ee65e0434f9347f9767a9102c089b22a6 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Mon, 14 Jul 2025 11:35:08 -0500 Subject: [PATCH 52/84] Pushing broken changes for now because I have to switch dev platforms due to constant crashes --- naga/src/back/spv/block.rs | 22 ++++------------------ naga/src/back/spv/mod.rs | 7 +++---- naga/src/back/spv/writer.rs | 28 ++++++++++++---------------- 3 files changed, 19 insertions(+), 38 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 46d0caf288c..8bcd6ece085 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -3702,23 +3702,9 @@ impl BlockContext<'_> { 0, )?; - let mut builtin_idx = 0; - let mut location_idx = 0; - for (i, member) in info.fields.iter().enumerate() { - let member_ty = self.writer.get_handle_type_id(member.ty); - let (array, idx) = match member.binding { - Some(crate::Binding::BuiltIn(_)) => { - builtin_idx += 1; - (info.builtin_output.unwrap(), builtin_idx - 1) - } - Some(crate::Binding::Location { .. }) => { - location_idx += 1; - (info.location_output.unwrap(), location_idx - 1) - } - None => continue, - }; + for (i, member_info) in info.outputs.iter().enumerate() { + let member_ty = info.inner_type; - let idx_const = self.writer.get_constant_scalar(crate::Literal::U32(idx)); let in_value_id = self.gen_id(); block.body.push(Instruction::composite_extract( member_ty, @@ -3730,8 +3716,8 @@ impl BlockContext<'_> { block.body.push(Instruction::access_chain( self.get_pointer_type_id(member_ty, spirv::StorageClass::Output), out_ptr_id, - array.var_id, - &[self.cached[index], idx_const], + member_info.var_id, + &[self.cached[index]], )); block .body diff --git a/naga/src/back/spv/mod.rs b/naga/src/back/spv/mod.rs index fd48d64b38e..42168f6d623 100644 --- a/naga/src/back/spv/mod.rs +++ b/naga/src/back/spv/mod.rs @@ -933,13 +933,12 @@ pub struct MeshOutputInfo { pub inner_type: Word, // Structs with elements with layout can't have elements with builtins, and vice versa. // Therefore, we separate it into 2 structs and whatnot - pub builtin_output: Option, - pub location_output: Option, - pub fields: Vec, + pub outputs: Vec, } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MeshOutputArrayInfo { pub inner_type: Word, pub array_type: Word, pub var_id: Word, + pub member: crate::StructMember, } diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 94f2f9c261d..bc8f2fb1ddd 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -931,17 +931,8 @@ impl Writer { true, mesh_info.max_primitives, )?; - - for info in [ - &vert_info.location_output, - &vert_info.builtin_output, - &prim_info.location_output, - &prim_info.builtin_output, - ] - .into_iter() - .flatten() - { - iface.varying_ids.push(info.var_id); + for array in vert_info.outputs.iter().chain(prim_info.outputs.iter()) { + iface.varying_ids.push(array.var_id); } } } @@ -2359,7 +2350,7 @@ impl Writer { _ => unreachable!("Mesh output type isn't a struct"), }; - let (location_type_id, builtin_type_id) = { + /*let (location_type_id, builtin_type_id) = { let mut location_type_id = None; let mut builtin_type_id = None; let mut location_ins = Instruction::type_struct(0, &[]); @@ -2464,14 +2455,19 @@ impl Writer { }; let location_output = location_type_id.map(&mut to_array_info); - let builtin_output = builtin_type_id.map(to_array_info); + let builtin_output = builtin_type_id.map(to_array_info);*/ + + let mut outputs = Vec::new(); + + for member in struct_members { + let member_ty = self.get_handle_type_id(member.ty); + let array_ty = self.id_gen.next(); + } let info = super::MeshOutputInfo { inner_type: main_type_id, index_of_length_decl: len_literal_idx, - fields: struct_members, - builtin_output, - location_output, + outputs, }; if is_primitive { self.mesh_state From cc865bb106aaa20cfee66f16f63c4cf9998829c4 Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Mon, 14 Jul 2025 11:59:16 -0500 Subject: [PATCH 53/84] Updated to not have 2 arrays of structs (gross) --- naga/src/back/spv/block.rs | 2 +- naga/src/back/spv/mod.rs | 6 +- naga/src/back/spv/writer.rs | 136 ++++++++-------------------- naga/tests/in/wgsl/mesh-shader.wgsl | 2 +- 4 files changed, 42 insertions(+), 104 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 8bcd6ece085..3521ab2738d 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -3703,7 +3703,7 @@ impl BlockContext<'_> { )?; for (i, member_info) in info.outputs.iter().enumerate() { - let member_ty = info.inner_type; + let member_ty = member_info.member_ty; let in_value_id = self.gen_id(); block.body.push(Instruction::composite_extract( diff --git a/naga/src/back/spv/mod.rs b/naga/src/back/spv/mod.rs index 42168f6d623..1bc4fc95401 100644 --- a/naga/src/back/spv/mod.rs +++ b/naga/src/back/spv/mod.rs @@ -930,15 +930,15 @@ pub struct MeshOutputInfo { /// of the max output sizes among all the entry points! It will default to zero, so that if an unused function /// tries to write to it, the function can still be valid if it is never called. pub index_of_length_decl: usize, - pub inner_type: Word, + pub inner_ty: Word, // Structs with elements with layout can't have elements with builtins, and vice versa. // Therefore, we separate it into 2 structs and whatnot pub outputs: Vec, } #[derive(Clone)] pub struct MeshOutputArrayInfo { - pub inner_type: Word, - pub array_type: Word, + pub member_ty: Word, + pub array_ty: Word, pub var_id: Word, pub member: crate::StructMember, } diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index bc8f2fb1ddd..9430f541a00 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -2023,7 +2023,12 @@ impl Writer { } let binding = self.map_binding(ir_module, stage, class, ty, binding)?; + self.write_binding(id, binding); + Ok(id) + } + + pub fn write_binding(&mut self, id: Word, binding: BindingDecorations) { match binding { BindingDecorations::None => (), BindingDecorations::BuiltIn(bi, others) => { @@ -2046,8 +2051,6 @@ impl Writer { } } } - - Ok(id) } pub fn write_binding_struct_member( @@ -2350,93 +2353,19 @@ impl Writer { _ => unreachable!("Mesh output type isn't a struct"), }; - /*let (location_type_id, builtin_type_id) = { - let mut location_type_id = None; - let mut builtin_type_id = None; - let mut location_ins = Instruction::type_struct(0, &[]); - let mut builtin_ins = Instruction::type_struct(0, &[]); - for member in &struct_members { - let binding = if let &Some(ref b) = &member.binding { - b - } else { - continue; - }; - let (subset_type_id, member_idx) = - if matches!(binding, &crate::Binding::Location { .. }) { - if location_type_id.is_none() { - location_type_id = Some(self.id_gen.next()); - location_ins.result_id = location_type_id; - } - location_ins.add_operand(self.get_handle_type_id(member.ty)); - (location_type_id.unwrap(), location_ins.operands.len() - 1) - } else if matches!(binding, &crate::Binding::BuiltIn(..)) { - if builtin_type_id.is_none() { - builtin_type_id = Some(self.id_gen.next()); - builtin_ins.result_id = builtin_type_id; - } - builtin_ins.add_operand(self.get_handle_type_id(member.ty)); - (builtin_type_id.unwrap(), builtin_ins.operands.len() - 1) - } else { - unreachable!() - }; - // TODO: update the offset - self.decorate_struct_member( - subset_type_id, - member_idx, - member, - &ir_module.types, - )?; - let binding = self.map_binding( - ir_module, - crate::ShaderStage::Mesh, - spirv::StorageClass::Output, - member.ty, - member.binding.as_ref().unwrap(), - )?; - self.write_binding_struct_member( - subset_type_id, - member_idx as Word, - binding, - ); - } - if let Some(location_type_id) = location_type_id { - location_ins.result_id = Some(location_type_id); - location_ins.to_words(&mut self.logical_layout.declarations); - self.decorate(location_type_id, spirv::Decoration::Block, &[]); - if self.flags.contains(WriterFlags::DEBUG) { - if let Some(ref name) = main_ty_ir.name { - let mut n = String::new(); - n.push_str("__"); - n.push_str(name); - n.push_str("_LocationOutputs"); - self.debugs.push(Instruction::name(location_type_id, &n)); - } - } - } - if let Some(builtin_type_id) = builtin_type_id { - builtin_ins.result_id = Some(builtin_type_id); - builtin_ins.to_words(&mut self.logical_layout.declarations); - self.decorate(builtin_type_id, spirv::Decoration::Block, &[]); - if self.flags.contains(WriterFlags::DEBUG) { - if let Some(ref name) = main_ty_ir.name { - let mut n = String::new(); - n.push_str("__"); - n.push_str(name); - n.push_str("_BuiltinOutputs"); - self.debugs.push(Instruction::name(builtin_type_id, &n)); - } - } - } - (location_type_id, builtin_type_id) - }; + let mut outputs = Vec::new(); - let mut to_array_info = |base_id| { - let array_type = self.id_gen.next(); - Instruction::type_array(array_type, base_id, len_value_id) + for member in struct_members { + if member.binding.is_none() { + continue; + } + let member_ty = self.get_handle_type_id(member.ty); + let array_ty = self.id_gen.next(); + Instruction::type_array(array_ty, member_ty, len_value_id) .to_words(&mut self.logical_layout.declarations); let var_id = self.id_gen.next(); Instruction::variable( - self.get_pointer_type_id(array_type, spirv::StorageClass::Output), + self.get_pointer_type_id(array_ty, spirv::StorageClass::Output), var_id, spirv::StorageClass::Output, None, @@ -2447,25 +2376,34 @@ impl Writer { self.decorate(var_id, spirv::Decoration::PerPrimitiveEXT, &[]); } - super::MeshOutputArrayInfo { - inner_type: base_id, - array_type, - var_id, - } - }; - - let location_output = location_type_id.map(&mut to_array_info); - let builtin_output = builtin_type_id.map(to_array_info);*/ + let binding = self.map_binding( + ir_module, + crate::ShaderStage::Mesh, + spirv::StorageClass::Output, + member.ty, + member.binding.as_ref().unwrap(), + )?; + self.write_binding(var_id, binding); - let mut outputs = Vec::new(); + if self + .flags + .contains(WriterFlags::DEBUG | WriterFlags::LABEL_VARYINGS) + { + if let Some(name) = member.name.as_deref() { + self.debugs.push(Instruction::name(var_id, name)); + } + } - for member in struct_members { - let member_ty = self.get_handle_type_id(member.ty); - let array_ty = self.id_gen.next(); + outputs.push(super::MeshOutputArrayInfo { + member_ty, + array_ty, + var_id, + member, + }) } let info = super::MeshOutputInfo { - inner_type: main_type_id, + inner_ty: main_type_id, index_of_length_decl: len_literal_idx, outputs, }; diff --git a/naga/tests/in/wgsl/mesh-shader.wgsl b/naga/tests/in/wgsl/mesh-shader.wgsl index f12c2ad5c69..6e8fe3f05f9 100644 --- a/naga/tests/in/wgsl/mesh-shader.wgsl +++ b/naga/tests/in/wgsl/mesh-shader.wgsl @@ -66,6 +66,6 @@ fn ms_main(@builtin(local_invocation_index) index: u32, @builtin(global_invocati setPrimitive(0, p); } @fragment -fn fs_main(vertex: VertexOutput, @per_primitive primitive: PrimitiveInput) -> @location(0) vec4 { +fn fs_main(vertex: VertexOutput, primitive: PrimitiveInput) -> @location(0) vec4 { return vertex.color * primitive.colorMask; } \ No newline at end of file From 291d56c160c493982e56dc92578515b627461a01 Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Mon, 14 Jul 2025 12:02:51 -0500 Subject: [PATCH 54/84] Updated snapshots --- naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm | 2 +- naga/tests/out/spv/wgsl-clip-distances.spvasm | 2 +- naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm | 6 +++--- naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm | 6 +++--- naga/tests/out/spv/wgsl-dualsource.spvasm | 2 +- naga/tests/out/spv/wgsl-interface.fragment.spvasm | 2 +- naga/tests/out/spv/wgsl-interface.vertex.spvasm | 2 +- naga/tests/out/spv/wgsl-interpolate_compat.spvasm | 2 +- naga/tests/out/spv/wgsl-quad.spvasm | 2 +- naga/tests/out/spv/wgsl-shadow.spvasm | 2 +- naga/tests/out/spv/wgsl-skybox.spvasm | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm b/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm index 4d306c2a056..57e08b61d92 100644 --- a/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm +++ b/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm @@ -5,7 +5,7 @@ OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %14 "vs" %8 %11 %11 %13 %13 +OpEntryPoint Vertex %14 "vs" %8 %11 %13 OpEntryPoint Fragment %33 "fs" %31 OpExecutionMode %33 OriginUpperLeft OpMemberDecorate %6 0 Offset 0 diff --git a/naga/tests/out/spv/wgsl-clip-distances.spvasm b/naga/tests/out/spv/wgsl-clip-distances.spvasm index 9f400a70bf9..482f13fac12 100644 --- a/naga/tests/out/spv/wgsl-clip-distances.spvasm +++ b/naga/tests/out/spv/wgsl-clip-distances.spvasm @@ -6,7 +6,7 @@ OpCapability Shader OpCapability ClipDistance %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %13 "main" %10 %10 %12 %12 +OpEntryPoint Vertex %13 "main" %10 %12 OpDecorate %5 ArrayStride 4 OpMemberDecorate %8 0 Offset 0 OpMemberDecorate %8 1 Offset 16 diff --git a/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm b/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm index bb2b9a534b9..4d978decc9c 100644 --- a/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm +++ b/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm @@ -7,9 +7,9 @@ OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %367 "gen_terrain_compute" %364 -OpEntryPoint Vertex %442 "gen_terrain_vertex" %435 %438 %438 %440 %440 %441 %441 -OpEntryPoint Fragment %494 "gen_terrain_fragment" %483 %485 %488 %491 %491 %493 %493 -OpEntryPoint Vertex %589 "vs_main" %580 %583 %585 %585 %587 %587 %588 %588 +OpEntryPoint Vertex %442 "gen_terrain_vertex" %435 %438 %440 %441 +OpEntryPoint Fragment %494 "gen_terrain_fragment" %483 %485 %488 %491 %493 +OpEntryPoint Vertex %589 "vs_main" %580 %583 %585 %587 %588 OpEntryPoint Fragment %615 "fs_main" %607 %609 %611 %613 OpExecutionMode %367 LocalSize 64 1 1 OpExecutionMode %494 OriginUpperLeft diff --git a/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm b/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm index d68a0128dd8..ad2d2f9a434 100644 --- a/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm +++ b/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm @@ -7,9 +7,9 @@ OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %367 "gen_terrain_compute" %364 -OpEntryPoint Vertex %442 "gen_terrain_vertex" %435 %438 %438 %440 %440 %441 %441 -OpEntryPoint Fragment %494 "gen_terrain_fragment" %483 %485 %488 %491 %491 %493 %493 -OpEntryPoint Vertex %589 "vs_main" %580 %583 %585 %585 %587 %587 %588 %588 +OpEntryPoint Vertex %442 "gen_terrain_vertex" %435 %438 %440 %441 +OpEntryPoint Fragment %494 "gen_terrain_fragment" %483 %485 %488 %491 %493 +OpEntryPoint Vertex %589 "vs_main" %580 %583 %585 %587 %588 OpEntryPoint Fragment %615 "fs_main" %607 %609 %611 %613 OpExecutionMode %367 LocalSize 64 1 1 OpExecutionMode %494 OriginUpperLeft diff --git a/naga/tests/out/spv/wgsl-dualsource.spvasm b/naga/tests/out/spv/wgsl-dualsource.spvasm index 0626a9f877e..c904f713684 100644 --- a/naga/tests/out/spv/wgsl-dualsource.spvasm +++ b/naga/tests/out/spv/wgsl-dualsource.spvasm @@ -5,7 +5,7 @@ OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %10 "main" %7 %7 %9 %9 +OpEntryPoint Fragment %10 "main" %7 %9 OpExecutionMode %10 OriginUpperLeft OpMemberDecorate %5 0 Offset 0 OpMemberDecorate %5 1 Offset 16 diff --git a/naga/tests/out/spv/wgsl-interface.fragment.spvasm b/naga/tests/out/spv/wgsl-interface.fragment.spvasm index 629c1ec8257..00eb33744d8 100644 --- a/naga/tests/out/spv/wgsl-interface.fragment.spvasm +++ b/naga/tests/out/spv/wgsl-interface.fragment.spvasm @@ -6,7 +6,7 @@ OpCapability Shader OpCapability SampleRateShading %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %34 "fragment" %16 %19 %22 %25 %28 %30 %30 %32 %32 %33 %33 +OpEntryPoint Fragment %34 "fragment" %16 %19 %22 %25 %28 %30 %32 %33 OpExecutionMode %34 OriginUpperLeft OpExecutionMode %34 DepthReplacing OpMemberDecorate %5 0 Offset 0 diff --git a/naga/tests/out/spv/wgsl-interface.vertex.spvasm b/naga/tests/out/spv/wgsl-interface.vertex.spvasm index 885fd0434b6..b54d77b9482 100644 --- a/naga/tests/out/spv/wgsl-interface.vertex.spvasm +++ b/naga/tests/out/spv/wgsl-interface.vertex.spvasm @@ -5,7 +5,7 @@ OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %28 "vertex" %15 %18 %20 %22 %22 %24 %24 %25 +OpEntryPoint Vertex %28 "vertex" %15 %18 %20 %22 %24 %25 OpMemberDecorate %5 0 Offset 0 OpMemberDecorate %5 1 Offset 16 OpMemberDecorate %7 0 Offset 0 diff --git a/naga/tests/out/spv/wgsl-interpolate_compat.spvasm b/naga/tests/out/spv/wgsl-interpolate_compat.spvasm index 7ead0a93ede..94d8a65d335 100644 --- a/naga/tests/out/spv/wgsl-interpolate_compat.spvasm +++ b/naga/tests/out/spv/wgsl-interpolate_compat.spvasm @@ -6,7 +6,7 @@ OpCapability Shader OpCapability SampleRateShading %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %26 "vert_main" %11 %11 %13 %13 %14 %14 %15 %15 %16 %16 %17 %17 %18 %18 %19 %19 %20 %20 %21 %21 %22 %22 %23 +OpEntryPoint Vertex %26 "vert_main" %11 %13 %14 %15 %16 %17 %18 %19 %20 %21 %22 %23 OpEntryPoint Fragment %128 "frag_main" %101 %104 %107 %109 %112 %115 %118 %120 %122 %124 %126 OpExecutionMode %128 OriginUpperLeft %3 = OpString "interpolate_compat.wgsl" diff --git a/naga/tests/out/spv/wgsl-quad.spvasm b/naga/tests/out/spv/wgsl-quad.spvasm index 64677c3b2f9..dbe498a7c1e 100644 --- a/naga/tests/out/spv/wgsl-quad.spvasm +++ b/naga/tests/out/spv/wgsl-quad.spvasm @@ -5,7 +5,7 @@ OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %24 "vert_main" %16 %19 %21 %21 %23 %23 +OpEntryPoint Vertex %24 "vert_main" %16 %19 %21 %23 OpEntryPoint Fragment %45 "frag_main" %41 %43 OpEntryPoint Fragment %61 "fs_extra" %60 OpExecutionMode %45 OriginUpperLeft diff --git a/naga/tests/out/spv/wgsl-shadow.spvasm b/naga/tests/out/spv/wgsl-shadow.spvasm index b0736171ef5..b6d6a3486e1 100644 --- a/naga/tests/out/spv/wgsl-shadow.spvasm +++ b/naga/tests/out/spv/wgsl-shadow.spvasm @@ -6,7 +6,7 @@ OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %84 "vs_main" %75 %78 %80 %80 %82 %82 %83 %83 +OpEntryPoint Vertex %84 "vs_main" %75 %78 %80 %82 %83 OpEntryPoint Fragment %143 "fs_main" %133 %136 %139 %141 OpEntryPoint Fragment %228 "fs_main_without_storage" %221 %223 %225 %227 OpExecutionMode %143 OriginUpperLeft diff --git a/naga/tests/out/spv/wgsl-skybox.spvasm b/naga/tests/out/spv/wgsl-skybox.spvasm index 722f5cf974a..45df3166133 100644 --- a/naga/tests/out/spv/wgsl-skybox.spvasm +++ b/naga/tests/out/spv/wgsl-skybox.spvasm @@ -5,7 +5,7 @@ OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %45 "vs_main" %39 %42 %42 %44 %44 +OpEntryPoint Vertex %45 "vs_main" %39 %42 %44 OpEntryPoint Fragment %106 "fs_main" %98 %101 %104 OpExecutionMode %106 OriginUpperLeft OpMemberDecorate %6 0 Offset 0 From e8585833babe812215b65f13e0d8a5405b255b48 Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Mon, 14 Jul 2025 12:14:19 -0500 Subject: [PATCH 55/84] Tried to hopefully fix stupid issue --- naga/src/back/spv/writer.rs | 2 +- .../spv/wgsl-6438-conflicting-idents.spvasm | 62 +-- naga/tests/out/spv/wgsl-clip-distances.spvasm | 45 +- .../spv/wgsl-debug-symbol-large-source.spvasm | 516 +++++++++--------- .../out/spv/wgsl-debug-symbol-terrain.spvasm | 516 +++++++++--------- naga/tests/out/spv/wgsl-dualsource.spvasm | 2 +- .../out/spv/wgsl-interface.fragment.spvasm | 57 +- .../out/spv/wgsl-interface.vertex.spvasm | 14 +- .../out/spv/wgsl-interpolate_compat.spvasm | 405 +++++++------- naga/tests/out/spv/wgsl-quad.spvasm | 80 +-- naga/tests/out/spv/wgsl-shadow.spvasm | 232 ++++---- naga/tests/out/spv/wgsl-skybox.spvasm | 152 +++--- 12 files changed, 1044 insertions(+), 1039 deletions(-) diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 9430f541a00..40ce964acfd 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -867,7 +867,7 @@ impl Writer { iface.stage, class, name, - result.ty, + member.ty, binding, )?; iface.varying_ids.push(varying_id); diff --git a/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm b/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm index 57e08b61d92..589eeb34624 100644 --- a/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm +++ b/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm @@ -5,15 +5,15 @@ OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %14 "vs" %8 %11 %13 -OpEntryPoint Fragment %33 "fs" %31 +OpEntryPoint Vertex %15 "vs" %8 %11 %13 +OpEntryPoint Fragment %33 "fs" %32 OpExecutionMode %33 OriginUpperLeft OpMemberDecorate %6 0 Offset 0 OpMemberDecorate %6 1 Offset 16 OpDecorate %8 Location 0 OpDecorate %11 BuiltIn Position OpDecorate %13 Location 0 -OpDecorate %31 Location 0 +OpDecorate %32 Location 0 %2 = OpTypeVoid %4 = OpTypeFloat 32 %3 = OpTypeVector %4 4 @@ -21,40 +21,40 @@ OpDecorate %31 Location 0 %6 = OpTypeStruct %3 %5 %9 = OpTypePointer Input %5 %8 = OpVariable %9 Input -%12 = OpTypePointer Output %6 +%12 = OpTypePointer Output %3 %11 = OpVariable %12 Output -%13 = OpVariable %12 Output -%15 = OpTypeFunction %2 -%16 = OpConstant %4 0.0 -%17 = OpConstant %4 1.0 -%19 = OpTypePointer Function %6 -%20 = OpConstantNull %6 -%22 = OpTypePointer Function %3 -%25 = OpTypeInt 32 0 -%24 = OpConstant %25 0 -%32 = OpTypePointer Output %3 -%31 = OpVariable %32 Output -%34 = OpConstantComposite %3 %17 %16 %16 %17 -%14 = OpFunction %2 None %15 +%14 = OpTypePointer Output %5 +%13 = OpVariable %14 Output +%16 = OpTypeFunction %2 +%17 = OpConstant %4 0.0 +%18 = OpConstant %4 1.0 +%20 = OpTypePointer Function %6 +%21 = OpConstantNull %6 +%23 = OpTypePointer Function %3 +%26 = OpTypeInt 32 0 +%25 = OpConstant %26 0 +%32 = OpVariable %12 Output +%34 = OpConstantComposite %3 %18 %17 %17 %18 +%15 = OpFunction %2 None %16 %7 = OpLabel -%18 = OpVariable %19 Function %20 +%19 = OpVariable %20 Function %21 %10 = OpLoad %5 %8 -OpBranch %21 -%21 = OpLabel -%23 = OpCompositeConstruct %3 %10 %16 %17 -%26 = OpAccessChain %22 %18 %24 -OpStore %26 %23 -%27 = OpLoad %6 %18 -%28 = OpCompositeExtract %3 %27 0 -OpStore %11 %28 -%29 = OpCompositeExtract %5 %27 1 -OpStore %13 %29 +OpBranch %22 +%22 = OpLabel +%24 = OpCompositeConstruct %3 %10 %17 %18 +%27 = OpAccessChain %23 %19 %25 +OpStore %27 %24 +%28 = OpLoad %6 %19 +%29 = OpCompositeExtract %3 %28 0 +OpStore %11 %29 +%30 = OpCompositeExtract %5 %28 1 +OpStore %13 %30 OpReturn OpFunctionEnd -%33 = OpFunction %2 None %15 -%30 = OpLabel +%33 = OpFunction %2 None %16 +%31 = OpLabel OpBranch %35 %35 = OpLabel -OpStore %31 %34 +OpStore %32 %34 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-clip-distances.spvasm b/naga/tests/out/spv/wgsl-clip-distances.spvasm index 482f13fac12..24deba3c706 100644 --- a/naga/tests/out/spv/wgsl-clip-distances.spvasm +++ b/naga/tests/out/spv/wgsl-clip-distances.spvasm @@ -1,12 +1,12 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 27 +; Bound: 28 OpCapability Shader OpCapability ClipDistance %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %13 "main" %10 %12 +OpEntryPoint Vertex %14 "main" %10 %12 OpDecorate %5 ArrayStride 4 OpMemberDecorate %8 0 Offset 0 OpMemberDecorate %8 1 Offset 16 @@ -19,27 +19,28 @@ OpDecorate %12 BuiltIn ClipDistance %6 = OpConstant %7 1 %5 = OpTypeArray %3 %6 %8 = OpTypeStruct %4 %5 -%11 = OpTypePointer Output %8 +%11 = OpTypePointer Output %4 %10 = OpVariable %11 Output -%12 = OpVariable %11 Output -%14 = OpTypeFunction %2 -%15 = OpConstant %3 0.5 -%17 = OpTypePointer Function %8 -%18 = OpConstantNull %8 -%20 = OpTypePointer Function %5 -%21 = OpTypePointer Function %3 -%22 = OpConstant %7 0 -%13 = OpFunction %2 None %14 +%13 = OpTypePointer Output %5 +%12 = OpVariable %13 Output +%15 = OpTypeFunction %2 +%16 = OpConstant %3 0.5 +%18 = OpTypePointer Function %8 +%19 = OpConstantNull %8 +%21 = OpTypePointer Function %5 +%22 = OpTypePointer Function %3 +%23 = OpConstant %7 0 +%14 = OpFunction %2 None %15 %9 = OpLabel -%16 = OpVariable %17 Function %18 -OpBranch %19 -%19 = OpLabel -%23 = OpAccessChain %21 %16 %6 %22 -OpStore %23 %15 -%24 = OpLoad %8 %16 -%25 = OpCompositeExtract %4 %24 0 -OpStore %10 %25 -%26 = OpCompositeExtract %5 %24 1 -OpStore %12 %26 +%17 = OpVariable %18 Function %19 +OpBranch %20 +%20 = OpLabel +%24 = OpAccessChain %22 %17 %6 %23 +OpStore %24 %16 +%25 = OpLoad %8 %17 +%26 = OpCompositeExtract %4 %25 0 +OpStore %10 %26 +%27 = OpCompositeExtract %5 %25 1 +OpStore %12 %27 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm b/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm index 4d978decc9c..f1db8e611ed 100644 --- a/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm +++ b/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm @@ -7,12 +7,12 @@ OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %367 "gen_terrain_compute" %364 -OpEntryPoint Vertex %442 "gen_terrain_vertex" %435 %438 %440 %441 -OpEntryPoint Fragment %494 "gen_terrain_fragment" %483 %485 %488 %491 %493 -OpEntryPoint Vertex %589 "vs_main" %580 %583 %585 %587 %588 -OpEntryPoint Fragment %615 "fs_main" %607 %609 %611 %613 +OpEntryPoint Vertex %444 "gen_terrain_vertex" %435 %438 %440 %442 +OpEntryPoint Fragment %495 "gen_terrain_fragment" %485 %487 %490 %493 %494 +OpEntryPoint Vertex %590 "vs_main" %581 %584 %586 %587 %589 +OpEntryPoint Fragment %615 "fs_main" %608 %610 %612 %614 OpExecutionMode %367 LocalSize 64 1 1 -OpExecutionMode %494 OriginUpperLeft +OpExecutionMode %495 OriginUpperLeft OpExecutionMode %615 OriginUpperLeft %3 = OpString "debug-symbol-large-source.wgsl" OpSource Unknown 0 %3 "//This is a test 这是测试 これはテストだ 테스트입니다 This is a test 这是测试 これはテストだ 테스트입니다 This is a test 这是测试 これはテストだ 테스트입니다 @@ -7567,25 +7567,25 @@ OpName %429 "rhs" OpName %435 "vindex" OpName %438 "index" OpName %440 "position" -OpName %441 "uv" -OpName %442 "gen_terrain_vertex" -OpName %483 "index" -OpName %485 "position" -OpName %488 "uv" -OpName %491 "vert_component" -OpName %493 "index" -OpName %494 "gen_terrain_fragment" -OpName %497 "vert_component" -OpName %498 "index" -OpName %580 "position" -OpName %583 "normal" -OpName %585 "clip_position" +OpName %442 "uv" +OpName %444 "gen_terrain_vertex" +OpName %485 "index" +OpName %487 "position" +OpName %490 "uv" +OpName %493 "vert_component" +OpName %494 "index" +OpName %495 "gen_terrain_fragment" +OpName %498 "vert_component" +OpName %499 "index" +OpName %581 "position" +OpName %584 "normal" +OpName %586 "clip_position" OpName %587 "normal" -OpName %588 "world_pos" -OpName %589 "vs_main" -OpName %607 "clip_position" -OpName %609 "normal" -OpName %611 "world_pos" +OpName %589 "world_pos" +OpName %590 "vs_main" +OpName %608 "clip_position" +OpName %610 "normal" +OpName %612 "world_pos" OpName %615 "fs_main" OpName %629 "color" OpMemberDecorate %13 0 Offset 0 @@ -7651,22 +7651,22 @@ OpDecorate %435 BuiltIn VertexIndex OpDecorate %438 Location 0 OpDecorate %438 Flat OpDecorate %440 BuiltIn Position -OpDecorate %441 Location 1 -OpDecorate %483 Location 0 -OpDecorate %483 Flat -OpDecorate %485 BuiltIn FragCoord -OpDecorate %488 Location 1 -OpDecorate %491 Location 0 -OpDecorate %493 Location 1 -OpDecorate %580 Location 0 -OpDecorate %583 Location 1 -OpDecorate %585 BuiltIn Position +OpDecorate %442 Location 1 +OpDecorate %485 Location 0 +OpDecorate %485 Flat +OpDecorate %487 BuiltIn FragCoord +OpDecorate %490 Location 1 +OpDecorate %493 Location 0 +OpDecorate %494 Location 1 +OpDecorate %581 Location 0 +OpDecorate %584 Location 1 +OpDecorate %586 BuiltIn Position OpDecorate %587 Location 0 -OpDecorate %588 Location 1 -OpDecorate %607 BuiltIn FragCoord -OpDecorate %609 Location 0 -OpDecorate %611 Location 1 -OpDecorate %613 Location 0 +OpDecorate %589 Location 1 +OpDecorate %608 BuiltIn FragCoord +OpDecorate %610 Location 0 +OpDecorate %612 Location 1 +OpDecorate %614 Location 0 %2 = OpTypeVoid %4 = OpTypeFloat 32 %5 = OpTypeVector %4 3 @@ -7799,37 +7799,37 @@ OpDecorate %613 Location 0 %415 = OpTypePointer StorageBuffer %8 %436 = OpTypePointer Input %8 %435 = OpVariable %436 Input -%439 = OpTypePointer Output %21 +%439 = OpTypePointer Output %8 %438 = OpVariable %439 Output -%440 = OpVariable %439 Output -%441 = OpVariable %439 Output -%443 = OpTypePointer Uniform %20 -%445 = OpConstant %4 -1.0 -%446 = OpConstantComposite %6 %445 %445 -%471 = OpConstant %4 4294967000.0 -%483 = OpVariable %436 Input -%486 = OpTypePointer Input %7 -%485 = OpVariable %486 Input -%489 = OpTypePointer Input %6 -%488 = OpVariable %489 Input -%492 = OpTypePointer Output %22 -%491 = OpVariable %492 Output -%493 = OpVariable %492 Output -%496 = OpConstant %4 6.0 -%581 = OpTypePointer Input %5 -%580 = OpVariable %581 Input -%583 = OpVariable %581 Input -%586 = OpTypePointer Output %26 -%585 = OpVariable %586 Output -%587 = OpVariable %586 Output -%588 = OpVariable %586 Output -%590 = OpTypePointer Uniform %24 -%593 = OpTypePointer Uniform %23 -%607 = OpVariable %486 Input -%609 = OpVariable %581 Input -%611 = OpVariable %581 Input -%614 = OpTypePointer Output %7 -%613 = OpVariable %614 Output +%441 = OpTypePointer Output %7 +%440 = OpVariable %441 Output +%443 = OpTypePointer Output %6 +%442 = OpVariable %443 Output +%445 = OpTypePointer Uniform %20 +%447 = OpConstant %4 -1.0 +%448 = OpConstantComposite %6 %447 %447 +%473 = OpConstant %4 4294967000.0 +%485 = OpVariable %436 Input +%488 = OpTypePointer Input %7 +%487 = OpVariable %488 Input +%491 = OpTypePointer Input %6 +%490 = OpVariable %491 Input +%493 = OpVariable %439 Output +%494 = OpVariable %439 Output +%497 = OpConstant %4 6.0 +%582 = OpTypePointer Input %5 +%581 = OpVariable %582 Input +%584 = OpVariable %582 Input +%586 = OpVariable %441 Output +%588 = OpTypePointer Output %5 +%587 = OpVariable %588 Output +%589 = OpVariable %588 Output +%591 = OpTypePointer Uniform %24 +%594 = OpTypePointer Uniform %23 +%608 = OpVariable %488 Input +%610 = OpVariable %582 Input +%612 = OpVariable %582 Input +%614 = OpVariable %441 Output %617 = OpTypePointer Uniform %25 %623 = OpConstantComposite %6 %56 %81 %624 = OpConstantComposite %5 %286 %286 %286 @@ -8351,260 +8351,260 @@ OpFunctionEnd %433 = OpUMod %8 %428 %432 OpReturnValue %433 OpFunctionEnd -%442 = OpFunction %2 None %368 +%444 = OpFunction %2 None %368 %434 = OpLabel %437 = OpLoad %8 %435 -%444 = OpAccessChain %443 %36 %135 -OpBranch %447 -%447 = OpLabel +%446 = OpAccessChain %445 %36 %135 +OpBranch %449 +%449 = OpLabel OpLine %3 7304 19 -%448 = OpIAdd %8 %437 %372 +%450 = OpIAdd %8 %437 %372 OpLine %3 7304 18 -%449 = OpFunctionCall %8 %313 %448 %373 +%451 = OpFunctionCall %8 %313 %450 %373 OpLine %3 7304 13 -%450 = OpFunctionCall %8 %427 %449 %372 -%451 = OpConvertUToF %4 %450 +%452 = OpFunctionCall %8 %427 %451 %372 +%453 = OpConvertUToF %4 %452 OpLine %3 7305 19 -%452 = OpIAdd %8 %437 %126 +%454 = OpIAdd %8 %437 %126 OpLine %3 7305 18 -%453 = OpFunctionCall %8 %313 %452 %373 +%455 = OpFunctionCall %8 %313 %454 %373 OpLine %3 7305 13 -%454 = OpFunctionCall %8 %427 %453 %372 -%455 = OpConvertUToF %4 %454 +%456 = OpFunctionCall %8 %427 %455 %372 +%457 = OpConvertUToF %4 %456 OpLine %3 7306 14 -%456 = OpCompositeConstruct %6 %451 %455 +%458 = OpCompositeConstruct %6 %453 %457 OpLine %3 7308 30 -%457 = OpVectorTimesScalar %6 %456 %81 +%459 = OpVectorTimesScalar %6 %458 %81 OpLine %3 7308 30 -%458 = OpFAdd %6 %446 %457 +%460 = OpFAdd %6 %448 %459 OpLine %3 7308 20 -%459 = OpCompositeConstruct %7 %458 %74 %56 +%461 = OpCompositeConstruct %7 %460 %74 %56 OpLine %3 7311 21 -%460 = OpCompositeExtract %4 %456 0 +%462 = OpCompositeExtract %4 %458 0 OpLine %3 7311 21 -%461 = OpAccessChain %393 %444 %373 -%462 = OpLoad %8 %461 -%463 = OpConvertUToF %4 %462 -%464 = OpFMul %4 %460 %463 -%465 = OpCompositeExtract %4 %456 1 +%463 = OpAccessChain %393 %446 %373 +%464 = OpLoad %8 %463 +%465 = OpConvertUToF %4 %464 +%466 = OpFMul %4 %462 %465 +%467 = OpCompositeExtract %4 %458 1 OpLine %3 7311 17 -%466 = OpAccessChain %393 %444 %373 -%467 = OpLoad %8 %466 -%468 = OpConvertUToF %4 %467 -%469 = OpFMul %4 %465 %468 -%470 = OpFAdd %4 %464 %469 -%472 = OpExtInst %4 %1 FClamp %470 %74 %471 -%473 = OpConvertFToU %8 %472 +%468 = OpAccessChain %393 %446 %373 +%469 = OpLoad %8 %468 +%470 = OpConvertUToF %4 %469 +%471 = OpFMul %4 %467 %470 +%472 = OpFAdd %4 %466 %471 +%474 = OpExtInst %4 %1 FClamp %472 %74 %473 +%475 = OpConvertFToU %8 %474 OpLine %3 7311 17 -%474 = OpAccessChain %393 %444 %374 -%475 = OpLoad %8 %474 -%476 = OpIAdd %8 %473 %475 +%476 = OpAccessChain %393 %446 %374 +%477 = OpLoad %8 %476 +%478 = OpIAdd %8 %475 %477 OpLine %3 7313 12 -%477 = OpCompositeConstruct %21 %476 %459 %456 -%478 = OpCompositeExtract %8 %477 0 -OpStore %438 %478 -%479 = OpCompositeExtract %7 %477 1 -OpStore %440 %479 -%480 = OpCompositeExtract %6 %477 2 -OpStore %441 %480 +%479 = OpCompositeConstruct %21 %478 %461 %458 +%480 = OpCompositeExtract %8 %479 0 +OpStore %438 %480 +%481 = OpCompositeExtract %7 %479 1 +OpStore %440 %481 +%482 = OpCompositeExtract %6 %479 2 +OpStore %442 %482 OpReturn OpFunctionEnd -%494 = OpFunction %2 None %368 -%481 = OpLabel -%497 = OpVariable %125 Function %74 -%498 = OpVariable %217 Function %135 -%484 = OpLoad %8 %483 -%487 = OpLoad %7 %485 -%490 = OpLoad %6 %488 -%482 = OpCompositeConstruct %21 %484 %487 %490 -%495 = OpAccessChain %443 %36 %135 -OpBranch %499 -%499 = OpLabel +%495 = OpFunction %2 None %368 +%483 = OpLabel +%498 = OpVariable %125 Function %74 +%499 = OpVariable %217 Function %135 +%486 = OpLoad %8 %485 +%489 = OpLoad %7 %487 +%492 = OpLoad %6 %490 +%484 = OpCompositeConstruct %21 %486 %489 %492 +%496 = OpAccessChain %445 %36 %135 +OpBranch %500 +%500 = OpLabel OpLine %3 7324 17 -%500 = OpCompositeExtract %6 %482 2 -%501 = OpCompositeExtract %4 %500 0 +%501 = OpCompositeExtract %6 %484 2 +%502 = OpCompositeExtract %4 %501 0 OpLine %3 7324 17 -%502 = OpAccessChain %393 %495 %373 -%503 = OpLoad %8 %502 -%504 = OpConvertUToF %4 %503 -%505 = OpFMul %4 %501 %504 -%506 = OpCompositeExtract %6 %482 2 -%507 = OpCompositeExtract %4 %506 1 +%503 = OpAccessChain %393 %496 %373 +%504 = OpLoad %8 %503 +%505 = OpConvertUToF %4 %504 +%506 = OpFMul %4 %502 %505 +%507 = OpCompositeExtract %6 %484 2 +%508 = OpCompositeExtract %4 %507 1 OpLine %3 7324 70 -%508 = OpAccessChain %393 %495 %373 -%509 = OpLoad %8 %508 +%509 = OpAccessChain %393 %496 %373 +%510 = OpLoad %8 %509 OpLine %3 7324 13 -%510 = OpAccessChain %393 %495 %373 -%511 = OpLoad %8 %510 -%512 = OpIMul %8 %509 %511 -%513 = OpConvertUToF %4 %512 -%514 = OpFMul %4 %507 %513 -%515 = OpFAdd %4 %505 %514 -%516 = OpExtInst %4 %1 FClamp %515 %74 %471 -%517 = OpConvertFToU %8 %516 +%511 = OpAccessChain %393 %496 %373 +%512 = OpLoad %8 %511 +%513 = OpIMul %8 %510 %512 +%514 = OpConvertUToF %4 %513 +%515 = OpFMul %4 %508 %514 +%516 = OpFAdd %4 %506 %515 +%517 = OpExtInst %4 %1 FClamp %516 %74 %473 +%518 = OpConvertFToU %8 %517 OpLine %3 7324 13 -%518 = OpAccessChain %393 %495 %374 -%519 = OpLoad %8 %518 -%520 = OpIAdd %8 %517 %519 +%519 = OpAccessChain %393 %496 %374 +%520 = OpLoad %8 %519 +%521 = OpIAdd %8 %518 %520 OpLine %3 7325 32 -%521 = OpConvertUToF %4 %520 +%522 = OpConvertUToF %4 %521 OpLine %3 7325 22 -%522 = OpFDiv %4 %521 %496 -%523 = OpExtInst %4 %1 Floor %522 -%524 = OpExtInst %4 %1 FClamp %523 %74 %471 -%525 = OpConvertFToU %8 %524 +%523 = OpFDiv %4 %522 %497 +%524 = OpExtInst %4 %1 Floor %523 +%525 = OpExtInst %4 %1 FClamp %524 %74 %473 +%526 = OpConvertFToU %8 %525 OpLine %3 7326 22 -%526 = OpFunctionCall %8 %427 %520 %371 +%527 = OpFunctionCall %8 %427 %521 %371 OpLine %3 7328 36 -%527 = OpAccessChain %377 %495 %135 -%528 = OpLoad %10 %527 +%528 = OpAccessChain %377 %496 %135 +%529 = OpLoad %10 %528 OpLine %3 7328 57 -%529 = OpAccessChain %380 %495 %126 -%530 = OpLoad %11 %529 +%530 = OpAccessChain %380 %496 %126 +%531 = OpLoad %11 %530 OpLine %3 7328 13 -%531 = OpFunctionCall %6 %325 %525 %528 %530 +%532 = OpFunctionCall %6 %325 %526 %529 %531 OpLine %3 7329 31 -%532 = OpAccessChain %386 %495 %372 -%533 = OpLoad %6 %532 +%533 = OpAccessChain %386 %496 %372 +%534 = OpLoad %6 %533 OpLine %3 7329 13 -%534 = OpFunctionCall %14 %284 %531 %533 +%535 = OpFunctionCall %14 %284 %532 %534 OpLine %3 7333 5 -OpSelectionMerge %535 None -OpSwitch %526 %542 0 %536 1 %537 2 %538 3 %539 4 %540 5 %541 -%536 = OpLabel +OpSelectionMerge %536 None +OpSwitch %527 %543 0 %537 1 %538 2 %539 3 %540 4 %541 5 %542 +%537 = OpLabel OpLine %3 7334 37 -%543 = OpCompositeExtract %5 %534 0 -%544 = OpCompositeExtract %4 %543 0 +%544 = OpCompositeExtract %5 %535 0 +%545 = OpCompositeExtract %4 %544 0 OpLine %3 7334 20 -OpStore %497 %544 -OpBranch %535 -%537 = OpLabel +OpStore %498 %545 +OpBranch %536 +%538 = OpLabel OpLine %3 7335 37 -%545 = OpCompositeExtract %5 %534 0 -%546 = OpCompositeExtract %4 %545 1 +%546 = OpCompositeExtract %5 %535 0 +%547 = OpCompositeExtract %4 %546 1 OpLine %3 7335 20 -OpStore %497 %546 -OpBranch %535 -%538 = OpLabel +OpStore %498 %547 +OpBranch %536 +%539 = OpLabel OpLine %3 7336 37 -%547 = OpCompositeExtract %5 %534 0 -%548 = OpCompositeExtract %4 %547 2 +%548 = OpCompositeExtract %5 %535 0 +%549 = OpCompositeExtract %4 %548 2 OpLine %3 7336 20 -OpStore %497 %548 -OpBranch %535 -%539 = OpLabel +OpStore %498 %549 +OpBranch %536 +%540 = OpLabel OpLine %3 7337 37 -%549 = OpCompositeExtract %5 %534 1 -%550 = OpCompositeExtract %4 %549 0 +%550 = OpCompositeExtract %5 %535 1 +%551 = OpCompositeExtract %4 %550 0 OpLine %3 7337 20 -OpStore %497 %550 -OpBranch %535 -%540 = OpLabel +OpStore %498 %551 +OpBranch %536 +%541 = OpLabel OpLine %3 7338 37 -%551 = OpCompositeExtract %5 %534 1 -%552 = OpCompositeExtract %4 %551 1 +%552 = OpCompositeExtract %5 %535 1 +%553 = OpCompositeExtract %4 %552 1 OpLine %3 7338 20 -OpStore %497 %552 -OpBranch %535 -%541 = OpLabel +OpStore %498 %553 +OpBranch %536 +%542 = OpLabel OpLine %3 7339 37 -%553 = OpCompositeExtract %5 %534 1 -%554 = OpCompositeExtract %4 %553 2 +%554 = OpCompositeExtract %5 %535 1 +%555 = OpCompositeExtract %4 %554 2 OpLine %3 7339 20 -OpStore %497 %554 -OpBranch %535 -%542 = OpLabel -OpBranch %535 -%535 = OpLabel +OpStore %498 %555 +OpBranch %536 +%543 = OpLabel +OpBranch %536 +%536 = OpLabel OpLine %3 7343 15 -%555 = OpAccessChain %393 %495 %135 %135 -%556 = OpLoad %8 %555 -%557 = OpFunctionCall %8 %313 %525 %556 -%558 = OpIAdd %8 %525 %557 +%556 = OpAccessChain %393 %496 %135 %135 +%557 = OpLoad %8 %556 +%558 = OpFunctionCall %8 %313 %526 %557 +%559 = OpIAdd %8 %526 %558 OpLine %3 7344 15 -%559 = OpIAdd %8 %558 %126 +%560 = OpIAdd %8 %559 %126 OpLine %3 7345 15 -%560 = OpAccessChain %393 %495 %135 %135 -%561 = OpLoad %8 %560 -%562 = OpIAdd %8 %558 %561 +%561 = OpAccessChain %393 %496 %135 %135 +%562 = OpLoad %8 %561 +%563 = OpIAdd %8 %559 %562 OpLine %3 7345 15 -%563 = OpIAdd %8 %562 %126 -OpLine %3 7346 15 %564 = OpIAdd %8 %563 %126 +OpLine %3 7346 15 +%565 = OpIAdd %8 %564 %126 OpLine %3 7349 5 -OpSelectionMerge %565 None -OpSwitch %526 %570 0 %566 3 %566 2 %567 4 %567 1 %568 5 %569 -%566 = OpLabel -OpLine %3 7350 24 -OpStore %498 %558 -OpBranch %565 +OpSelectionMerge %566 None +OpSwitch %527 %571 0 %567 3 %567 2 %568 4 %568 1 %569 5 %570 %567 = OpLabel -OpLine %3 7351 24 -OpStore %498 %564 -OpBranch %565 +OpLine %3 7350 24 +OpStore %499 %559 +OpBranch %566 %568 = OpLabel -OpLine %3 7352 20 -OpStore %498 %563 -OpBranch %565 +OpLine %3 7351 24 +OpStore %499 %565 +OpBranch %566 %569 = OpLabel -OpLine %3 7353 20 -OpStore %498 %559 -OpBranch %565 +OpLine %3 7352 20 +OpStore %499 %564 +OpBranch %566 %570 = OpLabel -OpBranch %565 -%565 = OpLabel +OpLine %3 7353 20 +OpStore %499 %560 +OpBranch %566 +%571 = OpLabel +OpBranch %566 +%566 = OpLabel OpLine %3 7356 13 -%571 = OpCompositeExtract %8 %482 0 +%572 = OpCompositeExtract %8 %484 0 OpLine %3 7356 5 -OpStore %498 %571 +OpStore %499 %572 OpLine %3 7365 27 -%572 = OpLoad %4 %497 -%573 = OpBitcast %8 %572 +%573 = OpLoad %4 %498 +%574 = OpBitcast %8 %573 OpLine %3 7366 12 -%574 = OpLoad %8 %498 -%575 = OpCompositeConstruct %22 %573 %574 -%576 = OpCompositeExtract %8 %575 0 -OpStore %491 %576 -%577 = OpCompositeExtract %8 %575 1 +%575 = OpLoad %8 %499 +%576 = OpCompositeConstruct %22 %574 %575 +%577 = OpCompositeExtract %8 %576 0 OpStore %493 %577 +%578 = OpCompositeExtract %8 %576 1 +OpStore %494 %578 OpReturn OpFunctionEnd -%589 = OpFunction %2 None %368 -%578 = OpLabel -%582 = OpLoad %5 %580 -%584 = OpLoad %5 %583 -%579 = OpCompositeConstruct %14 %582 %584 -%591 = OpAccessChain %590 %39 %135 -OpBranch %592 -%592 = OpLabel +%590 = OpFunction %2 None %368 +%579 = OpLabel +%583 = OpLoad %5 %581 +%585 = OpLoad %5 %584 +%580 = OpCompositeConstruct %14 %583 %585 +%592 = OpAccessChain %591 %39 %135 +OpBranch %593 +%593 = OpLabel OpLine %3 7397 25 -%594 = OpAccessChain %593 %591 %126 -%595 = OpLoad %23 %594 -%596 = OpCompositeExtract %5 %579 0 +%595 = OpAccessChain %594 %592 %126 +%596 = OpLoad %23 %595 +%597 = OpCompositeExtract %5 %580 0 OpLine %3 7397 25 -%597 = OpCompositeConstruct %7 %596 %56 -%598 = OpMatrixTimesVector %7 %595 %597 +%598 = OpCompositeConstruct %7 %597 %56 +%599 = OpMatrixTimesVector %7 %596 %598 OpLine %3 7398 18 -%599 = OpCompositeExtract %5 %579 1 +%600 = OpCompositeExtract %5 %580 1 OpLine %3 7399 12 -%600 = OpCompositeExtract %5 %579 0 -%601 = OpCompositeConstruct %26 %598 %599 %600 -%602 = OpCompositeExtract %7 %601 0 -OpStore %585 %602 -%603 = OpCompositeExtract %5 %601 1 -OpStore %587 %603 -%604 = OpCompositeExtract %5 %601 2 -OpStore %588 %604 +%601 = OpCompositeExtract %5 %580 0 +%602 = OpCompositeConstruct %26 %599 %600 %601 +%603 = OpCompositeExtract %7 %602 0 +OpStore %586 %603 +%604 = OpCompositeExtract %5 %602 1 +OpStore %587 %604 +%605 = OpCompositeExtract %5 %602 2 +OpStore %589 %605 OpReturn OpFunctionEnd %615 = OpFunction %2 None %368 -%605 = OpLabel +%606 = OpLabel %629 = OpVariable %95 Function %630 -%608 = OpLoad %7 %607 -%610 = OpLoad %5 %609 -%612 = OpLoad %5 %611 -%606 = OpCompositeConstruct %26 %608 %610 %612 -%616 = OpAccessChain %590 %39 %135 +%609 = OpLoad %7 %608 +%611 = OpLoad %5 %610 +%613 = OpLoad %5 %612 +%607 = OpCompositeConstruct %26 %609 %611 %613 +%616 = OpAccessChain %591 %39 %135 %618 = OpAccessChain %617 %42 %135 %619 = OpLoad %27 %45 %620 = OpLoad %28 %47 @@ -8618,7 +8618,7 @@ OpLine %3 7426 5 %632 = OpFunctionCall %5 %342 %623 OpLine %3 7428 28 OpLine %3 7428 17 -%633 = OpCompositeExtract %5 %606 2 +%633 = OpCompositeExtract %5 %607 2 %634 = OpExtInst %5 %1 Fract %633 %635 = OpExtInst %5 %1 SmoothStep %80 %624 %634 OpLine %3 7428 5 @@ -8644,21 +8644,21 @@ OpLine %3 7432 25 OpLine %3 7434 21 %650 = OpAccessChain %646 %618 %135 %651 = OpLoad %5 %650 -%652 = OpCompositeExtract %5 %606 2 +%652 = OpCompositeExtract %5 %607 2 %653 = OpFSub %5 %651 %652 %654 = OpExtInst %5 %1 Normalize %653 OpLine %3 7435 20 %656 = OpAccessChain %655 %616 %135 %657 = OpLoad %7 %656 %658 = OpVectorShuffle %5 %657 %657 0 1 2 -%659 = OpCompositeExtract %5 %606 2 +%659 = OpCompositeExtract %5 %607 2 %660 = OpFSub %5 %658 %659 %661 = OpExtInst %5 %1 Normalize %660 OpLine %3 7436 20 %662 = OpFAdd %5 %661 %654 %663 = OpExtInst %5 %1 Normalize %662 OpLine %3 7438 32 -%664 = OpCompositeExtract %5 %606 1 +%664 = OpCompositeExtract %5 %607 1 %665 = OpDot %4 %664 %654 OpLine %3 7438 28 %666 = OpExtInst %4 %1 FMax %665 %74 @@ -8667,7 +8667,7 @@ OpLine %3 7439 25 %668 = OpLoad %5 %667 %669 = OpVectorTimesScalar %5 %668 %666 OpLine %3 7441 37 -%670 = OpCompositeExtract %5 %606 1 +%670 = OpCompositeExtract %5 %607 1 %671 = OpDot %4 %670 %663 OpLine %3 7441 33 %672 = OpExtInst %4 %1 FMax %671 %74 @@ -8684,6 +8684,6 @@ OpLine %3 7444 18 %680 = OpFMul %5 %678 %679 OpLine %3 7446 12 %681 = OpCompositeConstruct %7 %680 %56 -OpStore %613 %681 +OpStore %614 %681 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm b/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm index ad2d2f9a434..69f08bcdb62 100644 --- a/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm +++ b/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm @@ -7,12 +7,12 @@ OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %367 "gen_terrain_compute" %364 -OpEntryPoint Vertex %442 "gen_terrain_vertex" %435 %438 %440 %441 -OpEntryPoint Fragment %494 "gen_terrain_fragment" %483 %485 %488 %491 %493 -OpEntryPoint Vertex %589 "vs_main" %580 %583 %585 %587 %588 -OpEntryPoint Fragment %615 "fs_main" %607 %609 %611 %613 +OpEntryPoint Vertex %444 "gen_terrain_vertex" %435 %438 %440 %442 +OpEntryPoint Fragment %495 "gen_terrain_fragment" %485 %487 %490 %493 %494 +OpEntryPoint Vertex %590 "vs_main" %581 %584 %586 %587 %589 +OpEntryPoint Fragment %615 "fs_main" %608 %610 %612 %614 OpExecutionMode %367 LocalSize 64 1 1 -OpExecutionMode %494 OriginUpperLeft +OpExecutionMode %495 OriginUpperLeft OpExecutionMode %615 OriginUpperLeft %3 = OpString "debug-symbol-terrain.wgsl" OpSource Unknown 0 %3 "// Taken from https://github.com/sotrh/learn-wgpu/blob/11820796f5e1dbce42fb1119f04ddeb4b167d2a0/code/intermediate/tutorial13-terrain/src/terrain.wgsl @@ -402,25 +402,25 @@ OpName %429 "rhs" OpName %435 "vindex" OpName %438 "index" OpName %440 "position" -OpName %441 "uv" -OpName %442 "gen_terrain_vertex" -OpName %483 "index" -OpName %485 "position" -OpName %488 "uv" -OpName %491 "vert_component" -OpName %493 "index" -OpName %494 "gen_terrain_fragment" -OpName %497 "vert_component" -OpName %498 "index" -OpName %580 "position" -OpName %583 "normal" -OpName %585 "clip_position" +OpName %442 "uv" +OpName %444 "gen_terrain_vertex" +OpName %485 "index" +OpName %487 "position" +OpName %490 "uv" +OpName %493 "vert_component" +OpName %494 "index" +OpName %495 "gen_terrain_fragment" +OpName %498 "vert_component" +OpName %499 "index" +OpName %581 "position" +OpName %584 "normal" +OpName %586 "clip_position" OpName %587 "normal" -OpName %588 "world_pos" -OpName %589 "vs_main" -OpName %607 "clip_position" -OpName %609 "normal" -OpName %611 "world_pos" +OpName %589 "world_pos" +OpName %590 "vs_main" +OpName %608 "clip_position" +OpName %610 "normal" +OpName %612 "world_pos" OpName %615 "fs_main" OpName %629 "color" OpMemberDecorate %13 0 Offset 0 @@ -486,22 +486,22 @@ OpDecorate %435 BuiltIn VertexIndex OpDecorate %438 Location 0 OpDecorate %438 Flat OpDecorate %440 BuiltIn Position -OpDecorate %441 Location 1 -OpDecorate %483 Location 0 -OpDecorate %483 Flat -OpDecorate %485 BuiltIn FragCoord -OpDecorate %488 Location 1 -OpDecorate %491 Location 0 -OpDecorate %493 Location 1 -OpDecorate %580 Location 0 -OpDecorate %583 Location 1 -OpDecorate %585 BuiltIn Position +OpDecorate %442 Location 1 +OpDecorate %485 Location 0 +OpDecorate %485 Flat +OpDecorate %487 BuiltIn FragCoord +OpDecorate %490 Location 1 +OpDecorate %493 Location 0 +OpDecorate %494 Location 1 +OpDecorate %581 Location 0 +OpDecorate %584 Location 1 +OpDecorate %586 BuiltIn Position OpDecorate %587 Location 0 -OpDecorate %588 Location 1 -OpDecorate %607 BuiltIn FragCoord -OpDecorate %609 Location 0 -OpDecorate %611 Location 1 -OpDecorate %613 Location 0 +OpDecorate %589 Location 1 +OpDecorate %608 BuiltIn FragCoord +OpDecorate %610 Location 0 +OpDecorate %612 Location 1 +OpDecorate %614 Location 0 %2 = OpTypeVoid %4 = OpTypeFloat 32 %5 = OpTypeVector %4 3 @@ -634,37 +634,37 @@ OpDecorate %613 Location 0 %415 = OpTypePointer StorageBuffer %8 %436 = OpTypePointer Input %8 %435 = OpVariable %436 Input -%439 = OpTypePointer Output %21 +%439 = OpTypePointer Output %8 %438 = OpVariable %439 Output -%440 = OpVariable %439 Output -%441 = OpVariable %439 Output -%443 = OpTypePointer Uniform %20 -%445 = OpConstant %4 -1.0 -%446 = OpConstantComposite %6 %445 %445 -%471 = OpConstant %4 4294967000.0 -%483 = OpVariable %436 Input -%486 = OpTypePointer Input %7 -%485 = OpVariable %486 Input -%489 = OpTypePointer Input %6 -%488 = OpVariable %489 Input -%492 = OpTypePointer Output %22 -%491 = OpVariable %492 Output -%493 = OpVariable %492 Output -%496 = OpConstant %4 6.0 -%581 = OpTypePointer Input %5 -%580 = OpVariable %581 Input -%583 = OpVariable %581 Input -%586 = OpTypePointer Output %26 -%585 = OpVariable %586 Output -%587 = OpVariable %586 Output -%588 = OpVariable %586 Output -%590 = OpTypePointer Uniform %24 -%593 = OpTypePointer Uniform %23 -%607 = OpVariable %486 Input -%609 = OpVariable %581 Input -%611 = OpVariable %581 Input -%614 = OpTypePointer Output %7 -%613 = OpVariable %614 Output +%441 = OpTypePointer Output %7 +%440 = OpVariable %441 Output +%443 = OpTypePointer Output %6 +%442 = OpVariable %443 Output +%445 = OpTypePointer Uniform %20 +%447 = OpConstant %4 -1.0 +%448 = OpConstantComposite %6 %447 %447 +%473 = OpConstant %4 4294967000.0 +%485 = OpVariable %436 Input +%488 = OpTypePointer Input %7 +%487 = OpVariable %488 Input +%491 = OpTypePointer Input %6 +%490 = OpVariable %491 Input +%493 = OpVariable %439 Output +%494 = OpVariable %439 Output +%497 = OpConstant %4 6.0 +%582 = OpTypePointer Input %5 +%581 = OpVariable %582 Input +%584 = OpVariable %582 Input +%586 = OpVariable %441 Output +%588 = OpTypePointer Output %5 +%587 = OpVariable %588 Output +%589 = OpVariable %588 Output +%591 = OpTypePointer Uniform %24 +%594 = OpTypePointer Uniform %23 +%608 = OpVariable %488 Input +%610 = OpVariable %582 Input +%612 = OpVariable %582 Input +%614 = OpVariable %441 Output %617 = OpTypePointer Uniform %25 %623 = OpConstantComposite %6 %56 %81 %624 = OpConstantComposite %5 %286 %286 %286 @@ -1186,260 +1186,260 @@ OpFunctionEnd %433 = OpUMod %8 %428 %432 OpReturnValue %433 OpFunctionEnd -%442 = OpFunction %2 None %368 +%444 = OpFunction %2 None %368 %434 = OpLabel %437 = OpLoad %8 %435 -%444 = OpAccessChain %443 %36 %135 -OpBranch %447 -%447 = OpLabel +%446 = OpAccessChain %445 %36 %135 +OpBranch %449 +%449 = OpLabel OpLine %3 161 19 -%448 = OpIAdd %8 %437 %372 +%450 = OpIAdd %8 %437 %372 OpLine %3 161 18 -%449 = OpFunctionCall %8 %313 %448 %373 +%451 = OpFunctionCall %8 %313 %450 %373 OpLine %3 161 13 -%450 = OpFunctionCall %8 %427 %449 %372 -%451 = OpConvertUToF %4 %450 +%452 = OpFunctionCall %8 %427 %451 %372 +%453 = OpConvertUToF %4 %452 OpLine %3 162 19 -%452 = OpIAdd %8 %437 %126 +%454 = OpIAdd %8 %437 %126 OpLine %3 162 18 -%453 = OpFunctionCall %8 %313 %452 %373 +%455 = OpFunctionCall %8 %313 %454 %373 OpLine %3 162 13 -%454 = OpFunctionCall %8 %427 %453 %372 -%455 = OpConvertUToF %4 %454 +%456 = OpFunctionCall %8 %427 %455 %372 +%457 = OpConvertUToF %4 %456 OpLine %3 163 14 -%456 = OpCompositeConstruct %6 %451 %455 +%458 = OpCompositeConstruct %6 %453 %457 OpLine %3 165 30 -%457 = OpVectorTimesScalar %6 %456 %81 +%459 = OpVectorTimesScalar %6 %458 %81 OpLine %3 165 30 -%458 = OpFAdd %6 %446 %457 +%460 = OpFAdd %6 %448 %459 OpLine %3 165 20 -%459 = OpCompositeConstruct %7 %458 %74 %56 +%461 = OpCompositeConstruct %7 %460 %74 %56 OpLine %3 168 21 -%460 = OpCompositeExtract %4 %456 0 +%462 = OpCompositeExtract %4 %458 0 OpLine %3 168 21 -%461 = OpAccessChain %393 %444 %373 -%462 = OpLoad %8 %461 -%463 = OpConvertUToF %4 %462 -%464 = OpFMul %4 %460 %463 -%465 = OpCompositeExtract %4 %456 1 +%463 = OpAccessChain %393 %446 %373 +%464 = OpLoad %8 %463 +%465 = OpConvertUToF %4 %464 +%466 = OpFMul %4 %462 %465 +%467 = OpCompositeExtract %4 %458 1 OpLine %3 168 17 -%466 = OpAccessChain %393 %444 %373 -%467 = OpLoad %8 %466 -%468 = OpConvertUToF %4 %467 -%469 = OpFMul %4 %465 %468 -%470 = OpFAdd %4 %464 %469 -%472 = OpExtInst %4 %1 FClamp %470 %74 %471 -%473 = OpConvertFToU %8 %472 +%468 = OpAccessChain %393 %446 %373 +%469 = OpLoad %8 %468 +%470 = OpConvertUToF %4 %469 +%471 = OpFMul %4 %467 %470 +%472 = OpFAdd %4 %466 %471 +%474 = OpExtInst %4 %1 FClamp %472 %74 %473 +%475 = OpConvertFToU %8 %474 OpLine %3 168 17 -%474 = OpAccessChain %393 %444 %374 -%475 = OpLoad %8 %474 -%476 = OpIAdd %8 %473 %475 +%476 = OpAccessChain %393 %446 %374 +%477 = OpLoad %8 %476 +%478 = OpIAdd %8 %475 %477 OpLine %3 170 12 -%477 = OpCompositeConstruct %21 %476 %459 %456 -%478 = OpCompositeExtract %8 %477 0 -OpStore %438 %478 -%479 = OpCompositeExtract %7 %477 1 -OpStore %440 %479 -%480 = OpCompositeExtract %6 %477 2 -OpStore %441 %480 +%479 = OpCompositeConstruct %21 %478 %461 %458 +%480 = OpCompositeExtract %8 %479 0 +OpStore %438 %480 +%481 = OpCompositeExtract %7 %479 1 +OpStore %440 %481 +%482 = OpCompositeExtract %6 %479 2 +OpStore %442 %482 OpReturn OpFunctionEnd -%494 = OpFunction %2 None %368 -%481 = OpLabel -%497 = OpVariable %125 Function %74 -%498 = OpVariable %217 Function %135 -%484 = OpLoad %8 %483 -%487 = OpLoad %7 %485 -%490 = OpLoad %6 %488 -%482 = OpCompositeConstruct %21 %484 %487 %490 -%495 = OpAccessChain %443 %36 %135 -OpBranch %499 -%499 = OpLabel +%495 = OpFunction %2 None %368 +%483 = OpLabel +%498 = OpVariable %125 Function %74 +%499 = OpVariable %217 Function %135 +%486 = OpLoad %8 %485 +%489 = OpLoad %7 %487 +%492 = OpLoad %6 %490 +%484 = OpCompositeConstruct %21 %486 %489 %492 +%496 = OpAccessChain %445 %36 %135 +OpBranch %500 +%500 = OpLabel OpLine %3 181 17 -%500 = OpCompositeExtract %6 %482 2 -%501 = OpCompositeExtract %4 %500 0 +%501 = OpCompositeExtract %6 %484 2 +%502 = OpCompositeExtract %4 %501 0 OpLine %3 181 17 -%502 = OpAccessChain %393 %495 %373 -%503 = OpLoad %8 %502 -%504 = OpConvertUToF %4 %503 -%505 = OpFMul %4 %501 %504 -%506 = OpCompositeExtract %6 %482 2 -%507 = OpCompositeExtract %4 %506 1 +%503 = OpAccessChain %393 %496 %373 +%504 = OpLoad %8 %503 +%505 = OpConvertUToF %4 %504 +%506 = OpFMul %4 %502 %505 +%507 = OpCompositeExtract %6 %484 2 +%508 = OpCompositeExtract %4 %507 1 OpLine %3 181 70 -%508 = OpAccessChain %393 %495 %373 -%509 = OpLoad %8 %508 +%509 = OpAccessChain %393 %496 %373 +%510 = OpLoad %8 %509 OpLine %3 181 13 -%510 = OpAccessChain %393 %495 %373 -%511 = OpLoad %8 %510 -%512 = OpIMul %8 %509 %511 -%513 = OpConvertUToF %4 %512 -%514 = OpFMul %4 %507 %513 -%515 = OpFAdd %4 %505 %514 -%516 = OpExtInst %4 %1 FClamp %515 %74 %471 -%517 = OpConvertFToU %8 %516 +%511 = OpAccessChain %393 %496 %373 +%512 = OpLoad %8 %511 +%513 = OpIMul %8 %510 %512 +%514 = OpConvertUToF %4 %513 +%515 = OpFMul %4 %508 %514 +%516 = OpFAdd %4 %506 %515 +%517 = OpExtInst %4 %1 FClamp %516 %74 %473 +%518 = OpConvertFToU %8 %517 OpLine %3 181 13 -%518 = OpAccessChain %393 %495 %374 -%519 = OpLoad %8 %518 -%520 = OpIAdd %8 %517 %519 +%519 = OpAccessChain %393 %496 %374 +%520 = OpLoad %8 %519 +%521 = OpIAdd %8 %518 %520 OpLine %3 182 32 -%521 = OpConvertUToF %4 %520 +%522 = OpConvertUToF %4 %521 OpLine %3 182 22 -%522 = OpFDiv %4 %521 %496 -%523 = OpExtInst %4 %1 Floor %522 -%524 = OpExtInst %4 %1 FClamp %523 %74 %471 -%525 = OpConvertFToU %8 %524 +%523 = OpFDiv %4 %522 %497 +%524 = OpExtInst %4 %1 Floor %523 +%525 = OpExtInst %4 %1 FClamp %524 %74 %473 +%526 = OpConvertFToU %8 %525 OpLine %3 183 22 -%526 = OpFunctionCall %8 %427 %520 %371 +%527 = OpFunctionCall %8 %427 %521 %371 OpLine %3 185 36 -%527 = OpAccessChain %377 %495 %135 -%528 = OpLoad %10 %527 +%528 = OpAccessChain %377 %496 %135 +%529 = OpLoad %10 %528 OpLine %3 185 57 -%529 = OpAccessChain %380 %495 %126 -%530 = OpLoad %11 %529 +%530 = OpAccessChain %380 %496 %126 +%531 = OpLoad %11 %530 OpLine %3 185 13 -%531 = OpFunctionCall %6 %325 %525 %528 %530 +%532 = OpFunctionCall %6 %325 %526 %529 %531 OpLine %3 186 31 -%532 = OpAccessChain %386 %495 %372 -%533 = OpLoad %6 %532 +%533 = OpAccessChain %386 %496 %372 +%534 = OpLoad %6 %533 OpLine %3 186 13 -%534 = OpFunctionCall %14 %284 %531 %533 +%535 = OpFunctionCall %14 %284 %532 %534 OpLine %3 190 5 -OpSelectionMerge %535 None -OpSwitch %526 %542 0 %536 1 %537 2 %538 3 %539 4 %540 5 %541 -%536 = OpLabel +OpSelectionMerge %536 None +OpSwitch %527 %543 0 %537 1 %538 2 %539 3 %540 4 %541 5 %542 +%537 = OpLabel OpLine %3 191 37 -%543 = OpCompositeExtract %5 %534 0 -%544 = OpCompositeExtract %4 %543 0 +%544 = OpCompositeExtract %5 %535 0 +%545 = OpCompositeExtract %4 %544 0 OpLine %3 191 20 -OpStore %497 %544 -OpBranch %535 -%537 = OpLabel +OpStore %498 %545 +OpBranch %536 +%538 = OpLabel OpLine %3 192 37 -%545 = OpCompositeExtract %5 %534 0 -%546 = OpCompositeExtract %4 %545 1 +%546 = OpCompositeExtract %5 %535 0 +%547 = OpCompositeExtract %4 %546 1 OpLine %3 192 20 -OpStore %497 %546 -OpBranch %535 -%538 = OpLabel +OpStore %498 %547 +OpBranch %536 +%539 = OpLabel OpLine %3 193 37 -%547 = OpCompositeExtract %5 %534 0 -%548 = OpCompositeExtract %4 %547 2 +%548 = OpCompositeExtract %5 %535 0 +%549 = OpCompositeExtract %4 %548 2 OpLine %3 193 20 -OpStore %497 %548 -OpBranch %535 -%539 = OpLabel +OpStore %498 %549 +OpBranch %536 +%540 = OpLabel OpLine %3 194 37 -%549 = OpCompositeExtract %5 %534 1 -%550 = OpCompositeExtract %4 %549 0 +%550 = OpCompositeExtract %5 %535 1 +%551 = OpCompositeExtract %4 %550 0 OpLine %3 194 20 -OpStore %497 %550 -OpBranch %535 -%540 = OpLabel +OpStore %498 %551 +OpBranch %536 +%541 = OpLabel OpLine %3 195 37 -%551 = OpCompositeExtract %5 %534 1 -%552 = OpCompositeExtract %4 %551 1 +%552 = OpCompositeExtract %5 %535 1 +%553 = OpCompositeExtract %4 %552 1 OpLine %3 195 20 -OpStore %497 %552 -OpBranch %535 -%541 = OpLabel +OpStore %498 %553 +OpBranch %536 +%542 = OpLabel OpLine %3 196 37 -%553 = OpCompositeExtract %5 %534 1 -%554 = OpCompositeExtract %4 %553 2 +%554 = OpCompositeExtract %5 %535 1 +%555 = OpCompositeExtract %4 %554 2 OpLine %3 196 20 -OpStore %497 %554 -OpBranch %535 -%542 = OpLabel -OpBranch %535 -%535 = OpLabel +OpStore %498 %555 +OpBranch %536 +%543 = OpLabel +OpBranch %536 +%536 = OpLabel OpLine %3 200 15 -%555 = OpAccessChain %393 %495 %135 %135 -%556 = OpLoad %8 %555 -%557 = OpFunctionCall %8 %313 %525 %556 -%558 = OpIAdd %8 %525 %557 +%556 = OpAccessChain %393 %496 %135 %135 +%557 = OpLoad %8 %556 +%558 = OpFunctionCall %8 %313 %526 %557 +%559 = OpIAdd %8 %526 %558 OpLine %3 201 15 -%559 = OpIAdd %8 %558 %126 +%560 = OpIAdd %8 %559 %126 OpLine %3 202 15 -%560 = OpAccessChain %393 %495 %135 %135 -%561 = OpLoad %8 %560 -%562 = OpIAdd %8 %558 %561 +%561 = OpAccessChain %393 %496 %135 %135 +%562 = OpLoad %8 %561 +%563 = OpIAdd %8 %559 %562 OpLine %3 202 15 -%563 = OpIAdd %8 %562 %126 -OpLine %3 203 15 %564 = OpIAdd %8 %563 %126 +OpLine %3 203 15 +%565 = OpIAdd %8 %564 %126 OpLine %3 206 5 -OpSelectionMerge %565 None -OpSwitch %526 %570 0 %566 3 %566 2 %567 4 %567 1 %568 5 %569 -%566 = OpLabel -OpLine %3 207 24 -OpStore %498 %558 -OpBranch %565 +OpSelectionMerge %566 None +OpSwitch %527 %571 0 %567 3 %567 2 %568 4 %568 1 %569 5 %570 %567 = OpLabel -OpLine %3 208 24 -OpStore %498 %564 -OpBranch %565 +OpLine %3 207 24 +OpStore %499 %559 +OpBranch %566 %568 = OpLabel -OpLine %3 209 20 -OpStore %498 %563 -OpBranch %565 +OpLine %3 208 24 +OpStore %499 %565 +OpBranch %566 %569 = OpLabel -OpLine %3 210 20 -OpStore %498 %559 -OpBranch %565 +OpLine %3 209 20 +OpStore %499 %564 +OpBranch %566 %570 = OpLabel -OpBranch %565 -%565 = OpLabel +OpLine %3 210 20 +OpStore %499 %560 +OpBranch %566 +%571 = OpLabel +OpBranch %566 +%566 = OpLabel OpLine %3 213 13 -%571 = OpCompositeExtract %8 %482 0 +%572 = OpCompositeExtract %8 %484 0 OpLine %3 213 5 -OpStore %498 %571 +OpStore %499 %572 OpLine %3 222 27 -%572 = OpLoad %4 %497 -%573 = OpBitcast %8 %572 +%573 = OpLoad %4 %498 +%574 = OpBitcast %8 %573 OpLine %3 223 12 -%574 = OpLoad %8 %498 -%575 = OpCompositeConstruct %22 %573 %574 -%576 = OpCompositeExtract %8 %575 0 -OpStore %491 %576 -%577 = OpCompositeExtract %8 %575 1 +%575 = OpLoad %8 %499 +%576 = OpCompositeConstruct %22 %574 %575 +%577 = OpCompositeExtract %8 %576 0 OpStore %493 %577 +%578 = OpCompositeExtract %8 %576 1 +OpStore %494 %578 OpReturn OpFunctionEnd -%589 = OpFunction %2 None %368 -%578 = OpLabel -%582 = OpLoad %5 %580 -%584 = OpLoad %5 %583 -%579 = OpCompositeConstruct %14 %582 %584 -%591 = OpAccessChain %590 %39 %135 -OpBranch %592 -%592 = OpLabel +%590 = OpFunction %2 None %368 +%579 = OpLabel +%583 = OpLoad %5 %581 +%585 = OpLoad %5 %584 +%580 = OpCompositeConstruct %14 %583 %585 +%592 = OpAccessChain %591 %39 %135 +OpBranch %593 +%593 = OpLabel OpLine %3 254 25 -%594 = OpAccessChain %593 %591 %126 -%595 = OpLoad %23 %594 -%596 = OpCompositeExtract %5 %579 0 +%595 = OpAccessChain %594 %592 %126 +%596 = OpLoad %23 %595 +%597 = OpCompositeExtract %5 %580 0 OpLine %3 254 25 -%597 = OpCompositeConstruct %7 %596 %56 -%598 = OpMatrixTimesVector %7 %595 %597 +%598 = OpCompositeConstruct %7 %597 %56 +%599 = OpMatrixTimesVector %7 %596 %598 OpLine %3 255 18 -%599 = OpCompositeExtract %5 %579 1 +%600 = OpCompositeExtract %5 %580 1 OpLine %3 256 12 -%600 = OpCompositeExtract %5 %579 0 -%601 = OpCompositeConstruct %26 %598 %599 %600 -%602 = OpCompositeExtract %7 %601 0 -OpStore %585 %602 -%603 = OpCompositeExtract %5 %601 1 -OpStore %587 %603 -%604 = OpCompositeExtract %5 %601 2 -OpStore %588 %604 +%601 = OpCompositeExtract %5 %580 0 +%602 = OpCompositeConstruct %26 %599 %600 %601 +%603 = OpCompositeExtract %7 %602 0 +OpStore %586 %603 +%604 = OpCompositeExtract %5 %602 1 +OpStore %587 %604 +%605 = OpCompositeExtract %5 %602 2 +OpStore %589 %605 OpReturn OpFunctionEnd %615 = OpFunction %2 None %368 -%605 = OpLabel +%606 = OpLabel %629 = OpVariable %95 Function %630 -%608 = OpLoad %7 %607 -%610 = OpLoad %5 %609 -%612 = OpLoad %5 %611 -%606 = OpCompositeConstruct %26 %608 %610 %612 -%616 = OpAccessChain %590 %39 %135 +%609 = OpLoad %7 %608 +%611 = OpLoad %5 %610 +%613 = OpLoad %5 %612 +%607 = OpCompositeConstruct %26 %609 %611 %613 +%616 = OpAccessChain %591 %39 %135 %618 = OpAccessChain %617 %42 %135 %619 = OpLoad %27 %45 %620 = OpLoad %28 %47 @@ -1453,7 +1453,7 @@ OpLine %3 283 5 %632 = OpFunctionCall %5 %342 %623 OpLine %3 285 28 OpLine %3 285 17 -%633 = OpCompositeExtract %5 %606 2 +%633 = OpCompositeExtract %5 %607 2 %634 = OpExtInst %5 %1 Fract %633 %635 = OpExtInst %5 %1 SmoothStep %80 %624 %634 OpLine %3 285 5 @@ -1479,21 +1479,21 @@ OpLine %3 289 25 OpLine %3 291 21 %650 = OpAccessChain %646 %618 %135 %651 = OpLoad %5 %650 -%652 = OpCompositeExtract %5 %606 2 +%652 = OpCompositeExtract %5 %607 2 %653 = OpFSub %5 %651 %652 %654 = OpExtInst %5 %1 Normalize %653 OpLine %3 292 20 %656 = OpAccessChain %655 %616 %135 %657 = OpLoad %7 %656 %658 = OpVectorShuffle %5 %657 %657 0 1 2 -%659 = OpCompositeExtract %5 %606 2 +%659 = OpCompositeExtract %5 %607 2 %660 = OpFSub %5 %658 %659 %661 = OpExtInst %5 %1 Normalize %660 OpLine %3 293 20 %662 = OpFAdd %5 %661 %654 %663 = OpExtInst %5 %1 Normalize %662 OpLine %3 295 32 -%664 = OpCompositeExtract %5 %606 1 +%664 = OpCompositeExtract %5 %607 1 %665 = OpDot %4 %664 %654 OpLine %3 295 28 %666 = OpExtInst %4 %1 FMax %665 %74 @@ -1502,7 +1502,7 @@ OpLine %3 296 25 %668 = OpLoad %5 %667 %669 = OpVectorTimesScalar %5 %668 %666 OpLine %3 298 37 -%670 = OpCompositeExtract %5 %606 1 +%670 = OpCompositeExtract %5 %607 1 %671 = OpDot %4 %670 %663 OpLine %3 298 33 %672 = OpExtInst %4 %1 FMax %671 %74 @@ -1519,6 +1519,6 @@ OpLine %3 301 18 %680 = OpFMul %5 %678 %679 OpLine %3 303 12 %681 = OpCompositeConstruct %7 %680 %56 -OpStore %613 %681 +OpStore %614 %681 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-dualsource.spvasm b/naga/tests/out/spv/wgsl-dualsource.spvasm index c904f713684..f6d5a4e34e2 100644 --- a/naga/tests/out/spv/wgsl-dualsource.spvasm +++ b/naga/tests/out/spv/wgsl-dualsource.spvasm @@ -17,7 +17,7 @@ OpDecorate %9 Index 1 %4 = OpTypeFloat 32 %3 = OpTypeVector %4 4 %5 = OpTypeStruct %3 %3 -%8 = OpTypePointer Output %5 +%8 = OpTypePointer Output %3 %7 = OpVariable %8 Output %9 = OpVariable %8 Output %11 = OpTypeFunction %2 diff --git a/naga/tests/out/spv/wgsl-interface.fragment.spvasm b/naga/tests/out/spv/wgsl-interface.fragment.spvasm index 00eb33744d8..d224df65aa0 100644 --- a/naga/tests/out/spv/wgsl-interface.fragment.spvasm +++ b/naga/tests/out/spv/wgsl-interface.fragment.spvasm @@ -1,14 +1,14 @@ ; SPIR-V ; Version: 1.0 ; Generator: rspirv -; Bound: 49 +; Bound: 50 OpCapability Shader OpCapability SampleRateShading %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %34 "fragment" %16 %19 %22 %25 %28 %30 %32 %33 -OpExecutionMode %34 OriginUpperLeft -OpExecutionMode %34 DepthReplacing +OpEntryPoint Fragment %35 "fragment" %16 %19 %22 %25 %28 %30 %32 %34 +OpExecutionMode %35 OriginUpperLeft +OpExecutionMode %35 DepthReplacing OpMemberDecorate %5 0 Offset 0 OpMemberDecorate %5 1 Offset 16 OpMemberDecorate %7 0 Offset 0 @@ -28,7 +28,7 @@ OpDecorate %28 BuiltIn SampleMask OpDecorate %28 Flat OpDecorate %30 BuiltIn FragDepth OpDecorate %32 BuiltIn SampleMask -OpDecorate %33 Location 0 +OpDecorate %34 Location 0 %2 = OpTypeVoid %3 = OpTypeFloat 32 %4 = OpTypeVector %3 4 @@ -50,14 +50,15 @@ OpDecorate %33 Location 0 %26 = OpTypePointer Input %6 %25 = OpVariable %26 Input %28 = OpVariable %26 Input -%31 = OpTypePointer Output %7 +%31 = OpTypePointer Output %3 %30 = OpVariable %31 Output -%32 = OpVariable %31 Output -%33 = OpVariable %31 Output -%35 = OpTypeFunction %2 -%36 = OpConstant %3 0.0 -%37 = OpConstant %3 1.0 -%34 = OpFunction %2 None %35 +%33 = OpTypePointer Output %6 +%32 = OpVariable %33 Output +%34 = OpVariable %31 Output +%36 = OpTypeFunction %2 +%37 = OpConstant %3 0.0 +%38 = OpConstant %3 1.0 +%35 = OpFunction %2 None %36 %14 = OpLabel %18 = OpLoad %4 %16 %21 = OpLoad %3 %19 @@ -65,21 +66,21 @@ OpDecorate %33 Location 0 %24 = OpLoad %8 %22 %27 = OpLoad %6 %25 %29 = OpLoad %6 %28 -OpBranch %38 -%38 = OpLabel -%39 = OpShiftLeftLogical %6 %10 %27 -%40 = OpBitwiseAnd %6 %29 %39 -%41 = OpSelect %3 %24 %37 %36 -%42 = OpCompositeExtract %3 %15 1 -%43 = OpCompositeConstruct %7 %42 %40 %41 -%44 = OpCompositeExtract %3 %43 0 -OpStore %30 %44 -%45 = OpLoad %3 %30 -%46 = OpExtInst %3 %1 FClamp %45 %36 %37 -OpStore %30 %46 -%47 = OpCompositeExtract %6 %43 1 -OpStore %32 %47 -%48 = OpCompositeExtract %3 %43 2 -OpStore %33 %48 +OpBranch %39 +%39 = OpLabel +%40 = OpShiftLeftLogical %6 %10 %27 +%41 = OpBitwiseAnd %6 %29 %40 +%42 = OpSelect %3 %24 %38 %37 +%43 = OpCompositeExtract %3 %15 1 +%44 = OpCompositeConstruct %7 %43 %41 %42 +%45 = OpCompositeExtract %3 %44 0 +OpStore %30 %45 +%46 = OpLoad %3 %30 +%47 = OpExtInst %3 %1 FClamp %46 %37 %38 +OpStore %30 %47 +%48 = OpCompositeExtract %6 %44 1 +OpStore %32 %48 +%49 = OpCompositeExtract %3 %44 2 +OpStore %34 %49 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-interface.vertex.spvasm b/naga/tests/out/spv/wgsl-interface.vertex.spvasm index b54d77b9482..d7f7d2144bc 100644 --- a/naga/tests/out/spv/wgsl-interface.vertex.spvasm +++ b/naga/tests/out/spv/wgsl-interface.vertex.spvasm @@ -5,7 +5,7 @@ OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %28 "vertex" %15 %18 %20 %22 %24 %25 +OpEntryPoint Vertex %28 "vertex" %15 %18 %20 %22 %24 %26 OpMemberDecorate %5 0 Offset 0 OpMemberDecorate %5 1 Offset 16 OpMemberDecorate %7 0 Offset 0 @@ -20,7 +20,7 @@ OpDecorate %20 Location 10 OpDecorate %22 BuiltIn Position OpDecorate %22 Invariant OpDecorate %24 Location 1 -OpDecorate %25 BuiltIn PointSize +OpDecorate %26 BuiltIn PointSize %2 = OpTypeVoid %3 = OpTypeFloat 32 %4 = OpTypeVector %3 4 @@ -37,11 +37,11 @@ OpDecorate %25 BuiltIn PointSize %15 = OpVariable %16 Input %18 = OpVariable %16 Input %20 = OpVariable %16 Input -%23 = OpTypePointer Output %5 +%23 = OpTypePointer Output %4 %22 = OpVariable %23 Output -%24 = OpVariable %23 Output -%26 = OpTypePointer Output %3 -%25 = OpVariable %26 Output +%25 = OpTypePointer Output %3 +%24 = OpVariable %25 Output +%26 = OpVariable %25 Output %27 = OpConstant %3 1.0 %29 = OpTypeFunction %2 %30 = OpConstantComposite %4 %27 %27 %27 %27 @@ -50,7 +50,7 @@ OpDecorate %25 BuiltIn PointSize %17 = OpLoad %6 %15 %19 = OpLoad %6 %18 %21 = OpLoad %6 %20 -OpStore %25 %27 +OpStore %26 %27 OpBranch %31 %31 = OpLabel %32 = OpIAdd %6 %17 %19 diff --git a/naga/tests/out/spv/wgsl-interpolate_compat.spvasm b/naga/tests/out/spv/wgsl-interpolate_compat.spvasm index 94d8a65d335..f6c72a053ef 100644 --- a/naga/tests/out/spv/wgsl-interpolate_compat.spvasm +++ b/naga/tests/out/spv/wgsl-interpolate_compat.spvasm @@ -1,14 +1,14 @@ ; SPIR-V ; Version: 1.0 ; Generator: rspirv -; Bound: 130 +; Bound: 133 OpCapability Shader OpCapability SampleRateShading %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %26 "vert_main" %11 %13 %14 %15 %16 %17 %18 %19 %20 %21 %22 %23 -OpEntryPoint Fragment %128 "frag_main" %101 %104 %107 %109 %112 %115 %118 %120 %122 %124 %126 -OpExecutionMode %128 OriginUpperLeft +OpEntryPoint Vertex %29 "vert_main" %11 %13 %15 %16 %18 %20 %22 %23 %24 %25 %26 %27 +OpEntryPoint Fragment %131 "frag_main" %104 %107 %110 %112 %115 %118 %121 %123 %125 %127 %129 +OpExecutionMode %131 OriginUpperLeft %3 = OpString "interpolate_compat.wgsl" OpSource Unknown 0 %3 "// NOTE: This is basically the same as `interpolate.wgsl`, except for the removal of // `@interpolate(flat, first)`, which is unsupported in GLSL and `compat`. @@ -68,29 +68,29 @@ OpMemberName %9 10 "perspective_center" OpName %9 "FragmentInput" OpName %11 "position" OpName %13 "_flat" -OpName %14 "flat_either" -OpName %15 "_linear" -OpName %16 "linear_centroid" -OpName %17 "linear_sample" -OpName %18 "linear_center" -OpName %19 "perspective" -OpName %20 "perspective_centroid" -OpName %21 "perspective_sample" -OpName %22 "perspective_center" -OpName %26 "vert_main" -OpName %55 "out" -OpName %101 "position" -OpName %104 "_flat" -OpName %107 "flat_either" -OpName %109 "_linear" -OpName %112 "linear_centroid" -OpName %115 "linear_sample" -OpName %118 "linear_center" -OpName %120 "perspective" -OpName %122 "perspective_centroid" -OpName %124 "perspective_sample" -OpName %126 "perspective_center" -OpName %128 "frag_main" +OpName %15 "flat_either" +OpName %16 "_linear" +OpName %18 "linear_centroid" +OpName %20 "linear_sample" +OpName %22 "linear_center" +OpName %23 "perspective" +OpName %24 "perspective_centroid" +OpName %25 "perspective_sample" +OpName %26 "perspective_center" +OpName %29 "vert_main" +OpName %58 "out" +OpName %104 "position" +OpName %107 "_flat" +OpName %110 "flat_either" +OpName %112 "_linear" +OpName %115 "linear_centroid" +OpName %118 "linear_sample" +OpName %121 "linear_center" +OpName %123 "perspective" +OpName %125 "perspective_centroid" +OpName %127 "perspective_sample" +OpName %129 "perspective_center" +OpName %131 "frag_main" OpMemberDecorate %9 0 Offset 0 OpMemberDecorate %9 1 Offset 16 OpMemberDecorate %9 2 Offset 20 @@ -105,46 +105,46 @@ OpMemberDecorate %9 10 Offset 104 OpDecorate %11 BuiltIn Position OpDecorate %13 Location 0 OpDecorate %13 Flat -OpDecorate %14 Location 2 -OpDecorate %14 Flat -OpDecorate %15 Location 3 -OpDecorate %15 NoPerspective -OpDecorate %16 Location 4 +OpDecorate %15 Location 2 +OpDecorate %15 Flat +OpDecorate %16 Location 3 OpDecorate %16 NoPerspective -OpDecorate %16 Centroid -OpDecorate %17 Location 6 -OpDecorate %17 NoPerspective -OpDecorate %17 Sample -OpDecorate %18 Location 7 +OpDecorate %18 Location 4 OpDecorate %18 NoPerspective -OpDecorate %19 Location 8 -OpDecorate %20 Location 9 -OpDecorate %20 Centroid -OpDecorate %21 Location 10 -OpDecorate %21 Sample -OpDecorate %22 Location 11 -OpDecorate %23 BuiltIn PointSize -OpDecorate %101 BuiltIn FragCoord -OpDecorate %104 Location 0 -OpDecorate %104 Flat -OpDecorate %107 Location 2 +OpDecorate %18 Centroid +OpDecorate %20 Location 6 +OpDecorate %20 NoPerspective +OpDecorate %20 Sample +OpDecorate %22 Location 7 +OpDecorate %22 NoPerspective +OpDecorate %23 Location 8 +OpDecorate %24 Location 9 +OpDecorate %24 Centroid +OpDecorate %25 Location 10 +OpDecorate %25 Sample +OpDecorate %26 Location 11 +OpDecorate %27 BuiltIn PointSize +OpDecorate %104 BuiltIn FragCoord +OpDecorate %107 Location 0 OpDecorate %107 Flat -OpDecorate %109 Location 3 -OpDecorate %109 NoPerspective -OpDecorate %112 Location 4 +OpDecorate %110 Location 2 +OpDecorate %110 Flat +OpDecorate %112 Location 3 OpDecorate %112 NoPerspective -OpDecorate %112 Centroid -OpDecorate %115 Location 6 +OpDecorate %115 Location 4 OpDecorate %115 NoPerspective -OpDecorate %115 Sample -OpDecorate %118 Location 7 +OpDecorate %115 Centroid +OpDecorate %118 Location 6 OpDecorate %118 NoPerspective -OpDecorate %120 Location 8 -OpDecorate %122 Location 9 -OpDecorate %122 Centroid -OpDecorate %124 Location 10 -OpDecorate %124 Sample -OpDecorate %126 Location 11 +OpDecorate %118 Sample +OpDecorate %121 Location 7 +OpDecorate %121 NoPerspective +OpDecorate %123 Location 8 +OpDecorate %125 Location 9 +OpDecorate %125 Centroid +OpDecorate %127 Location 10 +OpDecorate %127 Sample +OpDecorate %129 Location 11 %2 = OpTypeVoid %4 = OpTypeFloat 32 %5 = OpTypeVector %4 4 @@ -152,181 +152,184 @@ OpDecorate %126 Location 11 %7 = OpTypeVector %4 2 %8 = OpTypeVector %4 3 %9 = OpTypeStruct %5 %6 %6 %4 %7 %8 %8 %5 %4 %4 %4 -%12 = OpTypePointer Output %9 +%12 = OpTypePointer Output %5 %11 = OpVariable %12 Output -%13 = OpVariable %12 Output -%14 = OpVariable %12 Output -%15 = OpVariable %12 Output -%16 = OpVariable %12 Output -%17 = OpVariable %12 Output -%18 = OpVariable %12 Output -%19 = OpVariable %12 Output -%20 = OpVariable %12 Output -%21 = OpVariable %12 Output -%22 = OpVariable %12 Output -%24 = OpTypePointer Output %4 -%23 = OpVariable %24 Output -%25 = OpConstant %4 1.0 -%27 = OpTypeFunction %2 -%28 = OpConstant %4 2.0 -%29 = OpConstant %4 4.0 -%30 = OpConstant %4 5.0 -%31 = OpConstant %4 6.0 -%32 = OpConstantComposite %5 %28 %29 %30 %31 -%33 = OpConstant %6 8 -%34 = OpConstant %6 10 -%35 = OpConstant %4 27.0 -%36 = OpConstant %4 64.0 -%37 = OpConstant %4 125.0 -%38 = OpConstantComposite %7 %36 %37 -%39 = OpConstant %4 216.0 -%40 = OpConstant %4 343.0 -%41 = OpConstant %4 512.0 -%42 = OpConstantComposite %8 %39 %40 %41 -%43 = OpConstant %4 255.0 -%44 = OpConstant %4 511.0 -%45 = OpConstant %4 1024.0 -%46 = OpConstantComposite %8 %43 %44 %45 -%47 = OpConstant %4 729.0 -%48 = OpConstant %4 1000.0 -%49 = OpConstant %4 1331.0 -%50 = OpConstant %4 1728.0 -%51 = OpConstantComposite %5 %47 %48 %49 %50 -%52 = OpConstant %4 2197.0 -%53 = OpConstant %4 2744.0 -%54 = OpConstant %4 2812.0 -%56 = OpTypePointer Function %9 -%57 = OpConstantNull %9 -%59 = OpTypePointer Function %5 -%60 = OpConstant %6 0 -%62 = OpTypePointer Function %6 -%63 = OpConstant %6 1 -%65 = OpConstant %6 2 -%67 = OpTypePointer Function %4 -%68 = OpConstant %6 3 -%70 = OpTypePointer Function %7 -%71 = OpConstant %6 4 -%73 = OpTypePointer Function %8 -%74 = OpConstant %6 5 -%76 = OpConstant %6 6 -%78 = OpConstant %6 7 -%81 = OpConstant %6 9 -%102 = OpTypePointer Input %5 -%101 = OpVariable %102 Input -%105 = OpTypePointer Input %6 +%14 = OpTypePointer Output %6 +%13 = OpVariable %14 Output +%15 = OpVariable %14 Output +%17 = OpTypePointer Output %4 +%16 = OpVariable %17 Output +%19 = OpTypePointer Output %7 +%18 = OpVariable %19 Output +%21 = OpTypePointer Output %8 +%20 = OpVariable %21 Output +%22 = OpVariable %21 Output +%23 = OpVariable %12 Output +%24 = OpVariable %17 Output +%25 = OpVariable %17 Output +%26 = OpVariable %17 Output +%27 = OpVariable %17 Output +%28 = OpConstant %4 1.0 +%30 = OpTypeFunction %2 +%31 = OpConstant %4 2.0 +%32 = OpConstant %4 4.0 +%33 = OpConstant %4 5.0 +%34 = OpConstant %4 6.0 +%35 = OpConstantComposite %5 %31 %32 %33 %34 +%36 = OpConstant %6 8 +%37 = OpConstant %6 10 +%38 = OpConstant %4 27.0 +%39 = OpConstant %4 64.0 +%40 = OpConstant %4 125.0 +%41 = OpConstantComposite %7 %39 %40 +%42 = OpConstant %4 216.0 +%43 = OpConstant %4 343.0 +%44 = OpConstant %4 512.0 +%45 = OpConstantComposite %8 %42 %43 %44 +%46 = OpConstant %4 255.0 +%47 = OpConstant %4 511.0 +%48 = OpConstant %4 1024.0 +%49 = OpConstantComposite %8 %46 %47 %48 +%50 = OpConstant %4 729.0 +%51 = OpConstant %4 1000.0 +%52 = OpConstant %4 1331.0 +%53 = OpConstant %4 1728.0 +%54 = OpConstantComposite %5 %50 %51 %52 %53 +%55 = OpConstant %4 2197.0 +%56 = OpConstant %4 2744.0 +%57 = OpConstant %4 2812.0 +%59 = OpTypePointer Function %9 +%60 = OpConstantNull %9 +%62 = OpTypePointer Function %5 +%63 = OpConstant %6 0 +%65 = OpTypePointer Function %6 +%66 = OpConstant %6 1 +%68 = OpConstant %6 2 +%70 = OpTypePointer Function %4 +%71 = OpConstant %6 3 +%73 = OpTypePointer Function %7 +%74 = OpConstant %6 4 +%76 = OpTypePointer Function %8 +%77 = OpConstant %6 5 +%79 = OpConstant %6 6 +%81 = OpConstant %6 7 +%84 = OpConstant %6 9 +%105 = OpTypePointer Input %5 %104 = OpVariable %105 Input -%107 = OpVariable %105 Input -%110 = OpTypePointer Input %4 -%109 = OpVariable %110 Input -%113 = OpTypePointer Input %7 +%108 = OpTypePointer Input %6 +%107 = OpVariable %108 Input +%110 = OpVariable %108 Input +%113 = OpTypePointer Input %4 %112 = OpVariable %113 Input -%116 = OpTypePointer Input %8 +%116 = OpTypePointer Input %7 %115 = OpVariable %116 Input -%118 = OpVariable %116 Input -%120 = OpVariable %102 Input -%122 = OpVariable %110 Input -%124 = OpVariable %110 Input -%126 = OpVariable %110 Input -%26 = OpFunction %2 None %27 +%119 = OpTypePointer Input %8 +%118 = OpVariable %119 Input +%121 = OpVariable %119 Input +%123 = OpVariable %105 Input +%125 = OpVariable %113 Input +%127 = OpVariable %113 Input +%129 = OpVariable %113 Input +%29 = OpFunction %2 None %30 %10 = OpLabel -%55 = OpVariable %56 Function %57 -OpStore %23 %25 -OpBranch %58 -%58 = OpLabel +%58 = OpVariable %59 Function %60 +OpStore %27 %28 +OpBranch %61 +%61 = OpLabel OpLine %3 26 4 OpLine %3 26 19 OpLine %3 26 4 -%61 = OpAccessChain %59 %55 %60 -OpStore %61 %32 +%64 = OpAccessChain %62 %58 %63 +OpStore %64 %35 OpLine %3 27 4 OpLine %3 27 4 -%64 = OpAccessChain %62 %55 %63 -OpStore %64 %33 +%67 = OpAccessChain %65 %58 %66 +OpStore %67 %36 OpLine %3 29 4 OpLine %3 29 4 -%66 = OpAccessChain %62 %55 %65 -OpStore %66 %34 +%69 = OpAccessChain %65 %58 %68 +OpStore %69 %37 OpLine %3 30 4 OpLine %3 30 4 -%69 = OpAccessChain %67 %55 %68 -OpStore %69 %35 +%72 = OpAccessChain %70 %58 %71 +OpStore %72 %38 OpLine %3 31 4 OpLine %3 31 26 OpLine %3 31 4 -%72 = OpAccessChain %70 %55 %71 -OpStore %72 %38 +%75 = OpAccessChain %73 %58 %74 +OpStore %75 %41 OpLine %3 32 4 OpLine %3 32 24 OpLine %3 32 4 -%75 = OpAccessChain %73 %55 %74 -OpStore %75 %42 +%78 = OpAccessChain %76 %58 %77 +OpStore %78 %45 OpLine %3 33 4 OpLine %3 33 24 OpLine %3 33 4 -%77 = OpAccessChain %73 %55 %76 -OpStore %77 %46 +%80 = OpAccessChain %76 %58 %79 +OpStore %80 %49 OpLine %3 34 4 OpLine %3 34 22 OpLine %3 34 4 -%79 = OpAccessChain %59 %55 %78 -OpStore %79 %51 +%82 = OpAccessChain %62 %58 %81 +OpStore %82 %54 OpLine %3 35 4 OpLine %3 35 4 -%80 = OpAccessChain %67 %55 %33 -OpStore %80 %52 +%83 = OpAccessChain %70 %58 %36 +OpStore %83 %55 OpLine %3 36 4 OpLine %3 36 4 -%82 = OpAccessChain %67 %55 %81 -OpStore %82 %53 +%85 = OpAccessChain %70 %58 %84 +OpStore %85 %56 OpLine %3 37 4 OpLine %3 37 4 -%83 = OpAccessChain %67 %55 %34 -OpStore %83 %54 +%86 = OpAccessChain %70 %58 %37 +OpStore %86 %57 OpLine %3 1 1 -%84 = OpLoad %9 %55 -%85 = OpCompositeExtract %5 %84 0 -OpStore %11 %85 -%86 = OpAccessChain %24 %11 %63 -%87 = OpLoad %4 %86 -%88 = OpFNegate %4 %87 -OpStore %86 %88 -%89 = OpCompositeExtract %6 %84 1 -OpStore %13 %89 -%90 = OpCompositeExtract %6 %84 2 -OpStore %14 %90 -%91 = OpCompositeExtract %4 %84 3 -OpStore %15 %91 -%92 = OpCompositeExtract %7 %84 4 -OpStore %16 %92 -%93 = OpCompositeExtract %8 %84 5 -OpStore %17 %93 -%94 = OpCompositeExtract %8 %84 6 -OpStore %18 %94 -%95 = OpCompositeExtract %5 %84 7 -OpStore %19 %95 -%96 = OpCompositeExtract %4 %84 8 +%87 = OpLoad %9 %58 +%88 = OpCompositeExtract %5 %87 0 +OpStore %11 %88 +%89 = OpAccessChain %17 %11 %66 +%90 = OpLoad %4 %89 +%91 = OpFNegate %4 %90 +OpStore %89 %91 +%92 = OpCompositeExtract %6 %87 1 +OpStore %13 %92 +%93 = OpCompositeExtract %6 %87 2 +OpStore %15 %93 +%94 = OpCompositeExtract %4 %87 3 +OpStore %16 %94 +%95 = OpCompositeExtract %7 %87 4 +OpStore %18 %95 +%96 = OpCompositeExtract %8 %87 5 OpStore %20 %96 -%97 = OpCompositeExtract %4 %84 9 -OpStore %21 %97 -%98 = OpCompositeExtract %4 %84 10 -OpStore %22 %98 +%97 = OpCompositeExtract %8 %87 6 +OpStore %22 %97 +%98 = OpCompositeExtract %5 %87 7 +OpStore %23 %98 +%99 = OpCompositeExtract %4 %87 8 +OpStore %24 %99 +%100 = OpCompositeExtract %4 %87 9 +OpStore %25 %100 +%101 = OpCompositeExtract %4 %87 10 +OpStore %26 %101 OpReturn OpFunctionEnd -%128 = OpFunction %2 None %27 -%99 = OpLabel -%103 = OpLoad %5 %101 -%106 = OpLoad %6 %104 -%108 = OpLoad %6 %107 -%111 = OpLoad %4 %109 -%114 = OpLoad %7 %112 -%117 = OpLoad %8 %115 -%119 = OpLoad %8 %118 -%121 = OpLoad %5 %120 -%123 = OpLoad %4 %122 -%125 = OpLoad %4 %124 -%127 = OpLoad %4 %126 -%100 = OpCompositeConstruct %9 %103 %106 %108 %111 %114 %117 %119 %121 %123 %125 %127 -OpBranch %129 -%129 = OpLabel +%131 = OpFunction %2 None %30 +%102 = OpLabel +%106 = OpLoad %5 %104 +%109 = OpLoad %6 %107 +%111 = OpLoad %6 %110 +%114 = OpLoad %4 %112 +%117 = OpLoad %7 %115 +%120 = OpLoad %8 %118 +%122 = OpLoad %8 %121 +%124 = OpLoad %5 %123 +%126 = OpLoad %4 %125 +%128 = OpLoad %4 %127 +%130 = OpLoad %4 %129 +%103 = OpCompositeConstruct %9 %106 %109 %111 %114 %117 %120 %122 %124 %126 %128 %130 +OpBranch %132 +%132 = OpLabel OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-quad.spvasm b/naga/tests/out/spv/wgsl-quad.spvasm index dbe498a7c1e..a3532fb16e0 100644 --- a/naga/tests/out/spv/wgsl-quad.spvasm +++ b/naga/tests/out/spv/wgsl-quad.spvasm @@ -5,8 +5,8 @@ OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %24 "vert_main" %16 %19 %21 %23 -OpEntryPoint Fragment %45 "frag_main" %41 %43 +OpEntryPoint Vertex %25 "vert_main" %16 %19 %21 %23 +OpEntryPoint Fragment %45 "frag_main" %42 %44 OpEntryPoint Fragment %61 "fs_extra" %60 OpExecutionMode %45 OriginUpperLeft OpExecutionMode %61 OriginUpperLeft @@ -60,8 +60,8 @@ OpName %16 "pos" OpName %19 "uv" OpName %21 "uv" OpName %23 "position" -OpName %24 "vert_main" -OpName %41 "uv" +OpName %25 "vert_main" +OpName %42 "uv" OpName %45 "frag_main" OpName %61 "fs_extra" OpMemberDecorate %7 0 Offset 0 @@ -74,8 +74,8 @@ OpDecorate %16 Location 0 OpDecorate %19 Location 1 OpDecorate %21 Location 0 OpDecorate %23 BuiltIn Position -OpDecorate %41 Location 0 -OpDecorate %43 Location 0 +OpDecorate %42 Location 0 +OpDecorate %44 Location 0 OpDecorate %60 Location 0 %2 = OpTypeVoid %4 = OpTypeFloat 32 @@ -92,58 +92,58 @@ OpDecorate %60 Location 0 %17 = OpTypePointer Input %5 %16 = OpVariable %17 Input %19 = OpVariable %17 Input -%22 = OpTypePointer Output %7 +%22 = OpTypePointer Output %5 %21 = OpVariable %22 Output -%23 = OpVariable %22 Output -%25 = OpTypeFunction %2 -%26 = OpConstant %4 0.0 -%27 = OpConstant %4 1.0 -%34 = OpTypePointer Output %4 -%36 = OpTypeInt 32 0 -%35 = OpConstant %36 1 -%41 = OpVariable %17 Input -%44 = OpTypePointer Output %6 -%43 = OpVariable %44 Output +%24 = OpTypePointer Output %6 +%23 = OpVariable %24 Output +%26 = OpTypeFunction %2 +%27 = OpConstant %4 0.0 +%28 = OpConstant %4 1.0 +%35 = OpTypePointer Output %4 +%37 = OpTypeInt 32 0 +%36 = OpConstant %37 1 +%42 = OpVariable %17 Input +%44 = OpVariable %24 Output %49 = OpTypeSampledImage %8 %53 = OpTypeBool -%60 = OpVariable %44 Output +%60 = OpVariable %24 Output %62 = OpConstant %4 0.5 -%63 = OpConstantComposite %6 %26 %62 %26 %62 -%24 = OpFunction %2 None %25 +%63 = OpConstantComposite %6 %27 %62 %27 %62 +%25 = OpFunction %2 None %26 %15 = OpLabel %18 = OpLoad %5 %16 %20 = OpLoad %5 %19 -OpBranch %28 -%28 = OpLabel +OpBranch %29 +%29 = OpLabel OpLine %3 14 37 -%29 = OpVectorTimesScalar %5 %18 %10 +%30 = OpVectorTimesScalar %5 %18 %10 OpLine %3 14 10 -%30 = OpCompositeConstruct %6 %29 %26 %27 -%31 = OpCompositeConstruct %7 %20 %30 -%32 = OpCompositeExtract %5 %31 0 -OpStore %21 %32 -%33 = OpCompositeExtract %6 %31 1 -OpStore %23 %33 -%37 = OpAccessChain %34 %23 %35 -%38 = OpLoad %4 %37 -%39 = OpFNegate %4 %38 -OpStore %37 %39 +%31 = OpCompositeConstruct %6 %30 %27 %28 +%32 = OpCompositeConstruct %7 %20 %31 +%33 = OpCompositeExtract %5 %32 0 +OpStore %21 %33 +%34 = OpCompositeExtract %6 %32 1 +OpStore %23 %34 +%38 = OpAccessChain %35 %23 %36 +%39 = OpLoad %4 %38 +%40 = OpFNegate %4 %39 +OpStore %38 %40 OpReturn OpFunctionEnd -%45 = OpFunction %2 None %25 -%40 = OpLabel -%42 = OpLoad %5 %41 +%45 = OpFunction %2 None %26 +%41 = OpLabel +%43 = OpLoad %5 %42 %46 = OpLoad %8 %11 %47 = OpLoad %9 %13 OpBranch %48 %48 = OpLabel OpLine %3 23 15 %50 = OpSampledImage %49 %46 %47 -%51 = OpImageSampleImplicitLod %6 %50 %42 +%51 = OpImageSampleImplicitLod %6 %50 %43 OpLine %3 24 6 %52 = OpCompositeExtract %4 %51 3 OpLine %3 24 6 -%54 = OpFOrdEqual %53 %52 %26 +%54 = OpFOrdEqual %53 %52 %27 OpLine %3 24 3 OpSelectionMerge %55 None OpBranchConditional %54 %56 %55 @@ -153,10 +153,10 @@ OpKill OpLine %3 29 23 %57 = OpCompositeExtract %4 %51 3 %58 = OpVectorTimesScalar %6 %51 %57 -OpStore %43 %58 +OpStore %44 %58 OpReturn OpFunctionEnd -%61 = OpFunction %2 None %25 +%61 = OpFunction %2 None %26 %59 = OpLabel OpBranch %64 %64 = OpLabel diff --git a/naga/tests/out/spv/wgsl-shadow.spvasm b/naga/tests/out/spv/wgsl-shadow.spvasm index b6d6a3486e1..ea131ae6d03 100644 --- a/naga/tests/out/spv/wgsl-shadow.spvasm +++ b/naga/tests/out/spv/wgsl-shadow.spvasm @@ -6,8 +6,8 @@ OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %84 "vs_main" %75 %78 %80 %82 %83 -OpEntryPoint Fragment %143 "fs_main" %133 %136 %139 %141 +OpEntryPoint Vertex %85 "vs_main" %75 %78 %80 %82 %84 +OpEntryPoint Fragment %143 "fs_main" %134 %137 %140 %142 OpEntryPoint Fragment %228 "fs_main_without_storage" %221 %223 %225 %227 OpExecutionMode %143 OriginUpperLeft OpExecutionMode %228 OriginUpperLeft @@ -159,12 +159,12 @@ OpName %75 "position" OpName %78 "normal" OpName %80 "proj_position" OpName %82 "world_normal" -OpName %83 "world_position" -OpName %84 "vs_main" -OpName %91 "out" -OpName %133 "proj_position" -OpName %136 "world_normal" -OpName %139 "world_position" +OpName %84 "world_position" +OpName %85 "vs_main" +OpName %92 "out" +OpName %134 "proj_position" +OpName %137 "world_normal" +OpName %140 "world_position" OpName %143 "fs_main" OpName %150 "color" OpName %151 "i" @@ -219,11 +219,11 @@ OpDecorate %75 Location 0 OpDecorate %78 Location 1 OpDecorate %80 BuiltIn Position OpDecorate %82 Location 0 -OpDecorate %83 Location 1 -OpDecorate %133 BuiltIn FragCoord -OpDecorate %136 Location 0 -OpDecorate %139 Location 1 -OpDecorate %141 Location 0 +OpDecorate %84 Location 1 +OpDecorate %134 BuiltIn FragCoord +OpDecorate %137 Location 0 +OpDecorate %140 Location 1 +OpDecorate %142 Location 0 OpDecorate %221 BuiltIn FragCoord OpDecorate %223 Location 0 OpDecorate %225 Location 1 @@ -278,46 +278,46 @@ OpDecorate %227 Location 0 %76 = OpTypePointer Input %13 %75 = OpVariable %76 Input %78 = OpVariable %76 Input -%81 = OpTypePointer Output %12 +%81 = OpTypePointer Output %6 %80 = OpVariable %81 Output -%82 = OpVariable %81 Output -%83 = OpVariable %81 Output -%85 = OpTypeFunction %2 -%86 = OpTypePointer Uniform %9 -%87 = OpConstant %7 0 -%89 = OpTypePointer Uniform %10 -%92 = OpTypePointer Function %12 -%93 = OpConstantNull %12 -%95 = OpTypePointer Uniform %5 -%102 = OpTypePointer Function %11 -%110 = OpTypeVector %14 3 -%114 = OpConstant %7 1 -%116 = OpTypePointer Function %6 -%117 = OpConstant %7 2 -%125 = OpTypePointer Output %4 -%134 = OpTypePointer Input %6 -%133 = OpVariable %134 Input -%137 = OpTypePointer Input %11 -%136 = OpVariable %137 Input -%139 = OpVariable %134 Input -%142 = OpTypePointer Output %6 -%141 = OpVariable %142 Output +%83 = OpTypePointer Output %11 +%82 = OpVariable %83 Output +%84 = OpVariable %81 Output +%86 = OpTypeFunction %2 +%87 = OpTypePointer Uniform %9 +%88 = OpConstant %7 0 +%90 = OpTypePointer Uniform %10 +%93 = OpTypePointer Function %12 +%94 = OpConstantNull %12 +%96 = OpTypePointer Uniform %5 +%103 = OpTypePointer Function %11 +%111 = OpTypeVector %14 3 +%115 = OpConstant %7 1 +%117 = OpTypePointer Function %6 +%118 = OpConstant %7 2 +%126 = OpTypePointer Output %4 +%135 = OpTypePointer Input %6 +%134 = OpVariable %135 Input +%138 = OpTypePointer Input %11 +%137 = OpVariable %138 Input +%140 = OpVariable %135 Input +%142 = OpVariable %81 Output %146 = OpTypePointer StorageBuffer %17 %152 = OpTypePointer Function %7 %160 = OpTypeVector %7 2 %161 = OpTypePointer Function %160 %162 = OpTypeVector %56 2 -%163 = OpConstantComposite %160 %87 %87 +%163 = OpConstantComposite %160 %88 %88 %164 = OpConstant %7 4294967295 %165 = OpConstantComposite %160 %164 %164 %178 = OpTypePointer Uniform %8 %179 = OpTypePointer Uniform %7 %189 = OpTypePointer StorageBuffer %16 %215 = OpTypePointer Uniform %6 -%221 = OpVariable %134 Input -%223 = OpVariable %137 Input -%225 = OpVariable %134 Input -%227 = OpVariable %142 Output +%221 = OpVariable %135 Input +%223 = OpVariable %138 Input +%225 = OpVariable %135 Input +%227 = OpVariable %81 Output %231 = OpTypePointer Uniform %18 %265 = OpTypePointer Uniform %16 %44 = OpFunction %4 None %45 @@ -359,84 +359,84 @@ OpLine %3 77 12 %73 = OpImageSampleDrefExplicitLod %4 %72 %71 %68 Lod %48 OpReturnValue %73 OpFunctionEnd -%84 = OpFunction %2 None %85 +%85 = OpFunction %2 None %86 %74 = OpLabel -%91 = OpVariable %92 Function %93 +%92 = OpVariable %93 Function %94 %77 = OpLoad %13 %75 %79 = OpLoad %13 %78 -%88 = OpAccessChain %86 %25 %87 -%90 = OpAccessChain %89 %28 %87 -OpBranch %94 -%94 = OpLabel +%89 = OpAccessChain %87 %25 %88 +%91 = OpAccessChain %90 %28 %88 +OpBranch %95 +%95 = OpLabel OpLine %3 37 13 -%96 = OpAccessChain %95 %90 %87 -%97 = OpLoad %5 %96 +%97 = OpAccessChain %96 %91 %88 +%98 = OpLoad %5 %97 OpLine %3 38 21 -%98 = OpAccessChain %95 %90 %87 -%99 = OpLoad %5 %98 -%100 = OpConvertSToF %6 %77 -%101 = OpMatrixTimesVector %6 %99 %100 +%99 = OpAccessChain %96 %91 %88 +%100 = OpLoad %5 %99 +%101 = OpConvertSToF %6 %77 +%102 = OpMatrixTimesVector %6 %100 %101 OpLine %3 40 5 OpLine %3 40 36 -%103 = OpCompositeExtract %6 %97 0 -%104 = OpVectorShuffle %11 %103 %103 0 1 2 +%104 = OpCompositeExtract %6 %98 0 +%105 = OpVectorShuffle %11 %104 %104 0 1 2 OpLine %3 40 46 -%105 = OpCompositeExtract %6 %97 1 -%106 = OpVectorShuffle %11 %105 %105 0 1 2 +%106 = OpCompositeExtract %6 %98 1 +%107 = OpVectorShuffle %11 %106 %106 0 1 2 OpLine %3 40 24 -%107 = OpCompositeExtract %6 %97 2 -%108 = OpVectorShuffle %11 %107 %107 0 1 2 -%109 = OpCompositeConstruct %15 %104 %106 %108 -%111 = OpVectorShuffle %110 %79 %79 0 1 2 -%112 = OpConvertSToF %11 %111 -%113 = OpMatrixTimesVector %11 %109 %112 +%108 = OpCompositeExtract %6 %98 2 +%109 = OpVectorShuffle %11 %108 %108 0 1 2 +%110 = OpCompositeConstruct %15 %105 %107 %109 +%112 = OpVectorShuffle %111 %79 %79 0 1 2 +%113 = OpConvertSToF %11 %112 +%114 = OpMatrixTimesVector %11 %110 %113 OpLine %3 40 5 -%115 = OpAccessChain %102 %91 %114 -OpStore %115 %113 +%116 = OpAccessChain %103 %92 %115 +OpStore %116 %114 OpLine %3 41 5 OpLine %3 41 5 -%118 = OpAccessChain %116 %91 %117 -OpStore %118 %101 +%119 = OpAccessChain %117 %92 %118 +OpStore %119 %102 OpLine %3 42 5 OpLine %3 42 25 -%119 = OpAccessChain %95 %88 %87 -%120 = OpLoad %5 %119 -%121 = OpMatrixTimesVector %6 %120 %101 +%120 = OpAccessChain %96 %89 %88 +%121 = OpLoad %5 %120 +%122 = OpMatrixTimesVector %6 %121 %102 OpLine %3 42 5 -%122 = OpAccessChain %116 %91 %87 -OpStore %122 %121 +%123 = OpAccessChain %117 %92 %88 +OpStore %123 %122 OpLine %3 1 1 -%123 = OpLoad %12 %91 -%124 = OpCompositeExtract %6 %123 0 -OpStore %80 %124 -%126 = OpAccessChain %125 %80 %114 -%127 = OpLoad %4 %126 -%128 = OpFNegate %4 %127 -OpStore %126 %128 -%129 = OpCompositeExtract %11 %123 1 -OpStore %82 %129 -%130 = OpCompositeExtract %6 %123 2 -OpStore %83 %130 +%124 = OpLoad %12 %92 +%125 = OpCompositeExtract %6 %124 0 +OpStore %80 %125 +%127 = OpAccessChain %126 %80 %115 +%128 = OpLoad %4 %127 +%129 = OpFNegate %4 %128 +OpStore %127 %129 +%130 = OpCompositeExtract %11 %124 1 +OpStore %82 %130 +%131 = OpCompositeExtract %6 %124 2 +OpStore %84 %131 OpReturn OpFunctionEnd -%143 = OpFunction %2 None %85 -%131 = OpLabel -%150 = OpVariable %102 Function %24 -%151 = OpVariable %152 Function %87 +%143 = OpFunction %2 None %86 +%132 = OpLabel +%150 = OpVariable %103 Function %24 +%151 = OpVariable %152 Function %88 %166 = OpVariable %161 Function %165 -%135 = OpLoad %6 %133 -%138 = OpLoad %11 %136 -%140 = OpLoad %6 %139 -%132 = OpCompositeConstruct %12 %135 %138 %140 -%144 = OpAccessChain %86 %25 %87 -%145 = OpAccessChain %89 %28 %87 -%147 = OpAccessChain %146 %31 %87 +%136 = OpLoad %6 %134 +%139 = OpLoad %11 %137 +%141 = OpLoad %6 %140 +%133 = OpCompositeConstruct %12 %136 %139 %141 +%144 = OpAccessChain %87 %25 %88 +%145 = OpAccessChain %90 %28 %88 +%147 = OpAccessChain %146 %31 %88 %148 = OpLoad %20 %37 %149 = OpLoad %21 %39 OpBranch %153 %153 = OpLabel OpLine %3 85 18 -%154 = OpCompositeExtract %11 %132 1 +%154 = OpCompositeExtract %11 %133 1 %155 = OpExtInst %11 %1 Normalize %154 OpBranch %156 %156 = OpLabel @@ -451,9 +451,9 @@ OpSelectionMerge %171 None OpBranchConditional %170 %157 %171 %171 = OpLabel %172 = OpCompositeExtract %7 %168 1 -%173 = OpIEqual %56 %172 %87 -%174 = OpSelect %7 %173 %114 %87 -%175 = OpCompositeConstruct %160 %174 %114 +%173 = OpIEqual %56 %172 %88 +%174 = OpSelect %7 %173 %115 %88 +%175 = OpCompositeConstruct %160 %174 %115 %176 = OpISub %160 %168 %175 OpStore %166 %176 OpBranch %158 @@ -461,7 +461,7 @@ OpBranch %158 OpLine %3 1 1 %177 = OpLoad %7 %151 OpLine %3 88 29 -%180 = OpAccessChain %179 %144 %114 %87 +%180 = OpAccessChain %179 %144 %115 %88 %181 = OpLoad %7 %180 OpLine %3 88 21 %182 = OpExtInst %7 %1 UMin %181 %19 @@ -481,14 +481,14 @@ OpLine %3 89 21 OpLine %3 91 38 %192 = OpLoad %7 %151 %193 = OpCompositeExtract %5 %191 0 -%194 = OpCompositeExtract %6 %132 2 +%194 = OpCompositeExtract %6 %133 2 %195 = OpMatrixTimesVector %6 %193 %194 OpLine %3 91 22 %196 = OpFunctionCall %4 %44 %192 %195 OpLine %3 93 25 %197 = OpCompositeExtract %6 %191 1 %198 = OpVectorShuffle %11 %197 %197 0 1 2 -%199 = OpCompositeExtract %6 %132 2 +%199 = OpCompositeExtract %6 %133 2 %200 = OpVectorShuffle %11 %199 %199 0 1 2 %201 = OpFSub %11 %198 %200 %202 = OpExtInst %11 %1 Normalize %201 @@ -511,7 +511,7 @@ OpBranch %159 %159 = OpLabel OpLine %3 88 68 %211 = OpLoad %7 %151 -%212 = OpIAdd %7 %211 %114 +%212 = OpIAdd %7 %211 %115 OpLine %3 88 68 OpStore %151 %212 OpBranch %156 @@ -521,24 +521,24 @@ OpLine %3 1 1 OpLine %3 99 12 %214 = OpCompositeConstruct %6 %213 %49 OpLine %3 99 12 -%216 = OpAccessChain %215 %145 %114 +%216 = OpAccessChain %215 %145 %115 %217 = OpLoad %6 %216 %218 = OpFMul %6 %214 %217 -OpStore %141 %218 +OpStore %142 %218 OpReturn OpFunctionEnd -%228 = OpFunction %2 None %85 +%228 = OpFunction %2 None %86 %219 = OpLabel -%235 = OpVariable %102 Function %24 -%236 = OpVariable %152 Function %87 +%235 = OpVariable %103 Function %24 +%236 = OpVariable %152 Function %88 %244 = OpVariable %161 Function %165 %222 = OpLoad %6 %221 %224 = OpLoad %11 %223 %226 = OpLoad %6 %225 %220 = OpCompositeConstruct %12 %222 %224 %226 -%229 = OpAccessChain %86 %25 %87 -%230 = OpAccessChain %89 %28 %87 -%232 = OpAccessChain %231 %34 %87 +%229 = OpAccessChain %87 %25 %88 +%230 = OpAccessChain %90 %28 %88 +%232 = OpAccessChain %231 %34 %88 %233 = OpLoad %20 %37 %234 = OpLoad %21 %39 OpBranch %237 @@ -559,9 +559,9 @@ OpSelectionMerge %249 None OpBranchConditional %248 %241 %249 %249 = OpLabel %250 = OpCompositeExtract %7 %246 1 -%251 = OpIEqual %56 %250 %87 -%252 = OpSelect %7 %251 %114 %87 -%253 = OpCompositeConstruct %160 %252 %114 +%251 = OpIEqual %56 %250 %88 +%252 = OpSelect %7 %251 %115 %88 +%253 = OpCompositeConstruct %160 %252 %115 %254 = OpISub %160 %246 %253 OpStore %244 %254 OpBranch %242 @@ -569,7 +569,7 @@ OpBranch %242 OpLine %3 1 1 %255 = OpLoad %7 %236 OpLine %3 107 29 -%256 = OpAccessChain %179 %229 %114 %87 +%256 = OpAccessChain %179 %229 %115 %88 %257 = OpLoad %7 %256 OpLine %3 107 21 %258 = OpExtInst %7 %1 UMin %257 %19 @@ -619,7 +619,7 @@ OpBranch %243 %243 = OpLabel OpLine %3 107 68 %287 = OpLoad %7 %236 -%288 = OpIAdd %7 %287 %114 +%288 = OpIAdd %7 %287 %115 OpLine %3 107 68 OpStore %236 %288 OpBranch %240 @@ -629,7 +629,7 @@ OpLine %3 1 1 OpLine %3 116 12 %290 = OpCompositeConstruct %6 %289 %49 OpLine %3 116 12 -%291 = OpAccessChain %215 %230 %114 +%291 = OpAccessChain %215 %230 %115 %292 = OpLoad %6 %291 %293 = OpFMul %6 %290 %292 OpStore %227 %293 diff --git a/naga/tests/out/spv/wgsl-skybox.spvasm b/naga/tests/out/spv/wgsl-skybox.spvasm index 45df3166133..7bc7b30f6da 100644 --- a/naga/tests/out/spv/wgsl-skybox.spvasm +++ b/naga/tests/out/spv/wgsl-skybox.spvasm @@ -5,8 +5,8 @@ OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %45 "vs_main" %39 %42 %44 -OpEntryPoint Fragment %106 "fs_main" %98 %101 %104 +OpEntryPoint Vertex %46 "vs_main" %39 %42 %44 +OpEntryPoint Fragment %106 "fs_main" %99 %102 %105 OpExecutionMode %106 OriginUpperLeft OpMemberDecorate %6 0 Offset 0 OpMemberDecorate %6 1 Offset 16 @@ -27,9 +27,9 @@ OpDecorate %19 Binding 2 OpDecorate %39 BuiltIn VertexIndex OpDecorate %42 BuiltIn Position OpDecorate %44 Location 0 -OpDecorate %98 BuiltIn FragCoord -OpDecorate %101 Location 0 -OpDecorate %104 Location 0 +OpDecorate %99 BuiltIn FragCoord +OpDecorate %102 Location 0 +OpDecorate %105 Location 0 %2 = OpTypeVoid %4 = OpTypeFloat 32 %3 = OpTypeVector %4 4 @@ -57,29 +57,29 @@ OpDecorate %104 Location 0 %35 = OpConstant %10 1 %40 = OpTypePointer Input %9 %39 = OpVariable %40 Input -%43 = OpTypePointer Output %6 +%43 = OpTypePointer Output %3 %42 = OpVariable %43 Output -%44 = OpVariable %43 Output -%46 = OpTypeFunction %2 -%47 = OpTypePointer Uniform %8 -%48 = OpConstant %9 0 -%50 = OpConstant %10 2 -%51 = OpConstant %4 4.0 -%52 = OpConstant %4 1.0 -%53 = OpConstant %4 0.0 -%55 = OpTypePointer Function %10 -%56 = OpConstantNull %10 -%58 = OpConstantNull %10 -%73 = OpTypePointer Uniform %7 -%74 = OpTypePointer Uniform %3 -%75 = OpConstant %9 1 -%82 = OpConstant %9 2 -%99 = OpTypePointer Input %3 -%98 = OpVariable %99 Input -%102 = OpTypePointer Input %5 -%101 = OpVariable %102 Input -%105 = OpTypePointer Output %3 -%104 = OpVariable %105 Output +%45 = OpTypePointer Output %5 +%44 = OpVariable %45 Output +%47 = OpTypeFunction %2 +%48 = OpTypePointer Uniform %8 +%49 = OpConstant %9 0 +%51 = OpConstant %10 2 +%52 = OpConstant %4 4.0 +%53 = OpConstant %4 1.0 +%54 = OpConstant %4 0.0 +%56 = OpTypePointer Function %10 +%57 = OpConstantNull %10 +%59 = OpConstantNull %10 +%74 = OpTypePointer Uniform %7 +%75 = OpTypePointer Uniform %3 +%76 = OpConstant %9 1 +%83 = OpConstant %9 2 +%100 = OpTypePointer Input %3 +%99 = OpVariable %100 Input +%103 = OpTypePointer Input %5 +%102 = OpVariable %103 Input +%105 = OpVariable %43 Output %111 = OpTypeSampledImage %12 %21 = OpFunction %10 None %22 %23 = OpFunctionParameter %10 @@ -94,64 +94,64 @@ OpDecorate %104 Location 0 %37 = OpSDiv %10 %23 %36 OpReturnValue %37 OpFunctionEnd -%45 = OpFunction %2 None %46 +%46 = OpFunction %2 None %47 %38 = OpLabel -%54 = OpVariable %55 Function %56 -%57 = OpVariable %55 Function %58 +%55 = OpVariable %56 Function %57 +%58 = OpVariable %56 Function %59 %41 = OpLoad %9 %39 -%49 = OpAccessChain %47 %14 %48 -OpBranch %59 -%59 = OpLabel -%60 = OpBitcast %10 %41 -%61 = OpFunctionCall %10 %21 %60 %50 -OpStore %54 %61 -%62 = OpBitcast %10 %41 -%63 = OpBitwiseAnd %10 %62 %35 -OpStore %57 %63 -%64 = OpLoad %10 %54 -%65 = OpConvertSToF %4 %64 -%66 = OpFMul %4 %65 %51 -%67 = OpFSub %4 %66 %52 -%68 = OpLoad %10 %57 -%69 = OpConvertSToF %4 %68 -%70 = OpFMul %4 %69 %51 -%71 = OpFSub %4 %70 %52 -%72 = OpCompositeConstruct %3 %67 %71 %53 %52 -%76 = OpAccessChain %74 %49 %75 %48 -%77 = OpLoad %3 %76 -%78 = OpVectorShuffle %5 %77 %77 0 1 2 -%79 = OpAccessChain %74 %49 %75 %75 -%80 = OpLoad %3 %79 -%81 = OpVectorShuffle %5 %80 %80 0 1 2 -%83 = OpAccessChain %74 %49 %75 %82 -%84 = OpLoad %3 %83 -%85 = OpVectorShuffle %5 %84 %84 0 1 2 -%86 = OpCompositeConstruct %11 %78 %81 %85 -%87 = OpTranspose %11 %86 -%88 = OpAccessChain %73 %49 %48 -%89 = OpLoad %7 %88 -%90 = OpMatrixTimesVector %3 %89 %72 -%91 = OpVectorShuffle %5 %90 %90 0 1 2 -%92 = OpMatrixTimesVector %5 %87 %91 -%93 = OpCompositeConstruct %6 %72 %92 -%94 = OpCompositeExtract %3 %93 0 -OpStore %42 %94 -%95 = OpCompositeExtract %5 %93 1 -OpStore %44 %95 +%50 = OpAccessChain %48 %14 %49 +OpBranch %60 +%60 = OpLabel +%61 = OpBitcast %10 %41 +%62 = OpFunctionCall %10 %21 %61 %51 +OpStore %55 %62 +%63 = OpBitcast %10 %41 +%64 = OpBitwiseAnd %10 %63 %35 +OpStore %58 %64 +%65 = OpLoad %10 %55 +%66 = OpConvertSToF %4 %65 +%67 = OpFMul %4 %66 %52 +%68 = OpFSub %4 %67 %53 +%69 = OpLoad %10 %58 +%70 = OpConvertSToF %4 %69 +%71 = OpFMul %4 %70 %52 +%72 = OpFSub %4 %71 %53 +%73 = OpCompositeConstruct %3 %68 %72 %54 %53 +%77 = OpAccessChain %75 %50 %76 %49 +%78 = OpLoad %3 %77 +%79 = OpVectorShuffle %5 %78 %78 0 1 2 +%80 = OpAccessChain %75 %50 %76 %76 +%81 = OpLoad %3 %80 +%82 = OpVectorShuffle %5 %81 %81 0 1 2 +%84 = OpAccessChain %75 %50 %76 %83 +%85 = OpLoad %3 %84 +%86 = OpVectorShuffle %5 %85 %85 0 1 2 +%87 = OpCompositeConstruct %11 %79 %82 %86 +%88 = OpTranspose %11 %87 +%89 = OpAccessChain %74 %50 %49 +%90 = OpLoad %7 %89 +%91 = OpMatrixTimesVector %3 %90 %73 +%92 = OpVectorShuffle %5 %91 %91 0 1 2 +%93 = OpMatrixTimesVector %5 %88 %92 +%94 = OpCompositeConstruct %6 %73 %93 +%95 = OpCompositeExtract %3 %94 0 +OpStore %42 %95 +%96 = OpCompositeExtract %5 %94 1 +OpStore %44 %96 OpReturn OpFunctionEnd -%106 = OpFunction %2 None %46 -%96 = OpLabel -%100 = OpLoad %3 %98 -%103 = OpLoad %5 %101 -%97 = OpCompositeConstruct %6 %100 %103 +%106 = OpFunction %2 None %47 +%97 = OpLabel +%101 = OpLoad %3 %99 +%104 = OpLoad %5 %102 +%98 = OpCompositeConstruct %6 %101 %104 %107 = OpLoad %12 %17 %108 = OpLoad %13 %19 OpBranch %109 %109 = OpLabel -%110 = OpCompositeExtract %5 %97 1 +%110 = OpCompositeExtract %5 %98 1 %112 = OpSampledImage %111 %107 %108 %113 = OpImageSampleImplicitLod %3 %112 %110 -OpStore %104 %113 +OpStore %105 %113 OpReturn OpFunctionEnd \ No newline at end of file From d0821d7d6fb08d842525d916ecc049258e459d63 Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Mon, 14 Jul 2025 12:43:54 -0500 Subject: [PATCH 56/84] Updated mesh-shader.toml config --- naga/tests/in/wgsl/mesh-shader.toml | 3 +- .../out/analysis/wgsl-mesh-shader.info.ron | 1211 +++++++++++++++++ .../tests/out/ir/wgsl-mesh-shader.compact.ron | 840 ++++++++++++ naga/tests/out/ir/wgsl-mesh-shader.ron | 840 ++++++++++++ 4 files changed, 2893 insertions(+), 1 deletion(-) create mode 100644 naga/tests/out/analysis/wgsl-mesh-shader.info.ron create mode 100644 naga/tests/out/ir/wgsl-mesh-shader.compact.ron create mode 100644 naga/tests/out/ir/wgsl-mesh-shader.ron diff --git a/naga/tests/in/wgsl/mesh-shader.toml b/naga/tests/in/wgsl/mesh-shader.toml index bbbea9c3f05..a7780afbc21 100644 --- a/naga/tests/in/wgsl/mesh-shader.toml +++ b/naga/tests/in/wgsl/mesh-shader.toml @@ -1,7 +1,7 @@ # Stolen from ray-query.toml god_mode = true -targets = "SPIRV | METAL | HLSL" +targets = "SPIRV | IR | ANALYSIS" [msl] fake_missing_bindings = true @@ -16,3 +16,4 @@ zero_initialize_workgroup_memory = true [spv] version = [1, 4] +capabilities = ["MeshShadingEXT"] \ No newline at end of file diff --git a/naga/tests/out/analysis/wgsl-mesh-shader.info.ron b/naga/tests/out/analysis/wgsl-mesh-shader.info.ron new file mode 100644 index 00000000000..208e0aac84e --- /dev/null +++ b/naga/tests/out/analysis/wgsl-mesh-shader.info.ron @@ -0,0 +1,1211 @@ +( + type_flags: [ + ("DATA | SIZED | COPY | IO_SHAREABLE | HOST_SHAREABLE | CREATION_RESOLVED | ARGUMENT | CONSTRUCTIBLE"), + ("DATA | SIZED | COPY | IO_SHAREABLE | HOST_SHAREABLE | CREATION_RESOLVED | ARGUMENT | CONSTRUCTIBLE"), + ("DATA | SIZED | COPY | CREATION_RESOLVED | ARGUMENT | CONSTRUCTIBLE"), + ("DATA | SIZED | COPY | CREATION_RESOLVED | ARGUMENT | CONSTRUCTIBLE"), + ("DATA | SIZED | COPY | IO_SHAREABLE | HOST_SHAREABLE | CREATION_RESOLVED | ARGUMENT | CONSTRUCTIBLE"), + ("DATA | SIZED | COPY | IO_SHAREABLE | HOST_SHAREABLE | CREATION_RESOLVED | ARGUMENT | CONSTRUCTIBLE"), + ("DATA | SIZED | COPY | IO_SHAREABLE | HOST_SHAREABLE | CREATION_RESOLVED | ARGUMENT | CONSTRUCTIBLE"), + ("DATA | SIZED | COPY | CREATION_RESOLVED | ARGUMENT | CONSTRUCTIBLE"), + ("DATA | SIZED | COPY | IO_SHAREABLE | HOST_SHAREABLE | CREATION_RESOLVED | ARGUMENT | CONSTRUCTIBLE"), + ], + functions: [], + entry_points: [ + ( + flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + may_kill: false, + sampling_set: [], + global_uses: [ + ("READ | WRITE"), + ("WRITE"), + ], + expressions: [ + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: Some(1), + ty: Value(Pointer( + base: 0, + space: WorkGroup, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: Some(0), + ty: Value(Pointer( + base: 3, + space: TaskPayload, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: Some(0), + ty: Value(Pointer( + base: 1, + space: TaskPayload, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(1), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: Some(0), + ty: Value(Pointer( + base: 3, + space: TaskPayload, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: Some(0), + ty: Value(Pointer( + base: 2, + space: TaskPayload, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Bool, + width: 1, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Uint, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Uint, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Uint, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(6), + ), + ], + sampling: [], + dual_source_blending: false, + diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), + ), + ( + flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + may_kill: false, + sampling_set: [], + global_uses: [ + ("READ"), + ("WRITE"), + ], + expressions: [ + ( + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + ref_count: 0, + assignable_global: None, + ty: Handle(5), + ), + ( + uniformity: ( + non_uniform_result: Some(1), + requirements: (""), + ), + ref_count: 0, + assignable_global: None, + ty: Handle(6), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Uint, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Uint, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: Some(1), + ty: Value(Pointer( + base: 0, + space: WorkGroup, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: Some(6), + requirements: (""), + ), + ref_count: 9, + assignable_global: None, + ty: Value(Pointer( + base: 4, + space: Function, + )), + ), + ( + uniformity: ( + non_uniform_result: Some(6), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Pointer( + base: 1, + space: Function, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(1), + ), + ( + uniformity: ( + non_uniform_result: Some(6), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Pointer( + base: 1, + space: Function, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: Some(0), + ty: Value(Pointer( + base: 3, + space: TaskPayload, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: Some(0), + ty: Value(Pointer( + base: 1, + space: TaskPayload, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(1), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(1), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(1), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Uint, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: Some(6), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(4), + ), + ( + uniformity: ( + non_uniform_result: Some(6), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Pointer( + base: 1, + space: Function, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(1), + ), + ( + uniformity: ( + non_uniform_result: Some(6), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Pointer( + base: 1, + space: Function, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: Some(0), + ty: Value(Pointer( + base: 3, + space: TaskPayload, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: Some(0), + ty: Value(Pointer( + base: 1, + space: TaskPayload, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(1), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(1), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(1), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Uint, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: Some(6), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(4), + ), + ( + uniformity: ( + non_uniform_result: Some(6), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Pointer( + base: 1, + space: Function, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(1), + ), + ( + uniformity: ( + non_uniform_result: Some(6), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Pointer( + base: 1, + space: Function, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: Some(0), + ty: Value(Pointer( + base: 3, + space: TaskPayload, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: Some(0), + ty: Value(Pointer( + base: 1, + space: TaskPayload, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(1), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(1), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(1), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Uint, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: Some(6), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(4), + ), + ( + uniformity: ( + non_uniform_result: Some(61), + requirements: (""), + ), + ref_count: 4, + assignable_global: None, + ty: Value(Pointer( + base: 7, + space: Function, + )), + ), + ( + uniformity: ( + non_uniform_result: Some(61), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Pointer( + base: 6, + space: Function, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Uint, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Uint, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Uint, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(6), + ), + ( + uniformity: ( + non_uniform_result: Some(61), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Pointer( + base: 2, + space: Function, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: Some(0), + ty: Value(Pointer( + base: 3, + space: TaskPayload, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: Some(0), + ty: Value(Pointer( + base: 2, + space: TaskPayload, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(2), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(2), + ), + ( + uniformity: ( + non_uniform_result: Some(61), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Pointer( + base: 1, + space: Function, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Float, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(1), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Uint, + width: 4, + ))), + ), + ( + uniformity: ( + non_uniform_result: Some(61), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(7), + ), + ], + sampling: [], + dual_source_blending: false, + diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: Some((4, 24)), + primitive_type: Some((7, 79)), + ), + ), + ( + flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"), + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + may_kill: false, + sampling_set: [], + global_uses: [ + (""), + (""), + ], + expressions: [ + ( + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(4), + ), + ( + uniformity: ( + non_uniform_result: Some(1), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(8), + ), + ( + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(1), + ), + ( + uniformity: ( + non_uniform_result: Some(1), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(1), + ), + ( + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(1), + ), + ], + sampling: [], + dual_source_blending: false, + diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), + ), + ], + const_expression_types: [], +) \ No newline at end of file diff --git a/naga/tests/out/ir/wgsl-mesh-shader.compact.ron b/naga/tests/out/ir/wgsl-mesh-shader.compact.ron new file mode 100644 index 00000000000..5e320aa3895 --- /dev/null +++ b/naga/tests/out/ir/wgsl-mesh-shader.compact.ron @@ -0,0 +1,840 @@ +( + types: [ + ( + name: None, + inner: Scalar(( + kind: Float, + width: 4, + )), + ), + ( + name: None, + inner: Vector( + size: Quad, + scalar: ( + kind: Float, + width: 4, + ), + ), + ), + ( + name: None, + inner: Scalar(( + kind: Bool, + width: 1, + )), + ), + ( + name: Some("TaskPayload"), + inner: Struct( + members: [ + ( + name: Some("colorMask"), + ty: 1, + binding: None, + offset: 0, + ), + ( + name: Some("visible"), + ty: 2, + binding: None, + offset: 16, + ), + ], + span: 32, + ), + ), + ( + name: Some("VertexOutput"), + inner: Struct( + members: [ + ( + name: Some("position"), + ty: 1, + binding: Some(BuiltIn(Position( + invariant: false, + ))), + offset: 0, + ), + ( + name: Some("color"), + ty: 1, + binding: Some(Location( + location: 0, + interpolation: Some(Perspective), + sampling: Some(Center), + blend_src: None, + )), + offset: 16, + ), + ], + span: 32, + ), + ), + ( + name: None, + inner: Scalar(( + kind: Uint, + width: 4, + )), + ), + ( + name: None, + inner: Vector( + size: Tri, + scalar: ( + kind: Uint, + width: 4, + ), + ), + ), + ( + name: Some("PrimitiveOutput"), + inner: Struct( + members: [ + ( + name: Some("index"), + ty: 6, + binding: Some(BuiltIn(TriangleIndices)), + offset: 0, + ), + ( + name: Some("cull"), + ty: 2, + binding: Some(BuiltIn(CullPrimitive)), + offset: 12, + ), + ( + name: Some("colorMask"), + ty: 1, + binding: Some(Location( + location: 1, + interpolation: Some(Perspective), + sampling: Some(Center), + blend_src: None, + )), + offset: 16, + ), + ], + span: 32, + ), + ), + ( + name: Some("PrimitiveInput"), + inner: Struct( + members: [ + ( + name: Some("colorMask"), + ty: 1, + binding: Some(Location( + location: 1, + interpolation: Some(Perspective), + sampling: Some(Center), + blend_src: None, + )), + offset: 0, + ), + ], + span: 16, + ), + ), + ], + special_types: ( + ray_desc: None, + ray_intersection: None, + ray_vertex_return: None, + predeclared_types: {}, + ), + constants: [], + overrides: [], + global_variables: [ + ( + name: Some("taskPayload"), + space: TaskPayload, + binding: None, + ty: 3, + init: None, + ), + ( + name: Some("workgroupData"), + space: WorkGroup, + binding: None, + ty: 0, + init: None, + ), + ], + global_expressions: [], + functions: [], + entry_points: [ + ( + name: "ts_main", + stage: Task, + early_depth_test: None, + workgroup_size: (1, 1, 1), + workgroup_size_overrides: None, + function: ( + name: Some("ts_main"), + arguments: [], + result: Some(( + ty: 6, + binding: Some(BuiltIn(MeshTaskSize)), + )), + local_variables: [], + expressions: [ + GlobalVariable(1), + Literal(F32(1.0)), + GlobalVariable(0), + AccessIndex( + base: 2, + index: 0, + ), + Literal(F32(1.0)), + Literal(F32(1.0)), + Literal(F32(0.0)), + Literal(F32(1.0)), + Compose( + ty: 1, + components: [ + 4, + 5, + 6, + 7, + ], + ), + GlobalVariable(0), + AccessIndex( + base: 9, + index: 1, + ), + Literal(Bool(true)), + Literal(U32(3)), + Literal(U32(1)), + Literal(U32(1)), + Compose( + ty: 6, + components: [ + 12, + 13, + 14, + ], + ), + ], + named_expressions: {}, + body: [ + Store( + pointer: 0, + value: 1, + ), + Emit(( + start: 3, + end: 4, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 8, + end: 9, + )), + Store( + pointer: 3, + value: 8, + ), + Emit(( + start: 10, + end: 11, + )), + Store( + pointer: 10, + value: 11, + ), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 15, + end: 16, + )), + Return( + value: Some(15), + ), + ], + diagnostic_filter_leaf: None, + ), + mesh_info: None, + task_payload: Some(0), + ), + ( + name: "ms_main", + stage: Mesh, + early_depth_test: None, + workgroup_size: (1, 1, 1), + workgroup_size_overrides: None, + function: ( + name: Some("ms_main"), + arguments: [ + ( + name: Some("index"), + ty: 5, + binding: Some(BuiltIn(LocalInvocationIndex)), + ), + ( + name: Some("id"), + ty: 6, + binding: Some(BuiltIn(GlobalInvocationId)), + ), + ], + result: None, + local_variables: [ + ( + name: Some("v"), + ty: 4, + init: None, + ), + ( + name: Some("p"), + ty: 7, + init: None, + ), + ], + expressions: [ + FunctionArgument(0), + FunctionArgument(1), + Literal(U32(3)), + Literal(U32(1)), + GlobalVariable(1), + Literal(F32(2.0)), + LocalVariable(0), + AccessIndex( + base: 6, + index: 0, + ), + Literal(F32(0.0)), + Literal(F32(-1.0)), + Literal(F32(0.0)), + Literal(F32(1.0)), + Compose( + ty: 1, + components: [ + 8, + 9, + 10, + 11, + ], + ), + AccessIndex( + base: 6, + index: 1, + ), + GlobalVariable(0), + AccessIndex( + base: 14, + index: 0, + ), + Load( + pointer: 15, + ), + Literal(F32(0.0)), + Literal(F32(1.0)), + Literal(F32(0.0)), + Literal(F32(1.0)), + Compose( + ty: 1, + components: [ + 17, + 18, + 19, + 20, + ], + ), + Binary( + op: Multiply, + left: 21, + right: 16, + ), + Literal(U32(0)), + Load( + pointer: 6, + ), + AccessIndex( + base: 6, + index: 0, + ), + Literal(F32(-1.0)), + Literal(F32(1.0)), + Literal(F32(0.0)), + Literal(F32(1.0)), + Compose( + ty: 1, + components: [ + 26, + 27, + 28, + 29, + ], + ), + AccessIndex( + base: 6, + index: 1, + ), + GlobalVariable(0), + AccessIndex( + base: 32, + index: 0, + ), + Load( + pointer: 33, + ), + Literal(F32(0.0)), + Literal(F32(0.0)), + Literal(F32(1.0)), + Literal(F32(1.0)), + Compose( + ty: 1, + components: [ + 35, + 36, + 37, + 38, + ], + ), + Binary( + op: Multiply, + left: 39, + right: 34, + ), + Literal(U32(1)), + Load( + pointer: 6, + ), + AccessIndex( + base: 6, + index: 0, + ), + Literal(F32(1.0)), + Literal(F32(1.0)), + Literal(F32(0.0)), + Literal(F32(1.0)), + Compose( + ty: 1, + components: [ + 44, + 45, + 46, + 47, + ], + ), + AccessIndex( + base: 6, + index: 1, + ), + GlobalVariable(0), + AccessIndex( + base: 50, + index: 0, + ), + Load( + pointer: 51, + ), + Literal(F32(1.0)), + Literal(F32(0.0)), + Literal(F32(0.0)), + Literal(F32(1.0)), + Compose( + ty: 1, + components: [ + 53, + 54, + 55, + 56, + ], + ), + Binary( + op: Multiply, + left: 57, + right: 52, + ), + Literal(U32(2)), + Load( + pointer: 6, + ), + LocalVariable(1), + AccessIndex( + base: 61, + index: 0, + ), + Literal(U32(0)), + Literal(U32(1)), + Literal(U32(2)), + Compose( + ty: 6, + components: [ + 63, + 64, + 65, + ], + ), + AccessIndex( + base: 61, + index: 1, + ), + GlobalVariable(0), + AccessIndex( + base: 68, + index: 1, + ), + Load( + pointer: 69, + ), + Unary( + op: LogicalNot, + expr: 70, + ), + AccessIndex( + base: 61, + index: 2, + ), + Literal(F32(1.0)), + Literal(F32(0.0)), + Literal(F32(1.0)), + Literal(F32(1.0)), + Compose( + ty: 1, + components: [ + 73, + 74, + 75, + 76, + ], + ), + Literal(U32(0)), + Load( + pointer: 61, + ), + ], + named_expressions: { + 0: "index", + 1: "id", + }, + body: [ + MeshFunction(SetMeshOutputs( + vertex_count: 2, + primitive_count: 3, + )), + Store( + pointer: 4, + value: 5, + ), + Emit(( + start: 7, + end: 8, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 12, + end: 13, + )), + Store( + pointer: 7, + value: 12, + ), + Emit(( + start: 13, + end: 14, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 15, + end: 17, + )), + Emit(( + start: 21, + end: 23, + )), + Store( + pointer: 13, + value: 22, + ), + Emit(( + start: 24, + end: 25, + )), + MeshFunction(SetVertex( + index: 23, + value: 24, + )), + Emit(( + start: 25, + end: 26, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 30, + end: 31, + )), + Store( + pointer: 25, + value: 30, + ), + Emit(( + start: 31, + end: 32, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 33, + end: 35, + )), + Emit(( + start: 39, + end: 41, + )), + Store( + pointer: 31, + value: 40, + ), + Emit(( + start: 42, + end: 43, + )), + MeshFunction(SetVertex( + index: 41, + value: 42, + )), + Emit(( + start: 43, + end: 44, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 48, + end: 49, + )), + Store( + pointer: 43, + value: 48, + ), + Emit(( + start: 49, + end: 50, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 51, + end: 53, + )), + Emit(( + start: 57, + end: 59, + )), + Store( + pointer: 49, + value: 58, + ), + Emit(( + start: 60, + end: 61, + )), + MeshFunction(SetVertex( + index: 59, + value: 60, + )), + Emit(( + start: 62, + end: 63, + )), + Emit(( + start: 66, + end: 67, + )), + Store( + pointer: 62, + value: 66, + ), + Emit(( + start: 67, + end: 68, + )), + Emit(( + start: 69, + end: 72, + )), + Store( + pointer: 67, + value: 71, + ), + Emit(( + start: 72, + end: 73, + )), + Emit(( + start: 77, + end: 78, + )), + Store( + pointer: 72, + value: 77, + ), + Emit(( + start: 79, + end: 80, + )), + MeshFunction(SetPrimitive( + index: 78, + value: 79, + )), + Return( + value: None, + ), + ], + diagnostic_filter_leaf: None, + ), + mesh_info: Some(( + topology: Triangles, + max_vertices: 3, + max_vertices_override: None, + max_primitives: 1, + max_primitives_override: None, + vertex_output_type: 4, + primitive_output_type: 7, + )), + task_payload: Some(0), + ), + ( + name: "fs_main", + stage: Fragment, + early_depth_test: None, + workgroup_size: (0, 0, 0), + workgroup_size_overrides: None, + function: ( + name: Some("fs_main"), + arguments: [ + ( + name: Some("vertex"), + ty: 4, + binding: None, + ), + ( + name: Some("primitive"), + ty: 8, + binding: None, + ), + ], + result: Some(( + ty: 1, + binding: Some(Location( + location: 0, + interpolation: Some(Perspective), + sampling: Some(Center), + blend_src: None, + )), + )), + local_variables: [], + expressions: [ + FunctionArgument(0), + FunctionArgument(1), + AccessIndex( + base: 0, + index: 1, + ), + AccessIndex( + base: 1, + index: 0, + ), + Binary( + op: Multiply, + left: 2, + right: 3, + ), + ], + named_expressions: { + 0: "vertex", + 1: "primitive", + }, + body: [ + Emit(( + start: 2, + end: 5, + )), + Return( + value: Some(4), + ), + ], + diagnostic_filter_leaf: None, + ), + mesh_info: None, + task_payload: None, + ), + ], + diagnostic_filters: [], + diagnostic_filter_leaf: None, + doc_comments: None, +) \ No newline at end of file diff --git a/naga/tests/out/ir/wgsl-mesh-shader.ron b/naga/tests/out/ir/wgsl-mesh-shader.ron new file mode 100644 index 00000000000..5e320aa3895 --- /dev/null +++ b/naga/tests/out/ir/wgsl-mesh-shader.ron @@ -0,0 +1,840 @@ +( + types: [ + ( + name: None, + inner: Scalar(( + kind: Float, + width: 4, + )), + ), + ( + name: None, + inner: Vector( + size: Quad, + scalar: ( + kind: Float, + width: 4, + ), + ), + ), + ( + name: None, + inner: Scalar(( + kind: Bool, + width: 1, + )), + ), + ( + name: Some("TaskPayload"), + inner: Struct( + members: [ + ( + name: Some("colorMask"), + ty: 1, + binding: None, + offset: 0, + ), + ( + name: Some("visible"), + ty: 2, + binding: None, + offset: 16, + ), + ], + span: 32, + ), + ), + ( + name: Some("VertexOutput"), + inner: Struct( + members: [ + ( + name: Some("position"), + ty: 1, + binding: Some(BuiltIn(Position( + invariant: false, + ))), + offset: 0, + ), + ( + name: Some("color"), + ty: 1, + binding: Some(Location( + location: 0, + interpolation: Some(Perspective), + sampling: Some(Center), + blend_src: None, + )), + offset: 16, + ), + ], + span: 32, + ), + ), + ( + name: None, + inner: Scalar(( + kind: Uint, + width: 4, + )), + ), + ( + name: None, + inner: Vector( + size: Tri, + scalar: ( + kind: Uint, + width: 4, + ), + ), + ), + ( + name: Some("PrimitiveOutput"), + inner: Struct( + members: [ + ( + name: Some("index"), + ty: 6, + binding: Some(BuiltIn(TriangleIndices)), + offset: 0, + ), + ( + name: Some("cull"), + ty: 2, + binding: Some(BuiltIn(CullPrimitive)), + offset: 12, + ), + ( + name: Some("colorMask"), + ty: 1, + binding: Some(Location( + location: 1, + interpolation: Some(Perspective), + sampling: Some(Center), + blend_src: None, + )), + offset: 16, + ), + ], + span: 32, + ), + ), + ( + name: Some("PrimitiveInput"), + inner: Struct( + members: [ + ( + name: Some("colorMask"), + ty: 1, + binding: Some(Location( + location: 1, + interpolation: Some(Perspective), + sampling: Some(Center), + blend_src: None, + )), + offset: 0, + ), + ], + span: 16, + ), + ), + ], + special_types: ( + ray_desc: None, + ray_intersection: None, + ray_vertex_return: None, + predeclared_types: {}, + ), + constants: [], + overrides: [], + global_variables: [ + ( + name: Some("taskPayload"), + space: TaskPayload, + binding: None, + ty: 3, + init: None, + ), + ( + name: Some("workgroupData"), + space: WorkGroup, + binding: None, + ty: 0, + init: None, + ), + ], + global_expressions: [], + functions: [], + entry_points: [ + ( + name: "ts_main", + stage: Task, + early_depth_test: None, + workgroup_size: (1, 1, 1), + workgroup_size_overrides: None, + function: ( + name: Some("ts_main"), + arguments: [], + result: Some(( + ty: 6, + binding: Some(BuiltIn(MeshTaskSize)), + )), + local_variables: [], + expressions: [ + GlobalVariable(1), + Literal(F32(1.0)), + GlobalVariable(0), + AccessIndex( + base: 2, + index: 0, + ), + Literal(F32(1.0)), + Literal(F32(1.0)), + Literal(F32(0.0)), + Literal(F32(1.0)), + Compose( + ty: 1, + components: [ + 4, + 5, + 6, + 7, + ], + ), + GlobalVariable(0), + AccessIndex( + base: 9, + index: 1, + ), + Literal(Bool(true)), + Literal(U32(3)), + Literal(U32(1)), + Literal(U32(1)), + Compose( + ty: 6, + components: [ + 12, + 13, + 14, + ], + ), + ], + named_expressions: {}, + body: [ + Store( + pointer: 0, + value: 1, + ), + Emit(( + start: 3, + end: 4, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 8, + end: 9, + )), + Store( + pointer: 3, + value: 8, + ), + Emit(( + start: 10, + end: 11, + )), + Store( + pointer: 10, + value: 11, + ), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 15, + end: 16, + )), + Return( + value: Some(15), + ), + ], + diagnostic_filter_leaf: None, + ), + mesh_info: None, + task_payload: Some(0), + ), + ( + name: "ms_main", + stage: Mesh, + early_depth_test: None, + workgroup_size: (1, 1, 1), + workgroup_size_overrides: None, + function: ( + name: Some("ms_main"), + arguments: [ + ( + name: Some("index"), + ty: 5, + binding: Some(BuiltIn(LocalInvocationIndex)), + ), + ( + name: Some("id"), + ty: 6, + binding: Some(BuiltIn(GlobalInvocationId)), + ), + ], + result: None, + local_variables: [ + ( + name: Some("v"), + ty: 4, + init: None, + ), + ( + name: Some("p"), + ty: 7, + init: None, + ), + ], + expressions: [ + FunctionArgument(0), + FunctionArgument(1), + Literal(U32(3)), + Literal(U32(1)), + GlobalVariable(1), + Literal(F32(2.0)), + LocalVariable(0), + AccessIndex( + base: 6, + index: 0, + ), + Literal(F32(0.0)), + Literal(F32(-1.0)), + Literal(F32(0.0)), + Literal(F32(1.0)), + Compose( + ty: 1, + components: [ + 8, + 9, + 10, + 11, + ], + ), + AccessIndex( + base: 6, + index: 1, + ), + GlobalVariable(0), + AccessIndex( + base: 14, + index: 0, + ), + Load( + pointer: 15, + ), + Literal(F32(0.0)), + Literal(F32(1.0)), + Literal(F32(0.0)), + Literal(F32(1.0)), + Compose( + ty: 1, + components: [ + 17, + 18, + 19, + 20, + ], + ), + Binary( + op: Multiply, + left: 21, + right: 16, + ), + Literal(U32(0)), + Load( + pointer: 6, + ), + AccessIndex( + base: 6, + index: 0, + ), + Literal(F32(-1.0)), + Literal(F32(1.0)), + Literal(F32(0.0)), + Literal(F32(1.0)), + Compose( + ty: 1, + components: [ + 26, + 27, + 28, + 29, + ], + ), + AccessIndex( + base: 6, + index: 1, + ), + GlobalVariable(0), + AccessIndex( + base: 32, + index: 0, + ), + Load( + pointer: 33, + ), + Literal(F32(0.0)), + Literal(F32(0.0)), + Literal(F32(1.0)), + Literal(F32(1.0)), + Compose( + ty: 1, + components: [ + 35, + 36, + 37, + 38, + ], + ), + Binary( + op: Multiply, + left: 39, + right: 34, + ), + Literal(U32(1)), + Load( + pointer: 6, + ), + AccessIndex( + base: 6, + index: 0, + ), + Literal(F32(1.0)), + Literal(F32(1.0)), + Literal(F32(0.0)), + Literal(F32(1.0)), + Compose( + ty: 1, + components: [ + 44, + 45, + 46, + 47, + ], + ), + AccessIndex( + base: 6, + index: 1, + ), + GlobalVariable(0), + AccessIndex( + base: 50, + index: 0, + ), + Load( + pointer: 51, + ), + Literal(F32(1.0)), + Literal(F32(0.0)), + Literal(F32(0.0)), + Literal(F32(1.0)), + Compose( + ty: 1, + components: [ + 53, + 54, + 55, + 56, + ], + ), + Binary( + op: Multiply, + left: 57, + right: 52, + ), + Literal(U32(2)), + Load( + pointer: 6, + ), + LocalVariable(1), + AccessIndex( + base: 61, + index: 0, + ), + Literal(U32(0)), + Literal(U32(1)), + Literal(U32(2)), + Compose( + ty: 6, + components: [ + 63, + 64, + 65, + ], + ), + AccessIndex( + base: 61, + index: 1, + ), + GlobalVariable(0), + AccessIndex( + base: 68, + index: 1, + ), + Load( + pointer: 69, + ), + Unary( + op: LogicalNot, + expr: 70, + ), + AccessIndex( + base: 61, + index: 2, + ), + Literal(F32(1.0)), + Literal(F32(0.0)), + Literal(F32(1.0)), + Literal(F32(1.0)), + Compose( + ty: 1, + components: [ + 73, + 74, + 75, + 76, + ], + ), + Literal(U32(0)), + Load( + pointer: 61, + ), + ], + named_expressions: { + 0: "index", + 1: "id", + }, + body: [ + MeshFunction(SetMeshOutputs( + vertex_count: 2, + primitive_count: 3, + )), + Store( + pointer: 4, + value: 5, + ), + Emit(( + start: 7, + end: 8, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 12, + end: 13, + )), + Store( + pointer: 7, + value: 12, + ), + Emit(( + start: 13, + end: 14, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 15, + end: 17, + )), + Emit(( + start: 21, + end: 23, + )), + Store( + pointer: 13, + value: 22, + ), + Emit(( + start: 24, + end: 25, + )), + MeshFunction(SetVertex( + index: 23, + value: 24, + )), + Emit(( + start: 25, + end: 26, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 30, + end: 31, + )), + Store( + pointer: 25, + value: 30, + ), + Emit(( + start: 31, + end: 32, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 33, + end: 35, + )), + Emit(( + start: 39, + end: 41, + )), + Store( + pointer: 31, + value: 40, + ), + Emit(( + start: 42, + end: 43, + )), + MeshFunction(SetVertex( + index: 41, + value: 42, + )), + Emit(( + start: 43, + end: 44, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 48, + end: 49, + )), + Store( + pointer: 43, + value: 48, + ), + Emit(( + start: 49, + end: 50, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 51, + end: 53, + )), + Emit(( + start: 57, + end: 59, + )), + Store( + pointer: 49, + value: 58, + ), + Emit(( + start: 60, + end: 61, + )), + MeshFunction(SetVertex( + index: 59, + value: 60, + )), + Emit(( + start: 62, + end: 63, + )), + Emit(( + start: 66, + end: 67, + )), + Store( + pointer: 62, + value: 66, + ), + Emit(( + start: 67, + end: 68, + )), + Emit(( + start: 69, + end: 72, + )), + Store( + pointer: 67, + value: 71, + ), + Emit(( + start: 72, + end: 73, + )), + Emit(( + start: 77, + end: 78, + )), + Store( + pointer: 72, + value: 77, + ), + Emit(( + start: 79, + end: 80, + )), + MeshFunction(SetPrimitive( + index: 78, + value: 79, + )), + Return( + value: None, + ), + ], + diagnostic_filter_leaf: None, + ), + mesh_info: Some(( + topology: Triangles, + max_vertices: 3, + max_vertices_override: None, + max_primitives: 1, + max_primitives_override: None, + vertex_output_type: 4, + primitive_output_type: 7, + )), + task_payload: Some(0), + ), + ( + name: "fs_main", + stage: Fragment, + early_depth_test: None, + workgroup_size: (0, 0, 0), + workgroup_size_overrides: None, + function: ( + name: Some("fs_main"), + arguments: [ + ( + name: Some("vertex"), + ty: 4, + binding: None, + ), + ( + name: Some("primitive"), + ty: 8, + binding: None, + ), + ], + result: Some(( + ty: 1, + binding: Some(Location( + location: 0, + interpolation: Some(Perspective), + sampling: Some(Center), + blend_src: None, + )), + )), + local_variables: [], + expressions: [ + FunctionArgument(0), + FunctionArgument(1), + AccessIndex( + base: 0, + index: 1, + ), + AccessIndex( + base: 1, + index: 0, + ), + Binary( + op: Multiply, + left: 2, + right: 3, + ), + ], + named_expressions: { + 0: "vertex", + 1: "primitive", + }, + body: [ + Emit(( + start: 2, + end: 5, + )), + Return( + value: Some(4), + ), + ], + diagnostic_filter_leaf: None, + ), + mesh_info: None, + task_payload: None, + ), + ], + diagnostic_filters: [], + diagnostic_filter_leaf: None, + doc_comments: None, +) \ No newline at end of file From 04e01445598009daf24f69f4e9ee5d14908d8d0c Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Mon, 14 Jul 2025 12:45:04 -0500 Subject: [PATCH 57/84] Update rspirv version --- Cargo.lock | 17 +++++------------ Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7681964afa8..64c090b97ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2505,7 +2505,7 @@ dependencies = [ "rspirv", "rustc-hash", "serde", - "spirv 0.3.0+sdk-1.3.268.0", + "spirv", "strum 0.27.1", "thiserror 2.0.12", "toml", @@ -3549,11 +3549,12 @@ dependencies = [ [[package]] name = "rspirv" -version = "0.11.0+sdk-1.2.198" -source = "git+https://github.com/gfx-rs/rspirv?rev=b969f175d5663258b4891e44b76c1544da9661ab#b969f175d5663258b4891e44b76c1544da9661ab" +version = "0.12.0+sdk-1.3.268.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cf3a93856b6e5946537278df0d3075596371b1950ccff012f02b0f7eafec8d" dependencies = [ "rustc-hash", - "spirv 0.2.0+sdk-1.2.198", + "spirv", ] [[package]] @@ -3932,14 +3933,6 @@ dependencies = [ "lock_api", ] -[[package]] -name = "spirv" -version = "0.2.0+sdk-1.2.198" -source = "git+https://github.com/gfx-rs/rspirv?rev=b969f175d5663258b4891e44b76c1544da9661ab#b969f175d5663258b4891e44b76c1544da9661ab" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "spirv" version = "0.3.0+sdk-1.3.268.0" diff --git a/Cargo.toml b/Cargo.toml index 7083e33a12c..ca7f4121e2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -169,7 +169,7 @@ rwh_05 = { version = "0.5.2", package = "raw-window-handle" } # temporary compat rayon = "1.3" regex-lite = "0.1" renderdoc-sys = "1" -rspirv = { version = "0.11", git = "https://github.com/gfx-rs/rspirv", rev = "b969f175d5663258b4891e44b76c1544da9661ab" } +rspirv = "0.12" ron = "0.10" # NOTE: rustc-hash v2 is a completely different hasher with different performance characteristics # see discussion here (including with some other alternatives): https://github.com/gfx-rs/wgpu/issues/6999 From 1250feee106da406644d0a644954d5586cbd3c84 Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Mon, 14 Jul 2025 12:47:30 -0500 Subject: [PATCH 58/84] Updated naga snapshots --- .../spv/wgsl-6438-conflicting-idents.spvasm | 4 +- .../spv/wgsl-7048-multiple-dynamic-1.spvasm | 2 +- .../spv/wgsl-7048-multiple-dynamic-2.spvasm | 2 +- .../spv/wgsl-7048-multiple-dynamic-3.spvasm | 2 +- .../spv/wgsl-abstract-types-builtins.spvasm | 2 +- .../out/spv/wgsl-abstract-types-const.spvasm | 18 +++---- .../wgsl-abstract-types-function-calls.spvasm | 2 +- .../out/spv/wgsl-abstract-types-let.spvasm | 18 +++---- .../spv/wgsl-abstract-types-operators.spvasm | 14 ++--- .../out/spv/wgsl-abstract-types-return.spvasm | 2 +- .../out/spv/wgsl-abstract-types-var.spvasm | 18 +++---- naga/tests/out/spv/wgsl-access.spvasm | 34 ++++++------ .../out/spv/wgsl-aliased-ray-query.spvasm | 10 ++-- .../wgsl-array-in-function-return-type.spvasm | 6 +-- .../out/spv/wgsl-atomicCompareExchange.spvasm | 2 +- naga/tests/out/spv/wgsl-binding-arrays.spvasm | 2 +- naga/tests/out/spv/wgsl-bitcast.spvasm | 2 +- naga/tests/out/spv/wgsl-bits.spvasm | 2 +- naga/tests/out/spv/wgsl-boids.spvasm | 6 +-- ...l-bounds-check-image-restrict-depth.spvasm | 2 +- .../wgsl-bounds-check-image-restrict.spvasm | 2 +- .../wgsl-bounds-check-image-rzsw-depth.spvasm | 2 +- .../spv/wgsl-bounds-check-image-rzsw.spvasm | 2 +- .../out/spv/wgsl-bounds-check-restrict.spvasm | 16 +++--- .../out/spv/wgsl-bounds-check-zero.spvasm | 16 +++--- naga/tests/out/spv/wgsl-const-exprs.spvasm | 10 ++-- naga/tests/out/spv/wgsl-constructors.spvasm | 8 +-- .../spv/wgsl-conversion-float-to-int.spvasm | 54 +++++++++---------- naga/tests/out/spv/wgsl-conversions.spvasm | 2 +- naga/tests/out/spv/wgsl-cross.spvasm | 4 +- .../spv/wgsl-debug-symbol-large-source.spvasm | 28 +++++----- .../out/spv/wgsl-debug-symbol-simple.spvasm | 2 +- .../out/spv/wgsl-debug-symbol-terrain.spvasm | 28 +++++----- naga/tests/out/spv/wgsl-extra.spvasm | 2 +- naga/tests/out/spv/wgsl-f16.spvasm | 14 ++--- naga/tests/out/spv/wgsl-f64.spvasm | 14 ++--- .../tests/out/spv/wgsl-fragment-output.spvasm | 2 +- ...l-functions-optimized-by-capability.spvasm | 12 ++--- ...wgsl-functions-optimized-by-version.spvasm | 12 ++--- naga/tests/out/spv/wgsl-functions.spvasm | 14 ++--- naga/tests/out/spv/wgsl-globals.spvasm | 8 +-- naga/tests/out/spv/wgsl-image.spvasm | 8 +-- naga/tests/out/spv/wgsl-index-by-value.spvasm | 8 +-- naga/tests/out/spv/wgsl-int64.spvasm | 8 +-- .../out/spv/wgsl-interface.fragment.spvasm | 4 +- .../out/spv/wgsl-interface.vertex.spvasm | 2 +- .../wgsl-interface.vertex_two_structs.spvasm | 4 +- naga/tests/out/spv/wgsl-interpolate.spvasm | 42 +++++++-------- .../out/spv/wgsl-interpolate_compat.spvasm | 42 +++++++-------- naga/tests/out/spv/wgsl-math-functions.spvasm | 8 +-- naga/tests/out/spv/wgsl-operators.spvasm | 12 ++--- .../spv/wgsl-overrides-ray-query.main.spvasm | 16 +++--- naga/tests/out/spv/wgsl-overrides.main.spvasm | 10 ++-- naga/tests/out/spv/wgsl-padding.spvasm | 2 +- naga/tests/out/spv/wgsl-pointers.spvasm | 2 +- naga/tests/out/spv/wgsl-policy-mix.spvasm | 4 +- naga/tests/out/spv/wgsl-quad.spvasm | 4 +- naga/tests/out/spv/wgsl-ray-query.spvasm | 10 ++-- naga/tests/out/spv/wgsl-select.spvasm | 4 +- ...wgsl-separate-entry-points.fragment.spvasm | 2 +- naga/tests/out/spv/wgsl-shadow.spvasm | 4 +- naga/tests/out/spv/wgsl-skybox.spvasm | 6 +-- .../out/spv/wgsl-storage-textures.spvasm | 2 +- naga/tests/out/spv/wgsl-struct-layout.spvasm | 2 +- naga/tests/out/spv/wgsl-texture-arg.spvasm | 2 +- naga/tests/out/spv/wgsl-type-inference.spvasm | 4 +- 66 files changed, 307 insertions(+), 307 deletions(-) diff --git a/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm b/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm index 589eeb34624..be4ca450115 100644 --- a/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm +++ b/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm @@ -26,8 +26,8 @@ OpDecorate %32 Location 0 %14 = OpTypePointer Output %5 %13 = OpVariable %14 Output %16 = OpTypeFunction %2 -%17 = OpConstant %4 0.0 -%18 = OpConstant %4 1.0 +%17 = OpConstant %4 0 +%18 = OpConstant %4 1 %20 = OpTypePointer Function %6 %21 = OpConstantNull %6 %23 = OpTypePointer Function %3 diff --git a/naga/tests/out/spv/wgsl-7048-multiple-dynamic-1.spvasm b/naga/tests/out/spv/wgsl-7048-multiple-dynamic-1.spvasm index ad042682297..dd87117cfc4 100644 --- a/naga/tests/out/spv/wgsl-7048-multiple-dynamic-1.spvasm +++ b/naga/tests/out/spv/wgsl-7048-multiple-dynamic-1.spvasm @@ -18,7 +18,7 @@ OpDecorate %5 ArrayStride 16 %9 = OpTypeInt 32 1 %12 = OpTypeFunction %2 %13 = OpConstantNull %5 -%14 = OpConstant %4 0.0 +%14 = OpConstant %4 0 %15 = OpConstantComposite %8 %14 %14 %14 %14 %16 = OpConstant %9 0 %18 = OpTypePointer Function %8 diff --git a/naga/tests/out/spv/wgsl-7048-multiple-dynamic-2.spvasm b/naga/tests/out/spv/wgsl-7048-multiple-dynamic-2.spvasm index 504bd8f4eb3..1eba8a12a5e 100644 --- a/naga/tests/out/spv/wgsl-7048-multiple-dynamic-2.spvasm +++ b/naga/tests/out/spv/wgsl-7048-multiple-dynamic-2.spvasm @@ -20,7 +20,7 @@ OpDecorate %11 Location 0 %12 = OpTypePointer Output %3 %11 = OpVariable %12 Output %14 = OpTypeFunction %2 -%15 = OpConstant %4 0.0 +%15 = OpConstant %4 0 %16 = OpConstantComposite %5 %15 %15 %17 = OpConstantComposite %6 %16 %16 %18 = OpConstant %9 0 diff --git a/naga/tests/out/spv/wgsl-7048-multiple-dynamic-3.spvasm b/naga/tests/out/spv/wgsl-7048-multiple-dynamic-3.spvasm index d11c182d519..2e4ab1e1aef 100644 --- a/naga/tests/out/spv/wgsl-7048-multiple-dynamic-3.spvasm +++ b/naga/tests/out/spv/wgsl-7048-multiple-dynamic-3.spvasm @@ -20,7 +20,7 @@ OpDecorate %6 ArrayStride 16 %13 = OpTypeFunction %5 %6 %8 %14 = OpConstant %8 0 %15 = OpConstant %8 1 -%16 = OpConstant %3 0.0 +%16 = OpConstant %3 0 %17 = OpConstantComposite %4 %16 %16 %16 %18 = OpConstantComposite %5 %16 %17 %20 = OpTypePointer Function %8 diff --git a/naga/tests/out/spv/wgsl-abstract-types-builtins.spvasm b/naga/tests/out/spv/wgsl-abstract-types-builtins.spvasm index 83ef259cba5..0601a126b1b 100644 --- a/naga/tests/out/spv/wgsl-abstract-types-builtins.spvasm +++ b/naga/tests/out/spv/wgsl-abstract-types-builtins.spvasm @@ -12,7 +12,7 @@ OpExecutionMode %6 LocalSize 1 1 1 %4 = OpTypeFloat 32 %7 = OpTypeFunction %2 %8 = OpConstant %3 1 -%9 = OpConstant %4 1.0 +%9 = OpConstant %4 1 %11 = OpTypePointer Function %3 %13 = OpTypePointer Function %4 %6 = OpFunction %2 None %7 diff --git a/naga/tests/out/spv/wgsl-abstract-types-const.spvasm b/naga/tests/out/spv/wgsl-abstract-types-const.spvasm index b1da55273f5..b1dd0dc374e 100644 --- a/naga/tests/out/spv/wgsl-abstract-types-const.spvasm +++ b/naga/tests/out/spv/wgsl-abstract-types-const.spvasm @@ -32,11 +32,11 @@ OpMemberDecorate %14 2 Offset 8 %19 = OpConstant %5 44 %20 = OpConstant %5 45 %21 = OpConstantComposite %6 %19 %20 -%22 = OpConstant %7 46.0 -%23 = OpConstant %7 47.0 +%22 = OpConstant %7 46 +%23 = OpConstant %7 47 %24 = OpConstantComposite %8 %22 %23 -%25 = OpConstant %7 48.0 -%26 = OpConstant %7 49.0 +%25 = OpConstant %7 48 +%26 = OpConstant %7 49 %27 = OpConstantComposite %8 %25 %26 %28 = OpConstant %5 42 %29 = OpConstant %5 43 @@ -45,14 +45,14 @@ OpMemberDecorate %14 2 Offset 8 %32 = OpConstantComposite %4 %31 %31 %33 = OpConstant %5 0 %34 = OpConstantComposite %6 %33 %33 -%35 = OpConstant %7 0.0 +%35 = OpConstant %7 0 %36 = OpConstantComposite %8 %35 %35 %37 = OpConstantComposite %9 %36 %36 -%38 = OpConstant %7 1.0 -%39 = OpConstant %7 2.0 +%38 = OpConstant %7 1 +%39 = OpConstant %7 2 %40 = OpConstantComposite %8 %38 %39 -%41 = OpConstant %7 3.0 -%42 = OpConstant %7 4.0 +%41 = OpConstant %7 3 +%42 = OpConstant %7 4 %43 = OpConstantComposite %8 %41 %42 %44 = OpConstantComposite %9 %40 %43 %45 = OpConstant %3 1 diff --git a/naga/tests/out/spv/wgsl-abstract-types-function-calls.spvasm b/naga/tests/out/spv/wgsl-abstract-types-function-calls.spvasm index 81b0a5e44c5..40931665253 100644 --- a/naga/tests/out/spv/wgsl-abstract-types-function-calls.spvasm +++ b/naga/tests/out/spv/wgsl-abstract-types-function-calls.spvasm @@ -34,7 +34,7 @@ OpDecorate %13 ArrayStride 4 %62 = OpTypeFunction %2 %13 %68 = OpTypeFunction %2 %3 %4 %72 = OpTypeFunction %2 -%73 = OpConstant %3 0.0 +%73 = OpConstant %3 0 %74 = OpConstant %4 0 %75 = OpConstant %5 0 %76 = OpConstantComposite %6 %73 %73 diff --git a/naga/tests/out/spv/wgsl-abstract-types-let.spvasm b/naga/tests/out/spv/wgsl-abstract-types-let.spvasm index f0b7ea3c4f3..c9394ebaf4c 100644 --- a/naga/tests/out/spv/wgsl-abstract-types-let.spvasm +++ b/naga/tests/out/spv/wgsl-abstract-types-let.spvasm @@ -34,11 +34,11 @@ OpDecorate %17 ArrayStride 16 %24 = OpConstant %5 44 %25 = OpConstant %5 45 %26 = OpConstantComposite %6 %24 %25 -%27 = OpConstant %7 46.0 -%28 = OpConstant %7 47.0 +%27 = OpConstant %7 46 +%28 = OpConstant %7 47 %29 = OpConstantComposite %8 %27 %28 -%30 = OpConstant %7 48.0 -%31 = OpConstant %7 49.0 +%30 = OpConstant %7 48 +%31 = OpConstant %7 49 %32 = OpConstantComposite %8 %30 %31 %33 = OpConstant %5 42 %34 = OpConstant %5 43 @@ -47,14 +47,14 @@ OpDecorate %17 ArrayStride 16 %37 = OpConstantComposite %4 %36 %36 %38 = OpConstant %5 0 %39 = OpConstantComposite %6 %38 %38 -%40 = OpConstant %7 0.0 +%40 = OpConstant %7 0 %41 = OpConstantComposite %8 %40 %40 %42 = OpConstantComposite %9 %41 %41 -%43 = OpConstant %7 1.0 -%44 = OpConstant %7 2.0 +%43 = OpConstant %7 1 +%44 = OpConstant %7 2 %45 = OpConstantComposite %8 %43 %44 -%46 = OpConstant %7 3.0 -%47 = OpConstant %7 4.0 +%46 = OpConstant %7 3 +%47 = OpConstant %7 4 %48 = OpConstantComposite %8 %46 %47 %49 = OpConstantComposite %9 %45 %48 %50 = OpConstant %3 1 diff --git a/naga/tests/out/spv/wgsl-abstract-types-operators.spvasm b/naga/tests/out/spv/wgsl-abstract-types-operators.spvasm index c37f96d92bf..4ce80049d24 100644 --- a/naga/tests/out/spv/wgsl-abstract-types-operators.spvasm +++ b/naga/tests/out/spv/wgsl-abstract-types-operators.spvasm @@ -15,23 +15,23 @@ OpDecorate %116 BuiltIn LocalInvocationId %5 = OpTypeInt 32 0 %7 = OpConstant %5 64 %6 = OpTypeArray %5 %7 -%8 = OpConstant %3 3.0 +%8 = OpConstant %3 3 %9 = OpConstant %4 3 %10 = OpConstant %5 3 %11 = OpConstant %5 0 %12 = OpConstant %4 -2147483648 -%13 = OpConstant %3 -3.4028235e38 +%13 = OpConstant %3 -340282350000000000000000000000000000000 %14 = OpConstant %4 4 %15 = OpConstant %5 4 %16 = OpConstant %4 0 %18 = OpTypePointer Workgroup %6 %17 = OpVariable %18 Workgroup %21 = OpTypeFunction %2 -%22 = OpConstant %3 42.0 +%22 = OpConstant %3 42 %23 = OpConstant %4 43 %24 = OpConstant %5 44 -%25 = OpConstant %3 1.0 -%26 = OpConstant %3 2.0 +%25 = OpConstant %3 1 +%26 = OpConstant %3 2 %27 = OpConstant %4 1 %28 = OpConstant %4 2 %29 = OpConstant %5 1 @@ -52,8 +52,8 @@ OpDecorate %116 BuiltIn LocalInvocationId %64 = OpConstantNull %5 %66 = OpConstantNull %4 %68 = OpConstantNull %4 -%101 = OpConstant %3 5.0 -%102 = OpConstant %3 7.0 +%101 = OpConstant %3 5 +%102 = OpConstant %3 7 %108 = OpTypePointer Workgroup %5 %114 = OpConstantNull %6 %115 = OpTypeVector %5 3 diff --git a/naga/tests/out/spv/wgsl-abstract-types-return.spvasm b/naga/tests/out/spv/wgsl-abstract-types-return.spvasm index 48c1b155668..d2dc2cfed43 100644 --- a/naga/tests/out/spv/wgsl-abstract-types-return.spvasm +++ b/naga/tests/out/spv/wgsl-abstract-types-return.spvasm @@ -20,7 +20,7 @@ OpDecorate %7 ArrayStride 4 %16 = OpTypeFunction %4 %17 = OpConstant %4 1 %21 = OpTypeFunction %5 -%22 = OpConstant %5 1.0 +%22 = OpConstant %5 1 %29 = OpTypeFunction %6 %30 = OpConstantComposite %6 %22 %22 %34 = OpTypeFunction %7 diff --git a/naga/tests/out/spv/wgsl-abstract-types-var.spvasm b/naga/tests/out/spv/wgsl-abstract-types-var.spvasm index de7b74dae48..8dc36f0fb5f 100644 --- a/naga/tests/out/spv/wgsl-abstract-types-var.spvasm +++ b/naga/tests/out/spv/wgsl-abstract-types-var.spvasm @@ -35,11 +35,11 @@ OpDecorate %18 ArrayStride 16 %22 = OpConstant %5 44 %23 = OpConstant %5 45 %24 = OpConstantComposite %6 %22 %23 -%25 = OpConstant %7 46.0 -%26 = OpConstant %7 47.0 +%25 = OpConstant %7 46 +%26 = OpConstant %7 47 %27 = OpConstantComposite %8 %25 %26 -%28 = OpConstant %7 48.0 -%29 = OpConstant %7 49.0 +%28 = OpConstant %7 48 +%29 = OpConstant %7 49 %30 = OpConstantComposite %8 %28 %29 %31 = OpConstant %5 42 %32 = OpConstant %5 43 @@ -48,14 +48,14 @@ OpDecorate %18 ArrayStride 16 %35 = OpConstantComposite %4 %34 %34 %36 = OpConstant %5 0 %37 = OpConstantComposite %6 %36 %36 -%38 = OpConstant %7 0.0 +%38 = OpConstant %7 0 %39 = OpConstantComposite %8 %38 %38 %40 = OpConstantComposite %9 %39 %39 -%41 = OpConstant %7 1.0 -%42 = OpConstant %7 2.0 +%41 = OpConstant %7 1 +%42 = OpConstant %7 2 %43 = OpConstantComposite %8 %41 %42 -%44 = OpConstant %7 3.0 -%45 = OpConstant %7 4.0 +%44 = OpConstant %7 3 +%45 = OpConstant %7 4 %46 = OpConstantComposite %8 %44 %45 %47 = OpConstantComposite %9 %43 %46 %48 = OpConstant %3 1 diff --git a/naga/tests/out/spv/wgsl-access.spvasm b/naga/tests/out/spv/wgsl-access.spvasm index ae6a1d1c5f2..78d263d5fc6 100644 --- a/naga/tests/out/spv/wgsl-access.spvasm +++ b/naga/tests/out/spv/wgsl-access.spvasm @@ -463,29 +463,29 @@ OpDecorate %388 Location 0 %67 = OpTypeFunction %2 %68 = OpTypePointer Uniform %23 %70 = OpConstant %6 1 -%71 = OpConstant %9 1.0 +%71 = OpConstant %9 1 %72 = OpConstantComposite %13 %71 %71 -%73 = OpConstant %9 2.0 +%73 = OpConstant %9 2 %74 = OpConstantComposite %13 %73 %73 -%75 = OpConstant %9 3.0 +%75 = OpConstant %9 3 %76 = OpConstantComposite %13 %75 %75 %77 = OpConstantComposite %22 %72 %74 %76 %78 = OpConstantComposite %23 %77 -%79 = OpConstant %9 6.0 +%79 = OpConstant %9 6 %80 = OpConstantComposite %13 %79 %79 -%81 = OpConstant %9 5.0 +%81 = OpConstant %9 5 %82 = OpConstantComposite %13 %81 %81 -%83 = OpConstant %9 4.0 +%83 = OpConstant %9 4 %84 = OpConstantComposite %13 %83 %83 %85 = OpConstantComposite %22 %80 %82 %84 -%86 = OpConstant %9 9.0 +%86 = OpConstant %9 9 %87 = OpConstantComposite %13 %86 %86 -%88 = OpConstant %9 90.0 +%88 = OpConstant %9 90 %89 = OpConstantComposite %13 %88 %88 -%90 = OpConstant %9 10.0 -%91 = OpConstant %9 20.0 -%92 = OpConstant %9 30.0 -%93 = OpConstant %9 40.0 +%90 = OpConstant %9 10 +%91 = OpConstant %9 20 +%92 = OpConstant %9 30 +%93 = OpConstant %9 40 %95 = OpTypePointer Function %6 %97 = OpTypePointer Function %23 %101 = OpTypePointer Uniform %22 @@ -496,9 +496,9 @@ OpDecorate %388 Location 0 %141 = OpTypePointer Uniform %27 %143 = OpConstantNull %26 %144 = OpConstantComposite %27 %143 -%145 = OpConstant %9 8.0 +%145 = OpConstant %9 8 %146 = OpConstantComposite %13 %145 %145 -%147 = OpConstant %9 7.0 +%147 = OpConstant %9 7 %148 = OpConstantComposite %13 %147 %147 %149 = OpConstantComposite %25 %146 %148 %80 %82 %152 = OpTypePointer Function %27 @@ -542,7 +542,7 @@ OpDecorate %388 Location 0 %332 = OpTypePointer Output %32 %331 = OpVariable %332 Output %335 = OpTypePointer StorageBuffer %24 -%338 = OpConstant %9 0.0 +%338 = OpConstant %9 0 %339 = OpConstant %4 3 %340 = OpConstant %6 3 %341 = OpConstant %6 4 @@ -557,8 +557,8 @@ OpDecorate %388 Location 0 %363 = OpTypePointer StorageBuffer %20 %366 = OpTypePointer StorageBuffer %8 %367 = OpTypePointer StorageBuffer %6 -%372 = OpConstant %9 -2147483600.0 -%373 = OpConstant %9 2147483500.0 +%372 = OpConstant %9 -2147483600 +%373 = OpConstant %9 2147483500 %382 = OpTypeVector %6 4 %388 = OpVariable %332 Output %391 = OpConstantComposite %11 %338 %338 %338 diff --git a/naga/tests/out/spv/wgsl-aliased-ray-query.spvasm b/naga/tests/out/spv/wgsl-aliased-ray-query.spvasm index 2dc19683634..b095e8b8e83 100644 --- a/naga/tests/out/spv/wgsl-aliased-ray-query.spvasm +++ b/naga/tests/out/spv/wgsl-aliased-ray-query.spvasm @@ -34,7 +34,7 @@ OpDecorate %13 DescriptorSet 0 OpDecorate %13 Binding 0 %2 = OpTypeVoid %3 = OpTypeRayQueryKHR -%4 = OpTypeAccelerationStructureNV +%4 = OpTypeAccelerationStructureKHR %5 = OpTypeFloat 32 %6 = OpTypeVector %5 3 %7 = OpTypeInt 32 0 @@ -46,17 +46,17 @@ OpDecorate %13 Binding 0 %14 = OpTypePointer UniformConstant %4 %13 = OpVariable %14 UniformConstant %17 = OpTypeFunction %2 -%19 = OpConstant %5 0.0 +%19 = OpConstant %5 0 %20 = OpConstantComposite %6 %19 %19 %19 -%21 = OpConstant %5 1.0 +%21 = OpConstant %5 1 %22 = OpConstantComposite %6 %19 %21 %19 %23 = OpConstant %7 4 %24 = OpConstant %7 255 %25 = OpConstant %5 0.1 -%26 = OpConstant %5 100.0 +%26 = OpConstant %5 100 %27 = OpConstantComposite %8 %23 %24 %25 %26 %20 %22 %28 = OpConstant %7 3 -%29 = OpConstant %5 10.0 +%29 = OpConstant %5 10 %30 = OpConstant %7 1 %32 = OpTypePointer Function %3 %40 = OpTypePointer Function %12 diff --git a/naga/tests/out/spv/wgsl-array-in-function-return-type.spvasm b/naga/tests/out/spv/wgsl-array-in-function-return-type.spvasm index 146e032f354..9e2b2220f25 100644 --- a/naga/tests/out/spv/wgsl-array-in-function-return-type.spvasm +++ b/naga/tests/out/spv/wgsl-array-in-function-return-type.spvasm @@ -19,14 +19,14 @@ OpDecorate %26 Location 0 %7 = OpTypeArray %4 %8 %9 = OpTypeVector %3 4 %12 = OpTypeFunction %4 -%13 = OpConstant %3 1.0 -%14 = OpConstant %3 2.0 +%13 = OpConstant %3 1 +%14 = OpConstant %3 2 %15 = OpConstantComposite %4 %13 %14 %19 = OpTypeFunction %7 %27 = OpTypePointer Output %9 %26 = OpVariable %27 Output %29 = OpTypeFunction %2 -%30 = OpConstant %3 0.0 +%30 = OpConstant %3 0 %11 = OpFunction %4 None %12 %10 = OpLabel OpBranch %16 diff --git a/naga/tests/out/spv/wgsl-atomicCompareExchange.spvasm b/naga/tests/out/spv/wgsl-atomicCompareExchange.spvasm index 8b7e4ded087..e0e32c85d82 100644 --- a/naga/tests/out/spv/wgsl-atomicCompareExchange.spvasm +++ b/naga/tests/out/spv/wgsl-atomicCompareExchange.spvasm @@ -44,7 +44,7 @@ OpMemberDecorate %15 0 Offset 0 %21 = OpConstant %3 0 %23 = OpConstantFalse %8 %24 = OpTypeFloat 32 -%25 = OpConstant %24 1.0 +%25 = OpConstant %24 1 %26 = OpConstant %3 1 %28 = OpTypePointer Function %3 %30 = OpTypePointer Function %4 diff --git a/naga/tests/out/spv/wgsl-binding-arrays.spvasm b/naga/tests/out/spv/wgsl-binding-arrays.spvasm index 074aff8f9bc..c95bef4c567 100644 --- a/naga/tests/out/spv/wgsl-binding-arrays.spvasm +++ b/naga/tests/out/spv/wgsl-binding-arrays.spvasm @@ -130,7 +130,7 @@ OpDecorate %395 NonUniform %54 = OpTypePointer Uniform %4 %55 = OpConstant %3 0 %57 = OpConstantComposite %23 %55 %55 -%58 = OpConstant %6 0.0 +%58 = OpConstant %6 0 %59 = OpConstantComposite %22 %58 %58 %58 %58 %60 = OpTypeVector %6 2 %61 = OpConstantComposite %60 %58 %58 diff --git a/naga/tests/out/spv/wgsl-bitcast.spvasm b/naga/tests/out/spv/wgsl-bitcast.spvasm index 43dfa8df339..28b8fe56954 100644 --- a/naga/tests/out/spv/wgsl-bitcast.spvasm +++ b/naga/tests/out/spv/wgsl-bitcast.spvasm @@ -29,7 +29,7 @@ OpExecutionMode %16 LocalSize 1 1 1 %23 = OpConstantComposite %7 %22 %22 %24 = OpConstantComposite %9 %22 %22 %22 %25 = OpConstantComposite %10 %22 %22 %22 %22 -%26 = OpConstant %12 0.0 +%26 = OpConstant %12 0 %27 = OpConstantComposite %11 %26 %26 %28 = OpConstantComposite %13 %26 %26 %26 %29 = OpConstantComposite %14 %26 %26 %26 %26 diff --git a/naga/tests/out/spv/wgsl-bits.spvasm b/naga/tests/out/spv/wgsl-bits.spvasm index dec26768b3a..90786720f1a 100644 --- a/naga/tests/out/spv/wgsl-bits.spvasm +++ b/naga/tests/out/spv/wgsl-bits.spvasm @@ -29,7 +29,7 @@ OpExecutionMode %15 LocalSize 1 1 1 %22 = OpConstantComposite %8 %21 %21 %23 = OpConstantComposite %9 %21 %21 %21 %24 = OpConstantComposite %10 %21 %21 %21 %21 -%25 = OpConstant %12 0.0 +%25 = OpConstant %12 0 %26 = OpConstantComposite %11 %25 %25 %27 = OpConstantComposite %13 %25 %25 %25 %25 %28 = OpConstant %7 5 diff --git a/naga/tests/out/spv/wgsl-boids.spvasm b/naga/tests/out/spv/wgsl-boids.spvasm index 35bda2793b4..837d9326cd4 100644 --- a/naga/tests/out/spv/wgsl-boids.spvasm +++ b/naga/tests/out/spv/wgsl-boids.spvasm @@ -191,14 +191,14 @@ OpDecorate %21 BuiltIn GlobalInvocationId %25 = OpTypeFunction %2 %26 = OpTypePointer Uniform %8 %27 = OpConstant %4 0 -%29 = OpConstant %5 0.0 +%29 = OpConstant %5 0 %30 = OpConstantComposite %6 %29 %29 %31 = OpConstant %12 0 %32 = OpConstant %12 1 %33 = OpConstant %4 1 %34 = OpConstant %5 0.1 -%35 = OpConstant %5 -1.0 -%36 = OpConstant %5 1.0 +%35 = OpConstant %5 -1 +%36 = OpConstant %5 1 %38 = OpTypePointer Function %6 %39 = OpConstantNull %6 %41 = OpConstantNull %6 diff --git a/naga/tests/out/spv/wgsl-bounds-check-image-restrict-depth.spvasm b/naga/tests/out/spv/wgsl-bounds-check-image-restrict-depth.spvasm index b8a36ed3dfc..2f7efbe55df 100644 --- a/naga/tests/out/spv/wgsl-bounds-check-image-restrict-depth.spvasm +++ b/naga/tests/out/spv/wgsl-bounds-check-image-restrict-depth.spvasm @@ -101,7 +101,7 @@ OpDecorate %89 Location 0 %96 = OpConstantNull %7 %97 = OpConstant %6 0 %98 = OpConstant %9 0 -%99 = OpConstant %5 0.0 +%99 = OpConstant %5 0 %100 = OpConstantComposite %11 %99 %99 %99 %99 %21 = OpFunction %5 None %22 %19 = OpFunctionParameter %7 diff --git a/naga/tests/out/spv/wgsl-bounds-check-image-restrict.spvasm b/naga/tests/out/spv/wgsl-bounds-check-image-restrict.spvasm index aa311f557e6..4a7b1240e14 100644 --- a/naga/tests/out/spv/wgsl-bounds-check-image-restrict.spvasm +++ b/naga/tests/out/spv/wgsl-bounds-check-image-restrict.spvasm @@ -229,7 +229,7 @@ OpDecorate %172 Location 0 %187 = OpConstant %11 0 %188 = OpConstantNull %13 %189 = OpConstantNull %7 -%190 = OpConstant %5 0.0 +%190 = OpConstant %5 0 %191 = OpConstantComposite %7 %190 %190 %190 %190 %40 = OpFunction %7 None %41 %38 = OpFunctionParameter %6 diff --git a/naga/tests/out/spv/wgsl-bounds-check-image-rzsw-depth.spvasm b/naga/tests/out/spv/wgsl-bounds-check-image-rzsw-depth.spvasm index 0db821d3bf3..4ecca6c2f38 100644 --- a/naga/tests/out/spv/wgsl-bounds-check-image-rzsw-depth.spvasm +++ b/naga/tests/out/spv/wgsl-bounds-check-image-rzsw-depth.spvasm @@ -100,7 +100,7 @@ OpDecorate %100 Location 0 %107 = OpConstantNull %7 %108 = OpConstant %6 0 %109 = OpConstant %9 0 -%110 = OpConstant %5 0.0 +%110 = OpConstant %5 0 %111 = OpConstantComposite %11 %110 %110 %110 %110 %21 = OpFunction %5 None %22 %19 = OpFunctionParameter %7 diff --git a/naga/tests/out/spv/wgsl-bounds-check-image-rzsw.spvasm b/naga/tests/out/spv/wgsl-bounds-check-image-rzsw.spvasm index 7eb0c8b6121..814d2aa24df 100644 --- a/naga/tests/out/spv/wgsl-bounds-check-image-rzsw.spvasm +++ b/naga/tests/out/spv/wgsl-bounds-check-image-rzsw.spvasm @@ -226,7 +226,7 @@ OpDecorate %187 Location 0 %201 = OpConstantNull %9 %202 = OpConstant %11 0 %203 = OpConstantNull %13 -%204 = OpConstant %5 0.0 +%204 = OpConstant %5 0 %205 = OpConstantComposite %7 %204 %204 %204 %204 %40 = OpFunction %7 None %41 %38 = OpFunctionParameter %6 diff --git a/naga/tests/out/spv/wgsl-bounds-check-restrict.spvasm b/naga/tests/out/spv/wgsl-bounds-check-restrict.spvasm index 9885a0bde73..86a0a0547c6 100644 --- a/naga/tests/out/spv/wgsl-bounds-check-restrict.spvasm +++ b/naga/tests/out/spv/wgsl-bounds-check-restrict.spvasm @@ -45,9 +45,9 @@ OpDecorate %12 Binding 0 %59 = OpTypePointer StorageBuffer %8 %60 = OpConstant %6 2 %68 = OpTypeFunction %3 %11 %11 -%77 = OpConstant %3 100.0 -%83 = OpConstant %3 -2147483600.0 -%84 = OpConstant %3 2147483500.0 +%77 = OpConstant %3 100 +%83 = OpConstant %3 -2147483600 +%84 = OpConstant %3 2147483500 %92 = OpTypeFunction %3 %106 = OpTypeFunction %2 %11 %3 %130 = OpTypeFunction %2 %11 %7 @@ -56,14 +56,14 @@ OpDecorate %12 Binding 0 %170 = OpConstant %6 1000 %184 = OpTypeFunction %2 %185 = OpConstant %11 1 -%186 = OpConstant %3 2.0 -%187 = OpConstant %3 3.0 -%188 = OpConstant %3 4.0 -%189 = OpConstant %3 5.0 +%186 = OpConstant %3 2 +%187 = OpConstant %3 3 +%188 = OpConstant %3 4 +%189 = OpConstant %3 5 %190 = OpConstantComposite %7 %186 %187 %188 %189 %191 = OpConstant %11 6 %192 = OpConstant %11 2 -%193 = OpConstant %3 1.0 +%193 = OpConstant %3 1 %16 = OpFunction %3 None %17 %15 = OpFunctionParameter %11 %14 = OpLabel diff --git a/naga/tests/out/spv/wgsl-bounds-check-zero.spvasm b/naga/tests/out/spv/wgsl-bounds-check-zero.spvasm index c31e9e1ab73..f8cd0080678 100644 --- a/naga/tests/out/spv/wgsl-bounds-check-zero.spvasm +++ b/naga/tests/out/spv/wgsl-bounds-check-zero.spvasm @@ -48,9 +48,9 @@ OpDecorate %12 Binding 0 %74 = OpConstant %6 2 %76 = OpConstantNull %7 %85 = OpTypeFunction %3 %11 %11 -%98 = OpConstant %3 100.0 -%104 = OpConstant %3 -2147483600.0 -%105 = OpConstant %3 2147483500.0 +%98 = OpConstant %3 100 +%104 = OpConstant %3 -2147483600 +%105 = OpConstant %3 2147483500 %116 = OpTypeFunction %3 %118 = OpConstant %6 9 %131 = OpTypeFunction %2 %11 %3 @@ -60,14 +60,14 @@ OpDecorate %12 Binding 0 %206 = OpConstant %6 1000 %224 = OpTypeFunction %2 %225 = OpConstant %11 1 -%226 = OpConstant %3 2.0 -%227 = OpConstant %3 3.0 -%228 = OpConstant %3 4.0 -%229 = OpConstant %3 5.0 +%226 = OpConstant %3 2 +%227 = OpConstant %3 3 +%228 = OpConstant %3 4 +%229 = OpConstant %3 5 %230 = OpConstantComposite %7 %226 %227 %228 %229 %231 = OpConstant %11 6 %232 = OpConstant %11 2 -%233 = OpConstant %3 1.0 +%233 = OpConstant %3 1 %16 = OpFunction %3 None %17 %15 = OpFunctionParameter %11 %14 = OpLabel diff --git a/naga/tests/out/spv/wgsl-const-exprs.spvasm b/naga/tests/out/spv/wgsl-const-exprs.spvasm index c4413460f1e..84701b9e163 100644 --- a/naga/tests/out/spv/wgsl-const-exprs.spvasm +++ b/naga/tests/out/spv/wgsl-const-exprs.spvasm @@ -34,10 +34,10 @@ OpDecorate %13 ArrayStride 4 %24 = OpConstant %7 3.141 %25 = OpConstant %7 6.282 %26 = OpConstant %7 0.44444445 -%27 = OpConstant %7 0.0 +%27 = OpConstant %7 0 %28 = OpConstantComposite %8 %26 %27 %27 %27 -%29 = OpConstant %7 4.0 -%30 = OpConstant %7 5.0 +%29 = OpConstant %7 4 +%30 = OpConstant %7 5 %31 = OpConstantComposite %15 %29 %30 %32 = OpConstantComposite %12 %17 %18 %35 = OpTypeFunction %2 @@ -58,8 +58,8 @@ OpDecorate %13 ArrayStride 4 %86 = OpConstant %3 30 %87 = OpConstant %3 0 %94 = OpConstantNull %3 -%97 = OpConstant %7 1.0 -%98 = OpConstant %7 2.0 +%97 = OpConstant %7 1 +%98 = OpConstant %7 2 %99 = OpConstantComposite %8 %98 %97 %97 %97 %101 = OpTypePointer Function %8 %106 = OpTypePointer Function %9 diff --git a/naga/tests/out/spv/wgsl-constructors.spvasm b/naga/tests/out/spv/wgsl-constructors.spvasm index 233cb2735ea..0192183dc84 100644 --- a/naga/tests/out/spv/wgsl-constructors.spvasm +++ b/naga/tests/out/spv/wgsl-constructors.spvasm @@ -31,11 +31,11 @@ OpDecorate %18 ArrayStride 4 %19 = OpConstant %12 4 %18 = OpTypeArray %5 %19 %20 = OpTypeMatrix %7 2 -%21 = OpConstant %3 0.0 +%21 = OpConstant %3 0 %22 = OpConstantComposite %7 %21 %21 %21 -%23 = OpConstant %3 1.0 -%24 = OpConstant %3 2.0 -%25 = OpConstant %3 3.0 +%23 = OpConstant %3 1 +%24 = OpConstant %3 2 +%25 = OpConstant %3 3 %26 = OpConstantComposite %9 %21 %23 %27 = OpConstantComposite %9 %24 %25 %28 = OpConstantComposite %8 %26 %27 diff --git a/naga/tests/out/spv/wgsl-conversion-float-to-int.spvasm b/naga/tests/out/spv/wgsl-conversion-float-to-int.spvasm index 10cbbe3b8c4..8d8168bfc00 100644 --- a/naga/tests/out/spv/wgsl-conversion-float-to-int.spvasm +++ b/naga/tests/out/spv/wgsl-conversion-float-to-int.spvasm @@ -29,12 +29,12 @@ OpExecutionMode %278 LocalSize 1 1 1 %14 = OpTypeVector %9 2 %15 = OpTypeVector %4 2 %16 = OpTypeVector %5 2 -%17 = OpConstant %3 9.0399e-41 -%18 = OpConstant %3 4.4481e-41 -%19 = OpConstant %4 -3.4028235e38 -%20 = OpConstant %4 3.4028235e38 -%21 = OpConstant %5 -1.7976931348623157e308 -%22 = OpConstant %5 1.7976931348623157e308 +%17 = OpConstant %3 0.000000000000000000000000000000000000000090399 +%18 = OpConstant %3 0.000000000000000000000000000000000000000044481 +%19 = OpConstant %4 -340282350000000000000000000000000000000 +%20 = OpConstant %4 340282350000000000000000000000000000000 +%21 = OpConstant %5 -179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +%22 = OpConstant %5 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 %25 = OpTypeFunction %2 %26 = OpConstant %6 -65504 %27 = OpConstant %6 65504 @@ -60,31 +60,31 @@ OpExecutionMode %278 LocalSize 1 1 1 %54 = OpTypePointer Function %9 %80 = OpTypeFunction %6 %3 %87 = OpTypeFunction %7 %3 -%89 = OpConstant %3 0.0 +%89 = OpConstant %3 0 %95 = OpTypeFunction %8 %3 %102 = OpTypeFunction %9 %3 %109 = OpTypeFunction %6 %4 -%111 = OpConstant %4 -2147483600.0 -%112 = OpConstant %4 2147483500.0 +%111 = OpConstant %4 -2147483600 +%112 = OpConstant %4 2147483500 %118 = OpTypeFunction %7 %4 -%120 = OpConstant %4 0.0 -%121 = OpConstant %4 4294967000.0 +%120 = OpConstant %4 0 +%121 = OpConstant %4 4294967000 %127 = OpTypeFunction %8 %4 -%129 = OpConstant %4 -9.223372e18 -%130 = OpConstant %4 9.2233715e18 +%129 = OpConstant %4 -9223372000000000000 +%130 = OpConstant %4 9223371500000000000 %136 = OpTypeFunction %9 %4 -%138 = OpConstant %4 1.8446743e19 +%138 = OpConstant %4 18446743000000000000 %144 = OpTypeFunction %6 %5 -%146 = OpConstant %5 -2147483648.0 -%147 = OpConstant %5 2147483647.0 +%146 = OpConstant %5 -2147483648 +%147 = OpConstant %5 2147483647 %153 = OpTypeFunction %7 %5 -%155 = OpConstant %5 0.0 -%156 = OpConstant %5 4294967295.0 +%155 = OpConstant %5 0 +%156 = OpConstant %5 4294967295 %162 = OpTypeFunction %8 %5 -%164 = OpConstant %5 -9.223372036854776e18 -%165 = OpConstant %5 9.223372036854775e18 +%164 = OpConstant %5 -9223372036854776000 +%165 = OpConstant %5 9223372036854775000 %171 = OpTypeFunction %9 %5 -%173 = OpConstant %5 1.844674407370955e19 +%173 = OpConstant %5 18446744073709550000 %179 = OpTypeFunction %11 %10 %181 = OpConstantComposite %10 %17 %17 %182 = OpConstantComposite %10 %18 %18 @@ -114,14 +114,14 @@ OpExecutionMode %278 LocalSize 1 1 1 %266 = OpConstantComposite %16 %165 %165 %272 = OpTypeFunction %14 %16 %274 = OpConstantComposite %16 %173 %173 -%279 = OpConstant %3 2.1524e-41 -%280 = OpConstant %4 1.0 -%281 = OpConstant %5 1.0 -%282 = OpConstant %3 2.2959e-41 +%279 = OpConstant %3 0.000000000000000000000000000000000000000021524 +%280 = OpConstant %4 1 +%281 = OpConstant %5 1 +%282 = OpConstant %3 0.000000000000000000000000000000000000000022959 %283 = OpConstantComposite %10 %279 %282 -%284 = OpConstant %4 2.0 +%284 = OpConstant %4 2 %285 = OpConstantComposite %15 %280 %284 -%286 = OpConstant %5 2.0 +%286 = OpConstant %5 2 %287 = OpConstantComposite %16 %281 %286 %24 = OpFunction %2 None %25 %23 = OpLabel diff --git a/naga/tests/out/spv/wgsl-conversions.spvasm b/naga/tests/out/spv/wgsl-conversions.spvasm index 5dae778e115..112979819ce 100644 --- a/naga/tests/out/spv/wgsl-conversions.spvasm +++ b/naga/tests/out/spv/wgsl-conversions.spvasm @@ -10,7 +10,7 @@ OpExecutionMode %8 LocalSize 1 1 1 %2 = OpTypeVoid %4 = OpTypeFloat 32 %3 = OpTypeVector %4 2 -%5 = OpConstant %4 2.0 +%5 = OpConstant %4 2 %6 = OpConstantComposite %3 %5 %5 %9 = OpTypeFunction %2 %11 = OpTypePointer Function %3 diff --git a/naga/tests/out/spv/wgsl-cross.spvasm b/naga/tests/out/spv/wgsl-cross.spvasm index fd13684894b..849b26ef778 100644 --- a/naga/tests/out/spv/wgsl-cross.spvasm +++ b/naga/tests/out/spv/wgsl-cross.spvasm @@ -11,8 +11,8 @@ OpExecutionMode %6 LocalSize 1 1 1 %4 = OpTypeFloat 32 %3 = OpTypeVector %4 3 %7 = OpTypeFunction %2 -%8 = OpConstant %4 0.0 -%9 = OpConstant %4 1.0 +%8 = OpConstant %4 0 +%9 = OpConstant %4 1 %10 = OpConstantComposite %3 %8 %8 %9 %6 = OpFunction %2 None %7 %5 = OpLabel diff --git a/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm b/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm index f1db8e611ed..ef1d8bc534f 100644 --- a/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm +++ b/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm @@ -7716,10 +7716,10 @@ OpDecorate %614 Location 0 %49 = OpVariable %46 UniformConstant %50 = OpVariable %48 UniformConstant %54 = OpTypeFunction %5 %5 -%55 = OpConstant %4 34.0 -%56 = OpConstant %4 1.0 +%55 = OpConstant %4 34 +%56 = OpConstant %4 1 %57 = OpConstantComposite %5 %56 %56 %56 -%58 = OpConstant %4 289.0 +%58 = OpConstant %4 289 %59 = OpConstantComposite %5 %58 %58 %58 %68 = OpTypeFunction %4 %6 %69 = OpConstant %4 0.21132487 @@ -7727,18 +7727,18 @@ OpDecorate %614 Location 0 %71 = OpConstant %4 -0.57735026 %72 = OpConstant %4 0.024390243 %73 = OpConstantComposite %7 %69 %70 %71 %72 -%74 = OpConstant %4 0.0 +%74 = OpConstant %4 0 %75 = OpConstantComposite %6 %56 %74 %76 = OpConstantComposite %6 %74 %56 %77 = OpConstantComposite %6 %58 %58 %78 = OpConstant %4 0.5 %79 = OpConstantComposite %5 %78 %78 %78 %80 = OpConstantComposite %5 %74 %74 %74 -%81 = OpConstant %4 2.0 +%81 = OpConstant %4 2 %82 = OpConstant %4 0.85373473 %83 = OpConstant %4 1.7928429 %84 = OpConstantComposite %5 %83 %83 %83 -%85 = OpConstant %4 130.0 +%85 = OpConstant %4 130 %87 = OpTypePointer Function %6 %88 = OpConstantNull %6 %90 = OpConstantNull %6 @@ -7753,7 +7753,7 @@ OpDecorate %614 Location 0 %135 = OpConstant %8 0 %205 = OpConstant %8 5 %206 = OpConstant %4 0.01 -%207 = OpConstant %4 100.0 +%207 = OpConstant %4 100 %208 = OpConstantComposite %6 %207 %207 %209 = OpConstant %4 0.87758255 %210 = OpConstant %4 0.47942555 @@ -7775,11 +7775,11 @@ OpDecorate %614 Location 0 %314 = OpTypeFunction %8 %8 %8 %326 = OpTypeFunction %6 %8 %10 %11 %343 = OpTypeFunction %5 %6 -%344 = OpConstant %4 23.0 -%345 = OpConstant %4 32.0 +%344 = OpConstant %4 23 +%345 = OpConstant %4 32 %346 = OpConstantComposite %6 %344 %345 -%347 = OpConstant %4 -43.0 -%348 = OpConstant %4 3.0 +%347 = OpConstant %4 -43 +%348 = OpConstant %4 3 %349 = OpConstantComposite %6 %347 %348 %365 = OpTypePointer Input %19 %364 = OpVariable %365 Input @@ -7806,9 +7806,9 @@ OpDecorate %614 Location 0 %443 = OpTypePointer Output %6 %442 = OpVariable %443 Output %445 = OpTypePointer Uniform %20 -%447 = OpConstant %4 -1.0 +%447 = OpConstant %4 -1 %448 = OpConstantComposite %6 %447 %447 -%473 = OpConstant %4 4294967000.0 +%473 = OpConstant %4 4294967000 %485 = OpVariable %436 Input %488 = OpTypePointer Input %7 %487 = OpVariable %488 Input @@ -7816,7 +7816,7 @@ OpDecorate %614 Location 0 %490 = OpVariable %491 Input %493 = OpVariable %439 Output %494 = OpVariable %439 Output -%497 = OpConstant %4 6.0 +%497 = OpConstant %4 6 %582 = OpTypePointer Input %5 %581 = OpVariable %582 Input %584 = OpVariable %582 Input diff --git a/naga/tests/out/spv/wgsl-debug-symbol-simple.spvasm b/naga/tests/out/spv/wgsl-debug-symbol-simple.spvasm index bde02c231de..4adb3411b35 100644 --- a/naga/tests/out/spv/wgsl-debug-symbol-simple.spvasm +++ b/naga/tests/out/spv/wgsl-debug-symbol-simple.spvasm @@ -87,7 +87,7 @@ OpDecorate %48 Location 0 %20 = OpTypePointer Output %5 %19 = OpVariable %20 Output %22 = OpTypeFunction %2 -%23 = OpConstant %4 1.0 +%23 = OpConstant %4 1 %25 = OpTypePointer Function %8 %26 = OpConstantNull %8 %28 = OpTypePointer Function %5 diff --git a/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm b/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm index 69f08bcdb62..47009186afb 100644 --- a/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm +++ b/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm @@ -551,10 +551,10 @@ OpDecorate %614 Location 0 %49 = OpVariable %46 UniformConstant %50 = OpVariable %48 UniformConstant %54 = OpTypeFunction %5 %5 -%55 = OpConstant %4 34.0 -%56 = OpConstant %4 1.0 +%55 = OpConstant %4 34 +%56 = OpConstant %4 1 %57 = OpConstantComposite %5 %56 %56 %56 -%58 = OpConstant %4 289.0 +%58 = OpConstant %4 289 %59 = OpConstantComposite %5 %58 %58 %58 %68 = OpTypeFunction %4 %6 %69 = OpConstant %4 0.21132487 @@ -562,18 +562,18 @@ OpDecorate %614 Location 0 %71 = OpConstant %4 -0.57735026 %72 = OpConstant %4 0.024390243 %73 = OpConstantComposite %7 %69 %70 %71 %72 -%74 = OpConstant %4 0.0 +%74 = OpConstant %4 0 %75 = OpConstantComposite %6 %56 %74 %76 = OpConstantComposite %6 %74 %56 %77 = OpConstantComposite %6 %58 %58 %78 = OpConstant %4 0.5 %79 = OpConstantComposite %5 %78 %78 %78 %80 = OpConstantComposite %5 %74 %74 %74 -%81 = OpConstant %4 2.0 +%81 = OpConstant %4 2 %82 = OpConstant %4 0.85373473 %83 = OpConstant %4 1.7928429 %84 = OpConstantComposite %5 %83 %83 %83 -%85 = OpConstant %4 130.0 +%85 = OpConstant %4 130 %87 = OpTypePointer Function %6 %88 = OpConstantNull %6 %90 = OpConstantNull %6 @@ -588,7 +588,7 @@ OpDecorate %614 Location 0 %135 = OpConstant %8 0 %205 = OpConstant %8 5 %206 = OpConstant %4 0.01 -%207 = OpConstant %4 100.0 +%207 = OpConstant %4 100 %208 = OpConstantComposite %6 %207 %207 %209 = OpConstant %4 0.87758255 %210 = OpConstant %4 0.47942555 @@ -610,11 +610,11 @@ OpDecorate %614 Location 0 %314 = OpTypeFunction %8 %8 %8 %326 = OpTypeFunction %6 %8 %10 %11 %343 = OpTypeFunction %5 %6 -%344 = OpConstant %4 23.0 -%345 = OpConstant %4 32.0 +%344 = OpConstant %4 23 +%345 = OpConstant %4 32 %346 = OpConstantComposite %6 %344 %345 -%347 = OpConstant %4 -43.0 -%348 = OpConstant %4 3.0 +%347 = OpConstant %4 -43 +%348 = OpConstant %4 3 %349 = OpConstantComposite %6 %347 %348 %365 = OpTypePointer Input %19 %364 = OpVariable %365 Input @@ -641,9 +641,9 @@ OpDecorate %614 Location 0 %443 = OpTypePointer Output %6 %442 = OpVariable %443 Output %445 = OpTypePointer Uniform %20 -%447 = OpConstant %4 -1.0 +%447 = OpConstant %4 -1 %448 = OpConstantComposite %6 %447 %447 -%473 = OpConstant %4 4294967000.0 +%473 = OpConstant %4 4294967000 %485 = OpVariable %436 Input %488 = OpTypePointer Input %7 %487 = OpVariable %488 Input @@ -651,7 +651,7 @@ OpDecorate %614 Location 0 %490 = OpVariable %491 Input %493 = OpVariable %439 Output %494 = OpVariable %439 Output -%497 = OpConstant %4 6.0 +%497 = OpConstant %4 6 %582 = OpTypePointer Input %5 %581 = OpVariable %582 Input %584 = OpVariable %582 Input diff --git a/naga/tests/out/spv/wgsl-extra.spvasm b/naga/tests/out/spv/wgsl-extra.spvasm index 0e84427bad4..0d091ae1fe2 100644 --- a/naga/tests/out/spv/wgsl-extra.spvasm +++ b/naga/tests/out/spv/wgsl-extra.spvasm @@ -37,7 +37,7 @@ OpDecorate %20 Location 0 %23 = OpTypeFunction %2 %24 = OpTypePointer PushConstant %6 %25 = OpConstant %3 0 -%27 = OpConstant %5 1.0 +%27 = OpConstant %5 1 %28 = OpTypeVector %5 3 %29 = OpConstantComposite %28 %27 %27 %27 %32 = OpTypePointer PushConstant %3 diff --git a/naga/tests/out/spv/wgsl-f16.spvasm b/naga/tests/out/spv/wgsl-f16.spvasm index d6aed42b4eb..4fc6963ce87 100644 --- a/naga/tests/out/spv/wgsl-f16.spvasm +++ b/naga/tests/out/spv/wgsl-f16.spvasm @@ -100,8 +100,8 @@ OpMemberDecorate %41 0 Offset 0 %20 = OpTypeArray %3 %21 %22 = OpTypeStruct %20 %23 = OpTypeStruct %3 %3 %8 %3 %3 %4 -%24 = OpConstant %3 2.1524e-41 -%25 = OpConstant %3 2.7121e-41 +%24 = OpConstant %3 0.000000000000000000000000000000000000000021524 +%25 = OpConstant %3 0.000000000000000000000000000000000000000027121 %27 = OpTypePointer Private %3 %26 = OpVariable %27 Private %24 %29 = OpTypeStruct %19 @@ -124,13 +124,13 @@ OpMemberDecorate %41 0 Offset 0 %48 = OpConstant %4 0 %50 = OpTypePointer StorageBuffer %19 %52 = OpTypePointer StorageBuffer %22 -%56 = OpConstant %3 8.8991e-41 -%57 = OpConstant %3 2.4753e-41 +%56 = OpConstant %3 0.000000000000000000000000000000000000000088991 +%57 = OpConstant %3 0.000000000000000000000000000000000000000024753 %58 = OpConstant %5 65504 %59 = OpConstant %5 -65504 %60 = OpConstant %4 65504 -%61 = OpConstant %6 65504.0 -%62 = OpConstant %6 -65504.0 +%61 = OpConstant %6 65504 +%62 = OpConstant %6 -65504 %64 = OpTypePointer Function %23 %65 = OpConstantNull %23 %67 = OpTypePointer Function %3 @@ -192,7 +192,7 @@ OpMemberDecorate %41 0 Offset 0 %474 = OpTypeMatrix %344 4 %496 = OpTypeMatrix %350 4 %519 = OpTypeFunction %2 -%525 = OpConstant %3 2.2959e-41 +%525 = OpConstant %3 0.000000000000000000000000000000000000000022959 %528 = OpConstant %4 7 %45 = OpFunction %3 None %46 %44 = OpFunctionParameter %3 diff --git a/naga/tests/out/spv/wgsl-f64.spvasm b/naga/tests/out/spv/wgsl-f64.spvasm index d51bc3c8535..fd0fa038e1c 100644 --- a/naga/tests/out/spv/wgsl-f64.spvasm +++ b/naga/tests/out/spv/wgsl-f64.spvasm @@ -10,19 +10,19 @@ OpEntryPoint GLCompute %28 "main" OpExecutionMode %28 LocalSize 1 1 1 %2 = OpTypeVoid %3 = OpTypeFloat 64 -%4 = OpConstant %3 1.0 -%5 = OpConstant %3 2.0 +%4 = OpConstant %3 1 +%5 = OpConstant %3 2 %7 = OpTypePointer Private %3 %6 = OpVariable %7 Private %4 %11 = OpTypeFunction %3 %3 -%12 = OpConstant %3 30.0 -%13 = OpConstant %3 400.0 -%14 = OpConstant %3 5.0 -%15 = OpConstant %3 -1.0 +%12 = OpConstant %3 30 +%13 = OpConstant %3 400 +%14 = OpConstant %3 5 +%15 = OpConstant %3 -1 %17 = OpTypePointer Function %3 %18 = OpConstantNull %3 %29 = OpTypeFunction %2 -%30 = OpConstant %3 6.0 +%30 = OpConstant %3 6 %10 = OpFunction %3 None %11 %9 = OpFunctionParameter %3 %8 = OpLabel diff --git a/naga/tests/out/spv/wgsl-fragment-output.spvasm b/naga/tests/out/spv/wgsl-fragment-output.spvasm index 414c646c73c..cad9ebf7b24 100644 --- a/naga/tests/out/spv/wgsl-fragment-output.spvasm +++ b/naga/tests/out/spv/wgsl-fragment-output.spvasm @@ -61,7 +61,7 @@ OpDecorate %80 Location 5 %29 = OpTypePointer Output %11 %28 = OpVariable %29 Output %31 = OpTypeFunction %2 -%32 = OpConstant %3 0.0 +%32 = OpConstant %3 0 %33 = OpConstantComposite %4 %32 %32 %32 %32 %34 = OpConstant %5 0 %35 = OpConstantComposite %6 %34 %34 %34 %34 diff --git a/naga/tests/out/spv/wgsl-functions-optimized-by-capability.spvasm b/naga/tests/out/spv/wgsl-functions-optimized-by-capability.spvasm index 00fc02f9f8b..011a5e39e34 100644 --- a/naga/tests/out/spv/wgsl-functions-optimized-by-capability.spvasm +++ b/naga/tests/out/spv/wgsl-functions-optimized-by-capability.spvasm @@ -3,8 +3,8 @@ ; Generator: rspirv ; Bound: 30 OpCapability Shader -OpCapability DotProductKHR -OpCapability DotProductInput4x8BitPackedKHR +OpCapability DotProduct +OpCapability DotProductInput4x8BitPacked OpExtension "SPV_KHR_integer_dot_product" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -27,14 +27,14 @@ OpExecutionMode %26 LocalSize 1 1 1 %4 = OpLabel OpBranch %15 %15 = OpLabel -%17 = OpSDotKHR %16 %7 %8 PackedVectorFormat4x8BitKHR -%18 = OpUDotKHR %3 %9 %10 PackedVectorFormat4x8BitKHR +%17 = OpSDot %16 %7 %8 PackedVectorFormat4x8Bit +%18 = OpUDot %3 %9 %10 PackedVectorFormat4x8Bit %19 = OpIAdd %3 %11 %18 %20 = OpIAdd %3 %12 %18 -%21 = OpSDotKHR %16 %19 %20 PackedVectorFormat4x8BitKHR +%21 = OpSDot %16 %19 %20 PackedVectorFormat4x8Bit %22 = OpIAdd %3 %13 %18 %23 = OpIAdd %3 %14 %18 -%24 = OpUDotKHR %3 %22 %23 PackedVectorFormat4x8BitKHR +%24 = OpUDot %3 %22 %23 PackedVectorFormat4x8Bit OpReturnValue %24 OpFunctionEnd %26 = OpFunction %2 None %27 diff --git a/naga/tests/out/spv/wgsl-functions-optimized-by-version.spvasm b/naga/tests/out/spv/wgsl-functions-optimized-by-version.spvasm index 0c77fbda039..46aa7520ca1 100644 --- a/naga/tests/out/spv/wgsl-functions-optimized-by-version.spvasm +++ b/naga/tests/out/spv/wgsl-functions-optimized-by-version.spvasm @@ -3,8 +3,8 @@ ; Generator: rspirv ; Bound: 30 OpCapability Shader -OpCapability DotProductKHR -OpCapability DotProductInput4x8BitPackedKHR +OpCapability DotProduct +OpCapability DotProductInput4x8BitPacked %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %26 "main" @@ -26,14 +26,14 @@ OpExecutionMode %26 LocalSize 1 1 1 %4 = OpLabel OpBranch %15 %15 = OpLabel -%17 = OpSDotKHR %16 %7 %8 PackedVectorFormat4x8BitKHR -%18 = OpUDotKHR %3 %9 %10 PackedVectorFormat4x8BitKHR +%17 = OpSDot %16 %7 %8 PackedVectorFormat4x8Bit +%18 = OpUDot %3 %9 %10 PackedVectorFormat4x8Bit %19 = OpIAdd %3 %11 %18 %20 = OpIAdd %3 %12 %18 -%21 = OpSDotKHR %16 %19 %20 PackedVectorFormat4x8BitKHR +%21 = OpSDot %16 %19 %20 PackedVectorFormat4x8Bit %22 = OpIAdd %3 %13 %18 %23 = OpIAdd %3 %14 %18 -%24 = OpUDotKHR %3 %22 %23 PackedVectorFormat4x8BitKHR +%24 = OpUDot %3 %22 %23 PackedVectorFormat4x8Bit OpReturnValue %24 OpFunctionEnd %26 = OpFunction %2 None %27 diff --git a/naga/tests/out/spv/wgsl-functions.spvasm b/naga/tests/out/spv/wgsl-functions.spvasm index 35585e2a6c6..a84e322ae74 100644 --- a/naga/tests/out/spv/wgsl-functions.spvasm +++ b/naga/tests/out/spv/wgsl-functions.spvasm @@ -3,8 +3,8 @@ ; Generator: rspirv ; Bound: 95 OpCapability Shader -OpCapability DotProductKHR -OpCapability DotProductInput4x8BitPackedKHR +OpCapability DotProduct +OpCapability DotProductInput4x8BitPacked OpExtension "SPV_KHR_integer_dot_product" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -16,7 +16,7 @@ OpExecutionMode %89 LocalSize 1 1 1 %5 = OpTypeInt 32 1 %6 = OpTypeInt 32 0 %9 = OpTypeFunction %3 -%10 = OpConstant %4 2.0 +%10 = OpConstant %4 2 %11 = OpConstantComposite %3 %10 %10 %12 = OpConstant %4 0.5 %13 = OpConstantComposite %3 %12 %12 @@ -96,14 +96,14 @@ OpFunctionEnd %69 = OpLabel OpBranch %79 %79 = OpLabel -%80 = OpSDotKHR %5 %22 %72 PackedVectorFormat4x8BitKHR -%81 = OpUDotKHR %6 %73 %74 PackedVectorFormat4x8BitKHR +%80 = OpSDot %5 %22 %72 PackedVectorFormat4x8Bit +%81 = OpUDot %6 %73 %74 PackedVectorFormat4x8Bit %82 = OpIAdd %6 %75 %81 %83 = OpIAdd %6 %76 %81 -%84 = OpSDotKHR %5 %82 %83 PackedVectorFormat4x8BitKHR +%84 = OpSDot %5 %82 %83 PackedVectorFormat4x8Bit %85 = OpIAdd %6 %77 %81 %86 = OpIAdd %6 %78 %81 -%87 = OpUDotKHR %6 %85 %86 PackedVectorFormat4x8BitKHR +%87 = OpUDot %6 %85 %86 PackedVectorFormat4x8Bit OpReturnValue %87 OpFunctionEnd %89 = OpFunction %2 None %90 diff --git a/naga/tests/out/spv/wgsl-globals.spvasm b/naga/tests/out/spv/wgsl-globals.spvasm index 5cf31f80766..8feae9610ce 100644 --- a/naga/tests/out/spv/wgsl-globals.spvasm +++ b/naga/tests/out/spv/wgsl-globals.spvasm @@ -106,11 +106,11 @@ OpDecorate %116 BuiltIn LocalInvocationId %58 = OpTypeFunction %2 %59 = OpTypePointer StorageBuffer %9 %60 = OpConstant %7 0 -%62 = OpConstant %4 1.0 +%62 = OpConstant %4 1 %63 = OpConstantComposite %8 %62 %62 %62 %64 = OpConstant %23 1 -%65 = OpConstant %4 2.0 -%66 = OpConstant %4 3.0 +%65 = OpConstant %4 2 +%66 = OpConstant %4 3 %67 = OpConstantNull %24 %69 = OpTypePointer Function %23 %71 = OpTypePointer StorageBuffer %8 @@ -121,7 +121,7 @@ OpDecorate %116 BuiltIn LocalInvocationId %101 = OpTypePointer Uniform %15 %103 = OpTypePointer Uniform %19 %105 = OpTypePointer Uniform %22 -%107 = OpConstant %4 4.0 +%107 = OpConstant %4 4 %109 = OpTypePointer Function %4 %111 = OpTypePointer Function %3 %113 = OpConstantNull %5 diff --git a/naga/tests/out/spv/wgsl-image.spvasm b/naga/tests/out/spv/wgsl-image.spvasm index 25681afe888..541fb1f5e64 100644 --- a/naga/tests/out/spv/wgsl-image.spvasm +++ b/naga/tests/out/spv/wgsl-image.spvasm @@ -405,8 +405,8 @@ OpDecorate %549 Location 0 %117 = OpTypeVector %5 4 %132 = OpTypeVector %15 3 %195 = OpVariable %94 Input -%212 = OpConstant %8 0.0 -%213 = OpConstant %8 4294967000.0 +%212 = OpConstant %8 0 +%213 = OpConstant %8 4294967000 %219 = OpTypePointer Output %24 %218 = OpVariable %219 Output %229 = OpConstant %5 0 @@ -420,12 +420,12 @@ OpDecorate %549 Location 0 %314 = OpConstant %15 3 %315 = OpConstantComposite %14 %314 %88 %316 = OpConstant %8 2.3 -%317 = OpConstant %8 2.0 +%317 = OpConstant %8 2 %319 = OpTypePointer Function %24 %320 = OpConstantNull %24 %322 = OpTypeSampledImage %16 %327 = OpTypeSampledImage %17 -%351 = OpConstant %8 1.0 +%351 = OpConstant %8 1 %352 = OpConstantComposite %310 %351 %351 %359 = OpTypeSampledImage %19 %420 = OpTypeSampledImage %21 diff --git a/naga/tests/out/spv/wgsl-index-by-value.spvasm b/naga/tests/out/spv/wgsl-index-by-value.spvasm index 09fedc4d676..e9ed297e2bf 100644 --- a/naga/tests/out/spv/wgsl-index-by-value.spvasm +++ b/naga/tests/out/spv/wgsl-index-by-value.spvasm @@ -36,10 +36,10 @@ OpDecorate %77 BuiltIn Position %36 = OpConstantComposite %9 %32 %35 %38 = OpTypePointer Function %9 %46 = OpTypeFunction %10 %3 %3 -%47 = OpConstant %10 1.0 -%48 = OpConstant %10 2.0 -%49 = OpConstant %10 3.0 -%50 = OpConstant %10 4.0 +%47 = OpConstant %10 1 +%48 = OpConstant %10 2 +%49 = OpConstant %10 3 +%50 = OpConstant %10 4 %51 = OpConstantComposite %12 %47 %48 %52 = OpConstantComposite %12 %49 %50 %53 = OpConstantComposite %11 %51 %52 diff --git a/naga/tests/out/spv/wgsl-int64.spvasm b/naga/tests/out/spv/wgsl-int64.spvasm index 141a95be586..c35098f7bd2 100644 --- a/naga/tests/out/spv/wgsl-int64.spvasm +++ b/naga/tests/out/spv/wgsl-int64.spvasm @@ -99,8 +99,8 @@ OpMemberDecorate %36 0 Offset 0 %78 = OpTypePointer Uniform %6 %79 = OpConstant %5 1 %88 = OpTypePointer Uniform %7 -%94 = OpConstant %7 -9.223372e18 -%95 = OpConstant %7 9.2233715e18 +%94 = OpConstant %7 -9223372000000000000 +%95 = OpConstant %7 9223371500000000000 %100 = OpTypePointer Uniform %3 %101 = OpConstant %5 7 %108 = OpTypePointer Uniform %4 @@ -128,8 +128,8 @@ OpMemberDecorate %36 0 Offset 0 %230 = OpConstant %4 18446744073709551615 %231 = OpConstant %4 5 %233 = OpTypePointer Function %4 -%264 = OpConstant %7 0.0 -%265 = OpConstant %7 1.8446743e19 +%264 = OpConstant %7 0 +%265 = OpConstant %7 18446743000000000000 %299 = OpTypePointer StorageBuffer %4 %306 = OpTypePointer StorageBuffer %8 %313 = OpTypePointer StorageBuffer %9 diff --git a/naga/tests/out/spv/wgsl-interface.fragment.spvasm b/naga/tests/out/spv/wgsl-interface.fragment.spvasm index 891b10d863d..e78d69121f3 100644 --- a/naga/tests/out/spv/wgsl-interface.fragment.spvasm +++ b/naga/tests/out/spv/wgsl-interface.fragment.spvasm @@ -56,8 +56,8 @@ OpDecorate %34 Location 0 %32 = OpVariable %33 Output %34 = OpVariable %31 Output %36 = OpTypeFunction %2 -%37 = OpConstant %3 0.0 -%38 = OpConstant %3 1.0 +%37 = OpConstant %3 0 +%38 = OpConstant %3 1 %35 = OpFunction %2 None %36 %14 = OpLabel %18 = OpLoad %4 %16 diff --git a/naga/tests/out/spv/wgsl-interface.vertex.spvasm b/naga/tests/out/spv/wgsl-interface.vertex.spvasm index 63ca57fa7d6..fa11c5b89f7 100644 --- a/naga/tests/out/spv/wgsl-interface.vertex.spvasm +++ b/naga/tests/out/spv/wgsl-interface.vertex.spvasm @@ -42,7 +42,7 @@ OpDecorate %26 BuiltIn PointSize %25 = OpTypePointer Output %3 %24 = OpVariable %25 Output %26 = OpVariable %25 Output -%27 = OpConstant %3 1.0 +%27 = OpConstant %3 1 %29 = OpTypeFunction %2 %30 = OpConstantComposite %4 %27 %27 %27 %27 %28 = OpFunction %2 None %29 diff --git a/naga/tests/out/spv/wgsl-interface.vertex_two_structs.spvasm b/naga/tests/out/spv/wgsl-interface.vertex_two_structs.spvasm index cad89cc551a..f83a5a624b3 100644 --- a/naga/tests/out/spv/wgsl-interface.vertex_two_structs.spvasm +++ b/naga/tests/out/spv/wgsl-interface.vertex_two_structs.spvasm @@ -38,10 +38,10 @@ OpDecorate %24 BuiltIn PointSize %22 = OpVariable %23 Output %25 = OpTypePointer Output %3 %24 = OpVariable %25 Output -%26 = OpConstant %3 1.0 +%26 = OpConstant %3 1 %28 = OpTypeFunction %2 %29 = OpConstant %6 2 -%30 = OpConstant %3 0.0 +%30 = OpConstant %3 0 %32 = OpTypePointer Function %6 %27 = OpFunction %2 None %28 %14 = OpLabel diff --git a/naga/tests/out/spv/wgsl-interpolate.spvasm b/naga/tests/out/spv/wgsl-interpolate.spvasm index ce0a9211522..91af2f3fe2c 100644 --- a/naga/tests/out/spv/wgsl-interpolate.spvasm +++ b/naga/tests/out/spv/wgsl-interpolate.spvasm @@ -176,36 +176,36 @@ OpDecorate %135 Location 11 %26 = OpVariable %18 Output %27 = OpVariable %18 Output %28 = OpVariable %18 Output -%29 = OpConstant %4 1.0 +%29 = OpConstant %4 1 %31 = OpTypeFunction %2 -%32 = OpConstant %4 2.0 -%33 = OpConstant %4 4.0 -%34 = OpConstant %4 5.0 -%35 = OpConstant %4 6.0 +%32 = OpConstant %4 2 +%33 = OpConstant %4 4 +%34 = OpConstant %4 5 +%35 = OpConstant %4 6 %36 = OpConstantComposite %5 %32 %33 %34 %35 %37 = OpConstant %6 8 %38 = OpConstant %6 9 %39 = OpConstant %6 10 -%40 = OpConstant %4 27.0 -%41 = OpConstant %4 64.0 -%42 = OpConstant %4 125.0 +%40 = OpConstant %4 27 +%41 = OpConstant %4 64 +%42 = OpConstant %4 125 %43 = OpConstantComposite %7 %41 %42 -%44 = OpConstant %4 216.0 -%45 = OpConstant %4 343.0 -%46 = OpConstant %4 512.0 +%44 = OpConstant %4 216 +%45 = OpConstant %4 343 +%46 = OpConstant %4 512 %47 = OpConstantComposite %8 %44 %45 %46 -%48 = OpConstant %4 255.0 -%49 = OpConstant %4 511.0 -%50 = OpConstant %4 1024.0 +%48 = OpConstant %4 255 +%49 = OpConstant %4 511 +%50 = OpConstant %4 1024 %51 = OpConstantComposite %8 %48 %49 %50 -%52 = OpConstant %4 729.0 -%53 = OpConstant %4 1000.0 -%54 = OpConstant %4 1331.0 -%55 = OpConstant %4 1728.0 +%52 = OpConstant %4 729 +%53 = OpConstant %4 1000 +%54 = OpConstant %4 1331 +%55 = OpConstant %4 1728 %56 = OpConstantComposite %5 %52 %53 %54 %55 -%57 = OpConstant %4 2197.0 -%58 = OpConstant %4 2744.0 -%59 = OpConstant %4 2812.0 +%57 = OpConstant %4 2197 +%58 = OpConstant %4 2744 +%59 = OpConstant %4 2812 %61 = OpTypePointer Function %9 %62 = OpConstantNull %9 %64 = OpTypePointer Function %5 diff --git a/naga/tests/out/spv/wgsl-interpolate_compat.spvasm b/naga/tests/out/spv/wgsl-interpolate_compat.spvasm index f6c72a053ef..f09a39d5a52 100644 --- a/naga/tests/out/spv/wgsl-interpolate_compat.spvasm +++ b/naga/tests/out/spv/wgsl-interpolate_compat.spvasm @@ -169,35 +169,35 @@ OpDecorate %129 Location 11 %25 = OpVariable %17 Output %26 = OpVariable %17 Output %27 = OpVariable %17 Output -%28 = OpConstant %4 1.0 +%28 = OpConstant %4 1 %30 = OpTypeFunction %2 -%31 = OpConstant %4 2.0 -%32 = OpConstant %4 4.0 -%33 = OpConstant %4 5.0 -%34 = OpConstant %4 6.0 +%31 = OpConstant %4 2 +%32 = OpConstant %4 4 +%33 = OpConstant %4 5 +%34 = OpConstant %4 6 %35 = OpConstantComposite %5 %31 %32 %33 %34 %36 = OpConstant %6 8 %37 = OpConstant %6 10 -%38 = OpConstant %4 27.0 -%39 = OpConstant %4 64.0 -%40 = OpConstant %4 125.0 +%38 = OpConstant %4 27 +%39 = OpConstant %4 64 +%40 = OpConstant %4 125 %41 = OpConstantComposite %7 %39 %40 -%42 = OpConstant %4 216.0 -%43 = OpConstant %4 343.0 -%44 = OpConstant %4 512.0 +%42 = OpConstant %4 216 +%43 = OpConstant %4 343 +%44 = OpConstant %4 512 %45 = OpConstantComposite %8 %42 %43 %44 -%46 = OpConstant %4 255.0 -%47 = OpConstant %4 511.0 -%48 = OpConstant %4 1024.0 +%46 = OpConstant %4 255 +%47 = OpConstant %4 511 +%48 = OpConstant %4 1024 %49 = OpConstantComposite %8 %46 %47 %48 -%50 = OpConstant %4 729.0 -%51 = OpConstant %4 1000.0 -%52 = OpConstant %4 1331.0 -%53 = OpConstant %4 1728.0 +%50 = OpConstant %4 729 +%51 = OpConstant %4 1000 +%52 = OpConstant %4 1331 +%53 = OpConstant %4 1728 %54 = OpConstantComposite %5 %50 %51 %52 %53 -%55 = OpConstant %4 2197.0 -%56 = OpConstant %4 2744.0 -%57 = OpConstant %4 2812.0 +%55 = OpConstant %4 2197 +%56 = OpConstant %4 2744 +%57 = OpConstant %4 2812 %59 = OpTypePointer Function %9 %60 = OpConstantNull %9 %62 = OpTypePointer Function %5 diff --git a/naga/tests/out/spv/wgsl-math-functions.spvasm b/naga/tests/out/spv/wgsl-math-functions.spvasm index a85644d4548..9aba53bc248 100644 --- a/naga/tests/out/spv/wgsl-math-functions.spvasm +++ b/naga/tests/out/spv/wgsl-math-functions.spvasm @@ -33,12 +33,12 @@ OpMemberDecorate %15 1 Offset 16 %15 = OpTypeStruct %4 %6 %16 = OpTypeVector %3 3 %19 = OpTypeFunction %2 -%20 = OpConstant %3 1.0 -%21 = OpConstant %3 0.0 +%20 = OpConstant %3 1 +%21 = OpConstant %3 0 %22 = OpConstantComposite %4 %21 %21 %21 %21 %23 = OpConstant %5 -1 %24 = OpConstantComposite %6 %23 %23 %23 %23 -%25 = OpConstant %3 -1.0 +%25 = OpConstant %3 -1 %26 = OpConstantComposite %4 %25 %25 %25 %25 %27 = OpConstantNull %7 %28 = OpConstant %9 4294967295 @@ -54,7 +54,7 @@ OpMemberDecorate %15 1 Offset 16 %38 = OpConstant %9 31 %39 = OpConstantComposite %8 %38 %38 %40 = OpConstant %5 2 -%41 = OpConstant %3 2.0 +%41 = OpConstant %3 2 %42 = OpConstantComposite %10 %20 %41 %43 = OpConstant %5 3 %44 = OpConstant %5 4 diff --git a/naga/tests/out/spv/wgsl-operators.spvasm b/naga/tests/out/spv/wgsl-operators.spvasm index cf24cc8102f..9ffe1ae1ea2 100644 --- a/naga/tests/out/spv/wgsl-operators.spvasm +++ b/naga/tests/out/spv/wgsl-operators.spvasm @@ -21,9 +21,9 @@ OpDecorate %513 BuiltIn WorkgroupId %12 = OpTypeMatrix %8 4 %13 = OpTypeMatrix %4 3 %14 = OpTypeVector %5 3 -%15 = OpConstant %3 1.0 +%15 = OpConstant %3 1 %16 = OpConstantComposite %4 %15 %15 %15 %15 -%17 = OpConstant %3 0.0 +%17 = OpConstant %3 0 %18 = OpConstantComposite %4 %17 %17 %17 %17 %19 = OpConstant %3 0.5 %20 = OpConstantComposite %4 %19 %19 %19 %19 @@ -44,17 +44,17 @@ OpDecorate %513 BuiltIn WorkgroupId %60 = OpConstantComposite %6 %58 %58 %58 %58 %65 = OpConstantComposite %6 %21 %21 %21 %21 %72 = OpTypeFunction %4 %3 %5 -%73 = OpConstant %3 2.0 +%73 = OpConstant %3 2 %74 = OpConstantComposite %7 %73 %73 -%75 = OpConstant %3 4.0 +%75 = OpConstant %3 4 %76 = OpConstantComposite %7 %75 %75 -%77 = OpConstant %3 8.0 +%77 = OpConstant %3 8 %78 = OpConstantComposite %7 %77 %77 %79 = OpConstant %5 2 %80 = OpConstantComposite %6 %79 %79 %79 %79 %93 = OpTypeFunction %7 %94 = OpConstantComposite %7 %15 %15 -%95 = OpConstant %3 3.0 +%95 = OpConstant %3 3 %96 = OpConstantComposite %7 %95 %95 %98 = OpTypePointer Function %7 %110 = OpTypeFunction %8 %8 diff --git a/naga/tests/out/spv/wgsl-overrides-ray-query.main.spvasm b/naga/tests/out/spv/wgsl-overrides-ray-query.main.spvasm index 4ceae75e596..34a8df87711 100644 --- a/naga/tests/out/spv/wgsl-overrides-ray-query.main.spvasm +++ b/naga/tests/out/spv/wgsl-overrides-ray-query.main.spvasm @@ -19,24 +19,24 @@ OpDecorate %10 DescriptorSet 0 OpDecorate %10 Binding 0 %2 = OpTypeVoid %3 = OpTypeFloat 32 -%4 = OpTypeAccelerationStructureNV +%4 = OpTypeAccelerationStructureKHR %5 = OpTypeRayQueryKHR %6 = OpTypeInt 32 0 %7 = OpTypeVector %3 3 %8 = OpTypeStruct %6 %6 %3 %3 %7 %7 -%9 = OpConstant %3 2.0 +%9 = OpConstant %3 2 %11 = OpTypePointer UniformConstant %4 %10 = OpVariable %11 UniformConstant %14 = OpTypeFunction %2 %16 = OpConstant %6 4 %17 = OpConstant %6 255 -%18 = OpConstant %3 34.0 -%19 = OpConstant %3 38.0 -%20 = OpConstant %3 46.0 +%18 = OpConstant %3 34 +%19 = OpConstant %3 38 +%20 = OpConstant %3 46 %21 = OpConstantComposite %7 %20 %20 %20 -%22 = OpConstant %3 58.0 -%23 = OpConstant %3 62.0 -%24 = OpConstant %3 74.0 +%22 = OpConstant %3 58 +%23 = OpConstant %3 62 +%24 = OpConstant %3 74 %25 = OpConstantComposite %7 %22 %23 %24 %26 = OpConstantComposite %8 %16 %17 %18 %19 %21 %25 %28 = OpTypePointer Function %5 diff --git a/naga/tests/out/spv/wgsl-overrides.main.spvasm b/naga/tests/out/spv/wgsl-overrides.main.spvasm index a685272479e..3b9eaca2497 100644 --- a/naga/tests/out/spv/wgsl-overrides.main.spvasm +++ b/naga/tests/out/spv/wgsl-overrides.main.spvasm @@ -13,21 +13,21 @@ OpExecutionMode %22 LocalSize 1 1 1 %5 = OpTypeInt 32 0 %6 = OpConstantTrue %3 %7 = OpConstant %4 2.3 -%8 = OpConstant %4 0.0 +%8 = OpConstant %4 0 %9 = OpConstantFalse %3 %10 = OpConstant %4 1.1 -%11 = OpConstant %4 2.0 +%11 = OpConstant %4 2 %12 = OpConstant %4 4.6 %13 = OpConstant %4 2.718 %14 = OpConstant %5 0 -%15 = OpConstant %4 10.0 -%16 = OpConstant %4 11.0 +%15 = OpConstant %4 10 +%16 = OpConstant %4 11 %18 = OpTypePointer Private %4 %17 = OpVariable %18 Private %16 %20 = OpConstantNull %4 %19 = OpVariable %18 Private %20 %23 = OpTypeFunction %2 -%24 = OpConstant %4 23.0 +%24 = OpConstant %4 23 %26 = OpTypePointer Function %4 %28 = OpTypePointer Function %3 %29 = OpConstantNull %3 diff --git a/naga/tests/out/spv/wgsl-padding.spvasm b/naga/tests/out/spv/wgsl-padding.spvasm index 2df29c96d4b..615965cc3e4 100644 --- a/naga/tests/out/spv/wgsl-padding.spvasm +++ b/naga/tests/out/spv/wgsl-padding.spvasm @@ -107,7 +107,7 @@ OpDecorate %25 BuiltIn Position %30 = OpConstant %10 0 %32 = OpTypePointer Uniform %11 %34 = OpTypePointer Uniform %13 -%36 = OpConstant %4 1.0 +%36 = OpConstant %4 1 %37 = OpConstantComposite %14 %36 %36 %36 %36 %39 = OpTypePointer Uniform %4 %40 = OpConstant %10 1 diff --git a/naga/tests/out/spv/wgsl-pointers.spvasm b/naga/tests/out/spv/wgsl-pointers.spvasm index 779b01b8af9..08867c95384 100644 --- a/naga/tests/out/spv/wgsl-pointers.spvasm +++ b/naga/tests/out/spv/wgsl-pointers.spvasm @@ -71,7 +71,7 @@ OpDecorate %11 Binding 0 %12 = OpTypePointer StorageBuffer %9 %11 = OpVariable %12 StorageBuffer %15 = OpTypeFunction %2 -%16 = OpConstant %6 10.0 +%16 = OpConstant %6 10 %17 = OpConstantComposite %5 %16 %16 %19 = OpTypePointer Function %4 %20 = OpConstantNull %4 diff --git a/naga/tests/out/spv/wgsl-policy-mix.spvasm b/naga/tests/out/spv/wgsl-policy-mix.spvasm index 28e8d92226f..8d9209d7b35 100644 --- a/naga/tests/out/spv/wgsl-policy-mix.spvasm +++ b/naga/tests/out/spv/wgsl-policy-mix.spvasm @@ -120,8 +120,8 @@ OpDecorate %115 BuiltIn LocalInvocationId %42 = OpConstant %8 0 %44 = OpTypePointer Uniform %12 %47 = OpConstant %4 0.707 -%48 = OpConstant %4 0.0 -%49 = OpConstant %4 1.0 +%48 = OpConstant %4 0 +%49 = OpConstant %4 1 %50 = OpConstantComposite %5 %47 %48 %48 %49 %51 = OpConstantComposite %5 %48 %47 %48 %49 %52 = OpConstantComposite %20 %50 %51 diff --git a/naga/tests/out/spv/wgsl-quad.spvasm b/naga/tests/out/spv/wgsl-quad.spvasm index a3532fb16e0..307fa304926 100644 --- a/naga/tests/out/spv/wgsl-quad.spvasm +++ b/naga/tests/out/spv/wgsl-quad.spvasm @@ -97,8 +97,8 @@ OpDecorate %60 Location 0 %24 = OpTypePointer Output %6 %23 = OpVariable %24 Output %26 = OpTypeFunction %2 -%27 = OpConstant %4 0.0 -%28 = OpConstant %4 1.0 +%27 = OpConstant %4 0 +%28 = OpConstant %4 1 %35 = OpTypePointer Output %4 %37 = OpTypeInt 32 0 %36 = OpConstant %37 1 diff --git a/naga/tests/out/spv/wgsl-ray-query.spvasm b/naga/tests/out/spv/wgsl-ray-query.spvasm index 138efe2c352..d49ae40b2f8 100644 --- a/naga/tests/out/spv/wgsl-ray-query.spvasm +++ b/naga/tests/out/spv/wgsl-ray-query.spvasm @@ -43,7 +43,7 @@ OpMemberDecorate %18 0 Offset 0 %2 = OpTypeVoid %3 = OpTypeFloat 32 %4 = OpTypeVector %3 3 -%5 = OpTypeAccelerationStructureNV +%5 = OpTypeAccelerationStructureKHR %6 = OpTypeInt 32 0 %7 = OpTypeVector %3 2 %8 = OpTypeBool @@ -62,7 +62,7 @@ OpMemberDecorate %18 0 Offset 0 %27 = OpConstant %6 4 %28 = OpConstant %6 255 %29 = OpConstant %3 0.1 -%30 = OpConstant %3 100.0 +%30 = OpConstant %3 100 %32 = OpTypePointer Function %11 %45 = OpTypeVector %6 2 %46 = OpTypePointer Function %45 @@ -89,9 +89,9 @@ OpMemberDecorate %18 0 Offset 0 %113 = OpConstant %6 7 %115 = OpConstant %6 8 %123 = OpTypeFunction %4 %4 %10 -%124 = OpConstant %3 1.0 +%124 = OpConstant %3 1 %125 = OpConstant %3 2.4 -%126 = OpConstant %3 0.0 +%126 = OpConstant %3 0 %141 = OpTypeFunction %2 %143 = OpTypePointer StorageBuffer %13 %145 = OpConstantComposite %4 %126 %126 %126 @@ -99,7 +99,7 @@ OpMemberDecorate %18 0 Offset 0 %149 = OpTypePointer StorageBuffer %6 %154 = OpTypePointer StorageBuffer %4 %162 = OpConstantComposite %12 %27 %28 %29 %30 %145 %146 -%163 = OpConstant %3 10.0 +%163 = OpConstant %3 10 %76 = OpFunction %10 None %75 %78 = OpFunctionParameter %32 %79 = OpLabel diff --git a/naga/tests/out/spv/wgsl-select.spvasm b/naga/tests/out/spv/wgsl-select.spvasm index d0011c464f8..9725ab38beb 100644 --- a/naga/tests/out/spv/wgsl-select.spvasm +++ b/naga/tests/out/spv/wgsl-select.spvasm @@ -13,11 +13,11 @@ OpExecutionMode %8 LocalSize 1 1 1 %6 = OpTypeInt 32 1 %5 = OpTypeVector %6 2 %9 = OpTypeFunction %2 -%10 = OpConstant %4 1.0 +%10 = OpConstant %4 1 %11 = OpConstant %6 1 %12 = OpConstant %6 2 %13 = OpConstantComposite %5 %11 %12 -%14 = OpConstant %4 0.0 +%14 = OpConstant %4 0 %15 = OpConstantComposite %3 %10 %14 %16 = OpConstantComposite %3 %14 %10 %18 = OpTypePointer Function %5 diff --git a/naga/tests/out/spv/wgsl-separate-entry-points.fragment.spvasm b/naga/tests/out/spv/wgsl-separate-entry-points.fragment.spvasm index e29ce8f15db..ae58bae874f 100644 --- a/naga/tests/out/spv/wgsl-separate-entry-points.fragment.spvasm +++ b/naga/tests/out/spv/wgsl-separate-entry-points.fragment.spvasm @@ -12,7 +12,7 @@ OpDecorate %14 Location 0 %4 = OpTypeFloat 32 %3 = OpTypeVector %4 4 %7 = OpTypeFunction %2 -%8 = OpConstant %4 0.0 +%8 = OpConstant %4 0 %15 = OpTypePointer Output %3 %14 = OpVariable %15 Output %17 = OpConstantNull %3 diff --git a/naga/tests/out/spv/wgsl-shadow.spvasm b/naga/tests/out/spv/wgsl-shadow.spvasm index ea131ae6d03..1360528131a 100644 --- a/naga/tests/out/spv/wgsl-shadow.spvasm +++ b/naga/tests/out/spv/wgsl-shadow.spvasm @@ -267,8 +267,8 @@ OpDecorate %227 Location 0 %40 = OpTypePointer UniformConstant %21 %39 = OpVariable %40 UniformConstant %45 = OpTypeFunction %4 %7 %6 -%48 = OpConstant %4 0.0 -%49 = OpConstant %4 1.0 +%48 = OpConstant %4 0 +%49 = OpConstant %4 1 %50 = OpConstant %4 0.5 %51 = OpConstant %4 -0.5 %52 = OpConstantComposite %22 %50 %51 diff --git a/naga/tests/out/spv/wgsl-skybox.spvasm b/naga/tests/out/spv/wgsl-skybox.spvasm index 7bc7b30f6da..f3e4be2cc22 100644 --- a/naga/tests/out/spv/wgsl-skybox.spvasm +++ b/naga/tests/out/spv/wgsl-skybox.spvasm @@ -65,9 +65,9 @@ OpDecorate %105 Location 0 %48 = OpTypePointer Uniform %8 %49 = OpConstant %9 0 %51 = OpConstant %10 2 -%52 = OpConstant %4 4.0 -%53 = OpConstant %4 1.0 -%54 = OpConstant %4 0.0 +%52 = OpConstant %4 4 +%53 = OpConstant %4 1 +%54 = OpConstant %4 0 %56 = OpTypePointer Function %10 %57 = OpConstantNull %10 %59 = OpConstantNull %10 diff --git a/naga/tests/out/spv/wgsl-storage-textures.spvasm b/naga/tests/out/spv/wgsl-storage-textures.spvasm index c043c2b94e2..167d5f49299 100644 --- a/naga/tests/out/spv/wgsl-storage-textures.spvasm +++ b/naga/tests/out/spv/wgsl-storage-textures.spvasm @@ -48,7 +48,7 @@ OpDecorate %15 Binding 2 %24 = OpTypeVector %22 2 %25 = OpConstantComposite %24 %23 %23 %27 = OpTypeVector %4 4 -%36 = OpConstant %4 0.0 +%36 = OpConstant %4 0 %37 = OpConstantComposite %27 %36 %36 %36 %36 %17 = OpFunction %2 None %18 %16 = OpLabel diff --git a/naga/tests/out/spv/wgsl-struct-layout.spvasm b/naga/tests/out/spv/wgsl-struct-layout.spvasm index 42899de9b58..31611dad6a9 100644 --- a/naga/tests/out/spv/wgsl-struct-layout.spvasm +++ b/naga/tests/out/spv/wgsl-struct-layout.spvasm @@ -76,7 +76,7 @@ OpDecorate %77 BuiltIn Position %29 = OpTypePointer Output %6 %28 = OpVariable %29 Output %31 = OpTypeFunction %2 -%32 = OpConstant %3 0.0 +%32 = OpConstant %3 0 %33 = OpConstantComposite %6 %32 %32 %32 %32 %37 = OpVariable %23 Input %39 = OpVariable %26 Input diff --git a/naga/tests/out/spv/wgsl-texture-arg.spvasm b/naga/tests/out/spv/wgsl-texture-arg.spvasm index ebb110e8fd8..23bd0ce2977 100644 --- a/naga/tests/out/spv/wgsl-texture-arg.spvasm +++ b/naga/tests/out/spv/wgsl-texture-arg.spvasm @@ -44,7 +44,7 @@ OpDecorate %27 Location 0 %12 = OpTypePointer UniformConstant %6 %11 = OpVariable %12 UniformConstant %19 = OpTypeFunction %7 %10 %12 -%20 = OpConstant %5 0.0 +%20 = OpConstant %5 0 %21 = OpConstantComposite %8 %20 %20 %23 = OpTypeSampledImage %4 %28 = OpTypePointer Output %7 diff --git a/naga/tests/out/spv/wgsl-type-inference.spvasm b/naga/tests/out/spv/wgsl-type-inference.spvasm index adcaa8094e6..d56e1fdac6b 100644 --- a/naga/tests/out/spv/wgsl-type-inference.spvasm +++ b/naga/tests/out/spv/wgsl-type-inference.spvasm @@ -15,11 +15,11 @@ OpExecutionMode %18 LocalSize 1 1 1 %8 = OpTypeVector %4 2 %7 = OpTypeMatrix %8 2 %9 = OpConstant %3 1 -%10 = OpConstant %4 1.0 +%10 = OpConstant %4 1 %11 = OpConstantNull %6 %12 = OpConstant %5 1 %13 = OpConstantComposite %6 %12 %12 %12 %12 -%14 = OpConstant %4 0.0 +%14 = OpConstant %4 0 %15 = OpConstantComposite %8 %14 %14 %16 = OpConstantComposite %7 %15 %15 %19 = OpTypeFunction %2 From c9c7a637efe45b4b63c094168435eeca5c0d375d Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Mon, 14 Jul 2025 12:55:51 -0500 Subject: [PATCH 59/84] Updated snapshots --- naga/tests/out/analysis/wgsl-access.info.ron | 76 +++++++ naga/tests/out/spv/wgsl-mesh-shader.spvasm | 213 +++++++++++++++++++ 2 files changed, 289 insertions(+) create mode 100644 naga/tests/out/spv/wgsl-mesh-shader.spvasm diff --git a/naga/tests/out/analysis/wgsl-access.info.ron b/naga/tests/out/analysis/wgsl-access.info.ron index c22cd768f2e..d297b09a404 100644 --- a/naga/tests/out/analysis/wgsl-access.info.ron +++ b/naga/tests/out/analysis/wgsl-access.info.ron @@ -1197,6 +1197,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), @@ -2523,6 +2527,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), @@ -2563,6 +2571,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), @@ -2612,6 +2624,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), @@ -2655,6 +2671,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), @@ -2749,6 +2769,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), @@ -2870,6 +2894,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), @@ -2922,6 +2950,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), @@ -2977,6 +3009,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), @@ -3029,6 +3065,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), @@ -3084,6 +3124,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), @@ -3148,6 +3192,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), @@ -3221,6 +3269,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), @@ -3297,6 +3349,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), @@ -3397,6 +3453,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), @@ -3593,6 +3653,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ], entry_points: [ @@ -4290,6 +4354,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), @@ -4742,6 +4810,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), @@ -4812,6 +4884,10 @@ sampling: [], dual_source_blending: false, diagnostic_filter_leaf: None, + mesh_shader_info: ( + vertex_type: None, + primitive_type: None, + ), ), ], const_expression_types: [ diff --git a/naga/tests/out/spv/wgsl-mesh-shader.spvasm b/naga/tests/out/spv/wgsl-mesh-shader.spvasm new file mode 100644 index 00000000000..80d4813e439 --- /dev/null +++ b/naga/tests/out/spv/wgsl-mesh-shader.spvasm @@ -0,0 +1,213 @@ +; SPIR-V +; Version: 1.4 +; Generator: rspirv +; Bound: 142 +OpCapability Shader +OpCapability MeshShadingEXT +OpExtension "SPV_EXT_mesh_shader" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint TaskEXT %17 "ts_main" %12 %14 +OpEntryPoint MeshEXT %59 "ms_main" %36 %39 %12 %44 %47 %51 %54 %57 %14 +OpEntryPoint Fragment %137 "fs_main" %128 %131 %134 %136 +OpExecutionMode %17 LocalSize 1 1 1 +OpExecutionMode %59 LocalSize 1 1 1 +OpExecutionMode %59 OutputTrianglesNV +OpExecutionMode %59 OutputVertices 3 +OpExecutionMode %59 OutputPrimitivesNV 1 +OpExecutionMode %137 OriginUpperLeft +OpMemberDecorate %6 0 Offset 0 +OpMemberDecorate %6 1 Offset 16 +OpMemberDecorate %7 0 Offset 0 +OpMemberDecorate %7 1 Offset 16 +OpMemberDecorate %10 0 Offset 0 +OpMemberDecorate %10 1 Offset 12 +OpMemberDecorate %10 2 Offset 16 +OpMemberDecorate %11 0 Offset 0 +OpDecorate %36 BuiltIn LocalInvocationIndex +OpDecorate %39 BuiltIn GlobalInvocationId +OpDecorate %44 BuiltIn Position +OpDecorate %47 Location 0 +OpDecorate %51 PerPrimitiveNV +OpDecorate %51 BuiltIn PrimitiveTriangleIndicesEXT +OpDecorate %54 PerPrimitiveNV +OpDecorate %54 BuiltIn CullPrimitiveEXT +OpDecorate %57 PerPrimitiveNV +OpDecorate %57 Location 1 +OpDecorate %128 BuiltIn FragCoord +OpDecorate %131 Location 0 +OpDecorate %134 Location 1 +OpDecorate %136 Location 0 +%2 = OpTypeVoid +%3 = OpTypeFloat 32 +%4 = OpTypeVector %3 4 +%5 = OpTypeBool +%6 = OpTypeStruct %4 %5 +%7 = OpTypeStruct %4 %4 +%8 = OpTypeInt 32 0 +%9 = OpTypeVector %8 3 +%10 = OpTypeStruct %9 %5 %4 +%11 = OpTypeStruct %4 +%13 = OpTypePointer TaskPayloadWorkgroupEXT %6 +%12 = OpVariable %13 TaskPayloadWorkgroupEXT +%15 = OpTypePointer Workgroup %3 +%14 = OpVariable %15 Workgroup +%18 = OpTypeFunction %2 +%19 = OpConstant %3 1 +%20 = OpConstant %3 0 +%21 = OpConstantComposite %4 %19 %19 %20 %19 +%22 = OpConstantTrue %5 +%23 = OpConstant %8 3 +%24 = OpConstant %8 1 +%25 = OpConstantComposite %9 %23 %24 %24 +%27 = OpTypePointer TaskPayloadWorkgroupEXT %4 +%28 = OpConstant %8 0 +%30 = OpTypePointer TaskPayloadWorkgroupEXT %5 +%37 = OpTypePointer Input %8 +%36 = OpVariable %37 Input +%40 = OpTypePointer Input %9 +%39 = OpVariable %40 Input +%42 = OpConstant %8 3 +%43 = OpTypeArray %4 %42 +%45 = OpTypePointer Output %43 +%44 = OpVariable %45 Output +%46 = OpTypeArray %4 %42 +%48 = OpTypePointer Output %46 +%47 = OpVariable %48 Output +%49 = OpConstant %8 1 +%50 = OpTypeArray %9 %49 +%52 = OpTypePointer Output %50 +%51 = OpVariable %52 Output +%53 = OpTypeArray %5 %49 +%55 = OpTypePointer Output %53 +%54 = OpVariable %55 Output +%56 = OpTypeArray %4 %49 +%58 = OpTypePointer Output %56 +%57 = OpVariable %58 Output +%60 = OpConstant %3 2 +%61 = OpConstant %3 -1 +%62 = OpConstantComposite %4 %20 %61 %20 %19 +%63 = OpConstantComposite %4 %20 %19 %20 %19 +%64 = OpConstantComposite %4 %61 %19 %20 %19 +%65 = OpConstantComposite %4 %20 %20 %19 %19 +%66 = OpConstantComposite %4 %19 %20 %20 %19 +%67 = OpConstant %8 2 +%68 = OpConstantComposite %9 %28 %24 %67 +%69 = OpConstantComposite %4 %19 %20 %19 %19 +%71 = OpTypePointer Function %7 +%72 = OpConstantNull %7 +%74 = OpTypePointer Function %10 +%75 = OpConstantNull %10 +%77 = OpTypePointer Function %4 +%86 = OpTypePointer Output %4 +%109 = OpTypePointer Function %9 +%111 = OpTypePointer Function %5 +%120 = OpTypePointer Output %9 +%123 = OpTypePointer Output %5 +%129 = OpTypePointer Input %4 +%128 = OpVariable %129 Input +%131 = OpVariable %129 Input +%134 = OpVariable %129 Input +%136 = OpVariable %86 Output +%17 = OpFunction %2 None %18 +%16 = OpLabel +OpBranch %26 +%26 = OpLabel +OpStore %14 %19 +%29 = OpAccessChain %27 %12 %28 +OpStore %29 %21 +%31 = OpAccessChain %30 %12 %24 +OpStore %31 %22 +%32 = OpCompositeExtract %8 %25 0 +%33 = OpCompositeExtract %8 %25 1 +%34 = OpCompositeExtract %8 %25 2 +OpEmitMeshTasksEXT %32 %33 %34 %12 +OpFunctionEnd +%59 = OpFunction %2 None %18 +%35 = OpLabel +%70 = OpVariable %71 Function %72 +%73 = OpVariable %74 Function %75 +%38 = OpLoad %8 %36 +%41 = OpLoad %9 %39 +OpBranch %76 +%76 = OpLabel +OpSetMeshOutputsEXT %23 %24 +OpStore %14 %60 +%78 = OpAccessChain %77 %70 %28 +OpStore %78 %62 +%79 = OpAccessChain %27 %12 %28 +%80 = OpLoad %4 %79 +%81 = OpFMul %4 %63 %80 +%82 = OpAccessChain %77 %70 %24 +OpStore %82 %81 +%83 = OpLoad %7 %70 +%84 = OpCompositeExtract %4 %83 0 +%85 = OpAccessChain %86 %44 %28 +OpStore %85 %84 +%87 = OpCompositeExtract %4 %83 1 +%88 = OpAccessChain %86 %47 %28 +OpStore %88 %87 +%89 = OpAccessChain %77 %70 %28 +OpStore %89 %64 +%90 = OpAccessChain %27 %12 %28 +%91 = OpLoad %4 %90 +%92 = OpFMul %4 %65 %91 +%93 = OpAccessChain %77 %70 %24 +OpStore %93 %92 +%94 = OpLoad %7 %70 +%95 = OpCompositeExtract %4 %94 0 +%96 = OpAccessChain %86 %44 %24 +OpStore %96 %95 +%97 = OpCompositeExtract %4 %94 1 +%98 = OpAccessChain %86 %47 %24 +OpStore %98 %97 +%99 = OpAccessChain %77 %70 %28 +OpStore %99 %21 +%100 = OpAccessChain %27 %12 %28 +%101 = OpLoad %4 %100 +%102 = OpFMul %4 %66 %101 +%103 = OpAccessChain %77 %70 %24 +OpStore %103 %102 +%104 = OpLoad %7 %70 +%105 = OpCompositeExtract %4 %104 0 +%106 = OpAccessChain %86 %44 %67 +OpStore %106 %105 +%107 = OpCompositeExtract %4 %104 1 +%108 = OpAccessChain %86 %47 %67 +OpStore %108 %107 +%110 = OpAccessChain %109 %73 %28 +OpStore %110 %68 +%112 = OpAccessChain %30 %12 %24 +%113 = OpLoad %5 %112 +%114 = OpLogicalNot %5 %113 +%115 = OpAccessChain %111 %73 %24 +OpStore %115 %114 +%116 = OpAccessChain %77 %73 %67 +OpStore %116 %69 +%117 = OpLoad %10 %73 +%118 = OpCompositeExtract %9 %117 0 +%119 = OpAccessChain %120 %51 %28 +OpStore %119 %118 +%121 = OpCompositeExtract %5 %117 1 +%122 = OpAccessChain %123 %54 %28 +OpStore %122 %121 +%124 = OpCompositeExtract %4 %117 2 +%125 = OpAccessChain %86 %57 %28 +OpStore %125 %124 +OpReturn +OpFunctionEnd +%137 = OpFunction %2 None %18 +%126 = OpLabel +%130 = OpLoad %4 %128 +%132 = OpLoad %4 %131 +%127 = OpCompositeConstruct %7 %130 %132 +%135 = OpLoad %4 %134 +%133 = OpCompositeConstruct %11 %135 +OpBranch %138 +%138 = OpLabel +%139 = OpCompositeExtract %4 %127 1 +%140 = OpCompositeExtract %4 %133 0 +%141 = OpFMul %4 %139 %140 +OpStore %136 %141 +OpReturn +OpFunctionEnd \ No newline at end of file From 65c40a4f3231731eb8325ab695b02e6eca7fed4f Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Mon, 14 Jul 2025 13:03:25 -0500 Subject: [PATCH 60/84] Reformatted the config toml --- naga/tests/in/wgsl/mesh-shader.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/naga/tests/in/wgsl/mesh-shader.toml b/naga/tests/in/wgsl/mesh-shader.toml index a7780afbc21..1f02c781b5d 100644 --- a/naga/tests/in/wgsl/mesh-shader.toml +++ b/naga/tests/in/wgsl/mesh-shader.toml @@ -16,4 +16,4 @@ zero_initialize_workgroup_memory = true [spv] version = [1, 4] -capabilities = ["MeshShadingEXT"] \ No newline at end of file +capabilities = ["MeshShadingEXT"] From cef16062609b71667d313b9d74ebdf5a9bccdc41 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Mon, 14 Jul 2025 14:42:21 -0500 Subject: [PATCH 61/84] Implemented coordinate flipping --- naga/src/back/spv/block.rs | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 3521ab2738d..2efa8dc175c 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -3722,6 +3722,51 @@ impl BlockContext<'_> { block .body .push(Instruction::store(out_ptr_id, in_value_id, None)); + + // Coordinate flip + if self + .writer + .flags + .contains(WriterFlags::ADJUST_COORDINATE_SPACE) + && matches!( + member_info.member.binding, + Some(crate::Binding::BuiltIn(crate::BuiltIn::Position { .. })) + ) + { + let float_ptr_type_id = self + .writer + .get_f32_pointer_type_id(spirv::StorageClass::Output); + let index_y_id = self.get_index_constant(1); + + let access_id = self.gen_id(); + block.body.push(Instruction::access_chain( + float_ptr_type_id, + access_id, + out_ptr_id, + &[index_y_id], + )); + + let float_type_id = self.writer.get_f32_type_id(); + let y_val = self.gen_id(); + block.body.push(Instruction::composite_extract( + float_type_id, + y_val, + in_value_id, + &[1], + )); + + let flipped_y_val = self.gen_id(); + block.body.push(Instruction::unary( + spirv::Op::FNegate, + float_type_id, + flipped_y_val, + y_val, + )); + + block + .body + .push(Instruction::store(access_id, flipped_y_val, None)); + } } } Statement::SubgroupBallot { From 657719744d3c421667fff12a9c781bc79b8b82fc Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Sat, 9 Aug 2025 00:37:34 -0500 Subject: [PATCH 62/84] Updated shader test outputs --- naga/tests/out/ir/wgsl-mesh-shader.compact.ron | 2 ++ naga/tests/out/ir/wgsl-mesh-shader.ron | 2 ++ naga/tests/out/ir/wgsl-texture-external.compact.ron | 6 ++++++ naga/tests/out/ir/wgsl-texture-external.ron | 6 ++++++ 4 files changed, 16 insertions(+) diff --git a/naga/tests/out/ir/wgsl-mesh-shader.compact.ron b/naga/tests/out/ir/wgsl-mesh-shader.compact.ron index 5e320aa3895..77bbb8f9412 100644 --- a/naga/tests/out/ir/wgsl-mesh-shader.compact.ron +++ b/naga/tests/out/ir/wgsl-mesh-shader.compact.ron @@ -143,6 +143,8 @@ ray_desc: None, ray_intersection: None, ray_vertex_return: None, + external_texture_params: None, + external_texture_transfer_function: None, predeclared_types: {}, ), constants: [], diff --git a/naga/tests/out/ir/wgsl-mesh-shader.ron b/naga/tests/out/ir/wgsl-mesh-shader.ron index 5e320aa3895..77bbb8f9412 100644 --- a/naga/tests/out/ir/wgsl-mesh-shader.ron +++ b/naga/tests/out/ir/wgsl-mesh-shader.ron @@ -143,6 +143,8 @@ ray_desc: None, ray_intersection: None, ray_vertex_return: None, + external_texture_params: None, + external_texture_transfer_function: None, predeclared_types: {}, ), constants: [], diff --git a/naga/tests/out/ir/wgsl-texture-external.compact.ron b/naga/tests/out/ir/wgsl-texture-external.compact.ron index dbffbddcdc7..a544447f100 100644 --- a/naga/tests/out/ir/wgsl-texture-external.compact.ron +++ b/naga/tests/out/ir/wgsl-texture-external.compact.ron @@ -382,6 +382,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ( name: "vertex_main", @@ -418,6 +420,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ( name: "compute_main", @@ -449,6 +453,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], diff --git a/naga/tests/out/ir/wgsl-texture-external.ron b/naga/tests/out/ir/wgsl-texture-external.ron index dbffbddcdc7..a544447f100 100644 --- a/naga/tests/out/ir/wgsl-texture-external.ron +++ b/naga/tests/out/ir/wgsl-texture-external.ron @@ -382,6 +382,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ( name: "vertex_main", @@ -418,6 +420,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ( name: "compute_main", @@ -449,6 +453,8 @@ ], diagnostic_filter_leaf: None, ), + mesh_info: None, + task_payload: None, ), ], diagnostic_filters: [], From 825a0607109c8c5f62f1b41fe11d03946fd4f686 Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Sat, 9 Aug 2025 02:12:50 -0500 Subject: [PATCH 63/84] Added per primitive stuff --- docs/api-specs/mesh_shading.md | 10 +-- naga/src/back/glsl/features.rs | 1 + naga/src/back/glsl/mod.rs | 2 + naga/src/back/msl/mod.rs | 1 + naga/src/back/spv/helpers.rs | 2 +- naga/src/back/spv/writer.rs | 8 +-- naga/src/back/wgsl/writer.rs | 2 + naga/src/front/glsl/functions.rs | 2 + naga/src/front/glsl/variables.rs | 1 + naga/src/front/interpolator.rs | 1 + naga/src/front/spv/mod.rs | 1 + naga/src/front/wgsl/lower/mod.rs | 2 + naga/src/front/wgsl/parse/ast.rs | 1 + naga/src/front/wgsl/parse/mod.rs | 16 +++-- naga/src/ir/mod.rs | 1 + naga/src/valid/interface.rs | 96 +++++++++++++++++++++++------ naga/tests/in/wgsl/mesh-shader.wgsl | 4 +- 17 files changed, 116 insertions(+), 35 deletions(-) diff --git a/docs/api-specs/mesh_shading.md b/docs/api-specs/mesh_shading.md index 4e8042f2176..9826c0550ca 100644 --- a/docs/api-specs/mesh_shading.md +++ b/docs/api-specs/mesh_shading.md @@ -95,13 +95,13 @@ Mesh shaders must also be marked with `@primitive_output(OutputType, numOutputs) Vertex outputs from mesh shaders function identically to outputs of vertex shaders, and as such must have a field with `@builtin(position)`. -Primitive outputs from mesh shaders have some additional builtins they can set. These include `@builtin(cull_primitive)`, which must be a boolean value. If this is set to true, then the primitive is skipped during rendering. +Primitive outputs from mesh shaders have some additional builtins they can set. These include `@builtin(cull_primitive)`, which must be a boolean value. If this is set to true, then the primitive is skipped during rendering. All non-builtin primitive outputs must be decorated with `@per_primitive`. Mesh shader primitive outputs must also specify exactly one of `@builtin(triangle_indices)`, `@builtin(line_indices)`, or `@builtin(point_index)`. This determines the output topology of the mesh shader, and must match the output topology of the pipeline descriptor the mesh shader is used with. These must be of type `vec3`, `vec2`, and `u32` respectively. When setting this, each of the indices must be less than the number of vertices declared in `setMeshOutputs`. Additionally, the `@location` attributes from the vertex and primitive outputs can't overlap. -Before setting any vertices or indices, or exiting, the mesh shader must call `setMeshOutputs(numVertices: u32, numIndices: u32)`, which declares the number of vertices and indices that will be written to. These must be less than the corresponding maximums set in `@vertex_output` and `@primitive_output`. The mesh shader must then write to exactly these numbers of vertices and primitives. +Before setting any vertices or indices, or exiting, the mesh shader must call `setMeshOutputs(numVertices: u32, numIndices: u32)`, which declares the number of vertices and indices that will be written to. These must be less than the corresponding maximums set in `@vertex_output` and `@primitive_output`. The mesh shader must then write to exactly these numbers of vertices and primitives. A varying member with `@per_primitive` cannot be used in function interfaces except as the primitive output for mesh shaders or as input for fragment shaders. The mesh shader can write to vertices using the `setVertex(idx: u32, vertex: VertexOutput)` where `VertexOutput` is replaced with the vertex type declared in `@vertex_output`, and `idx` is the index of the vertex to write. Similarly, the mesh shader can write to vertices using `setPrimitive(idx: u32, primitive: PrimitiveOutput)`. These can be written to multiple times, however unsynchronized writes are undefined behavior. The primitives and indices are shared across the entire mesh shader workgroup. @@ -109,7 +109,7 @@ The mesh shader can write to vertices using the `setVertex(idx: u32, vertex: Ver Fragment shaders can access vertex output data as if it is from a vertex shader. They can also access primitive output data, provided the input is decorated with `@per_primitive`. The `@per_primitive` attribute can be applied to a value directly, such as `@per_primitive @location(1) value: vec4`, to a struct such as `@per_primitive primitive_input: PrimitiveInput` where `PrimitiveInput` is a struct containing fields decorated with `@location` and `@builtin`, or to members of a struct that are themselves decorated with `@location` or `@builtin`. -The primitive state is part of the fragment input and must match the output of the mesh shader in the pipeline. Using `@per_primitive` also requires enabling the mesh shader extension. +The primitive state is part of the fragment input and must match the output of the mesh shader in the pipeline. Using `@per_primitive` also requires enabling the mesh shader extension. Additionally, the locations of vertex and primitive input cannot overlap. ### Full example @@ -141,7 +141,7 @@ struct VertexOutput { struct PrimitiveOutput { @builtin(triangle_indices) index: vec3, @builtin(cull_primitive) cull: bool, - @location(1) colorMask: vec4, + @per_primitive @location(1) colorMask: vec4, } struct PrimitiveInput { @location(1) colorMask: vec4, @@ -184,7 +184,7 @@ fn ms_main(@builtin(local_invocation_index) index: u32, @builtin(global_invocati setPrimitive(0, p); } @fragment -fn fs_main(vertex: VertexOutput, @per_primitive primitive: PrimitiveInput) -> @location(0) vec4 { +fn fs_main(vertex: VertexOutput, primitive: PrimitiveInput) -> @location(0) vec4 { return vertex.color * primitive.colorMask; } ``` \ No newline at end of file diff --git a/naga/src/back/glsl/features.rs b/naga/src/back/glsl/features.rs index a6dfe4e3100..b884f08ac39 100644 --- a/naga/src/back/glsl/features.rs +++ b/naga/src/back/glsl/features.rs @@ -610,6 +610,7 @@ impl Writer<'_, W> { interpolation, sampling, blend_src, + per_primitive: _, } => { if interpolation == Some(Interpolation::Linear) { self.features.request(Features::NOPERSPECTIVE_QUALIFIER); diff --git a/naga/src/back/glsl/mod.rs b/naga/src/back/glsl/mod.rs index 9f6c43a3119..1af18528944 100644 --- a/naga/src/back/glsl/mod.rs +++ b/naga/src/back/glsl/mod.rs @@ -1618,6 +1618,7 @@ impl<'a, W: Write> Writer<'a, W> { interpolation, sampling, blend_src, + per_primitive: _, } => (location, interpolation, sampling, blend_src), crate::Binding::BuiltIn(built_in) => { match built_in { @@ -1736,6 +1737,7 @@ impl<'a, W: Write> Writer<'a, W> { interpolation: None, sampling: None, blend_src, + per_primitive: false, }, stage: self.entry_point.stage, options: VaryingOptions::from_writer_options(self.options, output), diff --git a/naga/src/back/msl/mod.rs b/naga/src/back/msl/mod.rs index 5acc26c1ec6..8a2e07635b8 100644 --- a/naga/src/back/msl/mod.rs +++ b/naga/src/back/msl/mod.rs @@ -494,6 +494,7 @@ impl Options { interpolation, sampling, blend_src, + per_primitive: _, } => match mode { LocationMode::VertexInput => Ok(ResolvedBinding::Attribute(location)), LocationMode::FragmentOutput => { diff --git a/naga/src/back/spv/helpers.rs b/naga/src/back/spv/helpers.rs index 73c9e6eb187..48dc7550ec6 100644 --- a/naga/src/back/spv/helpers.rs +++ b/naga/src/back/spv/helpers.rs @@ -160,7 +160,7 @@ pub enum BindingDecorations { BuiltIn(spirv::BuiltIn, ArrayVec), Location { location: Word, - others: ArrayVec, + others: ArrayVec, /// If this is `Some`, use Decoration::Index with blend_src as an operand blend_src: Option, }, diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index fd0da37c6fa..23ea7461d9b 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -2125,6 +2125,7 @@ impl Writer { interpolation, sampling, blend_src, + per_primitive, } => { let mut others = ArrayVec::new(); @@ -2169,6 +2170,9 @@ impl Writer { } } } + if per_primitive { + others.push(Decoration::PerPrimitiveEXT); + } Ok(BindingDecorations::Location { location, others, @@ -2373,10 +2377,6 @@ impl Writer { ) .to_words(&mut self.logical_layout.declarations); - if is_primitive { - self.decorate(var_id, spirv::Decoration::PerPrimitiveEXT, &[]); - } - let binding = self.map_binding( ir_module, crate::ShaderStage::Mesh, diff --git a/naga/src/back/wgsl/writer.rs b/naga/src/back/wgsl/writer.rs index f23a083ef36..245bc40dd5d 100644 --- a/naga/src/back/wgsl/writer.rs +++ b/naga/src/back/wgsl/writer.rs @@ -1823,6 +1823,7 @@ fn map_binding_to_attribute(binding: &crate::Binding) -> Vec { interpolation, sampling, blend_src: None, + per_primitive: _, } => vec![ Attribute::Location(location), Attribute::Interpolate(interpolation, sampling), @@ -1832,6 +1833,7 @@ fn map_binding_to_attribute(binding: &crate::Binding) -> Vec { interpolation, sampling, blend_src: Some(blend_src), + per_primitive: _, } => vec![ Attribute::Location(location), Attribute::BlendSrc(blend_src), diff --git a/naga/src/front/glsl/functions.rs b/naga/src/front/glsl/functions.rs index e4177e43c0e..ba096a82b3b 100644 --- a/naga/src/front/glsl/functions.rs +++ b/naga/src/front/glsl/functions.rs @@ -1448,6 +1448,7 @@ impl Context<'_> { interpolation, sampling: None, blend_src: None, + per_primitive: false, }; location += 1; @@ -1484,6 +1485,7 @@ impl Context<'_> { interpolation, sampling: None, blend_src: None, + per_primitive: false, }; location += 1; binding diff --git a/naga/src/front/glsl/variables.rs b/naga/src/front/glsl/variables.rs index ef98143b769..98871bd2f81 100644 --- a/naga/src/front/glsl/variables.rs +++ b/naga/src/front/glsl/variables.rs @@ -465,6 +465,7 @@ impl Frontend { interpolation, sampling, blend_src, + per_primitive: false, }, handle, storage, diff --git a/naga/src/front/interpolator.rs b/naga/src/front/interpolator.rs index e23cae0e7c2..126e860426c 100644 --- a/naga/src/front/interpolator.rs +++ b/naga/src/front/interpolator.rs @@ -44,6 +44,7 @@ impl crate::Binding { interpolation: ref mut interpolation @ None, ref mut sampling, blend_src: _, + per_primitive: _, } = *self { match ty.scalar_kind() { diff --git a/naga/src/front/spv/mod.rs b/naga/src/front/spv/mod.rs index 74eb381451c..396318f14dc 100644 --- a/naga/src/front/spv/mod.rs +++ b/naga/src/front/spv/mod.rs @@ -263,6 +263,7 @@ impl Decoration { interpolation, sampling, blend_src: None, + per_primitive: false, }), _ => Err(Error::MissingDecoration(spirv::Decoration::Location)), } diff --git a/naga/src/front/wgsl/lower/mod.rs b/naga/src/front/wgsl/lower/mod.rs index fbefe3ec2d7..066981418b6 100644 --- a/naga/src/front/wgsl/lower/mod.rs +++ b/naga/src/front/wgsl/lower/mod.rs @@ -4213,6 +4213,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { interpolation, sampling, blend_src, + per_primitive, }) => { let blend_src = if let Some(blend_src) = blend_src { Some(self.const_u32(blend_src, &mut ctx.as_const())?.0) @@ -4225,6 +4226,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { interpolation, sampling, blend_src, + per_primitive, }; binding.apply_default_interpolation(&ctx.module.types[ty].inner); Some(binding) diff --git a/naga/src/front/wgsl/parse/ast.rs b/naga/src/front/wgsl/parse/ast.rs index dd69264d3d2..49ecddfdee5 100644 --- a/naga/src/front/wgsl/parse/ast.rs +++ b/naga/src/front/wgsl/parse/ast.rs @@ -162,6 +162,7 @@ pub enum Binding<'a> { interpolation: Option, sampling: Option, blend_src: Option>>, + per_primitive: bool, }, } diff --git a/naga/src/front/wgsl/parse/mod.rs b/naga/src/front/wgsl/parse/mod.rs index 93684533c08..bcefc01cb3d 100644 --- a/naga/src/front/wgsl/parse/mod.rs +++ b/naga/src/front/wgsl/parse/mod.rs @@ -178,6 +178,7 @@ struct BindingParser<'a> { sampling: ParsedAttribute, invariant: ParsedAttribute, blend_src: ParsedAttribute>>, + per_primitive: ParsedAttribute<()>, } impl<'a> BindingParser<'a> { @@ -237,6 +238,9 @@ impl<'a> BindingParser<'a> { .set(parser.general_expression(lexer, ctx)?, name_span)?; lexer.expect(Token::Paren(')'))?; } + "per_primitive" => { + self.per_primitive.set((), name_span)?; + } _ => return Err(Box::new(Error::UnknownAttribute(name_span))), } Ok(()) @@ -250,9 +254,10 @@ impl<'a> BindingParser<'a> { self.sampling.value, self.invariant.value.unwrap_or_default(), self.blend_src.value, + self.per_primitive.value, ) { - (None, None, None, None, false, None) => Ok(None), - (Some(location), None, interpolation, sampling, false, blend_src) => { + (None, None, None, None, false, None, None) => Ok(None), + (Some(location), None, interpolation, sampling, false, blend_src, per_primitive) => { // Before handing over the completed `Module`, we call // `apply_default_interpolation` to ensure that the interpolation and // sampling have been explicitly specified on all vertex shader output and fragment @@ -262,17 +267,18 @@ impl<'a> BindingParser<'a> { interpolation, sampling, blend_src, + per_primitive: per_primitive.is_some(), })) } - (None, Some(crate::BuiltIn::Position { .. }), None, None, invariant, None) => { + (None, Some(crate::BuiltIn::Position { .. }), None, None, invariant, None, None) => { Ok(Some(ast::Binding::BuiltIn(crate::BuiltIn::Position { invariant, }))) } - (None, Some(built_in), None, None, false, None) => { + (None, Some(built_in), None, None, false, None, None) => { Ok(Some(ast::Binding::BuiltIn(built_in))) } - (_, _, _, _, _, _) => Err(Box::new(Error::InconsistentBinding(span))), + (_, _, _, _, _, _, _) => Err(Box::new(Error::InconsistentBinding(span))), } } } diff --git a/naga/src/ir/mod.rs b/naga/src/ir/mod.rs index b317f77168d..a975cc8a49d 100644 --- a/naga/src/ir/mod.rs +++ b/naga/src/ir/mod.rs @@ -984,6 +984,7 @@ pub enum Binding { /// Optional `blend_src` index used for dual source blending. /// See blend_src: Option, + per_primitive: bool, }, } diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index b366047dc5e..51167a4810d 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -92,6 +92,10 @@ pub enum VaryingError { }, #[error("Workgroup size is multi dimensional, `@builtin(subgroup_id)` and `@builtin(subgroup_invocation_id)` are not supported.")] InvalidMultiDimensionalSubgroupBuiltIn, + #[error("The `@per_primitive` attribute can only be used in fragment shader inputs or mesh shader primitive outputs")] + InvalidPerPrimitive, + #[error("Non-builtin members of a mesh primitive output struct must be decorated with `@per_primitive`")] + MissingPerPrimitive, } #[derive(Clone, Debug, thiserror::Error)] @@ -139,8 +143,10 @@ pub enum EntryPointError { UnexpectedMeshShaderEntryResult, #[error("Task shader entry point must return @builtin(mesh_task_size) vec3")] WrongTaskShaderEntryResult, - #[error("Mesh output type must be a user-defined struct")] + #[error("Mesh output type must be a user-defined struct.")] InvalidMeshOutputType, + #[error("Mesh primitive outputs must have exactly one of `@builtin(triangle_indices)`, `@builtin(line_indices)`, or `@builtin(point_index)`")] + InvalidMeshPrimitiveOutputType, } fn storage_usage(access: crate::StorageAccess) -> GlobalUse { @@ -157,6 +163,13 @@ fn storage_usage(access: crate::StorageAccess) -> GlobalUse { storage_usage } +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum MeshOutputType { + None, + VertexOutput, + PrimitiveOutput, +} + struct VaryingContext<'a> { stage: crate::ShaderStage, output: bool, @@ -167,6 +180,7 @@ struct VaryingContext<'a> { built_ins: &'a mut crate::FastHashSet, capabilities: Capabilities, flags: super::ValidationFlags, + mesh_output_type: MeshOutputType, } impl VaryingContext<'_> { @@ -320,15 +334,15 @@ impl VaryingContext<'_> { *ty_inner == Ti::Scalar(crate::Scalar::U32), ), Bi::CullPrimitive => ( - self.stage == St::Mesh && self.output, + self.mesh_output_type == MeshOutputType::PrimitiveOutput, *ty_inner == Ti::Scalar(crate::Scalar::BOOL), ), Bi::PointIndex => ( - self.stage == St::Mesh && self.output, + self.mesh_output_type == MeshOutputType::PrimitiveOutput, *ty_inner == Ti::Scalar(crate::Scalar::U32), ), Bi::LineIndices => ( - self.stage == St::Mesh && self.output, + self.mesh_output_type == MeshOutputType::PrimitiveOutput, *ty_inner == Ti::Vector { size: Vs::Bi, @@ -336,7 +350,7 @@ impl VaryingContext<'_> { }, ), Bi::TriangleIndices => ( - self.stage == St::Mesh && self.output, + self.mesh_output_type == MeshOutputType::PrimitiveOutput, *ty_inner == Ti::Vector { size: Vs::Tri, @@ -366,6 +380,7 @@ impl VaryingContext<'_> { interpolation, sampling, blend_src, + per_primitive, } => { // Only IO-shareable types may be stored in locations. if !self.type_info[ty.index()] @@ -374,6 +389,14 @@ impl VaryingContext<'_> { { return Err(VaryingError::NotIOShareableType(ty)); } + if !per_primitive && self.mesh_output_type == MeshOutputType::PrimitiveOutput { + return Err(VaryingError::MissingPerPrimitive); + } else if per_primitive + && ((self.stage != crate::ShaderStage::Fragment || self.output) + && self.mesh_output_type != MeshOutputType::PrimitiveOutput) + { + return Err(VaryingError::InvalidPerPrimitive); + } if let Some(blend_src) = blend_src { // `blend_src` is only valid if dual source blending was explicitly enabled, @@ -788,6 +811,7 @@ impl super::Validator { built_ins: &mut argument_built_ins, capabilities: self.capabilities, flags: self.flags, + mesh_output_type: MeshOutputType::None, }; ctx.validate(ep, fa.ty, fa.binding.as_ref()) .map_err_inner(|e| EntryPointError::Argument(index as u32, e).with_span())?; @@ -806,6 +830,7 @@ impl super::Validator { built_ins: &mut result_built_ins, capabilities: self.capabilities, flags: self.flags, + mesh_output_type: MeshOutputType::None, }; ctx.validate(ep, fr.ty, fr.binding.as_ref()) .map_err_inner(|e| EntryPointError::Result(e).with_span())?; @@ -937,19 +962,54 @@ impl super::Validator { } } - if !matches!( - module.types[mesh_info.vertex_output_type].inner, - crate::TypeInner::Struct { .. } - ) { - return Err(EntryPointError::InvalidMeshOutputType - .with_span_handle(mesh_info.vertex_output_type, &module.types)); - } - if !matches!( - module.types[mesh_info.primitive_output_type].inner, - crate::TypeInner::Struct { .. } - ) { - return Err(EntryPointError::InvalidMeshOutputType - .with_span_handle(mesh_info.primitive_output_type, &module.types)); + for (ty, mesh_output_type) in [ + (mesh_info.vertex_output_type, MeshOutputType::VertexOutput), + ( + mesh_info.primitive_output_type, + MeshOutputType::PrimitiveOutput, + ), + ] { + if !matches!(module.types[ty].inner, crate::TypeInner::Struct { .. }) { + return Err( + EntryPointError::InvalidMeshOutputType.with_span_handle(ty, &module.types) + ); + } + let mut result_built_ins = crate::FastHashSet::default(); + let mut ctx = VaryingContext { + stage: ep.stage, + output: true, + types: &module.types, + type_info: &self.types, + location_mask: &mut self.location_mask, + blend_src_mask: &mut self.blend_src_mask, + built_ins: &mut result_built_ins, + capabilities: self.capabilities, + flags: self.flags, + mesh_output_type, + }; + ctx.validate(ep, ty, None) + .map_err_inner(|e| EntryPointError::Result(e).with_span())?; + if mesh_output_type == MeshOutputType::PrimitiveOutput { + let mut num_indices_builtins = 0; + if result_built_ins.contains(&crate::BuiltIn::PointIndex) { + num_indices_builtins += 1; + } + if result_built_ins.contains(&crate::BuiltIn::LineIndices) { + num_indices_builtins += 1; + } + if result_built_ins.contains(&crate::BuiltIn::TriangleIndices) { + num_indices_builtins += 1; + } + if num_indices_builtins != 1 { + return Err(EntryPointError::InvalidMeshPrimitiveOutputType + .with_span_handle(ty, &module.types)); + } + } else if mesh_output_type == MeshOutputType::VertexOutput + && !result_built_ins.contains(&crate::BuiltIn::Position { invariant: false }) + { + return Err(EntryPointError::MissingVertexOutputPosition + .with_span_handle(ty, &module.types)); + } } } else if info.mesh_shader_info.vertex_type.is_some() || info.mesh_shader_info.primitive_type.is_some() diff --git a/naga/tests/in/wgsl/mesh-shader.wgsl b/naga/tests/in/wgsl/mesh-shader.wgsl index 6e8fe3f05f9..30a61aefc41 100644 --- a/naga/tests/in/wgsl/mesh-shader.wgsl +++ b/naga/tests/in/wgsl/mesh-shader.wgsl @@ -23,10 +23,10 @@ struct VertexOutput { struct PrimitiveOutput { @builtin(triangle_indices) index: vec3, @builtin(cull_primitive) cull: bool, - @location(1) colorMask: vec4, + @per_primitive @location(1) colorMask: vec4, } struct PrimitiveInput { - @location(1) colorMask: vec4, + @per_primitive @location(1) colorMask: vec4, } @task From 0ce18601821caf67b1c074b075ce75a52a9a58f9 Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Sat, 9 Aug 2025 13:52:26 -0500 Subject: [PATCH 64/84] Tried to completely overhaul the output variable writing for spirv --- naga/src/back/spv/block.rs | 279 +++++++++++++++++++++++++- naga/src/back/spv/mod.rs | 40 +++- naga/src/back/spv/writer.rs | 390 ++++++++++++++++++++++++++++++------ 3 files changed, 637 insertions(+), 72 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index c66e707aa28..297198e6164 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -297,6 +297,244 @@ impl Writer { } Ok(Instruction::return_void()) } + fn write_mesh_shader_return( + &mut self, + return_info: &super::MeshReturnInfo, + body: &mut Vec, + ) -> Result<(), Error> { + // TODO: (maybe) make this multithreaded if you have the patience + let vert_info = self.mesh_shader_output_variable( + return_info.vertex_type, + false, + return_info.max_vertices, + )?; + let prim_info = self.mesh_shader_output_variable( + return_info.primitive_type, + false, + return_info.max_primitives, + )?; + let vert_count_id = self.id_gen.next(); + body.push(Instruction::load( + self.get_u32_type_id(), + vert_count_id, + self.mesh_state.num_vertices_var.unwrap(), + None, + )); + let prim_count_id = self.id_gen.next(); + body.push(Instruction::load( + self.get_u32_type_id(), + prim_count_id, + self.mesh_state.num_primitives_var.unwrap(), + None, + )); + + // All this for the vertex loop lol + let u32_type_id = self.get_u32_type_id(); + let u32_ptr_id = self.get_pointer_type_id(u32_type_id, spirv::StorageClass::Function); + let zero_u32 = self.get_constant_scalar(crate::Literal::U32(0)); + let vertex_loop_header = self.id_gen.next(); + let prim_loop_header = self.id_gen.next(); + let in_between_loops = self.id_gen.next(); + let vertex_loop_body = self.id_gen.next(); + let prim_loop_body = self.id_gen.next(); + let func_end = self.id_gen.next(); + let counter_var = self.id_gen.next(); + body.push(Instruction::variable( + u32_ptr_id, + counter_var, + spirv::StorageClass::Function, + Some(zero_u32), + )); + + body.push(Instruction::branch(vertex_loop_header)); + + { + body.push(Instruction::label(in_between_loops)); + body.push(Instruction::store(counter_var, zero_u32, None)); + body.push(Instruction::branch(prim_loop_header)); + } + + let mut get_loop_continue_id = |loop_body, loop_header, loop_merge, count_id| { + let loop_continue = self.id_gen.next(); + + // Loop header - check if i is less than num vertices to copy + { + body.push(Instruction::label(loop_header)); + body.push(Instruction::loop_merge( + loop_merge, + loop_continue, + spirv::SelectionControl::empty(), + )); + let val_i = self.id_gen.next(); + body.push(Instruction::load(u32_type_id, val_i, counter_var, None)); + let cond = self.id_gen.next(); + body.push(Instruction { + op: spirv::Op::ULessThan, + type_id: Some(self.get_bool_type_id()), + result_id: Some(cond), + wc: 2, + operands: alloc::vec![val_i, count_id], + }); + body.push(Instruction::branch_conditional(cond, loop_body, loop_merge)); + } + // Loop continue - increment i + { + body.push(Instruction::label(loop_continue)); + let val_i = self.id_gen.next(); + let new_val_i = self.id_gen.next(); + body.push(Instruction::load(u32_type_id, val_i, counter_var, None)); + body.push(Instruction { + op: spirv::Op::IAdd, + type_id: Some(u32_type_id), + result_id: Some(new_val_i), + wc: 2, + operands: alloc::vec![val_i, self.get_constant_scalar(crate::Literal::U32(1))], + }); + body.push(Instruction::store(counter_var, new_val_i, None)); + body.push(Instruction::branch(loop_header)); + } + loop_continue + }; + let vertex_continue = get_loop_continue_id( + vertex_loop_body, + vertex_loop_header, + in_between_loops, + vert_count_id, + ); + let prim_continue = + get_loop_continue_id(prim_loop_body, prim_loop_header, func_end, prim_count_id); + + // Vertex copies + { + body.push(Instruction::label(vertex_loop_body)); + let val_i = self.id_gen.next(); + body.push(Instruction::load(u32_type_id, val_i, counter_var, None)); + + let vert_to_copy_ptr = self.id_gen.next(); + body.push(Instruction::access_chain( + self.get_pointer_type_id(vert_info.inner_ty, spirv::StorageClass::Workgroup), + vert_to_copy_ptr, + vert_info.var_id, + &[val_i], + )); + let vert_to_copy = self.id_gen.next(); + body.push(Instruction::load( + vert_info.inner_ty, + vert_to_copy, + vert_to_copy_ptr, + None, + )); + + let mut builtin_index = 0; + let mut binding_index = 0; + for (member_id, member) in return_info.vertex_members.iter().enumerate() { + let val_to_copy = self.id_gen.next(); + body.push(Instruction::composite_extract( + member.ty_id, + val_to_copy, + vert_to_copy, + &[self.get_constant_scalar(crate::Literal::U32(member_id as u32))], + )); + let ptr_to_copy_to = self.id_gen.next(); + match member.binding { + crate::Binding::BuiltIn(_) => { + body.push(Instruction::access_chain( + self.get_pointer_type_id(member.ty_id, spirv::StorageClass::Output), + ptr_to_copy_to, + return_info.vertex_builtin_block.as_ref().unwrap().var_id, + &[val_i, builtin_index], + )); + builtin_index += 1; + } + crate::Binding::Location { .. } => { + body.push(Instruction::access_chain( + self.get_pointer_type_id(member.ty_id, spirv::StorageClass::Output), + ptr_to_copy_to, + return_info.vertex_bindings[binding_index].var_id, + &[val_i, zero_u32], + )); + binding_index += 1; + } + } + body.push(Instruction::store(ptr_to_copy_to, val_to_copy, None)); + } + + body.push(Instruction::branch(vertex_continue)); + } + + // Primitive copies + { + body.push(Instruction::label(prim_loop_body)); + let val_i = self.id_gen.next(); + body.push(Instruction::load(u32_type_id, val_i, counter_var, None)); + + let prim_to_copy_ptr = self.id_gen.next(); + body.push(Instruction::access_chain( + self.get_pointer_type_id(prim_info.inner_ty, spirv::StorageClass::Workgroup), + prim_to_copy_ptr, + prim_info.var_id, + &[val_i], + )); + let prim_to_copy = self.id_gen.next(); + body.push(Instruction::load( + vert_info.inner_ty, + prim_to_copy, + prim_to_copy_ptr, + None, + )); + + let mut builtin_index = 0; + let mut binding_index = 0; + for (member_id, member) in return_info.primitive_members.iter().enumerate() { + let val_to_copy = self.id_gen.next(); + body.push(Instruction::composite_extract( + member.ty_id, + val_to_copy, + prim_to_copy, + &[self.get_constant_scalar(crate::Literal::U32(member_id as u32))], + )); + let ptr_to_copy_to = self.id_gen.next(); + match member.binding { + crate::Binding::BuiltIn( + crate::BuiltIn::PointIndex + | crate::BuiltIn::LineIndices + | crate::BuiltIn::TriangleIndices, + ) => { + body.push(Instruction::access_chain( + self.get_pointer_type_id(member.ty_id, spirv::StorageClass::Output), + ptr_to_copy_to, + return_info.primitive_indices.as_ref().unwrap().var_id, + &[val_i], + )); + } + crate::Binding::BuiltIn(_) => { + body.push(Instruction::access_chain( + self.get_pointer_type_id(member.ty_id, spirv::StorageClass::Output), + ptr_to_copy_to, + return_info.primitive_builtin_block.as_ref().unwrap().var_id, + &[val_i, builtin_index], + )); + builtin_index += 1; + } + crate::Binding::Location { .. } => { + body.push(Instruction::access_chain( + self.get_pointer_type_id(member.ty_id, spirv::StorageClass::Output), + ptr_to_copy_to, + return_info.primitive_bindings[binding_index].var_id, + &[val_i, zero_u32], + )); + binding_index += 1; + } + } + body.push(Instruction::store(ptr_to_copy_to, val_to_copy, None)); + } + + body.push(Instruction::branch(prim_continue)); + } + + body.push(Instruction::label(func_end)); + Ok(()) + } } impl BlockContext<'_> { @@ -3275,6 +3513,14 @@ impl BlockContext<'_> { return Ok(BlockExitDisposition::Discarded); } Statement::Return { value: None } => { + if let Some(super::EntryPointContext { + mesh_state: Some(ref mesh_state), + .. + }) = self.function.entry_point_context + { + self.writer + .write_mesh_shader_return(mesh_state, &mut block.body)?; + }; self.function.consume(block, Instruction::return_void()); return Ok(BlockExitDisposition::Discarded); } @@ -3674,6 +3920,16 @@ impl BlockContext<'_> { ins.add_operand(self.cached[vertex_count]); ins.add_operand(self.cached[primitive_count]); block.body.push(ins); + block.body.push(Instruction::store( + self.writer.mesh_state.num_vertices_var.unwrap(), + self.cached[vertex_count], + None, + )); + block.body.push(Instruction::store( + self.writer.mesh_state.num_primitives_var.unwrap(), + self.cached[primitive_count], + None, + )); } Statement::MeshFunction( crate::MeshFunction::SetVertex { index, value } @@ -3695,14 +3951,21 @@ impl BlockContext<'_> { } else { self.fun_info.mesh_shader_info.vertex_type.unwrap().0 }; - let info = self.writer.mesh_shader_output_variable( - self.ir_module, - type_handle, - is_prim, - 0, - )?; + let info = self + .writer + .mesh_shader_output_variable(type_handle, is_prim, 0)?; + let out_ptr_id = self.gen_id(); + block.body.push(Instruction::access_chain( + self.get_pointer_type_id(info.inner_ty, spirv::StorageClass::Output), + out_ptr_id, + info.var_id, + &[self.cached[index]], + )); + block + .body + .push(Instruction::store(out_ptr_id, self.cached[value], None)); - for (i, member_info) in info.outputs.iter().enumerate() { + /*for (i, member_info) in info.outputs.iter().enumerate() { let member_ty = member_info.member_ty; let in_value_id = self.gen_id(); @@ -3767,7 +4030,7 @@ impl BlockContext<'_> { .body .push(Instruction::store(access_id, flipped_y_val, None)); } - } + }*/ } Statement::SubgroupBallot { result, diff --git a/naga/src/back/spv/mod.rs b/naga/src/back/spv/mod.rs index 826d16d8cf7..4dae9bcdec7 100644 --- a/naga/src/back/spv/mod.rs +++ b/naga/src/back/spv/mod.rs @@ -141,10 +141,39 @@ struct ResultMember { built_in: Option, } +struct MeshReturnGlobalVariable { + _inner_ty: u32, + var_id: u32, +} + +#[derive(Clone)] +struct MeshReturnMember { + ty_id: u32, + binding: crate::Binding, +} +struct MeshReturnInfo { + vertex_type: Handle, + vertex_members: Vec, + max_vertices: u32, + primitive_type: Handle, + primitive_members: Vec, + max_primitives: u32, + // In vulkan, all builtins must be in the same block. + // All bindings must be in their own unique block. + // Also, the primitive indices builtin family needs its own block. + // Also also, cull primitive doesn't care about having its own block. + vertex_builtin_block: Option, + vertex_bindings: Vec, + primitive_builtin_block: Option, + primitive_bindings: Vec, + primitive_indices: Option, +} + struct EntryPointContext { argument_ids: Vec, results: Vec, task_payload: Option, + mesh_state: Option, } #[derive(Default)] @@ -921,6 +950,8 @@ pub fn write_vec( pub struct WriteMeshInfo { pub vertex_outputs_by_type: crate::FastHashMap, MeshOutputInfo>, pub primitive_outputs_by_type: crate::FastHashMap, MeshOutputInfo>, + pub num_vertices_var: Option, + pub num_primitives_var: Option, } #[derive(Clone)] @@ -932,14 +963,7 @@ pub struct MeshOutputInfo { /// tries to write to it, the function can still be valid if it is never called. pub index_of_length_decl: usize, pub inner_ty: Word, - // Structs with elements with layout can't have elements with builtins, and vice versa. - // Therefore, we separate it into 2 structs and whatnot - pub outputs: Vec, -} -#[derive(Clone)] -pub struct MeshOutputArrayInfo { - pub member_ty: Word, pub array_ty: Word, pub var_id: Word, - pub member: crate::StructMember, + pub array_size_id: Word, } diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 23ea7461d9b..5c61220b28d 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -15,6 +15,7 @@ use super::{ use crate::{ arena::{Handle, HandleVec, UniqueArena}, back::spv::{helpers::BindingDecorations, BindingInfo, WrappedFunction}, + non_max_u32::NonMaxU32, path_like::PathLike, proc::{Alignment, TypeResolution}, valid::{FunctionInfo, ModuleInfo}, @@ -98,6 +99,8 @@ impl Writer { mesh_state: super::WriteMeshInfo { vertex_outputs_by_type: crate::FastHashMap::default(), primitive_outputs_by_type: crate::FastHashMap::default(), + num_vertices_var: None, + num_primitives_var: None, }, }) } @@ -163,6 +166,8 @@ impl Writer { vertex_outputs_by_type: take(&mut self.mesh_state.vertex_outputs_by_type).recycle(), primitive_outputs_by_type: take(&mut self.mesh_state.primitive_outputs_by_type) .recycle(), + num_vertices_var: None, + num_primitives_var: None, }, }; @@ -694,6 +699,24 @@ impl Writer { Ok(()) } + fn write_mesh_return_global_variable( + &mut self, + ty: u32, + array_size_id: u32, + ) -> Result { + let array_ty = self.id_gen.next(); + Instruction::type_array(array_ty, ty, array_size_id) + .to_words(&mut self.logical_layout.declarations); + let ptr_ty = self.get_pointer_type_id(array_ty, spirv::StorageClass::Output); + let var_id = self.id_gen.next(); + Instruction::variable(ptr_ty, var_id, spirv::StorageClass::Output, None) + .to_words(&mut self.logical_layout.declarations); + Ok(super::MeshReturnGlobalVariable { + _inner_ty: ty, + var_id, + }) + } + fn write_function( &mut self, ir_function: &crate::Function, @@ -717,6 +740,7 @@ impl Writer { } else { None }, + mesh_state: None, }; let mut local_invocation_id = None; @@ -920,20 +944,290 @@ impl Writer { } if let Some(ref mesh_info) = iface.mesh_info { let vert_info = self.mesh_shader_output_variable( - ir_module, mesh_info.vertex_output_type, false, mesh_info.max_vertices, )?; let prim_info = self.mesh_shader_output_variable( - ir_module, mesh_info.primitive_output_type, true, mesh_info.max_primitives, )?; - for array in vert_info.outputs.iter().chain(prim_info.outputs.iter()) { - iface.varying_ids.push(array.var_id); + iface.varying_ids.push(vert_info.var_id); + iface.varying_ids.push(prim_info.var_id); + // These are guaranteed to be initialized after mesh_shader_output_variable + // is called + iface + .varying_ids + .push(self.mesh_state.num_vertices_var.unwrap()); + iface + .varying_ids + .push(self.mesh_state.num_primitives_var.unwrap()); + + let vertex_members = match &ir_module.types[mesh_info.vertex_output_type] { + &crate::Type { + inner: crate::TypeInner::Struct { ref members, .. }, + .. + } => members + .iter() + .map(|a| super::MeshReturnMember { + ty_id: self.get_handle_type_id(a.ty), + binding: a.binding.clone().unwrap(), + }) + .collect(), + _ => unreachable!(), + }; + let primitive_members = match &ir_module.types[mesh_info.primitive_output_type] { + &crate::Type { + inner: crate::TypeInner::Struct { ref members, .. }, + .. + } => members + .iter() + .map(|a| super::MeshReturnMember { + ty_id: self.get_handle_type_id(a.ty), + binding: a.binding.clone().unwrap(), + }) + .collect(), + _ => unreachable!(), + }; + let mut mesh_return_info = super::MeshReturnInfo { + vertex_type: mesh_info.vertex_output_type, + vertex_members, + max_vertices: mesh_info.max_vertices, + primitive_type: mesh_info.primitive_output_type, + primitive_members, + max_primitives: mesh_info.max_primitives, + vertex_bindings: Vec::new(), + vertex_builtin_block: None, + primitive_bindings: Vec::new(), + primitive_builtin_block: None, + primitive_indices: None, + }; + if mesh_return_info + .vertex_members + .iter() + .any(|a| matches!(a.binding, crate::Binding::BuiltIn(..))) + { + let builtin_block_ty_id = self.id_gen.next(); + let mut ins = Instruction::type_struct(builtin_block_ty_id, &[]); + let mut bi_index = 0; + let mut decorations = Vec::new(); + for member in &mesh_return_info.vertex_members { + if let crate::Binding::BuiltIn(_) = member.binding { + ins.add_operand(member.ty_id); + let binding = self.map_binding( + ir_module, + iface.stage, + spirv::StorageClass::Output, + // Unused except in fragment shaders with other conditions, so we can pass null + Handle::new(NonMaxU32::new(0).unwrap()), + &member.binding, + )?; + match binding { + BindingDecorations::BuiltIn(bi, others) => { + decorations.push(Instruction::member_decorate( + builtin_block_ty_id, + bi_index, + spirv::Decoration::BuiltIn, + &[bi as Word], + )); + for other in others { + decorations.push(Instruction::member_decorate( + builtin_block_ty_id, + bi_index, + other, + &[], + )); + } + } + _ => unreachable!(), + } + bi_index += 1; + } + } + ins.to_words(&mut self.logical_layout.declarations); + decorations.push(Instruction::decorate( + builtin_block_ty_id, + spirv::Decoration::Block, + &[], + )); + for dec in decorations { + dec.to_words(&mut self.logical_layout.declarations); + } + let v = self.write_mesh_return_global_variable( + builtin_block_ty_id, + vert_info.array_size_id, + )?; + iface.varying_ids.push(v.var_id); + mesh_return_info.vertex_builtin_block = Some(v); + } + if mesh_return_info.primitive_members.iter().any(|a| { + !matches!( + a.binding, + crate::Binding::BuiltIn( + crate::BuiltIn::PointIndex + | crate::BuiltIn::LineIndices + | crate::BuiltIn::TriangleIndices + ) | crate::Binding::Location { .. } + ) + }) { + let builtin_block_ty_id = self.id_gen.next(); + let mut ins = Instruction::type_struct(builtin_block_ty_id, &[]); + let mut bi_index = 0; + let mut decorations = Vec::new(); + for member in &mesh_return_info.primitive_members { + if let crate::Binding::BuiltIn(bi) = member.binding { + if matches!( + bi, + crate::BuiltIn::PointIndex + | crate::BuiltIn::LineIndices + | crate::BuiltIn::TriangleIndices, + ) { + continue; + } + ins.add_operand(member.ty_id); + let binding = self.map_binding( + ir_module, + iface.stage, + spirv::StorageClass::Output, + // Unused except in fragment shaders with other conditions, so we can pass null + Handle::new(NonMaxU32::new(0).unwrap()), + &member.binding, + )?; + match binding { + BindingDecorations::BuiltIn(bi, others) => { + decorations.push(Instruction::member_decorate( + builtin_block_ty_id, + bi_index, + spirv::Decoration::BuiltIn, + &[bi as Word], + )); + for other in others { + decorations.push(Instruction::member_decorate( + builtin_block_ty_id, + bi_index, + other, + &[], + )); + } + } + _ => unreachable!(), + } + bi_index += 1; + } + } + ins.to_words(&mut self.logical_layout.declarations); + decorations.push(Instruction::decorate( + builtin_block_ty_id, + spirv::Decoration::Block, + &[], + )); + for dec in decorations { + dec.to_words(&mut self.logical_layout.declarations); + } + let v = self.write_mesh_return_global_variable( + builtin_block_ty_id, + prim_info.array_size_id, + )?; + Instruction::decorate(v.var_id, spirv::Decoration::PerPrimitiveEXT, &[]) + .to_words(&mut self.logical_layout.declarations); + iface.varying_ids.push(v.var_id); + mesh_return_info.primitive_builtin_block = Some(v); } + { + for member in &mesh_return_info.vertex_members { + match member.binding { + crate::Binding::Location { location, .. } => { + let s_type = self.id_gen.next(); + Instruction::type_struct(s_type, &[member.ty_id]) + .to_words(&mut self.logical_layout.declarations); + Instruction::decorate(s_type, spirv::Decoration::Block, &[]) + .to_words(&mut self.logical_layout.declarations); + Instruction::member_decorate( + s_type, + 0, + spirv::Decoration::Location, + &[location], + ) + .to_words(&mut self.logical_layout.declarations); + let v = self.write_mesh_return_global_variable( + s_type, + prim_info.array_size_id, + )?; + iface.varying_ids.push(v.var_id); + mesh_return_info.vertex_bindings.push(v); + } + crate::Binding::BuiltIn(_) => (), + } + } + for member in &mesh_return_info.primitive_members { + match member.binding { + crate::Binding::BuiltIn( + crate::BuiltIn::PointIndex + | crate::BuiltIn::LineIndices + | crate::BuiltIn::TriangleIndices, + ) => { + let v = self.write_mesh_return_global_variable( + member.ty_id, + prim_info.array_size_id, + )?; + Instruction::decorate( + v.var_id, + spirv::Decoration::PerPrimitiveEXT, + &[], + ) + .to_words(&mut self.logical_layout.declarations); + Instruction::decorate( + v.var_id, + spirv::Decoration::BuiltIn, + &[match member.binding.to_built_in().unwrap() { + crate::BuiltIn::PointIndex => { + spirv::BuiltIn::PrimitivePointIndicesEXT + } + crate::BuiltIn::LineIndices => { + spirv::BuiltIn::PrimitiveLineIndicesEXT + } + crate::BuiltIn::TriangleIndices => { + spirv::BuiltIn::PrimitiveTriangleIndicesEXT + } + _ => unreachable!(), + } as Word], + ) + .to_words(&mut self.logical_layout.declarations); + iface.varying_ids.push(v.var_id); + mesh_return_info.primitive_indices = Some(v); + } + crate::Binding::Location { location, .. } => { + let s_type = self.id_gen.next(); + Instruction::type_struct(s_type, &[member.ty_id]) + .to_words(&mut self.logical_layout.declarations); + Instruction::decorate(s_type, spirv::Decoration::Block, &[]) + .to_words(&mut self.logical_layout.declarations); + Instruction::member_decorate( + s_type, + 0, + spirv::Decoration::Location, + &[location], + ) + .to_words(&mut self.logical_layout.declarations); + let v = self.write_mesh_return_global_variable( + s_type, + prim_info.array_size_id, + )?; + Instruction::decorate( + v.var_id, + spirv::Decoration::PerPrimitiveEXT, + &[], + ) + .to_words(&mut self.logical_layout.declarations); + iface.varying_ids.push(v.var_id); + mesh_return_info.primitive_bindings.push(v); + } + crate::Binding::BuiltIn(_) => (), + } + } + } + ep_context.mesh_state = Some(mesh_return_info); } } @@ -2170,7 +2464,7 @@ impl Writer { } } } - if per_primitive { + if per_primitive && stage == crate::ShaderStage::Fragment { others.push(Decoration::PerPrimitiveEXT); } Ok(BindingDecorations::Location { @@ -2323,11 +2617,32 @@ impl Writer { /// Returns the id of the variable, and the type of the array pub fn mesh_shader_output_variable( &mut self, - ir_module: &crate::Module, output_type: Handle, is_primitive: bool, array_len: Word, ) -> Result { + if self.mesh_state.num_vertices_var.is_none() { + let u32_ty = self.get_u32_type_id(); + let u32_ptr = self.get_pointer_type_id(u32_ty, spirv::StorageClass::Workgroup); + let var_id = self.id_gen.next(); + Instruction::variable(u32_ptr, var_id, spirv::StorageClass::Workgroup, None) + .to_words(&mut self.logical_layout.declarations); + self.mesh_state.num_vertices_var = Some(var_id); + if self.flags.contains(WriterFlags::DEBUG) { + Instruction::name(var_id, "naga_num_vertices"); + } + } + if self.mesh_state.num_primitives_var.is_none() { + let u32_ty = self.get_u32_type_id(); + let u32_ptr = self.get_pointer_type_id(u32_ty, spirv::StorageClass::Workgroup); + let var_id = self.id_gen.next(); + Instruction::variable(u32_ptr, var_id, spirv::StorageClass::Workgroup, None) + .to_words(&mut self.logical_layout.declarations); + self.mesh_state.num_primitives_var = Some(var_id); + if self.flags.contains(WriterFlags::DEBUG) { + Instruction::name(var_id, "naga_num_primitives"); + } + } let entry = if is_primitive { self.mesh_state.primitive_outputs_by_type.get(&output_type) } else { @@ -2352,61 +2667,24 @@ impl Writer { // This is the best part let len_literal_idx = self.logical_layout.declarations.len() - 1; - let main_ty_ir = &ir_module.types[output_type]; - let struct_members = match main_ty_ir.inner { - crate::TypeInner::Struct { ref members, .. } => members.clone(), - _ => unreachable!("Mesh output type isn't a struct"), - }; - - let mut outputs = Vec::new(); - - for member in struct_members { - if member.binding.is_none() { - continue; - } - let member_ty = self.get_handle_type_id(member.ty); - let array_ty = self.id_gen.next(); - Instruction::type_array(array_ty, member_ty, len_value_id) - .to_words(&mut self.logical_layout.declarations); - let var_id = self.id_gen.next(); - Instruction::variable( - self.get_pointer_type_id(array_ty, spirv::StorageClass::Output), - var_id, - spirv::StorageClass::Output, - None, - ) + let array_ty = self.id_gen.next(); + Instruction::type_array(array_ty, main_type_id, len_value_id) .to_words(&mut self.logical_layout.declarations); - - let binding = self.map_binding( - ir_module, - crate::ShaderStage::Mesh, - spirv::StorageClass::Output, - member.ty, - member.binding.as_ref().unwrap(), - )?; - self.write_binding(var_id, binding); - - if self - .flags - .contains(WriterFlags::DEBUG | WriterFlags::LABEL_VARYINGS) - { - if let Some(name) = member.name.as_deref() { - self.debugs.push(Instruction::name(var_id, name)); - } - } - - outputs.push(super::MeshOutputArrayInfo { - member_ty, - array_ty, - var_id, - member, - }) - } + let var_id = self.id_gen.next(); + Instruction::variable( + self.get_pointer_type_id(array_ty, spirv::StorageClass::Workgroup), + var_id, + spirv::StorageClass::Workgroup, + None, + ) + .to_words(&mut self.logical_layout.declarations); let info = super::MeshOutputInfo { inner_ty: main_type_id, index_of_length_decl: len_literal_idx, - outputs, + array_ty, + var_id, + array_size_id: len_value_id, }; if is_primitive { self.mesh_state From 14b2b8454e8fdc264f48a87f6d3cadb6cb090fe9 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 9 Aug 2025 15:06:50 -0500 Subject: [PATCH 65/84] Committing this nonsense before it all gets destroyed again by my stupid fucking pc --- naga/src/back/spv/block.rs | 37 +++--- naga/src/back/spv/writer.rs | 26 ++-- shaders/mesh.spv | Bin 0 -> 4124 bytes shaders/mesh.spv-asm | 253 ++++++++++++++++++++++++++++++++++++ 4 files changed, 288 insertions(+), 28 deletions(-) create mode 100644 shaders/mesh.spv create mode 100644 shaders/mesh.spv-asm diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 297198e6164..6e04bbbe015 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -368,13 +368,11 @@ impl Writer { let val_i = self.id_gen.next(); body.push(Instruction::load(u32_type_id, val_i, counter_var, None)); let cond = self.id_gen.next(); - body.push(Instruction { - op: spirv::Op::ULessThan, - type_id: Some(self.get_bool_type_id()), - result_id: Some(cond), - wc: 2, - operands: alloc::vec![val_i, count_id], - }); + let mut cmp_ins = Instruction::new(spirv::Op::ULessThan); + cmp_ins.set_type(self.get_bool_type_id()); + cmp_ins.set_result(cond); + cmp_ins.add_operands(alloc::vec![val_i, count_id]); + body.push(cmp_ins); body.push(Instruction::branch_conditional(cond, loop_body, loop_merge)); } // Loop continue - increment i @@ -383,13 +381,14 @@ impl Writer { let val_i = self.id_gen.next(); let new_val_i = self.id_gen.next(); body.push(Instruction::load(u32_type_id, val_i, counter_var, None)); - body.push(Instruction { - op: spirv::Op::IAdd, - type_id: Some(u32_type_id), - result_id: Some(new_val_i), - wc: 2, - operands: alloc::vec![val_i, self.get_constant_scalar(crate::Literal::U32(1))], - }); + let mut add_ins = Instruction::new(spirv::Op::IAdd); + add_ins.set_type(u32_type_id); + add_ins.set_result(new_val_i); + add_ins.add_operands(alloc::vec![ + val_i, + self.get_constant_scalar(crate::Literal::U32(1)) + ]); + body.push(add_ins); body.push(Instruction::store(counter_var, new_val_i, None)); body.push(Instruction::branch(loop_header)); } @@ -442,7 +441,10 @@ impl Writer { self.get_pointer_type_id(member.ty_id, spirv::StorageClass::Output), ptr_to_copy_to, return_info.vertex_builtin_block.as_ref().unwrap().var_id, - &[val_i, builtin_index], + &[ + val_i, + self.get_constant_scalar(crate::Literal::U32(builtin_index as u32)), + ], )); builtin_index += 1; } @@ -512,7 +514,10 @@ impl Writer { self.get_pointer_type_id(member.ty_id, spirv::StorageClass::Output), ptr_to_copy_to, return_info.primitive_builtin_block.as_ref().unwrap().var_id, - &[val_i, builtin_index], + &[ + val_i, + self.get_constant_scalar(crate::Literal::U32(builtin_index as u32)), + ], )); builtin_index += 1; } diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 5c61220b28d..0dcfa4bde79 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -1052,7 +1052,7 @@ impl Writer { &[], )); for dec in decorations { - dec.to_words(&mut self.logical_layout.declarations); + dec.to_words(&mut self.logical_layout.annotations); } let v = self.write_mesh_return_global_variable( builtin_block_ty_id, @@ -1123,14 +1123,14 @@ impl Writer { &[], )); for dec in decorations { - dec.to_words(&mut self.logical_layout.declarations); + dec.to_words(&mut self.logical_layout.annotations); } let v = self.write_mesh_return_global_variable( builtin_block_ty_id, prim_info.array_size_id, )?; Instruction::decorate(v.var_id, spirv::Decoration::PerPrimitiveEXT, &[]) - .to_words(&mut self.logical_layout.declarations); + .to_words(&mut self.logical_layout.annotations); iface.varying_ids.push(v.var_id); mesh_return_info.primitive_builtin_block = Some(v); } @@ -1142,14 +1142,14 @@ impl Writer { Instruction::type_struct(s_type, &[member.ty_id]) .to_words(&mut self.logical_layout.declarations); Instruction::decorate(s_type, spirv::Decoration::Block, &[]) - .to_words(&mut self.logical_layout.declarations); + .to_words(&mut self.logical_layout.annotations); Instruction::member_decorate( s_type, 0, spirv::Decoration::Location, &[location], ) - .to_words(&mut self.logical_layout.declarations); + .to_words(&mut self.logical_layout.annotations); let v = self.write_mesh_return_global_variable( s_type, prim_info.array_size_id, @@ -1176,7 +1176,7 @@ impl Writer { spirv::Decoration::PerPrimitiveEXT, &[], ) - .to_words(&mut self.logical_layout.declarations); + .to_words(&mut self.logical_layout.annotations); Instruction::decorate( v.var_id, spirv::Decoration::BuiltIn, @@ -1193,7 +1193,7 @@ impl Writer { _ => unreachable!(), } as Word], ) - .to_words(&mut self.logical_layout.declarations); + .to_words(&mut self.logical_layout.annotations); iface.varying_ids.push(v.var_id); mesh_return_info.primitive_indices = Some(v); } @@ -1202,14 +1202,14 @@ impl Writer { Instruction::type_struct(s_type, &[member.ty_id]) .to_words(&mut self.logical_layout.declarations); Instruction::decorate(s_type, spirv::Decoration::Block, &[]) - .to_words(&mut self.logical_layout.declarations); + .to_words(&mut self.logical_layout.annotations); Instruction::member_decorate( s_type, 0, spirv::Decoration::Location, &[location], ) - .to_words(&mut self.logical_layout.declarations); + .to_words(&mut self.logical_layout.annotations); let v = self.write_mesh_return_global_variable( s_type, prim_info.array_size_id, @@ -1219,7 +1219,7 @@ impl Writer { spirv::Decoration::PerPrimitiveEXT, &[], ) - .to_words(&mut self.logical_layout.declarations); + .to_words(&mut self.logical_layout.annotations); iface.varying_ids.push(v.var_id); mesh_return_info.primitive_bindings.push(v); } @@ -2629,7 +2629,8 @@ impl Writer { .to_words(&mut self.logical_layout.declarations); self.mesh_state.num_vertices_var = Some(var_id); if self.flags.contains(WriterFlags::DEBUG) { - Instruction::name(var_id, "naga_num_vertices"); + Instruction::name(var_id, "naga_num_vertices") + .to_words(&mut self.logical_layout.debugs); } } if self.mesh_state.num_primitives_var.is_none() { @@ -2640,7 +2641,8 @@ impl Writer { .to_words(&mut self.logical_layout.declarations); self.mesh_state.num_primitives_var = Some(var_id); if self.flags.contains(WriterFlags::DEBUG) { - Instruction::name(var_id, "naga_num_primitives"); + Instruction::name(var_id, "naga_num_primitives") + .to_words(&mut self.logical_layout.debugs); } } let entry = if is_primitive { diff --git a/shaders/mesh.spv b/shaders/mesh.spv new file mode 100644 index 0000000000000000000000000000000000000000..bcac61a4405ff1068b3c1f5481c8aec317ab0b7f GIT binary patch literal 4124 zcmZveX>(Ln5QcBahJX;+MT~)n$`(-rF32Xq0D=TT#5E3Ngpni@XC?t$nN zWwWx5?9kAW;ax`$5091WCx`1NOC#l4HXGi!!F`AJ_0=0Aef=9Zm_IjbRpq{U+5GGe zYHS3L)rZGQm2v848B{h0ao!$eDRLvS3R#V;M=aKl%tgAG%Npi7XGj-w$^S~huBr}0dYnv}`eqI-Cw%id~ zE1x+q*_fDY0Q1;c8jQ;LNcjxfe7QV-a&%Omy~@o%ioIG_ekhieN*g~L-f?Zb{MGn9 z<9R2p&vR=O)@NO`$NIWbUbl)&wrhvyajwsR^RMOGPU`igf#-ypuJJg+s| zi=IGsQ)MOE5q%C4E9V;Z-=>qH|2HPkFQ;GI`*bPsYZ7mswxheL@>uU&Gqx?if7ZN` za__>9Ikg?;y8q78k2crZ-U~->Q(fhZmFq%`i+fRwi#t(_^XweOIJv0jnOING9*eoL zZ;?Bg&PD!aL`>WH{`npkP{A6DSyL;z2U$W)8(OShNJKlj8{}H$0^7e>S;X&5bPwXN z&UI)xYjvld<;*vy8;`wd_wai?df6iHc9v~U*!9ZkpNDO%_4JFqkC8tgy9IGh{o?qJ zm`|D9Zx8y#?uR-0m!Pc``C`9Ua>k4Oc8J&VYg~MTmV<8syC-tibI*;HH(%_&7xUv@ znSTpD&sEO+6)9HUd~r|W+`E;@Hn$gB9CP1_?LNtyEB2c!XRhzYb1?UIv^eIy1KT)x zbH%=`$X$c&8q8gb7Dw(nY~$q375j~sGrkY){zv?s$tQ2T*tZ#T`Tkh+BXR`~j zC-+BR%>6KSv9`ANbT`_2uk^8V>OF|QM-uP7)~DW=e2*rdduQwr+P5C~39$QaJ^e2v z+aARy6ZRg9D`@irzXUelIb*Fg>=wkk=>G@w$(cWic5Zp^lem#M{r)Ysmzjw8eDXzq z7r@RJ{eP8g=P>@83SYco1(=)2XlI62M~Mlju|&qd?a6PSPa@a$`BdVg&!_YFER&DA&tMn(6dM#XiNp zW&QT~JaTQHrNl>{$G|%g`KWswyV$4Lxae~v`J>M=*ggjk&sA)Ue&5~+#QPTeE#8Ib z_wBui*r)4s4)66TME>W5M-yj`?{^HbX6%jF82#S0aYTRgB=$RG{aNTLqThJm`vlU1 zM2}))jQ4F!AxjJRG`4r$_jCsR2GWU`?|V6m_PxAy`{3>Fu^Gu^7_ib!*r^&SUcM!SQD}8dsKJCd~UPqrp98vFG>|!tP zf#uu-dlA2em}@WQNACOB#a=!D%N2W(vzOQx*A@96Vw>+dokxF!c-Q2OanCaMc(Jw>ycufoU!&ijdsnhKYIQGJ9_q8 z{w2~tUH~(w!2E;u36&q)ccj8;boapy5_IJo?#GF{CoUyUa h@3GArKw_OgVD}@%JUL@sr)TOqJ>!3~7Upcp{sX-ZInn?C literal 0 HcmV?d00001 diff --git a/shaders/mesh.spv-asm b/shaders/mesh.spv-asm new file mode 100644 index 00000000000..e2b5ff09948 --- /dev/null +++ b/shaders/mesh.spv-asm @@ -0,0 +1,253 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos; 28 +; Bound: 159 +; Schema: 0 + OpCapability Shader + OpCapability MeshShadingEXT + OpExtension "SPV_EXT_mesh_shader" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint MeshEXT %ms_main "ms_main" %index %id %taskPayload %28 %32 %naga_num_vertices %naga_num_primitives %37 %41 %45 %48 %52 %workgroupData + OpExecutionMode %ms_main LocalSize 1 1 1 + OpExecutionMode %ms_main OutputTrianglesEXT + OpExecutionMode %ms_main OutputVertices 3 + OpExecutionMode %ms_main OutputPrimitivesEXT 1 + OpName %naga_num_vertices "naga_num_vertices" + OpName %naga_num_primitives "naga_num_primitives" + OpMemberName %TaskPayload 0 "colorMask" + OpMemberName %TaskPayload 1 "visible" + OpName %TaskPayload "TaskPayload" + OpMemberName %VertexOutput 0 "position" + OpMemberName %VertexOutput 1 "color" + OpName %VertexOutput "VertexOutput" + OpMemberName %PrimitiveOutput 0 "index" + OpMemberName %PrimitiveOutput 1 "cull" + OpMemberName %PrimitiveOutput 2 "colorMask" + OpName %PrimitiveOutput "PrimitiveOutput" + OpMemberName %PrimitiveInput 0 "colorMask" + OpName %PrimitiveInput "PrimitiveInput" + OpName %taskPayload "taskPayload" + OpName %workgroupData "workgroupData" + OpName %index "index" + OpName %id "id" + OpName %ms_main "ms_main" + OpName %v "v" + OpName %p "p" + OpMemberDecorate %_struct_34 0 BuiltIn Position + OpDecorate %_struct_34 Block + OpMemberDecorate %_struct_38 0 BuiltIn CullPrimitiveEXT + OpDecorate %_struct_38 Block + OpDecorate %41 PerPrimitiveEXT + OpDecorate %_struct_42 Block + OpMemberDecorate %_struct_42 0 Location 0 + OpDecorate %48 PerPrimitiveEXT + OpDecorate %48 BuiltIn PrimitiveTriangleIndicesEXT + OpDecorate %_struct_49 Block + OpMemberDecorate %_struct_49 0 Location 1 + OpDecorate %52 PerPrimitiveEXT + OpMemberDecorate %TaskPayload 0 Offset 0 + OpMemberDecorate %TaskPayload 1 Offset 16 + OpMemberDecorate %VertexOutput 0 Offset 0 + OpMemberDecorate %VertexOutput 1 Offset 16 + OpMemberDecorate %PrimitiveOutput 0 Offset 0 + OpMemberDecorate %PrimitiveOutput 1 Offset 12 + OpMemberDecorate %PrimitiveOutput 2 Offset 16 + OpMemberDecorate %PrimitiveInput 0 Offset 0 + OpDecorate %index BuiltIn LocalInvocationIndex + OpDecorate %id BuiltIn GlobalInvocationId + %void = OpTypeVoid + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %bool = OpTypeBool +%TaskPayload = OpTypeStruct %v4float %bool +%VertexOutput = OpTypeStruct %v4float %v4float + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%PrimitiveOutput = OpTypeStruct %v3uint %bool %v4float +%PrimitiveInput = OpTypeStruct %v4float +%_ptr_TaskPayloadWorkgroupEXT_TaskPayload = OpTypePointer TaskPayloadWorkgroupEXT %TaskPayload +%taskPayload = OpVariable %_ptr_TaskPayloadWorkgroupEXT_TaskPayload TaskPayloadWorkgroupEXT +%_ptr_Workgroup_float = OpTypePointer Workgroup %float +%workgroupData = OpVariable %_ptr_Workgroup_float Workgroup +%_ptr_Input_uint = OpTypePointer Input %uint + %index = OpVariable %_ptr_Input_uint Input +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %id = OpVariable %_ptr_Input_v3uint Input +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint +%naga_num_vertices = OpVariable %_ptr_Workgroup_uint Workgroup +%naga_num_primitives = OpVariable %_ptr_Workgroup_uint Workgroup + %uint_3 = OpConstant %uint 3 +%_arr_VertexOutput_uint_3 = OpTypeArray %VertexOutput %uint_3 +%_ptr_Workgroup__arr_VertexOutput_uint_3 = OpTypePointer Workgroup %_arr_VertexOutput_uint_3 + %28 = OpVariable %_ptr_Workgroup__arr_VertexOutput_uint_3 Workgroup + %uint_1 = OpConstant %uint 1 +%_arr_PrimitiveOutput_uint_1 = OpTypeArray %PrimitiveOutput %uint_1 +%_ptr_Workgroup__arr_PrimitiveOutput_uint_1 = OpTypePointer Workgroup %_arr_PrimitiveOutput_uint_1 + %32 = OpVariable %_ptr_Workgroup__arr_PrimitiveOutput_uint_1 Workgroup + %_struct_34 = OpTypeStruct %v4float +%_arr__struct_34_uint_3 = OpTypeArray %_struct_34 %uint_3 +%_ptr_Output__arr__struct_34_uint_3 = OpTypePointer Output %_arr__struct_34_uint_3 + %37 = OpVariable %_ptr_Output__arr__struct_34_uint_3 Output + %_struct_38 = OpTypeStruct %bool +%_arr__struct_38_uint_1 = OpTypeArray %_struct_38 %uint_1 +%_ptr_Output__arr__struct_38_uint_1 = OpTypePointer Output %_arr__struct_38_uint_1 + %41 = OpVariable %_ptr_Output__arr__struct_38_uint_1 Output + %_struct_42 = OpTypeStruct %v4float +%_arr__struct_42_uint_1 = OpTypeArray %_struct_42 %uint_1 +%_ptr_Output__arr__struct_42_uint_1 = OpTypePointer Output %_arr__struct_42_uint_1 + %45 = OpVariable %_ptr_Output__arr__struct_42_uint_1 Output +%_arr_v3uint_uint_1 = OpTypeArray %v3uint %uint_1 +%_ptr_Output__arr_v3uint_uint_1 = OpTypePointer Output %_arr_v3uint_uint_1 + %48 = OpVariable %_ptr_Output__arr_v3uint_uint_1 Output + %_struct_49 = OpTypeStruct %v4float +%_arr__struct_49_uint_1 = OpTypeArray %_struct_49 %uint_1 +%_ptr_Output__arr__struct_49_uint_1 = OpTypePointer Output %_arr__struct_49_uint_1 + %52 = OpVariable %_ptr_Output__arr__struct_49_uint_1 Output + %54 = OpTypeFunction %void + %uint_3_0 = OpConstant %uint 3 + %uint_1_0 = OpConstant %uint 1 + %float_2 = OpConstant %float 2 + %float_0 = OpConstant %float 0 + %float_n1 = OpConstant %float -1 + %float_1 = OpConstant %float 1 + %61 = OpConstantComposite %v4float %float_0 %float_n1 %float_0 %float_1 + %62 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1 + %uint_0 = OpConstant %uint 0 + %64 = OpConstantComposite %v4float %float_n1 %float_1 %float_0 %float_1 + %65 = OpConstantComposite %v4float %float_0 %float_0 %float_1 %float_1 + %66 = OpConstantComposite %v4float %float_1 %float_1 %float_0 %float_1 + %67 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1 + %uint_2 = OpConstant %uint 2 + %69 = OpConstantComposite %v3uint %uint_0 %uint_1_0 %uint_2 + %70 = OpConstantComposite %v4float %float_1 %float_0 %float_1 %float_1 +%_ptr_Function_VertexOutput = OpTypePointer Function %VertexOutput + %73 = OpConstantNull %VertexOutput +%_ptr_Function_PrimitiveOutput = OpTypePointer Function %PrimitiveOutput + %76 = OpConstantNull %PrimitiveOutput +%_ptr_Function_v4float = OpTypePointer Function %v4float +%_ptr_TaskPayloadWorkgroupEXT_v4float = OpTypePointer TaskPayloadWorkgroupEXT %v4float +%_ptr_Output_VertexOutput = OpTypePointer Output %VertexOutput +%_ptr_Function_v3uint = OpTypePointer Function %v3uint +%_ptr_Function_bool = OpTypePointer Function %bool +%_ptr_TaskPayloadWorkgroupEXT_bool = OpTypePointer TaskPayloadWorkgroupEXT %bool +%_ptr_Output_PrimitiveOutput = OpTypePointer Output %PrimitiveOutput + %uint_1_1 = OpConstant %uint 1 +%_arr_PrimitiveOutput_uint_1_1 = OpTypeArray %PrimitiveOutput %uint_1_1 +%_ptr_Workgroup__arr_PrimitiveOutput_uint_1_1 = OpTypePointer Workgroup %_arr_PrimitiveOutput_uint_1_1 + %116 = OpVariable %_ptr_Workgroup__arr_PrimitiveOutput_uint_1_1 Workgroup +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Workgroup_VertexOutput = OpTypePointer Workgroup %VertexOutput +%_ptr_Output_v4float = OpTypePointer Output %v4float +%_ptr_Workgroup_PrimitiveOutput = OpTypePointer Workgroup %PrimitiveOutput +%_ptr_Output_v3uint = OpTypePointer Output %v3uint +%_ptr_Output_bool = OpTypePointer Output %bool + %ms_main = OpFunction %void None %54 + %16 = OpLabel + %v = OpVariable %_ptr_Function_VertexOutput Function %73 + %p = OpVariable %_ptr_Function_PrimitiveOutput Function %76 + %19 = OpLoad %uint %index + %22 = OpLoad %v3uint %id + OpBranch %77 + %77 = OpLabel + OpSetMeshOutputsEXT %uint_3_0 %uint_1_0 + OpStore %naga_num_vertices %uint_3_0 + OpStore %naga_num_primitives %uint_1_0 + OpStore %workgroupData %float_2 + %79 = OpAccessChain %_ptr_Function_v4float %v %uint_0 + OpStore %79 %61 + %81 = OpAccessChain %_ptr_TaskPayloadWorkgroupEXT_v4float %taskPayload %uint_0 + %82 = OpLoad %v4float %81 + %83 = OpFMul %v4float %62 %82 + %84 = OpAccessChain %_ptr_Function_v4float %v %uint_1_0 + OpStore %84 %83 + %85 = OpLoad %VertexOutput %v + %86 = OpAccessChain %_ptr_Output_VertexOutput %28 %uint_0 + OpStore %86 %85 + %88 = OpAccessChain %_ptr_Function_v4float %v %uint_0 + OpStore %88 %64 + %89 = OpAccessChain %_ptr_TaskPayloadWorkgroupEXT_v4float %taskPayload %uint_0 + %90 = OpLoad %v4float %89 + %91 = OpFMul %v4float %65 %90 + %92 = OpAccessChain %_ptr_Function_v4float %v %uint_1_0 + OpStore %92 %91 + %93 = OpLoad %VertexOutput %v + %94 = OpAccessChain %_ptr_Output_VertexOutput %28 %uint_1_0 + OpStore %94 %93 + %95 = OpAccessChain %_ptr_Function_v4float %v %uint_0 + OpStore %95 %66 + %96 = OpAccessChain %_ptr_TaskPayloadWorkgroupEXT_v4float %taskPayload %uint_0 + %97 = OpLoad %v4float %96 + %98 = OpFMul %v4float %67 %97 + %99 = OpAccessChain %_ptr_Function_v4float %v %uint_1_0 + OpStore %99 %98 + %100 = OpLoad %VertexOutput %v + %101 = OpAccessChain %_ptr_Output_VertexOutput %28 %uint_2 + OpStore %101 %100 + %103 = OpAccessChain %_ptr_Function_v3uint %p %uint_0 + OpStore %103 %69 + %106 = OpAccessChain %_ptr_TaskPayloadWorkgroupEXT_bool %taskPayload %uint_1_0 + %107 = OpLoad %bool %106 + %108 = OpLogicalNot %bool %107 + %109 = OpAccessChain %_ptr_Function_bool %p %uint_1_0 + OpStore %109 %108 + %110 = OpAccessChain %_ptr_Function_v4float %p %uint_2 + OpStore %110 %70 + %111 = OpLoad %PrimitiveOutput %p + %112 = OpAccessChain %_ptr_Output_PrimitiveOutput %32 %uint_0 + OpStore %112 %111 + %118 = OpLoad %uint %naga_num_vertices + %119 = OpLoad %uint %naga_num_primitives + %127 = OpVariable %_ptr_Function_uint Function %uint_0 + OpBranch %121 + %123 = OpLabel + OpStore %127 %uint_0 + OpBranch %122 + %121 = OpLabel + OpLoopMerge %123 %128 None + %129 = OpLoad %uint %127 + %130 = OpULessThan %bool %129 %118 + OpBranchConditional %130 %124 %123 + %128 = OpLabel + %131 = OpLoad %uint %127 + %132 = OpIAdd %uint %131 %uint_1_0 + OpStore %127 %132 + OpBranch %121 + %122 = OpLabel + OpLoopMerge %126 %133 None + %134 = OpLoad %uint %127 + %135 = OpULessThan %bool %134 %119 + OpBranchConditional %135 %125 %126 + %133 = OpLabel + %136 = OpLoad %uint %127 + %137 = OpIAdd %uint %136 %uint_1_0 + OpStore %127 %137 + OpBranch %122 + %124 = OpLabel + %138 = OpLoad %uint %127 + %139 = OpAccessChain %_ptr_Workgroup_VertexOutput %28 %138 + %141 = OpLoad %VertexOutput %139 + %142 = OpCompositeExtract %v4float %141 63 + %143 = OpAccessChain %_ptr_Output_v4float %37 %138 %uint_0 + OpStore %143 %142 + %145 = OpCompositeExtract %v4float %141 56 + %146 = OpAccessChain %_ptr_Output_v4float %45 %138 %uint_0 + OpStore %146 %145 + OpBranch %128 + %125 = OpLabel + %147 = OpLoad %uint %127 + %148 = OpAccessChain %_ptr_Workgroup_PrimitiveOutput %116 %147 + %150 = OpLoad %VertexOutput %148 + %151 = OpCompositeExtract %v3uint %150 63 + %152 = OpAccessChain %_ptr_Output_v3uint %48 %147 + OpStore %152 %151 + %154 = OpCompositeExtract %bool %150 56 + %155 = OpAccessChain %_ptr_Output_bool %41 %147 %uint_0 + OpStore %155 %154 + %157 = OpCompositeExtract %v4float %150 68 + %158 = OpAccessChain %_ptr_Output_v4float %52 %147 %uint_0 + OpStore %158 %157 + OpBranch %133 + %126 = OpLabel + OpReturn + OpFunctionEnd From 789ba11db77c6391c926a47bab4407bd64c2e39e Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 9 Aug 2025 15:36:47 -0500 Subject: [PATCH 66/84] A little more progress (I'm paranoid) --- naga/src/back/spv/block.rs | 27 ++++++++----- naga/src/back/spv/writer.rs | 14 +++++++ shaders/mesh.spv | Bin 4124 -> 4216 bytes shaders/mesh.spv-asm | 74 ++++++++++++++++++------------------ 4 files changed, 69 insertions(+), 46 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 6e04bbbe015..5bb918e6fc2 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -330,7 +330,6 @@ impl Writer { // All this for the vertex loop lol let u32_type_id = self.get_u32_type_id(); - let u32_ptr_id = self.get_pointer_type_id(u32_type_id, spirv::StorageClass::Function); let zero_u32 = self.get_constant_scalar(crate::Literal::U32(0)); let vertex_loop_header = self.id_gen.next(); let prim_loop_header = self.id_gen.next(); @@ -339,12 +338,16 @@ impl Writer { let prim_loop_body = self.id_gen.next(); let func_end = self.id_gen.next(); let counter_var = self.id_gen.next(); - body.push(Instruction::variable( - u32_ptr_id, + + Instruction::variable( + self.get_pointer_type_id(u32_type_id, spirv::StorageClass::Workgroup), counter_var, - spirv::StorageClass::Function, - Some(zero_u32), - )); + spirv::StorageClass::Workgroup, + None, + ) + .to_words(&mut self.logical_layout.declarations); + + body.push(Instruction::store(counter_var, zero_u32, None)); body.push(Instruction::branch(vertex_loop_header)); @@ -432,11 +435,12 @@ impl Writer { member.ty_id, val_to_copy, vert_to_copy, - &[self.get_constant_scalar(crate::Literal::U32(member_id as u32))], + &[member_id as u32], )); let ptr_to_copy_to = self.id_gen.next(); match member.binding { crate::Binding::BuiltIn(_) => { + // TODO: flip coordinates body.push(Instruction::access_chain( self.get_pointer_type_id(member.ty_id, spirv::StorageClass::Output), ptr_to_copy_to, @@ -479,7 +483,7 @@ impl Writer { )); let prim_to_copy = self.id_gen.next(); body.push(Instruction::load( - vert_info.inner_ty, + prim_info.inner_ty, prim_to_copy, prim_to_copy_ptr, None, @@ -493,7 +497,7 @@ impl Writer { member.ty_id, val_to_copy, prim_to_copy, - &[self.get_constant_scalar(crate::Literal::U32(member_id as u32))], + &[member_id as u32], )); let ptr_to_copy_to = self.id_gen.next(); match member.binding { @@ -3921,6 +3925,9 @@ impl BlockContext<'_> { vertex_count, primitive_count, }) => { + self.writer + .require_any("mesh shaders", &[spirv::Capability::MeshShadingEXT])?; + self.writer.use_extension("SPV_EXT_mesh_shader"); let mut ins = Instruction::new(spirv::Op::SetMeshOutputsEXT); ins.add_operand(self.cached[vertex_count]); ins.add_operand(self.cached[primitive_count]); @@ -3961,7 +3968,7 @@ impl BlockContext<'_> { .mesh_shader_output_variable(type_handle, is_prim, 0)?; let out_ptr_id = self.gen_id(); block.body.push(Instruction::access_chain( - self.get_pointer_type_id(info.inner_ty, spirv::StorageClass::Output), + self.get_pointer_type_id(info.inner_ty, spirv::StorageClass::Workgroup), out_ptr_id, info.var_id, &[self.cached[index]], diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 0dcfa4bde79..e19227e1a53 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -1059,6 +1059,10 @@ impl Writer { vert_info.array_size_id, )?; iface.varying_ids.push(v.var_id); + if self.flags.contains(WriterFlags::DEBUG) { + Instruction::name(v.var_id, "naga_vertex_builtin_outputs") + .to_words(&mut self.logical_layout.debugs); + } mesh_return_info.vertex_builtin_block = Some(v); } if mesh_return_info.primitive_members.iter().any(|a| { @@ -1132,6 +1136,10 @@ impl Writer { Instruction::decorate(v.var_id, spirv::Decoration::PerPrimitiveEXT, &[]) .to_words(&mut self.logical_layout.annotations); iface.varying_ids.push(v.var_id); + if self.flags.contains(WriterFlags::DEBUG) { + Instruction::name(v.var_id, "naga_primitive_builtin_outputs") + .to_words(&mut self.logical_layout.debugs); + } mesh_return_info.primitive_builtin_block = Some(v); } { @@ -1195,6 +1203,10 @@ impl Writer { ) .to_words(&mut self.logical_layout.annotations); iface.varying_ids.push(v.var_id); + if self.flags.contains(WriterFlags::DEBUG) { + Instruction::name(v.var_id, "naga_primitive_indices_outputs") + .to_words(&mut self.logical_layout.debugs); + } mesh_return_info.primitive_indices = Some(v); } crate::Binding::Location { location, .. } => { @@ -2466,6 +2478,8 @@ impl Writer { } if per_primitive && stage == crate::ShaderStage::Fragment { others.push(Decoration::PerPrimitiveEXT); + self.require_any("mesh shaders", &[spirv::Capability::MeshShadingEXT])?; + self.use_extension("SPV_EXT_mesh_shader"); } Ok(BindingDecorations::Location { location, diff --git a/shaders/mesh.spv b/shaders/mesh.spv index bcac61a4405ff1068b3c1f5481c8aec317ab0b7f..8bfb64b4fedb4331995157a283b6f2457fbb287c 100644 GIT binary patch delta 560 zcmZWmO-sW-5S?uj+Z1989*WdMKsCHDGD}^S!ot?Mu&CVoK_s4aN+-jaoK`TV``Q=nZY>`cC$b#lY)9d=}(7*Lg zBY7Fhz`KsZRup!~q9UzpO{*=hWGK7-oGjIC&g*1wF3qx6UkHhk4RMzjrur__ zu>KYr+q+~^1t&3J0xs4kL}Mm@%W^wAA15QbXQ%_Goa{KqLNru=v2yZ&(;jey#<)@+ zV2+_3PO)BnRJJp{;9tcRE& VXJZb~Lrk&X0%m>8O_V5C{{SlnS|0!a delta 521 zcmYk2y-ve06os$rgb<`iNDM3tkq`qzB?bm0M5{{h08ETbjBE@nC@c(6{!^epfM-B? zxpw0_#YPNY?)9;ceQqXYQx?9nnpxs(#mv6Gi)Gi2-6(Uu?&f{I$N9ltX^CC4oj?X! z-&1|iw0;WxLfC%|`*~P5?KB_yV%t(XMXDfcFN;H0>EHApp@@>%i z)Pc>-65P?Rfqc??WRj+{(f2^FyS53KOo?3%)4+x}j zM{oktW9a9g>v4_#0@8j%r>5UBh7FLfXO*7`Iw(_0eFK?d;)ebm) Date: Sat, 9 Aug 2025 16:40:03 -0500 Subject: [PATCH 67/84] A little more progress (still very broken) --- naga/src/back/spv/block.rs | 151 ++++++++++---------- naga/src/back/spv/mod.rs | 1 + naga/src/back/spv/writer.rs | 16 ++- shaders/mesh.spv | Bin 4216 -> 4236 bytes shaders/mesh.spv-asm | 277 ++++++++++++++++++------------------ 5 files changed, 229 insertions(+), 216 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 5bb918e6fc2..459e750824b 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -334,81 +334,17 @@ impl Writer { let vertex_loop_header = self.id_gen.next(); let prim_loop_header = self.id_gen.next(); let in_between_loops = self.id_gen.next(); - let vertex_loop_body = self.id_gen.next(); - let prim_loop_body = self.id_gen.next(); let func_end = self.id_gen.next(); - let counter_var = self.id_gen.next(); - - Instruction::variable( - self.get_pointer_type_id(u32_type_id, spirv::StorageClass::Workgroup), - counter_var, - spirv::StorageClass::Workgroup, - None, - ) - .to_words(&mut self.logical_layout.declarations); + let counter_var = self.mesh_state.counter_var.unwrap(); body.push(Instruction::store(counter_var, zero_u32, None)); body.push(Instruction::branch(vertex_loop_header)); - { - body.push(Instruction::label(in_between_loops)); - body.push(Instruction::store(counter_var, zero_u32, None)); - body.push(Instruction::branch(prim_loop_header)); - } - - let mut get_loop_continue_id = |loop_body, loop_header, loop_merge, count_id| { - let loop_continue = self.id_gen.next(); - - // Loop header - check if i is less than num vertices to copy - { - body.push(Instruction::label(loop_header)); - body.push(Instruction::loop_merge( - loop_merge, - loop_continue, - spirv::SelectionControl::empty(), - )); - let val_i = self.id_gen.next(); - body.push(Instruction::load(u32_type_id, val_i, counter_var, None)); - let cond = self.id_gen.next(); - let mut cmp_ins = Instruction::new(spirv::Op::ULessThan); - cmp_ins.set_type(self.get_bool_type_id()); - cmp_ins.set_result(cond); - cmp_ins.add_operands(alloc::vec![val_i, count_id]); - body.push(cmp_ins); - body.push(Instruction::branch_conditional(cond, loop_body, loop_merge)); - } - // Loop continue - increment i - { - body.push(Instruction::label(loop_continue)); - let val_i = self.id_gen.next(); - let new_val_i = self.id_gen.next(); - body.push(Instruction::load(u32_type_id, val_i, counter_var, None)); - let mut add_ins = Instruction::new(spirv::Op::IAdd); - add_ins.set_type(u32_type_id); - add_ins.set_result(new_val_i); - add_ins.add_operands(alloc::vec![ - val_i, - self.get_constant_scalar(crate::Literal::U32(1)) - ]); - body.push(add_ins); - body.push(Instruction::store(counter_var, new_val_i, None)); - body.push(Instruction::branch(loop_header)); - } - loop_continue - }; - let vertex_continue = get_loop_continue_id( - vertex_loop_body, - vertex_loop_header, - in_between_loops, - vert_count_id, - ); - let prim_continue = - get_loop_continue_id(prim_loop_body, prim_loop_header, func_end, prim_count_id); - + let vertex_copy_body = // Vertex copies { - body.push(Instruction::label(vertex_loop_body)); + let mut body = Vec::new(); let val_i = self.id_gen.next(); body.push(Instruction::load(u32_type_id, val_i, counter_var, None)); @@ -447,7 +383,7 @@ impl Writer { return_info.vertex_builtin_block.as_ref().unwrap().var_id, &[ val_i, - self.get_constant_scalar(crate::Literal::U32(builtin_index as u32)), + self.get_constant_scalar(crate::Literal::U32(builtin_index)), ], )); builtin_index += 1; @@ -464,13 +400,12 @@ impl Writer { } body.push(Instruction::store(ptr_to_copy_to, val_to_copy, None)); } - - body.push(Instruction::branch(vertex_continue)); - } + body + }; // Primitive copies - { - body.push(Instruction::label(prim_loop_body)); + let primitive_copy_body = { + let mut body = Vec::new(); let val_i = self.id_gen.next(); body.push(Instruction::load(u32_type_id, val_i, counter_var, None)); @@ -520,7 +455,7 @@ impl Writer { return_info.primitive_builtin_block.as_ref().unwrap().var_id, &[ val_i, - self.get_constant_scalar(crate::Literal::U32(builtin_index as u32)), + self.get_constant_scalar(crate::Literal::U32(builtin_index)), ], )); builtin_index += 1; @@ -537,9 +472,75 @@ impl Writer { } body.push(Instruction::store(ptr_to_copy_to, val_to_copy, None)); } + body + }; - body.push(Instruction::branch(prim_continue)); + let mut get_loop_continue_id = |body: &mut Vec, mut loop_body_block, loop_header, loop_merge, count_id| { + let condition_check = self.id_gen.next(); + let loop_continue = self.id_gen.next(); + let loop_body = self.id_gen.next(); + + // Loop header + { + body.push(Instruction::label(loop_header)); + body.push(Instruction::loop_merge( + loop_merge, + loop_continue, + spirv::SelectionControl::empty(), + )); + body.push(Instruction::branch(condition_check)); + } + // Condition check - check if i is less than num vertices to copy + { + body.push(Instruction::label(condition_check)); + let val_i = self.id_gen.next(); + body.push(Instruction::load(u32_type_id, val_i, counter_var, None)); + let cond = self.id_gen.next(); + let mut cmp_ins = Instruction::new(spirv::Op::ULessThan); + cmp_ins.set_type(self.get_bool_type_id()); + cmp_ins.set_result(cond); + cmp_ins.add_operands(alloc::vec![val_i, count_id]); + body.push(cmp_ins); + body.push(Instruction::branch_conditional(cond, loop_body, loop_merge)); + } + // Loop body + { + body.push(Instruction::label(loop_body)); + body.append(&mut loop_body_block); + + body.push(Instruction::branch(loop_continue)); + } + // Loop continue - increment i + { + body.push(Instruction::label(loop_continue)); + let val_i = self.id_gen.next(); + let new_val_i = self.id_gen.next(); + body.push(Instruction::load(u32_type_id, val_i, counter_var, None)); + let mut add_ins = Instruction::new(spirv::Op::IAdd); + add_ins.set_type(u32_type_id); + add_ins.set_result(new_val_i); + add_ins.add_operands(alloc::vec![ + val_i, + self.get_constant_scalar(crate::Literal::U32(1)) + ]); + body.push(add_ins); + body.push(Instruction::store(counter_var, new_val_i, None)); + body.push(Instruction::branch(loop_header)); + } + }; + get_loop_continue_id( + body, + vertex_copy_body, + vertex_loop_header, + in_between_loops, + vert_count_id, + ); + { + body.push(Instruction::label(in_between_loops)); + body.push(Instruction::store(counter_var, zero_u32, None)); + body.push(Instruction::branch(prim_loop_header)); } + get_loop_continue_id(body, primitive_copy_body, prim_loop_header, func_end, prim_count_id); body.push(Instruction::label(func_end)); Ok(()) diff --git a/naga/src/back/spv/mod.rs b/naga/src/back/spv/mod.rs index 4dae9bcdec7..c74d7265bcf 100644 --- a/naga/src/back/spv/mod.rs +++ b/naga/src/back/spv/mod.rs @@ -952,6 +952,7 @@ pub struct WriteMeshInfo { pub primitive_outputs_by_type: crate::FastHashMap, MeshOutputInfo>, pub num_vertices_var: Option, pub num_primitives_var: Option, + pub counter_var: Option, } #[derive(Clone)] diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index e19227e1a53..8b068430693 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -101,6 +101,7 @@ impl Writer { primitive_outputs_by_type: crate::FastHashMap::default(), num_vertices_var: None, num_primitives_var: None, + counter_var: None, }, }) } @@ -168,6 +169,7 @@ impl Writer { .recycle(), num_vertices_var: None, num_primitives_var: None, + counter_var: None, }, }; @@ -963,6 +965,7 @@ impl Writer { iface .varying_ids .push(self.mesh_state.num_primitives_var.unwrap()); + iface.varying_ids.push(self.mesh_state.counter_var.unwrap()); let vertex_members = match &ir_module.types[mesh_info.vertex_output_type] { &crate::Type { @@ -2635,9 +2638,9 @@ impl Writer { is_primitive: bool, array_len: Word, ) -> Result { + let u32_ty = self.get_u32_type_id(); + let u32_ptr = self.get_pointer_type_id(u32_ty, spirv::StorageClass::Workgroup); if self.mesh_state.num_vertices_var.is_none() { - let u32_ty = self.get_u32_type_id(); - let u32_ptr = self.get_pointer_type_id(u32_ty, spirv::StorageClass::Workgroup); let var_id = self.id_gen.next(); Instruction::variable(u32_ptr, var_id, spirv::StorageClass::Workgroup, None) .to_words(&mut self.logical_layout.declarations); @@ -2648,8 +2651,6 @@ impl Writer { } } if self.mesh_state.num_primitives_var.is_none() { - let u32_ty = self.get_u32_type_id(); - let u32_ptr = self.get_pointer_type_id(u32_ty, spirv::StorageClass::Workgroup); let var_id = self.id_gen.next(); Instruction::variable(u32_ptr, var_id, spirv::StorageClass::Workgroup, None) .to_words(&mut self.logical_layout.declarations); @@ -2659,6 +2660,13 @@ impl Writer { .to_words(&mut self.logical_layout.debugs); } } + // Counter for when we copy stuff at the end, very hacky stuff (check it out in `write_mesh_shader_return`!) + if self.mesh_state.counter_var.is_none() { + let var_id = self.id_gen.next(); + Instruction::variable(u32_ptr, var_id, spirv::StorageClass::Workgroup, None) + .to_words(&mut self.logical_layout.declarations); + self.mesh_state.counter_var = Some(var_id); + } let entry = if is_primitive { self.mesh_state.primitive_outputs_by_type.get(&output_type) } else { diff --git a/shaders/mesh.spv b/shaders/mesh.spv index 8bfb64b4fedb4331995157a283b6f2457fbb287c..37254f31d55a5e809331d45caebc5d90f432fa05 100644 GIT binary patch literal 4236 zcmZveX>(Ln5Qc9yb_FGXAjCuzG+-1Zh$1jSFd!g75OEy`5@96C#LOftZV|r~ zU;HMeKfqt5rB+$x^W2k)itOa{Y8=aA-VR2ya~ffg=Zc>W#sk&AoS-e{I&H$bE~mrP=S) z*n&M$FOO8JqtwqbsB95f1G>NsU?o@u)`4!&12%zPa4lHEeAY4Fc>_zBPyQE*F3DPR z-8yy=_GNs=w`Ftlxkf9eD&^6Mk@Dowc%yo9sGfZGFyk8=uZ~n3)k(Z<+5Eh(+-J_v zx$=pL>TshvTCPnr#wHrZEXe!LV`g&y6PCxhu32%_(Lo!TDaUI4H$6_)hHK*oEA=y& zbEqKidM2y&>WSeYm}%}PAp@23!?ns_o;`OuJsYdlSxIeF(|mdJ^SVg0<&Nb`JCv^o zGml-M!l1#Sb4c^$^8AV6VSRQg*9?liT33D`wlbAAej&VLcD(#d{Jv54*8bY^`_d?^ z&)VLLv$gRvr^ag&W4kMj3U(WJz&jHCws8}@Z`HwRU-2&L+ly~9&uhu{BgepAs;osi zqR)O}oJwk_GNS5E(8bYrcjU)%c_`PZX20q4}O9p5hVDU9 zVUGS4NNYvDw%6>YzJ+8g+5-i^TiR%5%z?vY$4ws*)_dFyF=F2($tu^NQ+Fd}-y)a0*CH>mla&tOg`+?k^`Yrt1r|q2^Idyy7 z0n9N@sXu%>3taf3j}ksd#P*?E!~BR1->$?3U!3E?l=FXiy9@OqH|F1i&wbj+OZ03W z0wv)7=!?1g(Tla!J6ZWYr1xI*uye|XfxZKY_g?E$9!$PN$>-h~dl>245BoT_y7ly* zO1eF2SCj2M)_wtLe%RyK<~wJs)&GYy0q z`7qhezlAQ`Q-2E`-o-y*{C(Jl&pq1{kG3@}>VC(9_Z#Y6?_*BSU;x-l2^g#GUDofJJPH1tbo~lo=AN3c@ld! zkdL~9=*2#@jf*~ql0W)<9@{?m0QXbd82!Gb)4=;y0{XRm`}%!LXMlaWPUrAm4+Ht1 zl0A|*b9|4Zz?!i)+Q#VjuGN74=t;XDSl@R#2J{>6`+X5~ffBGsZDWj|hdc|s=V6~i zUkQx$x4Hy;C+CsA6XhS|zJ&Y~IP`yl)US+MpQBsjD!sV&FMynL{!I<-&w#beRgc_P z(9Lxn-tAX`XCZHl_y08@f0!8G&=in!^zkjeh0>yn!Sk@p6=c}*bl-bC*K z#XLDXR$(r)!_R*B9Wdt#q$nMt%hx=3YVSSH|4m zpj$uo`df54&(pou{u)@zT=mGkgl=x!nYYjNu&1(j6J|Cm^f?}SWvF?%k(Ln5Qc9y0s$eiix>ll$`(-rqR6IT06~Hv;5rT@!bma`Gm`*r#07W76%_T8 zU;HMeKfqt5rB+$x^W2s`jk4DO;Xp*^h|N%~^BSl=M#v zv#cYVksawjR@!soXlZz`ex_7EQyv%`&1SD3i0gJEOOacU)yNuT17fjWWG>RlTGlYvHA6aCOa501c4n=) zy$oyzfv?~*zAbCd*Qu6ImrK>L;nMivXrpp!u%3LbKjj-4tqfNhm2tdn*{r;;+-J_< z`O?X;%21O?IXN^4Gszt#q`!P&s8$}xv)d=rvyobzoz$vA^X1LY>!Qt;JC<+lP`)Ez z9^0Y8LxY3o(dNtL`C~&v`s`G$87cN^UHSev%2e9;+3-HovChL}Y->LA*1Vo_@5PQawSCO> z{9UIPZLYOrURJ^R1ZS*VXX0Wmig7U$#W>%cPccp|>Un=%L(U$Hxp8ih+n3&p{B4Ms zw)6Az8?b;1)>zD*TF~9d5@K4>V)a5I+R$Af_bM0I{>927erKY)5g+T!Ld#jJEA=dA zzByfZ>`l9y-<#0O7CGBlwl!h*E2n=Rwz1aJFLoXye?E2-;+p!!@$E97GP&O#^ouuujALa`0gzS-wO6jty2_HIS)T5R`V z?mDzMa@S)UCvUFUzbkUa_nwm5R{PjT|*ioKiWuHbhw z+WC%m^+56k-U4n)esdl~cy{U+Ka|7CeDT&CPy8PKhbQrl^}Ka^+=iHAoLYbQwimeY zMISrx`9$naY-^YwvEkd5xZsOxJd$#5l=o<%UgXC5yYYEW>$!Qpn>~mc- zwY8noy=doN>EYzm`w)GPC*HZ%r#_H;Pb8mbXKX*(yB_#BSlfE~UrM$;iq9nM9E&Sx z^8>#EHs3X4ucO#ah_mSbLG;O)KZZ75-gy!?5~tt4#r852(eL-*A`<;x#&%8uUrjjr zy_T^3ZKg}ld=uj1to{Y#-;1sIJkvfT&Qi{^+@Cnla2qSx%L2sjoY=J%BYxNZrrtrc zb=AKtY{|R>zSr$^x)d$e_PZ9m-&F6yF4puN9YXBInJ`xDtn2rk9Y*FL`t8B}KZ(d+ zB1U`!@easG-J{snjdjJwS;Kulh3Gf_IQkf}9Em=}#zegn*u_4@JCol&pGKzl`Ap)Y z&u8=aER&DA&tVt)6dMcXd{ob|Hi1QZbE#8CZ_pZH+*r)q+4d?nSBL8#3 zLy0rT`#OwRGtNeAjDBaWis+A?#C~_I-+`_n`i=K~k09Mh^e8sQc<;tIvb2EDVLR*Y z_afRn@5u$U_vE!3_+CvuWB#PBF%yVStn(JO^{&&G=kPWn=lcJUBYqt**L5b)k^2s| zxf5jC^Sg*#oRL1cVxRV8FK?nRAwE&>J?vsH?}O#syS<3tK+Lrl^CR~I>|!q;g5`?6 z$k|Jri~EZFkFd@6{di|TMw~HuW7^T5Ao7QaX+?jUI23s^vdietkkyEJI}qQOoUxJj zIkvT$kjVQ2djnF;lQY(yC(!QM{YTGVVn@%;)K`e#eR*R#&|f3+uI)GWo5Z2=ypp#_?$dYt JFDq_A{sX8xTsQy# diff --git a/shaders/mesh.spv-asm b/shaders/mesh.spv-asm index e9bbcd77708..298b946d8c1 100644 --- a/shaders/mesh.spv-asm +++ b/shaders/mesh.spv-asm @@ -1,14 +1,14 @@ ; SPIR-V ; Version: 1.4 ; Generator: Khronos; 28 -; Bound: 157 +; Bound: 158 ; Schema: 0 OpCapability Shader OpCapability MeshShadingEXT OpExtension "SPV_EXT_mesh_shader" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 - OpEntryPoint MeshEXT %ms_main "ms_main" %index %id %taskPayload %28 %32 %naga_num_vertices %naga_num_primitives %naga_vertex_builtin_outputs %naga_primitive_builtin_outputs %45 %naga_primitive_indices_outputs %52 %workgroupData + OpEntryPoint MeshEXT %ms_main "ms_main" %index %id %taskPayload %29 %33 %naga_num_vertices %naga_num_primitives %26 %naga_vertex_builtin_outputs %naga_primitive_builtin_outputs %46 %naga_primitive_indices_outputs %53 %workgroupData OpExecutionMode %ms_main LocalSize 1 1 1 OpExecutionMode %ms_main OutputTrianglesEXT OpExecutionMode %ms_main OutputVertices 3 @@ -37,18 +37,18 @@ OpName %ms_main "ms_main" OpName %v "v" OpName %p "p" - OpMemberDecorate %_struct_34 0 BuiltIn Position - OpDecorate %_struct_34 Block - OpMemberDecorate %_struct_38 0 BuiltIn CullPrimitiveEXT - OpDecorate %_struct_38 Block + OpMemberDecorate %_struct_35 0 BuiltIn Position + OpDecorate %_struct_35 Block + OpMemberDecorate %_struct_39 0 BuiltIn CullPrimitiveEXT + OpDecorate %_struct_39 Block OpDecorate %naga_primitive_builtin_outputs PerPrimitiveEXT - OpDecorate %_struct_42 Block - OpMemberDecorate %_struct_42 0 Location 0 + OpDecorate %_struct_43 Block + OpMemberDecorate %_struct_43 0 Location 0 OpDecorate %naga_primitive_indices_outputs PerPrimitiveEXT OpDecorate %naga_primitive_indices_outputs BuiltIn PrimitiveTriangleIndicesEXT - OpDecorate %_struct_49 Block - OpMemberDecorate %_struct_49 0 Location 1 - OpDecorate %52 PerPrimitiveEXT + OpDecorate %_struct_50 Block + OpMemberDecorate %_struct_50 0 Location 1 + OpDecorate %53 PerPrimitiveEXT OpMemberDecorate %TaskPayload 0 Offset 0 OpMemberDecorate %TaskPayload 1 Offset 16 OpMemberDecorate %VertexOutput 0 Offset 0 @@ -80,54 +80,55 @@ %_ptr_Workgroup_uint = OpTypePointer Workgroup %uint %naga_num_vertices = OpVariable %_ptr_Workgroup_uint Workgroup %naga_num_primitives = OpVariable %_ptr_Workgroup_uint Workgroup + %26 = OpVariable %_ptr_Workgroup_uint Workgroup %uint_3 = OpConstant %uint 3 %_arr_VertexOutput_uint_3 = OpTypeArray %VertexOutput %uint_3 %_ptr_Workgroup__arr_VertexOutput_uint_3 = OpTypePointer Workgroup %_arr_VertexOutput_uint_3 - %28 = OpVariable %_ptr_Workgroup__arr_VertexOutput_uint_3 Workgroup + %29 = OpVariable %_ptr_Workgroup__arr_VertexOutput_uint_3 Workgroup %uint_1 = OpConstant %uint 1 %_arr_PrimitiveOutput_uint_1 = OpTypeArray %PrimitiveOutput %uint_1 %_ptr_Workgroup__arr_PrimitiveOutput_uint_1 = OpTypePointer Workgroup %_arr_PrimitiveOutput_uint_1 - %32 = OpVariable %_ptr_Workgroup__arr_PrimitiveOutput_uint_1 Workgroup - %_struct_34 = OpTypeStruct %v4float -%_arr__struct_34_uint_3 = OpTypeArray %_struct_34 %uint_3 -%_ptr_Output__arr__struct_34_uint_3 = OpTypePointer Output %_arr__struct_34_uint_3 -%naga_vertex_builtin_outputs = OpVariable %_ptr_Output__arr__struct_34_uint_3 Output - %_struct_38 = OpTypeStruct %bool -%_arr__struct_38_uint_1 = OpTypeArray %_struct_38 %uint_1 -%_ptr_Output__arr__struct_38_uint_1 = OpTypePointer Output %_arr__struct_38_uint_1 -%naga_primitive_builtin_outputs = OpVariable %_ptr_Output__arr__struct_38_uint_1 Output - %_struct_42 = OpTypeStruct %v4float -%_arr__struct_42_uint_1 = OpTypeArray %_struct_42 %uint_1 -%_ptr_Output__arr__struct_42_uint_1 = OpTypePointer Output %_arr__struct_42_uint_1 - %45 = OpVariable %_ptr_Output__arr__struct_42_uint_1 Output + %33 = OpVariable %_ptr_Workgroup__arr_PrimitiveOutput_uint_1 Workgroup + %_struct_35 = OpTypeStruct %v4float +%_arr__struct_35_uint_3 = OpTypeArray %_struct_35 %uint_3 +%_ptr_Output__arr__struct_35_uint_3 = OpTypePointer Output %_arr__struct_35_uint_3 +%naga_vertex_builtin_outputs = OpVariable %_ptr_Output__arr__struct_35_uint_3 Output + %_struct_39 = OpTypeStruct %bool +%_arr__struct_39_uint_1 = OpTypeArray %_struct_39 %uint_1 +%_ptr_Output__arr__struct_39_uint_1 = OpTypePointer Output %_arr__struct_39_uint_1 +%naga_primitive_builtin_outputs = OpVariable %_ptr_Output__arr__struct_39_uint_1 Output + %_struct_43 = OpTypeStruct %v4float +%_arr__struct_43_uint_1 = OpTypeArray %_struct_43 %uint_1 +%_ptr_Output__arr__struct_43_uint_1 = OpTypePointer Output %_arr__struct_43_uint_1 + %46 = OpVariable %_ptr_Output__arr__struct_43_uint_1 Output %_arr_v3uint_uint_1 = OpTypeArray %v3uint %uint_1 %_ptr_Output__arr_v3uint_uint_1 = OpTypePointer Output %_arr_v3uint_uint_1 %naga_primitive_indices_outputs = OpVariable %_ptr_Output__arr_v3uint_uint_1 Output - %_struct_49 = OpTypeStruct %v4float -%_arr__struct_49_uint_1 = OpTypeArray %_struct_49 %uint_1 -%_ptr_Output__arr__struct_49_uint_1 = OpTypePointer Output %_arr__struct_49_uint_1 - %52 = OpVariable %_ptr_Output__arr__struct_49_uint_1 Output - %54 = OpTypeFunction %void + %_struct_50 = OpTypeStruct %v4float +%_arr__struct_50_uint_1 = OpTypeArray %_struct_50 %uint_1 +%_ptr_Output__arr__struct_50_uint_1 = OpTypePointer Output %_arr__struct_50_uint_1 + %53 = OpVariable %_ptr_Output__arr__struct_50_uint_1 Output + %55 = OpTypeFunction %void %uint_3_0 = OpConstant %uint 3 %uint_1_0 = OpConstant %uint 1 %float_2 = OpConstant %float 2 %float_0 = OpConstant %float 0 %float_n1 = OpConstant %float -1 %float_1 = OpConstant %float 1 - %61 = OpConstantComposite %v4float %float_0 %float_n1 %float_0 %float_1 - %62 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1 + %62 = OpConstantComposite %v4float %float_0 %float_n1 %float_0 %float_1 + %63 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1 %uint_0 = OpConstant %uint 0 - %64 = OpConstantComposite %v4float %float_n1 %float_1 %float_0 %float_1 - %65 = OpConstantComposite %v4float %float_0 %float_0 %float_1 %float_1 - %66 = OpConstantComposite %v4float %float_1 %float_1 %float_0 %float_1 - %67 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1 + %65 = OpConstantComposite %v4float %float_n1 %float_1 %float_0 %float_1 + %66 = OpConstantComposite %v4float %float_0 %float_0 %float_1 %float_1 + %67 = OpConstantComposite %v4float %float_1 %float_1 %float_0 %float_1 + %68 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1 %uint_2 = OpConstant %uint 2 - %69 = OpConstantComposite %v3uint %uint_0 %uint_1_0 %uint_2 - %70 = OpConstantComposite %v4float %float_1 %float_0 %float_1 %float_1 + %70 = OpConstantComposite %v3uint %uint_0 %uint_1_0 %uint_2 + %71 = OpConstantComposite %v4float %float_1 %float_0 %float_1 %float_1 %_ptr_Function_VertexOutput = OpTypePointer Function %VertexOutput - %73 = OpConstantNull %VertexOutput + %74 = OpConstantNull %VertexOutput %_ptr_Function_PrimitiveOutput = OpTypePointer Function %PrimitiveOutput - %76 = OpConstantNull %PrimitiveOutput + %77 = OpConstantNull %PrimitiveOutput %_ptr_Function_v4float = OpTypePointer Function %v4float %_ptr_TaskPayloadWorkgroupEXT_v4float = OpTypePointer TaskPayloadWorkgroupEXT %v4float %_ptr_Workgroup_VertexOutput = OpTypePointer Workgroup %VertexOutput @@ -138,118 +139,120 @@ %uint_1_1 = OpConstant %uint 1 %_arr_PrimitiveOutput_uint_1_1 = OpTypeArray %PrimitiveOutput %uint_1_1 %_ptr_Workgroup__arr_PrimitiveOutput_uint_1_1 = OpTypePointer Workgroup %_arr_PrimitiveOutput_uint_1_1 - %116 = OpVariable %_ptr_Workgroup__arr_PrimitiveOutput_uint_1_1 Workgroup -%_ptr_Function_uint = OpTypePointer Function %uint - %127 = OpVariable %_ptr_Workgroup_uint Workgroup + %117 = OpVariable %_ptr_Workgroup__arr_PrimitiveOutput_uint_1_1 Workgroup %_ptr_Output_v4float = OpTypePointer Output %v4float %_ptr_Output_v3uint = OpTypePointer Output %v3uint %_ptr_Output_bool = OpTypePointer Output %bool - %ms_main = OpFunction %void None %54 + %ms_main = OpFunction %void None %55 %16 = OpLabel - %v = OpVariable %_ptr_Function_VertexOutput Function %73 - %p = OpVariable %_ptr_Function_PrimitiveOutput Function %76 + %v = OpVariable %_ptr_Function_VertexOutput Function %74 + %p = OpVariable %_ptr_Function_PrimitiveOutput Function %77 %19 = OpLoad %uint %index %22 = OpLoad %v3uint %id - OpBranch %77 - %77 = OpLabel + OpBranch %78 + %78 = OpLabel OpSetMeshOutputsEXT %uint_3_0 %uint_1_0 OpStore %naga_num_vertices %uint_3_0 OpStore %naga_num_primitives %uint_1_0 OpStore %workgroupData %float_2 - %79 = OpAccessChain %_ptr_Function_v4float %v %uint_0 - OpStore %79 %61 - %81 = OpAccessChain %_ptr_TaskPayloadWorkgroupEXT_v4float %taskPayload %uint_0 - %82 = OpLoad %v4float %81 - %83 = OpFMul %v4float %62 %82 - %84 = OpAccessChain %_ptr_Function_v4float %v %uint_1_0 - OpStore %84 %83 - %85 = OpLoad %VertexOutput %v - %86 = OpAccessChain %_ptr_Workgroup_VertexOutput %28 %uint_0 - OpStore %86 %85 - %88 = OpAccessChain %_ptr_Function_v4float %v %uint_0 - OpStore %88 %64 - %89 = OpAccessChain %_ptr_TaskPayloadWorkgroupEXT_v4float %taskPayload %uint_0 - %90 = OpLoad %v4float %89 - %91 = OpFMul %v4float %65 %90 - %92 = OpAccessChain %_ptr_Function_v4float %v %uint_1_0 - OpStore %92 %91 - %93 = OpLoad %VertexOutput %v - %94 = OpAccessChain %_ptr_Workgroup_VertexOutput %28 %uint_1_0 - OpStore %94 %93 - %95 = OpAccessChain %_ptr_Function_v4float %v %uint_0 - OpStore %95 %66 - %96 = OpAccessChain %_ptr_TaskPayloadWorkgroupEXT_v4float %taskPayload %uint_0 - %97 = OpLoad %v4float %96 - %98 = OpFMul %v4float %67 %97 - %99 = OpAccessChain %_ptr_Function_v4float %v %uint_1_0 - OpStore %99 %98 - %100 = OpLoad %VertexOutput %v - %101 = OpAccessChain %_ptr_Workgroup_VertexOutput %28 %uint_2 - OpStore %101 %100 - %103 = OpAccessChain %_ptr_Function_v3uint %p %uint_0 - OpStore %103 %69 - %106 = OpAccessChain %_ptr_TaskPayloadWorkgroupEXT_bool %taskPayload %uint_1_0 - %107 = OpLoad %bool %106 - %108 = OpLogicalNot %bool %107 - %109 = OpAccessChain %_ptr_Function_bool %p %uint_1_0 - OpStore %109 %108 - %110 = OpAccessChain %_ptr_Function_v4float %p %uint_2 - OpStore %110 %70 - %111 = OpLoad %PrimitiveOutput %p - %112 = OpAccessChain %_ptr_Workgroup_PrimitiveOutput %32 %uint_0 - OpStore %112 %111 - %118 = OpLoad %uint %naga_num_vertices - %119 = OpLoad %uint %naga_num_primitives - OpStore %127 %uint_0 + %80 = OpAccessChain %_ptr_Function_v4float %v %uint_0 + OpStore %80 %62 + %82 = OpAccessChain %_ptr_TaskPayloadWorkgroupEXT_v4float %taskPayload %uint_0 + %83 = OpLoad %v4float %82 + %84 = OpFMul %v4float %63 %83 + %85 = OpAccessChain %_ptr_Function_v4float %v %uint_1_0 + OpStore %85 %84 + %86 = OpLoad %VertexOutput %v + %87 = OpAccessChain %_ptr_Workgroup_VertexOutput %29 %uint_0 + OpStore %87 %86 + %89 = OpAccessChain %_ptr_Function_v4float %v %uint_0 + OpStore %89 %65 + %90 = OpAccessChain %_ptr_TaskPayloadWorkgroupEXT_v4float %taskPayload %uint_0 + %91 = OpLoad %v4float %90 + %92 = OpFMul %v4float %66 %91 + %93 = OpAccessChain %_ptr_Function_v4float %v %uint_1_0 + OpStore %93 %92 + %94 = OpLoad %VertexOutput %v + %95 = OpAccessChain %_ptr_Workgroup_VertexOutput %29 %uint_1_0 + OpStore %95 %94 + %96 = OpAccessChain %_ptr_Function_v4float %v %uint_0 + OpStore %96 %67 + %97 = OpAccessChain %_ptr_TaskPayloadWorkgroupEXT_v4float %taskPayload %uint_0 + %98 = OpLoad %v4float %97 + %99 = OpFMul %v4float %68 %98 + %100 = OpAccessChain %_ptr_Function_v4float %v %uint_1_0 + OpStore %100 %99 + %101 = OpLoad %VertexOutput %v + %102 = OpAccessChain %_ptr_Workgroup_VertexOutput %29 %uint_2 + OpStore %102 %101 + %104 = OpAccessChain %_ptr_Function_v3uint %p %uint_0 + OpStore %104 %70 + %107 = OpAccessChain %_ptr_TaskPayloadWorkgroupEXT_bool %taskPayload %uint_1_0 + %108 = OpLoad %bool %107 + %109 = OpLogicalNot %bool %108 + %110 = OpAccessChain %_ptr_Function_bool %p %uint_1_0 + OpStore %110 %109 + %111 = OpAccessChain %_ptr_Function_v4float %p %uint_2 + OpStore %111 %71 + %112 = OpLoad %PrimitiveOutput %p + %113 = OpAccessChain %_ptr_Workgroup_PrimitiveOutput %33 %uint_0 + OpStore %113 %112 + %119 = OpLoad %uint %naga_num_vertices + %120 = OpLoad %uint %naga_num_primitives + OpStore %26 %uint_0 OpBranch %121 - %123 = OpLabel - OpStore %127 %uint_0 - OpBranch %122 %121 = OpLabel - OpLoopMerge %123 %128 None - %129 = OpLoad %uint %127 - %130 = OpULessThan %bool %129 %118 - OpBranchConditional %130 %124 %123 - %128 = OpLabel - %131 = OpLoad %uint %127 - %132 = OpIAdd %uint %131 %uint_1_0 - OpStore %127 %132 + OpLoopMerge %123 %145 None + OpBranch %144 + %144 = OpLabel + %147 = OpLoad %uint %26 + %148 = OpULessThan %bool %147 %119 + OpBranchConditional %148 %146 %123 + %146 = OpLabel + %125 = OpLoad %uint %26 + %126 = OpAccessChain %_ptr_Workgroup_VertexOutput %29 %125 + %127 = OpLoad %VertexOutput %126 + %128 = OpCompositeExtract %v4float %127 0 + %129 = OpAccessChain %_ptr_Output_v4float %naga_vertex_builtin_outputs %125 %uint_0 + OpStore %129 %128 + %131 = OpCompositeExtract %v4float %127 1 + %132 = OpAccessChain %_ptr_Output_v4float %46 %125 %uint_0 + OpStore %132 %131 + OpBranch %145 + %145 = OpLabel + %149 = OpLoad %uint %26 + %150 = OpIAdd %uint %149 %uint_1_0 + OpStore %26 %150 OpBranch %121 + %123 = OpLabel + OpStore %26 %uint_0 + OpBranch %122 %122 = OpLabel - OpLoopMerge %126 %133 None - %134 = OpLoad %uint %127 - %135 = OpULessThan %bool %134 %119 - OpBranchConditional %135 %125 %126 - %133 = OpLabel - %136 = OpLoad %uint %127 - %137 = OpIAdd %uint %136 %uint_1_0 - OpStore %127 %137 + OpLoopMerge %124 %152 None + OpBranch %151 + %151 = OpLabel + %154 = OpLoad %uint %26 + %155 = OpULessThan %bool %154 %120 + OpBranchConditional %155 %153 %124 + %153 = OpLabel + %133 = OpLoad %uint %26 + %134 = OpAccessChain %_ptr_Workgroup_PrimitiveOutput %117 %133 + %135 = OpLoad %PrimitiveOutput %134 + %136 = OpCompositeExtract %v3uint %135 0 + %137 = OpAccessChain %_ptr_Output_v3uint %naga_primitive_indices_outputs %133 + OpStore %137 %136 + %139 = OpCompositeExtract %bool %135 1 + %140 = OpAccessChain %_ptr_Output_bool %naga_primitive_builtin_outputs %133 %uint_0 + OpStore %140 %139 + %142 = OpCompositeExtract %v4float %135 2 + %143 = OpAccessChain %_ptr_Output_v4float %53 %133 %uint_0 + OpStore %143 %142 + OpBranch %152 + %152 = OpLabel + %156 = OpLoad %uint %26 + %157 = OpIAdd %uint %156 %uint_1_0 + OpStore %26 %157 OpBranch %122 %124 = OpLabel - %138 = OpLoad %uint %127 - %139 = OpAccessChain %_ptr_Workgroup_VertexOutput %28 %138 - %140 = OpLoad %VertexOutput %139 - %141 = OpCompositeExtract %v4float %140 0 - %142 = OpAccessChain %_ptr_Output_v4float %naga_vertex_builtin_outputs %138 %uint_0 - OpStore %142 %141 - %144 = OpCompositeExtract %v4float %140 1 - %145 = OpAccessChain %_ptr_Output_v4float %45 %138 %uint_0 - OpStore %145 %144 - OpBranch %128 - %125 = OpLabel - %146 = OpLoad %uint %127 - %147 = OpAccessChain %_ptr_Workgroup_PrimitiveOutput %116 %146 - %148 = OpLoad %PrimitiveOutput %147 - %149 = OpCompositeExtract %v3uint %148 0 - %150 = OpAccessChain %_ptr_Output_v3uint %naga_primitive_indices_outputs %146 - OpStore %150 %149 - %152 = OpCompositeExtract %bool %148 1 - %153 = OpAccessChain %_ptr_Output_bool %naga_primitive_builtin_outputs %146 %uint_0 - OpStore %153 %152 - %155 = OpCompositeExtract %v4float %148 2 - %156 = OpAccessChain %_ptr_Output_v4float %52 %146 %uint_0 - OpStore %156 %155 - OpBranch %133 - %126 = OpLabel OpReturn OpFunctionEnd From 66b539746d9b42cf30d4a55f5de0137e67625c58 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 9 Aug 2025 17:04:25 -0500 Subject: [PATCH 68/84] Updated my todos --- naga/src/back/spv/block.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 459e750824b..00a0c6651af 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -302,7 +302,7 @@ impl Writer { return_info: &super::MeshReturnInfo, body: &mut Vec, ) -> Result<(), Error> { - // TODO: (maybe) make this multithreaded if you have the patience + // TODO: (maybe) make this better multithreaded if you have the patience let vert_info = self.mesh_shader_output_variable( return_info.vertex_type, false, @@ -328,7 +328,7 @@ impl Writer { None, )); - // All this for the vertex loop lol + // All this for a `for i in 0..num_vertices` lol let u32_type_id = self.get_u32_type_id(); let zero_u32 = self.get_constant_scalar(crate::Literal::U32(0)); let vertex_loop_header = self.id_gen.next(); @@ -474,7 +474,7 @@ impl Writer { } body }; - + // TODO: make the increments atomic let mut get_loop_continue_id = |body: &mut Vec, mut loop_body_block, loop_header, loop_merge, count_id| { let condition_check = self.id_gen.next(); let loop_continue = self.id_gen.next(); @@ -537,6 +537,7 @@ impl Writer { ); { body.push(Instruction::label(in_between_loops)); + // TODO: sync threads, make this an atomic write body.push(Instruction::store(counter_var, zero_u32, None)); body.push(Instruction::branch(prim_loop_header)); } From 44340b46a0d16becb5372972a2455554ec876c91 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 9 Aug 2025 18:26:20 -0500 Subject: [PATCH 69/84] It frickin works now I think --- naga/src/back/spv/block.rs | 91 ++++++++----- naga/src/back/spv/mod.rs | 1 + shaders/mesh.spv | Bin 4236 -> 0 bytes shaders/mesh.spv-asm | 258 ------------------------------------- 4 files changed, 63 insertions(+), 287 deletions(-) delete mode 100644 shaders/mesh.spv delete mode 100644 shaders/mesh.spv-asm diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 00a0c6651af..cbc04d1e2bf 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -302,7 +302,7 @@ impl Writer { return_info: &super::MeshReturnInfo, body: &mut Vec, ) -> Result<(), Error> { - // TODO: (maybe) make this better multithreaded if you have the patience + // TODO: (maybe) make this better multithreaded if you have the patience (current atomic stuff is stupid asf) let vert_info = self.mesh_shader_output_variable( return_info.vertex_type, false, @@ -310,7 +310,7 @@ impl Writer { )?; let prim_info = self.mesh_shader_output_variable( return_info.primitive_type, - false, + true, return_info.max_primitives, )?; let vert_count_id = self.id_gen.next(); @@ -336,17 +336,34 @@ impl Writer { let in_between_loops = self.id_gen.next(); let func_end = self.id_gen.next(); let counter_var = self.mesh_state.counter_var.unwrap(); + let vertex_val_i = self.id_gen.next(); + let primitive_val_i = self.id_gen.next(); + let workgroup_scope_id = + self.get_constant_scalar(crate::Literal::U32(spirv::Scope::Workgroup as u32)); + let relaxed_semantics_id = + self.get_constant_scalar(crate::Literal::U32(spirv::MemorySemantics::RELAXED.bits())); + let control_barrier_instruction = Instruction::control_barrier( + workgroup_scope_id, + workgroup_scope_id, + self.get_constant_scalar(crate::Literal::U32( + spirv::MemorySemantics::WORKGROUP_MEMORY.bits(), + )), + ); - body.push(Instruction::store(counter_var, zero_u32, None)); + body.push(Instruction::atomic_store( + counter_var, + workgroup_scope_id, + relaxed_semantics_id, + zero_u32, + )); + body.push(control_barrier_instruction.clone()); body.push(Instruction::branch(vertex_loop_header)); - let vertex_copy_body = // Vertex copies - { + let vertex_copy_body = { let mut body = Vec::new(); - let val_i = self.id_gen.next(); - body.push(Instruction::load(u32_type_id, val_i, counter_var, None)); + let val_i = vertex_val_i; let vert_to_copy_ptr = self.id_gen.next(); body.push(Instruction::access_chain( @@ -406,8 +423,7 @@ impl Writer { // Primitive copies let primitive_copy_body = { let mut body = Vec::new(); - let val_i = self.id_gen.next(); - body.push(Instruction::load(u32_type_id, val_i, counter_var, None)); + let val_i = primitive_val_i; let prim_to_copy_ptr = self.id_gen.next(); body.push(Instruction::access_chain( @@ -475,7 +491,12 @@ impl Writer { body }; // TODO: make the increments atomic - let mut get_loop_continue_id = |body: &mut Vec, mut loop_body_block, loop_header, loop_merge, count_id| { + let mut get_loop_continue_id = |body: &mut Vec, + mut loop_body_block, + loop_header, + loop_merge, + count_id, + val_i| { let condition_check = self.id_gen.next(); let loop_continue = self.id_gen.next(); let loop_body = self.id_gen.next(); @@ -493,8 +514,17 @@ impl Writer { // Condition check - check if i is less than num vertices to copy { body.push(Instruction::label(condition_check)); - let val_i = self.id_gen.next(); - body.push(Instruction::load(u32_type_id, val_i, counter_var, None)); + let mut inc_ins = Instruction::new(spirv::Op::AtomicIAdd); + inc_ins.set_type(u32_type_id); + inc_ins.set_result(val_i); + inc_ins.add_operands(alloc::vec![ + counter_var, + workgroup_scope_id, + relaxed_semantics_id, + self.get_constant_scalar(crate::Literal::U32(1)) + ]); + body.push(inc_ins); + let cond = self.id_gen.next(); let mut cmp_ins = Instruction::new(spirv::Op::ULessThan); cmp_ins.set_type(self.get_bool_type_id()); @@ -507,41 +537,44 @@ impl Writer { { body.push(Instruction::label(loop_body)); body.append(&mut loop_body_block); - body.push(Instruction::branch(loop_continue)); } // Loop continue - increment i { body.push(Instruction::label(loop_continue)); - let val_i = self.id_gen.next(); - let new_val_i = self.id_gen.next(); - body.push(Instruction::load(u32_type_id, val_i, counter_var, None)); - let mut add_ins = Instruction::new(spirv::Op::IAdd); - add_ins.set_type(u32_type_id); - add_ins.set_result(new_val_i); - add_ins.add_operands(alloc::vec![ - val_i, - self.get_constant_scalar(crate::Literal::U32(1)) - ]); - body.push(add_ins); - body.push(Instruction::store(counter_var, new_val_i, None)); body.push(Instruction::branch(loop_header)); } }; get_loop_continue_id( - body, + body, vertex_copy_body, vertex_loop_header, in_between_loops, vert_count_id, + vertex_val_i, ); { body.push(Instruction::label(in_between_loops)); - // TODO: sync threads, make this an atomic write - body.push(Instruction::store(counter_var, zero_u32, None)); + + body.push(control_barrier_instruction.clone()); + body.push(Instruction::atomic_store( + counter_var, + workgroup_scope_id, + relaxed_semantics_id, + zero_u32, + )); + body.push(control_barrier_instruction.clone()); + body.push(Instruction::branch(prim_loop_header)); } - get_loop_continue_id(body, primitive_copy_body, prim_loop_header, func_end, prim_count_id); + get_loop_continue_id( + body, + primitive_copy_body, + prim_loop_header, + func_end, + prim_count_id, + primitive_val_i, + ); body.push(Instruction::label(func_end)); Ok(()) diff --git a/naga/src/back/spv/mod.rs b/naga/src/back/spv/mod.rs index c74d7265bcf..c8f91d6cd70 100644 --- a/naga/src/back/spv/mod.rs +++ b/naga/src/back/spv/mod.rs @@ -52,6 +52,7 @@ struct LogicalLayout { function_definitions: Vec, } +#[derive(Clone)] struct Instruction { op: spirv::Op, wc: u32, diff --git a/shaders/mesh.spv b/shaders/mesh.spv deleted file mode 100644 index 37254f31d55a5e809331d45caebc5d90f432fa05..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4236 zcmZveX>(Ln5Qc9yb_FGXAjCuzG+-1Zh$1jSFd!g75OEy`5@96C#LOftZV|r~ zU;HMeKfqt5rB+$x^W2k)itOa{Y8=aA-VR2ya~ffg=Zc>W#sk&AoS-e{I&H$bE~mrP=S) z*n&M$FOO8JqtwqbsB95f1G>NsU?o@u)`4!&12%zPa4lHEeAY4Fc>_zBPyQE*F3DPR z-8yy=_GNs=w`Ftlxkf9eD&^6Mk@Dowc%yo9sGfZGFyk8=uZ~n3)k(Z<+5Eh(+-J_v zx$=pL>TshvTCPnr#wHrZEXe!LV`g&y6PCxhu32%_(Lo!TDaUI4H$6_)hHK*oEA=y& zbEqKidM2y&>WSeYm}%}PAp@23!?ns_o;`OuJsYdlSxIeF(|mdJ^SVg0<&Nb`JCv^o zGml-M!l1#Sb4c^$^8AV6VSRQg*9?liT33D`wlbAAej&VLcD(#d{Jv54*8bY^`_d?^ z&)VLLv$gRvr^ag&W4kMj3U(WJz&jHCws8}@Z`HwRU-2&L+ly~9&uhu{BgepAs;osi zqR)O}oJwk_GNS5E(8bYrcjU)%c_`PZX20q4}O9p5hVDU9 zVUGS4NNYvDw%6>YzJ+8g+5-i^TiR%5%z?vY$4ws*)_dFyF=F2($tu^NQ+Fd}-y)a0*CH>mla&tOg`+?k^`Yrt1r|q2^Idyy7 z0n9N@sXu%>3taf3j}ksd#P*?E!~BR1->$?3U!3E?l=FXiy9@OqH|F1i&wbj+OZ03W z0wv)7=!?1g(Tla!J6ZWYr1xI*uye|XfxZKY_g?E$9!$PN$>-h~dl>245BoT_y7ly* zO1eF2SCj2M)_wtLe%RyK<~wJs)&GYy0q z`7qhezlAQ`Q-2E`-o-y*{C(Jl&pq1{kG3@}>VC(9_Z#Y6?_*BSU;x-l2^g#GUDofJJPH1tbo~lo=AN3c@ld! zkdL~9=*2#@jf*~ql0W)<9@{?m0QXbd82!Gb)4=;y0{XRm`}%!LXMlaWPUrAm4+Ht1 zl0A|*b9|4Zz?!i)+Q#VjuGN74=t;XDSl@R#2J{>6`+X5~ffBGsZDWj|hdc|s=V6~i zUkQx$x4Hy;C+CsA6XhS|zJ&Y~IP`yl)US+MpQBsjD!sV&FMynL{!I<-&w#beRgc_P z(9Lxn-tAX`XCZHl_y08@f0!8G&=in!^zkjeh0>yn!Sk@p6=c}*bl-bC*K z#XLDXR$(r)!_R*B9Wdt#q$nMt%hx=3YVSSH|4m zpj$uo`df54&(pou{u)@zT=mGkgl=x!nYYjNu&1(j6J|Cm^f?}SWvF?%k Date: Sat, 9 Aug 2025 18:34:27 -0500 Subject: [PATCH 70/84] Implemented coordinate flip --- naga/src/back/spv/block.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index cbc04d1e2bf..9188f6b5fdf 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -384,6 +384,7 @@ impl Writer { let mut binding_index = 0; for (member_id, member) in return_info.vertex_members.iter().enumerate() { let val_to_copy = self.id_gen.next(); + let mut needs_y_flip = false; body.push(Instruction::composite_extract( member.ty_id, val_to_copy, @@ -392,8 +393,7 @@ impl Writer { )); let ptr_to_copy_to = self.id_gen.next(); match member.binding { - crate::Binding::BuiltIn(_) => { - // TODO: flip coordinates + crate::Binding::BuiltIn(bi) => { body.push(Instruction::access_chain( self.get_pointer_type_id(member.ty_id, spirv::StorageClass::Output), ptr_to_copy_to, @@ -403,6 +403,8 @@ impl Writer { self.get_constant_scalar(crate::Literal::U32(builtin_index)), ], )); + needs_y_flip = matches!(bi, crate::BuiltIn::Position { .. }) + && self.flags.contains(WriterFlags::ADJUST_COORDINATE_SPACE); builtin_index += 1; } crate::Binding::Location { .. } => { @@ -416,6 +418,9 @@ impl Writer { } } body.push(Instruction::store(ptr_to_copy_to, val_to_copy, None)); + if needs_y_flip { + self.write_epilogue_position_y_flip(ptr_to_copy_to, &mut body)?; + } } body }; From 397d89d8d9c7379825f40101162dbc4d98c7b088 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 9 Aug 2025 20:03:01 -0500 Subject: [PATCH 71/84] Made the example properly work with ALL naga shaders!! --- docs/api-specs/mesh_shading.md | 8 +-- examples/features/src/mesh_shader/mod.rs | 58 ++++----------- examples/features/src/mesh_shader/shader.wgsl | 71 +++++++++++++++++++ naga/src/back/spv/block.rs | 29 +++++++- naga/src/back/spv/writer.rs | 16 ++--- naga/tests/in/wgsl/mesh-shader.wgsl | 8 +-- wgpu-core/src/validation.rs | 2 + wgpu-hal/src/vulkan/adapter.rs | 3 + 8 files changed, 131 insertions(+), 64 deletions(-) create mode 100644 examples/features/src/mesh_shader/shader.wgsl diff --git a/docs/api-specs/mesh_shading.md b/docs/api-specs/mesh_shading.md index 9826c0550ca..ee14f99e757 100644 --- a/docs/api-specs/mesh_shading.md +++ b/docs/api-specs/mesh_shading.md @@ -119,9 +119,9 @@ The following is a full example of WGSL shaders that could be used to create a m enable mesh_shading; const positions = array( - vec4(0.,-1.,0.,1.), - vec4(-1.,1.,0.,1.), - vec4(1.,1.,0.,1.) + vec4(0.,1.,0.,1.), + vec4(-1.,-1.,0.,1.), + vec4(1.,-1.,0.,1.) ); const colors = array( vec4(0.,1.,0.,1.), @@ -144,7 +144,7 @@ struct PrimitiveOutput { @per_primitive @location(1) colorMask: vec4, } struct PrimitiveInput { - @location(1) colorMask: vec4, + @per_primitive @location(1) colorMask: vec4, } @task diff --git a/examples/features/src/mesh_shader/mod.rs b/examples/features/src/mesh_shader/mod.rs index 956722a661d..b16dd7e2460 100644 --- a/examples/features/src/mesh_shader/mod.rs +++ b/examples/features/src/mesh_shader/mod.rs @@ -1,37 +1,4 @@ -use std::{io::Write, process::Stdio}; - -// Same as in mesh shader tests -fn compile_glsl( - device: &wgpu::Device, - data: &[u8], - shader_stage: &'static str, -) -> wgpu::ShaderModule { - let cmd = std::process::Command::new("glslc") - .args([ - &format!("-fshader-stage={shader_stage}"), - "-", - "-o", - "-", - "--target-env=vulkan1.2", - "--target-spv=spv1.4", - ]) - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .spawn() - .expect("Failed to call glslc"); - cmd.stdin.as_ref().unwrap().write_all(data).unwrap(); - println!("{shader_stage}"); - let output = cmd.wait_with_output().expect("Error waiting for glslc"); - assert!(output.status.success()); - unsafe { - device.create_shader_module_passthrough(wgpu::ShaderModuleDescriptorPassthrough::SpirV( - wgpu::ShaderModuleDescriptorSpirV { - label: None, - source: wgpu::util::make_spirv_raw(&output.stdout), - }, - )) - } -} +use wgpu::include_wgsl; pub struct Example { pipeline: wgpu::RenderPipeline, @@ -48,27 +15,28 @@ impl crate::framework::Example for Example { bind_group_layouts: &[], push_constant_ranges: &[], }); - let (ts, ms, fs) = ( - compile_glsl(device, include_bytes!("shader.task"), "task"), - compile_glsl(device, include_bytes!("shader.mesh"), "mesh"), - compile_glsl(device, include_bytes!("shader.frag"), "frag"), - ); + let shader_module = unsafe { + device.create_shader_module_trusted( + include_wgsl!("shader.wgsl"), + wgpu::ShaderRuntimeChecks::unchecked(), + ) + }; let pipeline = device.create_mesh_pipeline(&wgpu::MeshPipelineDescriptor { label: None, layout: Some(&pipeline_layout), task: Some(wgpu::TaskState { - module: &ts, - entry_point: Some("main"), + module: &shader_module, + entry_point: Some("ts_main"), compilation_options: Default::default(), }), mesh: wgpu::MeshState { - module: &ms, - entry_point: Some("main"), + module: &shader_module, + entry_point: Some("ms_main"), compilation_options: Default::default(), }, fragment: Some(wgpu::FragmentState { - module: &fs, - entry_point: Some("main"), + module: &shader_module, + entry_point: Some("fs_main"), compilation_options: Default::default(), targets: &[Some(config.view_formats[0].into())], }), diff --git a/examples/features/src/mesh_shader/shader.wgsl b/examples/features/src/mesh_shader/shader.wgsl new file mode 100644 index 00000000000..70fc2aec333 --- /dev/null +++ b/examples/features/src/mesh_shader/shader.wgsl @@ -0,0 +1,71 @@ +enable mesh_shading; + +const positions = array( + vec4(0.,1.,0.,1.), + vec4(-1.,-1.,0.,1.), + vec4(1.,-1.,0.,1.) +); +const colors = array( + vec4(0.,1.,0.,1.), + vec4(0.,0.,1.,1.), + vec4(1.,0.,0.,1.) +); +struct TaskPayload { + colorMask: vec4, + visible: bool, +} +var taskPayload: TaskPayload; +var workgroupData: f32; +struct VertexOutput { + @builtin(position) position: vec4, + @location(0) color: vec4, +} +struct PrimitiveOutput { + @builtin(triangle_indices) index: vec3, + @builtin(cull_primitive) cull: bool, + @per_primitive @location(1) colorMask: vec4, +} +struct PrimitiveInput { + @per_primitive @location(1) colorMask: vec4, +} + +@task +@payload(taskPayload) +@workgroup_size(1) +fn ts_main() -> @builtin(mesh_task_size) vec3 { + workgroupData = 1.0; + taskPayload.colorMask = vec4(1.0, 1.0, 0.0, 1.0); + taskPayload.visible = true; + return vec3(3, 1, 1); +} +@mesh +@payload(taskPayload) +@vertex_output(VertexOutput, 3) @primitive_output(PrimitiveOutput, 1) +@workgroup_size(1) +fn ms_main(@builtin(local_invocation_index) index: u32, @builtin(global_invocation_id) id: vec3) { + setMeshOutputs(3, 1); + workgroupData = 2.0; + var v: VertexOutput; + + v.position = positions[0]; + v.color = colors[0] * taskPayload.colorMask; + setVertex(0, v); + + v.position = positions[1]; + v.color = colors[1] * taskPayload.colorMask; + setVertex(1, v); + + v.position = positions[2]; + v.color = colors[2] * taskPayload.colorMask; + setVertex(2, v); + + var p: PrimitiveOutput; + p.index = vec3(0, 1, 2); + p.cull = !taskPayload.visible; + p.colorMask = vec4(1.0, 0.0, 1.0, 1.0); + setPrimitive(0, p); +} +@fragment +fn fs_main(vertex: VertexOutput, primitive: PrimitiveInput) -> @location(0) vec4 { + return vertex.color * primitive.colorMask; +} diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 9188f6b5fdf..55b5a3d2997 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -345,8 +345,11 @@ impl Writer { let control_barrier_instruction = Instruction::control_barrier( workgroup_scope_id, workgroup_scope_id, + // TODO: ensure that I actually need these memory semantics given the silly atomic nonsense self.get_constant_scalar(crate::Literal::U32( - spirv::MemorySemantics::WORKGROUP_MEMORY.bits(), + (spirv::MemorySemantics::WORKGROUP_MEMORY + | spirv::MemorySemantics::ACQUIRE_RELEASE) + .bits(), )), ); @@ -418,8 +421,30 @@ impl Writer { } } body.push(Instruction::store(ptr_to_copy_to, val_to_copy, None)); + // Can't use epilogue flip because can't read from Output if needs_y_flip { - self.write_epilogue_position_y_flip(ptr_to_copy_to, &mut body)?; + let prev_y = self.id_gen.next(); + body.push(Instruction::composite_extract( + self.get_f32_type_id(), + prev_y, + val_to_copy, + &[1], + )); + let new_y = self.id_gen.next(); + body.push(Instruction::unary( + spirv::Op::FNegate, + self.get_f32_type_id(), + new_y, + prev_y, + )); + let new_ptr_to_copy_to = self.id_gen.next(); + body.push(Instruction::access_chain( + self.get_f32_pointer_type_id(spirv::StorageClass::Output), + new_ptr_to_copy_to, + ptr_to_copy_to, + &[self.get_constant_scalar(crate::Literal::U32(1))], + )); + body.push(Instruction::store(new_ptr_to_copy_to, new_y, None)); } } body diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 8b068430693..4139b95dde5 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -3047,20 +3047,18 @@ impl Writer { if self.flags.contains(WriterFlags::DEBUG) { if let Some(debug_info) = debug_info.as_ref() { let source_file_id = self.id_gen.next(); - self.debugs.push(Instruction::string( - &debug_info.file_name.to_string_lossy(), - source_file_id, - )); + Instruction::string(&debug_info.file_name.to_string_lossy(), source_file_id) + .to_words(&mut self.logical_layout.debugs); debug_info_inner = Some(DebugInfoInner { source_code: debug_info.source_code, source_file_id, }); - self.debugs.append(&mut Instruction::source_auto_continued( - debug_info.language, - 0, - &debug_info_inner, - )); + for ins in + Instruction::source_auto_continued(debug_info.language, 0, &debug_info_inner) + { + ins.to_words(&mut self.logical_layout.debugs); + } } } diff --git a/naga/tests/in/wgsl/mesh-shader.wgsl b/naga/tests/in/wgsl/mesh-shader.wgsl index 30a61aefc41..70fc2aec333 100644 --- a/naga/tests/in/wgsl/mesh-shader.wgsl +++ b/naga/tests/in/wgsl/mesh-shader.wgsl @@ -1,9 +1,9 @@ enable mesh_shading; const positions = array( - vec4(0.,-1.,0.,1.), - vec4(-1.,1.,0.,1.), - vec4(1.,1.,0.,1.) + vec4(0.,1.,0.,1.), + vec4(-1.,-1.,0.,1.), + vec4(1.,-1.,0.,1.) ); const colors = array( vec4(0.,1.,0.,1.), @@ -68,4 +68,4 @@ fn ms_main(@builtin(local_invocation_index) index: u32, @builtin(global_invocati @fragment fn fs_main(vertex: VertexOutput, primitive: PrimitiveInput) -> @location(0) vec4 { return vertex.color * primitive.colorMask; -} \ No newline at end of file +} diff --git a/wgpu-core/src/validation.rs b/wgpu-core/src/validation.rs index 5c0ff887538..0246b59f5bb 100644 --- a/wgpu-core/src/validation.rs +++ b/wgpu-core/src/validation.rs @@ -1084,6 +1084,8 @@ impl Interface { wgt::ShaderStages::VERTEX => naga::ShaderStage::Vertex, wgt::ShaderStages::FRAGMENT => naga::ShaderStage::Fragment, wgt::ShaderStages::COMPUTE => naga::ShaderStage::Compute, + wgt::ShaderStages::MESH => naga::ShaderStage::Mesh, + wgt::ShaderStages::TASK => naga::ShaderStage::Task, _ => unreachable!(), } } diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index 19c1ffe4ca7..85a5daa9744 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -2081,6 +2081,9 @@ impl super::Adapter { if features.contains(wgt::Features::EXPERIMENTAL_RAY_HIT_VERTEX_RETURN) { capabilities.push(spv::Capability::RayQueryPositionFetchKHR) } + if features.contains(wgt::Features::EXPERIMENTAL_MESH_SHADER) { + capabilities.push(spv::Capability::MeshShadingEXT); + } if self.private_caps.shader_integer_dot_product { // See . capabilities.extend(&[ From 97381d57f01fa9063d636369285fc2272db09a4d Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Sat, 9 Aug 2025 23:49:48 -0500 Subject: [PATCH 72/84] Upgraded the copy algorithm to not be complete garbage --- naga/src/back/spv/block.rs | 101 ++++++++++++++++-------------------- naga/src/back/spv/mod.rs | 5 +- naga/src/back/spv/writer.rs | 67 ++++++++++++++++++++---- 3 files changed, 107 insertions(+), 66 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 55b5a3d2997..839135c7c9e 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -328,6 +328,13 @@ impl Writer { None, )); + { + let mut ins = Instruction::new(spirv::Op::SetMeshOutputsEXT); + ins.add_operand(vert_count_id); + ins.add_operand(prim_count_id); + body.push(ins); + } + // All this for a `for i in 0..num_vertices` lol let u32_type_id = self.get_u32_type_id(); let zero_u32 = self.get_constant_scalar(crate::Literal::U32(0)); @@ -335,38 +342,20 @@ impl Writer { let prim_loop_header = self.id_gen.next(); let in_between_loops = self.id_gen.next(); let func_end = self.id_gen.next(); - let counter_var = self.mesh_state.counter_var.unwrap(); - let vertex_val_i = self.id_gen.next(); - let primitive_val_i = self.id_gen.next(); - let workgroup_scope_id = - self.get_constant_scalar(crate::Literal::U32(spirv::Scope::Workgroup as u32)); - let relaxed_semantics_id = - self.get_constant_scalar(crate::Literal::U32(spirv::MemorySemantics::RELAXED.bits())); - let control_barrier_instruction = Instruction::control_barrier( - workgroup_scope_id, - workgroup_scope_id, - // TODO: ensure that I actually need these memory semantics given the silly atomic nonsense - self.get_constant_scalar(crate::Literal::U32( - (spirv::MemorySemantics::WORKGROUP_MEMORY - | spirv::MemorySemantics::ACQUIRE_RELEASE) - .bits(), - )), - ); + let index_var = return_info.function_variable; - body.push(Instruction::atomic_store( - counter_var, - workgroup_scope_id, - relaxed_semantics_id, - zero_u32, + body.push(Instruction::store( + index_var, + return_info.local_invocation_index_id, + None, )); - body.push(control_barrier_instruction.clone()); - body.push(Instruction::branch(vertex_loop_header)); // Vertex copies let vertex_copy_body = { let mut body = Vec::new(); - let val_i = vertex_val_i; + let val_i = self.id_gen.next(); + body.push(Instruction::load(u32_type_id, val_i, index_var, None)); let vert_to_copy_ptr = self.id_gen.next(); body.push(Instruction::access_chain( @@ -453,7 +442,8 @@ impl Writer { // Primitive copies let primitive_copy_body = { let mut body = Vec::new(); - let val_i = primitive_val_i; + let val_i = self.id_gen.next(); + body.push(Instruction::load(u32_type_id, val_i, index_var, None)); let prim_to_copy_ptr = self.id_gen.next(); body.push(Instruction::access_chain( @@ -526,7 +516,7 @@ impl Writer { loop_header, loop_merge, count_id, - val_i| { + index_var| { let condition_check = self.id_gen.next(); let loop_continue = self.id_gen.next(); let loop_body = self.id_gen.next(); @@ -544,23 +534,18 @@ impl Writer { // Condition check - check if i is less than num vertices to copy { body.push(Instruction::label(condition_check)); - let mut inc_ins = Instruction::new(spirv::Op::AtomicIAdd); - inc_ins.set_type(u32_type_id); - inc_ins.set_result(val_i); - inc_ins.add_operands(alloc::vec![ - counter_var, - workgroup_scope_id, - relaxed_semantics_id, - self.get_constant_scalar(crate::Literal::U32(1)) - ]); - body.push(inc_ins); + + let val_i = self.id_gen.next(); + body.push(Instruction::load(u32_type_id, val_i, index_var, None)); let cond = self.id_gen.next(); - let mut cmp_ins = Instruction::new(spirv::Op::ULessThan); - cmp_ins.set_type(self.get_bool_type_id()); - cmp_ins.set_result(cond); - cmp_ins.add_operands(alloc::vec![val_i, count_id]); - body.push(cmp_ins); + body.push(Instruction::binary( + spirv::Op::ULessThan, + self.get_bool_type_id(), + cond, + val_i, + count_id, + )); body.push(Instruction::branch_conditional(cond, loop_body, loop_merge)); } // Loop body @@ -572,6 +557,19 @@ impl Writer { // Loop continue - increment i { body.push(Instruction::label(loop_continue)); + + let prev_val_i = self.id_gen.next(); + body.push(Instruction::load(u32_type_id, prev_val_i, index_var, None)); + let new_val_i = self.id_gen.next(); + body.push(Instruction::binary( + spirv::Op::IAdd, + u32_type_id, + new_val_i, + prev_val_i, + return_info.workgroup_size, + )); + body.push(Instruction::store(index_var, new_val_i, None)); + body.push(Instruction::branch(loop_header)); } }; @@ -581,19 +579,16 @@ impl Writer { vertex_loop_header, in_between_loops, vert_count_id, - vertex_val_i, + index_var, ); { body.push(Instruction::label(in_between_loops)); - body.push(control_barrier_instruction.clone()); - body.push(Instruction::atomic_store( - counter_var, - workgroup_scope_id, - relaxed_semantics_id, - zero_u32, + body.push(Instruction::store( + index_var, + return_info.local_invocation_index_id, + None, )); - body.push(control_barrier_instruction.clone()); body.push(Instruction::branch(prim_loop_header)); } @@ -603,7 +598,7 @@ impl Writer { prim_loop_header, func_end, prim_count_id, - primitive_val_i, + index_var, ); body.push(Instruction::label(func_end)); @@ -3993,10 +3988,6 @@ impl BlockContext<'_> { self.writer .require_any("mesh shaders", &[spirv::Capability::MeshShadingEXT])?; self.writer.use_extension("SPV_EXT_mesh_shader"); - let mut ins = Instruction::new(spirv::Op::SetMeshOutputsEXT); - ins.add_operand(self.cached[vertex_count]); - ins.add_operand(self.cached[primitive_count]); - block.body.push(ins); block.body.push(Instruction::store( self.writer.mesh_state.num_vertices_var.unwrap(), self.cached[vertex_count], diff --git a/naga/src/back/spv/mod.rs b/naga/src/back/spv/mod.rs index c8f91d6cd70..abeefb6eac0 100644 --- a/naga/src/back/spv/mod.rs +++ b/naga/src/back/spv/mod.rs @@ -168,6 +168,10 @@ struct MeshReturnInfo { primitive_builtin_block: Option, primitive_bindings: Vec, primitive_indices: Option, + local_invocation_index_id: u32, + workgroup_size: u32, + /// The id of a function variable in the entry point for a u32 + function_variable: u32, } struct EntryPointContext { @@ -953,7 +957,6 @@ pub struct WriteMeshInfo { pub primitive_outputs_by_type: crate::FastHashMap, MeshOutputInfo>, pub num_vertices_var: Option, pub num_primitives_var: Option, - pub counter_var: Option, } #[derive(Clone)] diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 4139b95dde5..f3a8ade51ab 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -26,6 +26,7 @@ struct FunctionInterface<'a> { stage: crate::ShaderStage, task_payload: Option>, mesh_info: Option, + workgroup_size: [u32; 3], } impl Function { @@ -101,7 +102,6 @@ impl Writer { primitive_outputs_by_type: crate::FastHashMap::default(), num_vertices_var: None, num_primitives_var: None, - counter_var: None, }, }) } @@ -169,7 +169,6 @@ impl Writer { .recycle(), num_vertices_var: None, num_primitives_var: None, - counter_var: None, }, }; @@ -748,6 +747,9 @@ impl Writer { let mut local_invocation_id = None; let mut parameter_type_ids = Vec::with_capacity(ir_function.arguments.len()); + + let mut local_invocation_index_id = None; + for argument in ir_function.arguments.iter() { let class = spirv::StorageClass::Input; let handle_ty = ir_module.types[argument.ty].inner.is_handle(); @@ -777,6 +779,10 @@ impl Writer { if binding == &crate::Binding::BuiltIn(crate::BuiltIn::LocalInvocationId) { local_invocation_id = Some(id); + } else if binding + == &crate::Binding::BuiltIn(crate::BuiltIn::LocalInvocationIndex) + { + local_invocation_index_id = Some(id); } id @@ -806,6 +812,10 @@ impl Writer { if binding == &crate::Binding::BuiltIn(crate::BuiltIn::LocalInvocationId) { local_invocation_id = Some(id); + } else if binding + == &crate::Binding::BuiltIn(crate::BuiltIn::LocalInvocationIndex) + { + local_invocation_index_id = Some(id); } } prelude.body.push(Instruction::composite_construct( @@ -965,7 +975,8 @@ impl Writer { iface .varying_ids .push(self.mesh_state.num_primitives_var.unwrap()); - iface.varying_ids.push(self.mesh_state.counter_var.unwrap()); + + // TODO: zero initialize num_vertices and num_primitives let vertex_members = match &ir_module.types[mesh_info.vertex_output_type] { &crate::Type { @@ -993,6 +1004,43 @@ impl Writer { .collect(), _ => unreachable!(), }; + let local_invocation_index_id = match local_invocation_index_id { + Some(a) => a, + None => { + let u32_id = self.get_u32_type_id(); + let var = self.id_gen.next(); + Instruction::variable( + self.get_pointer_type_id(u32_id, spirv::StorageClass::Input), + var, + spirv::StorageClass::Input, + None, + ) + .to_words(&mut self.logical_layout.declarations); + Instruction::decorate( + var, + spirv::Decoration::BuiltIn, + &[spirv::BuiltIn::LocalInvocationIndex as u32], + ) + .to_words(&mut self.logical_layout.annotations); + + let loaded_value = self.id_gen.next(); + prelude + .body + .push(Instruction::load(u32_id, loaded_value, var, None)); + loaded_value + } + }; + let u32_id = self.get_u32_type_id(); + let function_variable = self.id_gen.next(); + prelude.body.insert( + 0, + Instruction::variable( + self.get_pointer_type_id(u32_id, spirv::StorageClass::Function), + function_variable, + spirv::StorageClass::Function, + None, + ), + ); let mut mesh_return_info = super::MeshReturnInfo { vertex_type: mesh_info.vertex_output_type, vertex_members, @@ -1005,6 +1053,11 @@ impl Writer { primitive_bindings: Vec::new(), primitive_builtin_block: None, primitive_indices: None, + local_invocation_index_id, + workgroup_size: self.get_constant_scalar(crate::Literal::U32( + iface.workgroup_size.iter().product(), + )), + function_variable, }; if mesh_return_info .vertex_members @@ -1480,6 +1533,7 @@ impl Writer { stage: entry_point.stage, task_payload: entry_point.task_payload, mesh_info: entry_point.mesh_info.clone(), + workgroup_size: entry_point.workgroup_size, }), debug_info, )?; @@ -2660,13 +2714,6 @@ impl Writer { .to_words(&mut self.logical_layout.debugs); } } - // Counter for when we copy stuff at the end, very hacky stuff (check it out in `write_mesh_shader_return`!) - if self.mesh_state.counter_var.is_none() { - let var_id = self.id_gen.next(); - Instruction::variable(u32_ptr, var_id, spirv::StorageClass::Workgroup, None) - .to_words(&mut self.logical_layout.declarations); - self.mesh_state.counter_var = Some(var_id); - } let entry = if is_primitive { self.mesh_state.primitive_outputs_by_type.get(&output_type) } else { From 866b85d136cd191b5c4ff649f514a89c726b4b9f Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Sun, 10 Aug 2025 01:44:08 -0500 Subject: [PATCH 73/84] Final tweaks and removing // TODO 's --- naga/src/back/spv/block.rs | 14 ++------------ naga/src/back/spv/writer.rs | 30 ++++++++++++++++-------------- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 839135c7c9e..ff480bb9962 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -302,7 +302,6 @@ impl Writer { return_info: &super::MeshReturnInfo, body: &mut Vec, ) -> Result<(), Error> { - // TODO: (maybe) make this better multithreaded if you have the patience (current atomic stuff is stupid asf) let vert_info = self.mesh_shader_output_variable( return_info.vertex_type, false, @@ -510,7 +509,6 @@ impl Writer { } body }; - // TODO: make the increments atomic let mut get_loop_continue_id = |body: &mut Vec, mut loop_body_block, loop_header, @@ -3985,9 +3983,7 @@ impl BlockContext<'_> { vertex_count, primitive_count, }) => { - self.writer - .require_any("mesh shaders", &[spirv::Capability::MeshShadingEXT])?; - self.writer.use_extension("SPV_EXT_mesh_shader"); + self.writer.require_mesh_shaders()?; block.body.push(Instruction::store( self.writer.mesh_state.num_vertices_var.unwrap(), self.cached[vertex_count], @@ -4003,13 +3999,7 @@ impl BlockContext<'_> { crate::MeshFunction::SetVertex { index, value } | crate::MeshFunction::SetPrimitive { index, value }, ) => { - self.writer - .require_any("mesh shaders", &[spirv::Capability::MeshShadingEXT])?; - self.writer.use_extension("SPV_EXT_mesh_shader"); - let lang_version = self.writer.lang_version(); - if lang_version.0 <= 1 && lang_version.1 < 4 { - return Err(Error::SpirvVersionTooLow(1, 4)); - } + self.writer.require_mesh_shaders()?; let is_prim = matches!( *statement, Statement::MeshFunction(crate::MeshFunction::SetPrimitive { .. }) diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index f3a8ade51ab..57d4a4f521b 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -2535,8 +2535,7 @@ impl Writer { } if per_primitive && stage == crate::ShaderStage::Fragment { others.push(Decoration::PerPrimitiveEXT); - self.require_any("mesh shaders", &[spirv::Capability::MeshShadingEXT])?; - self.use_extension("SPV_EXT_mesh_shader"); + self.require_mesh_shaders()?; } Ok(BindingDecorations::Location { location, @@ -3002,6 +3001,16 @@ impl Writer { self.physical_layout.bound = self.id_gen.0 + 1; } + pub(super) fn require_mesh_shaders(&mut self) -> Result<(), Error> { + self.use_extension("SPV_EXT_mesh_shader"); + self.require_any("Mesh Shaders", &[spirv::Capability::MeshShadingEXT])?; + let lang_version = self.lang_version(); + if lang_version.0 <= 1 && lang_version.1 < 4 { + return Err(Error::SpirvVersionTooLow(1, 4)); + } + Ok(()) + } + fn write_logical_layout( &mut self, ir_module: &crate::Module, @@ -3038,13 +3047,11 @@ impl Writer { let mut has_ray_query = ir_module.special_types.ray_desc.is_some() | ir_module.special_types.ray_intersection.is_some(); let has_vertex_return = ir_module.special_types.ray_vertex_return.is_some(); - // Ways mesh shaders are required: - // * Mesh entry point used - // * Mesh function like setVertex used outside mesh entry point, this is handled elsewhere - // * Task payload global variable - // * Fragment shader with per primitive data (currently unhandle by naga in general) - // TODO: check for that last condition + // Ways mesh shaders are required: + // * Mesh entry point used - checked for + // * Mesh function like setVertex used outside mesh entry point, this is handled when those are written + // * Fragment shader with per primitive data - handled in `map_binding` let has_mesh_shaders = ir_module.entry_points.iter().any(|entry| { entry.stage == crate::ShaderStage::Mesh || entry.stage == crate::ShaderStage::Task }) || ir_module @@ -3079,12 +3086,7 @@ impl Writer { .to_words(&mut self.logical_layout.extensions); } if has_mesh_shaders { - self.use_extension("SPV_EXT_mesh_shader"); - self.require_any("Mesh Shaders", &[spirv::Capability::MeshShadingEXT])?; - let lang_version = self.lang_version(); - if lang_version.0 <= 1 && lang_version.1 < 4 { - return Err(Error::SpirvVersionTooLow(1, 4)); - } + self.require_mesh_shaders()?; } Instruction::type_void(self.void_type).to_words(&mut self.logical_layout.declarations); Instruction::ext_inst_import(self.gl450_ext_inst_id, "GLSL.std.450") From 24f9196620f6ea6a9e0324a819bcfa9971fae865 Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Thu, 14 Aug 2025 01:08:45 -0500 Subject: [PATCH 74/84] Tried to address some comments and also add comments --- naga/src/back/spv/block.rs | 93 +-- naga/src/back/spv/mod.rs | 2 + naga/src/back/spv/writer.rs | 762 +++++++++--------- naga/src/front/wgsl/lower/mod.rs | 1 - naga/src/ir/mod.rs | 1 - naga/tests/out/ir/spv-shadow.compact.ron | 3 + naga/tests/out/ir/spv-shadow.ron | 3 + .../out/ir/spv-spec-constants.compact.ron | 4 + naga/tests/out/ir/spv-spec-constants.ron | 4 + naga/tests/out/ir/wgsl-access.compact.ron | 1 + naga/tests/out/ir/wgsl-access.ron | 1 + .../tests/out/ir/wgsl-mesh-shader.compact.ron | 10 +- naga/tests/out/ir/wgsl-mesh-shader.ron | 10 +- .../out/ir/wgsl-texture-external.compact.ron | 1 + naga/tests/out/ir/wgsl-texture-external.ron | 1 + naga/tests/out/spv/wgsl-mesh-shader.spvasm | 418 ++++++---- 16 files changed, 716 insertions(+), 599 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index ff480bb9962..c4dbbdac758 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -257,7 +257,8 @@ impl Writer { _ => {} } } - // MeshTaskSize must be called write before exiting + // OpEmitMeshTasksEXT must be called right before exiting (after setting other + // output variables if there are any) for (index, res_member) in result_members.iter().enumerate() { if res_member.built_in == Some(crate::BuiltIn::MeshTaskSize) { let member_value_id = match ir_result.binding { @@ -283,7 +284,6 @@ impl Writer { &[i as Word], ); body.push(instruction); - // Use OpCompositeExtract to save the component of the vec3 } let mut instruction = Instruction::new(spirv::Op::EmitMeshTasksEXT); for id in values { @@ -297,11 +297,15 @@ impl Writer { } Ok(Instruction::return_void()) } + + /// Writes the return call for a mesh shader, which involves copying previously + /// written vertices/primitives into the actual output location. fn write_mesh_shader_return( &mut self, return_info: &super::MeshReturnInfo, body: &mut Vec, ) -> Result<(), Error> { + // Gets the info about temporary buffers and such let vert_info = self.mesh_shader_output_variable( return_info.vertex_type, false, @@ -312,6 +316,7 @@ impl Writer { true, return_info.max_primitives, )?; + // Load the actual vertex and primitive counts let vert_count_id = self.id_gen.next(); body.push(Instruction::load( self.get_u32_type_id(), @@ -327,6 +332,8 @@ impl Writer { None, )); + // Call this. It must be called exactly once, which the user shouldn't be assumed + // to have done correctly. { let mut ins = Instruction::new(spirv::Op::SetMeshOutputsEXT); ins.add_operand(vert_count_id); @@ -335,6 +342,7 @@ impl Writer { } // All this for a `for i in 0..num_vertices` lol + // This is basically just a memcpy but the result is split up to multiple places let u32_type_id = self.get_u32_type_id(); let zero_u32 = self.get_constant_scalar(crate::Literal::U32(0)); let vertex_loop_header = self.id_gen.next(); @@ -353,6 +361,7 @@ impl Writer { // Vertex copies let vertex_copy_body = { let mut body = Vec::new(); + // Current index to copy let val_i = self.id_gen.next(); body.push(Instruction::load(u32_type_id, val_i, index_var, None)); @@ -363,6 +372,8 @@ impl Writer { vert_info.var_id, &[val_i], )); + + // Load the entire vertex value let vert_to_copy = self.id_gen.next(); body.push(Instruction::load( vert_info.inner_ty, @@ -373,6 +384,7 @@ impl Writer { let mut builtin_index = 0; let mut binding_index = 0; + // Write individual members of the vertex for (member_id, member) in return_info.vertex_members.iter().enumerate() { let val_to_copy = self.id_gen.next(); let mut needs_y_flip = false; @@ -383,6 +395,8 @@ impl Writer { &[member_id as u32], )); let ptr_to_copy_to = self.id_gen.next(); + // Get the variable that holds it and indexed pointer, which points to + // the value and not a wrapper struct match member.binding { crate::Binding::BuiltIn(bi) => { body.push(Instruction::access_chain( @@ -409,7 +423,7 @@ impl Writer { } } body.push(Instruction::store(ptr_to_copy_to, val_to_copy, None)); - // Can't use epilogue flip because can't read from Output + // Can't use epilogue flip because can't read from this storage class I believe if needs_y_flip { let prev_y = self.id_gen.next(); body.push(Instruction::composite_extract( @@ -440,6 +454,7 @@ impl Writer { // Primitive copies let primitive_copy_body = { + // See comments in `vertex_copy_body` let mut body = Vec::new(); let val_i = self.id_gen.next(); body.push(Instruction::load(u32_type_id, val_i, index_var, None)); @@ -509,6 +524,8 @@ impl Writer { } body }; + + // This writes the actual loop let mut get_loop_continue_id = |body: &mut Vec, mut loop_body_block, loop_header, @@ -571,6 +588,7 @@ impl Writer { body.push(Instruction::branch(loop_header)); } }; + // Write vertex copy loop get_loop_continue_id( body, vertex_copy_body, @@ -579,6 +597,7 @@ impl Writer { vert_count_id, index_var, ); + // In between loops, reset the initial index { body.push(Instruction::label(in_between_loops)); @@ -590,6 +609,7 @@ impl Writer { body.push(Instruction::branch(prim_loop_header)); } + // Write primitive copy loop get_loop_continue_id( body, primitive_copy_body, @@ -4022,73 +4042,6 @@ impl BlockContext<'_> { block .body .push(Instruction::store(out_ptr_id, self.cached[value], None)); - - /*for (i, member_info) in info.outputs.iter().enumerate() { - let member_ty = member_info.member_ty; - - let in_value_id = self.gen_id(); - block.body.push(Instruction::composite_extract( - member_ty, - in_value_id, - self.cached[value], - &[i as Word], - )); - let out_ptr_id = self.gen_id(); - block.body.push(Instruction::access_chain( - self.get_pointer_type_id(member_ty, spirv::StorageClass::Output), - out_ptr_id, - member_info.var_id, - &[self.cached[index]], - )); - block - .body - .push(Instruction::store(out_ptr_id, in_value_id, None)); - - // Coordinate flip - if self - .writer - .flags - .contains(WriterFlags::ADJUST_COORDINATE_SPACE) - && matches!( - member_info.member.binding, - Some(crate::Binding::BuiltIn(crate::BuiltIn::Position { .. })) - ) - { - let float_ptr_type_id = self - .writer - .get_f32_pointer_type_id(spirv::StorageClass::Output); - let index_y_id = self.get_index_constant(1); - - let access_id = self.gen_id(); - block.body.push(Instruction::access_chain( - float_ptr_type_id, - access_id, - out_ptr_id, - &[index_y_id], - )); - - let float_type_id = self.writer.get_f32_type_id(); - let y_val = self.gen_id(); - block.body.push(Instruction::composite_extract( - float_type_id, - y_val, - in_value_id, - &[1], - )); - - let flipped_y_val = self.gen_id(); - block.body.push(Instruction::unary( - spirv::Op::FNegate, - float_type_id, - flipped_y_val, - y_val, - )); - - block - .body - .push(Instruction::store(access_id, flipped_y_val, None)); - } - }*/ } Statement::SubgroupBallot { result, diff --git a/naga/src/back/spv/mod.rs b/naga/src/back/spv/mod.rs index abeefb6eac0..e5c1d4a692b 100644 --- a/naga/src/back/spv/mod.rs +++ b/naga/src/back/spv/mod.rs @@ -955,7 +955,9 @@ pub fn write_vec( pub struct WriteMeshInfo { pub vertex_outputs_by_type: crate::FastHashMap, MeshOutputInfo>, pub primitive_outputs_by_type: crate::FastHashMap, MeshOutputInfo>, + /// The workgroup variable containing the number of vertices to write pub num_vertices_var: Option, + /// The workgroup variable containing the number of primitives to write pub num_primitives_var: Option, } diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 57d4a4f521b..704d063dacb 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -718,6 +718,378 @@ impl Writer { }) } + /// This does various setup things to allow mesh shader entry points + /// to be properly written, such as creating the output variables + fn write_entry_point_mesh_shader_info( + &mut self, + iface: &mut FunctionInterface, + local_invocation_index_id: Option, + ir_module: &crate::Module, + prelude: &mut Block, + ep_context: &mut EntryPointContext, + ) -> Result<(), Error> { + if let Some(ref mesh_info) = iface.mesh_info { + // Create the temporary output variables + let vert_info = self.mesh_shader_output_variable( + mesh_info.vertex_output_type, + false, + mesh_info.max_vertices, + )?; + let prim_info = self.mesh_shader_output_variable( + mesh_info.primitive_output_type, + true, + mesh_info.max_primitives, + )?; + iface.varying_ids.push(vert_info.var_id); + iface.varying_ids.push(prim_info.var_id); + + // These are guaranteed to be initialized after mesh_shader_output_variable + // is called + iface + .varying_ids + .push(self.mesh_state.num_vertices_var.unwrap()); + iface + .varying_ids + .push(self.mesh_state.num_primitives_var.unwrap()); + + // Maybe TODO: zero initialize num_vertices and num_primitives + + // Collect the members in the output structs + let vertex_members = match &ir_module.types[mesh_info.vertex_output_type] { + &crate::Type { + inner: crate::TypeInner::Struct { ref members, .. }, + .. + } => members + .iter() + .map(|a| super::MeshReturnMember { + ty_id: self.get_handle_type_id(a.ty), + binding: a.binding.clone().unwrap(), + }) + .collect(), + _ => unreachable!(), + }; + let primitive_members = match &ir_module.types[mesh_info.primitive_output_type] { + &crate::Type { + inner: crate::TypeInner::Struct { ref members, .. }, + .. + } => members + .iter() + .map(|a| super::MeshReturnMember { + ty_id: self.get_handle_type_id(a.ty), + binding: a.binding.clone().unwrap(), + }) + .collect(), + _ => unreachable!(), + }; + // In the final return, we do a giant memcpy, for which this is helpful + let local_invocation_index_id = match local_invocation_index_id { + Some(a) => a, + None => { + let u32_id = self.get_u32_type_id(); + let var = self.id_gen.next(); + Instruction::variable( + self.get_pointer_type_id(u32_id, spirv::StorageClass::Input), + var, + spirv::StorageClass::Input, + None, + ) + .to_words(&mut self.logical_layout.declarations); + Instruction::decorate( + var, + spirv::Decoration::BuiltIn, + &[spirv::BuiltIn::LocalInvocationIndex as u32], + ) + .to_words(&mut self.logical_layout.annotations); + + let loaded_value = self.id_gen.next(); + prelude + .body + .push(Instruction::load(u32_id, loaded_value, var, None)); + loaded_value + } + }; + let u32_id = self.get_u32_type_id(); + // A general function variable that we guarantee to allow in the final return. It must be + // declared at the top of the function. Currently it is used in the memcpy part to keep + // index to copy track of the current + let function_variable = self.id_gen.next(); + prelude.body.insert( + 0, + Instruction::variable( + self.get_pointer_type_id(u32_id, spirv::StorageClass::Function), + function_variable, + spirv::StorageClass::Function, + None, + ), + ); + // This is the information that is passed to the function writer + // so that it can write the final return logic + let mut mesh_return_info = super::MeshReturnInfo { + vertex_type: mesh_info.vertex_output_type, + vertex_members, + max_vertices: mesh_info.max_vertices, + primitive_type: mesh_info.primitive_output_type, + primitive_members, + max_primitives: mesh_info.max_primitives, + vertex_bindings: Vec::new(), + vertex_builtin_block: None, + primitive_bindings: Vec::new(), + primitive_builtin_block: None, + primitive_indices: None, + local_invocation_index_id, + workgroup_size: self.get_constant_scalar(crate::Literal::U32( + iface.workgroup_size.iter().product(), + )), + function_variable, + }; + // Create the actual output variables and types. + // According to SPIR-V, + // * All builtins must be in the same output `Block` + // * Each member with `location` must be in its own `Block`. + // * Some builtins like CullPrimitiveEXT don't care as much (older validation layers don't know this!) + // * Some builtins like the indices ones need to be in their + // own output variable without a struct wrapper + if mesh_return_info + .vertex_members + .iter() + .any(|a| matches!(a.binding, crate::Binding::BuiltIn(..))) + { + let builtin_block_ty_id = self.id_gen.next(); + let mut ins = Instruction::type_struct(builtin_block_ty_id, &[]); + let mut bi_index = 0; + let mut decorations = Vec::new(); + for member in &mesh_return_info.vertex_members { + if let crate::Binding::BuiltIn(_) = member.binding { + ins.add_operand(member.ty_id); + let binding = self.map_binding( + ir_module, + iface.stage, + spirv::StorageClass::Output, + // Unused except in fragment shaders with other conditions, so we can pass null + Handle::new(NonMaxU32::new(0).unwrap()), + &member.binding, + )?; + match binding { + BindingDecorations::BuiltIn(bi, others) => { + decorations.push(Instruction::member_decorate( + builtin_block_ty_id, + bi_index, + spirv::Decoration::BuiltIn, + &[bi as Word], + )); + for other in others { + decorations.push(Instruction::member_decorate( + builtin_block_ty_id, + bi_index, + other, + &[], + )); + } + } + _ => unreachable!(), + } + bi_index += 1; + } + } + ins.to_words(&mut self.logical_layout.declarations); + decorations.push(Instruction::decorate( + builtin_block_ty_id, + spirv::Decoration::Block, + &[], + )); + for dec in decorations { + dec.to_words(&mut self.logical_layout.annotations); + } + let v = self.write_mesh_return_global_variable( + builtin_block_ty_id, + vert_info.array_size_id, + )?; + iface.varying_ids.push(v.var_id); + if self.flags.contains(WriterFlags::DEBUG) { + Instruction::name(v.var_id, "naga_vertex_builtin_outputs") + .to_words(&mut self.logical_layout.debugs); + } + mesh_return_info.vertex_builtin_block = Some(v); + } + if mesh_return_info.primitive_members.iter().any(|a| { + !matches!( + a.binding, + crate::Binding::BuiltIn( + crate::BuiltIn::PointIndex + | crate::BuiltIn::LineIndices + | crate::BuiltIn::TriangleIndices + ) | crate::Binding::Location { .. } + ) + }) { + let builtin_block_ty_id = self.id_gen.next(); + let mut ins = Instruction::type_struct(builtin_block_ty_id, &[]); + let mut bi_index = 0; + let mut decorations = Vec::new(); + for member in &mesh_return_info.primitive_members { + if let crate::Binding::BuiltIn(bi) = member.binding { + if matches!( + bi, + crate::BuiltIn::PointIndex + | crate::BuiltIn::LineIndices + | crate::BuiltIn::TriangleIndices, + ) { + continue; + } + ins.add_operand(member.ty_id); + let binding = self.map_binding( + ir_module, + iface.stage, + spirv::StorageClass::Output, + // Unused except in fragment shaders with other conditions, so we can pass null + Handle::new(NonMaxU32::new(0).unwrap()), + &member.binding, + )?; + match binding { + BindingDecorations::BuiltIn(bi, others) => { + decorations.push(Instruction::member_decorate( + builtin_block_ty_id, + bi_index, + spirv::Decoration::BuiltIn, + &[bi as Word], + )); + for other in others { + decorations.push(Instruction::member_decorate( + builtin_block_ty_id, + bi_index, + other, + &[], + )); + } + } + _ => unreachable!(), + } + bi_index += 1; + } + } + ins.to_words(&mut self.logical_layout.declarations); + decorations.push(Instruction::decorate( + builtin_block_ty_id, + spirv::Decoration::Block, + &[], + )); + for dec in decorations { + dec.to_words(&mut self.logical_layout.annotations); + } + let v = self.write_mesh_return_global_variable( + builtin_block_ty_id, + prim_info.array_size_id, + )?; + Instruction::decorate(v.var_id, spirv::Decoration::PerPrimitiveEXT, &[]) + .to_words(&mut self.logical_layout.annotations); + iface.varying_ids.push(v.var_id); + if self.flags.contains(WriterFlags::DEBUG) { + Instruction::name(v.var_id, "naga_primitive_builtin_outputs") + .to_words(&mut self.logical_layout.debugs); + } + mesh_return_info.primitive_builtin_block = Some(v); + } + { + for member in &mesh_return_info.vertex_members { + match member.binding { + crate::Binding::Location { location, .. } => { + let s_type = self.id_gen.next(); + Instruction::type_struct(s_type, &[member.ty_id]) + .to_words(&mut self.logical_layout.declarations); + Instruction::decorate(s_type, spirv::Decoration::Block, &[]) + .to_words(&mut self.logical_layout.annotations); + Instruction::member_decorate( + s_type, + 0, + spirv::Decoration::Location, + &[location], + ) + .to_words(&mut self.logical_layout.annotations); + let v = self.write_mesh_return_global_variable( + s_type, + prim_info.array_size_id, + )?; + iface.varying_ids.push(v.var_id); + mesh_return_info.vertex_bindings.push(v); + } + crate::Binding::BuiltIn(_) => (), + } + } + for member in &mesh_return_info.primitive_members { + match member.binding { + crate::Binding::BuiltIn( + crate::BuiltIn::PointIndex + | crate::BuiltIn::LineIndices + | crate::BuiltIn::TriangleIndices, + ) => { + let v = self.write_mesh_return_global_variable( + member.ty_id, + prim_info.array_size_id, + )?; + Instruction::decorate( + v.var_id, + spirv::Decoration::PerPrimitiveEXT, + &[], + ) + .to_words(&mut self.logical_layout.annotations); + Instruction::decorate( + v.var_id, + spirv::Decoration::BuiltIn, + &[match member.binding.to_built_in().unwrap() { + crate::BuiltIn::PointIndex => { + spirv::BuiltIn::PrimitivePointIndicesEXT + } + crate::BuiltIn::LineIndices => { + spirv::BuiltIn::PrimitiveLineIndicesEXT + } + crate::BuiltIn::TriangleIndices => { + spirv::BuiltIn::PrimitiveTriangleIndicesEXT + } + _ => unreachable!(), + } as Word], + ) + .to_words(&mut self.logical_layout.annotations); + iface.varying_ids.push(v.var_id); + if self.flags.contains(WriterFlags::DEBUG) { + Instruction::name(v.var_id, "naga_primitive_indices_outputs") + .to_words(&mut self.logical_layout.debugs); + } + mesh_return_info.primitive_indices = Some(v); + } + crate::Binding::Location { location, .. } => { + let s_type = self.id_gen.next(); + Instruction::type_struct(s_type, &[member.ty_id]) + .to_words(&mut self.logical_layout.declarations); + Instruction::decorate(s_type, spirv::Decoration::Block, &[]) + .to_words(&mut self.logical_layout.annotations); + Instruction::member_decorate( + s_type, + 0, + spirv::Decoration::Location, + &[location], + ) + .to_words(&mut self.logical_layout.annotations); + let v = self.write_mesh_return_global_variable( + s_type, + prim_info.array_size_id, + )?; + Instruction::decorate( + v.var_id, + spirv::Decoration::PerPrimitiveEXT, + &[], + ) + .to_words(&mut self.logical_layout.annotations); + iface.varying_ids.push(v.var_id); + mesh_return_info.primitive_bindings.push(v); + } + crate::Binding::BuiltIn(_) => (), + } + } + } + ep_context.mesh_state = Some(mesh_return_info); + } + Ok(()) + } + fn write_function( &mut self, ir_function: &crate::Function, @@ -954,349 +1326,13 @@ impl Writer { .varying_ids .push(self.global_variables[task_payload].var_id); } - if let Some(ref mesh_info) = iface.mesh_info { - let vert_info = self.mesh_shader_output_variable( - mesh_info.vertex_output_type, - false, - mesh_info.max_vertices, - )?; - let prim_info = self.mesh_shader_output_variable( - mesh_info.primitive_output_type, - true, - mesh_info.max_primitives, - )?; - iface.varying_ids.push(vert_info.var_id); - iface.varying_ids.push(prim_info.var_id); - // These are guaranteed to be initialized after mesh_shader_output_variable - // is called - iface - .varying_ids - .push(self.mesh_state.num_vertices_var.unwrap()); - iface - .varying_ids - .push(self.mesh_state.num_primitives_var.unwrap()); - - // TODO: zero initialize num_vertices and num_primitives - - let vertex_members = match &ir_module.types[mesh_info.vertex_output_type] { - &crate::Type { - inner: crate::TypeInner::Struct { ref members, .. }, - .. - } => members - .iter() - .map(|a| super::MeshReturnMember { - ty_id: self.get_handle_type_id(a.ty), - binding: a.binding.clone().unwrap(), - }) - .collect(), - _ => unreachable!(), - }; - let primitive_members = match &ir_module.types[mesh_info.primitive_output_type] { - &crate::Type { - inner: crate::TypeInner::Struct { ref members, .. }, - .. - } => members - .iter() - .map(|a| super::MeshReturnMember { - ty_id: self.get_handle_type_id(a.ty), - binding: a.binding.clone().unwrap(), - }) - .collect(), - _ => unreachable!(), - }; - let local_invocation_index_id = match local_invocation_index_id { - Some(a) => a, - None => { - let u32_id = self.get_u32_type_id(); - let var = self.id_gen.next(); - Instruction::variable( - self.get_pointer_type_id(u32_id, spirv::StorageClass::Input), - var, - spirv::StorageClass::Input, - None, - ) - .to_words(&mut self.logical_layout.declarations); - Instruction::decorate( - var, - spirv::Decoration::BuiltIn, - &[spirv::BuiltIn::LocalInvocationIndex as u32], - ) - .to_words(&mut self.logical_layout.annotations); - - let loaded_value = self.id_gen.next(); - prelude - .body - .push(Instruction::load(u32_id, loaded_value, var, None)); - loaded_value - } - }; - let u32_id = self.get_u32_type_id(); - let function_variable = self.id_gen.next(); - prelude.body.insert( - 0, - Instruction::variable( - self.get_pointer_type_id(u32_id, spirv::StorageClass::Function), - function_variable, - spirv::StorageClass::Function, - None, - ), - ); - let mut mesh_return_info = super::MeshReturnInfo { - vertex_type: mesh_info.vertex_output_type, - vertex_members, - max_vertices: mesh_info.max_vertices, - primitive_type: mesh_info.primitive_output_type, - primitive_members, - max_primitives: mesh_info.max_primitives, - vertex_bindings: Vec::new(), - vertex_builtin_block: None, - primitive_bindings: Vec::new(), - primitive_builtin_block: None, - primitive_indices: None, - local_invocation_index_id, - workgroup_size: self.get_constant_scalar(crate::Literal::U32( - iface.workgroup_size.iter().product(), - )), - function_variable, - }; - if mesh_return_info - .vertex_members - .iter() - .any(|a| matches!(a.binding, crate::Binding::BuiltIn(..))) - { - let builtin_block_ty_id = self.id_gen.next(); - let mut ins = Instruction::type_struct(builtin_block_ty_id, &[]); - let mut bi_index = 0; - let mut decorations = Vec::new(); - for member in &mesh_return_info.vertex_members { - if let crate::Binding::BuiltIn(_) = member.binding { - ins.add_operand(member.ty_id); - let binding = self.map_binding( - ir_module, - iface.stage, - spirv::StorageClass::Output, - // Unused except in fragment shaders with other conditions, so we can pass null - Handle::new(NonMaxU32::new(0).unwrap()), - &member.binding, - )?; - match binding { - BindingDecorations::BuiltIn(bi, others) => { - decorations.push(Instruction::member_decorate( - builtin_block_ty_id, - bi_index, - spirv::Decoration::BuiltIn, - &[bi as Word], - )); - for other in others { - decorations.push(Instruction::member_decorate( - builtin_block_ty_id, - bi_index, - other, - &[], - )); - } - } - _ => unreachable!(), - } - bi_index += 1; - } - } - ins.to_words(&mut self.logical_layout.declarations); - decorations.push(Instruction::decorate( - builtin_block_ty_id, - spirv::Decoration::Block, - &[], - )); - for dec in decorations { - dec.to_words(&mut self.logical_layout.annotations); - } - let v = self.write_mesh_return_global_variable( - builtin_block_ty_id, - vert_info.array_size_id, - )?; - iface.varying_ids.push(v.var_id); - if self.flags.contains(WriterFlags::DEBUG) { - Instruction::name(v.var_id, "naga_vertex_builtin_outputs") - .to_words(&mut self.logical_layout.debugs); - } - mesh_return_info.vertex_builtin_block = Some(v); - } - if mesh_return_info.primitive_members.iter().any(|a| { - !matches!( - a.binding, - crate::Binding::BuiltIn( - crate::BuiltIn::PointIndex - | crate::BuiltIn::LineIndices - | crate::BuiltIn::TriangleIndices - ) | crate::Binding::Location { .. } - ) - }) { - let builtin_block_ty_id = self.id_gen.next(); - let mut ins = Instruction::type_struct(builtin_block_ty_id, &[]); - let mut bi_index = 0; - let mut decorations = Vec::new(); - for member in &mesh_return_info.primitive_members { - if let crate::Binding::BuiltIn(bi) = member.binding { - if matches!( - bi, - crate::BuiltIn::PointIndex - | crate::BuiltIn::LineIndices - | crate::BuiltIn::TriangleIndices, - ) { - continue; - } - ins.add_operand(member.ty_id); - let binding = self.map_binding( - ir_module, - iface.stage, - spirv::StorageClass::Output, - // Unused except in fragment shaders with other conditions, so we can pass null - Handle::new(NonMaxU32::new(0).unwrap()), - &member.binding, - )?; - match binding { - BindingDecorations::BuiltIn(bi, others) => { - decorations.push(Instruction::member_decorate( - builtin_block_ty_id, - bi_index, - spirv::Decoration::BuiltIn, - &[bi as Word], - )); - for other in others { - decorations.push(Instruction::member_decorate( - builtin_block_ty_id, - bi_index, - other, - &[], - )); - } - } - _ => unreachable!(), - } - bi_index += 1; - } - } - ins.to_words(&mut self.logical_layout.declarations); - decorations.push(Instruction::decorate( - builtin_block_ty_id, - spirv::Decoration::Block, - &[], - )); - for dec in decorations { - dec.to_words(&mut self.logical_layout.annotations); - } - let v = self.write_mesh_return_global_variable( - builtin_block_ty_id, - prim_info.array_size_id, - )?; - Instruction::decorate(v.var_id, spirv::Decoration::PerPrimitiveEXT, &[]) - .to_words(&mut self.logical_layout.annotations); - iface.varying_ids.push(v.var_id); - if self.flags.contains(WriterFlags::DEBUG) { - Instruction::name(v.var_id, "naga_primitive_builtin_outputs") - .to_words(&mut self.logical_layout.debugs); - } - mesh_return_info.primitive_builtin_block = Some(v); - } - { - for member in &mesh_return_info.vertex_members { - match member.binding { - crate::Binding::Location { location, .. } => { - let s_type = self.id_gen.next(); - Instruction::type_struct(s_type, &[member.ty_id]) - .to_words(&mut self.logical_layout.declarations); - Instruction::decorate(s_type, spirv::Decoration::Block, &[]) - .to_words(&mut self.logical_layout.annotations); - Instruction::member_decorate( - s_type, - 0, - spirv::Decoration::Location, - &[location], - ) - .to_words(&mut self.logical_layout.annotations); - let v = self.write_mesh_return_global_variable( - s_type, - prim_info.array_size_id, - )?; - iface.varying_ids.push(v.var_id); - mesh_return_info.vertex_bindings.push(v); - } - crate::Binding::BuiltIn(_) => (), - } - } - for member in &mesh_return_info.primitive_members { - match member.binding { - crate::Binding::BuiltIn( - crate::BuiltIn::PointIndex - | crate::BuiltIn::LineIndices - | crate::BuiltIn::TriangleIndices, - ) => { - let v = self.write_mesh_return_global_variable( - member.ty_id, - prim_info.array_size_id, - )?; - Instruction::decorate( - v.var_id, - spirv::Decoration::PerPrimitiveEXT, - &[], - ) - .to_words(&mut self.logical_layout.annotations); - Instruction::decorate( - v.var_id, - spirv::Decoration::BuiltIn, - &[match member.binding.to_built_in().unwrap() { - crate::BuiltIn::PointIndex => { - spirv::BuiltIn::PrimitivePointIndicesEXT - } - crate::BuiltIn::LineIndices => { - spirv::BuiltIn::PrimitiveLineIndicesEXT - } - crate::BuiltIn::TriangleIndices => { - spirv::BuiltIn::PrimitiveTriangleIndicesEXT - } - _ => unreachable!(), - } as Word], - ) - .to_words(&mut self.logical_layout.annotations); - iface.varying_ids.push(v.var_id); - if self.flags.contains(WriterFlags::DEBUG) { - Instruction::name(v.var_id, "naga_primitive_indices_outputs") - .to_words(&mut self.logical_layout.debugs); - } - mesh_return_info.primitive_indices = Some(v); - } - crate::Binding::Location { location, .. } => { - let s_type = self.id_gen.next(); - Instruction::type_struct(s_type, &[member.ty_id]) - .to_words(&mut self.logical_layout.declarations); - Instruction::decorate(s_type, spirv::Decoration::Block, &[]) - .to_words(&mut self.logical_layout.annotations); - Instruction::member_decorate( - s_type, - 0, - spirv::Decoration::Location, - &[location], - ) - .to_words(&mut self.logical_layout.annotations); - let v = self.write_mesh_return_global_variable( - s_type, - prim_info.array_size_id, - )?; - Instruction::decorate( - v.var_id, - spirv::Decoration::PerPrimitiveEXT, - &[], - ) - .to_words(&mut self.logical_layout.annotations); - iface.varying_ids.push(v.var_id); - mesh_return_info.primitive_bindings.push(v); - } - crate::Binding::BuiltIn(_) => (), - } - } - } - ep_context.mesh_state = Some(mesh_return_info); - } + self.write_entry_point_mesh_shader_info( + iface, + local_invocation_index_id, + ir_module, + &mut prelude, + &mut ep_context, + )?; } let lookup_function_type = LookupFunctionType { @@ -1466,20 +1502,21 @@ impl Writer { match (context.writer.zero_initialize_workgroup_memory, interface) { ( super::ZeroInitializeWorkgroupMemoryMode::Polyfill, - Some( - ref mut interface @ FunctionInterface { - stage: crate::ShaderStage::Compute, - .. - }, - ), - ) => context.writer.generate_workgroup_vars_init_block( - next_id, - ir_module, - info, - local_invocation_id, - interface, - context.function, - ), + Some(ref mut interface @ FunctionInterface { stage, .. }), + ) => { + if stage.compute_like() { + context.writer.generate_workgroup_vars_init_block( + next_id, + ir_module, + info, + local_invocation_id, + interface, + context.function, + ) + } else { + None + } + } _ => None, }; @@ -2684,13 +2721,19 @@ impl Writer { } } - /// Returns the id of the variable, and the type of the array + /// Sets up the temporary mesh shader output buffer for the given output type, + /// and ensures it is long enough. pub fn mesh_shader_output_variable( &mut self, output_type: Handle, is_primitive: bool, array_len: Word, ) -> Result { + // We only want one temporary buffer per (type, is_primitive) combo, + // as functions that can be used by multiple entry points should be + // able to write to the output for all of them. However, the actual + // output buffers for mesh shaders must have an exact size, so we use + // a temporary buffer with size the largest of any entry points'. let u32_ty = self.get_u32_type_id(); let u32_ptr = self.get_pointer_type_id(u32_ty, spirv::StorageClass::Workgroup); if self.mesh_state.num_vertices_var.is_none() { @@ -2730,11 +2773,12 @@ impl Writer { } None => { // We write the literal, and avoid caching as it might change lol + // (no `get_constant_scalar`) let len_value_id = self.id_gen.next(); let main_type_id = self.get_handle_type_id(output_type); Instruction::constant_32bit(self.get_u32_type_id(), len_value_id, array_len) .to_words(&mut self.logical_layout.declarations); - // This is the best part + // This is the best part. We store the word index so we can change it later as needed let len_literal_idx = self.logical_layout.declarations.len() - 1; let array_ty = self.id_gen.next(); diff --git a/naga/src/front/wgsl/lower/mod.rs b/naga/src/front/wgsl/lower/mod.rs index 066981418b6..ef63e6aaea7 100644 --- a/naga/src/front/wgsl/lower/mod.rs +++ b/naga/src/front/wgsl/lower/mod.rs @@ -3260,7 +3260,6 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let rctx = ctx.runtime_expression_ctx(span)?; - // TODO: fix this // Emit all previous expressions, even if not used directly rctx.block .extend(rctx.emitter.finish(&rctx.function.expressions)); diff --git a/naga/src/ir/mod.rs b/naga/src/ir/mod.rs index a975cc8a49d..a182bf0e064 100644 --- a/naga/src/ir/mod.rs +++ b/naga/src/ir/mod.rs @@ -2619,7 +2619,6 @@ pub enum MeshOutputTopology { #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[allow(dead_code)] pub struct MeshStageInfo { - /// Should be Some by the time it passes validation pub topology: MeshOutputTopology, pub max_vertices: u32, pub max_vertices_override: Option>, diff --git a/naga/tests/out/ir/spv-shadow.compact.ron b/naga/tests/out/ir/spv-shadow.compact.ron index 5d52f8b6e75..bed86a5334d 100644 --- a/naga/tests/out/ir/spv-shadow.compact.ron +++ b/naga/tests/out/ir/spv-shadow.compact.ron @@ -974,6 +974,7 @@ interpolation: Some(Perspective), sampling: Some(Center), blend_src: None, + per_primitive: false, )), ), ( @@ -984,6 +985,7 @@ interpolation: Some(Perspective), sampling: Some(Center), blend_src: None, + per_primitive: false, )), ), ], @@ -994,6 +996,7 @@ interpolation: None, sampling: None, blend_src: None, + per_primitive: false, )), )), local_variables: [], diff --git a/naga/tests/out/ir/spv-shadow.ron b/naga/tests/out/ir/spv-shadow.ron index c88a8498594..bdda1d18566 100644 --- a/naga/tests/out/ir/spv-shadow.ron +++ b/naga/tests/out/ir/spv-shadow.ron @@ -1252,6 +1252,7 @@ interpolation: Some(Perspective), sampling: Some(Center), blend_src: None, + per_primitive: false, )), ), ( @@ -1262,6 +1263,7 @@ interpolation: Some(Perspective), sampling: Some(Center), blend_src: None, + per_primitive: false, )), ), ], @@ -1272,6 +1274,7 @@ interpolation: None, sampling: None, blend_src: None, + per_primitive: false, )), )), local_variables: [], diff --git a/naga/tests/out/ir/spv-spec-constants.compact.ron b/naga/tests/out/ir/spv-spec-constants.compact.ron index c6dcde535b8..67eb29c2475 100644 --- a/naga/tests/out/ir/spv-spec-constants.compact.ron +++ b/naga/tests/out/ir/spv-spec-constants.compact.ron @@ -151,6 +151,7 @@ interpolation: Some(Perspective), sampling: Some(Center), blend_src: None, + per_primitive: false, )), offset: 0, ), @@ -510,6 +511,7 @@ interpolation: None, sampling: None, blend_src: None, + per_primitive: false, )), ), ( @@ -520,6 +522,7 @@ interpolation: None, sampling: None, blend_src: None, + per_primitive: false, )), ), ( @@ -530,6 +533,7 @@ interpolation: None, sampling: None, blend_src: None, + per_primitive: false, )), ), ], diff --git a/naga/tests/out/ir/spv-spec-constants.ron b/naga/tests/out/ir/spv-spec-constants.ron index 182efb53038..51686aa20eb 100644 --- a/naga/tests/out/ir/spv-spec-constants.ron +++ b/naga/tests/out/ir/spv-spec-constants.ron @@ -242,6 +242,7 @@ interpolation: Some(Perspective), sampling: Some(Center), blend_src: None, + per_primitive: false, )), offset: 0, ), @@ -616,6 +617,7 @@ interpolation: None, sampling: None, blend_src: None, + per_primitive: false, )), ), ( @@ -626,6 +628,7 @@ interpolation: None, sampling: None, blend_src: None, + per_primitive: false, )), ), ( @@ -636,6 +639,7 @@ interpolation: None, sampling: None, blend_src: None, + per_primitive: false, )), ), ], diff --git a/naga/tests/out/ir/wgsl-access.compact.ron b/naga/tests/out/ir/wgsl-access.compact.ron index 63411fe5d99..c3df0c8c500 100644 --- a/naga/tests/out/ir/wgsl-access.compact.ron +++ b/naga/tests/out/ir/wgsl-access.compact.ron @@ -2674,6 +2674,7 @@ interpolation: Some(Perspective), sampling: Some(Center), blend_src: None, + per_primitive: false, )), )), local_variables: [], diff --git a/naga/tests/out/ir/wgsl-access.ron b/naga/tests/out/ir/wgsl-access.ron index 63411fe5d99..c3df0c8c500 100644 --- a/naga/tests/out/ir/wgsl-access.ron +++ b/naga/tests/out/ir/wgsl-access.ron @@ -2674,6 +2674,7 @@ interpolation: Some(Perspective), sampling: Some(Center), blend_src: None, + per_primitive: false, )), )), local_variables: [], diff --git a/naga/tests/out/ir/wgsl-mesh-shader.compact.ron b/naga/tests/out/ir/wgsl-mesh-shader.compact.ron index 77bbb8f9412..38c79cba451 100644 --- a/naga/tests/out/ir/wgsl-mesh-shader.compact.ron +++ b/naga/tests/out/ir/wgsl-mesh-shader.compact.ron @@ -64,6 +64,7 @@ interpolation: Some(Perspective), sampling: Some(Center), blend_src: None, + per_primitive: false, )), offset: 16, ), @@ -112,6 +113,7 @@ interpolation: Some(Perspective), sampling: Some(Center), blend_src: None, + per_primitive: true, )), offset: 16, ), @@ -131,6 +133,7 @@ interpolation: Some(Perspective), sampling: Some(Center), blend_src: None, + per_primitive: true, )), offset: 0, ), @@ -314,7 +317,7 @@ index: 0, ), Literal(F32(0.0)), - Literal(F32(-1.0)), + Literal(F32(1.0)), Literal(F32(0.0)), Literal(F32(1.0)), Compose( @@ -365,7 +368,7 @@ index: 0, ), Literal(F32(-1.0)), - Literal(F32(1.0)), + Literal(F32(-1.0)), Literal(F32(0.0)), Literal(F32(1.0)), Compose( @@ -416,7 +419,7 @@ index: 0, ), Literal(F32(1.0)), - Literal(F32(1.0)), + Literal(F32(-1.0)), Literal(F32(0.0)), Literal(F32(1.0)), Compose( @@ -797,6 +800,7 @@ interpolation: Some(Perspective), sampling: Some(Center), blend_src: None, + per_primitive: false, )), )), local_variables: [], diff --git a/naga/tests/out/ir/wgsl-mesh-shader.ron b/naga/tests/out/ir/wgsl-mesh-shader.ron index 77bbb8f9412..38c79cba451 100644 --- a/naga/tests/out/ir/wgsl-mesh-shader.ron +++ b/naga/tests/out/ir/wgsl-mesh-shader.ron @@ -64,6 +64,7 @@ interpolation: Some(Perspective), sampling: Some(Center), blend_src: None, + per_primitive: false, )), offset: 16, ), @@ -112,6 +113,7 @@ interpolation: Some(Perspective), sampling: Some(Center), blend_src: None, + per_primitive: true, )), offset: 16, ), @@ -131,6 +133,7 @@ interpolation: Some(Perspective), sampling: Some(Center), blend_src: None, + per_primitive: true, )), offset: 0, ), @@ -314,7 +317,7 @@ index: 0, ), Literal(F32(0.0)), - Literal(F32(-1.0)), + Literal(F32(1.0)), Literal(F32(0.0)), Literal(F32(1.0)), Compose( @@ -365,7 +368,7 @@ index: 0, ), Literal(F32(-1.0)), - Literal(F32(1.0)), + Literal(F32(-1.0)), Literal(F32(0.0)), Literal(F32(1.0)), Compose( @@ -416,7 +419,7 @@ index: 0, ), Literal(F32(1.0)), - Literal(F32(1.0)), + Literal(F32(-1.0)), Literal(F32(0.0)), Literal(F32(1.0)), Compose( @@ -797,6 +800,7 @@ interpolation: Some(Perspective), sampling: Some(Center), blend_src: None, + per_primitive: false, )), )), local_variables: [], diff --git a/naga/tests/out/ir/wgsl-texture-external.compact.ron b/naga/tests/out/ir/wgsl-texture-external.compact.ron index a544447f100..379e76566c5 100644 --- a/naga/tests/out/ir/wgsl-texture-external.compact.ron +++ b/naga/tests/out/ir/wgsl-texture-external.compact.ron @@ -360,6 +360,7 @@ interpolation: Some(Perspective), sampling: Some(Center), blend_src: None, + per_primitive: false, )), )), local_variables: [], diff --git a/naga/tests/out/ir/wgsl-texture-external.ron b/naga/tests/out/ir/wgsl-texture-external.ron index a544447f100..379e76566c5 100644 --- a/naga/tests/out/ir/wgsl-texture-external.ron +++ b/naga/tests/out/ir/wgsl-texture-external.ron @@ -360,6 +360,7 @@ interpolation: Some(Perspective), sampling: Some(Center), blend_src: None, + per_primitive: false, )), )), local_variables: [], diff --git a/naga/tests/out/spv/wgsl-mesh-shader.spvasm b/naga/tests/out/spv/wgsl-mesh-shader.spvasm index 80d4813e439..28dfb64740c 100644 --- a/naga/tests/out/spv/wgsl-mesh-shader.spvasm +++ b/naga/tests/out/spv/wgsl-mesh-shader.spvasm @@ -1,21 +1,33 @@ ; SPIR-V ; Version: 1.4 ; Generator: rspirv -; Bound: 142 +; Bound: 199 OpCapability Shader OpCapability MeshShadingEXT OpExtension "SPV_EXT_mesh_shader" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint TaskEXT %17 "ts_main" %12 %14 -OpEntryPoint MeshEXT %59 "ms_main" %36 %39 %12 %44 %47 %51 %54 %57 %14 -OpEntryPoint Fragment %137 "fs_main" %128 %131 %134 %136 +OpEntryPoint TaskEXT %17 "ts_main" %12 %14 %28 +OpEntryPoint MeshEXT %86 "ms_main" %49 %52 %12 %59 %63 %55 %56 %70 %74 %78 %81 %85 %14 %103 +OpEntryPoint Fragment %194 "fs_main" %185 %188 %191 %193 OpExecutionMode %17 LocalSize 1 1 1 -OpExecutionMode %59 LocalSize 1 1 1 -OpExecutionMode %59 OutputTrianglesNV -OpExecutionMode %59 OutputVertices 3 -OpExecutionMode %59 OutputPrimitivesNV 1 -OpExecutionMode %137 OriginUpperLeft +OpExecutionMode %86 LocalSize 1 1 1 +OpExecutionMode %86 OutputTrianglesNV +OpExecutionMode %86 OutputVertices 3 +OpExecutionMode %86 OutputPrimitivesNV 1 +OpExecutionMode %194 OriginUpperLeft +OpMemberDecorate %67 0 BuiltIn Position +OpDecorate %67 Block +OpMemberDecorate %71 0 BuiltIn CullPrimitiveEXT +OpDecorate %71 Block +OpDecorate %74 PerPrimitiveNV +OpDecorate %75 Block +OpMemberDecorate %75 0 Location 0 +OpDecorate %81 PerPrimitiveNV +OpDecorate %81 BuiltIn PrimitiveTriangleIndicesEXT +OpDecorate %82 Block +OpMemberDecorate %82 0 Location 1 +OpDecorate %85 PerPrimitiveNV OpMemberDecorate %6 0 Offset 0 OpMemberDecorate %6 1 Offset 16 OpMemberDecorate %7 0 Offset 0 @@ -24,20 +36,15 @@ OpMemberDecorate %10 0 Offset 0 OpMemberDecorate %10 1 Offset 12 OpMemberDecorate %10 2 Offset 16 OpMemberDecorate %11 0 Offset 0 -OpDecorate %36 BuiltIn LocalInvocationIndex -OpDecorate %39 BuiltIn GlobalInvocationId -OpDecorate %44 BuiltIn Position -OpDecorate %47 Location 0 -OpDecorate %51 PerPrimitiveNV -OpDecorate %51 BuiltIn PrimitiveTriangleIndicesEXT -OpDecorate %54 PerPrimitiveNV -OpDecorate %54 BuiltIn CullPrimitiveEXT -OpDecorate %57 PerPrimitiveNV -OpDecorate %57 Location 1 -OpDecorate %128 BuiltIn FragCoord -OpDecorate %131 Location 0 -OpDecorate %134 Location 1 -OpDecorate %136 Location 0 +OpDecorate %28 BuiltIn LocalInvocationId +OpDecorate %49 BuiltIn LocalInvocationIndex +OpDecorate %52 BuiltIn GlobalInvocationId +OpDecorate %103 BuiltIn LocalInvocationId +OpDecorate %185 BuiltIn FragCoord +OpDecorate %188 Location 0 +OpDecorate %191 Location 1 +OpDecorate %191 PerPrimitiveNV +OpDecorate %193 Location 0 %2 = OpTypeVoid %3 = OpTypeFloat 32 %4 = OpTypeVector %3 4 @@ -60,154 +67,241 @@ OpDecorate %136 Location 0 %23 = OpConstant %8 3 %24 = OpConstant %8 1 %25 = OpConstantComposite %9 %23 %24 %24 -%27 = OpTypePointer TaskPayloadWorkgroupEXT %4 -%28 = OpConstant %8 0 -%30 = OpTypePointer TaskPayloadWorkgroupEXT %5 -%37 = OpTypePointer Input %8 -%36 = OpVariable %37 Input -%40 = OpTypePointer Input %9 -%39 = OpVariable %40 Input -%42 = OpConstant %8 3 -%43 = OpTypeArray %4 %42 -%45 = OpTypePointer Output %43 -%44 = OpVariable %45 Output -%46 = OpTypeArray %4 %42 -%48 = OpTypePointer Output %46 -%47 = OpVariable %48 Output -%49 = OpConstant %8 1 -%50 = OpTypeArray %9 %49 -%52 = OpTypePointer Output %50 -%51 = OpVariable %52 Output -%53 = OpTypeArray %5 %49 -%55 = OpTypePointer Output %53 -%54 = OpVariable %55 Output -%56 = OpTypeArray %4 %49 -%58 = OpTypePointer Output %56 -%57 = OpVariable %58 Output -%60 = OpConstant %3 2 -%61 = OpConstant %3 -1 -%62 = OpConstantComposite %4 %20 %61 %20 %19 -%63 = OpConstantComposite %4 %20 %19 %20 %19 -%64 = OpConstantComposite %4 %61 %19 %20 %19 -%65 = OpConstantComposite %4 %20 %20 %19 %19 -%66 = OpConstantComposite %4 %19 %20 %20 %19 -%67 = OpConstant %8 2 -%68 = OpConstantComposite %9 %28 %24 %67 -%69 = OpConstantComposite %4 %19 %20 %19 %19 -%71 = OpTypePointer Function %7 -%72 = OpConstantNull %7 -%74 = OpTypePointer Function %10 -%75 = OpConstantNull %10 -%77 = OpTypePointer Function %4 -%86 = OpTypePointer Output %4 -%109 = OpTypePointer Function %9 -%111 = OpTypePointer Function %5 -%120 = OpTypePointer Output %9 -%123 = OpTypePointer Output %5 -%129 = OpTypePointer Input %4 -%128 = OpVariable %129 Input -%131 = OpVariable %129 Input -%134 = OpVariable %129 Input -%136 = OpVariable %86 Output +%27 = OpConstantNull %3 +%29 = OpTypePointer Input %9 +%28 = OpVariable %29 Input +%31 = OpConstantNull %9 +%32 = OpTypeVector %5 3 +%37 = OpConstant %8 2 +%38 = OpConstant %8 264 +%40 = OpTypePointer TaskPayloadWorkgroupEXT %4 +%41 = OpConstant %8 0 +%43 = OpTypePointer TaskPayloadWorkgroupEXT %5 +%50 = OpTypePointer Input %8 +%49 = OpVariable %50 Input +%52 = OpVariable %29 Input +%54 = OpTypePointer Workgroup %8 +%55 = OpVariable %54 Workgroup +%56 = OpVariable %54 Workgroup +%57 = OpConstant %8 3 +%58 = OpTypeArray %7 %57 +%60 = OpTypePointer Workgroup %58 +%59 = OpVariable %60 Workgroup +%61 = OpConstant %8 1 +%62 = OpTypeArray %10 %61 +%64 = OpTypePointer Workgroup %62 +%63 = OpVariable %64 Workgroup +%66 = OpTypePointer Function %8 +%67 = OpTypeStruct %4 +%68 = OpTypeArray %67 %57 +%69 = OpTypePointer Output %68 +%70 = OpVariable %69 Output +%71 = OpTypeStruct %5 +%72 = OpTypeArray %71 %61 +%73 = OpTypePointer Output %72 +%74 = OpVariable %73 Output +%75 = OpTypeStruct %4 +%76 = OpTypeArray %75 %61 +%77 = OpTypePointer Output %76 +%78 = OpVariable %77 Output +%79 = OpTypeArray %9 %61 +%80 = OpTypePointer Output %79 +%81 = OpVariable %80 Output +%82 = OpTypeStruct %4 +%83 = OpTypeArray %82 %61 +%84 = OpTypePointer Output %83 +%85 = OpVariable %84 Output +%87 = OpConstant %3 2 +%88 = OpConstantComposite %4 %20 %19 %20 %19 +%89 = OpConstant %3 -1 +%90 = OpConstantComposite %4 %89 %89 %20 %19 +%91 = OpConstantComposite %4 %20 %20 %19 %19 +%92 = OpConstantComposite %4 %19 %89 %20 %19 +%93 = OpConstantComposite %4 %19 %20 %20 %19 +%94 = OpConstantComposite %9 %41 %24 %37 +%95 = OpConstantComposite %4 %19 %20 %19 %19 +%97 = OpTypePointer Function %7 +%98 = OpConstantNull %7 +%100 = OpTypePointer Function %10 +%101 = OpConstantNull %10 +%103 = OpVariable %29 Input +%110 = OpTypePointer Function %4 +%118 = OpTypePointer Workgroup %7 +%133 = OpTypePointer Function %9 +%135 = OpTypePointer Function %5 +%143 = OpTypePointer Workgroup %10 +%155 = OpTypePointer Output %4 +%163 = OpTypePointer Output %9 +%166 = OpTypePointer Output %5 +%186 = OpTypePointer Input %4 +%185 = OpVariable %186 Input +%188 = OpVariable %186 Input +%191 = OpVariable %186 Input +%193 = OpVariable %155 Output %17 = OpFunction %2 None %18 %16 = OpLabel OpBranch %26 %26 = OpLabel +%30 = OpLoad %9 %28 +%33 = OpIEqual %32 %30 %31 +%34 = OpAll %5 %33 +OpSelectionMerge %35 None +OpBranchConditional %34 %36 %35 +%36 = OpLabel +OpStore %14 %27 +OpBranch %35 +%35 = OpLabel +OpControlBarrier %37 %37 %38 +OpBranch %39 +%39 = OpLabel OpStore %14 %19 -%29 = OpAccessChain %27 %12 %28 -OpStore %29 %21 -%31 = OpAccessChain %30 %12 %24 -OpStore %31 %22 -%32 = OpCompositeExtract %8 %25 0 -%33 = OpCompositeExtract %8 %25 1 -%34 = OpCompositeExtract %8 %25 2 -OpEmitMeshTasksEXT %32 %33 %34 %12 +%42 = OpAccessChain %40 %12 %41 +OpStore %42 %21 +%44 = OpAccessChain %43 %12 %24 +OpStore %44 %22 +%45 = OpCompositeExtract %8 %25 0 +%46 = OpCompositeExtract %8 %25 1 +%47 = OpCompositeExtract %8 %25 2 +OpEmitMeshTasksEXT %45 %46 %47 %12 OpFunctionEnd -%59 = OpFunction %2 None %18 -%35 = OpLabel -%70 = OpVariable %71 Function %72 -%73 = OpVariable %74 Function %75 -%38 = OpLoad %8 %36 -%41 = OpLoad %9 %39 -OpBranch %76 -%76 = OpLabel -OpSetMeshOutputsEXT %23 %24 -OpStore %14 %60 -%78 = OpAccessChain %77 %70 %28 -OpStore %78 %62 -%79 = OpAccessChain %27 %12 %28 -%80 = OpLoad %4 %79 -%81 = OpFMul %4 %63 %80 -%82 = OpAccessChain %77 %70 %24 -OpStore %82 %81 -%83 = OpLoad %7 %70 -%84 = OpCompositeExtract %4 %83 0 -%85 = OpAccessChain %86 %44 %28 -OpStore %85 %84 -%87 = OpCompositeExtract %4 %83 1 -%88 = OpAccessChain %86 %47 %28 -OpStore %88 %87 -%89 = OpAccessChain %77 %70 %28 -OpStore %89 %64 -%90 = OpAccessChain %27 %12 %28 -%91 = OpLoad %4 %90 -%92 = OpFMul %4 %65 %91 -%93 = OpAccessChain %77 %70 %24 -OpStore %93 %92 -%94 = OpLoad %7 %70 -%95 = OpCompositeExtract %4 %94 0 -%96 = OpAccessChain %86 %44 %24 -OpStore %96 %95 -%97 = OpCompositeExtract %4 %94 1 -%98 = OpAccessChain %86 %47 %24 -OpStore %98 %97 -%99 = OpAccessChain %77 %70 %28 -OpStore %99 %21 -%100 = OpAccessChain %27 %12 %28 -%101 = OpLoad %4 %100 -%102 = OpFMul %4 %66 %101 -%103 = OpAccessChain %77 %70 %24 -OpStore %103 %102 -%104 = OpLoad %7 %70 -%105 = OpCompositeExtract %4 %104 0 -%106 = OpAccessChain %86 %44 %67 -OpStore %106 %105 -%107 = OpCompositeExtract %4 %104 1 -%108 = OpAccessChain %86 %47 %67 -OpStore %108 %107 -%110 = OpAccessChain %109 %73 %28 -OpStore %110 %68 -%112 = OpAccessChain %30 %12 %24 -%113 = OpLoad %5 %112 -%114 = OpLogicalNot %5 %113 -%115 = OpAccessChain %111 %73 %24 +%86 = OpFunction %2 None %18 +%48 = OpLabel +%96 = OpVariable %97 Function %98 +%99 = OpVariable %100 Function %101 +%65 = OpVariable %66 Function +%51 = OpLoad %8 %49 +%53 = OpLoad %9 %52 +OpBranch %102 +%102 = OpLabel +%104 = OpLoad %9 %103 +%105 = OpIEqual %32 %104 %31 +%106 = OpAll %5 %105 +OpSelectionMerge %107 None +OpBranchConditional %106 %108 %107 +%108 = OpLabel +OpStore %14 %27 +OpBranch %107 +%107 = OpLabel +OpControlBarrier %37 %37 %38 +OpBranch %109 +%109 = OpLabel +OpStore %55 %23 +OpStore %56 %24 +OpStore %14 %87 +%111 = OpAccessChain %110 %96 %41 +OpStore %111 %88 +%112 = OpAccessChain %40 %12 %41 +%113 = OpLoad %4 %112 +%114 = OpFMul %4 %88 %113 +%115 = OpAccessChain %110 %96 %24 OpStore %115 %114 -%116 = OpAccessChain %77 %73 %67 -OpStore %116 %69 -%117 = OpLoad %10 %73 -%118 = OpCompositeExtract %9 %117 0 -%119 = OpAccessChain %120 %51 %28 -OpStore %119 %118 -%121 = OpCompositeExtract %5 %117 1 -%122 = OpAccessChain %123 %54 %28 -OpStore %122 %121 -%124 = OpCompositeExtract %4 %117 2 -%125 = OpAccessChain %86 %57 %28 +%116 = OpLoad %7 %96 +%117 = OpAccessChain %118 %59 %41 +OpStore %117 %116 +%119 = OpAccessChain %110 %96 %41 +OpStore %119 %90 +%120 = OpAccessChain %40 %12 %41 +%121 = OpLoad %4 %120 +%122 = OpFMul %4 %91 %121 +%123 = OpAccessChain %110 %96 %24 +OpStore %123 %122 +%124 = OpLoad %7 %96 +%125 = OpAccessChain %118 %59 %24 OpStore %125 %124 +%126 = OpAccessChain %110 %96 %41 +OpStore %126 %92 +%127 = OpAccessChain %40 %12 %41 +%128 = OpLoad %4 %127 +%129 = OpFMul %4 %93 %128 +%130 = OpAccessChain %110 %96 %24 +OpStore %130 %129 +%131 = OpLoad %7 %96 +%132 = OpAccessChain %118 %59 %37 +OpStore %132 %131 +%134 = OpAccessChain %133 %99 %41 +OpStore %134 %94 +%136 = OpAccessChain %43 %12 %24 +%137 = OpLoad %5 %136 +%138 = OpLogicalNot %5 %137 +%139 = OpAccessChain %135 %99 %24 +OpStore %139 %138 +%140 = OpAccessChain %110 %99 %37 +OpStore %140 %95 +%141 = OpLoad %10 %99 +%142 = OpAccessChain %143 %63 %41 +OpStore %142 %141 +%144 = OpLoad %8 %55 +%145 = OpLoad %8 %56 +OpSetMeshOutputsEXT %144 %145 +OpStore %65 %51 +OpBranch %146 +%146 = OpLabel +OpLoopMerge %148 %170 None +OpBranch %169 +%169 = OpLabel +%172 = OpLoad %8 %65 +%173 = OpULessThan %5 %172 %144 +OpBranchConditional %173 %171 %148 +%171 = OpLabel +%150 = OpLoad %8 %65 +%151 = OpAccessChain %118 %59 %150 +%152 = OpLoad %7 %151 +%153 = OpCompositeExtract %4 %152 0 +%154 = OpAccessChain %155 %70 %150 %41 +OpStore %154 %153 +%156 = OpCompositeExtract %4 %152 1 +%157 = OpAccessChain %155 %78 %150 %41 +OpStore %157 %156 +OpBranch %170 +%170 = OpLabel +%174 = OpLoad %8 %65 +%175 = OpIAdd %8 %174 %24 +OpStore %65 %175 +OpBranch %146 +%148 = OpLabel +OpStore %65 %51 +OpBranch %147 +%147 = OpLabel +OpLoopMerge %149 %177 None +OpBranch %176 +%176 = OpLabel +%179 = OpLoad %8 %65 +%180 = OpULessThan %5 %179 %145 +OpBranchConditional %180 %178 %149 +%178 = OpLabel +%158 = OpLoad %8 %65 +%159 = OpAccessChain %143 %63 %158 +%160 = OpLoad %10 %159 +%161 = OpCompositeExtract %9 %160 0 +%162 = OpAccessChain %163 %81 %158 +OpStore %162 %161 +%164 = OpCompositeExtract %5 %160 1 +%165 = OpAccessChain %166 %74 %158 %41 +OpStore %165 %164 +%167 = OpCompositeExtract %4 %160 2 +%168 = OpAccessChain %155 %85 %158 %41 +OpStore %168 %167 +OpBranch %177 +%177 = OpLabel +%181 = OpLoad %8 %65 +%182 = OpIAdd %8 %181 %24 +OpStore %65 %182 +OpBranch %147 +%149 = OpLabel OpReturn OpFunctionEnd -%137 = OpFunction %2 None %18 -%126 = OpLabel -%130 = OpLoad %4 %128 -%132 = OpLoad %4 %131 -%127 = OpCompositeConstruct %7 %130 %132 -%135 = OpLoad %4 %134 -%133 = OpCompositeConstruct %11 %135 -OpBranch %138 -%138 = OpLabel -%139 = OpCompositeExtract %4 %127 1 -%140 = OpCompositeExtract %4 %133 0 -%141 = OpFMul %4 %139 %140 -OpStore %136 %141 +%194 = OpFunction %2 None %18 +%183 = OpLabel +%187 = OpLoad %4 %185 +%189 = OpLoad %4 %188 +%184 = OpCompositeConstruct %7 %187 %189 +%192 = OpLoad %4 %191 +%190 = OpCompositeConstruct %11 %192 +OpBranch %195 +%195 = OpLabel +%196 = OpCompositeExtract %4 %184 1 +%197 = OpCompositeExtract %4 %190 0 +%198 = OpFMul %4 %196 %197 +OpStore %193 %198 OpReturn OpFunctionEnd \ No newline at end of file From d54f7c65ed4c8a1314d8bcbaf60f4c8817cd2922 Mon Sep 17 00:00:00 2001 From: SupaMaggie70 Date: Thu, 14 Aug 2025 01:13:04 -0500 Subject: [PATCH 75/84] Addressed another comment --- naga/src/back/spv/writer.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 704d063dacb..c66f44a66ec 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -1265,6 +1265,9 @@ impl Writer { let binding = member.binding.as_ref().unwrap(); has_point_size |= *binding == crate::Binding::BuiltIn(crate::BuiltIn::PointSize); + // This isn't an actual builtin in SPIR-V. It can only appear as the + // output of a task shader and the output is used when writing the + // entry point return, in which case the id is ignored anyway. let varying_id = if *binding == crate::Binding::BuiltIn(crate::BuiltIn::MeshTaskSize) { From 68ebb3e999a2adc91e9dd63ab4305888227e0d04 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Thu, 14 Aug 2025 16:41:20 -0500 Subject: [PATCH 76/84] Quick before corruption! --- Cargo.lock | 8 +- benches/Cargo.toml | 10 + benches/benches/wgpu-benchmark/shader.rs | 124 +++--- naga/Cargo.toml | 23 +- naga/src/back/spv/writer.rs | 15 + naga/src/front/wgsl/mod.rs | 3 + naga/tests/naga/snapshots.rs | 458 ++--------------------- tests/Cargo.toml | 18 + tests/src/lib.rs | 1 + tests/src/naga.rs | 450 ++++++++++++++++++++++ 10 files changed, 625 insertions(+), 485 deletions(-) create mode 100644 tests/src/naga.rs diff --git a/Cargo.lock b/Cargo.lock index 1f0c5b5ab22..a23867607aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2522,9 +2522,9 @@ dependencies = [ "spirv", "strum 0.27.2", "thiserror 2.0.14", - "toml 0.9.5", "unicode-ident", "walkdir", + "wgpu-test", ] [[package]] @@ -4940,6 +4940,7 @@ dependencies = [ "rayon", "tracy-client", "wgpu", + "wgpu-test", ] [[package]] @@ -5161,15 +5162,20 @@ dependencies = [ "js-sys", "libtest-mimic", "log", + "naga", "nanorand 0.8.0", "nv-flip", "parking_lot", "png", "pollster", "profiling", + "ron", + "rspirv", "serde", "serde_json", + "spirv", "strum 0.27.2", + "toml 0.9.5", "trybuild", "wasm-bindgen", "wasm-bindgen-futures", diff --git a/benches/Cargo.toml b/benches/Cargo.toml index 9af4cf4ae7d..53c992ce86a 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -47,3 +47,13 @@ profiling.workspace = true rayon.workspace = true tracy-client = { workspace = true, optional = true } wgpu.workspace = true +wgpu-test = { workspace = true, features = [ + "wgsl-in", + "spv-in", + "glsl-in", + "spv-out", + "msl-out", + "hlsl-out", + "glsl-out", + "wgsl-out", +] } diff --git a/benches/benches/wgpu-benchmark/shader.rs b/benches/benches/wgpu-benchmark/shader.rs index b98cef01ae5..a8a6c54f56c 100644 --- a/benches/benches/wgpu-benchmark/shader.rs +++ b/benches/benches/wgpu-benchmark/shader.rs @@ -1,57 +1,55 @@ use criterion::*; -use std::{fs, path::PathBuf, process::Command}; +use std::{fs, process::Command}; -struct Input { - filename: String, - size: u64, +const DIR_IN: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../naga/tests/in"); +const DIR_OUT: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../naga/tests/in"); + +use wgpu_test::naga::*; + +struct InputWithInfo { + inner: Input, data: Vec, string: Option, + options: Parameters, module: Option, module_info: Option, } +impl From for InputWithInfo { + fn from(value: Input) -> Self { + Self { + options: value.read_parameters(DIR_IN), + inner: value, + data: Vec::new(), + string: None, + module: None, + module_info: None, + } + } +} +impl InputWithInfo { + fn filename(&self) -> &str { + self.inner.file_name.file_name().unwrap().to_str().unwrap() + } +} struct Inputs { - inner: Vec, + inner: Vec, } impl Inputs { #[track_caller] fn from_dir(folder: &str, extension: &str) -> Self { - let mut inputs = Vec::new(); - let read_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join(folder) - .read_dir() - .unwrap(); - - for file_entry in read_dir { - match file_entry { - Ok(entry) => match entry.path().extension() { - Some(ostr) if ostr == extension => { - let path = entry.path(); - - inputs.push(Input { - filename: path.to_string_lossy().into_owned(), - size: entry.metadata().unwrap().len(), - string: None, - data: vec![], - module: None, - module_info: None, - }); - } - _ => continue, - }, - Err(e) => { - eprintln!("Skipping file: {e:?}"); - continue; - } - } - } + let inputs: Vec = Input::files_in_dir(folder, &[extension], DIR_IN) + .map(|a| a.into()) + .collect(); Self { inner: inputs } } - fn bytes(&self) -> u64 { - self.inner.iter().map(|input| input.size).sum() + self.inner + .iter() + .map(|input| input.inner.bytes(DIR_IN)) + .sum() } fn load(&mut self) { @@ -60,7 +58,7 @@ impl Inputs { continue; } - input.data = fs::read(&input.filename).unwrap_or_default(); + input.data = fs::read(&input.inner.file_name).unwrap_or_default(); } } @@ -85,6 +83,10 @@ impl Inputs { continue; } + let WgslInParameters { parse_doc_comments } = input.options.wgsl_in; + let options = naga::front::wgsl::Options { parse_doc_comments }; + parser.set_options(options); + input.module = Some(parser.parse(input.string.as_ref().unwrap()).unwrap()); } } @@ -122,22 +124,22 @@ fn parse_glsl(stage: naga::ShaderStage, inputs: &Inputs) { }; for input in &inputs.inner { parser - .parse(&options, input.string.as_deref().unwrap()) + .parse(&options, &input.inner.read_source(DIR_IN)) .unwrap(); } } fn get_wgsl_inputs() -> Inputs { - let mut inputs = Inputs::from_dir("../naga/tests/in/wgsl", "wgsl"); + let mut inputs: Vec = Input::files_in_dir("wgsl", &["wgsl"], DIR_IN) + .map(|a| a.into()) + .collect(); // remove "large-source" tests, they skew the results - inputs - .inner - .retain(|input| !input.filename.contains("large-source")); + inputs.retain(|input| !input.filename().contains("large-source")); assert!(!inputs.is_empty()); - inputs + Inputs { inner: inputs } } fn frontends(c: &mut Criterion) { @@ -178,6 +180,9 @@ fn frontends(c: &mut Criterion) { let mut frontend = naga::front::wgsl::Frontend::new(); b.iter(|| { for input in &inputs_wgsl.inner { + let WgslInParameters { parse_doc_comments } = input.options.wgsl_in; + let options = naga::front::wgsl::Options { parse_doc_comments }; + frontend.set_options(options); frontend.parse(input.string.as_ref().unwrap()).unwrap(); } }); @@ -190,7 +195,7 @@ fn frontends(c: &mut Criterion) { let mut assembled_spirv = Vec::>::new(); 'spirv: for input in &inputs_spirv.inner { let output = match Command::new("spirv-as") - .arg(&input.filename) + .arg(input.filename()) .arg("-o") .arg("-") .output() @@ -220,12 +225,25 @@ fn frontends(c: &mut Criterion) { let total_bytes = assembled_spirv.iter().map(|spv| spv.len() as u64).sum(); + assert!(assembled_spirv.len() == inputs_spirv.inner.len() || assembled_spirv.is_empty()); + group.throughput(Throughput::Bytes(total_bytes)); group.bench_function("shader: spv-in", |b| { b.iter(|| { - let options = naga::front::spv::Options::default(); - for input in &assembled_spirv { - let parser = naga::front::spv::Frontend::new(input.iter().cloned(), &options); + for (i, input) in assembled_spirv.iter().enumerate() { + let params = &inputs_spirv.inner[i].options; + let SpirvInParameters { + adjust_coordinate_space, + } = params.spv_in; + + let parser = naga::front::spv::Frontend::new( + input.iter().cloned(), + &naga::front::spv::Options { + adjust_coordinate_space, + strict_capabilities: true, + ..Default::default() + }, + ); parser.parse().unwrap(); } }); @@ -312,9 +330,9 @@ fn backends(c: &mut Criterion) { group.bench_function("shader: wgsl-out", |b| { b.iter(|| { let mut string = String::new(); - let flags = naga::back::wgsl::WriterFlags::empty(); for input in &inputs.inner { - let mut writer = naga::back::wgsl::Writer::new(&mut string, flags); + let mut writer = + naga::back::wgsl::Writer::new(&mut string, (&input.options.wgsl).into()); let _ = writer.write( input.module.as_ref().unwrap(), input.module_info.as_ref().unwrap(), @@ -327,13 +345,13 @@ fn backends(c: &mut Criterion) { group.bench_function("shader: spv-out", |b| { b.iter(|| { let mut data = Vec::new(); - let options = naga::back::spv::Options::default(); + let mut writer = naga::back::spv::Writer::new(&Default::default()).unwrap(); for input in &inputs.inner { - if input.filename.contains("pointer-function-arg") { + if input.filename().contains("pointer-function-arg") { // These fail due to https://github.com/gfx-rs/wgpu/issues/7315 continue; } - let mut writer = naga::back::spv::Writer::new(&options).unwrap(); + let opt = input.options.spv.to_options(bounds_check_policies, debug_info) let _ = writer.write( input.module.as_ref().unwrap(), input.module_info.as_ref().unwrap(), @@ -350,7 +368,7 @@ fn backends(c: &mut Criterion) { let mut data = Vec::new(); let options = naga::back::spv::Options::default(); for input in &inputs.inner { - if input.filename.contains("pointer-function-arg") { + if input.filename().contains("pointer-function-arg") { // These fail due to https://github.com/gfx-rs/wgpu/issues/7315 continue; } diff --git a/naga/Cargo.toml b/naga/Cargo.toml index 02eda4c198a..824bc9d6d87 100644 --- a/naga/Cargo.toml +++ b/naga/Cargo.toml @@ -20,20 +20,20 @@ all-features = true [features] default = [] -dot-out = [] -glsl-in = ["dep:pp-rs"] -glsl-out = [] +dot-out = ["wgpu-test/dot-out"] +glsl-in = ["dep:pp-rs", "wgpu-test/glsl-in"] +glsl-out = ["wgpu-test/glsl-out"] ## Enables outputting to the Metal Shading Language (MSL). ## ## This enables MSL output regardless of the target platform. ## If you want to enable it only when targeting iOS/tvOS/watchOS/macOS, use `naga/msl-out-if-target-apple`. -msl-out = [] +msl-out = ["wgpu-test/msl-out"] ## Enables outputting to the Metal Shading Language (MSL) only if the target platform is iOS/tvOS/watchOS/macOS. ## ## If you want to enable MSL output it regardless of the target platform, use `naga/msl-out`. -msl-out-if-target-apple = [] +msl-out-if-target-apple = ["wgpu-test/msl-out"] serialize = [ "dep:serde", @@ -56,16 +56,16 @@ arbitrary = [ "half/arbitrary", "half/std", ] -spv-in = ["dep:petgraph", "petgraph/graphmap", "dep:spirv"] -spv-out = ["dep:spirv"] -wgsl-in = ["dep:hexf-parse", "dep:unicode-ident"] -wgsl-out = [] +spv-in = ["dep:petgraph", "petgraph/graphmap", "dep:spirv", "wgpu-test/spv-in"] +spv-out = ["dep:spirv", "wgpu-test/spv-out"] +wgsl-in = ["dep:hexf-parse", "dep:unicode-ident", "wgpu-test/wgsl-in"] +wgsl-out = ["wgpu-test/wgsl-out"] ## Enables outputting to HLSL (Microsoft's High-Level Shader Language). ## ## This enables HLSL output regardless of the target platform. ## If you want to enable it only when targeting Windows, use `hlsl-out-if-target-windows`. -hlsl-out = [] +hlsl-out = ["wgpu-test/hlsl-out"] ## Enables outputting to HLSL (Microsoft's High-Level Shader Language) only if the target platform is Windows. ## @@ -116,10 +116,9 @@ itertools.workspace = true ron.workspace = true rspirv.workspace = true serde = { workspace = true, features = ["default", "derive"] } -spirv = { workspace = true, features = ["deserialize"] } strum = { workspace = true } -toml.workspace = true walkdir.workspace = true +wgpu-test.workspace = true [lints.clippy] std_instead_of_alloc = "warn" diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index c66f44a66ec..2f5315c7443 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -106,6 +106,21 @@ impl Writer { }) } + pub fn set_options(&mut self, options: &Options) -> Result<(), Error> { + let (major, minor) = options.lang_version; + if major != 1 { + return Err(Error::UnsupportedVersion(major, minor)); + } + self.physical_layout = PhysicalLayout::new(major, minor); + self.capabilities_available = options.capabilities.clone(); + self.flags = options.flags; + self.bounds_check_policies = options.bounds_check_policies; + self.zero_initialize_workgroup_memory = options.zero_initialize_workgroup_memory; + self.force_loop_bounding = options.force_loop_bounding; + self.binding_map = options.binding_map.clone(); + Ok(()) + } + /// Returns `(major, minor)` of the SPIR-V language version. pub const fn lang_version(&self) -> (u8, u8) { self.physical_layout.lang_version() diff --git a/naga/src/front/wgsl/mod.rs b/naga/src/front/wgsl/mod.rs index 1080392cc61..ce8e6639a38 100644 --- a/naga/src/front/wgsl/mod.rs +++ b/naga/src/front/wgsl/mod.rs @@ -48,6 +48,9 @@ impl Frontend { options, } } + pub const fn set_options(&mut self, options: Options) { + self.options = options; + } pub fn parse(&mut self, source: &str) -> core::result::Result { self.inner(source).map_err(|x| x.as_parse_error(source)) diff --git a/naga/tests/naga/snapshots.rs b/naga/tests/naga/snapshots.rs index e2288eee918..e61b6b44979 100644 --- a/naga/tests/naga/snapshots.rs +++ b/naga/tests/naga/snapshots.rs @@ -1,389 +1,12 @@ -// A lot of the code can be unused based on configuration flags, -// the corresponding warnings aren't helpful. -#![allow(dead_code, unused_imports)] - -use core::fmt::Write; - -use std::{ - fs, - path::{Path, PathBuf}, -}; - use naga::compact::KeepUnused; -use ron::de; - -const CRATE_ROOT: &str = env!("CARGO_MANIFEST_DIR"); -const BASE_DIR_IN: &str = "tests/in"; -const BASE_DIR_OUT: &str = "tests/out"; - -bitflags::bitflags! { - #[derive(Clone, Copy, serde::Deserialize)] - #[serde(transparent)] - #[derive(Debug, Eq, PartialEq)] - struct Targets: u32 { - /// A serialization of the `naga::Module`, in RON format. - const IR = 1; - - /// A serialization of the `naga::valid::ModuleInfo`, in RON format. - const ANALYSIS = 1 << 1; - - const SPIRV = 1 << 2; - const METAL = 1 << 3; - const GLSL = 1 << 4; - const DOT = 1 << 5; - const HLSL = 1 << 6; - const WGSL = 1 << 7; - const NO_VALIDATION = 1 << 8; - } -} - -impl Targets { - /// Defaults for `spv` and `glsl` snapshots. - fn non_wgsl_default() -> Self { - Targets::WGSL - } - - /// Defaults for `wgsl` snapshots. - fn wgsl_default() -> Self { - Targets::HLSL | Targets::SPIRV | Targets::GLSL | Targets::METAL | Targets::WGSL - } -} - -#[derive(serde::Deserialize)] -struct SpvOutVersion(u8, u8); -impl Default for SpvOutVersion { - fn default() -> Self { - SpvOutVersion(1, 1) - } -} - -#[cfg(all(feature = "deserialize", spv_out))] -#[derive(serde::Deserialize)] -struct BindingMapSerialization { - resource_binding: naga::ResourceBinding, - bind_target: naga::back::spv::BindingInfo, -} - -#[cfg(all(feature = "deserialize", spv_out))] -fn deserialize_binding_map<'de, D>(deserializer: D) -> Result -where - D: serde::Deserializer<'de>, -{ - use serde::Deserialize; - - let vec = Vec::::deserialize(deserializer)?; - let mut map = naga::back::spv::BindingMap::default(); - for item in vec { - map.insert(item.resource_binding, item.bind_target); - } - Ok(map) -} - -#[derive(Default, serde::Deserialize)] -#[serde(default)] -struct WgslInParameters { - parse_doc_comments: bool, -} - -#[derive(Default, serde::Deserialize)] -#[serde(default)] -struct SpirvInParameters { - adjust_coordinate_space: bool, -} - -#[derive(Default, serde::Deserialize)] -#[serde(default)] -struct SpirvOutParameters { - version: SpvOutVersion, - capabilities: naga::FastHashSet, - debug: bool, - adjust_coordinate_space: bool, - force_point_size: bool, - clamp_frag_depth: bool, - separate_entry_points: bool, - #[cfg(all(feature = "deserialize", spv_out))] - #[serde(deserialize_with = "deserialize_binding_map")] - binding_map: naga::back::spv::BindingMap, -} - -#[derive(Default, serde::Deserialize)] -#[serde(default)] -struct WgslOutParameters { - explicit_types: bool, -} - -#[derive(Default, serde::Deserialize)] -struct FragmentModule { - path: String, - entry_point: String, -} - -#[derive(Default, serde::Deserialize)] -#[serde(default)] -struct Parameters { - // -- GOD MODE -- - god_mode: bool, - - // -- wgsl-in options -- - #[serde(rename = "wgsl-in")] - wgsl_in: WgslInParameters, - - // -- spirv-in options -- - #[serde(rename = "spv-in")] - spv_in: SpirvInParameters, - - // -- SPIR-V options -- - spv: SpirvOutParameters, - - /// Defaults to [`Targets::non_wgsl_default()`] for `spv` and `glsl` snapshots, - /// and [`Targets::wgsl_default()`] for `wgsl` snapshots. - targets: Option, - - // -- MSL options -- - #[cfg(all(feature = "deserialize", msl_out))] - msl: naga::back::msl::Options, - #[cfg(all(feature = "deserialize", msl_out))] - #[serde(default)] - msl_pipeline: naga::back::msl::PipelineOptions, - - // -- GLSL options -- - #[cfg(all(feature = "deserialize", glsl_out))] - glsl: naga::back::glsl::Options, - glsl_exclude_list: naga::FastHashSet, - #[cfg(all(feature = "deserialize", glsl_out))] - glsl_multiview: Option, - - // -- HLSL options -- - #[cfg(all(feature = "deserialize", hlsl_out))] - hlsl: naga::back::hlsl::Options, - - // -- WGSL options -- - wgsl: WgslOutParameters, - - // -- General options -- - - // Allow backends to be aware of the fragment module. - // Is the name of a WGSL file in the same directory as the test file. - fragment_module: Option, - - #[cfg(feature = "deserialize")] - bounds_check_policies: naga::proc::BoundsCheckPolicies, - - #[cfg(all(feature = "deserialize", any(hlsl_out, msl_out, spv_out, glsl_out)))] - pipeline_constants: naga::back::PipelineConstants, -} - -/// Information about a shader input file. -#[derive(Debug)] -struct Input { - /// The subdirectory of `tests/in` to which this input belongs, if any. - /// - /// If the subdirectory is omitted, we assume that the output goes - /// to "wgsl". - subdirectory: PathBuf, - - /// The input filename name, without a directory. - file_name: PathBuf, - - /// True if output filenames should add the output extension on top of - /// `file_name`'s existing extension, rather than replacing it. - /// - /// This is used by `convert_snapshots_glsl`, which wants to take input files - /// like `210-bevy-2d-shader.frag` and just add `.wgsl` to it, producing - /// `210-bevy-2d-shader.frag.wgsl`. - keep_input_extension: bool, -} - -impl Input { - /// Read an input file and its corresponding parameters file. - /// - /// Given `input`, the relative path of a shader input file, return - /// a `Source` value containing its path, code, and parameters. - /// - /// The `input` path is interpreted relative to the `BASE_DIR_IN` - /// subdirectory of the directory given by the `CARGO_MANIFEST_DIR` - /// environment variable. - fn new(subdirectory: &str, name: &str, extension: &str) -> Input { - Input { - subdirectory: PathBuf::from(subdirectory), - // Don't wipe out any extensions on `name`, as - // `with_extension` would do. - file_name: PathBuf::from(format!("{name}.{extension}")), - keep_input_extension: false, - } - } - - /// Return an iterator that produces an `Input` for each entry in `subdirectory`. - fn files_in_dir( - subdirectory: &'static str, - file_extensions: &'static [&'static str], - ) -> impl Iterator + 'static { - let input_directory = Path::new(CRATE_ROOT).join(BASE_DIR_IN).join(subdirectory); - - let entries = match std::fs::read_dir(&input_directory) { - Ok(entries) => entries, - Err(err) => panic!( - "Error opening directory '{}': {}", - input_directory.display(), - err - ), - }; +use wgpu_test::naga::*; - entries.filter_map(move |result| { - let entry = result.expect("error reading directory"); - if !entry.file_type().unwrap().is_file() { - return None; - } - - let file_name = PathBuf::from(entry.file_name()); - let extension = file_name - .extension() - .expect("all files in snapshot input directory should have extensions"); - - if !file_extensions.contains(&extension.to_str().unwrap()) { - return None; - } - - if let Ok(pat) = std::env::var("NAGA_SNAPSHOT") { - if !file_name.to_string_lossy().contains(&pat) { - return None; - } - } - - let input = Input::new( - subdirectory, - file_name.file_stem().unwrap().to_str().unwrap(), - extension.to_str().unwrap(), - ); - Some(input) - }) - } - - /// Return the path to the input directory. - fn input_directory(&self) -> PathBuf { - let mut dir = Path::new(CRATE_ROOT).join(BASE_DIR_IN); - dir.push(&self.subdirectory); - dir - } - - /// Return the path to the output directory. - fn output_directory(subdirectory: &str) -> PathBuf { - let mut dir = Path::new(CRATE_ROOT).join(BASE_DIR_OUT); - dir.push(subdirectory); - dir - } - - /// Return the path to the input file. - fn input_path(&self) -> PathBuf { - let mut input = self.input_directory(); - input.push(&self.file_name); - input - } - - fn output_path(&self, subdirectory: &str, extension: &str) -> PathBuf { - let mut output = Self::output_directory(subdirectory); - if self.keep_input_extension { - let file_name = format!( - "{}-{}.{}", - self.subdirectory.display(), - self.file_name.display(), - extension - ); - - output.push(&file_name); - } else { - let file_name = format!( - "{}-{}", - self.subdirectory.display(), - self.file_name.display() - ); - - output.push(&file_name); - output.set_extension(extension); - } - output - } - - /// Return the contents of the input file as a string. - fn read_source(&self) -> String { - println!("Processing '{}'", self.file_name.display()); - let input_path = self.input_path(); - match fs::read_to_string(&input_path) { - Ok(source) => source, - Err(err) => { - panic!( - "Couldn't read shader input file `{}`: {}", - input_path.display(), - err - ); - } - } - } - - /// Return the contents of the input file as a vector of bytes. - fn read_bytes(&self) -> Vec { - println!("Processing '{}'", self.file_name.display()); - let input_path = self.input_path(); - match fs::read(&input_path) { - Ok(bytes) => bytes, - Err(err) => { - panic!( - "Couldn't read shader input file `{}`: {}", - input_path.display(), - err - ); - } - } - } - - /// Return this input's parameter file, parsed. - fn read_parameters(&self) -> Parameters { - let mut param_path = self.input_path(); - param_path.set_extension("toml"); - let mut params = match fs::read_to_string(¶m_path) { - Ok(string) => match toml::de::from_str(&string) { - Ok(params) => params, - Err(e) => panic!( - "Couldn't parse param file: {} due to: {e}", - param_path.display() - ), - }, - Err(_) => Parameters::default(), - }; - - if params.targets.is_none() { - match self.input_path().extension().unwrap().to_str().unwrap() { - "wgsl" => params.targets = Some(Targets::wgsl_default()), - "spvasm" => params.targets = Some(Targets::non_wgsl_default()), - "vert" | "frag" | "comp" => params.targets = Some(Targets::non_wgsl_default()), - e => { - panic!("Unknown extension: {e}"); - } - } - } - - params - } - - /// Write `data` to a file corresponding to this input file in - /// `subdirectory`, with `extension`. - fn write_output_file(&self, subdirectory: &str, extension: &str, data: impl AsRef<[u8]>) { - let output_path = self.output_path(subdirectory, extension); - fs::create_dir_all(output_path.parent().unwrap()).unwrap(); - if let Err(err) = fs::write(&output_path, data) { - panic!("Error writing {}: {}", output_path.display(), err); - } - } -} - -#[cfg(hlsl_out)] -type FragmentEntryPoint<'a> = naga::back::hlsl::FragmentEntryPoint<'a>; -#[cfg(not(hlsl_out))] -type FragmentEntryPoint<'a> = (); +const DIR_IN: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/in"); +const DIR_OUT: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/out"); #[allow(unused_variables)] fn check_targets(input: &Input, module: &mut naga::Module, source_code: Option<&str>) { - let params = input.read_parameters(); + let params = input.read_parameters(DIR_IN); let name = &input.file_name; let targets = params.targets.unwrap(); @@ -402,12 +25,11 @@ fn check_targets(input: &Input, module: &mut naga::Module, source_code: Option<& ) }; - #[cfg(feature = "serialize")] { if targets.contains(Targets::IR) { let config = ron::ser::PrettyConfig::default().new_line("\n".to_string()); let string = ron::ser::to_string_pretty(module, config).unwrap(); - input.write_output_file("ir", "ron", string); + input.write_output_file("ir", "ron", string, DIR_OUT); } } @@ -438,12 +60,11 @@ fn check_targets(input: &Input, module: &mut naga::Module, source_code: Option<& // snapshots makes the output independent of unused arena entries. naga::compact::compact(module, KeepUnused::No); - #[cfg(feature = "serialize")] { if targets.contains(Targets::IR) { let config = ron::ser::PrettyConfig::default().new_line("\n".to_string()); let string = ron::ser::to_string_pretty(module, config).unwrap(); - input.write_output_file("ir", "compact.ron", string); + input.write_output_file("ir", "compact.ron", string, DIR_OUT); } } @@ -460,16 +81,15 @@ fn check_targets(input: &Input, module: &mut naga::Module, source_code: Option<& }) }; - #[cfg(feature = "serialize")] { if targets.contains(Targets::ANALYSIS) { let config = ron::ser::PrettyConfig::default().new_line("\n".to_string()); let string = ron::ser::to_string_pretty(&info, config).unwrap(); - input.write_output_file("analysis", "info.ron", string); + input.write_output_file("analysis", "info.ron", string, DIR_OUT); } } - #[cfg(all(feature = "deserialize", spv_out))] + #[cfg(feature = "spv-out")] { if targets.contains(Targets::SPIRV) { let mut debug_info = None; @@ -495,7 +115,7 @@ fn check_targets(input: &Input, module: &mut naga::Module, source_code: Option<& ); } } - #[cfg(all(feature = "deserialize", msl_out))] + #[cfg(feature = "msl-out")] { if targets.contains(Targets::METAL) { write_output_msl( @@ -509,7 +129,7 @@ fn check_targets(input: &Input, module: &mut naga::Module, source_code: Option<& ); } } - #[cfg(all(feature = "deserialize", glsl_out))] + #[cfg(feature = "glsl-out")] { if targets.contains(Targets::GLSL) { for ep in module.entry_points.iter() { @@ -530,20 +150,20 @@ fn check_targets(input: &Input, module: &mut naga::Module, source_code: Option<& } } } - #[cfg(dot_out)] + #[cfg(feature = "dot-out")] { if targets.contains(Targets::DOT) { let string = naga::back::dot::write(module, Some(&info), Default::default()).unwrap(); - input.write_output_file("dot", "dot", string); + input.write_output_file("dot", "dot", string, DIR_OUT); } } - #[cfg(all(feature = "deserialize", hlsl_out))] + #[cfg(feature = "hlsl-out")] { if targets.contains(Targets::HLSL) { let frag_module; let mut frag_ep = None; if let Some(ref module_spec) = params.fragment_module { - let full_path = input.input_directory().join(&module_spec.path); + let full_path = input.input_directory(DIR_IN).join(&module_spec.path); assert_eq!( full_path.extension().unwrap().to_string_lossy(), @@ -551,7 +171,7 @@ fn check_targets(input: &Input, module: &mut naga::Module, source_code: Option<& "Currently all fragment modules must be in WGSL" ); - let frag_src = fs::read_to_string(full_path).unwrap(); + let frag_src = std::fs::read_to_string(full_path).unwrap(); frag_module = naga::front::wgsl::parse_str(&frag_src) .expect("Failed to parse fragment module"); @@ -575,7 +195,7 @@ fn check_targets(input: &Input, module: &mut naga::Module, source_code: Option<& ); } } - #[cfg(all(feature = "deserialize", wgsl_out))] + #[cfg(feature = "wgsl-out")] { if targets.contains(Targets::WGSL) { write_output_wgsl(input, module, &info, ¶ms.wgsl); @@ -583,7 +203,7 @@ fn check_targets(input: &Input, module: &mut naga::Module, source_code: Option<& } } -#[cfg(spv_out)] +#[cfg(feature = "spv-out")] fn write_output_spv( input: &Input, module: &naga::Module, @@ -594,7 +214,6 @@ fn write_output_spv( pipeline_constants: &naga::back::PipelineConstants, ) { use naga::back::spv; - use rspirv::binary::Disassemble; let mut flags = spv::WriterFlags::LABEL_VARYINGS; flags.set(spv::WriterFlags::DEBUG, params.debug); @@ -644,7 +263,7 @@ fn write_output_spv( } } -#[cfg(spv_out)] +#[cfg(feature = "spv-out")] fn write_output_spv_inner( input: &Input, module: &naga::Module, @@ -667,10 +286,10 @@ fn write_output_spv_inner( } else { dis }; - input.write_output_file("spv", extension, dis); + input.write_output_file("spv", extension, dis, DIR_OUT); } -#[cfg(msl_out)] +#[cfg(feature = "msl-out")] fn write_output_msl( input: &Input, module: &naga::Module, @@ -699,10 +318,10 @@ fn write_output_msl( } } - input.write_output_file("msl", "msl", string); + input.write_output_file("msl", "msl", string, DIR_OUT); } -#[cfg(glsl_out)] +#[cfg(feature = "glsl-out")] #[allow(clippy::too_many_arguments)] fn write_output_glsl( input: &Input, @@ -741,10 +360,10 @@ fn write_output_glsl( writer.write().expect("GLSL write failed"); let extension = format!("{ep_name}.{stage:?}.glsl"); - input.write_output_file("glsl", &extension, buffer); + input.write_output_file("glsl", &extension, buffer, DIR_OUT); } -#[cfg(hlsl_out)] +#[cfg(feature = "hlsl-out")] fn write_output_hlsl( input: &Input, module: &naga::Module, @@ -753,7 +372,6 @@ fn write_output_hlsl( pipeline_constants: &naga::back::PipelineConstants, frag_ep: Option, ) { - use core::fmt::Write as _; use naga::back::hlsl; println!("generating HLSL"); @@ -769,7 +387,7 @@ fn write_output_hlsl( .write(&module, &info, frag_ep.as_ref()) .expect("HLSL write failed"); - input.write_output_file("hlsl", "hlsl", buffer); + input.write_output_file("hlsl", "hlsl", buffer, DIR_OUT); // We need a config file for validation script // This file contains an info about profiles (shader stages) contains inside generated shader @@ -796,10 +414,12 @@ fn write_output_hlsl( }); } - config.to_file(input.output_path("hlsl", "ron")).unwrap(); + config + .to_file(input.output_path("hlsl", "ron", DIR_OUT)) + .unwrap(); } -#[cfg(wgsl_out)] +#[cfg(feature = "wgsl-out")] fn write_output_wgsl( input: &Input, module: &naga::Module, @@ -815,7 +435,7 @@ fn write_output_wgsl( let string = wgsl::write_string(module, info, flags).expect("WGSL write failed"); - input.write_output_file("wgsl", "wgsl", string); + input.write_output_file("wgsl", "wgsl", string, DIR_OUT); } // While we _can_ run this test under miri, it is extremely slow (>5 minutes), @@ -826,12 +446,12 @@ fn write_output_wgsl( fn convert_snapshots_wgsl() { let _ = env_logger::try_init(); - for input in Input::files_in_dir("wgsl", &["wgsl"]) { - let source = input.read_source(); + for input in Input::files_in_dir("wgsl", &["wgsl"], DIR_IN) { + let source = input.read_source(DIR_IN); // crlf will make the large split output different on different platform let source = source.replace('\r', ""); - let params = input.read_parameters(); + let params = input.read_parameters(DIR_IN); let WgslInParameters { parse_doc_comments } = params.wgsl_in; let options = naga::front::wgsl::Options { parse_doc_comments }; @@ -840,7 +460,7 @@ fn convert_snapshots_wgsl() { Ok(mut module) => check_targets(&input, &mut module, Some(&source)), Err(e) => panic!( "{}", - e.emit_to_string_with_path(&source, input.input_path()) + e.emit_to_string_with_path(&source, input.input_path(DIR_IN)) ), } } @@ -855,11 +475,11 @@ fn convert_snapshots_spv() { let _ = env_logger::try_init(); - for input in Input::files_in_dir("spv", &["spvasm"]) { + for input in Input::files_in_dir("spv", &["spvasm"], DIR_IN) { println!("Assembling '{}'", input.file_name.display()); let command = Command::new("spirv-as") - .arg(input.input_path()) + .arg(input.input_path(DIR_IN)) .arg("-o") .arg("-") .output() @@ -878,7 +498,7 @@ fn convert_snapshots_spv() { ); } - let params = input.read_parameters(); + let params = input.read_parameters(DIR_IN); let SpirvInParameters { adjust_coordinate_space, } = params.spv_in; @@ -906,7 +526,7 @@ fn convert_snapshots_spv() { fn convert_snapshots_glsl() { let _ = env_logger::try_init(); - for input in Input::files_in_dir("glsl", &["vert", "frag", "comp"]) { + for input in Input::files_in_dir("glsl", &["vert", "frag", "comp"], DIR_IN) { let input = Input { keep_input_extension: true, ..input @@ -927,7 +547,7 @@ fn convert_snapshots_glsl() { stage, defines: Default::default(), }, - &input.read_source(), + &input.read_source(DIR_IN), ) .unwrap(); diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 95301df9488..ec87864bf06 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -33,11 +33,29 @@ webgl = ["wgpu/webgl"] # allows us to force the build to have profiling code enabled so we can test that configuration. test-build-with-profiling = ["profiling/type-check"] +# Naga forwarded features +glsl-in = ["naga/glsl-in"] +glsl-out = ["naga/glsl-out"] +spv-in = ["naga/spv-in"] +spv-out = ["naga/spv-out"] +wgsl-in = ["naga/wgsl-in"] +wgsl-out = ["naga/wgsl-out"] +msl-out = ["naga/msl-out"] +dot-out = ["naga/dot-out"] +hlsl-out = ["naga/hlsl-out"] + [dependencies] wgpu = { workspace = true, features = ["noop"] } wgpu-hal = { workspace = true, features = ["validation_canary"] } wgpu-macros.workspace = true +# Naga stuff that lives here due to sharing logic with benchmarks +naga = { workspace = true, features = [] } +spirv = { workspace = true, features = ["deserialize"] } +rspirv.workspace = true +ron.workspace = true +toml.workspace = true + anyhow.workspace = true arrayvec.workspace = true approx.workspace = true diff --git a/tests/src/lib.rs b/tests/src/lib.rs index 22afd7ecf77..775a3fdfc2b 100644 --- a/tests/src/lib.rs +++ b/tests/src/lib.rs @@ -7,6 +7,7 @@ mod expectations; pub mod image; mod init; mod isolation; +pub mod naga; pub mod native; mod params; mod poll; diff --git a/tests/src/naga.rs b/tests/src/naga.rs new file mode 100644 index 00000000000..b4445eb5430 --- /dev/null +++ b/tests/src/naga.rs @@ -0,0 +1,450 @@ +// A lot of the code can be unused based on configuration flags, +// the corresponding warnings aren't helpful. +#![allow(dead_code, unused_imports)] + +use core::fmt::Write; + +use std::{ + fs, + path::{Path, PathBuf}, +}; + +use naga::compact::KeepUnused; +use ron::de; + +bitflags::bitflags! { + #[derive(Clone, Copy, serde::Deserialize)] + #[serde(transparent)] + #[derive(Debug, Eq, PartialEq)] + pub struct Targets: u32 { + /// A serialization of the `naga::Module`, in RON format. + const IR = 1; + + /// A serialization of the `naga::valid::ModuleInfo`, in RON format. + const ANALYSIS = 1 << 1; + + const SPIRV = 1 << 2; + const METAL = 1 << 3; + const GLSL = 1 << 4; + const DOT = 1 << 5; + const HLSL = 1 << 6; + const WGSL = 1 << 7; + const NO_VALIDATION = 1 << 8; + } +} + +impl Targets { + /// Defaults for `spv` and `glsl` snapshots. + pub fn non_wgsl_default() -> Self { + Targets::WGSL + } + + /// Defaults for `wgsl` snapshots. + pub fn wgsl_default() -> Self { + Targets::HLSL | Targets::SPIRV | Targets::GLSL | Targets::METAL | Targets::WGSL + } +} + +#[derive(serde::Deserialize)] +pub struct SpvOutVersion(pub u8, pub u8); +impl Default for SpvOutVersion { + fn default() -> Self { + SpvOutVersion(1, 1) + } +} + +#[cfg(feature = "spv-out")] +#[derive(serde::Deserialize)] +pub struct BindingMapSerialization { + pub resource_binding: naga::ResourceBinding, + pub bind_target: naga::back::spv::BindingInfo, +} + +#[cfg(feature = "spv-out")] +pub fn deserialize_binding_map<'de, D>( + deserializer: D, +) -> Result +where + D: serde::Deserializer<'de>, +{ + use serde::Deserialize; + + let vec = Vec::::deserialize(deserializer)?; + let mut map = naga::back::spv::BindingMap::default(); + for item in vec { + map.insert(item.resource_binding, item.bind_target); + } + Ok(map) +} + +#[derive(Default, serde::Deserialize)] +#[serde(default)] +pub struct WgslInParameters { + pub parse_doc_comments: bool, +} +#[cfg(feature = "wgsl-in")] +impl From<&WgslInParameters> for naga::front::wgsl::Options { + fn from(value: &WgslInParameters) -> Self { + Self { + parse_doc_comments: value.parse_doc_comments, + } + } +} + +#[derive(Default, serde::Deserialize)] +#[serde(default)] +pub struct SpirvInParameters { + pub adjust_coordinate_space: bool, +} +#[cfg(feature = "spv-in")] +impl From<&SpirvInParameters> for naga::front::spv::Options { + fn from(value: &SpirvInParameters) -> Self { + Self { + adjust_coordinate_space: value.adjust_coordinate_space, + ..Default::default() + } + } +} + +#[derive(Default, serde::Deserialize)] +#[serde(default)] +pub struct SpirvOutParameters { + pub version: SpvOutVersion, + pub capabilities: naga::FastHashSet, + pub debug: bool, + pub adjust_coordinate_space: bool, + pub force_point_size: bool, + pub clamp_frag_depth: bool, + pub separate_entry_points: bool, + #[cfg(feature = "spv-out")] + #[serde(deserialize_with = "deserialize_binding_map")] + pub binding_map: naga::back::spv::BindingMap, +} +#[cfg(feature = "spv-out")] +impl SpirvOutParameters { + pub fn to_options<'a>( + &'a self, + bounds_check_policies: naga::proc::BoundsCheckPolicies, + debug_info: Option>, + ) -> naga::back::spv::Options<'a> { + use naga::back::spv; + let mut flags = spv::WriterFlags::LABEL_VARYINGS; + flags.set(spv::WriterFlags::DEBUG, self.debug); + flags.set( + spv::WriterFlags::ADJUST_COORDINATE_SPACE, + self.adjust_coordinate_space, + ); + flags.set(spv::WriterFlags::FORCE_POINT_SIZE, self.force_point_size); + flags.set(spv::WriterFlags::CLAMP_FRAG_DEPTH, self.clamp_frag_depth); + naga::back::spv::Options { + lang_version: (self.version.0, self.version.1), + flags, + capabilities: if self.capabilities.is_empty() { + None + } else { + Some(self.capabilities.clone()) + }, + bounds_check_policies, + binding_map: self.binding_map.clone(), + zero_initialize_workgroup_memory: spv::ZeroInitializeWorkgroupMemoryMode::Polyfill, + force_loop_bounding: true, + debug_info, + } + } +} + +#[derive(Default, serde::Deserialize)] +#[serde(default)] +pub struct WgslOutParameters { + pub explicit_types: bool, +} +#[cfg(feature = "wgsl-out")] +impl From<&WgslOutParameters> for naga::back::wgsl::WriterFlags { + fn from(value: &WgslOutParameters) -> Self { + let mut flags = Self::empty(); + flags.set(Self::EXPLICIT_TYPES, value.explicit_types); + flags + } +} + +#[derive(Default, serde::Deserialize)] +pub struct FragmentModule { + pub path: String, + pub entry_point: String, +} + +#[derive(Default, serde::Deserialize)] +#[serde(default)] +pub struct Parameters { + // -- GOD MODE -- + pub god_mode: bool, + + // -- wgsl-in options -- + #[serde(rename = "wgsl-in")] + pub wgsl_in: WgslInParameters, + + // -- spirv-in options -- + #[serde(rename = "spv-in")] + pub spv_in: SpirvInParameters, + + // -- SPIR-V options -- + pub spv: SpirvOutParameters, + + /// Defaults to [`Targets::non_wgsl_default()`] for `spv` and `glsl` snapshots, + /// and [`Targets::wgsl_default()`] for `wgsl` snapshots. + pub targets: Option, + + // -- MSL options -- + #[cfg(feature = "msl-out")] + pub msl: naga::back::msl::Options, + #[cfg(feature = "msl-out")] + #[serde(default)] + pub msl_pipeline: naga::back::msl::PipelineOptions, + + // -- GLSL options -- + #[cfg(feature = "glsl-out")] + pub glsl: naga::back::glsl::Options, + pub glsl_exclude_list: naga::FastHashSet, + #[cfg(feature = "glsl-out")] + pub glsl_multiview: Option, + + // -- HLSL options -- + #[cfg(feature = "hlsl-out")] + pub hlsl: naga::back::hlsl::Options, + + // -- WGSL options -- + pub wgsl: WgslOutParameters, + + // -- General options -- + + // Allow backends to be aware of the fragment module. + // Is the name of a WGSL file in the same directory as the test file. + pub fragment_module: Option, + + pub bounds_check_policies: naga::proc::BoundsCheckPolicies, + + #[cfg(any( + feature = "hlsl-out", + feature = "msl-out", + feature = "spv-out", + feature = "glsl-out" + ))] + pub pipeline_constants: naga::back::PipelineConstants, +} + +/// Information about a shader input file. +#[derive(Debug)] +pub struct Input { + /// The subdirectory of `tests/in` to which this input belongs, if any. + /// + /// If the subdirectory is omitted, we assume that the output goes + /// to "wgsl". + pub subdirectory: PathBuf, + + /// The input filename name, without a directory. + pub file_name: PathBuf, + + /// True if output filenames should add the output extension on top of + /// `file_name`'s existing extension, rather than replacing it. + /// + /// This is used by `convert_snapshots_glsl`, which wants to take input files + /// like `210-bevy-2d-shader.frag` and just add `.wgsl` to it, producing + /// `210-bevy-2d-shader.frag.wgsl`. + pub keep_input_extension: bool, +} + +impl Input { + /// Read an input file and its corresponding parameters file. + /// + /// Given `input`, the relative path of a shader input file, return + /// a `Source` value containing its path, code, and parameters. + /// + /// The `input` path is interpreted relative to the `BASE_DIR_IN` + /// subdirectory of the directory given by the `CARGO_MANIFEST_DIR` + /// environment variable. + pub fn new(subdirectory: &str, name: &str, extension: &str) -> Input { + Input { + subdirectory: PathBuf::from(subdirectory), + // Don't wipe out any extensions on `name`, as + // `with_extension` would do. + file_name: PathBuf::from(format!("{name}.{extension}")), + keep_input_extension: false, + } + } + + /// Return an iterator that produces an `Input` for each entry in `subdirectory`. + pub fn files_in_dir( + subdirectory: &'static str, + file_extensions: &'static [&'static str], + dir_in: &str, + ) -> impl Iterator + 'static { + let input_directory = Path::new(dir_in).join(subdirectory); + + let entries = match std::fs::read_dir(&input_directory) { + Ok(entries) => entries, + Err(err) => panic!( + "Error opening directory '{}': {}", + input_directory.display(), + err + ), + }; + + entries.filter_map(move |result| { + let entry = result.expect("error reading directory"); + if !entry.file_type().unwrap().is_file() { + return None; + } + + let file_name = PathBuf::from(entry.file_name()); + let extension = file_name + .extension() + .expect("all files in snapshot input directory should have extensions"); + + if !file_extensions.contains(&extension.to_str().unwrap()) { + return None; + } + + if let Ok(pat) = std::env::var("NAGA_SNAPSHOT") { + if !file_name.to_string_lossy().contains(&pat) { + return None; + } + } + + let input = Input::new( + subdirectory, + file_name.file_stem().unwrap().to_str().unwrap(), + extension.to_str().unwrap(), + ); + Some(input) + }) + } + + /// Return the path to the input directory. + pub fn input_directory(&self, dir_in: &str) -> PathBuf { + Path::new(dir_in).join(&self.subdirectory) + } + + /// Return the path to the output directory. + pub fn output_directory(subdirectory: &str, dir_out: &str) -> PathBuf { + Path::new(dir_out).join(subdirectory) + } + + /// Return the path to the input file. + pub fn input_path(&self, dir_in: &str) -> PathBuf { + let mut input = self.input_directory(dir_in); + input.push(&self.file_name); + input + } + + pub fn output_path(&self, subdirectory: &str, extension: &str, dir_out: &str) -> PathBuf { + let mut output = Self::output_directory(subdirectory, dir_out); + if self.keep_input_extension { + let file_name = format!( + "{}-{}.{}", + self.subdirectory.display(), + self.file_name.display(), + extension + ); + + output.push(&file_name); + } else { + let file_name = format!( + "{}-{}", + self.subdirectory.display(), + self.file_name.display() + ); + + output.push(&file_name); + output.set_extension(extension); + } + output + } + + /// Return the contents of the input file as a string. + pub fn read_source(&self, dir_in: &str) -> String { + println!("Processing '{}'", self.file_name.display()); + let input_path = self.input_path(dir_in); + match fs::read_to_string(&input_path) { + Ok(source) => source, + Err(err) => { + panic!( + "Couldn't read shader input file `{}`: {}", + input_path.display(), + err + ); + } + } + } + + /// Return the contents of the input file as a vector of bytes. + pub fn read_bytes(&self, dir_in: &str) -> Vec { + println!("Processing '{}'", self.file_name.display()); + let input_path = self.input_path(dir_in); + match fs::read(&input_path) { + Ok(bytes) => bytes, + Err(err) => { + panic!( + "Couldn't read shader input file `{}`: {}", + input_path.display(), + err + ); + } + } + } + + pub fn bytes(&self, dir_in: &str) -> u64 { + let input_path = self.input_path(dir_in); + std::fs::metadata(input_path).unwrap().len() + } + + /// Return this input's parameter file, parsed. + pub fn read_parameters(&self, dir_in: &str) -> Parameters { + let mut param_path = self.input_path(dir_in); + param_path.set_extension("toml"); + let mut params = match fs::read_to_string(¶m_path) { + Ok(string) => match toml::de::from_str(&string) { + Ok(params) => params, + Err(e) => panic!( + "Couldn't parse param file: {} due to: {e}", + param_path.display() + ), + }, + Err(_) => Parameters::default(), + }; + + if params.targets.is_none() { + match self + .input_path(dir_in) + .extension() + .unwrap() + .to_str() + .unwrap() + { + "wgsl" => params.targets = Some(Targets::wgsl_default()), + "spvasm" => params.targets = Some(Targets::non_wgsl_default()), + "vert" | "frag" | "comp" => params.targets = Some(Targets::non_wgsl_default()), + e => { + panic!("Unknown extension: {e}"); + } + } + } + + params + } + + /// Write `data` to a file corresponding to this input file in + /// `subdirectory`, with `extension`. + pub fn write_output_file( + &self, + subdirectory: &str, + extension: &str, + data: impl AsRef<[u8]>, + dir_out: &str, + ) { + let output_path = self.output_path(subdirectory, extension, dir_out); + fs::create_dir_all(output_path.parent().unwrap()).unwrap(); + if let Err(err) = fs::write(&output_path, data) { + panic!("Error writing {}: {}", output_path.display(), err); + } + } +} From 9947762e162fa1c154415d63a39aa318c174b7c4 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Thu, 14 Aug 2025 16:48:37 -0500 Subject: [PATCH 77/84] A few more changes --- benches/benches/wgpu-benchmark/shader.rs | 14 +++---- naga/tests/naga/snapshots.rs | 49 +++--------------------- 2 files changed, 13 insertions(+), 50 deletions(-) diff --git a/benches/benches/wgpu-benchmark/shader.rs b/benches/benches/wgpu-benchmark/shader.rs index a8a6c54f56c..403c28abfc0 100644 --- a/benches/benches/wgpu-benchmark/shader.rs +++ b/benches/benches/wgpu-benchmark/shader.rs @@ -83,9 +83,7 @@ impl Inputs { continue; } - let WgslInParameters { parse_doc_comments } = input.options.wgsl_in; - let options = naga::front::wgsl::Options { parse_doc_comments }; - parser.set_options(options); + parser.set_options((&input.options.wgsl_in).into()); input.module = Some(parser.parse(input.string.as_ref().unwrap()).unwrap()); } @@ -180,9 +178,7 @@ fn frontends(c: &mut Criterion) { let mut frontend = naga::front::wgsl::Frontend::new(); b.iter(|| { for input in &inputs_wgsl.inner { - let WgslInParameters { parse_doc_comments } = input.options.wgsl_in; - let options = naga::front::wgsl::Options { parse_doc_comments }; - frontend.set_options(options); + frontend.set_options((&input.options.wgsl_in).into()); frontend.parse(input.string.as_ref().unwrap()).unwrap(); } }); @@ -351,7 +347,11 @@ fn backends(c: &mut Criterion) { // These fail due to https://github.com/gfx-rs/wgpu/issues/7315 continue; } - let opt = input.options.spv.to_options(bounds_check_policies, debug_info) + let opt = input + .options + .spv + .to_options(input.options.bounds_check_policies, None); + writer.set_options(&opt); let _ = writer.write( input.module.as_ref().unwrap(), input.module_info.as_ref().unwrap(), diff --git a/naga/tests/naga/snapshots.rs b/naga/tests/naga/snapshots.rs index e61b6b44979..c4b081a2764 100644 --- a/naga/tests/naga/snapshots.rs +++ b/naga/tests/naga/snapshots.rs @@ -215,29 +215,7 @@ fn write_output_spv( ) { use naga::back::spv; - let mut flags = spv::WriterFlags::LABEL_VARYINGS; - flags.set(spv::WriterFlags::DEBUG, params.debug); - flags.set( - spv::WriterFlags::ADJUST_COORDINATE_SPACE, - params.adjust_coordinate_space, - ); - flags.set(spv::WriterFlags::FORCE_POINT_SIZE, params.force_point_size); - flags.set(spv::WriterFlags::CLAMP_FRAG_DEPTH, params.clamp_frag_depth); - - let options = spv::Options { - lang_version: (params.version.0, params.version.1), - flags, - capabilities: if params.capabilities.is_empty() { - None - } else { - Some(params.capabilities.clone()) - }, - bounds_check_policies, - binding_map: params.binding_map.clone(), - zero_initialize_workgroup_memory: spv::ZeroInitializeWorkgroupMemoryMode::Polyfill, - force_loop_bounding: true, - debug_info, - }; + let options = params.to_options(bounds_check_policies, debug_info); let (module, info) = naga::back::pipeline_constants::process_overrides(module, info, None, pipeline_constants) @@ -430,10 +408,7 @@ fn write_output_wgsl( println!("generating WGSL"); - let mut flags = wgsl::WriterFlags::empty(); - flags.set(wgsl::WriterFlags::EXPLICIT_TYPES, params.explicit_types); - - let string = wgsl::write_string(module, info, flags).expect("WGSL write failed"); + let string = wgsl::write_string(module, info, params.into()).expect("WGSL write failed"); input.write_output_file("wgsl", "wgsl", string, DIR_OUT); } @@ -452,10 +427,8 @@ fn convert_snapshots_wgsl() { let source = source.replace('\r', ""); let params = input.read_parameters(DIR_IN); - let WgslInParameters { parse_doc_comments } = params.wgsl_in; - let options = naga::front::wgsl::Options { parse_doc_comments }; - let mut frontend = naga::front::wgsl::Frontend::new_with_options(options); + let mut frontend = naga::front::wgsl::Frontend::new_with_options((¶ms.wgsl_in).into()); match frontend.parse(&source) { Ok(mut module) => check_targets(&input, &mut module, Some(&source)), Err(e) => panic!( @@ -499,19 +472,9 @@ fn convert_snapshots_spv() { } let params = input.read_parameters(DIR_IN); - let SpirvInParameters { - adjust_coordinate_space, - } = params.spv_in; - - let mut module = naga::front::spv::parse_u8_slice( - &command.stdout, - &naga::front::spv::Options { - adjust_coordinate_space, - strict_capabilities: true, - ..Default::default() - }, - ) - .unwrap(); + + let mut module = + naga::front::spv::parse_u8_slice(&command.stdout, &(¶ms.spv_in).into()).unwrap(); check_targets(&input, &mut module, None); } From e648f946d2072cfb66b7b3e46ad18ff389960588 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Thu, 14 Aug 2025 16:53:24 -0500 Subject: [PATCH 78/84] Tried to fix a stupid accidentally pushed issue --- benches/benches/wgpu-benchmark/shader.rs | 20 ++++++++++---------- tests/src/naga.rs | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/benches/benches/wgpu-benchmark/shader.rs b/benches/benches/wgpu-benchmark/shader.rs index 403c28abfc0..365ff97465b 100644 --- a/benches/benches/wgpu-benchmark/shader.rs +++ b/benches/benches/wgpu-benchmark/shader.rs @@ -2,7 +2,6 @@ use criterion::*; use std::{fs, process::Command}; const DIR_IN: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../naga/tests/in"); -const DIR_OUT: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../naga/tests/in"); use wgpu_test::naga::*; @@ -351,15 +350,16 @@ fn backends(c: &mut Criterion) { .options .spv .to_options(input.options.bounds_check_policies, None); - writer.set_options(&opt); - let _ = writer.write( - input.module.as_ref().unwrap(), - input.module_info.as_ref().unwrap(), - None, - &None, - &mut data, - ); - data.clear(); + if writer.set_options(&opt).is_ok() { + let _ = writer.write( + input.module.as_ref().unwrap(), + input.module_info.as_ref().unwrap(), + None, + &None, + &mut data, + ); + data.clear(); + } } }); }); diff --git a/tests/src/naga.rs b/tests/src/naga.rs index b4445eb5430..f78ccac8d7b 100644 --- a/tests/src/naga.rs +++ b/tests/src/naga.rs @@ -273,11 +273,11 @@ impl Input { } /// Return an iterator that produces an `Input` for each entry in `subdirectory`. - pub fn files_in_dir( - subdirectory: &'static str, - file_extensions: &'static [&'static str], + pub fn files_in_dir<'a>( + subdirectory: &'a str, + file_extensions: &'a [&'a str], dir_in: &str, - ) -> impl Iterator + 'static { + ) -> impl Iterator + 'a { let input_directory = Path::new(dir_in).join(subdirectory); let entries = match std::fs::read_dir(&input_directory) { From d6b937521541c7d4ac976cc1f00329f7fdcc52a4 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Thu, 14 Aug 2025 17:00:12 -0500 Subject: [PATCH 79/84] Brief little fix for bad paths --- benches/benches/wgpu-benchmark/shader.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/benches/benches/wgpu-benchmark/shader.rs b/benches/benches/wgpu-benchmark/shader.rs index 365ff97465b..79674971cde 100644 --- a/benches/benches/wgpu-benchmark/shader.rs +++ b/benches/benches/wgpu-benchmark/shader.rs @@ -183,14 +183,14 @@ fn frontends(c: &mut Criterion) { }); }); - let inputs_spirv = Inputs::from_dir("../naga/tests/in/spv", "spvasm"); + let inputs_spirv = Inputs::from_dir("spv", "spvasm"); assert!(!inputs_spirv.is_empty()); // Assemble all the SPIR-V assembly. let mut assembled_spirv = Vec::>::new(); 'spirv: for input in &inputs_spirv.inner { let output = match Command::new("spirv-as") - .arg(input.filename()) + .arg(input.inner.input_path(DIR_IN)) .arg("-o") .arg("-") .output() @@ -244,8 +244,8 @@ fn frontends(c: &mut Criterion) { }); }); - let mut inputs_vertex = Inputs::from_dir("../naga/tests/in/glsl", "vert"); - let mut inputs_fragment = Inputs::from_dir("../naga/tests/in/glsl", "frag"); + let mut inputs_vertex = Inputs::from_dir("glsl", "vert"); + let mut inputs_fragment = Inputs::from_dir("glsl", "frag"); assert!(!inputs_vertex.is_empty()); assert!(!inputs_fragment.is_empty()); // let mut inputs_compute = Inputs::from_dir("../naga/tests/in/glsl", "comp"); From 9ac167f74a67b01a02af658feeaf3ba707658f45 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Thu, 14 Aug 2025 17:14:22 -0500 Subject: [PATCH 80/84] Removed `const` thing from a functoin that cant be const on older compilers --- naga/src/front/wgsl/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/naga/src/front/wgsl/mod.rs b/naga/src/front/wgsl/mod.rs index ce8e6639a38..dfacc7d975a 100644 --- a/naga/src/front/wgsl/mod.rs +++ b/naga/src/front/wgsl/mod.rs @@ -48,7 +48,7 @@ impl Frontend { options, } } - pub const fn set_options(&mut self, options: Options) { + pub fn set_options(&mut self, options: Options) { self.options = options; } From 587e5e65557f481cb9f587e126ce0517c44de06d Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Thu, 14 Aug 2025 18:01:28 -0500 Subject: [PATCH 81/84] Broken shaders now break :party: --- benches/benches/wgpu-benchmark/shader.rs | 7 ++++--- naga/tests/naga/snapshots.rs | 4 ++-- tests/src/naga.rs | 12 ++++++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/benches/benches/wgpu-benchmark/shader.rs b/benches/benches/wgpu-benchmark/shader.rs index 79674971cde..93e567eb11e 100644 --- a/benches/benches/wgpu-benchmark/shader.rs +++ b/benches/benches/wgpu-benchmark/shader.rs @@ -57,7 +57,7 @@ impl Inputs { continue; } - input.data = fs::read(&input.inner.file_name).unwrap_or_default(); + input.data = fs::read(input.inner.input_path(DIR_IN)).unwrap_or_default(); } } @@ -121,7 +121,7 @@ fn parse_glsl(stage: naga::ShaderStage, inputs: &Inputs) { }; for input in &inputs.inner { parser - .parse(&options, &input.inner.read_source(DIR_IN)) + .parse(&options, &input.inner.read_source(DIR_IN, false)) .unwrap(); } } @@ -418,11 +418,12 @@ fn backends(c: &mut Criterion) { let pipeline_options = Default::default(); let mut writer = naga::back::hlsl::Writer::new(&mut string, &options, &pipeline_options); - let _ = writer.write( + let err = writer.write( input.module.as_ref().unwrap(), input.module_info.as_ref().unwrap(), None, ); // may fail on unimplemented things + err.unwrap(); string.clear(); } }); diff --git a/naga/tests/naga/snapshots.rs b/naga/tests/naga/snapshots.rs index c4b081a2764..f08dbcb59dd 100644 --- a/naga/tests/naga/snapshots.rs +++ b/naga/tests/naga/snapshots.rs @@ -422,7 +422,7 @@ fn convert_snapshots_wgsl() { let _ = env_logger::try_init(); for input in Input::files_in_dir("wgsl", &["wgsl"], DIR_IN) { - let source = input.read_source(DIR_IN); + let source = input.read_source(DIR_IN, true); // crlf will make the large split output different on different platform let source = source.replace('\r', ""); @@ -510,7 +510,7 @@ fn convert_snapshots_glsl() { stage, defines: Default::default(), }, - &input.read_source(DIR_IN), + &input.read_source(DIR_IN, true), ) .unwrap(); diff --git a/tests/src/naga.rs b/tests/src/naga.rs index f78ccac8d7b..075b26e46c0 100644 --- a/tests/src/naga.rs +++ b/tests/src/naga.rs @@ -361,8 +361,10 @@ impl Input { } /// Return the contents of the input file as a string. - pub fn read_source(&self, dir_in: &str) -> String { - println!("Processing '{}'", self.file_name.display()); + pub fn read_source(&self, dir_in: &str, print: bool) -> String { + if print { + println!("Processing '{}'", self.file_name.display()); + } let input_path = self.input_path(dir_in); match fs::read_to_string(&input_path) { Ok(source) => source, @@ -377,8 +379,10 @@ impl Input { } /// Return the contents of the input file as a vector of bytes. - pub fn read_bytes(&self, dir_in: &str) -> Vec { - println!("Processing '{}'", self.file_name.display()); + pub fn read_bytes(&self, dir_in: &str, print: bool) -> Vec { + if print { + println!("Processing '{}'", self.file_name.display()); + } let input_path = self.input_path(dir_in); match fs::read(&input_path) { Ok(bytes) => bytes, From 7ad0f50eea091d3e0b62888d1d9831df0f6a7ad4 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Thu, 14 Aug 2025 18:10:14 -0500 Subject: [PATCH 82/84] re-unbroke broken shaders --- benches/benches/wgpu-benchmark/shader.rs | 181 ++++++++++++----------- 1 file changed, 97 insertions(+), 84 deletions(-) diff --git a/benches/benches/wgpu-benchmark/shader.rs b/benches/benches/wgpu-benchmark/shader.rs index 93e567eb11e..3ccc5b01ced 100644 --- a/benches/benches/wgpu-benchmark/shader.rs +++ b/benches/benches/wgpu-benchmark/shader.rs @@ -15,8 +15,10 @@ struct InputWithInfo { } impl From for InputWithInfo { fn from(value: Input) -> Self { + let mut options = value.read_parameters(DIR_IN); + options.targets = Some(options.targets.unwrap_or(Targets::all())); Self { - options: value.read_parameters(DIR_IN), + options, inner: value, data: Vec::new(), string: None, @@ -326,13 +328,15 @@ fn backends(c: &mut Criterion) { b.iter(|| { let mut string = String::new(); for input in &inputs.inner { - let mut writer = - naga::back::wgsl::Writer::new(&mut string, (&input.options.wgsl).into()); - let _ = writer.write( - input.module.as_ref().unwrap(), - input.module_info.as_ref().unwrap(), - ); - string.clear(); + if input.options.targets.unwrap().contains(Targets::WGSL) { + let mut writer = + naga::back::wgsl::Writer::new(&mut string, (&input.options.wgsl).into()); + let _ = writer.write( + input.module.as_ref().unwrap(), + input.module_info.as_ref().unwrap(), + ); + string.clear(); + } } }); }); @@ -342,23 +346,25 @@ fn backends(c: &mut Criterion) { let mut data = Vec::new(); let mut writer = naga::back::spv::Writer::new(&Default::default()).unwrap(); for input in &inputs.inner { - if input.filename().contains("pointer-function-arg") { - // These fail due to https://github.com/gfx-rs/wgpu/issues/7315 - continue; - } - let opt = input - .options - .spv - .to_options(input.options.bounds_check_policies, None); - if writer.set_options(&opt).is_ok() { - let _ = writer.write( - input.module.as_ref().unwrap(), - input.module_info.as_ref().unwrap(), - None, - &None, - &mut data, - ); - data.clear(); + if input.options.targets.unwrap().contains(Targets::SPIRV) { + if input.filename().contains("pointer-function-arg") { + // These fail due to https://github.com/gfx-rs/wgpu/issues/7315 + continue; + } + let opt = input + .options + .spv + .to_options(input.options.bounds_check_policies, None); + if writer.set_options(&opt).is_ok() { + let _ = writer.write( + input.module.as_ref().unwrap(), + input.module_info.as_ref().unwrap(), + None, + &None, + &mut data, + ); + data.clear(); + } } } }); @@ -368,25 +374,27 @@ fn backends(c: &mut Criterion) { let mut data = Vec::new(); let options = naga::back::spv::Options::default(); for input in &inputs.inner { - if input.filename().contains("pointer-function-arg") { - // These fail due to https://github.com/gfx-rs/wgpu/issues/7315 - continue; - } - let mut writer = naga::back::spv::Writer::new(&options).unwrap(); - let module = input.module.as_ref().unwrap(); - for ep in module.entry_points.iter() { - let pipeline_options = naga::back::spv::PipelineOptions { - shader_stage: ep.stage, - entry_point: ep.name.clone(), - }; - let _ = writer.write( - input.module.as_ref().unwrap(), - input.module_info.as_ref().unwrap(), - Some(&pipeline_options), - &None, - &mut data, - ); - data.clear(); + if input.options.targets.unwrap().contains(Targets::SPIRV) { + if input.filename().contains("pointer-function-arg") { + // These fail due to https://github.com/gfx-rs/wgpu/issues/7315 + continue; + } + let mut writer = naga::back::spv::Writer::new(&options).unwrap(); + let module = input.module.as_ref().unwrap(); + for ep in module.entry_points.iter() { + let pipeline_options = naga::back::spv::PipelineOptions { + shader_stage: ep.stage, + entry_point: ep.name.clone(), + }; + let _ = writer.write( + input.module.as_ref().unwrap(), + input.module_info.as_ref().unwrap(), + Some(&pipeline_options), + &None, + &mut data, + ); + data.clear(); + } } } }); @@ -397,15 +405,17 @@ fn backends(c: &mut Criterion) { let mut string = String::new(); let options = naga::back::msl::Options::default(); for input in &inputs.inner { - let pipeline_options = naga::back::msl::PipelineOptions::default(); - let mut writer = naga::back::msl::Writer::new(&mut string); - let _ = writer.write( - input.module.as_ref().unwrap(), - input.module_info.as_ref().unwrap(), - &options, - &pipeline_options, - ); - string.clear(); + if input.options.targets.unwrap().contains(Targets::METAL) { + let pipeline_options = naga::back::msl::PipelineOptions::default(); + let mut writer = naga::back::msl::Writer::new(&mut string); + let _ = writer.write( + input.module.as_ref().unwrap(), + input.module_info.as_ref().unwrap(), + &options, + &pipeline_options, + ); + string.clear(); + } } }); }); @@ -415,16 +425,17 @@ fn backends(c: &mut Criterion) { let options = naga::back::hlsl::Options::default(); let mut string = String::new(); for input in &inputs.inner { - let pipeline_options = Default::default(); - let mut writer = - naga::back::hlsl::Writer::new(&mut string, &options, &pipeline_options); - let err = writer.write( - input.module.as_ref().unwrap(), - input.module_info.as_ref().unwrap(), - None, - ); // may fail on unimplemented things - err.unwrap(); - string.clear(); + if input.options.targets.unwrap().contains(Targets::HLSL) { + let pipeline_options = Default::default(); + let mut writer = + naga::back::hlsl::Writer::new(&mut string, &options, &pipeline_options); + let _ = writer.write( + input.module.as_ref().unwrap(), + input.module_info.as_ref().unwrap(), + None, + ); // may fail on unimplemented things + string.clear(); + } } }); }); @@ -439,28 +450,30 @@ fn backends(c: &mut Criterion) { zero_initialize_workgroup_memory: true, }; for input in &inputs.inner { - let module = input.module.as_ref().unwrap(); - let info = input.module_info.as_ref().unwrap(); - for ep in module.entry_points.iter() { - let pipeline_options = naga::back::glsl::PipelineOptions { - shader_stage: ep.stage, - entry_point: ep.name.clone(), - multiview: None, - }; - - // might be `Err` if missing features - if let Ok(mut writer) = naga::back::glsl::Writer::new( - &mut string, - module, - info, - &options, - &pipeline_options, - naga::proc::BoundsCheckPolicies::default(), - ) { - let _ = writer.write(); // might be `Err` if unsupported + if input.options.targets.unwrap().contains(Targets::GLSL) { + let module = input.module.as_ref().unwrap(); + let info = input.module_info.as_ref().unwrap(); + for ep in module.entry_points.iter() { + let pipeline_options = naga::back::glsl::PipelineOptions { + shader_stage: ep.stage, + entry_point: ep.name.clone(), + multiview: None, + }; + + // might be `Err` if missing features + if let Ok(mut writer) = naga::back::glsl::Writer::new( + &mut string, + module, + info, + &options, + &pipeline_options, + naga::proc::BoundsCheckPolicies::default(), + ) { + let _ = writer.write(); // might be `Err` if unsupported + } + + string.clear(); } - - string.clear(); } } }); From d186f5a06be036f859a348279aa40fd8f1f8f87d Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Fri, 15 Aug 2025 12:46:07 -0500 Subject: [PATCH 83/84] Fixed compile fail failing --- tests/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Cargo.toml b/tests/Cargo.toml index ec87864bf06..581af3e879c 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -50,7 +50,7 @@ wgpu-hal = { workspace = true, features = ["validation_canary"] } wgpu-macros.workspace = true # Naga stuff that lives here due to sharing logic with benchmarks -naga = { workspace = true, features = [] } +naga = { workspace = true, features = ["serialize", "deserialize"] } spirv = { workspace = true, features = ["deserialize"] } rspirv.workspace = true ron.workspace = true From b96d7f241320dd8a5387da84bd7be636a7b13dd1 Mon Sep 17 00:00:00 2001 From: SupaMaggie70Incorporated Date: Fri, 15 Aug 2025 13:07:43 -0500 Subject: [PATCH 84/84] Tried to fix CI failing on --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e3422e62bd..bf8f00b4cfd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -262,9 +262,9 @@ jobs: set -e # build for WebGPU - cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} --tests --features glsl,spirv,fragile-send-sync-non-atomic-wasm - cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} --tests --features glsl,spirv - cargo doc --target ${{ matrix.target }} ${{ matrix.extra-flags }} --no-deps --features glsl,spirv + cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} --tests --features glsl,fragile-send-sync-non-atomic-wasm + cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} --tests --features glsl + cargo doc --target ${{ matrix.target }} ${{ matrix.extra-flags }} --no-deps --features glsl # check with only the web feature cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} --no-default-features --features=web