i965: Move intel_context::upload to brw_context.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 3 Jul 2013 21:46:44 +0000 (14:46 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 9 Jul 2013 21:09:17 +0000 (14:09 -0700)
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Chris Forbes <chrisf@ijw.co.nz>
Acked-by: Paul Berry <stereotype441@gmail.com>
Acked-by: Anuj Phogat <anuj.phogat@gmail.com>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/intel_buffer_objects.c
src/mesa/drivers/dri/i965/intel_context.h

index ce639d731e308de916446bbb207f39cd2b51f27d..63775c738d49a613aec444b9a26d243849e4a923 100644 (file)
@@ -809,6 +809,14 @@ struct brw_context
    struct intel_batchbuffer batch;
    bool no_batch_wrap;
 
+   struct {
+      drm_intel_bo *bo;
+      GLuint offset;
+      uint32_t buffer_len;
+      uint32_t buffer_offset;
+      char buffer[4096];
+   } upload;
+
    /**
     * Set if rendering has occured to the drawable's front buffer.
     *
index 0fcb990d0fad9930ac087b1b9c53edd621fc2a8a..0b4782b894d1fd7d28d7c192d5728ae3888551aa 100644 (file)
@@ -422,32 +422,30 @@ intel_bufferobj_buffer(struct brw_context *brw,
 void
 intel_upload_finish(struct brw_context *brw)
 {
-   struct intel_context *intel = &brw->intel;
-   if (!intel->upload.bo)
+   if (!brw->upload.bo)
           return;
 
-   if (intel->upload.buffer_len) {
-          drm_intel_bo_subdata(intel->upload.bo,
-                               intel->upload.buffer_offset,
-                               intel->upload.buffer_len,
-                               intel->upload.buffer);
-          intel->upload.buffer_len = 0;
+   if (brw->upload.buffer_len) {
+          drm_intel_bo_subdata(brw->upload.bo,
+                               brw->upload.buffer_offset,
+                               brw->upload.buffer_len,
+                               brw->upload.buffer);
+          brw->upload.buffer_len = 0;
    }
 
-   drm_intel_bo_unreference(intel->upload.bo);
-   intel->upload.bo = NULL;
+   drm_intel_bo_unreference(brw->upload.bo);
+   brw->upload.bo = NULL;
 }
 
 static void wrap_buffers(struct brw_context *brw, GLuint size)
 {
-   struct intel_context *intel = &brw->intel;
    intel_upload_finish(brw);
 
    if (size < INTEL_UPLOAD_SIZE)
       size = INTEL_UPLOAD_SIZE;
 
-   intel->upload.bo = drm_intel_bo_alloc(brw->bufmgr, "upload", size, 0);
-   intel->upload.offset = 0;
+   brw->upload.bo = drm_intel_bo_alloc(brw->bufmgr, "upload", size, 0);
+   brw->upload.offset = 0;
 }
 
 void intel_upload_data(struct brw_context *brw,
@@ -455,79 +453,77 @@ void intel_upload_data(struct brw_context *brw,
                       drm_intel_bo **return_bo,
                       GLuint *return_offset)
 {
-   struct intel_context *intel = &brw->intel;
    GLuint base, delta;
 
-   base = (intel->upload.offset + align - 1) / align * align;
-   if (intel->upload.bo == NULL || base + size > intel->upload.bo->size) {
+   base = (brw->upload.offset + align - 1) / align * align;
+   if (brw->upload.bo == NULL || base + size > brw->upload.bo->size) {
       wrap_buffers(brw, size);
       base = 0;
    }
 
-   drm_intel_bo_reference(intel->upload.bo);
-   *return_bo = intel->upload.bo;
+   drm_intel_bo_reference(brw->upload.bo);
+   *return_bo = brw->upload.bo;
    *return_offset = base;
 
-   delta = base - intel->upload.offset;
-   if (intel->upload.buffer_len &&
-       intel->upload.buffer_len + delta + size > sizeof(intel->upload.buffer))
+   delta = base - brw->upload.offset;
+   if (brw->upload.buffer_len &&
+       brw->upload.buffer_len + delta + size > sizeof(brw->upload.buffer))
    {
-      drm_intel_bo_subdata(intel->upload.bo,
-                          intel->upload.buffer_offset,
-                          intel->upload.buffer_len,
-                          intel->upload.buffer);
-      intel->upload.buffer_len = 0;
+      drm_intel_bo_subdata(brw->upload.bo,
+                          brw->upload.buffer_offset,
+                          brw->upload.buffer_len,
+                          brw->upload.buffer);
+      brw->upload.buffer_len = 0;
    }
 
-   if (size < sizeof(intel->upload.buffer))
+   if (size < sizeof(brw->upload.buffer))
    {
-      if (intel->upload.buffer_len == 0)
-        intel->upload.buffer_offset = base;
+      if (brw->upload.buffer_len == 0)
+        brw->upload.buffer_offset = base;
       else
-        intel->upload.buffer_len += delta;
+        brw->upload.buffer_len += delta;
 
-      memcpy(intel->upload.buffer + intel->upload.buffer_len, ptr, size);
-      intel->upload.buffer_len += size;
+      memcpy(brw->upload.buffer + brw->upload.buffer_len, ptr, size);
+      brw->upload.buffer_len += size;
    }
    else
    {
-      drm_intel_bo_subdata(intel->upload.bo, base, size, ptr);
+      drm_intel_bo_subdata(brw->upload.bo, base, size, ptr);
    }
 
-   intel->upload.offset = base + size;
+   brw->upload.offset = base + size;
 }
 
 void *intel_upload_map(struct brw_context *brw, GLuint size, GLuint align)
 {
-   struct intel_context *intel = &brw->intel;
    GLuint base, delta;
    char *ptr;
 
-   base = (intel->upload.offset + align - 1) / align * align;
-   if (intel->upload.bo == NULL || base + size > intel->upload.bo->size) {
+   base = (brw->upload.offset + align - 1) / align * align;
+   if (brw->upload.bo == NULL || base + size > brw->upload.bo->size) {
       wrap_buffers(brw, size);
       base = 0;
    }
 
-   delta = base - intel->upload.offset;
-   if (intel->upload.buffer_len &&
-       intel->upload.buffer_len + delta + size > sizeof(intel->upload.buffer))
+   delta = base - brw->upload.offset;
+   if (brw->upload.buffer_len &&
+       brw->upload.buffer_len + delta + size > sizeof(brw->upload.buffer))
    {
-      drm_intel_bo_subdata(intel->upload.bo,
-                          intel->upload.buffer_offset,
-                          intel->upload.buffer_len,
-                          intel->upload.buffer);
-      intel->upload.buffer_len = 0;
+      drm_intel_bo_subdata(brw->upload.bo,
+                          brw->upload.buffer_offset,
+                          brw->upload.buffer_len,
+                          brw->upload.buffer);
+      brw->upload.buffer_len = 0;
    }
 
-   if (size <= sizeof(intel->upload.buffer)) {
-      if (intel->upload.buffer_len == 0)
-        intel->upload.buffer_offset = base;
+   if (size <= sizeof(brw->upload.buffer)) {
+      if (brw->upload.buffer_len == 0)
+        brw->upload.buffer_offset = base;
       else
-        intel->upload.buffer_len += delta;
+        brw->upload.buffer_len += delta;
 
-      ptr = intel->upload.buffer + intel->upload.buffer_len;
-      intel->upload.buffer_len += size;
+      ptr = brw->upload.buffer + brw->upload.buffer_len;
+      brw->upload.buffer_len += size;
    } else
       ptr = malloc(size);
 
@@ -539,20 +535,19 @@ void intel_upload_unmap(struct brw_context *brw,
                        drm_intel_bo **return_bo,
                        GLuint *return_offset)
 {
-   struct intel_context *intel = &brw->intel;
    GLuint base;
 
-   base = (intel->upload.offset + align - 1) / align * align;
-   if (size > sizeof(intel->upload.buffer)) {
-      drm_intel_bo_subdata(intel->upload.bo, base, size, ptr);
+   base = (brw->upload.offset + align - 1) / align * align;
+   if (size > sizeof(brw->upload.buffer)) {
+      drm_intel_bo_subdata(brw->upload.bo, base, size, ptr);
       free((void*)ptr);
    }
 
-   drm_intel_bo_reference(intel->upload.bo);
-   *return_bo = intel->upload.bo;
+   drm_intel_bo_reference(brw->upload.bo);
+   *return_bo = brw->upload.bo;
    *return_offset = base;
 
-   intel->upload.offset = base + size;
+   brw->upload.offset = base + size;
 }
 
 drm_intel_bo *
index ae0bc93d011e7e121c15002a2bbeec48f3354b0b..0ec15a73952ee319275922f18792d17c2d01b41e 100644 (file)
@@ -129,14 +129,6 @@ struct intel_context
    bool has_llc;
    bool has_swizzling;
 
-   struct {
-      drm_intel_bo *bo;
-      GLuint offset;
-      uint32_t buffer_len;
-      uint32_t buffer_offset;
-      char buffer[4096];
-   } upload;
-
    int driFd;
 
    __DRIcontext *driContext;