blob: 62b498ab0b58916b36c278e2264f2027404c7f8b [file] [log] [blame]
// Copyright (c) 2022-2025 The Khronos Group Inc.
// Copyright (c) 2022-2025 Valve Corporation
// Copyright (c) 2022-2025 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 460
#extension GL_EXT_ray_tracing : require
#extension GL_EXT_buffer_reference : require
#if defined(GL_ARB_gpu_shader_int64)
#extension GL_ARB_gpu_shader_int64 : require
#else
#error No extension available for 64-bit integers.
#endif
#extension GL_GOOGLE_include_directive : enable
struct VkTraceRaysIndirectCommandKHR {
uint width;
uint height;
uint depth;
};
layout(buffer_reference, std430) buffer IndirectCommandReference {
VkTraceRaysIndirectCommandKHR trace_rays_dimensions;
};
layout(push_constant) uniform PushConstants {
// Need to put the buffer reference first otherwise it is incorrect, probably an alignment issue
IndirectCommandReference indirect_data;
uint trace_rays_width_limit;
uint trace_rays_height_limit;
uint trace_rays_depth_limit;
uint max_ray_dispatch_invocation_count;
};
#include "common.h"
void main() {
if (indirect_data.trace_rays_dimensions.width > trace_rays_width_limit) {
GpuavLogError2(kErrorGroupGpuPreTraceRays, kErrorSubCodePreTraceRaysLimitWidth, indirect_data.trace_rays_dimensions.width, 0);
}
if (indirect_data.trace_rays_dimensions.height > trace_rays_height_limit) {
GpuavLogError2(kErrorGroupGpuPreTraceRays, kErrorSubCodePreTraceRaysLimitHeight, indirect_data.trace_rays_dimensions.height, 0);
}
if (indirect_data.trace_rays_dimensions.depth > trace_rays_depth_limit) {
GpuavLogError2(kErrorGroupGpuPreTraceRays, kErrorSubCodePreTraceRaysLimitDepth, indirect_data.trace_rays_dimensions.depth, 0);
}
const uint64_t trace_rays_volume =
indirect_data.trace_rays_dimensions.width *
indirect_data.trace_rays_dimensions.height *
indirect_data.trace_rays_dimensions.depth;
if (trace_rays_volume > max_ray_dispatch_invocation_count) {
GpuavLogError4(
kErrorGroupGpuPreTraceRays,
kErrorSubCodePreTraceRaysLimitVolume,
indirect_data.trace_rays_dimensions.width,
indirect_data.trace_rays_dimensions.height,
indirect_data.trace_rays_dimensions.depth,
0);
}
}