diff options
author | Eric Anholt <[email protected]> | 2014-09-24 14:47:06 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-09-24 15:59:03 -0700 |
commit | 52476b35c1db963b13856d4b08b866adf8e05470 (patch) | |
tree | 10603915af3dc65fab09e5ccf5e23255e683595e /src/gallium | |
parent | 66b7bd60e01fd17a356bf26d69ea351261080586 (diff) |
vc4: Add support for gl_PointCoord.
Fixes piglit glsl-fs-pointcoord, point-sprite, and fbo-gl_pointcoord.
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_program.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index a52092205ed..8d243374dae 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -59,7 +59,9 @@ struct vc4_fs_key { bool is_points; bool is_lines; bool alpha_test; + bool point_coord_upper_left; uint8_t alpha_test_func; + uint32_t point_sprite_mask; struct pipe_rt_blend_state blend; }; @@ -868,6 +870,26 @@ emit_fragcoord_input(struct vc4_compile *c, int attr) c->inputs[attr * 4 + 3] = qir_RCP(c, qir_FRAG_W(c)); } +static void +emit_point_coord_input(struct vc4_compile *c, int attr) +{ + if (c->point_x.file == QFILE_NULL) { + c->point_x = qir_uniform_f(c, 0.0); + c->point_y = qir_uniform_f(c, 0.0); + } + + c->inputs[attr * 4 + 0] = c->point_x; + if (c->fs_key->point_coord_upper_left) { + c->inputs[attr * 4 + 1] = qir_FSUB(c, + qir_uniform_f(c, 1.0), + c->point_y); + } else { + c->inputs[attr * 4 + 1] = c->point_y; + } + c->inputs[attr * 4 + 2] = qir_uniform_f(c, 0.0); + c->inputs[attr * 4 + 3] = qir_uniform_f(c, 1.0); +} + static struct qreg emit_fragment_varying(struct vc4_compile *c, int index) { @@ -915,6 +937,10 @@ emit_tgsi_declaration(struct vc4_compile *c, if (decl->Semantic.Name == TGSI_SEMANTIC_POSITION) { emit_fragcoord_input(c, i); + } else if (decl->Semantic.Name == TGSI_SEMANTIC_GENERIC && + (c->fs_key->point_sprite_mask & + (1 << decl->Semantic.Index))) { + emit_point_coord_input(c, i); } else { emit_fragment_input(c, i, decl); } @@ -1705,6 +1731,14 @@ vc4_update_compiled_fs(struct vc4_context *vc4, uint8_t prim_mode) key->alpha_test_func = vc4->zsa->base.alpha.func; } + if (key->is_points) { + key->point_sprite_mask = + vc4->rasterizer->base.sprite_coord_enable; + key->point_coord_upper_left = + (vc4->rasterizer->base.sprite_coord_mode == + PIPE_SPRITE_COORD_UPPER_LEFT); + } + vc4->prog.fs = util_hash_table_get(vc4->fs_cache, key); if (vc4->prog.fs) return; |