Blender V5.3
gpu_shader_cxx_attribute.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
14
15#pragma once
16
17#if !defined(_MSC_VER) || defined(__clang__)
18/* MSVC doesn't support using the same attribute multiple times (fixed in later versions).
19 * However, Clang in MSVC compatibility mode does. */
20
21/* Specify a function is a compute shader entry point. */
22# define compute maybe_unused
23/* Specify a function is a vertex shader entry point. */
24# define vertex maybe_unused
25/* Specify a function is a fragment shader entry point. */
26# define fragment maybe_unused
27/* Set compute shader workgroup size. */
28# define local_size(...) maybe_unused
29/* Request performing fragment tests before the fragment function executes. */
30# define early_fragment_tests maybe_unused
31/* Metal specific hints. To be used on entry point functions. */
32# define metal_max_total_threads_per_threadgroup(count) maybe_unused
33/* Enable shader patching on GL to remap clip range to 0..1. */
34# define clip_control maybe_unused
35/* Enable texture atomics on older versions of metal. */
36# define texture_atomic maybe_unused
37
38/* In a compute function, specify an input variable containing the 3-dimensional index of the local
39 * work invocation within the work group that the current shader is executing in. */
40# define local_invocation_id maybe_unused
41/* In a compute function, specify a derived input variable containing the 3-dimensional index of
42 * the work invocation within the global work group that the current shader is executing on. The
43 * value is equal to work_group_id * work_group_size + local_invocation_id. */
44# define global_invocation_id maybe_unused
45/* In a compute function, specify an 1-dimensional linearized index of the work invocation within
46 * the work group that the current shader is executing on. */
47# define local_invocation_index maybe_unused
48/* In a compute function, specify an input variable containing the 3-dimensional index of the
49 * global work group that the current compute shader invocation is executing within. */
50# define work_group_id maybe_unused
51/* In a compute function, specify an input variable containing the total number of work groups that
52 * will execute for the current compute shader dispatch. */
53# define num_work_groups maybe_unused
54
55/* Specify a vertex attribute. */
56# define attribute(slot) maybe_unused
57/* Vertex attribute interpolation modes. */
58# define flat maybe_unused
59# define smooth maybe_unused
60# define no_perspective maybe_unused
61
62/* Vertex shader output position. */
63# define position maybe_unused
64/* Vertex shader output point size. */
65# define point_size maybe_unused
66/* Vertex shader output, distance from vertex to clipping plane. */
67# define clip_distance maybe_unused
68/* The render target array index. */
69# define layer maybe_unused
70/* The viewport (and scissor rectangle) index value of the primitive. */
71# define viewport_index maybe_unused
72
73/* Vertex shader input vertex index, which includes the base vertex if one is specified. */
74# define vertex_id maybe_unused
75/* Vertex shader input instance index, which doesn't include the base instance. */
76# define instance_id maybe_unused
77/* Vertex shader input instance index, which includes the base instance if one is specified. */
78# define instance_index maybe_unused
79/* Vertex shader input base instance value added to each instance identifier before reading
80 * per-instance data. */
81# define base_instance maybe_unused
82
83# define frag_coord maybe_unused
84# define point_coord maybe_unused
85# define front_facing maybe_unused
86/* Builtin barycentric computation per triangle vertex.
87 * Might be emulated using geometry shaders on low-end devices. */
88# define bary_coord maybe_unused
89
90/* Fragment shader color input index for subpass input.
91 * `sampler_type` is the type of image to bind to this (e.g. usampler2DArray).
92 * It must be compatible with the frame-buffer attachment type. */
93# define subpass_input(index, sampler_type) maybe_unused
94
95/* Fragment shader output. */
96# define frag_color(slot) maybe_unused
97/* Fragment shader output. */
98# define frag_depth(mode) maybe_unused
99/* Fragment shader output. Set stencil reference value per pixel.
100 * Only supported on some platform. Check for compatibility first. */
101# define frag_stencil_ref maybe_unused
102/* Fragment shader color output index for dual source blending. */
103# define index(i) maybe_unused
104/* Fragment shader color output index for raster order group on Metal. */
105# define raster_order_group(i) maybe_unused
106
107/* Graphic pipeline stage in/out. */
108# define in maybe_unused
109# define out maybe_unused
110# define subpass_in maybe_unused
111
112/* Declare a dependency to a legacy create info whose name is the struct member name. */
113# define legacy_info maybe_unused
114/* Declare a sampler at the given slot. */
115# define sampler(slot) maybe_unused
116/* Declare a uniform buffer at the given slot. */
117# define uniform(slot) maybe_unused
118/* Declare a storage buffer at the given slot. */
119# define storage(slot, qualifiers) maybe_unused
120/* Declare a storage buffer at the given slot. */
121# define image(slot, qualifiers, format) maybe_unused
122/* Declare an acceleration structure at the given slot. */
123# define acceleration_structure(slot) maybe_unused
124# define compilation_constant maybe_unused
125# define specialization_constant(default_value) maybe_unused
126# define push_constant maybe_unused
127/* Declare a nested resource table member. */
128# define resource_table maybe_unused
129/* Only declare the member if cond evaluates to true. */
130# define condition(cond) maybe_unused
131/* Set binding frequency of a resource (storage, uniform, image, sampler). */
132# define frequency(freq) maybe_unused
133/* Allow to resize array at runtime using the given compilation constants.
134 * The array must be sized to its maximum size. */
135# define capacity(const) maybe_unused
136
137/* Make a structure layout or enum shared between CPU and GPU code.
138 * Required for structs defining storage and uniform buffer layout. */
139# define host_shared
140
142# define node maybe_unused
143
144/* Make the branch condition evaluate at compile time. */
145# define static_branch likely
146/* Unroll the loop at compile time. */
147# define unroll likely
152# define unroll_n(N) likely
153/* Force a function to be inlined during BSL compilation. */
154# define force_inline maybe_unused
155#else
156/* This path checks for unused variables. Disable warning about unknown attributes. */
157# if defined(__GNUC__) || defined(__clang__)
158# pragma GCC diagnostic push
159# pragma GCC diagnostic ignored "-Wattributes"
160# elif defined(_MSC_VER)
161# pragma warning(push)
162# pragma warning(disable : 5030)
163# pragma warning(disable : 5222)
164# endif
165#endif