Module: Mesa Branch: gallium-resources Commit: f3e98fd47f36804d019a684d49ff230df3ab0cf5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f3e98fd47f36804d019a684d49ff230df3ab0cf5
Author: Keith Whitwell <[email protected]> Date: Sun Mar 14 09:25:46 2010 +0000 st/vega: convert to pipe_resource --- src/gallium/state_trackers/vega/api_filters.c | 28 ++++++------ src/gallium/state_trackers/vega/api_images.c | 8 ++-- src/gallium/state_trackers/vega/api_masks.c | 7 ++- src/gallium/state_trackers/vega/image.c | 28 ++++++------ src/gallium/state_trackers/vega/image.h | 6 +- src/gallium/state_trackers/vega/mask.c | 26 +++++----- src/gallium/state_trackers/vega/mask.h | 4 +- src/gallium/state_trackers/vega/paint.c | 26 +++++----- src/gallium/state_trackers/vega/paint.h | 4 +- src/gallium/state_trackers/vega/polygon.c | 9 ++-- src/gallium/state_trackers/vega/renderer.c | 49 ++++++++++--------- src/gallium/state_trackers/vega/renderer.h | 10 ++-- src/gallium/state_trackers/vega/shader.c | 13 +++-- src/gallium/state_trackers/vega/st_inlines.h | 63 ++++++------------------- src/gallium/state_trackers/vega/vg_context.c | 12 ++-- src/gallium/state_trackers/vega/vg_context.h | 14 +++--- src/gallium/state_trackers/vega/vg_tracker.c | 22 ++++---- src/gallium/state_trackers/vega/vg_tracker.h | 2 +- 18 files changed, 151 insertions(+), 180 deletions(-) diff --git a/src/gallium/state_trackers/vega/api_filters.c b/src/gallium/state_trackers/vega/api_filters.c index b1bd297..01c9896 100644 --- a/src/gallium/state_trackers/vega/api_filters.c +++ b/src/gallium/state_trackers/vega/api_filters.c @@ -53,17 +53,17 @@ struct filter_info { const void *const_buffer; VGint const_buffer_len; VGTilingMode tiling_mode; - struct pipe_texture *extra_texture; + struct pipe_resource *extra_texture; }; -static INLINE struct pipe_texture *create_texture_1d(struct vg_context *ctx, +static INLINE struct pipe_resource *create_texture_1d(struct vg_context *ctx, const VGuint *color_data, const VGint color_data_len) { struct pipe_context *pipe = ctx->pipe; struct pipe_screen *screen = pipe->screen; - struct pipe_texture *tex = 0; - struct pipe_texture templ; + struct pipe_resource *tex = 0; + struct pipe_resource templ; memset(&templ, 0, sizeof(templ)); templ.target = PIPE_TEXTURE_1D; @@ -74,18 +74,18 @@ static INLINE struct pipe_texture *create_texture_1d(struct vg_context *ctx, templ.depth0 = 1; templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER; - tex = screen->texture_create(screen, &templ); + tex = screen->resource_create(screen, &templ); { /* upload color_data */ struct pipe_transfer *transfer = - pipe->get_transfer(pipe, tex, + pipe_get_transfer(pipe, tex, 0, 0, 0, PIPE_TRANSFER_READ_WRITE , 0, 0, tex->width0, tex->height0); void *map = pipe->transfer_map(pipe, transfer); memcpy(map, color_data, sizeof(VGint)*color_data_len); pipe->transfer_unmap(pipe, transfer); - pipe->tex_transfer_destroy(pipe, transfer); + pipe->transfer_destroy(pipe, transfer); } return tex; @@ -147,11 +147,11 @@ static void setup_constant_buffer(struct vg_context *ctx, const void *buffer, VGint param_bytes) { struct pipe_context *pipe = ctx->pipe; - struct pipe_buffer **cbuf = &ctx->filter.buffer; + struct pipe_resource **cbuf = &ctx->filter.buffer; /* We always need to get a new buffer, to keep the drivers simple and * avoid gratuitous rendering synchronization. */ - pipe_buffer_reference(cbuf, NULL); + pipe_resource_reference(cbuf, NULL); *cbuf = pipe_buffer_create(pipe->screen, 16, PIPE_BUFFER_USAGE_CONSTANT, @@ -168,7 +168,7 @@ static void setup_constant_buffer(struct vg_context *ctx, const void *buffer, static void setup_samplers(struct vg_context *ctx, struct filter_info *info) { struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS]; - struct pipe_texture *textures[PIPE_MAX_SAMPLERS]; + struct pipe_resource *textures[PIPE_MAX_SAMPLERS]; struct pipe_sampler_state sampler[3]; int num_samplers = 0; int num_textures = 0; @@ -688,7 +688,7 @@ void vgLookup(VGImage dst, VGImage src, struct vg_image *d, *s; VGuint color_data[256]; VGint i; - struct pipe_texture *lut_texture; + struct pipe_resource *lut_texture; VGfloat buffer[4]; struct filter_info info; @@ -732,7 +732,7 @@ void vgLookup(VGImage dst, VGImage src, execute_filter(ctx, &info); - pipe_texture_reference(&lut_texture, NULL); + pipe_resource_reference(&lut_texture, NULL); } void vgLookupSingle(VGImage dst, VGImage src, @@ -743,7 +743,7 @@ void vgLookupSingle(VGImage dst, VGImage src, { struct vg_context *ctx = vg_current_context(); struct vg_image *d, *s; - struct pipe_texture *lut_texture; + struct pipe_resource *lut_texture; VGfloat buffer[4]; struct filter_info info; VGuint color_data[256]; @@ -801,5 +801,5 @@ void vgLookupSingle(VGImage dst, VGImage src, execute_filter(ctx, &info); - pipe_texture_reference(&lut_texture, NULL); + pipe_resource_reference(&lut_texture, NULL); } diff --git a/src/gallium/state_trackers/vega/api_images.c b/src/gallium/state_trackers/vega/api_images.c index 3765f15..6c7fd3b 100644 --- a/src/gallium/state_trackers/vega/api_images.c +++ b/src/gallium/state_trackers/vega/api_images.c @@ -441,9 +441,9 @@ void vgReadPixels(void * data, VGint dataStride, { struct pipe_transfer *transfer; - transfer = pipe->get_transfer(pipe, strb->texture, 0, 0, 0, - PIPE_TRANSFER_READ, - 0, 0, width, height); + transfer = pipe_get_transfer(pipe, strb->texture, 0, 0, 0, + PIPE_TRANSFER_READ, + 0, 0, width, height); /* Do a row at a time to flip image data vertically */ for (i = 0; i < height; i++) { @@ -457,7 +457,7 @@ void vgReadPixels(void * data, VGint dataStride, dst += dataStride; } - pipe->tex_transfer_destroy(pipe, transfer); + pipe->transfer_destroy(pipe, transfer); } } diff --git a/src/gallium/state_trackers/vega/api_masks.c b/src/gallium/state_trackers/vega/api_masks.c index 7eb5ea1..9796bca 100644 --- a/src/gallium/state_trackers/vega/api_masks.c +++ b/src/gallium/state_trackers/vega/api_masks.c @@ -51,7 +51,7 @@ draw_clear_quad(struct vg_context *st, const VGfloat color[4]) { struct pipe_context *pipe = st->pipe; - struct pipe_buffer *buf; + struct pipe_resource *buf; VGuint i; /* positions */ @@ -81,7 +81,8 @@ draw_clear_quad(struct vg_context *st, /* put vertex data into vbuf */ buf = pipe_user_buffer_create(pipe->screen, st->clear.vertices, - sizeof(st->clear.vertices)); + sizeof(st->clear.vertices), + PIPE_BUFFER_USAGE_VERTEX); /* draw */ @@ -93,7 +94,7 @@ draw_clear_quad(struct vg_context *st, 4, /* verts */ 2); /* attribs/vert */ - pipe_buffer_reference(&buf, NULL); + pipe_resource_reference(&buf, NULL); } } diff --git a/src/gallium/state_trackers/vega/image.c b/src/gallium/state_trackers/vega/image.c index bf86533..2f55d80 100644 --- a/src/gallium/state_trackers/vega/image.c +++ b/src/gallium/state_trackers/vega/image.c @@ -80,8 +80,8 @@ static INLINE void vg_sync_size(VGfloat *src_loc, VGfloat *dst_loc) static void vg_copy_texture(struct vg_context *ctx, - struct pipe_texture *dst, VGint dx, VGint dy, - struct pipe_texture *src, VGint sx, VGint sy, + struct pipe_resource *dst, VGint dx, VGint dy, + struct pipe_resource *src, VGint sx, VGint sy, VGint width, VGint height) { VGfloat dst_loc[4], src_loc[4]; @@ -216,9 +216,9 @@ void vg_copy_surface(struct vg_context *ctx, } -static struct pipe_texture *image_texture(struct vg_image *img) +static struct pipe_resource *image_texture(struct vg_image *img) { - struct pipe_texture *tex = img->texture; + struct pipe_resource *tex = img->texture; return tex; } @@ -249,7 +249,7 @@ struct vg_image * image_create(VGImageFormat format, struct vg_context *ctx = vg_current_context(); struct vg_image *image = CALLOC_STRUCT(vg_image); enum pipe_format pformat = vg_format_to_pipe(format); - struct pipe_texture pt, *newtex; + struct pipe_resource pt, *newtex; struct pipe_screen *screen = ctx->pipe->screen; vg_init_object(&image->base, ctx, VG_OBJECT_IMAGE); @@ -277,7 +277,7 @@ struct vg_image * image_create(VGImageFormat format, pt.depth0 = 1; pt.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER; - newtex = screen->texture_create(screen, &pt); + newtex = screen->resource_create(screen, &pt); debug_assert(newtex); @@ -345,7 +345,7 @@ void image_destroy(struct vg_image *img) array_destroy(img->children_array); } - pipe_texture_reference(&img->texture, NULL); + pipe_resource_reference(&img->texture, NULL); free(img); } @@ -379,7 +379,7 @@ void image_sub_data(struct vg_image *image, VGint i; struct vg_context *ctx = vg_current_context(); struct pipe_context *pipe = ctx->pipe; - struct pipe_texture *texture = image_texture(image); + struct pipe_resource *texture = image_texture(image); VGint xoffset = 0, yoffset = 0; if (x < 0) { @@ -412,7 +412,7 @@ void image_sub_data(struct vg_image *image, } { /* upload color_data */ - struct pipe_transfer *transfer = pipe->get_transfer( + struct pipe_transfer *transfer = pipe_get_transfer( pipe, texture, 0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0, texture->width0, texture->height0); src += (dataStride * yoffset); @@ -422,7 +422,7 @@ void image_sub_data(struct vg_image *image, y += yStep; src += dataStride; } - pipe->tex_transfer_destroy(pipe, transfer); + pipe->transfer_destroy(pipe, transfer); } } @@ -443,7 +443,7 @@ void image_get_sub_data(struct vg_image * image, { struct pipe_transfer *transfer = - pipe->get_transfer(pipe, + pipe_get_transfer(pipe, image->texture, 0, 0, 0, PIPE_TRANSFER_READ, 0, 0, @@ -460,7 +460,7 @@ void image_get_sub_data(struct vg_image * image, dst += dataStride; } - pipe->tex_transfer_destroy(pipe, transfer); + pipe->transfer_destroy(pipe, transfer); } } @@ -479,7 +479,7 @@ struct vg_image * image_child_image(struct vg_image *parent, image->height = height; image->parent = parent; image->texture = 0; - pipe_texture_reference(&image->texture, + pipe_resource_reference(&image->texture, parent->texture); image->sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE; @@ -624,7 +624,7 @@ VGboolean vg_image_overlaps(struct vg_image *dst, } VGint image_bind_samplers(struct vg_image *img, struct pipe_sampler_state **samplers, - struct pipe_texture **textures) + struct pipe_resource **textures) { img->sampler.min_img_filter = image_sampler_filter(img->base.ctx); img->sampler.mag_img_filter = image_sampler_filter(img->base.ctx); diff --git a/src/gallium/state_trackers/vega/image.h b/src/gallium/state_trackers/vega/image.h index 78e17cf..8dcaf13 100644 --- a/src/gallium/state_trackers/vega/image.h +++ b/src/gallium/state_trackers/vega/image.h @@ -30,7 +30,7 @@ #include "vg_context.h" #include "pipe/p_state.h" -struct pipe_texture; +struct pipe_resource; struct array; struct vg_context; struct pipe_surface; @@ -43,7 +43,7 @@ struct vg_image { struct vg_image *parent; - struct pipe_texture *texture; + struct pipe_resource *texture; struct pipe_sampler_state sampler; struct array *children_array; @@ -89,7 +89,7 @@ void image_get_pixels(struct vg_image *dst, VGint dx, VGint dy, VGint width, VGint height); VGint image_bind_samplers(struct vg_image *dst, struct pipe_sampler_state **samplers, - struct pipe_texture **textures); + struct pipe_resource **textures); VGboolean vg_image_overlaps(struct vg_image *dst, struct vg_image *src); diff --git a/src/gallium/state_trackers/vega/mask.c b/src/gallium/state_trackers/vega/mask.c index 839dc19..379e46b 100644 --- a/src/gallium/state_trackers/vega/mask.c +++ b/src/gallium/state_trackers/vega/mask.c @@ -45,7 +45,7 @@ struct vg_mask_layer { VGint width; VGint height; - struct pipe_texture *texture; + struct pipe_resource *texture; }; static INLINE struct pipe_surface * @@ -217,7 +217,7 @@ static void setup_mask_framebuffer(struct pipe_surface *surf, static void setup_mask_operation(VGMaskOperation operation) { struct vg_context *ctx = vg_current_context(); - struct pipe_buffer **cbuf = &ctx->mask.cbuf; + struct pipe_resource **cbuf = &ctx->mask.cbuf; const VGint param_bytes = 4 * sizeof(VGfloat); const VGfloat ones[4] = {1.f, 1.f, 1.f, 1.f}; void *shader = 0; @@ -225,7 +225,7 @@ static void setup_mask_operation(VGMaskOperation operation) /* We always need to get a new buffer, to keep the drivers simple and * avoid gratuitous rendering synchronization. */ - pipe_buffer_reference(cbuf, NULL); + pipe_resource_reference(cbuf, NULL); *cbuf = pipe_buffer_create(ctx->pipe->screen, 1, PIPE_BUFFER_USAGE_CONSTANT, @@ -284,13 +284,13 @@ static void setup_mask_operation(VGMaskOperation operation) cso_set_fragment_shader_handle(ctx->cso_context, shader); } -static void setup_mask_samplers(struct pipe_texture *umask) +static void setup_mask_samplers(struct pipe_resource *umask) { struct vg_context *ctx = vg_current_context(); struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS]; - struct pipe_texture *textures[PIPE_MAX_SAMPLERS]; + struct pipe_resource *textures[PIPE_MAX_SAMPLERS]; struct st_framebuffer *fb_buffers = ctx->draw_buffer; - struct pipe_texture *uprev = NULL; + struct pipe_resource *uprev = NULL; struct pipe_sampler_state sampler; uprev = fb_buffers->blend_texture; @@ -320,13 +320,13 @@ static void setup_mask_samplers(struct pipe_texture *umask) static void setup_mask_fill(const VGfloat color[4]) { struct vg_context *ctx = vg_current_context(); - struct pipe_buffer **cbuf = &ctx->mask.cbuf; + struct pipe_resource **cbuf = &ctx->mask.cbuf; const VGint param_bytes = 4 * sizeof(VGfloat); /* We always need to get a new buffer, to keep the drivers simple and * avoid gratuitous rendering synchronization. */ - pipe_buffer_reference(cbuf, NULL); + pipe_resource_reference(cbuf, NULL); *cbuf = pipe_buffer_create(ctx->pipe->screen, 1, PIPE_BUFFER_USAGE_CONSTANT, @@ -411,7 +411,7 @@ static void surface_fill(struct pipe_surface *surf, } -static void mask_using_texture(struct pipe_texture *texture, +static void mask_using_texture(struct pipe_resource *texture, VGMaskOperation operation, VGint x, VGint y, VGint width, VGint height) @@ -483,7 +483,7 @@ struct vg_mask_layer * mask_layer_create(VGint width, VGint height) mask->height = height; { - struct pipe_texture pt; + struct pipe_resource pt; struct pipe_screen *screen = ctx->pipe->screen; memset(&pt, 0, sizeof(pt)); @@ -496,7 +496,7 @@ struct vg_mask_layer * mask_layer_create(VGint width, VGint height) pt.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER; pt.compressed = 0; - mask->texture = screen->texture_create(screen, &pt); + mask->texture = screen->resource_create(screen, &pt); } vg_context_add_object(ctx, VG_OBJECT_MASK, mask); @@ -509,7 +509,7 @@ void mask_layer_destroy(struct vg_mask_layer *layer) struct vg_context *ctx = vg_current_context(); vg_context_remove_object(ctx, VG_OBJECT_MASK, layer); - pipe_texture_release(&layer->texture); + pipe_resource_release(&layer->texture); free(layer); } @@ -672,7 +672,7 @@ void mask_fill(VGint x, VGint y, VGint width, VGint height, } VGint mask_bind_samplers(struct pipe_sampler_state **samplers, - struct pipe_texture **textures) + struct pipe_resource **textures) { struct vg_context *ctx = vg_current_context(); diff --git a/src/gallium/state_trackers/vega/mask.h b/src/gallium/state_trackers/vega/mask.h index 5eaaede..1489257 100644 --- a/src/gallium/state_trackers/vega/mask.h +++ b/src/gallium/state_trackers/vega/mask.h @@ -31,7 +31,7 @@ struct path; struct vg_image; -struct pipe_texture; +struct pipe_resource; struct vg_mask_layer *mask_layer_create(VGint width, VGint height); void mask_layer_destroy(struct vg_mask_layer *layer); @@ -63,6 +63,6 @@ void mask_fill(VGint x, VGint y, VGfloat value); VGint mask_bind_samplers(struct pipe_sampler_state **samplers, - struct pipe_texture **textures); + struct pipe_resource **textures); #endif diff --git a/src/gallium/state_trackers/vega/paint.c b/src/gallium/state_trackers/vega/paint.c index 1bf0227..5c1482c 100644 --- a/src/gallium/state_trackers/vega/paint.c +++ b/src/gallium/state_trackers/vega/paint.c @@ -61,7 +61,7 @@ struct vg_paint { VGfloat vals[5]; VGint valsi[5]; } radial; - struct pipe_texture *texture; + struct pipe_resource *texture; struct pipe_sampler_state sampler; VGfloat *ramp_stops; @@ -72,13 +72,13 @@ struct vg_paint { } gradient; struct { - struct pipe_texture *texture; + struct pipe_resource *texture; VGTilingMode tiling_mode; struct pipe_sampler_state sampler; } pattern; /* XXX next 3 all unneded? */ - struct pipe_buffer *cbuf; + struct pipe_resource *cbuf; struct pipe_shader_state fs_state; void *fs; }; @@ -142,12 +142,12 @@ static INLINE void create_gradient_data(const VGfloat *ramp_stops, data[size-1] = last_color; } -static INLINE struct pipe_texture *create_gradient_texture(struct vg_paint *p) +static INLINE struct pipe_resource *create_gradient_texture(struct vg_paint *p) { struct pipe_context *pipe = p->base.ctx->pipe; struct pipe_screen *screen = pipe->screen; - struct pipe_texture *tex = 0; - struct pipe_texture templ; + struct pipe_resource *tex = 0; + struct pipe_resource templ; memset(&templ, 0, sizeof(templ)); templ.target = PIPE_TEXTURE_1D; @@ -158,7 +158,7 @@ static INLINE struct pipe_texture *create_gradient_texture(struct vg_paint *p) templ.depth0 = 1; templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER; - tex = screen->texture_create(screen, &templ); + tex = screen->resource_create(screen, &templ); { /* upload color_data */ struct pipe_transfer *transfer = @@ -167,7 +167,7 @@ static INLINE struct pipe_texture *create_gradient_texture(struct vg_paint *p) void *map = pipe->transfer_map(pipe, transfer); memcpy(map, p->gradient.color_data, sizeof(VGint)*1024); pipe->transfer_unmap(pipe, transfer); - pipe->tex_transfer_destroy(pipe, transfer); + pipe->transfer_destroy(pipe, transfer); } return tex; @@ -208,7 +208,7 @@ void paint_destroy(struct vg_paint *paint) { struct vg_context *ctx = paint->base.ctx; if (paint->pattern.texture) - pipe_texture_reference(&paint->pattern.texture, NULL); + pipe_resource_reference(&paint->pattern.texture, NULL); if (ctx) vg_context_remove_object(ctx, VG_OBJECT_PAINT, paint); @@ -395,7 +395,7 @@ void paint_set_ramp_stops(struct vg_paint *paint, const VGfloat *stops, 1024); if (paint->gradient.texture) { - pipe_texture_reference(&paint->gradient.texture, NULL); + pipe_resource_reference(&paint->gradient.texture, NULL); paint->gradient.texture = 0; } @@ -460,10 +460,10 @@ void paint_set_pattern(struct vg_paint *paint, struct vg_image *img) { if (paint->pattern.texture) - pipe_texture_reference(&paint->pattern.texture, NULL); + pipe_resource_reference(&paint->pattern.texture, NULL); paint->pattern.texture = 0; - pipe_texture_reference(&paint->pattern.texture, + pipe_resource_reference(&paint->pattern.texture, img->texture); } @@ -611,7 +611,7 @@ VGTilingMode paint_pattern_tiling(struct vg_paint *paint) } VGint paint_bind_samplers(struct vg_paint *paint, struct pipe_sampler_state **samplers, - struct pipe_texture **textures) + struct pipe_resource **textures) { struct vg_context *ctx = vg_current_context(); diff --git a/src/gallium/state_trackers/vega/paint.h b/src/gallium/state_trackers/vega/paint.h index 999b5c1..cf9a701 100644 --- a/src/gallium/state_trackers/vega/paint.h +++ b/src/gallium/state_trackers/vega/paint.h @@ -35,7 +35,7 @@ struct vg_paint; struct vg_image; struct pipe_sampler_state; -struct pipe_texture; +struct pipe_resource; struct vg_paint *paint_create(struct vg_context *ctx); void paint_destroy(struct vg_paint *paint); @@ -108,7 +108,7 @@ VGboolean paint_color_ramp_premultiplied(struct vg_paint *paint); VGint paint_bind_samplers(struct vg_paint *paint, struct pipe_sampler_state **samplers, - struct pipe_texture **textures); + struct pipe_resource **textures); VGint paint_constant_buffer_size(struct vg_paint *paint); void paint_fill_constant_buffer(struct vg_paint *paint, diff --git a/src/gallium/state_trackers/vega/polygon.c b/src/gallium/state_trackers/vega/polygon.c index eef2c1e..ecfe7aa 100644 --- a/src/gallium/state_trackers/vega/polygon.c +++ b/src/gallium/state_trackers/vega/polygon.c @@ -58,7 +58,7 @@ struct polygon VGint num_verts; VGboolean dirty; - struct pipe_buffer *vbuf; + struct pipe_resource *vbuf; struct pipe_screen *screen; }; @@ -110,7 +110,7 @@ struct polygon * polygon_create_from_data(float *data, int size) void polygon_destroy(struct polygon *poly) { if (poly->vbuf) - pipe_buffer_reference(&poly->vbuf, NULL); + pipe_resource_reference(&poly->vbuf, NULL); free(poly->data); free(poly); @@ -272,13 +272,14 @@ static void draw_polygon(struct vg_context *ctx, if (poly->vbuf == NULL || poly->dirty) { if (poly->vbuf) { - pipe_buffer_reference(&poly->vbuf, + pipe_resource_reference(&poly->vbuf, NULL); } poly->screen = pipe->screen; poly->vbuf= pipe_user_buffer_create(poly->screen, poly->data, - vert_size); + vert_size, + PIPE_BUFFER_USAGE_VERTEX); poly->dirty = VG_FALSE; } diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c index 47e8b47..415dd5e 100644 --- a/src/gallium/state_trackers/vega/renderer.c +++ b/src/gallium/state_trackers/vega/renderer.c @@ -60,7 +60,7 @@ static void setup_shaders(struct renderer *ctx) ctx->fs = util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D); } -static struct pipe_buffer * +static struct pipe_resource * setup_vertex_data(struct renderer *ctx, float x0, float y0, float x1, float y1, float z) { @@ -90,10 +90,11 @@ setup_vertex_data(struct renderer *ctx, return pipe_user_buffer_create( ctx->pipe->screen, ctx->vertices, - sizeof(ctx->vertices) ); + sizeof(ctx->vertices), + PIPE_BUFFER_USAGE_VERTEX); } -static struct pipe_buffer * +static struct pipe_resource * setup_vertex_data_tex(struct renderer *ctx, float x0, float y0, float x1, float y1, float s0, float t0, float s1, float t1, @@ -125,11 +126,12 @@ setup_vertex_data_tex(struct renderer *ctx, return pipe_user_buffer_create( ctx->pipe->screen, ctx->vertices, - sizeof(ctx->vertices) ); + sizeof(ctx->vertices), + PIPE_BUFFER_USAGE_VERTEX); } -static struct pipe_buffer * +static struct pipe_resource * setup_vertex_data_qtex(struct renderer *ctx, float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, @@ -162,7 +164,8 @@ setup_vertex_data_qtex(struct renderer *ctx, return pipe_user_buffer_create( ctx->pipe->screen, ctx->vertices, - sizeof(ctx->vertices) ); + sizeof(ctx->vertices), + PIPE_BUFFER_USAGE_VERTEX); } struct renderer * renderer_create(struct vg_context *owner) @@ -205,7 +208,7 @@ void renderer_draw_quad(struct renderer *r, VGfloat x2, VGfloat y2, VGfloat depth) { - struct pipe_buffer *buf; + struct pipe_resource *buf; buf = setup_vertex_data(r, x1, y1, x2, y2, depth); @@ -216,20 +219,20 @@ void renderer_draw_quad(struct renderer *r, 4, /* verts */ 2); /* attribs/vert */ - pipe_buffer_reference( &buf, + pipe_resource_reference( &buf, NULL ); } } void renderer_draw_texture(struct renderer *r, - struct pipe_texture *tex, + struct pipe_resource *tex, VGfloat x1offset, VGfloat y1offset, VGfloat x2offset, VGfloat y2offset, VGfloat x1, VGfloat y1, VGfloat x2, VGfloat y2) { struct pipe_context *pipe = r->pipe; - struct pipe_buffer *buf; + struct pipe_resource *buf; VGfloat s0, t0, s1, t1; assert(tex->width0 != 0); @@ -255,7 +258,7 @@ void renderer_draw_texture(struct renderer *r, 4, /* verts */ 2); /* attribs/vert */ - pipe_buffer_reference( &buf, + pipe_resource_reference( &buf, NULL ); } @@ -263,16 +266,16 @@ void renderer_draw_texture(struct renderer *r, } void renderer_copy_texture(struct renderer *ctx, - struct pipe_texture *src, + struct pipe_resource *src, VGfloat sx1, VGfloat sy1, VGfloat sx2, VGfloat sy2, - struct pipe_texture *dst, + struct pipe_resource *dst, VGfloat dx1, VGfloat dy1, VGfloat dx2, VGfloat dy2) { struct pipe_context *pipe = ctx->pipe; struct pipe_screen *screen = pipe->screen; - struct pipe_buffer *buf; + struct pipe_resource *buf; struct pipe_surface *dst_surf = screen->get_tex_surface( screen, dst, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); @@ -378,7 +381,7 @@ void renderer_copy_texture(struct renderer *ctx, 4, /* verts */ 2); /* attribs/vert */ - pipe_buffer_reference( &buf, + pipe_resource_reference( &buf, NULL ); } @@ -405,8 +408,8 @@ void renderer_copy_surface(struct renderer *ctx, { struct pipe_context *pipe = ctx->pipe; struct pipe_screen *screen = pipe->screen; - struct pipe_buffer *buf; - struct pipe_texture texTemp, *tex; + struct pipe_resource *buf; + struct pipe_resource texTemp, *tex; struct pipe_surface *texSurf; struct pipe_framebuffer_state fb; struct st_framebuffer *stfb = ctx->owner->draw_buffer; @@ -453,7 +456,7 @@ void renderer_copy_surface(struct renderer *ctx, texTemp.height0 = srcH; texTemp.depth0 = 1; - tex = screen->texture_create(screen, &texTemp); + tex = screen->resource_create(screen, &texTemp); if (!tex) return; @@ -544,7 +547,7 @@ void renderer_copy_surface(struct renderer *ctx, 4, /* verts */ 2); /* attribs/vert */ - pipe_buffer_reference( &buf, + pipe_resource_reference( &buf, NULL ); } @@ -558,11 +561,11 @@ void renderer_copy_surface(struct renderer *ctx, cso_restore_vertex_shader(ctx->cso); cso_restore_viewport(ctx->cso); - pipe_texture_reference(&tex, NULL); + pipe_resource_reference(&tex, NULL); } void renderer_texture_quad(struct renderer *r, - struct pipe_texture *tex, + struct pipe_resource *tex, VGfloat x1offset, VGfloat y1offset, VGfloat x2offset, VGfloat y2offset, VGfloat x1, VGfloat y1, @@ -571,7 +574,7 @@ void renderer_texture_quad(struct renderer *r, VGfloat x4, VGfloat y4) { struct pipe_context *pipe = r->pipe; - struct pipe_buffer *buf; + struct pipe_resource *buf; VGfloat s0, t0, s1, t1; assert(tex->width0 != 0); @@ -597,7 +600,7 @@ void renderer_texture_quad(struct renderer *r, 4, /* verts */ 2); /* attribs/vert */ - pipe_buffer_reference(&buf, + pipe_resource_reference(&buf, NULL); } diff --git a/src/gallium/state_trackers/vega/renderer.h b/src/gallium/state_trackers/vega/renderer.h index 990cd32..6afb309 100644 --- a/src/gallium/state_trackers/vega/renderer.h +++ b/src/gallium/state_trackers/vega/renderer.h @@ -32,7 +32,7 @@ struct renderer; struct vg_context; -struct pipe_texture; +struct pipe_resource; struct pipe_surface; struct renderer *renderer_create(struct vg_context *owner); @@ -43,13 +43,13 @@ void renderer_draw_quad(struct renderer *, VGfloat x2, VGfloat y2, VGfloat depth); void renderer_draw_texture(struct renderer *, - struct pipe_texture *texture, + struct pipe_resource *texture, VGfloat x1offset, VGfloat y1offset, VGfloat x2offset, VGfloat y2offset, VGfloat x1, VGfloat y1, VGfloat x2, VGfloat y2); void renderer_texture_quad(struct renderer *, - struct pipe_texture *texture, + struct pipe_resource *texture, VGfloat x1offset, VGfloat y1offset, VGfloat x2offset, VGfloat y2offset, VGfloat x1, VGfloat y1, @@ -57,10 +57,10 @@ void renderer_texture_quad(struct renderer *, VGfloat x3, VGfloat y3, VGfloat x4, VGfloat y4); void renderer_copy_texture(struct renderer *r, - struct pipe_texture *src, + struct pipe_resource *src, VGfloat sx1, VGfloat sy1, VGfloat sx2, VGfloat sy2, - struct pipe_texture *dst, + struct pipe_resource *dst, VGfloat dx1, VGfloat dy1, VGfloat dx2, VGfloat dy2); void renderer_copy_surface(struct renderer *r, diff --git a/src/gallium/state_trackers/vega/shader.c b/src/gallium/state_trackers/vega/shader.c index 0e71a50..e1a3676 100644 --- a/src/gallium/state_trackers/vega/shader.c +++ b/src/gallium/state_trackers/vega/shader.c @@ -51,7 +51,7 @@ struct shader { VGImageMode image_mode; float constants[MAX_CONSTANTS]; - struct pipe_buffer *cbuf; + struct pipe_resource *cbuf; struct pipe_shader_state fs_state; void *fs; }; @@ -96,7 +96,7 @@ static void setup_constant_buffer(struct shader *shader) { struct vg_context *ctx = shader->context; struct pipe_context *pipe = shader->context->pipe; - struct pipe_buffer **cbuf = &shader->cbuf; + struct pipe_resource **cbuf = &shader->cbuf; VGint param_bytes = paint_constant_buffer_size(shader->paint); float temp_buf[MAX_CONSTANTS]; @@ -106,12 +106,13 @@ static void setup_constant_buffer(struct shader *shader) if (*cbuf == NULL || memcmp(temp_buf, shader->constants, param_bytes) != 0) { - pipe_buffer_reference(cbuf, NULL); + pipe_resource_reference(cbuf, NULL); memcpy(shader->constants, temp_buf, param_bytes); *cbuf = pipe_user_buffer_create(pipe->screen, &shader->constants, - sizeof(shader->constants)); + sizeof(shader->constants), + PIPE_BUFFER_USAGE_VERTEX); } ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, *cbuf); @@ -119,7 +120,7 @@ static void setup_constant_buffer(struct shader *shader) static VGint blend_bind_samplers(struct vg_context *ctx, struct pipe_sampler_state **samplers, - struct pipe_texture **textures) + struct pipe_resource **textures) { VGBlendMode bmode = ctx->state.vg.blend_mode; @@ -151,7 +152,7 @@ static VGint blend_bind_samplers(struct vg_context *ctx, static void setup_samplers(struct shader *shader) { struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS]; - struct pipe_texture *textures[PIPE_MAX_SAMPLERS]; + struct pipe_resource *textures[PIPE_MAX_SAMPLERS]; struct vg_context *ctx = shader->context; /* a little wonky: we use the num as a boolean that just says * whether any sampler/textures have been set. the actual numbering diff --git a/src/gallium/state_trackers/vega/st_inlines.h b/src/gallium/state_trackers/vega/st_inlines.h index a35658d..7eaa67c 100644 --- a/src/gallium/state_trackers/vega/st_inlines.h +++ b/src/gallium/state_trackers/vega/st_inlines.h @@ -43,7 +43,7 @@ static INLINE struct pipe_transfer * st_cond_flush_get_transfer(struct vg_context *st, - struct pipe_texture *pt, + struct pipe_resource *pt, unsigned int face, unsigned int level, unsigned int zslice, @@ -52,20 +52,14 @@ st_cond_flush_get_transfer(struct vg_context *st, unsigned int w, unsigned int h) { struct pipe_context *pipe = st->pipe; - unsigned referenced = - pipe->is_texture_referenced(pipe, pt, face, level); - if (referenced && ((referenced & PIPE_REFERENCED_FOR_WRITE) || - (usage & PIPE_TRANSFER_WRITE))) - vgFlush(); - - return pipe->get_transfer(pipe, pt, face, level, zslice, usage, - x, y, w, h); + return pipe_get_transfer(pipe, pt, face, level, zslice, usage, + x, y, w, h); } static INLINE struct pipe_transfer * st_no_flush_get_transfer(struct vg_context *st, - struct pipe_texture *pt, + struct pipe_resource *pt, unsigned int face, unsigned int level, unsigned int zslice, @@ -75,82 +69,53 @@ st_no_flush_get_transfer(struct vg_context *st, { struct pipe_context *pipe = st->pipe; - return pipe->get_transfer(pipe, pt, face, level, - zslice, usage, x, y, w, h); -} - -static INLINE void * -st_cond_flush_pipe_buffer_map(struct vg_context *st, - struct pipe_buffer *buf, - unsigned int map_flags) -{ - struct pipe_context *pipe = st->pipe; - unsigned int referenced = pipe->is_buffer_referenced(pipe, buf); - - if (referenced && ((referenced & PIPE_REFERENCED_FOR_WRITE) || - (map_flags & PIPE_BUFFER_USAGE_CPU_WRITE))) - vgFlush(); - - return pipe_buffer_map(pipe->screen, buf, map_flags); -} - -static INLINE void * -st_no_flush_pipe_buffer_map(struct vg_context *st, - struct pipe_buffer *buf, - unsigned int map_flags) -{ - return pipe_buffer_map(st->pipe->screen, buf, map_flags); + return pipe_get_transfer(pipe, pt, face, level, + zslice, usage, x, y, w, h); } static INLINE void st_cond_flush_pipe_buffer_write(struct vg_context *st, - struct pipe_buffer *buf, + struct pipe_resource *buf, unsigned int offset, unsigned int size, const void * data) { struct pipe_context *pipe = st->pipe; - if (pipe->is_buffer_referenced(pipe, buf)) - vgFlush(); - - pipe_buffer_write(pipe->screen, buf, offset, size, data); + pipe_buffer_write(pipe, buf, offset, size, data); } static INLINE void st_no_flush_pipe_buffer_write(struct vg_context *st, - struct pipe_buffer *buf, + struct pipe_resource *buf, unsigned int offset, unsigned int size, const void * data) { - pipe_buffer_write(st->pipe->screen, buf, offset, size, data); + pipe_buffer_write(st->pipe, buf, offset, size, data); } static INLINE void st_cond_flush_pipe_buffer_read(struct vg_context *st, - struct pipe_buffer *buf, + struct pipe_resource *buf, unsigned int offset, unsigned int size, void * data) { struct pipe_context *pipe = st->pipe; - if (pipe->is_buffer_referenced(pipe, buf) & PIPE_REFERENCED_FOR_WRITE) - vgFlush(); - - pipe_buffer_read(pipe->screen, buf, offset, size, data); + pipe_buffer_read(pipe, buf, offset, size, data); } static INLINE void st_no_flush_pipe_buffer_read(struct vg_context *st, - struct pipe_buffer *buf, + struct pipe_resource *buf, unsigned int offset, unsigned int size, void * data) { - pipe_buffer_read(st->pipe->screen, buf, offset, size, data); + pipe_buffer_read(st->pipe, buf, offset, size, data); } #endif diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c index 170391e..49ddb34 100644 --- a/src/gallium/state_trackers/vega/vg_context.c +++ b/src/gallium/state_trackers/vega/vg_context.c @@ -130,8 +130,8 @@ struct vg_context * vg_create_context(struct pipe_context *pipe, void vg_destroy_context(struct vg_context *ctx) { - struct pipe_buffer **cbuf = &ctx->mask.cbuf; - struct pipe_buffer **vsbuf = &ctx->vs_const_buffer; + struct pipe_resource **cbuf = &ctx->mask.cbuf; + struct pipe_resource **vsbuf = &ctx->vs_const_buffer; util_destroy_blit(ctx->blit); renderer_destroy(ctx->renderer); @@ -140,10 +140,10 @@ void vg_destroy_context(struct vg_context *ctx) paint_destroy(ctx->default_paint); if (*cbuf) - pipe_buffer_reference(cbuf, NULL); + pipe_resource_reference(cbuf, NULL); if (*vsbuf) - pipe_buffer_reference(vsbuf, NULL); + pipe_resource_reference(vsbuf, NULL); if (ctx->clear.fs) { cso_delete_fragment_shader(ctx->cso_context, ctx->clear.fs); @@ -377,11 +377,11 @@ void vg_validate_state(struct vg_context *ctx) 2.f/fb->width, 2.f/fb->height, 1, 1, -1, -1, 0, 0 }; - struct pipe_buffer **cbuf = &ctx->vs_const_buffer; + struct pipe_resource **cbuf = &ctx->vs_const_buffer; vg_set_viewport(ctx, VEGA_Y0_BOTTOM); - pipe_buffer_reference(cbuf, NULL); + pipe_resource_reference(cbuf, NULL); *cbuf = pipe_buffer_create(ctx->pipe->screen, 16, PIPE_BUFFER_USAGE_CONSTANT, param_bytes); diff --git a/src/gallium/state_trackers/vega/vg_context.h b/src/gallium/state_trackers/vega/vg_context.h index 804e9e7..361c962 100644 --- a/src/gallium/state_trackers/vega/vg_context.h +++ b/src/gallium/state_trackers/vega/vg_context.h @@ -45,7 +45,7 @@ struct vg_shader; struct st_renderbuffer { enum pipe_format format; struct pipe_surface *surface; - struct pipe_texture *texture; + struct pipe_resource *texture; VGint width, height; }; @@ -54,9 +54,9 @@ struct st_framebuffer { struct st_renderbuffer *strb; struct st_renderbuffer *dsrb; - struct pipe_texture *alpha_mask; + struct pipe_resource *alpha_mask; - struct pipe_texture *blend_texture; + struct pipe_resource *blend_texture; void *privateData; }; @@ -113,7 +113,7 @@ struct vg_context } clear; struct { - struct pipe_buffer *cbuf; + struct pipe_resource *cbuf; struct pipe_sampler_state sampler; struct vg_shader *union_fs; @@ -126,7 +126,7 @@ struct vg_context struct cso_context *cso_context; - struct pipe_buffer *stencil_quad; + struct pipe_resource *stencil_quad; VGfloat stencil_vertices[4][2][4]; struct renderer *renderer; @@ -135,7 +135,7 @@ struct vg_context struct pipe_sampler_state blend_sampler; struct { - struct pipe_buffer *buffer; + struct pipe_resource *buffer; void *color_matrix_fs; } filter; struct vg_paint *default_paint; @@ -145,7 +145,7 @@ struct vg_context struct vg_shader *plain_vs; struct vg_shader *clear_vs; struct vg_shader *texture_vs; - struct pipe_buffer *vs_const_buffer; + struct pipe_resource *vs_const_buffer; struct pipe_vertex_element velems[2]; }; diff --git a/src/gallium/state_trackers/vega/vg_tracker.c b/src/gallium/state_trackers/vega/vg_tracker.c index ea5c2ce..4e59216 100644 --- a/src/gallium/state_trackers/vega/vg_tracker.c +++ b/src/gallium/state_trackers/vega/vg_tracker.c @@ -39,11 +39,11 @@ /* advertise OpenVG support */ PUBLIC const int st_api_OpenVG = 1; -static struct pipe_texture * +static struct pipe_resource * create_texture(struct pipe_context *pipe, enum pipe_format format, VGint width, VGint height) { - struct pipe_texture templ; + struct pipe_resource templ; memset(&templ, 0, sizeof(templ)); @@ -68,7 +68,7 @@ create_texture(struct pipe_context *pipe, enum pipe_format format, PIPE_TEXTURE_USAGE_SAMPLER); } - return pipe->screen->texture_create(pipe->screen, &templ); + return pipe->screen->resource_create(pipe->screen, &templ); } /** @@ -107,7 +107,7 @@ st_renderbuffer_alloc_storage(struct vg_context * ctx, /* Free the old surface and texture */ pipe_surface_reference(&strb->surface, NULL); - pipe_texture_reference(&strb->texture, NULL); + pipe_resource_reference(&strb->texture, NULL); /* Probably need dedicated flags for surface usage too: @@ -206,7 +206,7 @@ static void setup_new_alpha_mask(struct vg_context *ctx, uint width, uint height) { struct pipe_context *pipe = ctx->pipe; - struct pipe_texture *old_texture = stfb->alpha_mask; + struct pipe_resource *old_texture = stfb->alpha_mask; /* we use PIPE_FORMAT_B8G8R8A8_UNORM because we want to render to @@ -218,7 +218,7 @@ static void setup_new_alpha_mask(struct vg_context *ctx, if (!stfb->alpha_mask) { if (old_texture) - pipe_texture_reference(&old_texture, NULL); + pipe_resource_reference(&old_texture, NULL); return; } @@ -265,7 +265,7 @@ static void setup_new_alpha_mask(struct vg_context *ctx, /* Free the old texture */ if (old_texture) - pipe_texture_reference(&old_texture, NULL); + pipe_resource_reference(&old_texture, NULL); } void st_resize_framebuffer(struct st_framebuffer *stfb, @@ -326,7 +326,7 @@ void st_resize_framebuffer(struct st_framebuffer *stfb, setup_new_alpha_mask(ctx, stfb, width, height); - pipe_texture_reference( &stfb->blend_texture, NULL ); + pipe_resource_reference( &stfb->blend_texture, NULL ); stfb->blend_texture = create_texture(ctx->pipe, PIPE_FORMAT_B8G8R8A8_UNORM, width, height); } @@ -338,11 +338,11 @@ void st_set_framebuffer_surface(struct st_framebuffer *stfb, /* unreference existing surfaces */ pipe_surface_reference( &rb->surface, NULL ); - pipe_texture_reference( &rb->texture, NULL ); + pipe_resource_reference( &rb->texture, NULL ); /* reference new ones */ pipe_surface_reference( &rb->surface, surf ); - pipe_texture_reference( &rb->texture, surf->texture ); + pipe_resource_reference( &rb->texture, surf->texture ); rb->width = surf->width; rb->height = surf->height; @@ -357,7 +357,7 @@ int st_get_framebuffer_surface(struct st_framebuffer *stfb, } int st_get_framebuffer_texture(struct st_framebuffer *stfb, - uint surfIndex, struct pipe_texture **tex) + uint surfIndex, struct pipe_resource **tex) { struct st_renderbuffer *rb = stfb->strb; *tex = rb->texture; diff --git a/src/gallium/state_trackers/vega/vg_tracker.h b/src/gallium/state_trackers/vega/vg_tracker.h index 165a6b7..c16d55f 100644 --- a/src/gallium/state_trackers/vega/vg_tracker.h +++ b/src/gallium/state_trackers/vega/vg_tracker.h @@ -90,7 +90,7 @@ int st_get_framebuffer_surface(struct st_framebuffer *stfb, PUBLIC int st_get_framebuffer_texture(struct st_framebuffer *stfb, - uint surfIndex, struct pipe_texture **tex); + uint surfIndex, struct pipe_resource **tex); PUBLIC void *st_framebuffer_private(struct st_framebuffer *stfb); _______________________________________________ mesa-commit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-commit
