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

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

Issue 1309743005: command_buffer: Implement EXT_blend_func_extended (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new-05-path-fragment-input-gen
Patch Set: address review comments Created 5 years, 3 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/test_helper.cc
diff --git a/gpu/command_buffer/service/test_helper.cc b/gpu/command_buffer/service/test_helper.cc
index 448234aad4aaa928cfcaaa6021c258ac6f4cb063..97623a2036b5baa5eb6410824517d8bed059b45b 100644
--- a/gpu/command_buffer/service/test_helper.cc
+++ b/gpu/command_buffer/service/test_helper.cc
@@ -339,6 +339,16 @@ void TestHelper::SetupContextGroupInitExpectations(
.WillOnce(SetArgumentPointee<1>(kMaxSamples))
.RetiresOnSaturation();
}
+
+ if (gl_info.IsAtLeastGL(3, 3) ||
+ (gl_info.IsAtLeastGL(3, 2) &&
+ strstr(extensions, "GL_ARB_blend_func_extended")) ||
+ (gl_info.is_es && strstr(extensions, "GL_EXT_blend_func_extended"))) {
+ EXPECT_CALL(*gl, GetIntegerv(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT, _))
+ .WillOnce(SetArgumentPointee<1>(8))
+ .RetiresOnSaturation();
+ }
+
EXPECT_CALL(*gl, GetIntegerv(GL_MAX_VERTEX_ATTRIBS, _))
.WillOnce(SetArgumentPointee<1>(kNumVertexAttribs))
.RetiresOnSaturation();
@@ -689,6 +699,8 @@ void TestHelper::SetupProgramSuccessExpectations(
size_t num_uniforms,
VaryingInfo* varyings,
size_t num_varyings,
+ ProgramOutputInfo* program_outputs,
+ size_t num_program_outputs,
GLuint service_id) {
EXPECT_CALL(*gl,
GetProgramiv(service_id, GL_LINK_STATUS, _))
@@ -724,7 +736,7 @@ void TestHelper::SetupProgramSuccessExpectations(
SetArrayArgument<6>(info.name,
info.name + strlen(info.name) + 1)))
.RetiresOnSaturation();
- if (!ProgramManager::IsInvalidPrefix(info.name, strlen(info.name))) {
+ if (!ProgramManager::HasBuiltInPrefix(info.name)) {
EXPECT_CALL(*gl, GetAttribLocation(service_id, StrEq(info.name)))
.WillOnce(Return(info.location))
.RetiresOnSaturation();
@@ -809,7 +821,9 @@ void TestHelper::SetupProgramSuccessExpectations(
SetArrayArgument<5>(
info.name, info.name + strlen(info.name) + 1)))
.RetiresOnSaturation();
- if (!ProgramManager::IsInvalidPrefix(info.name, strlen(info.name))) {
+ if (ProgramManager::HasBuiltInPrefix(info.name)) {
+ continue;
+ }
static const GLenum kPropsArray[] = {GL_LOCATION, GL_TYPE,
GL_ARRAY_SIZE};
static const size_t kPropsSize = arraysize(kPropsArray);
@@ -828,6 +842,62 @@ void TestHelper::SetupProgramSuccessExpectations(
}))
.RetiresOnSaturation();
}
+ }
+ if (feature_info->feature_flags().ext_blend_func_extended) {
+ EXPECT_CALL(*gl, GetProgramInterfaceiv(service_id, GL_PROGRAM_OUTPUT,
+ GL_ACTIVE_RESOURCES, _))
+ .WillOnce(SetArgumentPointee<3>(int(num_program_outputs)))
+ .RetiresOnSaturation();
+ size_t max_program_output_len = 0;
+ for (size_t ii = 0; ii < num_program_outputs; ++ii) {
+ size_t len = strlen(program_outputs[ii].name) + 1;
+ max_program_output_len = std::max(max_program_output_len, len);
+ }
+ EXPECT_CALL(*gl, GetProgramInterfaceiv(service_id, GL_PROGRAM_OUTPUT,
+ GL_MAX_NAME_LENGTH, _))
+ .WillOnce(SetArgumentPointee<3>(int(max_program_output_len)))
+ .RetiresOnSaturation();
+ for (size_t ii = 0; ii < num_program_outputs; ++ii) {
+ ProgramOutputInfo& info = program_outputs[ii];
+ EXPECT_CALL(*gl, GetProgramResourceName(service_id, GL_PROGRAM_OUTPUT, ii,
+ max_program_output_len, _, _))
+ .WillOnce(DoAll(SetArgumentPointee<4>(strlen(info.name)),
+ SetArrayArgument<5>(
+ info.name, info.name + strlen(info.name) + 1)))
+ .RetiresOnSaturation();
+ if (ProgramManager::HasBuiltInPrefix(info.name)) {
+ continue;
+ }
+ static const GLenum kPropsArray[] = {GL_LOCATION, GL_LOCATION_INDEX,
+ GL_TYPE, GL_ARRAY_SIZE};
+ static const size_t kPropsSize = arraysize(kPropsArray);
+ EXPECT_CALL(*gl,
+ GetProgramResourceiv(
+ service_id, GL_PROGRAM_OUTPUT, ii, kPropsSize,
+ _ /*testing::ElementsAreArray(kPropsArray, kPropsSize)*/,
+ kPropsSize, _, _))
+ .WillOnce(testing::Invoke([info](GLuint, GLenum, GLuint, GLsizei,
+ const GLenum*, GLsizei,
+ GLsizei* length, GLint* params) {
+ *length = kPropsSize;
+ params[0] = info.color_name;
+ params[1] = info.index;
+ params[2] = info.type;
+ params[3] = info.size;
+ }))
+ .RetiresOnSaturation();
+ }
+ } else if (feature_info->gl_version_info().IsES3Capable() &&
+ !feature_info->disable_shader_translator()) {
+ for (size_t ii = 0; ii < num_program_outputs; ++ii) {
+ ProgramOutputInfo& info = program_outputs[ii];
+ EXPECT_CALL(*gl, GetFragDataLocation(service_id, StrEq(info.name)))
+ .WillOnce(Return(info.color_name))
+ .RetiresOnSaturation();
+ DCHECK(info.index == 0);
+ // Test case must not use indices, or the context of the testcase has to
+ // support
+ // the dual source blending.
}
}
}
@@ -844,8 +914,8 @@ void TestHelper::SetupShaderExpectations(::gfx::MockGLInterface* gl,
EXPECT_CALL(*gl, LinkProgram(service_id)).Times(1).RetiresOnSaturation();
SetupProgramSuccessExpectations(gl, feature_info, attribs, num_attribs,
- uniforms, num_uniforms, nullptr, 0,
- service_id);
+ uniforms, num_uniforms, nullptr, 0, nullptr,
+ 0, service_id);
}
void TestHelper::SetupShaderExpectationsWithVaryings(
@@ -857,6 +927,8 @@ void TestHelper::SetupShaderExpectationsWithVaryings(
size_t num_uniforms,
VaryingInfo* varyings,
size_t num_varyings,
+ ProgramOutputInfo* program_outputs,
+ size_t num_program_outputs,
GLuint service_id) {
InSequence s;
@@ -865,9 +937,9 @@ void TestHelper::SetupShaderExpectationsWithVaryings(
.Times(1)
.RetiresOnSaturation();
- SetupProgramSuccessExpectations(gl, feature_info, attribs, num_attribs,
- uniforms, num_uniforms, varyings,
- num_varyings, service_id);
+ SetupProgramSuccessExpectations(
+ gl, feature_info, attribs, num_attribs, uniforms, num_uniforms, varyings,
+ num_varyings, program_outputs, num_program_outputs, service_id);
}
void TestHelper::DoBufferData(
@@ -917,15 +989,17 @@ void TestHelper::SetTexParameteriWithExpectations(
// static
void TestHelper::SetShaderStates(
- ::gfx::MockGLInterface* gl, Shader* shader,
- bool expected_valid,
- const std::string* const expected_log_info,
- const std::string* const expected_translated_source,
- const int* const expected_shader_version,
- const AttributeMap* const expected_attrib_map,
- const UniformMap* const expected_uniform_map,
- const VaryingMap* const expected_varying_map,
- const NameMap* const expected_name_map) {
+ ::gfx::MockGLInterface* gl,
+ Shader* shader,
+ bool expected_valid,
+ const std::string* const expected_log_info,
+ const std::string* const expected_translated_source,
+ const int* const expected_shader_version,
+ const AttributeMap* const expected_attrib_map,
+ const UniformMap* const expected_uniform_map,
+ const VaryingMap* const expected_varying_map,
+ const OutputVariableList* const expected_output_variable_list,
+ const NameMap* const expected_name_map) {
const std::string empty_log_info;
const std::string* log_info = (expected_log_info && !expected_valid) ?
expected_log_info : &empty_log_info;
@@ -945,6 +1019,11 @@ void TestHelper::SetShaderStates(
const VaryingMap empty_varying_map;
const VaryingMap* varying_map = (expected_varying_map && expected_valid) ?
expected_varying_map : &empty_varying_map;
+ const OutputVariableList empty_output_variable_list;
+ const OutputVariableList* output_variable_list =
+ (expected_output_variable_list && expected_valid)
+ ? expected_output_variable_list
+ : &empty_output_variable_list;
const NameMap empty_name_map;
const NameMap* name_map = (expected_name_map && expected_valid) ?
expected_name_map : &empty_name_map;
@@ -952,12 +1031,13 @@ void TestHelper::SetShaderStates(
MockShaderTranslator* mock_translator = new MockShaderTranslator;
scoped_refptr<ShaderTranslatorInterface> translator(mock_translator);
EXPECT_CALL(*mock_translator, Translate(_,
- NotNull(), // log_info
- NotNull(), // translated_source
- NotNull(), // shader_version
- NotNull(), // attrib_map
- NotNull(), // uniform_map
- NotNull(), // varying_map
+ NotNull(), // log_info
+ NotNull(), // translated_source
+ NotNull(), // shader_version
+ NotNull(), // attrib_map
+ NotNull(), // uniform_map
+ NotNull(), // varying_map
+ NotNull(), // output_variable_list
NotNull())) // name_map
.WillOnce(DoAll(SetArgumentPointee<1>(*log_info),
SetArgumentPointee<2>(*translated_source),
@@ -965,8 +1045,8 @@ void TestHelper::SetShaderStates(
SetArgumentPointee<4>(*attrib_map),
SetArgumentPointee<5>(*uniform_map),
SetArgumentPointee<6>(*varying_map),
- SetArgumentPointee<7>(*name_map),
- Return(expected_valid)))
+ SetArgumentPointee<7>(*output_variable_list),
+ SetArgumentPointee<8>(*name_map), Return(expected_valid)))
.RetiresOnSaturation();
if (expected_valid) {
EXPECT_CALL(*gl, ShaderSource(shader->service_id(), 1, _, NULL))
@@ -988,7 +1068,8 @@ void TestHelper::SetShaderStates(
// static
void TestHelper::SetShaderStates(
::gfx::MockGLInterface* gl, Shader* shader, bool valid) {
- SetShaderStates(gl, shader, valid, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ SetShaderStates(gl, shader, valid, nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr);
}
// static
@@ -1015,6 +1096,16 @@ sh::Varying TestHelper::ConstructVarying(
type, array_size, precision, static_use, name);
}
+sh::OutputVariable TestHelper::ConstructOutputVariable(
+ GLenum type,
+ GLint array_size,
+ GLenum precision,
+ bool static_use,
+ const std::string& name) {
+ return ConstructShaderVariable<sh::OutputVariable>(
+ type, array_size, precision, static_use, name);
+}
+
ScopedGLImplementationSetter::ScopedGLImplementationSetter(
gfx::GLImplementation implementation)
: old_implementation_(gfx::GetGLImplementation()) {

Powered by Google App Engine
This is Rietveld 408576698