i965: Add support for GL_EXT_texture_array and GL_MESA_texture_array.

This commit is contained in:
Eric Anholt 2011-09-06 10:21:54 -07:00
parent 82691574b6
commit 669f1822d2
9 changed files with 43 additions and 5 deletions

View file

@ -100,6 +100,11 @@ GLboolean brwCreateContext( int api,
ctx->Const.MaxTextureLevels = MAX_TEXTURE_LEVELS;
ctx->Const.Max3DTextureLevels = 9;
ctx->Const.MaxCubeTextureLevels = 12;
/* minimum maximum. Users are likely to run into memory problems
* even at this size, since 64 * 2048 * 2048 * 4 = 1GB and we can't
* address that much.
*/
ctx->Const.MaxArrayTextureLayers = 64;
ctx->Const.MaxTextureRectSize = (1<<12);
ctx->Const.MaxTextureMaxAnisotropy = 16.0;

View file

@ -168,6 +168,11 @@ brw_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree *mt)
break;
}
case GL_TEXTURE_2D_ARRAY:
case GL_TEXTURE_1D_ARRAY:
brw_miptree_layout_texture_array(intel, mt, mt->depth0);
break;
default:
i945_miptree_layout_2d(mt, 1);
break;

View file

@ -1076,11 +1076,13 @@ void emit_tex(struct brw_wm_compile *c,
nr_texcoords = 1;
break;
case TEXTURE_2D_INDEX:
case TEXTURE_1D_ARRAY_INDEX:
case TEXTURE_RECT_INDEX:
emit = WRITEMASK_XY;
nr_texcoords = 2;
break;
case TEXTURE_3D_INDEX:
case TEXTURE_2D_ARRAY_INDEX:
case TEXTURE_CUBE_INDEX:
emit = WRITEMASK_XYZ;
nr_texcoords = 3;

View file

@ -93,8 +93,10 @@ static GLuint get_texcoord_mask( GLuint tex_idx )
case TEXTURE_1D_INDEX:
return WRITEMASK_X;
case TEXTURE_2D_INDEX:
case TEXTURE_1D_ARRAY_INDEX:
return WRITEMASK_XY;
case TEXTURE_3D_INDEX:
case TEXTURE_2D_ARRAY_INDEX:
return WRITEMASK_XYZ;
case TEXTURE_CUBE_INDEX:
return WRITEMASK_XYZ;

View file

@ -50,12 +50,14 @@ translate_tex_target(GLenum target)
{
switch (target) {
case GL_TEXTURE_1D:
case GL_TEXTURE_1D_ARRAY_EXT:
return BRW_SURFACE_1D;
case GL_TEXTURE_RECTANGLE_NV:
return BRW_SURFACE_2D;
case GL_TEXTURE_2D:
case GL_TEXTURE_2D_ARRAY_EXT:
return BRW_SURFACE_2D;
case GL_TEXTURE_3D:

View file

@ -116,12 +116,14 @@ intelInitExtensions(struct gl_context *ctx)
ctx->Extensions.ARB_texture_rg = true;
ctx->Extensions.EXT_draw_buffers2 = true;
ctx->Extensions.EXT_framebuffer_sRGB = true;
ctx->Extensions.EXT_texture_array = true;
ctx->Extensions.EXT_texture_snorm = true;
ctx->Extensions.EXT_texture_sRGB = true;
ctx->Extensions.EXT_texture_sRGB_decode = true;
ctx->Extensions.EXT_texture_swizzle = true;
ctx->Extensions.EXT_vertex_array_bgra = true;
ctx->Extensions.ATI_envmap_bumpmap = true;
ctx->Extensions.MESA_texture_array = true;
ctx->Extensions.NV_conditional_render = true;
}

View file

@ -319,15 +319,22 @@ intel_miptree_get_image_offset(struct intel_mipmap_tree *mt,
GLuint level, GLuint face, GLuint depth,
GLuint *x, GLuint *y)
{
if (mt->target == GL_TEXTURE_CUBE_MAP_ARB) {
switch (mt->target) {
case GL_TEXTURE_CUBE_MAP_ARB:
*x = mt->level[level].x_offset[face];
*y = mt->level[level].y_offset[face];
} else if (mt->target == GL_TEXTURE_3D) {
break;
case GL_TEXTURE_3D:
case GL_TEXTURE_2D_ARRAY_EXT:
case GL_TEXTURE_1D_ARRAY_EXT:
assert(depth < mt->level[level].nr_images);
*x = mt->level[level].x_offset[depth];
*y = mt->level[level].y_offset[depth];
} else {
break;
default:
*x = mt->level[level].x_offset[0];
*y = mt->level[level].y_offset[0];
break;
}
}

View file

@ -58,6 +58,7 @@ void i945_miptree_layout_2d(struct intel_mipmap_tree *mt, int nr_images)
GLuint y = 0;
GLuint width = mt->width0;
GLuint height = mt->height0;
GLuint depth = mt->depth0; /* number of array layers. */
mt->total_width = mt->width0;
intel_get_texture_alignment_unit(mt->format, &align_w, &align_h);
@ -93,7 +94,7 @@ void i945_miptree_layout_2d(struct intel_mipmap_tree *mt, int nr_images)
GLuint img_height;
intel_miptree_set_level_info(mt, level, nr_images, x, y, width,
height, 1);
height, depth);
img_height = ALIGN(height, align_h);
if (mt->compressed)

View file

@ -138,9 +138,21 @@ intel_tex_map_image_for_swrast(struct intel_context *intel,
mt = intel_image->mt;
if (mt->target == GL_TEXTURE_3D) {
if (mt->target == GL_TEXTURE_3D ||
mt->target == GL_TEXTURE_2D_ARRAY ||
mt->target == GL_TEXTURE_1D_ARRAY) {
int i;
if (mt->target == GL_TEXTURE_2D_ARRAY ||
mt->target == GL_TEXTURE_1D_ARRAY) {
/* Mesa only allocates one entry for these, but we really do have an
* offset per depth.
*/
free(intel_image->base.Base.ImageOffsets);
intel_image->base.Base.ImageOffsets = malloc(mt->level[level].depth *
sizeof(GLuint));
}
/* ImageOffsets[] is only used for swrast's fetch_texel_3d, so we can't
* share code with the normal path.
*/