Add support for arrays of arrays to VariableLocation
Array indices are sorted so that the outermost index is in the back.
This is because we want to be consistent with future arrays of arrays
parsing code. In parsing we'll have a utility function to make a
TType object into an array, and there it's most natural to push the
new outermost sizes to the back of the vector.
Further patches will still be needed to parse arrays of arrays and
add support to arrays of arrays into the API.
BUG=angleproject:2125
TEST=angle_unittests, angle_end2end_tests
Change-Id: I6c88edabf68ae9dbd803ec6d20543016c408b702
Reviewed-on: https://chromium-review.googlesource.com/686414
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/libANGLE/renderer/d3d/ProgramD3D.cpp b/src/libANGLE/renderer/d3d/ProgramD3D.cpp
index 1a5559f..a15be2b 100644
--- a/src/libANGLE/renderer/d3d/ProgramD3D.cpp
+++ b/src/libANGLE/renderer/d3d/ProgramD3D.cpp
@@ -2169,11 +2169,11 @@
{
D3DUniform *targetUniform = mD3DUniforms[locationInfo.index];
const int components = targetUniform->typeInfo.componentCount;
- unsigned int arrayElement = locationInfo.element;
+ unsigned int arrayElementOffset = locationInfo.flattenedArrayOffset;
if (targetUniform->typeInfo.type == uniformType)
{
- T *dest = reinterpret_cast<T *>(targetData) + arrayElement * 4;
+ T *dest = reinterpret_cast<T *>(targetData) + arrayElementOffset * 4;
const T *source = v;
for (GLint i = 0; i < count; i++, dest += 4, source += components)
@@ -2184,7 +2184,7 @@
else
{
ASSERT(targetUniform->typeInfo.type == gl::VariableBoolVectorType(uniformType));
- GLint *boolParams = reinterpret_cast<GLint *>(targetData) + arrayElement * 4;
+ GLint *boolParams = reinterpret_cast<GLint *>(targetData) + arrayElementOffset * 4;
for (GLint i = 0; i < count; i++)
{
@@ -2209,7 +2209,7 @@
{
ASSERT(uniformType == GL_INT);
size_t size = count * sizeof(T);
- auto dest = &targetUniform->mSamplerData[locationInfo.element];
+ auto dest = &targetUniform->mSamplerData[locationInfo.flattenedArrayOffset];
if (memcmp(dest, v, size) != 0)
{
memcpy(dest, v, size);
@@ -2248,12 +2248,13 @@
D3DUniform *targetUniform = getD3DUniformFromLocation(location);
unsigned int elementCount = targetUniform->elementCount();
- unsigned int arrayElement = mState.getUniformLocations()[location].element;
- unsigned int count = std::min(elementCount - arrayElement, static_cast<unsigned int>(countIn));
+ unsigned int arrayElementOffset = mState.getUniformLocations()[location].flattenedArrayOffset;
+ unsigned int count =
+ std::min(elementCount - arrayElementOffset, static_cast<unsigned int>(countIn));
const unsigned int targetMatrixStride = (4 * rows);
- GLfloat *target = reinterpret_cast<GLfloat *>(targetData + arrayElement * sizeof(GLfloat) *
- targetMatrixStride);
+ GLfloat *target = reinterpret_cast<GLfloat *>(
+ targetData + arrayElementOffset * sizeof(GLfloat) * targetMatrixStride);
bool dirty = false;
@@ -2586,8 +2587,13 @@
}
else
{
+ std::vector<unsigned int> subscripts;
+ std::string baseName = gl::ParseResourceName(tfVaryingName, &subscripts);
size_t subscript = GL_INVALID_INDEX;
- std::string baseName = gl::ParseResourceName(tfVaryingName, &subscript);
+ if (!subscripts.empty())
+ {
+ subscript = subscripts.back();
+ }
for (const auto ®isterInfo : varyingPacking.getRegisterList())
{
const auto &varying = *registerInfo.packedVarying->varying;
@@ -2694,7 +2700,8 @@
const gl::LinkedUniform &uniform = mState.getUniforms()[locationInfo.index];
const D3DUniform *targetUniform = getD3DUniformFromLocation(location);
- const uint8_t *srcPointer = targetUniform->getDataPtrToElement(locationInfo.element);
+ const uint8_t *srcPointer = targetUniform->getDataPtrToElement(
+ locationInfo.arrayIndices.empty() ? 0u : locationInfo.flattenedArrayOffset);
if (gl::IsMatrixType(uniform.type))
{