Added validation for CopyTexImage with integer textures.

TRAC #23049 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Geoff Lang git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2375 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent e19409b5
...@@ -623,8 +623,8 @@ static InternalFormatInfoMap buildES3InternalFormatInfoMap() ...@@ -623,8 +623,8 @@ static InternalFormatInfoMap buildES3InternalFormatInfoMap()
map.insert(InternalFormatInfoPair(GL_BGR5_A1_ANGLEX, InternalFormatInfo::RGBAFormat( 5, 5, 5, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, NormalizedFixedPoint, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); map.insert(InternalFormatInfoPair(GL_BGR5_A1_ANGLEX, InternalFormatInfo::RGBAFormat( 5, 5, 5, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, NormalizedFixedPoint, AlwaysSupported, AlwaysSupported, AlwaysSupported )));
// Floating point renderability and filtering is provided by OES_texture_float and OES_texture_half_float // Floating point renderability and filtering is provided by OES_texture_float and OES_texture_half_float
// | Internal format | | D |S | Format | Type | Internal fmt |Color | Texture | Supported | // | Internal format | | D |S | Format | Type | Internal fmt | Color | Texture | Supported |
// | | | | | | | type | | filterable | | // | | | | | | | type | renderable | filterable | |
map.insert(InternalFormatInfoPair(GL_R16F, InternalFormatInfo::RGBAFormat(16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT, FloatingPoint, CheckSupport<&Context::supportsFloat16RenderableTextures, &rx::Renderer::getFloat16TextureRenderingSupport>, CheckSupport<&Context::supportsFloat16LinearFilter, &rx::Renderer::getFloat16TextureFilteringSupport>, AlwaysSupported ))); map.insert(InternalFormatInfoPair(GL_R16F, InternalFormatInfo::RGBAFormat(16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT, FloatingPoint, CheckSupport<&Context::supportsFloat16RenderableTextures, &rx::Renderer::getFloat16TextureRenderingSupport>, CheckSupport<&Context::supportsFloat16LinearFilter, &rx::Renderer::getFloat16TextureFilteringSupport>, AlwaysSupported )));
map.insert(InternalFormatInfoPair(GL_RG16F, InternalFormatInfo::RGBAFormat(16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT, FloatingPoint, CheckSupport<&Context::supportsFloat16RenderableTextures, &rx::Renderer::getFloat16TextureRenderingSupport>, CheckSupport<&Context::supportsFloat16LinearFilter, &rx::Renderer::getFloat16TextureFilteringSupport>, AlwaysSupported ))); map.insert(InternalFormatInfoPair(GL_RG16F, InternalFormatInfo::RGBAFormat(16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT, FloatingPoint, CheckSupport<&Context::supportsFloat16RenderableTextures, &rx::Renderer::getFloat16TextureRenderingSupport>, CheckSupport<&Context::supportsFloat16LinearFilter, &rx::Renderer::getFloat16TextureFilteringSupport>, AlwaysSupported )));
map.insert(InternalFormatInfoPair(GL_RGB16F, InternalFormatInfo::RGBAFormat(16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT, FloatingPoint, CheckSupport<&Context::supportsFloat16RenderableTextures, &rx::Renderer::getFloat16TextureRenderingSupport>, CheckSupport<&Context::supportsFloat16LinearFilter, &rx::Renderer::getFloat16TextureFilteringSupport>, AlwaysSupported ))); map.insert(InternalFormatInfoPair(GL_RGB16F, InternalFormatInfo::RGBAFormat(16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT, FloatingPoint, CheckSupport<&Context::supportsFloat16RenderableTextures, &rx::Renderer::getFloat16TextureRenderingSupport>, CheckSupport<&Context::supportsFloat16LinearFilter, &rx::Renderer::getFloat16TextureFilteringSupport>, AlwaysSupported )));
...@@ -907,6 +907,17 @@ static CopyConversionSet buildValidES3CopyTexImageCombinations() ...@@ -907,6 +907,17 @@ static CopyConversionSet buildValidES3CopyTexImageCombinations()
set.insert(CopyConversion(GL_RGB, GL_RGBA)); set.insert(CopyConversion(GL_RGB, GL_RGBA));
set.insert(CopyConversion(GL_RGBA, GL_RGBA)); set.insert(CopyConversion(GL_RGBA, GL_RGBA));
set.insert(CopyConversion(GL_RED_INTEGER, GL_RED_INTEGER));
set.insert(CopyConversion(GL_RED_INTEGER, GL_RG_INTEGER));
set.insert(CopyConversion(GL_RED_INTEGER, GL_RGB_INTEGER));
set.insert(CopyConversion(GL_RED_INTEGER, GL_RGBA_INTEGER));
set.insert(CopyConversion(GL_RG_INTEGER, GL_RG_INTEGER));
set.insert(CopyConversion(GL_RG_INTEGER, GL_RGB_INTEGER));
set.insert(CopyConversion(GL_RG_INTEGER, GL_RGBA_INTEGER));
set.insert(CopyConversion(GL_RGB_INTEGER, GL_RGB_INTEGER));
set.insert(CopyConversion(GL_RGB_INTEGER, GL_RGBA_INTEGER));
set.insert(CopyConversion(GL_RGBA_INTEGER, GL_RGBA_INTEGER));
return set; return set;
} }
...@@ -988,17 +999,48 @@ bool IsValidFormatCombination(GLint internalFormat, GLenum format, GLenum type, ...@@ -988,17 +999,48 @@ bool IsValidFormatCombination(GLint internalFormat, GLenum format, GLenum type,
} }
} }
bool IsValidCopyTexImageCombination(GLenum textureFormat, GLenum frameBufferFormat, GLuint clientVersion) bool IsValidCopyTexImageCombination(GLenum textureInternalFormat, GLenum frameBufferInternalFormat, GLuint clientVersion)
{ {
if (clientVersion == 2) InternalFormatInfo textureInternalFormatInfo;
{ InternalFormatInfo framebufferInternalFormatInfo;
UNIMPLEMENTED(); if (getInternalFormatInfo(textureInternalFormat, clientVersion, &textureInternalFormatInfo) &&
return false; getInternalFormatInfo(frameBufferInternalFormat, clientVersion, &framebufferInternalFormatInfo))
}
else if (clientVersion == 3)
{ {
static const CopyConversionSet conversionSet = buildValidES3CopyTexImageCombinations(); if (clientVersion == 2)
return conversionSet.find(CopyConversion(textureFormat, frameBufferFormat)) != conversionSet.end(); {
UNIMPLEMENTED();
return false;
}
else if (clientVersion == 3)
{
static const CopyConversionSet conversionSet = buildValidES3CopyTexImageCombinations();
const CopyConversion conversion = CopyConversion(textureInternalFormatInfo.mFormat,
framebufferInternalFormatInfo.mFormat);
if (conversionSet.find(conversion) != conversionSet.end())
{
// Section 3.8.5 of the GLES3 3.0.2 spec states that source and destination formats
// must both be signed or unsigned or fixed/floating point
if ((textureInternalFormatInfo.mStorageType == SignedInteger && framebufferInternalFormatInfo.mStorageType == SignedInteger ) ||
(textureInternalFormatInfo.mStorageType == UnsignedInteger && framebufferInternalFormatInfo.mStorageType == UnsignedInteger))
{
return true;
}
if ((textureInternalFormatInfo.mStorageType == NormalizedFixedPoint || textureInternalFormatInfo.mStorageType == FloatingPoint) &&
(framebufferInternalFormatInfo.mStorageType == NormalizedFixedPoint || framebufferInternalFormatInfo.mStorageType == FloatingPoint))
{
return true;
}
}
return false;
}
else
{
UNREACHABLE();
return false;
}
} }
else else
{ {
......
...@@ -39,7 +39,7 @@ bool IsValidFormat(GLenum format, GLuint clientVersion); ...@@ -39,7 +39,7 @@ bool IsValidFormat(GLenum format, GLuint clientVersion);
bool IsValidType(GLenum type, GLuint clientVersion); bool IsValidType(GLenum type, GLuint clientVersion);
bool IsValidFormatCombination(GLint internalFormat, GLenum format, GLenum type, GLuint clientVersion); bool IsValidFormatCombination(GLint internalFormat, GLenum format, GLenum type, GLuint clientVersion);
bool IsValidCopyTexImageCombination(GLenum textureFormat, GLenum frameBufferFormat, GLuint clientVersion); bool IsValidCopyTexImageCombination(GLenum textureInternalFormat, GLenum frameBufferInternalFormat, GLuint clientVersion);
bool IsSizedInternalFormat(GLint internalFormat, GLuint clientVersion); bool IsSizedInternalFormat(GLint internalFormat, GLuint clientVersion);
GLint GetSizedInternalFormat(GLenum format, GLenum type, GLuint clientVersion); GLint GetSizedInternalFormat(GLenum format, GLenum type, GLuint clientVersion);
......
...@@ -1092,9 +1092,9 @@ bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLin ...@@ -1092,9 +1092,9 @@ bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLin
} }
gl::Renderbuffer *source = framebuffer->getReadColorbuffer(); gl::Renderbuffer *source = framebuffer->getReadColorbuffer();
GLenum colorbufferFormat = source->getInternalFormat(); GLenum colorbufferInternalFormat = source->getInternalFormat();
gl::Texture *texture = NULL; gl::Texture *texture = NULL;
GLenum textureFormat = GL_RGBA; GLenum textureInternalFormat = GL_NONE;
bool textureCompressed = false; bool textureCompressed = false;
GLint textureLevelWidth = 0; GLint textureLevelWidth = 0;
GLint textureLevelHeight = 0; GLint textureLevelHeight = 0;
...@@ -1106,7 +1106,7 @@ bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLin ...@@ -1106,7 +1106,7 @@ bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLin
gl::Texture2D *texture2d = context->getTexture2D(); gl::Texture2D *texture2d = context->getTexture2D();
if (texture2d) if (texture2d)
{ {
textureFormat = gl::GetFormat(texture2d->getInternalFormat(level), context->getClientVersion()); textureInternalFormat = texture2d->getInternalFormat(level);
textureCompressed = texture2d->isCompressed(level); textureCompressed = texture2d->isCompressed(level);
textureLevelWidth = texture2d->getWidth(level); textureLevelWidth = texture2d->getWidth(level);
textureLevelHeight = texture2d->getHeight(level); textureLevelHeight = texture2d->getHeight(level);
...@@ -1126,7 +1126,7 @@ bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLin ...@@ -1126,7 +1126,7 @@ bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLin
gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
if (textureCube) if (textureCube)
{ {
textureFormat = gl::GetFormat(textureCube->getInternalFormat(target, level), context->getClientVersion()); textureInternalFormat = textureCube->getInternalFormat(target, level);
textureCompressed = textureCube->isCompressed(target, level); textureCompressed = textureCube->isCompressed(target, level);
textureLevelWidth = textureCube->getWidth(target, level); textureLevelWidth = textureCube->getWidth(target, level);
textureLevelHeight = textureCube->getHeight(target, level); textureLevelHeight = textureCube->getHeight(target, level);
...@@ -1141,7 +1141,7 @@ bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLin ...@@ -1141,7 +1141,7 @@ bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLin
gl::Texture2DArray *texture2dArray = context->getTexture2DArray(); gl::Texture2DArray *texture2dArray = context->getTexture2DArray();
if (texture2dArray) if (texture2dArray)
{ {
textureFormat = gl::GetFormat(texture2dArray->getInternalFormat(level), context->getClientVersion()); textureInternalFormat = texture2dArray->getInternalFormat(level);
textureCompressed = texture2dArray->isCompressed(level); textureCompressed = texture2dArray->isCompressed(level);
textureLevelWidth = texture2dArray->getWidth(level); textureLevelWidth = texture2dArray->getWidth(level);
textureLevelHeight = texture2dArray->getHeight(level); textureLevelHeight = texture2dArray->getHeight(level);
...@@ -1156,7 +1156,7 @@ bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLin ...@@ -1156,7 +1156,7 @@ bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLin
gl::Texture3D *texture3d = context->getTexture3D(); gl::Texture3D *texture3d = context->getTexture3D();
if (texture3d) if (texture3d)
{ {
textureFormat = gl::GetFormat(texture3d->getInternalFormat(level), context->getClientVersion()); textureInternalFormat = texture3d->getInternalFormat(level);
textureCompressed = texture3d->isCompressed(level); textureCompressed = texture3d->isCompressed(level);
textureLevelWidth = texture3d->getWidth(level); textureLevelWidth = texture3d->getWidth(level);
textureLevelHeight = texture3d->getHeight(level); textureLevelHeight = texture3d->getHeight(level);
...@@ -1196,7 +1196,8 @@ bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLin ...@@ -1196,7 +1196,8 @@ bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLin
return gl::error(GL_INVALID_VALUE, false); return gl::error(GL_INVALID_VALUE, false);
} }
if (!gl::IsValidCopyTexImageCombination(textureFormat, colorbufferFormat, context->getClientVersion())) if (!gl::IsValidCopyTexImageCombination(textureInternalFormat, colorbufferInternalFormat,
context->getClientVersion()))
{ {
return gl::error(GL_INVALID_OPERATION, false); return gl::error(GL_INVALID_OPERATION, false);
} }
......
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