mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
D3D: Make StateCache thread safe
This commit is contained in:
@ -212,6 +212,7 @@ StateCache::~StateCache()
|
|||||||
|
|
||||||
ID3D11SamplerState* StateCache::Get(SamplerState state)
|
ID3D11SamplerState* StateCache::Get(SamplerState state)
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> guard(m_lock);
|
||||||
auto it = m_sampler.find(state.hex);
|
auto it = m_sampler.find(state.hex);
|
||||||
if (it != m_sampler.end())
|
if (it != m_sampler.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
@ -266,6 +267,7 @@ ID3D11SamplerState* StateCache::Get(SamplerState state)
|
|||||||
|
|
||||||
ID3D11BlendState* StateCache::Get(BlendingState state)
|
ID3D11BlendState* StateCache::Get(BlendingState state)
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> guard(m_lock);
|
||||||
auto it = m_blend.find(state.hex);
|
auto it = m_blend.find(state.hex);
|
||||||
if (it != m_blend.end())
|
if (it != m_blend.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
@ -348,6 +350,7 @@ ID3D11BlendState* StateCache::Get(BlendingState state)
|
|||||||
|
|
||||||
ID3D11RasterizerState* StateCache::Get(RasterizationState state)
|
ID3D11RasterizerState* StateCache::Get(RasterizationState state)
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> guard(m_lock);
|
||||||
auto it = m_raster.find(state.hex);
|
auto it = m_raster.find(state.hex);
|
||||||
if (it != m_raster.end())
|
if (it != m_raster.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
@ -372,6 +375,7 @@ ID3D11RasterizerState* StateCache::Get(RasterizationState state)
|
|||||||
|
|
||||||
ID3D11DepthStencilState* StateCache::Get(DepthState state)
|
ID3D11DepthStencilState* StateCache::Get(DepthState state)
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> guard(m_lock);
|
||||||
auto it = m_depth.find(state.hex);
|
auto it = m_depth.find(state.hex);
|
||||||
if (it != m_depth.end())
|
if (it != m_depth.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <mutex>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "Common/BitField.h"
|
#include "Common/BitField.h"
|
||||||
@ -35,6 +36,7 @@ private:
|
|||||||
std::unordered_map<u32, ID3D11RasterizerState*> m_raster;
|
std::unordered_map<u32, ID3D11RasterizerState*> m_raster;
|
||||||
std::unordered_map<u32, ID3D11BlendState*> m_blend;
|
std::unordered_map<u32, ID3D11BlendState*> m_blend;
|
||||||
std::unordered_map<SamplerState::StorageType, ID3D11SamplerState*> m_sampler;
|
std::unordered_map<SamplerState::StorageType, ID3D11SamplerState*> m_sampler;
|
||||||
|
std::mutex m_lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace D3D
|
namespace D3D
|
||||||
|
Reference in New Issue
Block a user