exa->bound_textures);
}
-static void
-setup_vs_constant_buffer(struct exa_context *exa,
- int width, int height)
-{
- const int param_bytes = 8 * sizeof(float);
- float vs_consts[8] = {
- 2.f/width, 2.f/height, 1, 1,
- -1, -1, 0, 0
- };
- renderer_set_constants(exa->renderer, PIPE_SHADER_VERTEX,
- vs_consts, param_bytes);
-}
static void
static void
setup_constant_buffers(struct exa_context *exa, struct exa_pixmap_priv *pDst)
{
- int width = pDst->tex->width[0];
- int height = pDst->tex->height[0];
-
- setup_vs_constant_buffer(exa, width, height);
setup_fs_constant_buffer(exa);
}
struct exa_pixmap_priv *pMask,
struct exa_pixmap_priv *pDst)
{
- renderer_bind_framebuffer(exa->renderer, pDst);
- renderer_bind_viewport(exa->renderer, pDst);
+ struct pipe_surface *dst_surf = xorg_gpu_surface(exa->scrn, pDst);
+
+ renderer_bind_destination(exa->renderer, dst_surf);
+
bind_blend_state(exa, op, pSrcPicture, pMaskPicture, pDstPicture);
renderer_bind_rasterizer(exa->renderer);
bind_shaders(exa, op, pSrcPicture, pMaskPicture, pDstPicture, pSrc, pMask);
struct exa_pixmap_priv *pixmap,
Pixel fg)
{
+ struct pipe_surface *dst_surf = xorg_gpu_surface(exa->scrn, pixmap);
unsigned vs_traits, fs_traits;
struct xorg_shader shader;
vs_traits = VS_SOLID_FILL;
fs_traits = FS_SOLID_FILL;
- renderer_bind_framebuffer(exa->renderer, pixmap);
- renderer_bind_viewport(exa->renderer, pixmap);
+ renderer_bind_destination(exa->renderer, dst_surf);
renderer_bind_rasterizer(exa->renderer);
bind_blend_state(exa, PictOpSrc, NULL, NULL, NULL);
cso_set_samplers(exa->renderer->cso, 0, NULL);
r->attrs_per_vertex); /* attribs/vert */
pipe_buffer_reference(&buf, NULL);
+ pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
}
}
-static void
-set_viewport(struct xorg_renderer *r, int width, int height,
- enum AxisOrientation orientation)
+/* 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 xorg_renderer *r,
+ struct pipe_surface *surface )
{
+
+ struct pipe_framebuffer_state fb;
struct pipe_viewport_state viewport;
- float y_scale = (orientation == Y0_BOTTOM) ? -2.f : 2.f;
+ int width = surface->width;
+ int height = surface->height;
+
+ memset(&fb, 0, sizeof fb);
+ fb.width = width;
+ fb.height = height;
+ fb.nr_cbufs = 1;
+ fb.cbufs[0] = surface;
+ fb.zsbuf = 0;
viewport.scale[0] = width / 2.f;
- viewport.scale[1] = height / y_scale;
+ viewport.scale[1] = height / 2.f;
viewport.scale[2] = 1.0;
viewport.scale[3] = 1.0;
viewport.translate[0] = width / 2.f;
viewport.translate[2] = 0.0;
viewport.translate[3] = 0.0;
+ 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);
}
-
struct xorg_renderer * renderer_create(struct pipe_context *pipe)
{
struct xorg_renderer *renderer = CALLOC_STRUCT(xorg_renderer);
}
}
-void renderer_bind_framebuffer(struct xorg_renderer *r,
- struct exa_pixmap_priv *priv)
-{
- unsigned i;
- struct pipe_framebuffer_state state;
- struct pipe_surface *surface = xorg_gpu_surface(r->pipe->screen, priv);
- memset(&state, 0, sizeof(struct pipe_framebuffer_state));
-
- state.width = priv->tex->width[0];
- state.height = priv->tex->height[0];
- state.nr_cbufs = 1;
- state.cbufs[0] = surface;
- for (i = 1; i < PIPE_MAX_COLOR_BUFS; ++i)
- state.cbufs[i] = 0;
- /* currently we don't use depth/stencil */
- state.zsbuf = 0;
- cso_set_framebuffer(r->cso, &state);
-
- /* we do fire and forget for the framebuffer, this is the forget part */
- pipe_surface_reference(&surface, NULL);
-}
-
-void renderer_bind_viewport(struct xorg_renderer *r,
- struct exa_pixmap_priv *dst)
-{
- int width = dst->tex->width[0];
- int height = dst->tex->height[0];
-
- /*debug_printf("Bind viewport (%d, %d)\n", width, height);*/
-
- set_viewport(r, width, height, Y0_TOP);
-}
void renderer_bind_rasterizer(struct xorg_renderer *r)
{
r->pipe->set_constant_buffer(r->pipe, shader_type, 0, cbuf);
}
-static void
-setup_vs_constant_buffer(struct xorg_renderer *r,
- int width, int height)
-{
- const int param_bytes = 8 * sizeof(float);
- float vs_consts[8] = {
- 2.f/width, 2.f/height, 1, 1,
- -1, -1, 0, 0
- };
- renderer_set_constants(r, PIPE_SHADER_VERTEX,
- vs_consts, param_bytes);
-}
-
static void
setup_fs_constant_buffer(struct xorg_renderer *r)
{
struct pipe_surface *dst_surf = screen->get_tex_surface(
screen, dst, 0, 0, 0,
PIPE_BUFFER_USAGE_GPU_WRITE);
- struct pipe_framebuffer_state fb;
float s0, t0, s1, t1;
struct xorg_shader shader;
cso_single_sampler_done(r->cso);
}
- set_viewport(r, dst_surf->width, dst_surf->height, Y0_TOP);
+ renderer_bind_destination(r, dst_surf);
/* texture */
cso_set_sampler_textures(r->cso, 1, &src);
cso_set_vertex_shader_handle(r->cso, shader.vs);
cso_set_fragment_shader_handle(r->cso, shader.fs);
- /* drawing dest */
- memset(&fb, 0, sizeof(fb));
- fb.width = dst_surf->width;
- fb.height = dst_surf->height;
- fb.nr_cbufs = 1;
- fb.cbufs[0] = dst_surf;
- {
- int i;
- for (i = 1; i < PIPE_MAX_COLOR_BUFS; ++i)
- fb.cbufs[i] = 0;
- }
- cso_set_framebuffer(r->cso, &fb);
- setup_vs_constant_buffer(r, fb.width, fb.height);
setup_fs_constant_buffer(r);
/* draw quad */
}
-static void
-setup_vs_video_constants(struct xorg_renderer *r, struct exa_pixmap_priv *dst)
-{
- int width = dst->tex->width[0];
- int height = dst->tex->height[0];
- const int param_bytes = 8 * sizeof(float);
- float vs_consts[8] = {
- 2.f/width, 2.f/height, 1, 1,
- -1, -1, 0, 0
- };
-
- renderer_set_constants(r, PIPE_SHADER_VERTEX,
- vs_consts, param_bytes);
-}
-
static void
setup_fs_video_constants(struct xorg_renderer *r, boolean hdtv)
{
Bool hdtv;
int x, y, w, h;
struct exa_pixmap_priv *dst = exaGetPixmapDriverPrivate(pPixmap);
+ struct pipe_surface *dst_surf = xorg_gpu_surface(pPriv->r->pipe->screen, dst);
if (dst && !dst->tex) {
xorg_exa_set_shared_usage(pPixmap);
pbox = REGION_RECTS(dstRegion);
nbox = REGION_NUM_RECTS(dstRegion);
- renderer_bind_framebuffer(pPriv->r, dst);
- renderer_bind_viewport(pPriv->r, dst);
+ renderer_bind_destination(pPriv->r, dst_surf);
bind_blend_state(pPriv);
renderer_bind_rasterizer(pPriv->r);
bind_shaders(pPriv);
bind_samplers(pPriv);
- setup_vs_video_constants(pPriv->r, dst);
setup_fs_video_constants(pPriv->r, hdtv);
exaMoveInPixmap(pPixmap);