diff options
Diffstat (limited to 'src/mesa/drivers')
| -rw-r--r-- | src/mesa/drivers/dri/intel/intel_fbo.c | 104 | ||||
| -rw-r--r-- | src/mesa/drivers/dri/intel/intel_span.c | 74 | ||||
| -rw-r--r-- | src/mesa/drivers/dri/intel/intel_span.h | 4 | ||||
| -rw-r--r-- | src/mesa/drivers/dri/intel/intel_tex.h | 1 | ||||
| -rw-r--r-- | src/mesa/drivers/dri/intel/intel_tex_format.c | 33 | 
5 files changed, 78 insertions, 138 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c index 18e796a118..bd51fc280d 100644 --- a/src/mesa/drivers/dri/intel/intel_fbo.c +++ b/src/mesa/drivers/dri/intel/intel_fbo.c @@ -42,6 +42,8 @@  #include "intel_fbo.h"  #include "intel_mipmap_tree.h"  #include "intel_regions.h" +#include "intel_tex.h" +#include "intel_span.h"  #define FILE_DEBUG_FLAG DEBUG_FBO @@ -110,26 +112,21 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer     case GL_RED:     case GL_R8:        rb->Format = MESA_FORMAT_R8; -      rb->DataType = GL_UNSIGNED_BYTE;        break;     case GL_R16:        rb->Format = MESA_FORMAT_R16; -      rb->DataType = GL_UNSIGNED_SHORT;        break;     case GL_RG:     case GL_RG8:        rb->Format = MESA_FORMAT_RG88; -      rb->DataType = GL_UNSIGNED_BYTE;        break;     case GL_RG16:        rb->Format = MESA_FORMAT_RG1616; -      rb->DataType = GL_UNSIGNED_SHORT;        break;     case GL_R3_G3_B2:     case GL_RGB4:     case GL_RGB5:        rb->Format = MESA_FORMAT_RGB565; -      rb->DataType = GL_UNSIGNED_BYTE;        break;     case GL_RGB:     case GL_RGB8: @@ -137,7 +134,6 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer     case GL_RGB12:     case GL_RGB16:        rb->Format = MESA_FORMAT_XRGB8888; -      rb->DataType = GL_UNSIGNED_BYTE;        break;     case GL_RGBA:     case GL_RGBA2: @@ -148,16 +144,13 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer     case GL_RGBA12:     case GL_RGBA16:        rb->Format = MESA_FORMAT_ARGB8888; -      rb->DataType = GL_UNSIGNED_BYTE;        break;     case GL_ALPHA:     case GL_ALPHA8:        rb->Format = MESA_FORMAT_A8; -      rb->DataType = GL_UNSIGNED_BYTE;        break;     case GL_DEPTH_COMPONENT16:        rb->Format = MESA_FORMAT_Z16; -      rb->DataType = GL_UNSIGNED_SHORT;        break;     case GL_STENCIL_INDEX:     case GL_STENCIL_INDEX1_EXT: @@ -171,7 +164,6 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer     case GL_DEPTH24_STENCIL8_EXT:        /* alloc a depth+stencil buffer */        rb->Format = MESA_FORMAT_S8_Z24; -      rb->DataType = GL_UNSIGNED_INT_24_8_EXT;        break;     default:        _mesa_problem(ctx, @@ -180,6 +172,7 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer     }     rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat); +   rb->DataType = intel_mesa_format_to_rb_datatype(rb->Format);     cpp = _mesa_get_format_bytes(rb->Format);     intel_flush(ctx); @@ -338,39 +331,30 @@ intel_create_renderbuffer(gl_format format)     switch (format) {     case MESA_FORMAT_RGB565:        irb->Base._BaseFormat = GL_RGB; -      irb->Base.DataType = GL_UNSIGNED_BYTE;        break;     case MESA_FORMAT_XRGB8888:        irb->Base._BaseFormat = GL_RGB; -      irb->Base.DataType = GL_UNSIGNED_BYTE;        break;     case MESA_FORMAT_ARGB8888:        irb->Base._BaseFormat = GL_RGBA; -      irb->Base.DataType = GL_UNSIGNED_BYTE;        break;     case MESA_FORMAT_Z16:        irb->Base._BaseFormat = GL_DEPTH_COMPONENT; -      irb->Base.DataType = GL_UNSIGNED_SHORT;        break;     case MESA_FORMAT_X8_Z24:        irb->Base._BaseFormat = GL_DEPTH_COMPONENT; -      irb->Base.DataType = GL_UNSIGNED_INT;        break;     case MESA_FORMAT_S8_Z24:        irb->Base._BaseFormat = GL_DEPTH_STENCIL; -      irb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;        break;     case MESA_FORMAT_A8:        irb->Base._BaseFormat = GL_ALPHA; -      irb->Base.DataType = GL_UNSIGNED_BYTE;        break;     case MESA_FORMAT_R8:        irb->Base._BaseFormat = GL_RED; -      irb->Base.DataType = GL_UNSIGNED_BYTE;        break;     case MESA_FORMAT_RG88:        irb->Base._BaseFormat = GL_RG; -      irb->Base.DataType = GL_UNSIGNED_BYTE;        break;     default:        _mesa_problem(NULL, @@ -381,6 +365,7 @@ intel_create_renderbuffer(gl_format format)     irb->Base.Format = format;     irb->Base.InternalFormat = irb->Base._BaseFormat; +   irb->Base.DataType = intel_mesa_format_to_rb_datatype(format);     /* intel-specific methods */     irb->Base.Delete = intel_delete_renderbuffer; @@ -457,70 +442,16 @@ static GLboolean  intel_update_wrapper(struct gl_context *ctx, struct intel_renderbuffer *irb,   		     struct gl_texture_image *texImage)  { -   if (texImage->TexFormat == MESA_FORMAT_ARGB8888) { -      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"); -   } -#ifndef I915 -   else if (texImage->TexFormat == MESA_FORMAT_SARGB8) { -      irb->Base.DataType = GL_UNSIGNED_BYTE; -      DBG("Render to SARGB8 texture OK\n"); -   } -#endif -   else if (texImage->TexFormat == MESA_FORMAT_RGB565) { -      irb->Base.DataType = GL_UNSIGNED_BYTE; -      DBG("Render to RGB5 texture OK\n"); -   } -   else if (texImage->TexFormat == MESA_FORMAT_ARGB1555) { -      irb->Base.DataType = GL_UNSIGNED_BYTE; -      DBG("Render to ARGB1555 texture OK\n"); -   } -   else if (texImage->TexFormat == MESA_FORMAT_ARGB4444) { -      irb->Base.DataType = GL_UNSIGNED_BYTE; -      DBG("Render to ARGB4444 texture OK\n"); -   } -#ifndef I915 -   else if (texImage->TexFormat == MESA_FORMAT_A8) { -      irb->Base.DataType = GL_UNSIGNED_BYTE; -      DBG("Render to A8 texture OK\n"); -   } -   else if (texImage->TexFormat == MESA_FORMAT_R8) { -      irb->Base.DataType = GL_UNSIGNED_BYTE; -      DBG("Render to R8 texture OK\n"); -   } -   else if (texImage->TexFormat == MESA_FORMAT_RG88) { -      irb->Base.DataType = GL_UNSIGNED_BYTE; -      DBG("Render to RG88 texture OK\n"); -   } -   else if (texImage->TexFormat == MESA_FORMAT_R16) { -      irb->Base.DataType = GL_UNSIGNED_SHORT; -      DBG("Render to R8 texture OK\n"); -   } -   else if (texImage->TexFormat == MESA_FORMAT_RG1616) { -      irb->Base.DataType = GL_UNSIGNED_SHORT; -      DBG("Render to RG88 texture OK\n"); -   } -#endif -   else if (texImage->TexFormat == MESA_FORMAT_Z16) { -      irb->Base.DataType = GL_UNSIGNED_SHORT; -      DBG("Render to DEPTH16 texture OK\n"); -   } -   else if (texImage->TexFormat == MESA_FORMAT_S8_Z24) { -      irb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT; -      DBG("Render to DEPTH_STENCIL texture OK\n"); -   } -   else { +   if (!intel_span_supports_format(texImage->TexFormat)) {        DBG("Render to texture BAD FORMAT %s\n",  	  _mesa_get_format_name(texImage->TexFormat));        return GL_FALSE; +   } else { +      DBG("Render to texture %s\n", _mesa_get_format_name(texImage->TexFormat));     }     irb->Base.Format = texImage->TexFormat; - +   irb->Base.DataType = intel_mesa_format_to_rb_datatype(texImage->TexFormat);     irb->Base.InternalFormat = texImage->InternalFormat;     irb->Base._BaseFormat = _mesa_base_fbo_format(ctx, irb->Base.InternalFormat);     irb->Base.Width = texImage->Width; @@ -711,22 +642,9 @@ intel_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)  	 continue;        } -      switch (irb->Base.Format) { -      case MESA_FORMAT_ARGB8888: -      case MESA_FORMAT_XRGB8888: -      case MESA_FORMAT_RGB565: -      case MESA_FORMAT_ARGB1555: -      case MESA_FORMAT_ARGB4444: -#ifndef I915 -      case MESA_FORMAT_SARGB8: -      case MESA_FORMAT_A8: -      case MESA_FORMAT_R8: -      case MESA_FORMAT_R16: -      case MESA_FORMAT_RG88: -      case MESA_FORMAT_RG1616: -#endif -	 break; -      default: +      if (!intel_span_supports_format(irb->Base.Format)) { +	 DBG("Unsupported texture/renderbuffer format attached: %s\n", +	     _mesa_get_format_name(irb->Base.Format));  	 fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;        }     } diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c index 1c128bbfdf..1f41518535 100644 --- a/src/mesa/drivers/dri/intel/intel_span.c +++ b/src/mesa/drivers/dri/intel/intel_span.c @@ -25,6 +25,7 @@   *    **************************************************************************/ +#include <stdbool.h>  #include "main/glheader.h"  #include "main/macros.h"  #include "main/mtypes.h" @@ -359,6 +360,32 @@ intel_unmap_vertex_shader_textures(struct gl_context *ctx)     }  } +typedef void (*span_init_func)(struct gl_renderbuffer *rb); + +static span_init_func intel_span_init_funcs[MESA_FORMAT_COUNT] = +{ +   [MESA_FORMAT_A8] = intel_InitPointers_A8, +   [MESA_FORMAT_RGB565] = intel_InitPointers_RGB565, +   [MESA_FORMAT_ARGB4444] = intel_InitPointers_ARGB4444, +   [MESA_FORMAT_ARGB1555] = intel_InitPointers_ARGB1555, +   [MESA_FORMAT_XRGB8888] = intel_InitPointers_xRGB8888, +   [MESA_FORMAT_ARGB8888] = intel_InitPointers_ARGB8888, +   [MESA_FORMAT_SARGB8] = intel_InitPointers_ARGB8888, +   [MESA_FORMAT_Z16] = intel_InitDepthPointers_z16, +   [MESA_FORMAT_X8_Z24] = intel_InitDepthPointers_z24_s8, +   [MESA_FORMAT_S8_Z24] = intel_InitDepthPointers_z24_s8, +   [MESA_FORMAT_R8] = intel_InitPointers_R8, +   [MESA_FORMAT_RG88] = intel_InitPointers_RG88, +   [MESA_FORMAT_R16] = intel_InitPointers_R16, +   [MESA_FORMAT_RG1616] = intel_InitPointers_RG1616, +}; + +bool +intel_span_supports_format(gl_format format) +{ +   return intel_span_init_funcs[format] != NULL; +} +  /**   * Plug in appropriate span read/write functions for the given renderbuffer.   * These are used for the software fallbacks. @@ -369,49 +396,6 @@ intel_set_span_functions(struct intel_context *intel,  {     struct intel_renderbuffer *irb = (struct intel_renderbuffer *) rb; -   switch (irb->Base.Format) { -   case MESA_FORMAT_A8: -      intel_InitPointers_A8(rb); -      break; -   case MESA_FORMAT_RGB565: -      intel_InitPointers_RGB565(rb); -      break; -   case MESA_FORMAT_ARGB4444: -      intel_InitPointers_ARGB4444(rb); -      break; -   case MESA_FORMAT_ARGB1555: -      intel_InitPointers_ARGB1555(rb); -      break; -   case MESA_FORMAT_XRGB8888: -      intel_InitPointers_xRGB8888(rb); -      break; -   case MESA_FORMAT_ARGB8888: -   case MESA_FORMAT_SARGB8: -      intel_InitPointers_ARGB8888(rb); -      break; -   case MESA_FORMAT_Z16: -      intel_InitDepthPointers_z16(rb); -      break; -   case MESA_FORMAT_X8_Z24: -   case MESA_FORMAT_S8_Z24: -      intel_InitDepthPointers_z24_s8(rb); -      break; -   case MESA_FORMAT_R8: -      intel_InitPointers_R8(rb); -      break; -   case MESA_FORMAT_RG88: -      intel_InitPointers_RG88(rb); -      break; -   case MESA_FORMAT_R16: -      intel_InitPointers_R16(rb); -      break; -   case MESA_FORMAT_RG1616: -      intel_InitPointers_RG1616(rb); -      break; -   default: -      _mesa_problem(NULL, -		    "Unexpected MesaFormat %d in intelSetSpanFunctions", -		    irb->Base.Format); -      break; -   } +   assert(intel_span_init_funcs[irb->Base.Format]); +   intel_span_init_funcs[irb->Base.Format](rb);  } diff --git a/src/mesa/drivers/dri/intel/intel_span.h b/src/mesa/drivers/dri/intel/intel_span.h index aa8d08e843..5a4c4e8e52 100644 --- a/src/mesa/drivers/dri/intel/intel_span.h +++ b/src/mesa/drivers/dri/intel/intel_span.h @@ -28,6 +28,9 @@  #ifndef _INTEL_SPAN_H  #define _INTEL_SPAN_H +#include "main/formats.h" +#include <stdbool.h> +  extern void intelInitSpanFuncs(struct gl_context * ctx);  extern void intelSpanRenderFinish(struct gl_context * ctx); @@ -38,5 +41,6 @@ void intel_renderbuffer_unmap(struct intel_context *intel,  			      struct gl_renderbuffer *rb);  void intel_map_vertex_shader_textures(struct gl_context *ctx);  void intel_unmap_vertex_shader_textures(struct gl_context *ctx); +bool intel_span_supports_format(gl_format format);  #endif diff --git a/src/mesa/drivers/dri/intel/intel_tex.h b/src/mesa/drivers/dri/intel/intel_tex.h index 7906554e45..b638628c71 100644 --- a/src/mesa/drivers/dri/intel/intel_tex.h +++ b/src/mesa/drivers/dri/intel/intel_tex.h @@ -42,6 +42,7 @@ void intelInitTextureCopyImageFuncs(struct dd_function_table *functions);  gl_format intelChooseTextureFormat(struct gl_context *ctx, GLint internalFormat,                                     GLenum format, GLenum type); +GLenum intel_mesa_format_to_rb_datatype(gl_format format);  void intelSetTexBuffer(__DRIcontext *pDRICtx,  		       GLint target, __DRIdrawable *pDraw); diff --git a/src/mesa/drivers/dri/intel/intel_tex_format.c b/src/mesa/drivers/dri/intel/intel_tex_format.c index f8316ae2f8..c9763c9ae1 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_format.c +++ b/src/mesa/drivers/dri/intel/intel_tex_format.c @@ -4,6 +4,39 @@  #include "main/formats.h"  /** + * Returns the renderbuffer DataType for a MESA_FORMAT. + */ +GLenum +intel_mesa_format_to_rb_datatype(gl_format format) +{ +   switch (format) { +   case MESA_FORMAT_ARGB8888: +   case MESA_FORMAT_XRGB8888: +   case MESA_FORMAT_SARGB8: +   case MESA_FORMAT_R8: +   case MESA_FORMAT_RG88: +   case MESA_FORMAT_A8: +   case MESA_FORMAT_AL88: +   case MESA_FORMAT_RGB565: +   case MESA_FORMAT_ARGB1555: +   case MESA_FORMAT_ARGB4444: +      return GL_UNSIGNED_BYTE; +   case MESA_FORMAT_R16: +   case MESA_FORMAT_RG1616: +   case MESA_FORMAT_Z16: +      return GL_UNSIGNED_SHORT; +   case MESA_FORMAT_X8_Z24: +      return GL_UNSIGNED_INT; +   case MESA_FORMAT_S8_Z24: +      return GL_UNSIGNED_INT_24_8_EXT; +   default: +      _mesa_problem(NULL, "unexpected MESA_FORMAT for renderbuffer"); +      return GL_UNSIGNED_BYTE; +   } +} + + +/**   * Choose hardware texture format given the user's glTexImage parameters.   *   * It works out that this function is fine for all the supported  | 
