aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2018-07-21 23:40:16 -0700
committerKenneth Graunke <[email protected]>2019-01-15 20:53:44 -0800
commit5b51d754d00dfd7d8f4069aca4619f3b056c4eac (patch)
treee0e95d45b11d37e4b72694fe6c7544d60da4ca84 /src/mesa/main
parent11735d6c9c76256df3be65a8853d78f3437aedd0 (diff)
st/mesa: Optionally override RGB/RGBX dst alpha blend factors
Intel's blending hardware does not properly return 1.0 for destination alpha for RGBX formats; it requires the factors to be overridden to either zero or one. Broadcom vc4 and v3d also could use this override. While overriding these factors is safe in general, Nouveau and Radeon would prefer not to. Their blending hardware already returns correct values for RGB/RGBX formats, and would like to avoid the resulting per-buffer blending and independent blend factors (rgb != a) since it can cause additional overhead. I considered simply handling this in the driver, but it's not as nice. pipe_blend_state doesn't have any format information, so we'd need the hardware blend state to depend on both pipe_blend_state and pipe_framebuffer_state. Furthermore, Intel GPUs don't have a native RGBX_SNORM format, so I avoid exposing one, which makes Gallium fall back to RGBA_SNORM. The pipe_surfaces we get in the driver have an RGBA format, making it impossible to tell that there shouldn't be an alpha channel. One could argue that st not handling it in that case is a bug. To work around this, we'd have to expose RGBX pipe formats, mapped to RGBA hardware formats, and add format swizzling special cases. All doable, but it ends up being more code than I'd like. st_atom_blend already has access to the right information and it's trivial to accomplish there, so we just add a cap bit and do that. Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/fbobject.c4
-rw-r--r--src/mesa/main/mtypes.h1
2 files changed, 5 insertions, 0 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 23e49396199..4ff00f273b5 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1003,6 +1003,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
fb->_HasSNormOrFloatColorBuffer = GL_FALSE;
fb->_HasAttachments = true;
fb->_IntegerBuffers = 0;
+ fb->_RGBBuffers = 0;
/* Start at -2 to more easily loop over all attachment points.
* -2: depth buffer
@@ -1149,6 +1150,9 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
if (_mesa_is_format_integer_color(attFormat))
fb->_IntegerBuffers |= (1 << i);
+ if (f == GL_RGB)
+ fb->_RGBBuffers |= (1 << i);
+
fb->_AllColorBuffersFixedPoint =
fb->_AllColorBuffersFixedPoint &&
(type == GL_UNSIGNED_NORMALIZED || type == GL_SIGNED_NORMALIZED);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 3d4673aa7e8..241c2b92f7a 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3506,6 +3506,7 @@ struct gl_framebuffer
bool _HasAttachments;
GLbitfield _IntegerBuffers; /**< Which color buffers are integer valued */
+ GLbitfield _RGBBuffers; /**< Which color buffers have baseformat == RGB */
/* ARB_color_buffer_float */
GLboolean _AllColorBuffersFixedPoint; /* no integer, no float */