Commit 8e7549bd by Geoff Lang

Revert "In D3D11, check for 16-bit texture support and use if possible"

Causing failures on Windows 8 bots running ES CTS and Windows 7 Intel bot running angle tests. Example failures: https://build.chromium.org/p/chromium.gpu.fyi/builders/Win8%20Release%20%28NVIDIA%29/builds/14442 https://build.chromium.org/p/chromium.gpu.fyi/builders/Win7%20Release%20%28Intel%29/builds/11627 This reverts commit d63f08fc. Change-Id: I841aee5fb0973432f249277126424b909d5b3e17 Reviewed-on: https://chromium-review.googlesource.com/273416Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 294cad9d
...@@ -569,7 +569,6 @@ inline bool IsIntegerCastSafe(BigIntT bigValue) ...@@ -569,7 +569,6 @@ inline bool IsIntegerCastSafe(BigIntT bigValue)
#if defined(_MSC_VER) #if defined(_MSC_VER)
#define ANGLE_ROTL(x,y) _rotl(x,y) #define ANGLE_ROTL(x,y) _rotl(x,y)
#define ANGLE_ROTR16(x,y) _rotr16(x,y)
#else #else
...@@ -578,13 +577,7 @@ inline uint32_t RotL(uint32_t x, int8_t r) ...@@ -578,13 +577,7 @@ inline uint32_t RotL(uint32_t x, int8_t r)
return (x << r) | (x >> (32 - r)); return (x << r) | (x >> (32 - r));
} }
inline uint16_t RotR16(uint16_t x, int8_t r)
{
return (x >> r) | (x << (16 - r));
}
#define ANGLE_ROTL(x,y) RotL(x,y) #define ANGLE_ROTL(x,y) RotL(x,y)
#define ANGLE_ROTR16(x,y) RotR16(x,y)
#endif // namespace rx #endif // namespace rx
......
...@@ -307,7 +307,7 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, const gl ...@@ -307,7 +307,7 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, const gl
// Check if the actual format has a channel that the internal format does not and set them to the // Check if the actual format has a channel that the internal format does not and set them to the
// default values // default values
float clearValues[4] = const float clearValues[4] =
{ {
((formatInfo.redBits == 0 && dxgiFormatInfo.redBits > 0) ? 0.0f : clearParams.colorFClearValue.red), ((formatInfo.redBits == 0 && dxgiFormatInfo.redBits > 0) ? 0.0f : clearParams.colorFClearValue.red),
((formatInfo.greenBits == 0 && dxgiFormatInfo.greenBits > 0) ? 0.0f : clearParams.colorFClearValue.green), ((formatInfo.greenBits == 0 && dxgiFormatInfo.greenBits > 0) ? 0.0f : clearParams.colorFClearValue.green),
...@@ -315,14 +315,6 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, const gl ...@@ -315,14 +315,6 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, const gl
((formatInfo.alphaBits == 0 && dxgiFormatInfo.alphaBits > 0) ? 1.0f : clearParams.colorFClearValue.alpha), ((formatInfo.alphaBits == 0 && dxgiFormatInfo.alphaBits > 0) ? 1.0f : clearParams.colorFClearValue.alpha),
}; };
if (dxgiFormatInfo.alphaBits == 1)
{
// Some drivers do not correctly handle calling Clear() on a format with 1-bit alpha.
// They can incorrectly round all non-zero values up to 1.0f. Note that WARP does not do this.
// We should handle the rounding for them instead.
clearValues[3] = (clearParams.colorFClearValue.alpha >= 0.5f) ? 1.0f : 0.0f;
}
if (needScissoredClear) if (needScissoredClear)
{ {
// We shouldn't reach here if deviceContext1 is unavailable. // We shouldn't reach here if deviceContext1 is unavailable.
......
...@@ -213,9 +213,6 @@ Renderer11::Renderer11(egl::Display *display) ...@@ -213,9 +213,6 @@ Renderer11::Renderer11(egl::Display *display)
mRenderer11DeviceCaps.supportsClearView = false; mRenderer11DeviceCaps.supportsClearView = false;
mRenderer11DeviceCaps.supportsConstantBufferOffsets = false; mRenderer11DeviceCaps.supportsConstantBufferOffsets = false;
mRenderer11DeviceCaps.supportsDXGI1_2 = false; mRenderer11DeviceCaps.supportsDXGI1_2 = false;
mRenderer11DeviceCaps.B5G6R5support = 0;
mRenderer11DeviceCaps.B4G4R4A4support = 0;
mRenderer11DeviceCaps.B5G5R5A1support = 0;
mD3d11Module = NULL; mD3d11Module = NULL;
mDxgiModule = NULL; mDxgiModule = NULL;
...@@ -454,6 +451,7 @@ egl::Error Renderer11::initialize() ...@@ -454,6 +451,7 @@ egl::Error Renderer11::initialize()
SafeRelease(dxgiDevice); SafeRelease(dxgiDevice);
IDXGIAdapter2 *dxgiAdapter2 = d3d11::DynamicCastComObject<IDXGIAdapter2>(mDxgiAdapter); IDXGIAdapter2 *dxgiAdapter2 = d3d11::DynamicCastComObject<IDXGIAdapter2>(mDxgiAdapter);
mRenderer11DeviceCaps.supportsDXGI1_2 = (dxgiAdapter2 != nullptr);
// On D3D_FEATURE_LEVEL_9_*, IDXGIAdapter::GetDesc returns "Software Adapter" for the description string. // On D3D_FEATURE_LEVEL_9_*, IDXGIAdapter::GetDesc returns "Software Adapter" for the description string.
// If DXGI1.2 is available then IDXGIAdapter2::GetDesc2 can be used to get the actual hardware values. // If DXGI1.2 is available then IDXGIAdapter2::GetDesc2 can be used to get the actual hardware values.
...@@ -533,8 +531,6 @@ void Renderer11::initializeDevice() ...@@ -533,8 +531,6 @@ void Renderer11::initializeDevice()
{ {
TRACE_EVENT0("gpu.angle", "Renderer11::initializeDevice"); TRACE_EVENT0("gpu.angle", "Renderer11::initializeDevice");
populateRenderer11DeviceCaps();
mStateCache.initialize(mDevice); mStateCache.initialize(mDevice);
mInputLayoutCache.initialize(mDevice, mDeviceContext); mInputLayoutCache.initialize(mDevice, mDeviceContext);
...@@ -565,6 +561,17 @@ void Renderer11::initializeDevice() ...@@ -565,6 +561,17 @@ void Renderer11::initializeDevice()
const gl::Caps &rendererCaps = getRendererCaps(); const gl::Caps &rendererCaps = getRendererCaps();
if (mDeviceContext1)
{
D3D11_FEATURE_DATA_D3D11_OPTIONS d3d11Options;
HRESULT result = mDevice->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS, &d3d11Options, sizeof(D3D11_FEATURE_DATA_D3D11_OPTIONS));
if (SUCCEEDED(result))
{
mRenderer11DeviceCaps.supportsClearView = (d3d11Options.ClearView != FALSE);
mRenderer11DeviceCaps.supportsConstantBufferOffsets = (d3d11Options.ConstantBufferOffsetting != FALSE);
}
}
mForceSetVertexSamplerStates.resize(rendererCaps.maxVertexTextureImageUnits); mForceSetVertexSamplerStates.resize(rendererCaps.maxVertexTextureImageUnits);
mCurVertexSamplerStates.resize(rendererCaps.maxVertexTextureImageUnits); mCurVertexSamplerStates.resize(rendererCaps.maxVertexTextureImageUnits);
...@@ -595,44 +602,6 @@ void Renderer11::initializeDevice() ...@@ -595,44 +602,6 @@ void Renderer11::initializeDevice()
NUM_ANGLE_FEATURE_LEVELS); NUM_ANGLE_FEATURE_LEVELS);
} }
void Renderer11::populateRenderer11DeviceCaps()
{
HRESULT hr = S_OK;
if (mDeviceContext1)
{
D3D11_FEATURE_DATA_D3D11_OPTIONS d3d11Options;
HRESULT result = mDevice->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS, &d3d11Options, sizeof(D3D11_FEATURE_DATA_D3D11_OPTIONS));
if (SUCCEEDED(result))
{
mRenderer11DeviceCaps.supportsClearView = (d3d11Options.ClearView != FALSE);
mRenderer11DeviceCaps.supportsConstantBufferOffsets = (d3d11Options.ConstantBufferOffsetting != FALSE);
}
}
hr = mDevice->CheckFormatSupport(DXGI_FORMAT_B5G6R5_UNORM, &(mRenderer11DeviceCaps.B5G6R5support));
if (FAILED(hr))
{
mRenderer11DeviceCaps.B5G6R5support = 0;
}
hr = mDevice->CheckFormatSupport(DXGI_FORMAT_B4G4R4A4_UNORM, &(mRenderer11DeviceCaps.B4G4R4A4support));
if (FAILED(hr))
{
mRenderer11DeviceCaps.B4G4R4A4support = 0;
}
hr = mDevice->CheckFormatSupport(DXGI_FORMAT_B5G5R5A1_UNORM, &(mRenderer11DeviceCaps.B5G5R5A1support));
if (FAILED(hr))
{
mRenderer11DeviceCaps.B5G5R5A1support = 0;
}
IDXGIAdapter2 *dxgiAdapter2 = d3d11::DynamicCastComObject<IDXGIAdapter2>(mDxgiAdapter);
mRenderer11DeviceCaps.supportsDXGI1_2 = (dxgiAdapter2 != nullptr);
SafeRelease(dxgiAdapter2);
}
egl::ConfigSet Renderer11::generateConfigs() const egl::ConfigSet Renderer11::generateConfigs() const
{ {
static const GLenum colorBufferFormats[] = static const GLenum colorBufferFormats[] =
......
...@@ -45,9 +45,6 @@ struct Renderer11DeviceCaps ...@@ -45,9 +45,6 @@ struct Renderer11DeviceCaps
bool supportsDXGI1_2; // Support for DXGI 1.2 bool supportsDXGI1_2; // Support for DXGI 1.2
bool supportsClearView; // Support for ID3D11DeviceContext1::ClearView bool supportsClearView; // Support for ID3D11DeviceContext1::ClearView
bool supportsConstantBufferOffsets; // Support for Constant buffer offset bool supportsConstantBufferOffsets; // Support for Constant buffer offset
UINT B5G6R5support; // Bitfield of D3D11_FORMAT_SUPPORT values for DXGI_FORMAT_B5G6R5_UNORM
UINT B4G4R4A4support; // Bitfield of D3D11_FORMAT_SUPPORT values for DXGI_FORMAT_B4G4R4A4_UNORM
UINT B5G5R5A1support; // Bitfield of D3D11_FORMAT_SUPPORT values for DXGI_FORMAT_B5G5R5A1_UNORM
}; };
enum enum
...@@ -274,8 +271,6 @@ class Renderer11 : public RendererD3D ...@@ -274,8 +271,6 @@ class Renderer11 : public RendererD3D
ID3D11Texture2D *resolveMultisampledTexture(ID3D11Texture2D *source, unsigned int subresource); ID3D11Texture2D *resolveMultisampledTexture(ID3D11Texture2D *source, unsigned int subresource);
void unsetConflictingSRVs(gl::SamplerType shaderType, uintptr_t resource, const gl::ImageIndex &index); void unsetConflictingSRVs(gl::SamplerType shaderType, uintptr_t resource, const gl::ImageIndex &index);
void populateRenderer11DeviceCaps();
HMODULE mD3d11Module; HMODULE mD3d11Module;
HMODULE mDxgiModule; HMODULE mDxgiModule;
std::vector<D3D_FEATURE_LEVEL> mAvailableFeatureLevels; std::vector<D3D_FEATURE_LEVEL> mAvailableFeatureLevels;
......
...@@ -348,24 +348,6 @@ void LoadRGBA8ToBGRA8(size_t width, size_t height, size_t depth, ...@@ -348,24 +348,6 @@ void LoadRGBA8ToBGRA8(size_t width, size_t height, size_t depth,
} }
} }
void LoadRGBA4ToARGB4(size_t width, size_t height, size_t depth,
const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
for (size_t z = 0; z < depth; z++)
{
for (size_t y = 0; y < height; y++)
{
const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
uint16_t *dest = OffsetDataPointer<uint16_t>(output, y, z, outputRowPitch, outputDepthPitch);
for (size_t x = 0; x < width; x++)
{
dest[x] = ANGLE_ROTR16(source[x], 4);
}
}
}
}
void LoadRGBA4ToBGRA8(size_t width, size_t height, size_t depth, void LoadRGBA4ToBGRA8(size_t width, size_t height, size_t depth,
const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch, const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch) uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
...@@ -432,24 +414,6 @@ void LoadBGRA4ToBGRA8(size_t width, size_t height, size_t depth, ...@@ -432,24 +414,6 @@ void LoadBGRA4ToBGRA8(size_t width, size_t height, size_t depth,
} }
} }
void LoadRGB5A1ToA1RGB5(size_t width, size_t height, size_t depth,
const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
for (size_t z = 0; z < depth; z++)
{
for (size_t y = 0; y < height; y++)
{
const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
uint16_t *dest = OffsetDataPointer<uint16_t>(output, y, z, outputRowPitch, outputDepthPitch);
for (size_t x = 0; x < width; x++)
{
dest[x] = ANGLE_ROTR16(source[x], 1);
}
}
}
}
void LoadRGB5A1ToBGRA8(size_t width, size_t height, size_t depth, void LoadRGB5A1ToBGRA8(size_t width, size_t height, size_t depth,
const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch, const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch) uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
...@@ -494,6 +458,7 @@ void LoadRGB5A1ToRGBA8(size_t width, size_t height, size_t depth, ...@@ -494,6 +458,7 @@ void LoadRGB5A1ToRGBA8(size_t width, size_t height, size_t depth,
} }
} }
void LoadBGR5A1ToBGRA8(size_t width, size_t height, size_t depth, void LoadBGR5A1ToBGRA8(size_t width, size_t height, size_t depth,
const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch, const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch) uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
......
...@@ -96,10 +96,6 @@ void LoadRGBA8ToBGRA8(size_t width, size_t height, size_t depth, ...@@ -96,10 +96,6 @@ void LoadRGBA8ToBGRA8(size_t width, size_t height, size_t depth,
const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch, const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch); uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
void LoadRGBA4ToARGB4(size_t width, size_t height, size_t depth,
const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
void LoadRGBA4ToBGRA8(size_t width, size_t height, size_t depth, void LoadRGBA4ToBGRA8(size_t width, size_t height, size_t depth,
const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch, const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch); uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
...@@ -112,10 +108,6 @@ void LoadBGRA4ToBGRA8(size_t width, size_t height, size_t depth, ...@@ -112,10 +108,6 @@ void LoadBGRA4ToBGRA8(size_t width, size_t height, size_t depth,
const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch, const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch); uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
void LoadRGB5A1ToA1RGB5(size_t width, size_t height, size_t depth,
const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
void LoadRGB5A1ToBGRA8(size_t width, size_t height, size_t depth, void LoadRGB5A1ToBGRA8(size_t width, size_t height, size_t depth,
const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch, const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch); uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
......
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
'<(angle_path)/src/tests/gl_tests/ReadPixelsTest.cpp', '<(angle_path)/src/tests/gl_tests/ReadPixelsTest.cpp',
'<(angle_path)/src/tests/gl_tests/RendererTest.cpp', '<(angle_path)/src/tests/gl_tests/RendererTest.cpp',
'<(angle_path)/src/tests/gl_tests/SimpleOperationTest.cpp', '<(angle_path)/src/tests/gl_tests/SimpleOperationTest.cpp',
'<(angle_path)/src/tests/gl_tests/SixteenBppTextureTest.cpp',
'<(angle_path)/src/tests/gl_tests/SRGBTextureTest.cpp', '<(angle_path)/src/tests/gl_tests/SRGBTextureTest.cpp',
'<(angle_path)/src/tests/gl_tests/SwizzleTest.cpp', '<(angle_path)/src/tests/gl_tests/SwizzleTest.cpp',
'<(angle_path)/src/tests/gl_tests/TextureTest.cpp', '<(angle_path)/src/tests/gl_tests/TextureTest.cpp',
......
//
// 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);
}
virtual void SetUp()
{
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");
}
virtual void TearDown()
{
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)
{
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)
{
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)
{
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)
{
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment