gfxstream: guest: vk_CmdBeginTransformFeedbackEXT fix

pCounterBuffers can be NULL, which crashes on the autogen path:

"For each element of pCounterBuffers that is VK_NULL_HANDLE,
transform feedback will start capturing vertex data to byte zero
in the corresponding bound transform feedback buffer."

Need to special case.

     Intel

Reviewed-by: Aaron Ruby <aruby@blackberry.com>
Acked-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27246>
This commit is contained in:
Gurchetan Singh
2024-07-12 11:31:59 -07:00
committed by Marge Bot
parent 96cceac511
commit b05f3f8e12
2 changed files with 24 additions and 0 deletions

View File

@@ -122,6 +122,8 @@ HANDWRITTEN_ENTRY_POINTS = [
"vkResetCommandPool",
"vkFreeCommandBuffers",
"vkResetCommandPool",
# Transform feedback
"vkCmdBeginTransformFeedbackEXT",
# Special cases to handle struct translations in the pNext chain
# TODO: Make a codegen module (use deepcopy as reference) to make this more robust
"vkAllocateMemory",

View File

@@ -186,3 +186,25 @@ void gfxstream_vk_FreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
vk_command_buffer_destroyOp(&gfxstream_commandBuffer->vk);
}
}
void gfxstream_vk_CmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
uint32_t firstCounterBuffer,
uint32_t counterBufferCount,
const VkBuffer* pCounterBuffers,
const VkDeviceSize* pCounterBufferOffsets) {
AEMU_SCOPED_TRACE("vkCmdBeginTransformFeedbackEXT");
VK_FROM_HANDLE(gfxstream_vk_command_buffer, gfxstream_commandBuffer, commandBuffer);
auto vkEnc = gfxstream::vk::ResourceTracker::getCommandBufferEncoder(
gfxstream_commandBuffer->internal_object);
std::vector<VkBuffer> internal_pCounterBuffers(counterBufferCount);
for (uint32_t i = 0; i < counterBufferCount; ++i) {
if (pCounterBuffers && pCounterBuffers[i]) {
VK_FROM_HANDLE(gfxstream_vk_buffer, gfxstream_pCounterBuffers, pCounterBuffers[i]);
internal_pCounterBuffers[i] = gfxstream_pCounterBuffers->internal_object;
}
}
vkEnc->vkCmdBeginTransformFeedbackEXT(gfxstream_commandBuffer->internal_object,
firstCounterBuffer, counterBufferCount,
pCounterBuffers ? internal_pCounterBuffers.data() : NULL,
pCounterBufferOffsets, true /* do lock */);
}