st/mesa: move some st_cb_drawpixels.c code, add comments

This commit is contained in:
Brian Paul 2016-02-09 14:19:25 -07:00
parent c624241ef4
commit a5b8ede253

View file

@ -648,6 +648,7 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
sampler.normalized_coords = normalized;
if (fpv) {
/* drawing a color image */
const struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS];
uint num = MAX2(MAX2(fpv->drawpix_sampler, fpv->pixelmap_sampler) + 1,
st->state.num_samplers[PIPE_SHADER_FRAGMENT]);
@ -662,12 +663,33 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
cso_set_samplers(cso, PIPE_SHADER_FRAGMENT, num, samplers);
} else {
/* drawing a depth/stencil image */
const struct pipe_sampler_state *samplers[2] = {&sampler, &sampler};
cso_set_samplers(cso, PIPE_SHADER_FRAGMENT, num_sampler_view, samplers);
}
}
/* user textures, plus the drawpix textures */
if (fpv) {
/* drawing a color image */
struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
uint num = MAX3(fpv->drawpix_sampler + 1,
fpv->pixelmap_sampler + 1,
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT]);
memcpy(sampler_views, st->state.sampler_views[PIPE_SHADER_FRAGMENT],
sizeof(sampler_views));
sampler_views[fpv->drawpix_sampler] = sv[0];
if (sv[1])
sampler_views[fpv->pixelmap_sampler] = sv[1];
cso_set_sampler_views(cso, PIPE_SHADER_FRAGMENT, num, sampler_views);
} else {
/* drawing a depth/stencil image */
cso_set_sampler_views(cso, PIPE_SHADER_FRAGMENT, num_sampler_view, sv);
}
/* viewport state: viewport matching window dims */
{
const float w = (float) ctx->DrawBuffer->Width;
@ -685,23 +707,6 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
cso_set_vertex_elements(cso, 3, st->velems_util_draw);
cso_set_stream_outputs(st->cso_context, 0, NULL, NULL);
/* user textures, plus the drawpix textures */
if (fpv) {
struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
uint num = MAX3(fpv->drawpix_sampler + 1,
fpv->pixelmap_sampler + 1,
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT]);
memcpy(sampler_views, st->state.sampler_views[PIPE_SHADER_FRAGMENT],
sizeof(sampler_views));
sampler_views[fpv->drawpix_sampler] = sv[0];
if (sv[1])
sampler_views[fpv->pixelmap_sampler] = sv[1];
cso_set_sampler_views(cso, PIPE_SHADER_FRAGMENT, num, sampler_views);
} else
cso_set_sampler_views(cso, PIPE_SHADER_FRAGMENT, num_sampler_view, sv);
/* Compute Gallium window coords (y=0=top) with pixel zoom.
* Recall that these coords are transformed by the current
* vertex shader and viewport transformation.