[Mesa-dev] [PATCH 03/14] mesa: move _NEW_BUFFER_OBJECT flagging from BufferData to drivers

Marek Olšák maraeo at gmail.com
Mon Apr 15 06:17:28 PDT 2013


A driver doesn't have to set _NEW_BUFFER_OBJECT if it doesn't reallocate
the buffer from core Mesa's point of view, which avoids unnecessary state
validation.

Gallium drivers can be asked to reallocate a buffer privately by setting
PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE.

st/mesa doesn't set _NEW_BUFFER_OBJECT if transfer_inline_write is used.
---
 src/mesa/drivers/dri/intel/intel_buffer_objects.c   |    2 ++
 src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c    |    4 +++-
 src/mesa/drivers/dri/radeon/radeon_buffer_objects.c |    2 ++
 src/mesa/main/bufferobj.c                           |    4 +++-
 src/mesa/state_tracker/st_cb_bufferobjects.c        |    2 ++
 5 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
index e270db8..4499764 100644
--- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
@@ -128,6 +128,8 @@ intel_bufferobj_data(struct gl_context * ctx,
    (void) target;
 #endif
 
+   ctx->NewState |= _NEW_BUFFER_OBJECT;
+
    intel_obj->Base.Size = size;
    intel_obj->Base.Usage = usage;
 
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
index 717c0b8..2508933 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
@@ -79,7 +79,9 @@ nouveau_bufferobj_data(struct gl_context *ctx, GLenum target, GLsizeiptrARB size
 	struct nouveau_bufferobj *nbo = to_nouveau_bufferobj(obj);
 	int ret;
 
-	obj->Size = size;
+        ctx->NewState |= _NEW_BUFFER_OBJECT;
+
+        obj->Size = size;
 	obj->Usage = usage;
 
 	/* Free previous storage */
diff --git a/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c b/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c
index 5abc52b..c855224 100644
--- a/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c
+++ b/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c
@@ -92,6 +92,8 @@ radeonBufferData(struct gl_context * ctx,
     radeonContextPtr radeon = RADEON_CONTEXT(ctx);
     struct radeon_buffer_object *radeon_obj = get_radeon_buffer_object(obj);
 
+    ctx->NewState |= _NEW_BUFFER_OBJECT;
+
     radeon_obj->Base.Size = size;
     radeon_obj->Base.Usage = usage;
 
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index b82ba7b..32a69aa 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -413,6 +413,8 @@ _mesa_buffer_data( struct gl_context *ctx, GLenum target, GLsizeiptrARB size,
 
    (void) ctx; (void) target;
 
+   ctx->NewState |= _NEW_BUFFER_OBJECT;
+
    new_data = _mesa_realloc( bufObj->Data, bufObj->Size, size );
    if (new_data) {
       bufObj->Data = (GLubyte *) new_data;
@@ -1061,7 +1063,7 @@ _mesa_BufferData(GLenum target, GLsizeiptrARB size,
       ASSERT(bufObj->Pointer == NULL);
    }  
 
-   FLUSH_VERTICES(ctx, _NEW_BUFFER_OBJECT);
+   FLUSH_VERTICES(ctx, 0);
 
    bufObj->Written = GL_TRUE;
 
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
index 1b3991c..60df7cc 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -196,6 +196,8 @@ st_bufferobj_data(struct gl_context *ctx,
       return GL_TRUE;
    }
 
+   ctx->NewState |= _NEW_BUFFER_OBJECT;
+
    st_obj->Base.Size = size;
    st_obj->Base.Usage = usage;
    
-- 
1.7.10.4



More information about the mesa-dev mailing list