ac/surface: fix an addrlib race condition on gfx9
Addrlib calls GetMetaEquation, which generates and saves address equations
in a global table that is not thread safe.
Fixes: df2cbdd2e3
- amd/addrlib: expose DCC address equations to drivers
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6361
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16091>
This commit is contained in:
parent
f7a77ff900
commit
c4ca059dee
|
@ -93,6 +93,7 @@
|
|||
|
||||
struct ac_addrlib {
|
||||
ADDR_HANDLE handle;
|
||||
simple_mtx_t lock;
|
||||
};
|
||||
|
||||
bool ac_modifier_has_dcc(uint64_t modifier)
|
||||
|
@ -503,11 +504,13 @@ struct ac_addrlib *ac_addrlib_create(const struct radeon_info *info,
|
|||
}
|
||||
|
||||
addrlib->handle = addrCreateOutput.hLib;
|
||||
simple_mtx_init(&addrlib->lock, mtx_plain);
|
||||
return addrlib;
|
||||
}
|
||||
|
||||
void ac_addrlib_destroy(struct ac_addrlib *addrlib)
|
||||
{
|
||||
simple_mtx_destroy(&addrlib->lock);
|
||||
AddrDestroy(addrlib->handle);
|
||||
free(addrlib);
|
||||
}
|
||||
|
@ -1829,7 +1832,12 @@ static int gfx9_compute_miptree(struct ac_addrlib *addrlib, const struct radeon_
|
|||
din.dataSurfaceSize = out.surfSize;
|
||||
din.firstMipIdInTail = out.firstMipIdInTail;
|
||||
|
||||
if (info->chip_class == GFX9)
|
||||
simple_mtx_lock(&addrlib->lock);
|
||||
ret = Addr2ComputeDccInfo(addrlib->handle, &din, &dout);
|
||||
if (info->chip_class == GFX9)
|
||||
simple_mtx_unlock(&addrlib->lock);
|
||||
|
||||
if (ret != ADDR_OK)
|
||||
return ret;
|
||||
|
||||
|
@ -1910,7 +1918,12 @@ static int gfx9_compute_miptree(struct ac_addrlib *addrlib, const struct radeon_
|
|||
assert(surf->tile_swizzle == 0);
|
||||
assert(surf->u.gfx9.color.dcc.pipe_aligned || surf->u.gfx9.color.dcc.rb_aligned);
|
||||
|
||||
if (info->chip_class == GFX9)
|
||||
simple_mtx_lock(&addrlib->lock);
|
||||
ret = Addr2ComputeDccInfo(addrlib->handle, &din, &dout);
|
||||
if (info->chip_class == GFX9)
|
||||
simple_mtx_unlock(&addrlib->lock);
|
||||
|
||||
if (ret != ADDR_OK)
|
||||
return ret;
|
||||
|
||||
|
@ -2010,7 +2023,12 @@ static int gfx9_compute_miptree(struct ac_addrlib *addrlib, const struct radeon_
|
|||
else
|
||||
cin.swizzleMode = in->swizzleMode;
|
||||
|
||||
if (info->chip_class == GFX9)
|
||||
simple_mtx_lock(&addrlib->lock);
|
||||
ret = Addr2ComputeCmaskInfo(addrlib->handle, &cin, &cout);
|
||||
if (info->chip_class == GFX9)
|
||||
simple_mtx_unlock(&addrlib->lock);
|
||||
|
||||
if (ret != ADDR_OK)
|
||||
return ret;
|
||||
|
||||
|
|
Loading…
Reference in New Issue