Ejemplo n.º 1
0
static void
xa_yuv_fs_constants(struct xa_context *r, const float conversion_matrix[])
{
    const int param_bytes = 12 * sizeof(float);

    renderer_set_constants(r, PIPE_SHADER_FRAGMENT,
			   conversion_matrix, param_bytes);
}
Ejemplo n.º 2
0
/* Set up framebuffer, viewport and vertex shader constant buffer
 * state for a particular destinaton surface.  In all our rendering,
 * these concepts are linked.
 */
void
renderer_bind_destination(struct xa_context *r,
			  struct pipe_surface *surface)
{
    int width = surface->width;
    int height = surface->height;

    struct pipe_framebuffer_state fb;
    struct pipe_viewport_state viewport;

    xa_scissor_reset(r);

    /* Framebuffer uses actual surface width/height
     */
    memset(&fb, 0, sizeof fb);
    fb.width = surface->width;
    fb.height = surface->height;
    fb.nr_cbufs = 1;
    fb.cbufs[0] = surface;
    fb.zsbuf = 0;

    /* Viewport just touches the bit we're interested in:
     */
    viewport.scale[0] = width / 2.f;
    viewport.scale[1] = height / 2.f;
    viewport.scale[2] = 1.0;
    viewport.scale[3] = 1.0;
    viewport.translate[0] = width / 2.f;
    viewport.translate[1] = height / 2.f;
    viewport.translate[2] = 0.0;
    viewport.translate[3] = 0.0;

    /* Constant buffer set up to match viewport dimensions:
     */
    if (r->fb_width != width || r->fb_height != height) {
	float vs_consts[8] = {
	    2.f / width, 2.f / height, 1, 1,
	    -1, -1, 0, 0
	};

	r->fb_width = width;
	r->fb_height = height;

	renderer_set_constants(r, PIPE_SHADER_VERTEX,
			       vs_consts, sizeof vs_consts);
    }

    cso_set_framebuffer(r->cso, &fb);
    cso_set_viewport(r->cso, &viewport);
}