Commit 25ab4510 by Vincent Lang Committed by Commit Bot

Implement GL_EXT_texture_norm16 extension

BUG=angleproject:1365 Change-Id: I972b156ecb41ff44bc1f6365373ab386bacc85f1 Reviewed-on: https://chromium-review.googlesource.com/346530Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent fd08a959
...@@ -162,7 +162,8 @@ Extensions::Extensions() ...@@ -162,7 +162,8 @@ Extensions::Extensions()
syncQuery(false), syncQuery(false),
colorBufferFloat(false), colorBufferFloat(false),
multisampleCompatibility(false), multisampleCompatibility(false),
framebufferMixedSamples(false) framebufferMixedSamples(false),
textureNorm16(false)
{ {
} }
...@@ -238,6 +239,7 @@ std::vector<std::string> Extensions::getStrings() const ...@@ -238,6 +239,7 @@ std::vector<std::string> Extensions::getStrings() const
InsertExtensionString("GL_CHROMIUM_sync_query", syncQuery, &extensionStrings); InsertExtensionString("GL_CHROMIUM_sync_query", syncQuery, &extensionStrings);
InsertExtensionString("GL_EXT_multisample_compatibility", multisampleCompatibility, &extensionStrings); InsertExtensionString("GL_EXT_multisample_compatibility", multisampleCompatibility, &extensionStrings);
InsertExtensionString("GL_CHROMIUM_framebuffer_mixed_samples", framebufferMixedSamples, &extensionStrings); InsertExtensionString("GL_CHROMIUM_framebuffer_mixed_samples", framebufferMixedSamples, &extensionStrings);
InsertExtensionString("GL_EXT_texture_norm16", textureNorm16, &extensionStrings);
// clang-format on // clang-format on
return extensionStrings; return extensionStrings;
...@@ -503,6 +505,28 @@ static bool DetermineColorBufferFloatSupport(const TextureCapsMap &textureCaps) ...@@ -503,6 +505,28 @@ static bool DetermineColorBufferFloatSupport(const TextureCapsMap &textureCaps)
return GetFormatSupport(textureCaps, requiredFormats, true, false, true); return GetFormatSupport(textureCaps, requiredFormats, true, false, true);
} }
// Check for GL_EXT_texture_norm16
static bool DetermineTextureNorm16Support(const TextureCapsMap &textureCaps)
{
std::vector<GLenum> requiredFilterFormats;
requiredFilterFormats.push_back(GL_R16_EXT);
requiredFilterFormats.push_back(GL_RG16_EXT);
requiredFilterFormats.push_back(GL_RGB16_EXT);
requiredFilterFormats.push_back(GL_RGBA16_EXT);
requiredFilterFormats.push_back(GL_R16_SNORM_EXT);
requiredFilterFormats.push_back(GL_RG16_SNORM_EXT);
requiredFilterFormats.push_back(GL_RGB16_SNORM_EXT);
requiredFilterFormats.push_back(GL_RGBA16_SNORM_EXT);
std::vector<GLenum> requiredRenderFormats;
requiredFilterFormats.push_back(GL_R16_EXT);
requiredFilterFormats.push_back(GL_RG16_EXT);
requiredFilterFormats.push_back(GL_RGBA16_EXT);
return GetFormatSupport(textureCaps, requiredFilterFormats, true, true, false) &&
GetFormatSupport(textureCaps, requiredRenderFormats, true, false, true);
}
void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps) void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps)
{ {
packedDepthStencil = DeterminePackedDepthStencilSupport(textureCaps); packedDepthStencil = DeterminePackedDepthStencilSupport(textureCaps);
...@@ -524,6 +548,7 @@ void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps) ...@@ -524,6 +548,7 @@ void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps)
depthTextures = DetermineDepthTextureSupport(textureCaps); depthTextures = DetermineDepthTextureSupport(textureCaps);
depth32 = DetermineDepth32Support(textureCaps); depth32 = DetermineDepth32Support(textureCaps);
colorBufferFloat = DetermineColorBufferFloatSupport(textureCaps); colorBufferFloat = DetermineColorBufferFloatSupport(textureCaps);
textureNorm16 = DetermineTextureNorm16Support(textureCaps);
} }
TypePrecision::TypePrecision() TypePrecision::TypePrecision()
......
...@@ -87,6 +87,7 @@ struct Extensions ...@@ -87,6 +87,7 @@ struct Extensions
// GL_EXT_sRGB // GL_EXT_sRGB
// GL_ANGLE_depth_texture, GL_OES_depth32 // GL_ANGLE_depth_texture, GL_OES_depth32
// GL_EXT_color_buffer_float // GL_EXT_color_buffer_float
// GL_EXT_texture_norm16
void setTextureExtensionSupport(const TextureCapsMap &textureCaps); void setTextureExtensionSupport(const TextureCapsMap &textureCaps);
// ES2 Extension support // ES2 Extension support
...@@ -298,6 +299,10 @@ struct Extensions ...@@ -298,6 +299,10 @@ struct Extensions
// GL_CHROMIUM_framebuffer_mixed_samples // GL_CHROMIUM_framebuffer_mixed_samples
bool framebufferMixedSamples; bool framebufferMixedSamples;
// GL_EXT_texture_norm16
// written against ES 3.1 but can apply to ES 3.0 as well.
bool textureNorm16;
}; };
struct Limitations struct Limitations
......
...@@ -2090,6 +2090,7 @@ void Context::initCaps() ...@@ -2090,6 +2090,7 @@ void Context::initCaps()
// Disable ES3+ extensions // Disable ES3+ extensions
mExtensions.colorBufferFloat = false; mExtensions.colorBufferFloat = false;
mExtensions.eglImageExternalEssl3 = false; mExtensions.eglImageExternalEssl3 = false;
mExtensions.textureNorm16 = false;
} }
if (mClientVersion > 2) if (mClientVersion > 2)
......
...@@ -568,6 +568,17 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap() ...@@ -568,6 +568,17 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap()
// From GL_ANGLE_lossy_etc_decode // From GL_ANGLE_lossy_etc_decode
map.insert(InternalFormatInfoPair(GL_ETC1_RGB8_LOSSY_DECODE_ANGLE, CompressedFormat(4, 4, 64, 3, GL_ETC1_RGB8_OES, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::lossyETCDecode>, NeverSupported, AlwaysSupported))); map.insert(InternalFormatInfoPair(GL_ETC1_RGB8_LOSSY_DECODE_ANGLE, CompressedFormat(4, 4, 64, 3, GL_ETC1_RGB8_OES, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::lossyETCDecode>, NeverSupported, AlwaysSupported)));
// From GL_EXT_texture_norm16
// | Internal format | | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Renderable | Filterable |
map.insert(InternalFormatInfoPair(GL_R16_EXT, RGBAFormat(16, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, RequireExt<&Extensions::textureNorm16>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_R16_SNORM_EXT, RGBAFormat(16, 0, 0, 0, 0, GL_RED, GL_SHORT, GL_SIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RG16_EXT, RGBAFormat(16, 16, 0, 0, 0, GL_RG, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, RequireExt<&Extensions::textureNorm16>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RG16_SNORM_EXT, RGBAFormat(16, 16, 0, 0, 0, GL_RG, GL_SHORT, GL_SIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGB16_EXT, RGBAFormat(16, 16, 16, 0, 0, GL_RGB, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGB16_SNORM_EXT, RGBAFormat(16, 16, 16, 0, 0, GL_RGB, GL_SHORT, GL_SIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA16_EXT, RGBAFormat(16, 16, 16, 16, 0, GL_RGBA, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, RequireExt<&Extensions::textureNorm16>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA16_SNORM_EXT, RGBAFormat(16, 16, 16, 16, 0, GL_RGBA, GL_SHORT, GL_SIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, NeverSupported, AlwaysSupported)));
// clang-format on // clang-format on
return map; return map;
......
...@@ -279,10 +279,14 @@ def get_internal_format_initializer(internal_format, angle_format): ...@@ -279,10 +279,14 @@ def get_internal_format_initializer(internal_format, angle_format):
internal_format_initializer = 'Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0x01>' internal_format_initializer = 'Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0x01>'
elif angle_format['componentType'] == 'unorm' and angle_format['bits']['red'] == 8: elif angle_format['componentType'] == 'unorm' and angle_format['bits']['red'] == 8:
internal_format_initializer = 'Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>' internal_format_initializer = 'Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>'
elif angle_format['componentType'] == 'unorm' and angle_format['bits']['red'] == 16:
internal_format_initializer = 'Initialize4ComponentData<GLubyte, 0x0000, 0x0000, 0x0000, 0xFFFF>'
elif angle_format['componentType'] == 'int' and angle_format['bits']['red'] == 8: elif angle_format['componentType'] == 'int' and angle_format['bits']['red'] == 8:
internal_format_initializer = 'Initialize4ComponentData<GLbyte, 0x00, 0x00, 0x00, 0x01>' internal_format_initializer = 'Initialize4ComponentData<GLbyte, 0x00, 0x00, 0x00, 0x01>'
elif angle_format['componentType'] == 'snorm' and angle_format['bits']['red'] == 8: elif angle_format['componentType'] == 'snorm' and angle_format['bits']['red'] == 8:
internal_format_initializer = 'Initialize4ComponentData<GLbyte, 0x00, 0x00, 0x00, 0x7F>' internal_format_initializer = 'Initialize4ComponentData<GLbyte, 0x00, 0x00, 0x00, 0x7F>'
elif angle_format['componentType'] == 'snorm' and angle_format['bits']['red'] == 16:
internal_format_initializer = 'Initialize4ComponentData<GLushort, 0x0000, 0x0000, 0x0000, 0x7FFF>'
elif angle_format['componentType'] == 'float' and angle_format['bits']['red'] == 16: elif angle_format['componentType'] == 'float' and angle_format['bits']['red'] == 16:
internal_format_initializer = 'Initialize4ComponentData<GLhalf, 0x0000, 0x0000, 0x0000, gl::Float16One>' internal_format_initializer = 'Initialize4ComponentData<GLhalf, 0x0000, 0x0000, 0x0000, gl::Float16One>'
elif angle_format['componentType'] == 'uint' and angle_format['bits']['red'] == 16: elif angle_format['componentType'] == 'uint' and angle_format['bits']['red'] == 16:
......
...@@ -1112,5 +1112,77 @@ ...@@ -1112,5 +1112,77 @@
"requiresConversion": "true" "requiresConversion": "true"
} }
] ]
},
"GL_R16_EXT": {
"GL_UNSIGNED_SHORT": [
{
"loadFunction": "LoadToNative<GLushort,1>",
"dxgiFormat": "DXGI_FORMAT_R16_UNORM",
"requiresConversion": "false"
}
]
},
"GL_RG16_EXT": {
"GL_UNSIGNED_SHORT": [
{
"loadFunction": "LoadToNative<GLushort,2>",
"dxgiFormat": "DXGI_FORMAT_R16G16_UNORM",
"requiresConversion": "false"
}
]
},
"GL_RGB16_EXT": {
"GL_UNSIGNED_SHORT": [
{
"loadFunction": "LoadToNative3To4<GLushort,0xFFFF>",
"dxgiFormat": "DXGI_FORMAT_R16G16B16A16_UNORM",
"requiresConversion": "true"
}
]
},
"GL_RGBA16_EXT": {
"GL_UNSIGNED_SHORT": [
{
"loadFunction": "LoadToNative<GLushort,4>",
"dxgiFormat": "DXGI_FORMAT_R16G16B16A16_UNORM",
"requiresConversion": "false"
}
]
},
"GL_R16_SNORM_EXT": {
"GL_SHORT": [
{
"loadFunction": "LoadToNative<GLushort,1>",
"dxgiFormat": "DXGI_FORMAT_R16_SNORM",
"requiresConversion": "false"
}
]
},
"GL_RG16_SNORM_EXT": {
"GL_SHORT": [
{
"loadFunction": "LoadToNative<GLushort,2>",
"dxgiFormat": "DXGI_FORMAT_R16G16_SNORM",
"requiresConversion": "false"
}
]
},
"GL_RGB16_SNORM_EXT": {
"GL_SHORT": [
{
"loadFunction": "LoadToNative3To4<GLushort,0x7FFF>",
"dxgiFormat": "DXGI_FORMAT_R16G16B16A16_SNORM",
"requiresConversion": "true"
}
]
},
"GL_RGBA16_SNORM_EXT": {
"GL_SHORT": [
{
"loadFunction": "LoadToNative<GLushort,4>",
"dxgiFormat": "DXGI_FORMAT_R16G16B16A16_SNORM",
"requiresConversion": "false"
}
]
} }
} }
\ No newline at end of file
...@@ -1143,6 +1143,42 @@ const std::map<GLenum, LoadImageFunctionInfo> &GetLoadFunctionsMap(GLenum intern ...@@ -1143,6 +1143,42 @@ const std::map<GLenum, LoadImageFunctionInfo> &GetLoadFunctionsMap(GLenum intern
break; break;
} }
} }
case GL_R16_EXT:
{
switch (dxgiFormat)
{
case DXGI_FORMAT_R16_UNORM:
{
static const std::map<GLenum, LoadImageFunctionInfo> loadFunctionsMap = []() {
std::map<GLenum, LoadImageFunctionInfo> loadMap;
loadMap[GL_UNSIGNED_SHORT] = LoadImageFunctionInfo(LoadToNative<GLushort,1>, false);
return loadMap;
}();
return loadFunctionsMap;
}
default:
break;
}
}
case GL_R16_SNORM_EXT:
{
switch (dxgiFormat)
{
case DXGI_FORMAT_R16_SNORM:
{
static const std::map<GLenum, LoadImageFunctionInfo> loadFunctionsMap = []() {
std::map<GLenum, LoadImageFunctionInfo> loadMap;
loadMap[GL_SHORT] = LoadImageFunctionInfo(LoadToNative<GLushort,1>, false);
return loadMap;
}();
return loadFunctionsMap;
}
default:
break;
}
}
case GL_R32F: case GL_R32F:
{ {
switch (dxgiFormat) switch (dxgiFormat)
...@@ -1325,6 +1361,42 @@ const std::map<GLenum, LoadImageFunctionInfo> &GetLoadFunctionsMap(GLenum intern ...@@ -1325,6 +1361,42 @@ const std::map<GLenum, LoadImageFunctionInfo> &GetLoadFunctionsMap(GLenum intern
break; break;
} }
} }
case GL_RG16_EXT:
{
switch (dxgiFormat)
{
case DXGI_FORMAT_R16G16_UNORM:
{
static const std::map<GLenum, LoadImageFunctionInfo> loadFunctionsMap = []() {
std::map<GLenum, LoadImageFunctionInfo> loadMap;
loadMap[GL_UNSIGNED_SHORT] = LoadImageFunctionInfo(LoadToNative<GLushort,2>, false);
return loadMap;
}();
return loadFunctionsMap;
}
default:
break;
}
}
case GL_RG16_SNORM_EXT:
{
switch (dxgiFormat)
{
case DXGI_FORMAT_R16G16_SNORM:
{
static const std::map<GLenum, LoadImageFunctionInfo> loadFunctionsMap = []() {
std::map<GLenum, LoadImageFunctionInfo> loadMap;
loadMap[GL_SHORT] = LoadImageFunctionInfo(LoadToNative<GLushort,2>, false);
return loadMap;
}();
return loadFunctionsMap;
}
default:
break;
}
}
case GL_RG32F: case GL_RG32F:
{ {
switch (dxgiFormat) switch (dxgiFormat)
...@@ -1571,6 +1643,42 @@ const std::map<GLenum, LoadImageFunctionInfo> &GetLoadFunctionsMap(GLenum intern ...@@ -1571,6 +1643,42 @@ const std::map<GLenum, LoadImageFunctionInfo> &GetLoadFunctionsMap(GLenum intern
break; break;
} }
} }
case GL_RGB16_EXT:
{
switch (dxgiFormat)
{
case DXGI_FORMAT_R16G16B16A16_UNORM:
{
static const std::map<GLenum, LoadImageFunctionInfo> loadFunctionsMap = []() {
std::map<GLenum, LoadImageFunctionInfo> loadMap;
loadMap[GL_UNSIGNED_SHORT] = LoadImageFunctionInfo(LoadToNative3To4<GLushort,0xFFFF>, true);
return loadMap;
}();
return loadFunctionsMap;
}
default:
break;
}
}
case GL_RGB16_SNORM_EXT:
{
switch (dxgiFormat)
{
case DXGI_FORMAT_R16G16B16A16_SNORM:
{
static const std::map<GLenum, LoadImageFunctionInfo> loadFunctionsMap = []() {
std::map<GLenum, LoadImageFunctionInfo> loadMap;
loadMap[GL_SHORT] = LoadImageFunctionInfo(LoadToNative3To4<GLushort,0x7FFF>, true);
return loadMap;
}();
return loadFunctionsMap;
}
default:
break;
}
}
case GL_RGB32F: case GL_RGB32F:
{ {
switch (dxgiFormat) switch (dxgiFormat)
...@@ -1863,6 +1971,42 @@ const std::map<GLenum, LoadImageFunctionInfo> &GetLoadFunctionsMap(GLenum intern ...@@ -1863,6 +1971,42 @@ const std::map<GLenum, LoadImageFunctionInfo> &GetLoadFunctionsMap(GLenum intern
break; break;
} }
} }
case GL_RGBA16_EXT:
{
switch (dxgiFormat)
{
case DXGI_FORMAT_R16G16B16A16_UNORM:
{
static const std::map<GLenum, LoadImageFunctionInfo> loadFunctionsMap = []() {
std::map<GLenum, LoadImageFunctionInfo> loadMap;
loadMap[GL_UNSIGNED_SHORT] = LoadImageFunctionInfo(LoadToNative<GLushort,4>, false);
return loadMap;
}();
return loadFunctionsMap;
}
default:
break;
}
}
case GL_RGBA16_SNORM_EXT:
{
switch (dxgiFormat)
{
case DXGI_FORMAT_R16G16B16A16_SNORM:
{
static const std::map<GLenum, LoadImageFunctionInfo> loadFunctionsMap = []() {
std::map<GLenum, LoadImageFunctionInfo> loadMap;
loadMap[GL_SHORT] = LoadImageFunctionInfo(LoadToNative<GLushort,4>, false);
return loadMap;
}();
return loadFunctionsMap;
}
default:
break;
}
}
case GL_RGBA32F: case GL_RGBA32F:
{ {
switch (dxgiFormat) switch (dxgiFormat)
......
...@@ -498,5 +498,45 @@ ...@@ -498,5 +498,45 @@
"channels": "ds", "channels": "ds",
"bits": { "depth": 24, "stencil": 8 }, "bits": { "depth": 24, "stencil": 8 },
"glInternalFormat": "GL_DEPTH24_STENCIL8_OES" "glInternalFormat": "GL_DEPTH24_STENCIL8_OES"
},
"ANGLE_FORMAT_R16_UNORM": {
"texFormat": "DXGI_FORMAT_R16_UNORM",
"srvFormat": "DXGI_FORMAT_R16_UNORM",
"rtvFormat": "DXGI_FORMAT_R16_UNORM",
"channels": "r",
"componentType": "unorm",
"bits": { "red": 16 }
},
"ANGLE_FORMAT_R16G16_UNORM": {
"texFormat": "DXGI_FORMAT_R16G16_UNORM",
"srvFormat": "DXGI_FORMAT_R16G16_UNORM",
"rtvFormat": "DXGI_FORMAT_R16G16_UNORM",
"channels": "rg",
"componentType": "unorm",
"bits": { "red": 16, "green": 16 }
},
"ANGLE_FORMAT_R16_SNORM": {
"texFormat": "DXGI_FORMAT_R16_SNORM",
"srvFormat": "DXGI_FORMAT_R16_SNORM",
"channels": "r",
"componentType": "snorm",
"bits": { "red": 16 },
"glInternalFormat": "GL_R16_SNORM_EXT"
},
"ANGLE_FORMAT_R16G16_SNORM": {
"texFormat": "DXGI_FORMAT_R16G16_SNORM",
"srvFormat": "DXGI_FORMAT_R16G16_SNORM",
"channels": "rg",
"componentType": "snorm",
"bits": { "red": 16, "green": 16 },
"glInternalFormat": "GL_RG16_SNORM_EXT"
},
"ANGLE_FORMAT_R16G16B16A16_SNORM": {
"texFormat": "DXGI_FORMAT_R16G16B16A16_SNORM",
"srvFormat": "DXGI_FORMAT_R16G16B16A16_SNORM",
"channels": "rgba",
"componentType": "snorm",
"bits": { "red": 16, "green": 16, "blue": 16, "alpha": 16 },
"glInternalFormat": "GL_RGBA16_SNORM_EXT"
} }
} }
...@@ -144,5 +144,13 @@ ...@@ -144,5 +144,13 @@
"GL_STENCIL_INDEX8": { "GL_STENCIL_INDEX8": {
"OnlyFL10Plus": "ANGLE_FORMAT_X24_TYPELESS_G8_UINT", "OnlyFL10Plus": "ANGLE_FORMAT_X24_TYPELESS_G8_UINT",
"OnlyFL9_3": "ANGLE_FORMAT_D24_UNORM_S8_UINT_FL9_3" "OnlyFL9_3": "ANGLE_FORMAT_D24_UNORM_S8_UINT_FL9_3"
} },
"GL_R16_EXT": "ANGLE_FORMAT_R16_UNORM",
"GL_RG16_EXT": "ANGLE_FORMAT_R16G16_UNORM",
"GL_RGB16_EXT": "ANGLE_FORMAT_R16G16B16A16_UNORM",
"GL_RGBA16_EXT": "ANGLE_FORMAT_R16G16B16A16_UNORM",
"GL_R16_SNORM_EXT": "ANGLE_FORMAT_R16_SNORM",
"GL_RG16_SNORM_EXT": "ANGLE_FORMAT_R16G16_SNORM",
"GL_RGB16_SNORM_EXT": "ANGLE_FORMAT_R16G16B16A16_SNORM",
"GL_RGBA16_SNORM_EXT": "ANGLE_FORMAT_R16G16B16A16_SNORM"
} }
...@@ -439,6 +439,20 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat) ...@@ -439,6 +439,20 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
ReadColor<R16G16B16A16S, GLint>); ReadColor<R16G16B16A16S, GLint>);
return formatInfo; return formatInfo;
} }
case ANGLE_FORMAT_R16G16B16A16_SNORM:
{
static const ANGLEFormatSet formatInfo(ANGLE_FORMAT_R16G16B16A16_SNORM,
GL_RGBA16_SNORM_EXT,
DXGI_FORMAT_R16G16B16A16_SNORM,
DXGI_FORMAT_R16G16B16A16_SNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R16G16B16A16_SNORM,
ANGLE_FORMAT_R16G16B16A16_SNORM,
GenerateMip<R16G16B16A16S>,
ReadColor<R16G16B16A16S, GLfloat>);
return formatInfo;
}
case ANGLE_FORMAT_R16G16B16A16_UINT: case ANGLE_FORMAT_R16G16B16A16_UINT:
{ {
static const ANGLEFormatSet formatInfo(ANGLE_FORMAT_R16G16B16A16_UINT, static const ANGLEFormatSet formatInfo(ANGLE_FORMAT_R16G16B16A16_UINT,
...@@ -495,6 +509,20 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat) ...@@ -495,6 +509,20 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
ReadColor<R16G16S, GLint>); ReadColor<R16G16S, GLint>);
return formatInfo; return formatInfo;
} }
case ANGLE_FORMAT_R16G16_SNORM:
{
static const ANGLEFormatSet formatInfo(ANGLE_FORMAT_R16G16_SNORM,
GL_RG16_SNORM_EXT,
DXGI_FORMAT_R16G16_SNORM,
DXGI_FORMAT_R16G16_SNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R16G16_SNORM,
ANGLE_FORMAT_R16G16B16A16_SNORM,
GenerateMip<R16G16S>,
ReadColor<R16G16S, GLfloat>);
return formatInfo;
}
case ANGLE_FORMAT_R16G16_UINT: case ANGLE_FORMAT_R16G16_UINT:
{ {
static const ANGLEFormatSet formatInfo(ANGLE_FORMAT_R16G16_UINT, static const ANGLEFormatSet formatInfo(ANGLE_FORMAT_R16G16_UINT,
...@@ -509,6 +537,20 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat) ...@@ -509,6 +537,20 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
ReadColor<R16G16, GLuint>); ReadColor<R16G16, GLuint>);
return formatInfo; return formatInfo;
} }
case ANGLE_FORMAT_R16G16_UNORM:
{
static const ANGLEFormatSet formatInfo(ANGLE_FORMAT_R16G16_UNORM,
GL_NONE,
DXGI_FORMAT_R16G16_UNORM,
DXGI_FORMAT_R16G16_UNORM,
DXGI_FORMAT_R16G16_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R16G16_UNORM,
ANGLE_FORMAT_R16G16B16A16_UNORM,
GenerateMip<R16G16>,
ReadColor<R16G16, GLfloat>);
return formatInfo;
}
case ANGLE_FORMAT_R16_FLOAT: case ANGLE_FORMAT_R16_FLOAT:
{ {
static const ANGLEFormatSet formatInfo(ANGLE_FORMAT_R16_FLOAT, static const ANGLEFormatSet formatInfo(ANGLE_FORMAT_R16_FLOAT,
...@@ -537,6 +579,20 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat) ...@@ -537,6 +579,20 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
ReadColor<R16S, GLint>); ReadColor<R16S, GLint>);
return formatInfo; return formatInfo;
} }
case ANGLE_FORMAT_R16_SNORM:
{
static const ANGLEFormatSet formatInfo(ANGLE_FORMAT_R16_SNORM,
GL_R16_SNORM_EXT,
DXGI_FORMAT_R16_SNORM,
DXGI_FORMAT_R16_SNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R16_SNORM,
ANGLE_FORMAT_R16G16B16A16_SNORM,
GenerateMip<R16S>,
ReadColor<R16S, GLfloat>);
return formatInfo;
}
case ANGLE_FORMAT_R16_UINT: case ANGLE_FORMAT_R16_UINT:
{ {
static const ANGLEFormatSet formatInfo(ANGLE_FORMAT_R16_UINT, static const ANGLEFormatSet formatInfo(ANGLE_FORMAT_R16_UINT,
...@@ -551,6 +607,20 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat) ...@@ -551,6 +607,20 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
ReadColor<R16, GLuint>); ReadColor<R16, GLuint>);
return formatInfo; return formatInfo;
} }
case ANGLE_FORMAT_R16_UNORM:
{
static const ANGLEFormatSet formatInfo(ANGLE_FORMAT_R16_UNORM,
GL_NONE,
DXGI_FORMAT_R16_UNORM,
DXGI_FORMAT_R16_UNORM,
DXGI_FORMAT_R16_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R16_UNORM,
ANGLE_FORMAT_R16G16B16A16_UNORM,
GenerateMip<R16>,
ReadColor<R16, GLfloat>);
return formatInfo;
}
case ANGLE_FORMAT_R32G32B32A32_FLOAT: case ANGLE_FORMAT_R32G32B32A32_FLOAT:
{ {
static const ANGLEFormatSet formatInfo(ANGLE_FORMAT_R32G32B32A32_FLOAT, static const ANGLEFormatSet formatInfo(ANGLE_FORMAT_R32G32B32A32_FLOAT,
...@@ -1464,6 +1534,20 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat, ...@@ -1464,6 +1534,20 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat,
nullptr); nullptr);
return textureFormat; return textureFormat;
} }
case GL_R16_EXT:
{
static const TextureFormat textureFormat(internalFormat,
ANGLE_FORMAT_R16_UNORM,
nullptr);
return textureFormat;
}
case GL_R16_SNORM_EXT:
{
static const TextureFormat textureFormat(internalFormat,
ANGLE_FORMAT_R16_SNORM,
nullptr);
return textureFormat;
}
case GL_R32F: case GL_R32F:
{ {
static const TextureFormat textureFormat(internalFormat, static const TextureFormat textureFormat(internalFormat,
...@@ -1534,6 +1618,20 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat, ...@@ -1534,6 +1618,20 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat,
nullptr); nullptr);
return textureFormat; return textureFormat;
} }
case GL_RG16_EXT:
{
static const TextureFormat textureFormat(internalFormat,
ANGLE_FORMAT_R16G16_UNORM,
nullptr);
return textureFormat;
}
case GL_RG16_SNORM_EXT:
{
static const TextureFormat textureFormat(internalFormat,
ANGLE_FORMAT_R16G16_SNORM,
nullptr);
return textureFormat;
}
case GL_RG32F: case GL_RG32F:
{ {
static const TextureFormat textureFormat(internalFormat, static const TextureFormat textureFormat(internalFormat,
...@@ -1625,6 +1723,20 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat, ...@@ -1625,6 +1723,20 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat,
Initialize4ComponentData<GLushort, 0x0000, 0x0000, 0x0000, 0x0001>); Initialize4ComponentData<GLushort, 0x0000, 0x0000, 0x0000, 0x0001>);
return textureFormat; return textureFormat;
} }
case GL_RGB16_EXT:
{
static const TextureFormat textureFormat(internalFormat,
ANGLE_FORMAT_R16G16B16A16_UNORM,
Initialize4ComponentData<GLubyte, 0x0000, 0x0000, 0x0000, 0xFFFF>);
return textureFormat;
}
case GL_RGB16_SNORM_EXT:
{
static const TextureFormat textureFormat(internalFormat,
ANGLE_FORMAT_R16G16B16A16_SNORM,
Initialize4ComponentData<GLushort, 0x0000, 0x0000, 0x0000, 0x7FFF>);
return textureFormat;
}
case GL_RGB32F: case GL_RGB32F:
{ {
static const TextureFormat textureFormat(internalFormat, static const TextureFormat textureFormat(internalFormat,
...@@ -1751,6 +1863,20 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat, ...@@ -1751,6 +1863,20 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat,
nullptr); nullptr);
return textureFormat; return textureFormat;
} }
case GL_RGBA16_EXT:
{
static const TextureFormat textureFormat(internalFormat,
ANGLE_FORMAT_R16G16B16A16_UNORM,
nullptr);
return textureFormat;
}
case GL_RGBA16_SNORM_EXT:
{
static const TextureFormat textureFormat(internalFormat,
ANGLE_FORMAT_R16G16B16A16_SNORM,
nullptr);
return textureFormat;
}
case GL_RGBA32F: case GL_RGBA32F:
{ {
static const TextureFormat textureFormat(internalFormat, static const TextureFormat textureFormat(internalFormat,
......
...@@ -34,14 +34,19 @@ enum ANGLEFormat ...@@ -34,14 +34,19 @@ enum ANGLEFormat
ANGLE_FORMAT_R11G11B10_FLOAT, ANGLE_FORMAT_R11G11B10_FLOAT,
ANGLE_FORMAT_R16G16B16A16_FLOAT, ANGLE_FORMAT_R16G16B16A16_FLOAT,
ANGLE_FORMAT_R16G16B16A16_SINT, ANGLE_FORMAT_R16G16B16A16_SINT,
ANGLE_FORMAT_R16G16B16A16_SNORM,
ANGLE_FORMAT_R16G16B16A16_UINT, ANGLE_FORMAT_R16G16B16A16_UINT,
ANGLE_FORMAT_R16G16B16A16_UNORM, ANGLE_FORMAT_R16G16B16A16_UNORM,
ANGLE_FORMAT_R16G16_FLOAT, ANGLE_FORMAT_R16G16_FLOAT,
ANGLE_FORMAT_R16G16_SINT, ANGLE_FORMAT_R16G16_SINT,
ANGLE_FORMAT_R16G16_SNORM,
ANGLE_FORMAT_R16G16_UINT, ANGLE_FORMAT_R16G16_UINT,
ANGLE_FORMAT_R16G16_UNORM,
ANGLE_FORMAT_R16_FLOAT, ANGLE_FORMAT_R16_FLOAT,
ANGLE_FORMAT_R16_SINT, ANGLE_FORMAT_R16_SINT,
ANGLE_FORMAT_R16_SNORM,
ANGLE_FORMAT_R16_UINT, ANGLE_FORMAT_R16_UINT,
ANGLE_FORMAT_R16_UNORM,
ANGLE_FORMAT_R32G32B32A32_FLOAT, ANGLE_FORMAT_R32G32B32A32_FLOAT,
ANGLE_FORMAT_R32G32B32A32_SINT, ANGLE_FORMAT_R32G32B32A32_SINT,
ANGLE_FORMAT_R32G32B32A32_UINT, ANGLE_FORMAT_R32G32B32A32_UINT,
......
...@@ -41,6 +41,9 @@ static FormatWriteFunctionMap BuildFormatWriteFunctionMap() ...@@ -41,6 +41,9 @@ static FormatWriteFunctionMap BuildFormatWriteFunctionMap()
InsertFormatWriteFunctionMapping(&map, GL_RGBA, GL_FLOAT, WriteColor<R32G32B32A32F, GLfloat>); InsertFormatWriteFunctionMapping(&map, GL_RGBA, GL_FLOAT, WriteColor<R32G32B32A32F, GLfloat>);
InsertFormatWriteFunctionMapping(&map, GL_RGBA, GL_HALF_FLOAT, WriteColor<R16G16B16A16F, GLfloat>); InsertFormatWriteFunctionMapping(&map, GL_RGBA, GL_HALF_FLOAT, WriteColor<R16G16B16A16F, GLfloat>);
InsertFormatWriteFunctionMapping(&map, GL_RGBA, GL_HALF_FLOAT_OES, WriteColor<R16G16B16A16F, GLfloat>); InsertFormatWriteFunctionMapping(&map, GL_RGBA, GL_HALF_FLOAT_OES, WriteColor<R16G16B16A16F, GLfloat>);
InsertFormatWriteFunctionMapping(&map, GL_RGBA, GL_UNSIGNED_SHORT,
WriteColor<R16G16B16A16, GLfloat>);
InsertFormatWriteFunctionMapping(&map, GL_RGBA, GL_SHORT, WriteColor<R16G16B16A16S, GLfloat>);
InsertFormatWriteFunctionMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, WriteColor<R8G8B8A8, GLuint> ); InsertFormatWriteFunctionMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, WriteColor<R8G8B8A8, GLuint> );
InsertFormatWriteFunctionMapping(&map, GL_RGBA_INTEGER, GL_BYTE, WriteColor<R8G8B8A8S, GLint> ); InsertFormatWriteFunctionMapping(&map, GL_RGBA_INTEGER, GL_BYTE, WriteColor<R8G8B8A8S, GLint> );
...@@ -58,6 +61,9 @@ static FormatWriteFunctionMap BuildFormatWriteFunctionMap() ...@@ -58,6 +61,9 @@ static FormatWriteFunctionMap BuildFormatWriteFunctionMap()
InsertFormatWriteFunctionMapping(&map, GL_RGB, GL_FLOAT, WriteColor<R32G32B32F, GLfloat> ); InsertFormatWriteFunctionMapping(&map, GL_RGB, GL_FLOAT, WriteColor<R32G32B32F, GLfloat> );
InsertFormatWriteFunctionMapping(&map, GL_RGB, GL_HALF_FLOAT, WriteColor<R16G16B16F, GLfloat> ); InsertFormatWriteFunctionMapping(&map, GL_RGB, GL_HALF_FLOAT, WriteColor<R16G16B16F, GLfloat> );
InsertFormatWriteFunctionMapping(&map, GL_RGB, GL_HALF_FLOAT_OES, WriteColor<R16G16B16F, GLfloat> ); InsertFormatWriteFunctionMapping(&map, GL_RGB, GL_HALF_FLOAT_OES, WriteColor<R16G16B16F, GLfloat> );
InsertFormatWriteFunctionMapping(&map, GL_RGB, GL_UNSIGNED_SHORT,
WriteColor<R16G16B16, GLfloat>);
InsertFormatWriteFunctionMapping(&map, GL_RGB, GL_SHORT, WriteColor<R16G16B16S, GLfloat>);
InsertFormatWriteFunctionMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, WriteColor<R8G8B8, GLuint> ); InsertFormatWriteFunctionMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, WriteColor<R8G8B8, GLuint> );
InsertFormatWriteFunctionMapping(&map, GL_RGB_INTEGER, GL_BYTE, WriteColor<R8G8B8S, GLint> ); InsertFormatWriteFunctionMapping(&map, GL_RGB_INTEGER, GL_BYTE, WriteColor<R8G8B8S, GLint> );
...@@ -71,6 +77,8 @@ static FormatWriteFunctionMap BuildFormatWriteFunctionMap() ...@@ -71,6 +77,8 @@ static FormatWriteFunctionMap BuildFormatWriteFunctionMap()
InsertFormatWriteFunctionMapping(&map, GL_RG, GL_FLOAT, WriteColor<R32G32F, GLfloat> ); InsertFormatWriteFunctionMapping(&map, GL_RG, GL_FLOAT, WriteColor<R32G32F, GLfloat> );
InsertFormatWriteFunctionMapping(&map, GL_RG, GL_HALF_FLOAT, WriteColor<R16G16F, GLfloat> ); InsertFormatWriteFunctionMapping(&map, GL_RG, GL_HALF_FLOAT, WriteColor<R16G16F, GLfloat> );
InsertFormatWriteFunctionMapping(&map, GL_RG, GL_HALF_FLOAT_OES, WriteColor<R16G16F, GLfloat> ); InsertFormatWriteFunctionMapping(&map, GL_RG, GL_HALF_FLOAT_OES, WriteColor<R16G16F, GLfloat> );
InsertFormatWriteFunctionMapping(&map, GL_RG, GL_UNSIGNED_SHORT, WriteColor<R16G16, GLfloat>);
InsertFormatWriteFunctionMapping(&map, GL_RG, GL_SHORT, WriteColor<R16G16S, GLfloat>);
InsertFormatWriteFunctionMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_BYTE, WriteColor<R8G8, GLuint> ); InsertFormatWriteFunctionMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_BYTE, WriteColor<R8G8, GLuint> );
InsertFormatWriteFunctionMapping(&map, GL_RG_INTEGER, GL_BYTE, WriteColor<R8G8S, GLint> ); InsertFormatWriteFunctionMapping(&map, GL_RG_INTEGER, GL_BYTE, WriteColor<R8G8S, GLint> );
...@@ -84,6 +92,8 @@ static FormatWriteFunctionMap BuildFormatWriteFunctionMap() ...@@ -84,6 +92,8 @@ static FormatWriteFunctionMap BuildFormatWriteFunctionMap()
InsertFormatWriteFunctionMapping(&map, GL_RED, GL_FLOAT, WriteColor<R32F, GLfloat> ); InsertFormatWriteFunctionMapping(&map, GL_RED, GL_FLOAT, WriteColor<R32F, GLfloat> );
InsertFormatWriteFunctionMapping(&map, GL_RED, GL_HALF_FLOAT, WriteColor<R16F, GLfloat> ); InsertFormatWriteFunctionMapping(&map, GL_RED, GL_HALF_FLOAT, WriteColor<R16F, GLfloat> );
InsertFormatWriteFunctionMapping(&map, GL_RED, GL_HALF_FLOAT_OES, WriteColor<R16F, GLfloat> ); InsertFormatWriteFunctionMapping(&map, GL_RED, GL_HALF_FLOAT_OES, WriteColor<R16F, GLfloat> );
InsertFormatWriteFunctionMapping(&map, GL_RED, GL_UNSIGNED_SHORT, WriteColor<R16, GLfloat>);
InsertFormatWriteFunctionMapping(&map, GL_RED, GL_SHORT, WriteColor<R16S, GLfloat>);
InsertFormatWriteFunctionMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_BYTE, WriteColor<R8, GLuint> ); InsertFormatWriteFunctionMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_BYTE, WriteColor<R8, GLuint> );
InsertFormatWriteFunctionMapping(&map, GL_RED_INTEGER, GL_BYTE, WriteColor<R8S, GLint> ); InsertFormatWriteFunctionMapping(&map, GL_RED_INTEGER, GL_BYTE, WriteColor<R8S, GLint> );
......
...@@ -197,6 +197,16 @@ ES3FormatCombinationSet BuildES3FormatSet() ...@@ -197,6 +197,16 @@ ES3FormatCombinationSet BuildES3FormatSet()
// From GL_ANGLE_depth_texture // From GL_ANGLE_depth_texture
InsertES3FormatCombo(&set, GL_DEPTH_COMPONENT32_OES, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT_24_8_OES ); InsertES3FormatCombo(&set, GL_DEPTH_COMPONENT32_OES, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT_24_8_OES );
// From GL_EXT_texture_norm16
InsertES3FormatCombo(&set, GL_R16_EXT, GL_RED, GL_UNSIGNED_SHORT);
InsertES3FormatCombo(&set, GL_RG16_EXT, GL_RG, GL_UNSIGNED_SHORT);
InsertES3FormatCombo(&set, GL_RGB16_EXT, GL_RGB, GL_UNSIGNED_SHORT);
InsertES3FormatCombo(&set, GL_RGBA16_EXT, GL_RGBA, GL_UNSIGNED_SHORT);
InsertES3FormatCombo(&set, GL_R16_SNORM_EXT, GL_RED, GL_SHORT);
InsertES3FormatCombo(&set, GL_RG16_SNORM_EXT, GL_RG, GL_SHORT);
InsertES3FormatCombo(&set, GL_RGB16_SNORM_EXT, GL_RGB, GL_SHORT);
InsertES3FormatCombo(&set, GL_RGBA16_SNORM_EXT, GL_RGBA, GL_SHORT);
return set; return set;
} }
...@@ -1257,6 +1267,13 @@ bool ValidES3ReadFormatType(Context *context, GLenum internalFormat, GLenum form ...@@ -1257,6 +1267,13 @@ bool ValidES3ReadFormatType(Context *context, GLenum internalFormat, GLenum form
{ {
case GL_UNSIGNED_BYTE: case GL_UNSIGNED_BYTE:
break; break;
case GL_UNSIGNED_SHORT:
if (internalFormatInfo.componentType != GL_UNSIGNED_NORMALIZED &&
internalFormatInfo.type != GL_UNSIGNED_SHORT)
{
return false;
}
break;
case GL_UNSIGNED_INT_2_10_10_10_REV: case GL_UNSIGNED_INT_2_10_10_10_REV:
if (internalFormat != GL_RGB10_A2) if (internalFormat != GL_RGB10_A2)
{ {
...@@ -1313,6 +1330,13 @@ bool ValidES3ReadFormatType(Context *context, GLenum internalFormat, GLenum form ...@@ -1313,6 +1330,13 @@ bool ValidES3ReadFormatType(Context *context, GLenum internalFormat, GLenum form
{ {
case GL_UNSIGNED_BYTE: case GL_UNSIGNED_BYTE:
break; break;
case GL_UNSIGNED_SHORT:
if (internalFormatInfo.componentType != GL_UNSIGNED_NORMALIZED &&
internalFormatInfo.type != GL_UNSIGNED_SHORT)
{
return false;
}
break;
default: default:
return false; return false;
} }
......
...@@ -11,6 +11,27 @@ using namespace angle; ...@@ -11,6 +11,27 @@ using namespace angle;
namespace namespace
{ {
// Take a pixel, and reset the components not covered by the format to default
// values. In particular, the default value for the alpha component is 65535
// (1.0 as unsigned normalized fixed point value).
GLColor16 SliceFormatColor16(GLenum format, GLColor16 full)
{
switch (format)
{
case GL_RED:
return GLColor16(full.R, 0, 0, 65535u);
case GL_RG:
return GLColor16(full.R, full.G, 0, 65535u);
case GL_RGB:
return GLColor16(full.R, full.G, full.B, 65535u);
case GL_RGBA:
return full;
default:
UNREACHABLE();
}
return GLColor16::white;
}
class TexCoordDrawTest : public ANGLETest class TexCoordDrawTest : public ANGLETest
{ {
protected: protected:
...@@ -3156,6 +3177,147 @@ TEST_P(TextureLimitsTest, DrawWithTexturePastMaximum) ...@@ -3156,6 +3177,147 @@ TEST_P(TextureLimitsTest, DrawWithTexturePastMaximum)
EXPECT_GL_ERROR(GL_INVALID_OPERATION); EXPECT_GL_ERROR(GL_INVALID_OPERATION);
} }
class Texture2DNorm16TestES3 : public Texture2DTestES3
{
protected:
Texture2DNorm16TestES3() : Texture2DTestES3(), mTextures{0, 0, 0}, mFBO(0), mRenderbuffer(0) {}
void SetUp() override
{
Texture2DTestES3::SetUp();
glActiveTexture(GL_TEXTURE0);
glGenTextures(3, mTextures);
glGenFramebuffers(1, &mFBO);
glGenRenderbuffers(1, &mRenderbuffer);
for (size_t textureIndex = 0; textureIndex < 3; textureIndex++)
{
glBindTexture(GL_TEXTURE_2D, mTextures[textureIndex]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
glBindTexture(GL_TEXTURE_2D, 0);
ASSERT_GL_NO_ERROR();
}
void TearDown() override
{
glDeleteTextures(3, mTextures);
glDeleteFramebuffers(1, &mFBO);
glDeleteRenderbuffers(1, &mRenderbuffer);
Texture2DTestES3::TearDown();
}
void testNorm16Texture(GLint internalformat, GLenum format, GLenum type)
{
GLushort pixelValue = type == GL_SHORT ? 0x7FFF : 0x6A35;
GLColor16 imageData(pixelValue, pixelValue, pixelValue, pixelValue);
setUpProgram();
glBindFramebuffer(GL_FRAMEBUFFER, mFBO);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTextures[0],
0);
glBindTexture(GL_TEXTURE_2D, mTextures[0]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16_EXT, 1, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT, nullptr);
glBindTexture(GL_TEXTURE_2D, mTextures[1]);
glTexImage2D(GL_TEXTURE_2D, 0, internalformat, 1, 1, 0, format, type, &imageData.R);
EXPECT_GL_NO_ERROR();
drawQuad(mProgram, "position", 0.5f);
GLColor16 expectedValue = imageData;
if (type == GL_SHORT)
{
// sampled as signed value; then stored as unsigned value
expectedValue = GLColor16::white;
}
EXPECT_PIXEL_COLOR16_EQ(0, 0, SliceFormatColor16(format, expectedValue));
glBindFramebuffer(GL_FRAMEBUFFER, 0);
ASSERT_GL_NO_ERROR();
}
void testNorm16Render(GLint internalformat, GLenum format, GLenum type)
{
GLushort pixelValue = 0x6A35;
GLColor16 imageData(pixelValue, pixelValue, pixelValue, pixelValue);
setUpProgram();
glBindTexture(GL_TEXTURE_2D, mTextures[1]);
glTexImage2D(GL_TEXTURE_2D, 0, internalformat, 1, 1, 0, format, type, nullptr);
glBindFramebuffer(GL_FRAMEBUFFER, mFBO);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTextures[1],
0);
glBindTexture(GL_TEXTURE_2D, mTextures[2]);
glTexImage2D(GL_TEXTURE_2D, 0, internalformat, 1, 1, 0, format, type, &imageData.R);
EXPECT_GL_NO_ERROR();
drawQuad(mProgram, "position", 0.5f);
EXPECT_PIXEL_COLOR16_EQ(0, 0, SliceFormatColor16(format, imageData));
glBindRenderbuffer(GL_RENDERBUFFER, mRenderbuffer);
glRenderbufferStorage(GL_RENDERBUFFER, internalformat, 1, 1);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
mRenderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
EXPECT_GL_NO_ERROR();
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1);
GLColor16 expectedValue = GLColor16::white;
EXPECT_PIXEL_COLOR16_EQ(0, 0, SliceFormatColor16(format, expectedValue));
glBindFramebuffer(GL_FRAMEBUFFER, 0);
ASSERT_GL_NO_ERROR();
}
GLuint mTextures[3];
GLuint mFBO;
GLuint mRenderbuffer;
};
// Test texture formats enabled by the GL_EXT_texture_norm16 extension.
TEST_P(Texture2DNorm16TestES3, TextureNorm16Test)
{
if (!extensionEnabled("GL_EXT_texture_norm16"))
{
std::cout << "Test skipped due to missing GL_EXT_texture_norm16." << std::endl;
return;
}
testNorm16Texture(GL_R16_EXT, GL_RED, GL_UNSIGNED_SHORT);
testNorm16Texture(GL_RG16_EXT, GL_RG, GL_UNSIGNED_SHORT);
testNorm16Texture(GL_RGB16_EXT, GL_RGB, GL_UNSIGNED_SHORT);
testNorm16Texture(GL_RGBA16_EXT, GL_RGBA, GL_UNSIGNED_SHORT);
testNorm16Texture(GL_R16_SNORM_EXT, GL_RED, GL_SHORT);
testNorm16Texture(GL_RG16_SNORM_EXT, GL_RG, GL_SHORT);
testNorm16Texture(GL_RGB16_SNORM_EXT, GL_RGB, GL_SHORT);
testNorm16Texture(GL_RGBA16_SNORM_EXT, GL_RGBA, GL_SHORT);
testNorm16Render(GL_R16_EXT, GL_RED, GL_UNSIGNED_SHORT);
testNorm16Render(GL_RG16_EXT, GL_RG, GL_UNSIGNED_SHORT);
testNorm16Render(GL_RGBA16_EXT, GL_RGBA, GL_UNSIGNED_SHORT);
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
// TODO(oetuaho): Enable all below tests on OpenGL. Requires a fix for ANGLE bug 1278. // TODO(oetuaho): Enable all below tests on OpenGL. Requires a fix for ANGLE bug 1278.
ANGLE_INSTANTIATE_TEST(Texture2DTest, ANGLE_INSTANTIATE_TEST(Texture2DTest,
...@@ -3239,5 +3401,6 @@ ANGLE_INSTANTIATE_TEST(SamplerInStructAndOtherVariableTest, ...@@ -3239,5 +3401,6 @@ ANGLE_INSTANTIATE_TEST(SamplerInStructAndOtherVariableTest,
ES2_OPENGL(), ES2_OPENGL(),
ES2_OPENGLES()); ES2_OPENGLES());
ANGLE_INSTANTIATE_TEST(TextureLimitsTest, ES2_D3D11(), ES2_OPENGL(), ES2_OPENGLES()); ANGLE_INSTANTIATE_TEST(TextureLimitsTest, ES2_D3D11(), ES2_OPENGL(), ES2_OPENGLES());
ANGLE_INSTANTIATE_TEST(Texture2DNorm16TestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
} // namespace } // namespace
...@@ -22,6 +22,8 @@ const GLColor GLColor::cyan = GLColor(0u, 255u, 255u, 255u); ...@@ -22,6 +22,8 @@ const GLColor GLColor::cyan = GLColor(0u, 255u, 255u, 255u);
const GLColor GLColor::black = GLColor(0u, 0u, 0u, 255u); const GLColor GLColor::black = GLColor(0u, 0u, 0u, 255u);
const GLColor GLColor::white = GLColor(255u, 255u, 255u, 255u); const GLColor GLColor::white = GLColor(255u, 255u, 255u, 255u);
const GLColor16 GLColor16::white = GLColor16(65535u, 65535u, 65535u, 65535u);
namespace namespace
{ {
float ColorNorm(GLubyte channelValue) float ColorNorm(GLubyte channelValue)
...@@ -122,6 +124,35 @@ std::ostream &operator<<(std::ostream &ostream, const GLColor &color) ...@@ -122,6 +124,35 @@ std::ostream &operator<<(std::ostream &ostream, const GLColor &color)
return ostream; return ostream;
} }
GLColor16::GLColor16() : R(0), G(0), B(0), A(0)
{
}
GLColor16::GLColor16(GLushort r, GLushort g, GLushort b, GLushort a) : R(r), G(g), B(b), A(a)
{
}
GLColor16 ReadColor16(GLint x, GLint y)
{
GLColor16 actual;
glReadPixels((x), (y), 1, 1, GL_RGBA, GL_UNSIGNED_SHORT, &actual.R);
EXPECT_GL_NO_ERROR();
return actual;
}
bool operator==(const GLColor16 &a, const GLColor16 &b)
{
return a.R == b.R && a.G == b.G && a.B == b.B && a.A == b.A;
}
std::ostream &operator<<(std::ostream &ostream, const GLColor16 &color)
{
ostream << "(" << static_cast<unsigned int>(color.R) << ", "
<< static_cast<unsigned int>(color.G) << ", " << static_cast<unsigned int>(color.B)
<< ", " << static_cast<unsigned int>(color.A) << ")";
return ostream;
}
} // namespace angle } // namespace angle
ANGLETest::ANGLETest() ANGLETest::ANGLETest()
...@@ -545,6 +576,11 @@ int ANGLETest::getClientVersion() const ...@@ -545,6 +576,11 @@ int ANGLETest::getClientVersion() const
return mEGLWindow->getClientMajorVersion(); return mEGLWindow->getClientMajorVersion();
} }
int ANGLETest::getClientMinorVersion() const
{
return mEGLWindow->getClientMinorVersion();
}
EGLWindow *ANGLETest::getEGLWindow() const EGLWindow *ANGLETest::getEGLWindow() const
{ {
return mEGLWindow; return mEGLWindow;
......
...@@ -74,6 +74,28 @@ bool operator==(const GLColor &a, const GLColor &b); ...@@ -74,6 +74,28 @@ bool operator==(const GLColor &a, const GLColor &b);
std::ostream &operator<<(std::ostream &ostream, const GLColor &color); std::ostream &operator<<(std::ostream &ostream, const GLColor &color);
GLColor ReadColor(GLint x, GLint y); GLColor ReadColor(GLint x, GLint y);
struct GLColor16
{
GLColor16();
GLColor16(GLushort r, GLushort g, GLushort b, GLushort a);
GLushort R, G, B, A;
static const GLColor16 white;
};
// Useful to cast any type to GLushort.
template <typename TR, typename TG, typename TB, typename TA>
GLColor16 MakeGLColor16(TR r, TG g, TB b, TA a)
{
return GLColor16(static_cast<GLushort>(r), static_cast<GLushort>(g), static_cast<GLushort>(b),
static_cast<GLushort>(a));
}
bool operator==(const GLColor16 &a, const GLColor16 &b);
std::ostream &operator<<(std::ostream &ostream, const GLColor16 &color);
GLColor16 ReadColor16(GLint x, GLint y);
} // namespace angle } // namespace angle
#define EXPECT_PIXEL_EQ(x, y, r, g, b, a) \ #define EXPECT_PIXEL_EQ(x, y, r, g, b, a) \
...@@ -95,6 +117,8 @@ GLColor ReadColor(GLint x, GLint y); ...@@ -95,6 +117,8 @@ GLColor ReadColor(GLint x, GLint y);
EXPECT_NEAR((a), pixel[3], abs_error); \ EXPECT_NEAR((a), pixel[3], abs_error); \
} }
#define EXPECT_PIXEL_COLOR16_EQ(x, y, angleColor) EXPECT_EQ(angleColor, angle::ReadColor16(x, y))
class EGLWindow; class EGLWindow;
class OSWindow; class OSWindow;
...@@ -154,6 +178,7 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters> ...@@ -154,6 +178,7 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters>
void setNoErrorEnabled(bool enabled); void setNoErrorEnabled(bool enabled);
int getClientVersion() const; int getClientVersion() const;
int getClientMinorVersion() const;
EGLWindow *getEGLWindow() const; EGLWindow *getEGLWindow() const;
int getWindowWidth() const; int getWindowWidth() const;
......
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