tu: pCounterBuffers can be NULL in vkCmd*TransformFeedbackEXT()

According to the spec:

"pCounterBuffers is an optional array of buffer handles [...]
 If pCounterBuffers is NULL, then transform feedback will start
 capturing vertex data to byte offset zero in all bound transform
 feedback buffers."

"If counterBufferCount is not 0, and pCounterBuffers is not NULL,
 pCounterBuffers must be a valid pointer to an array [...]"

So counterBufferCount could be non-zero with pCounterBuffers
being NULL.

Fixes crash in RenderDoc when inspecting draw call with tesselation
or geometry shader present.

Fixes: 98b0d900 "turnip: rework streamout state and add missing counter buffer read/writes"
Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8140>
This commit is contained in:
Danylo Piliaiev 2020-12-17 14:41:52 +02:00 committed by Marge Bot
parent 6aec3c9a23
commit b34bc3db67

View file

@ -1918,7 +1918,7 @@ tu_CmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
for (uint32_t i = 0; i < IR3_MAX_SO_BUFFERS; i++)
tu_cs_emit_regs(cs, A6XX_VPC_SO_BUFFER_OFFSET(i, cmd->state.streamout_offset[i]));
for (uint32_t i = 0; i < counterBufferCount; i++) {
for (uint32_t i = 0; i < (pCounterBuffers ? counterBufferCount : 0); i++) {
uint32_t idx = firstCounterBuffer + i;
uint32_t offset = cmd->state.streamout_offset[idx];
uint64_t counter_buffer_offset = pCounterBufferOffsets ? pCounterBufferOffsets[i] : 0u;
@ -1967,7 +1967,7 @@ void tu_CmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
tu6_emit_event_write(cmd, cs, FLUSH_SO_0 + i);
}
for (uint32_t i = 0; i < counterBufferCount; i++) {
for (uint32_t i = 0; i < (pCounterBuffers ? counterBufferCount : 0); i++) {
uint32_t idx = firstCounterBuffer + i;
uint32_t offset = cmd->state.streamout_offset[idx];
uint64_t counter_buffer_offset = pCounterBufferOffsets ? pCounterBufferOffsets[i] : 0u;