Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 217813004: Make ShaderTranslatorCache thread safe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: protect ShFinalize Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/gles2_cmd_decoder.cc
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index c3bdae5d5d94a78b9cfa80d8087581f367118ec0..abaaaba3bf1492c37c120c29d447af9166bd4107 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -580,12 +580,14 @@ class GLES2DecoderImpl : public GLES2Decoder,
virtual const char* GetCommandName(unsigned int command_id) const OVERRIDE;
// Overridden from GLES2Decoder.
- virtual bool Initialize(const scoped_refptr<gfx::GLSurface>& surface,
- const scoped_refptr<gfx::GLContext>& context,
- bool offscreen,
- const gfx::Size& size,
- const DisallowedFeatures& disallowed_features,
- const std::vector<int32>& attribs) OVERRIDE;
+ virtual bool Initialize(
+ const scoped_refptr<gfx::GLSurface>& surface,
+ const scoped_refptr<gfx::GLContext>& context,
+ const scoped_refptr<ShaderTranslatorCache>& shader_translator_cache,
+ bool offscreen,
+ const gfx::Size& size,
+ const DisallowedFeatures& disallowed_features,
+ const std::vector<int32>& attribs) OVERRIDE;
virtual void Destroy(bool have_context) OVERRIDE;
virtual void SetSurface(
const scoped_refptr<gfx::GLSurface>& surface) OVERRIDE;
@@ -1724,6 +1726,7 @@ class GLES2DecoderImpl : public GLES2Decoder,
error::Error current_decoder_error_;
bool use_shader_translator_;
+ scoped_refptr<ShaderTranslatorCache> shader_translator_cache_;
scoped_refptr<ShaderTranslator> vertex_translator_;
scoped_refptr<ShaderTranslator> fragment_translator_;
@@ -2285,6 +2288,7 @@ GLES2DecoderImpl::~GLES2DecoderImpl() {
bool GLES2DecoderImpl::Initialize(
const scoped_refptr<gfx::GLSurface>& surface,
const scoped_refptr<gfx::GLContext>& context,
+ const scoped_refptr<ShaderTranslatorCache>& shader_translator_cache,
bool offscreen,
const gfx::Size& size,
const DisallowedFeatures& disallowed_features,
@@ -2319,6 +2323,8 @@ bool GLES2DecoderImpl::Initialize(
context_ = context;
surface_ = surface;
+ shader_translator_cache_ = shader_translator_cache;
+
ContextCreationAttribHelper attrib_parser;
if (!attrib_parser.Parse(attribs))
return false;
@@ -2750,8 +2756,7 @@ bool GLES2DecoderImpl::InitializeShaderTranslator() {
if (workarounds().unroll_for_loop_with_sampler_array_index)
driver_bug_workarounds |= SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX;
- ShaderTranslatorCache* cache = ShaderTranslatorCache::GetInstance();
- vertex_translator_ = cache->GetTranslator(
+ vertex_translator_ = shader_translator_cache_->GetTranslator(
SH_VERTEX_SHADER, shader_spec, &resources,
implementation_type,
static_cast<ShCompileOptions>(driver_bug_workarounds));
@@ -2761,7 +2766,7 @@ bool GLES2DecoderImpl::InitializeShaderTranslator() {
return false;
}
- fragment_translator_ = cache->GetTranslator(
+ fragment_translator_ = shader_translator_cache_->GetTranslator(
SH_FRAGMENT_SHADER, shader_spec, &resources,
implementation_type,
static_cast<ShCompileOptions>(driver_bug_workarounds));

Powered by Google App Engine
This is Rietveld 408576698