File: gpu_pre_dispatch.comp

package info (click to toggle)
vulkan-validationlayers 1.3.239.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 33,020 kB
  • sloc: cpp: 424,221; python: 16,164; ansic: 3,523; sh: 359; xml: 27; makefile: 21
file content (63 lines) | stat: -rw-r--r-- 2,269 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) 2022 The Khronos Group Inc.
// Copyright (c) 2022 Valve Corporation
// Copyright (c) 2022 LunarG, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// * Author: Spencer Fricke <spencerfricke@gmail.com>
//

#version 450
#define VAL_OUT_RECORD_SZ 10
#extension GL_GOOGLE_include_directive : enable
#include "gpu_shaders_constants.h"
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

layout(set = 0, binding = 0) buffer OutputBuffer {
    uint flags;
    uint output_buffer_count;
    uint output_buffer[];
};

layout(set = 0, binding = 1) buffer IndirectBuffer { uint indirect_buffer[]; };

layout(push_constant) uniform UniformInfo {
    uint limit_x;
    uint limit_y;
    uint limit_z;
    uint indirect_x_offset;
} u_info;

void valErrorOut(uint error, uint count) {
    uint vo_idx = atomicAdd(output_buffer_count, VAL_OUT_RECORD_SZ);
    if (vo_idx + VAL_OUT_RECORD_SZ > output_buffer.length())
        return;
    output_buffer[vo_idx + _kInstValidationOutError] = _kInstErrorPreDispatchValidate;
    output_buffer[vo_idx + _kInstValidationOutError + 1] = error;
    output_buffer[vo_idx + _kInstValidationOutError + 2] = count;
}

void main() {
    uint indirect_x = indirect_buffer[u_info.indirect_x_offset];
    uint indirect_y = indirect_buffer[u_info.indirect_x_offset + 1];
    uint indirect_z = indirect_buffer[u_info.indirect_x_offset + 2];

    if (indirect_x > u_info.limit_x) {
        valErrorOut(pre_dispatch_count_exceeds_limit_x_error, indirect_x);
    } else if (indirect_y > u_info.limit_y) {
        valErrorOut(pre_dispatch_count_exceeds_limit_y_error, indirect_y);
    } else if (indirect_z > u_info.limit_z) {
        valErrorOut(pre_dispatch_count_exceeds_limit_z_error, indirect_z);
    }

}