mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
(Naga) Add support for Storage Image Multisample when ingesting SPIR-V (#8270)
This commit is contained in:
parent
a01ffb7967
commit
8cb94db802
@ -200,6 +200,7 @@ 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).
|
- **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).
|
- 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 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
|
#### DX12
|
||||||
|
|
||||||
|
|||||||
@ -83,6 +83,7 @@ pub const SUPPORTED_CAPABILITIES: &[spirv::Capability] = &[
|
|||||||
spirv::Capability::GroupNonUniformShuffle,
|
spirv::Capability::GroupNonUniformShuffle,
|
||||||
spirv::Capability::GroupNonUniformShuffleRelative,
|
spirv::Capability::GroupNonUniformShuffleRelative,
|
||||||
spirv::Capability::RuntimeDescriptorArray,
|
spirv::Capability::RuntimeDescriptorArray,
|
||||||
|
spirv::Capability::StorageImageMultisample,
|
||||||
// tricky ones
|
// tricky ones
|
||||||
spirv::Capability::UniformBufferArrayDynamicIndexing,
|
spirv::Capability::UniformBufferArrayDynamicIndexing,
|
||||||
spirv::Capability::StorageBufferArrayDynamicIndexing,
|
spirv::Capability::StorageBufferArrayDynamicIndexing,
|
||||||
|
|||||||
21
naga/tests/in/spv/load-ms-texture.slang
Normal file
21
naga/tests/in/spv/load-ms-texture.slang
Normal file
@ -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
naga/tests/in/spv/load-ms-texture.spvasm
Normal file
93
naga/tests/in/spv/load-ms-texture.spvasm
Normal file
@ -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
naga/tests/in/spv/load-ms-texture.toml
Normal file
4
naga/tests/in/spv/load-ms-texture.toml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
god_mode = true
|
||||||
|
|
||||||
|
[spv-in]
|
||||||
|
adjust_coordinate_space = true
|
||||||
37
naga/tests/out/wgsl/spv-load-ms-texture.wgsl
Normal file
37
naga/tests/out/wgsl/spv-load-ms-texture.wgsl
Normal file
@ -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…
x
Reference in New Issue
Block a user