[Mesa-dev] [PATCH 05/18] gallium/u_blitter: use viewport state to set vertex positions
Marek Olšák
maraeo at gmail.com
Thu Aug 17 18:31:26 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
---
src/gallium/auxiliary/util/u_blitter.c | 34 ++++++++++++++++------------------
1 file changed, 16 insertions(+), 18 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index 5c82677..0fea7fc 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -709,45 +709,43 @@ void util_blitter_restore_constant_buffer_state(struct blitter_context *blitter)
pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, blitter->cb_slot,
&blitter->saved_fs_constant_buffer);
pipe_resource_reference(&blitter->saved_fs_constant_buffer.buffer, NULL);
}
static void blitter_set_rectangle(struct blitter_context_priv *ctx,
int x1, int y1, int x2, int y2,
float depth)
{
- int i;
+ int width = x2 - x1;
+ int height = y2 - y1;
/* set vertex positions */
- ctx->vertices[0][0][0] = (float)x1 / ctx->dst_width * 2.0f - 1.0f; /*v0.x*/
- ctx->vertices[0][0][1] = (float)y1 / ctx->dst_height * 2.0f - 1.0f; /*v0.y*/
-
- ctx->vertices[1][0][0] = (float)x2 / ctx->dst_width * 2.0f - 1.0f; /*v1.x*/
- ctx->vertices[1][0][1] = (float)y1 / ctx->dst_height * 2.0f - 1.0f; /*v1.y*/
+ ctx->vertices[0][0][0] = -1; /*v0.x*/
+ ctx->vertices[0][0][1] = -1; /*v0.y*/
- ctx->vertices[2][0][0] = (float)x2 / ctx->dst_width * 2.0f - 1.0f; /*v2.x*/
- ctx->vertices[2][0][1] = (float)y2 / ctx->dst_height * 2.0f - 1.0f; /*v2.y*/
+ ctx->vertices[1][0][0] = 1; /*v1.x*/
+ ctx->vertices[1][0][1] = -1; /*v1.y*/
- ctx->vertices[3][0][0] = (float)x1 / ctx->dst_width * 2.0f - 1.0f; /*v3.x*/
- ctx->vertices[3][0][1] = (float)y2 / ctx->dst_height * 2.0f - 1.0f; /*v3.y*/
+ ctx->vertices[2][0][0] = 1; /*v2.x*/
+ ctx->vertices[2][0][1] = 1; /*v2.y*/
- for (i = 0; i < 4; i++)
- ctx->vertices[i][0][2] = depth; /*z*/
+ ctx->vertices[3][0][0] = -1; /*v3.x*/
+ ctx->vertices[3][0][1] = 1; /*v3.y*/
/* viewport */
- ctx->viewport.scale[0] = 0.5f * ctx->dst_width;
- ctx->viewport.scale[1] = 0.5f * ctx->dst_height;
- ctx->viewport.scale[2] = 1.0f;
- ctx->viewport.translate[0] = 0.5f * ctx->dst_width;
- ctx->viewport.translate[1] = 0.5f * ctx->dst_height;
- ctx->viewport.translate[2] = 0.0f;
+ ctx->viewport.scale[0] = width / 2.0;
+ ctx->viewport.scale[1] = height / 2.0;
+ ctx->viewport.scale[2] = 0;
+ ctx->viewport.translate[0] = width / 2.0 + x1;
+ ctx->viewport.translate[1] = height / 2.0 + y1;
+ ctx->viewport.translate[2] = depth;
ctx->base.pipe->set_viewport_states(ctx->base.pipe, 0, 1, &ctx->viewport);
}
static void blitter_set_clear_color(struct blitter_context_priv *ctx,
const union pipe_color_union *color)
{
int i;
if (color) {
for (i = 0; i < 4; i++) {
--
2.7.4
More information about the mesa-dev
mailing list