Module: Mesa
Branch: master
Commit: 4b8f4e7ce17aeaa7fba1140897ab66f74d715b0a
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4b8f4e7ce17aeaa7fba1140897ab66f74d715b0a

Author: Eric Anholt <[email protected]>
Date:   Mon Oct 17 10:18:30 2011 -0700

nouveau: Add implementation of MapRenderbuffer.

Perhaps the easiest implementation, nouveau can directly map buffers
even if tiled, and uses separate surfaces for its texture
renderbuffers so we don't have to worry about that offset.

Reviewed-by: Brian Paul <[email protected]>

---

 src/mesa/drivers/dri/nouveau/nouveau_fbo.c |   46 ++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c 
b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
index b36b578..d56e954 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
@@ -133,6 +133,50 @@ nouveau_renderbuffer_new(struct gl_context *ctx, GLuint 
name)
        return rb;
 }
 
+static void
+nouveau_renderbuffer_map(struct gl_context *ctx,
+                        struct gl_renderbuffer *rb,
+                        GLuint x, GLuint y, GLuint w, GLuint h,
+                        GLbitfield mode,
+                        GLubyte **out_map,
+                        GLint *out_stride)
+{
+       struct nouveau_surface *s = &to_nouveau_renderbuffer(rb)->surface;
+       GLubyte *map;
+       int stride;
+       int flags = 0;
+
+       if (mode & GL_MAP_READ_BIT)
+               flags |= NOUVEAU_BO_RD;
+       if (mode & GL_MAP_WRITE_BIT)
+               flags |= NOUVEAU_BO_WR;
+
+       nouveau_bo_map(s->bo, flags);
+
+       map = s->bo->map;
+       stride = s->pitch;
+
+       if (rb->Name == 0) {
+               map += stride * (rb->Height - 1);
+               stride = -stride;
+       }
+
+       map += x * s->cpp;
+       map += (int)y * stride;
+
+       *out_map = map;
+       *out_stride = stride;
+}
+
+static void
+nouveau_renderbuffer_unmap(struct gl_context *ctx,
+                          struct gl_renderbuffer *rb)
+{
+       struct nouveau_surface *s = &to_nouveau_renderbuffer(rb)->surface;
+
+       nouveau_bo_unmap(s->bo);
+}
+
 static GLboolean
 nouveau_renderbuffer_dri_storage(struct gl_context *ctx, struct 
gl_renderbuffer *rb,
                                 GLenum internalFormat,
@@ -268,6 +312,8 @@ nouveau_fbo_functions_init(struct dd_function_table 
*functions)
 #if FEATURE_EXT_framebuffer_object
        functions->NewFramebuffer = nouveau_framebuffer_new;
        functions->NewRenderbuffer = nouveau_renderbuffer_new;
+       functions->MapRenderbuffer = nouveau_renderbuffer_map;
+       functions->UnmapRenderbuffer = nouveau_renderbuffer_unmap;
        functions->BindFramebuffer = nouveau_bind_framebuffer;
        functions->FramebufferRenderbuffer = nouveau_framebuffer_renderbuffer;
        functions->RenderTexture = nouveau_render_texture;

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to