Hash :
405f3471
Author :
Date :
2015-06-04T13:09:06
In D3D11, check for 16-bit texture support and use if possible BUG=angleproject:1002 The last patch added new tests which failed on some Intel Win7 machines. This was due to a driver bug. Windows Updates have been applied to the failing machine, and the tests now pass. Changes between second and current (third) failed 16-bit patch: - Reenable usage of 16-bit DXGI textures on all Intel cards - Disable 16bpp tests on Intel D3D11 until the bots are updated - Updated Win7 test machine. Tests now pass Changes between first and second failed 16-bit patch: - Disabled usage of 16-bit DXGI textures on all Intel cards - Added DXGI->GL conversion entries for 16-bit formats, which fixes FBO readback issues. The ES CTS and dEQP tests which failed with the last patch now pass. Change-Id: Id8ea89bfbc450beea54afdd398956bc97ecf3c01 Reviewed-on: https://chromium-review.googlesource.com/275082 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Austin Kinross <aukinros@microsoft.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
//
// Copyright 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// SixteenBppTextureTest:
// Basic tests using 16bpp texture formats (e.g. GL_RGB565).
#include "test_utils/ANGLETest.h"
using namespace angle;
namespace
{
class SixteenBppTextureTest : public ANGLETest
{
protected:
SixteenBppTextureTest()
{
setWindowWidth(128);
setWindowHeight(128);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
}
void SetUp() override
{
ANGLETest::SetUp();
const std::string vertexShaderSource = SHADER_SOURCE
(
precision highp float;
attribute vec4 position;
varying vec2 texcoord;
void main()
{
gl_Position = vec4(position.xy, 0.0, 1.0);
texcoord = (position.xy * 0.5) + 0.5;
}
);
const std::string fragmentShaderSource2D = SHADER_SOURCE
(
precision highp float;
uniform sampler2D tex;
varying vec2 texcoord;
void main()
{
gl_FragColor = texture2D(tex, texcoord);
}
);
m2DProgram = CompileProgram(vertexShaderSource, fragmentShaderSource2D);
mTexture2DUniformLocation = glGetUniformLocation(m2DProgram, "tex");
}
void TearDown() override
{
glDeleteProgram(m2DProgram);
ANGLETest::TearDown();
}
void simpleValidationBase(GLuint tex)
{
// Draw a quad using the texture
glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(m2DProgram);
glUniform1i(mTexture2DUniformLocation, 0);
drawQuad(m2DProgram, "position", 0.5f);
EXPECT_GL_NO_ERROR();
// Check that it drew as expected
EXPECT_PIXEL_EQ(0, 0, 255, 0, 0, 255);
EXPECT_PIXEL_EQ(getWindowHeight() - 1, 0, 0, 255, 0, 255);
EXPECT_PIXEL_EQ(0, getWindowWidth() - 1, 0, 0, 255, 255);
EXPECT_PIXEL_EQ(getWindowHeight() - 1, getWindowWidth() - 1, 255, 255, 0, 255);
swapBuffers();
// Generate mipmaps
glGenerateMipmap(GL_TEXTURE_2D);
// Draw a quad using the texture
glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(m2DProgram);
glUniform1i(mTexture2DUniformLocation, 0);
drawQuad(m2DProgram, "position", 0.5f);
EXPECT_GL_NO_ERROR();
// Check that it drew as expected
EXPECT_PIXEL_EQ(0, 0, 255, 0, 0, 255);
EXPECT_PIXEL_EQ(getWindowHeight() - 1, 0, 0, 255, 0, 255);
EXPECT_PIXEL_EQ(0, getWindowWidth() - 1, 0, 0, 255, 255);
EXPECT_PIXEL_EQ(getWindowHeight() - 1, getWindowWidth() - 1, 255, 255, 0, 255);
swapBuffers();
// Bind the texture as a framebuffer, render to it, then check the results
GLuint fbo = 0;
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glBindTexture(GL_TEXTURE_2D, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
EXPECT_PIXEL_EQ(0, 0, 255, 0, 0, 255);
EXPECT_PIXEL_EQ(1, 0, 255, 0, 0, 255);
EXPECT_PIXEL_EQ(1, 1, 255, 0, 0, 255);
EXPECT_PIXEL_EQ(0, 1, 255, 0, 0, 255);
glDeleteFramebuffers(1, &fbo);
}
GLuint m2DProgram;
GLint mTexture2DUniformLocation;
};
// Simple validation test for GL_RGB565 textures.
// Samples from the texture, renders to it, generates mipmaps etc.
TEST_P(SixteenBppTextureTest, RGB565Validation)
{
// These tests fail on certain Intel machines running an un-updated version of Win7
// The tests pass after installing the latest updates from Windows Update.
// TODO: reenable these tests once the bots have been updated
if (isIntel() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
{
std::cout << "Test skipped on Intel D3D11." << std::endl;
return;
}
GLushort pixels[4] =
{
0xF800, // Red
0x07E0, // Green
0x001F, // Blue
0xFFE0 // Red + Green
};
glClearColor(0, 0, 0, 0);
// Create a simple RGB565 texture
GLuint tex = 0;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 2, 2, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
EXPECT_GL_NO_ERROR();
// Supply the data to it
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 2, 2, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, pixels);
EXPECT_GL_NO_ERROR();
simpleValidationBase(tex);
glDeleteTextures(1, &tex);
}
// Simple validation test for GL_RGBA5551 textures.
// Samples from the texture, renders to it, generates mipmaps etc.
TEST_P(SixteenBppTextureTest, RGBA5551Validation)
{
// These tests fail on certain Intel machines running an un-updated version of Win7
// The tests pass after installing the latest updates from Windows Update.
// TODO: reenable these tests once the bots have been updated
if (isIntel() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
{
std::cout << "Test skipped on Intel D3D11." << std::endl;
return;
}
GLushort pixels[4] =
{
0xF801, // Red
0x07C1, // Green
0x003F, // Blue
0xFFC1 // Red + Green
};
// Create a simple 5551 texture
GLuint tex = 0;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
EXPECT_GL_NO_ERROR();
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, pixels);
EXPECT_GL_NO_ERROR();
simpleValidationBase(tex);
glDeleteTextures(1, &tex);
}
// Test to ensure calling Clear() on an RGBA5551 texture does something reasonable
// Based on WebGL test conformance/textures/texture-attachment-formats.html
TEST_P(SixteenBppTextureTest, RGBA5551ClearAlpha)
{
// These tests fail on certain Intel machines running an un-updated version of Win7
// The tests pass after installing the latest updates from Windows Update.
// TODO: reenable these tests once the bots have been updated
if (isIntel() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
{
std::cout << "Test skipped on Intel D3D11." << std::endl;
return;
}
GLuint tex = 0;
GLuint fbo = 0;
GLubyte pixel[4];
glClearColor(0.0f, 0.0f, 0.0f, 0.1f);
// Create a simple 5551 texture
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
EXPECT_GL_NO_ERROR();
// Bind the texture as a framebuffer, clear it, then check the results
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glBindTexture(GL_TEXTURE_2D, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
glClear(GL_COLOR_BUFFER_BIT);
glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
EXPECT_GL_NO_ERROR();
EXPECT_NEAR(0, pixel[0], 32);
EXPECT_NEAR(0, pixel[1], 32);
EXPECT_NEAR(0, pixel[2], 32);
EXPECT_NEAR(26, pixel[3], 128);
glDeleteFramebuffers(1, &fbo);
glDeleteTextures(1, &tex);
glDeleteFramebuffers(1, &fbo);
}
// Simple validation test for GL_RGBA4444 textures.
// Samples from the texture, renders to it, generates mipmaps etc.
TEST_P(SixteenBppTextureTest, RGBA4444Validation)
{
// These tests fail on certain Intel machines running an un-updated version of Win7
// The tests pass after installing the latest updates from Windows Update.
// TODO: reenable these tests once the bots have been updated
if (isIntel() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
{
std::cout << "Test skipped on Intel D3D11." << std::endl;
return;
}
GLushort pixels[4] =
{
0xF00F, // Red
0x0F0F, // Green
0x00FF, // Blue
0xFF0F // Red + Green
};
glClearColor(0, 0, 0, 0);
// Generate a RGBA4444 texture, no mipmaps
GLuint tex = 0;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
EXPECT_GL_NO_ERROR();
// Provide some data for the texture
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, pixels);
EXPECT_GL_NO_ERROR();
simpleValidationBase(tex);
glDeleteTextures(1, &tex);
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(SixteenBppTextureTest, ES2_D3D9(), ES2_D3D11(), ES2_D3D11_FL9_3(), ES2_OPENGL());
} // namespace