st/mesa: Combine the DrawPixels and Bitmap passthrough VS programs.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 4 Dec 2018 06:41:32 +0000 (22:41 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Fri, 21 Dec 2018 23:29:29 +0000 (15:29 -0800)
They're now identical, so we can just compile it once.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/state_tracker/st_cb_bitmap.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_drawpixels.h
src/mesa/state_tracker/st_context.h

index a73d6c7e06233bab59f094032b73d662437e2743..7ef0d7ea5c621f04fcc26be31e7f5392a01f0b55 100644 (file)
@@ -46,6 +46,7 @@
 #include "st_draw.h"
 #include "st_program.h"
 #include "st_cb_bitmap.h"
+#include "st_cb_drawpixels.h"
 #include "st_sampler_view.h"
 #include "st_texture.h"
 
@@ -53,7 +54,6 @@
 #include "pipe/p_defines.h"
 #include "pipe/p_shader_tokens.h"
 #include "util/u_inlines.h"
-#include "util/u_simple_shaders.h"
 #include "util/u_upload_mgr.h"
 #include "program/prog_instruction.h"
 #include "cso_cache/cso_context.h"
@@ -214,7 +214,7 @@ setup_render_state(struct gl_context *ctx,
    cso_set_fragment_shader_handle(cso, fpv->driver_shader);
 
    /* vertex shader state: position + texcoord pass-through */
-   cso_set_vertex_shader_handle(cso, st->bitmap.vs);
+   cso_set_vertex_shader_handle(cso, st->passthrough_vs);
 
    /* disable other shaders */
    cso_set_tessctrl_shader_handle(cso, NULL);
@@ -538,7 +538,7 @@ init_bitmap_state(struct st_context *st)
    struct pipe_screen *screen = pipe->screen;
 
    /* This function should only be called once */
-   assert(st->bitmap.vs == NULL);
+   assert(!st->bitmap.tex_format);
 
    assert(st->internal_target == PIPE_TEXTURE_2D ||
           st->internal_target == PIPE_TEXTURE_RECT);
@@ -585,17 +585,7 @@ init_bitmap_state(struct st_context *st)
    }
 
    /* Create the vertex shader */
-   {
-      const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
-                                      TGSI_SEMANTIC_COLOR,
-        st->needs_texcoord_semantic ? TGSI_SEMANTIC_TEXCOORD :
-                                      TGSI_SEMANTIC_GENERIC };
-      const uint semantic_indexes[] = { 0, 0, 0 };
-      st->bitmap.vs = util_make_vertex_passthrough_shader(st->pipe, 3,
-                                                          semantic_names,
-                                                          semantic_indexes,
-                                                          FALSE);
-   }
+   st_make_passthrough_vertex_shader(st);
 
    reset_cache(st);
 }
@@ -617,7 +607,7 @@ st_Bitmap(struct gl_context *ctx, GLint x, GLint y,
 
    st_invalidate_readpix_cache(st);
 
-   if (!st->bitmap.vs) {
+   if (!st->bitmap.tex_format) {
       init_bitmap_state(st);
    }
 
@@ -677,7 +667,7 @@ st_DrawAtlasBitmaps(struct gl_context *ctx,
    struct pipe_vertex_buffer vb = {0};
    unsigned i;
 
-   if (!st->bitmap.vs) {
+   if (!st->bitmap.tex_format) {
       init_bitmap_state(st);
    }
 
@@ -807,11 +797,6 @@ st_destroy_bitmap(struct st_context *st)
    struct pipe_context *pipe = st->pipe;
    struct st_bitmap_cache *cache = &st->bitmap.cache;
 
-   if (st->bitmap.vs) {
-      cso_delete_vertex_shader(st->cso_context, st->bitmap.vs);
-      st->bitmap.vs = NULL;
-   }
-
    if (cache->trans && cache->buffer) {
       pipe_transfer_unmap(pipe, cache->trans);
    }
index 120b5c48339daa8de2876e984d3deb4b4ae75fee..672b665310b7c493fccc5f8f925a6e96c440e65f 100644 (file)
@@ -194,10 +194,10 @@ get_drawpix_z_stencil_program(struct st_context *st,
  * Create a simple vertex shader that just passes through the
  * vertex position, texcoord, and color.
  */
-static void
-make_passthrough_vertex_shader(struct st_context *st)
+void
+st_make_passthrough_vertex_shader(struct st_context *st)
 {
-   if (st->drawpix.vert_shader)
+   if (st->passthrough_vs)
       return;
 
    const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
@@ -206,7 +206,7 @@ make_passthrough_vertex_shader(struct st_context *st)
                                    TGSI_SEMANTIC_GENERIC };
    const uint semantic_indexes[] = { 0, 0, 0 };
 
-   st->drawpix.vert_shader =
+   st->passthrough_vs =
       util_make_vertex_passthrough_shader(st->pipe, 3, semantic_names,
                                           semantic_indexes, false);
 }
@@ -1164,7 +1164,7 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
       return;
    }
 
-   make_passthrough_vertex_shader(st);
+   st_make_passthrough_vertex_shader(st);
 
    /*
     * Get vertex/fragment shaders
@@ -1225,7 +1225,7 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
                       ctx->Pixel.ZoomX, ctx->Pixel.ZoomY,
                       sv,
                       num_sampler_view,
-                      st->drawpix.vert_shader,
+                      st->passthrough_vs,
                       driver_fp, fpv,
                       ctx->Current.RasterColor,
                       GL_FALSE, write_depth, write_stencil);
@@ -1526,7 +1526,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
     * are handled.
     */
 
-   make_passthrough_vertex_shader(st);
+   st_make_passthrough_vertex_shader(st);
 
    /*
     * Get vertex/fragment shaders
@@ -1681,7 +1681,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
                       width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY,
                       sv,
                       num_sampler_view,
-                      st->drawpix.vert_shader,
+                      st->passthrough_vs,
                       driver_fp, fpv,
                       ctx->Current.Attrib[VERT_ATTRIB_COLOR0],
                       invertTex, GL_FALSE, GL_FALSE);
@@ -1710,8 +1710,8 @@ st_destroy_drawpix(struct st_context *st)
                                     st->drawpix.zs_shaders[i]);
    }
 
-   if (st->drawpix.vert_shader)
-      cso_delete_vertex_shader(st->cso_context, st->drawpix.vert_shader);
+   if (st->passthrough_vs)
+      cso_delete_vertex_shader(st->cso_context, st->passthrough_vs);
 
    /* Free cache data */
    for (i = 0; i < ARRAY_SIZE(st->drawpix_cache.entries); i++) {
index 84a70be9706a754c50f3204b2479c6e2d224f0fc..88142c3f9ab81cc1319a385aa68df5f86bda0961 100644 (file)
@@ -47,4 +47,7 @@ st_get_drawpix_shader(const struct tgsi_token *tokens, bool use_texcoord,
                       unsigned drawpix_sampler, unsigned pixelmap_sampler,
                       unsigned texcoord_const, unsigned tex_target);
 
+extern void
+st_make_passthrough_vertex_shader(struct st_context *st);
+
 #endif /* ST_CB_DRAWPIXELS_H */
index 622b7a40dc4946b6fa8be8d0ccb40bf2101a2e40..b31e719708e369e6e97c3a5e139dac2d1a963242 100644 (file)
@@ -224,14 +224,12 @@ struct st_context
       struct pipe_sampler_state sampler;
       struct pipe_sampler_state atlas_sampler;
       enum pipe_format tex_format;
-      void *vs;
       struct st_bitmap_cache cache;
    } bitmap;
 
    /** for glDraw/CopyPixels */
    struct {
       void *zs_shaders[4];
-      void *vert_shader;   /**< ureg shader */
    } drawpix;
 
    /** Cache of glDrawPixels images */
@@ -278,6 +276,9 @@ struct st_context
    /** for drawing with st_util_vertex */
    struct pipe_vertex_element util_velems[3];
 
+   /** passthrough vertex shader matching the util_velem attributes */
+   void *passthrough_vs;
+
    enum pipe_texture_target internal_target;
 
    struct cso_context *cso_context;