Skip to content

Commit 29260f6

Browse files
committed
fix test
1 parent 1a2421d commit 29260f6

3 files changed

Lines changed: 30 additions & 13 deletions

File tree

tests/compiletests/ui/lang/consts/large_array_nonzero_fill.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@
44

55
// build-pass
66

7+
#![no_std]
8+
use spirv_std::glam::Vec4;
79
use spirv_std::spirv;
810

9-
#[spirv(fragment)]
10-
pub fn main(out: &mut f32) {
11-
let arr = [1.0f32; 2048];
12-
*out = arr[0];
11+
#[spirv(vertex)]
12+
pub fn test_vs(
13+
#[spirv(push_constant)] index: &u32,
14+
#[spirv(position)] out_pos: &mut Vec4,
15+
) {
16+
let nonzeroed = [1.0f32; 2048];
17+
18+
let i = *index as usize % 2048;
19+
*out_pos = Vec4::new(nonzeroed[i], nonzeroed[i], 0.0, 1.0);
1320
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
warning: large array of 2048 elements with a non-zero fill will generate 2048 SPIR-V store instructions, which may be slow to compile; consider using a storage buffer for large data instead
2-
--> $DIR/large_array_nonzero_fill.rs:11:15
2+
--> $DIR/large_array_nonzero_fill.rs:16:21
33
|
4-
LL | let arr = [1.0f32; 2048];
5-
| ^^^^^^^^^^^^^^
4+
LL | let nonzeroed = [1.0f32; 2048];
5+
| ^^^^^^^^^^^^^^
66

77
warning: 1 warning emitted
88

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
// Tests that zero-initialized large arrays compile without warnings.
22
// A `[0; N]` array goes through `memset_const_pattern` with fill_byte=0,
3-
// which should emit a single OpConstantNull rather than an OpConstantComposite
4-
// with N operands.
3+
// which should emit a single OpConstantNull
54

65
// build-pass
76

7+
#![no_std]
8+
use spirv_std::glam::Vec4;
89
use spirv_std::spirv;
910

10-
#[spirv(fragment)]
11-
pub fn main(out: &mut f32) {
12-
let arr = [0.0f32; 2048];
13-
*out = arr[0];
11+
#[spirv(vertex)]
12+
pub fn test_vs(
13+
#[spirv(push_constant)] index: &u32,
14+
#[spirv(position)] out_pos: &mut Vec4,
15+
) {
16+
let zeroed = [1.0f32; 2048];
17+
18+
let i = *index as usize % 2048;
19+
*out_pos = Vec4::new(zeroed[i], zeroed[i], 0.0, 1.0);
1420
}
21+
22+
23+
24+

0 commit comments

Comments
 (0)