radeonsi: add si_screen helper
Add a si_screen cast helper, with 2 purposes: * correctly cast from pipe_screen to si_screen using get_driver_pipe_screen * check that the result's type is correct It's only useful when intending to use pipe_resource::screen as a si_screen. Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30587>
This commit is contained in:

committed by
Marge Bot

parent
c9806b3595
commit
b7b10b971a
@@ -402,7 +402,7 @@ static void si_set_sampler_view_desc(struct si_context *sctx, struct si_sampler_
|
||||
|
||||
static bool color_needs_decompression(struct si_texture *tex)
|
||||
{
|
||||
struct si_screen *sscreen = (struct si_screen *)tex->buffer.b.b.screen;
|
||||
struct si_screen *sscreen = si_screen(tex->buffer.b.b.screen);
|
||||
|
||||
if (sscreen->info.gfx_level >= GFX11 || tex->is_depth)
|
||||
return false;
|
||||
|
@@ -975,7 +975,7 @@ static struct pipe_context *si_pipe_create_context(struct pipe_screen *screen, v
|
||||
/*
|
||||
* pipe_screen
|
||||
*/
|
||||
static void si_destroy_screen(struct pipe_screen *pscreen)
|
||||
void si_destroy_screen(struct pipe_screen *pscreen)
|
||||
{
|
||||
struct si_screen *sscreen = (struct si_screen *)pscreen;
|
||||
struct si_shader_part *parts[] = {sscreen->ps_prologs, sscreen->ps_epilogs};
|
||||
|
@@ -1625,6 +1625,7 @@ void si_init_aux_async_compute_ctx(struct si_screen *sscreen);
|
||||
struct si_context *si_get_aux_context(struct si_aux_context *ctx);
|
||||
void si_put_aux_context_flush(struct si_aux_context *ctx);
|
||||
void si_put_aux_shader_upload_context_flush(struct si_screen *sscreen);
|
||||
void si_destroy_screen(struct pipe_screen *pscreen);
|
||||
|
||||
/* si_perfcounters.c */
|
||||
void si_init_perfcounters(struct si_screen *screen);
|
||||
@@ -1743,6 +1744,18 @@ void si_handle_sqtt(struct si_context *sctx, struct radeon_cmdbuf *rcs);
|
||||
* common helpers
|
||||
*/
|
||||
|
||||
/* Use this helper when casting pipe_resouce::screen to get a real si_screen
|
||||
* instance (= this is only useful when intending to access si_screen members directly)
|
||||
*/
|
||||
static inline struct si_screen *
|
||||
si_screen(struct pipe_screen *pscreen)
|
||||
{
|
||||
struct pipe_screen *s =
|
||||
pscreen->get_driver_pipe_screen ? pscreen->get_driver_pipe_screen(pscreen) : pscreen;
|
||||
assert(s->destroy == si_destroy_screen);
|
||||
return (struct si_screen *)s;
|
||||
}
|
||||
|
||||
static inline void si_compute_reference(struct si_compute **dst, struct si_compute *src)
|
||||
{
|
||||
if (pipe_reference(&(*dst)->sel.base.reference, &src->sel.base.reference))
|
||||
@@ -1929,7 +1942,7 @@ static inline bool si_can_sample_zs(struct si_texture *tex, bool stencil_sampler
|
||||
|
||||
static inline bool si_htile_enabled(struct si_texture *tex, unsigned level, unsigned zs_mask)
|
||||
{
|
||||
struct si_screen *sscreen = (struct si_screen *)tex->buffer.b.b.screen;
|
||||
struct si_screen *sscreen = si_screen(tex->buffer.b.b.screen);
|
||||
|
||||
/* Gfx12 should never call this. */
|
||||
assert(sscreen->info.gfx_level < GFX12);
|
||||
@@ -1954,7 +1967,7 @@ static inline bool si_htile_enabled(struct si_texture *tex, unsigned level, unsi
|
||||
static inline bool vi_tc_compat_htile_enabled(struct si_texture *tex, unsigned level,
|
||||
unsigned zs_mask)
|
||||
{
|
||||
struct si_screen *sscreen = (struct si_screen *)tex->buffer.b.b.screen;
|
||||
struct si_screen *sscreen = si_screen(tex->buffer.b.b.screen);
|
||||
|
||||
/* Gfx12 should never call this. */
|
||||
assert(sscreen->info.gfx_level < GFX12);
|
||||
|
@@ -2208,7 +2208,7 @@ bool vi_dcc_formats_are_incompatible(struct pipe_resource *tex, unsigned level,
|
||||
struct si_texture *stex = (struct si_texture *)tex;
|
||||
|
||||
return vi_dcc_enabled(stex, level) &&
|
||||
!vi_dcc_formats_compatible((struct si_screen *)tex->screen, tex->format, view_format);
|
||||
!vi_dcc_formats_compatible(si_screen(tex->screen), tex->format, view_format);
|
||||
}
|
||||
|
||||
/* This can't be merged with the above function, because
|
||||
|
Reference in New Issue
Block a user