/**
* Create a simple vertex shader that just passes through the
- * vertex position and texcoord (and optionally, color).
+ * vertex position, texcoord, and color.
*/
-static void *
-make_passthrough_vertex_shader(struct st_context *st,
- GLboolean passColor)
+static void
+make_passthrough_vertex_shader(struct st_context *st)
{
const enum tgsi_semantic texcoord_semantic = st->needs_texcoord_semantic ?
TGSI_SEMANTIC_TEXCOORD : TGSI_SEMANTIC_GENERIC;
- if (!st->drawpix.vert_shaders[passColor]) {
+ if (!st->drawpix.vert_shader) {
struct ureg_program *ureg = ureg_create( PIPE_SHADER_VERTEX );
if (ureg == NULL)
- return NULL;
+ return;
/* MOV result.pos, vertex.pos; */
ureg_MOV(ureg,
ureg_DECL_output( ureg, TGSI_SEMANTIC_POSITION, 0 ),
ureg_DECL_vs_input( ureg, 0 ));
- if (passColor) {
- /* MOV result.color0, vertex.attr[1]; */
- ureg_MOV(ureg,
- ureg_DECL_output( ureg, TGSI_SEMANTIC_COLOR, 0 ),
- ureg_DECL_vs_input( ureg, 1 ));
- }
+ /* MOV result.color0, vertex.attr[1]; */
+ ureg_MOV(ureg,
+ ureg_DECL_output( ureg, TGSI_SEMANTIC_COLOR, 0 ),
+ ureg_DECL_vs_input( ureg, 1 ));
/* MOV result.texcoord0, vertex.attr[2]; */
ureg_MOV(ureg,
ureg_END( ureg );
- st->drawpix.vert_shaders[passColor] =
+ st->drawpix.vert_shader =
ureg_create_shader_and_destroy( ureg, st->pipe );
}
-
- return st->drawpix.vert_shaders[passColor];
}
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *unpack, const void *pixels)
{
- void *driver_vp, *driver_fp;
+ void *driver_fp;
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
GLboolean write_stencil = GL_FALSE, write_depth = GL_FALSE;
return;
}
+ make_passthrough_vertex_shader(st);
+
/*
* Get vertex/fragment shaders
*/
if (write_depth || write_stencil) {
driver_fp = get_drawpix_z_stencil_program(st, write_depth,
write_stencil);
- driver_vp = make_passthrough_vertex_shader(st, GL_TRUE);
}
else {
fpv = get_color_fp_variant(st);
driver_fp = fpv->driver_shader;
- driver_vp = make_passthrough_vertex_shader(st, GL_FALSE);
if (ctx->Pixel.MapColorFlag) {
pipe_sampler_view_reference(&sv[1],
ctx->Pixel.ZoomX, ctx->Pixel.ZoomY,
sv,
num_sampler_view,
- driver_vp,
+ st->drawpix.vert_shader,
driver_fp, fpv,
ctx->Current.RasterColor,
GL_FALSE, write_depth, write_stencil);
struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = pipe->screen;
struct st_renderbuffer *rbRead;
- void *driver_vp, *driver_fp;
+ void *driver_fp;
struct pipe_resource *pt;
struct pipe_sampler_view *sv[2] = { NULL };
struct st_fp_variant *fpv = NULL;
* are handled.
*/
+ make_passthrough_vertex_shader(st);
/*
* Get vertex/fragment shaders
rbRead = st_get_color_read_renderbuffer(ctx);
driver_fp = fpv->driver_shader;
- driver_vp = make_passthrough_vertex_shader(st, GL_FALSE);
if (ctx->Pixel.MapColorFlag) {
pipe_sampler_view_reference(&sv[1],
Attachment[BUFFER_DEPTH].Renderbuffer);
driver_fp = get_drawpix_z_stencil_program(st, GL_TRUE, GL_FALSE);
- driver_vp = make_passthrough_vertex_shader(st, GL_TRUE);
}
/* Choose the format for the temporary texture. */
width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY,
sv,
num_sampler_view,
- driver_vp,
+ st->drawpix.vert_shader,
driver_fp, fpv,
ctx->Current.Attrib[VERT_ATTRIB_COLOR0],
invertTex, GL_FALSE, GL_FALSE);
st->drawpix.zs_shaders[i]);
}
- if (st->drawpix.vert_shaders[0])
- cso_delete_vertex_shader(st->cso_context, st->drawpix.vert_shaders[0]);
- if (st->drawpix.vert_shaders[1])
- cso_delete_vertex_shader(st->cso_context, st->drawpix.vert_shaders[1]);
+ if (st->drawpix.vert_shader)
+ cso_delete_vertex_shader(st->cso_context, st->drawpix.vert_shader);
/* Free cache data */
for (i = 0; i < ARRAY_SIZE(st->drawpix_cache.entries); i++) {