Commit 5f82dde6 by Shahbaz Youssefi Committed by Commit Bot

Fix block size calculation w.r.t variable-size arrays

In SSBOs, there can be a last array whose size is not specified (i.e. can take any size). This is especially prevalent in Compute shaders that process a buffer. In the shader translator, the size of this array is given as 0. HLSL register offset calculation was tripped up by this as it used (arraySize - 1). The optimization in [1] effectively removed a test that would perform this calculation only when the size is positive. This change adds back this guard. [1] https://chromium-review.googlesource.com/c/angle/angle/+/684742 Bug: angleproject:2516 Change-Id: If45ac934f542c5ffcad67f962eebe45a3aeba70b Reviewed-on: https://chromium-review.googlesource.com/c/1409403 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent d3e0e84c
...@@ -85,7 +85,11 @@ void HLSLBlockEncoder::advanceOffset(GLenum typeIn, ...@@ -85,7 +85,11 @@ void HLSLBlockEncoder::advanceOffset(GLenum typeIn,
if (!arraySizes.empty()) if (!arraySizes.empty())
{ {
mCurrentOffset += arrayStride * (gl::ArraySizeProduct(arraySizes) - 1); unsigned int arraySize = gl::ArraySizeProduct(arraySizes);
if (arraySize > 0)
{
mCurrentOffset += arrayStride * (arraySize - 1);
}
} }
if (gl::IsMatrixType(type)) if (gl::IsMatrixType(type))
......
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