Skip to content

Commit

Permalink
gpu: Use the sh-scoped translator methods.
Browse files Browse the repository at this point in the history
The old ShCompile will be removed and replaced with sh::Compile in
ANGLE to avoid conflicting with glslang's identically named methods.

BUG=angleproject:1319
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2610603002
Cr-Commit-Position: refs/heads/master@{#441166}
  • Loading branch information
null77 authored and Commit bot committed Jan 3, 2017
1 parent f5845f6 commit d16b210
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 32 deletions.
4 changes: 2 additions & 2 deletions gpu/angle_unittest_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ int RunHelper(base::TestSuite* test_suite) {
int main(int argc, char** argv) {
base::CommandLine::Init(argc, argv);
testing::InitGoogleMock(&argc, argv);
ShInitialize();
sh::Initialize();
base::TestSuite test_suite(argc, argv);
int rt = base::LaunchUnitTestsSerially(
argc,
argv,
base::Bind(&RunHelper, base::Unretained(&test_suite)));
ShFinalize();
sh::Finalize();
return rt;
}
2 changes: 1 addition & 1 deletion gpu/command_buffer/service/gles2_cmd_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3748,7 +3748,7 @@ bool GLES2DecoderImpl::InitializeShaderTranslator() {
return true;
}
ShBuiltInResources resources;
ShInitBuiltInResources(&resources);
sh::InitBuiltInResources(&resources);
resources.MaxVertexAttribs = group_->max_vertex_attribs();
resources.MaxVertexUniformVectors =
group_->max_vertex_uniform_vectors();
Expand Down
5 changes: 2 additions & 3 deletions gpu/command_buffer/service/program_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2080,9 +2080,8 @@ bool Program::CheckVaryingsPacking(
for (const auto& key_value : combined_map) {
variables.push_back(*key_value.second);
}
return ShCheckVariablesWithinPackingLimits(
static_cast<int>(manager_->max_varying_vectors()),
variables);
return sh::CheckVariablesWithinPackingLimits(
static_cast<int>(manager_->max_varying_vectors()), variables);
}

void Program::GetProgramInfo(
Expand Down
37 changes: 18 additions & 19 deletions gpu/command_buffer/service/shader_translator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ class ShaderTranslatorInitializer {
public:
ShaderTranslatorInitializer() {
TRACE_EVENT0("gpu", "ShInitialize");
CHECK(ShInitialize());
CHECK(sh::Initialize());
}

~ShaderTranslatorInitializer() {
TRACE_EVENT0("gpu", "ShFinalize");
ShFinalize();
sh::Finalize();
}
};

Expand All @@ -43,7 +43,7 @@ void GetAttributes(ShHandle compiler, AttributeMap* var_map) {
if (!var_map)
return;
var_map->clear();
const std::vector<sh::Attribute>* attribs = ShGetAttributes(compiler);
const std::vector<sh::Attribute>* attribs = sh::GetAttributes(compiler);
if (attribs) {
for (size_t ii = 0; ii < attribs->size(); ++ii)
(*var_map)[(*attribs)[ii].mappedName] = (*attribs)[ii];
Expand All @@ -54,7 +54,7 @@ void GetUniforms(ShHandle compiler, UniformMap* var_map) {
if (!var_map)
return;
var_map->clear();
const std::vector<sh::Uniform>* uniforms = ShGetUniforms(compiler);
const std::vector<sh::Uniform>* uniforms = sh::GetUniforms(compiler);
if (uniforms) {
for (size_t ii = 0; ii < uniforms->size(); ++ii)
(*var_map)[(*uniforms)[ii].mappedName] = (*uniforms)[ii];
Expand All @@ -65,7 +65,7 @@ void GetVaryings(ShHandle compiler, VaryingMap* var_map) {
if (!var_map)
return;
var_map->clear();
const std::vector<sh::Varying>* varyings = ShGetVaryings(compiler);
const std::vector<sh::Varying>* varyings = sh::GetVaryings(compiler);
if (varyings) {
for (size_t ii = 0; ii < varyings->size(); ++ii)
(*var_map)[(*varyings)[ii].mappedName] = (*varyings)[ii];
Expand All @@ -74,15 +74,15 @@ void GetVaryings(ShHandle compiler, VaryingMap* var_map) {
void GetOutputVariables(ShHandle compiler, OutputVariableList* var_list) {
if (!var_list)
return;
*var_list = *ShGetOutputVariables(compiler);
*var_list = *sh::GetOutputVariables(compiler);
}

void GetInterfaceBlocks(ShHandle compiler, InterfaceBlockMap* var_map) {
if (!var_map)
return;
var_map->clear();
const std::vector<sh::InterfaceBlock>* interface_blocks =
ShGetInterfaceBlocks(compiler);
sh::GetInterfaceBlocks(compiler);
if (interface_blocks) {
for (const auto& block : *interface_blocks) {
(*var_map)[block.mappedName] = block;
Expand All @@ -96,7 +96,7 @@ void GetNameHashingInfo(ShHandle compiler, NameMap* name_map) {
name_map->clear();

typedef std::map<std::string, std::string> NameMapANGLE;
const NameMapANGLE* angle_map = ShGetNameHashingMap(compiler);
const NameMapANGLE* angle_map = sh::GetNameHashingMap(compiler);
DCHECK(angle_map);

for (NameMapANGLE::const_iterator iter = angle_map->begin();
Expand Down Expand Up @@ -182,8 +182,8 @@ bool ShaderTranslator::Init(GLenum shader_type,

{
TRACE_EVENT0("gpu", "ShConstructCompiler");
compiler_ = ShConstructCompiler(shader_type, shader_spec,
shader_output_language, resources);
compiler_ = sh::ConstructCompiler(shader_type, shader_spec,
shader_output_language, resources);
}

compile_options_ =
Expand Down Expand Up @@ -226,16 +226,15 @@ bool ShaderTranslator::Translate(const std::string& shader_source,
{
TRACE_EVENT0("gpu", "ShCompile");
const char* const shader_strings[] = { shader_source.c_str() };
success = ShCompile(
compiler_, shader_strings, 1, GetCompileOptions());
success = sh::Compile(compiler_, shader_strings, 1, GetCompileOptions());
}
if (success) {
// Get translated shader.
if (translated_source) {
*translated_source = ShGetObjectCode(compiler_);
*translated_source = sh::GetObjectCode(compiler_);
}
// Get shader version.
*shader_version = ShGetShaderVersion(compiler_);
*shader_version = sh::GetShaderVersion(compiler_);
// Get info for attribs, uniforms, varyings and output variables.
GetAttributes(compiler_, attrib_map);
GetUniforms(compiler_, uniform_map);
Expand All @@ -248,11 +247,11 @@ bool ShaderTranslator::Translate(const std::string& shader_source,

// Get info log.
if (info_log) {
*info_log = ShGetInfoLog(compiler_);
*info_log = sh::GetInfoLog(compiler_);
}

// We don't need results in the compiler anymore.
ShClearResults(compiler_);
sh::ClearResults(compiler_);

return success;
}
Expand All @@ -261,8 +260,8 @@ std::string ShaderTranslator::GetStringForOptionsThatWouldAffectCompilation()
const {
DCHECK(compiler_ != NULL);
return std::string(":CompileOptions:" +
base::Uint64ToString(GetCompileOptions())) +
ShGetBuiltInResourcesString(compiler_);
base::Uint64ToString(GetCompileOptions())) +
sh::GetBuiltInResourcesString(compiler_);
}

void ShaderTranslator::AddDestructionObserver(
Expand All @@ -280,7 +279,7 @@ ShaderTranslator::~ShaderTranslator() {
observer.OnDestruct(this);

if (compiler_ != NULL)
ShDestruct(compiler_);
sh::Destruct(compiler_);
}

} // namespace gles2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ TEST(ShaderTranslatorCacheTest, InitParamComparable) {

ShBuiltInResources a_resources;
memset(&a_resources, 88, sizeof(a_resources));
ShInitBuiltInResources(&a_resources);
sh::InitBuiltInResources(&a_resources);

ShBuiltInResources b_resources;
memset(&b_resources, 77, sizeof(b_resources));
ShInitBuiltInResources(&b_resources);
sh::InitBuiltInResources(&b_resources);

EXPECT_TRUE(memcmp(&a_resources, &b_resources, sizeof(a_resources)) == 0);

Expand Down
10 changes: 5 additions & 5 deletions gpu/command_buffer/service/shader_translator_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ShaderTranslatorTest : public testing::Test {
protected:
void SetUp() override {
ShBuiltInResources resources;
ShInitBuiltInResources(&resources);
sh::InitBuiltInResources(&resources);
resources.MaxExpressionComplexity = 32;
resources.MaxCallStackDepth = 32;

Expand Down Expand Up @@ -63,7 +63,7 @@ class ES3ShaderTranslatorTest : public testing::Test {
protected:
void SetUp() override {
ShBuiltInResources resources;
ShInitBuiltInResources(&resources);
sh::InitBuiltInResources(&resources);
resources.MaxExpressionComplexity = 32;
resources.MaxCallStackDepth = 32;

Expand Down Expand Up @@ -424,7 +424,7 @@ TEST_F(ShaderTranslatorTest, OptionsString) {
scoped_refptr<ShaderTranslator> translator_3 = new ShaderTranslator();

ShBuiltInResources resources;
ShInitBuiltInResources(&resources);
sh::InitBuiltInResources(&resources);

ASSERT_TRUE(translator_1->Init(GL_VERTEX_SHADER, SH_GLES2_SPEC, &resources,
SH_GLSL_150_CORE_OUTPUT,
Expand Down Expand Up @@ -464,7 +464,7 @@ class ShaderTranslatorOutputVersionTest
// https://bugs.chromium.org/p/angleproject/issues/detail?id=1277
TEST_F(ShaderTranslatorOutputVersionTest, DISABLED_CompatibilityOutput) {
ShBuiltInResources resources;
ShInitBuiltInResources(&resources);
sh::InitBuiltInResources(&resources);
ShCompileOptions compile_options = SH_OBJECT_CODE;
ShShaderOutput shader_output_language = SH_GLSL_COMPATIBILITY_OUTPUT;
scoped_refptr<ShaderTranslator> vertex_translator = new ShaderTranslator();
Expand Down Expand Up @@ -532,7 +532,7 @@ TEST_P(ShaderTranslatorOutputVersionTest, HasCorrectOutputGLSLVersion) {

scoped_refptr<ShaderTranslator> translator = new ShaderTranslator();
ShBuiltInResources resources;
ShInitBuiltInResources(&resources);
sh::InitBuiltInResources(&resources);
ShCompileOptions compile_options = SH_OBJECT_CODE;
ShShaderOutput shader_output_language =
ShaderTranslator::GetShaderOutputLanguageForContext(
Expand Down

0 comments on commit d16b210

Please sign in to comment.