diff options
Diffstat (limited to 'mesalib')
-rw-r--r-- | mesalib/scons/gallium.py | 5 | ||||
-rw-r--r-- | mesalib/src/mesa/main/clear.c | 27 | ||||
-rw-r--r-- | mesalib/src/mesa/main/formats.c | 29 | ||||
-rw-r--r-- | mesalib/src/mesa/main/formats.h | 4 |
4 files changed, 64 insertions, 1 deletions
diff --git a/mesalib/scons/gallium.py b/mesalib/scons/gallium.py index f505a62be..e11d4dba3 100644 --- a/mesalib/scons/gallium.py +++ b/mesalib/scons/gallium.py @@ -269,6 +269,11 @@ def generate(env): cppdefines += ['HAVE_ALIAS'] else: cppdefines += ['GLX_ALIAS_UNSUPPORTED'] + if env['platform'] == 'haiku': + cppdefines += [ + 'HAVE_PTHREAD', + 'HAVE_POSIX_MEMALIGN' + ] if platform == 'windows': cppdefines += [ 'WIN32', diff --git a/mesalib/src/mesa/main/clear.c b/mesalib/src/mesa/main/clear.c index 077c5fca3..9df1f5e09 100644 --- a/mesalib/src/mesa/main/clear.c +++ b/mesalib/src/mesa/main/clear.c @@ -107,6 +107,31 @@ _mesa_ClearColorIuiEXT(GLuint r, GLuint g, GLuint b, GLuint a) /** + * Returns true if color writes are enabled for the given color attachment. + * + * Beyond checking ColorMask, this uses _mesa_format_has_color_component to + * ignore components that don't actually exist in the format (such as X in + * XRGB). + */ +static bool +color_buffer_writes_enabled(const struct gl_context *ctx, unsigned idx) +{ + struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[idx]; + GLuint c; + GLubyte colorMask = 0; + + if (rb) { + for (c = 0; c < 4; c++) { + if (_mesa_format_has_color_component(rb->Format, c)) + colorMask |= ctx->Color.ColorMask[idx][c]; + } + } + + return colorMask != 0; +} + + +/** * Clear buffers. * * \param mask bit-mask indicating the buffers to be cleared. @@ -181,7 +206,7 @@ _mesa_Clear( GLbitfield mask ) for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) { GLint buf = ctx->DrawBuffer->_ColorDrawBufferIndexes[i]; - if (buf >= 0) { + if (buf >= 0 && color_buffer_writes_enabled(ctx, i)) { bufferMask |= 1 << buf; } } diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c index e74625f23..fb2501c69 100644 --- a/mesalib/src/mesa/main/formats.c +++ b/mesalib/src/mesa/main/formats.c @@ -2207,6 +2207,35 @@ _mesa_format_num_components(mesa_format format) /** + * Returns true if a color format has data stored in the R/G/B/A channels, + * given an index from 0 to 3. + */ +bool +_mesa_format_has_color_component(mesa_format format, int component) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + + assert(info->BaseFormat != GL_DEPTH_COMPONENT && + info->BaseFormat != GL_DEPTH_STENCIL && + info->BaseFormat != GL_STENCIL_INDEX); + + switch (component) { + case 0: + return (info->RedBits + info->IntensityBits + info->LuminanceBits) > 0; + case 1: + return (info->GreenBits + info->IntensityBits + info->LuminanceBits) > 0; + case 2: + return (info->BlueBits + info->IntensityBits + info->LuminanceBits) > 0; + case 3: + return (info->AlphaBits + info->IntensityBits) > 0; + default: + assert(!"Invalid color component: must be 0..3"); + return false; + } +} + + +/** * Return number of bytes needed to store an image of the given size * in the given format. */ diff --git a/mesalib/src/mesa/main/formats.h b/mesalib/src/mesa/main/formats.h index 3079f0356..89bd0219e 100644 --- a/mesalib/src/mesa/main/formats.h +++ b/mesalib/src/mesa/main/formats.h @@ -34,6 +34,7 @@ #include <GL/gl.h> +#include <stdbool.h> #ifdef __cplusplus @@ -474,6 +475,9 @@ _mesa_get_uncompressed_format(mesa_format format); extern GLuint _mesa_format_num_components(mesa_format format); +extern bool +_mesa_format_has_color_component(mesa_format format, int component); + GLboolean _mesa_format_matches_format_and_type(mesa_format mesa_format, GLenum format, GLenum type, |