From e34ea368d9fccaf84b7e4aec4ba3f633eeaefec6 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Tue, 8 Sep 2009 18:08:24 +0200 Subject: st/xorg: Add support for EXA_MIXED_PIXMAPS and EXA_SUPPORTS_PREPARE_AUX. Also make sure not to leak malloced memory when switching pixmaps to texture based. --- src/gallium/state_trackers/xorg/xorg_dri2.c | 1 + src/gallium/state_trackers/xorg/xorg_exa.c | 9 +++++++++ 2 files changed, 10 insertions(+) (limited to 'src/gallium/state_trackers/xorg') diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c index 6431a0fe25..8a362596c7 100644 --- a/src/gallium/state_trackers/xorg/xorg_dri2.c +++ b/src/gallium/state_trackers/xorg/xorg_dri2.c @@ -118,6 +118,7 @@ driDoCreateBuffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int format) } if (!tex) { + exaMoveInPixmap(private->pPixmap); xorg_exa_set_shared_usage(private->pPixmap); pScreen->ModifyPixmapHeader(private->pPixmap, 0, 0, 0, 0, 0, NULL); tex = xorg_exa_get_texture(private->pPixmap); diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index a17a71f23a..1a183de6db 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -563,6 +563,9 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, pPixmap->devKind, 0, 0); exa->scrn->transfer_unmap(exa->scrn, transfer); exa->scrn->tex_transfer_destroy(transfer); + + xfree(pPixmap->devPrivate.ptr); + pPixmap->devPrivate.ptr = NULL; } } #ifdef DRM_MODE_FEATURE_DIRTYFB @@ -645,6 +648,12 @@ xorg_exa_init(ScrnInfoPtr pScrn) pExa->pixmapOffsetAlign = 0; pExa->pixmapPitchAlign = 1; pExa->flags = EXA_OFFSCREEN_PIXMAPS | EXA_HANDLES_PIXMAPS; +#ifdef EXA_SUPPORTS_PREPARE_AUX + pExa->flags |= EXA_SUPPORTS_PREPARE_AUX; +#endif +#ifdef EXA_MIXED_PIXMAPS + pExa->flags |= EXA_MIXED_PIXMAPS; +#endif pExa->maxX = 8191; /* FIXME */ pExa->maxY = 8191; /* FIXME */ -- cgit v1.2.3 From 3167c2e8a0a248c290ae8bfff23c88db8f39cd11 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 9 Sep 2009 05:34:56 -0400 Subject: st/xorg: start adding support for surface fills --- src/gallium/state_trackers/xorg/xorg_composite.c | 41 ++++++++++++++++-------- src/gallium/state_trackers/xorg/xorg_composite.h | 7 ++++ src/gallium/state_trackers/xorg/xorg_exa.c | 38 ++++++++++++++++------ src/gallium/state_trackers/xorg/xorg_exa.h | 2 +- src/gallium/state_trackers/xorg/xorg_exa_tgsi.c | 4 +-- 5 files changed, 66 insertions(+), 26 deletions(-) (limited to 'src/gallium/state_trackers/xorg') diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index c708ac3170..1f8fbd1610 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -41,8 +41,8 @@ static const struct xorg_composite_blend xorg_blends[] = { }; static INLINE void -pixel_to_float4(PictFormatPtr format, - CARD32 pixel, float *color) +render_pixel_to_float4(PictFormatPtr format, + CARD32 pixel, float *color) { CARD32 r, g, b, a; @@ -291,16 +291,15 @@ boolean xorg_composite_accelerated(int op, } static void -bind_framebuffer_state(struct exa_context *exa, PicturePtr pDstPicture, - struct exa_pixmap_priv *pDst) +bind_framebuffer_state(struct exa_context *exa, struct exa_pixmap_priv *pDst) { unsigned i; struct pipe_framebuffer_state state; struct pipe_surface *surface = exa_gpu_surface(exa, pDst); memset(&state, 0, sizeof(struct pipe_framebuffer_state)); - state.width = pDstPicture->pDrawable->width; - state.height = pDstPicture->pDrawable->height; + state.width = pDst->tex->width[0]; + state.height = pDst->tex->height[0]; state.nr_cbufs = 1; state.cbufs[0] = surface; @@ -338,10 +337,10 @@ set_viewport(struct exa_context *exa, int width, int height, } static void -bind_viewport_state(struct exa_context *exa, PicturePtr pDstPicture) +bind_viewport_state(struct exa_context *exa, struct exa_pixmap_priv *pDst) { - int width = pDstPicture->pDrawable->width; - int height = pDstPicture->pDrawable->height; + int width = pDst->tex->width[0]; + int height = pDst->tex->height[0]; set_viewport(exa, width, height, Y0_TOP); } @@ -395,9 +394,9 @@ bind_shaders(struct exa_context *exa, int op, if (pSrcPicture->pSourcePict->type == SourcePictTypeSolidFill) { fs_traits |= FS_SOLID_FILL; vs_traits |= VS_SOLID_FILL; - pixel_to_float4(pSrcPicture->pFormat, - pSrcPicture->pSourcePict->solidFill.color, - exa->solid_color); + render_pixel_to_float4(pSrcPicture->pFormat, + pSrcPicture->pSourcePict->solidFill.color, + exa->solid_color); } else { debug_assert("!gradients not supported"); } @@ -530,8 +529,8 @@ boolean xorg_composite_bind_state(struct exa_context *exa, struct exa_pixmap_priv *pMask, struct exa_pixmap_priv *pDst) { - bind_framebuffer_state(exa, pDstPicture, pDst); - bind_viewport_state(exa, pDstPicture); + bind_framebuffer_state(exa, pDst); + bind_viewport_state(exa, pDst); bind_blend_state(exa, op, pSrcPicture, pMaskPicture); bind_rasterizer_state(exa); bind_shaders(exa, op, pSrcPicture, pMaskPicture); @@ -582,3 +581,17 @@ void xorg_composite(struct exa_context *exa, } } +boolean xorg_solid_bind_state(struct exa_context *exa, + struct exa_pixmap_priv *pixmap, + Pixel fg) +{ + + return TRUE; +} + +void xorg_solid(struct exa_context *exa, + struct exa_pixmap_priv *pixmap, + int x0, int y0, int x1, int y1) +{ +} + diff --git a/src/gallium/state_trackers/xorg/xorg_composite.h b/src/gallium/state_trackers/xorg/xorg_composite.h index 17dfcb199e..236addf1ce 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.h +++ b/src/gallium/state_trackers/xorg/xorg_composite.h @@ -22,4 +22,11 @@ void xorg_composite(struct exa_context *exa, int srcX, int srcY, int maskX, int maskY, int dstX, int dstY, int width, int height); +boolean xorg_solid_bind_state(struct exa_context *exa, + struct exa_pixmap_priv *pixmap, + Pixel fg); +void xorg_solid(struct exa_context *exa, + struct exa_pixmap_priv *pixmap, + int x0, int y0, int x1, int y1); + #endif diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index 1a183de6db..cf4478a03d 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -82,6 +82,22 @@ exa_get_pipe_format(int depth, enum pipe_format *format, int *bbp) } } + +static INLINE void +pixel_to_float4(Pixel pixel, float *color) +{ + CARD32 r, g, b, a; + + a = (pixel >> 24) & 0xff; + r = (pixel >> 16) & 0xff; + g = (pixel >> 8) & 0xff; + b = (pixel >> 0) & 0xff; + color[0] = ((float)r) / 255.; + color[1] = ((float)g) / 255.; + color[2] = ((float)b) / 255.; + color[3] = ((float)a) / 255.; +} + /* * Static exported EXA functions */ @@ -250,6 +266,7 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg) struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap); struct exa_context *exa = ms->exa; + debug_printf("ExaPrepareSolid\n"); if (pPixmap->drawable.depth < 15) return FALSE; @@ -262,12 +279,10 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg) if (alu != GXcopy) return FALSE; - if (!exa->ctx || !exa->ctx->surface_fill) + if (!exa->ctx) return FALSE; - priv->color = fg; - - return TRUE; + return xorg_solid_bind_state(exa, priv, fg); } static void @@ -277,12 +292,9 @@ ExaSolid(PixmapPtr pPixmap, int x0, int y0, int x1, int y1) modesettingPtr ms = modesettingPTR(pScrn); struct exa_context *exa = ms->exa; struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap); - struct pipe_surface *surf = exa_gpu_surface(exa, priv); - exa->ctx->surface_fill(exa->ctx, surf, x0, y0, x1 - x0, y1 - y0, - priv->color); - - exa->scrn->tex_surface_destroy(surf); + debug_printf("\tExaSolid\n"); + xorg_solid(exa, priv, x0, y0, x1, y1) ; } static Bool @@ -295,6 +307,8 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDstPixmap); struct exa_pixmap_priv *src_priv = exaGetPixmapDriverPrivate(pSrcPixmap); + debug_printf("ExaPrepareCopy\n"); + if (alu != GXcopy) return FALSE; @@ -328,6 +342,8 @@ ExaCopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY, struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDstPixmap); struct pipe_surface *surf = exa_gpu_surface(exa, priv); + debug_printf("\tExaCopy\n"); + exa->ctx->surface_copy(exa->ctx, surf, dstX, dstY, priv->src_surf, srcX, srcY, width, height); exa->scrn->tex_surface_destroy(surf); @@ -342,6 +358,8 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture, modesettingPtr ms = modesettingPTR(pScrn); struct exa_context *exa = ms->exa; + debug_printf("ExaPrepareComposite\n"); + return xorg_composite_bind_state(exa, op, pSrcPicture, pMaskPicture, pDstPicture, exaGetPixmapDriverPrivate(pSrc), @@ -358,6 +376,8 @@ ExaComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, struct exa_context *exa = ms->exa; struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDst); + debug_printf("\tExaComposite\n"); + xorg_composite(exa, priv, srcX, srcY, maskX, maskY, dstX, dstY, width, height); } diff --git a/src/gallium/state_trackers/xorg/xorg_exa.h b/src/gallium/state_trackers/xorg/xorg_exa.h index 5b515be139..a62c57bf4a 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.h +++ b/src/gallium/state_trackers/xorg/xorg_exa.h @@ -36,7 +36,7 @@ struct exa_pixmap_priv struct pipe_texture *tex; struct pipe_texture *depth_stencil_tex; - unsigned int color; + float solid_color[4]; struct pipe_surface *src_surf; /* for copies */ struct pipe_transfer *map_transfer; diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c index cfee10c3b3..14d5605f39 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c +++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c @@ -318,8 +318,8 @@ create_fs(struct pipe_context *pipe, TGSI_SEMANTIC_POSITION, 0, TGSI_INTERPOLATE_PERSPECTIVE); - } - if (is_fill) { + } else { + debug_assert(is_fill); if (is_solid) src_input = ureg_DECL_fs_input(ureg, TGSI_SEMANTIC_COLOR, -- cgit v1.2.3 From 6be1a98ab9d64584c3852b97e2f1d63697f7bf76 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 9 Sep 2009 11:33:33 -0400 Subject: st/xorg: implement exasolids with full pipelining plus fix some small issues with the shaders --- src/gallium/state_trackers/xorg/xorg_composite.c | 120 +++++++++++++++++++++-- src/gallium/state_trackers/xorg/xorg_exa.c | 41 ++++---- src/gallium/state_trackers/xorg/xorg_exa.h | 2 +- src/gallium/state_trackers/xorg/xorg_exa_tgsi.c | 4 +- 4 files changed, 135 insertions(+), 32 deletions(-) (limited to 'src/gallium/state_trackers/xorg') diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index 1f8fbd1610..778a8a183e 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -40,6 +40,22 @@ static const struct xorg_composite_blend xorg_blends[] = { PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA }, }; + +static INLINE void +pixel_to_float4(Pixel pixel, float *color) +{ + CARD32 r, g, b, a; + + a = (pixel >> 24) & 0xff; + r = (pixel >> 16) & 0xff; + g = (pixel >> 8) & 0xff; + b = (pixel >> 0) & 0xff; + color[0] = ((float)r) / 255.; + color[1] = ((float)g) / 255.; + color[2] = ((float)b) / 255.; + color[3] = ((float)a) / 255.; +} + static INLINE void render_pixel_to_float4(PictFormatPtr format, CARD32 pixel, float *color) @@ -290,6 +306,15 @@ boolean xorg_composite_accelerated(int op, return FALSE; } +static void +bind_clip_state(struct exa_context *exa) +{ + struct pipe_depth_stencil_alpha_state dsa; + + memset(&dsa, 0, sizeof(struct pipe_depth_stencil_alpha_state)); + cso_set_depth_stencil_alpha(exa->cso, &dsa); +} + static void bind_framebuffer_state(struct exa_context *exa, struct exa_pixmap_priv *pDst) { @@ -342,6 +367,8 @@ bind_viewport_state(struct exa_context *exa, struct exa_pixmap_priv *pDst) int width = pDst->tex->width[0]; int height = pDst->tex->height[0]; + debug_printf("Bind viewport (%d, %d)\n", width, height); + set_viewport(exa, width, height, Y0_TOP); } @@ -349,7 +376,8 @@ static void bind_blend_state(struct exa_context *exa, int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture) { - boolean component_alpha = pSrcPicture->componentAlpha; + boolean component_alpha = (pSrcPicture) ? + pSrcPicture->componentAlpha : FALSE; struct xorg_composite_blend blend_opt; struct pipe_blend_state blend; @@ -389,6 +417,8 @@ bind_shaders(struct exa_context *exa, int op, unsigned vs_traits = 0, fs_traits = 0; struct xorg_shader shader; + exa->has_solid_color = FALSE; + if (pSrcPicture) { if (pSrcPicture->pSourcePict) { if (pSrcPicture->pSourcePict->type == SourcePictTypeSolidFill) { @@ -397,6 +427,7 @@ bind_shaders(struct exa_context *exa, int op, render_pixel_to_float4(pSrcPicture->pFormat, pSrcPicture->pSourcePict->solidFill.color, exa->solid_color); + exa->has_solid_color = TRUE; } else { debug_assert("!gradients not supported"); } @@ -511,10 +542,10 @@ setup_fs_constant_buffer(struct exa_context *exa) } static void -setup_constant_buffers(struct exa_context *exa, PicturePtr pDstPicture) +setup_constant_buffers(struct exa_context *exa, struct exa_pixmap_priv *pDst) { - int width = pDstPicture->pDrawable->width; - int height = pDstPicture->pDrawable->height; + int width = pDst->tex->width[0]; + int height = pDst->tex->height[0]; setup_vs_constant_buffer(exa, width, height); setup_fs_constant_buffer(exa); @@ -536,8 +567,8 @@ boolean xorg_composite_bind_state(struct exa_context *exa, bind_shaders(exa, op, pSrcPicture, pMaskPicture); bind_samplers(exa, op, pSrcPicture, pMaskPicture, pDstPicture, pSrc, pMask, pDst); - - setup_constant_buffers(exa, pDstPicture); + bind_clip_state(exa); + setup_constant_buffers(exa, pDst); return FALSE; } @@ -572,10 +603,15 @@ void xorg_composite(struct exa_context *exa, } if (buf) { + int num_attribs = 1; /*pos*/ + num_attribs += exa->num_bound_samplers; + if (exa->has_solid_color) + ++num_attribs; + util_draw_vertex_buffer(pipe, buf, 0, PIPE_PRIM_TRIANGLE_FAN, 4, /* verts */ - 1 + exa->num_bound_samplers); /* attribs/vert */ + num_attribs); /* attribs/vert */ pipe_buffer_reference(&buf, NULL); } @@ -585,7 +621,41 @@ boolean xorg_solid_bind_state(struct exa_context *exa, struct exa_pixmap_priv *pixmap, Pixel fg) { - + unsigned vs_traits, fs_traits; + struct xorg_shader shader; + + pixel_to_float4(fg, exa->solid_color); + exa->has_solid_color = TRUE; + + exa->solid_color[3] = 1.f; + + 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; + fs_traits = FS_SOLID_FILL; + + bind_framebuffer_state(exa, pixmap); + bind_viewport_state(exa, pixmap); + bind_rasterizer_state(exa); + bind_blend_state(exa, PictOpSrc, NULL, NULL); + setup_constant_buffers(exa, pixmap); + bind_clip_state(exa); + + shader = xorg_shaders_get(exa->shaders, vs_traits, fs_traits); + cso_set_vertex_shader_handle(exa->cso, shader.vs); + cso_set_fragment_shader_handle(exa->cso, shader.fs); + return TRUE; } @@ -593,5 +663,39 @@ void xorg_solid(struct exa_context *exa, struct exa_pixmap_priv *pixmap, int x0, int y0, int x1, int y1) { + struct pipe_context *pipe = exa->ctx; + 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); + /* 2nd vertex */ + setup_vertex0(vertices[1], x1, y0, + exa->solid_color); + /* 3rd vertex */ + setup_vertex0(vertices[2], x1, y1, + exa->solid_color); + /* 4th vertex */ + setup_vertex0(vertices[3], x0, y1, + exa->solid_color); + + buf = pipe_user_buffer_create(exa->ctx->screen, + vertices, + sizeof(vertices)); + + + if (buf) { + debug_printf("Drawing buf is %p\n", buf); + util_draw_vertex_buffer(pipe, buf, 0, + PIPE_PRIM_TRIANGLE_FAN, + 4, /* verts */ + 2); /* attribs/vert */ + + pipe_buffer_reference(&buf, NULL); + } } diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index cf4478a03d..1eed3d86f7 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -82,22 +82,6 @@ exa_get_pipe_format(int depth, enum pipe_format *format, int *bbp) } } - -static INLINE void -pixel_to_float4(Pixel pixel, float *color) -{ - CARD32 r, g, b, a; - - a = (pixel >> 24) & 0xff; - r = (pixel >> 16) & 0xff; - g = (pixel >> 8) & 0xff; - b = (pixel >> 0) & 0xff; - color[0] = ((float)r) / 255.; - color[1] = ((float)g) / 255.; - color[2] = ((float)b) / 255.; - color[3] = ((float)a) / 255.; -} - /* * Static exported EXA functions */ @@ -243,10 +227,15 @@ ExaDone(PixmapPtr pPixmap) modesettingPtr ms = modesettingPTR(pScrn); struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap); struct exa_context *exa = ms->exa; + struct pipe_fence_handle *fence = NULL; if (!priv) return; + exa->ctx->flush(exa->ctx, PIPE_FLUSH_RENDER_CACHE, &fence); + exa->ctx->screen->fence_finish(exa->ctx->screen, fence, 0); + exa->ctx->screen->fence_reference(exa->ctx->screen, &fence, NULL); + if (priv->src_surf) exa->scrn->tex_surface_destroy(priv->src_surf); priv->src_surf = NULL; @@ -266,7 +255,7 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg) struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap); struct exa_context *exa = ms->exa; - debug_printf("ExaPrepareSolid\n"); + debug_printf("ExaPrepareSolid - test\n"); if (pPixmap->drawable.depth < 15) return FALSE; @@ -282,6 +271,7 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg) if (!exa->ctx) return FALSE; + debug_printf(" ExaPrepareSolid(0x%x)\n", fg); return xorg_solid_bind_state(exa, priv, fg); } @@ -293,8 +283,17 @@ ExaSolid(PixmapPtr pPixmap, int x0, int y0, int x1, int y1) struct exa_context *exa = ms->exa; struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap); - debug_printf("\tExaSolid\n"); - xorg_solid(exa, priv, x0, y0, x1, y1) ; + debug_printf("\tExaSolid(%d, %d, %d, %d)\n", x0, y0, x1, y1); + +#if 0 + 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->solid_color, 1., 0); + } else +#endif + xorg_solid(exa, priv, x0, y0, x1, y1) ; } static Bool @@ -358,7 +357,7 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture, modesettingPtr ms = modesettingPTR(pScrn); struct exa_context *exa = ms->exa; - debug_printf("ExaPrepareComposite\n"); + debug_printf("ExaPrepareComposite\n"); return xorg_composite_bind_state(exa, op, pSrcPicture, pMaskPicture, pDstPicture, @@ -376,7 +375,7 @@ ExaComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, struct exa_context *exa = ms->exa; struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDst); - debug_printf("\tExaComposite\n"); + debug_printf("\tExaComposite\n"); xorg_composite(exa, priv, srcX, srcY, maskX, maskY, dstX, dstY, width, height); diff --git a/src/gallium/state_trackers/xorg/xorg_exa.h b/src/gallium/state_trackers/xorg/xorg_exa.h index a62c57bf4a..64b6de7048 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.h +++ b/src/gallium/state_trackers/xorg/xorg_exa.h @@ -26,6 +26,7 @@ struct exa_context int num_bound_samplers; float solid_color[4]; + boolean has_solid_color; }; @@ -36,7 +37,6 @@ struct exa_pixmap_priv struct pipe_texture *tex; struct pipe_texture *depth_stencil_tex; - float solid_color[4]; struct pipe_surface *src_surf; /* for copies */ struct pipe_transfer *map_transfer; diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c index 14d5605f39..2d2c2e884b 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c +++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c @@ -268,8 +268,8 @@ create_vs(struct pipe_context *pipe, } if (is_fill) { src = ureg_DECL_vs_input(ureg, - TGSI_SEMANTIC_COLOR, 1); - dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_COLOR, 1); + TGSI_SEMANTIC_COLOR, 0); + dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_COLOR, 0); ureg_MOV(ureg, dst, src); } -- cgit v1.2.3 From 16886c8be34fd17ed34c83ed2e83af2c825c989d Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 9 Sep 2009 11:35:34 -0400 Subject: st/xorg: disable solid fills until copies are accelerated as well --- src/gallium/state_trackers/xorg/xorg_composite.c | 2 +- src/gallium/state_trackers/xorg/xorg_exa.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gallium/state_trackers/xorg') diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index 778a8a183e..dff51f220d 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -656,7 +656,7 @@ boolean xorg_solid_bind_state(struct exa_context *exa, cso_set_vertex_shader_handle(exa->cso, shader.vs); cso_set_fragment_shader_handle(exa->cso, shader.fs); - return TRUE; + return FALSE; } void xorg_solid(struct exa_context *exa, diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index 1eed3d86f7..458ddb66bb 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -233,8 +233,10 @@ ExaDone(PixmapPtr pPixmap) return; exa->ctx->flush(exa->ctx, PIPE_FLUSH_RENDER_CACHE, &fence); +#if 0 exa->ctx->screen->fence_finish(exa->ctx->screen, fence, 0); exa->ctx->screen->fence_reference(exa->ctx->screen, &fence, NULL); +#endif if (priv->src_surf) exa->scrn->tex_surface_destroy(priv->src_surf); -- cgit v1.2.3 From 974dec2e7b86474af75708dd2cc8236416f25662 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 9 Sep 2009 15:43:09 -0400 Subject: st/xorg: abstract flushing and syncing for the exa code --- src/gallium/state_trackers/xorg/xorg_exa.c | 25 ++++++++++++++++++++----- src/gallium/state_trackers/xorg/xorg_exa.h | 3 +++ 2 files changed, 23 insertions(+), 5 deletions(-) (limited to 'src/gallium/state_trackers/xorg') diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index 458ddb66bb..8d95551363 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -227,15 +227,14 @@ ExaDone(PixmapPtr pPixmap) modesettingPtr ms = modesettingPTR(pScrn); struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap); struct exa_context *exa = ms->exa; - struct pipe_fence_handle *fence = NULL; if (!priv) return; - exa->ctx->flush(exa->ctx, PIPE_FLUSH_RENDER_CACHE, &fence); -#if 0 - exa->ctx->screen->fence_finish(exa->ctx->screen, fence, 0); - exa->ctx->screen->fence_reference(exa->ctx->screen, &fence, NULL); +#if 1 + xorg_exa_flush(exa, PIPE_FLUSH_RENDER_CACHE, NULL); +#else + xorg_finish(exa); #endif if (priv->src_surf) @@ -728,3 +727,19 @@ exa_gpu_surface(struct exa_context *exa, struct exa_pixmap_priv *priv) } +void xorg_exa_flush(struct exa_context *exa, uint pipeFlushFlags, + struct pipe_fence_handle **fence) +{ + exa->ctx->flush(exa->ctx, pipeFlushFlags, fence); +} + +void xorg_exa_finish(struct exa_context *exa) +{ + struct pipe_fence_handle *fence = NULL; + + xorg_exa_flush(exa, PIPE_FLUSH_RENDER_CACHE, &fence); + + exa->ctx->screen->fence_finish(exa->ctx->screen, fence, 0); + exa->ctx->screen->fence_reference(exa->ctx->screen, &fence, NULL); +} + diff --git a/src/gallium/state_trackers/xorg/xorg_exa.h b/src/gallium/state_trackers/xorg/xorg_exa.h index 64b6de7048..8157c71172 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.h +++ b/src/gallium/state_trackers/xorg/xorg_exa.h @@ -46,5 +46,8 @@ struct exa_pixmap_priv struct pipe_surface * exa_gpu_surface(struct exa_context *exa, struct exa_pixmap_priv *priv); +void xorg_exa_flush(struct exa_context *exa, uint pipeFlushFlags, + struct pipe_fence_handle **fence); +void xorg_exa_finish(struct exa_context *exa); #endif -- cgit v1.2.3 From 57d0934bc562c7a0de0c79fb0263ab3569eed002 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 9 Sep 2009 16:08:00 -0400 Subject: st/xorg: unite finalization and stub out pipelined copies --- src/gallium/state_trackers/xorg/xorg_composite.c | 8 ++++ src/gallium/state_trackers/xorg/xorg_composite.h | 5 +++ src/gallium/state_trackers/xorg/xorg_exa.c | 51 +++++++++++++++--------- src/gallium/state_trackers/xorg/xorg_exa.h | 6 ++- 4 files changed, 50 insertions(+), 20 deletions(-) (limited to 'src/gallium/state_trackers/xorg') diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index dff51f220d..b2da064b59 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -699,3 +699,11 @@ void xorg_solid(struct exa_context *exa, } } +void xorg_copy_pixmap(struct exa_context *ctx, + struct exa_pixmap_priv *dst, int dx, int dy, + struct exa_pixmap_priv *src, int sx, int sy, + int width, int height) +{ + +} + diff --git a/src/gallium/state_trackers/xorg/xorg_composite.h b/src/gallium/state_trackers/xorg/xorg_composite.h index 236addf1ce..e73f1c704a 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.h +++ b/src/gallium/state_trackers/xorg/xorg_composite.h @@ -29,4 +29,9 @@ void xorg_solid(struct exa_context *exa, struct exa_pixmap_priv *pixmap, int x0, int y0, int x1, int y1); +void xorg_copy_pixmap(struct exa_context *ctx, + struct exa_pixmap_priv *dst, int dx, int dy, + struct exa_pixmap_priv *src, int sx, int sy, + int width, int height); + #endif diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index 8d95551363..d3e7607cc3 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -82,6 +82,15 @@ exa_get_pipe_format(int depth, enum pipe_format *format, int *bbp) } } +static void +xorg_exa_common_done(struct exa_context *exa) +{ + exa->copy.src = NULL; + exa->copy.dst = NULL; + exa->has_solid_color = FALSE; + exa->num_bound_samplers = 0; +} + /* * Static exported EXA functions */ @@ -236,16 +245,17 @@ ExaDone(PixmapPtr pPixmap) #else xorg_finish(exa); #endif - - if (priv->src_surf) - exa->scrn->tex_surface_destroy(priv->src_surf); - priv->src_surf = NULL; + xorg_exa_common_done(exa); } static void ExaDoneComposite(PixmapPtr pPixmap) { + ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + struct exa_context *exa = ms->exa; + xorg_exa_common_done(exa); } static Bool @@ -324,10 +334,11 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, if (!priv->tex || !src_priv->tex) return FALSE; - if (!exa->ctx || !exa->ctx->surface_copy) + if (!exa->ctx) return FALSE; - priv->src_surf = exa_gpu_surface(exa, src_priv); + exa->copy.src = src_priv; + exa->copy.dst = priv; return TRUE; } @@ -336,17 +347,19 @@ static void ExaCopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY, int width, int height) { - ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; - modesettingPtr ms = modesettingPTR(pScrn); - struct exa_context *exa = ms->exa; - struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDstPixmap); - struct pipe_surface *surf = exa_gpu_surface(exa, priv); + ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + struct exa_context *exa = ms->exa; + struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDstPixmap); + + debug_printf("\tExaCopy(srcx=%d, srcy=%d, dstX=%d, dstY=%d, w=%d, h=%d)\n", + srcX, srcY, dstX, dstY, width, height); - debug_printf("\tExaCopy\n"); + debug_assert(priv == exa->copy.dst); - exa->ctx->surface_copy(exa->ctx, surf, dstX, dstY, priv->src_surf, - srcX, srcY, width, height); - exa->scrn->tex_surface_destroy(surf); + xorg_copy_pixmap(exa, exa->copy.dst, dstX, dstY, + exa->copy.src, srcX, srcY, + width, height); } static Bool @@ -557,16 +570,16 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, if (priv->tex) { 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); - priv->src_surf = exa_gpu_surface(exa, priv); - exa->ctx->surface_copy(exa->ctx, dst_surf, 0, 0, priv->src_surf, + src_surf = exa_gpu_surface(exa, priv); + exa->ctx->surface_copy(exa->ctx, dst_surf, 0, 0, src_surf, 0, 0, min(width, texture->width[0]), min(height, texture->height[0])); exa->scrn->tex_surface_destroy(dst_surf); - exa->scrn->tex_surface_destroy(priv->src_surf); - priv->src_surf = NULL; + exa->scrn->tex_surface_destroy(src_surf); } else if (pPixmap->devPrivate.ptr) { struct pipe_transfer *transfer; diff --git a/src/gallium/state_trackers/xorg/xorg_exa.h b/src/gallium/state_trackers/xorg/xorg_exa.h index 8157c71172..7229e87101 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.h +++ b/src/gallium/state_trackers/xorg/xorg_exa.h @@ -27,6 +27,11 @@ struct exa_context float solid_color[4]; boolean has_solid_color; + + struct { + struct exa_pixmap_priv *src; + struct exa_pixmap_priv *dst; + } copy; }; @@ -37,7 +42,6 @@ struct exa_pixmap_priv struct pipe_texture *tex; struct pipe_texture *depth_stencil_tex; - struct pipe_surface *src_surf; /* for copies */ struct pipe_transfer *map_transfer; unsigned map_count; -- cgit v1.2.3 From feb74e7753f56c0fa3ec943a45bbf48f2183e04c Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 9 Sep 2009 17:14:21 -0400 Subject: st/xorg: implement pipelines surface/texture copies --- src/gallium/state_trackers/xorg/xorg_composite.c | 324 ++++++++++++++++++++++- src/gallium/state_trackers/xorg/xorg_exa.c | 12 + 2 files changed, 329 insertions(+), 7 deletions(-) (limited to 'src/gallium/state_trackers/xorg') diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index b2da064b59..66e5e7284a 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -4,6 +4,7 @@ #include "cso_cache/cso_context.h" #include "util/u_draw_quad.h" +#include "util/u_math.h" #include "pipe/p_inlines.h" @@ -215,6 +216,33 @@ setup_vertex_data1(struct exa_context *ctx, sizeof(vertices)); } +static struct pipe_buffer * +setup_vertex_data_tex(struct exa_context *ctx, + float x0, float y0, float x1, float y1, + float s0, float t0, float s1, float t1, + float z) +{ + float vertices[4][2][4]; + + /* 1st vertex */ + setup_vertex1(vertices[0], x0, y0, + s0, t0); + /* 2nd vertex */ + setup_vertex1(vertices[1], x1, y0, + s1, t0); + /* 3rd vertex */ + setup_vertex1(vertices[2], x1, y1, + s1, t1); + /* 4th vertex */ + setup_vertex1(vertices[3], x0, y1, + s0, t1); + + return pipe_user_buffer_create(ctx->ctx->screen, + vertices, + sizeof(vertices)); +} + + static INLINE void setup_vertex2(float vertex[3][4], float x, float y, @@ -309,10 +337,6 @@ boolean xorg_composite_accelerated(int op, static void bind_clip_state(struct exa_context *exa) { - struct pipe_depth_stencil_alpha_state dsa; - - memset(&dsa, 0, sizeof(struct pipe_depth_stencil_alpha_state)); - cso_set_depth_stencil_alpha(exa->cso, &dsa); } static void @@ -699,11 +723,297 @@ void xorg_solid(struct exa_context *exa, } } + +static INLINE void shift_rectx(float coords[4], + const float *bounds, + const float shift) +{ + coords[0] += shift; + coords[2] -= shift; + if (bounds) { + coords[2] = MIN2(coords[2], bounds[2]); + /* bound x/y + width/height */ + if ((coords[0] + coords[2]) > (bounds[0] + bounds[2])) { + coords[2] = (bounds[0] + bounds[2]) - coords[0]; + } + } +} + +static INLINE void shift_recty(float coords[4], + const float *bounds, + const float shift) +{ + coords[1] += shift; + coords[3] -= shift; + if (bounds) { + coords[3] = MIN2(coords[3], bounds[3]); + if ((coords[1] + coords[3]) > (bounds[1] + bounds[3])) { + coords[3] = (bounds[1] + bounds[3]) - coords[1]; + } + } +} + +static INLINE void bound_rect(float coords[4], + const float bounds[4], + float shift[4]) +{ + /* if outside the bounds */ + if (coords[0] > (bounds[0] + bounds[2]) || + coords[1] > (bounds[1] + bounds[3]) || + (coords[0] + coords[2]) < bounds[0] || + (coords[1] + coords[3]) < bounds[1]) { + coords[0] = 0.f; + coords[1] = 0.f; + coords[2] = 0.f; + coords[3] = 0.f; + shift[0] = 0.f; + shift[1] = 0.f; + return; + } + + /* bound x */ + if (coords[0] < bounds[0]) { + shift[0] = bounds[0] - coords[0]; + coords[2] -= shift[0]; + coords[0] = bounds[0]; + } else + shift[0] = 0.f; + + /* bound y */ + if (coords[1] < bounds[1]) { + shift[1] = bounds[1] - coords[1]; + coords[3] -= shift[1]; + coords[1] = bounds[1]; + } else + shift[1] = 0.f; + + shift[2] = bounds[2] - coords[2]; + shift[3] = bounds[3] - coords[3]; + /* bound width/height */ + coords[2] = MIN2(coords[2], bounds[2]); + coords[3] = MIN2(coords[3], bounds[3]); + + /* bound x/y + width/height */ + if ((coords[0] + coords[2]) > (bounds[0] + bounds[2])) { + coords[2] = (bounds[0] + bounds[2]) - coords[0]; + } + if ((coords[1] + coords[3]) > (bounds[1] + bounds[3])) { + coords[3] = (bounds[1] + bounds[3]) - coords[1]; + } + + /* if outside the bounds */ + if ((coords[0] + coords[2]) < bounds[0] || + (coords[1] + coords[3]) < bounds[1]) { + coords[0] = 0.f; + coords[1] = 0.f; + coords[2] = 0.f; + coords[3] = 0.f; + return; + } +} + +static INLINE void sync_size(float *src_loc, float *dst_loc) +{ + src_loc[2] = MIN2(src_loc[2], dst_loc[2]); + src_loc[3] = MIN2(src_loc[3], dst_loc[3]); + dst_loc[2] = src_loc[2]; + dst_loc[3] = src_loc[3]; +} + + +static void renderer_copy_texture(struct exa_context *exa, + struct pipe_texture *src, + float sx1, float sy1, + float sx2, float sy2, + struct pipe_texture *dst, + float dx1, float dy1, + float dx2, float dy2) +{ + struct pipe_context *pipe = exa->ctx; + struct pipe_screen *screen = pipe->screen; + struct pipe_buffer *buf; + 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; + + assert(src->width[0] != 0); + assert(src->height[0] != 0); + 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]; + t0 = sy1 / src->height[0]; + t1 = sy2 / src->height[0]; +#else + s0 = 0; + s1 = 1; + t0 = 0; + t1 = 1; +#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); + cso_save_samplers(exa->cso); + cso_save_sampler_textures(exa->cso); + cso_save_framebuffer(exa->cso); + cso_save_fragment_shader(exa->cso); + cso_save_vertex_shader(exa->cso); + + cso_save_viewport(exa->cso); + + + /* set misc state we care about */ + { + struct pipe_blend_state blend; + memset(&blend, 0, sizeof(blend)); + blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.colormask = PIPE_MASK_RGBA; + cso_set_blend(exa->cso, &blend); + } + + /* sampler */ + { + struct pipe_sampler_state sampler; + memset(&sampler, 0, sizeof(sampler)); + sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE; + sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE; + sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE; + sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE; + sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST; + sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST; + sampler.normalized_coords = 1; + cso_single_sampler(exa->cso, 0, &sampler); + cso_single_sampler_done(exa->cso); + } + + set_viewport(exa, dst_surf->width, dst_surf->height, Y0_TOP); + + /* texture */ + cso_set_sampler_textures(exa->cso, 1, &src); + + /* shaders */ + shader = xorg_shaders_get(exa->shaders, + VS_COMPOSITE, + FS_COMPOSITE); + cso_set_vertex_shader_handle(exa->cso, shader.vs); + cso_set_fragment_shader_handle(exa->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(exa->cso, &fb); + + /* draw quad */ + buf = setup_vertex_data_tex(exa, + dx1, dy1, + dx2, dy2, + s0, t0, s1, t1, + 0.0f); + + if (buf) { + util_draw_vertex_buffer(exa->ctx, buf, 0, + PIPE_PRIM_TRIANGLE_FAN, + 4, /* verts */ + 2); /* attribs/vert */ + + pipe_buffer_reference(&buf, NULL); + } + + /* restore state we changed */ + cso_restore_blend(exa->cso); + cso_restore_samplers(exa->cso); + cso_restore_sampler_textures(exa->cso); + cso_restore_framebuffer(exa->cso); + cso_restore_vertex_shader(exa->cso); + cso_restore_fragment_shader(exa->cso); + cso_restore_viewport(exa->cso); + + pipe_surface_reference(&dst_surf, NULL); +} + void xorg_copy_pixmap(struct exa_context *ctx, - struct exa_pixmap_priv *dst, int dx, int dy, - struct exa_pixmap_priv *src, int sx, int sy, + struct exa_pixmap_priv *dst_priv, int dx, int dy, + struct exa_pixmap_priv *src_priv, int sx, int sy, int width, int height) { - + float dst_loc[4], src_loc[4]; + float dst_bounds[4], src_bounds[4]; + float src_shift[4], dst_shift[4], shift[4]; + struct pipe_texture *dst = dst_priv->tex; + struct pipe_texture *src = src_priv->tex; + + dst_loc[0] = dx; + dst_loc[1] = dy; + dst_loc[2] = width; + dst_loc[3] = height; + dst_bounds[0] = 0.f; + dst_bounds[1] = 0.f; + dst_bounds[2] = dst->width[0]; + dst_bounds[3] = dst->height[0]; + + src_loc[0] = sx; + src_loc[1] = sy; + src_loc[2] = width; + src_loc[3] = height; + src_bounds[0] = 0.f; + src_bounds[1] = 0.f; + src_bounds[2] = src->width[0]; + src_bounds[3] = src->height[0]; + + bound_rect(src_loc, src_bounds, src_shift); + bound_rect(dst_loc, dst_bounds, dst_shift); + shift[0] = src_shift[0] - dst_shift[0]; + shift[1] = src_shift[1] - dst_shift[1]; + + if (shift[0] < 0) + shift_rectx(src_loc, src_bounds, -shift[0]); + else + shift_rectx(dst_loc, dst_bounds, shift[0]); + + if (shift[1] < 0) + shift_recty(src_loc, src_bounds, -shift[1]); + else + shift_recty(dst_loc, dst_bounds, shift[1]); + + sync_size(src_loc, dst_loc); + + if (src_loc[2] >= 0 && src_loc[3] >= 0 && + dst_loc[2] >= 0 && dst_loc[3] >= 0) { + renderer_copy_texture(ctx, + src, + src_loc[0], + src_loc[1] + src_loc[3], + src_loc[0] + src_loc[2], + src_loc[1], + dst, + dst_loc[0], + dst_loc[1] + dst_loc[3], + dst_loc[0] + dst_loc[2], + dst_loc[1]); + } } diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index d3e7607cc3..e40f9f1f6b 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -82,6 +82,16 @@ exa_get_pipe_format(int depth, enum pipe_format *format, int *bbp) } } +static void +xorg_exa_init_state(struct exa_context *exa) +{ + struct pipe_depth_stencil_alpha_state dsa; + + /* set common initial clip state */ + memset(&dsa, 0, sizeof(struct pipe_depth_stencil_alpha_state)); + cso_set_depth_stencil_alpha(exa->cso, &dsa); +} + static void xorg_exa_common_done(struct exa_context *exa) { @@ -723,6 +733,8 @@ xorg_exa_init(ScrnInfoPtr pScrn) exa->cso = cso_create_context(exa->ctx); exa->shaders = xorg_shaders_create(exa); + xorg_exa_init_state(exa); + return (void *)exa; out_err: -- cgit v1.2.3 From 85a716bf627080c5b57653ddfca199e752f6906e Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 9 Sep 2009 17:16:02 -0400 Subject: st/xorg: temporarily disablie copies --- src/gallium/state_trackers/xorg/xorg_exa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gallium/state_trackers/xorg') diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index e40f9f1f6b..a302aa589e 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -350,7 +350,8 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, exa->copy.src = src_priv; exa->copy.dst = priv; - return TRUE; + /*XXX disabled until some issues with syncing are fixed */ + return FALSE; } static void -- cgit v1.2.3 From 8c37a4c8fd133f3cddc6798a0834038730acc213 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 9 Sep 2009 17:38:13 -0400 Subject: st/xorg: rename ctx to pipe to match every other gallium state tracker plus it avoids the "ctx->ctx->" syntax --- src/gallium/state_trackers/xorg/xorg_composite.c | 30 ++++++++++----------- src/gallium/state_trackers/xorg/xorg_exa.c | 34 ++++++++++++------------ src/gallium/state_trackers/xorg/xorg_exa.h | 2 +- src/gallium/state_trackers/xorg/xorg_exa_tgsi.c | 4 +-- 4 files changed, 35 insertions(+), 35 deletions(-) (limited to 'src/gallium/state_trackers/xorg') diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index 66e5e7284a..15c955450d 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -165,7 +165,7 @@ setup_vertex_data0(struct exa_context *ctx, setup_vertex0(vertices[3], dstX, dstY + height, ctx->solid_color); - return pipe_user_buffer_create(ctx->ctx->screen, + return pipe_user_buffer_create(ctx->pipe->screen, vertices, sizeof(vertices)); } @@ -211,7 +211,7 @@ setup_vertex_data1(struct exa_context *ctx, setup_vertex1(vertices[3], dstX, dstY + height, s0, t1); - return pipe_user_buffer_create(ctx->ctx->screen, + return pipe_user_buffer_create(ctx->pipe->screen, vertices, sizeof(vertices)); } @@ -237,7 +237,7 @@ setup_vertex_data_tex(struct exa_context *ctx, setup_vertex1(vertices[3], x0, y1, s0, t1); - return pipe_user_buffer_create(ctx->ctx->screen, + return pipe_user_buffer_create(ctx->pipe->screen, vertices, sizeof(vertices)); } @@ -297,7 +297,7 @@ setup_vertex_data2(struct exa_context *ctx, setup_vertex2(vertices[3], dstX, dstY + height, st0[0], st0[3], st1[0], st1[3]); - return pipe_user_buffer_create(ctx->ctx->screen, + return pipe_user_buffer_create(ctx->pipe->screen, vertices, sizeof(vertices)); } @@ -532,15 +532,15 @@ setup_vs_constant_buffer(struct exa_context *exa, struct pipe_constant_buffer *cbuf = &exa->vs_const_buffer; pipe_buffer_reference(&cbuf->buffer, NULL); - cbuf->buffer = pipe_buffer_create(exa->ctx->screen, 16, + cbuf->buffer = pipe_buffer_create(exa->pipe->screen, 16, PIPE_BUFFER_USAGE_CONSTANT, param_bytes); if (cbuf->buffer) { - pipe_buffer_write(exa->ctx->screen, cbuf->buffer, + pipe_buffer_write(exa->pipe->screen, cbuf->buffer, 0, param_bytes, vs_consts); } - exa->ctx->set_constant_buffer(exa->ctx, PIPE_SHADER_VERTEX, 0, cbuf); + exa->pipe->set_constant_buffer(exa->pipe, PIPE_SHADER_VERTEX, 0, cbuf); } @@ -554,15 +554,15 @@ setup_fs_constant_buffer(struct exa_context *exa) struct pipe_constant_buffer *cbuf = &exa->fs_const_buffer; pipe_buffer_reference(&cbuf->buffer, NULL); - cbuf->buffer = pipe_buffer_create(exa->ctx->screen, 16, + cbuf->buffer = pipe_buffer_create(exa->pipe->screen, 16, PIPE_BUFFER_USAGE_CONSTANT, param_bytes); if (cbuf->buffer) { - pipe_buffer_write(exa->ctx->screen, cbuf->buffer, + pipe_buffer_write(exa->pipe->screen, cbuf->buffer, 0, param_bytes, fs_consts); } - exa->ctx->set_constant_buffer(exa->ctx, PIPE_SHADER_FRAGMENT, 0, cbuf); + exa->pipe->set_constant_buffer(exa->pipe, PIPE_SHADER_FRAGMENT, 0, cbuf); } static void @@ -602,7 +602,7 @@ void xorg_composite(struct exa_context *exa, int srcX, int srcY, int maskX, int maskY, int dstX, int dstY, int width, int height) { - struct pipe_context *pipe = exa->ctx; + struct pipe_context *pipe = exa->pipe; struct pipe_buffer *buf = 0; if (exa->num_bound_samplers == 0 ) { /* solid fill */ @@ -687,7 +687,7 @@ void xorg_solid(struct exa_context *exa, struct exa_pixmap_priv *pixmap, int x0, int y0, int x1, int y1) { - struct pipe_context *pipe = exa->ctx; + struct pipe_context *pipe = exa->pipe; struct pipe_buffer *buf = 0; float vertices[4][2][4]; @@ -707,7 +707,7 @@ void xorg_solid(struct exa_context *exa, setup_vertex0(vertices[3], x0, y1, exa->solid_color); - buf = pipe_user_buffer_create(exa->ctx->screen, + buf = pipe_user_buffer_create(exa->pipe->screen, vertices, sizeof(vertices)); @@ -829,7 +829,7 @@ static void renderer_copy_texture(struct exa_context *exa, float dx1, float dy1, float dx2, float dy2) { - struct pipe_context *pipe = exa->ctx; + struct pipe_context *pipe = exa->pipe; struct pipe_screen *screen = pipe->screen; struct pipe_buffer *buf; struct pipe_surface *dst_surf = screen->get_tex_surface( @@ -935,7 +935,7 @@ static void renderer_copy_texture(struct exa_context *exa, 0.0f); if (buf) { - util_draw_vertex_buffer(exa->ctx, buf, 0, + util_draw_vertex_buffer(exa->pipe, buf, 0, PIPE_PRIM_TRIANGLE_FAN, 4, /* verts */ 2); /* attribs/vert */ diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index a302aa589e..312dab1544 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -130,9 +130,9 @@ ExaDownloadFromScreen(PixmapPtr pPix, int x, int y, int w, int h, char *dst, if (!priv || !priv->tex) return FALSE; - if (exa->ctx->is_texture_referenced(exa->ctx, priv->tex, 0, 0) & + if (exa->pipe->is_texture_referenced(exa->pipe, priv->tex, 0, 0) & PIPE_REFERENCED_FOR_WRITE) - exa->ctx->flush(exa->ctx, 0, NULL); + exa->pipe->flush(exa->pipe, 0, NULL); transfer = exa->scrn->get_tex_transfer(exa->scrn, priv->tex, 0, 0, 0, PIPE_TRANSFER_READ, x, y, w, h); @@ -197,9 +197,9 @@ ExaPrepareAccess(PixmapPtr pPix, int index) if (priv->map_count++ == 0) { - if (exa->ctx->is_texture_referenced(exa->ctx, priv->tex, 0, 0) & + if (exa->pipe->is_texture_referenced(exa->pipe, priv->tex, 0, 0) & PIPE_REFERENCED_FOR_WRITE) - exa->ctx->flush(exa->ctx, 0, NULL); + exa->pipe->flush(exa->pipe, 0, NULL); priv->map_transfer = exa->scrn->get_tex_transfer(exa->scrn, priv->tex, 0, 0, 0, @@ -289,7 +289,7 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg) if (alu != GXcopy) return FALSE; - if (!exa->ctx) + if (!exa->pipe) return FALSE; debug_printf(" ExaPrepareSolid(0x%x)\n", fg); @@ -344,7 +344,7 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, if (!priv->tex || !src_priv->tex) return FALSE; - if (!exa->ctx) + if (!exa->pipe) return FALSE; exa->copy.src = src_priv; @@ -586,9 +586,9 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, 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->ctx->surface_copy(exa->ctx, dst_surf, 0, 0, src_surf, - 0, 0, min(width, texture->width[0]), - min(height, texture->height[0])); + exa->pipe->surface_copy(exa->pipe, dst_surf, 0, 0, src_surf, + 0, 0, min(width, texture->width[0]), + min(height, texture->height[0])); exa->scrn->tex_surface_destroy(dst_surf); exa->scrn->tex_surface_destroy(src_surf); } else if (pPixmap->devPrivate.ptr) { @@ -658,8 +658,8 @@ xorg_exa_close(ScrnInfoPtr pScrn) cso_destroy_context(exa->cso); } - if (exa->ctx) - exa->ctx->destroy(exa->ctx); + if (exa->pipe) + exa->pipe->destroy(exa->pipe); exaDriverFini(pScrn->pScreen); xfree(exa); @@ -727,11 +727,11 @@ xorg_exa_init(ScrnInfoPtr pScrn) } exa->scrn = ms->screen; - exa->ctx = ms->api->create_context(ms->api, exa->scrn); + exa->pipe = ms->api->create_context(ms->api, exa->scrn); /* Share context with DRI */ - ms->ctx = exa->ctx; + ms->ctx = exa->pipe; - exa->cso = cso_create_context(exa->ctx); + exa->cso = cso_create_context(exa->pipe); exa->shaders = xorg_shaders_create(exa); xorg_exa_init_state(exa); @@ -756,7 +756,7 @@ exa_gpu_surface(struct exa_context *exa, struct exa_pixmap_priv *priv) void xorg_exa_flush(struct exa_context *exa, uint pipeFlushFlags, struct pipe_fence_handle **fence) { - exa->ctx->flush(exa->ctx, pipeFlushFlags, fence); + exa->pipe->flush(exa->pipe, pipeFlushFlags, fence); } void xorg_exa_finish(struct exa_context *exa) @@ -765,7 +765,7 @@ void xorg_exa_finish(struct exa_context *exa) xorg_exa_flush(exa, PIPE_FLUSH_RENDER_CACHE, &fence); - exa->ctx->screen->fence_finish(exa->ctx->screen, fence, 0); - exa->ctx->screen->fence_reference(exa->ctx->screen, &fence, NULL); + exa->pipe->screen->fence_finish(exa->pipe->screen, fence, 0); + exa->pipe->screen->fence_reference(exa->pipe->screen, &fence, NULL); } diff --git a/src/gallium/state_trackers/xorg/xorg_exa.h b/src/gallium/state_trackers/xorg/xorg_exa.h index 7229e87101..43949b04a4 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.h +++ b/src/gallium/state_trackers/xorg/xorg_exa.h @@ -14,7 +14,7 @@ struct xorg_shaders; struct exa_context { ExaDriverPtr pExa; - struct pipe_context *ctx; + struct pipe_context *pipe; struct pipe_screen *scrn; struct cso_context *cso; struct xorg_shaders *shaders; diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c index 2d2c2e884b..694eded09a 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c +++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c @@ -473,9 +473,9 @@ struct xorg_shader xorg_shaders_get(struct xorg_shaders *sc, struct xorg_shader shader = {0}; void *vs, *fs; - vs = shader_from_cache(sc->exa->ctx, PIPE_SHADER_VERTEX, + vs = shader_from_cache(sc->exa->pipe, PIPE_SHADER_VERTEX, sc->vs_hash, vs_traits); - fs = shader_from_cache(sc->exa->ctx, PIPE_SHADER_FRAGMENT, + fs = shader_from_cache(sc->exa->pipe, PIPE_SHADER_FRAGMENT, sc->fs_hash, fs_traits); debug_assert(vs && fs); -- cgit v1.2.3 From 6d8dbd3d1ec888300fb0e9ac3cf61808ba8ecc2b Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sat, 12 Sep 2009 14:12:35 -0700 Subject: tgsi/ureg: VS inputs don't have any semantic tags, just an index Fix ureg_DECL_vs_input to reflect this and fix up all callers. --- src/gallium/auxiliary/tgsi/tgsi_ureg.c | 72 ++++++++++++------------- src/gallium/auxiliary/tgsi/tgsi_ureg.h | 3 +- src/gallium/auxiliary/util/u_simple_shaders.c | 4 +- src/gallium/state_trackers/xorg/xorg_exa_tgsi.c | 15 +++--- 4 files changed, 44 insertions(+), 50 deletions(-) (limited to 'src/gallium/state_trackers/xorg') diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index e24a0ad776..55a4e5b2e9 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -87,8 +87,10 @@ struct ureg_program unsigned semantic_name; unsigned semantic_index; unsigned interp; - } input[UREG_MAX_INPUT]; - unsigned nr_inputs; + } fs_input[UREG_MAX_INPUT]; + unsigned nr_fs_inputs; + + unsigned vs_inputs[UREG_MAX_INPUT/32]; struct { unsigned semantic_name; @@ -232,25 +234,25 @@ ureg_src_register( unsigned file, -static struct ureg_src -ureg_DECL_input( struct ureg_program *ureg, - unsigned name, - unsigned index, - unsigned interp_mode ) +struct ureg_src +ureg_DECL_fs_input( struct ureg_program *ureg, + unsigned name, + unsigned index, + unsigned interp_mode ) { unsigned i; - for (i = 0; i < ureg->nr_inputs; i++) { - if (ureg->input[i].semantic_name == name && - ureg->input[i].semantic_index == index) + for (i = 0; i < ureg->nr_fs_inputs; i++) { + if (ureg->fs_input[i].semantic_name == name && + ureg->fs_input[i].semantic_index == index) goto out; } - if (ureg->nr_inputs < UREG_MAX_INPUT) { - ureg->input[i].semantic_name = name; - ureg->input[i].semantic_index = index; - ureg->input[i].interp = interp_mode; - ureg->nr_inputs++; + if (ureg->nr_fs_inputs < UREG_MAX_INPUT) { + ureg->fs_input[i].semantic_name = name; + ureg->fs_input[i].semantic_index = index; + ureg->fs_input[i].interp = interp_mode; + ureg->nr_fs_inputs++; } else { set_bad( ureg ); @@ -261,25 +263,14 @@ out: } - -struct ureg_src -ureg_DECL_fs_input( struct ureg_program *ureg, - unsigned name, - unsigned index, - unsigned interp ) -{ - assert(ureg->processor == TGSI_PROCESSOR_FRAGMENT); - return ureg_DECL_input( ureg, name, index, interp ); -} - - struct ureg_src ureg_DECL_vs_input( struct ureg_program *ureg, - unsigned name, unsigned index ) { assert(ureg->processor == TGSI_PROCESSOR_VERTEX); - return ureg_DECL_input( ureg, name, index, TGSI_INTERPOLATE_CONSTANT ); + + ureg->vs_inputs[index/32] |= 1 << (index % 32); + return ureg_src_register( TGSI_FILE_INPUT, index ); } @@ -781,13 +772,22 @@ static void emit_decls( struct ureg_program *ureg ) { unsigned i; - for (i = 0; i < ureg->nr_inputs; i++) { - emit_decl( ureg, - TGSI_FILE_INPUT, - i, - ureg->input[i].semantic_name, - ureg->input[i].semantic_index, - ureg->input[i].interp ); + if (ureg->processor == TGSI_PROCESSOR_VERTEX) { + for (i = 0; i < UREG_MAX_INPUT; i++) { + if (ureg->vs_inputs[i/32] & (1 << (i%32))) { + emit_decl_range( ureg, TGSI_FILE_INPUT, i, 1 ); + } + } + } + else { + for (i = 0; i < ureg->nr_fs_inputs; i++) { + emit_decl( ureg, + TGSI_FILE_INPUT, + i, + ureg->fs_input[i].semantic_name, + ureg->fs_input[i].semantic_index, + ureg->fs_input[i].interp ); + } } for (i = 0; i < ureg->nr_outputs; i++) { diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index acbca59040..3bc1b77503 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -116,8 +116,7 @@ ureg_DECL_fs_input( struct ureg_program *, struct ureg_src ureg_DECL_vs_input( struct ureg_program *, - unsigned semantic_name, - unsigned semantic_index ); + unsigned index ); struct ureg_dst ureg_DECL_output( struct ureg_program *, diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c index e5fc9b0cee..0d706f9449 100644 --- a/src/gallium/auxiliary/util/u_simple_shaders.c +++ b/src/gallium/auxiliary/util/u_simple_shaders.c @@ -61,9 +61,7 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe, struct ureg_src src; struct ureg_dst dst; - src = ureg_DECL_vs_input( ureg, - semantic_names[i], - semantic_indexes[i]); + src = ureg_DECL_vs_input( ureg, i ); dst = ureg_DECL_output( ureg, semantic_names[i], diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c index 694eded09a..978dc209c0 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c +++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c @@ -241,6 +241,7 @@ create_vs(struct pipe_context *pipe, boolean is_fill = vs_traits & VS_FILL; boolean is_composite = vs_traits & VS_COMPOSITE; boolean has_mask = vs_traits & VS_MASK; + unsigned input_slot = 0; ureg = ureg_create(TGSI_PROCESSOR_VERTEX); if (ureg == NULL) @@ -252,30 +253,26 @@ create_vs(struct pipe_context *pipe, /* it has to be either a fill or a composite op */ debug_assert(is_fill ^ is_composite); - src = ureg_DECL_vs_input(ureg, - TGSI_SEMANTIC_POSITION, 0); + src = ureg_DECL_vs_input(ureg, input_slot++); dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_POSITION, 0); src = vs_normalize_coords(ureg, src, const0, const1); ureg_MOV(ureg, dst, src); - if (is_composite) { - src = ureg_DECL_vs_input(ureg, - TGSI_SEMANTIC_GENERIC, 1); + src = ureg_DECL_vs_input(ureg, input_slot++); dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_GENERIC, 1); ureg_MOV(ureg, dst, src); } + if (is_fill) { - src = ureg_DECL_vs_input(ureg, - TGSI_SEMANTIC_COLOR, 0); + src = ureg_DECL_vs_input(ureg, input_slot++); dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_COLOR, 0); ureg_MOV(ureg, dst, src); } if (has_mask) { - src = ureg_DECL_vs_input(ureg, - TGSI_SEMANTIC_GENERIC, 2); + src = ureg_DECL_vs_input(ureg, input_slot++); dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_POSITION, 2); ureg_MOV(ureg, dst, src); } -- cgit v1.2.3 From ae4704eabc237e13c9b06df9c44f31c9baca6208 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sat, 12 Sep 2009 14:16:00 -0700 Subject: tgsi/ureg: give ureg_DECL_constant an explicit index parameter Avoid the need to emit all constant declarations in order. Makes referring to a specific constant in the constant buffer much easier. --- src/gallium/auxiliary/tgsi/tgsi_ureg.c | 5 ++++- src/gallium/auxiliary/tgsi/tgsi_ureg.h | 3 ++- src/gallium/state_trackers/xorg/xorg_exa_tgsi.c | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src/gallium/state_trackers/xorg') diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index 55a4e5b2e9..9222af91fe 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -308,8 +308,11 @@ out: * value or manage any constant_buffer contents -- that's the * resposibility of the calling code. */ -struct ureg_src ureg_DECL_constant(struct ureg_program *ureg ) +struct ureg_src ureg_DECL_constant(struct ureg_program *ureg, + unsigned index ) { + + return ureg_src_register( TGSI_FILE_CONSTANT, ureg->nr_constants++ ); } diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index 3bc1b77503..627a5b0c52 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -129,7 +129,8 @@ ureg_DECL_immediate( struct ureg_program *, unsigned nr ); struct ureg_src -ureg_DECL_constant( struct ureg_program * ); +ureg_DECL_constant( struct ureg_program *, + unsigned index ); struct ureg_dst ureg_DECL_temporary( struct ureg_program * ); diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c index 978dc209c0..b30cbff479 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c +++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c @@ -247,8 +247,8 @@ create_vs(struct pipe_context *pipe, if (ureg == NULL) return 0; - const0 = ureg_DECL_constant(ureg); - const1 = ureg_DECL_constant(ureg); + const0 = ureg_DECL_constant(ureg, 0); + const1 = ureg_DECL_constant(ureg, 1); /* it has to be either a fill or a composite op */ debug_assert(is_fill ^ is_composite); -- cgit v1.2.3 From 5a87a25a65012122dd91256a8d2f3d1c3ffe5de0 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 14 Sep 2009 15:47:07 -0600 Subject: st/xorg: fix ureg_DECL_constant() parameters This fixes the compilation errors reported in bug 23945 but someone more familiar with the code should review for correctness and close the bug report. --- src/gallium/state_trackers/xorg/xorg_exa_tgsi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/gallium/state_trackers/xorg') diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c index b30cbff479..801d0d8df4 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c +++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c @@ -367,11 +367,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, -- cgit v1.2.3 From ef7746217176ba251dc6a5deb90c308c9964ed7b Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Mon, 14 Sep 2009 19:01:21 -0400 Subject: st/xorg: add some debugging helpers --- src/gallium/state_trackers/xorg/xorg_composite.c | 18 ++++++--------- src/gallium/state_trackers/xorg/xorg_exa.c | 29 +++++++++++++++++++++--- 2 files changed, 33 insertions(+), 14 deletions(-) (limited to 'src/gallium/state_trackers/xorg') diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index 15c955450d..e45a82944b 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -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); @@ -861,8 +853,10 @@ 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)); + 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); @@ -966,6 +960,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; diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index 312dab1544..0d60b963bf 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 */ @@ -253,7 +255,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,7 +278,9 @@ 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"); +#endif if (pPixmap->drawable.depth < 15) return FALSE; @@ -292,7 +296,14 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg) 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 +321,23 @@ 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 + 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]); +#else + xorg_solid(exa, priv, x0, y0, x1, y1) ; +#endif } static Bool -- cgit v1.2.3 From be94a1d3bc147320ac7bfd98235783359bfada5c Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Tue, 15 Sep 2009 18:23:00 +0200 Subject: st/xorg: Use A8 format for depth 8 pixmaps. The inconsistent bpp caused issues with UploadTo/DownloadFromScreen. --- src/gallium/state_trackers/xorg/xorg_exa.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/gallium/state_trackers/xorg') diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index 0d60b963bf..d6241aa19e 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -74,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 */ -- cgit v1.2.3 From 45cf2696ca2ad5f2ef77a3c35ee1d0ab1709b1da Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Tue, 15 Sep 2009 18:30:58 +0200 Subject: st/xorg: Explicitly check whether the driver supports the pixmap formats. Rather than arbitrarily checking for pixmap depth < 15. --- src/gallium/state_trackers/xorg/xorg_exa.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/gallium/state_trackers/xorg') diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index d6241aa19e..88149b9d5c 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -284,15 +284,17 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg) #if 0 debug_printf("ExaPrepareSolid - test\n"); #endif - if (pPixmap->drawable.depth < 15) - return FALSE; - 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; @@ -358,15 +360,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; -- cgit v1.2.3 From 0469465c31371177d85ab7af103359500323c1f8 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Tue, 15 Sep 2009 18:31:07 +0200 Subject: st/xorg: Only unreference texture on pixmap destruction, don't destroy it. Fixes memory corruption if e.g. the driver still has references to the texture. --- src/gallium/state_trackers/xorg/xorg_exa.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/gallium/state_trackers/xorg') diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index 88149b9d5c..75524891f7 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -466,14 +466,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); } -- cgit v1.2.3 From f1ce6b09cdb21d9217d6ad6057f7fb97375df8be Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Tue, 15 Sep 2009 06:00:52 -0400 Subject: st/xorg: Brian suggested that those could be mad's optimizes the common paths --- src/gallium/state_trackers/xorg/xorg_exa_tgsi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/gallium/state_trackers/xorg') diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c index 801d0d8df4..d61cae53c7 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; -- cgit v1.2.3 From 8adcad0c703a9d339b6630ceaba5f96981c524d9 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Tue, 15 Sep 2009 09:02:20 -0400 Subject: st/xorg: lots of fixes fixes blending binding and copy coordinates --- src/gallium/state_trackers/xorg/xorg_composite.c | 25 +++++++++++++----------- src/gallium/state_trackers/xorg/xorg_exa.c | 20 +++++++++++++++++-- 2 files changed, 32 insertions(+), 13 deletions(-) (limited to 'src/gallium/state_trackers/xorg') diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index e45a82944b..edb7620f12 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 */ }; @@ -836,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]; @@ -853,6 +848,12 @@ static void renderer_copy_texture(struct exa_context *exa, t1 = 1; #endif +#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, @@ -920,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, @@ -1002,14 +1005,14 @@ void xorg_copy_pixmap(struct exa_context *ctx, renderer_copy_texture(ctx, 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]); } } diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index 75524891f7..3c2639e7d9 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -309,6 +309,7 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg) #if 1 debug_printf(" ExaPrepareSolid(0x%x)\n", fg); #endif + return xorg_solid_bind_state(exa, priv, fg); } @@ -332,6 +333,15 @@ ExaSolid(PixmapPtr pPixmap, int x0, int y0, int x1, int y1) #endif #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); @@ -340,6 +350,12 @@ ExaSolid(PixmapPtr pPixmap, int x0, int y0, int x1, int y1) priv->tex->height[0] - 10, priv->tex->width[0], priv->tex->height[0]); + + ExaPrepareCopy(pPixmap, pPixmap, 0, 0, GXcopy, 0xffffffff); + ExaCopy(pPixmap, 350, 350, 510, 350, 150, 150); + ExaCopy(pPixmap, 350, 350, 510, 190, 150, 150); + xorg_exa_finish(exa); + ExaCopy(pPixmap, 0, 0, 0, 0, 1024, 768); #else xorg_solid(exa, priv, x0, y0, x1, y1) ; #endif @@ -613,8 +629,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]), -- cgit v1.2.3 From a016043386045d7cc35d70e42d963704fcae3731 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Tue, 15 Sep 2009 11:01:21 -0400 Subject: st/xorg: fixing copies and composite shaders copies were busted when src == dst. also the composite shaders were incorrectly using the fragments instead of the texture coordinate. --- src/gallium/state_trackers/xorg/xorg_composite.c | 65 +++++++++++++++++++++++- src/gallium/state_trackers/xorg/xorg_exa.c | 20 +++++--- src/gallium/state_trackers/xorg/xorg_exa_tgsi.c | 4 +- 3 files changed, 78 insertions(+), 11 deletions(-) (limited to 'src/gallium/state_trackers/xorg') diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index edb7620f12..66ca4cb590 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -952,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, @@ -1002,8 +1057,13 @@ 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[0] + src_loc[2], @@ -1013,6 +1073,9 @@ void xorg_copy_pixmap(struct exa_context *ctx, dst_loc[1], dst_loc[0] + dst_loc[2], 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 3c2639e7d9..dea9f4c2bc 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -342,20 +342,24 @@ ExaSolid(PixmapPtr pPixmap, int x0, int y0, int x1, int y1) 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, + 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, 350, 350, 510, 350, 150, 150); - ExaCopy(pPixmap, 350, 350, 510, 190, 150, 150); - xorg_exa_finish(exa); - ExaCopy(pPixmap, 0, 0, 0, 0, 1024, 768); + ExaCopy(pPixmap, 0, 0, 50, 50, 500, 500); #else xorg_solid(exa, priv, x0, y0, x1, y1) ; #endif diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c index d61cae53c7..2daa5b5628 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c +++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c @@ -259,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); } @@ -310,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 { -- cgit v1.2.3 From e9d6ab72be065becf7a077c33919d37faa8db92e Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 21 Sep 2009 13:26:48 +1000 Subject: xorg/st: fixup builds against later dpms headers. --- configure.ac | 5 +++++ src/gallium/state_trackers/xorg/xorg_crtc.c | 4 ++++ src/gallium/state_trackers/xorg/xorg_output.c | 4 ++++ 3 files changed, 13 insertions(+) (limited to 'src/gallium/state_trackers/xorg') diff --git a/configure.ac b/configure.ac index 75189761ee..2881bb6bc2 100644 --- a/configure.ac +++ b/configure.ac @@ -1148,6 +1148,11 @@ yes) if test "$tracker" = egl && test "x$enable_egl" != xyes; then AC_MSG_ERROR([cannot build egl state tracker without EGL library]) fi + if test "$tracker" = xorg; then + PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1], + HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71" + HAVE_XEXTPROTO_71="no") + fi done GALLIUM_STATE_TRACKERS_DIRS="$state_trackers" ;; diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c index fe08bde9ef..67fe29a69d 100644 --- a/src/gallium/state_trackers/xorg/xorg_crtc.c +++ b/src/gallium/state_trackers/xorg/xorg_crtc.c @@ -42,8 +42,12 @@ #include "xorg_tracker.h" #include "xf86Modes.h" +#ifdef HAVE_XEXTPROTO_71 +#include +#else #define DPMS_SERVER #include +#endif #include "pipe/p_inlines.h" #include "util/u_rect.h" diff --git a/src/gallium/state_trackers/xorg/xorg_output.c b/src/gallium/state_trackers/xorg/xorg_output.c index 950af942f5..26f45f8d64 100644 --- a/src/gallium/state_trackers/xorg/xorg_output.c +++ b/src/gallium/state_trackers/xorg/xorg_output.c @@ -42,8 +42,12 @@ #include #include +#ifdef HAVE_XEXTPROTO_71 +#include +#else #define DPMS_SERVER #include +#endif #include "X11/Xatom.h" -- cgit v1.2.3