Blender V5.0
gpu_capabilities.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2005 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
11
12#include "DNA_userdef_types.h" /* For `U.glreslimit`. */
13
14#include "GPU_capabilities.hh"
15
17
19
20namespace blender::gpu {
21
23
24}
25
26using namespace blender::gpu;
27
28/* -------------------------------------------------------------------- */
31
33{
34 return GCaps.max_texture_size;
35}
36
38{
39 return GCaps.max_texture_3d_size;
40}
41
43{
44 return GCaps.max_buffer_texture_size;
45}
46
48{
50 int reslimit = (U.glreslimit != 0) ? min_ii(U.glreslimit, size) : size;
51 return min_ii(reslimit, res);
52}
53
54bool GPU_is_safe_texture_size(int width, int height)
55{
56 const int max_texture_size = GPU_max_texture_size();
57 return size_t(width) * height <= size_t(max_texture_size) * max_texture_size / 4;
58}
59
61{
62 return GCaps.max_texture_layers;
63}
64
66{
67 return GCaps.max_textures_vert;
68}
69
71{
72 return GCaps.max_textures_geom;
73}
74
76{
77 return GCaps.max_textures_frag;
78}
79
81{
82 return GCaps.max_textures;
83}
84
86{
87 return GCaps.max_images;
88}
89
91{
92 return GCaps.max_work_group_count[index];
93}
94
96{
97 return GCaps.max_work_group_size[index];
98}
99
101{
102 return GCaps.max_uniforms_vert;
103}
104
106{
107 return GCaps.max_uniforms_frag;
108}
109
111{
112 return GCaps.max_batch_indices;
113}
114
116{
117 return GCaps.max_batch_vertices;
118}
119
121{
122 return GCaps.max_vertex_attribs;
123}
124
126{
127 return GCaps.max_varying_floats;
128}
129
131{
132 return GCaps.extensions_len;
133}
134
135const char *GPU_extension_get(int i)
136{
137 return GCaps.extension_get ? GCaps.extension_get(i) : "\0";
138}
139
141{
142 return GCaps.max_samplers;
143}
144
146{
147 return GCaps.use_subprocess_shader_compilations;
148}
149
151{
152 return GCaps.max_parallel_compilations;
153}
154
156{
157 return GCaps.depth_blitting_workaround;
158}
159
161{
162 return GCaps.use_main_context_workaround;
163}
164
166{
167 return GCaps.use_hq_normals_workaround;
168}
169
171{
172 return GCaps.stencil_clasify_buffer_workaround;
173}
174
176{
177 return GCaps.geometry_shader_support;
178}
179
181{
182 return GCaps.hdr_viewport_support;
183}
184
186{
187 return GCaps.stencil_export_support;
188}
189
191{
192 return GCaps.max_shader_storage_buffer_bindings;
193}
194
196{
197 return GCaps.max_compute_shader_storage_blocks;
198}
199
201{
202 return GCaps.minimum_per_vertex_stride;
203}
204
206{
207 return GCaps.max_uniform_buffer_size;
208}
209
211{
212 return GCaps.max_storage_buffer_size;
213}
214
216{
217 return GCaps.storage_buffer_alignment;
218}
219
221
222/* -------------------------------------------------------------------- */
225
227{
228 return GCaps.mem_stats_support;
229}
230
231void GPU_mem_stats_get(int *r_totalmem, int *r_freemem)
232{
233 Context::get()->memory_statistics_get(r_totalmem, r_freemem);
234}
235
237{
238 return Context::get()->front_right != nullptr;
239}
240
242
243/* -------------------------------------------------------------------- */
246
248{
249 BLI_assert(GCaps.max_parallel_compilations == -1);
250 GCaps.max_parallel_compilations = count;
251}
252
#define BLI_assert(a)
Definition BLI_assert.h:46
MINLINE int min_ii(int a, int b)
#define U
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
static Context * get()
virtual void memory_statistics_get(int *r_total_mem, int *r_free_mem)=0
size_t GPU_max_uniform_buffer_size()
int GPU_max_batch_indices()
int GPU_minimum_per_vertex_stride()
int GPU_max_textures()
int GPU_max_samplers()
bool GPU_hdr_support()
int GPU_max_work_group_size(int index)
bool GPU_is_safe_texture_size(int width, int height)
int GPU_max_texture_3d_size()
int GPU_max_parallel_compilations()
int GPU_max_texture_layers()
void GPU_mem_stats_get(int *r_totalmem, int *r_freemem)
int GPU_max_images()
int GPU_max_uniforms_vert()
int GPU_max_shader_storage_buffer_bindings()
int GPU_texture_size_with_limit(int res)
bool GPU_geometry_shader_support()
bool GPU_depth_blitting_workaround()
int GPU_max_work_group_count(int index)
bool GPU_stencil_export_support()
bool GPU_mem_stats_supported()
bool GPU_stereo_quadbuffer_support()
int GPU_max_textures_geom()
bool GPU_use_main_context_workaround()
int GPU_max_textures_frag()
uint32_t GPU_max_buffer_texture_size()
bool GPU_use_subprocess_compilation()
size_t GPU_storage_buffer_alignment()
int GPU_max_vertex_attribs()
bool GPU_use_hq_normals_workaround()
const char * GPU_extension_get(int i)
size_t GPU_max_storage_buffer_size()
int GPU_max_varying_floats()
int GPU_max_compute_shader_storage_blocks()
int GPU_max_batch_vertices()
int GPU_extensions_len()
int GPU_max_uniforms_frag()
bool GPU_stencil_clasify_buffer_workaround()
int GPU_max_texture_size()
void GPU_compilation_subprocess_override_set(int count)
int GPU_max_textures_vert()
int count
GPUCapabilities GCaps
i
Definition text_draw.cc:230