[Mesa-dev] [PATCH 06/24] nouveau: Add implementation of MapRenderbuffer.
Eric Anholt
eric at anholt.net
Fri Oct 28 12:49:56 PDT 2011
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.
---
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;
--
1.7.7
More information about the mesa-dev
mailing list