1/*
2 * Copyright © 2020 Intel 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#ifndef BRW_NIR_RT_H
25#define BRW_NIR_RT_H
26
27#include "brw_nir.h"
28#include "brw_rt.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34void brw_nir_lower_raygen(nir_shader *nir);
35void brw_nir_lower_any_hit(nir_shader *nir,
36                           const struct intel_device_info *devinfo);
37void brw_nir_lower_closest_hit(nir_shader *nir);
38void brw_nir_lower_miss(nir_shader *nir);
39void brw_nir_lower_callable(nir_shader *nir);
40void brw_nir_lower_combined_intersection_any_hit(nir_shader *intersection,
41                                                 const nir_shader *any_hit,
42                                                 const struct intel_device_info *devinfo);
43
44/* We reserve the first 16B of the stack for callee data pointers */
45#define BRW_BTD_STACK_RESUME_BSR_ADDR_OFFSET 0
46#define BRW_BTD_STACK_CALL_DATA_PTR_OFFSET 8
47#define BRW_BTD_STACK_CALLEE_DATA_SIZE 16
48
49/* We require the stack to be 8B aligned at the start of a shader */
50#define BRW_BTD_STACK_ALIGN 8
51
52void brw_nir_lower_shader_returns(nir_shader *shader);
53
54bool brw_nir_lower_shader_calls(nir_shader *shader);
55
56void brw_nir_lower_rt_intrinsics(nir_shader *shader,
57                                 const struct intel_device_info *devinfo);
58void brw_nir_lower_intersection_shader(nir_shader *intersection,
59                                       const nir_shader *any_hit,
60                                       const struct intel_device_info *devinfo);
61
62nir_shader *
63brw_nir_create_raygen_trampoline(const struct brw_compiler *compiler,
64                                 void *mem_ctx);
65nir_shader *
66brw_nir_create_trivial_return_shader(const struct brw_compiler *compiler,
67                                     void *mem_ctx);
68
69#ifdef __cplusplus
70}
71#endif
72
73#endif /* BRW_NIR_RT_H */
74