glamor: Add support for component alpha rendering.
Brings x11perf -rgb24text from 230/sec to 18400/sec
This commit is contained in:
parent
d07fc66a05
commit
858ce0c192
|
@ -116,6 +116,8 @@ enum shader_mask {
|
||||||
enum shader_in {
|
enum shader_in {
|
||||||
SHADER_IN_SOURCE_ONLY,
|
SHADER_IN_SOURCE_ONLY,
|
||||||
SHADER_IN_NORMAL,
|
SHADER_IN_NORMAL,
|
||||||
|
SHADER_IN_CA_SOURCE,
|
||||||
|
SHADER_IN_CA_ALPHA,
|
||||||
SHADER_IN_COUNT,
|
SHADER_IN_COUNT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,16 @@ glamor_create_composite_fs(struct shader_key *key)
|
||||||
"{\n"
|
"{\n"
|
||||||
" gl_FragColor = get_source() * get_mask().a;\n"
|
" gl_FragColor = get_source() * get_mask().a;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
const char *in_ca_source =
|
||||||
|
"void main()\n"
|
||||||
|
"{\n"
|
||||||
|
" gl_FragColor = get_source() * get_mask();\n"
|
||||||
|
"}\n";
|
||||||
|
const char *in_ca_alpha =
|
||||||
|
"void main()\n"
|
||||||
|
"{\n"
|
||||||
|
" gl_FragColor = get_source().a * get_mask();\n"
|
||||||
|
"}\n";
|
||||||
char *source;
|
char *source;
|
||||||
const char *source_fetch;
|
const char *source_fetch;
|
||||||
const char *mask_fetch = "";
|
const char *mask_fetch = "";
|
||||||
|
@ -161,6 +171,12 @@ glamor_create_composite_fs(struct shader_key *key)
|
||||||
case SHADER_IN_NORMAL:
|
case SHADER_IN_NORMAL:
|
||||||
in = in_normal;
|
in = in_normal;
|
||||||
break;
|
break;
|
||||||
|
case SHADER_IN_CA_SOURCE:
|
||||||
|
in = in_ca_source;
|
||||||
|
break;
|
||||||
|
case SHADER_IN_CA_ALPHA:
|
||||||
|
in = in_ca_alpha;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
FatalError("Bad composite IN type");
|
FatalError("Bad composite IN type");
|
||||||
}
|
}
|
||||||
|
@ -615,11 +631,22 @@ glamor_composite_with_shader(CARD8 op,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
key.in = SHADER_IN_NORMAL;
|
if (!mask->componentAlpha) {
|
||||||
|
key.in = SHADER_IN_NORMAL;
|
||||||
|
} else {
|
||||||
|
/* We only handle two CA modes. */
|
||||||
|
if (op == PictOpAdd)
|
||||||
|
key.in = SHADER_IN_CA_SOURCE;
|
||||||
|
else {
|
||||||
|
assert(op == PictOpOutReverse);
|
||||||
|
key.in = SHADER_IN_CA_ALPHA;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
key.mask = SHADER_MASK_NONE;
|
key.mask = SHADER_MASK_NONE;
|
||||||
key.in = SHADER_IN_SOURCE_ONLY;
|
key.in = SHADER_IN_SOURCE_ONLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source->alphaMap) {
|
if (source->alphaMap) {
|
||||||
glamor_fallback("source alphaMap\n");
|
glamor_fallback("source alphaMap\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -838,22 +865,25 @@ glamor_composite(CARD8 op,
|
||||||
/* Do two-pass PictOpOver componentAlpha, until we enable
|
/* Do two-pass PictOpOver componentAlpha, until we enable
|
||||||
* dual source color blending.
|
* dual source color blending.
|
||||||
*/
|
*/
|
||||||
if (mask && mask->componentAlpha)
|
if (mask && mask->componentAlpha) {
|
||||||
goto fail;
|
if (op == PictOpOver) {
|
||||||
if (mask && mask->componentAlpha && op == PictOpOver) {
|
glamor_composite(PictOpOutReverse,
|
||||||
glamor_composite(PictOpOutReverse,
|
source, mask, dest,
|
||||||
source, mask, dest,
|
x_source, y_source,
|
||||||
x_source, y_source,
|
x_mask, y_mask,
|
||||||
x_mask, y_mask,
|
x_dest, y_dest,
|
||||||
x_dest, y_dest,
|
width, height);
|
||||||
width, height);
|
glamor_composite(PictOpAdd,
|
||||||
glamor_composite(PictOpAdd,
|
source, mask, dest,
|
||||||
source, mask, dest,
|
x_source, y_source,
|
||||||
x_source, y_source,
|
x_mask, y_mask,
|
||||||
x_mask, y_mask,
|
x_dest, y_dest,
|
||||||
x_dest, y_dest,
|
width, height);
|
||||||
width, height);
|
return;
|
||||||
return;
|
} else if (op != PictOpAdd && op != PictOpOutReverse) {
|
||||||
|
glamor_fallback("glamor_composite(): component alpha\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mask) {
|
if (!mask) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user