diff options
author | Eric Anholt <[email protected]> | 2011-10-17 10:18:30 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2011-11-01 15:42:18 -0700 |
commit | 4b8f4e7ce17aeaa7fba1140897ab66f74d715b0a (patch) | |
tree | 8c6680edb1bc695fe937a7bc5ef68655c2eed3a9 | |
parent | 425b8d54b8c97bcbd433393f34a27027e4ff8c4d (diff) |
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]>
-rw-r--r-- | 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 b36b5788781..d56e954e45a 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; |