GPU: Add maximum image units to GPU capabilities

This patch adds the maximum number of supported image units to the GPU
capabilities module. Currently, the GPU module assume a maximum of 8
units, so the patch is not currently particularly useful, but we can
consider committing it for the future anyways.

Pull Request: https://projects.blender.org/blender/blender/pulls/119057
This commit is contained in:
Omar Emara 2024-03-05 07:25:20 +01:00 committed by Omar Emara
parent d27ddccc60
commit eb91828aab
8 changed files with 27 additions and 0 deletions

@ -208,6 +208,7 @@ def write_sysinfo(filepath):
output.write("Maximum Vertex Image Units:\t%d\n" % gpu.capabilities.max_textures_vert_get())
output.write("Maximum Fragment Image Units:\t%d\n" % gpu.capabilities.max_textures_frag_get())
output.write("Maximum Pipeline Image Units:\t%d\n" % gpu.capabilities.max_textures_get())
output.write("Maximum Image Units:\t%d\n" % gpu.capabilities.max_images_get())
output.write("\nFeatures:\n")
output.write("Compute Shader Support: \t%d\n" %

@ -25,6 +25,7 @@ int GPU_max_textures(void);
int GPU_max_textures_vert(void);
int GPU_max_textures_geom(void);
int GPU_max_textures_frag(void);
int GPU_max_images(void);
int GPU_max_work_group_count(int index);
int GPU_max_work_group_size(int index);
int GPU_max_uniforms_vert(void);

@ -71,6 +71,11 @@ int GPU_max_textures()
return GCaps.max_textures;
}
int GPU_max_images()
{
return GCaps.max_images;
}
int GPU_max_work_group_count(int index)
{
return GCaps.max_work_group_count[index];

@ -28,6 +28,7 @@ struct GPUCapabilities {
int max_textures_geom = 0;
int max_textures_frag = 0;
int max_samplers = 0;
int max_images = 0;
int max_work_group_count[3] = {0, 0, 0};
int max_work_group_size[3] = {0, 0, 0};
int max_uniforms_vert = 0;

@ -413,6 +413,8 @@ void MTLBackend::capabilities_init(MTLContext *ctx)
GCaps.max_textures_geom = 0; /* N/A geometry shaders not supported. */
GCaps.max_textures_frag = GCaps.max_textures;
GCaps.max_images = GCaps.max_textures;
/* Conservative uniform data limit is 4KB per-stage -- This is the limit of setBytes.
* MTLBuffer path is also supported but not as efficient. */
GCaps.max_uniforms_vert = 1024;

@ -513,6 +513,7 @@ void GLBackend::capabilities_init()
glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &GCaps.max_batch_vertices);
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &GCaps.max_vertex_attribs);
glGetIntegerv(GL_MAX_VARYING_FLOATS, &GCaps.max_varying_floats);
glGetIntegerv(GL_MAX_IMAGE_UNITS, &GCaps.max_images);
glGetIntegerv(GL_NUM_EXTENSIONS, &GCaps.extensions_len);
GCaps.extension_get = gl_extension_get;

@ -263,6 +263,7 @@ void VKBackend::capabilities_init(VKDevice &device)
GCaps.max_textures_geom = limits.maxPerStageDescriptorSampledImages;
GCaps.max_textures_frag = limits.maxPerStageDescriptorSampledImages;
GCaps.max_samplers = limits.maxSamplerAllocationCount;
GCaps.max_images = limits.maxPerStageDescriptorStorageImages;
for (int i = 0; i < 3; i++) {
GCaps.max_work_group_count[i] = limits.maxComputeWorkGroupCount[i];
GCaps.max_work_group_size[i] = limits.maxComputeWorkGroupSize[i];

@ -111,6 +111,20 @@ static PyObject *pygpu_max_textures_frag_get(PyObject * /*self*/)
return PyLong_FromLong(GPU_max_textures_frag());
}
PyDoc_STRVAR(
/* Wrap. */
pygpu_max_images_get_doc,
".. function:: max_images_get()\n"
"\n"
" Get maximum supported number of image units.\n"
"\n"
" :return: Number of image units.\n"
" :rtype: int\n");
static PyObject *pygpu_max_images_get(PyObject * /*self*/)
{
return PyLong_FromLong(GPU_max_images());
}
PyDoc_STRVAR(
/* Wrap. */
pygpu_max_uniforms_vert_get_doc,
@ -345,6 +359,7 @@ static PyMethodDef pygpu_capabilities__tp_methods[] = {
(PyCFunction)pygpu_max_textures_frag_get,
METH_NOARGS,
pygpu_max_textures_frag_get_doc},
{"max_images_get", (PyCFunction)pygpu_max_images_get, METH_NOARGS, pygpu_max_images_get_doc},
{"max_uniforms_vert_get",
(PyCFunction)pygpu_max_uniforms_vert_get,
METH_NOARGS,