aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/main')
-rwxr-xr-x[-rw-r--r--]mesalib/src/mesa/main/bufferobj.c21
-rw-r--r--mesalib/src/mesa/main/bufferobj.h2
-rw-r--r--mesalib/src/mesa/main/dd.h2
-rw-r--r--mesalib/src/mesa/main/mtypes.h13
-rw-r--r--mesalib/src/mesa/main/shared.c2
-rw-r--r--mesalib/src/mesa/main/teximage.c6
6 files changed, 35 insertions, 11 deletions
diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c
index c29a8c777..c88744afb 100644..100755
--- a/mesalib/src/mesa/main/bufferobj.c
+++ b/mesalib/src/mesa/main/bufferobj.c
@@ -389,14 +389,14 @@ convert_clear_buffer_data(struct gl_context *ctx,
* Default callback for the \c dd_function_table::NewBufferObject() hook.
*/
struct gl_buffer_object *
-_mesa_new_buffer_object( struct gl_context *ctx, GLuint name, GLenum target )
+_mesa_new_buffer_object(struct gl_context *ctx, GLuint name)
{
struct gl_buffer_object *obj;
(void) ctx;
obj = MALLOC_STRUCT(gl_buffer_object);
- _mesa_initialize_buffer_object(ctx, obj, name, target);
+ _mesa_initialize_buffer_object(ctx, obj, name);
return obj;
}
@@ -494,12 +494,10 @@ _mesa_reference_buffer_object_(struct gl_context *ctx,
* Initialize a buffer object to default values.
*/
void
-_mesa_initialize_buffer_object( struct gl_context *ctx,
- struct gl_buffer_object *obj,
- GLuint name, GLenum target )
+_mesa_initialize_buffer_object(struct gl_context *ctx,
+ struct gl_buffer_object *obj,
+ GLuint name)
{
- (void) target;
-
memset(obj, 0, sizeof(struct gl_buffer_object));
mtx_init(&obj->Mutex, mtx_plain);
obj->RefCount = 1;
@@ -906,7 +904,7 @@ _mesa_handle_bind_buffer_gen(struct gl_context *ctx,
* never used before, allocate a buffer object now.
*/
ASSERT(ctx->Driver.NewBufferObject);
- buf = ctx->Driver.NewBufferObject(ctx, buffer, target);
+ buf = ctx->Driver.NewBufferObject(ctx, buffer);
if (!buf) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", caller);
return false;
@@ -2652,6 +2650,12 @@ set_ubo_binding(struct gl_context *ctx,
binding->Offset = offset;
binding->Size = size;
binding->AutomaticSize = autoSize;
+
+ /* If this is a real buffer object, mark it has having been used
+ * at some point as a UBO.
+ */
+ if (size >= 0)
+ bufObj->UsageHistory |= USAGE_UNIFORM_BUFFER;
}
/**
@@ -2764,6 +2768,7 @@ set_atomic_buffer_binding(struct gl_context *ctx,
} else {
binding->Offset = offset;
binding->Size = size;
+ bufObj->UsageHistory |= USAGE_ATOMIC_COUNTER_BUFFER;
}
}
diff --git a/mesalib/src/mesa/main/bufferobj.h b/mesalib/src/mesa/main/bufferobj.h
index 0779605c0..fe294fc0b 100644
--- a/mesalib/src/mesa/main/bufferobj.h
+++ b/mesalib/src/mesa/main/bufferobj.h
@@ -103,7 +103,7 @@ _mesa_multi_bind_lookup_bufferobj(struct gl_context *ctx,
extern void
_mesa_initialize_buffer_object(struct gl_context *ctx,
struct gl_buffer_object *obj,
- GLuint name, GLenum target);
+ GLuint name);
extern void
_mesa_reference_buffer_object_(struct gl_context *ctx,
diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h
index c130b14a5..c07e83ad9 100644
--- a/mesalib/src/mesa/main/dd.h
+++ b/mesalib/src/mesa/main/dd.h
@@ -602,7 +602,7 @@ struct dd_function_table {
*/
/*@{*/
struct gl_buffer_object * (*NewBufferObject)(struct gl_context *ctx,
- GLuint buffer, GLenum target);
+ GLuint buffer);
void (*DeleteBuffer)( struct gl_context *ctx, struct gl_buffer_object *obj );
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index 5e9453b2f..9f44edac6 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -1465,6 +1465,16 @@ struct gl_buffer_mapping {
/**
+ * Usages we've seen for a buffer object.
+ */
+typedef enum {
+ USAGE_UNIFORM_BUFFER = 0x1,
+ USAGE_TEXTURE_BUFFER = 0x2,
+ USAGE_ATOMIC_COUNTER_BUFFER = 0x4,
+} gl_buffer_usage;
+
+
+/**
* GL_ARB_vertex/pixel_buffer_object buffer object
*/
struct gl_buffer_object
@@ -1481,6 +1491,7 @@ struct gl_buffer_object
GLboolean Written; /**< Ever written to? (for debugging) */
GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
GLboolean Immutable; /**< GL_ARB_buffer_storage */
+ gl_buffer_usage UsageHistory; /**< How has this buffer been used so far? */
struct gl_buffer_mapping Mappings[MAP_COUNT];
};
@@ -4060,6 +4071,8 @@ struct gl_driver_flags
*/
uint64_t NewUniformBuffer;
+ uint64_t NewTextureBuffer;
+
/**
* gl_context::AtomicBufferBindings
*/
diff --git a/mesalib/src/mesa/main/shared.c b/mesalib/src/mesa/main/shared.c
index 7ef932ff0..f74a8232f 100644
--- a/mesalib/src/mesa/main/shared.c
+++ b/mesalib/src/mesa/main/shared.c
@@ -86,7 +86,7 @@ _mesa_alloc_shared_state(struct gl_context *ctx)
shared->SamplerObjects = _mesa_NewHashTable();
/* Allocate the default buffer object */
- shared->NullBufferObj = ctx->Driver.NewBufferObject(ctx, 0, 0);
+ shared->NullBufferObj = ctx->Driver.NewBufferObject(ctx, 0);
/* Create default texture objects */
for (i = 0; i < NUM_TEXTURE_TARGETS; i++) {
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index c0298af8e..4f4bb11dd 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -4652,6 +4652,12 @@ texbufferrange(struct gl_context *ctx, GLenum target, GLenum internalFormat,
texObj->BufferSize = size;
}
_mesa_unlock_texture(ctx, texObj);
+
+ ctx->NewDriverState |= ctx->DriverFlags.NewTextureBuffer;
+
+ if (bufObj) {
+ bufObj->UsageHistory |= USAGE_TEXTURE_BUFFER;
+ }
}