summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian <[email protected]>2008-02-05 18:13:28 -0700
committerBrian <[email protected]>2008-02-06 09:35:39 -0700
commitafc54983370033b65e3a7cbb29bd9c87156f0881 (patch)
treef9f8f40d31eea835819df31d85068a52976db5b6
parent105b3596be6c0644e3aaa0823ab7e27aa76fa909 (diff)
clean-ups
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c67
1 files changed, 29 insertions, 38 deletions
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index ba0950e2950..eee94baa20c 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -76,13 +76,13 @@ struct st_texture_object
-
static INLINE struct st_texture_object *
st_texture_object(struct gl_texture_object *obj)
{
return (struct st_texture_object *) obj;
}
+
static INLINE struct st_texture_image *
st_texture_image(struct gl_texture_image *img)
{
@@ -122,32 +122,28 @@ gl_target_to_pipe(GLenum target)
}
+/**
+ * Return nominal bytes per texel for a compressed format, 0 for non-compressed
+ * format.
+ */
static int
compressed_num_bytes(GLuint mesaFormat)
{
- int bytes = 0;
switch(mesaFormat) {
-
case MESA_FORMAT_RGB_FXT1:
case MESA_FORMAT_RGBA_FXT1:
case MESA_FORMAT_RGB_DXT1:
case MESA_FORMAT_RGBA_DXT1:
- bytes = 2;
- break;
-
+ return 2;
case MESA_FORMAT_RGBA_DXT3:
case MESA_FORMAT_RGBA_DXT5:
- bytes = 4;
+ return 4;
default:
- break;
+ return 0;
}
-
- return bytes;
}
-
-
static GLboolean
st_IsTextureResident(GLcontext * ctx, struct gl_texture_object *texObj)
{
@@ -164,7 +160,6 @@ st_IsTextureResident(GLcontext * ctx, struct gl_texture_object *texObj)
}
-
static struct gl_texture_image *
st_NewTextureImage(GLcontext * ctx)
{
@@ -216,8 +211,6 @@ st_FreeTextureImageData(GLcontext * ctx, struct gl_texture_image *texImage)
}
-
-
/* ================================================================
* From linux kernel i386 header files, copes with odd sizes better
* than COPY_DWORDS would:
@@ -302,7 +295,7 @@ logbase2(int n)
static void
guess_and_alloc_texture(struct st_context *st,
struct st_texture_object *stObj,
- struct st_texture_image *stImage)
+ const struct st_texture_image *stImage)
{
GLuint firstLevel;
GLuint lastLevel;
@@ -487,21 +480,18 @@ try_pbo_upload(GLcontext *ctx,
-
-
-
-
static void
st_TexImage(GLcontext * ctx,
- GLint dims,
- GLenum target, GLint level,
- GLint internalFormat,
- GLint width, GLint height, GLint depth,
- GLint border,
- GLenum format, GLenum type, const void *pixels,
- const struct gl_pixelstore_attrib *unpack,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage, GLsizei imageSize, int compressed)
+ GLint dims,
+ GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint depth,
+ GLint border,
+ GLenum format, GLenum type, const void *pixels,
+ const struct gl_pixelstore_attrib *unpack,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage,
+ GLsizei imageSize, int compressed)
{
struct st_texture_object *stObj = st_texture_object(texObj);
struct st_texture_image *stImage = st_texture_image(texImage);
@@ -524,7 +514,7 @@ st_TexImage(GLcontext * ctx,
/* choose the texture format */
texImage->TexFormat = st_ChooseTextureFormat(ctx, internalFormat,
- format, type);
+ format, type);
_mesa_set_fetch_functions(texImage, dims);
@@ -536,7 +526,8 @@ st_TexImage(GLcontext * ctx,
ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
texImage->Height, texImage->Depth,
texImage->TexFormat->MesaFormat);
- } else {
+ }
+ else {
texelBytes = texImage->TexFormat->TexelBytes;
/* Minimum pitch of 32 bytes */
@@ -669,7 +660,7 @@ st_TexImage(GLcontext * ctx,
* conversion and copy:
*/
if (compressed) {
- memcpy(texImage->Data, pixels, imageSize);
+ memcpy(texImage->Data, pixels, imageSize);
}
else {
GLuint srcImageStride = _mesa_image_image_stride(unpack, width, height,
@@ -1401,7 +1392,10 @@ copy_image_data_to_texture(struct st_context *st,
}
-/*
+/**
+ * Called during state validation. When this function is finished,
+ * the texture object should be ready for rendering.
+ * \return GL_FALSE if a texture border is present, GL_TRUE otherwise
*/
GLboolean
st_finalize_texture(GLcontext *ctx,
@@ -1410,11 +1404,10 @@ st_finalize_texture(GLcontext *ctx,
GLboolean *needFlush)
{
struct st_texture_object *stObj = st_texture_object(tObj);
+ const GLuint nr_faces = (stObj->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
int comp_byte = 0;
int cpp;
-
GLuint face, i;
- GLuint nr_faces = 0;
struct st_texture_image *firstImage;
*needFlush = GL_FALSE;
@@ -1426,8 +1419,7 @@ st_finalize_texture(GLcontext *ctx,
/* What levels must the texture include at a minimum?
*/
calculate_first_last_level(stObj);
- firstImage =
- st_texture_image(stObj->base.Image[0][stObj->firstLevel]);
+ firstImage = st_texture_image(stObj->base.Image[0][stObj->firstLevel]);
/* Fallback case:
*/
@@ -1503,7 +1495,6 @@ st_finalize_texture(GLcontext *ctx,
/* Pull in any images not in the object's texture:
*/
- nr_faces = (stObj->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
for (face = 0; face < nr_faces; face++) {
for (i = stObj->firstLevel; i <= stObj->lastLevel; i++) {
struct st_texture_image *stImage =