r300: Add more pipe_texture stuff.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Fri, 23 Jan 2009 11:09:15 +0000 (03:09 -0800)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Mon, 2 Feb 2009 07:30:26 +0000 (23:30 -0800)
This is enough to sate glxinfo, for now.

src/gallium/drivers/r300/r300_texture.c

index 2f6c52b1375386965eb97c952579e0b102a92780..c1df905033faba349be03337a70d32043bdb84df 100644 (file)
@@ -104,8 +104,62 @@ static void r300_texture_release(struct pipe_screen* screen,
     *texture = NULL;
 }
 
+static struct pipe_surface* r300_get_tex_surface(struct pipe_screen* screen,
+                                                 struct pipe_texture* texture,
+                                                 unsigned face,
+                                                 unsigned level,
+                                                 unsigned zslice,
+                                                 unsigned flags)
+{
+    struct r300_texture* tex = (struct r300_texture*)texture;
+    struct pipe_surface* surface = CALLOC_STRUCT(pipe_surface);
+    unsigned offset;
+
+    /* XXX this is certainly dependent on tex target */
+    offset = tex->offset[level];
+
+    if (surface) {
+        surface->refcount = 1;
+        surface->winsys = screen->winsys;
+        pipe_texture_reference(&surface->texture, texture);
+        pipe_buffer_reference(screen, &surface->buffer, tex->buffer);
+        surface->format = texture->format;
+        surface->width = texture->width[level];
+        surface->height = texture->height[level];
+        surface->block = texture->block;
+        surface->nblocksx = texture->nblocksx[level];
+        surface->nblocksy = texture->nblocksy[level];
+        /* XXX save the actual stride instead plz kthnxbai */
+        surface->stride =
+            (texture->nblocksx[level] * texture->block.size + 31) & ~31;
+        surface->offset = offset;
+        surface->usage = flags;
+        surface->status = PIPE_SURFACE_STATUS_DEFINED;
+    }
+
+    return surface;
+}
+
+static void r300_tex_surface_release(struct pipe_screen* screen,
+                                     struct pipe_surface** surface)
+{
+    struct pipe_surface* s = *surface;
+
+    s->refcount--;
+
+    if (s->refcount <= 0) {
+        pipe_texture_reference(&s->texture, NULL);
+        pipe_buffer_reference(screen, &s->buffer, NULL);
+        FREE(s);
+    }
+
+    *surface = NULL;
+}
+
 void r300_init_screen_texture_functions(struct pipe_screen* screen)
 {
     screen->texture_create = r300_texture_create;
     screen->texture_release = r300_texture_release;
+    screen->get_tex_surface = r300_get_tex_surface;
+    screen->tex_surface_release = r300_tex_surface_release;
 }