They're now identical, so we can just compile it once.
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
#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"
#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"
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);
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);
}
/* 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);
}
st_invalidate_readpix_cache(st);
- if (!st->bitmap.vs) {
+ if (!st->bitmap.tex_format) {
init_bitmap_state(st);
}
struct pipe_vertex_buffer vb = {0};
unsigned i;
- if (!st->bitmap.vs) {
+ if (!st->bitmap.tex_format) {
init_bitmap_state(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);
}
* 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,
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);
}
return;
}
- make_passthrough_vertex_shader(st);
+ st_make_passthrough_vertex_shader(st);
/*
* Get vertex/fragment shaders
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);
* are handled.
*/
- make_passthrough_vertex_shader(st);
+ st_make_passthrough_vertex_shader(st);
/*
* Get vertex/fragment shaders
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);
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++) {
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 */
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 */
/** 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;