pipe->region_alloc() now takes width instead of pitch, plus a flags param
authorBrian <brian.paul@tungstengraphics.com>
Fri, 10 Aug 2007 18:13:48 +0000 (12:13 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Fri, 10 Aug 2007 18:14:25 +0000 (12:14 -0600)
src/mesa/pipe/i915simple/i915_regions.c
src/mesa/pipe/p_context.h
src/mesa/pipe/p_defines.h
src/mesa/pipe/p_state.h
src/mesa/pipe/softpipe/sp_region.c
src/mesa/state_tracker/st_cb_bufferobjects.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_fbo.c
src/mesa/state_tracker/st_mipmap_tree.c

index e2b807f959ab27d94cd203d968fd5244944ae5fc..b3bcae547d1d5bc2a69c4d9f85a554603f4b765f 100644 (file)
@@ -31,6 +31,7 @@
  *   - refcounting of buffer mappings.
  */
 
+#include "pipe/p_defines.h"
 #include "i915_context.h"
 #include "i915_winsys.h"
 #include "i915_blit.h"
@@ -70,7 +71,7 @@ i915_region_unmap(struct pipe_context *pipe, struct pipe_region *region)
 
 static struct pipe_region *
 i915_region_alloc(struct pipe_context *pipe,
-                 GLuint cpp, GLuint width, GLuint height)
+                 GLuint cpp, GLuint width, GLuint height, GLbitfield flags)
 {
    struct i915_context *i915 = i915_context( pipe );
    struct pipe_region *region = calloc(sizeof(*region), 1);
@@ -82,7 +83,13 @@ i915_region_alloc(struct pipe_context *pipe,
     * clearly want to be able to render to textures under some
     * circumstances, but maybe not always a requirement.
     */
-   unsigned pitch = ((cpp * width + 63) & ~63) / cpp;
+   unsigned pitch;
+
+   /* XXX is the pitch different for textures vs. drawables? */
+   if (flags & PIPE_SURFACE_FLAG_TEXTURE)  /* or PIPE_SURFACE_FLAG_RENDER? */
+      pitch = ((cpp * width + 63) & ~63) / cpp;
+   else
+      pitch = ((cpp * width + 63) & ~63) / cpp;
 
    region->cpp = cpp;
    region->pitch = pitch;
index b5dd149603c9495c39e11f4e1ac988232f849461..7eb492816b4f6f23aff2a93882906fb30986db8a 100644 (file)
@@ -140,7 +140,8 @@ struct pipe_context {
     * Some of these may go away...
     */
    struct pipe_region *(*region_alloc)(struct pipe_context *pipe,
-                                       GLuint cpp, GLuint pitch, GLuint height);
+                                       GLuint cpp, GLuint width, GLuint height,
+                                       GLbitfield flags);
 
    void (*region_release)(struct pipe_context *pipe, struct pipe_region **r);
 
index efbb3239a2ecff1d3a4f444283a31331ca057846..52ecd5b11902fcff30e4a23bf9bc48a4a54c9336 100644 (file)
 
 
 /**
- * Buffer mapping access modes
+ * Surface flags
  */
-#define PIPE_MAP_READ         1
-#define PIPE_MAP_WRITE        2
-#define PIPE_MAP_READ_WRITE   3
+#define PIPE_SURFACE_FLAG_TEXTURE 0x1
+#define PIPE_SURFACE_FLAG_RENDER  0x2
+
+
+/**
+ * Buffer flags
+ */
+#define PIPE_BUFFER_FLAG_READ    0x1
+#define PIPE_BUFFER_FLAG_WRITE   0x2
+
+#define PIPE_BUFFER_USE_TEXTURE         0x1
+#define PIPE_BUFFER_USE_VERTEX_BUFFER   0x2
+#define PIPE_BUFFER_USE_INDEX_BUFFER    0x4
+#define PIPE_BUFFER_USE_RENDER_TARGET   0x8
 
 
 /** 
index 64a475ba00d5e9a8fae752908f17142e0728f729..df456cc2edd8cc28bf18b04fd4e8ff2e3a65039b 100644 (file)
@@ -329,15 +329,5 @@ struct pipe_mipmap_tree
 
 struct pipe_buffer_handle;
 
-#define PIPE_BUFFER_FLAG_READ    0x1
-#define PIPE_BUFFER_FLAG_WRITE   0x2
-
-#define PIPE_BUFFER_USE_TEXTURE         0x1
-#define PIPE_BUFFER_USE_VERTEX_BUFFER   0x2
-#define PIPE_BUFFER_USE_INDEX_BUFFER    0x4
-#define PIPE_BUFFER_USE_RENDER_TARGET   0x8
-
-
-
 
 #endif
index 58749492ec1dcca851f814db4ac7d9483897c00b..1db508f028fddec3a77ff27988850e0b4d8f6b9f 100644 (file)
@@ -70,7 +70,7 @@ sp_region_unmap(struct pipe_context *pipe, struct pipe_region *region)
 
 static struct pipe_region *
 sp_region_alloc(struct pipe_context *pipe,
-               GLuint cpp, GLuint pitch, GLuint height)
+               GLuint cpp, GLuint pitch, GLuint height, GLbitfield flags)
 {
    struct softpipe_context *sp = softpipe_context( pipe );
    struct pipe_region *region = calloc(sizeof(*region), 1);
index d020eb2007b2698588188c9c2879666cfa4d207a..78fc18a49ad3d77f1832b6100677b07b0e473d62 100644 (file)
@@ -34,6 +34,9 @@
 #include "st_cb_bufferobjects.h"
 
 #include "pipe/p_context.h"
+#include "pipe/p_defines.h"
+
+
 
 /* Pixel buffers and Vertex/index buffers are handled through these
  * mesa callbacks.  Framebuffer/Renderbuffer objects are
@@ -160,7 +163,7 @@ st_bufferobj_map(GLcontext *ctx,
       flags = PIPE_BUFFER_FLAG_WRITE;
       break;
 
-
+   case GL_READ_ONLY:
       flags = PIPE_BUFFER_FLAG_READ;
       break;
 
index f0c7a2bfc5abf3c86f035451f5bf01dcae35892f..6981097ef4a1b53caa644ea2e86e279a5fbe7da4 100644 (file)
@@ -101,20 +101,19 @@ make_mipmap_tree(struct st_context *st,
                  const GLvoid *pixels)
 {
    GLuint pipeFormat = st_choose_pipe_format(st->pipe, GL_RGBA, format, type);
-   int cpp = 4, pitch;
+   int cpp = 4;
    struct pipe_mipmap_tree *mt = CALLOC_STRUCT(pipe_mipmap_tree);
+   GLbitfield flags = PIPE_SURFACE_FLAG_TEXTURE;
 
    assert(pipeFormat);
 
-   pitch = width; /* XXX pad */
-
    if (unpack->BufferObj) {
       /*
       mt->region = buffer_object_region(unpack->BufferObj);
       */
    }
    else {
-      mt->region = st->pipe->region_alloc(st->pipe, cpp, pitch, height);
+      mt->region = st->pipe->region_alloc(st->pipe, cpp, width, height, flags);
       /* XXX do texstore() here */
    }
 
@@ -128,7 +127,7 @@ make_mipmap_tree(struct st_context *st,
    mt->depth0 = 1;
    mt->cpp = cpp;
    mt->compressed = 0;
-   mt->pitch = pitch;
+   mt->pitch = mt->region->pitch;
    mt->depth_pitch = 0;
    mt->total_height = height;
    mt->level[0].level_offset = 0;
index 64ec8022164c61de41a600e2114be57ca4b5d868..bb588d10ea23966a67a0aaa713d87e1ebf6111d0 100644 (file)
@@ -62,7 +62,8 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    const GLuint pipeFormat
       = st_choose_pipe_format(pipe, internalFormat, GL_NONE, GL_NONE);
    const struct pipe_format_info *info = st_get_format_info(pipeFormat);
-   GLuint cpp, pitch;
+   GLuint cpp;
+   GLbitfield flags = PIPE_SURFACE_FLAG_RENDER; /* want to render to surface */
 
    assert(info);
    if (!info)
@@ -98,11 +99,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
       pipe->region_release(pipe, &strb->surface->region);
    }
 
-   /* Choose a pitch to match hardware requirements:
-    */
-   pitch = ((cpp * width + 63) & ~63) / cpp; /* XXX fix: device-specific */
-
-   strb->surface->region = pipe->region_alloc(pipe, cpp, pitch, height);
+   strb->surface->region = pipe->region_alloc(pipe, cpp, width, height, flags);
    if (!strb->surface->region)
       return GL_FALSE; /* out of memory, try s/w buffer? */
 
index ac74335ba134997398904cd00be9cf393546edfb..3cbe697ab3faf08dce2a4abd2ad31f222af5c487 100644 (file)
@@ -62,6 +62,7 @@ st_miptree_create(struct pipe_context *pipe,
 {
    GLboolean ok;
    struct pipe_mipmap_tree *mt = calloc(sizeof(*mt), 1);
+   GLbitfield flags = 0x0;
 
    DBG("%s target %s format %s level %d..%d\n", __FUNCTION__,
        _mesa_lookup_enum_by_nr(target),
@@ -79,9 +80,11 @@ st_miptree_create(struct pipe_context *pipe,
    mt->refcount = 1; 
 
    ok = pipe->mipmap_tree_layout(pipe, mt);
-   if (ok)
-      mt->region = pipe->region_alloc(pipe,
-                                      mt->cpp, mt->pitch, mt->total_height);
+   if (ok) {
+      /* note: it's OK to pass 'pitch' as 'width' here: */
+      mt->region = pipe->region_alloc(pipe, mt->cpp, mt->pitch,
+                                      mt->total_height, flags);
+   }
 
    if (!mt->region) {
       free(mt);