summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2010-02-24 11:10:47 -0700
committerBrian Paul <[email protected]>2010-02-24 11:10:47 -0700
commit87c85347ed8f74a855532fe6862d3ef62937ccbb (patch)
tree9ffa768a80f466fc6643ac9a97e7f3cf4331ad16 /src/mesa/state_tracker
parent5d8aae55f29fe35ec3d514b54b05b6c6fc8bebe2 (diff)
st/mesa: clean-up of format-related code
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c9
-rw-r--r--src/mesa/state_tracker/st_format.c60
-rw-r--r--src/mesa/state_tracker/st_format.h21
3 files changed, 13 insertions, 77 deletions
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index 906eccdc09f..0898866a735 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -57,11 +57,11 @@
/**
* Compute the renderbuffer's Red/Green/EtcBit fields from the pipe format.
*/
-static int
+static void
init_renderbuffer_bits(struct st_renderbuffer *strb,
enum pipe_format pipeFormat)
{
- struct pipe_format_info info;
+ struct st_format_info info;
if (!st_get_format_info( pipeFormat, &info )) {
assert( 0 );
@@ -69,10 +69,9 @@ init_renderbuffer_bits(struct st_renderbuffer *strb,
strb->Base.Format = info.mesa_format;
strb->Base.DataType = st_format_datatype(pipeFormat);
-
- return info.size;
}
+
/**
* gl_renderbuffer::AllocStorage()
* This is called to allocate the original drawing surface, and
@@ -99,7 +98,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
strb->defined = GL_FALSE; /* undefined contents now */
- if(strb->software) {
+ if (strb->software) {
size_t size;
free(strb->data);
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 3100a4edaa5..8789d4b750a 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -59,23 +59,12 @@ format_max_bits(enum pipe_format format)
return size;
}
-static GLuint
-format_size(enum pipe_format format)
-{
- return
- util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0) +
- util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 1) +
- util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 2) +
- util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 3) +
- util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0) +
- util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1);
-}
/*
* XXX temporary here
*/
GLboolean
-st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo)
+st_get_format_info(enum pipe_format format, struct st_format_info *pinfo)
{
const struct util_format_description *desc;
@@ -118,43 +107,15 @@ st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo)
}
}
- /* Component bits */
- pinfo->red_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0);
- pinfo->green_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 1);
- pinfo->blue_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 2);
- pinfo->alpha_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 3);
- pinfo->depth_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0);
- pinfo->stencil_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1);
- pinfo->luminance_bits = 0;
- pinfo->intensity_bits = 0;
-
- /* Format size */
- pinfo->size = format_size(format) / 8;
-
- /* Luminance & Intensity bits */
- if (desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_X &&
- desc->swizzle[1] == UTIL_FORMAT_SWIZZLE_X &&
- desc->swizzle[2] == UTIL_FORMAT_SWIZZLE_X) {
- if (desc->swizzle[3] == UTIL_FORMAT_SWIZZLE_X) {
- pinfo->intensity_bits = pinfo->red_bits;
- }
- else {
- pinfo->luminance_bits = pinfo->red_bits;
- }
- pinfo->red_bits = 0;
- }
-
pinfo->mesa_format = st_pipe_format_to_mesa_format(format);
}
else if (format == PIPE_FORMAT_YCBCR) {
pinfo->mesa_format = MESA_FORMAT_YCBCR;
pinfo->datatype = GL_UNSIGNED_SHORT;
- pinfo->size = 2; /* two bytes per "texel" */
}
else if (format == PIPE_FORMAT_YCBCR_REV) {
pinfo->mesa_format = MESA_FORMAT_YCBCR_REV;
pinfo->datatype = GL_UNSIGNED_SHORT;
- pinfo->size = 2; /* two bytes per "texel" */
}
else {
/* compressed format? */
@@ -179,27 +140,12 @@ st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo)
/**
- * Return bytes per pixel for the given format.
- */
-GLuint
-st_sizeof_format(enum pipe_format format)
-{
- struct pipe_format_info info;
- if (!st_get_format_info( format, &info )) {
- assert( 0 );
- return 0;
- }
- return info.size;
-}
-
-
-/**
- * Return bytes per pixel for the given format.
+ * Return basic GL datatype for the given format.
*/
GLenum
st_format_datatype(enum pipe_format format)
{
- struct pipe_format_info info;
+ struct st_format_info info;
if (!st_get_format_info( format, &info )) {
assert( 0 );
return 0;
diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h
index 7cddf5aa66a..721c6aeb3d8 100644
--- a/src/mesa/state_tracker/st_format.h
+++ b/src/mesa/state_tracker/st_format.h
@@ -31,29 +31,20 @@
#include "main/formats.h"
-struct pipe_format_info
+
+/**
+ * Information for mapping Mesa formats to Gallium formats.
+ */
+struct st_format_info
{
enum pipe_format format;
gl_format mesa_format;
GLenum datatype;
- GLubyte red_bits;
- GLubyte green_bits;
- GLubyte blue_bits;
- GLubyte alpha_bits;
- GLubyte luminance_bits;
- GLubyte intensity_bits;
- GLubyte depth_bits;
- GLubyte stencil_bits;
- GLubyte size; /**< in bytes */
};
GLboolean
-st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo);
-
-
-extern GLuint
-st_sizeof_format(enum pipe_format format);
+st_get_format_info(enum pipe_format format, struct st_format_info *pinfo);
extern GLenum