X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fstate_trackers%2Fvega%2Fvg_tracker.c;h=f438e34087e71a87ad674fb6d957ffddedd50b2b;hb=2689dd304c6d644b04c941e6da63e466be5de0d6;hp=c4da01e52ccbb07c721b36acd1417557406a89f5;hpb=3d36d6b4cf735e93a6ae5eadf28e671252fb5303;p=mesa.git diff --git a/src/gallium/state_trackers/vega/vg_tracker.c b/src/gallium/state_trackers/vega/vg_tracker.c index c4da01e52cc..f438e34087e 100644 --- a/src/gallium/state_trackers/vega/vg_tracker.c +++ b/src/gallium/state_trackers/vega/vg_tracker.c @@ -29,14 +29,20 @@ #include "mask.h" #include "pipe/p_context.h" -#include "pipe/p_inlines.h" +#include "util/u_inlines.h" #include "pipe/p_screen.h" +#include "util/u_format.h" +#include "util/u_sampler.h" #include "util/u_memory.h" #include "util/u_math.h" +#include "util/u_rect.h" + +/* advertise OpenVG support */ +PUBLIC const int st_api_OpenVG = 1; static struct pipe_texture * create_texture(struct pipe_context *pipe, enum pipe_format format, - VGint width, VGint height) + VGint width, VGint height) { struct pipe_texture templ; @@ -46,17 +52,16 @@ create_texture(struct pipe_context *pipe, enum pipe_format format, templ.format = format; } else { - templ.format = PIPE_FORMAT_A8R8G8B8_UNORM; + templ.format = PIPE_FORMAT_B8G8R8A8_UNORM; } templ.target = PIPE_TEXTURE_2D; - pf_get_block(templ.format, &templ.block); - templ.width[0] = width; - templ.height[0] = height; - templ.depth[0] = 1; + templ.width0 = width; + templ.height0 = height; + templ.depth0 = 1; templ.last_level = 0; - if (pf_get_component_bits(format, PIPE_FORMAT_COMP_S)) { + if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1)) { templ.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL; } else { templ.tex_usage = (PIPE_TEXTURE_USAGE_DISPLAY_TARGET | @@ -67,6 +72,27 @@ create_texture(struct pipe_context *pipe, enum pipe_format format, return pipe->screen->texture_create(pipe->screen, &templ); } +static struct pipe_sampler_view * +create_tex_and_view(struct pipe_context *pipe, enum pipe_format format, + VGint width, VGint height) +{ + struct pipe_texture *texture; + struct pipe_sampler_view view_templ; + struct pipe_sampler_view *view; + + texture = create_texture(pipe, format, width, height); + + if (!texture) + return NULL; + + u_sampler_view_default_template(&view_templ, texture, texture->format); + view = pipe->create_sampler_view(pipe, texture, &view_templ); + /* want the texture to go away if the view is freed */ + pipe_texture_reference(&texture, NULL); + + return view; +} + /** * Allocate a renderbuffer for a an on-screen window (not a user-created * renderbuffer). The window system code determines the format. @@ -111,8 +137,8 @@ st_renderbuffer_alloc_storage(struct vg_context * ctx, surface_usage = (PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE); - strb->texture = create_texture(pipe, strb->format, - width, height); + strb->texture = create_texture(pipe, strb->format, width, height); + if (!strb->texture) return FALSE; @@ -182,15 +208,15 @@ struct st_framebuffer * st_create_framebuffer(const void *visual, if (stencilFormat == depthFormat) stfb->dsrb = st_new_renderbuffer_fb(stencilFormat); else - stfb->dsrb = st_new_renderbuffer_fb(PIPE_FORMAT_S8Z24_UNORM); + stfb->dsrb = st_new_renderbuffer_fb(PIPE_FORMAT_Z24S8_UNORM); /*### currently we always allocate it but it's possible it's not necessary if EGL_ALPHA_MASK_SIZE was 0 */ - stfb->alpha_mask = 0; + stfb->alpha_mask_view = NULL; - stfb->init_width = width; - stfb->init_height = height; + stfb->width = width; + stfb->height = height; stfb->privateData = privateData; } @@ -202,19 +228,19 @@ 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_sampler_view *old_sampler_view = stfb->alpha_mask_view; /* - we use PIPE_FORMAT_A8R8G8B8_UNORM because we want to render to + we use PIPE_FORMAT_B8G8R8A8_UNORM because we want to render to this texture and use it as a sampler, so while this wastes some space it makes both of those a lot simpler */ - stfb->alpha_mask = - create_texture(pipe, PIPE_FORMAT_A8R8G8B8_UNORM, width, height); + stfb->alpha_mask_view = + create_tex_and_view(pipe, PIPE_FORMAT_B8G8R8A8_UNORM, width, height); - if (!stfb->alpha_mask) { - if (old_texture) - pipe_texture_reference(&old_texture, NULL); + if (!stfb->alpha_mask_view) { + if (old_sampler_view) + pipe_sampler_view_reference(&old_sampler_view, NULL); return; } @@ -224,15 +250,15 @@ static void setup_new_alpha_mask(struct vg_context *ctx, mask_fill(0, 0, width, height, 1.f); /* if we had an old surface copy it over */ - if (old_texture) { + if (old_sampler_view) { struct pipe_surface *surface = pipe->screen->get_tex_surface( pipe->screen, - stfb->alpha_mask, + stfb->alpha_mask_view->texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); struct pipe_surface *old_surface = pipe->screen->get_tex_surface( pipe->screen, - old_texture, + old_sampler_view->texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ); if (pipe->surface_copy) { @@ -260,8 +286,8 @@ static void setup_new_alpha_mask(struct vg_context *ctx, /* Free the old texture */ - if (old_texture) - pipe_texture_reference(&old_texture, NULL); + if (old_sampler_view) + pipe_sampler_view_reference(&old_sampler_view, NULL); } void st_resize_framebuffer(struct st_framebuffer *stfb, @@ -278,11 +304,14 @@ void st_resize_framebuffer(struct st_framebuffer *stfb, /* If this is a noop, exit early and don't do the clear, etc below. */ - if (strb->width == width && - strb->height == height && + if (stfb->width == width && + stfb->height == height && state->zsbuf) return; + stfb->width = width; + stfb->height = height; + if (strb->width != width || strb->height != height) st_renderbuffer_alloc_storage(ctx, strb, width, height); @@ -319,9 +348,9 @@ void st_resize_framebuffer(struct st_framebuffer *stfb, setup_new_alpha_mask(ctx, stfb, width, height); - pipe_texture_reference( &stfb->blend_texture, NULL ); - stfb->blend_texture = create_texture(ctx->pipe, PIPE_FORMAT_A8R8G8B8_UNORM, - width, height); + pipe_sampler_view_reference( &stfb->blend_texture_view, NULL ); + stfb->blend_texture_view = create_tex_and_view(ctx->pipe, PIPE_FORMAT_B8G8R8A8_UNORM, + width, height); } void st_set_framebuffer_surface(struct st_framebuffer *stfb, @@ -367,14 +396,15 @@ void st_unreference_framebuffer(struct st_framebuffer *stfb) /* FIXME */ } -void st_make_current(struct vg_context *st, - struct st_framebuffer *draw, - struct st_framebuffer *read) +boolean st_make_current(struct vg_context *st, + struct st_framebuffer *draw, + struct st_framebuffer *read, + void *winsys_drawable_handle) { vg_set_current_context(st); - if (st) { + if (st) st->draw_buffer = draw; - } + return VG_TRUE; } struct vg_context *st_get_current(void) @@ -424,3 +454,8 @@ int st_unbind_texture_surface(struct pipe_surface *ps, int target, int level) { return 0; } + +st_proc st_get_proc_address(const char *procname) +{ + return NULL; +}