Commit 5dec9d19 by Shahbaz Youssefi Committed by Commit Bot

Use 0 as special value for glTexBuffer instead of UINT_MAX

This is more in line with the rest of ANGLE which assumes a binding of 0 size means the size of gl::Buffer. This allows GetBoundBufferAvailableSize to be used in texture buffer related code. Bug: angleproject:3573 Change-Id: I305835f305d4bf4422759bb96e030cbbc136871a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2542863 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent c09ef1b3
......@@ -1914,10 +1914,9 @@ angle::Result Texture::setBuffer(const gl::Context *context,
gl::Buffer *buffer,
GLenum internalFormat)
{
// Use UINT_MAX to indicate that the size is taken from whatever size the buffer has when the
// texture buffer is used.
return setBufferRange(context, buffer, internalFormat, 0,
std::numeric_limits<GLsizeiptr>::max());
// Use 0 to indicate that the size is taken from whatever size the buffer has when the texture
// buffer is used.
return setBufferRange(context, buffer, internalFormat, 0, 0);
}
angle::Result Texture::setBufferRange(const gl::Context *context,
......@@ -1938,7 +1937,7 @@ angle::Result Texture::setBufferRange(const gl::Context *context,
return angle::Result::Continue;
}
size = std::min(size, static_cast<GLsizeiptr>(buffer->getSize()));
size = GetBoundBufferAvailableSize(mState.mBuffer);
mState.mImmutableLevels = static_cast<GLuint>(1);
InternalFormat internalFormatInfo = GetSizedInternalFormatInfo(internalFormat);
......@@ -2194,8 +2193,7 @@ void Texture::onSubjectStateChange(angle::SubjectIndex index, angle::SubjectMess
ASSERT(buffer != nullptr);
// Update cached image desc based on buffer size.
GLsizeiptr size =
std::min(mState.mBuffer.getSize(), static_cast<GLsizeiptr>(buffer->getSize()));
GLsizeiptr size = GetBoundBufferAvailableSize(mState.mBuffer);
ImageDesc desc = mState.getImageDesc(TextureTarget::Buffer, 0);
const GLuint pixelBytes = desc.format.info->pixelBytes;
......
......@@ -226,20 +226,9 @@ void QueryTexLevelParameterBase(const Texture *texture,
pname, static_cast<GLint>(texture->getBuffer().getOffset()));
break;
case GL_TEXTURE_BUFFER_SIZE:
{
const OffsetBindingPointer<Buffer> &bufferBinding = texture->getBuffer();
Buffer *buffer = bufferBinding.get();
GLsizeiptr size = bufferBinding.getSize();
const GLintptr offset = bufferBinding.getOffset();
if (buffer != nullptr)
{
size = std::min(size, static_cast<GLsizeiptr>(buffer->getSize()) - offset);
}
*params = CastFromStateValue<ParamType>(pname, static_cast<GLint>(size));
}
break;
*params = CastFromStateValue<ParamType>(
pname, static_cast<GLint>(GetBoundBufferAvailableSize(texture->getBuffer())));
break;
default:
UNREACHABLE();
break;
......
......@@ -1731,17 +1731,18 @@ angle::Result TextureGL::setBuffer(const gl::Context *context, GLenum internalFo
const GLsizeiptr size = bufferBinding.getSize();
const GLuint bufferID = buffer ? GetImplAs<BufferGL>(buffer)->getBufferID() : 0;
// If buffer is not bound, use texBuffer to unbind it. If size is UINT_MAX, texBuffer was used
// to create this binding, so use the same function. This will allow the implementation to take
// If buffer is not bound, use texBuffer to unbind it. If size is 0, texBuffer was used to
// create this binding, so use the same function. This will allow the implementation to take
// the current size of the buffer on every draw/dispatch call even if the buffer size changes.
if (buffer == nullptr || size == std::numeric_limits<GLsizeiptr>::max())
if (buffer == nullptr || size == 0)
{
ANGLE_GL_TRY(context, functions->texBuffer(GL_TEXTURE_BUFFER, internalFormat, bufferID));
}
else
{
ANGLE_GL_TRY(context, functions->texBufferRange(GL_TEXTURE_BUFFER, internalFormat, bufferID,
offset, size));
ANGLE_GL_TRY(context,
functions->texBufferRange(GL_TEXTURE_BUFFER, internalFormat, bufferID, offset,
GetBoundBufferAvailableSize(bufferBinding)));
}
return angle::Result::Continue;
......
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