summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/vega
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/vega')
-rw-r--r--src/gallium/state_trackers/vega/image.c2
-rw-r--r--src/gallium/state_trackers/vega/mask.c2
-rw-r--r--src/gallium/state_trackers/vega/paint.c2
-rw-r--r--src/gallium/state_trackers/vega/path.c2
-rw-r--r--src/gallium/state_trackers/vega/renderer.c2
-rw-r--r--src/gallium/state_trackers/vega/shader.c2
-rw-r--r--src/gallium/state_trackers/vega/shaders_cache.c8
-rw-r--r--src/gallium/state_trackers/vega/vg_context.c32
-rw-r--r--src/gallium/state_trackers/vega/vg_context.h1
-rw-r--r--src/gallium/state_trackers/vega/vg_manager.c24
10 files changed, 49 insertions, 28 deletions
diff --git a/src/gallium/state_trackers/vega/image.c b/src/gallium/state_trackers/vega/image.c
index 7c421dfcd4..c12dc71b86 100644
--- a/src/gallium/state_trackers/vega/image.c
+++ b/src/gallium/state_trackers/vega/image.c
@@ -355,7 +355,7 @@ void image_destroy(struct vg_image *img)
}
pipe_sampler_view_reference(&img->sampler_view, NULL);
- free(img);
+ FREE(img);
}
void image_clear(struct vg_image *img,
diff --git a/src/gallium/state_trackers/vega/mask.c b/src/gallium/state_trackers/vega/mask.c
index 6d627b0e8d..ef28ebd740 100644
--- a/src/gallium/state_trackers/vega/mask.c
+++ b/src/gallium/state_trackers/vega/mask.c
@@ -520,7 +520,7 @@ void mask_layer_destroy(struct vg_mask_layer *layer)
vg_context_remove_object(ctx, VG_OBJECT_MASK, layer);
pipe_resource_release(&layer->texture);
- free(layer);
+ FREE(layer);
}
void mask_layer_fill(struct vg_mask_layer *layer,
diff --git a/src/gallium/state_trackers/vega/paint.c b/src/gallium/state_trackers/vega/paint.c
index 05540e8275..2c0eb6b23d 100644
--- a/src/gallium/state_trackers/vega/paint.c
+++ b/src/gallium/state_trackers/vega/paint.c
@@ -236,7 +236,7 @@ void paint_destroy(struct vg_paint *paint)
free(paint->gradient.ramp_stopsi);
free(paint->gradient.ramp_stops);
- free(paint);
+ FREE(paint);
}
void paint_set_color(struct vg_paint *paint,
diff --git a/src/gallium/state_trackers/vega/path.c b/src/gallium/state_trackers/vega/path.c
index 4fc23a7a27..05f8b0d997 100644
--- a/src/gallium/state_trackers/vega/path.c
+++ b/src/gallium/state_trackers/vega/path.c
@@ -218,7 +218,7 @@ void path_destroy(struct path *p)
if (p->stroked.path)
path_destroy(p->stroked.path);
- free(p);
+ FREE(p);
}
VGbitfield path_capabilities(struct path *p)
diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c
index c40ea8675e..8c023044c4 100644
--- a/src/gallium/state_trackers/vega/renderer.c
+++ b/src/gallium/state_trackers/vega/renderer.c
@@ -203,7 +203,7 @@ void renderer_destroy(struct renderer *ctx)
ctx->fs = NULL;
}
#endif
- free(ctx);
+ FREE(ctx);
}
void renderer_draw_quad(struct renderer *r,
diff --git a/src/gallium/state_trackers/vega/shader.c b/src/gallium/state_trackers/vega/shader.c
index 6eef94ce76..eab1349639 100644
--- a/src/gallium/state_trackers/vega/shader.c
+++ b/src/gallium/state_trackers/vega/shader.c
@@ -68,7 +68,7 @@ struct shader * shader_create(struct vg_context *ctx)
void shader_destroy(struct shader *shader)
{
- free(shader);
+ FREE(shader);
}
void shader_set_masking(struct shader *shader, VGboolean set)
diff --git a/src/gallium/state_trackers/vega/shaders_cache.c b/src/gallium/state_trackers/vega/shaders_cache.c
index f43fe6ee4c..53e6bfcf16 100644
--- a/src/gallium/state_trackers/vega/shaders_cache.c
+++ b/src/gallium/state_trackers/vega/shaders_cache.c
@@ -381,7 +381,7 @@ void shaders_cache_destroy(struct shaders_cache *sc)
}
cso_hash_delete(sc->hash);
- free(sc);
+ FREE(sc);
}
void * shaders_cache_fill(struct shaders_cache *sc,
@@ -410,7 +410,7 @@ struct vg_shader * shader_create_from_text(struct pipe_context *pipe,
const char *txt, int num_tokens,
int type)
{
- struct vg_shader *shader = (struct vg_shader *)malloc(
+ struct vg_shader *shader = (struct vg_shader *)MALLOC(
sizeof(struct vg_shader));
struct tgsi_token *tokens = tokens_from_assembly(txt, num_tokens);
struct pipe_shader_state state;
@@ -435,6 +435,6 @@ void vg_shader_destroy(struct vg_context *ctx, struct vg_shader *shader)
cso_delete_fragment_shader(ctx->cso_context, shader->driver);
else
cso_delete_vertex_shader(ctx->cso_context, shader->driver);
- free(shader->tokens);
- free(shader);
+ FREE(shader->tokens);
+ FREE(shader);
}
diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c
index f02db8949d..5cb2590602 100644
--- a/src/gallium/state_trackers/vega/vg_context.c
+++ b/src/gallium/state_trackers/vega/vg_context.c
@@ -65,6 +65,32 @@ static void init_clear(struct vg_context *st)
st->clear.fs =
util_make_fragment_passthrough_shader(pipe);
}
+
+/**
+ * A depth/stencil rb will be needed regardless of what the visual says.
+ */
+static boolean
+choose_depth_stencil_format(struct vg_context *ctx)
+{
+ struct pipe_screen *screen = ctx->pipe->screen;
+ enum pipe_format formats[] = {
+ PIPE_FORMAT_Z24_UNORM_S8_USCALED,
+ PIPE_FORMAT_S8_USCALED_Z24_UNORM,
+ PIPE_FORMAT_NONE
+ };
+ enum pipe_format *fmt;
+
+ for (fmt = formats; *fmt != PIPE_FORMAT_NONE; fmt++) {
+ if (screen->is_format_supported(screen, *fmt,
+ PIPE_TEXTURE_2D, 0, PIPE_BIND_DEPTH_STENCIL, 0))
+ break;
+ }
+
+ ctx->ds_format = *fmt;
+
+ return (ctx->ds_format != PIPE_FORMAT_NONE);
+}
+
void vg_set_current_context(struct vg_context *ctx)
{
_vg_context = ctx;
@@ -81,6 +107,10 @@ struct vg_context * vg_create_context(struct pipe_context *pipe,
ctx = CALLOC_STRUCT(vg_context);
ctx->pipe = pipe;
+ if (!choose_depth_stencil_format(ctx)) {
+ FREE(ctx);
+ return NULL;
+ }
ctx->dispatch = api_create_dispatch();
@@ -191,7 +221,7 @@ void vg_destroy_context(struct vg_context *ctx)
api_destroy_dispatch(ctx->dispatch);
- free(ctx);
+ FREE(ctx);
}
void vg_init_object(struct vg_object *obj, struct vg_context *ctx, enum vg_object_type type)
diff --git a/src/gallium/state_trackers/vega/vg_context.h b/src/gallium/state_trackers/vega/vg_context.h
index 7b59ad512a..80a6c07c69 100644
--- a/src/gallium/state_trackers/vega/vg_context.h
+++ b/src/gallium/state_trackers/vega/vg_context.h
@@ -94,6 +94,7 @@ struct vg_context
struct mapi_table *dispatch;
struct pipe_context *pipe;
+ enum pipe_format ds_format;
struct {
struct vg_state vg;
diff --git a/src/gallium/state_trackers/vega/vg_manager.c b/src/gallium/state_trackers/vega/vg_manager.c
index 3b04816df0..c2aa98b231 100644
--- a/src/gallium/state_trackers/vega/vg_manager.c
+++ b/src/gallium/state_trackers/vega/vg_manager.c
@@ -388,7 +388,7 @@ destroy_renderbuffer(struct st_renderbuffer *strb)
{
pipe_surface_reference(&strb->surface, NULL);
pipe_resource_reference(&strb->texture, NULL);
- free(strb);
+ FREE(strb);
}
/**
@@ -448,11 +448,10 @@ vg_context_bind_framebuffers(struct st_context_iface *stctxi,
/* free the existing fb */
if (!stdrawi ||
stfb->strb_att != strb_att ||
- stfb->strb->format != stdrawi->visual->color_format ||
- stfb->dsrb->format != stdrawi->visual->depth_stencil_format) {
+ stfb->strb->format != stdrawi->visual->color_format) {
destroy_renderbuffer(stfb->strb);
destroy_renderbuffer(stfb->dsrb);
- free(stfb);
+ FREE(stfb);
ctx->draw_buffer = NULL;
}
@@ -472,14 +471,14 @@ vg_context_bind_framebuffers(struct st_context_iface *stctxi,
stfb->strb = create_renderbuffer(stdrawi->visual->color_format);
if (!stfb->strb) {
- free(stfb);
+ FREE(stfb);
return FALSE;
}
- stfb->dsrb = create_renderbuffer(stdrawi->visual->depth_stencil_format);
+ stfb->dsrb = create_renderbuffer(ctx->ds_format);
if (!stfb->dsrb) {
- free(stfb->strb);
- free(stfb);
+ FREE(stfb->strb);
+ FREE(stfb);
return FALSE;
}
@@ -517,14 +516,6 @@ vg_api_get_current(struct st_api *stapi)
return (ctx) ? &ctx->iface : NULL;
}
-static boolean
-vg_api_is_visual_supported(struct st_api *stapi,
- const struct st_visual *visual)
-{
- /* the impl requires a depth/stencil buffer */
- return util_format_is_depth_and_stencil(visual->depth_stencil_format);
-}
-
static st_proc_t
vg_api_get_proc_address(struct st_api *stapi, const char *procname)
{
@@ -539,7 +530,6 @@ vg_api_destroy(struct st_api *stapi)
static const struct st_api vg_api = {
vg_api_destroy,
vg_api_get_proc_address,
- vg_api_is_visual_supported,
vg_api_create_context,
vg_api_make_current,
vg_api_get_current,