diff options
author | Brian Paul <brianp@vmware.com> | 2016-02-16 10:22:32 -0700 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2016-02-16 10:22:32 -0700 |
commit | f7af12ae852bdc957fc6f197c722822b82043ead (patch) | |
tree | 5aaa27ae6988cd5186e12f2b5e0ab88a4a05ee38 /src/gallium/auxiliary/cso_cache/cso_context.c | |
parent | f88c859cd36f54bd50ca37dbf9806f4f56f70b68 (diff) | |
download | external_mesa3d-f7af12ae852bdc957fc6f197c722822b82043ead.zip external_mesa3d-f7af12ae852bdc957fc6f197c722822b82043ead.tar.gz external_mesa3d-f7af12ae852bdc957fc6f197c722822b82043ead.tar.bz2 |
cso: add new cso_set_viewport_dims() helper
To simplify some viewport setting code in the state tracker.
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Diffstat (limited to 'src/gallium/auxiliary/cso_cache/cso_context.c')
-rw-r--r-- | src/gallium/auxiliary/cso_cache/cso_context.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 79ae753..2d6540d 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -674,6 +674,24 @@ void cso_set_viewport(struct cso_context *ctx, } } +/** + * Setup viewport state for given width and height (position is always (0,0)). + * Invert the Y axis if 'invert' is true. + */ +void +cso_set_viewport_dims(struct cso_context *ctx, + float width, float height, boolean invert) +{ + struct pipe_viewport_state vp; + vp.scale[0] = width * 0.5f; + vp.scale[1] = height * (invert ? -0.5f : 0.5f); + vp.scale[2] = 0.5f; + vp.translate[0] = 0.5f * width; + vp.translate[1] = 0.5f * height; + vp.translate[2] = 0.5f; + cso_set_viewport(ctx, &vp); +} + void cso_save_viewport(struct cso_context *ctx) { ctx->vp_saved = ctx->vp; |