• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2# Copyright 2019 The Amber Authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     https://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16SHADER compute buffer_overrun GLSL
17#version 430
18
19// Only one invocation per workgroup.
20layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
21
22layout(set = 0, binding = 0) buffer BlockUint {
23  uint data[];
24} ssbo_uint;
25
26layout(set = 0, binding = 1) buffer BlockInt {
27  int data[];
28} ssbo_int;
29
30void main() {
31  uint upper_bound = ssbo_uint.data[0];
32  uint ui;
33  for (ui = 0; ui < upper_bound; ++ui) {
34    ssbo_uint.data[ui]++;
35  }
36
37  int int_lower = ssbo_int.data[0];
38  int int_upper = ssbo_int.data[1];
39  int i;
40  for (i = int_lower; i < int_upper; ++i) {
41    ssbo_int.data[i]++;
42  }
43}
44END
45
46BUFFER buf_uint DATA_TYPE uint32 DATA
4710000 0 0 0
48END
49
50BUFFER buf_int DATA_TYPE int32 DATA
51-5 10 0 0 0
52END
53
54PIPELINE compute pipeline
55  ATTACH buffer_overrun
56  SHADER_OPTIMIZATION buffer_overrun
57    --graphics-robust-access
58  END
59
60  BIND BUFFER buf_uint AS storage DESCRIPTOR_SET 0 BINDING 0
61  BIND BUFFER buf_int AS storage DESCRIPTOR_SET 0 BINDING 1
62END
63
64# Only one workgroup.  Having only one invocation execute ensures
65# there are no race conditions.
66RUN pipeline 1 1 1
67
68# In the unsigned int index case:
69#   The first 4 entries are incremented, as expected.
70#   Beyond that, the remaining indices are clamped to the upper
71#   bound of the length of the array, minus 1.
72EXPECT buf_uint IDX 0 EQ 10001 1 1 9997
73
74# In the signed int index case:
75#
76#   Index 0 is incremented 6 times, for i values -5, -4, -3, -2, -1, 0
77#   since negative indices are clamped to 0.
78#     So initial value -5 + 6 --> 1
79#   Indices 1, 2, 3 are incremented once each.
80#   Index 4 is incremented 6 times, for i values 4, 5, 6, 7, 8, 9
81EXPECT buf_int IDX 0 EQ 1 11 1 1 6
82