@@ -540,9 +540,12 @@ static void set_resource(struct shader_runner *runner, struct resource *resource static void set_uniforms(struct shader_runner *runner, size_t offset, size_t count, const void *uniforms) { + size_t initial_capacity = runner->uniform_capacity; + runner->uniform_count = align(max(runner->uniform_count, offset + count), 4); vkd3d_array_reserve((void **)&runner->uniforms, &runner->uniform_capacity, runner->uniform_count, sizeof(*runner->uniforms)); + memset(runner->uniforms + initial_capacity, 0, runner->uniform_capacity - initial_capacity); memcpy(runner->uniforms + offset, uniforms, count * sizeof(*runner->uniforms)); }
How does that work? Are we sending more than "uniform_count" uniforms to the shader anywhere? Or is this about the potential padding introduced by align? In the latter case, we need to clear a fair bit less than we do here. We may also want to consider clearing with a value other than zero.
The first version of this MR was doing (a) but the current one does (b). The disadvantage of (b) is that we have to add more "if" qualifiers, if you think these are too many I can revert to (a).
We could conceivably introduce additional types that do type conversion when targetting d3dbc if the current scheme becomes too cumbersome, but for the moment this seems fine.