diff options
author | Chia-I Wu <olv@lunarg.com> | 2010-11-28 03:48:23 +0800 |
---|---|---|
committer | Chia-I Wu <olv@lunarg.com> | 2010-12-01 11:23:50 +0800 |
commit | 4690cdfe076a03b6e9da1db9f1908a663c49c820 (patch) | |
tree | 0a8a5d9c0f754ea259e813aa74941630556d2318 /src | |
parent | ace4539e88f6ef90d8e9fd2f1543eca0ae854b82 (diff) |
st/vega: Clean up renderer fields and functions.
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/state_trackers/vega/renderer.c | 144 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/renderer.h | 10 |
2 files changed, 46 insertions, 108 deletions
diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c index c0d69ee2ba..868393a86f 100644 --- a/src/gallium/state_trackers/vega/renderer.c +++ b/src/gallium/state_trackers/vega/renderer.c @@ -73,16 +73,10 @@ typedef enum { struct renderer { struct pipe_context *pipe; - struct vg_context *owner; - struct cso_context *cso; - void *fs; - struct { - struct pipe_blend_state blend; struct pipe_rasterizer_state rasterizer; - struct pipe_shader_state vs_state; struct pipe_depth_stencil_alpha_state dsa; struct pipe_framebuffer_state fb; } g3d; @@ -265,23 +259,23 @@ typedef enum { VEGA_Y0_BOTTOM } VegaOrientation; -static void vg_set_viewport(struct vg_context *ctx, +static void vg_set_viewport(struct renderer *r, VegaOrientation orientation) { - struct st_framebuffer *stfb = ctx->draw_buffer; + const struct pipe_framebuffer_state *fb = &r->g3d.fb; struct pipe_viewport_state viewport; VGfloat y_scale = (orientation == VEGA_Y0_BOTTOM) ? -2.f : 2.f; - viewport.scale[0] = stfb->width / 2.f; - viewport.scale[1] = stfb->height / y_scale; + viewport.scale[0] = fb->width / 2.f; + viewport.scale[1] = fb->height / y_scale; viewport.scale[2] = 1.0; viewport.scale[3] = 1.0; - viewport.translate[0] = stfb->width / 2.f; - viewport.translate[1] = stfb->height / 2.f; + viewport.translate[0] = fb->width / 2.f; + viewport.translate[1] = fb->height / 2.f; viewport.translate[2] = 0.0; viewport.translate[3] = 0.0; - cso_set_viewport(ctx->cso_context, &viewport); + cso_set_viewport(r->cso, &viewport); } /** @@ -304,7 +298,7 @@ static void renderer_set_target(struct renderer *r, fb.zsbuf = zsbuf; cso_set_framebuffer(r->cso, &fb); - vg_set_viewport(r->owner, (y0_top) ? VEGA_Y0_TOP : VEGA_Y0_BOTTOM); + vg_set_viewport(r, (y0_top) ? VEGA_Y0_TOP : VEGA_Y0_BOTTOM); } /** @@ -1066,14 +1060,6 @@ void renderer_polygon_fill_end(struct renderer *renderer) renderer->state = RENDERER_STATE_INIT; } -static void setup_shaders(struct renderer *ctx) -{ - struct pipe_context *pipe = ctx->pipe; - /* fragment shader */ - ctx->fs = util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D, - TGSI_INTERPOLATE_LINEAR); -} - struct renderer * renderer_create(struct vg_context *owner) { VGint i; @@ -1082,12 +1068,9 @@ struct renderer * renderer_create(struct vg_context *owner) if (!renderer) return NULL; - renderer->owner = owner; renderer->pipe = owner->pipe; renderer->cso = owner->cso_context; - setup_shaders(renderer); - /* init vertex data that doesn't change */ for (i = 0; i < 4; i++) renderer->vertices[i][0][3] = 1.0f; /* w */ @@ -1189,63 +1172,63 @@ void renderer_validate(struct renderer *renderer, assert(renderer->state == RENDERER_STATE_INIT); if (dirty & BLEND_DIRTY) { - struct pipe_blend_state *blend = &renderer->g3d.blend; - memset(blend, 0, sizeof(struct pipe_blend_state)); - blend->rt[0].blend_enable = 1; - blend->rt[0].colormask = PIPE_MASK_RGBA; + struct pipe_blend_state blend; + memset(&blend, 0, sizeof(blend)); + blend.rt[0].blend_enable = 1; + blend.rt[0].colormask = PIPE_MASK_RGBA; switch (state->blend_mode) { case VG_BLEND_SRC: - blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend->rt[0].blend_enable = 0; + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].blend_enable = 0; break; case VG_BLEND_SRC_OVER: - blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_SRC_ALPHA; - blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA; - blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA; + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_SRC_ALPHA; + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA; + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA; break; case VG_BLEND_DST_OVER: - blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_INV_DST_ALPHA; - blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_INV_DST_ALPHA; - blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_DST_ALPHA; - blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_DST_ALPHA; + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_INV_DST_ALPHA; + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_INV_DST_ALPHA; + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_DST_ALPHA; + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_DST_ALPHA; break; case VG_BLEND_SRC_IN: - blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_DST_ALPHA; - blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_DST_ALPHA; - blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_DST_ALPHA; + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_DST_ALPHA; + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; break; case VG_BLEND_DST_IN: - blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ZERO; - blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ZERO; - blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_SRC_ALPHA; - blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_SRC_ALPHA; + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_SRC_ALPHA; + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_SRC_ALPHA; break; case VG_BLEND_MULTIPLY: case VG_BLEND_SCREEN: case VG_BLEND_DARKEN: case VG_BLEND_LIGHTEN: - blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend->rt[0].blend_enable = 0; + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].blend_enable = 0; break; case VG_BLEND_ADDITIVE: - blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ONE; - blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ONE; break; default: assert(!"not implemented blend mode"); } - cso_set_blend(renderer->cso, blend); + cso_set_blend(renderer->cso, &blend); } if (dirty & RASTERIZER_DIRTY) { @@ -1268,7 +1251,7 @@ void renderer_validate(struct renderer *renderer, fb->zsbuf = stfb->dsrb->surface; cso_set_framebuffer(renderer->cso, fb); - vg_set_viewport(renderer->owner, VEGA_Y0_BOTTOM); + vg_set_viewport(renderer, VEGA_Y0_BOTTOM); /* surface coordinates to clipped coordinates */ vs_consts[0] = 2.0f / fb->width; @@ -1325,41 +1308,6 @@ void renderer_validate_for_shader(struct renderer *renderer, const_buffer, const_buffer_len); } -void renderer_draw_quad(struct renderer *r, - VGfloat x1, VGfloat y1, - VGfloat x2, VGfloat y2, - VGfloat depth) -{ - assert(r->state == RENDERER_STATE_INIT); - assert(floatsEqual(depth, 0.0f)); - - renderer_quad_pos(r, x1, y1, x2, y2, VG_TRUE); - renderer_quad_draw(r); -} - -void renderer_draw_texture(struct renderer *r, - struct pipe_resource *tex, - VGfloat x1offset, VGfloat y1offset, - VGfloat x2offset, VGfloat y2offset, - VGfloat x1, VGfloat y1, - VGfloat x2, VGfloat y2) -{ - assert(r->state == RENDERER_STATE_INIT); - assert(tex->width0 != 0); - assert(tex->height0 != 0); - - cso_save_vertex_shader(r->cso); - - renderer_set_vs(r, RENDERER_VS_TEXTURE); - - renderer_quad_pos(r, x1, y1, x2, y2, VG_TRUE); - renderer_quad_texcoord(r, x1offset, y1offset, - x2offset, y2offset, tex->width0, tex->height0); - renderer_quad_draw(r); - - cso_restore_vertex_shader(r->cso); -} - void renderer_copy_texture(struct renderer *ctx, struct pipe_sampler_view *src, VGfloat sx1, VGfloat sy1, @@ -1424,7 +1372,7 @@ void renderer_copy_surface(struct renderer *ctx, struct pipe_sampler_view *view; struct pipe_resource texTemp, *tex; struct pipe_subresource subsrc, subdst; - struct st_framebuffer *stfb = ctx->owner->draw_buffer; + const struct pipe_framebuffer_state *fb = &ctx->g3d.fb; const int srcW = abs(srcX1 - srcX0); const int srcH = abs(srcY1 - srcY0); const int srcLeft = MIN2(srcX0, srcX1); @@ -1492,7 +1440,7 @@ void renderer_copy_surface(struct renderer *ctx, assert(floatsEqual(z, 0.0f)); /* draw */ - if (stfb->strb->surface == dst) { + if (fb->cbufs[0] == dst) { /* transform back to surface coordinates */ dstY0 = dst->height - dstY0; dstY1 = dst->height - dstY1; diff --git a/src/gallium/state_trackers/vega/renderer.h b/src/gallium/state_trackers/vega/renderer.h index 88d0a89fc2..44ea972958 100644 --- a/src/gallium/state_trackers/vega/renderer.h +++ b/src/gallium/state_trackers/vega/renderer.h @@ -131,16 +131,6 @@ void renderer_polygon_fill(struct renderer *renderer, void renderer_polygon_fill_end(struct renderer *renderer); -void renderer_draw_quad(struct renderer *, - VGfloat x1, VGfloat y1, - VGfloat x2, VGfloat y2, - VGfloat depth); -void renderer_draw_texture(struct renderer *, - struct pipe_resource *texture, - VGfloat x1offset, VGfloat y1offset, - VGfloat x2offset, VGfloat y2offset, - VGfloat x1, VGfloat y1, - VGfloat x2, VGfloat y2); void renderer_texture_quad(struct renderer *, struct pipe_resource *texture, VGfloat x1offset, VGfloat y1offset, |