GPU: Add GPU_max_storage_buffer_size #113516

Merged
Miguel Pozo merged 2 commits from pragma37/blender:pull-caps-ssbo-size into main 2023-10-11 19:26:48 +02:00
8 changed files with 16 additions and 4 deletions

View File

@ -12,6 +12,8 @@
#pragma once
#include "BLI_sys_types.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -34,6 +36,7 @@ int GPU_max_varying_floats(void);
int GPU_max_shader_storage_buffer_bindings(void);
int GPU_max_compute_shader_storage_blocks(void);
int GPU_max_samplers(void);
size_t GPU_max_storage_buffer_size(void);
int GPU_extensions_len(void);
const char *GPU_extension_get(int i);

View File

@ -207,6 +207,11 @@ bool GPU_transform_feedback_support()
return GCaps.transform_feedback_support;
}
size_t GPU_max_storage_buffer_size()
{
return GCaps.max_storage_buffer_size;
}
/** \} */
/* -------------------------------------------------------------------- */

View File

@ -38,6 +38,7 @@ struct GPUCapabilities {
int max_varying_floats = 0;
int max_shader_storage_buffer_bindings = 0;
int max_compute_shader_storage_blocks = 0;
size_t max_storage_buffer_size = 0;
int extensions_len = 0;
const char *(*extension_get)(int);

View File

@ -436,6 +436,7 @@ void MTLBackend::capabilities_init(MTLContext *ctx)
/* Maximum buffer bindings: 31. Consider required slot for uniforms/UBOs/Vertex attributes.
* Can use argument buffers if a higher limit is required. */
GCaps.max_shader_storage_buffer_bindings = 14;
GCaps.max_storage_buffer_size = size_t(ctx->device.maxBufferLength);
if (GCaps.compute_shader_support) {
GCaps.max_work_group_count[0] = 65535;

View File

@ -469,7 +469,6 @@ GLint GLContext::max_cubemap_size = 0;
GLint GLContext::max_ubo_binds = 0;
GLint GLContext::max_ubo_size = 0;
GLint GLContext::max_ssbo_binds = 0;
GLint GLContext::max_ssbo_size = 0;
/** Extensions. */
@ -544,6 +543,9 @@ void GLBackend::capabilities_init()
glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS,
&GCaps.max_shader_storage_buffer_bindings);
glGetIntegerv(GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS, &GCaps.max_compute_shader_storage_blocks);
int64_t max_ssbo_size;
glGetInteger64v(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &max_ssbo_size);
GCaps.max_storage_buffer_size = size_t(max_ssbo_size);
}
GCaps.transform_feedback_support = true;
GCaps.texture_view_support = epoxy_gl_version() >= 43 ||
@ -562,7 +564,6 @@ void GLBackend::capabilities_init()
GLContext::max_ssbo_binds = min_ii(GLContext::max_ssbo_binds, max_ssbo_binds);
glGetIntegerv(GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS, &max_ssbo_binds);
GLContext::max_ssbo_binds = min_ii(GLContext::max_ssbo_binds, max_ssbo_binds);
glGetIntegerv(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &GLContext::max_ssbo_size);
GLContext::base_instance_support = epoxy_has_gl_extension("GL_ARB_base_instance");
GLContext::clear_texture_support = epoxy_has_gl_extension("GL_ARB_clear_texture");
GLContext::copy_image_support = epoxy_has_gl_extension("GL_ARB_copy_image");

View File

@ -43,7 +43,6 @@ class GLContext : public Context {
static GLint max_cubemap_size;
static GLint max_ubo_size;
static GLint max_ubo_binds;
static GLint max_ssbo_size;
static GLint max_ssbo_binds;
/** Extensions. */

View File

@ -8,6 +8,7 @@
#include "BLI_string.h"
#include "GPU_capabilities.h"
#include "gpu_backend.hh"
#include "gpu_context_private.hh"
@ -27,7 +28,7 @@ GLStorageBuf::GLStorageBuf(size_t size, GPUUsageType usage, const char *name)
{
usage_ = usage;
/* Do not create UBO GL buffer here to allow allocation from any thread. */
BLI_assert(size <= GLContext::max_ssbo_size);
BLI_assert(size <= GPU_max_storage_buffer_size());
}
GLStorageBuf::~GLStorageBuf()

View File

@ -251,6 +251,7 @@ void VKBackend::capabilities_init(VKDevice &device)
GCaps.max_varying_floats = limits.maxVertexOutputComponents;
GCaps.max_shader_storage_buffer_bindings = limits.maxPerStageDescriptorStorageBuffers;
GCaps.max_compute_shader_storage_blocks = limits.maxPerStageDescriptorStorageBuffers;
GCaps.max_storage_buffer_size = size_t(limits.maxStorageBufferRange);
detect_workarounds(device);
}