intel: update intel_create_renderbuffer(format), add XRGB support
authorBrian Paul <brianp@vmware.com>
Fri, 30 Oct 2009 01:12:50 +0000 (19:12 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 30 Oct 2009 01:12:50 +0000 (19:12 -0600)
Pass a gl_format to intel_create_renderbuffer() instead of GLenum.
Add cases for MESA_FORMAT_XRGB8888 textures and renderbuffers.
However, we don't yet create any renderbuffers or textures with that
format.  It seems the default alpha value is zero instead of one.
Need to investigate that first.

12 files changed:
src/mesa/drivers/dri/i915/i830_texstate.c
src/mesa/drivers/dri/i915/i830_vtbl.c
src/mesa/drivers/dri/i915/i915_texstate.c
src/mesa/drivers/dri/i915/i915_vtbl.c
src/mesa/drivers/dri/i965/brw_wm_surface_state.c
src/mesa/drivers/dri/intel/intel_blit.c
src/mesa/drivers/dri/intel/intel_fbo.c
src/mesa/drivers/dri/intel/intel_fbo.h
src/mesa/drivers/dri/intel/intel_pixel_draw.c
src/mesa/drivers/dri/intel/intel_screen.c
src/mesa/drivers/dri/intel/intel_span.c
src/mesa/drivers/dri/intel/intel_tex_format.c

index 28263fbe3c65ccac92d9c2dc3e221ab1775f2d0a..f4bbb53b863a15bb3438627d838c52e4ecac7bb3 100644 (file)
@@ -59,6 +59,8 @@ translate_texture_format(GLuint mesa_format, GLuint internal_format)
         return MAPSURF_32BIT | MT_32BIT_XRGB8888;
       else
         return MAPSURF_32BIT | MT_32BIT_ARGB8888;
+   case MESA_FORMAT_XRGB8888:
+      return MAPSURF_32BIT | MT_32BIT_XRGB8888;
    case MESA_FORMAT_YCBCR_REV:
       return (MAPSURF_422 | MT_422_YCRCB_NORMAL);
    case MESA_FORMAT_YCBCR:
index 22f8bc7f1930010ffecdef854e0d5438be328c32..41336961294b9d952da5a1a4d8834e22cab8440e 100644 (file)
@@ -647,6 +647,7 @@ i830_state_draw_region(struct intel_context *intel,
    if (irb != NULL) {
       switch (irb->texformat) {
       case MESA_FORMAT_ARGB8888:
+      case MESA_FORMAT_XRGB8888:
         value |= DV_PF_8888;
         break;
       case MESA_FORMAT_RGB565:
index bea47f5af821ac702d47c30ed72c3020698cec5e..d6689af53f61305a85f223a6892741a9f719b58e 100644 (file)
@@ -60,6 +60,8 @@ translate_texture_format(gl_format mesa_format, GLuint internal_format,
         return MAPSURF_32BIT | MT_32BIT_XRGB8888;
       else
         return MAPSURF_32BIT | MT_32BIT_ARGB8888;
+   case MESA_FORMAT_XRGB8888:
+      return MAPSURF_32BIT | MT_32BIT_XRGB8888;
    case MESA_FORMAT_YCBCR_REV:
       return (MAPSURF_422 | MT_422_YCRCB_NORMAL);
    case MESA_FORMAT_YCBCR:
index d84df1a142dafc43e2747fb5277912881816d4b5..3c1b2dd0b0c8acb8dfbce50d0f4462cfb1c7e9b5 100644 (file)
@@ -589,6 +589,7 @@ i915_state_draw_region(struct intel_context *intel,
    if (irb != NULL) {
       switch (irb->texformat) {
       case MESA_FORMAT_ARGB8888:
+      case MESA_FORMAT_XRGB8888:
         value |= DV_PF_8888;
         break;
       case MESA_FORMAT_RGB565:
index 3b2c6a25be00c2f737d6050acac6bd4a59314dc4..0bf735c0f2c3ce57004d980f555ef4bdd104cf47 100644 (file)
@@ -96,7 +96,11 @@ static GLuint translate_tex_format( gl_format mesa_format,
       else
         return BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
 
+   case MESA_FORMAT_XRGB8888:
+      return BRW_SURFACEFORMAT_B8G8R8X8_UNORM;
+
    case MESA_FORMAT_RGBA8888_REV:
+      _mesa_problem(NULL, "unexpected format in i965:translate_tex_format()");
       if (internal_format == GL_RGB)
         return BRW_SURFACEFORMAT_R8G8B8X8_UNORM;
       else
@@ -531,6 +535,9 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
       case MESA_FORMAT_ARGB8888:
         key.surface_format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
         break;
+      case MESA_FORMAT_XRGB8888:
+        key.surface_format = BRW_SURFACEFORMAT_B8G8R8X8_UNORM;
+        break;
       case MESA_FORMAT_RGB565:
         key.surface_format = BRW_SURFACEFORMAT_B5G6R5_UNORM;
         break;
index 55d97a0f76abff2606daae6450c86d449fbb90d3..817223da41d63af1acada031caba8f25d1d8ef40 100644 (file)
@@ -498,6 +498,7 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
 
                  switch (irb->texformat) {
                  case MESA_FORMAT_ARGB8888:
+                 case MESA_FORMAT_XRGB8888:
                     clearVal = intel->ClearColor8888;
                     break;
                  case MESA_FORMAT_RGB565:
index d006389f5abe83c1730de37fc79c591397c9d63b..9c780d40ccd343d45eb22dbfd5c031df40319c2c 100644 (file)
@@ -292,7 +292,7 @@ intel_renderbuffer_set_region(struct intel_renderbuffer *rb,
  * not a user-created renderbuffer.
  */
 struct intel_renderbuffer *
-intel_create_renderbuffer(GLenum intFormat)
+intel_create_renderbuffer(gl_format format)
 {
    GET_CURRENT_CONTEXT(ctx);
 
@@ -308,48 +308,30 @@ intel_create_renderbuffer(GLenum intFormat)
    _mesa_init_renderbuffer(&irb->Base, name);
    irb->Base.ClassID = INTEL_RB_CLASS;
 
-   switch (intFormat) {
-   case GL_RGB5:
-      irb->Base.Format = MESA_FORMAT_RGB565;
+   switch (format) {
+   case MESA_FORMAT_RGB565:
       irb->Base._BaseFormat = GL_RGB;
       irb->Base.DataType = GL_UNSIGNED_BYTE;
-      irb->texformat = MESA_FORMAT_RGB565;
       break;
-   case GL_RGB8:
-      irb->Base.Format = MESA_FORMAT_ARGB8888; /* XXX: NEED XRGB8888 */
+   case MESA_FORMAT_XRGB8888:
       irb->Base._BaseFormat = GL_RGB;
       irb->Base.DataType = GL_UNSIGNED_BYTE;
-      irb->texformat = MESA_FORMAT_ARGB8888; /* XXX: NEED XRGB8888 */
       break;
-   case GL_RGBA8:
-      irb->Base.Format = MESA_FORMAT_ARGB8888;
+   case MESA_FORMAT_ARGB8888:
       irb->Base._BaseFormat = GL_RGBA;
       irb->Base.DataType = GL_UNSIGNED_BYTE;
-      irb->texformat = MESA_FORMAT_ARGB8888;
-      break;
-   case GL_STENCIL_INDEX8_EXT:
-      irb->Base.Format = MESA_FORMAT_S8_Z24;
-      irb->Base._BaseFormat = GL_STENCIL_INDEX;
-      irb->Base.DataType = GL_UNSIGNED_BYTE;
-      irb->texformat = MESA_FORMAT_S8_Z24;
       break;
-   case GL_DEPTH_COMPONENT16:
-      irb->Base.Format = MESA_FORMAT_Z16;
+   case MESA_FORMAT_Z16:
       irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
       irb->Base.DataType = GL_UNSIGNED_SHORT;
-      irb->texformat = MESA_FORMAT_Z16;
       break;
-   case GL_DEPTH_COMPONENT24:
-      irb->Base.Format = MESA_FORMAT_S8_Z24;
+   case MESA_FORMAT_X8_Z24:
       irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
       irb->Base.DataType = GL_UNSIGNED_INT;
-      irb->texformat = MESA_FORMAT_S8_Z24;
       break;
-   case GL_DEPTH24_STENCIL8_EXT:
-      irb->Base.Format = MESA_FORMAT_S8_Z24;
+   case MESA_FORMAT_S8_Z24:
       irb->Base._BaseFormat = GL_DEPTH_STENCIL;
       irb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
-      irb->texformat = MESA_FORMAT_S8_Z24;
       break;
    default:
       _mesa_problem(NULL,
@@ -358,7 +340,10 @@ intel_create_renderbuffer(GLenum intFormat)
       return NULL;
    }
 
-   irb->Base.InternalFormat = intFormat;
+   assert(irb->Base._BaseFormat == _mesa_get_format_base_format(format));
+   irb->Base.Format = format;
+   irb->Base.InternalFormat = irb->Base._BaseFormat;
+   irb->texformat = format;
 
    /* intel-specific methods */
    irb->Base.Delete = intel_delete_renderbuffer;
@@ -442,6 +427,10 @@ intel_update_wrapper(GLcontext *ctx, struct intel_renderbuffer *irb,
       irb->Base.DataType = GL_UNSIGNED_BYTE;
       DBG("Render to RGBA8 texture OK\n");
    }
+   else if (texImage->TexFormat == MESA_FORMAT_XRGB8888) {
+      irb->Base.DataType = GL_UNSIGNED_BYTE;
+      DBG("Render to XGBA8 texture OK\n");
+   }
    else if (texImage->TexFormat == MESA_FORMAT_RGB565) {
       irb->Base.DataType = GL_UNSIGNED_BYTE;
       DBG("Render to RGB5 texture OK\n");
@@ -644,6 +633,7 @@ intel_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
 
       switch (irb->texformat) {
       case MESA_FORMAT_ARGB8888:
+      case MESA_FORMAT_XRGB8888:
       case MESA_FORMAT_RGB565:
       case MESA_FORMAT_ARGB1555:
       case MESA_FORMAT_ARGB4444:
index e0584e3494b5a9355e8559d59d31db7671782e1c..50a8a959858fc71baad70496e88a7364f6196083 100644 (file)
@@ -115,7 +115,7 @@ intel_renderbuffer_set_region(struct intel_renderbuffer *irb,
 
 
 extern struct intel_renderbuffer *
-intel_create_renderbuffer(GLenum intFormat);
+intel_create_renderbuffer(gl_format format);
 
 
 extern void
index 5ffa847fd4af62969c41f339c0856575b84f4856..9b382e36225c4e98a1f50b209c9d8ec951f0b417 100644 (file)
@@ -169,7 +169,7 @@ intel_stencil_drawpixels(GLcontext * ctx,
     * buffer.
     */
    depth_irb = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_DEPTH);
-   irb = intel_create_renderbuffer(GL_RGBA8);
+   irb = intel_create_renderbuffer(MESA_FORMAT_ARGB8888);
    rb = &irb->Base;
    irb->Base.Width = depth_irb->Base.Width;
    irb->Base.Height = depth_irb->Base.Height;
index 41342ddcae9b8817d5ea1e3efc2659390eab4dba..62c322b4ed47c6e8e97eb2741fd2276b4dc28012 100644 (file)
@@ -349,7 +349,7 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
    else {
       GLboolean swStencil = (mesaVis->stencilBits > 0 &&
                              mesaVis->depthBits != 24);
-      GLenum rgbFormat;
+      gl_format rgbFormat;
 
       struct intel_framebuffer *intel_fb = CALLOC_STRUCT(intel_framebuffer);
 
@@ -359,11 +359,11 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
       _mesa_initialize_framebuffer(&intel_fb->Base, mesaVis);
 
       if (mesaVis->redBits == 5)
-        rgbFormat = GL_RGB5;
+        rgbFormat = MESA_FORMAT_RGB565;
       else if (mesaVis->alphaBits == 0)
-        rgbFormat = GL_RGB8;
+        rgbFormat = MESA_FORMAT_ARGB8888; /* XXX change to XRGB someday */
       else
-        rgbFormat = GL_RGBA8;
+        rgbFormat = MESA_FORMAT_ARGB8888;
 
       /* setup the hardware-based renderbuffers */
       intel_fb->color_rb[0] = intel_create_renderbuffer(rgbFormat);
@@ -382,7 +382,7 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
         if (mesaVis->stencilBits == 8) {
            /* combined depth/stencil buffer */
            struct intel_renderbuffer *depthStencilRb
-              = intel_create_renderbuffer(GL_DEPTH24_STENCIL8_EXT);
+              = intel_create_renderbuffer(MESA_FORMAT_S8_Z24);
            /* note: bind RB to two attachment points */
            _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH,
                                   &depthStencilRb->Base);
@@ -390,7 +390,7 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
                                   &depthStencilRb->Base);
         } else {
            struct intel_renderbuffer *depthRb
-              = intel_create_renderbuffer(GL_DEPTH_COMPONENT24);
+              = intel_create_renderbuffer(MESA_FORMAT_X8_Z24);
            _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH,
                                   &depthRb->Base);
         }
@@ -398,7 +398,7 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
       else if (mesaVis->depthBits == 16) {
          /* just 16-bit depth buffer, no hw stencil */
          struct intel_renderbuffer *depthRb
-           = intel_create_renderbuffer(GL_DEPTH_COMPONENT16);
+           = intel_create_renderbuffer(MESA_FORMAT_Z16);
          _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, &depthRb->Base);
       }
 
index a36c077fbd4c918446e7162cf62760ec2e31e2e3..b0484a99591169562cc6c1a9f8272263f1250a28 100644 (file)
@@ -651,8 +651,23 @@ intel_set_span_functions(struct intel_context *intel,
         break;
       }
       break;
+   case MESA_FORMAT_XRGB8888:
+      switch (tiling) {
+      case I915_TILING_NONE:
+      default:
+         intelInitPointers_xRGB8888(rb);
+         break;
+      case I915_TILING_X:
+         intel_XTile_InitPointers_xRGB8888(rb);
+         break;
+      case I915_TILING_Y:
+         intel_YTile_InitPointers_xRGB8888(rb);
+         break;
+      }
+      break;
    case MESA_FORMAT_ARGB8888:
       if (0 /*rb->AlphaBits == 0*/) { /* XXX: Need xRGB8888 Mesa format */
+         /* XXX remove this code someday when we enable XRGB surfaces */
         /* 8888 RGBx */
         switch (tiling) {
         case I915_TILING_NONE:
index eca0f6d5723609e57f2ff263e882fe05fa0b261e..f37a545c7f8d72cebea60ae2e0b39e16695c5a06 100644 (file)
@@ -50,6 +50,7 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
       if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) {
          return MESA_FORMAT_RGB565;
       }
+      /* XXX use MESA_FORMAT_XRGB8888 someday */
       return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565;
 
    case GL_RGBA8:
@@ -69,6 +70,7 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
    case GL_RGB10:
    case GL_RGB12:
    case GL_RGB16:
+      /* XXX use MESA_FORMAT_XRGB8888 someday */
       return MESA_FORMAT_ARGB8888;
 
    case GL_RGB5: