}
}
+static GLboolean
+get_clamp_color(const struct gl_framebuffer *fb, GLenum clamp)
+{
+ if (clamp == GL_TRUE || clamp == GL_FALSE)
+ return clamp;
+
+ ASSERT(clamp == GL_FIXED_ONLY);
+ if (!fb)
+ return GL_TRUE;
+
+ return fb->_AllColorBuffersFixedPoint;
+}
+
+GLboolean
+_mesa_get_clamp_fragment_color(const struct gl_context *ctx)
+{
+ return get_clamp_color(ctx->DrawBuffer,
+ ctx->Color.ClampFragmentColor);
+}
+GLboolean
+_mesa_get_clamp_vertex_color(const struct gl_context *ctx)
+{
+ return get_clamp_color(ctx->DrawBuffer, ctx->Light.ClampVertexColor);
+}
+
+GLboolean
+_mesa_get_clamp_read_color(const struct gl_context *ctx)
+{
+ return get_clamp_color(ctx->ReadBuffer, ctx->Color.ClampReadColor);
+}
/**********************************************************************/
ctx->Color.ClampFragmentColor = GL_FIXED_ONLY_ARB;
ctx->Color._ClampFragmentColor = GL_TRUE;
ctx->Color.ClampReadColor = GL_FIXED_ONLY_ARB;
- ctx->Color._ClampReadColor = GL_TRUE;
if (ctx->API == API_OPENGLES2) {
/* GLES 3 behaves as though GL_FRAMEBUFFER_SRGB is always enabled. */
extern void GLAPIENTRY
_mesa_ClampColor(GLenum target, GLenum clamp);
+extern GLboolean
+_mesa_get_clamp_fragment_color(const struct gl_context *ctx);
+
+extern GLboolean
+_mesa_get_clamp_vertex_color(const struct gl_context *ctx);
+
+extern GLboolean
+_mesa_get_clamp_read_color(const struct gl_context *ctx);
extern void
_mesa_init_color( struct gl_context * ctx );
numImages = 0;
fb->Width = 0;
fb->Height = 0;
+ fb->_AllColorBuffersFixedPoint = GL_TRUE;
/* Start at -2 to more easily loop over all attachment points.
* -2: depth buffer
/* check if integer color */
fb->_IntegerColor = _mesa_is_format_integer_color(attFormat);
+ /* Update _AllColorBuffersFixedPoint. */
+ if (i >= 0) {
+ GLenum type = _mesa_get_format_datatype(attFormat);
+
+ fb->_AllColorBuffersFixedPoint =
+ fb->_AllColorBuffersFixedPoint &&
+ (type == GL_UNSIGNED_NORMALIZED || type == GL_SIGNED_NORMALIZED);
+ }
+
/* Error-check width, height, format */
if (numImages == 1) {
/* save format */
fb->Delete = _mesa_destroy_framebuffer;
fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT;
+ fb->_AllColorBuffersFixedPoint = !visual->floatMode;
compute_depth_max(fb);
}
GLenum ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
GLboolean _ClampFragmentColor; /** < with GL_FIXED_ONLY_ARB resolved */
GLenum ClampReadColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
- GLboolean _ClampReadColor; /** < with GL_FIXED_ONLY_ARB resolved */
GLboolean sRGBEnabled; /**< Framebuffer sRGB blending/updating requested */
};
/** Integer color values */
GLboolean _IntegerColor;
+ /* ARB_color_buffer_float */
+ GLboolean _AllColorBuffersFixedPoint; /* no integer, no float */
+
/** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT];
#include "glheader.h"
#include "imports.h"
+#include "blend.h"
#include "bufferobj.h"
#include "context.h"
#include "enums.h"
if (uses_blit) {
/* For blit-based ReadPixels packing, the clamping is done automatically
* unless the type is float. */
- if (ctx->Color._ClampReadColor == GL_TRUE &&
+ if (_mesa_get_clamp_read_color(ctx) &&
(type == GL_FLOAT || type == GL_HALF_FLOAT)) {
transferOps |= IMAGE_CLAMP_BIT;
}
else {
/* For CPU-based ReadPixels packing, the clamping must always be done
* for non-float types, */
- if (ctx->Color._ClampReadColor == GL_TRUE ||
+ if (_mesa_get_clamp_read_color(ctx) ||
(type != GL_FLOAT && type != GL_HALF_FLOAT)) {
transferOps |= IMAGE_CLAMP_BIT;
}
#include "texobj.h"
#include "texstate.h"
#include "varray.h"
+#include "blend.h"
static void
static void
update_clamp_fragment_color(struct gl_context *ctx)
{
- if (ctx->Color.ClampFragmentColor == GL_FIXED_ONLY_ARB)
- ctx->Color._ClampFragmentColor =
- !ctx->DrawBuffer || !ctx->DrawBuffer->Visual.floatMode;
- else
- ctx->Color._ClampFragmentColor = ctx->Color.ClampFragmentColor;
+ ctx->Color._ClampFragmentColor = _mesa_get_clamp_fragment_color(ctx);
}
static void
update_clamp_vertex_color(struct gl_context *ctx)
{
- if (ctx->Light.ClampVertexColor == GL_FIXED_ONLY_ARB)
- ctx->Light._ClampVertexColor =
- !ctx->DrawBuffer || !ctx->DrawBuffer->Visual.floatMode;
- else
- ctx->Light._ClampVertexColor = ctx->Light.ClampVertexColor;
+ ctx->Light._ClampVertexColor = _mesa_get_clamp_vertex_color(ctx);
}
-/**
- * Update the ctx->Color._ClampReadColor field
- */
-static void
-update_clamp_read_color(struct gl_context *ctx)
-{
- if (ctx->Color.ClampReadColor == GL_FIXED_ONLY_ARB)
- ctx->Color._ClampReadColor =
- !ctx->ReadBuffer || !ctx->ReadBuffer->Visual.floatMode;
- else
- ctx->Color._ClampReadColor = ctx->Color.ClampReadColor;
-}
-
/**
* Update the ctx->VertexProgram._TwoSideEnabled flag.
*/
if (new_state & (_NEW_MULTISAMPLE | _NEW_BUFFERS))
update_multisample( ctx );
- if (new_state & (_NEW_COLOR | _NEW_BUFFERS))
- update_clamp_read_color(ctx);
-
if(new_state & (_NEW_FRAG_CLAMP | _NEW_BUFFERS))
update_clamp_fragment_color(ctx);