diff options
author | Michal Krol <michal@vmware.com> | 2009-09-17 12:44:24 +0200 |
---|---|---|
committer | Michal Krol <michal@vmware.com> | 2009-09-17 12:44:24 +0200 |
commit | 2a661c383fee65bc4413541e706925fa3e9b9cf5 (patch) | |
tree | dbea0c9d65d17b81720fe2f161604dfc91eb0546 /src/gallium/state_trackers/xorg | |
parent | 90daefd1c474a6e0502df5053b581987c12b8673 (diff) | |
parent | 21caa29fbd332a2ee05a58df91e1664fbbc4e61f (diff) |
Merge commit 'origin/master' into glsl-pp-rework-2
Conflicts:
src/gallium/winsys/gdi/SConscript
Diffstat (limited to 'src/gallium/state_trackers/xorg')
-rw-r--r-- | src/gallium/state_trackers/xorg/xorg_composite.c | 108 | ||||
-rw-r--r-- | src/gallium/state_trackers/xorg/xorg_exa.c | 80 | ||||
-rw-r--r-- | src/gallium/state_trackers/xorg/xorg_exa_tgsi.c | 20 |
3 files changed, 159 insertions, 49 deletions
diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index 15c955450d..66ca4cb590 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -12,9 +12,9 @@ struct xorg_composite_blend { int op:8; unsigned rgb_src_factor:5; /**< PIPE_BLENDFACTOR_x */ - unsigned rgb_dst_factor:5; /**< PIPE_BLENDFACTOR_x */ - unsigned alpha_src_factor:5; /**< PIPE_BLENDFACTOR_x */ + + unsigned rgb_dst_factor:5; /**< PIPE_BLENDFACTOR_x */ unsigned alpha_dst_factor:5; /**< PIPE_BLENDFACTOR_x */ }; @@ -653,17 +653,12 @@ boolean xorg_solid_bind_state(struct exa_context *exa, exa->solid_color[3] = 1.f; +#if 0 debug_printf("Color Pixel=(%d, %d, %d, %d), RGBA=(%f, %f, %f, %f)\n", (fg >> 24) & 0xff, (fg >> 16) & 0xff, (fg >> 8) & 0xff, (fg >> 0) & 0xff, exa->solid_color[0], exa->solid_color[1], exa->solid_color[2], exa->solid_color[3]); - -#if 0 - exa->solid_color[0] = 1.f; - exa->solid_color[1] = 0.f; - exa->solid_color[2] = 0.f; - exa->solid_color[3] = 1.f; #endif vs_traits = VS_SOLID_FILL; @@ -691,9 +686,6 @@ void xorg_solid(struct exa_context *exa, struct pipe_buffer *buf = 0; float vertices[4][2][4]; - x0 = 10; y0 = 10; - x1 = 300; y1 = 300; - /* 1st vertex */ setup_vertex0(vertices[0], x0, y0, exa->solid_color); @@ -844,11 +836,6 @@ static void renderer_copy_texture(struct exa_context *exa, assert(dst->width[0] != 0); assert(dst->height[0] != 0); -#if 0 - debug_printf("copy texture [%f, %f, %f, %f], [%f, %f, %f, %f]\n", - sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2); -#endif - #if 1 s0 = sx1 / src->width[0]; s1 = sx2 / src->width[0]; @@ -861,8 +848,16 @@ static void renderer_copy_texture(struct exa_context *exa, t1 = 1; #endif - assert(screen->is_format_supported(screen, dst_surf->format, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)); +#if 1 + debug_printf("copy texture src=[%f, %f, %f, %f], dst=[%f, %f, %f, %f], tex=[%f, %f, %f, %f]\n", + sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2, + s0, t0, s1, t1); +#endif + + assert(screen->is_format_supported(screen, dst_surf->format, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_RENDER_TARGET, + 0)); /* save state (restored below) */ cso_save_blend(exa->cso); @@ -926,6 +921,8 @@ static void renderer_copy_texture(struct exa_context *exa, fb.cbufs[i] = 0; } cso_set_framebuffer(exa->cso, &fb); + setup_vs_constant_buffer(exa, fb.width, fb.height); + setup_fs_constant_buffer(exa); /* draw quad */ buf = setup_vertex_data_tex(exa, @@ -955,6 +952,61 @@ static void renderer_copy_texture(struct exa_context *exa, pipe_surface_reference(&dst_surf, NULL); } + +static struct pipe_texture * +create_sampler_texture(struct exa_context *ctx, + struct pipe_texture *src) +{ + enum pipe_format format; + struct pipe_context *pipe = ctx->pipe; + struct pipe_screen *screen = pipe->screen; + struct pipe_texture *pt; + struct pipe_texture templ; + + pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); + + /* the coming in texture should already have that invariance */ + debug_assert(screen->is_format_supported(screen, src->format, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_SAMPLER, 0)); + + format = src->format; + + memset(&templ, 0, sizeof(templ)); + templ.target = PIPE_TEXTURE_2D; + templ.format = format; + templ.last_level = 0; + templ.width[0] = src->width[0]; + templ.height[0] = src->height[0]; + templ.depth[0] = 1; + pf_get_block(format, &templ.block); + templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER; + + pt = screen->texture_create(screen, &templ); + + debug_assert(!pt || pipe_is_referenced(&pt->reference)); + + if (!pt) + return NULL; + + { + /* copy source framebuffer surface into texture */ + struct pipe_surface *ps_read = screen->get_tex_surface( + screen, src, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ); + struct pipe_surface *ps_tex = screen->get_tex_surface( + screen, pt, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE ); + pipe->surface_copy(pipe, + ps_tex, /* dest */ + 0, 0, /* destx/y */ + ps_read, + 0, 0, src->width[0], src->height[0]); + pipe_surface_reference(&ps_read, NULL); + pipe_surface_reference(&ps_tex, NULL); + } + + return pt; +} + void xorg_copy_pixmap(struct exa_context *ctx, struct exa_pixmap_priv *dst_priv, int dx, int dy, struct exa_pixmap_priv *src_priv, int sx, int sy, @@ -966,6 +1018,8 @@ void xorg_copy_pixmap(struct exa_context *ctx, struct pipe_texture *dst = dst_priv->tex; struct pipe_texture *src = src_priv->tex; + xorg_exa_finish(ctx); + dst_loc[0] = dx; dst_loc[1] = dy; dst_loc[2] = width; @@ -1003,17 +1057,25 @@ void xorg_copy_pixmap(struct exa_context *ctx, if (src_loc[2] >= 0 && src_loc[3] >= 0 && dst_loc[2] >= 0 && dst_loc[3] >= 0) { + struct pipe_texture *temp_src = src; + + if (src == dst) + temp_src = create_sampler_texture(ctx, src); + renderer_copy_texture(ctx, - src, + temp_src, src_loc[0], - src_loc[1] + src_loc[3], - src_loc[0] + src_loc[2], src_loc[1], + src_loc[0] + src_loc[2], + src_loc[1] + src_loc[3], dst, dst_loc[0], - dst_loc[1] + dst_loc[3], + dst_loc[1], dst_loc[0] + dst_loc[2], - dst_loc[1]); + dst_loc[1] + dst_loc[3]); + + if (src == dst) + pipe_texture_reference(&temp_src, NULL); } } diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index 312dab1544..dea9f4c2bc 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -47,6 +47,8 @@ #include "util/u_rect.h" +#define DEBUG_SOLID 0 + /* * Helper functions */ @@ -72,6 +74,9 @@ exa_get_pipe_format(int depth, enum pipe_format *format, int *bbp) assert(*bbp == 16); break; case 8: + *format = PIPE_FORMAT_A8_UNORM; + assert(*bbp == 8); + break; case 4: case 1: *format = PIPE_FORMAT_A8R8G8B8_UNORM; /* bad bad bad */ @@ -253,7 +258,7 @@ ExaDone(PixmapPtr pPixmap) #if 1 xorg_exa_flush(exa, PIPE_FLUSH_RENDER_CACHE, NULL); #else - xorg_finish(exa); + xorg_exa_finish(exa); #endif xorg_exa_common_done(exa); } @@ -276,23 +281,35 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg) struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap); struct exa_context *exa = ms->exa; +#if 0 debug_printf("ExaPrepareSolid - test\n"); - if (pPixmap->drawable.depth < 15) - return FALSE; - +#endif if (!EXA_PM_IS_SOLID(&pPixmap->drawable, planeMask)) return FALSE; if (!priv || !priv->tex) return FALSE; + if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format, + priv->tex->target, + PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) + return FALSE; + if (alu != GXcopy) return FALSE; if (!exa->pipe) return FALSE; + +#if DEBUG_SOLID + fg = 0xffff0000; +#endif + +#if 1 debug_printf(" ExaPrepareSolid(0x%x)\n", fg); +#endif + return xorg_solid_bind_state(exa, priv, fg); } @@ -310,11 +327,42 @@ ExaSolid(PixmapPtr pPixmap, int x0, int y0, int x1, int y1) if (x0 == 0 && y0 == 0 && x1 == priv->tex->width[0] && y1 == priv->tex->height[0]) { - exa->ctx->clear(exa->ctx, PIPE_CLEAR_COLOR | PIPE_CLEAR_DEPTHSTENCIL, + exa->ctx->clear(exa->pipe, PIPE_CLEAR_COLOR, exa->solid_color, 1., 0); } else #endif - xorg_solid(exa, priv, x0, y0, x1, y1) ; + +#if DEBUG_SOLID + exa->solid_color[0] = 0.f; + exa->solid_color[1] = 1.f; + exa->solid_color[2] = 0.f; + exa->solid_color[3] = 1.f; + xorg_solid(exa, priv, 0, 0, 1024, 768); + exa->solid_color[0] = 1.f; + exa->solid_color[1] = 0.f; + exa->solid_color[2] = 0.f; + exa->solid_color[3] = 1.f; + xorg_solid(exa, priv, 0, 0, 300, 300); + xorg_solid(exa, priv, 300, 300, 350, 350); + xorg_solid(exa, priv, 350, 350, 500, 500); + + xorg_solid(exa, priv, + priv->tex->width[0] - 10, + priv->tex->height[0] - 10, + priv->tex->width[0], + priv->tex->height[0]); + + exa->solid_color[0] = 0.f; + exa->solid_color[1] = 0.f; + exa->solid_color[2] = 1.f; + exa->solid_color[3] = 1.f; + + exa->has_solid_color = FALSE; + ExaPrepareCopy(pPixmap, pPixmap, 0, 0, GXcopy, 0xffffffff); + ExaCopy(pPixmap, 0, 0, 50, 50, 500, 500); +#else + xorg_solid(exa, priv, x0, y0, x1, y1) ; +#endif } static Bool @@ -332,15 +380,20 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, if (alu != GXcopy) return FALSE; - if (pSrcPixmap->drawable.depth < 15 || pDstPixmap->drawable.depth < 15) - return FALSE; - if (!EXA_PM_IS_SOLID(&pSrcPixmap->drawable, planeMask)) return FALSE; if (!priv || !src_priv) return FALSE; + if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format, + priv->tex->target, + PIPE_TEXTURE_USAGE_RENDER_TARGET, 0) || + !exa->scrn->is_format_supported(exa->scrn, src_priv->tex->format, + src_priv->tex->target, + PIPE_TEXTURE_USAGE_SAMPLER, 0)) + return FALSE; + if (!priv->tex || !src_priv->tex) return FALSE; @@ -433,14 +486,11 @@ static void ExaDestroyPixmap(ScreenPtr pScreen, void *dPriv) { struct exa_pixmap_priv *priv = (struct exa_pixmap_priv *)dPriv; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - modesettingPtr ms = modesettingPTR(pScrn); if (!priv) return; - if (priv->tex) - ms->screen->texture_destroy(priv->tex); + pipe_texture_reference(&priv->tex, NULL); xfree(priv); } @@ -583,8 +633,8 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, struct pipe_surface *dst_surf; struct pipe_surface *src_surf; - dst_surf = exa->scrn->get_tex_surface(exa->scrn, texture, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_WRITE); + dst_surf = exa->scrn->get_tex_surface( + exa->scrn, texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); src_surf = exa_gpu_surface(exa, priv); exa->pipe->surface_copy(exa->pipe, dst_surf, 0, 0, src_surf, 0, 0, min(width, texture->width[0]), diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c index b30cbff479..2daa5b5628 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c +++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c @@ -52,8 +52,7 @@ struct xorg_shaders { static const char over_op[] = "SUB TEMP[3], CONST[0].wwww, TEMP[1].wwww\n" - "MUL TEMP[3], TEMP[0], TEMP[3]\n" - "ADD TEMP[0], TEMP[3], TEMP[0]\n"; + "MAD TEMP[3], TEMP[0], TEMP[3], TEMP[0]\n"; static INLINE void @@ -79,8 +78,7 @@ vs_normalize_coords(struct ureg_program *ureg, struct ureg_src coords, { struct ureg_dst tmp = ureg_DECL_temporary(ureg); struct ureg_src ret; - ureg_MUL(ureg, tmp, coords, const0); - ureg_ADD(ureg, tmp, ureg_src(tmp), const1); + ureg_MAD(ureg, tmp, coords, const0, const1); ret = ureg_src(tmp); ureg_release_temporary(ureg, tmp); return ret; @@ -261,7 +259,7 @@ create_vs(struct pipe_context *pipe, if (is_composite) { src = ureg_DECL_vs_input(ureg, input_slot++); - dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_GENERIC, 1); + dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_GENERIC, 0); ureg_MOV(ureg, dst, src); } @@ -312,7 +310,7 @@ create_fs(struct pipe_context *pipe, if (is_composite) { src_sampler = ureg_DECL_sampler(ureg, 0); src_input = ureg_DECL_fs_input(ureg, - TGSI_SEMANTIC_POSITION, + TGSI_SEMANTIC_GENERIC, 0, TGSI_INTERPOLATE_PERSPECTIVE); } else { @@ -367,11 +365,11 @@ create_fs(struct pipe_context *pipe, else src = out; - coords = ureg_DECL_constant(ureg); - const0124 = ureg_DECL_constant(ureg); - matrow0 = ureg_DECL_constant(ureg); - matrow1 = ureg_DECL_constant(ureg); - matrow2 = ureg_DECL_constant(ureg); + coords = ureg_DECL_constant(ureg, 0); + const0124 = ureg_DECL_constant(ureg, 1); + matrow0 = ureg_DECL_constant(ureg, 2); + matrow1 = ureg_DECL_constant(ureg, 3); + matrow2 = ureg_DECL_constant(ureg, 4); if (is_lingrad) { linear_gradient(ureg, src, |