summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2009-11-25 18:41:11 +0000
committerKeith Whitwell <[email protected]>2009-11-26 11:23:36 +0000
commit7fbdbad5c02e3d5bfbf0e641e2aec224e39fa974 (patch)
treed074d29b2eb11c60e46523dc2d02d5a253bc2f1b
parent808f0376607b0e2d31dfebc888fd8f1e737fed09 (diff)
st/xorg: consolidate some dest surface state setting
-rw-r--r--src/gallium/state_trackers/xorg/xorg_composite.c26
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa.c2
-rw-r--r--src/gallium/state_trackers/xorg/xorg_renderer.c102
-rw-r--r--src/gallium/state_trackers/xorg/xorg_renderer.h5
-rw-r--r--src/gallium/state_trackers/xorg/xorg_xv.c20
5 files changed, 50 insertions, 105 deletions
diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c
index f16816b2a77..99e357328d1 100644
--- a/src/gallium/state_trackers/xorg/xorg_composite.c
+++ b/src/gallium/state_trackers/xorg/xorg_composite.c
@@ -421,18 +421,6 @@ bind_samplers(struct exa_context *exa, int op,
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
@@ -449,10 +437,6 @@ setup_fs_constant_buffer(struct exa_context *exa)
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);
}
@@ -503,8 +487,10 @@ boolean xorg_composite_bind_state(struct exa_context *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);
@@ -556,6 +542,7 @@ boolean xorg_solid_bind_state(struct exa_context *exa,
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;
@@ -573,8 +560,7 @@ boolean xorg_solid_bind_state(struct exa_context *exa,
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);
diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c
index aa04586455f..308eb2715e6 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa.c
+++ b/src/gallium/state_trackers/xorg/xorg_exa.c
@@ -441,7 +441,7 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir,
exa->copy.src = src_priv;
exa->copy.dst = priv;
- if (exa->pipe->surface_copy) {
+ if (0 && exa->pipe->surface_copy) {
exa->copy.src_surface =
exa->scrn->get_tex_surface( exa->scrn,
exa->copy.src->tex,
diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c
index 723605312c5..bf38fa7de24 100644
--- a/src/gallium/state_trackers/xorg/xorg_renderer.c
+++ b/src/gallium/state_trackers/xorg/xorg_renderer.c
@@ -79,6 +79,7 @@ renderer_draw(struct xorg_renderer *r)
r->attrs_per_vertex); /* attribs/vert */
pipe_buffer_reference(&buf, NULL);
+ pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
}
}
@@ -322,15 +323,28 @@ setup_vertex_data_yuv(struct xorg_renderer *r,
-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;
@@ -338,11 +352,26 @@ set_viewport(struct xorg_renderer *r, int width, int height,
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);
@@ -379,41 +408,9 @@ void renderer_destroy(struct xorg_renderer *r)
}
}
-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)
{
@@ -447,19 +444,6 @@ void renderer_set_constants(struct xorg_renderer *r,
}
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)
{
const int param_bytes = 4 * sizeof(float);
@@ -580,7 +564,6 @@ static void renderer_copy_texture(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;
@@ -650,7 +633,7 @@ static void renderer_copy_texture(struct xorg_renderer *r,
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);
@@ -664,19 +647,6 @@ static void renderer_copy_texture(struct xorg_renderer *r,
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 */
diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.h b/src/gallium/state_trackers/xorg/xorg_renderer.h
index 2f0b865dbdc..51e0272b46f 100644
--- a/src/gallium/state_trackers/xorg/xorg_renderer.h
+++ b/src/gallium/state_trackers/xorg/xorg_renderer.h
@@ -21,6 +21,8 @@ struct xorg_renderer {
struct cso_context *cso;
struct xorg_shaders *shaders;
+ int fb_width;
+ int fb_height;
struct pipe_constant_buffer vs_const_buffer;
struct pipe_constant_buffer fs_const_buffer;
@@ -35,6 +37,9 @@ struct xorg_renderer {
struct xorg_renderer *renderer_create(struct pipe_context *pipe);
void renderer_destroy(struct xorg_renderer *renderer);
+void renderer_bind_destination(struct xorg_renderer *r,
+ struct pipe_surface *surface );
+
void renderer_bind_framebuffer(struct xorg_renderer *r,
struct exa_pixmap_priv *priv);
void renderer_bind_viewport(struct xorg_renderer *r,
diff --git a/src/gallium/state_trackers/xorg/xorg_xv.c b/src/gallium/state_trackers/xorg/xorg_xv.c
index a8f74ceea29..7a43da89887 100644
--- a/src/gallium/state_trackers/xorg/xorg_xv.c
+++ b/src/gallium/state_trackers/xorg/xorg_xv.c
@@ -318,21 +318,6 @@ copy_packed_data(ScrnInfoPtr pScrn,
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)
{
const int param_bytes = 12 * sizeof(float);
@@ -445,6 +430,7 @@ display_video(ScrnInfoPtr pScrn, struct xorg_xv_port_priv *pPriv, int id,
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);
@@ -465,13 +451,11 @@ display_video(ScrnInfoPtr pScrn, struct xorg_xv_port_priv *pPriv, int id,
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);