summaryrefslogtreecommitdiffstats
path: root/gfx/wr/webrender/res/ps_quad_textured.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/wr/webrender/res/ps_quad_textured.glsl')
-rw-r--r--gfx/wr/webrender/res/ps_quad_textured.glsl38
1 files changed, 28 insertions, 10 deletions
diff --git a/gfx/wr/webrender/res/ps_quad_textured.glsl b/gfx/wr/webrender/res/ps_quad_textured.glsl
index b405ccac2c..82868d68df 100644
--- a/gfx/wr/webrender/res/ps_quad_textured.glsl
+++ b/gfx/wr/webrender/res/ps_quad_textured.glsl
@@ -4,24 +4,42 @@
/// This shader renders solid colors or simple images in a color or alpha target.
-#include ps_quad
+#include ps_quad,sample_color0
+
+#define v_flags_textured v_flags.x
+#define v_flags_sample_as_mask v_flags.y
#ifdef WR_VERTEX_SHADER
+
void pattern_vertex(PrimitiveInfo info) {
+ // Note: Since the uv rect is passed via segments, This shader cannot sample from a
+ // texture if no segments are provided
+ if (info.segment.uv_rect.p0 != info.segment.uv_rect.p1) {
+ // Textured
+ v_flags_textured = 1;
+
+ vec2 f = (info.local_pos - info.segment.rect.p0) / rect_size(info.segment.rect);
+ vs_init_sample_color0(f, info.segment.uv_rect);
+ } else {
+ // Solid color
+ v_flags_textured = 0;
+ }
+
if ((info.quad_flags & QF_SAMPLE_AS_MASK) != 0) {
- v_flags.z = 1;
+ v_flags_sample_as_mask = 1;
} else {
- v_flags.z = 0;
+ v_flags_sample_as_mask = 0;
}
}
+
#endif
#ifdef WR_FRAGMENT_SHADER
+
vec4 pattern_fragment(vec4 color) {
- if (v_flags.y != 0) {
- vec2 uv = clamp(v_uv, v_uv_sample_bounds.xy, v_uv_sample_bounds.zw);
- vec4 texel = TEX_SAMPLE(sColor0, uv);
- if (v_flags.z != 0) {
+ if (v_flags_textured != 0) {
+ vec4 texel = fs_sample_color0();
+ if (v_flags_sample_as_mask != 0) {
texel = texel.rrrr;
}
color *= texel;
@@ -32,12 +50,12 @@ vec4 pattern_fragment(vec4 color) {
#if defined(SWGL_DRAW_SPAN)
void swgl_drawSpanRGBA8() {
- if (v_flags.y != 0) {
- if (v_flags.z != 0) {
+ if (v_flags_textured != 0) {
+ if (v_flags_sample_as_mask != 0) {
// Fall back to fragment shader as we don't specialize for mask yet. Perhaps
// we can use an existing swgl commit or add a new one though?
} else {
- swgl_commitTextureLinearColorRGBA8(sColor0, v_uv, v_uv_sample_bounds, v_color);
+ swgl_commitTextureLinearColorRGBA8(sColor0, v_uv0, v_uv0_sample_bounds, v_color);
}
} else {
swgl_commitSolidRGBA8(v_color);