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
22 changes: 11 additions & 11 deletions crates/rustc_codegen_spirv/src/builder/spirv_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,20 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
SpirvType::Float(inst.operands[0].unwrap_literal_bit32()).def(self.span(), self)
}
Op::TypeStruct => {
self.err("OpTypeStruct in asm! is not supported yet");
self.err("`OpTypeStruct` in asm! is not supported");
return;
}
Op::TypeVector => SpirvType::Vector {
element: inst.operands[0].unwrap_id_ref(),
count: inst.operands[1].unwrap_literal_bit32(),
Op::TypeVector => {
self.struct_err(
"`OpTypeVector` in asm! is not supported, since `#[spirv(vector)]` structs can \
create different vector types due to varying size and alignment",
)
.with_note(
"pass `glam::VecN` as parameters and use `typeof{foo}` or `typeof*{foo}` (pointer to type) to resolve vector type",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory we could extract the operands and suggest the exact correct type, but that feels overkill.

)
.emit();
return;
}
.def(self.span(), self),
Op::TypeMatrix => SpirvType::Matrix {
element: inst.operands[0].unwrap_id_ref(),
count: inst.operands[1].unwrap_literal_bit32(),
Expand Down Expand Up @@ -762,12 +768,6 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
}
.def(DUMMY_SP, cx),

TyPat::Vector4(pat) => SpirvType::Vector {
element: subst_ty_pat(cx, pat, ty_vars, leftover_operands)?,
count: 4,
}
.def(DUMMY_SP, cx),

TyPat::SampledImage(pat) => SpirvType::SampledImage {
image_type: subst_ty_pat(cx, pat, ty_vars, leftover_operands)?,
}
Expand Down
3 changes: 1 addition & 2 deletions crates/spirv-std/src/arch/subgroup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,9 @@ pub fn subgroup_ballot(predicate: bool) -> SubgroupMask {
unsafe {
asm! {
"%u32 = OpTypeInt 32 0",
"%groupmask = OpTypeVector %u32 4",
"%subgroup = OpConstant %u32 {subgroup}",
"%predicate = OpLoad _ {predicate}",
"%result = OpGroupNonUniformBallot %groupmask %subgroup %predicate",
"%result = OpGroupNonUniformBallot typeof*{result} %subgroup %predicate",
"OpStore {result} %result",
subgroup = const SUBGROUP,
predicate = in(reg) &predicate,
Expand Down
20 changes: 5 additions & 15 deletions crates/spirv-std/src/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ pub fn f16x2_to_vec2<V: Vector<f32, 2>>(int: u32) -> V {
unsafe {
asm!(
"%glsl = OpExtInstImport \"GLSL.std.450\"",
"%float = OpTypeFloat 32",
"%vec2 = OpTypeVector %float 2",
// 62 = UnpackHalf2x16
"%result = OpExtInst %vec2 %glsl 62 {int}",
"%result = OpExtInst typeof*{result} %glsl 62 {int}",
"OpStore {result} %result",
int = in(reg) int,
result = in(reg) &mut result,
Expand Down Expand Up @@ -164,10 +162,8 @@ pub fn u8x4_to_vec4_snorm<V: Vector<f32, 4>>(int: u32) -> V {
unsafe {
asm!(
"%glsl = OpExtInstImport \"GLSL.std.450\"",
"%float = OpTypeFloat 32",
"%vec4 = OpTypeVector %float 4",
// 63 = UnpackSnorm4x8
"%result = OpExtInst %vec4 %glsl 63 {int}",
"%result = OpExtInst typeof*{result} %glsl 63 {int}",
"OpStore {result} %result",
int = in(reg) int,
result = in(reg) &mut result,
Expand All @@ -185,10 +181,8 @@ pub fn u8x4_to_vec4_unorm<V: Vector<f32, 4>>(int: u32) -> V {
unsafe {
asm!(
"%glsl = OpExtInstImport \"GLSL.std.450\"",
"%float = OpTypeFloat 32",
"%vec4 = OpTypeVector %float 4",
// 64 = UnpackUnorm4x8
"%result = OpExtInst %vec4 %glsl 64 {int}",
"%result = OpExtInst typeof*{result} %glsl 64 {int}",
"OpStore {result} %result",
int = in(reg) int,
result = in(reg) &mut result,
Expand All @@ -206,10 +200,8 @@ pub fn u16x2_to_vec2_snorm<V: Vector<f32, 2>>(int: u32) -> V {
unsafe {
asm!(
"%glsl = OpExtInstImport \"GLSL.std.450\"",
"%float = OpTypeFloat 32",
"%vec2 = OpTypeVector %float 2",
// 60 = UnpackSnorm2x16
"%result = OpExtInst %vec2 %glsl 60 {int}",
"%result = OpExtInst typeof*{result} %glsl 60 {int}",
"OpStore {result} %result",
int = in(reg) int,
result = in(reg) &mut result,
Expand All @@ -227,10 +219,8 @@ pub fn u16x2_to_vec2_unorm<V: Vector<f32, 2>>(int: u32) -> V {
unsafe {
asm!(
"%glsl = OpExtInstImport \"GLSL.std.450\"",
"%float = OpTypeFloat 32",
"%vec2 = OpTypeVector %float 2",
// 61 = UnpackUnorm2x16
"%result = OpExtInst %vec2 %glsl 61 {int}",
"%result = OpExtInst typeof*{result} %glsl 61 {int}",
"OpStore {result} %result",
int = in(reg) int,
result = in(reg) &mut result,
Expand Down
28 changes: 14 additions & 14 deletions crates/spirv-std/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ impl<
"%coordinate = OpLoad _ {coordinate}",
"%lod = OpLoad _ {lod}",
"%sampledImage = OpSampledImage _ %image %sampler",
"%result = OpImageSampleExplicitLod _ %sampledImage %coordinate Lod %lod",
"%result = OpImageSampleExplicitLod typeof*{result} %sampledImage %coordinate Lod %lod",
"OpStore {result} %result",
result = in(reg) &mut result,
this = in(reg) self,
Expand Down Expand Up @@ -372,7 +372,7 @@ impl<
"%gradient_dx = OpLoad _ {gradient_dx}",
"%gradient_dy = OpLoad _ {gradient_dy}",
"%sampledImage = OpSampledImage _ %image %sampler",
"%result = OpImageSampleExplicitLod _ %sampledImage %coordinate Grad %gradient_dx %gradient_dy",
"%result = OpImageSampleExplicitLod typeof*{result} %sampledImage %coordinate Grad %gradient_dx %gradient_dy",
"OpStore {result} %result",
result = in(reg) &mut result,
this = in(reg) self,
Expand Down Expand Up @@ -409,7 +409,7 @@ impl<
"%coordinate = OpLoad _ {coordinate}",
"%depth_reference = OpLoad _ {depth_reference}", // not required to do this way, but done for consistency
"%sampledImage = OpSampledImage _ %image %sampler",
"%result = OpImageSampleDrefImplicitLod _ %sampledImage %coordinate %depth_reference",
"%result = OpImageSampleDrefImplicitLod typeof*{result} %sampledImage %coordinate %depth_reference",
"OpStore {result} %result",
result = in(reg) &mut result,
this = in(reg) self,
Expand Down Expand Up @@ -447,7 +447,7 @@ impl<
"%depth_reference = OpLoad _ {depth_reference}",
"%lod = OpLoad _ {lod}",
"%sampledImage = OpSampledImage _ %image %sampler",
"%result = OpImageSampleDrefExplicitLod _ %sampledImage %coordinate %depth_reference Lod %lod",
"%result = OpImageSampleDrefExplicitLod typeof*{result} %sampledImage %coordinate %depth_reference Lod %lod",
"OpStore {result} %result",
result = in(reg) &mut result,
this = in(reg) self,
Expand Down Expand Up @@ -489,7 +489,7 @@ impl<
"%gradient_dx = OpLoad _ {gradient_dx}",
"%gradient_dy = OpLoad _ {gradient_dy}",
"%sampledImage = OpSampledImage _ %image %sampler",
"%result = OpImageSampleDrefExplicitLod _ %sampledImage %coordinate %depth_reference Grad %gradient_dx %gradient_dy",
"%result = OpImageSampleDrefExplicitLod typeof*{result} %sampledImage %coordinate %depth_reference Grad %gradient_dx %gradient_dy",
"OpStore {result} %result",
result = in(reg) &mut result,
this = in(reg) self,
Expand Down Expand Up @@ -545,7 +545,7 @@ impl<
"%sampler = OpLoad _ {sampler}",
"%project_coordinate = OpLoad _ {project_coordinate}",
"%sampledImage = OpSampledImage _ %image %sampler",
"%result = OpImageSampleProjImplicitLod _ %sampledImage %project_coordinate",
"%result = OpImageSampleProjImplicitLod typeof*{result} %sampledImage %project_coordinate",
"OpStore {result} %result",
result = in(reg) &mut result,
this = in(reg) self,
Expand Down Expand Up @@ -580,7 +580,7 @@ impl<
"%project_coordinate = OpLoad _ {project_coordinate}",
"%lod = OpLoad _ {lod}",
"%sampledImage = OpSampledImage _ %image %sampler",
"%result = OpImageSampleProjExplicitLod _ %sampledImage %project_coordinate Lod %lod",
"%result = OpImageSampleProjExplicitLod typeof*{result} %sampledImage %project_coordinate Lod %lod",
"OpStore {result} %result",
result = in(reg) &mut result,
this = in(reg) self,
Expand Down Expand Up @@ -618,7 +618,7 @@ impl<
"%gradient_dx = OpLoad _ {gradient_dx}",
"%gradient_dy = OpLoad _ {gradient_dy}",
"%sampledImage = OpSampledImage _ %image %sampler",
"%result = OpImageSampleProjExplicitLod _ %sampledImage %project_coordinate Grad %gradient_dx %gradient_dy",
"%result = OpImageSampleProjExplicitLod typeof*{result} %sampledImage %project_coordinate Grad %gradient_dx %gradient_dy",
"OpStore {result} %result",
result = in(reg) &mut result,
this = in(reg) self,
Expand Down Expand Up @@ -655,7 +655,7 @@ impl<
"%project_coordinate = OpLoad _ {project_coordinate}",
"%depth_reference = OpLoad _ {depth_reference}", // not required to do this way, but done for consistency
"%sampledImage = OpSampledImage _ %image %sampler",
"%result = OpImageSampleProjDrefImplicitLod _ %sampledImage %project_coordinate %depth_reference",
"%result = OpImageSampleProjDrefImplicitLod typeof*{result} %sampledImage %project_coordinate %depth_reference",
"OpStore {result} %result",
result = in(reg) &mut result,
this = in(reg) self,
Expand Down Expand Up @@ -693,7 +693,7 @@ impl<
"%depth_reference = OpLoad _ {depth_reference}",
"%lod = OpLoad _ {lod}",
"%sampledImage = OpSampledImage _ %image %sampler",
"%result = OpImageSampleProjDrefExplicitLod _ %sampledImage %coordinate %depth_reference Lod %lod",
"%result = OpImageSampleProjDrefExplicitLod typeof*{result} %sampledImage %coordinate %depth_reference Lod %lod",
"OpStore {result} %result",
result = in(reg) &mut result,
this = in(reg) self,
Expand Down Expand Up @@ -735,7 +735,7 @@ impl<
"%gradient_dx = OpLoad _ {gradient_dx}",
"%gradient_dy = OpLoad _ {gradient_dy}",
"%sampledImage = OpSampledImage _ %image %sampler",
"%result = OpImageSampleProjDrefExplicitLod _ %sampledImage %coordinate %depth_reference Grad %gradient_dx %gradient_dy",
"%result = OpImageSampleProjDrefExplicitLod typeof*{result} %sampledImage %coordinate %depth_reference Grad %gradient_dx %gradient_dy",
"OpStore {result} %result",
result = in(reg) &mut result,
this = in(reg) self,
Expand Down Expand Up @@ -1542,7 +1542,7 @@ impl<
"%coordinate = OpLoad _ {coordinate}",
"%depth_reference = OpLoad _ {depth_reference}", // not required to do this way, but done for consistency
"%sampledImage = OpSampledImage _ %image %sampler",
"%result = OpImageSampleDref$LOD _ %sampledImage %coordinate %depth_reference $PARAMS",
"%result = OpImageSampleDref$LOD typeof*{result} %sampledImage %coordinate %depth_reference $PARAMS",
"OpStore {result} %result",
result = in(reg) &mut result,
this = in(reg) self,
Expand Down Expand Up @@ -1577,7 +1577,7 @@ impl<
"%sampler = OpLoad _ {sampler}",
"%project_coordinate = OpLoad _ {project_coordinate}",
"%sampledImage = OpSampledImage _ %image %sampler",
"%result = OpImageSampleProj$LOD _ %sampledImage %project_coordinate $PARAMS",
"%result = OpImageSampleProj$LOD typeof*{result} %sampledImage %project_coordinate $PARAMS",
"OpStore {result} %result",
result = in(reg) &mut result,
this = in(reg) self,
Expand Down Expand Up @@ -1613,7 +1613,7 @@ impl<
"%project_coordinate = OpLoad _ {project_coordinate}",
"%depth_reference = OpLoad _ {depth_reference}", // not required to do this way, but done for consistency
"%sampledImage = OpSampledImage _ %image %sampler",
"%result = OpImageSampleProjDref$LOD _ %sampledImage %project_coordinate %depth_reference $PARAMS",
"%result = OpImageSampleProjDref$LOD typeof*{result} %sampledImage %project_coordinate %depth_reference $PARAMS",
"OpStore {result} %result",
result = in(reg) &mut result,
this = in(reg) self,
Expand Down
4 changes: 2 additions & 2 deletions tests/compiletests/ui/arch/subgroup/subgroup_ballot.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
%1 = OpFunction %2 None %3
%4 = OpFunctionParameter %2
%5 = OpLabel
OpLine %6 378 13
OpLine %6 377 13
%7 = OpGroupNonUniformBallot %8 %9 %4
OpLine %6 417 13
OpLine %6 416 13
%10 = OpGroupNonUniformInverseBallot %2 %9 %7
OpNoLine
OpReturnValue %10
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%1 = OpFunction %2 None %3
%4 = OpFunctionParameter %5
%6 = OpLabel
OpLine %7 512 0
OpLine %7 511 0
%8 = OpGroupNonUniformBallotBitCount %2 %9 Reduce %4
OpNoLine
OpReturnValue %8
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
error[E0080]: evaluation panicked: `ClusterSize` must be at least 1
--> $SPIRV_STD_SRC/arch/subgroup.rs:840:1
--> $SPIRV_STD_SRC/arch/subgroup.rs:839:1
|
840 | / macro_subgroup_op_clustered!(impl Integer, "OpGroupNonUniformIAdd", subgroup_clustered_i_add; r"
841 | | An integer add group operation of all `value` operands contributed by active invocations in the group.
842 | |
843 | | Result Type must be a scalar or vector of integer type.
839 | / macro_subgroup_op_clustered!(impl Integer, "OpGroupNonUniformIAdd", subgroup_clustered_i_add; r"
840 | | An integer add group operation of all `value` operands contributed by active invocations in the group.
841 | |
842 | | Result Type must be a scalar or vector of integer type.
... |
856 | | * `ClusterSize` must not be greater than the size of the group
857 | | ");
855 | | * `ClusterSize` must not be greater than the size of the group
856 | | ");
| |__^ evaluation of `spirv_std::arch::subgroup_clustered_i_add::<0, u32, u32>::{constant#0}` failed here
|
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `macro_subgroup_op_clustered` (in Nightly builds, run with -Z macro-backtrace for more info)

note: erroneous constant encountered
--> $SPIRV_STD_SRC/arch/subgroup.rs:840:1
--> $SPIRV_STD_SRC/arch/subgroup.rs:839:1
|
840 | / macro_subgroup_op_clustered!(impl Integer, "OpGroupNonUniformIAdd", subgroup_clustered_i_add; r"
841 | | An integer add group operation of all `value` operands contributed by active invocations in the group.
842 | |
843 | | Result Type must be a scalar or vector of integer type.
839 | / macro_subgroup_op_clustered!(impl Integer, "OpGroupNonUniformIAdd", subgroup_clustered_i_add; r"
840 | | An integer add group operation of all `value` operands contributed by active invocations in the group.
841 | |
842 | | Result Type must be a scalar or vector of integer type.
... |
856 | | * `ClusterSize` must not be greater than the size of the group
857 | | ");
855 | | * `ClusterSize` must not be greater than the size of the group
856 | | ");
| |__^
|
= note: this note originates in the macro `macro_subgroup_op_clustered` (in Nightly builds, run with -Z macro-backtrace for more info)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
error[E0080]: evaluation panicked: `ClusterSize` must be a power of 2
--> $SPIRV_STD_SRC/arch/subgroup.rs:840:1
--> $SPIRV_STD_SRC/arch/subgroup.rs:839:1
|
840 | / macro_subgroup_op_clustered!(impl Integer, "OpGroupNonUniformIAdd", subgroup_clustered_i_add; r"
841 | | An integer add group operation of all `value` operands contributed by active invocations in the group.
842 | |
843 | | Result Type must be a scalar or vector of integer type.
839 | / macro_subgroup_op_clustered!(impl Integer, "OpGroupNonUniformIAdd", subgroup_clustered_i_add; r"
840 | | An integer add group operation of all `value` operands contributed by active invocations in the group.
841 | |
842 | | Result Type must be a scalar or vector of integer type.
... |
856 | | * `ClusterSize` must not be greater than the size of the group
857 | | ");
855 | | * `ClusterSize` must not be greater than the size of the group
856 | | ");
| |__^ evaluation of `spirv_std::arch::subgroup_clustered_i_add::<5, u32, u32>::{constant#0}` failed here
|
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `macro_subgroup_op_clustered` (in Nightly builds, run with -Z macro-backtrace for more info)

note: erroneous constant encountered
--> $SPIRV_STD_SRC/arch/subgroup.rs:840:1
--> $SPIRV_STD_SRC/arch/subgroup.rs:839:1
|
840 | / macro_subgroup_op_clustered!(impl Integer, "OpGroupNonUniformIAdd", subgroup_clustered_i_add; r"
841 | | An integer add group operation of all `value` operands contributed by active invocations in the group.
842 | |
843 | | Result Type must be a scalar or vector of integer type.
839 | / macro_subgroup_op_clustered!(impl Integer, "OpGroupNonUniformIAdd", subgroup_clustered_i_add; r"
840 | | An integer add group operation of all `value` operands contributed by active invocations in the group.
841 | |
842 | | Result Type must be a scalar or vector of integer type.
... |
856 | | * `ClusterSize` must not be greater than the size of the group
857 | | ");
855 | | * `ClusterSize` must not be greater than the size of the group
856 | | ");
| |__^
|
= note: this note originates in the macro `macro_subgroup_op_clustered` (in Nightly builds, run with -Z macro-backtrace for more info)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%1 = OpFunction %2 None %3
%4 = OpFunctionParameter %2
%5 = OpLabel
OpLine %6 840 0
OpLine %6 839 0
%7 = OpGroupNonUniformIAdd %2 %8 ClusteredReduce %4 %9
OpNoLine
OpReturnValue %7
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%1 = OpFunction %2 None %3
%4 = OpFunctionParameter %2
%5 = OpLabel
OpLine %6 827 0
OpLine %6 826 0
%7 = OpGroupNonUniformIAdd %2 %8 ExclusiveScan %4
OpNoLine
OpReturnValue %7
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%1 = OpFunction %2 None %3
%4 = OpFunctionParameter %2
%5 = OpLabel
OpLine %6 827 0
OpLine %6 826 0
%7 = OpGroupNonUniformIAdd %2 %8 InclusiveScan %4
OpNoLine
OpReturnValue %7
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%1 = OpFunction %2 None %3
%4 = OpFunctionParameter %2
%5 = OpLabel
OpLine %6 827 0
OpLine %6 826 0
%7 = OpGroupNonUniformIAdd %2 %8 Reduce %4
OpNoLine
OpReturnValue %7
Expand Down
Loading