Merge branch 'llvm-cliptest-viewport'
[mesa.git] / src / gallium / state_trackers / vega / vg_manager.c
index 3b04816df04dfc8533040b92aa88e5356307e799..232deefa166472d1dab244c2e362d41ca5f0bfd4 100644 (file)
@@ -341,13 +341,20 @@ vg_context_destroy(struct st_context_iface *stctxi)
 
 static struct st_context_iface *
 vg_api_create_context(struct st_api *stapi, struct st_manager *smapi,
-                      const struct st_visual *visual,
+                      const struct st_context_attribs *attribs,
                       struct st_context_iface *shared_stctxi)
 {
    struct vg_context *shared_ctx = (struct vg_context *) shared_stctxi;
    struct vg_context *ctx;
    struct pipe_context *pipe;
 
+   if (!(stapi->profile_mask & (1 << attribs->profile)))
+      return NULL;
+
+   /* only 1.0 is supported */
+   if (attribs->major > 1 || (attribs->major == 1 && attribs->minor > 0))
+      return NULL;
+
    pipe = smapi->screen->context_create(smapi->screen, NULL);
    if (!pipe)
       return NULL;
@@ -388,7 +395,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 +455,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 +478,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 +523,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)
 {
@@ -537,9 +535,10 @@ vg_api_destroy(struct st_api *stapi)
 }
 
 static const struct st_api vg_api = {
+   ST_API_OPENVG,
+   ST_PROFILE_DEFAULT_MASK,
    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,