diff options
author | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-06 18:07:24 +0000 |
---|---|---|
committer | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-06 18:07:24 +0000 |
commit | c2f8c84089f32aac6377c95da14d52153a165b39 (patch) | |
tree | 91e39d58e5b54b21d2f6070654a0e89208cd5236 /gpu/command_buffer/service | |
parent | 5ac981e18bcad738dbe3e34a59c5814a9f00ea08 (diff) | |
download | chromium_src-c2f8c84089f32aac6377c95da14d52153a165b39.zip chromium_src-c2f8c84089f32aac6377c95da14d52153a165b39.tar.gz chromium_src-c2f8c84089f32aac6377c95da14d52153a165b39.tar.bz2 |
Exposed support for dynamically enabling extensions in command buffer
implementation via new glGetRequestableExtensionsCHROMIUM and
glRequestExtensionCHROMIUM entry points. These entry points are needed in
order to allow WebGL to both query the available extensions and enable them
individually.
Added these entry points to WebGraphicsContext3DCommandBufferImpl. A
subsequent WebKit checkin under https://bugs.webkit.org/show_bug.cgi?id=40316
will utilize them and implement the OES_texture_float extension for WebGL.
BUG=none
TEST=none (ran with new oes-texture-float.html WebGL conformance test)
Review URL: http://codereview.chromium.org/5626008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68352 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service')
10 files changed, 207 insertions, 111 deletions
diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc index cf755d8..5d9403e 100644 --- a/gpu/command_buffer/service/feature_info.cc +++ b/gpu/command_buffer/service/feature_info.cc @@ -215,21 +215,32 @@ void FeatureInfo::AddFeatures(const char* desired_features) { bool enable_texture_float_linear = false; bool enable_texture_half_float = false; bool enable_texture_half_float_linear = false; - if (ext.HaveAndDesire("GL_ARB_texture_float")) { + + bool have_arb_texture_float = ext.Have("GL_ARB_texture_float"); + + if (have_arb_texture_float && ext.Desire("GL_ARB_texture_float")) { enable_texture_float = true; enable_texture_float_linear = true; enable_texture_half_float = true; enable_texture_half_float_linear = true; } else { - if (ext.HaveAndDesire("GL_OES_texture_float")) { + if (ext.HaveAndDesire("GL_OES_texture_float") || + (have_arb_texture_float && + ext.Desire("GL_OES_texture_float"))) { enable_texture_float = true; - if (ext.HaveAndDesire("GL_OES_texture_float_linear")) { + if (ext.HaveAndDesire("GL_OES_texture_float_linear") || + (have_arb_texture_float && + ext.Desire("GL_OES_texture_float_linear"))) { enable_texture_float_linear = true; } } - if (ext.HaveAndDesire("GL_OES_texture_half_float")) { + if (ext.HaveAndDesire("GL_OES_texture_half_float") || + (have_arb_texture_float && + ext.Desire("GL_OES_texture_half_float"))) { enable_texture_half_float = true; - if (ext.HaveAndDesire("GL_OES_texture_half_float_linear")) { + if (ext.HaveAndDesire("GL_OES_texture_half_float_linear") || + (have_arb_texture_float && + ext.Desire("GL_OES_texture_half_float_linear"))) { enable_texture_half_float_linear = true; } } diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 6c468ca..5d373fc 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -708,6 +708,9 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>, TextureManager::TextureInfo::Ref bound_texture_cube_map; }; + // Initialize or re-initialize the shader translator. + bool InitializeShaderTranslator(); + // Helpers for the glGen and glDelete functions. bool GenTexturesHelper(GLsizei n, const GLuint* client_ids); void DeleteTexturesHelper(GLsizei n, const GLuint* client_ids); @@ -1767,12 +1770,15 @@ GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) attrib_0_value_.v[2] = 0.0f; attrib_0_value_.v[3] = 1.0f; - // The shader translator is not needed for EGL because it already uses the - // GLSL ES syntax. It is translated for the unit tests because - // GLES2DecoderWithShaderTest.GetShaderInfoLogValidArgs passes the empty - // string to CompileShader and this is not a valid shader. TODO(apatrick): - // fix this test. - if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 || + // The shader translator is used for WebGL even when running on EGL + // because additional restrictions are needed (like only enabling + // GL_OES_standard_derivatives on demand). It is used for the unit + // tests because + // GLES2DecoderWithShaderTest.GetShaderInfoLogValidArgs passes the + // empty string to CompileShader and this is not a valid shader. + // TODO(apatrick): fix this test. + if ((gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 && + !feature_info_->feature_flags().chromium_webglsl) || gfx::GetGLImplementation() == gfx::kGLImplementationMockGL) { use_shader_translator_ = false; } @@ -1981,42 +1987,59 @@ bool GLES2DecoderImpl::Initialize(gfx::GLContext* context, glEnable(GL_POINT_SPRITE); } - if (use_shader_translator_) { - ShBuiltInResources resources; - ShInitBuiltInResources(&resources); - resources.MaxVertexAttribs = group_->max_vertex_attribs(); - resources.MaxVertexUniformVectors = - group_->max_vertex_uniform_vectors(); - resources.MaxVaryingVectors = group_->max_varying_vectors(); - resources.MaxVertexTextureImageUnits = - group_->max_vertex_texture_image_units(); - resources.MaxCombinedTextureImageUnits = group_->max_texture_units(); - resources.MaxTextureImageUnits = group_->max_texture_image_units(); - resources.MaxFragmentUniformVectors = - group_->max_fragment_uniform_vectors(); - resources.MaxDrawBuffers = 1; - resources.OES_standard_derivatives = - feature_info_->feature_flags().oes_standard_derivatives ? 1 : 0; - vertex_translator_.reset(new ShaderTranslator); - ShShaderSpec shader_spec = feature_info_->feature_flags().chromium_webglsl ? - SH_WEBGL_SPEC : SH_GLES2_SPEC; - if (!vertex_translator_->Init(SH_VERTEX_SHADER, shader_spec, &resources)) { - LOG(ERROR) << "Could not initialize vertex shader translator."; - Destroy(); - return false; - } - fragment_translator_.reset(new ShaderTranslator); - if (!fragment_translator_->Init( - SH_FRAGMENT_SHADER, shader_spec, &resources)) { - LOG(ERROR) << "Could not initialize fragment shader translator."; - Destroy(); - return false; - } + if (!InitializeShaderTranslator()) { + return false; } return true; } +bool GLES2DecoderImpl::InitializeShaderTranslator() { + // Re-check the state of use_shader_translator_ each time this is called. + if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 && + feature_info_->feature_flags().chromium_webglsl && + !use_shader_translator_) { + use_shader_translator_ = true; + } + if (!use_shader_translator_) { + return true; + } + ShBuiltInResources resources; + ShInitBuiltInResources(&resources); + resources.MaxVertexAttribs = group_->max_vertex_attribs(); + resources.MaxVertexUniformVectors = + group_->max_vertex_uniform_vectors(); + resources.MaxVaryingVectors = group_->max_varying_vectors(); + resources.MaxVertexTextureImageUnits = + group_->max_vertex_texture_image_units(); + resources.MaxCombinedTextureImageUnits = group_->max_texture_units(); + resources.MaxTextureImageUnits = group_->max_texture_image_units(); + resources.MaxFragmentUniformVectors = + group_->max_fragment_uniform_vectors(); + resources.MaxDrawBuffers = 1; + resources.OES_standard_derivatives = + feature_info_->feature_flags().oes_standard_derivatives ? 1 : 0; + vertex_translator_.reset(new ShaderTranslator); + ShShaderSpec shader_spec = feature_info_->feature_flags().chromium_webglsl ? + SH_WEBGL_SPEC : SH_GLES2_SPEC; + bool is_glsl_es = + gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2; + if (!vertex_translator_->Init( + SH_VERTEX_SHADER, shader_spec, &resources, is_glsl_es)) { + LOG(ERROR) << "Could not initialize vertex shader translator."; + Destroy(); + return false; + } + fragment_translator_.reset(new ShaderTranslator); + if (!fragment_translator_->Init( + SH_FRAGMENT_SHADER, shader_spec, &resources, is_glsl_es)) { + LOG(ERROR) << "Could not initialize fragment shader translator."; + Destroy(); + return false; + } + return true; +} + bool GLES2DecoderImpl::GenBuffersHelper(GLsizei n, const GLuint* client_ids) { for (GLsizei ii = 0; ii < n; ++ii) { if (GetBufferInfo(client_ids[ii])) { @@ -5935,6 +5958,43 @@ error::Error GLES2DecoderImpl::HandleCommandBufferEnableCHROMIUM( return error::kNoError; } +error::Error GLES2DecoderImpl::HandleGetRequestableExtensionsCHROMIUM( + uint32 immediate_data_size, + const gles2::GetRequestableExtensionsCHROMIUM& c) { + Bucket* bucket = CreateBucket(c.bucket_id); + scoped_ptr<FeatureInfo> info(new FeatureInfo()); + info->Initialize(NULL); + bucket->SetFromString(info->extensions().c_str()); + return error::kNoError; +} + +error::Error GLES2DecoderImpl::HandleRequestExtensionCHROMIUM( + uint32 immediate_data_size, const gles2::RequestExtensionCHROMIUM& c) { + Bucket* bucket = GetBucket(c.bucket_id); + std::string feature_str; + if (!bucket->GetAsString(&feature_str)) { + return error::kInvalidArguments; + } + + bool std_derivatives_enabled = + feature_info_->feature_flags().oes_standard_derivatives; + bool webglsl_enabled = + feature_info_->feature_flags().chromium_webglsl; + + feature_info_->AddFeatures(feature_str.c_str()); + + // If we just enabled a feature which affects the shader translator, + // we may need to re-initialize it. + if (std_derivatives_enabled != + feature_info_->feature_flags().oes_standard_derivatives || + webglsl_enabled != + feature_info_->feature_flags().chromium_webglsl) { + InitializeShaderTranslator(); + } + + return error::kNoError; +} + // Include the auto-generated part of this file. We split this because it means // we can easily edit the non-auto generated parts right here in this file // instead of having to edit some template or the code generator. diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1.cc index 9237a20..75597fa 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1.cc @@ -119,6 +119,17 @@ void GLES2DecoderTestBase::SpecializedSetup<GetProgramInfoLog, 0>( info->set_log_info("hello"); }; +template <> +void GLES2DecoderTestBase::SpecializedSetup<GetVertexAttribfv, 0>(bool valid) { + DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); + DoVertexAttribPointer(1, 1, GL_FLOAT, 0, 0); + if (valid) { + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); + } +}; #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h" diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h index eaa7af3..786ad92 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h @@ -1755,5 +1755,47 @@ TEST_F(GLES2DecoderTest1, GetTexParameterivInvalidArgs2_1) { // TODO(gman): GetUniformLocationBucket + +TEST_F(GLES2DecoderTest1, GetVertexAttribfvValidArgs) { + SpecializedSetup<GetVertexAttribfv, 0>(true); + typedef GetVertexAttribfv::Result Result; + Result* result = static_cast<Result*>(shared_memory_address_); + result->size = 0; + GetVertexAttribfv cmd; + cmd.Init( + 1, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( + GL_VERTEX_ATTRIB_ARRAY_NORMALIZED), + result->GetNumResults()); + EXPECT_EQ(GL_NO_ERROR, GetGLError()); +} + +TEST_F(GLES2DecoderTest1, GetVertexAttribfvInvalidArgs2_0) { + EXPECT_CALL(*gl_, GetVertexAttribfv(_, _, _)).Times(0); + SpecializedSetup<GetVertexAttribfv, 0>(false); + GetVertexAttribfv::Result* result = + static_cast<GetVertexAttribfv::Result*>(shared_memory_address_); + result->size = 0; + GetVertexAttribfv cmd; + cmd.Init(1, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, kInvalidSharedMemoryId, 0); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0u, result->size); +} + +TEST_F(GLES2DecoderTest1, GetVertexAttribfvInvalidArgs2_1) { + EXPECT_CALL(*gl_, GetVertexAttribfv(_, _, _)).Times(0); + SpecializedSetup<GetVertexAttribfv, 0>(false); + GetVertexAttribfv::Result* result = + static_cast<GetVertexAttribfv::Result*>(shared_memory_address_); + result->size = 0; + GetVertexAttribfv cmd; + cmd.Init( + 1, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, shared_memory_id_, + kInvalidSharedMemoryOffset); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0u, result->size); +} #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_1_AUTOGEN_H_ diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc index 925e28f..a86149f 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc @@ -224,18 +224,6 @@ void GLES2DecoderTestBase::SpecializedSetup<TexParameterivImmediate, 0>( }; template <> -void GLES2DecoderTestBase::SpecializedSetup<GetVertexAttribfv, 0>(bool valid) { - DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); - DoVertexAttribPointer(1, 1, GL_FLOAT, 0, 0); - if (valid) { - EXPECT_CALL(*gl_, GetError()) - .WillOnce(Return(GL_NO_ERROR)) - .WillOnce(Return(GL_NO_ERROR)) - .RetiresOnSaturation(); - } -}; - -template <> void GLES2DecoderTestBase::SpecializedSetup<GetVertexAttribiv, 0>(bool valid) { DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); DoVertexAttribPointer(1, 1, GL_FLOAT, 0, 0); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h index 7b0d1c9..7549fa9e 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h @@ -9,48 +9,6 @@ #define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_2_AUTOGEN_H_ -TEST_F(GLES2DecoderTest2, GetVertexAttribfvValidArgs) { - SpecializedSetup<GetVertexAttribfv, 0>(true); - typedef GetVertexAttribfv::Result Result; - Result* result = static_cast<Result*>(shared_memory_address_); - result->size = 0; - GetVertexAttribfv cmd; - cmd.Init( - 1, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, shared_memory_id_, - shared_memory_offset_); - EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( - GL_VERTEX_ATTRIB_ARRAY_NORMALIZED), - result->GetNumResults()); - EXPECT_EQ(GL_NO_ERROR, GetGLError()); -} - -TEST_F(GLES2DecoderTest2, GetVertexAttribfvInvalidArgs2_0) { - EXPECT_CALL(*gl_, GetVertexAttribfv(_, _, _)).Times(0); - SpecializedSetup<GetVertexAttribfv, 0>(false); - GetVertexAttribfv::Result* result = - static_cast<GetVertexAttribfv::Result*>(shared_memory_address_); - result->size = 0; - GetVertexAttribfv cmd; - cmd.Init(1, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, kInvalidSharedMemoryId, 0); - EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); - EXPECT_EQ(0u, result->size); -} - -TEST_F(GLES2DecoderTest2, GetVertexAttribfvInvalidArgs2_1) { - EXPECT_CALL(*gl_, GetVertexAttribfv(_, _, _)).Times(0); - SpecializedSetup<GetVertexAttribfv, 0>(false); - GetVertexAttribfv::Result* result = - static_cast<GetVertexAttribfv::Result*>(shared_memory_address_); - result->size = 0; - GetVertexAttribfv cmd; - cmd.Init( - 1, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, shared_memory_id_, - kInvalidSharedMemoryOffset); - EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); - EXPECT_EQ(0u, result->size); -} - TEST_F(GLES2DecoderTest2, GetVertexAttribivValidArgs) { SpecializedSetup<GetVertexAttribiv, 0>(true); typedef GetVertexAttribiv::Result Result; @@ -1611,5 +1569,9 @@ TEST_F(GLES2DecoderTest2, ViewportInvalidArgs3_0) { // TODO(gman): CopyTextureToParentTextureCHROMIUM // TODO(gman): ResizeCHROMIUM +// TODO(gman): GetRequestableExtensionsCHROMIUM + +// TODO(gman): RequestExtensionCHROMIUM + #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_2_AUTOGEN_H_ diff --git a/gpu/command_buffer/service/mocks.h b/gpu/command_buffer/service/mocks.h index 8c84547..8a11aee 100644 --- a/gpu/command_buffer/service/mocks.h +++ b/gpu/command_buffer/service/mocks.h @@ -83,10 +83,11 @@ class MockShaderTranslator : public ShaderTranslatorInterface { public: virtual ~MockShaderTranslator() { } - MOCK_METHOD3(Init, bool( + MOCK_METHOD4(Init, bool( ShShaderType shader_type, ShShaderSpec shader_spec, - const ShBuiltInResources* resources)); + const ShBuiltInResources* resources, + bool implementation_is_glsl_es)); MOCK_METHOD1(Translate, bool(const char* shader)); MOCK_CONST_METHOD0(translated_shader, const char*()); MOCK_CONST_METHOD0(info_log, const char*()); diff --git a/gpu/command_buffer/service/shader_translator.cc b/gpu/command_buffer/service/shader_translator.cc index 551ae14..eb5b265 100644 --- a/gpu/command_buffer/service/shader_translator.cc +++ b/gpu/command_buffer/service/shader_translator.cc @@ -4,6 +4,8 @@ #include "gpu/command_buffer/service/shader_translator.h" +#include <string.h> + #include "base/at_exit.h" #include "base/logging.h" @@ -62,7 +64,9 @@ void GetVariableInfo(ShHandle compiler, ShShaderInfo var_type, namespace gpu { namespace gles2 { -ShaderTranslator::ShaderTranslator() : compiler_(NULL) { +ShaderTranslator::ShaderTranslator() + : compiler_(NULL), + implementation_is_glsl_es_(false) { } ShaderTranslator::~ShaderTranslator() { @@ -72,7 +76,8 @@ ShaderTranslator::~ShaderTranslator() { bool ShaderTranslator::Init(ShShaderType shader_type, ShShaderSpec shader_spec, - const ShBuiltInResources* resources) { + const ShBuiltInResources* resources, + bool implementation_is_glsl_es) { // Make sure Init is called only once. DCHECK(compiler_ == NULL); DCHECK(shader_type == SH_FRAGMENT_SHADER || shader_type == SH_VERTEX_SHADER); @@ -83,6 +88,7 @@ bool ShaderTranslator::Init(ShShaderType shader_type, return false; compiler_ = ShConstructCompiler(shader_type, shader_spec, resources); + implementation_is_glsl_es_ = implementation_is_glsl_es; return compiler_ != NULL; } @@ -96,12 +102,23 @@ bool ShaderTranslator::Translate(const char* shader) { int compile_options = SH_OBJECT_CODE | SH_ATTRIBUTES_UNIFORMS; if (ShCompile(compiler_, &shader, 1, compile_options)) { success = true; - // Get translated shader. - int obj_code_len = 0; - ShGetInfo(compiler_, SH_OBJECT_CODE_LENGTH, &obj_code_len); - if (obj_code_len > 1) { - translated_shader_.reset(new char[obj_code_len]); - ShGetObjectCode(compiler_, translated_shader_.get()); + if (!implementation_is_glsl_es_) { + // Get translated shader. + int obj_code_len = 0; + ShGetInfo(compiler_, SH_OBJECT_CODE_LENGTH, &obj_code_len); + if (obj_code_len > 1) { + translated_shader_.reset(new char[obj_code_len]); + ShGetObjectCode(compiler_, translated_shader_.get()); + } + } else { + // Pass down the original shader's source rather than the + // compiler's output. TODO(kbr): once the shader compiler has a + // GLSL ES backend, use its output. + int shader_code_len = 1 + strlen(shader); + if (shader_code_len > 1) { + translated_shader_.reset(new char[shader_code_len]); + strncpy(translated_shader_.get(), shader, shader_code_len); + } } // Get info for attribs and uniforms. GetVariableInfo(compiler_, SH_ACTIVE_ATTRIBUTES, &attrib_map_); diff --git a/gpu/command_buffer/service/shader_translator.h b/gpu/command_buffer/service/shader_translator.h index 852ee5f..084d1b8 100644 --- a/gpu/command_buffer/service/shader_translator.h +++ b/gpu/command_buffer/service/shader_translator.h @@ -15,7 +15,8 @@ namespace gpu { namespace gles2 { -// Translates GLSL ES 2.0 shader to desktop GLSL shader. +// Translates a GLSL ES 2.0 shader to desktop GLSL shader, or just +// validates GLSL ES 2.0 shaders on a true GLSL ES implementation. class ShaderTranslatorInterface { public: virtual ~ShaderTranslatorInterface() { } @@ -25,7 +26,8 @@ class ShaderTranslatorInterface { virtual bool Init( ShShaderType shader_type, ShShaderSpec shader_spec, - const ShBuiltInResources* resources) = 0; + const ShBuiltInResources* resources, + bool implementation_is_glsl_es) = 0; // Translates the given shader source. // Returns true if translation is successful, false otherwise. @@ -66,7 +68,8 @@ class ShaderTranslator : public ShaderTranslatorInterface { virtual bool Init( ShShaderType shader_type, ShShaderSpec shader_spec, - const ShBuiltInResources* resources); + const ShBuiltInResources* resources, + bool implementation_is_glsl_es); // Overridden from ShaderTranslatorInterface. virtual bool Translate(const char* shader); @@ -88,6 +91,7 @@ class ShaderTranslator : public ShaderTranslatorInterface { scoped_array<char> info_log_; VariableMap attrib_map_; VariableMap uniform_map_; + bool implementation_is_glsl_es_; DISALLOW_COPY_AND_ASSIGN(ShaderTranslator); }; diff --git a/gpu/command_buffer/service/shader_translator_unittest.cc b/gpu/command_buffer/service/shader_translator_unittest.cc index dbd9c60..5238859 100644 --- a/gpu/command_buffer/service/shader_translator_unittest.cc +++ b/gpu/command_buffer/service/shader_translator_unittest.cc @@ -22,9 +22,9 @@ class ShaderTranslatorTest : public testing::Test { ShInitBuiltInResources(&resources); ASSERT_TRUE(vertex_translator_.Init( - SH_VERTEX_SHADER, SH_GLES2_SPEC, &resources)); + SH_VERTEX_SHADER, SH_GLES2_SPEC, &resources, false)); ASSERT_TRUE(fragment_translator_.Init( - SH_FRAGMENT_SHADER, SH_GLES2_SPEC, &resources)); + SH_FRAGMENT_SHADER, SH_GLES2_SPEC, &resources, false)); // Post-init the results must be empty. // Vertex translator results. EXPECT_TRUE(vertex_translator_.translated_shader() == NULL); |