Skip to content

Commit f6da233

Browse files
committed
nonuniform: ByteAddressableBuffer always decorates NonUniform
1 parent 1932353 commit f6da233

File tree

8 files changed

+21
-9
lines changed

8 files changed

+21
-9
lines changed

crates/rustc_codegen_spirv/src/builder/byte_addressable_buffer.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::Builder;
22
use crate::builder_spirv::{SpirvValue, SpirvValueExt, SpirvValueKind};
33
use crate::spirv_type::SpirvType;
4-
use rspirv::spirv::Word;
4+
use rspirv::spirv::{Decoration, Word};
55
use rustc_codegen_ssa::traits::BuilderMethods;
66
use rustc_errors::ErrorGuaranteed;
77
use rustc_span::DUMMY_SP;
@@ -38,9 +38,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
3838
};
3939
let u32_ty = SpirvType::Integer(32, false).def(DUMMY_SP, self);
4040
let u32_ptr = self.type_ptr_to(u32_ty);
41+
let array = array.def(self);
42+
let actual_index = actual_index.def(self);
43+
self.emit().decorate(array, Decoration::NonUniform, []);
44+
self.emit()
45+
.decorate(actual_index, Decoration::NonUniform, []);
4146
let ptr = self
4247
.emit()
43-
.in_bounds_access_chain(u32_ptr, None, array.def(self), [actual_index.def(self)])
48+
.in_bounds_access_chain(u32_ptr, None, array, [actual_index])
4449
.unwrap()
4550
.with_type(u32_ptr);
4651
self.load(u32_ty, ptr, Align::ONE)

tests/ui/byte_addressable_buffer/arr.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// build-pass
2+
// compile-flags: -Ctarget-feature=+ShaderNonUniform,+ext:SPV_EXT_descriptor_indexing
23

34
use spirv_std::spirv;
4-
use spirv_std::{glam::Vec4, ByteAddressableBuffer};
5+
use spirv_std::{ByteAddressableBuffer, glam::Vec4};
56

67
#[spirv(fragment)]
78
pub fn load(

tests/ui/byte_addressable_buffer/big_struct.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// build-pass
2+
// compile-flags: -Ctarget-feature=+ShaderNonUniform,+ext:SPV_EXT_descriptor_indexing
23

3-
use spirv_std::spirv;
44
use spirv_std::ByteAddressableBuffer;
5+
use spirv_std::spirv;
56

67
pub struct BigStruct {
78
a: u32,

tests/ui/byte_addressable_buffer/complex.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// build-pass
2+
// compile-flags: -Ctarget-feature=+ShaderNonUniform,+ext:SPV_EXT_descriptor_indexing
23

34
use spirv_std::spirv;
4-
use spirv_std::{glam::Vec2, ByteAddressableBuffer};
5+
use spirv_std::{ByteAddressableBuffer, glam::Vec2};
56

67
pub struct Complex {
78
x: u32,

tests/ui/byte_addressable_buffer/f32.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// build-pass
2+
// compile-flags: -Ctarget-feature=+ShaderNonUniform,+ext:SPV_EXT_descriptor_indexing
23

3-
use spirv_std::spirv;
44
use spirv_std::ByteAddressableBuffer;
5+
use spirv_std::spirv;
56

67
#[spirv(fragment)]
78
pub fn load(#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buf: &[u32], out: &mut f32) {

tests/ui/byte_addressable_buffer/small_struct.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// build-pass
2+
// compile-flags: -Ctarget-feature=+ShaderNonUniform,+ext:SPV_EXT_descriptor_indexing
23

3-
use spirv_std::spirv;
44
use spirv_std::ByteAddressableBuffer;
5+
use spirv_std::spirv;
56

67
pub struct SmallStruct {
78
a: u32,

tests/ui/byte_addressable_buffer/u32.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// build-pass
2+
// compile-flags: -Ctarget-feature=+ShaderNonUniform,+ext:SPV_EXT_descriptor_indexing
23

3-
use spirv_std::spirv;
44
use spirv_std::ByteAddressableBuffer;
5+
use spirv_std::spirv;
56

67
#[spirv(fragment)]
78
pub fn load(#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buf: &[u32], out: &mut u32) {

tests/ui/byte_addressable_buffer/vec.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// build-pass
2+
// compile-flags: -Ctarget-feature=+ShaderNonUniform,+ext:SPV_EXT_descriptor_indexing
23

34
use spirv_std::spirv;
4-
use spirv_std::{glam::Vec4, ByteAddressableBuffer};
5+
use spirv_std::{ByteAddressableBuffer, glam::Vec4};
56

67
#[spirv(matrix)]
78
pub struct Mat4 {

0 commit comments

Comments
 (0)