• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright © 2024 Valve Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24#version 460
25
26#extension GL_GOOGLE_include_directive : require
27
28#extension GL_EXT_shader_explicit_arithmetic_types_int8 : require
29#extension GL_EXT_shader_explicit_arithmetic_types_int16 : require
30#extension GL_EXT_shader_explicit_arithmetic_types_int32 : require
31#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
32#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require
33#extension GL_EXT_scalar_block_layout : require
34#extension GL_EXT_buffer_reference : require
35#extension GL_EXT_buffer_reference2 : require
36
37layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
38
39#include "tu_build_interface.h"
40
41layout(push_constant) uniform CONSTS
42{
43   header_args args;
44};
45
46void
47main(void)
48{
49   uint32_t compacted_size = args.bvh_offset + DEREF(args.src).dst_node_offset * SIZEOF(tu_internal_node);
50
51   uint32_t serialization_size = compacted_size + SIZEOF(uint64_t) * args.instance_count;
52
53   uint32_t size = serialization_size - SIZEOF(vk_accel_struct_serialization_header) -
54                   SIZEOF(uint64_t) * args.instance_count;
55
56   DEREF(args.dst).compacted_size = compacted_size;
57
58   DEREF(args.dst).copy_dispatch_size[0] = DIV_ROUND_UP(compacted_size, 16 * 128);
59   DEREF(args.dst).copy_dispatch_size[1] = 1;
60   DEREF(args.dst).copy_dispatch_size[2] = 1;
61
62   DEREF(args.dst).serialization_size = serialization_size;
63
64   DEREF(args.dst).size = size;
65}
66