Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ By @cwfitzgerald in [#8162](https://github.com/gfx-rs/wgpu/pull/8162).
- **BREAKING**: Previously the WGSL storage-texture format `rg11b10float` was incorrectly accepted and generated by naga, but now only accepts the the correct name `rg11b10ufloat` instead. By @ErikWDev in [#8219](https://github.com/gfx-rs/wgpu/pull/8219).
- The [`source()`](https://doc.rust-lang.org/std/error/trait.Error.html#method.source) method of `ShaderError` no longer reports the error as its own source. By @andyleiserson in [#8258](https://github.com/gfx-rs/wgpu/pull/8258).
- naga correctly ingests SPIR-V that use descriptor runtime indexing, which in turn is correctly converted into WGSLs binding array. By @hasenbanck in [8256](https://github.com/gfx-rs/wgpu/pull/8256).

- naga correctly ingests SPIR-V that loads from multi-sampled textures, which in turn is correctly converted into WGSLs texture_multisampled_2d and load operations. By @hasenbanck in [8270](https://github.com/gfx-rs/wgpu/pull/8270).

#### DX12

- Allow disabling waiting for latency waitable object. By @marcpabst in [#7400](https://github.com/gfx-rs/wgpu/pull/7400)
Expand Down
1 change: 1 addition & 0 deletions naga/src/front/spv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pub const SUPPORTED_CAPABILITIES: &[spirv::Capability] = &[
spirv::Capability::GroupNonUniformShuffle,
spirv::Capability::GroupNonUniformShuffleRelative,
spirv::Capability::RuntimeDescriptorArray,
spirv::Capability::StorageImageMultisample,
// tricky ones
spirv::Capability::UniformBufferArrayDynamicIndexing,
spirv::Capability::StorageBufferArrayDynamicIndexing,
Expand Down
21 changes: 21 additions & 0 deletions naga/tests/in/spv/load-ms-texture.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Compiled with:
// slangc -target spirv -profile spirv_1_5 -o naga/tests/in/spv/load-ms-texture.spv naga/tests/in/spv/load-ms-texture.slang
// Disassembled with:
// spirv-dis naga/tests/in/spv/load-ms-texture.spv -o naga/tests/in/spv/load-ms-texture.spvasm
#language slang 2026

[[vk::binding(0, 0)]] var texture: Texture2DMS;

[[shader("pixel")]]
func fs_main(float4 position : SV_Position) -> float4 {
let pixel_coord = int2(position.xy);
var color: float4;

for (var index: int = 0; index < 8; index++) {
color += texture.Load(pixel_coord, index);
}

color = color / 8.0;

return color;
}
93 changes: 93 additions & 0 deletions naga/tests/in/spv/load-ms-texture.spvasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
; SPIR-V
; Version: 1.5
; Generator: Khronos Slang Compiler; 0
; Bound: 65
; Schema: 0
OpCapability StorageImageMultisample
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %fs_main "main" %texture %entryPointParam_fs_main %gl_FragCoord
OpExecutionMode %fs_main OriginUpperLeft
OpSource Slang 1
OpName %index "index"
OpName %index "index"
OpName %color "color"
OpName %color "color"
OpName %color_0 "color"
OpName %entryPointParam_fs_main "entryPointParam_fs_main"
OpName %texture "texture"
OpName %sampled "sampled"
OpName %color_1 "color"
OpName %fs_main "fs_main"
OpDecorate %gl_FragCoord BuiltIn FragCoord
OpDecorate %entryPointParam_fs_main Location 0
OpDecorate %texture Binding 0
OpDecorate %texture DescriptorSet 0
%void = OpTypeVoid
%3 = OpTypeFunction %void
%int = OpTypeInt 32 1
%_ptr_Function_int = OpTypePointer Function %int
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Function_v4float = OpTypePointer Function %v4float
%_ptr_Input_v4float = OpTypePointer Input %v4float
%v2float = OpTypeVector %float 2
%v2int = OpTypeVector %int 2
%int_0 = OpConstant %int 0
%bool = OpTypeBool
%int_8 = OpConstant %int 8
%_ptr_Output_v4float = OpTypePointer Output %v4float
%45 = OpTypeImage %float 2D 2 0 1 1 Unknown
%_ptr_UniformConstant_45 = OpTypePointer UniformConstant %45
%int_1 = OpConstant %int 1
%gl_FragCoord = OpVariable %_ptr_Input_v4float Input
%entryPointParam_fs_main = OpVariable %_ptr_Output_v4float Output
%texture = OpVariable %_ptr_UniformConstant_45 UniformConstant
%float_0_125 = OpConstant %float 0.125
%64 = OpConstantComposite %v4float %float_0_125 %float_0_125 %float_0_125 %float_0_125
%fs_main = OpFunction %void None %3
%4 = OpLabel
%index = OpVariable %_ptr_Function_int Function
%color = OpVariable %_ptr_Function_v4float Function
%22 = OpLoad %v4float %gl_FragCoord
%26 = OpVectorShuffle %v2float %22 %22 0 1
%28 = OpConvertFToS %v2int %26
OpStore %index %int_0
OpBranch %12
%12 = OpLabel
OpLoopMerge %17 %21 None
OpBranch %13
%13 = OpLabel
OpBranch %14
%14 = OpLabel
OpBranch %15
%15 = OpLabel
%31 = OpLoad %int %index
%33 = OpSLessThan %bool %31 %int_8
OpSelectionMerge %18 None
OpBranchConditional %33 %18 %16
%16 = OpLabel
OpBranch %17
%18 = OpLabel
%46 = OpLoad %45 %texture
%49 = OpLoad %int %index
%sampled = OpImageFetch %v4float %46 %28 Sample %49
%52 = OpLoad %v4float %color
%color_1 = OpFAdd %v4float %52 %sampled
OpBranch %19
%19 = OpLabel
OpBranch %20
%20 = OpLabel
%56 = OpLoad %int %index
%57 = OpIAdd %int %56 %int_1
OpStore %index %57
OpStore %color %color_1
OpBranch %21
%21 = OpLabel
OpBranch %12
%17 = OpLabel
%37 = OpLoad %v4float %color
%color_0 = OpFMul %v4float %37 %64
OpStore %entryPointParam_fs_main %color_0
OpReturn
OpFunctionEnd
4 changes: 4 additions & 0 deletions naga/tests/in/spv/load-ms-texture.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
god_mode = true

[spv-in]
adjust_coordinate_space = true
37 changes: 37 additions & 0 deletions naga/tests/out/wgsl/spv-load-ms-texture.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
var<private> global: vec4<f32>;
var<private> entryPointParam_fs_main: vec4<f32>;
@group(0) @binding(0)
var texture: texture_multisampled_2d<f32>;

fn fs_main() {
var index: i32;
var color: vec4<f32>;

let _e9 = global;
index = 0i;
loop {
let _e12 = index;
if (_e12 < 8i) {
} else {
break;
}
let _e14 = index;
let _e15 = textureLoad(texture, vec2<i32>(_e9.xy), _e14);
let _e16 = color;
let _e18 = index;
index = (_e18 + 1i);
color = (_e16 + _e15);
continue;
}
let _e20 = color;
entryPointParam_fs_main = (_e20 * vec4<f32>(0.125f, 0.125f, 0.125f, 0.125f));
return;
}

@fragment
fn main(@builtin(position) param: vec4<f32>) -> @location(0) vec4<f32> {
global = param;
fs_main();
let _e3 = entryPointParam_fs_main;
return _e3;
}
Loading