From 5d4d8b6205af9a09e67f53631eefad77054aa8e9 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 28 Nov 2010 16:59:03 +0100 Subject: u_blitter: interpolate clear color using a GENERIC varying instead of COLOR There are also some u_simple_shaders changes. On r300, the TGSI_SEMANTIC_COLOR varying is a fixed-point number clamped to the range [0,1] and limited to 12 bits of precision. Therefore we can't use it for passing through a clear color in order to clear high precision texture formats. This also makes u_blitter use only one vertex shader instead of two. --- src/gallium/auxiliary/util/u_blitter.c | 32 ++++++++++----------------- src/gallium/auxiliary/util/u_simple_shaders.c | 11 +++++---- src/gallium/auxiliary/util/u_simple_shaders.h | 4 +++- 3 files changed, 22 insertions(+), 25 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 31fc75aa11..bd9e65f43b 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -63,8 +63,7 @@ struct blitter_context_priv /* Constant state objects. */ /* Vertex shaders. */ - void *vs_col; /**< Vertex shader which passes {pos, color} to the output */ - void *vs_tex; /**< Vertex shader which passes {pos, texcoord} to the output.*/ + void *vs; /**< Vertex shader which passes {pos, generic} to the output.*/ /* Fragment shaders. */ /* The shader at index i outputs color to color buffers 0,1,...,i-1. */ @@ -211,20 +210,12 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) /* fragment shaders are created on-demand */ - /* vertex shaders */ - { - const uint semantic_names[] = { TGSI_SEMANTIC_POSITION, - TGSI_SEMANTIC_COLOR }; - const uint semantic_indices[] = { 0, 0 }; - ctx->vs_col = - util_make_vertex_passthrough_shader(pipe, 2, semantic_names, - semantic_indices); - } + /* vertex shader */ { const uint semantic_names[] = { TGSI_SEMANTIC_POSITION, TGSI_SEMANTIC_GENERIC }; const uint semantic_indices[] = { 0, 0 }; - ctx->vs_tex = + ctx->vs = util_make_vertex_passthrough_shader(pipe, 2, semantic_names, semantic_indices); } @@ -257,8 +248,7 @@ void util_blitter_destroy(struct blitter_context *blitter) pipe->delete_depth_stencil_alpha_state(pipe, ctx->dsa_flush_depth_stencil); pipe->delete_rasterizer_state(pipe, ctx->rs_state); - pipe->delete_vs_state(pipe, ctx->vs_col); - pipe->delete_vs_state(pipe, ctx->vs_tex); + pipe->delete_vs_state(pipe, ctx->vs); pipe->delete_vertex_elements_state(pipe, ctx->velem_state); for (i = 0; i < PIPE_MAX_TEXTURE_TYPES; i++) { @@ -569,7 +559,9 @@ void *blitter_get_fs_col(struct blitter_context_priv *ctx, unsigned num_cbufs) if (!ctx->fs_col[num_cbufs]) ctx->fs_col[num_cbufs] = - util_make_fragment_clonecolor_shader(pipe, num_cbufs); + util_make_fragment_cloneinput_shader(pipe, num_cbufs, + TGSI_SEMANTIC_GENERIC, + TGSI_INTERPOLATE_LINEAR); return ctx->fs_col[num_cbufs]; } @@ -700,7 +692,7 @@ void util_blitter_clear(struct blitter_context *blitter, pipe->bind_rasterizer_state(pipe, ctx->rs_state); pipe->bind_vertex_elements_state(pipe, ctx->velem_state); pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, num_cbufs)); - pipe->bind_vs_state(pipe, ctx->vs_col); + pipe->bind_vs_state(pipe, ctx->vs); blitter_set_dst_dimensions(ctx, width, height); blitter->draw_rectangle(blitter, 0, 0, width, height, depth, @@ -813,7 +805,7 @@ void util_blitter_copy_region(struct blitter_context *blitter, /* Set rasterizer state, shaders, and textures. */ pipe->bind_rasterizer_state(pipe, ctx->rs_state); - pipe->bind_vs_state(pipe, ctx->vs_tex); + pipe->bind_vs_state(pipe, ctx->vs); pipe->bind_fragment_sampler_states(pipe, 1, blitter_get_sampler_state(ctx, subsrc.level, normalized)); pipe->bind_vertex_elements_state(pipe, ctx->velem_state); @@ -890,7 +882,7 @@ void util_blitter_clear_render_target(struct blitter_context *blitter, pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil); pipe->bind_rasterizer_state(pipe, ctx->rs_state); pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 1)); - pipe->bind_vs_state(pipe, ctx->vs_col); + pipe->bind_vs_state(pipe, ctx->vs); pipe->bind_vertex_elements_state(pipe, ctx->velem_state); /* set a framebuffer state */ @@ -950,7 +942,7 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter, pipe->bind_rasterizer_state(pipe, ctx->rs_state); pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 0)); - pipe->bind_vs_state(pipe, ctx->vs_col); + pipe->bind_vs_state(pipe, ctx->vs); pipe->bind_vertex_elements_state(pipe, ctx->velem_state); /* set a framebuffer state */ @@ -991,7 +983,7 @@ void util_blitter_custom_depth_stencil(struct blitter_context *blitter, pipe->bind_rasterizer_state(pipe, ctx->rs_state); pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 0)); - pipe->bind_vs_state(pipe, ctx->vs_col); + pipe->bind_vs_state(pipe, ctx->vs); pipe->bind_vertex_elements_state(pipe, ctx->velem_state); /* set a framebuffer state */ diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c index 58ef68377f..b0f2dd8aa2 100644 --- a/src/gallium/auxiliary/util/u_simple_shaders.c +++ b/src/gallium/auxiliary/util/u_simple_shaders.c @@ -204,7 +204,8 @@ util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe, void * util_make_fragment_passthrough_shader(struct pipe_context *pipe) { - return util_make_fragment_clonecolor_shader(pipe, 1); + return util_make_fragment_cloneinput_shader(pipe, 1, TGSI_SEMANTIC_COLOR, + TGSI_INTERPOLATE_PERSPECTIVE); } @@ -212,7 +213,9 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe) * Make a fragment shader that copies the input color to N output colors. */ void * -util_make_fragment_clonecolor_shader(struct pipe_context *pipe, int num_cbufs) +util_make_fragment_cloneinput_shader(struct pipe_context *pipe, int num_cbufs, + int input_semantic, + int input_interpolate) { struct ureg_program *ureg; struct ureg_src src; @@ -225,8 +228,8 @@ util_make_fragment_clonecolor_shader(struct pipe_context *pipe, int num_cbufs) if (ureg == NULL) return NULL; - src = ureg_DECL_fs_input( ureg, TGSI_SEMANTIC_COLOR, 0, - TGSI_INTERPOLATE_PERSPECTIVE ); + src = ureg_DECL_fs_input( ureg, input_semantic, 0, + input_interpolate ); for (i = 0; i < num_cbufs; i++) dst[i] = ureg_DECL_output( ureg, TGSI_SEMANTIC_COLOR, i ); diff --git a/src/gallium/auxiliary/util/u_simple_shaders.h b/src/gallium/auxiliary/util/u_simple_shaders.h index 4aa34bc475..1bfec183e3 100644 --- a/src/gallium/auxiliary/util/u_simple_shaders.h +++ b/src/gallium/auxiliary/util/u_simple_shaders.h @@ -71,7 +71,9 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe); extern void * -util_make_fragment_clonecolor_shader(struct pipe_context *pipe, int num_cbufs); +util_make_fragment_cloneinput_shader(struct pipe_context *pipe, int num_cbufs, + int input_semantic, + int input_interpolate); #ifdef __cplusplus } -- cgit v1.2.3