mesa: Add shader storage buffer support to struct gl_context

This includes the array of bindings, the current buffer bound to the
GL_SHADER_STORAGE_BUFFER target and a set of general limits and default
values for shader storage buffers.

v2:
- Use spec values for the new defined constants (Jordan)

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
This commit is contained in:
Iago Toral Quiroga 2015-03-19 10:15:30 +01:00 committed by Samuel Iglesias Gonsalvez
parent df89ed1591
commit cd50906e03
4 changed files with 51 additions and 0 deletions

View file

@ -112,6 +112,11 @@ get_buffer_target(struct gl_context *ctx, GLenum target)
return &ctx->UniformBuffer;
}
break;
case GL_SHADER_STORAGE_BUFFER:
if (ctx->Extensions.ARB_shader_storage_buffer_object) {
return &ctx->ShaderStorageBuffer;
}
break;
case GL_ATOMIC_COUNTER_BUFFER:
if (ctx->Extensions.ARB_shader_atomic_counters) {
return &ctx->AtomicBuffer;

View file

@ -171,8 +171,10 @@
#define MAX_PROGRAM_LOCAL_PARAMS 4096
#define MAX_UNIFORMS 4096
#define MAX_UNIFORM_BUFFERS 15 /* + 1 default uniform buffer */
#define MAX_SHADER_STORAGE_BUFFERS 7 /* + 1 default shader storage buffer */
/* 6 is for vertex, hull, domain, geometry, fragment, and compute shader. */
#define MAX_COMBINED_UNIFORM_BUFFERS (MAX_UNIFORM_BUFFERS * 6)
#define MAX_COMBINED_SHADER_STORAGE_BUFFERS (MAX_SHADER_STORAGE_BUFFERS * 6)
#define MAX_ATOMIC_COUNTERS 4096
/* 6 is for vertex, hull, domain, geometry, fragment, and compute shader. */
#define MAX_COMBINED_ATOMIC_BUFFERS (MAX_UNIFORM_BUFFERS * 6)

View file

@ -597,6 +597,12 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api)
consts->MaxUniformBlockSize = 16384;
consts->UniformBufferOffsetAlignment = 1;
/** GL_ARB_shader_storage_buffer_object */
consts->MaxCombinedShaderStorageBlocks = 8;
consts->MaxShaderStorageBufferBindings = 8;
consts->MaxShaderStorageBlockSize = 16 * 1024 * 1024;
consts->ShaderStorageBufferOffsetAlignment = 256;
/* GL_ARB_explicit_uniform_location, GL_MAX_UNIFORM_LOCATIONS */
consts->MaxUserAssignableUniformLocations =
4 * MESA_SHADER_STAGES * MAX_UNIFORMS;

View file

@ -3403,6 +3403,15 @@ struct gl_constants
GLuint UniformBufferOffsetAlignment;
/** @} */
/** @{
* GL_ARB_shader_storage_buffer_object
*/
GLuint MaxCombinedShaderStorageBlocks;
GLuint MaxShaderStorageBufferBindings;
GLuint MaxShaderStorageBlockSize;
GLuint ShaderStorageBufferOffsetAlignment;
/** @} */
/**
* GL_ARB_explicit_uniform_location
*/
@ -4049,6 +4058,20 @@ struct gl_uniform_buffer_binding
GLboolean AutomaticSize;
};
struct gl_shader_storage_buffer_binding
{
struct gl_buffer_object *BufferObject;
/** Start of shader storage block data in the buffer */
GLintptr Offset;
/** Size of data allowed to be referenced from the buffer (in bytes) */
GLsizeiptr Size;
/**
* glBindBufferBase() indicates that the Size should be ignored and only
* limited by the current size of the BufferObject.
*/
GLboolean AutomaticSize;
};
/**
* ARB_shader_image_load_store image unit.
*/
@ -4295,6 +4318,12 @@ struct gl_context
*/
struct gl_buffer_object *UniformBuffer;
/**
* Current GL_ARB_shader_storage_buffer_object binding referenced by
* GL_SHADER_STORAGE_BUFFER target for glBufferData, glMapBuffer, etc.
*/
struct gl_buffer_object *ShaderStorageBuffer;
/**
* Array of uniform buffers for GL_ARB_uniform_buffer_object and GL 3.1.
* This is set up using glBindBufferRange() or glBindBufferBase(). They are
@ -4304,6 +4333,15 @@ struct gl_context
struct gl_uniform_buffer_binding
UniformBufferBindings[MAX_COMBINED_UNIFORM_BUFFERS];
/**
* Array of shader storage buffers for ARB_shader_storage_buffer_object
* and GL 4.3. This is set up using glBindBufferRange() or
* glBindBufferBase(). They are associated with shader storage blocks by
* glShaderStorageBlockBinding()'s state in the shader program.
*/
struct gl_shader_storage_buffer_binding
ShaderStorageBufferBindings[MAX_COMBINED_SHADER_STORAGE_BUFFERS];
/**
* Object currently associated with the GL_ATOMIC_COUNTER_BUFFER
* target.