st/mesa: Combine the DrawPixels and Bitmap passthrough VS programs.

They're now identical, so we can just compile it once.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Kenneth Graunke 2018-12-03 22:41:32 -08:00
parent 80dd9dfe33
commit bcb6f19947
4 changed files with 22 additions and 33 deletions

View 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);
}

View 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++) {

View 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 */

View 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;