Commit 13a2f85b by Jamie Madill

Implement max elements indices and vertices.

ES3 has integer queries for the maximum recommended number of vertices and indices per draw call. These are roughly correlated to D3D's resource limits -- however, while ES3 has recommended limits D3D has hard limits. Change-Id: Ib653bc27e61607c78d0c5e70b0d97fea7af6464f Reviewed-on: https://chromium-review.googlesource.com/179670Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Reviewed-by: 's avatarNicolas Capens <nicolascapens@chromium.org> Commit-Queue: Nicolas Capens <nicolascapens@chromium.org> Tested-by: 's avatarNicolas Capens <nicolascapens@chromium.org>
parent cd65ae16
...@@ -1688,6 +1688,8 @@ bool Context::getIntegerv(GLenum pname, GLint *params) ...@@ -1688,6 +1688,8 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
case GL_MAX_COMBINED_UNIFORM_BLOCKS: *params = getMaximumCombinedUniformBufferBindings(); break; case GL_MAX_COMBINED_UNIFORM_BLOCKS: *params = getMaximumCombinedUniformBufferBindings(); break;
case GL_MAJOR_VERSION: *params = mClientVersion; break; case GL_MAJOR_VERSION: *params = mClientVersion; break;
case GL_MINOR_VERSION: *params = 0; break; case GL_MINOR_VERSION: *params = 0; break;
case GL_MAX_ELEMENTS_INDICES: *params = mRenderer->getMaxRecommendedElementsIndices(); break;
case GL_MAX_ELEMENTS_VERTICES: *params = mRenderer->getMaxRecommendedElementsVertices(); break;
case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: *params = 0; UNIMPLEMENTED(); break; case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: *params = 0; UNIMPLEMENTED(); break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS: case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
params[0] = mNumCompressedTextureFormats; params[0] = mNumCompressedTextureFormats;
...@@ -2227,6 +2229,8 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu ...@@ -2227,6 +2229,8 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
case GL_NUM_EXTENSIONS: case GL_NUM_EXTENSIONS:
case GL_MAJOR_VERSION: case GL_MAJOR_VERSION:
case GL_MINOR_VERSION: case GL_MINOR_VERSION:
case GL_MAX_ELEMENTS_INDICES:
case GL_MAX_ELEMENTS_VERTICES:
{ {
*type = GL_INT; *type = GL_INT;
*numParams = 1; *numParams = 1;
......
...@@ -198,6 +198,8 @@ class Renderer ...@@ -198,6 +198,8 @@ class Renderer
virtual bool getShareHandleSupport() const = 0; virtual bool getShareHandleSupport() const = 0;
virtual bool getDerivativeInstructionSupport() const = 0; virtual bool getDerivativeInstructionSupport() const = 0;
virtual bool getPostSubBufferSupport() const = 0; virtual bool getPostSubBufferSupport() const = 0;
virtual int getMaxRecommendedElementsIndices() const = 0;
virtual int getMaxRecommendedElementsVertices() const = 0;
virtual int getMajorShaderModel() const = 0; virtual int getMajorShaderModel() const = 0;
virtual float getMaxPointSize() const = 0; virtual float getMaxPointSize() const = 0;
......
...@@ -2165,6 +2165,24 @@ bool Renderer11::getPostSubBufferSupport() const ...@@ -2165,6 +2165,24 @@ bool Renderer11::getPostSubBufferSupport() const
return false; return false;
} }
int Renderer11::getMaxRecommendedElementsIndices() const
{
META_ASSERT(D3D11_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP == 32);
META_ASSERT(D3D10_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP == 32);
// D3D11 allows up to 2^32 elements, but we report max signed int for convenience.
return std::numeric_limits<GLint>::max();
}
int Renderer11::getMaxRecommendedElementsVertices() const
{
META_ASSERT(D3D11_REQ_DRAW_VERTEX_COUNT_2_TO_EXP == 32);
META_ASSERT(D3D10_REQ_DRAW_VERTEX_COUNT_2_TO_EXP == 32);
// D3D11 allows up to 2^32 elements, but we report max signed int for convenience.
return std::numeric_limits<GLint>::max();
}
int Renderer11::getMajorShaderModel() const int Renderer11::getMajorShaderModel() const
{ {
switch (mFeatureLevel) switch (mFeatureLevel)
......
...@@ -136,6 +136,8 @@ class Renderer11 : public Renderer ...@@ -136,6 +136,8 @@ class Renderer11 : public Renderer
virtual bool getShareHandleSupport() const; virtual bool getShareHandleSupport() const;
virtual bool getDerivativeInstructionSupport() const; virtual bool getDerivativeInstructionSupport() const;
virtual bool getPostSubBufferSupport() const; virtual bool getPostSubBufferSupport() const;
virtual int getMaxRecommendedElementsIndices() const;
virtual int getMaxRecommendedElementsVertices() const;
virtual int getMajorShaderModel() const; virtual int getMajorShaderModel() const;
virtual float getMaxPointSize() const; virtual float getMaxPointSize() const;
......
...@@ -1413,7 +1413,7 @@ GLenum Renderer9::applyVertexBuffer(gl::ProgramBinary *programBinary, const gl:: ...@@ -1413,7 +1413,7 @@ GLenum Renderer9::applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::
{ {
return err; return err;
} }
return mVertexDeclarationCache.applyDeclaration(mDevice, attributes, programBinary, instances, &mRepeatDraw); return mVertexDeclarationCache.applyDeclaration(mDevice, attributes, programBinary, instances, &mRepeatDraw);
} }
...@@ -1442,7 +1442,7 @@ GLenum Renderer9::applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArr ...@@ -1442,7 +1442,7 @@ GLenum Renderer9::applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArr
void Renderer9::drawArrays(GLenum mode, GLsizei count, GLsizei instances) void Renderer9::drawArrays(GLenum mode, GLsizei count, GLsizei instances)
{ {
startScene(); startScene();
if (mode == GL_LINE_LOOP) if (mode == GL_LINE_LOOP)
{ {
drawLineLoop(count, GL_NONE, NULL, 0, NULL); drawLineLoop(count, GL_NONE, NULL, 0, NULL);
...@@ -2521,6 +2521,20 @@ bool Renderer9::getPostSubBufferSupport() const ...@@ -2521,6 +2521,20 @@ bool Renderer9::getPostSubBufferSupport() const
return true; return true;
} }
int Renderer9::getMaxRecommendedElementsIndices() const
{
// ES3 only
UNREACHABLE();
return 0;
}
int Renderer9::getMaxRecommendedElementsVertices() const
{
// ES3 only
UNREACHABLE();
return 0;
}
int Renderer9::getMajorShaderModel() const int Renderer9::getMajorShaderModel() const
{ {
return D3DSHADER_VERSION_MAJOR(mDeviceCaps.PixelShaderVersion); return D3DSHADER_VERSION_MAJOR(mDeviceCaps.PixelShaderVersion);
...@@ -2597,7 +2611,7 @@ GLsizei Renderer9::getNumSampleCounts(GLenum internalFormat) const ...@@ -2597,7 +2611,7 @@ GLsizei Renderer9::getNumSampleCounts(GLenum internalFormat) const
{ {
D3DFORMAT format = gl_d3d9::GetTextureFormat(internalFormat, this); D3DFORMAT format = gl_d3d9::GetTextureFormat(internalFormat, this);
MultisampleSupportMap::const_iterator iter = mMultiSampleSupport.find(format); MultisampleSupportMap::const_iterator iter = mMultiSampleSupport.find(format);
unsigned int numCounts = 0; unsigned int numCounts = 0;
if (iter != mMultiSampleSupport.end()) if (iter != mMultiSampleSupport.end())
{ {
...@@ -2726,7 +2740,7 @@ bool Renderer9::copyToRenderTarget(TextureStorageInterface2D *dest, TextureStora ...@@ -2726,7 +2740,7 @@ bool Renderer9::copyToRenderTarget(TextureStorageInterface2D *dest, TextureStora
{ {
IDirect3DSurface9 *srcSurf = source9->getSurfaceLevel(i, false); IDirect3DSurface9 *srcSurf = source9->getSurfaceLevel(i, false);
IDirect3DSurface9 *dstSurf = dest9->getSurfaceLevel(i, false); IDirect3DSurface9 *dstSurf = dest9->getSurfaceLevel(i, false);
result = copyToRenderTarget(dstSurf, srcSurf, source9->isManaged()); result = copyToRenderTarget(dstSurf, srcSurf, source9->isManaged());
SafeRelease(srcSurf); SafeRelease(srcSurf);
...@@ -3029,7 +3043,7 @@ bool Renderer9::blitRect(gl::Framebuffer *readFramebuffer, const gl::Rectangle & ...@@ -3029,7 +3043,7 @@ bool Renderer9::blitRect(gl::Framebuffer *readFramebuffer, const gl::Rectangle &
return true; return true;
} }
void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type,
GLsizei outputPitch, bool packReverseRowOrder, GLint packAlignment, void* pixels) GLsizei outputPitch, bool packReverseRowOrder, GLint packAlignment, void* pixels)
{ {
RenderTarget9 *renderTarget = NULL; RenderTarget9 *renderTarget = NULL;
...@@ -3040,7 +3054,7 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz ...@@ -3040,7 +3054,7 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz
{ {
renderTarget = RenderTarget9::makeRenderTarget9(colorbuffer->getRenderTarget()); renderTarget = RenderTarget9::makeRenderTarget9(colorbuffer->getRenderTarget());
} }
if (renderTarget) if (renderTarget)
{ {
surface = renderTarget->getSurface(); surface = renderTarget->getSurface();
......
...@@ -149,6 +149,8 @@ class Renderer9 : public Renderer ...@@ -149,6 +149,8 @@ class Renderer9 : public Renderer
virtual bool getShareHandleSupport() const; virtual bool getShareHandleSupport() const;
virtual bool getDerivativeInstructionSupport() const; virtual bool getDerivativeInstructionSupport() const;
virtual bool getPostSubBufferSupport() const; virtual bool getPostSubBufferSupport() const;
virtual int getMaxRecommendedElementsIndices() const;
virtual int getMaxRecommendedElementsVertices() const;
virtual int getMajorShaderModel() const; virtual int getMajorShaderModel() const;
virtual float getMaxPointSize() const; virtual float getMaxPointSize() 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