mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-03-06 18:40:42 +01:00
mesa: refactor clamping controls, get rid of _ClampReadColor
v2: cosmetic changes from Brian's email Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
parent
c4629ad3f9
commit
21d407c1b8
7 changed files with 58 additions and 30 deletions
|
|
@ -782,7 +782,37 @@ _mesa_ClampColor(GLenum target, GLenum clamp)
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
|
|
@ -835,7 +865,6 @@ void _mesa_init_color( struct gl_context * ctx )
|
|||
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. */
|
||||
|
|
|
|||
|
|
@ -99,6 +99,14 @@ _mesa_ColorMaski( GLuint buf, GLboolean red, GLboolean green,
|
|||
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 );
|
||||
|
|
|
|||
|
|
@ -784,6 +784,7 @@ _mesa_test_framebuffer_completeness(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
|
||||
|
|
@ -900,6 +901,15 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
|
|||
/* 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 */
|
||||
|
|
|
|||
|
|
@ -154,6 +154,7 @@ _mesa_initialize_window_framebuffer(struct gl_framebuffer *fb,
|
|||
|
||||
fb->Delete = _mesa_destroy_framebuffer;
|
||||
fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT;
|
||||
fb->_AllColorBuffersFixedPoint = !visual->floatMode;
|
||||
|
||||
compute_depth_max(fb);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -673,7 +673,6 @@ struct gl_colorbuffer_attrib
|
|||
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 */
|
||||
};
|
||||
|
|
@ -2661,6 +2660,9 @@ struct gl_framebuffer
|
|||
/** 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];
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "glheader.h"
|
||||
#include "imports.h"
|
||||
#include "blend.h"
|
||||
#include "bufferobj.h"
|
||||
#include "context.h"
|
||||
#include "enums.h"
|
||||
|
|
@ -80,7 +81,7 @@ get_readpixels_transfer_ops(const struct gl_context *ctx, gl_format texFormat,
|
|||
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;
|
||||
}
|
||||
|
|
@ -88,7 +89,7 @@ get_readpixels_transfer_ops(const struct gl_context *ctx, gl_format texFormat,
|
|||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@
|
|||
#include "texobj.h"
|
||||
#include "texstate.h"
|
||||
#include "varray.h"
|
||||
#include "blend.h"
|
||||
|
||||
|
||||
static void
|
||||
|
|
@ -313,11 +314,7 @@ update_multisample(struct gl_context *ctx)
|
|||
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);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -327,27 +324,10 @@ update_clamp_fragment_color(struct gl_context *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.
|
||||
*/
|
||||
|
|
@ -525,9 +505,6 @@ _mesa_update_state_locked( struct gl_context *ctx )
|
|||
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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue