gallium: Permit surface_copy and surface_fill to be NULL.

Uf. Lots of files touched. Would people with working vega, xorg, dri1, etc.
please make sure you are not broken, and fix yourself up if you are.

There were only two or three places where the code did not have painful
fallbacks, so I would advise st maintainers to find less painful workarounds,
or consider overhauling util_surface_copy and util_surface_fill.

Per ymanton, darktama, and Dr_Jakob's suggestions, clear has been left as-is.

I will not add PIPE_CAP_BLITTER unless it is deemed necessary.
This commit is contained in:
Corbin Simpson
2009-10-17 21:32:56 -07:00
parent bfd877e470
commit bb567357bc
14 changed files with 156 additions and 54 deletions

View File

@@ -46,6 +46,7 @@
#include "util/u_memory.h"
#include "util/u_simple_shaders.h"
#include "util/u_surface.h"
#include "util/u_rect.h"
#include "cso_cache/cso_context.h"
@@ -301,7 +302,8 @@ util_blit_pixels_writemask(struct blit_state *ctx,
* no overlapping.
* Filter mode should not matter since there's no stretching.
*/
if (dst->format == src->format &&
if (pipe->surface_copy &&
dst->format == src->format &&
srcX0 < srcX1 &&
dstX0 < dstX1 &&
srcY0 < srcY1 &&
@@ -365,10 +367,17 @@ util_blit_pixels_writemask(struct blit_state *ctx,
PIPE_BUFFER_USAGE_GPU_WRITE);
/* load temp texture */
if (pipe->surface_copy) {
pipe->surface_copy(pipe,
texSurf, 0, 0, /* dest */
src, srcLeft, srcTop, /* src */
srcW, srcH); /* size */
} else {
util_surface_copy(pipe, FALSE,
texSurf, 0, 0, /* dest */
src, srcLeft, srcTop, /* src */
srcW, srcH); /* size */
}
/* free the surface, update the texture if necessary.
*/

View File

@@ -32,6 +32,7 @@
#include "pipe/p_context.h"
#include "pipe/p_state.h"
#include "util/u_pack_color.h"
#include "util/u_rect.h"
/**
@@ -48,13 +49,22 @@ util_clear(struct pipe_context *pipe,
unsigned color;
util_pack_color(rgba, ps->format, &color);
if (pipe->surface_fill) {
pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, color);
} else {
util_surface_fill(pipe, ps, 0, 0, ps->width, ps->height, color);
}
}
if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
struct pipe_surface *ps = framebuffer->zsbuf;
if (pipe->surface_fill) {
pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height,
util_pack_z_stencil(ps->format, depth, stencil));
} else {
util_surface_fill(pipe, ps, 0, 0, ps->width, ps->height,
util_pack_z_stencil(ps->format, depth, stencil));
}
}
}

View File

@@ -206,7 +206,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
r300_init_query_functions(r300);
r300_init_surface_functions(r300);
/* r300_init_surface_functions(r300); */
r300_init_state_functions(r300);

View File

@@ -189,6 +189,9 @@ struct pipe_context {
/**
* Surface functions
*
* The pipe driver is allowed to set these functions to NULL, and in that
* case, they will not be available.
*/
/*@{*/

View File

@@ -45,6 +45,7 @@
#include "state_tracker/st_cb_fbo.h"
#include "util/u_memory.h"
#include "util/u_rect.h"
static struct pipe_surface *
dri_surface_from_handle(struct drm_api *api,
@@ -541,12 +542,21 @@ dri1_swap_copy(struct dri_context *ctx,
cur = dPriv->pClipRects;
for (i = 0; i < dPriv->numClipRects; ++i) {
if (dri1_intersect_src_bbox(&clip, dPriv->x, dPriv->y, cur++, bbox))
if (dri1_intersect_src_bbox(&clip, dPriv->x, dPriv->y, cur++, bbox)) {
if (pipe->surface_copy) {
pipe->surface_copy(pipe, dst, clip.x1, clip.y1,
src,
(int)clip.x1 - dPriv->x,
(int)clip.y1 - dPriv->y,
clip.x2 - clip.x1, clip.y2 - clip.y1);
} else {
util_surface_copy(pipe, FALSE, dst, clip.x1, clip.y1,
src,
(int)clip.x1 - dPriv->x,
(int)clip.y1 - dPriv->y,
clip.x2 - clip.x1, clip.y2 - clip.y1);
}
}
}
}

View File

@@ -12,6 +12,8 @@
#include "state_tracker/drm_api.h"
#include "util/u_rect.h"
/*
* Util functions
*/
@@ -360,12 +362,21 @@ drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw)
st_notify_swapbuffers(surf->stfb);
if (ctx && surf->screen) {
if (ctx->pipe->surface_copy) {
ctx->pipe->surface_copy(ctx->pipe,
surf->screen->surface,
0, 0,
back_surf,
0, 0,
surf->w, surf->h);
} else {
util_surface_copy(ctx->pipe, FALSE,
surf->screen->surface,
0, 0,
back_surf,
0, 0,
surf->w, surf->h);
}
ctx->pipe->flush(ctx->pipe, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_TEXTURE_CACHE, NULL);
#ifdef DRM_MODE_FEATURE_DIRTYFB

View File

@@ -37,6 +37,7 @@
#include "util/u_draw_quad.h"
#include "util/u_simple_shaders.h"
#include "util/u_memory.h"
#include "util/u_rect.h"
#include "cso_cache/cso_context.h"
@@ -457,10 +458,17 @@ void renderer_copy_surface(struct renderer *ctx,
PIPE_BUFFER_USAGE_GPU_WRITE);
/* load temp texture */
if (pipe->surface_copy) {
pipe->surface_copy(pipe,
texSurf, 0, 0, /* dest */
src, srcLeft, srcTop, /* src */
srcW, srcH); /* size */
} else {
util_surface_copy(pipe, FALSE,
texSurf, 0, 0, /* dest */
src, srcLeft, srcTop, /* src */
srcW, srcH); /* size */
}
/* free the surface, update the texture if necessary.*/
screen->tex_surface_destroy(texSurf);

View File

@@ -235,6 +235,7 @@ static void setup_new_alpha_mask(struct vg_context *ctx,
old_texture,
0, 0, 0,
PIPE_BUFFER_USAGE_GPU_READ);
if (pipe->surface_copy) {
pipe->surface_copy(pipe,
surface,
0, 0,
@@ -242,6 +243,15 @@ static void setup_new_alpha_mask(struct vg_context *ctx,
0, 0,
MIN2(old_surface->width, width),
MIN2(old_surface->height, height));
} else {
util_surface_copy(pipe, FALSE,
surface,
0, 0,
old_surface,
0, 0,
MIN2(old_surface->width, width),
MIN2(old_surface->height, height));
}
if (surface)
pipe_surface_reference(&surface, NULL);
if (old_surface)

View File

@@ -693,9 +693,15 @@ 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 = xorg_gpu_surface(exa->pipe->screen, priv);
if (exa->pipe->surface_copy) {
exa->pipe->surface_copy(exa->pipe, dst_surf, 0, 0, src_surf,
0, 0, min(width, texture->width[0]),
min(height, texture->height[0]));
} else {
util_surface_copy(exa->pipe, FALSE, 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);
}

View File

@@ -7,6 +7,7 @@
#include "util/u_draw_quad.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_rect.h"
#include "pipe/p_inlines.h"
@@ -586,11 +587,19 @@ create_sampler_texture(struct xorg_renderer *r,
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 );
if (pipe->surface_copy) {
pipe->surface_copy(pipe,
ps_tex, /* dest */
0, 0, /* destx/y */
ps_read,
0, 0, src->width[0], src->height[0]);
} else {
util_surface_copy(pipe, FALSE,
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);
}

View File

@@ -39,6 +39,7 @@
#include "pipe/p_context.h"
#include "pipe/p_inlines.h"
#include "cso_cache/cso_context.h"
#include "util/u_rect.h"
@@ -162,10 +163,17 @@ update_framebuffer_state( struct st_context *st )
(void) st_get_framebuffer_surface(stfb, ST_SURFACE_FRONT_LEFT, &surf_front);
(void) st_get_framebuffer_surface(stfb, ST_SURFACE_BACK_LEFT, &surf_back);
if (st->pipe->surface_copy) {
st->pipe->surface_copy(st->pipe,
surf_front, 0, 0, /* dest */
surf_back, 0, 0, /* src */
fb->Width, fb->Height);
} else {
util_surface_copy(st->pipe, FALSE,
surf_front, 0, 0,
surf_back, 0, 0,
fb->Width, fb->Height);
}
}
/* we're assuming we'll really draw to the front buffer */
st->frontbuffer_status = FRONT_STATUS_DIRTY;

View File

@@ -62,6 +62,7 @@
#include "util/u_tile.h"
#include "util/u_draw_quad.h"
#include "util/u_math.h"
#include "util/u_rect.h"
#include "shader/prog_instruction.h"
#include "cso_cache/cso_context.h"
@@ -1075,11 +1076,19 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
PIPE_BUFFER_USAGE_GPU_READ);
struct pipe_surface *psTex = screen->get_tex_surface(screen, pt, 0, 0, 0,
PIPE_BUFFER_USAGE_GPU_WRITE );
if (pipe->surface_copy) {
pipe->surface_copy(pipe,
psTex, /* dest */
0, 0, /* destx/y */
psRead,
srcx, srcy, width, height);
} else {
util_surface_copy(pipe, FALSE,
psTex,
0, 0,
psRead,
srcx, srcy, width, height);
}
pipe_surface_reference(&psRead, NULL);
pipe_surface_reference(&psTex, NULL);
}

View File

@@ -49,6 +49,7 @@
#include "st_public.h"
#include "st_texture.h"
#include "util/u_rect.h"
/**
@@ -538,10 +539,17 @@ copy_back_to_front(struct st_context *st,
(void) st_get_framebuffer_surface(stfb, backIndex, &surf_back);
if (surf_front && surf_back) {
if (st->pipe->surface_copy) {
st->pipe->surface_copy(st->pipe,
surf_front, 0, 0, /* dest */
surf_back, 0, 0, /* src */
fb->Width, fb->Height);
} else {
util_surface_copy(st->pipe, FALSE,
surf_front, 0, 0,
surf_back, 0, 0,
fb->Width, fb->Height);
}
}
}

View File

@@ -1546,7 +1546,8 @@ st_copy_texsubimage(GLcontext *ctx,
if (ctx->_ImageTransferState == 0x0) {
if (matching_base_formats &&
if (pipe->surface_copy &&
matching_base_formats &&
src_format == dest_format &&
!do_flip)
{