Avoid calling getContext() for resource limits.

TRAC #22243 Signed-off-by: Jamie Madill Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1776 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 28d268ea
...@@ -270,7 +270,6 @@ void Context::makeCurrent(egl::Surface *surface) ...@@ -270,7 +270,6 @@ void Context::makeCurrent(egl::Surface *surface)
mSupportsLuminanceAlphaTextures = mRenderer->getLuminanceAlphaTextureSupport(); mSupportsLuminanceAlphaTextures = mRenderer->getLuminanceAlphaTextureSupport();
mSupportsDepthTextures = mRenderer->getDepthTextureSupport(); mSupportsDepthTextures = mRenderer->getDepthTextureSupport();
mSupportsTextureFilterAnisotropy = mRenderer->getTextureFilterAnisotropySupport(); mSupportsTextureFilterAnisotropy = mRenderer->getTextureFilterAnisotropySupport();
mSupportsDerivativeInstructions = mRenderer->getDerivativeInstructionSupport();
mSupports32bitIndices = mRenderer->get32BitIndexSupport(); mSupports32bitIndices = mRenderer->get32BitIndexSupport();
mNumCompressedTextureFormats = 0; mNumCompressedTextureFormats = 0;
...@@ -1269,8 +1268,8 @@ bool Context::getIntegerv(GLenum pname, GLint *params) ...@@ -1269,8 +1268,8 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
{ {
case GL_MAX_VERTEX_ATTRIBS: *params = gl::MAX_VERTEX_ATTRIBS; break; case GL_MAX_VERTEX_ATTRIBS: *params = gl::MAX_VERTEX_ATTRIBS; break;
case GL_MAX_VERTEX_UNIFORM_VECTORS: *params = mRenderer->getMaxVertexUniformVectors(); break; case GL_MAX_VERTEX_UNIFORM_VECTORS: *params = mRenderer->getMaxVertexUniformVectors(); break;
case GL_MAX_VARYING_VECTORS: *params = getMaximumVaryingVectors(); break; case GL_MAX_VARYING_VECTORS: *params = mRenderer->getMaxVaryingVectors(); break;
case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: *params = getMaximumCombinedTextureImageUnits(); break; case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: *params = mRenderer->getMaxCombinedTextureImageUnits(); break;
case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: *params = mRenderer->getMaxVertexTextureImageUnits(); break; case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: *params = mRenderer->getMaxVertexTextureImageUnits(); 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 = mRenderer->getMaxFragmentUniformVectors(); break; case GL_MAX_FRAGMENT_UNIFORM_VECTORS: *params = mRenderer->getMaxFragmentUniformVectors(); break;
...@@ -1468,7 +1467,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params) ...@@ -1468,7 +1467,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
break; break;
case GL_TEXTURE_BINDING_2D: case GL_TEXTURE_BINDING_2D:
{ {
if (mState.activeSampler > getMaximumCombinedTextureImageUnits() - 1) if (mState.activeSampler > mRenderer->getMaxCombinedTextureImageUnits() - 1)
{ {
error(GL_INVALID_OPERATION); error(GL_INVALID_OPERATION);
return false; return false;
...@@ -1479,7 +1478,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params) ...@@ -1479,7 +1478,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
break; break;
case GL_TEXTURE_BINDING_CUBE_MAP: case GL_TEXTURE_BINDING_CUBE_MAP:
{ {
if (mState.activeSampler > getMaximumCombinedTextureImageUnits() - 1) if (mState.activeSampler > mRenderer->getMaxCombinedTextureImageUnits() - 1)
{ {
error(GL_INVALID_OPERATION); error(GL_INVALID_OPERATION);
return false; return false;
...@@ -2126,14 +2125,9 @@ float Context::getMaximumPointSize() const ...@@ -2126,14 +2125,9 @@ float Context::getMaximumPointSize() const
return mMaximumPointSize; return mMaximumPointSize;
} }
int Context::getMaximumVaryingVectors() const
{
return mRenderer->getMaxVaryingVectors();
}
unsigned int Context::getMaximumCombinedTextureImageUnits() const unsigned int Context::getMaximumCombinedTextureImageUnits() const
{ {
return MAX_TEXTURE_IMAGE_UNITS + mRenderer->getMaxVertexTextureImageUnits(); return mRenderer->getMaxCombinedTextureImageUnits();
} }
int Context::getMaxSupportedSamples() const int Context::getMaxSupportedSamples() const
...@@ -2256,11 +2250,6 @@ bool Context::supportsTextureFilterAnisotropy() const ...@@ -2256,11 +2250,6 @@ bool Context::supportsTextureFilterAnisotropy() const
return mSupportsTextureFilterAnisotropy; return mSupportsTextureFilterAnisotropy;
} }
bool Context::supportsDerivativeInstructions() const
{
return mSupportsDerivativeInstructions;
}
float Context::getTextureMaxAnisotropy() const float Context::getTextureMaxAnisotropy() const
{ {
return mMaxTextureAnisotropy; return mMaxTextureAnisotropy;
...@@ -2499,7 +2488,7 @@ void Context::initExtensionString() ...@@ -2499,7 +2488,7 @@ void Context::initExtensionString()
extensionString += "GL_OES_packed_depth_stencil "; extensionString += "GL_OES_packed_depth_stencil ";
extensionString += "GL_OES_get_program_binary "; extensionString += "GL_OES_get_program_binary ";
extensionString += "GL_OES_rgb8_rgba8 "; extensionString += "GL_OES_rgb8_rgba8 ";
if (supportsDerivativeInstructions()) if (mRenderer->getDerivativeInstructionSupport())
{ {
extensionString += "GL_OES_standard_derivatives "; extensionString += "GL_OES_standard_derivatives ";
} }
......
...@@ -374,7 +374,6 @@ class Context ...@@ -374,7 +374,6 @@ class Context
int getMajorShaderModel() const; int getMajorShaderModel() const;
float getMaximumPointSize() const; float getMaximumPointSize() const;
int getMaximumVaryingVectors() const;
unsigned int getMaximumCombinedTextureImageUnits() const; unsigned int getMaximumCombinedTextureImageUnits() const;
int getMaximumRenderbufferDimension() const; int getMaximumRenderbufferDimension() const;
int getMaximumTextureDimension() const; int getMaximumTextureDimension() const;
...@@ -402,7 +401,6 @@ class Context ...@@ -402,7 +401,6 @@ class Context
bool supportsNonPower2Texture() const; bool supportsNonPower2Texture() const;
bool supportsInstancing() const; bool supportsInstancing() const;
bool supportsTextureFilterAnisotropy() const; bool supportsTextureFilterAnisotropy() const;
bool supportsDerivativeInstructions() const;
bool getCurrentReadFormatType(GLenum *format, GLenum *type); bool getCurrentReadFormatType(GLenum *format, GLenum *type);
...@@ -509,7 +507,6 @@ class Context ...@@ -509,7 +507,6 @@ class Context
bool mSupportsDepthTextures; bool mSupportsDepthTextures;
bool mSupports32bitIndices; bool mSupports32bitIndices;
bool mSupportsTextureFilterAnisotropy; bool mSupportsTextureFilterAnisotropy;
bool mSupportsDerivativeInstructions;
int mNumCompressedTextureFormats; int mNumCompressedTextureFormats;
ResourceManager *mResourceManager; ResourceManager *mResourceManager;
......
...@@ -165,7 +165,7 @@ GLint ProgramBinary::getSamplerMapping(SamplerType type, unsigned int samplerInd ...@@ -165,7 +165,7 @@ GLint ProgramBinary::getSamplerMapping(SamplerType type, unsigned int samplerInd
default: UNREACHABLE(); default: UNREACHABLE();
} }
if (logicalTextureUnit >= 0 && logicalTextureUnit < (GLint)getContext()->getMaximumCombinedTextureImageUnits()) if (logicalTextureUnit >= 0 && logicalTextureUnit < (GLint)mRenderer->getMaxCombinedTextureImageUnits())
{ {
return logicalTextureUnit; return logicalTextureUnit;
} }
...@@ -1007,8 +1007,7 @@ void ProgramBinary::applyUniforms() ...@@ -1007,8 +1007,7 @@ void ProgramBinary::applyUniforms()
// Returns the number of used varying registers, or -1 if unsuccesful // Returns the number of used varying registers, or -1 if unsuccesful
int ProgramBinary::packVaryings(InfoLog &infoLog, const Varying *packing[][4], FragmentShader *fragmentShader) int ProgramBinary::packVaryings(InfoLog &infoLog, const Varying *packing[][4], FragmentShader *fragmentShader)
{ {
Context *context = getContext(); const int maxVaryingVectors = mRenderer->getMaxVaryingVectors();
const int maxVaryingVectors = context->getMaximumVaryingVectors();
for (VaryingList::iterator varying = fragmentShader->mVaryings.begin(); varying != fragmentShader->mVaryings.end(); varying++) for (VaryingList::iterator varying = fragmentShader->mVaryings.begin(); varying != fragmentShader->mVaryings.end(); varying++)
{ {
...@@ -1184,8 +1183,7 @@ bool ProgramBinary::linkVaryings(InfoLog &infoLog, std::string& pixelHLSL, std:: ...@@ -1184,8 +1183,7 @@ bool ProgramBinary::linkVaryings(InfoLog &infoLog, std::string& pixelHLSL, std::
// Write the HLSL input/output declarations // Write the HLSL input/output declarations
const int shaderModel = mRenderer->getMajorShaderModel(); const int shaderModel = mRenderer->getMajorShaderModel();
Context *context = getContext(); const int maxVaryingVectors = mRenderer->getMaxVaryingVectors();
const int maxVaryingVectors = context->getMaximumVaryingVectors();
if (registers == maxVaryingVectors && fragmentShader->mUsesFragCoord) if (registers == maxVaryingVectors && fragmentShader->mUsesFragCoord)
{ {
...@@ -2176,7 +2174,7 @@ bool ProgramBinary::validateSamplers(InfoLog *infoLog) ...@@ -2176,7 +2174,7 @@ bool ProgramBinary::validateSamplers(InfoLog *infoLog)
// texture image unit, and this is the current program, then ValidateProgram will fail, and // texture image unit, and this is the current program, then ValidateProgram will fail, and
// DrawArrays and DrawElements will issue the INVALID_OPERATION error. // DrawArrays and DrawElements will issue the INVALID_OPERATION error.
const unsigned int maxCombinedTextureImageUnits = getContext()->getMaximumCombinedTextureImageUnits(); const unsigned int maxCombinedTextureImageUnits = mRenderer->getMaxCombinedTextureImageUnits();
TextureType textureUnitType[IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS]; TextureType textureUnitType[IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS];
for (unsigned int i = 0; i < IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS; ++i) for (unsigned int i = 0; i < IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS; ++i)
......
...@@ -229,7 +229,6 @@ void Shader::initializeCompiler() ...@@ -229,7 +229,6 @@ void Shader::initializeCompiler()
if (result) if (result)
{ {
Context *context = getContext();
ShShaderOutput hlslVersion = (mRenderer->getMajorShaderModel() >= 4) ? SH_HLSL11_OUTPUT : SH_HLSL9_OUTPUT; ShShaderOutput hlslVersion = (mRenderer->getMajorShaderModel() >= 4) ? SH_HLSL11_OUTPUT : SH_HLSL9_OUTPUT;
ShBuiltInResources resources; ShBuiltInResources resources;
...@@ -237,14 +236,14 @@ void Shader::initializeCompiler() ...@@ -237,14 +236,14 @@ void Shader::initializeCompiler()
resources.MaxVertexAttribs = MAX_VERTEX_ATTRIBS; resources.MaxVertexAttribs = MAX_VERTEX_ATTRIBS;
resources.MaxVertexUniformVectors = mRenderer->getMaxVertexUniformVectors(); resources.MaxVertexUniformVectors = mRenderer->getMaxVertexUniformVectors();
resources.MaxVaryingVectors = context->getMaximumVaryingVectors(); resources.MaxVaryingVectors = mRenderer->getMaxVaryingVectors();
resources.MaxVertexTextureImageUnits = mRenderer->getMaxVertexTextureImageUnits(); resources.MaxVertexTextureImageUnits = mRenderer->getMaxVertexTextureImageUnits();
resources.MaxCombinedTextureImageUnits = context->getMaximumCombinedTextureImageUnits(); resources.MaxCombinedTextureImageUnits = mRenderer->getMaxCombinedTextureImageUnits();
resources.MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS; resources.MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
resources.MaxFragmentUniformVectors = mRenderer->getMaxFragmentUniformVectors(); resources.MaxFragmentUniformVectors = mRenderer->getMaxFragmentUniformVectors();
resources.MaxDrawBuffers = MAX_DRAW_BUFFERS; resources.MaxDrawBuffers = MAX_DRAW_BUFFERS;
resources.OES_standard_derivatives = context->supportsDerivativeInstructions() ? 1 : 0; resources.OES_standard_derivatives = mRenderer->getDerivativeInstructionSupport();
// resources.OES_EGL_image_external = getDisplay()->getRenderer()->getShareHandleSupport() ? 1 : 0; // TODO: commented out until the extension is actually supported. // resources.OES_EGL_image_external = mRenderer->getShareHandleSupport() ? 1 : 0; // TODO: commented out until the extension is actually supported.
mFragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_GLES2_SPEC, hlslVersion, &resources); mFragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_GLES2_SPEC, hlslVersion, &resources);
mVertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, SH_GLES2_SPEC, hlslVersion, &resources); mVertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, SH_GLES2_SPEC, hlslVersion, &resources);
......
...@@ -145,6 +145,7 @@ class Renderer ...@@ -145,6 +145,7 @@ class Renderer
virtual bool getLuminanceAlphaTextureSupport() = 0; virtual bool getLuminanceAlphaTextureSupport() = 0;
bool getVertexTextureSupport() const { return getMaxVertexTextureImageUnits() > 0; } bool getVertexTextureSupport() const { return getMaxVertexTextureImageUnits() > 0; }
virtual unsigned int getMaxVertexTextureImageUnits() const = 0; virtual unsigned int getMaxVertexTextureImageUnits() const = 0;
virtual unsigned int getMaxCombinedTextureImageUnits() const = 0;
virtual int getMaxVertexUniformVectors() const = 0; virtual int getMaxVertexUniformVectors() const = 0;
virtual int getMaxFragmentUniformVectors() const = 0; virtual int getMaxFragmentUniformVectors() const = 0;
virtual int getMaxVaryingVectors() const = 0; virtual int getMaxVaryingVectors() const = 0;
......
...@@ -1870,6 +1870,11 @@ unsigned int Renderer11::getMaxVertexTextureImageUnits() const ...@@ -1870,6 +1870,11 @@ unsigned int Renderer11::getMaxVertexTextureImageUnits() const
} }
} }
unsigned int Renderer11::getMaxCombinedTextureImageUnits() const
{
return gl::MAX_TEXTURE_IMAGE_UNITS + getMaxVertexTextureImageUnits();
}
int Renderer11::getMaxVertexUniformVectors() const int Renderer11::getMaxVertexUniformVectors() const
{ {
META_ASSERT(MAX_VERTEX_UNIFORM_VECTORS_D3D11 <= D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT); META_ASSERT(MAX_VERTEX_UNIFORM_VECTORS_D3D11 <= D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT);
......
...@@ -105,6 +105,7 @@ class Renderer11 : public Renderer ...@@ -105,6 +105,7 @@ class Renderer11 : public Renderer
virtual bool getLuminanceTextureSupport(); virtual bool getLuminanceTextureSupport();
virtual bool getLuminanceAlphaTextureSupport(); virtual bool getLuminanceAlphaTextureSupport();
virtual unsigned int getMaxVertexTextureImageUnits() const; virtual unsigned int getMaxVertexTextureImageUnits() const;
virtual unsigned int getMaxCombinedTextureImageUnits() const;
virtual int getMaxVertexUniformVectors() const; virtual int getMaxVertexUniformVectors() const;
virtual int getMaxFragmentUniformVectors() const; virtual int getMaxFragmentUniformVectors() const;
virtual int getMaxVaryingVectors() const; virtual int getMaxVaryingVectors() const;
......
...@@ -2240,6 +2240,11 @@ unsigned int Renderer9::getMaxVertexTextureImageUnits() const ...@@ -2240,6 +2240,11 @@ unsigned int Renderer9::getMaxVertexTextureImageUnits() const
return mVertexTextureSupport ? MAX_TEXTURE_IMAGE_UNITS_VTF_SM3 : 0; return mVertexTextureSupport ? MAX_TEXTURE_IMAGE_UNITS_VTF_SM3 : 0;
} }
unsigned int Renderer9::getMaxCombinedTextureImageUnits() const
{
return gl::MAX_TEXTURE_IMAGE_UNITS + getMaxVertexTextureImageUnits();
}
int Renderer9::getMaxVertexUniformVectors() const int Renderer9::getMaxVertexUniformVectors() const
{ {
return MAX_VERTEX_UNIFORM_VECTORS; return MAX_VERTEX_UNIFORM_VECTORS;
......
...@@ -134,6 +134,7 @@ class Renderer9 : public Renderer ...@@ -134,6 +134,7 @@ class Renderer9 : public Renderer
virtual bool getLuminanceTextureSupport(); virtual bool getLuminanceTextureSupport();
virtual bool getLuminanceAlphaTextureSupport(); virtual bool getLuminanceAlphaTextureSupport();
virtual unsigned int getMaxVertexTextureImageUnits() const; virtual unsigned int getMaxVertexTextureImageUnits() const;
virtual unsigned int getMaxCombinedTextureImageUnits() const;
virtual int getMaxVertexUniformVectors() const; virtual int getMaxVertexUniformVectors() const;
virtual int getMaxFragmentUniformVectors() const; virtual int getMaxFragmentUniformVectors() const;
virtual int getMaxVaryingVectors() const; virtual int getMaxVaryingVectors() 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