[vulkan] Prevent particle update buffers escaping the staging buffer

The escape was actually harmless as the buffers would not be read due to
the particle count being 0 (thus why the buffers were at the end of the
staging buffer: no space was allocated for them, only for the system
buffer, but their offsets were just past the system buffer). However,
the validation layers quite rightly did not like that. Thus, the two
buffers are pointed to the system buffer so all three descriptors are
always valid.
This commit is contained in:
Bill Currie 2022-12-02 12:46:45 +09:00
parent b35854c706
commit 9b609469ed

View file

@ -406,8 +406,17 @@ particles_update (qfv_renderframe_t *rFrame)
qfv_parameters_t *params = (qfv_parameters_t *)((byte *)system + paramoffs);
memcpy (params, pctx->psystem->partparams, paramsize);
partsize = max (1, partsize);
paramsize = max (1, paramsize);
if (!numParticles) {
// if there are no particles, then no space for the particle states or
// parameters has been allocated in the staging buffer, so map the
// two buffers over the system buffer. This avoids either buffer being
// just past the end of the staging buffer (which the validation layers
// (correctly) do not like).
// This is fine because the two buffers are only read by the the
// compute shader.
partsize = paramsize = syssize;
partoffs = paramoffs = 0;
}
size_t sysoffs = packet->offset;
VkDescriptorBufferInfo bufferInfo[] = {