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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,15 @@ Bottom level categories:

### New Features

#### General

- Added support for cooperative load/store operations in shaders. Currently only WGSL on the input and SPIR-V, METAL, and WGSL on the output are supported. By @kvark in [#8251](https://github.com/gfx-rs/wgpu/issues/8251).
- Added support for obtaining `AdapterInfo` from `Device`. By @sagudev in [#8807](https://github.com/gfx-rs/wgpu/pull/8807).

#### naga

- Added support for dual-source blending in SPIR-V shaders. By @andyleiserson in [#8865](https://github.com/gfx-rs/wgpu/pull/8865).

### Bug Fixes

#### General
Expand Down
17 changes: 17 additions & 0 deletions naga/src/front/spv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ struct Decoration {
name: Option<String>,
built_in: Option<spirv::Word>,
location: Option<spirv::Word>,
index: Option<spirv::Word>,
desc_set: Option<spirv::Word>,
desc_index: Option<spirv::Word>,
specialization_constant_id: Option<spirv::Word>,
Expand Down Expand Up @@ -256,6 +257,18 @@ impl Decoration {
invariant,
..
} => Ok(crate::Binding::BuiltIn(map_builtin(built_in, invariant)?)),
Decoration {
built_in: None,
location: Some(location),
index: Some(index),
..
} => Ok(crate::Binding::Location {
location,
interpolation: None,
sampling: None,
blend_src: Some(index),
per_primitive: false,
}),
Decoration {
built_in: None,
location: Some(location),
Expand Down Expand Up @@ -746,6 +759,10 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
inst.expect(base_words + 2)?;
dec.location = Some(self.next()?);
}
spirv::Decoration::Index => {
inst.expect(base_words + 2)?;
dec.index = Some(self.next()?);
}
spirv::Decoration::DescriptorSet => {
inst.expect(base_words + 2)?;
dec.desc_set = Some(self.next()?);
Expand Down
35 changes: 35 additions & 0 deletions naga/tests/in/spv/dual-source-blending.spvasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 22
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %output0 %output1
OpExecutionMode %main OriginUpperLeft
OpSource GLSL 450
OpName %main "main"
OpName %output0 "output0"
OpName %output1 "output1"
OpDecorate %output0 Location 0
OpDecorate %output0 Index 0
OpDecorate %output1 Location 0
OpDecorate %output1 Index 1
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%output0 = OpVariable %_ptr_Output_v4float Output
%float_1 = OpConstant %float 1
%float_0 = OpConstant %float 0
%13 = OpConstantComposite %v4float %float_1 %float_0 %float_1 %float_0
%output1 = OpVariable %_ptr_Output_v4float Output
%15 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
%main = OpFunction %void None %3
%5 = OpLabel
OpStore %output0 %13
OpStore %output1 %15
OpReturn
OpFunctionEnd
1 change: 1 addition & 0 deletions naga/tests/in/spv/dual-source-blending.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
capabilities = "DUAL_SOURCE_BLENDING"
23 changes: 23 additions & 0 deletions naga/tests/out/wgsl/spv-dual-source-blending.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
enable dual_source_blending;

struct FragmentOutput {
@location(0) @blend_src(0) member: vec4<f32>,
@location(0) @blend_src(1) member_1: vec4<f32>,
}

var<private> output0_: vec4<f32>;
var<private> output1_: vec4<f32>;

fn main_1() {
output0_ = vec4<f32>(1f, 0f, 1f, 0f);
output1_ = vec4<f32>(0f, 1f, 0f, 1f);
return;
}

@fragment
fn main() -> FragmentOutput {
main_1();
let _e2 = output0_;
let _e3 = output1_;
return FragmentOutput(_e2, _e3);
}