Commit 50c526d2 by gman@chromium.org

Add support for DXT3 and DXT5

TEST=none BUG=none Review URL: http://codereview.appspot.com/4809068 git-svn-id: https://angleproject.googlecode.com/svn/trunk@721 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent a1a86201
Name
ANGLE_texture_compression_dxt
Name Strings
GL_ANGLE_texture_compression_dxt3
GL_ANGLE_texture_compression_dxt5
Contributors
Gregg Tavares, Google Inc.
Daniel Koch, TransGaming Inc.
Al Patrick, Google Inc.
Contacts
Gregg Tavares, Google Inc. (gman 'at' google 'dot' com)
Status
Implemented in ANGLE ES2
Version
Last Modified Date: Aug 2, 2011
Number
OpenGL ES Extension #..
Dependencies
Requires OpenGL ES 2.0.
The extension is written against the OpenGL ES 2.0 specification.
Overview
These extensions are exactly the same as EXT_texture_compression_dxt1
except they expose the formats COMPRESSED_RGBA_S3TC_DXT3_ANGLE and
COMPRESSED_RGBA_S3TC_DXT5_ANGLE respectively.
See EXT_texture_compression_dxt1 for the full list of changes. Also
see EXT_texture_compression_s3tc for a description of the formats.
New Procedures and Functions
None.
New Types
None.
New Tokens
Accepted by the <internalformat> parameter of CompressedTexImage2D
and the <format> parameter of CompressedTexSubImage2D:
COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2
COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3
Errors
None.
New State
None.
Revision History
...@@ -207,6 +207,16 @@ typedef void* GLeglImageOES; ...@@ -207,6 +207,16 @@ typedef void* GLeglImageOES;
#define GL_MAX_SAMPLES_ANGLE 0x8D57 #define GL_MAX_SAMPLES_ANGLE 0x8D57
#endif #endif
/* GL_ANGLE_texture_compression_dxt3 */
#ifndef GL_ANGLE_texture_compression_dxt3
#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2
#endif
/* GL_ANGLE_texture_compression_dxt5 */
#ifndef GL_ANGLE_texture_compression_dxt5
#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3
#endif
/*------------------------------------------------------------------------* /*------------------------------------------------------------------------*
* APPLE extension tokens * APPLE extension tokens
*------------------------------------------------------------------------*/ *------------------------------------------------------------------------*/
...@@ -790,6 +800,16 @@ GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target ...@@ -790,6 +800,16 @@ GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
#endif #endif
/* GL_ANGLE_texture_compression_dxt3 */
#ifndef GL_ANGLE_texture_compression_dxt3
#define GL_ANGLE_texture_compression_dxt3 1
#endif
/* GL_ANGLE_texture_compression_dxt5 */
#ifndef GL_ANGLE_texture_compression_dxt5
#define GL_ANGLE_texture_compression_dxt5 1
#endif
/*------------------------------------------------------------------------* /*------------------------------------------------------------------------*
* APPLE extension functions * APPLE extension functions
*------------------------------------------------------------------------*/ *------------------------------------------------------------------------*/
......
#define MAJOR_VERSION 0 #define MAJOR_VERSION 0
#define MINOR_VERSION 0 #define MINOR_VERSION 0
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 720 #define BUILD_REVISION 721
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -773,7 +773,7 @@ void Display::getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray) ...@@ -773,7 +773,7 @@ void Display::getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray)
} }
} }
bool Display::getCompressedTextureSupport() bool Display::getDXT1TextureSupport()
{ {
D3DDISPLAYMODE currentDisplayMode; D3DDISPLAYMODE currentDisplayMode;
mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode); mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
...@@ -781,6 +781,22 @@ bool Display::getCompressedTextureSupport() ...@@ -781,6 +781,22 @@ bool Display::getCompressedTextureSupport()
return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT1)); return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT1));
} }
bool Display::getDXT3TextureSupport()
{
D3DDISPLAYMODE currentDisplayMode;
mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT3));
}
bool Display::getDXT5TextureSupport()
{
D3DDISPLAYMODE currentDisplayMode;
mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT5));
}
bool Display::getFloatTextureSupport(bool *filtering, bool *renderable) bool Display::getFloatTextureSupport(bool *filtering, bool *renderable)
{ {
D3DDISPLAYMODE currentDisplayMode; D3DDISPLAYMODE currentDisplayMode;
......
...@@ -63,7 +63,9 @@ class Display ...@@ -63,7 +63,9 @@ class Display
virtual D3DADAPTER_IDENTIFIER9 *getAdapterIdentifier(); virtual D3DADAPTER_IDENTIFIER9 *getAdapterIdentifier();
bool isDeviceLost(); bool isDeviceLost();
virtual void getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray); virtual void getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray);
virtual bool getCompressedTextureSupport(); virtual bool getDXT1TextureSupport();
virtual bool getDXT3TextureSupport();
virtual bool getDXT5TextureSupport();
virtual bool getEventQuerySupport(); virtual bool getEventQuerySupport();
virtual bool getFloatTextureSupport(bool *filtering, bool *renderable); virtual bool getFloatTextureSupport(bool *filtering, bool *renderable);
virtual bool getHalfFloatTextureSupport(bool *filtering, bool *renderable); virtual bool getHalfFloatTextureSupport(bool *filtering, bool *renderable);
......
...@@ -156,8 +156,11 @@ Context::Context(const egl::Config *config, const gl::Context *shareContext) : m ...@@ -156,8 +156,11 @@ Context::Context(const egl::Config *config, const gl::Context *shareContext) : m
mHasBeenCurrent = false; mHasBeenCurrent = false;
mSupportsCompressedTextures = false; mSupportsDXT1Textures = false;
mSupportsDXT3Textures = false;
mSupportsDXT5Textures = false;
mSupportsEventQueries = false; mSupportsEventQueries = false;
mNumCompressedTextureFormats = 0;
mMaxSupportedSamples = 0; mMaxSupportedSamples = 0;
mMaskedClearSavedState = NULL; mMaskedClearSavedState = NULL;
markAllStateDirty(); markAllStateDirty();
...@@ -280,7 +283,9 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface) ...@@ -280,7 +283,9 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
mMaxSupportedSamples = max; mMaxSupportedSamples = max;
mSupportsEventQueries = display->getEventQuerySupport(); mSupportsEventQueries = display->getEventQuerySupport();
mSupportsCompressedTextures = display->getCompressedTextureSupport(); mSupportsDXT1Textures = display->getDXT1TextureSupport();
mSupportsDXT3Textures = display->getDXT3TextureSupport();
mSupportsDXT5Textures = display->getDXT5TextureSupport();
mSupportsFloatTextures = display->getFloatTextureSupport(&mSupportsFloatLinearFilter, &mSupportsFloatRenderableTextures); mSupportsFloatTextures = display->getFloatTextureSupport(&mSupportsFloatLinearFilter, &mSupportsFloatRenderableTextures);
mSupportsHalfFloatTextures = display->getHalfFloatTextureSupport(&mSupportsHalfFloatLinearFilter, &mSupportsHalfFloatRenderableTextures); mSupportsHalfFloatTextures = display->getHalfFloatTextureSupport(&mSupportsHalfFloatLinearFilter, &mSupportsHalfFloatRenderableTextures);
mSupportsLuminanceTextures = display->getLuminanceTextureSupport(); mSupportsLuminanceTextures = display->getLuminanceTextureSupport();
...@@ -288,6 +293,20 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface) ...@@ -288,6 +293,20 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
mSupports32bitIndices = mDeviceCaps.MaxVertexIndex >= (1 << 16); mSupports32bitIndices = mDeviceCaps.MaxVertexIndex >= (1 << 16);
mNumCompressedTextureFormats = 0;
if (supportsDXT1Textures())
{
mNumCompressedTextureFormats += 2;
}
if (supportsDXT3Textures())
{
mNumCompressedTextureFormats += 1;
}
if (supportsDXT5Textures())
{
mNumCompressedTextureFormats += 1;
}
initExtensionString(); initExtensionString();
mState.viewportX = 0; mState.viewportX = 0;
...@@ -1240,18 +1259,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params) ...@@ -1240,18 +1259,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
case GL_MAX_TEXTURE_SIZE: *params = getMaximumTextureDimension(); break; case GL_MAX_TEXTURE_SIZE: *params = getMaximumTextureDimension(); break;
case GL_MAX_CUBE_MAP_TEXTURE_SIZE: *params = getMaximumCubeTextureDimension(); break; case GL_MAX_CUBE_MAP_TEXTURE_SIZE: *params = getMaximumCubeTextureDimension(); break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS: case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
{ params[0] = mNumCompressedTextureFormats;
if (supportsCompressedTextures())
{
// at current, only GL_COMPRESSED_RGB_S3TC_DXT1_EXT and
// GL_COMPRESSED_RGBA_S3TC_DXT1_EXT are supported
*params = 2;
}
else
{
*params = 0;
}
}
break; break;
case GL_MAX_SAMPLES_ANGLE: case GL_MAX_SAMPLES_ANGLE:
{ {
...@@ -1307,10 +1315,18 @@ bool Context::getIntegerv(GLenum pname, GLint *params) ...@@ -1307,10 +1315,18 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
break; break;
case GL_COMPRESSED_TEXTURE_FORMATS: case GL_COMPRESSED_TEXTURE_FORMATS:
{ {
if (supportsCompressedTextures()) if (supportsDXT1Textures())
{
*params++ = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
*params++ = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
}
if (supportsDXT3Textures())
{
*params++ = GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE;
}
if (supportsDXT5Textures())
{ {
params[0] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; *params++ = GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE;
params[1] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
} }
} }
break; break;
...@@ -1422,7 +1438,12 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu ...@@ -1422,7 +1438,12 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
// application. // application.
switch (pname) switch (pname)
{ {
case GL_COMPRESSED_TEXTURE_FORMATS: /* no compressed texture formats are supported */ case GL_COMPRESSED_TEXTURE_FORMATS:
{
*type = GL_INT;
*numParams = mNumCompressedTextureFormats;
}
break;
case GL_SHADER_BINARY_FORMATS: case GL_SHADER_BINARY_FORMATS:
{ {
*type = GL_INT; *type = GL_INT;
...@@ -3053,9 +3074,19 @@ bool Context::supportsEventQueries() const ...@@ -3053,9 +3074,19 @@ bool Context::supportsEventQueries() const
return mSupportsEventQueries; return mSupportsEventQueries;
} }
bool Context::supportsCompressedTextures() const bool Context::supportsDXT1Textures() const
{
return mSupportsDXT1Textures;
}
bool Context::supportsDXT3Textures() const
{ {
return mSupportsCompressedTextures; return mSupportsDXT3Textures;
}
bool Context::supportsDXT5Textures() const
{
return mSupportsDXT5Textures;
} }
bool Context::supportsFloatTextures() const bool Context::supportsFloatTextures() const
...@@ -3330,11 +3361,21 @@ void Context::initExtensionString() ...@@ -3330,11 +3361,21 @@ void Context::initExtensionString()
mExtensionString += "GL_NV_fence "; mExtensionString += "GL_NV_fence ";
} }
if (supportsCompressedTextures()) if (supportsDXT1Textures())
{ {
mExtensionString += "GL_EXT_texture_compression_dxt1 "; mExtensionString += "GL_EXT_texture_compression_dxt1 ";
} }
if (supportsDXT3Textures())
{
mExtensionString += "GL_ANGLE_texture_compression_dxt3 ";
}
if (supportsDXT5Textures())
{
mExtensionString += "GL_ANGLE_texture_compression_dxt5 ";
}
if (supportsFloatTextures()) if (supportsFloatTextures())
{ {
mExtensionString += "GL_OES_texture_float "; mExtensionString += "GL_OES_texture_float ";
......
...@@ -437,7 +437,9 @@ class Context ...@@ -437,7 +437,9 @@ class Context
int getNearestSupportedSamples(D3DFORMAT format, int requested) const; int getNearestSupportedSamples(D3DFORMAT format, int requested) const;
const char *getExtensionString() const; const char *getExtensionString() const;
bool supportsEventQueries() const; bool supportsEventQueries() const;
bool supportsCompressedTextures() const; bool supportsDXT1Textures() const;
bool supportsDXT3Textures() const;
bool supportsDXT5Textures() const;
bool supportsFloatTextures() const; bool supportsFloatTextures() const;
bool supportsFloatLinearFilter() const; bool supportsFloatLinearFilter() const;
bool supportsFloatRenderableTextures() const; bool supportsFloatRenderableTextures() const;
...@@ -532,7 +534,9 @@ class Context ...@@ -532,7 +534,9 @@ class Context
std::map<D3DFORMAT, bool *> mMultiSampleSupport; std::map<D3DFORMAT, bool *> mMultiSampleSupport;
GLsizei mMaxSupportedSamples; GLsizei mMaxSupportedSamples;
bool mSupportsEventQueries; bool mSupportsEventQueries;
bool mSupportsCompressedTextures; bool mSupportsDXT1Textures;
bool mSupportsDXT3Textures;
bool mSupportsDXT5Textures;
bool mSupportsFloatTextures; bool mSupportsFloatTextures;
bool mSupportsFloatLinearFilter; bool mSupportsFloatLinearFilter;
bool mSupportsFloatRenderableTextures; bool mSupportsFloatRenderableTextures;
...@@ -542,6 +546,7 @@ class Context ...@@ -542,6 +546,7 @@ class Context
bool mSupportsLuminanceTextures; bool mSupportsLuminanceTextures;
bool mSupportsLuminanceAlphaTextures; bool mSupportsLuminanceAlphaTextures;
bool mSupports32bitIndices; bool mSupports32bitIndices;
int mNumCompressedTextureFormats;
// state caching flags // state caching flags
bool mClearStateDirty; bool mClearStateDirty;
......
...@@ -185,6 +185,12 @@ class Texture : public RefCountObject ...@@ -185,6 +185,12 @@ class Texture : public RefCountObject
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadCompressedImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void loadCompressedImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const; int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadDXT1ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadDXT3ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadDXT5ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
static unsigned int issueSerial(); static unsigned int issueSerial();
......
...@@ -772,6 +772,8 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna ...@@ -772,6 +772,8 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna
{ {
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
break; break;
default: default:
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
...@@ -821,9 +823,27 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna ...@@ -821,9 +823,27 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
} }
if (!context->supportsCompressedTextures()) switch (internalformat) {
{ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
if (!context->supportsDXT1Textures())
{
return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
}
break;
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
if (!context->supportsDXT3Textures())
{
return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
}
break;
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
if (!context->supportsDXT5Textures())
{
return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
}
break;
default: UNREACHABLE();
} }
if (imageSize != gl::ComputeCompressedSize(width, height, internalformat)) if (imageSize != gl::ComputeCompressedSize(width, height, internalformat))
...@@ -897,6 +917,8 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs ...@@ -897,6 +917,8 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs
{ {
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
break; break;
default: default:
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
...@@ -916,9 +938,27 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs ...@@ -916,9 +938,27 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs
return error(GL_INVALID_VALUE); return error(GL_INVALID_VALUE);
} }
if (!context->supportsCompressedTextures()) switch (format) {
{ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
return error(GL_INVALID_ENUM); // in this case, it's as though the format switch has failed. case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
if (!context->supportsDXT1Textures())
{
return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
}
break;
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
if (!context->supportsDXT3Textures())
{
return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
}
break;
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
if (!context->supportsDXT5Textures())
{
return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
}
break;
default: UNREACHABLE();
} }
if (imageSize != gl::ComputeCompressedSize(width, height, format)) if (imageSize != gl::ComputeCompressedSize(width, height, format))
...@@ -929,7 +969,7 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs ...@@ -929,7 +969,7 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs
if (xoffset % 4 != 0 || yoffset % 4 != 0) if (xoffset % 4 != 0 || yoffset % 4 != 0)
{ {
return error(GL_INVALID_OPERATION); // we wait to check the offsets until this point, because the multiple-of-four restriction return error(GL_INVALID_OPERATION); // we wait to check the offsets until this point, because the multiple-of-four restriction
// does not exist unless DXT1 textures are supported. // does not exist unless DXT textures are supported.
} }
if (target == GL_TEXTURE_2D) if (target == GL_TEXTURE_2D)
...@@ -1093,7 +1133,27 @@ void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalforma ...@@ -1093,7 +1133,27 @@ void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalforma
break; break;
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
if (context->supportsCompressedTextures()) if (context->supportsDXT1Textures())
{
return error(GL_INVALID_OPERATION);
}
else
{
return error(GL_INVALID_ENUM);
}
break;
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
if (context->supportsDXT3Textures())
{
return error(GL_INVALID_OPERATION);
}
else
{
return error(GL_INVALID_ENUM);
}
break;
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
if (context->supportsDXT5Textures())
{ {
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
...@@ -1245,6 +1305,8 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL ...@@ -1245,6 +1305,8 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL
break; break;
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
default: default:
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
...@@ -4467,6 +4529,8 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL ...@@ -4467,6 +4529,8 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL
break; break;
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // error cases for compressed textures are handled below case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // error cases for compressed textures are handled below
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
break; break;
default: default:
return error(GL_INVALID_VALUE); return error(GL_INVALID_VALUE);
...@@ -4511,10 +4575,10 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL ...@@ -4511,10 +4575,10 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
} }
if (format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT || switch (format) {
format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
{ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
if (context->supportsCompressedTextures()) if (context->supportsDXT1Textures())
{ {
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
...@@ -4522,6 +4586,29 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL ...@@ -4522,6 +4586,29 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL
{ {
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
} }
break;
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
if (context->supportsDXT3Textures())
{
return error(GL_INVALID_OPERATION);
}
else
{
return error(GL_INVALID_ENUM);
}
break;
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
if (context->supportsDXT5Textures())
{
return error(GL_INVALID_OPERATION);
}
else
{
return error(GL_INVALID_ENUM);
}
break;
default:
break;
} }
if (type == GL_FLOAT) if (type == GL_FLOAT)
......
...@@ -200,18 +200,23 @@ GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum format) ...@@ -200,18 +200,23 @@ GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum format)
{ {
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
return 8 * (GLsizei)ceil((float)width / 4.0f) * (GLsizei)ceil((float)height / 4.0f);
break; break;
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
return 16 * (GLsizei)ceil((float)width / 4.0f) * (GLsizei)ceil((float)height / 4.0f);
default: default:
return 0; return 0;
} }
return 8 * (GLsizei)ceil((float)width / 4.0f) * (GLsizei)ceil((float)height / 4.0f);
} }
bool IsCompressed(GLenum format) bool IsCompressed(GLenum format)
{ {
if(format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT || if(format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ||
format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ||
format == GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE ||
format == GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE)
{ {
return true; return true;
} }
......
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