| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <GLES2/gl2.h> | 5 #include <GLES2/gl2.h> |
| 6 #include <GLES2/gl2ext.h> | 6 #include <GLES2/gl2ext.h> |
| 7 #include <GLES2/gl2extchromium.h> | 7 #include <GLES2/gl2extchromium.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> |
| 11 |
| 10 #include "gpu/command_buffer/tests/gl_manager.h" | 12 #include "gpu/command_buffer/tests/gl_manager.h" |
| 11 #include "gpu/command_buffer/tests/gl_test_utils.h" | 13 #include "gpu/command_buffer/tests/gl_test_utils.h" |
| 12 #include "gpu/config/gpu_test_config.h" | 14 #include "gpu/config/gpu_test_config.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 16 |
| 15 #define SHADER0(Src) #Src | 17 #define SHADER0(Src) #Src |
| 16 | 18 |
| 17 namespace gpu { | 19 namespace gpu { |
| 18 | 20 |
| 19 class EXTMultisampleCompatibilityTest : public testing::Test { | 21 class EXTMultisampleCompatibilityTest : public testing::Test { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 } | 149 } |
| 148 | 150 |
| 149 static const float kBlue[] = {0.0f, 0.0f, 1.0f, 1.0f}; | 151 static const float kBlue[] = {0.0f, 0.0f, 1.0f, 1.0f}; |
| 150 static const float kGreen[] = {0.0f, 1.0f, 0.0f, 1.0f}; | 152 static const float kGreen[] = {0.0f, 1.0f, 0.0f, 1.0f}; |
| 151 static const float kRed[] = {1.0f, 0.0f, 0.0f, 1.0f}; | 153 static const float kRed[] = {1.0f, 0.0f, 0.0f, 1.0f}; |
| 152 | 154 |
| 153 // Different drivers seem to behave differently with respect to resulting | 155 // Different drivers seem to behave differently with respect to resulting |
| 154 // values. These might be due to different MSAA sample counts causing | 156 // values. These might be due to different MSAA sample counts causing |
| 155 // different samples to hit. Other option is driver bugs. Just test that | 157 // different samples to hit. Other option is driver bugs. Just test that |
| 156 // disabling multisample causes a difference. | 158 // disabling multisample causes a difference. |
| 157 scoped_ptr<uint8_t[]> results[3]; | 159 std::unique_ptr<uint8_t[]> results[3]; |
| 158 const GLint kResultSize = kWidth * kHeight * 4; | 160 const GLint kResultSize = kWidth * kHeight * 4; |
| 159 for (int pass = 0; pass < 3; pass++) { | 161 for (int pass = 0; pass < 3; pass++) { |
| 160 PrepareForDraw(); | 162 PrepareForDraw(); |
| 161 // Green: from top right to bottom left. | 163 // Green: from top right to bottom left. |
| 162 glUniform4fv(color_loc_, 1, kGreen); | 164 glUniform4fv(color_loc_, 1, kGreen); |
| 163 glDrawArrays(GL_TRIANGLES, 0, 3); | 165 glDrawArrays(GL_TRIANGLES, 0, 3); |
| 164 | 166 |
| 165 // Blue: from top left to bottom right. | 167 // Blue: from top left to bottom right. |
| 166 glUniform4fv(color_loc_, 1, kBlue); | 168 glUniform4fv(color_loc_, 1, kBlue); |
| 167 glDrawArrays(GL_TRIANGLES, 3, 3); | 169 glDrawArrays(GL_TRIANGLES, 3, 3); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 static const float kBlue[] = {0.0f, 0.0f, 1.0f, 0.5f}; | 201 static const float kBlue[] = {0.0f, 0.0f, 1.0f, 0.5f}; |
| 200 static const float kGreen[] = {0.0f, 1.0f, 0.0f, 0.5f}; | 202 static const float kGreen[] = {0.0f, 1.0f, 0.0f, 0.5f}; |
| 201 static const float kRed[] = {1.0f, 0.0f, 0.0f, 0.5f}; | 203 static const float kRed[] = {1.0f, 0.0f, 0.0f, 0.5f}; |
| 202 | 204 |
| 203 // Different drivers seem to behave differently with respect to resulting | 205 // Different drivers seem to behave differently with respect to resulting |
| 204 // alpha value. These might be due to different MSAA sample counts causing | 206 // alpha value. These might be due to different MSAA sample counts causing |
| 205 // different samples to hit. Other option is driver bugs. Testing exact or | 207 // different samples to hit. Other option is driver bugs. Testing exact or |
| 206 // even approximate sample values is not that easy. Thus, just test | 208 // even approximate sample values is not that easy. Thus, just test |
| 207 // representative positions which have fractional pixels, inspecting that | 209 // representative positions which have fractional pixels, inspecting that |
| 208 // normal rendering is different to SAMPLE_ALPHA_TO_ONE rendering. | 210 // normal rendering is different to SAMPLE_ALPHA_TO_ONE rendering. |
| 209 scoped_ptr<uint8_t[]> results[3]; | 211 std::unique_ptr<uint8_t[]> results[3]; |
| 210 const GLint kResultSize = kWidth * kHeight * 4; | 212 const GLint kResultSize = kWidth * kHeight * 4; |
| 211 | 213 |
| 212 for (int pass = 0; pass < 3; ++pass) { | 214 for (int pass = 0; pass < 3; ++pass) { |
| 213 PrepareForDraw(); | 215 PrepareForDraw(); |
| 214 if (pass == 1) { | 216 if (pass == 1) { |
| 215 glEnable(GL_SAMPLE_ALPHA_TO_ONE_EXT); | 217 glEnable(GL_SAMPLE_ALPHA_TO_ONE_EXT); |
| 216 } | 218 } |
| 217 glEnable(GL_MULTISAMPLE_EXT); | 219 glEnable(GL_MULTISAMPLE_EXT); |
| 218 glUniform4fv(color_loc_, 1, kGreen); | 220 glUniform4fv(color_loc_, 1, kGreen); |
| 219 glDrawArrays(GL_TRIANGLES, 0, 3); | 221 glDrawArrays(GL_TRIANGLES, 0, 3); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 234 glDisable(GL_SAMPLE_ALPHA_TO_ONE_EXT); | 236 glDisable(GL_SAMPLE_ALPHA_TO_ONE_EXT); |
| 235 } | 237 } |
| 236 } | 238 } |
| 237 EXPECT_NE(0, memcmp(results[0].get(), results[1].get(), kResultSize)); | 239 EXPECT_NE(0, memcmp(results[0].get(), results[1].get(), kResultSize)); |
| 238 // Verify that rendering is deterministic, so that the pass above does not | 240 // Verify that rendering is deterministic, so that the pass above does not |
| 239 // come from non-deterministic rendering. | 241 // come from non-deterministic rendering. |
| 240 EXPECT_EQ(0, memcmp(results[0].get(), results[2].get(), kResultSize)); | 242 EXPECT_EQ(0, memcmp(results[0].get(), results[2].get(), kResultSize)); |
| 241 } | 243 } |
| 242 | 244 |
| 243 } // namespace gpu | 245 } // namespace gpu |
| OLD | NEW |