android: video_core: gl_rasterizer_cache: Make cache access thread safe.

master
bunnei 2019-10-01 23:53:43 +07:00 committed by SachinVin
parent 4f737c329e
commit 5a31aa175d
2 changed files with 11 additions and 0 deletions

@ -1832,6 +1832,8 @@ void RasterizerCacheOpenGL::ClearAll(bool flush) {
} }
void RasterizerCacheOpenGL::FlushRegion(PAddr addr, u32 size, Surface flush_surface) { void RasterizerCacheOpenGL::FlushRegion(PAddr addr, u32 size, Surface flush_surface) {
std::lock_guard lock{mutex};
if (size == 0) if (size == 0)
return; return;
@ -1868,6 +1870,8 @@ void RasterizerCacheOpenGL::FlushAll() {
} }
void RasterizerCacheOpenGL::InvalidateRegion(PAddr addr, u32 size, const Surface& region_owner) { void RasterizerCacheOpenGL::InvalidateRegion(PAddr addr, u32 size, const Surface& region_owner) {
std::lock_guard lock{mutex};
if (size == 0) if (size == 0)
return; return;
@ -1943,6 +1947,8 @@ Surface RasterizerCacheOpenGL::CreateSurface(const SurfaceParams& params) {
} }
void RasterizerCacheOpenGL::RegisterSurface(const Surface& surface) { void RasterizerCacheOpenGL::RegisterSurface(const Surface& surface) {
std::lock_guard lock{mutex};
if (surface->registered) { if (surface->registered) {
return; return;
} }
@ -1952,6 +1958,8 @@ void RasterizerCacheOpenGL::RegisterSurface(const Surface& surface) {
} }
void RasterizerCacheOpenGL::UnregisterSurface(const Surface& surface) { void RasterizerCacheOpenGL::UnregisterSurface(const Surface& surface) {
std::lock_guard lock{mutex};
if (!surface->registered) { if (!surface->registered) {
return; return;
} }

@ -7,6 +7,7 @@
#include <array> #include <array>
#include <list> #include <list>
#include <memory> #include <memory>
#include <mutex>
#include <set> #include <set>
#include <tuple> #include <tuple>
#ifdef __GNUC__ #ifdef __GNUC__
@ -365,6 +366,8 @@ private:
std::unordered_map<TextureCubeConfig, CachedTextureCube> texture_cube_cache; std::unordered_map<TextureCubeConfig, CachedTextureCube> texture_cube_cache;
std::recursive_mutex mutex;
public: public:
OGLTexture AllocateSurfaceTexture(const FormatTuple& format_tuple, u32 width, u32 height); OGLTexture AllocateSurfaceTexture(const FormatTuple& format_tuple, u32 width, u32 height);