mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-06 06:32:56 +01:00
Merge pull request #24412 from ZehMatt/opengl-locking
Remove lock from TextureCache, draw calls are never done in parallel
This commit is contained in:
@@ -37,8 +37,6 @@ TextureCache::~TextureCache()
|
||||
|
||||
void TextureCache::InvalidateImage(ImageIndex image)
|
||||
{
|
||||
unique_lock lock(_mutex);
|
||||
|
||||
uint32_t index = _indexMap[image];
|
||||
if (index == kUnusedIndex)
|
||||
return;
|
||||
@@ -75,8 +73,6 @@ BasicTextureInfo TextureCache::GetOrLoadImageTexture(const ImageId imageId)
|
||||
|
||||
// Try to read cached texture first.
|
||||
{
|
||||
shared_lock lock(_mutex);
|
||||
|
||||
index = _indexMap[imageId.GetIndex()];
|
||||
if (index != kUnusedIndex)
|
||||
{
|
||||
@@ -89,8 +85,6 @@ BasicTextureInfo TextureCache::GetOrLoadImageTexture(const ImageId imageId)
|
||||
}
|
||||
|
||||
// Load new texture.
|
||||
unique_lock lock(_mutex);
|
||||
|
||||
index = static_cast<uint32_t>(_textureCache.size());
|
||||
|
||||
AtlasTextureInfo info = LoadImageTexture(imageId);
|
||||
@@ -108,8 +102,6 @@ BasicTextureInfo TextureCache::GetOrLoadGlyphTexture(const ImageId imageId, cons
|
||||
|
||||
// Try to read cached texture first.
|
||||
{
|
||||
shared_lock lock(_mutex);
|
||||
|
||||
uint8_t glyphMap[8];
|
||||
for (uint8_t i = 0; i < 8; i++)
|
||||
{
|
||||
@@ -129,8 +121,6 @@ BasicTextureInfo TextureCache::GetOrLoadGlyphTexture(const ImageId imageId, cons
|
||||
}
|
||||
|
||||
// Load new texture.
|
||||
unique_lock lock(_mutex);
|
||||
|
||||
auto cacheInfo = LoadGlyphTexture(imageId, paletteMap);
|
||||
auto it = _glyphTextureMap.insert(std::make_pair(glyphId, cacheInfo));
|
||||
|
||||
@@ -143,8 +133,6 @@ BasicTextureInfo TextureCache::GetOrLoadBitmapTexture(ImageIndex image, const vo
|
||||
|
||||
// Try to read cached texture first.
|
||||
{
|
||||
shared_lock lock(_mutex);
|
||||
|
||||
index = _indexMap[image];
|
||||
if (index != kUnusedIndex)
|
||||
{
|
||||
@@ -157,8 +145,6 @@ BasicTextureInfo TextureCache::GetOrLoadBitmapTexture(ImageIndex image, const vo
|
||||
}
|
||||
|
||||
// Load new texture.
|
||||
unique_lock lock(_mutex);
|
||||
|
||||
index = uint32_t(_textureCache.size());
|
||||
|
||||
AtlasTextureInfo info = LoadBitmapTexture(image, pixels, width, height);
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <openrct2/SpriteIds.h>
|
||||
#include <openrct2/drawing/Drawing.h>
|
||||
#include <openrct2/drawing/DrawingLock.hpp>
|
||||
#include <shared_mutex>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
@@ -201,10 +200,6 @@ namespace OpenRCT2::Ui
|
||||
GLuint _paletteTexture = 0;
|
||||
GLuint _blendPaletteTexture = 0;
|
||||
|
||||
std::shared_mutex _mutex;
|
||||
using shared_lock = DrawingSharedLock<std::shared_mutex>;
|
||||
using unique_lock = DrawingUniqueLock<std::shared_mutex>;
|
||||
|
||||
public:
|
||||
TextureCache();
|
||||
~TextureCache();
|
||||
|
||||
Reference in New Issue
Block a user