Commit 2c327386 authored by Eric Anholt's avatar Eric Anholt

glamor: Clarify how the repeat values being passed around work.

Signed-off-by: Eric Anholt's avatarEric Anholt <eric@anholt.net>
Reviewed-by: default avatarDave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke's avatarKenneth Graunke <kenneth@whitecape.org>
parent 990a8ee0
......@@ -76,11 +76,11 @@ glamor_create_composite_fs(struct shader_key *key)
"{\n"
" vec2 rel_tex; \n"
" rel_tex = texture * wh.xy; \n"
" if (repeat == RepeatNone)\n"
" if (repeat == RepeatFix + RepeatNone)\n"
" return rel_tex; \n"
" else if (repeat == RepeatNormal) \n"
" else if (repeat == RepeatFix + RepeatNormal) \n"
" rel_tex = floor(rel_tex) + (fract(rel_tex) / wh.xy); \n"
" else if (repeat == RepeatPad) { \n"
" else if (repeat == RepeatFix + RepeatPad) { \n"
" if (rel_tex.x >= 1.0) \n"
" rel_tex.x = 1.0 - wh.z * wh.x / 2.; \n"
" else if (rel_tex.x < 0.0) \n"
......@@ -90,7 +90,7 @@ glamor_create_composite_fs(struct shader_key *key)
" else if (rel_tex.y < 0.0) \n"
" rel_tex.y = 0.0; \n"
" rel_tex = rel_tex / wh.xy; \n"
" } else if (repeat == RepeatReflect) {\n"
" } else if (repeat == RepeatFix + RepeatReflect) {\n"
" if ((1.0 - mod(abs(floor(rel_tex.x)), 2.0)) < 0.001)\n"
" rel_tex.x = 2.0 - (1.0 - fract(rel_tex.x)) / wh.x;\n"
" else \n"
......@@ -107,8 +107,8 @@ glamor_create_composite_fs(struct shader_key *key)
const char *rel_sampler =
" vec4 rel_sampler(sampler2D tex_image, vec2 tex, vec4 wh, int repeat, int set_alpha)\n"
"{\n"
" tex = rel_tex_coord(tex, wh, repeat - RepeatFix);\n"
" if (repeat == RepeatFix) {\n"
" tex = rel_tex_coord(tex, wh, repeat);\n"
" if (repeat == RepeatFix + RepeatNone) {\n"
" if (!(tex.x >= 0.0 && tex.x < 1.0 \n"
" && tex.y >= 0.0 && tex.y < 1.0))\n"
" return vec4(0.0, 0.0, 0.0, set_alpha);\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment