GPU capabilities: detect max SSBO bindings

This adds detection of the maximum number of shader storage buffer
bindings that is supported on the current platform. This can be
useful to turn off features that require compute shaders but use
more buffer bindings than available.

Differential Revision: https://developer.blender.org/D14337
This commit is contained in:
Kévin Dietrich 2022-03-15 16:04:41 +01:00
parent e08180fdab
commit 45b637e1e7
4 changed files with 9 additions and 0 deletions

View File

@ -29,6 +29,7 @@ int GPU_max_batch_indices(void);
int GPU_max_batch_vertices(void);
int GPU_max_vertex_attribs(void);
int GPU_max_varying_floats(void);
int GPU_max_shader_storage_buffer_bindings(void);
int GPU_extensions_len(void);
const char *GPU_extension_get(int i);

View File

@ -157,6 +157,11 @@ bool GPU_shader_image_load_store_support()
return GCaps.shader_image_load_store_support;
}
int GPU_max_shader_storage_buffer_bindings()
{
return GCaps.max_shader_storage_buffer_bindings;
}
/** \} */
/* -------------------------------------------------------------------- */

View File

@ -33,6 +33,7 @@ struct GPUCapabilities {
int max_batch_vertices = 0;
int max_vertex_attribs = 0;
int max_varying_floats = 0;
int max_shader_storage_buffer_bindings = 0;
int extensions_len = 0;
const char *(*extension_get)(int);

View File

@ -485,6 +485,8 @@ void GLBackend::capabilities_init()
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 0, &GCaps.max_work_group_size[0]);
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 1, &GCaps.max_work_group_size[1]);
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 2, &GCaps.max_work_group_size[2]);
glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS,
&GCaps.max_shader_storage_buffer_bindings);
}
GCaps.shader_storage_buffer_objects_support = GLEW_ARB_shader_storage_buffer_object;
/* GL specific capabilities. */