diff options
author | Brian <[email protected]> | 2007-10-14 11:55:31 -0600 |
---|---|---|
committer | Brian <[email protected]> | 2007-10-14 11:55:31 -0600 |
commit | 7b0b694406e4043cb163f9832c9c02934fa54568 (patch) | |
tree | b6c33b4483eecd2542a0cca834aa0b1f3678ee61 /src/mesa/state_tracker | |
parent | d45fdc3f1f8200c1f1703bdcd5a74a153c74b1c4 (diff) |
16-bit rgba surface/format for accum
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_cb_fbo.c | 12 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_format.c | 49 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_format.h | 5 |
3 files changed, 57 insertions, 9 deletions
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 3e4aeab5236..e1cc7d98bd6 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -70,14 +70,6 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, if (!info) return GL_FALSE; - switch (pipeFormat) { - case PIPE_FORMAT_S8_Z24: - strb->Base.DataType = GL_UNSIGNED_INT; - break; - default: - strb->Base.DataType = GL_UNSIGNED_BYTE; /* XXX fix */ - } - strb->Base._ActualFormat = info->base_format; strb->Base.RedBits = info->red_bits; strb->Base.GreenBits = info->green_bits; @@ -85,6 +77,9 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, strb->Base.AlphaBits = info->alpha_bits; strb->Base.DepthBits = info->depth_bits; strb->Base.StencilBits = info->stencil_bits; + strb->Base.DataType = st_format_datatype(pipeFormat); + + assert(strb->Base.DataType); cpp = info->size; @@ -229,6 +224,7 @@ st_new_renderbuffer_fb(GLenum intFormat) switch (intFormat) { case GL_RGB5: case GL_RGBA8: + case GL_RGBA16: strb->Base._BaseFormat = GL_RGBA; break; case GL_DEPTH_COMPONENT16: diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 2d20892cb00..7564c6014ee 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -54,6 +54,7 @@ st_get_format_info(GLuint format) { PIPE_FORMAT_U_R8_G8_B8_A8, /* format */ GL_RGBA, /* base_format */ + GL_UNSIGNED_BYTE, /* datatype for renderbuffers */ 8, 8, 8, 8, 0, 0, /* color bits */ 0, 0, /* depth, stencil */ 4 /* size in bytes */ @@ -61,6 +62,7 @@ st_get_format_info(GLuint format) { PIPE_FORMAT_U_A8_R8_G8_B8, GL_RGBA, /* base_format */ + GL_UNSIGNED_BYTE, /* datatype for renderbuffers */ 8, 8, 8, 8, 0, 0, /* color bits */ 0, 0, /* depth, stencil */ 4 /* size in bytes */ @@ -68,6 +70,7 @@ st_get_format_info(GLuint format) { PIPE_FORMAT_U_A1_R5_G5_B5, GL_RGBA, /* base_format */ + GL_UNSIGNED_SHORT, /* datatype for renderbuffers */ 5, 5, 5, 1, 0, 0, /* color bits */ 0, 0, /* depth, stencil */ 2 /* size in bytes */ @@ -75,13 +78,23 @@ st_get_format_info(GLuint format) { PIPE_FORMAT_U_R5_G6_B5, GL_RGBA, /* base_format */ + GL_UNSIGNED_SHORT, /* datatype for renderbuffers */ 5, 6, 5, 0, 0, 0, /* color bits */ 0, 0, /* depth, stencil */ 2 /* size in bytes */ }, { + PIPE_FORMAT_S_R16_G16_B16_A16, + GL_RGBA, /* base_format */ + GL_UNSIGNED_SHORT, /* datatype for renderbuffers */ + 16, 16, 16, 16, 0, 0, /* color bits */ + 0, 0, /* depth, stencil */ + 8 /* size in bytes */ + }, + { PIPE_FORMAT_U_Z16, GL_DEPTH_COMPONENT, /* base_format */ + GL_UNSIGNED_SHORT, /* datatype for renderbuffers */ 0, 0, 0, 0, 0, 0, /* color bits */ 16, 0, /* depth, stencil */ 2 /* size in bytes */ @@ -89,6 +102,7 @@ st_get_format_info(GLuint format) { PIPE_FORMAT_U_Z32, GL_DEPTH_COMPONENT, /* base_format */ + GL_UNSIGNED_INT, /* datatype for renderbuffers */ 0, 0, 0, 0, 0, 0, /* color bits */ 32, 0, /* depth, stencil */ 4 /* size in bytes */ @@ -96,6 +110,7 @@ st_get_format_info(GLuint format) { PIPE_FORMAT_S8_Z24, GL_DEPTH_STENCIL_EXT, /* base_format */ + GL_UNSIGNED_INT, /* datatype for renderbuffers */ 0, 0, 0, 0, 0, 0, /* color bits */ 24, 8, /* depth, stencil */ 4 /* size in bytes */ @@ -112,6 +127,9 @@ st_get_format_info(GLuint format) } +/** + * Return bytes per pixel for the given format. + */ GLuint st_sizeof_format(GLuint pipeFormat) { @@ -121,6 +139,18 @@ st_sizeof_format(GLuint pipeFormat) } +/** + * Return bytes per pixel for the given format. + */ +GLenum +st_format_datatype(GLuint pipeFormat) +{ + const struct pipe_format_info *info = st_get_format_info(pipeFormat); + assert(info); + return info->datatype; +} + + GLuint st_mesa_format_to_pipe_format(GLuint mesaFormat) { @@ -165,6 +195,22 @@ default_rgba_format(const GLuint formats[], GLuint num) /** + * Search list of formats for first RGBA format with >8 bits/channel. + */ +static GLuint +default_deep_rgba_format(const GLuint formats[], GLuint num) +{ + GLuint i; + for (i = 0; i < num; i++) { + if (formats[i] == PIPE_FORMAT_S_R16_G16_B16_A16) { + return formats[i]; + } + } + return PIPE_FORMAT_NONE; +} + + +/** * Search list of formats for first depth/Z format. */ static GLuint @@ -244,8 +290,9 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, case GL_RGBA8: case GL_RGB10_A2: case GL_RGBA12: - case GL_RGBA16: return default_rgba_format(supported, n); + case GL_RGBA16: + return default_deep_rgba_format(supported, n); case GL_RGBA4: case GL_RGBA2: diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h index 6b3cba0f631..17d09854112 100644 --- a/src/mesa/state_tracker/st_format.h +++ b/src/mesa/state_tracker/st_format.h @@ -34,6 +34,7 @@ struct pipe_format_info { GLuint format; GLenum base_format; + GLenum datatype; GLubyte red_bits; GLubyte green_bits; GLubyte blue_bits; @@ -54,6 +55,10 @@ extern GLuint st_sizeof_format(GLuint pipeFormat); +extern GLenum +st_format_datatype(GLuint pipeFormat); + + extern GLuint st_mesa_format_to_pipe_format(GLuint mesaFormat); |