From: Eric Anholt Date: Mon, 17 Oct 2011 17:18:30 +0000 (-0700) Subject: nouveau: Add implementation of MapRenderbuffer. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4b8f4e7ce17aeaa7fba1140897ab66f74d715b0a;p=mesa.git 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 --- 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;