mesa/st: fixup viewport drawable invalidation
This moves the code into more appropriate places Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14675>
This commit is contained in:
parent
018251908e
commit
5f675630d9
|
@ -61,7 +61,7 @@
|
||||||
#include "api_exec_decl.h"
|
#include "api_exec_decl.h"
|
||||||
|
|
||||||
#include "state_tracker/st_cb_texture.h"
|
#include "state_tracker/st_cb_texture.h"
|
||||||
#include "state_tracker/st_cb_viewport.h"
|
#include "state_tracker/st_manager.h"
|
||||||
#include "state_tracker/st_context.h"
|
#include "state_tracker/st_context.h"
|
||||||
#include "state_tracker/st_sampler_view.h"
|
#include "state_tracker/st_sampler_view.h"
|
||||||
|
|
||||||
|
@ -1093,7 +1093,8 @@ _mesa_PopAttrib(void)
|
||||||
|
|
||||||
memcpy(&ctx->ViewportArray[i].X, &vp->X, sizeof(float) * 6);
|
memcpy(&ctx->ViewportArray[i].X, &vp->X, sizeof(float) * 6);
|
||||||
|
|
||||||
st_viewport(ctx);
|
if (st_context(ctx)->invalidate_on_gl_viewport)
|
||||||
|
st_manager_invalidate_drawables(ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#include "viewport.h"
|
#include "viewport.h"
|
||||||
#include "api_exec_decl.h"
|
#include "api_exec_decl.h"
|
||||||
|
|
||||||
#include "state_tracker/st_cb_viewport.h"
|
#include "state_tracker/st_manager.h"
|
||||||
#include "state_tracker/st_context.h"
|
#include "state_tracker/st_context.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -116,7 +116,8 @@ viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei width,
|
||||||
for (unsigned i = 0; i < ctx->Const.MaxViewports; i++)
|
for (unsigned i = 0; i < ctx->Const.MaxViewports; i++)
|
||||||
set_viewport_no_notify(ctx, i, input.X, input.Y, input.Width, input.Height);
|
set_viewport_no_notify(ctx, i, input.X, input.Y, input.Width, input.Height);
|
||||||
|
|
||||||
st_viewport(ctx);
|
if (st_context(ctx)->invalidate_on_gl_viewport)
|
||||||
|
st_manager_invalidate_drawables(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -168,7 +169,8 @@ _mesa_set_viewport(struct gl_context *ctx, unsigned idx, GLfloat x, GLfloat y,
|
||||||
clamp_viewport(ctx, &x, &y, &width, &height);
|
clamp_viewport(ctx, &x, &y, &width, &height);
|
||||||
set_viewport_no_notify(ctx, idx, x, y, width, height);
|
set_viewport_no_notify(ctx, idx, x, y, width, height);
|
||||||
|
|
||||||
st_viewport(ctx);
|
if (st_context(ctx)->invalidate_on_gl_viewport)
|
||||||
|
st_manager_invalidate_drawables(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -183,7 +185,8 @@ viewport_array(struct gl_context *ctx, GLuint first, GLsizei count,
|
||||||
inputs[i].Width, inputs[i].Height);
|
inputs[i].Width, inputs[i].Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
st_viewport(ctx);
|
if (st_context(ctx)->invalidate_on_gl_viewport)
|
||||||
|
st_manager_invalidate_drawables(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLAPIENTRY
|
void GLAPIENTRY
|
||||||
|
|
|
@ -350,8 +350,6 @@ files_libmesa = files(
|
||||||
'state_tracker/st_cb_readpixels.h',
|
'state_tracker/st_cb_readpixels.h',
|
||||||
'state_tracker/st_cb_texture.c',
|
'state_tracker/st_cb_texture.c',
|
||||||
'state_tracker/st_cb_texture.h',
|
'state_tracker/st_cb_texture.h',
|
||||||
'state_tracker/st_cb_viewport.c',
|
|
||||||
'state_tracker/st_cb_viewport.h',
|
|
||||||
'state_tracker/st_context.c',
|
'state_tracker/st_context.c',
|
||||||
'state_tracker/st_context.h',
|
'state_tracker/st_context.h',
|
||||||
'state_tracker/st_copytex.c',
|
'state_tracker/st_copytex.c',
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* Copyright 2009 VMware, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice (including the
|
|
||||||
* next paragraph) shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#include "main/glheader.h"
|
|
||||||
#include "st_context.h"
|
|
||||||
#include "st_manager.h"
|
|
||||||
#include "st_cb_viewport.h"
|
|
||||||
|
|
||||||
#include "pipe/p_state.h"
|
|
||||||
#include "pipe/p_defines.h"
|
|
||||||
#include "util/u_atomic.h"
|
|
||||||
|
|
||||||
void st_viewport(struct gl_context *ctx)
|
|
||||||
{
|
|
||||||
struct st_context *st = ctx->st;
|
|
||||||
struct gl_framebuffer *stdraw;
|
|
||||||
struct gl_framebuffer *stread;
|
|
||||||
|
|
||||||
if (!st->invalidate_on_gl_viewport)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Normally we'd want the frontend manager to mark the drawables
|
|
||||||
* invalid only when needed. This will force the frontend manager
|
|
||||||
* to revalidate the drawable, rather than just update the context with
|
|
||||||
* the latest cached drawable info.
|
|
||||||
*/
|
|
||||||
|
|
||||||
stdraw = st_ws_framebuffer(st->ctx->DrawBuffer);
|
|
||||||
stread = st_ws_framebuffer(st->ctx->ReadBuffer);
|
|
||||||
|
|
||||||
if (stdraw)
|
|
||||||
stdraw->iface_stamp = p_atomic_read(&stdraw->iface->stamp) - 1;
|
|
||||||
if (stread && stread != stdraw)
|
|
||||||
stread->iface_stamp = p_atomic_read(&stread->iface->stamp) - 1;
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* Copyright 2009 VMware, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice (including the
|
|
||||||
* next paragraph) shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#ifndef ST_CB_VIEWPORT_H
|
|
||||||
#define ST_CB_VIEWPORT_H
|
|
||||||
|
|
||||||
void st_viewport(struct gl_context *ctx);
|
|
||||||
|
|
||||||
#endif /* ST_CB_VIEW_PORT_H */
|
|
|
@ -73,6 +73,21 @@ struct st_manager_private
|
||||||
simple_mtx_t st_mutex;
|
simple_mtx_t st_mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cast wrapper to convert a struct gl_framebuffer to an gl_framebuffer.
|
||||||
|
* Return NULL if the struct gl_framebuffer is a user-created framebuffer.
|
||||||
|
* We'll only return non-null for window system framebuffers.
|
||||||
|
* Note that this function may fail.
|
||||||
|
*/
|
||||||
|
static inline struct gl_framebuffer *
|
||||||
|
st_ws_framebuffer(struct gl_framebuffer *fb)
|
||||||
|
{
|
||||||
|
/* FBO cannot be casted. See st_new_framebuffer */
|
||||||
|
if (fb && _mesa_is_winsys_fbo(fb) &&
|
||||||
|
fb != _mesa_get_incomplete_framebuffer())
|
||||||
|
return fb;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map an attachment to a buffer index.
|
* Map an attachment to a buffer index.
|
||||||
|
@ -1454,3 +1469,25 @@ st_gl_api_create(void)
|
||||||
{
|
{
|
||||||
return (struct st_api *) &st_gl_api;
|
return (struct st_api *) &st_gl_api;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
st_manager_invalidate_drawables(struct gl_context *ctx)
|
||||||
|
{
|
||||||
|
struct gl_framebuffer *stdraw;
|
||||||
|
struct gl_framebuffer *stread;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Normally we'd want the frontend manager to mark the drawables
|
||||||
|
* invalid only when needed. This will force the frontend manager
|
||||||
|
* to revalidate the drawable, rather than just update the context with
|
||||||
|
* the latest cached drawable info.
|
||||||
|
*/
|
||||||
|
|
||||||
|
stdraw = st_ws_framebuffer(ctx->DrawBuffer);
|
||||||
|
stread = st_ws_framebuffer(ctx->ReadBuffer);
|
||||||
|
|
||||||
|
if (stdraw)
|
||||||
|
stdraw->iface_stamp = p_atomic_read(&stdraw->iface->stamp) - 1;
|
||||||
|
if (stread && stread != stdraw)
|
||||||
|
stread->iface_stamp = p_atomic_read(&stread->iface->stamp) - 1;
|
||||||
|
}
|
||||||
|
|
|
@ -40,22 +40,6 @@ struct st_framebuffer_interface;
|
||||||
struct gl_renderbuffer;
|
struct gl_renderbuffer;
|
||||||
struct pipe_surface;
|
struct pipe_surface;
|
||||||
|
|
||||||
/**
|
|
||||||
* Cast wrapper to convert a struct gl_framebuffer to an gl_framebuffer.
|
|
||||||
* Return NULL if the struct gl_framebuffer is a user-created framebuffer.
|
|
||||||
* We'll only return non-null for window system framebuffers.
|
|
||||||
* Note that this function may fail.
|
|
||||||
*/
|
|
||||||
static inline struct gl_framebuffer *
|
|
||||||
st_ws_framebuffer(struct gl_framebuffer *fb)
|
|
||||||
{
|
|
||||||
/* FBO cannot be casted. See st_new_framebuffer */
|
|
||||||
if (fb && _mesa_is_winsys_fbo(fb) &&
|
|
||||||
fb != _mesa_get_incomplete_framebuffer())
|
|
||||||
return fb;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
st_manager_flush_frontbuffer(struct st_context *st);
|
st_manager_flush_frontbuffer(struct st_context *st);
|
||||||
|
|
||||||
|
@ -76,4 +60,5 @@ void
|
||||||
st_set_ws_renderbuffer_surface(struct gl_renderbuffer *rb,
|
st_set_ws_renderbuffer_surface(struct gl_renderbuffer *rb,
|
||||||
struct pipe_surface *surf);
|
struct pipe_surface *surf);
|
||||||
|
|
||||||
|
void st_manager_invalidate_drawables(struct gl_context *ctx);
|
||||||
#endif /* ST_MANAGER_H */
|
#endif /* ST_MANAGER_H */
|
||||||
|
|
Loading…
Reference in New Issue