static void
setup_render_state(struct gl_context *ctx,
struct pipe_sampler_view *sv,
- const GLfloat *color)
+ const GLfloat *color, struct gl_program *fp,
+ bool scissor_enabled, bool clamp_frag_color)
{
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
key.st = st->has_shareable_shaders ? NULL : st;
key.bitmap = GL_TRUE;
key.clamp_color = st->clamp_frag_color_in_shader &&
- ctx->Color._ClampFragmentColor;
+ clamp_frag_color;
key.lower_alpha_func = COMPARE_FUNC_ALWAYS;
- fpv = st_get_fp_variant(st, st->fp, &key);
+ fpv = st_get_fp_variant(st, fp, &key);
/* As an optimization, Mesa's fragment programs will sometimes get the
* primary color from a statevar/constant rather than a varying variable.
GLfloat colorSave[4];
COPY_4V(colorSave, ctx->Current.Attrib[VERT_ATTRIB_COLOR0]);
COPY_4V(ctx->Current.Attrib[VERT_ATTRIB_COLOR0], color);
- st_upload_constants(st, st->fp, MESA_SHADER_FRAGMENT);
+ st_upload_constants(st, fp, MESA_SHADER_FRAGMENT);
COPY_4V(ctx->Current.Attrib[VERT_ATTRIB_COLOR0], colorSave);
}
/* rasterizer state: just scissor */
- st->bitmap.rasterizer.scissor = ctx->Scissor.EnableFlags & 1;
+ st->bitmap.rasterizer.scissor = scissor_enabled;
cso_set_rasterizer(cso, &st->bitmap.rasterizer);
/* fragment shader state: TEX lookup program */
{
struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
unsigned num_views =
- st_get_sampler_views(st, PIPE_SHADER_FRAGMENT,
- ctx->FragmentProgram._Current, sampler_views);
+ st_get_sampler_views(st, PIPE_SHADER_FRAGMENT, fp, sampler_views);
num_views = MAX2(fpv->bitmap_sampler + 1, num_views);
sampler_views[fpv->bitmap_sampler] = sv;
static void
draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
GLsizei width, GLsizei height,
- struct pipe_sampler_view *sv, const GLfloat *color)
+ struct pipe_sampler_view *sv, const GLfloat *color,
+ struct gl_program *fp, bool scissor_enabled,
+ bool clamp_frag_color)
{
struct st_context *st = st_context(ctx);
const float fb_width = (float) st->state.fb_width;
tBot = (float) height;
}
- setup_render_state(ctx, sv, color);
+ setup_render_state(ctx, sv, color, fp, scissor_enabled, clamp_frag_color);
/* convert Z from [0,1] to [-1,-1] to match viewport Z scale/bias */
z = z * 2.0f - 1.0f;
cache->ymin = 1000000;
cache->ymax = -1000000;
+ _mesa_reference_program(st->ctx, &cache->fp, NULL);
+
assert(!cache->texture);
/* allocate a new texture */
cache->zpos,
BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT,
sv,
- cache->color);
+ cache->color,
+ cache->fp,
+ cache->scissor_enabled,
+ cache->clamp_frag_color);
}
/* release/free the texture */
height > BITMAP_CACHE_HEIGHT)
return GL_FALSE; /* too big to cache */
+ bool scissor_enabled = ctx->Scissor.EnableFlags & 0x1;
+ bool clamp_frag_color = ctx->Color._ClampFragmentColor;
+
if (!cache->empty) {
px = x - cache->xpos; /* pos in buffer */
py = y - cache->ypos;
if (px < 0 || px + width > BITMAP_CACHE_WIDTH ||
py < 0 || py + height > BITMAP_CACHE_HEIGHT ||
!TEST_EQ_4V(ctx->Current.RasterColor, cache->color) ||
+ ctx->FragmentProgram._Current != cache->fp ||
+ scissor_enabled != cache->scissor_enabled ||
+ clamp_frag_color != cache->clamp_frag_color ||
((fabsf(z - cache->zpos) > Z_EPSILON))) {
/* This bitmap would extend beyond cache bounds, or the bitmap
* color is changing
cache->zpos = z;
cache->empty = GL_FALSE;
COPY_4FV(cache->color, ctx->Current.RasterColor);
+ _mesa_reference_program(ctx, &cache->fp, ctx->FragmentProgram._Current);
+ cache->scissor_enabled = scissor_enabled;
+ cache->clamp_frag_color = clamp_frag_color;
}
assert(px != -999);
if (view) {
draw_bitmap_quad(ctx, x, y, ctx->Current.RasterPos[2],
- width, height, view, ctx->Current.RasterColor);
+ width, height, view, ctx->Current.RasterColor,
+ ctx->FragmentProgram._Current,
+ ctx->Scissor.EnableFlags & 0x1,
+ ctx->Color._ClampFragmentColor);
}
}
pipe_texture_unmap(pipe, cache->trans);
}
pipe_resource_reference(&st->bitmap.cache.texture, NULL);
+ _mesa_reference_program(st->ctx, &st->bitmap.cache.fp, NULL);
}