diff options
Diffstat (limited to 'src/gallium/state_trackers/vega')
-rw-r--r-- | src/gallium/state_trackers/vega/api_filters.c | 8 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/api_images.c | 6 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/image.c | 40 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/mask.c | 24 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/paint.c | 5 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/renderer.c | 21 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/vg_context.c | 49 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/vg_manager.c | 13 |
8 files changed, 90 insertions, 76 deletions
diff --git a/src/gallium/state_trackers/vega/api_filters.c b/src/gallium/state_trackers/vega/api_filters.c index 384554a..95f900f 100644 --- a/src/gallium/state_trackers/vega/api_filters.c +++ b/src/gallium/state_trackers/vega/api_filters.c @@ -41,7 +41,6 @@ #include "util/u_sampler.h" #include "util/u_string.h" - #include "asm_filters.h" @@ -72,6 +71,7 @@ static INLINE struct pipe_resource *create_texture_1d(struct vg_context *ctx, templ.width0 = color_data_len; templ.height0 = 1; templ.depth0 = 1; + templ.array_size = 1; templ.bind = PIPE_BIND_SAMPLER_VIEW; tex = screen->resource_create(screen, &templ); @@ -79,9 +79,9 @@ static INLINE struct pipe_resource *create_texture_1d(struct vg_context *ctx, { /* upload color_data */ struct pipe_transfer *transfer = pipe_get_transfer(pipe, tex, - 0, 0, 0, - PIPE_TRANSFER_READ_WRITE , - 0, 0, tex->width0, tex->height0); + 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); diff --git a/src/gallium/state_trackers/vega/api_images.c b/src/gallium/state_trackers/vega/api_images.c index 60f9db6..ad95409 100644 --- a/src/gallium/state_trackers/vega/api_images.c +++ b/src/gallium/state_trackers/vega/api_images.c @@ -447,9 +447,9 @@ void vegaReadPixels(void * data, VGint dataStride, VGint y = (stfb->height - sy) - 1, yStep = -1; struct pipe_transfer *transfer; - transfer = pipe_get_transfer(pipe, strb->texture, 0, 0, 0, - PIPE_TRANSFER_READ, - 0, 0, sx + width, stfb->height - sy); + transfer = pipe_get_transfer(pipe, strb->texture, 0, 0, + PIPE_TRANSFER_READ, + 0, 0, sx + width, stfb->height - sy); /* Do a row at a time to flip image data vertically */ for (i = 0; i < height; i++) { diff --git a/src/gallium/state_trackers/vega/image.c b/src/gallium/state_trackers/vega/image.c index a20b6d5..164af30 100644 --- a/src/gallium/state_trackers/vega/image.c +++ b/src/gallium/state_trackers/vega/image.c @@ -42,6 +42,7 @@ #include "util/u_memory.h" #include "util/u_math.h" #include "util/u_sampler.h" +#include "util/u_surface.h" static enum pipe_format vg_format_to_pipe(VGImageFormat format) { @@ -135,11 +136,11 @@ static void vg_copy_texture(struct vg_context *ctx, if (src_loc[2] >= 0 && src_loc[3] >= 0 && dst_loc[2] >= 0 && dst_loc[3] >= 0) { - struct pipe_surface *surf; + struct pipe_surface *surf, surf_tmpl; /* get the destination surface */ - surf = ctx->pipe->screen->get_tex_surface(ctx->pipe->screen, - dst, 0, 0, 0, PIPE_BIND_RENDER_TARGET); + u_surface_default_template(&surf_tmpl, dst, PIPE_BIND_RENDER_TARGET); + surf = ctx->pipe->create_surface(ctx->pipe, dst, &surf_tmpl); if (surf && renderer_copy_begin(ctx->renderer, surf, VG_TRUE, src)) { renderer_copy(ctx->renderer, dst_loc[0], dst_loc[1], dst_loc[2], dst_loc[3], @@ -265,6 +266,7 @@ struct vg_image * image_create(VGImageFormat format, pt.width0 = width; pt.height0 = height; pt.depth0 = 1; + pt.array_size = 1; pt.bind = PIPE_BIND_SAMPLER_VIEW; newtex = screen->resource_create(screen, &pt); @@ -415,7 +417,7 @@ void image_sub_data(struct vg_image *image, { /* upload color_data */ struct pipe_transfer *transfer = pipe_get_transfer( - pipe, texture, 0, 0, 0, + pipe, texture, 0, 0, PIPE_TRANSFER_WRITE, 0, 0, texture->width0, texture->height0); src += (dataStride * yoffset); for (i = 0; i < height; i++) { @@ -446,11 +448,11 @@ void image_get_sub_data(struct vg_image * image, { struct pipe_transfer *transfer = pipe_get_transfer(pipe, - image->sampler_view->texture, 0, 0, 0, - PIPE_TRANSFER_READ, - 0, 0, - image->x + image->width, - image->y + image->height); + image->sampler_view->texture, 0, 0, + PIPE_TRANSFER_READ, + 0, 0, + image->x + image->width, + image->y + image->height); /* Do a row at a time to flip image data vertically */ for (i = 0; i < height; i++) { #if 0 @@ -566,20 +568,21 @@ void image_set_pixels(VGint dx, VGint dy, { struct vg_context *ctx = vg_current_context(); struct pipe_context *pipe = ctx->pipe; - struct pipe_screen *screen = pipe->screen; - struct pipe_surface *surf; + struct pipe_surface *surf, surf_tmpl; struct st_renderbuffer *strb = ctx->draw_buffer->strb; /* make sure rendering has completed */ pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); - surf = screen->get_tex_surface(screen, image_texture(src), 0, 0, 0, - 0 /* no bind flags as surf isn't actually used??? */); + memset(&surf_tmpl, 0, sizeof(surf_tmpl)); + u_surface_default_template(&surf_tmpl, image_texture(src), + 0 /* no bind flag - not a surface*/); + surf = pipe->create_surface(pipe, image_texture(src), &surf_tmpl); vg_copy_surface(ctx, strb->surface, dx, dy, surf, sx+src->x, sy+src->y, width, height); - screen->tex_surface_destroy(surf); + pipe->surface_destroy(pipe, surf); } void image_get_pixels(struct vg_image *dst, VGint dx, VGint dy, @@ -588,8 +591,7 @@ void image_get_pixels(struct vg_image *dst, VGint dx, VGint dy, { struct vg_context *ctx = vg_current_context(); struct pipe_context *pipe = ctx->pipe; - struct pipe_screen *screen = pipe->screen; - struct pipe_surface *surf; + struct pipe_surface *surf, surf_tmpl; struct st_renderbuffer *strb = ctx->draw_buffer->strb; /* flip the y coordinates */ @@ -598,8 +600,10 @@ void image_get_pixels(struct vg_image *dst, VGint dx, VGint dy, /* make sure rendering has completed */ pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); - surf = screen->get_tex_surface(screen, image_texture(dst), 0, 0, 0, - 0 /* no bind flags as surf isn't actually used??? */); + memset(&surf_tmpl, 0, sizeof(surf_tmpl)); + u_surface_default_template(&surf_tmpl, image_texture(dst), + PIPE_BIND_RENDER_TARGET); + surf = pipe->create_surface(pipe, image_texture(dst), &surf_tmpl); vg_copy_surface(ctx, surf, dst->x + dx, dst->y + dy, strb->surface, sx, sy, width, height); diff --git a/src/gallium/state_trackers/vega/mask.c b/src/gallium/state_trackers/vega/mask.c index 8431e1b..d8dc85f 100644 --- a/src/gallium/state_trackers/vega/mask.c +++ b/src/gallium/state_trackers/vega/mask.c @@ -37,6 +37,7 @@ #include "util/u_inlines.h" #include "util/u_format.h" #include "util/u_memory.h" +#include "util/u_surface.h" #include "util/u_sampler.h" struct vg_mask_layer { @@ -99,7 +100,6 @@ static void read_alpha_mask(void * data, VGint dataStride, { struct vg_context *ctx = vg_current_context(); struct pipe_context *pipe = ctx->pipe; - struct pipe_screen *screen = pipe->screen; struct st_framebuffer *stfb = ctx->draw_buffer; struct st_renderbuffer *strb = stfb->alpha_mask; @@ -130,8 +130,8 @@ static void read_alpha_mask(void * data, VGint dataStride, { struct pipe_surface *surf; - surf = screen->get_tex_surface(screen, strb->texture, 0, 0, 0, - PIPE_BIND_TRANSFER_READ); + surf = pipe->create_surface(pipe, strb->texture, 0, 0, 0, + PIPE_BIND_TRANSFER_READ); /* Do a row at a time to flip image data vertically */ for (i = 0; i < height; i++) { @@ -400,11 +400,13 @@ void mask_copy(struct vg_mask_layer *layer, { struct vg_context *ctx = vg_current_context(); struct pipe_sampler_view *src = vg_get_surface_mask(ctx); - struct pipe_surface *surf; + struct pipe_surface *surf, surf_tmpl; /* get the destination surface */ - surf = ctx->pipe->screen->get_tex_surface(ctx->pipe->screen, - layer->sampler_view->texture, 0, 0, 0, PIPE_BIND_RENDER_TARGET); + u_surface_default_template(&surf_tmpl, layer->sampler_view->texture, + PIPE_BIND_RENDER_TARGET); + surf = ctx->pipe->create_surface(ctx->pipe, layer->sampler_view->texture, + &surf_tmpl); if (surf && renderer_copy_begin(ctx->renderer, surf, VG_FALSE, src)) { /* layer should be flipped when used as a texture */ sy += height; @@ -424,13 +426,13 @@ static void mask_layer_render_to(struct vg_mask_layer *layer, VGbitfield paint_modes) { struct vg_context *ctx = vg_current_context(); - struct pipe_screen *screen = ctx->pipe->screen; + struct pipe_context *pipe = ctx->pipe; struct pipe_sampler_view *view = vg_get_surface_mask(ctx); struct matrix *mat = &ctx->state.vg.path_user_to_surface_matrix; - struct pipe_surface *surf; - - surf = screen->get_tex_surface(screen, view->texture, - 0, 0, 0, PIPE_BIND_RENDER_TARGET); + struct pipe_surface *surf, surf_tmpl; + u_surface_default_template(&surf_tmpl, view->texture, + PIPE_BIND_RENDER_TARGET); + surf = pipe->create_surface(pipe, view->texture, &surf_tmpl); renderer_validate_for_mask_rendering(ctx->renderer, surf); diff --git a/src/gallium/state_trackers/vega/paint.c b/src/gallium/state_trackers/vega/paint.c index 31c1784..2db8cbc 100644 --- a/src/gallium/state_trackers/vega/paint.c +++ b/src/gallium/state_trackers/vega/paint.c @@ -154,14 +154,15 @@ static INLINE struct pipe_resource *create_gradient_texture(struct vg_paint *p) templ.width0 = 1024; templ.height0 = 1; templ.depth0 = 1; + templ.array_size = 1; templ.bind = PIPE_BIND_SAMPLER_VIEW; tex = screen->resource_create(screen, &templ); { /* upload color_data */ struct pipe_transfer *transfer = - pipe_get_transfer(p->base.ctx->pipe, tex, 0, 0, 0, - PIPE_TRANSFER_WRITE, 0, 0, 1024, 1); + pipe_get_transfer(p->base.ctx->pipe, tex, 0, 0, + PIPE_TRANSFER_WRITE, 0, 0, 1024, 1); void *map = pipe->transfer_map(pipe, transfer); memcpy(map, p->gradient.color_data, sizeof(VGint)*1024); pipe->transfer_unmap(pipe, transfer); diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c index 169526b..080bcf6 100644 --- a/src/gallium/state_trackers/vega/renderer.c +++ b/src/gallium/state_trackers/vega/renderer.c @@ -40,6 +40,7 @@ #include "util/u_simple_shaders.h" #include "util/u_memory.h" #include "util/u_sampler.h" +#include "util/u_surface.h" #include "util/u_math.h" #include "cso_cache/cso_context.h" @@ -815,7 +816,7 @@ VGboolean renderer_filter_begin(struct renderer *renderer, const void *const_buffer, VGint const_buffer_len) { - struct pipe_surface *surf; + struct pipe_surface *surf, surf_tmpl; assert(renderer->state == RENDERER_STATE_INIT); @@ -824,8 +825,9 @@ VGboolean renderer_filter_begin(struct renderer *renderer, if (!renderer_can_support(renderer, dst, PIPE_BIND_RENDER_TARGET)) return VG_FALSE; - surf = renderer->pipe->screen->get_tex_surface(renderer->pipe->screen, - dst, 0, 0, 0, PIPE_BIND_RENDER_TARGET); + u_surface_default_template(&surf_tmpl, dst, + PIPE_BIND_RENDER_TARGET); + surf = renderer->pipe->create_surface(renderer->pipe, dst, &surf_tmpl); if (!surf) return VG_FALSE; @@ -1380,8 +1382,8 @@ void renderer_copy_surface(struct renderer *ctx, struct pipe_screen *screen = pipe->screen; struct pipe_sampler_view view_templ; struct pipe_sampler_view *view; + struct pipe_box src_box; struct pipe_resource texTemp, *tex; - struct pipe_subresource subsrc, subdst; const struct pipe_framebuffer_state *fb = &ctx->g3d.fb; const int srcW = abs(srcX1 - srcX0); const int srcH = abs(srcY1 - srcY0); @@ -1425,6 +1427,7 @@ void renderer_copy_surface(struct renderer *ctx, texTemp.width0 = srcW; texTemp.height0 = srcH; texTemp.depth0 = 1; + texTemp.array_size = 1; texTemp.bind = PIPE_BIND_SAMPLER_VIEW; tex = screen->resource_create(screen, &texTemp); @@ -1437,15 +1440,11 @@ void renderer_copy_surface(struct renderer *ctx, if (!view) return; - subdst.face = 0; - subdst.level = 0; - subsrc.face = src->face; - subsrc.level = src->level; + u_box_2d_zslice(srcLeft, srcTop, src->u.tex.first_layer, srcW, srcH, &src_box); pipe->resource_copy_region(pipe, - tex, subdst, 0, 0, 0, /* dest */ - src->texture, subsrc, srcLeft, srcTop, src->zslice, /* src */ - srcW, srcH); /* size */ + tex, 0, 0, 0, 0, /* dest */ + src->texture, 0, &src_box); assert(floatsEqual(z, 0.0f)); diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c index 5b07265..5479edc 100644 --- a/src/gallium/state_trackers/vega/vg_context.c +++ b/src/gallium/state_trackers/vega/vg_context.c @@ -44,6 +44,7 @@ #include "util/u_memory.h" #include "util/u_blit.h" #include "util/u_sampler.h" +#include "util/u_surface.h" #include "util/u_format.h" struct vg_context *_vg_context = 0; @@ -241,6 +242,7 @@ create_texture(struct pipe_context *pipe, enum pipe_format format, templ.width0 = width; templ.height0 = height; templ.depth0 = 1; + templ.array_size = 1; templ.last_level = 0; if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1)) { @@ -310,22 +312,18 @@ vg_context_update_surface_mask_view(struct vg_context *ctx, /* if we had an old surface copy it over */ if (old_sampler_view) { - struct pipe_subresource subsurf, subold_surf; - subsurf.face = 0; - subsurf.level = 0; - subold_surf.face = 0; - subold_surf.level = 0; + struct pipe_box src_box; + u_box_origin_2d(MIN2(old_sampler_view->texture->width0, + stfb->surface_mask_view->texture->width0), + MIN2(old_sampler_view->texture->height0, + stfb->surface_mask_view->texture->height0), + &src_box); + pipe->resource_copy_region(pipe, stfb->surface_mask_view->texture, - subsurf, - 0, 0, 0, + 0, 0, 0, 0, old_sampler_view->texture, - subold_surf, - 0, 0, 0, - MIN2(old_sampler_view->texture->width0, - stfb->surface_mask_view->texture->width0), - MIN2(old_sampler_view->texture->height0, - stfb->surface_mask_view->texture->height0)); + 0, &src_box); } /* Free the old texture @@ -359,7 +357,7 @@ vg_context_update_depth_stencil_rb(struct vg_context * ctx, { struct st_renderbuffer *dsrb = ctx->draw_buffer->dsrb; struct pipe_context *pipe = ctx->pipe; - unsigned surface_usage; + struct pipe_surface surf_tmpl; if ((dsrb->width == width && dsrb->height == height) && dsrb->texture) return FALSE; @@ -369,18 +367,16 @@ vg_context_update_depth_stencil_rb(struct vg_context * ctx, pipe_resource_reference(&dsrb->texture, NULL); dsrb->width = dsrb->height = 0; - /* Probably need dedicated flags for surface usage too: - */ - surface_usage = PIPE_BIND_DEPTH_STENCIL; /* XXX: was: RENDER_TARGET */ - dsrb->texture = create_texture(pipe, dsrb->format, width, height); if (!dsrb->texture) return TRUE; - dsrb->surface = pipe->screen->get_tex_surface(pipe->screen, - dsrb->texture, - 0, 0, 0, - surface_usage); + memset(&surf_tmpl, 0, sizeof(surf_tmpl)); + u_surface_default_template(&surf_tmpl, dsrb->texture, + PIPE_BIND_DEPTH_STENCIL); + dsrb->surface = pipe->create_surface(pipe, + dsrb->texture, + &surf_tmpl); if (!dsrb->surface) { pipe_resource_reference(&dsrb->texture, NULL); return TRUE; @@ -439,11 +435,16 @@ static void vg_prepare_blend_texture(struct vg_context *ctx, { struct st_framebuffer *stfb = ctx->draw_buffer; struct pipe_surface *surf; + struct pipe_surface surf_tmpl; vg_context_update_blend_texture_view(ctx, stfb->width, stfb->height); - surf = ctx->pipe->screen->get_tex_surface(ctx->pipe->screen, - stfb->blend_texture_view->texture, 0, 0, 0, PIPE_BIND_RENDER_TARGET); + memset(&surf_tmpl, 0, sizeof(surf_tmpl)); + u_surface_default_template(&surf_tmpl, stfb->blend_texture_view->texture, + PIPE_BIND_RENDER_TARGET); + surf = ctx->pipe->create_surface(ctx->pipe, + stfb->blend_texture_view->texture, + &surf_tmpl); if (surf) { util_blit_pixels_tex(ctx->blit, src, 0, 0, stfb->width, stfb->height, diff --git a/src/gallium/state_trackers/vega/vg_manager.c b/src/gallium/state_trackers/vega/vg_manager.c index 03c8d22..d538e66 100644 --- a/src/gallium/state_trackers/vega/vg_manager.c +++ b/src/gallium/state_trackers/vega/vg_manager.c @@ -34,6 +34,8 @@ #include "util/u_memory.h" #include "util/u_inlines.h" #include "util/u_sampler.h" +#include "util/u_box.h" +#include "util/u_surface.h" #include "vg_api.h" #include "vg_manager.h" @@ -45,7 +47,8 @@ static boolean vg_context_update_color_rb(struct vg_context *ctx, struct pipe_resource *pt) { struct st_renderbuffer *strb = ctx->draw_buffer->strb; - struct pipe_screen *screen = ctx->pipe->screen; + struct pipe_context *pipe = ctx->pipe; + struct pipe_surface surf_tmpl; if (strb->texture == pt) { pipe_resource_reference(&pt, NULL); @@ -58,8 +61,12 @@ vg_context_update_color_rb(struct vg_context *ctx, struct pipe_resource *pt) strb->width = strb->height = 0; strb->texture = pt; - strb->surface = screen->get_tex_surface(screen, strb->texture, 0, 0, 0, - PIPE_BIND_RENDER_TARGET); + + memset(&surf_tmpl, 0, sizeof(surf_tmpl)); + u_surface_default_template(&surf_tmpl, strb->texture, + PIPE_BIND_RENDER_TARGET); + strb->surface = pipe->create_surface(pipe, strb->texture, &surf_tmpl); + if (!strb->surface) { pipe_resource_reference(&strb->texture, NULL); return TRUE; |