blob: e8cbc6b7590e8167ab745ef23708a33cfcdb4c95 [file] [log] [blame]
// Copyright (c) 2022 The Khronos Group Inc.
// Copyright (c) 2022-2023 Valve Corporation
// Copyright (c) 2022-2023 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.
#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);
}
}