Blender V5.0
device/hiprt/globals.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5/* Constant Globals */
6
7#pragma once
8
9#include "kernel/types.h"
12#include "kernel/util/profiler.h" // IWYU pragma: export
14#include "util/color.h" // IWYU pragma: export
15#include "util/texture.h" // IWYU pragma: export
17/* The size of global stack available to each thread (memory reserved for each thread in
18 * global_stack_buffer). */
19#define HIPRT_THREAD_STACK_SIZE 64
21/* LDS (Local Data Storage) allocation for each thread, the number is obtained empirically. */
22#define HIPRT_SHARED_STACK_SIZE 24
24/* HIPRT_THREAD_GROUP_SIZE is the number of threads per work group for intersection kernels
25 * The default number of threads per work-group is 1024, however, since HIP RT intersection kernels
26 * use local memory, and the local memory size in those kernels scales up with the number of
27 * threads, the number of threads to is scaled down to 256 to avoid going over maximum local memory
28 * and to strike a balance between memory access and the number of waves.
29 *
30 * Total local stack size would be number of threads * HIPRT_SHARED_STACK_SIZE. */
31#define HIPRT_THREAD_GROUP_SIZE 256
37 hiprtSharedStackBuffer shared_stack;
38};
42/* This macro allocates shared memory and to pass the shared memory down to intersection functions
43 * KernelGlobals is used. */
44#define HIPRT_INIT_KERNEL_GLOBAL() \
45 ccl_gpu_shared int shared_stack[HIPRT_SHARED_STACK_SIZE * HIPRT_THREAD_GROUP_SIZE]; \
46 ccl_global KernelGlobalsGPU kg_gpu; \
47 KernelGlobals kg = &kg_gpu; \
48 kg->shared_stack.stackData = &shared_stack[0]; \
49 kg->shared_stack.stackSize = HIPRT_SHARED_STACK_SIZE; \
50 kg->global_stack_buffer = stack_buffer;
51
53 KernelData data;
54#define KERNEL_DATA_ARRAY(type, name) const type *name;
55 KERNEL_DATA_ARRAY(int, user_instance_id)
57 KERNEL_DATA_ARRAY(int2, custom_prim_info)
58 KERNEL_DATA_ARRAY(int2, custom_prim_info_offset)
60 KERNEL_DATA_ARRAY(int, prim_time_offset)
61#include "kernel/data_arrays.h"
63 /* Integrator state */
67 hiprtFuncTable table_shadow_intersect;
68 hiprtFuncTable table_local_intersect;
69 hiprtFuncTable table_volume_intersect;
70};
72/* Intersection_Function_Table_Index defines index values to retrieve custom intersection
73 * functions from function table. */
76 // Triangles use the intersection function provided by HIP RT and don't need custom intersection
77 // functions
78 // Custom intersection functions for closest intersect.
79 Curve_Intersect_Function = 1, // Custom intersection for curves
80 Motion_Triangle_Intersect_Function, // Custom intersection for triangles with vertex motion blur
81 // attributes.
82 Point_Intersect_Function, // Custom intersection for point cloud.
83 // Custom intersection functions for shadow rendering are the same as the function for closest
84 // intersect.
85 // However, the table indices are different
90 // Custom intersection functions for subsurface scattering.
91 // Only motion triangles have valid custom intersection function
96 // Custom intersection functions for volume rendering.
97 // Only motion triangles have valid custom intersection function
104// Filter functions, filter hits, i.e. test whether a hit should be accepted or not, and whether
105// traversal should stop or continue.
107 Triangle_Filter_Closest = 0, // Filter function for triangles for closest intersect, no custom
108 // intersection function is needed.
109 Curve_Filter_Opaque_None, // No filter function is needed and everything is handled in the
110 // intersection function.
111 Motion_Triangle_Filter_Opaque_None, // No filter function is needed and everything is handled in
112 // intersection function.
113 Point_Filter_Opaque_Non, // No filter function is needed.
114 // Filter function for all primitives for shadow intersection.
115 // All primitives use the same function but each has a different index in the table.
120 // Filter functions for subsurface scattering. Triangles and motion triangles need function
121 // assignment. They indices for triangles and motion triangles point to the same function. Points
122 // and curves dont need any function since subsurface scattering is not applied on either.
123 Triangle_Filter_Local, // Filter functions for triangles
124 Curve_Filter_Local_None, // Subsurface scattering is not applied on curves, no filter function
125 // is
126 // needed.
129 // Filter functions for volume rendering.
130 // Volume rendering only applies to triangles and motion triangles.
131 // Triangles and motion triangles use the same filter functions for volume rendering
138#ifdef __KERNEL_GPU__
139__constant__ KernelParamsHIPRT kernel_params;
141typedef hiprtGlobalStack Stack;
142typedef hiprtEmptyInstanceStack Instance_Stack;
143#endif
145/* Abstraction macros */
146#define kernel_data kernel_params.data
147#define kernel_data_fetch(name, index) kernel_params.name[(index)]
148#define kernel_data_array(name) (kernel_params.name)
149#define kernel_integrator_state kernel_params.integrator_state
unsigned long long int uint64_t
#define CCL_NAMESPACE_END
#define ccl_restrict
#define KERNEL_DATA_ARRAY(type, name)
Filter_Function_Table_Index
@ Curve_Filter_Local_None
@ Point_Filter_Opaque_Non
@ Motion_Triangle_Filter_Volume
@ Motion_Triangle_Filter_Local
@ Point_Filter_Local_None
@ Triangle_Filter_Closest
@ Curve_Filter_Volume_None
@ Curve_Filter_Shadow
@ Motion_Triangle_Filter_Opaque_None
@ Point_Filter_Volume_None
@ Motion_Triangle_Filter_Shadow
@ Curve_Filter_Opaque_None
@ Point_Filter_Shadow
@ Triangle_Filter_Local
@ Triangle_Filter_Volume
@ Triangle_Filter_Shadow
ccl_global KernelGlobalsGPU *ccl_restrict KernelGlobals
Intersection_Function_Table_Index
@ Motion_Triangle_Intersect_Shadow
@ Curve_Intersect_Local_None
@ Curve_Intersect_Function
@ Triangle_Intersect_Local_None
@ Point_Intersect_Volume_None
@ Motion_Triangle_Intersect_Function
@ Point_Intersect_Shadow
@ Curve_Intersect_Shadow
@ Triangle_Intersect_Volume_None
@ Point_Intersect_Function
@ Curve_Intersect_Volume_None
@ Motion_Triangle_Intersect_Volume
@ Motion_Triangle_Intersect_Local
@ Triangle_Intersect_Shadow_None
@ Point_Intersect_Local_None
#define ccl_global
hiprtSharedStackBuffer shared_stack
hiprtGlobalStackBuffer global_stack_buffer
hiprtFuncTable table_closest_intersect
hiprtFuncTable table_volume_intersect
hiprtFuncTable table_local_intersect
CCL_NAMESPACE_END IntegratorStateGPU integrator_state
hiprtFuncTable table_shadow_intersect