frontend/hgl: inherit pipe_frontend_drawable instead of allocating separately
authorYonggang Luo <luoyonggang@gmail.com>
Mon, 5 Dec 2022 14:25:33 +0000 (09:25 -0500)
committerMarge Bot <emma+marge@anholt.net>
Fri, 9 Dec 2022 13:14:03 +0000 (13:14 +0000)
This is required by st/mesa now.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20027>

src/gallium/frontends/hgl/hgl.c
src/gallium/frontends/hgl/hgl_context.h
src/gallium/targets/haiku-softpipe/GalliumContext.cpp

index e75d850..ed2e31e 100644 (file)
@@ -230,10 +230,6 @@ hgl_create_st_framebuffer(struct hgl_context* context, void *winsysContext)
        buffer = CALLOC_STRUCT(hgl_buffer);
        assert(buffer);
 
-       // calloc and configure our st_framebuffer interface
-       buffer->drawable = CALLOC_STRUCT(pipe_frontend_drawable);
-       assert(buffer->drawable);
-
        // Prepare our buffer
        buffer->visual = context->stVisual;
        buffer->screen = context->display->fscreen->screen;
@@ -245,13 +241,13 @@ hgl_create_st_framebuffer(struct hgl_context* context, void *winsysContext)
                buffer->target = PIPE_TEXTURE_RECT;
 
        // Prepare our frontend interface
-       buffer->drawable->flush_front = hgl_st_framebuffer_flush_front;
-       buffer->drawable->validate = hgl_st_framebuffer_validate;
-       buffer->drawable->visual = context->stVisual;
+       buffer->base.flush_front = hgl_st_framebuffer_flush_front;
+       buffer->base.validate = hgl_st_framebuffer_validate;
+       buffer->base.visual = context->stVisual;
 
-       p_atomic_set(&buffer->drawable->stamp, 1);
-       buffer->drawable->ID = p_atomic_inc_return(&hgl_fb_ID);
-       buffer->drawable->fscreen = context->display->fscreen;
+       p_atomic_set(&buffer->base.stamp, 1);
+       buffer->base.ID = p_atomic_inc_return(&hgl_fb_ID);
+       buffer->base.fscreen = context->display->fscreen;
 
        return buffer;
 }
@@ -266,7 +262,6 @@ hgl_destroy_st_framebuffer(struct hgl_buffer *buffer)
        for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
                pipe_resource_reference(&buffer->textures[i], NULL);
 
-       FREE(buffer->drawable);
        FREE(buffer);
 }
 
index c75a6db..1ac73e5 100644 (file)
@@ -31,7 +31,7 @@ typedef int64 context_id;
 
 struct hgl_buffer
 {
-       struct pipe_frontend_drawable *drawable;
+       struct pipe_frontend_drawable base;
        struct st_visual* visual;
 
        unsigned width;
index bb80166..3f80275 100644 (file)
@@ -303,8 +303,8 @@ GalliumContext::SetCurrentContext(bool set, context_id contextID)
        }
 
        // We need to lock and unlock framebuffers before accessing them
-       st_api_make_current(context->st, context->buffer->drawable,
-               context->buffer->drawable);
+       st_api_make_current(context->st, &context->buffer->base,
+               &context->buffer->base);
        Unlock();
 
        return B_OK;
@@ -335,7 +335,7 @@ GalliumContext::SwapBuffers(context_id contextID)
                buffer->screen->flush_frontbuffer(buffer->screen, NULL, buffer->textures[ST_ATTACHMENT_BACK_LEFT],
                        0, 0, buffer->winsysContext, NULL);
                std::swap(buffer->textures[ST_ATTACHMENT_FRONT_LEFT], buffer->textures[ST_ATTACHMENT_BACK_LEFT]);
-               p_atomic_inc(&buffer->drawable->stamp);
+               p_atomic_inc(&buffer->base.stamp);
        }
 
         /* TODO: remove this if the framebuffer state doesn't change. */
@@ -395,7 +395,7 @@ GalliumContext::Invalidate(uint32 width, uint32 height)
        fContext[fCurrentContext]->height = height + 1;
 
        // Is this the best way to invalidate?
-       p_atomic_inc(&fContext[fCurrentContext]->buffer->drawable->stamp);
+       p_atomic_inc(&fContext[fCurrentContext]->buffer->base.stamp);
 }