mirror of https://github.com/bjornbytes/lovr.git
Fix issue with blend shape compute shader;
It was only copying the raw vertex data for the first blend shape, not the first blend shape in each group.
This commit is contained in:
parent
5fb5a4a00d
commit
97cc7d9137
|
@ -10,6 +10,7 @@ layout(push_constant) uniform PushConstants {
|
|||
uint vertexCount;
|
||||
uint blendShapeCount;
|
||||
uint baseBlendVertex;
|
||||
bool first;
|
||||
};
|
||||
|
||||
struct ModelVertex {
|
||||
|
@ -36,7 +37,7 @@ void lovrmain() {
|
|||
uint vertexIndex = baseVertex + GlobalThreadID.x;
|
||||
uint blendVertexIndex = baseBlendVertex + GlobalThreadID.x;
|
||||
|
||||
ModelVertex vertex = baseBlendVertex == 0 ? rawVertices[vertexIndex] : vertices[vertexIndex];
|
||||
ModelVertex vertex = first ? rawVertices[vertexIndex] : vertices[vertexIndex];
|
||||
|
||||
for (uint i = 0; i < blendShapeCount; i++, blendVertexIndex += vertexCount) {
|
||||
float weight = weights[i / 4][i % 4];
|
||||
|
|
|
@ -4206,6 +4206,7 @@ static void lovrModelAnimateVertices(Model* model) {
|
|||
|
||||
for (uint32_t j = 0; j < group->count; j += chunkSize) {
|
||||
uint32_t count = MIN(group->count - j, chunkSize);
|
||||
bool first = j == 0;
|
||||
|
||||
MappedBuffer mapped = mapBuffer(&state.streamBuffers, chunkSize * sizeof(float), state.limits.uniformBufferAlign);
|
||||
memcpy(mapped.pointer, model->blendShapeWeights + group->index + j, count * sizeof(float));
|
||||
|
@ -4215,7 +4216,7 @@ static void lovrModelAnimateVertices(Model* model) {
|
|||
gpu_bundle_info bundleInfo = { layout, bindings, COUNTOF(bindings) };
|
||||
gpu_bundle_write(&bundle, &bundleInfo, 1);
|
||||
|
||||
uint32_t constants[] = { group->vertexIndex, group->vertexCount, count, blendBufferCursor };
|
||||
uint32_t constants[] = { group->vertexIndex, group->vertexCount, count, blendBufferCursor, first };
|
||||
uint32_t subgroupSize = state.device.subgroupSize;
|
||||
|
||||
gpu_push_constants(state.stream, shader->gpu, constants, sizeof(constants));
|
||||
|
|
Loading…
Reference in New Issue