intel: update intel_create_renderbuffer(format), add XRGB support
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.
This commit is contained in:
@@ -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:
|
||||
|
@@ -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:
|
||||
|
@@ -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:
|
||||
|
@@ -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:
|
||||
|
@@ -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;
|
||||
|
@@ -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:
|
||||
|
@@ -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:
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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:
|
||||
|
@@ -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:
|
||||
|
Reference in New Issue
Block a user