mirror of
https://github.com/love2d/love.git
synced 2026-08-19 04:06:17 +02:00
vulkan: fix uniform vec3 array alignment
This commit is contained in:
@@ -708,40 +708,10 @@ void Shader::updateUniform(const UniformInfo *info, int count)
|
||||
|
||||
count = std::min(count, info->count);
|
||||
|
||||
// TODO: store some of this in UniformInfo.
|
||||
size_t elementsize = info->components * 4;
|
||||
if (info->baseType == UNIFORM_MATRIX)
|
||||
elementsize = info->matrix.columns * info->matrix.rows * 4;
|
||||
|
||||
size_t offset = (const uint8 *)info->data - localUniformStagingData;
|
||||
uint8 *dst = localUniformBufferData + offset;
|
||||
|
||||
// Assuming std140 packing rules, the source data can only be direct-copied
|
||||
// to the uniform buffer in certain cases because it's tightly packed whereas
|
||||
// the buffer's data isn't.
|
||||
if (elementsize * info->count == info->dataSize || (count == 1 && info->baseType != UNIFORM_MATRIX))
|
||||
{
|
||||
memcpy(localUniformBufferData + offset, info->data, elementsize * count);
|
||||
}
|
||||
else
|
||||
{
|
||||
int veccount = count;
|
||||
int comp = info->components;
|
||||
|
||||
if (info->baseType == UNIFORM_MATRIX)
|
||||
{
|
||||
veccount *= info->matrix.rows;
|
||||
comp = info->matrix.columns;
|
||||
}
|
||||
|
||||
const int *src = info->ints;
|
||||
int *dst = (int *) (localUniformBufferData + offset);
|
||||
|
||||
for (int i = 0; i < veccount; i++)
|
||||
{
|
||||
for (int c = 0; c < comp; c++)
|
||||
dst[i * 4 + c] = src[i * comp + c];
|
||||
}
|
||||
}
|
||||
copyToUniformBuffer(info, info->data, dst, count);
|
||||
}
|
||||
|
||||
void Shader::sendTextures(const UniformInfo *info, love::graphics::Texture **textures, int count)
|
||||
|
||||
Reference in New Issue
Block a user