From 5be128f67dade50533a5fa3ac374e61b203a8442 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Mon, 5 Dec 2022 09:25:33 -0500 Subject: [PATCH] frontend/hgl: inherit pipe_frontend_drawable instead of allocating separately MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This is required by st/mesa now. Reviewed-by: Marek Olšák Part-of: --- src/gallium/frontends/hgl/hgl.c | 17 ++++++----------- src/gallium/frontends/hgl/hgl_context.h | 2 +- src/gallium/targets/haiku-softpipe/GalliumContext.cpp | 8 ++++---- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/gallium/frontends/hgl/hgl.c b/src/gallium/frontends/hgl/hgl.c index e75d850..ed2e31e 100644 --- a/src/gallium/frontends/hgl/hgl.c +++ b/src/gallium/frontends/hgl/hgl.c @@ -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); } diff --git a/src/gallium/frontends/hgl/hgl_context.h b/src/gallium/frontends/hgl/hgl_context.h index c75a6db..1ac73e5 100644 --- a/src/gallium/frontends/hgl/hgl_context.h +++ b/src/gallium/frontends/hgl/hgl_context.h @@ -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; diff --git a/src/gallium/targets/haiku-softpipe/GalliumContext.cpp b/src/gallium/targets/haiku-softpipe/GalliumContext.cpp index bb80166..3f80275 100644 --- a/src/gallium/targets/haiku-softpipe/GalliumContext.cpp +++ b/src/gallium/targets/haiku-softpipe/GalliumContext.cpp @@ -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); } -- 2.7.4