checkpoint: no longer using intel_fbo.c
authorBrian <brian@i915.localnet.net>
Thu, 9 Aug 2007 18:27:44 +0000 (12:27 -0600)
committerBrian <brian@i915.localnet.net>
Thu, 9 Aug 2007 20:28:41 +0000 (14:28 -0600)
src/mesa/drivers/dri/intel_winsys/Makefile
src/mesa/drivers/dri/intel_winsys/intel_buffers.c
src/mesa/drivers/dri/intel_winsys/intel_context.c
src/mesa/drivers/dri/intel_winsys/intel_fbo.h
src/mesa/drivers/dri/intel_winsys/intel_screen.c
src/mesa/drivers/dri/intel_winsys/intel_surface.c
src/mesa/state_tracker/st_cb_fbo.c
src/mesa/state_tracker/st_cb_fbo.h
src/mesa/state_tracker/st_context.c

index 8d3d17e13ee0a8a4d8f26f25a7068676a529c5e7..32c2c3bb24f52a6b7e13b14d49921979ecb4ad7b 100644 (file)
@@ -22,10 +22,10 @@ DRIVER_SOURCES = \
        intel_ioctl.c \
        intel_screen.c \
        intel_surface.c \
-       intel_fbo.c \
        intel_batchpool.c
 
-UNUSED =       intel_depthstencil.c 
+UNUSED =       intel_depthstencil.c \
+       intel_fbo.c 
 
 C_SOURCES = \
        $(COMMON_SOURCES) \
index 9266fb62affb5713cbfcd2d199b41fe3f1f9978c..d0139d5b2ad4cb25b12704dd6f46c4e72373b87e 100644 (file)
@@ -96,6 +96,7 @@ intel_intersect_cliprects(drm_clip_rect_t * dst,
 /**
  * Return pointer to current color drawing region, or NULL.
  */
+#if 0
 struct pipe_region *
 intel_drawbuf_region(struct intel_context *intel)
 {
@@ -120,7 +121,7 @@ intel_readbuf_region(struct intel_context *intel)
    else
       return NULL;
 }
-
+#endif
 
 /**
  * This will be called whenever the currently bound window is moved/resized.
index 9defcc1aaec8efbfac9d276cd15ea3f3cb280296..0d83d4efd61a917c0d1c26d1f39e1b02915c0971 100644 (file)
@@ -360,6 +360,58 @@ intelCreateContext(const __GLcontextModes * mesaVis,
    _vbo_CreateContext(ctx);
    _tnl_CreateContext(ctx);
 
+   /*
+    * Pipe-related setup
+    */
+   if (!getenv("INTEL_HW")) {
+      intel->pipe = intel_create_softpipe( intel );
+      intel->pipe->surface_alloc = intel_new_surface;
+      intel->pipe->supported_formats = intel_supported_formats;
+   }
+   else {
+      switch (intel->intelScreen->deviceID) {
+      case PCI_CHIP_I945_G:
+      case PCI_CHIP_I945_GM:
+      case PCI_CHIP_I945_GME:
+      case PCI_CHIP_G33_G:
+      case PCI_CHIP_Q33_G:
+      case PCI_CHIP_Q35_G:
+      case PCI_CHIP_I915_G:
+      case PCI_CHIP_I915_GM:
+        intel->pipe = intel_create_i915simple( intel );
+        break;
+      default:
+        _mesa_printf("Unknown PCIID %x in %s, using software driver\n", 
+                     intel->intelScreen->deviceID, __FUNCTION__);
+
+        intel->pipe = intel_create_softpipe( intel );
+        break;
+      }
+   }
+
+   st_create_context( &intel->ctx, intel->pipe ); 
+
+
+   /* TODO: Push this down into the pipe driver:
+    */
+   switch (intel->intelScreen->deviceID) {
+   case PCI_CHIP_I945_G:
+   case PCI_CHIP_I945_GM:
+   case PCI_CHIP_I945_GME:
+   case PCI_CHIP_G33_G:
+   case PCI_CHIP_Q33_G:
+   case PCI_CHIP_Q35_G:
+      intel->pipe->mipmap_tree_layout = i945_miptree_layout;
+      break;
+   case PCI_CHIP_I915_G:
+   case PCI_CHIP_I915_GM:
+   case PCI_CHIP_I830_M:
+   case PCI_CHIP_I855_GM:
+   case PCI_CHIP_I865_G:
+      intel->pipe->mipmap_tree_layout = i915_miptree_layout;
+   default:
+      assert(0); /*FIX*/
+   }
 
 
    /*
@@ -397,7 +449,9 @@ intelCreateContext(const __GLcontextModes * mesaVis,
    intel->last_swap_fence = NULL;
    intel->first_swap_fence = NULL;
 
+#if 00
    intel_fbo_init(intel);
+#endif
 
    if (intel->ctx.Mesa_DXTn) {
       _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
index 578e1013c2dc1b13d8ae571a5f00907d0b26368f..2801c7345d0380d5737fb7296dd887136a8613bb 100644 (file)
@@ -73,19 +73,26 @@ struct intel_framebuffer
  * not pointers because in some circumstances a deleted renderbuffer could
  * result in a dangling pointer here.
  */
+#if 0
 struct intel_renderbuffer
 {
    struct gl_renderbuffer Base;
 };
+#endif
 
-
+#if 0
 extern struct intel_renderbuffer *intel_new_renderbuffer_fb(GLuint intFormat);
+#endif
 
 extern void intel_fbo_init(struct intel_context *intel);
 
 
 extern struct pipe_surface *
-intel_new_surface(GLuint intFormat);
+intel_new_surface(struct pipe_context *pipe, GLuint pipeFormat);
+
+
+extern const GLuint *
+intel_supported_formats(struct pipe_context *pipe, GLuint *numFormats);
 
 
 #endif /* INTEL_FBO_H */
index 74cd714cf340984270214d5c46358b2d4c7b137e..e5f7b365274f78016449c35c57f946ee34abb601 100644 (file)
@@ -302,34 +302,32 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
         /* fake frontbuffer */
         /* XXX allocation should only happen in the unusual case
             it's actually needed */
-         struct intel_renderbuffer *irb 
-            = intel_new_renderbuffer_fb(rgbFormat);
-         _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT,
-                               &irb->Base);
+         struct gl_renderbuffer *rb 
+            = st_new_renderbuffer_fb(rgbFormat);
+         _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT, rb);
       }
 
       if (mesaVis->doubleBufferMode) {
-         struct intel_renderbuffer *irb 
-            = intel_new_renderbuffer_fb(rgbFormat);
-         _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT,
-                               &irb->Base);
+         struct gl_renderbuffer *rb 
+            = st_new_renderbuffer_fb(rgbFormat);
+         _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT, rb);
       }
 
       if (mesaVis->depthBits == 24 && mesaVis->stencilBits == 8) {
          /* combined depth/stencil buffer */
-         struct intel_renderbuffer *depthStencilRb
-            = intel_new_renderbuffer_fb(GL_DEPTH24_STENCIL8_EXT);
+         struct gl_renderbuffer *depthStencilRb
+            = st_new_renderbuffer_fb(GL_DEPTH24_STENCIL8_EXT);
          /* note: bind RB to two attachment points */
          _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH,
-                               &depthStencilRb->Base);
+                               depthStencilRb);
          _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_STENCIL,
-                               &depthStencilRb->Base);
+                               depthStencilRb);
       }
       else if (mesaVis->depthBits == 16) {
          /* just 16-bit depth buffer, no hw stencil */
-         struct intel_renderbuffer *depthRb
-            = intel_new_renderbuffer_fb(GL_DEPTH_COMPONENT16);
-         _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, &depthRb->Base);
+         struct gl_renderbuffer *depthRb
+            = st_new_renderbuffer_fb(GL_DEPTH_COMPONENT16);
+         _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, depthRb);
       }
 
 
index d2e2dabadeaebc06d3d565aa34d20d3e6be3c9da..20b6bda83f7f6b02ef291efedae22980a772c04c 100644 (file)
@@ -159,8 +159,43 @@ write_quad_stencil(struct softpipe_surface *sps,
 }
 
 
+
+
+static void
+a8r8g8b8_get_tile(struct pipe_surface *ps,
+                  GLuint x, GLuint y, GLuint w, GLuint h, GLfloat *p)
+{
+   const GLuint *src
+      = ((const GLuint *) (ps->region->map + ps->offset))
+      + y * ps->region->pitch + x;
+   GLuint i, j;
+#if 0
+   assert(x + w <= ps->width);
+   assert(y + h <= ps->height);
+#else
+   /* temp hack */
+   if (x + w > ps->width)
+      w = ps->width - x;
+   if (y + h > ps->height)
+      h = ps->height -y;
+#endif
+   for (i = 0; i < h; i++) {
+      for (j = 0; j < w; j++) {
+         p[0] = UBYTE_TO_FLOAT((src[j] >> 16) & 0xff);
+         p[1] = UBYTE_TO_FLOAT((src[j] >>  8) & 0xff);
+         p[2] = UBYTE_TO_FLOAT((src[j] >>  0) & 0xff);
+         p[3] = UBYTE_TO_FLOAT((src[j] >> 24) & 0xff);
+         p += 4;
+      }
+      src += ps->region->pitch;
+   }
+}
+
+
+
+
 struct pipe_surface *
-intel_new_surface(GLuint intFormat)
+intel_new_surface(struct pipe_context *pipe, GLuint pipeFormat)
 {
    struct softpipe_surface *sps = CALLOC_STRUCT(softpipe_surface);
    if (!sps)
@@ -168,31 +203,42 @@ intel_new_surface(GLuint intFormat)
 
    sps->surface.width = 0; /* set in intel_alloc_renderbuffer_storage() */
    sps->surface.height = 0;
+   sps->surface.refcount = 1;
+   sps->surface.format = pipeFormat;
 
-   if (intFormat == GL_RGBA8) {
-      sps->surface.format = PIPE_FORMAT_U_A8_R8_G8_B8;
+   switch (pipeFormat) {
+   case PIPE_FORMAT_U_A8_R8_G8_B8:
       sps->read_quad_f_swz = read_quad_f_swz;
       sps->write_quad_f_swz = write_quad_f_swz;
-   }
-   else if (intFormat == GL_RGB5) {
-      sps->surface.format = PIPE_FORMAT_U_R5_G6_B5;
-
-   }
-   else if (intFormat == GL_DEPTH_COMPONENT16) {
-      sps->surface.format = PIPE_FORMAT_U_Z16;
-
-   }
-   else if (intFormat == GL_DEPTH24_STENCIL8_EXT) {
-      sps->surface.format = PIPE_FORMAT_S8_Z24;
+      sps->surface.get_tile = a8r8g8b8_get_tile;
+      break;
+   case PIPE_FORMAT_U_R5_G6_B5:
+      break;
+   case PIPE_FORMAT_U_Z16:
+      break;
+   case PIPE_FORMAT_S8_Z24:
       sps->read_quad_z = read_quad_z24;
       sps->write_quad_z = write_quad_z24;
       sps->read_quad_stencil = read_quad_stencil;
       sps->write_quad_stencil = write_quad_stencil;
-   }
-   else {
-      /* TBD / unknown */
-
+      break;
    }
 
    return &sps->surface;
 }
+
+
+
+const GLuint *
+intel_supported_formats(struct pipe_context *pipe, GLuint *numFormats)
+{
+   static const GLuint formats[] = {
+      PIPE_FORMAT_U_A8_R8_G8_B8,
+      PIPE_FORMAT_U_R5_G6_B5,
+      PIPE_FORMAT_S8_Z24,
+   };
+
+   *numFormats = sizeof(formats) / sizeof(formats[0]);
+   return formats;
+}
+
index d0205fd63529e25547f8d8f71a577975508eaa6b..3cd1fbe851af4761c4000a811fadc27d61f0f929 100644 (file)
@@ -53,7 +53,9 @@
 struct st_renderbuffer
 {
    struct gl_renderbuffer Base;
+#if 0
    struct pipe_surface *surface;
+#endif
 };
 
 
@@ -93,14 +95,14 @@ pipe_get_format_info(GLuint format)
       {
          PIPE_FORMAT_U_R8_G8_B8_A8,  /* format */
          GL_RGBA,                    /* base_format */
-         4, 4, 4, 4, 0, 0,           /* color bits */
+         8, 8, 8, 8, 0, 0,           /* color bits */
          0, 0,                       /* depth, stencil */
          4                           /* size in bytes */
       },
       {
          PIPE_FORMAT_U_A8_R8_G8_B8,
          GL_RGBA,                    /* base_format */
-         4, 4, 4, 4, 0, 0,           /* color bits */
+         8, 8, 8, 8, 0, 0,           /* color bits */
          0, 0,                       /* depth, stencil */
          4                           /* size in bytes */
       },
@@ -166,29 +168,29 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
 
    cpp = info->size;
 
-   if (!strb->surface) {
-      strb->surface = pipe->surface_alloc(pipe, pipeFormat);
-      if (!strb->surface)
+   if (!strb->Base.surface) {
+      strb->Base.surface = pipe->surface_alloc(pipe, pipeFormat);
+      if (!strb->Base.surface)
          return GL_FALSE;
    }
 
    /* free old region */
-   if (strb->surface->region) {
-      pipe->region_release(pipe, &strb->surface->region);
+   if (strb->Base.surface->region) {
+      pipe->region_release(pipe, &strb->Base.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);
-   if (!strb->surface->region)
+   strb->Base.surface->region = pipe->region_alloc(pipe, cpp, pitch, height);
+   if (!strb->Base.surface->region)
       return GL_FALSE; /* out of memory, try s/w buffer? */
 
-   ASSERT(strb->surface->region->buffer);
+   ASSERT(strb->Base.surface->region->buffer);
 
-   strb->Base.Width  = strb->surface->width  = width;
-   strb->Base.Height = strb->surface->height = height;
+   strb->Base.Width  = strb->Base.surface->width  = width;
+   strb->Base.Height = strb->Base.surface->height = height;
 
    return GL_TRUE;
 }
@@ -204,11 +206,11 @@ st_renderbuffer_delete(struct gl_renderbuffer *rb)
    struct pipe_context *pipe = ctx->st->pipe;
    struct st_renderbuffer *strb = st_renderbuffer(rb);
    ASSERT(strb);
-   if (strb && strb->surface) {
+   if (strb && strb->Base.surface) {
       if (rb->surface->region) {
-         pipe->region_release(pipe, &strb->surface->region);
+         pipe->region_release(pipe, &strb->Base.surface->region);
       }
-      free(strb->surface);
+      free(strb->Base.surface);
    }
    free(strb);
 }
@@ -257,6 +259,76 @@ st_new_renderbuffer(GLcontext *ctx, GLuint name)
    return NULL;
 }
 
+
+#if 000
+struct gl_renderbuffer *
+st_new_renderbuffer_fb(struct pipe_region *region, GLuint width, GLuint height)
+{
+   struct st_renderbuffer *strb = CALLOC_STRUCT(st_renderbuffer);
+   if (!strb)
+      return;
+
+   _mesa_init_renderbuffer(&strb->Base, name);
+   strb->Base.Delete = st_renderbuffer_delete;
+   strb->Base.AllocStorage = st_renderbuffer_alloc_storage;
+   strb->Base.GetPointer = null_get_pointer;
+   strb->Base.Width = width;
+   strb->Base.Heigth = height;
+
+   strb->region = region;
+
+   return &strb->Base;
+}
+
+#else
+
+struct gl_renderbuffer *
+st_new_renderbuffer_fb(GLuint intFormat)
+{
+   struct st_renderbuffer *irb;
+
+   irb = CALLOC_STRUCT(st_renderbuffer);
+   if (!irb) {
+      _mesa_error(NULL, GL_OUT_OF_MEMORY, "creating renderbuffer");
+      return NULL;
+   }
+
+   _mesa_init_renderbuffer(&irb->Base, 0);
+   irb->Base.ClassID = 0x42; /* XXX temp */
+   irb->Base.InternalFormat = intFormat;
+
+   switch (intFormat) {
+   case GL_RGB5:
+   case GL_RGBA8:
+      irb->Base._BaseFormat = GL_RGBA;
+      break;
+   case GL_DEPTH_COMPONENT16:
+      irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
+      break;
+   case GL_DEPTH24_STENCIL8_EXT:
+      irb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
+      break;
+   default:
+      _mesa_problem(NULL,
+                   "Unexpected intFormat in st_new_renderbuffer");
+      return NULL;
+   }
+
+   /* st-specific methods */
+   irb->Base.Delete = st_renderbuffer_delete;
+   irb->Base.AllocStorage = st_renderbuffer_alloc_storage;
+   irb->Base.GetPointer = null_get_pointer;
+   /* span routines set in alloc_storage function */
+
+   irb->Base.surface = NULL;/*intel_new_surface(intFormat);*/
+   /*irb->Base.surface->rb = irb;*/
+
+   return &irb->Base;
+}
+#endif
+
+
+
 /**
  * Called via ctx->Driver.BindFramebufferEXT().
  */
index 6142434ec6737d2b8eb32911ba16dc8500b6adf1..7f52ab10d711171fd3fdd89b9afcf9c0ce97ec61 100644 (file)
 #define ST_CB_FBO_H
 
 
+/*
+extern struct gl_renderbuffer *
+st_new_renderbuffer_fb(struct pipe_region *region, GLuint width, GLuint height);
+*/
+extern struct gl_renderbuffer *
+st_new_renderbuffer_fb(GLuint intFormat);
+
+
 extern void
 st_init_fbo_functions(struct dd_function_table *functions);
 
index 0ea06c692d0dbdb40605d354add0892b1bd86860..9f7916e40e80641992ba2be2489bae3d1585839f 100644 (file)
@@ -31,6 +31,7 @@
 #include "st_cb_bufferobjects.h"
 #include "st_cb_clear.h"
 #include "st_cb_drawpixels.h"
+#include "st_cb_fbo.h"
 #include "st_cb_texture.h"
 #include "st_atom.h"
 #include "st_draw.h"
@@ -102,6 +103,7 @@ void st_init_driver_functions(struct dd_function_table *functions)
    st_init_bufferobject_functions(functions);
    st_init_clear_functions(functions);
    st_init_drawpixels_functions(functions);
+   st_init_fbo_functions(functions);
    st_init_program_functions(functions);
    st_init_texture_functions(functions);
 }