summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmma Anholt <emma@anholt.net>2021-06-22 16:55:15 -0700
committerMarge Bot <eric+marge@anholt.net>2021-06-23 19:54:55 +0000
commit1ccb8ab8011da054c27962e18bc63aabf90c1375 (patch)
tree01d52a0298e25dc24b6701477b5c2ce75a8b010c /src
parent2683c7bf9ada52f92163cd6b27fb588ea80c47b4 (diff)
i915g: Finish out blend factor overrides for both RGBx and A8.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11559>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt29
-rw-r--r--src/gallium/drivers/i915/i915_context.h9
-rw-r--r--src/gallium/drivers/i915/i915_state.c54
-rw-r--r--src/gallium/drivers/i915/i915_state_dynamic.c14
-rw-r--r--src/gallium/drivers/i915/i915_state_emit.c23
-rw-r--r--src/gallium/drivers/i915/i915_state_immediate.c11
-rw-r--r--src/gallium/drivers/i915/i915_surface.c13
7 files changed, 96 insertions, 57 deletions
diff --git a/src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt b/src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt
index 8b2c8413ffe..f3a3a65f806 100644
--- a/src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt
+++ b/src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt
@@ -158,10 +158,6 @@ spec@!opengl 1.1@clipflat@glDrawElements(GL_QUADS)- glFrontFace(GL_CW)- glPolygo
spec@!opengl 1.1@clipflat@glDrawElements(GL_QUAD_STRIP)- glFrontFace(GL_CCW)- glPolygonMode(GL_FILL)- quadrant: center middle PV: FIRST,Fail
spec@!opengl 1.1@clipflat@glDrawElements(GL_QUAD_STRIP)- glFrontFace(GL_CW)- glPolygonMode(GL_FILL)- quadrant: center middle PV: FIRST,Fail
spec@!opengl 1.1@depthstencil-default_fb-clear,Fail
-spec@!opengl 1.1@depthstencil-default_fb-copypixels,Fail
-spec@!opengl 1.1@depthstencil-default_fb-drawpixels-float-and-ushort,Fail
-spec@!opengl 1.1@draw-pixels,Fail
-spec@!opengl 1.1@drawpix-z,Fail
spec@!opengl 1.1@getteximage-formats,Crash
spec@!opengl 1.1@gl-1.1-drawarrays-vertex-count 100000 varray gl_quad_strip,Crash
spec@!opengl 1.1@gl-1.1-drawarrays-vertex-count 100000 vbo gl_quad_strip,Crash
@@ -251,7 +247,6 @@ spec@!opengl 1.2@texwrap 3d proj,Fail
spec@!opengl 1.2@texwrap 3d proj@GL_RGBA8- NPOT- projected,Fail
spec@!opengl 1.2@texwrap 3d proj bordercolor,Fail
spec@!opengl 1.2@texwrap 3d proj bordercolor@GL_RGBA8- projected- border color only,Fail
-spec@!opengl 1.4@copy-pixels,Fail
spec@!opengl 1.4@gl-1.4-polygon-offset,Fail
# 1D textures are treated as 2D, but we don't force
@@ -335,12 +330,6 @@ spec@arb_depth_texture@fbo-clear-formats@GL_DEPTH_COMPONENT,Fail
spec@arb_depth_texture@fbo-clear-formats@GL_DEPTH_COMPONENT16,Fail
spec@arb_depth_texture@fbo-clear-formats@GL_DEPTH_COMPONENT24,Fail
spec@arb_depth_texture@fbo-clear-formats@GL_DEPTH_COMPONENT32,Fail
-spec@arb_depth_texture@fbo-depth-gl_depth_component16-copypixels,Fail
-spec@arb_depth_texture@fbo-depth-gl_depth_component16-drawpixels,Fail
-spec@arb_depth_texture@fbo-depth-gl_depth_component24-copypixels,Fail
-spec@arb_depth_texture@fbo-depth-gl_depth_component24-drawpixels,Fail
-spec@arb_depth_texture@fbo-depth-gl_depth_component32-copypixels,Fail
-spec@arb_depth_texture@fbo-depth-gl_depth_component32-drawpixels,Fail
spec@arb_depth_texture@fbo-generatemipmap-formats,Fail
spec@arb_depth_texture@fbo-generatemipmap-formats@GL_DEPTH_COMPONENT,Fail
spec@arb_depth_texture@fbo-generatemipmap-formats@GL_DEPTH_COMPONENT NPOT,Fail
@@ -366,7 +355,6 @@ spec@arb_fragment_program_shadow@tex-shadow2drect,Fail
spec@arb_fragment_program_shadow@txp-shadow1d,Fail
spec@arb_fragment_program_shadow@txp-shadow2d,Fail
spec@arb_fragment_program_shadow@txp-shadow2drect,Fail
-spec@arb_framebuffer_object@arb_framebuffer_object-depth-stencil-blit depth gl_depth24_stencil8,Fail
spec@arb_framebuffer_object@arb_framebuffer_object-depth-stencil-blit stencil gl_depth24_stencil8,Fail
spec@arb_framebuffer_object@arb_framebuffer_object-depth-stencil-blit stencil gl_stencil_index1,Fail
spec@arb_framebuffer_object@arb_framebuffer_object-depth-stencil-blit stencil gl_stencil_index16,Fail
@@ -410,7 +398,6 @@ spec@arb_texture_compression@texwrap formats bordercolor@GL_COMPRESSED_RGB- bord
spec@arb_texture_compression@texwrap formats bordercolor@GL_COMPRESSED_RGBA- border color only,Fail
spec@arb_texture_cube_map@copyteximage cube,Fail
spec@arb_texture_cube_map@cubemap npot,Fail
-spec@arb_texture_rectangle@copyteximage rect,Fail
spec@arb_texture_rectangle@glsl-fs-shadow2drect,Fail
spec@arb_texture_rectangle@glsl-fs-shadow2drect-01,Fail
spec@arb_texture_rectangle@glsl-fs-shadow2drect-03,Fail
@@ -491,12 +478,6 @@ spec@ext_framebuffer_multisample@accuracy all_samples stencil_resolve depthstenc
spec@ext_framebuffer_multisample@accuracy all_samples stencil_resolve small depthstencil,Fail
spec@ext_framebuffer_object@fbo-blending-format-quirks,Fail
spec@ext_framebuffer_object@fbo-blending-formats,Fail
-spec@ext_framebuffer_object@fbo-blending-formats@3,Fail
-spec@ext_framebuffer_object@fbo-blending-formats@GL_ALPHA,Fail
-spec@ext_framebuffer_object@fbo-blending-formats@GL_ALPHA12,Fail
-spec@ext_framebuffer_object@fbo-blending-formats@GL_ALPHA16,Fail
-spec@ext_framebuffer_object@fbo-blending-formats@GL_ALPHA4,Fail
-spec@ext_framebuffer_object@fbo-blending-formats@GL_ALPHA8,Fail
spec@ext_framebuffer_object@fbo-blending-formats@GL_INTENSITY,Fail
spec@ext_framebuffer_object@fbo-blending-formats@GL_INTENSITY12,Fail
spec@ext_framebuffer_object@fbo-blending-formats@GL_INTENSITY16,Fail
@@ -507,13 +488,9 @@ spec@ext_framebuffer_object@fbo-blending-formats@GL_LUMINANCE12,Fail
spec@ext_framebuffer_object@fbo-blending-formats@GL_LUMINANCE16,Fail
spec@ext_framebuffer_object@fbo-blending-formats@GL_LUMINANCE4,Fail
spec@ext_framebuffer_object@fbo-blending-formats@GL_LUMINANCE8,Fail
-spec@ext_framebuffer_object@fbo-blending-formats@GL_RGB,Fail
spec@ext_framebuffer_object@fbo-blending-formats@GL_RGB10,Fail
-spec@ext_framebuffer_object@fbo-blending-formats@GL_RGB12,Fail
-spec@ext_framebuffer_object@fbo-blending-formats@GL_RGB16,Fail
spec@ext_framebuffer_object@fbo-blending-formats@GL_RGB4,Fail
spec@ext_framebuffer_object@fbo-blending-formats@GL_RGB5,Fail
-spec@ext_framebuffer_object@fbo-blending-formats@GL_RGB8,Fail
spec@ext_framebuffer_object@fbo-clear-formats,Fail
spec@ext_framebuffer_object@fbo-clear-formats@GL_INTENSITY,Fail
spec@ext_framebuffer_object@fbo-clear-formats@GL_INTENSITY12,Fail
@@ -581,19 +558,13 @@ spec@ext_image_dma_buf_import@ext_image_dma_buf_import-transcode-nv12-as-r8-gr88
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-unsupported_format,Fail
spec@ext_occlusion_query_boolean@any-samples,Fail
spec@ext_packed_depth_stencil@depth_stencil texture,Fail
-spec@ext_packed_depth_stencil@fbo-blit-d24s8,Fail
spec@ext_packed_depth_stencil@fbo-clear-formats,Fail
spec@ext_packed_depth_stencil@fbo-clear-formats@GL_DEPTH24_STENCIL8,Fail
spec@ext_packed_depth_stencil@fbo-clear-formats@GL_DEPTH_STENCIL,Fail
spec@ext_packed_depth_stencil@fbo-clear-formats stencil,Fail
spec@ext_packed_depth_stencil@fbo-clear-formats stencil@GL_DEPTH24_STENCIL8,Fail
spec@ext_packed_depth_stencil@fbo-clear-formats stencil@GL_DEPTH_STENCIL,Fail
-spec@ext_packed_depth_stencil@fbo-depth-gl_depth24_stencil8-blit,Fail
-spec@ext_packed_depth_stencil@fbo-depth-gl_depth24_stencil8-copypixels,Fail
-spec@ext_packed_depth_stencil@fbo-depth-gl_depth24_stencil8-drawpixels,Fail
spec@ext_packed_depth_stencil@fbo-depthstencil-gl_depth24_stencil8-clear,Fail
-spec@ext_packed_depth_stencil@fbo-depthstencil-gl_depth24_stencil8-copypixels,Fail
-spec@ext_packed_depth_stencil@fbo-depthstencil-gl_depth24_stencil8-drawpixels-float-and-ushort,Fail
spec@ext_packed_depth_stencil@fbo-stencil-gl_depth24_stencil8-blit,Fail
spec@ext_packed_depth_stencil@texwrap formats bordercolor,Fail
spec@ext_packed_depth_stencil@texwrap formats bordercolor@GL_DEPTH24_STENCIL8- border color only,Fail
diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h
index b0bfdba4dc4..179e0cc29c0 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -181,9 +181,15 @@ struct i915_state
struct i915_blend_state {
unsigned iab;
+ unsigned iab_alpha_in_g;
+ unsigned iab_alpha_is_x;
+
unsigned modes4;
unsigned LIS5;
+
unsigned LIS6;
+ unsigned LIS6_alpha_in_g;
+ unsigned LIS6_alpha_is_x;
};
struct i915_depth_stencil_state {
@@ -222,6 +228,9 @@ struct i915_surface {
uint32_t oc_swizzle;
/* cbuf swizzle from dst r/g/b/a channels in memory to channels of gallium API. */
uint8_t color_swizzle[4];
+
+ bool alpha_in_g : 1;
+ bool alpha_is_x : 1;
};
struct i915_velems_state {
diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c
index 1e85d7c4846..ef5710a7d22 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -97,6 +97,50 @@ static unsigned translate_mip_filter( unsigned filter )
}
}
+static uint32_t
+i915_remap_lis6_blend_dst_alpha(uint32_t lis6, uint32_t normal, uint32_t inv)
+{
+ uint32_t src = (lis6 >> S6_CBUF_SRC_BLEND_FACT_SHIFT) & BLENDFACT_MASK;
+ lis6 &= ~SRC_BLND_FACT(BLENDFACT_MASK);
+ if (src == BLENDFACT_DST_ALPHA)
+ src = normal;
+ else if (src == BLENDFACT_INV_DST_ALPHA)
+ src = inv;
+ lis6 |= SRC_BLND_FACT(src);
+
+ uint32_t dst = (lis6 >> S6_CBUF_DST_BLEND_FACT_SHIFT) & BLENDFACT_MASK;
+ lis6 &= ~DST_BLND_FACT(BLENDFACT_MASK);
+ if (dst == BLENDFACT_DST_ALPHA)
+ dst = normal;
+ else if (dst == BLENDFACT_INV_DST_ALPHA)
+ dst = inv;
+ lis6 |= DST_BLND_FACT(dst);
+
+ return lis6;
+}
+
+static uint32_t
+i915_remap_iab_blend_dst_alpha(uint32_t iab, uint32_t normal, uint32_t inv)
+{
+ uint32_t src = (iab >> IAB_SRC_FACTOR_SHIFT) & BLENDFACT_MASK;
+ iab &= ~SRC_BLND_FACT(BLENDFACT_MASK);
+ if (src == BLENDFACT_DST_ALPHA)
+ src = normal;
+ else if (src == BLENDFACT_INV_DST_ALPHA)
+ src = inv;
+ iab |= SRC_ABLND_FACT(src);
+
+ uint32_t dst = (iab >> IAB_DST_FACTOR_SHIFT) & BLENDFACT_MASK;
+ iab &= ~DST_BLND_FACT(BLENDFACT_MASK);
+ if (dst == BLENDFACT_DST_ALPHA)
+ dst = normal;
+ else if (dst == BLENDFACT_INV_DST_ALPHA)
+ dst = inv;
+ iab |= DST_ABLND_FACT(dst);
+
+ return iab;
+}
+
/* None of this state is actually used for anything yet.
*/
static void *
@@ -173,6 +217,16 @@ i915_create_blend_state(struct pipe_context *pipe,
(i915_translate_blend_func(funcRGB) << S6_CBUF_BLEND_FUNC_SHIFT));
}
+ cso_data->LIS6_alpha_in_g =
+ i915_remap_lis6_blend_dst_alpha(cso_data->LIS6, BLENDFACT_DST_COLR, BLENDFACT_INV_DST_COLR);
+ cso_data->LIS6_alpha_is_x =
+ i915_remap_lis6_blend_dst_alpha(cso_data->LIS6, BLENDFACT_ONE, BLENDFACT_ZERO);
+
+ cso_data->iab_alpha_in_g =
+ i915_remap_iab_blend_dst_alpha(cso_data->iab, BLENDFACT_DST_COLR, BLENDFACT_INV_DST_COLR);
+ cso_data->iab_alpha_is_x =
+ i915_remap_iab_blend_dst_alpha(cso_data->iab, BLENDFACT_ONE, BLENDFACT_ZERO);
+
return cso_data;
}
diff --git a/src/gallium/drivers/i915/i915_state_dynamic.c b/src/gallium/drivers/i915/i915_state_dynamic.c
index 9193df07ff1..278ca9bda7e 100644
--- a/src/gallium/drivers/i915/i915_state_dynamic.c
+++ b/src/gallium/drivers/i915/i915_state_dynamic.c
@@ -164,7 +164,17 @@ const struct i915_tracked_state i915_upload_BLENDCOLOR = {
*/
static void upload_IAB(struct i915_context *i915)
{
- unsigned iab = i915->blend->iab;
+ unsigned iab = 0;
+
+ if (i915->blend) {
+ struct i915_surface *cbuf = i915_surface(i915->framebuffer.cbufs[0]);
+ if (cbuf && cbuf->alpha_in_g)
+ iab |= i915->blend->iab_alpha_in_g;
+ else if (cbuf && cbuf->alpha_is_x)
+ iab |= i915->blend->iab_alpha_is_x;
+ else
+ iab |= i915->blend->iab;
+ }
set_dynamic(i915, I915_DYNAMIC_IAB, iab);
}
@@ -172,7 +182,7 @@ static void upload_IAB(struct i915_context *i915)
const struct i915_tracked_state i915_upload_IAB = {
"IAB",
upload_IAB,
- I915_NEW_BLEND
+ I915_NEW_BLEND | I915_NEW_FRAMEBUFFER
};
diff --git a/src/gallium/drivers/i915/i915_state_emit.c b/src/gallium/drivers/i915/i915_state_emit.c
index 4e48040c18a..0296a17287b 100644
--- a/src/gallium/drivers/i915/i915_state_emit.c
+++ b/src/gallium/drivers/i915/i915_state_emit.c
@@ -154,27 +154,6 @@ static void emit_immediate_s5(struct i915_context *i915, uint imm)
OUT_BATCH(imm);
}
-static void emit_immediate_s6(struct i915_context *i915, uint imm)
-{
- /* Fixup blend function for A8 dst buffers.
- * When we blend to an A8 buffer, the GPU thinks it's a G8 buffer,
- * and therefore we need to use the color factor for alphas. */
- uint srcRGB;
-
- if (i915->framebuffer.cbufs[0] &&
- i915->framebuffer.cbufs[0]->format == PIPE_FORMAT_A8_UNORM) {
- srcRGB = (imm >> S6_CBUF_SRC_BLEND_FACT_SHIFT) & BLENDFACT_MASK;
- if (srcRGB == BLENDFACT_DST_ALPHA)
- srcRGB = BLENDFACT_DST_COLR;
- else if (srcRGB == BLENDFACT_INV_DST_ALPHA)
- srcRGB = BLENDFACT_INV_DST_COLR;
- imm &= ~SRC_BLND_FACT(BLENDFACT_MASK);
- imm |= SRC_BLND_FACT(srcRGB);
- }
-
- OUT_BATCH(imm);
-}
-
static void
emit_immediate(struct i915_context *i915)
{
@@ -202,8 +181,6 @@ emit_immediate(struct i915_context *i915)
if (dirty & (1 << i)) {
if (i == I915_IMMEDIATE_S5)
emit_immediate_s5(i915, i915->current.immediate[i]);
- else if (i == I915_IMMEDIATE_S6)
- emit_immediate_s6(i915, i915->current.immediate[i]);
else
OUT_BATCH(i915->current.immediate[i]);
}
diff --git a/src/gallium/drivers/i915/i915_state_immediate.c b/src/gallium/drivers/i915/i915_state_immediate.c
index 0631fa1d126..91b6cf5ceb6 100644
--- a/src/gallium/drivers/i915/i915_state_immediate.c
+++ b/src/gallium/drivers/i915/i915_state_immediate.c
@@ -168,8 +168,15 @@ static void upload_S6(struct i915_context *i915)
/* I915_NEW_BLEND
*/
- if (i915->blend)
- LIS6 |= i915->blend->LIS6;
+ if (i915->blend) {
+ struct i915_surface *cbuf = i915_surface(i915->framebuffer.cbufs[0]);
+ if (cbuf && cbuf->alpha_in_g)
+ LIS6 |= i915->blend->LIS6_alpha_in_g;
+ else if (cbuf && cbuf->alpha_is_x)
+ LIS6 |= i915->blend->LIS6_alpha_is_x;
+ else
+ LIS6 |= i915->blend->LIS6;
+ }
/* I915_NEW_DEPTH
*/
diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c
index f642c151c47..84b0207b7e1 100644
--- a/src/gallium/drivers/i915/i915_surface.c
+++ b/src/gallium/drivers/i915/i915_surface.c
@@ -351,6 +351,8 @@ i915_clear_depth_stencil_blitter(struct pipe_context *pipe,
static void i915_set_color_surface_swizzle(struct i915_surface *surf)
{
+ enum pipe_format format = surf->templ.format;
+
const struct {
enum pipe_format format;
uint8_t color_swizzle[4];
@@ -358,13 +360,22 @@ static void i915_set_color_surface_swizzle(struct i915_surface *surf)
} fixup_formats[] = {
{ PIPE_FORMAT_R8G8B8A8_UNORM, {2, 1, 0, 3 }, 0x21030000 /* BGRA */},
{ PIPE_FORMAT_R8G8B8X8_UNORM, {2, 1, 0, 3 }, 0x21030000 /* BGRX */},
+
+ /* These are rendered to using COLORBUF_8BIT, where the G channel written
+ * by shader (and output by blending) is used.
+ */
{ PIPE_FORMAT_L8_UNORM, {0, 0, 0, 0 }, 0x00030000 /* RRRA */},
{ PIPE_FORMAT_I8_UNORM, {0, 0, 0, 0 }, 0x00030000 /* RRRA */},
{ PIPE_FORMAT_A8_UNORM, {3, 3, 3, 3 }, 0x33330000 /* AAAA */},
};
+ if (format == PIPE_FORMAT_A8_UNORM)
+ surf->alpha_in_g = true;
+ else if (util_format_is_rgbx_or_bgrx(format))
+ surf->alpha_is_x = true;
+
for (int i = 0; i < ARRAY_SIZE(fixup_formats); i++) {
- if (fixup_formats[i].format == surf->templ.format) {
+ if (fixup_formats[i].format == format) {
memcpy(surf->color_swizzle, fixup_formats[i].color_swizzle, sizeof(surf->color_swizzle));
surf->oc_swizzle = fixup_formats[i].oc_swizzle;
return;