st/hgl: Move st_manager create/destroy into hgl state_tracker
authorAlexander von Gluck IV <kallisti5@unixzen.com>
Fri, 29 Aug 2014 14:42:26 +0000 (14:42 +0000)
committerAlexander von Gluck IV <kallisti5@unixzen.com>
Sat, 30 Aug 2014 23:35:24 +0000 (19:35 -0400)
src/gallium/state_trackers/hgl/hgl.c
src/gallium/state_trackers/hgl/hgl_context.h
src/gallium/targets/haiku-softpipe/GalliumContext.cpp

index 8dcd6e315f3f208c871bc8951cc0cad8a04cb603..66abc61cb2d417c940ab03ef5592e5b5f77c254b 100644 (file)
@@ -131,6 +131,23 @@ hgl_st_framebuffer_validate(struct st_context_iface *stctx,
 }
 
 
+static int
+hgl_st_manager_get_param(struct st_manager *smapi, enum st_manager_param param)
+{
+    CALLED();
+
+       switch (param) {
+               case ST_MANAGER_BROKEN_INVALIDATE:
+                       TRACE("%s: TODO: How should we handle BROKEN_INVALIDATE calls?\n",
+                               __func__);
+                       // For now we force validation of the framebuffer.
+                       return 1;
+       }
+
+       return 0;
+}
+
+
 /**
  * Create new framebuffer
  */
@@ -148,7 +165,7 @@ hgl_create_st_framebuffer(struct hgl_context* context)
                // Copy context visual into framebuffer
                memcpy(&buffer->visual, context->stVisual, sizeof(struct st_visual));
 
-               // calloc our st_framebuffer interface
+               // calloc and configure our st_framebuffer interface
                buffer->stfbi = CALLOC_STRUCT(st_framebuffer_iface);
                if (!buffer->stfbi) {
                        ERROR("%s: Couldn't calloc framebuffer!\n", __func__);
@@ -167,3 +184,34 @@ hgl_create_st_framebuffer(struct hgl_context* context)
 
    return buffer;
 }
+
+
+struct st_manager *
+hgl_create_st_manager(struct pipe_screen* screen)
+{
+       CALLED();
+
+       assert(screen);
+       struct st_manager* manager = CALLOC_STRUCT(st_manager);
+
+       if (!manager) {
+               ERROR("%s: Couldn't allocate state tracker manager!\n", __func__);
+               return NULL;
+       }
+
+       //manager->display = dpy;
+       manager->screen = screen;
+       manager->get_param = hgl_st_manager_get_param;
+
+       return manager;
+}
+
+
+void
+hgl_destroy_st_manager(struct st_manager *manager)
+{
+       CALLED();
+
+       if (manager)
+               FREE(manager);
+}
index f1f43fa113bd0daa7dbcafb67fe4b8030c3f08e4..a520d490e522f028d982e001b5ebbb64e08ea494 100644 (file)
@@ -73,7 +73,12 @@ struct hgl_context
 };
 
 
+// hgl state_tracker framebuffer
 struct hgl_buffer* hgl_create_st_framebuffer(struct hgl_context* context);
 
+// hgl state_tracker manager
+struct st_manager* hgl_create_st_manager(struct pipe_screen* screen);
+void hgl_destroy_st_manager(struct st_manager *manager);
+
 
 #endif /* HGL_CONTEXT_H */
index d7d5d9d731c7ce824a3ca19236b532aabbfc10dd..ed4171282d88de566f1f64a3b3e24e1424c15449 100644 (file)
@@ -69,23 +69,6 @@ hgl_viewport(struct gl_context* glContext)
 }
 
 
-static int
-hook_stm_get_param(struct st_manager *smapi, enum st_manager_param param)
-{
-       CALLED();
-
-       switch (param) {
-               case ST_MANAGER_BROKEN_INVALIDATE:
-                       TRACE("%s: TODO: How should we handle BROKEN_INVALIDATE calls?\n",
-                               __func__);
-                       // For now we force validation of the framebuffer.
-                       return 1;
-       }
-
-       return 0;
-}
-
-
 GalliumContext::GalliumContext(ulong options)
        :
        fOptions(options),
@@ -264,12 +247,8 @@ GalliumContext::CreateContext(Bitmap *bitmap)
                return -1;
        }
 
-       context->manager = CALLOC_STRUCT(st_manager);
-       if (!context->manager) {
-               ERROR("%s: Couldn't allocate Mesa state tracker manager!\n", __func__);
-               return -1;
-       }
-       context->manager->get_param = hook_stm_get_param;
+       // Create state_tracker manager
+       context->manager = hgl_create_st_manager(fScreen);
 
        // Create state tracker visual
        context->stVisual = CreateVisual();
@@ -287,9 +266,6 @@ GalliumContext::CreateContext(Bitmap *bitmap)
                return -1;
        }
 
-       // We need to assign the screen *before* calling st_api create_context
-       context->manager->screen = fScreen;
-
        // Build state tracker attributes
        struct st_context_attribs attribs;
        memset(&attribs, 0, sizeof(attribs));
@@ -405,7 +381,7 @@ GalliumContext::DestroyContext(context_id contextID)
                FREE(fContext[contextID]->stVisual);
 
        if (fContext[contextID]->manager)
-               FREE(fContext[contextID]->manager);
+               hgl_destroy_st_manager(fContext[contextID]->manager);
 
        FREE(fContext[contextID]);
 }
@@ -523,7 +499,7 @@ GalliumContext::ResizeViewport(int32 width, int32 height)
                if (fContext[i] && fContext[i]->st) {
                        struct st_context *stContext = (struct st_context*)fContext[i]->st;
                        _mesa_set_viewport(stContext->ctx, 0, 0, 0, width, height);
-                       st_manager_validate_framebuffers(stContext);
+                       st_manager_validate_framebuffers(stContext);
                }
        }
 }