projects
/
mesa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mesa: add shader_storage_block_binding() helper
[mesa.git]
/
src
/
mesa
/
main
/
program_resource.c
diff --git
a/src/mesa/main/program_resource.c
b/src/mesa/main/program_resource.c
index b7e25fe38409fd891816615b2992c252f4db4cf0..4eacdfb9e9aeda6c09170220df369828799f102c 100644
(file)
--- a/
src/mesa/main/program_resource.c
+++ b/
src/mesa/main/program_resource.c
@@
-30,7
+30,7
@@
#include "main/shaderobj.h"
#include "main/context.h"
#include "program_resource.h"
#include "main/shaderobj.h"
#include "main/context.h"
#include "program_resource.h"
-#include "ir_uniform.h"
+#include "
compiler/glsl/
ir_uniform.h"
static bool
supported_interface_enum(struct gl_context *ctx, GLenum iface)
{
static bool
supported_interface_enum(struct gl_context *ctx, GLenum iface)
{
@@
-39,6
+39,7
@@
supported_interface_enum(struct gl_context *ctx, GLenum iface)
case GL_UNIFORM_BLOCK:
case GL_PROGRAM_INPUT:
case GL_PROGRAM_OUTPUT:
case GL_UNIFORM_BLOCK:
case GL_PROGRAM_INPUT:
case GL_PROGRAM_OUTPUT:
+ case GL_TRANSFORM_FEEDBACK_BUFFER:
case GL_TRANSFORM_FEEDBACK_VARYING:
case GL_ATOMIC_COUNTER_BUFFER:
case GL_BUFFER_VARIABLE:
case GL_TRANSFORM_FEEDBACK_VARYING:
case GL_ATOMIC_COUNTER_BUFFER:
case GL_BUFFER_VARIABLE:
@@
-48,28
+49,53
@@
supported_interface_enum(struct gl_context *ctx, GLenum iface)
case GL_FRAGMENT_SUBROUTINE:
case GL_VERTEX_SUBROUTINE_UNIFORM:
case GL_FRAGMENT_SUBROUTINE_UNIFORM:
case GL_FRAGMENT_SUBROUTINE:
case GL_VERTEX_SUBROUTINE_UNIFORM:
case GL_FRAGMENT_SUBROUTINE_UNIFORM:
- return _mesa_has_shader_subroutine(ctx);
+ return _mesa_has_
ARB_
shader_subroutine(ctx);
case GL_GEOMETRY_SUBROUTINE:
case GL_GEOMETRY_SUBROUTINE_UNIFORM:
case GL_GEOMETRY_SUBROUTINE:
case GL_GEOMETRY_SUBROUTINE_UNIFORM:
- return _mesa_has_geometry_shaders(ctx) && _mesa_has_shader_subroutine(ctx);
+ return _mesa_has_geometry_shaders(ctx) && _mesa_has_
ARB_
shader_subroutine(ctx);
case GL_COMPUTE_SUBROUTINE:
case GL_COMPUTE_SUBROUTINE_UNIFORM:
case GL_COMPUTE_SUBROUTINE:
case GL_COMPUTE_SUBROUTINE_UNIFORM:
- return _mesa_has_compute_shaders(ctx) && _mesa_has_shader_subroutine(ctx);
+ return _mesa_has_compute_shaders(ctx) && _mesa_has_
ARB_
shader_subroutine(ctx);
case GL_TESS_CONTROL_SUBROUTINE:
case GL_TESS_EVALUATION_SUBROUTINE:
case GL_TESS_CONTROL_SUBROUTINE_UNIFORM:
case GL_TESS_EVALUATION_SUBROUTINE_UNIFORM:
case GL_TESS_CONTROL_SUBROUTINE:
case GL_TESS_EVALUATION_SUBROUTINE:
case GL_TESS_CONTROL_SUBROUTINE_UNIFORM:
case GL_TESS_EVALUATION_SUBROUTINE_UNIFORM:
- return _mesa_has_tessellation(ctx) && _mesa_has_shader_subroutine(ctx);
+ return _mesa_has_tessellation(ctx) && _mesa_has_
ARB_
shader_subroutine(ctx);
default:
return false;
}
}
default:
return false;
}
}
+static struct gl_shader_program *
+lookup_linked_program(GLuint program, const char *caller)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_shader_program *prog =
+ _mesa_lookup_shader_program_err(ctx, program, caller);
+
+ if (!prog)
+ return NULL;
+
+ if (prog->data->LinkStatus == linking_failure) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(program not linked)",
+ caller);
+ return NULL;
+ }
+ return prog;
+}
+
void GLAPIENTRY
_mesa_GetProgramInterfaceiv(GLuint program, GLenum programInterface,
GLenum pname, GLint *params)
{
GET_CURRENT_CONTEXT(ctx);
void GLAPIENTRY
_mesa_GetProgramInterfaceiv(GLuint program, GLenum programInterface,
GLenum pname, GLint *params)
{
GET_CURRENT_CONTEXT(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API) {
+ _mesa_debug(ctx, "glGetProgramInterfaceiv(%u, %s, %s, %p)\n",
+ program, _mesa_enum_to_string(programInterface),
+ _mesa_enum_to_string(pname), params);
+ }
+
unsigned i;
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program,
unsigned i;
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program,
@@
-93,12
+119,13
@@
_mesa_GetProgramInterfaceiv(GLuint program, GLenum programInterface,
/* Validate pname against interface. */
switch(pname) {
case GL_ACTIVE_RESOURCES:
/* Validate pname against interface. */
switch(pname) {
case GL_ACTIVE_RESOURCES:
- for (i = 0, *params = 0; i < shProg->NumProgramResourceList; i++)
- if (shProg->ProgramResourceList[i].Type == programInterface)
+ for (i = 0, *params = 0; i < shProg->
data->
NumProgramResourceList; i++)
+ if (shProg->
data->
ProgramResourceList[i].Type == programInterface)
(*params)++;
break;
case GL_MAX_NAME_LENGTH:
(*params)++;
break;
case GL_MAX_NAME_LENGTH:
- if (programInterface == GL_ATOMIC_COUNTER_BUFFER) {
+ if (programInterface == GL_ATOMIC_COUNTER_BUFFER ||
+ programInterface == GL_TRANSFORM_FEEDBACK_BUFFER) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetProgramInterfaceiv(%s pname %s)",
_mesa_enum_to_string(programInterface),
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetProgramInterfaceiv(%s pname %s)",
_mesa_enum_to_string(programInterface),
@@
-108,32
+135,32
@@
_mesa_GetProgramInterfaceiv(GLuint program, GLenum programInterface,
/* Name length consists of base name, 3 additional chars '[0]' if
* resource is an array and finally 1 char for string terminator.
*/
/* Name length consists of base name, 3 additional chars '[0]' if
* resource is an array and finally 1 char for string terminator.
*/
- for (i = 0, *params = 0; i < shProg->NumProgramResourceList; i++) {
- if (shProg->ProgramResourceList[i].Type != programInterface)
+ for (i = 0, *params = 0; i < shProg->
data->
NumProgramResourceList; i++) {
+ if (shProg->
data->
ProgramResourceList[i].Type != programInterface)
continue;
unsigned len =
continue;
unsigned len =
- _mesa_program_resource_name_len(&shProg->ProgramResourceList[i]);
+ _mesa_program_resource_name_len(&shProg->
data->
ProgramResourceList[i]);
*params = MAX2(*params, len + 1);
}
break;
case GL_MAX_NUM_ACTIVE_VARIABLES:
switch (programInterface) {
case GL_UNIFORM_BLOCK:
*params = MAX2(*params, len + 1);
}
break;
case GL_MAX_NUM_ACTIVE_VARIABLES:
switch (programInterface) {
case GL_UNIFORM_BLOCK:
- for (i = 0, *params = 0; i < shProg->NumProgramResourceList; i++) {
- if (shProg->ProgramResourceList[i].Type == programInterface) {
+ for (i = 0, *params = 0; i < shProg->
data->
NumProgramResourceList; i++) {
+ if (shProg->
data->
ProgramResourceList[i].Type == programInterface) {
struct gl_uniform_block *block =
(struct gl_uniform_block *)
struct gl_uniform_block *block =
(struct gl_uniform_block *)
- shProg->ProgramResourceList[i].Data;
+ shProg->
data->
ProgramResourceList[i].Data;
*params = MAX2(*params, block->NumUniforms);
}
}
break;
case GL_SHADER_STORAGE_BLOCK:
*params = MAX2(*params, block->NumUniforms);
}
}
break;
case GL_SHADER_STORAGE_BLOCK:
- for (i = 0, *params = 0; i < shProg->NumProgramResourceList; i++) {
- if (shProg->ProgramResourceList[i].Type == programInterface) {
+ for (i = 0, *params = 0; i < shProg->
data->
NumProgramResourceList; i++) {
+ if (shProg->
data->
ProgramResourceList[i].Type == programInterface) {
struct gl_uniform_block *block =
(struct gl_uniform_block *)
struct gl_uniform_block *block =
(struct gl_uniform_block *)
- shProg->ProgramResourceList[i].Data;
+ shProg->
data->
ProgramResourceList[i].Data;
GLint block_params = 0;
for (unsigned j = 0; j < block->NumUniforms; j++) {
const char *iname = block->Uniforms[j].IndexName;
GLint block_params = 0;
for (unsigned j = 0; j < block->NumUniforms; j++) {
const char *iname = block->Uniforms[j].IndexName;
@@
-149,15
+176,25
@@
_mesa_GetProgramInterfaceiv(GLuint program, GLenum programInterface,
}
break;
case GL_ATOMIC_COUNTER_BUFFER:
}
break;
case GL_ATOMIC_COUNTER_BUFFER:
- for (i = 0, *params = 0; i < shProg->NumProgramResourceList; i++) {
- if (shProg->ProgramResourceList[i].Type == programInterface) {
+ for (i = 0, *params = 0; i < shProg->
data->
NumProgramResourceList; i++) {
+ if (shProg->
data->
ProgramResourceList[i].Type == programInterface) {
struct gl_active_atomic_buffer *buffer =
(struct gl_active_atomic_buffer *)
struct gl_active_atomic_buffer *buffer =
(struct gl_active_atomic_buffer *)
- shProg->ProgramResourceList[i].Data;
+ shProg->
data->
ProgramResourceList[i].Data;
*params = MAX2(*params, buffer->NumUniforms);
}
}
break;
*params = MAX2(*params, buffer->NumUniforms);
}
}
break;
+ case GL_TRANSFORM_FEEDBACK_BUFFER:
+ for (i = 0, *params = 0; i < shProg->data->NumProgramResourceList; i++) {
+ if (shProg->data->ProgramResourceList[i].Type == programInterface) {
+ struct gl_transform_feedback_buffer *buffer =
+ (struct gl_transform_feedback_buffer *)
+ shProg->data->ProgramResourceList[i].Data;
+ *params = MAX2(*params, buffer->NumVaryings);
+ }
+ }
+ break;
default:
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetProgramInterfaceiv(%s pname %s)",
default:
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetProgramInterfaceiv(%s pname %s)",
@@
-173,11
+210,11
@@
_mesa_GetProgramInterfaceiv(GLuint program, GLenum programInterface,
case GL_COMPUTE_SUBROUTINE_UNIFORM:
case GL_TESS_CONTROL_SUBROUTINE_UNIFORM:
case GL_TESS_EVALUATION_SUBROUTINE_UNIFORM: {
case GL_COMPUTE_SUBROUTINE_UNIFORM:
case GL_TESS_CONTROL_SUBROUTINE_UNIFORM:
case GL_TESS_EVALUATION_SUBROUTINE_UNIFORM: {
- for (i = 0, *params = 0; i < shProg->NumProgramResourceList; i++) {
- if (shProg->ProgramResourceList[i].Type == programInterface) {
+ for (i = 0, *params = 0; i < shProg->
data->
NumProgramResourceList; i++) {
+ if (shProg->
data->
ProgramResourceList[i].Type == programInterface) {
struct gl_uniform_storage *uni =
(struct gl_uniform_storage *)
struct gl_uniform_storage *uni =
(struct gl_uniform_storage *)
- shProg->ProgramResourceList[i].Data;
+ shProg->
data->
ProgramResourceList[i].Data;
*params = MAX2(*params, uni->num_compatible_subroutines);
}
}
*params = MAX2(*params, uni->num_compatible_subroutines);
}
}
@@
-226,6
+263,12
@@
_mesa_GetProgramResourceIndex(GLuint program, GLenum programInterface,
const GLchar *name)
{
GET_CURRENT_CONTEXT(ctx);
const GLchar *name)
{
GET_CURRENT_CONTEXT(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API) {
+ _mesa_debug(ctx, "glGetProgramResourceIndex(%u, %s, %s)\n",
+ program, _mesa_enum_to_string(programInterface), name);
+ }
+
unsigned array_index = 0;
struct gl_program_resource *res;
struct gl_shader_program *shProg =
unsigned array_index = 0;
struct gl_program_resource *res;
struct gl_shader_program *shProg =
@@
-276,6
+319,7
@@
_mesa_GetProgramResourceIndex(GLuint program, GLenum programInterface,
return _mesa_program_resource_index(shProg, res);
case GL_ATOMIC_COUNTER_BUFFER:
return _mesa_program_resource_index(shProg, res);
case GL_ATOMIC_COUNTER_BUFFER:
+ case GL_TRANSFORM_FEEDBACK_BUFFER:
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramResourceIndex(%s)",
_mesa_enum_to_string(programInterface));
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramResourceIndex(%s)",
_mesa_enum_to_string(programInterface));
@@
-290,6
+334,13
@@
_mesa_GetProgramResourceName(GLuint program, GLenum programInterface,
GLchar *name)
{
GET_CURRENT_CONTEXT(ctx);
GLchar *name)
{
GET_CURRENT_CONTEXT(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API) {
+ _mesa_debug(ctx, "glGetProgramResourceName(%u, %s, %u, %d, %p, %p)\n",
+ program, _mesa_enum_to_string(programInterface), index,
+ bufSize, length, name);
+ }
+
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program,
"glGetProgramResourceName");
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program,
"glGetProgramResourceName");
@@
-298,6
+349,7
@@
_mesa_GetProgramResourceName(GLuint program, GLenum programInterface,
return;
if (programInterface == GL_ATOMIC_COUNTER_BUFFER ||
return;
if (programInterface == GL_ATOMIC_COUNTER_BUFFER ||
+ programInterface == GL_TRANSFORM_FEEDBACK_BUFFER ||
!supported_interface_enum(ctx, programInterface)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramResourceName(%s)",
_mesa_enum_to_string(programInterface));
!supported_interface_enum(ctx, programInterface)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramResourceName(%s)",
_mesa_enum_to_string(programInterface));
@@
-315,6
+367,13
@@
_mesa_GetProgramResourceiv(GLuint program, GLenum programInterface,
GLsizei *length, GLint *params)
{
GET_CURRENT_CONTEXT(ctx);
GLsizei *length, GLint *params)
{
GET_CURRENT_CONTEXT(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API) {
+ _mesa_debug(ctx, "glGetProgramResourceiv(%u, %s, %u, %d, %p, %d, %p, %p)\n",
+ program, _mesa_enum_to_string(programInterface), index,
+ propCount, props, bufSize, length, params);
+ }
+
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program, "glGetProgramResourceiv");
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program, "glGetProgramResourceiv");
@@
-330,37
+389,21
@@
_mesa_GetProgramResourceiv(GLuint program, GLenum programInterface,
return;
}
return;
}
- /* No need to write any properties, user requested none. */
- if (bufSize == 0)
- return;
-
_mesa_get_program_resourceiv(shProg, programInterface, index,
propCount, props, bufSize, length, params);
}
_mesa_get_program_resourceiv(shProg, programInterface, index,
propCount, props, bufSize, length, params);
}
-static struct gl_shader_program *
-lookup_linked_program(GLuint program, const char *caller)
-{
- GET_CURRENT_CONTEXT(ctx);
- struct gl_shader_program *prog =
- _mesa_lookup_shader_program_err(ctx, program, caller);
-
- if (!prog)
- return NULL;
-
- if (prog->LinkStatus == GL_FALSE) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "%s(program not linked)",
- caller);
- return NULL;
- }
- return prog;
-}
-
GLint GLAPIENTRY
_mesa_GetProgramResourceLocation(GLuint program, GLenum programInterface,
const GLchar *name)
{
GET_CURRENT_CONTEXT(ctx);
GLint GLAPIENTRY
_mesa_GetProgramResourceLocation(GLuint program, GLenum programInterface,
const GLchar *name)
{
GET_CURRENT_CONTEXT(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API) {
+ _mesa_debug(ctx, "glGetProgramResourceLocation(%u, %s, %s)\n",
+ program, _mesa_enum_to_string(programInterface), name);
+ }
+
struct gl_shader_program *shProg =
lookup_linked_program(program, "glGetProgramResourceLocation");
struct gl_shader_program *shProg =
lookup_linked_program(program, "glGetProgramResourceLocation");
@@
-376,20
+419,20
@@
_mesa_GetProgramResourceLocation(GLuint program, GLenum programInterface,
case GL_VERTEX_SUBROUTINE_UNIFORM:
case GL_FRAGMENT_SUBROUTINE_UNIFORM:
case GL_VERTEX_SUBROUTINE_UNIFORM:
case GL_FRAGMENT_SUBROUTINE_UNIFORM:
- if (!_mesa_has_shader_subroutine(ctx))
+ if (!_mesa_has_
ARB_
shader_subroutine(ctx))
goto fail;
break;
case GL_GEOMETRY_SUBROUTINE_UNIFORM:
goto fail;
break;
case GL_GEOMETRY_SUBROUTINE_UNIFORM:
- if (!_mesa_has_geometry_shaders(ctx) || !_mesa_has_shader_subroutine(ctx))
+ if (!_mesa_has_geometry_shaders(ctx) || !_mesa_has_
ARB_
shader_subroutine(ctx))
goto fail;
break;
case GL_COMPUTE_SUBROUTINE_UNIFORM:
goto fail;
break;
case GL_COMPUTE_SUBROUTINE_UNIFORM:
- if (!_mesa_has_compute_shaders(ctx) || !_mesa_has_shader_subroutine(ctx))
+ if (!_mesa_has_compute_shaders(ctx) || !_mesa_has_
ARB_
shader_subroutine(ctx))
goto fail;
break;
case GL_TESS_CONTROL_SUBROUTINE_UNIFORM:
case GL_TESS_EVALUATION_SUBROUTINE_UNIFORM:
goto fail;
break;
case GL_TESS_CONTROL_SUBROUTINE_UNIFORM:
case GL_TESS_EVALUATION_SUBROUTINE_UNIFORM:
- if (!_mesa_has_tessellation(ctx) || !_mesa_has_shader_subroutine(ctx))
+ if (!_mesa_has_tessellation(ctx) || !_mesa_has_
ARB_
shader_subroutine(ctx))
goto fail;
break;
default:
goto fail;
break;
default:
@@
-411,6
+454,12
@@
_mesa_GetProgramResourceLocationIndex(GLuint program, GLenum programInterface,
const GLchar *name)
{
GET_CURRENT_CONTEXT(ctx);
const GLchar *name)
{
GET_CURRENT_CONTEXT(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API) {
+ _mesa_debug(ctx, "glGetProgramResourceLocationIndex(%u, %s, %s)\n",
+ program, _mesa_enum_to_string(programInterface), name);
+ }
+
struct gl_shader_program *shProg =
lookup_linked_program(program, "glGetProgramResourceLocationIndex");
struct gl_shader_program *shProg =
lookup_linked_program(program, "glGetProgramResourceLocationIndex");