swImg->ImageOffsets[i] = i * width * height;
}
+ _swrast_init_texture_image(texImage, width, height, depth);
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Code that overrides ctx->Driver.AllocTextureImageBuffer may use this to
+ * initialize the fields of swrast_texture_image without allocating the image
+ * buffer or initializing ImageOffsets or RowStride.
+ *
+ * Returns GL_TRUE on success, GL_FALSE on memory allocation failure.
+ */
+void
+_swrast_init_texture_image(struct gl_texture_image *texImage, GLsizei width,
+ GLsizei height, GLsizei depth)
+{
+ struct swrast_texture_image *swImg = swrast_texture_image(texImage);
+
if ((width == 1 || _mesa_is_pow_two(texImage->Width2)) &&
(height == 1 || _mesa_is_pow_two(texImage->Height2)) &&
(depth == 1 || _mesa_is_pow_two(texImage->Depth2)))
swImg->HeightScale = (GLfloat) texImage->Height;
swImg->DepthScale = (GLfloat) texImage->Depth;
}
-
- return GL_TRUE;
}
stride = _mesa_format_row_stride(texImage->TexFormat, texImage->Width);
_mesa_get_format_block_size(texImage->TexFormat, &bw, &bh);
- assert(swImage->Buffer);
+ assert(x % bw == 0);
+ assert(y % bh == 0);
+ if (!swImage->Buffer) {
+ /* probably ran out of memory when allocating tex mem */
+ *mapOut = NULL;
+ return;
+ }
+
map = swImage->Buffer;
if (texImage->TexObject->Target == GL_TEXTURE_3D ||
swrast_texture_image(texImage);
/* XXX we'll eventually call _swrast_map_teximage() here */
- swImage->Data = swImage->Buffer;
+ swImage->Map = swImage->Buffer;
}
}
}
= swrast_texture_image(texImage);
/* XXX we'll eventually call _swrast_unmap_teximage() here */
- swImage->Data = NULL;
+ swImage->Map = NULL;
}
}
}
/* loop over enabled texture units */
while (enabledUnits) {
- GLuint unit = _mesa_ffs(enabledUnits) - 1;
+ GLuint unit = ffs(enabledUnits) - 1;
struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current;
_swrast_map_texture(ctx, texObj);
/* loop over enabled texture units */
while (enabledUnits) {
- GLuint unit = _mesa_ffs(enabledUnits) - 1;
+ GLuint unit = ffs(enabledUnits) - 1;
struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current;
_swrast_unmap_texture(ctx, texObj);
}
-/**
- * Map or unmap any textures that we may be rendering to as renderbuffers.
- */
-static void
-map_unmap_renderbuffers(struct gl_context *ctx,
- struct gl_framebuffer *fb,
- GLboolean map)
-{
- GLuint i;
-
- for (i = 0; i < Elements(fb->Attachment); i++) {
- struct gl_texture_object *texObj = fb->Attachment[i].Texture;
- if (texObj) {
- const GLuint level = fb->Attachment[i].TextureLevel;
- const GLuint face = fb->Attachment[i].CubeMapFace;
- struct gl_texture_image *texImage = texObj->Image[face][level];
- if (texImage) {
- struct swrast_texture_image *swImage
- = swrast_texture_image(texImage);
-
- if (map) {
- /* XXX we'll eventually call _swrast_map_teximage() here */
- swImage->Data = swImage->Buffer;
- }
- else {
- /* XXX we'll eventually call _swrast_unmap_teximage() here */
- swImage->Data = NULL;
- }
- }
- }
- }
-}
-
-
-void
-_swrast_map_renderbuffers(struct gl_context *ctx)
-{
- map_unmap_renderbuffers(ctx, ctx->DrawBuffer, GL_TRUE);
- if (ctx->ReadBuffer != ctx->DrawBuffer)
- map_unmap_renderbuffers(ctx, ctx->ReadBuffer, GL_TRUE);
-}
-
-
-void
-_swrast_unmap_renderbuffers(struct gl_context *ctx)
-{
- map_unmap_renderbuffers(ctx, ctx->DrawBuffer, GL_FALSE);
- if (ctx->ReadBuffer != ctx->DrawBuffer)
- map_unmap_renderbuffers(ctx, ctx->ReadBuffer, GL_FALSE);
-}
-
-
-
/**
* Called via ctx->Driver.AllocTextureStorage()
* Just have to allocate memory for the texture images.