Add proper detection for maximum texture and renderbuffer size

Trac #13849 Increased the maximum possible texture & renderbuffer size to 16384 (the minimum required for DX11 cards). Limit the actual maximum texture & renderbuffer size to the maximum that it reported by the underlying D3D9 device. Note that creating textures and renderbuffers at the maximum size will quickly exhaust video memory! Signed-off-by: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@447 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 1c76801e
...@@ -240,6 +240,16 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface) ...@@ -240,6 +240,16 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
mIndexDataManager = new IndexDataManager(this, mBufferBackEnd); mIndexDataManager = new IndexDataManager(this, mBufferBackEnd);
mBlit = new Blit(this); mBlit = new Blit(this);
mSupportsShaderModel3 = mDeviceCaps.PixelShaderVersion == D3DPS_VERSION(3, 0);
mMaxTextureDimension = std::min(std::min((int)mDeviceCaps.MaxTextureWidth, (int)mDeviceCaps.MaxTextureHeight),
(int)gl::IMPLEMENTATION_MAX_TEXTURE_SIZE);
mMaxCubeTextureDimension = std::min(mMaxTextureDimension, (int)gl::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE);
mMaxRenderbufferDimension = mMaxTextureDimension;
mMaxTextureLevel = log2(mMaxTextureDimension) + 1;
TRACE("MaxTextureDimension=%d, MaxCubeTextureDimension=%d, MaxRenderbufferDimension=%d, MaxTextureLevel=%d",
mMaxTextureDimension, mMaxCubeTextureDimension, mMaxRenderbufferDimension, mMaxTextureLevel);
const D3DFORMAT renderBufferFormats[] = const D3DFORMAT renderBufferFormats[] =
{ {
D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8,
...@@ -306,8 +316,6 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface) ...@@ -306,8 +316,6 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
depthStencil->Release(); depthStencil->Release();
} }
mSupportsShaderModel3 = mDeviceCaps.PixelShaderVersion == D3DPS_VERSION(3, 0);
markAllStateDirty(); markAllStateDirty();
} }
...@@ -1202,7 +1210,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params) ...@@ -1202,7 +1210,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: *params = gl::MAX_VERTEX_TEXTURE_IMAGE_UNITS; break; case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: *params = gl::MAX_VERTEX_TEXTURE_IMAGE_UNITS; break;
case GL_MAX_TEXTURE_IMAGE_UNITS: *params = gl::MAX_TEXTURE_IMAGE_UNITS; break; case GL_MAX_TEXTURE_IMAGE_UNITS: *params = gl::MAX_TEXTURE_IMAGE_UNITS; break;
case GL_MAX_FRAGMENT_UNIFORM_VECTORS: *params = gl::MAX_FRAGMENT_UNIFORM_VECTORS; break; case GL_MAX_FRAGMENT_UNIFORM_VECTORS: *params = gl::MAX_FRAGMENT_UNIFORM_VECTORS; break;
case GL_MAX_RENDERBUFFER_SIZE: *params = gl::MAX_RENDERBUFFER_SIZE; break; case GL_MAX_RENDERBUFFER_SIZE: *params = getMaximumRenderbufferDimension(); break;
case GL_NUM_SHADER_BINARY_FORMATS: *params = 0; break; case GL_NUM_SHADER_BINARY_FORMATS: *params = 0; break;
case GL_SHADER_BINARY_FORMATS: /* no shader binary formats are supported */ break; case GL_SHADER_BINARY_FORMATS: /* no shader binary formats are supported */ break;
case GL_ARRAY_BUFFER_BINDING: *params = mState.arrayBuffer.id(); break; case GL_ARRAY_BUFFER_BINDING: *params = mState.arrayBuffer.id(); break;
...@@ -1240,8 +1248,8 @@ bool Context::getIntegerv(GLenum pname, GLint *params) ...@@ -1240,8 +1248,8 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
case GL_STENCIL_BACK_WRITEMASK: *params = mState.stencilBackWritemask; break; case GL_STENCIL_BACK_WRITEMASK: *params = mState.stencilBackWritemask; break;
case GL_STENCIL_CLEAR_VALUE: *params = mState.stencilClearValue; break; case GL_STENCIL_CLEAR_VALUE: *params = mState.stencilClearValue; break;
case GL_SUBPIXEL_BITS: *params = 4; break; case GL_SUBPIXEL_BITS: *params = 4; break;
case GL_MAX_TEXTURE_SIZE: *params = gl::MAX_TEXTURE_SIZE; break; case GL_MAX_TEXTURE_SIZE: *params = getMaximumTextureDimension(); break;
case GL_MAX_CUBE_MAP_TEXTURE_SIZE: *params = gl::MAX_CUBE_MAP_TEXTURE_SIZE; break; case GL_MAX_CUBE_MAP_TEXTURE_SIZE: *params = getMaximumCubeTextureDimension(); break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS: case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
{ {
if (supportsCompressedTextures()) if (supportsCompressedTextures())
...@@ -1303,7 +1311,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params) ...@@ -1303,7 +1311,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
case GL_IMPLEMENTATION_COLOR_READ_FORMAT: *params = gl::IMPLEMENTATION_COLOR_READ_FORMAT; break; case GL_IMPLEMENTATION_COLOR_READ_FORMAT: *params = gl::IMPLEMENTATION_COLOR_READ_FORMAT; break;
case GL_MAX_VIEWPORT_DIMS: case GL_MAX_VIEWPORT_DIMS:
{ {
int maxDimension = std::max((int)gl::MAX_RENDERBUFFER_SIZE, (int)gl::MAX_TEXTURE_SIZE); int maxDimension = std::max(getMaximumRenderbufferDimension(), getMaximumTextureDimension());
params[0] = maxDimension; params[0] = maxDimension;
params[1] = maxDimension; params[1] = maxDimension;
} }
...@@ -2954,6 +2962,26 @@ bool Context::supportsHalfFloatRenderableTextures() const ...@@ -2954,6 +2962,26 @@ bool Context::supportsHalfFloatRenderableTextures() const
return mSupportsHalfFloatRenderableTextures; return mSupportsHalfFloatRenderableTextures;
} }
int Context::getMaximumRenderbufferDimension() const
{
return mMaxRenderbufferDimension;
}
int Context::getMaximumTextureDimension() const
{
return mMaxTextureDimension;
}
int Context::getMaximumCubeTextureDimension() const
{
return mMaxCubeTextureDimension;
}
int Context::getMaximumTextureLevel() const
{
return mMaxTextureLevel;
}
void Context::detachBuffer(GLuint buffer) void Context::detachBuffer(GLuint buffer)
{ {
// [OpenGL ES 2.0.24] section 2.9 page 22: // [OpenGL ES 2.0.24] section 2.9 page 22:
......
...@@ -63,7 +63,6 @@ enum ...@@ -63,7 +63,6 @@ enum
MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0, MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0,
MAX_TEXTURE_IMAGE_UNITS = 16, MAX_TEXTURE_IMAGE_UNITS = 16,
MAX_FRAGMENT_UNIFORM_VECTORS = 16, MAX_FRAGMENT_UNIFORM_VECTORS = 16,
MAX_RENDERBUFFER_SIZE = 4096, // FIXME: Verify
MAX_DRAW_BUFFERS = 1, MAX_DRAW_BUFFERS = 1,
IMPLEMENTATION_COLOR_READ_FORMAT = GL_RGB, IMPLEMENTATION_COLOR_READ_FORMAT = GL_RGB,
...@@ -383,6 +382,10 @@ class Context ...@@ -383,6 +382,10 @@ class Context
GLenum getError(); GLenum getError();
bool supportsShaderModel3() const; bool supportsShaderModel3() const;
int getMaximumRenderbufferDimension() const;
int getMaximumTextureDimension() const;
int getMaximumCubeTextureDimension() const;
int getMaximumTextureLevel() const;
GLsizei getMaxSupportedSamples() const; GLsizei getMaxSupportedSamples() const;
int getNearestSupportedSamples(D3DFORMAT format, int requested) const; int getNearestSupportedSamples(D3DFORMAT format, int requested) const;
const char *getExtensionString() const; const char *getExtensionString() const;
...@@ -459,6 +462,10 @@ class Context ...@@ -459,6 +462,10 @@ class Context
bool mDepthStencilInitialized; bool mDepthStencilInitialized;
bool mSupportsShaderModel3; bool mSupportsShaderModel3;
int mMaxRenderbufferDimension;
int mMaxTextureDimension;
int mMaxCubeTextureDimension;
int mMaxTextureLevel;
std::map<D3DFORMAT, bool *> mMultiSampleSupport; std::map<D3DFORMAT, bool *> mMultiSampleSupport;
GLsizei mMaxSupportedSamples; GLsizei mMaxSupportedSamples;
bool mSupportsEventQueries; bool mSupportsEventQueries;
......
...@@ -996,7 +996,7 @@ bool Texture2D::redefineTexture(GLint level, GLenum internalFormat, GLsizei widt ...@@ -996,7 +996,7 @@ bool Texture2D::redefineTexture(GLint level, GLenum internalFormat, GLsizei widt
// Purge all the levels and the texture. // Purge all the levels and the texture.
for (int i = 0; i < MAX_TEXTURE_LEVELS; i++) for (int i = 0; i < IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
{ {
if (mImageArray[i].surface != NULL) if (mImageArray[i].surface != NULL)
{ {
...@@ -1831,7 +1831,7 @@ bool TextureCubeMap::redefineTexture(GLint level, GLenum internalFormat, GLsizei ...@@ -1831,7 +1831,7 @@ bool TextureCubeMap::redefineTexture(GLint level, GLenum internalFormat, GLsizei
internalFormat, width); internalFormat, width);
// Purge all the levels and the texture. // Purge all the levels and the texture.
for (int i = 0; i < MAX_TEXTURE_LEVELS; i++) for (int i = 0; i < IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
{ {
for (int f = 0; f < 6; f++) for (int f = 0; f < 6; f++)
{ {
......
...@@ -28,10 +28,13 @@ class Blit; ...@@ -28,10 +28,13 @@ class Blit;
enum enum
{ {
MAX_TEXTURE_SIZE = 2048, // These are the maximums the implementation can support
MAX_CUBE_MAP_TEXTURE_SIZE = 2048, // The actual GL caps are limited by the device caps
// and should be queried from the Context
IMPLEMENTATION_MAX_TEXTURE_SIZE = 16384,
IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE = 16384,
MAX_TEXTURE_LEVELS = 12 // 1+log2 of MAX_TEXTURE_SIZE IMPLEMENTATION_MAX_TEXTURE_LEVELS = 15 // 1+log2 of MAX_TEXTURE_SIZE
}; };
class Texture : public RefCountObject class Texture : public RefCountObject
...@@ -237,7 +240,7 @@ class Texture2D : public Texture ...@@ -237,7 +240,7 @@ class Texture2D : public Texture
bool redefineTexture(GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLenum type); bool redefineTexture(GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLenum type);
void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
Image mImageArray[MAX_TEXTURE_LEVELS]; Image mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
IDirect3DTexture9 *mTexture; IDirect3DTexture9 *mTexture;
...@@ -297,7 +300,7 @@ class TextureCubeMap : public Texture ...@@ -297,7 +300,7 @@ class TextureCubeMap : public Texture
void commitRect(GLenum faceTarget, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); void commitRect(GLenum faceTarget, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
bool redefineTexture(GLint level, GLenum internalFormat, GLsizei width); bool redefineTexture(GLint level, GLenum internalFormat, GLsizei width);
Image mImageArray[6][MAX_TEXTURE_LEVELS]; Image mImageArray[6][IMPLEMENTATION_MAX_TEXTURE_LEVELS];
IDirect3DCubeTexture9 *mTexture; IDirect3DCubeTexture9 *mTexture;
......
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