Commit 0af26e10 by Jamie Madill

Prefer using caps to system attachment limits.

The caps structure can often give a lower and faster bound, as well as being more general. We should gradually move away from the implementation limits. BUG=angleproject:930 Change-Id: I979472cdb6f59c6f0cc0c80f1c29c51295872bea Reviewed-on: https://chromium-review.googlesource.com/256731Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 092e1a12
......@@ -544,7 +544,7 @@ size_t RendererD3D::getBoundFramebufferTextureSerials(const gl::Data &data,
size_t serialCount = 0;
const gl::Framebuffer *drawFramebuffer = data.state->getDrawFramebuffer();
for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; i++)
for (unsigned int i = 0; i < data.caps->maxColorAttachments; i++)
{
gl::FramebufferAttachment *attachment = drawFramebuffer->getColorbuffer(i);
if (attachment && attachment->type() == GL_TEXTURE)
......
......@@ -1220,7 +1220,7 @@ gl::Error Renderer11::applyRenderTarget(const gl::Framebuffer *framebuffer)
mForceSetRasterState = true;
}
for (unsigned int rtIndex = 0; rtIndex < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; rtIndex++)
for (size_t rtIndex = 0; rtIndex < ArraySize(framebufferRTVs); rtIndex++)
{
mAppliedRTVs[rtIndex] = reinterpret_cast<uintptr_t>(framebufferRTVs[rtIndex]);
}
......@@ -1924,7 +1924,7 @@ gl::Error Renderer11::applyUniforms(const ProgramImpl &program, const std::vecto
void Renderer11::markAllStateDirty()
{
for (unsigned int rtIndex = 0; rtIndex < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; rtIndex++)
for (size_t rtIndex = 0; rtIndex < ArraySize(mAppliedRTVs); rtIndex++)
{
mAppliedRTVs[rtIndex] = DirtyPointer;
}
......@@ -2449,7 +2449,7 @@ void Renderer11::setOneTimeRenderTarget(ID3D11RenderTargetView *renderTargetView
mDeviceContext->OMSetRenderTargets(getRendererCaps().maxDrawBuffers, rtvArray, NULL);
// Do not preserve the serial for this one-time-use render target
for (unsigned int rtIndex = 0; rtIndex < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; rtIndex++)
for (size_t rtIndex = 0; rtIndex < ArraySize(mAppliedRTVs); rtIndex++)
{
mAppliedRTVs[rtIndex] = DirtyPointer;
}
......
......@@ -524,7 +524,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint
GLenum readInternalFormat = readColorBuffer->getInternalFormat();
const InternalFormat &readFormatInfo = GetInternalFormatInfo(readInternalFormat);
for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; i++)
for (GLuint i = 0; i < context->getCaps().maxColorAttachments; i++)
{
if (drawFramebuffer->isEnabledColorAttachment(i))
{
......@@ -580,7 +580,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint
return false;
}
for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
for (GLuint colorAttachment = 0; colorAttachment < context->getCaps().maxColorAttachments; ++colorAttachment)
{
if (drawFramebuffer->isEnabledColorAttachment(colorAttachment))
{
......@@ -1123,11 +1123,13 @@ bool ValidateStateQuery(gl::Context *context, GLenum pname, GLenum *nativeType,
return false;
}
const Caps &caps = context->getCaps();
if (pname >= GL_DRAW_BUFFER0 && pname <= GL_DRAW_BUFFER15)
{
unsigned int colorAttachment = (pname - GL_DRAW_BUFFER0);
if (colorAttachment >= context->getCaps().maxDrawBuffers)
if (colorAttachment >= caps.maxDrawBuffers)
{
context->recordError(Error(GL_INVALID_OPERATION));
return false;
......@@ -1140,7 +1142,7 @@ bool ValidateStateQuery(gl::Context *context, GLenum pname, GLenum *nativeType,
case GL_TEXTURE_BINDING_CUBE_MAP:
case GL_TEXTURE_BINDING_3D:
case GL_TEXTURE_BINDING_2D_ARRAY:
if (context->getState().getActiveSampler() >= context->getCaps().maxCombinedTextureImageUnits)
if (context->getState().getActiveSampler() >= caps.maxCombinedTextureImageUnits)
{
context->recordError(Error(GL_INVALID_OPERATION));
return 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