st/mesa: first implementation of Map/UnmapRenderbuffer()
authorBrian Paul <brianp@vmware.com>
Sat, 5 Nov 2011 16:48:18 +0000 (10:48 -0600)
committerBrian Paul <brianp@vmware.com>
Mon, 7 Nov 2011 21:25:48 +0000 (14:25 -0700)
Untested, but also unused at this point.

src/mesa/state_tracker/st_cb_fbo.c
src/mesa/state_tracker/st_cb_fbo.h

index 6da65d7b9eddf69ed3c6c6c4d4c8daabe731a912..e04cb4406f92e81a179f0f19ff8d44d6ae8573da 100644 (file)
@@ -630,6 +630,62 @@ st_ReadBuffer(struct gl_context *ctx, GLenum buffer)
 }
 
 
+
+/**
+ * Called via ctx->Driver.MapRenderbuffer.
+ */
+static void
+st_MapRenderbuffer(struct gl_context *ctx,
+                   struct gl_renderbuffer *rb,
+                   GLuint x, GLuint y, GLuint w, GLuint h,
+                   GLbitfield mode,
+                   GLubyte **mapOut, GLint *rowStrideOut)
+{
+   struct st_context *st = st_context(ctx);
+   struct st_renderbuffer *strb = st_renderbuffer(rb);
+   struct pipe_context *pipe = st->pipe;
+   unsigned usage;
+
+   usage = 0x0;
+   if (mode & GL_MAP_READ_BIT)
+      usage |= PIPE_TRANSFER_READ;
+   if (mode & GL_MAP_WRITE_BIT)
+      usage |= PIPE_TRANSFER_WRITE;
+
+   strb->transfer = pipe_get_transfer(pipe,
+                                      strb->texture,
+                                      strb->rtt_level,
+                                      strb->rtt_face + strb->rtt_slice,
+                                      usage, x, y, w, h);
+   if (strb->transfer) {
+      *mapOut = pipe_transfer_map(pipe, strb->transfer);
+      *rowStrideOut = strb->transfer->stride;
+   }
+   else {
+      *mapOut = NULL;
+      *rowStrideOut = 0;
+   }
+}
+
+
+/**
+ * Called via ctx->Driver.UnmapRenderbuffer.
+ */
+static void
+st_UnmapRenderbuffer(struct gl_context *ctx,
+                     struct gl_renderbuffer *rb)
+{
+   struct st_context *st = st_context(ctx);
+   struct st_renderbuffer *strb = st_renderbuffer(rb);
+   struct pipe_context *pipe = st->pipe;
+
+   pipe_transfer_unmap(pipe, strb->transfer);
+   pipe->transfer_destroy(pipe, strb->transfer);
+   strb->transfer = NULL;
+}
+
+
+
 void st_init_fbo_functions(struct dd_function_table *functions)
 {
 #if FEATURE_EXT_framebuffer_object
@@ -647,6 +703,9 @@ void st_init_fbo_functions(struct dd_function_table *functions)
 
    functions->DrawBuffers = st_DrawBuffers;
    functions->ReadBuffer = st_ReadBuffer;
+
+   functions->MapRenderbuffer = st_MapRenderbuffer;
+   functions->UnmapRenderbuffer = st_UnmapRenderbuffer;
 }
 
 
index 1afa3fe6ec3b58176bdcb38e679f39e700a1837f..1be017314ef6a832906c3876070a9fdc21a7d1dd 100644 (file)
@@ -51,6 +51,8 @@ struct st_renderbuffer
    enum pipe_format format;  /** preferred format, or PIPE_FORMAT_NONE */
    GLboolean defined;        /**< defined contents? */
 
+   struct pipe_transfer *transfer; /**< only used when mapping the resource */
+
    /**
     * Used only when hardware accumulation buffers are not supported.
     */