st/vega: Clean up vg_context fields and functions.
authorChia-I Wu <olv@lunarg.com>
Sat, 27 Nov 2010 19:39:18 +0000 (03:39 +0800)
committerChia-I Wu <olv@lunarg.com>
Wed, 1 Dec 2010 03:23:50 +0000 (11:23 +0800)
src/gallium/state_trackers/vega/asm_util.h
src/gallium/state_trackers/vega/renderer.c
src/gallium/state_trackers/vega/vg_context.c
src/gallium/state_trackers/vega/vg_context.h

index 903bfc8..ae1842a 100644 (file)
 #ifndef ASM_UTIL_H
 #define ASM_UTIL_H
 
-
-static const char pass_through_depth_asm[] =
-   "FRAG\n"
-   "DCL IN[0], POSITION, LINEAR\n"
-   "DCL OUT[0].z, POSITION, CONSTANT\n"
-   "0: MOV OUT[0].z, IN[0].zzzz\n"
-   "1: END\n";
-
-
-
 /* μnew = μmask */
 static const char set_mask_asm[] =
    "FRAG\n"
@@ -92,45 +82,4 @@ static const char subtract_mask_asm[] =
    "3: MUL OUT[0], TEMP[2].wwww, TEMP[0].wwww\n"
    "4: END\n";
 
-
-static const char vs_plain_asm[] =
-   "VERT\n"
-   "DCL IN[0]\n"
-   "DCL OUT[0], POSITION\n"
-   "DCL TEMP[0]\n"
-   "DCL CONST[0..1]\n"
-   "0: MUL TEMP[0], IN[0], CONST[0]\n"
-   "1: ADD TEMP[0], TEMP[0], CONST[1]\n"
-   "2: MOV OUT[0], TEMP[0]\n"
-   "3: END\n";
-
-static const char vs_clear_asm[] =
-   "VERT\n"
-   "DCL IN[0]\n"
-   "DCL IN[1]\n"
-   "DCL OUT[0], POSITION\n"
-   "DCL OUT[1], COLOR\n"
-   "DCL TEMP[0]\n"
-   "DCL CONST[0..1]\n"
-   "0: MUL TEMP[0], IN[0], CONST[0]\n"
-   "1: ADD TEMP[0], TEMP[0], CONST[1]\n"
-   "2: MOV OUT[0], TEMP[0]\n"
-   "3: MOV OUT[1], IN[1]\n"
-   "4: END\n";
-
-
-static const char vs_texture_asm[] =
-   "VERT\n"
-   "DCL IN[0]\n"
-   "DCL IN[1]\n"
-   "DCL OUT[0], POSITION\n"
-   "DCL OUT[1], GENERIC\n"
-   "DCL TEMP[0]\n"
-   "DCL CONST[0..1]\n"
-   "0: MUL TEMP[0], IN[0], CONST[0]\n"
-   "1: ADD TEMP[0], TEMP[0], CONST[1]\n"
-   "2: MOV OUT[0], TEMP[0]\n"
-   "3: MOV OUT[1], IN[1]\n"
-   "4: END\n";
-
 #endif
index 2c5b5df..c0d69ee 100644 (file)
@@ -89,6 +89,7 @@ struct renderer {
 
    struct pipe_resource *vs_const_buffer;
 
+   struct pipe_vertex_element velems[2];
    VGfloat vertices[4][2][4];
 
    void *cached_vs[NUM_RENDERER_VS];
@@ -489,7 +490,7 @@ static void renderer_quad_draw(struct renderer *r)
                                  sizeof(r->vertices),
                                  PIPE_BIND_VERTEX_BUFFER);
    if (buf) {
-      cso_set_vertex_elements(r->cso, 2, r->owner->velems);
+      cso_set_vertex_elements(r->cso, 2, r->velems);
       util_draw_vertex_buffer(r->pipe, buf, 0,
                               PIPE_PRIM_TRIANGLE_FAN,
                               Elements(r->vertices),     /* verts */
@@ -1091,6 +1092,13 @@ struct renderer * renderer_create(struct vg_context *owner)
    for (i = 0; i < 4; i++)
       renderer->vertices[i][0][3] = 1.0f; /* w */
 
+   for (i = 0; i < 2; i++) {
+      renderer->velems[i].src_offset = i * 4 * sizeof(float);
+      renderer->velems[i].instance_divisor = 0;
+      renderer->velems[i].vertex_buffer_index = 0;
+      renderer->velems[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+   }
+
    renderer->state = RENDERER_STATE_INIT;
 
    return renderer;
index e76a656..f2966fc 100644 (file)
@@ -54,19 +54,6 @@ struct vg_context * vg_current_context(void)
    return _vg_context;
 }
 
-static void init_clear(struct vg_context *st)
-{
-   struct pipe_context *pipe = st->pipe;
-
-   /* rasterizer state: bypass clipping */
-   memset(&st->clear.raster, 0, sizeof(st->clear.raster));
-   st->clear.raster.gl_rasterization_rules = 1;
-
-   /* fragment shader state: color pass-through program */
-   st->clear.fs =
-      util_make_fragment_passthrough_shader(pipe);
-}
-
 /**
  * A depth/stencil rb will be needed regardless of what the visual says.
  */
@@ -103,7 +90,6 @@ struct vg_context * vg_create_context(struct pipe_context *pipe,
                                       struct vg_context *share)
 {
    struct vg_context *ctx;
-   unsigned i;
 
    ctx = CALLOC_STRUCT(vg_context);
 
@@ -120,8 +106,6 @@ struct vg_context * vg_create_context(struct pipe_context *pipe,
 
    ctx->cso_context = cso_create_context(pipe);
 
-   init_clear(ctx);
-
    ctx->default_paint = paint_create(ctx);
    ctx->state.vg.stroke_paint = ctx->default_paint;
    ctx->state.vg.fill_paint = ctx->default_paint;
@@ -143,13 +127,6 @@ struct vg_context * vg_create_context(struct pipe_context *pipe,
    ctx->blend_sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST;
    ctx->blend_sampler.normalized_coords = 0;
 
-   for (i = 0; i < 2; i++) {
-      ctx->velems[i].src_offset = i * 4 * sizeof(float);
-      ctx->velems[i].instance_divisor = 0;
-      ctx->velems[i].vertex_buffer_index = 0;
-      ctx->velems[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
-   }
-
    vg_set_error(ctx, VG_NO_ERROR);
 
    ctx->owned_objects[VG_OBJECT_PAINT] = cso_hash_create();
@@ -170,7 +147,6 @@ struct vg_context * vg_create_context(struct pipe_context *pipe,
 void vg_destroy_context(struct vg_context *ctx)
 {
    struct pipe_resource **cbuf = &ctx->mask.cbuf;
-   struct pipe_resource **vsbuf = &ctx->vs_const_buffer;
 
    util_destroy_blit(ctx->blit);
    renderer_destroy(ctx->renderer);
@@ -181,29 +157,6 @@ void vg_destroy_context(struct vg_context *ctx)
    if (*cbuf)
       pipe_resource_reference(cbuf, NULL);
 
-   if (*vsbuf)
-      pipe_resource_reference(vsbuf, NULL);
-
-   if (ctx->clear.fs) {
-      cso_delete_fragment_shader(ctx->cso_context, ctx->clear.fs);
-      ctx->clear.fs = NULL;
-   }
-
-   if (ctx->plain_vs) {
-      vg_shader_destroy(ctx, ctx->plain_vs);
-      ctx->plain_vs = NULL;
-   }
-   if (ctx->clear_vs) {
-      vg_shader_destroy(ctx, ctx->clear_vs);
-      ctx->clear_vs = NULL;
-   }
-   if (ctx->texture_vs) {
-      vg_shader_destroy(ctx, ctx->texture_vs);
-      ctx->texture_vs = NULL;
-   }
-
-   if (ctx->pass_through_depth_fs)
-      vg_shader_destroy(ctx, ctx->pass_through_depth_fs);
    if (ctx->mask.union_fs)
       vg_shader_destroy(ctx, ctx->mask.union_fs);
    if (ctx->mask.intersect_fs)
@@ -556,40 +509,3 @@ void vg_prepare_blend_surface_from_mask(struct vg_context *ctx)
    if (dest_surface)
       pipe_surface_reference(&dest_surface, NULL);
 }
-
-void * vg_plain_vs(struct vg_context *ctx)
-{
-   if (!ctx->plain_vs) {
-      ctx->plain_vs = shader_create_from_text(ctx->pipe,
-                                              vs_plain_asm,
-                                              200,
-                                              PIPE_SHADER_VERTEX);
-   }
-
-   return ctx->plain_vs->driver;
-}
-
-
-void * vg_clear_vs(struct vg_context *ctx)
-{
-   if (!ctx->clear_vs) {
-      ctx->clear_vs = shader_create_from_text(ctx->pipe,
-                                              vs_clear_asm,
-                                              200,
-                                              PIPE_SHADER_VERTEX);
-   }
-
-   return ctx->clear_vs->driver;
-}
-
-void * vg_texture_vs(struct vg_context *ctx)
-{
-   if (!ctx->texture_vs) {
-      ctx->texture_vs = shader_create_from_text(ctx->pipe,
-                                                vs_texture_asm,
-                                                200,
-                                                PIPE_SHADER_VERTEX);
-   }
-
-   return ctx->texture_vs->driver;
-}
index b3263cd..07f3ca7 100644 (file)
@@ -109,14 +109,6 @@ struct vg_context
    struct cso_hash *owned_objects[VG_OBJECT_LAST];
 
    struct {
-      struct pipe_shader_state vert_shader;
-      struct pipe_shader_state frag_shader;
-      struct pipe_rasterizer_state raster;
-      void *fs;
-      float vertices[4][2][4];  /**< vertex pos + color */
-   } clear;
-
-   struct {
       struct pipe_resource *cbuf;
       struct pipe_sampler_state sampler;
 
@@ -126,31 +118,16 @@ struct vg_context
       struct vg_shader *set_fs;
    } mask;
 
-   struct vg_shader *pass_through_depth_fs;
-
    struct cso_context *cso_context;
 
-   struct pipe_resource *stencil_quad;
-   VGfloat stencil_vertices[4][2][4];
-
    struct renderer *renderer;
    struct shaders_cache *sc;
    struct shader *shader;
 
    struct pipe_sampler_state blend_sampler;
-   struct {
-      struct pipe_resource *buffer;
-      void *color_matrix_fs;
-   } filter;
    struct vg_paint *default_paint;
 
    struct blit_state *blit;
-
-   struct vg_shader *plain_vs;
-   struct vg_shader *clear_vs;
-   struct vg_shader *texture_vs;
-   struct pipe_resource *vs_const_buffer;
-   struct pipe_vertex_element velems[2];
 };
 
 struct vg_object {
@@ -285,8 +262,4 @@ static INLINE void vg_bound_rect(VGfloat coords[4],
    }
 }
 
-void *vg_plain_vs(struct vg_context *ctx);
-void *vg_clear_vs(struct vg_context *ctx);
-void *vg_texture_vs(struct vg_context *ctx);
-
 #endif