summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2009-11-20 10:45:36 -0800
committerIan Romanick <ian.d.romanick@intel.com>2010-10-01 15:49:13 -0700
commitc77cd9ec10f7c6ad2927740e15900591d1ff388a (patch)
treefe9966623851f5a2698d173774691a62f6815378
parent9ef390dc14edd0adc0fa0d07c64621b0f220edd8 (diff)
i965: Enable GL_ARB_texture_rg
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_surface_state.c24
-rw-r--r--src/mesa/drivers/dri/intel/intel_extensions.c1
-rw-r--r--src/mesa/drivers/dri/intel/intel_fbo.c46
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_format.c20
4 files changed, 91 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 05f1aa1813..37104f1f23 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -89,6 +89,18 @@ static GLuint translate_tex_format( gl_format mesa_format,
case MESA_FORMAT_AL1616:
return BRW_SURFACEFORMAT_L16A16_UNORM;
+ case MESA_FORMAT_R8:
+ return BRW_SURFACEFORMAT_R8_UNORM;
+
+ case MESA_FORMAT_R16:
+ return BRW_SURFACEFORMAT_R16_UNORM;
+
+ case MESA_FORMAT_RG88:
+ return BRW_SURFACEFORMAT_R8G8_UNORM;
+
+ case MESA_FORMAT_RG1616:
+ return BRW_SURFACEFORMAT_R16G16_UNORM;
+
case MESA_FORMAT_RGB888:
assert(0); /* not supported for sampling */
return BRW_SURFACEFORMAT_R8G8B8_UNORM;
@@ -444,6 +456,18 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
case MESA_FORMAT_A8:
key.surface_format = BRW_SURFACEFORMAT_A8_UNORM;
break;
+ case MESA_FORMAT_R8:
+ key.surface_format = BRW_SURFACEFORMAT_R8_UNORM;
+ break;
+ case MESA_FORMAT_R16:
+ key.surface_format = BRW_SURFACEFORMAT_R16_UNORM;
+ break;
+ case MESA_FORMAT_RG88:
+ key.surface_format = BRW_SURFACEFORMAT_R8G8_UNORM;
+ break;
+ case MESA_FORMAT_RG1616:
+ key.surface_format = BRW_SURFACEFORMAT_R16G16_UNORM;
+ break;
default:
_mesa_problem(ctx, "Bad renderbuffer format: %d\n", irb->Base.Format);
}
diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c b/src/mesa/drivers/dri/intel/intel_extensions.c
index d741f82767..b1b29d8526 100644
--- a/src/mesa/drivers/dri/intel/intel_extensions.c
+++ b/src/mesa/drivers/dri/intel/intel_extensions.c
@@ -166,6 +166,7 @@ static const struct dri_extension brw_extensions[] = {
{ "GL_ARB_shadow", NULL },
{ "GL_MESA_texture_signed_rgba", NULL },
{ "GL_ARB_texture_non_power_of_two", NULL },
+ { "GL_ARB_texture_rg", NULL },
{ "GL_EXT_draw_buffers2", GL_EXT_draw_buffers2_functions },
{ "GL_EXT_shadow_funcs", NULL },
{ "GL_EXT_stencil_two_side", GL_EXT_stencil_two_side_functions },
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index 8c0491d59a..a70c83b39d 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -107,6 +107,24 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
ASSERT(rb->Name != 0);
switch (internalFormat) {
+ 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:
@@ -346,6 +364,14 @@ intel_create_renderbuffer(gl_format format)
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,
"Unexpected intFormat in intel_create_renderbuffer");
@@ -459,6 +485,22 @@ intel_update_wrapper(GLcontext *ctx, struct intel_renderbuffer *irb,
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");
+ }
else if (texImage->TexFormat == MESA_FORMAT_Z16) {
irb->Base.DataType = GL_UNSIGNED_SHORT;
DBG("Render to DEPTH16 texture OK\n");
@@ -673,6 +715,10 @@ intel_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
case MESA_FORMAT_ARGB1555:
case MESA_FORMAT_ARGB4444:
case MESA_FORMAT_A8:
+ case MESA_FORMAT_R8:
+ case MESA_FORMAT_R16:
+ case MESA_FORMAT_RG88:
+ case MESA_FORMAT_RG1616:
break;
default:
fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
diff --git a/src/mesa/drivers/dri/intel/intel_tex_format.c b/src/mesa/drivers/dri/intel/intel_tex_format.c
index e03b203fb4..97b26efcb7 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_format.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_format.c
@@ -93,6 +93,10 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
case GL_LUMINANCE12_ALPHA4:
case GL_LUMINANCE12_ALPHA12:
case GL_LUMINANCE16_ALPHA16:
+ /* i915 could implement this mode using MT_32BIT_RG1616. However, this
+ * would require an extra swizzle instruction in the fragment shader to
+ * convert the { R, G, 1.0, 1.0 } to { R, R, R, G }.
+ */
#ifndef I915
return MESA_FORMAT_AL1616;
#else
@@ -193,6 +197,22 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
case GL_RGBA_SNORM:
case GL_RGBA8_SNORM:
return MESA_FORMAT_SIGNED_RGBA8888_REV;
+
+ /* i915 can do a RG16, but it can't do any of the other RED or RG formats.
+ * In addition, it only implements the broken D3D mode where undefined
+ * components are read as 1.0. I'm not sure who thought reading
+ * { R, G, 1.0, 1.0 } from a red-green texture would be useful.
+ */
+ case GL_RED:
+ case GL_R8:
+ return MESA_FORMAT_R8;
+ case GL_R16:
+ return MESA_FORMAT_R16;
+ case GL_RG:
+ case GL_RG8:
+ return MESA_FORMAT_RG88;
+ case GL_RG16:
+ return MESA_FORMAT_RG1616;
#endif
default: