static GLboolean intel_alloc_texture_image_buffer(struct gl_context *ctx, struct gl_texture_image *image) { struct intel_context *intel = intel_context(ctx); struct intel_texture_image *intel_image = intel_texture_image(image); struct gl_texture_object *texobj = image->TexObject; struct intel_texture_object *intel_texobj = intel_texture_object(texobj); GLuint slices; assert(image->Border == 0); /* Because the driver uses AllocTextureImageBuffer() internally, it may end * up mismatched with FreeTextureImageBuffer(), but that is safe to call * multiple times. */ ctx->Driver.FreeTextureImageBuffer(ctx, image); /* Allocate the swrast_texture_image::ImageOffsets array now */ switch (texobj->Target) { case GL_TEXTURE_3D: case GL_TEXTURE_2D_ARRAY: slices = image->Depth; break; case GL_TEXTURE_1D_ARRAY: slices = image->Height; break; default: slices = 1; } assert(!intel_image->base.ImageOffsets); intel_image->base.ImageOffsets = malloc(slices * sizeof(GLuint)); _swrast_init_texture_image(image); if (intel_texobj->mt && intel_miptree_match_image(intel_texobj->mt, image)) { intel_miptree_reference(&intel_image->mt, intel_texobj->mt); DBG("%s: alloc obj %p level %d %dx%dx%d using object's miptree %p\n", __FUNCTION__, texobj, image->Level, image->Width, image->Height, image->Depth, intel_texobj->mt); } else { intel_image->mt = intel_miptree_create_for_teximage(intel, intel_texobj, intel_image, false); /* Even if the object currently has a mipmap tree associated * with it, this one is a more likely candidate to represent the * whole object since our level didn't fit what was there * before, and any lower levels would fit into our miptree. */ intel_miptree_reference(&intel_texobj->mt, intel_image->mt); DBG("%s: alloc obj %p level %d %dx%dx%d using new miptree %p\n", __FUNCTION__, texobj, image->Level, image->Width, image->Height, image->Depth, intel_image->mt); } return true; }
static GLboolean intel_alloc_texture_image_buffer(struct gl_context *ctx, struct gl_texture_image *image) { struct brw_context *brw = brw_context(ctx); struct intel_texture_image *intel_image = intel_texture_image(image); struct gl_texture_object *texobj = image->TexObject; struct intel_texture_object *intel_texobj = intel_texture_object(texobj); assert(image->Border == 0); /* Quantize sample count */ if (image->NumSamples) { image->NumSamples = intel_quantize_num_samples(brw->screen, image->NumSamples); if (!image->NumSamples) return false; } /* Because the driver uses AllocTextureImageBuffer() internally, it may end * up mismatched with FreeTextureImageBuffer(), but that is safe to call * multiple times. */ ctx->Driver.FreeTextureImageBuffer(ctx, image); if (!_swrast_init_texture_image(image)) return false; if (intel_texobj->mt && intel_miptree_match_image(intel_texobj->mt, image)) { intel_miptree_reference(&intel_image->mt, intel_texobj->mt); DBG("%s: alloc obj %p level %d %dx%dx%d using object's miptree %p\n", __func__, texobj, image->Level, image->Width, image->Height, image->Depth, intel_texobj->mt); } else { intel_image->mt = intel_miptree_create_for_teximage(brw, intel_texobj, intel_image, MIPTREE_CREATE_DEFAULT); if (!intel_image->mt) return false; /* Even if the object currently has a mipmap tree associated * with it, this one is a more likely candidate to represent the * whole object since our level didn't fit what was there * before, and any lower levels would fit into our miptree. */ intel_miptree_reference(&intel_texobj->mt, intel_image->mt); DBG("%s: alloc obj %p level %d %dx%dx%d using new miptree %p\n", __func__, texobj, image->Level, image->Width, image->Height, image->Depth, intel_image->mt); } intel_texobj->needs_validate = true; return true; }