diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-11-02 22:17:56 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-11-02 22:17:56 +0000 |
commit | 8d461e7f3ba926c1d42a673c9b96eb0e29a3bb51 (patch) | |
tree | d647b37c71bf6470a24298fd06f64c425d8da900 | |
parent | 28a7b37b199bbe0c8c6fe2d5817b04223e61122f (diff) | |
parent | a6aeac644e337188b5e0d6f4b79cbee16a75ab7b (diff) | |
download | goldfish-opengl-8d461e7f3ba926c1d42a673c9b96eb0e29a3bb51.tar.gz |
Snap for 11041982 from a6aeac644e337188b5e0d6f4b79cbee16a75ab7b to mainline-networking-releaseaml_net_341311010aml_net_341310020
Change-Id: I659b934d31bb31de7d5b340b0218aee93a51ea2e
-rw-r--r-- | android-emu/aemu/base/threads/AndroidWorkPool.cpp | 2 | ||||
-rw-r--r-- | system/OpenglSystemCommon/HostConnection.cpp | 1 | ||||
-rw-r--r-- | system/OpenglSystemCommon/HostConnection.h | 1 | ||||
-rw-r--r-- | system/vulkan_enc/DescriptorSetVirtualization.cpp | 38 | ||||
-rw-r--r-- | system/vulkan_enc/DescriptorSetVirtualization.h | 5 | ||||
-rw-r--r-- | system/vulkan_enc/ResourceTracker.cpp | 472 | ||||
-rw-r--r-- | system/vulkan_enc/ResourceTracker.h | 9 | ||||
-rw-r--r-- | system/vulkan_enc/VkEncoder.cpp | 427 | ||||
-rw-r--r-- | system/vulkan_enc/VkEncoder.h | 13 | ||||
-rw-r--r-- | system/vulkan_enc/func_table.cpp | 357 | ||||
-rw-r--r-- | system/vulkan_enc/goldfish_vk_counting_guest.cpp | 14 | ||||
-rw-r--r-- | system/vulkan_enc/goldfish_vk_marshaling_guest.cpp | 23 | ||||
-rw-r--r-- | system/vulkan_enc/goldfish_vk_marshaling_guest.h | 2 | ||||
-rw-r--r-- | system/vulkan_enc/goldfish_vk_reserved_marshaling_guest.cpp | 13 | ||||
-rw-r--r-- | system/vulkan_enc/vk_struct_id.h | 5 | ||||
-rw-r--r-- | system/vulkan_enc/vulkan_gfxstream.h | 23 |
16 files changed, 1097 insertions, 308 deletions
diff --git a/android-emu/aemu/base/threads/AndroidWorkPool.cpp b/android-emu/aemu/base/threads/AndroidWorkPool.cpp index b5baa418..f4e9cdea 100644 --- a/android-emu/aemu/base/threads/AndroidWorkPool.cpp +++ b/android-emu/aemu/base/threads/AndroidWorkPool.cpp @@ -131,7 +131,7 @@ private: while (conditionFunc()) { doWait(currTimeout); - if (!conditionFunc()) { + if (conditionFunc()) { // Decrement timeout for wakeups uint64_t nextTime = currTimeUs(); WorkPool::TimeoutUs waited = diff --git a/system/OpenglSystemCommon/HostConnection.cpp b/system/OpenglSystemCommon/HostConnection.cpp index f52e84e9..d1300731 100644 --- a/system/OpenglSystemCommon/HostConnection.cpp +++ b/system/OpenglSystemCommon/HostConnection.cpp @@ -212,6 +212,7 @@ public: { return static_cast<size_t>(cb_handle_t::from(handle)->allocatedSize()); } + virtual bool treatBlobAsImage() { return true; } }; static inline uint32_t align_up(uint32_t n, uint32_t a) { diff --git a/system/OpenglSystemCommon/HostConnection.h b/system/OpenglSystemCommon/HostConnection.h index 64f0137b..59b914ed 100644 --- a/system/OpenglSystemCommon/HostConnection.h +++ b/system/OpenglSystemCommon/HostConnection.h @@ -150,6 +150,7 @@ public: return 0; } virtual size_t getAllocatedSize(native_handle_t const* handle) = 0; + virtual bool treatBlobAsImage() { return false; }; virtual ~Gralloc() {} }; diff --git a/system/vulkan_enc/DescriptorSetVirtualization.cpp b/system/vulkan_enc/DescriptorSetVirtualization.cpp index 0cc68262..fa0cb78c 100644 --- a/system/vulkan_enc/DescriptorSetVirtualization.cpp +++ b/system/vulkan_enc/DescriptorSetVirtualization.cpp @@ -155,8 +155,29 @@ void doEmulatedDescriptorWrite(const VkWriteDescriptorSet* write, ReifiedDescrip entry.type = DescriptorWriteType::BufferView; entry.descriptorType = descType; } - } else if (isDescriptorTypeInlineUniformBlock(descType) || - isDescriptorTypeAccelerationStructure(descType)) { + } else if (isDescriptorTypeInlineUniformBlock(descType)) { + const VkWriteDescriptorSetInlineUniformBlock* descInlineUniformBlock = + static_cast<const VkWriteDescriptorSetInlineUniformBlock*>(write->pNext); + while (descInlineUniformBlock && + descInlineUniformBlock->sType != + VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_INLINE_UNIFORM_BLOCK) { + descInlineUniformBlock = static_cast<const VkWriteDescriptorSetInlineUniformBlock*>( + descInlineUniformBlock->pNext); + } + if (!descInlineUniformBlock) { + ALOGE("%s: did not find inline uniform block\n", __func__); + return; + } + auto& entry = table[dstBinding][0]; + entry.inlineUniformBlock = *descInlineUniformBlock; + entry.inlineUniformBlockBuffer.assign( + static_cast<const uint8_t*>(descInlineUniformBlock->pData), + static_cast<const uint8_t*>(descInlineUniformBlock->pData) + + descInlineUniformBlock->dataSize); + entry.type = DescriptorWriteType::InlineUniformBlock; + entry.descriptorType = descType; + entry.dstArrayElement = dstArrayElement; + } else if (isDescriptorTypeAccelerationStructure(descType)) { // TODO // Look for pNext inline uniform block or acceleration structure. // Append new DescriptorWrite entry that holds the buffer @@ -268,6 +289,19 @@ void doEmulatedDescriptorBufferViewWriteFromTemplate( } } +void doEmulatedDescriptorInlineUniformBlockFromTemplate(VkDescriptorType descType, uint32_t binding, + uint32_t dstArrayElement, uint32_t count, + const void* pData, + ReifiedDescriptorSet* set) { + DescriptorWriteTable& table = set->allWrites; + auto& entry = table[binding][0]; + entry.dstArrayElement = dstArrayElement; + entry.inlineUniformBlockBuffer.assign(static_cast<const uint8_t*>(pData), + static_cast<const uint8_t*>(pData) + count); + entry.type = DescriptorWriteType::InlineUniformBlock; + entry.descriptorType = descType; +} + static bool isBindingFeasibleForAlloc( const DescriptorPoolAllocationInfo::DescriptorCountInfo& countInfo, const VkDescriptorSetLayoutBinding& binding) { diff --git a/system/vulkan_enc/DescriptorSetVirtualization.h b/system/vulkan_enc/DescriptorSetVirtualization.h index 15e42266..c6a6c42e 100644 --- a/system/vulkan_enc/DescriptorSetVirtualization.h +++ b/system/vulkan_enc/DescriptorSetVirtualization.h @@ -140,6 +140,11 @@ void doEmulatedDescriptorBufferViewWriteFromTemplate( const VkBufferView* bufferViews, ReifiedDescriptorSet* set); +void doEmulatedDescriptorInlineUniformBlockFromTemplate(VkDescriptorType descType, uint32_t binding, + uint32_t dstArrayElement, uint32_t count, + const void* pData, + ReifiedDescriptorSet* set); + void applyDescriptorSetAllocation(VkDescriptorPool pool, VkDescriptorSetLayout setLayout); void fillDescriptorSetInfoForPool(VkDescriptorPool pool, VkDescriptorSetLayout setLayout, VkDescriptorSet set); VkResult validateAndApplyVirtualDescriptorSetAllocation(const VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pSets); diff --git a/system/vulkan_enc/ResourceTracker.cpp b/system/vulkan_enc/ResourceTracker.cpp index 54147007..d5ae1d38 100644 --- a/system/vulkan_enc/ResourceTracker.cpp +++ b/system/vulkan_enc/ResourceTracker.cpp @@ -369,12 +369,15 @@ public: uint32_t imageInfoCount = 0; uint32_t bufferInfoCount = 0; uint32_t bufferViewCount = 0; + uint32_t inlineUniformBlockCount = 0; uint32_t* imageInfoIndices; uint32_t* bufferInfoIndices; uint32_t* bufferViewIndices; VkDescriptorImageInfo* imageInfos; VkDescriptorBufferInfo* bufferInfos; VkBufferView* bufferViews; + std::vector<uint8_t> inlineUniformBlockBuffer; + std::vector<uint32_t> inlineUniformBlockBytesPerBlocks; // bytes per uniform block }; struct VkFence_Info { @@ -1216,7 +1219,6 @@ public: const char*, uint32_t* pPropertyCount, VkExtensionProperties* pProperties) { - std::vector<const char*> allowedExtensionNames = { "VK_KHR_vulkan_memory_model", "VK_KHR_buffer_device_address", @@ -1228,8 +1230,8 @@ public: "VK_KHR_get_memory_requirements2", "VK_KHR_sampler_ycbcr_conversion", "VK_KHR_shader_float16_int8", - // Timeline semaphores buggy in newer NVIDIA drivers - // (vkWaitSemaphoresKHR causes further vkCommandBuffer dispatches to deadlock) + // Timeline semaphores buggy in newer NVIDIA drivers + // (vkWaitSemaphoresKHR causes further vkCommandBuffer dispatches to deadlock) #ifndef VK_USE_PLATFORM_ANDROID_KHR "VK_KHR_timeline_semaphore", #endif @@ -1264,9 +1266,12 @@ public: "VK_EXT_device_memory_report", #endif #if !defined(VK_USE_PLATFORM_ANDROID_KHR) && defined(__linux__) - "VK_KHR_create_renderpass2", - "VK_KHR_imageless_framebuffer", + "VK_KHR_create_renderpass2", + "VK_KHR_imageless_framebuffer", #endif + // Vulkan 1.3 + "VK_KHR_synchronization2", + "VK_EXT_private_data", }; VkEncoder* enc = (VkEncoder*)context; @@ -1657,6 +1662,51 @@ public: } #ifdef VK_USE_PLATFORM_ANDROID_KHR + uint32_t getColorBufferMemoryIndex(void* context, VkDevice device) { + // Create test image to get the memory requirements + VkEncoder* enc = (VkEncoder*)context; + VkImageCreateInfo createInfo = { + .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, + .imageType = VK_IMAGE_TYPE_2D, + .format = VK_FORMAT_R8G8B8A8_UNORM, + .extent = {64, 64, 1}, + .mipLevels = 1, + .arrayLayers = 1, + .samples = VK_SAMPLE_COUNT_1_BIT, + .tiling = VK_IMAGE_TILING_OPTIMAL, + .usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | + VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | + VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, + .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED, + }; + VkImage image = VK_NULL_HANDLE; + VkResult res = enc->vkCreateImage(device, &createInfo, nullptr, &image, true /* do lock */); + + if (res != VK_SUCCESS) { + return 0; + } + + VkMemoryRequirements memReqs; + enc->vkGetImageMemoryRequirements( + device, image, &memReqs, true /* do lock */); + enc->vkDestroyImage(device, image, nullptr, true /* do lock */); + + const VkPhysicalDeviceMemoryProperties& memProps = + getPhysicalDeviceMemoryProperties(context, device, VK_NULL_HANDLE); + + // Currently, host looks for the last index that has with memory + // property type VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT + VkMemoryPropertyFlags memoryProperty = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + for (int i = VK_MAX_MEMORY_TYPES - 1; i >= 0; --i) { + if ((memReqs.memoryTypeBits & (1u << i)) && + (memProps.memoryTypes[i].propertyFlags & memoryProperty)) { + return i; + } + } + + return 0; + } + VkResult on_vkGetAndroidHardwareBufferPropertiesANDROID( void* context, VkResult, VkDevice device, @@ -1666,12 +1716,9 @@ public: ResourceTracker::threadingCallbacks.hostConnectionGetFunc()->grallocHelper(); // Delete once goldfish Linux drivers are gone - if (mCaps.gfxstreamCapset.colorBufferMemoryIndex == 0xFFFFFFFF) { - const VkPhysicalDeviceMemoryProperties& memProps = - getPhysicalDeviceMemoryProperties(context, device, VK_NULL_HANDLE); - + if (mCaps.gfxstreamCapset.colorBufferMemoryIndex == 0xFFFFFFFF) { mCaps.gfxstreamCapset.colorBufferMemoryIndex = - (1u << memProps.memoryTypeCount) - 1; + getColorBufferMemoryIndex(context, device); } updateMemoryTypeBits(&pProperties->memoryTypeBits, @@ -3441,7 +3488,8 @@ public: AHardwareBuffer_Desc ahbDesc = {}; AHardwareBuffer_describe(ahw, &ahbDesc); - if (ahbDesc.format == AHARDWAREBUFFER_FORMAT_BLOB) { + if (ahbDesc.format == AHARDWAREBUFFER_FORMAT_BLOB + && !ResourceTracker::threadingCallbacks.hostConnectionGetFunc()->grallocHelper()->treatBlobAsImage()) { importBufferInfo.buffer = hostHandle; vk_append_struct(&structChainIter, &importBufferInfo); } else { @@ -3777,7 +3825,9 @@ public: enc->vkAllocateMemory( device, &finalAllocInfo, pAllocator, pMemory, true /* do lock */); - if (input_result != VK_SUCCESS) _RETURN_FAILURE_WITH_DEVICE_MEMORY_REPORT(input_result); + if (input_result != VK_SUCCESS) { + _RETURN_FAILURE_WITH_DEVICE_MEMORY_REPORT(input_result); + } VkDeviceSize allocationSize = finalAllocInfo.allocationSize; setDeviceMemoryInfo( @@ -3828,8 +3878,9 @@ public: // Host visible memory with direct mapping VkResult result = getCoherentMemory(&finalAllocInfo, enc, device, pMemory); - if (result != VK_SUCCESS) + if (result != VK_SUCCESS) { return result; + } _RETURN_SCUCCESS_WITH_DEVICE_MEMORY_REPORT; } @@ -3938,10 +3989,14 @@ public: createBlob.size = info.coherentMemorySize; auto blob = instance.createBlob(createBlob); - if (!blob) return VK_ERROR_OUT_OF_DEVICE_MEMORY; + if (!blob) { + return VK_ERROR_OUT_OF_DEVICE_MEMORY; + } mapping = blob->createMapping(); - if (!mapping) return VK_ERROR_OUT_OF_DEVICE_MEMORY; + if (!mapping) { + return VK_ERROR_OUT_OF_DEVICE_MEMORY; + } auto coherentMemory = std::make_shared<CoherentMemory>(mapping, createBlob.size, device, memory); @@ -4054,6 +4109,11 @@ public: VkEncoder* enc = (VkEncoder*)context; VkImageCreateInfo localCreateInfo = vk_make_orphan_copy(*pCreateInfo); + if (localCreateInfo.sharingMode != VK_SHARING_MODE_CONCURRENT) { + localCreateInfo.queueFamilyIndexCount = 0; + localCreateInfo.pQueueFamilyIndices = nullptr; + } + vk_struct_chain_iterator structChainIter = vk_make_chain_iterator(&localCreateInfo); VkExternalMemoryImageCreateInfo localExtImgCi; @@ -4245,8 +4305,11 @@ public: // Delete `protocolVersion` check goldfish drivers are gone. #ifdef VK_USE_PLATFORM_ANDROID_KHR + if (mCaps.gfxstreamCapset.colorBufferMemoryIndex == 0xFFFFFFFF) { + mCaps.gfxstreamCapset.colorBufferMemoryIndex = + getColorBufferMemoryIndex(context, device); + } if (extImgCiPtr && - mCaps.gfxstreamCapset.protocolVersion && (extImgCiPtr->handleTypes & VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID)) { updateMemoryTypeBits(&memReqs.memoryTypeBits, @@ -4396,6 +4459,39 @@ public: return enc->vkCreateSampler(device, &localCreateInfo, pAllocator, pSampler, true /* do lock */); } + void on_vkGetPhysicalDeviceExternalBufferProperties( + void* context, + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, + VkExternalBufferProperties* pExternalBufferProperties) { + VkEncoder* enc = (VkEncoder*)context; + // b/299520213 + // We declared blob formar not supported. + if (ResourceTracker::threadingCallbacks.hostConnectionGetFunc()->grallocHelper()->treatBlobAsImage() + && pExternalBufferInfo->handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID) { + pExternalBufferProperties->externalMemoryProperties.externalMemoryFeatures = 0; + pExternalBufferProperties->externalMemoryProperties.exportFromImportedHandleTypes = 0; + pExternalBufferProperties->externalMemoryProperties.compatibleHandleTypes = 0; + return; + } + uint32_t supportedHandleType = 0; +#ifdef VK_USE_PLATFORM_FUCHSIA + supportedHandleType |= VK_EXTERNAL_MEMORY_HANDLE_TYPE_ZIRCON_VM_BIT_FUCHSIA; +#endif +#ifdef VK_USE_PLATFORM_ANDROID_KHR + supportedHandleType |= VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT | + VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID; +#endif + if (supportedHandleType) { + // 0 is a valid handleType so we can't check against 0 + if (pExternalBufferInfo->handleType != (pExternalBufferInfo->handleType & supportedHandleType)) { + return; + } + } + enc->vkGetPhysicalDeviceExternalBufferProperties(physicalDevice, pExternalBufferInfo, pExternalBufferProperties, true /* do lock */); + transformImpl_VkExternalMemoryProperties_fromhost(&pExternalBufferProperties->externalMemoryProperties, 0); + } + void on_vkGetPhysicalDeviceExternalFenceProperties( void* context, VkPhysicalDevice physicalDevice, @@ -5229,6 +5325,22 @@ public: vk_append_struct(&structChainIter, &localExtBufCi); } + VkBufferOpaqueCaptureAddressCreateInfo localCapAddrCi; + const VkBufferOpaqueCaptureAddressCreateInfo* pCapAddrCi = + vk_find_struct<VkBufferOpaqueCaptureAddressCreateInfo>(pCreateInfo); + if (pCapAddrCi) { + localCapAddrCi = vk_make_orphan_copy(*pCapAddrCi); + vk_append_struct(&structChainIter, &localCapAddrCi); + } + + VkBufferDeviceAddressCreateInfoEXT localDevAddrCi; + const VkBufferDeviceAddressCreateInfoEXT* pDevAddrCi = + vk_find_struct<VkBufferDeviceAddressCreateInfoEXT>(pCreateInfo); + if (pDevAddrCi) { + localDevAddrCi = vk_make_orphan_copy(*pDevAddrCi); + vk_append_struct(&structChainIter, &localDevAddrCi); + } + #ifdef VK_USE_PLATFORM_FUCHSIA Optional<zx::vmo> vmo; bool isSysmemBackedMemory = false; @@ -5297,8 +5409,11 @@ public: // Delete `protocolVersion` check goldfish drivers are gone. #ifdef VK_USE_PLATFORM_ANDROID_KHR + if (mCaps.gfxstreamCapset.colorBufferMemoryIndex == 0xFFFFFFFF) { + mCaps.gfxstreamCapset.colorBufferMemoryIndex = + getColorBufferMemoryIndex(context, device); + } if (extBufCiPtr && - mCaps.gfxstreamCapset.protocolVersion && (extBufCiPtr->handleTypes & VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID)) { updateMemoryTypeBits(&memReqs.memoryTypeBits, @@ -5858,11 +5973,61 @@ public: } } - void flushStagingStreams(void* context, VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits) { + uint32_t getWaitSemaphoreCount(const VkSubmitInfo& pSubmit) { + return pSubmit.waitSemaphoreCount; + } + + uint32_t getWaitSemaphoreCount(const VkSubmitInfo2& pSubmit) { + return pSubmit.waitSemaphoreInfoCount; + } + + uint32_t getCommandBufferCount(const VkSubmitInfo& pSubmit) { + return pSubmit.commandBufferCount; + } + + uint32_t getCommandBufferCount(const VkSubmitInfo2& pSubmit) { + return pSubmit.commandBufferInfoCount; + } + + uint32_t getSignalSemaphoreCount(const VkSubmitInfo& pSubmit) { + return pSubmit.signalSemaphoreCount; + } + + uint32_t getSignalSemaphoreCount(const VkSubmitInfo2& pSubmit) { + return pSubmit.signalSemaphoreInfoCount; + } + + VkSemaphore getWaitSemaphore(const VkSubmitInfo& pSubmit, int i) { + return pSubmit.pWaitSemaphores[i]; + } + + VkSemaphore getWaitSemaphore(const VkSubmitInfo2& pSubmit, int i) { + return pSubmit.pWaitSemaphoreInfos[i].semaphore; + } + + VkSemaphore getSignalSemaphore(const VkSubmitInfo& pSubmit, int i) { + return pSubmit.pSignalSemaphores[i]; + } + + VkSemaphore getSignalSemaphore(const VkSubmitInfo2& pSubmit, int i) { + return pSubmit.pSignalSemaphoreInfos[i].semaphore; + } + + VkCommandBuffer getCommandBuffer(const VkSubmitInfo& pSubmit, int i) { + return pSubmit.pCommandBuffers[i]; + } + + VkCommandBuffer getCommandBuffer(const VkSubmitInfo2& pSubmit, int i) { + return pSubmit.pCommandBufferInfos[i].commandBuffer; + } + + template <class VkSubmitInfoType> + void flushStagingStreams(void* context, VkQueue queue, uint32_t submitCount, + const VkSubmitInfoType* pSubmits) { std::vector<VkCommandBuffer> toFlush; for (uint32_t i = 0; i < submitCount; ++i) { - for (uint32_t j = 0; j < pSubmits[i].commandBufferCount; ++j) { - toFlush.push_back(pSubmits[i].pCommandBuffers[j]); + for (uint32_t j = 0; j < getCommandBufferCount(pSubmits[i]); ++j) { + toFlush.push_back(getCommandBuffer(pSubmits[i], j)); } } @@ -5881,7 +6046,41 @@ public: void* context, VkResult input_result, VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence) { AEMU_SCOPED_TRACE("on_vkQueueSubmit"); + return on_vkQueueSubmitTemplate<VkSubmitInfo>(context, input_result, queue, submitCount, + pSubmits, fence); + } + + VkResult on_vkQueueSubmit2(void* context, VkResult input_result, VkQueue queue, + uint32_t submitCount, const VkSubmitInfo2* pSubmits, VkFence fence) { + AEMU_SCOPED_TRACE("on_vkQueueSubmit2"); + return on_vkQueueSubmitTemplate<VkSubmitInfo2>(context, input_result, queue, submitCount, + pSubmits, fence); + } + + VkResult vkQueueSubmitEnc(VkEncoder* enc, VkQueue queue, uint32_t submitCount, + const VkSubmitInfo* pSubmits, VkFence fence) { + if (supportsAsyncQueueSubmit()) { + enc->vkQueueSubmitAsyncGOOGLE(queue, submitCount, pSubmits, fence, true /* do lock */); + return VK_SUCCESS; + } else { + return enc->vkQueueSubmit(queue, submitCount, pSubmits, fence, true /* do lock */); + } + } + VkResult vkQueueSubmitEnc(VkEncoder* enc, VkQueue queue, uint32_t submitCount, + const VkSubmitInfo2* pSubmits, VkFence fence) { + if (supportsAsyncQueueSubmit()) { + enc->vkQueueSubmitAsync2GOOGLE(queue, submitCount, pSubmits, fence, true /* do lock */); + return VK_SUCCESS; + } else { + return enc->vkQueueSubmit2(queue, submitCount, pSubmits, fence, true /* do lock */); + } + } + + template <typename VkSubmitInfoType> + VkResult on_vkQueueSubmitTemplate(void* context, VkResult input_result, VkQueue queue, + uint32_t submitCount, const VkSubmitInfoType* pSubmits, + VkFence fence) { flushStagingStreams(context, queue, submitCount, pSubmits); std::vector<VkSemaphore> pre_signal_semaphores; @@ -5895,26 +6094,27 @@ public: AutoLock<RecursiveLock> lock(mLock); for (uint32_t i = 0; i < submitCount; ++i) { - for (uint32_t j = 0; j < pSubmits[i].waitSemaphoreCount; ++j) { - auto it = info_VkSemaphore.find(pSubmits[i].pWaitSemaphores[j]); + for (uint32_t j = 0; j < getWaitSemaphoreCount(pSubmits[i]); ++j) { + VkSemaphore semaphore = getWaitSemaphore(pSubmits[i], j); + auto it = info_VkSemaphore.find(semaphore); if (it != info_VkSemaphore.end()) { auto& semInfo = it->second; #ifdef VK_USE_PLATFORM_FUCHSIA if (semInfo.eventHandle) { pre_signal_events.push_back(semInfo.eventHandle); - pre_signal_semaphores.push_back(pSubmits[i].pWaitSemaphores[j]); + pre_signal_semaphores.push_back(semaphore); } #endif #if defined(VK_USE_PLATFORM_ANDROID_KHR) || defined(__linux__) if (semInfo.syncFd.has_value()) { pre_signal_sync_fds.push_back(semInfo.syncFd.value()); - pre_signal_semaphores.push_back(pSubmits[i].pWaitSemaphores[j]); + pre_signal_semaphores.push_back(semaphore); } #endif } } - for (uint32_t j = 0; j < pSubmits[i].signalSemaphoreCount; ++j) { - auto it = info_VkSemaphore.find(pSubmits[i].pSignalSemaphores[j]); + for (uint32_t j = 0; j < getSignalSemaphoreCount(pSubmits[i]); ++j) { + auto it = info_VkSemaphore.find(getSignalSemaphore(pSubmits[i], j)); if (it != info_VkSemaphore.end()) { auto& semInfo = it->second; #ifdef VK_USE_PLATFORM_FUCHSIA @@ -5945,13 +6145,8 @@ public: lock.unlock(); if (pre_signal_semaphores.empty()) { - if (supportsAsyncQueueSubmit()) { - enc->vkQueueSubmitAsyncGOOGLE(queue, submitCount, pSubmits, fence, true /* do lock */); - input_result = VK_SUCCESS; - } else { - input_result = enc->vkQueueSubmit(queue, submitCount, pSubmits, fence, true /* do lock */); - if (input_result != VK_SUCCESS) return input_result; - } + input_result = vkQueueSubmitEnc(enc, queue, submitCount, pSubmits, fence); + if (input_result != VK_SUCCESS) return input_result; } else { // Schedule waits on the OS external objects and // signal the wait semaphores @@ -5985,6 +6180,7 @@ public: mWorkPool.waitAll(waitGroupHandle); } + // Use the old version of VkSubmitInfo VkSubmitInfo submit_info = { .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, .waitSemaphoreCount = 0, @@ -5993,22 +6189,10 @@ public: .signalSemaphoreCount = static_cast<uint32_t>(pre_signal_semaphores.size()), .pSignalSemaphores = pre_signal_semaphores.data()}; - - if (supportsAsyncQueueSubmit()) { - enc->vkQueueSubmitAsyncGOOGLE(queue, 1, &submit_info, VK_NULL_HANDLE, true /* do lock */); - } else { - enc->vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE, true /* do lock */); - } - - if (supportsAsyncQueueSubmit()) { - enc->vkQueueSubmitAsyncGOOGLE(queue, submitCount, pSubmits, fence, true /* do lock */); - input_result = VK_SUCCESS; - } else { - input_result = enc->vkQueueSubmit(queue, submitCount, pSubmits, fence, true /* do lock */); - if (input_result != VK_SUCCESS) return input_result; - } + vkQueueSubmitEnc(enc, queue, 1, &submit_info, VK_NULL_HANDLE); + input_result = vkQueueSubmitEnc(enc, queue, submitCount, pSubmits, fence); + if (input_result != VK_SUCCESS) return input_result; } - lock.lock(); int externalFenceFdToSignal = -1; @@ -6063,7 +6247,6 @@ public: auto& queueWorkItems = mQueueSensitiveWorkPoolItems[queue]; queueWorkItems.push_back(queueAsyncWaitHandle); } - return VK_SUCCESS; } @@ -6261,22 +6444,28 @@ public: } auto& info = it->second; + uint32_t inlineUniformBlockBufferSize = 0; for (uint32_t i = 0; i < pCreateInfo->descriptorUpdateEntryCount; ++i) { const auto& entry = pCreateInfo->pDescriptorUpdateEntries[i]; uint32_t descCount = entry.descriptorCount; VkDescriptorType descType = entry.descriptorType; ++info.templateEntryCount; - for (uint32_t j = 0; j < descCount; ++j) { - if (isDescriptorTypeImageInfo(descType)) { - ++info.imageInfoCount; - } else if (isDescriptorTypeBufferInfo(descType)) { - ++info.bufferInfoCount; - } else if (isDescriptorTypeBufferView(descType)) { - ++info.bufferViewCount; - } else { - ALOGE("%s: FATAL: Unknown descriptor type %d\n", __func__, descType); - abort(); + if (isDescriptorTypeInlineUniformBlock(descType)) { + inlineUniformBlockBufferSize += descCount; + ++info.inlineUniformBlockCount; + } else { + for (uint32_t j = 0; j < descCount; ++j) { + if (isDescriptorTypeImageInfo(descType)) { + ++info.imageInfoCount; + } else if (isDescriptorTypeBufferInfo(descType)) { + ++info.bufferInfoCount; + } else if (isDescriptorTypeBufferView(descType)) { + ++info.bufferViewCount; + } else { + ALOGE("%s: FATAL: Unknown descriptor type %d\n", __func__, descType); + abort(); + } } } } @@ -6299,9 +6488,15 @@ public: info.bufferViews = new VkBufferView[info.bufferViewCount]; } + if (info.inlineUniformBlockCount) { + info.inlineUniformBlockBuffer.resize(inlineUniformBlockBufferSize); + info.inlineUniformBlockBytesPerBlocks.resize(info.inlineUniformBlockCount); + } + uint32_t imageInfoIndex = 0; uint32_t bufferInfoIndex = 0; uint32_t bufferViewIndex = 0; + uint32_t inlineUniformBlockIndex = 0; for (uint32_t i = 0; i < pCreateInfo->descriptorUpdateEntryCount; ++i) { const auto& entry = pCreateInfo->pDescriptorUpdateEntries[i]; @@ -6310,19 +6505,24 @@ public: info.templateEntries[i] = entry; - for (uint32_t j = 0; j < descCount; ++j) { - if (isDescriptorTypeImageInfo(descType)) { - info.imageInfoIndices[imageInfoIndex] = i; - ++imageInfoIndex; - } else if (isDescriptorTypeBufferInfo(descType)) { - info.bufferInfoIndices[bufferInfoIndex] = i; - ++bufferInfoIndex; - } else if (isDescriptorTypeBufferView(descType)) { - info.bufferViewIndices[bufferViewIndex] = i; - ++bufferViewIndex; - } else { - ALOGE("%s: FATAL: Unknown descriptor type %d\n", __func__, descType); - abort(); + if (isDescriptorTypeInlineUniformBlock(descType)) { + info.inlineUniformBlockBytesPerBlocks[inlineUniformBlockIndex] = descCount; + ++inlineUniformBlockIndex; + } else { + for (uint32_t j = 0; j < descCount; ++j) { + if (isDescriptorTypeImageInfo(descType)) { + info.imageInfoIndices[imageInfoIndex] = i; + ++imageInfoIndex; + } else if (isDescriptorTypeBufferInfo(descType)) { + info.bufferInfoIndices[bufferInfoIndex] = i; + ++bufferInfoIndex; + } else if (isDescriptorTypeBufferView(descType)) { + info.bufferViewIndices[bufferViewIndex] = i; + ++bufferViewIndex; + } else { + ALOGE("%s: FATAL: Unknown descriptor type %d\n", __func__, descType); + // abort(); + } } } } @@ -6390,18 +6590,23 @@ public: uint32_t imageInfoCount = info.imageInfoCount; uint32_t bufferInfoCount = info.bufferInfoCount; uint32_t bufferViewCount = info.bufferViewCount; + uint32_t inlineUniformBlockCount = info.inlineUniformBlockCount; uint32_t* imageInfoIndices = info.imageInfoIndices; uint32_t* bufferInfoIndices = info.bufferInfoIndices; uint32_t* bufferViewIndices = info.bufferViewIndices; VkDescriptorImageInfo* imageInfos = info.imageInfos; VkDescriptorBufferInfo* bufferInfos = info.bufferInfos; VkBufferView* bufferViews = info.bufferViews; + uint8_t* inlineUniformBlockBuffer = info.inlineUniformBlockBuffer.data(); + uint32_t* inlineUniformBlockBytesPerBlocks = info.inlineUniformBlockBytesPerBlocks.data(); lock.unlock(); size_t currImageInfoOffset = 0; size_t currBufferInfoOffset = 0; size_t currBufferViewOffset = 0; + size_t inlineUniformBlockOffset = 0; + size_t inlineUniformBlockIdx = 0; struct goldfish_VkDescriptorSet* ds = as_goldfish_VkDescriptorSet(descriptorSet); ReifiedDescriptorSet* reified = ds->reified; @@ -6479,21 +6684,32 @@ public: for (uint32_t j = 0; j < descCount; ++j) { const VkBufferView* user = - (const VkBufferView*)(userBuffer + offset + j * stride); + (const VkBufferView*)(userBuffer + offset + j * stride); - memcpy(((uint8_t*)bufferViews) + currBufferViewOffset, - user, sizeof(VkBufferView)); - currBufferViewOffset += sizeof(VkBufferView); + memcpy(((uint8_t*)bufferViews) + currBufferViewOffset, user, + sizeof(VkBufferView)); + currBufferViewOffset += sizeof(VkBufferView); } if (batched) { - doEmulatedDescriptorBufferViewWriteFromTemplate( - descType, - dstBinding, - dstArrayElement, - descCount, - currBufferViewBegin, - reified); + doEmulatedDescriptorBufferViewWriteFromTemplate(descType, dstBinding, + dstArrayElement, descCount, + currBufferViewBegin, reified); + } + } else if (isDescriptorTypeInlineUniformBlock(descType)) { + uint32_t inlineUniformBlockBytesPerBlock = + inlineUniformBlockBytesPerBlocks[inlineUniformBlockIdx]; + uint8_t* currInlineUniformBlockBufferBegin = + inlineUniformBlockBuffer + inlineUniformBlockOffset; + memcpy(currInlineUniformBlockBufferBegin, userBuffer + offset, + inlineUniformBlockBytesPerBlock); + inlineUniformBlockIdx++; + inlineUniformBlockOffset += inlineUniformBlockBytesPerBlock; + + if (batched) { + doEmulatedDescriptorInlineUniformBlockFromTemplate( + descType, dstBinding, dstArrayElement, descCount, + currInlineUniformBlockBufferBegin, reified); } } else { ALOGE("%s: FATAL: Unknown descriptor type %d\n", __func__, descType); @@ -6503,20 +6719,11 @@ public: if (batched) return; - enc->vkUpdateDescriptorSetWithTemplateSizedGOOGLE( - device, - descriptorSet, - descriptorUpdateTemplate, - imageInfoCount, - bufferInfoCount, - bufferViewCount, - imageInfoIndices, - bufferInfoIndices, - bufferViewIndices, - imageInfos, - bufferInfos, - bufferViews, - true /* do lock */); + enc->vkUpdateDescriptorSetWithTemplateSized2GOOGLE( + device, descriptorSet, descriptorUpdateTemplate, imageInfoCount, bufferInfoCount, + bufferViewCount, static_cast<uint32_t>(info.inlineUniformBlockBuffer.size()), + imageInfoIndices, bufferInfoIndices, bufferViewIndices, imageInfos, bufferInfos, + bufferViews, inlineUniformBlockBuffer, true /* do lock */); } VkResult on_vkGetPhysicalDeviceImageFormatProperties2_common( @@ -6529,6 +6736,9 @@ public: VkEncoder* enc = (VkEncoder*)context; (void)input_result; + uint32_t supportedHandleType = 0; + VkExternalImageFormatProperties* ext_img_properties = + vk_find_struct<VkExternalImageFormatProperties>(pImageFormatProperties); #ifdef VK_USE_PLATFORM_FUCHSIA constexpr VkFormat kExternalImageSupportedFormats[] = { @@ -6560,9 +6770,6 @@ public: VK_FORMAT_R8G8_SRGB, }; - VkExternalImageFormatProperties* ext_img_properties = - vk_find_struct<VkExternalImageFormatProperties>(pImageFormatProperties); - if (ext_img_properties) { if (std::find(std::begin(kExternalImageSupportedFormats), std::end(kExternalImageSupportedFormats), @@ -6570,13 +6777,24 @@ public: return VK_ERROR_FORMAT_NOT_SUPPORTED; } } + supportedHandleType |= VK_EXTERNAL_MEMORY_HANDLE_TYPE_ZIRCON_VM_BIT_FUCHSIA; #endif #ifdef VK_USE_PLATFORM_ANDROID_KHR VkAndroidHardwareBufferUsageANDROID* output_ahw_usage = vk_find_struct<VkAndroidHardwareBufferUsageANDROID>(pImageFormatProperties); + supportedHandleType |= VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT | + VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID; #endif - + const VkPhysicalDeviceExternalImageFormatInfo* ext_img_info = + vk_find_struct<VkPhysicalDeviceExternalImageFormatInfo>(pImageFormatInfo); + + if (supportedHandleType && ext_img_info) { + // 0 is a valid handleType so we don't check against 0 + if (ext_img_info->handleType != (ext_img_info->handleType & supportedHandleType)) { + return VK_ERROR_FORMAT_NOT_SUPPORTED; + } + } VkResult hostRes; if (isKhr) { @@ -6593,8 +6811,6 @@ public: #ifdef VK_USE_PLATFORM_FUCHSIA if (ext_img_properties) { - const VkPhysicalDeviceExternalImageFormatInfo* ext_img_info = - vk_find_struct<VkPhysicalDeviceExternalImageFormatInfo>(pImageFormatInfo); if (ext_img_info) { if (static_cast<uint32_t>(ext_img_info->handleType) == VK_EXTERNAL_MEMORY_HANDLE_TYPE_ZIRCON_VMO_BIT_FUCHSIA) { @@ -6620,7 +6836,9 @@ public: pImageFormatInfo->usage); } #endif - + if (ext_img_properties) { + transformImpl_VkExternalMemoryProperties_fromhost(&ext_img_properties->externalMemoryProperties, 0); + } return hostRes; } @@ -6663,7 +6881,16 @@ public: VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT; } #else - if (pExternalSemaphoreInfo->handleType == + const VkSemaphoreTypeCreateInfo* semaphoreTypeCi = + vk_find_struct<VkSemaphoreTypeCreateInfo>(pExternalSemaphoreInfo); + bool isSemaphoreTimeline = semaphoreTypeCi != nullptr && semaphoreTypeCi->semaphoreType == VK_SEMAPHORE_TYPE_TIMELINE; + if (isSemaphoreTimeline) { + // b/304373623 + // dEQP-VK.api.external.semaphore.sync_fd#info_timeline + pExternalSemaphoreProperties->compatibleHandleTypes = 0; + pExternalSemaphoreProperties->exportFromImportedHandleTypes = 0; + pExternalSemaphoreProperties->externalSemaphoreFeatures = 0; + } else if (pExternalSemaphoreInfo->handleType == VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT) { pExternalSemaphoreProperties->compatibleHandleTypes |= VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT; @@ -7121,6 +7348,7 @@ public: *fd = exec.handle.osHandle; } else { + ensureSyncDeviceFd(); goldfish_sync_queue_work( mSyncDeviceFd, get_host_u64_VkImage(image) /* the handle */, @@ -7253,12 +7481,27 @@ public: graphicsPipelineCreateInfo.pMultisampleState = nullptr; } + bool forceDepthStencilState = false; + bool forceColorBlendState = false; + + const VkPipelineRenderingCreateInfo* pipelineRenderingInfo = + vk_find_struct<VkPipelineRenderingCreateInfo>(&graphicsPipelineCreateInfo); + if (pipelineRenderingInfo) { + forceDepthStencilState |= pipelineRenderingInfo->depthAttachmentFormat != VK_FORMAT_UNDEFINED; + forceDepthStencilState |= pipelineRenderingInfo->stencilAttachmentFormat != VK_FORMAT_UNDEFINED; + forceColorBlendState |= pipelineRenderingInfo->colorAttachmentCount != 0; + } // VUID-VkGraphicsPipelineCreateInfo-renderPass-06043 // VUID-VkGraphicsPipelineCreateInfo-renderPass-06044 if (graphicsPipelineCreateInfo.renderPass == VK_NULL_HANDLE || !shouldIncludeFragmentShaderState) { - graphicsPipelineCreateInfo.pDepthStencilState = nullptr; - graphicsPipelineCreateInfo.pColorBlendState = nullptr; + // VUID-VkGraphicsPipelineCreateInfo-renderPass-06053 + if (!forceDepthStencilState) { + graphicsPipelineCreateInfo.pDepthStencilState = nullptr; + } + if (!forceColorBlendState) { + graphicsPipelineCreateInfo.pColorBlendState = nullptr; + } } } return enc->vkCreateGraphicsPipelines(device, pipelineCache, localCreateInfos.size(), @@ -7913,6 +8156,12 @@ VkResult ResourceTracker::on_vkQueueSubmit( context, input_result, queue, submitCount, pSubmits, fence); } +VkResult ResourceTracker::on_vkQueueSubmit2(void* context, VkResult input_result, VkQueue queue, + uint32_t submitCount, const VkSubmitInfo2* pSubmits, + VkFence fence) { + return mImpl->on_vkQueueSubmit2(context, input_result, queue, submitCount, pSubmits, fence); +} + VkResult ResourceTracker::on_vkQueueWaitIdle( void* context, VkResult input_result, VkQueue queue) { @@ -8114,6 +8363,15 @@ VkResult ResourceTracker::on_vkCreateSampler( context, input_result, device, pCreateInfo, pAllocator, pSampler); } +void ResourceTracker::on_vkGetPhysicalDeviceExternalBufferProperties( + void* context, + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, + VkExternalBufferProperties* pExternalBufferProperties) { + mImpl->on_vkGetPhysicalDeviceExternalBufferProperties( + context, physicalDevice, pExternalBufferInfo, pExternalBufferProperties); +} + void ResourceTracker::on_vkGetPhysicalDeviceExternalFenceProperties( void* context, VkPhysicalDevice physicalDevice, diff --git a/system/vulkan_enc/ResourceTracker.h b/system/vulkan_enc/ResourceTracker.h index e7af1c20..698ce197 100644 --- a/system/vulkan_enc/ResourceTracker.h +++ b/system/vulkan_enc/ResourceTracker.h @@ -252,6 +252,9 @@ public: void* context, VkResult input_result, VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence); + VkResult on_vkQueueSubmit2(void* context, VkResult input_result, VkQueue queue, + uint32_t submitCount, const VkSubmitInfo2* pSubmits, VkFence fence); + VkResult on_vkQueueWaitIdle( void* context, VkResult input_result, VkQueue queue); @@ -364,6 +367,12 @@ public: const VkAllocationCallbacks* pAllocator, VkSampler* pSampler); + void on_vkGetPhysicalDeviceExternalBufferProperties( + void* context, + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, + VkExternalBufferProperties* pExternalBufferProperties); + void on_vkGetPhysicalDeviceExternalFenceProperties( void* context, VkPhysicalDevice physicalDevice, diff --git a/system/vulkan_enc/VkEncoder.cpp b/system/vulkan_enc/VkEncoder.cpp index e273e474..7470c180 100644 --- a/system/vulkan_enc/VkEncoder.cpp +++ b/system/vulkan_enc/VkEncoder.cpp @@ -50,7 +50,6 @@ #include "aemu/base/synchronization/AndroidLock.h" #include "goldfish_vk_counting_guest.h" #include "goldfish_vk_deepcopy_guest.h" -#include "goldfish_vk_handlemap_guest.h" #include "goldfish_vk_marshaling_guest.h" #include "goldfish_vk_private_defs.h" #include "goldfish_vk_reserved_marshaling_guest.h" @@ -66766,6 +66765,432 @@ VkResult VkEncoder::vkGetBlobGOOGLE(VkDevice device, VkDeviceMemory memory, uint return vkGetBlobGOOGLE_VkResult_return; } +void VkEncoder::vkUpdateDescriptorSetWithTemplateSized2GOOGLE( + VkDevice device, VkDescriptorSet descriptorSet, + VkDescriptorUpdateTemplate descriptorUpdateTemplate, uint32_t imageInfoCount, + uint32_t bufferInfoCount, uint32_t bufferViewCount, uint32_t inlineUniformBlockCount, + const uint32_t* pImageInfoEntryIndices, const uint32_t* pBufferInfoEntryIndices, + const uint32_t* pBufferViewEntryIndices, const VkDescriptorImageInfo* pImageInfos, + const VkDescriptorBufferInfo* pBufferInfos, const VkBufferView* pBufferViews, + const uint8_t* pInlineUniformBlockData, uint32_t doLock) { + std::optional<uint32_t> healthMonitorAnnotation_seqno = std::nullopt; + std::optional<uint32_t> healthMonitorAnnotation_packetSize = std::nullopt; + std::vector<uint8_t> healthMonitorAnnotation_packetContents; + + auto watchdog = + WATCHDOG_BUILDER(mHealthMonitor, + "vkUpdateDescriptorSetWithTemplateSized2GOOGLE in VkEncoder") + .setOnHangCallback([&]() { + auto annotations = std::make_unique<EventHangMetadata::HangAnnotations>(); + if (healthMonitorAnnotation_seqno) { + annotations->insert( + {{"seqno", std::to_string(healthMonitorAnnotation_seqno.value())}}); + } + if (healthMonitorAnnotation_packetSize) { + annotations->insert( + {{"packetSize", + std::to_string(healthMonitorAnnotation_packetSize.value())}}); + } + if (!healthMonitorAnnotation_packetContents.empty()) { + annotations->insert( + {{"packetContents", + getPacketContents(&healthMonitorAnnotation_packetContents[0], + healthMonitorAnnotation_packetContents.size())}}); + } + return std::move(annotations); + }) + .build(); + + ENCODER_DEBUG_LOG( + "vkUpdateDescriptorSetWithTemplateSized2GOOGLE(device:%p, descriptorSet:%p, " + "descriptorUpdateTemplate:%p, imageInfoCount:%d, bufferInfoCount:%d, bufferViewCount:%d, " + "inlineUniformBlockCount:%d, pImageInfoEntryIndices:%p, pBufferInfoEntryIndices:%p, " + "pBufferViewEntryIndices:%p, pImageInfos:%p, pBufferInfos:%p, pBufferViews:%p, " + "pInlineUniformBlockData:%p)", + device, descriptorSet, descriptorUpdateTemplate, imageInfoCount, bufferInfoCount, + bufferViewCount, inlineUniformBlockCount, pImageInfoEntryIndices, pBufferInfoEntryIndices, + pBufferViewEntryIndices, pImageInfos, pBufferInfos, pBufferViews, pInlineUniformBlockData); + (void)doLock; + bool queueSubmitWithCommandsEnabled = + sFeatureBits & VULKAN_STREAM_FEATURE_QUEUE_SUBMIT_WITH_COMMANDS_BIT; + if (!queueSubmitWithCommandsEnabled && doLock) this->lock(); + auto stream = mImpl->stream(); + auto pool = mImpl->pool(); + VkDevice local_device; + VkDescriptorSet local_descriptorSet; + VkDescriptorUpdateTemplate local_descriptorUpdateTemplate; + uint32_t local_imageInfoCount; + uint32_t local_bufferInfoCount; + uint32_t local_bufferViewCount; + uint32_t local_inlineUniformBlockCount; + uint32_t* local_pImageInfoEntryIndices; + uint32_t* local_pBufferInfoEntryIndices; + uint32_t* local_pBufferViewEntryIndices; + VkDescriptorImageInfo* local_pImageInfos; + VkDescriptorBufferInfo* local_pBufferInfos; + VkBufferView* local_pBufferViews; + uint8_t* local_pInlineUniformBlockData; + local_device = device; + local_descriptorSet = descriptorSet; + local_descriptorUpdateTemplate = descriptorUpdateTemplate; + local_imageInfoCount = imageInfoCount; + local_bufferInfoCount = bufferInfoCount; + local_bufferViewCount = bufferViewCount; + local_inlineUniformBlockCount = inlineUniformBlockCount; + // Avoiding deepcopy for pImageInfoEntryIndices + local_pImageInfoEntryIndices = (uint32_t*)pImageInfoEntryIndices; + // Avoiding deepcopy for pBufferInfoEntryIndices + local_pBufferInfoEntryIndices = (uint32_t*)pBufferInfoEntryIndices; + // Avoiding deepcopy for pBufferViewEntryIndices + local_pBufferViewEntryIndices = (uint32_t*)pBufferViewEntryIndices; + local_pImageInfos = nullptr; + if (pImageInfos) { + local_pImageInfos = (VkDescriptorImageInfo*)pool->alloc( + ((imageInfoCount)) * sizeof(const VkDescriptorImageInfo)); + for (uint32_t i = 0; i < (uint32_t)((imageInfoCount)); ++i) { + deepcopy_VkDescriptorImageInfo(pool, VK_STRUCTURE_TYPE_MAX_ENUM, pImageInfos + i, + (VkDescriptorImageInfo*)(local_pImageInfos + i)); + } + } + local_pBufferInfos = nullptr; + if (pBufferInfos) { + local_pBufferInfos = (VkDescriptorBufferInfo*)pool->alloc( + ((bufferInfoCount)) * sizeof(const VkDescriptorBufferInfo)); + for (uint32_t i = 0; i < (uint32_t)((bufferInfoCount)); ++i) { + deepcopy_VkDescriptorBufferInfo(pool, VK_STRUCTURE_TYPE_MAX_ENUM, pBufferInfos + i, + (VkDescriptorBufferInfo*)(local_pBufferInfos + i)); + } + } + // Avoiding deepcopy for pBufferViews + local_pBufferViews = (VkBufferView*)pBufferViews; + // Avoiding deepcopy for pInlineUniformBlockData + local_pInlineUniformBlockData = (uint8_t*)pInlineUniformBlockData; + if (local_pImageInfos) { + for (uint32_t i = 0; i < (uint32_t)((imageInfoCount)); ++i) { + transform_tohost_VkDescriptorImageInfo(sResourceTracker, + (VkDescriptorImageInfo*)(local_pImageInfos + i)); + } + } + if (local_pBufferInfos) { + for (uint32_t i = 0; i < (uint32_t)((bufferInfoCount)); ++i) { + transform_tohost_VkDescriptorBufferInfo( + sResourceTracker, (VkDescriptorBufferInfo*)(local_pBufferInfos + i)); + } + } + size_t count = 0; + size_t* countPtr = &count; + { + uint64_t cgen_var_0; + *countPtr += 1 * 8; + uint64_t cgen_var_1; + *countPtr += 1 * 8; + uint64_t cgen_var_2; + *countPtr += 1 * 8; + *countPtr += sizeof(uint32_t); + *countPtr += sizeof(uint32_t); + *countPtr += sizeof(uint32_t); + *countPtr += sizeof(uint32_t); + // WARNING PTR CHECK + *countPtr += 8; + if (local_pImageInfoEntryIndices) { + *countPtr += ((imageInfoCount)) * sizeof(uint32_t); + } + // WARNING PTR CHECK + *countPtr += 8; + if (local_pBufferInfoEntryIndices) { + *countPtr += ((bufferInfoCount)) * sizeof(uint32_t); + } + // WARNING PTR CHECK + *countPtr += 8; + if (local_pBufferViewEntryIndices) { + *countPtr += ((bufferViewCount)) * sizeof(uint32_t); + } + // WARNING PTR CHECK + *countPtr += 8; + if (local_pImageInfos) { + for (uint32_t i = 0; i < (uint32_t)((imageInfoCount)); ++i) { + count_VkDescriptorImageInfo(sFeatureBits, VK_STRUCTURE_TYPE_MAX_ENUM, + (VkDescriptorImageInfo*)(local_pImageInfos + i), + countPtr); + } + } + // WARNING PTR CHECK + *countPtr += 8; + if (local_pBufferInfos) { + for (uint32_t i = 0; i < (uint32_t)((bufferInfoCount)); ++i) { + count_VkDescriptorBufferInfo(sFeatureBits, VK_STRUCTURE_TYPE_MAX_ENUM, + (VkDescriptorBufferInfo*)(local_pBufferInfos + i), + countPtr); + } + } + // WARNING PTR CHECK + *countPtr += 8; + if (local_pBufferViews) { + if (((bufferViewCount))) { + *countPtr += ((bufferViewCount)) * 8; + } + } + // WARNING PTR CHECK + *countPtr += 8; + if (local_pInlineUniformBlockData) { + *countPtr += ((inlineUniformBlockCount)) * sizeof(uint8_t); + } + } + uint32_t packetSize_vkUpdateDescriptorSetWithTemplateSized2GOOGLE = + 4 + 4 + (queueSubmitWithCommandsEnabled ? 4 : 0) + count; + healthMonitorAnnotation_packetSize = + std::make_optional(packetSize_vkUpdateDescriptorSetWithTemplateSized2GOOGLE); + uint8_t* streamPtr = stream->reserve(packetSize_vkUpdateDescriptorSetWithTemplateSized2GOOGLE); + uint8_t* packetBeginPtr = streamPtr; + uint8_t** streamPtrPtr = &streamPtr; + uint32_t opcode_vkUpdateDescriptorSetWithTemplateSized2GOOGLE = + OP_vkUpdateDescriptorSetWithTemplateSized2GOOGLE; + uint32_t seqno; + if (queueSubmitWithCommandsEnabled) seqno = ResourceTracker::nextSeqno(); + healthMonitorAnnotation_seqno = std::make_optional(seqno); + memcpy(streamPtr, &opcode_vkUpdateDescriptorSetWithTemplateSized2GOOGLE, sizeof(uint32_t)); + streamPtr += sizeof(uint32_t); + memcpy(streamPtr, &packetSize_vkUpdateDescriptorSetWithTemplateSized2GOOGLE, sizeof(uint32_t)); + streamPtr += sizeof(uint32_t); + if (queueSubmitWithCommandsEnabled) { + memcpy(streamPtr, &seqno, sizeof(uint32_t)); + streamPtr += sizeof(uint32_t); + } + uint64_t cgen_var_0; + *&cgen_var_0 = get_host_u64_VkDevice((*&local_device)); + memcpy(*streamPtrPtr, (uint64_t*)&cgen_var_0, 1 * 8); + *streamPtrPtr += 1 * 8; + uint64_t cgen_var_1; + *&cgen_var_1 = get_host_u64_VkDescriptorSet((*&local_descriptorSet)); + memcpy(*streamPtrPtr, (uint64_t*)&cgen_var_1, 1 * 8); + *streamPtrPtr += 1 * 8; + uint64_t cgen_var_2; + *&cgen_var_2 = get_host_u64_VkDescriptorUpdateTemplate((*&local_descriptorUpdateTemplate)); + memcpy(*streamPtrPtr, (uint64_t*)&cgen_var_2, 1 * 8); + *streamPtrPtr += 1 * 8; + memcpy(*streamPtrPtr, (uint32_t*)&local_imageInfoCount, sizeof(uint32_t)); + *streamPtrPtr += sizeof(uint32_t); + memcpy(*streamPtrPtr, (uint32_t*)&local_bufferInfoCount, sizeof(uint32_t)); + *streamPtrPtr += sizeof(uint32_t); + memcpy(*streamPtrPtr, (uint32_t*)&local_bufferViewCount, sizeof(uint32_t)); + *streamPtrPtr += sizeof(uint32_t); + memcpy(*streamPtrPtr, (uint32_t*)&local_inlineUniformBlockCount, sizeof(uint32_t)); + *streamPtrPtr += sizeof(uint32_t); + // WARNING PTR CHECK + uint64_t cgen_var_3 = (uint64_t)(uintptr_t)local_pImageInfoEntryIndices; + memcpy((*streamPtrPtr), &cgen_var_3, 8); + android::base::Stream::toBe64((uint8_t*)(*streamPtrPtr)); + *streamPtrPtr += 8; + if (local_pImageInfoEntryIndices) { + memcpy(*streamPtrPtr, (uint32_t*)local_pImageInfoEntryIndices, + ((imageInfoCount)) * sizeof(uint32_t)); + *streamPtrPtr += ((imageInfoCount)) * sizeof(uint32_t); + } + // WARNING PTR CHECK + uint64_t cgen_var_4 = (uint64_t)(uintptr_t)local_pBufferInfoEntryIndices; + memcpy((*streamPtrPtr), &cgen_var_4, 8); + android::base::Stream::toBe64((uint8_t*)(*streamPtrPtr)); + *streamPtrPtr += 8; + if (local_pBufferInfoEntryIndices) { + memcpy(*streamPtrPtr, (uint32_t*)local_pBufferInfoEntryIndices, + ((bufferInfoCount)) * sizeof(uint32_t)); + *streamPtrPtr += ((bufferInfoCount)) * sizeof(uint32_t); + } + // WARNING PTR CHECK + uint64_t cgen_var_5 = (uint64_t)(uintptr_t)local_pBufferViewEntryIndices; + memcpy((*streamPtrPtr), &cgen_var_5, 8); + android::base::Stream::toBe64((uint8_t*)(*streamPtrPtr)); + *streamPtrPtr += 8; + if (local_pBufferViewEntryIndices) { + memcpy(*streamPtrPtr, (uint32_t*)local_pBufferViewEntryIndices, + ((bufferViewCount)) * sizeof(uint32_t)); + *streamPtrPtr += ((bufferViewCount)) * sizeof(uint32_t); + } + // WARNING PTR CHECK + uint64_t cgen_var_6 = (uint64_t)(uintptr_t)local_pImageInfos; + memcpy((*streamPtrPtr), &cgen_var_6, 8); + android::base::Stream::toBe64((uint8_t*)(*streamPtrPtr)); + *streamPtrPtr += 8; + if (local_pImageInfos) { + for (uint32_t i = 0; i < (uint32_t)((imageInfoCount)); ++i) { + reservedmarshal_VkDescriptorImageInfo(stream, VK_STRUCTURE_TYPE_MAX_ENUM, + (VkDescriptorImageInfo*)(local_pImageInfos + i), + streamPtrPtr); + } + } + // WARNING PTR CHECK + uint64_t cgen_var_7 = (uint64_t)(uintptr_t)local_pBufferInfos; + memcpy((*streamPtrPtr), &cgen_var_7, 8); + android::base::Stream::toBe64((uint8_t*)(*streamPtrPtr)); + *streamPtrPtr += 8; + if (local_pBufferInfos) { + for (uint32_t i = 0; i < (uint32_t)((bufferInfoCount)); ++i) { + reservedmarshal_VkDescriptorBufferInfo( + stream, VK_STRUCTURE_TYPE_MAX_ENUM, + (VkDescriptorBufferInfo*)(local_pBufferInfos + i), streamPtrPtr); + } + } + // WARNING PTR CHECK + uint64_t cgen_var_8 = (uint64_t)(uintptr_t)local_pBufferViews; + memcpy((*streamPtrPtr), &cgen_var_8, 8); + android::base::Stream::toBe64((uint8_t*)(*streamPtrPtr)); + *streamPtrPtr += 8; + if (local_pBufferViews) { + if (((bufferViewCount))) { + uint8_t* cgen_var_8_0_ptr = (uint8_t*)(*streamPtrPtr); + for (uint32_t k = 0; k < ((bufferViewCount)); ++k) { + uint64_t tmpval = get_host_u64_VkBufferView(local_pBufferViews[k]); + memcpy(cgen_var_8_0_ptr + k * 8, &tmpval, sizeof(uint64_t)); + } + *streamPtrPtr += 8 * ((bufferViewCount)); + } + } + // WARNING PTR CHECK + uint64_t cgen_var_9 = (uint64_t)(uintptr_t)local_pInlineUniformBlockData; + memcpy((*streamPtrPtr), &cgen_var_9, 8); + android::base::Stream::toBe64((uint8_t*)(*streamPtrPtr)); + *streamPtrPtr += 8; + if (local_pInlineUniformBlockData) { + memcpy(*streamPtrPtr, (uint8_t*)local_pInlineUniformBlockData, + ((inlineUniformBlockCount)) * sizeof(uint8_t)); + *streamPtrPtr += ((inlineUniformBlockCount)) * sizeof(uint8_t); + } + if (watchdog) { + size_t watchdogBufSize = std::min<size_t>( + static_cast<size_t>(packetSize_vkUpdateDescriptorSetWithTemplateSized2GOOGLE), + kWatchdogBufferMax); + healthMonitorAnnotation_packetContents.resize(watchdogBufSize); + memcpy(&healthMonitorAnnotation_packetContents[0], packetBeginPtr, watchdogBufSize); + } + stream->flush(); + ++encodeCount; + ; + if (0 == encodeCount % POOL_CLEAR_INTERVAL) { + pool->freeAll(); + stream->clearPool(); + } + if (!queueSubmitWithCommandsEnabled && doLock) this->unlock(); +} + +void VkEncoder::vkQueueSubmitAsync2GOOGLE(VkQueue queue, uint32_t submitCount, + const VkSubmitInfo2* pSubmits, VkFence fence, + uint32_t doLock) { + std::optional<uint32_t> healthMonitorAnnotation_seqno = std::nullopt; + std::optional<uint32_t> healthMonitorAnnotation_packetSize = std::nullopt; + std::vector<uint8_t> healthMonitorAnnotation_packetContents; + + auto watchdog = + WATCHDOG_BUILDER(mHealthMonitor, "vkQueueSubmitAsync2GOOGLE in VkEncoder") + .setOnHangCallback([&]() { + auto annotations = std::make_unique<EventHangMetadata::HangAnnotations>(); + if (healthMonitorAnnotation_seqno) { + annotations->insert( + {{"seqno", std::to_string(healthMonitorAnnotation_seqno.value())}}); + } + if (healthMonitorAnnotation_packetSize) { + annotations->insert( + {{"packetSize", + std::to_string(healthMonitorAnnotation_packetSize.value())}}); + } + if (!healthMonitorAnnotation_packetContents.empty()) { + annotations->insert( + {{"packetContents", + getPacketContents(&healthMonitorAnnotation_packetContents[0], + healthMonitorAnnotation_packetContents.size())}}); + } + return std::move(annotations); + }) + .build(); + + ENCODER_DEBUG_LOG("vkQueueSubmitAsync2GOOGLE(queue:%p, submitCount:%d, pSubmits:%p, fence:%p)", + queue, submitCount, pSubmits, fence); + (void)doLock; + bool queueSubmitWithCommandsEnabled = + sFeatureBits & VULKAN_STREAM_FEATURE_QUEUE_SUBMIT_WITH_COMMANDS_BIT; + if (!queueSubmitWithCommandsEnabled && doLock) this->lock(); + auto stream = mImpl->stream(); + auto pool = mImpl->pool(); + VkQueue local_queue; + uint32_t local_submitCount; + VkSubmitInfo2* local_pSubmits; + VkFence local_fence; + local_queue = queue; + local_submitCount = submitCount; + local_pSubmits = nullptr; + if (pSubmits) { + local_pSubmits = (VkSubmitInfo2*)pool->alloc(((submitCount)) * sizeof(const VkSubmitInfo2)); + for (uint32_t i = 0; i < (uint32_t)((submitCount)); ++i) { + deepcopy_VkSubmitInfo2(pool, VK_STRUCTURE_TYPE_MAX_ENUM, pSubmits + i, + (VkSubmitInfo2*)(local_pSubmits + i)); + } + } + local_fence = fence; + if (local_pSubmits) { + for (uint32_t i = 0; i < (uint32_t)((submitCount)); ++i) { + transform_tohost_VkSubmitInfo2(sResourceTracker, (VkSubmitInfo2*)(local_pSubmits + i)); + } + } + size_t count = 0; + size_t* countPtr = &count; + { + uint64_t cgen_var_0; + *countPtr += 1 * 8; + *countPtr += sizeof(uint32_t); + for (uint32_t i = 0; i < (uint32_t)((submitCount)); ++i) { + count_VkSubmitInfo2(sFeatureBits, VK_STRUCTURE_TYPE_MAX_ENUM, + (VkSubmitInfo2*)(local_pSubmits + i), countPtr); + } + uint64_t cgen_var_1; + *countPtr += 1 * 8; + } + uint32_t packetSize_vkQueueSubmitAsync2GOOGLE = + 4 + 4 + (queueSubmitWithCommandsEnabled ? 4 : 0) + count; + healthMonitorAnnotation_packetSize = std::make_optional(packetSize_vkQueueSubmitAsync2GOOGLE); + uint8_t* streamPtr = stream->reserve(packetSize_vkQueueSubmitAsync2GOOGLE); + uint8_t* packetBeginPtr = streamPtr; + uint8_t** streamPtrPtr = &streamPtr; + uint32_t opcode_vkQueueSubmitAsync2GOOGLE = OP_vkQueueSubmitAsync2GOOGLE; + uint32_t seqno; + if (queueSubmitWithCommandsEnabled) seqno = ResourceTracker::nextSeqno(); + healthMonitorAnnotation_seqno = std::make_optional(seqno); + memcpy(streamPtr, &opcode_vkQueueSubmitAsync2GOOGLE, sizeof(uint32_t)); + streamPtr += sizeof(uint32_t); + memcpy(streamPtr, &packetSize_vkQueueSubmitAsync2GOOGLE, sizeof(uint32_t)); + streamPtr += sizeof(uint32_t); + if (queueSubmitWithCommandsEnabled) { + memcpy(streamPtr, &seqno, sizeof(uint32_t)); + streamPtr += sizeof(uint32_t); + } + uint64_t cgen_var_0; + *&cgen_var_0 = get_host_u64_VkQueue((*&local_queue)); + memcpy(*streamPtrPtr, (uint64_t*)&cgen_var_0, 1 * 8); + *streamPtrPtr += 1 * 8; + memcpy(*streamPtrPtr, (uint32_t*)&local_submitCount, sizeof(uint32_t)); + *streamPtrPtr += sizeof(uint32_t); + for (uint32_t i = 0; i < (uint32_t)((submitCount)); ++i) { + reservedmarshal_VkSubmitInfo2(stream, VK_STRUCTURE_TYPE_MAX_ENUM, + (VkSubmitInfo2*)(local_pSubmits + i), streamPtrPtr); + } + uint64_t cgen_var_1; + *&cgen_var_1 = get_host_u64_VkFence((*&local_fence)); + memcpy(*streamPtrPtr, (uint64_t*)&cgen_var_1, 1 * 8); + *streamPtrPtr += 1 * 8; + if (watchdog) { + size_t watchdogBufSize = std::min<size_t>( + static_cast<size_t>(packetSize_vkQueueSubmitAsync2GOOGLE), kWatchdogBufferMax); + healthMonitorAnnotation_packetContents.resize(watchdogBufSize); + memcpy(&healthMonitorAnnotation_packetContents[0], packetBeginPtr, watchdogBufSize); + } + stream->flush(); + ++encodeCount; + ; + if (0 == encodeCount % POOL_CLEAR_INTERVAL) { + pool->freeAll(); + stream->clearPool(); + } + if (!queueSubmitWithCommandsEnabled && doLock) this->unlock(); +} + #endif #ifdef VK_EXT_global_priority_query #endif diff --git a/system/vulkan_enc/VkEncoder.h b/system/vulkan_enc/VkEncoder.h index a04660fa..c2dc6730 100644 --- a/system/vulkan_enc/VkEncoder.h +++ b/system/vulkan_enc/VkEncoder.h @@ -37,10 +37,9 @@ #include "goldfish_vk_private_defs.h" #include "vulkan_gfxstream.h" -// ToT and udc-dev defines IOStream in different namespace // namespace gfxstream { class IOStream; -// } +//} namespace gfxstream { namespace vk { @@ -2227,6 +2226,16 @@ class VkEncoder { VkDeviceSize dataOffset, VkDeviceSize dataSize, uint32_t doLock); VkResult vkGetBlobGOOGLE(VkDevice device, VkDeviceMemory memory, uint32_t doLock); + void vkUpdateDescriptorSetWithTemplateSized2GOOGLE( + VkDevice device, VkDescriptorSet descriptorSet, + VkDescriptorUpdateTemplate descriptorUpdateTemplate, uint32_t imageInfoCount, + uint32_t bufferInfoCount, uint32_t bufferViewCount, uint32_t inlineUniformBlockCount, + const uint32_t* pImageInfoEntryIndices, const uint32_t* pBufferInfoEntryIndices, + const uint32_t* pBufferViewEntryIndices, const VkDescriptorImageInfo* pImageInfos, + const VkDescriptorBufferInfo* pBufferInfos, const VkBufferView* pBufferViews, + const uint8_t* pInlineUniformBlockData, uint32_t doLock); + void vkQueueSubmitAsync2GOOGLE(VkQueue queue, uint32_t submitCount, + const VkSubmitInfo2* pSubmits, VkFence fence, uint32_t doLock); #endif #ifdef VK_EXT_global_priority_query #endif diff --git a/system/vulkan_enc/func_table.cpp b/system/vulkan_enc/func_table.cpp index 4dc556eb..b66d9626 100644 --- a/system/vulkan_enc/func_table.cpp +++ b/system/vulkan_enc/func_table.cpp @@ -45,6 +45,9 @@ // required extensions, but the approach will be to // implement them completely on the guest side. #undef VK_KHR_android_surface +#if defined(LINUX_GUEST_BUILD) +#undef VK_ANDROID_native_buffer +#endif namespace gfxstream { namespace vk { @@ -1561,8 +1564,9 @@ static void entry_vkGetPhysicalDeviceExternalBufferProperties( VkExternalBufferProperties* pExternalBufferProperties) { AEMU_SCOPED_TRACE("vkGetPhysicalDeviceExternalBufferProperties"); auto vkEnc = ResourceTracker::getThreadLocalEncoder(); - vkEnc->vkGetPhysicalDeviceExternalBufferProperties( - physicalDevice, pExternalBufferInfo, pExternalBufferProperties, true /* do lock */); + auto resources = ResourceTracker::get(); + resources->on_vkGetPhysicalDeviceExternalBufferProperties( + vkEnc, physicalDevice, pExternalBufferInfo, pExternalBufferProperties); } static void entry_vkGetPhysicalDeviceExternalFenceProperties( VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, @@ -1637,7 +1641,7 @@ static VkResult dynCheck_entry_vkCreateRenderPass2(VkDevice device, const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass) { auto resources = ResourceTracker::get(); - if (!resources->hasDeviceExtension(device, "VK_VERSION_1_2")) { + if (resources->getApiVersionFromDevice(device) < VK_API_VERSION_1_2) { sOnInvalidDynamicallyCheckedCall("vkCreateRenderPass2", "VK_VERSION_1_2"); } AEMU_SCOPED_TRACE("vkCreateRenderPass2"); @@ -1677,7 +1681,7 @@ static void entry_vkResetQueryPool(VkDevice device, VkQueryPool queryPool, uint3 static void dynCheck_entry_vkResetQueryPool(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount) { auto resources = ResourceTracker::get(); - if (!resources->hasDeviceExtension(device, "VK_VERSION_1_2")) { + if (resources->getApiVersionFromDevice(device) < VK_API_VERSION_1_2) { sOnInvalidDynamicallyCheckedCall("vkResetQueryPool", "VK_VERSION_1_2"); } AEMU_SCOPED_TRACE("vkResetQueryPool"); @@ -1696,7 +1700,7 @@ static VkResult entry_vkGetSemaphoreCounterValue(VkDevice device, VkSemaphore se static VkResult dynCheck_entry_vkGetSemaphoreCounterValue(VkDevice device, VkSemaphore semaphore, uint64_t* pValue) { auto resources = ResourceTracker::get(); - if (!resources->hasDeviceExtension(device, "VK_VERSION_1_2")) { + if (resources->getApiVersionFromDevice(device) < VK_API_VERSION_1_2) { sOnInvalidDynamicallyCheckedCall("vkGetSemaphoreCounterValue", "VK_VERSION_1_2"); } AEMU_SCOPED_TRACE("vkGetSemaphoreCounterValue"); @@ -1719,7 +1723,7 @@ static VkResult dynCheck_entry_vkWaitSemaphores(VkDevice device, const VkSemaphoreWaitInfo* pWaitInfo, uint64_t timeout) { auto resources = ResourceTracker::get(); - if (!resources->hasDeviceExtension(device, "VK_VERSION_1_2")) { + if (resources->getApiVersionFromDevice(device) < VK_API_VERSION_1_2) { sOnInvalidDynamicallyCheckedCall("vkWaitSemaphores", "VK_VERSION_1_2"); } AEMU_SCOPED_TRACE("vkWaitSemaphores"); @@ -1740,7 +1744,7 @@ static VkResult entry_vkSignalSemaphore(VkDevice device, const VkSemaphoreSignal static VkResult dynCheck_entry_vkSignalSemaphore(VkDevice device, const VkSemaphoreSignalInfo* pSignalInfo) { auto resources = ResourceTracker::get(); - if (!resources->hasDeviceExtension(device, "VK_VERSION_1_2")) { + if (resources->getApiVersionFromDevice(device) < VK_API_VERSION_1_2) { sOnInvalidDynamicallyCheckedCall("vkSignalSemaphore", "VK_VERSION_1_2"); } AEMU_SCOPED_TRACE("vkSignalSemaphore"); @@ -1762,7 +1766,7 @@ static VkDeviceAddress entry_vkGetBufferDeviceAddress(VkDevice device, static VkDeviceAddress dynCheck_entry_vkGetBufferDeviceAddress( VkDevice device, const VkBufferDeviceAddressInfo* pInfo) { auto resources = ResourceTracker::get(); - if (!resources->hasDeviceExtension(device, "VK_VERSION_1_2")) { + if (resources->getApiVersionFromDevice(device) < VK_API_VERSION_1_2) { sOnInvalidDynamicallyCheckedCall("vkGetBufferDeviceAddress", "VK_VERSION_1_2"); } AEMU_SCOPED_TRACE("vkGetBufferDeviceAddress"); @@ -1784,7 +1788,7 @@ static uint64_t entry_vkGetBufferOpaqueCaptureAddress(VkDevice device, static uint64_t dynCheck_entry_vkGetBufferOpaqueCaptureAddress( VkDevice device, const VkBufferDeviceAddressInfo* pInfo) { auto resources = ResourceTracker::get(); - if (!resources->hasDeviceExtension(device, "VK_VERSION_1_2")) { + if (resources->getApiVersionFromDevice(device) < VK_API_VERSION_1_2) { sOnInvalidDynamicallyCheckedCall("vkGetBufferOpaqueCaptureAddress", "VK_VERSION_1_2"); } AEMU_SCOPED_TRACE("vkGetBufferOpaqueCaptureAddress"); @@ -1806,7 +1810,7 @@ static uint64_t entry_vkGetDeviceMemoryOpaqueCaptureAddress( static uint64_t dynCheck_entry_vkGetDeviceMemoryOpaqueCaptureAddress( VkDevice device, const VkDeviceMemoryOpaqueCaptureAddressInfo* pInfo) { auto resources = ResourceTracker::get(); - if (!resources->hasDeviceExtension(device, "VK_VERSION_1_2")) { + if (resources->getApiVersionFromDevice(device) < VK_API_VERSION_1_2) { sOnInvalidDynamicallyCheckedCall("vkGetDeviceMemoryOpaqueCaptureAddress", "VK_VERSION_1_2"); } AEMU_SCOPED_TRACE("vkGetDeviceMemoryOpaqueCaptureAddress"); @@ -1843,7 +1847,7 @@ static VkResult dynCheck_entry_vkCreatePrivateDataSlot( VkDevice device, const VkPrivateDataSlotCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPrivateDataSlot* pPrivateDataSlot) { auto resources = ResourceTracker::get(); - if (!resources->hasDeviceExtension(device, "VK_VERSION_1_3")) { + if (resources->getApiVersionFromDevice(device) < VK_API_VERSION_1_3) { sOnInvalidDynamicallyCheckedCall("vkCreatePrivateDataSlot", "VK_VERSION_1_3"); } AEMU_SCOPED_TRACE("vkCreatePrivateDataSlot"); @@ -1863,7 +1867,7 @@ static void dynCheck_entry_vkDestroyPrivateDataSlot(VkDevice device, VkPrivateDataSlot privateDataSlot, const VkAllocationCallbacks* pAllocator) { auto resources = ResourceTracker::get(); - if (!resources->hasDeviceExtension(device, "VK_VERSION_1_3")) { + if (resources->getApiVersionFromDevice(device) < VK_API_VERSION_1_3) { sOnInvalidDynamicallyCheckedCall("vkDestroyPrivateDataSlot", "VK_VERSION_1_3"); } AEMU_SCOPED_TRACE("vkDestroyPrivateDataSlot"); @@ -1884,7 +1888,7 @@ static VkResult dynCheck_entry_vkSetPrivateData(VkDevice device, VkObjectType ob uint64_t objectHandle, VkPrivateDataSlot privateDataSlot, uint64_t data) { auto resources = ResourceTracker::get(); - if (!resources->hasDeviceExtension(device, "VK_VERSION_1_3")) { + if (resources->getApiVersionFromDevice(device) < VK_API_VERSION_1_3) { sOnInvalidDynamicallyCheckedCall("vkSetPrivateData", "VK_VERSION_1_3"); } AEMU_SCOPED_TRACE("vkSetPrivateData"); @@ -1905,7 +1909,7 @@ static void dynCheck_entry_vkGetPrivateData(VkDevice device, VkObjectType object uint64_t objectHandle, VkPrivateDataSlot privateDataSlot, uint64_t* pData) { auto resources = ResourceTracker::get(); - if (!resources->hasDeviceExtension(device, "VK_VERSION_1_3")) { + if (resources->getApiVersionFromDevice(device) < VK_API_VERSION_1_3) { sOnInvalidDynamicallyCheckedCall("vkGetPrivateData", "VK_VERSION_1_3"); } AEMU_SCOPED_TRACE("vkGetPrivateData"); @@ -1950,8 +1954,9 @@ static VkResult entry_vkQueueSubmit2(VkQueue queue, uint32_t submitCount, AEMU_SCOPED_TRACE("vkQueueSubmit2"); auto vkEnc = ResourceTracker::getQueueEncoder(queue); VkResult vkQueueSubmit2_VkResult_return = (VkResult)0; + auto resources = ResourceTracker::get(); vkQueueSubmit2_VkResult_return = - vkEnc->vkQueueSubmit2(queue, submitCount, pSubmits, fence, true /* do lock */); + resources->on_vkQueueSubmit2(vkEnc, VK_SUCCESS, queue, submitCount, pSubmits, fence); return vkQueueSubmit2_VkResult_return; } static void entry_vkCmdCopyBuffer2(VkCommandBuffer commandBuffer, @@ -2106,7 +2111,7 @@ static void dynCheck_entry_vkGetDeviceBufferMemoryRequirements( VkDevice device, const VkDeviceBufferMemoryRequirements* pInfo, VkMemoryRequirements2* pMemoryRequirements) { auto resources = ResourceTracker::get(); - if (!resources->hasDeviceExtension(device, "VK_VERSION_1_3")) { + if (resources->getApiVersionFromDevice(device) < VK_API_VERSION_1_3) { sOnInvalidDynamicallyCheckedCall("vkGetDeviceBufferMemoryRequirements", "VK_VERSION_1_3"); } AEMU_SCOPED_TRACE("vkGetDeviceBufferMemoryRequirements"); @@ -2126,7 +2131,7 @@ static void dynCheck_entry_vkGetDeviceImageMemoryRequirements( VkDevice device, const VkDeviceImageMemoryRequirements* pInfo, VkMemoryRequirements2* pMemoryRequirements) { auto resources = ResourceTracker::get(); - if (!resources->hasDeviceExtension(device, "VK_VERSION_1_3")) { + if (resources->getApiVersionFromDevice(device) < VK_API_VERSION_1_3) { sOnInvalidDynamicallyCheckedCall("vkGetDeviceImageMemoryRequirements", "VK_VERSION_1_3"); } AEMU_SCOPED_TRACE("vkGetDeviceImageMemoryRequirements"); @@ -2148,7 +2153,7 @@ static void dynCheck_entry_vkGetDeviceImageSparseMemoryRequirements( uint32_t* pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2* pSparseMemoryRequirements) { auto resources = ResourceTracker::get(); - if (!resources->hasDeviceExtension(device, "VK_VERSION_1_3")) { + if (resources->getApiVersionFromDevice(device) < VK_API_VERSION_1_3) { sOnInvalidDynamicallyCheckedCall("vkGetDeviceImageSparseMemoryRequirements", "VK_VERSION_1_3"); } @@ -9327,6 +9332,49 @@ static VkResult dynCheck_entry_vkGetBlobGOOGLE(VkDevice device, VkDeviceMemory m vkGetBlobGOOGLE_VkResult_return = vkEnc->vkGetBlobGOOGLE(device, memory, true /* do lock */); return vkGetBlobGOOGLE_VkResult_return; } +static void entry_vkUpdateDescriptorSetWithTemplateSized2GOOGLE( + VkDevice device, VkDescriptorSet descriptorSet, + VkDescriptorUpdateTemplate descriptorUpdateTemplate, uint32_t imageInfoCount, + uint32_t bufferInfoCount, uint32_t bufferViewCount, uint32_t inlineUniformBlockCount, + const uint32_t* pImageInfoEntryIndices, const uint32_t* pBufferInfoEntryIndices, + const uint32_t* pBufferViewEntryIndices, const VkDescriptorImageInfo* pImageInfos, + const VkDescriptorBufferInfo* pBufferInfos, const VkBufferView* pBufferViews, + const uint8_t* pInlineUniformBlockData) { + AEMU_SCOPED_TRACE("vkUpdateDescriptorSetWithTemplateSized2GOOGLE"); + auto vkEnc = ResourceTracker::getThreadLocalEncoder(); + vkEnc->vkUpdateDescriptorSetWithTemplateSized2GOOGLE( + device, descriptorSet, descriptorUpdateTemplate, imageInfoCount, bufferInfoCount, + bufferViewCount, inlineUniformBlockCount, pImageInfoEntryIndices, pBufferInfoEntryIndices, + pBufferViewEntryIndices, pImageInfos, pBufferInfos, pBufferViews, pInlineUniformBlockData, + true /* do lock */); +} +static void dynCheck_entry_vkUpdateDescriptorSetWithTemplateSized2GOOGLE( + VkDevice device, VkDescriptorSet descriptorSet, + VkDescriptorUpdateTemplate descriptorUpdateTemplate, uint32_t imageInfoCount, + uint32_t bufferInfoCount, uint32_t bufferViewCount, uint32_t inlineUniformBlockCount, + const uint32_t* pImageInfoEntryIndices, const uint32_t* pBufferInfoEntryIndices, + const uint32_t* pBufferViewEntryIndices, const VkDescriptorImageInfo* pImageInfos, + const VkDescriptorBufferInfo* pBufferInfos, const VkBufferView* pBufferViews, + const uint8_t* pInlineUniformBlockData) { + auto resources = ResourceTracker::get(); + if (!resources->hasDeviceExtension(device, "VK_GOOGLE_gfxstream")) { + sOnInvalidDynamicallyCheckedCall("vkUpdateDescriptorSetWithTemplateSized2GOOGLE", + "VK_GOOGLE_gfxstream"); + } + AEMU_SCOPED_TRACE("vkUpdateDescriptorSetWithTemplateSized2GOOGLE"); + auto vkEnc = ResourceTracker::getThreadLocalEncoder(); + vkEnc->vkUpdateDescriptorSetWithTemplateSized2GOOGLE( + device, descriptorSet, descriptorUpdateTemplate, imageInfoCount, bufferInfoCount, + bufferViewCount, inlineUniformBlockCount, pImageInfoEntryIndices, pBufferInfoEntryIndices, + pBufferViewEntryIndices, pImageInfos, pBufferInfos, pBufferViews, pInlineUniformBlockData, + true /* do lock */); +} +static void entry_vkQueueSubmitAsync2GOOGLE(VkQueue queue, uint32_t submitCount, + const VkSubmitInfo2* pSubmits, VkFence fence) { + AEMU_SCOPED_TRACE("vkQueueSubmitAsync2GOOGLE"); + auto vkEnc = ResourceTracker::getQueueEncoder(queue); + vkEnc->vkQueueSubmitAsync2GOOGLE(queue, submitCount, pSubmits, fence, true /* do lock */); +} #endif #ifdef VK_EXT_global_priority_query #endif @@ -13467,6 +13515,12 @@ void* goldfish_vulkan_get_proc_address(const char* name) { if (!strcmp(name, "vkGetBlobGOOGLE")) { return nullptr; } + if (!strcmp(name, "vkUpdateDescriptorSetWithTemplateSized2GOOGLE")) { + return nullptr; + } + if (!strcmp(name, "vkQueueSubmitAsync2GOOGLE")) { + return nullptr; + } #endif #ifdef VK_EXT_multi_draw if (!strcmp(name, "vkCmdDrawMultiEXT")) { @@ -13791,6 +13845,7 @@ void* goldfish_vulkan_get_instance_proc_address(VkInstance instance, const char* auto resources = ResourceTracker::get(); bool has1_1OrHigher = resources->getApiVersionFromInstance(instance) >= VK_API_VERSION_1_1; bool has1_2OrHigher = resources->getApiVersionFromInstance(instance) >= VK_API_VERSION_1_2; + bool has1_3OrHigher = resources->getApiVersionFromInstance(instance) >= VK_API_VERSION_1_3; #ifdef VK_VERSION_1_0 if (!strcmp(name, "vkCreateInstance")) { return (void*)entry_vkCreateInstance; @@ -14335,151 +14390,114 @@ void* goldfish_vulkan_get_instance_proc_address(VkInstance instance, const char* #endif #ifdef VK_VERSION_1_3 if (!strcmp(name, "vkGetPhysicalDeviceToolProperties")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkGetPhysicalDeviceToolProperties; + return has1_3OrHigher ? (void*)entry_vkGetPhysicalDeviceToolProperties : nullptr; } if (!strcmp(name, "vkCreatePrivateDataSlot")) { - // TODO(b/236246382): Check support for device extension; return (void*)dynCheck_entry_vkCreatePrivateDataSlot; } if (!strcmp(name, "vkDestroyPrivateDataSlot")) { - // TODO(b/236246382): Check support for device extension; return (void*)dynCheck_entry_vkDestroyPrivateDataSlot; } if (!strcmp(name, "vkSetPrivateData")) { - // TODO(b/236246382): Check support for device extension; return (void*)dynCheck_entry_vkSetPrivateData; } if (!strcmp(name, "vkGetPrivateData")) { - // TODO(b/236246382): Check support for device extension; return (void*)dynCheck_entry_vkGetPrivateData; } if (!strcmp(name, "vkCmdSetEvent2")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdSetEvent2; + return has1_3OrHigher ? (void*)entry_vkCmdSetEvent2 : nullptr; } if (!strcmp(name, "vkCmdResetEvent2")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdResetEvent2; + return has1_3OrHigher ? (void*)entry_vkCmdResetEvent2 : nullptr; } if (!strcmp(name, "vkCmdWaitEvents2")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdWaitEvents2; + return has1_3OrHigher ? (void*)entry_vkCmdWaitEvents2 : nullptr; } if (!strcmp(name, "vkCmdPipelineBarrier2")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdPipelineBarrier2; + return has1_3OrHigher ? (void*)entry_vkCmdPipelineBarrier2 : nullptr; } if (!strcmp(name, "vkCmdWriteTimestamp2")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdWriteTimestamp2; + return has1_3OrHigher ? (void*)entry_vkCmdWriteTimestamp2 : nullptr; } if (!strcmp(name, "vkQueueSubmit2")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkQueueSubmit2; + return has1_3OrHigher ? (void*)entry_vkQueueSubmit2 : nullptr; } if (!strcmp(name, "vkCmdCopyBuffer2")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdCopyBuffer2; + return has1_3OrHigher ? (void*)entry_vkCmdCopyBuffer2 : nullptr; } if (!strcmp(name, "vkCmdCopyImage2")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdCopyImage2; + return has1_3OrHigher ? (void*)entry_vkCmdCopyImage2 : nullptr; } if (!strcmp(name, "vkCmdCopyBufferToImage2")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdCopyBufferToImage2; + return has1_3OrHigher ? (void*)entry_vkCmdCopyBufferToImage2 : nullptr; } if (!strcmp(name, "vkCmdCopyImageToBuffer2")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdCopyImageToBuffer2; + return has1_3OrHigher ? (void*)entry_vkCmdCopyImageToBuffer2 : nullptr; } if (!strcmp(name, "vkCmdBlitImage2")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdBlitImage2; + return has1_3OrHigher ? (void*)entry_vkCmdBlitImage2 : nullptr; } if (!strcmp(name, "vkCmdResolveImage2")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdResolveImage2; + return has1_3OrHigher ? (void*)entry_vkCmdResolveImage2 : nullptr; } if (!strcmp(name, "vkCmdBeginRendering")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdBeginRendering; + return has1_3OrHigher ? (void*)entry_vkCmdBeginRendering : nullptr; } if (!strcmp(name, "vkCmdEndRendering")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdEndRendering; + return has1_3OrHigher ? (void*)entry_vkCmdEndRendering : nullptr; } if (!strcmp(name, "vkCmdSetCullMode")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdSetCullMode; + return has1_3OrHigher ? (void*)entry_vkCmdSetCullMode : nullptr; } if (!strcmp(name, "vkCmdSetFrontFace")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdSetFrontFace; + return has1_3OrHigher ? (void*)entry_vkCmdSetFrontFace : nullptr; } if (!strcmp(name, "vkCmdSetPrimitiveTopology")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdSetPrimitiveTopology; + return has1_3OrHigher ? (void*)entry_vkCmdSetPrimitiveTopology : nullptr; } if (!strcmp(name, "vkCmdSetViewportWithCount")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdSetViewportWithCount; + return has1_3OrHigher ? (void*)entry_vkCmdSetViewportWithCount : nullptr; } if (!strcmp(name, "vkCmdSetScissorWithCount")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdSetScissorWithCount; + return has1_3OrHigher ? (void*)entry_vkCmdSetScissorWithCount : nullptr; } if (!strcmp(name, "vkCmdBindVertexBuffers2")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdBindVertexBuffers2; + return has1_3OrHigher ? (void*)entry_vkCmdBindVertexBuffers2 : nullptr; } if (!strcmp(name, "vkCmdSetDepthTestEnable")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdSetDepthTestEnable; + return has1_3OrHigher ? (void*)entry_vkCmdSetDepthTestEnable : nullptr; } if (!strcmp(name, "vkCmdSetDepthWriteEnable")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdSetDepthWriteEnable; + return has1_3OrHigher ? (void*)entry_vkCmdSetDepthWriteEnable : nullptr; } if (!strcmp(name, "vkCmdSetDepthCompareOp")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdSetDepthCompareOp; + return has1_3OrHigher ? (void*)entry_vkCmdSetDepthCompareOp : nullptr; } if (!strcmp(name, "vkCmdSetDepthBoundsTestEnable")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdSetDepthBoundsTestEnable; + return has1_3OrHigher ? (void*)entry_vkCmdSetDepthBoundsTestEnable : nullptr; } if (!strcmp(name, "vkCmdSetStencilTestEnable")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdSetStencilTestEnable; + return has1_3OrHigher ? (void*)entry_vkCmdSetStencilTestEnable : nullptr; } if (!strcmp(name, "vkCmdSetStencilOp")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdSetStencilOp; + return has1_3OrHigher ? (void*)entry_vkCmdSetStencilOp : nullptr; } if (!strcmp(name, "vkCmdSetRasterizerDiscardEnable")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdSetRasterizerDiscardEnable; + return has1_3OrHigher ? (void*)entry_vkCmdSetRasterizerDiscardEnable : nullptr; } if (!strcmp(name, "vkCmdSetDepthBiasEnable")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdSetDepthBiasEnable; + return has1_3OrHigher ? (void*)entry_vkCmdSetDepthBiasEnable : nullptr; } if (!strcmp(name, "vkCmdSetPrimitiveRestartEnable")) { - // TODO(b/236246382): Check support for device extension; - return (void*)entry_vkCmdSetPrimitiveRestartEnable; + return has1_3OrHigher ? (void*)entry_vkCmdSetPrimitiveRestartEnable : nullptr; } if (!strcmp(name, "vkGetDeviceBufferMemoryRequirements")) { - // TODO(b/236246382): Check support for device extension; return (void*)dynCheck_entry_vkGetDeviceBufferMemoryRequirements; } if (!strcmp(name, "vkGetDeviceImageMemoryRequirements")) { - // TODO(b/236246382): Check support for device extension; return (void*)dynCheck_entry_vkGetDeviceImageMemoryRequirements; } if (!strcmp(name, "vkGetDeviceImageSparseMemoryRequirements")) { - // TODO(b/236246382): Check support for device extension; return (void*)dynCheck_entry_vkGetDeviceImageSparseMemoryRequirements; } #endif @@ -16140,6 +16158,15 @@ void* goldfish_vulkan_get_instance_proc_address(VkInstance instance, const char* bool hasExt = resources->hasInstanceExtension(instance, "VK_GOOGLE_gfxstream"); return hasExt ? (void*)dynCheck_entry_vkGetBlobGOOGLE : nullptr; } + if (!strcmp(name, "vkUpdateDescriptorSetWithTemplateSized2GOOGLE")) { + bool hasExt = resources->hasInstanceExtension(instance, "VK_GOOGLE_gfxstream"); + return hasExt ? (void*)dynCheck_entry_vkUpdateDescriptorSetWithTemplateSized2GOOGLE + : nullptr; + } + if (!strcmp(name, "vkQueueSubmitAsync2GOOGLE")) { + bool hasExt = resources->hasInstanceExtension(instance, "VK_GOOGLE_gfxstream"); + return hasExt ? (void*)entry_vkQueueSubmitAsync2GOOGLE : nullptr; + } #endif #ifdef VK_EXT_multi_draw if (!strcmp(name, "vkCmdDrawMultiEXT")) { @@ -16558,6 +16585,8 @@ void* goldfish_vulkan_get_instance_proc_address(VkInstance instance, const char* void* goldfish_vulkan_get_device_proc_address(VkDevice device, const char* name) { auto resources = ResourceTracker::get(); bool has1_1OrHigher = resources->getApiVersionFromDevice(device) >= VK_API_VERSION_1_1; + bool has1_2OrHigher = resources->getApiVersionFromDevice(device) >= VK_API_VERSION_1_2; + bool has1_3OrHigher = resources->getApiVersionFromDevice(device) >= VK_API_VERSION_1_3; #ifdef VK_VERSION_1_0 if (!strcmp(name, "vkCreateInstance")) { return (void*)entry_vkCreateInstance; @@ -17061,206 +17090,156 @@ void* goldfish_vulkan_get_device_proc_address(VkDevice device, const char* name) #endif #ifdef VK_VERSION_1_2 if (!strcmp(name, "vkCmdDrawIndirectCount")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_2"); - return hasExt ? (void*)entry_vkCmdDrawIndirectCount : nullptr; + return has1_2OrHigher ? (void*)entry_vkCmdDrawIndirectCount : nullptr; } if (!strcmp(name, "vkCmdDrawIndexedIndirectCount")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_2"); - return hasExt ? (void*)entry_vkCmdDrawIndexedIndirectCount : nullptr; + return has1_2OrHigher ? (void*)entry_vkCmdDrawIndexedIndirectCount : nullptr; } if (!strcmp(name, "vkCreateRenderPass2")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_2"); - return hasExt ? (void*)entry_vkCreateRenderPass2 : nullptr; + return has1_2OrHigher ? (void*)entry_vkCreateRenderPass2 : nullptr; } if (!strcmp(name, "vkCmdBeginRenderPass2")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_2"); - return hasExt ? (void*)entry_vkCmdBeginRenderPass2 : nullptr; + return has1_2OrHigher ? (void*)entry_vkCmdBeginRenderPass2 : nullptr; } if (!strcmp(name, "vkCmdNextSubpass2")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_2"); - return hasExt ? (void*)entry_vkCmdNextSubpass2 : nullptr; + return has1_2OrHigher ? (void*)entry_vkCmdNextSubpass2 : nullptr; } if (!strcmp(name, "vkCmdEndRenderPass2")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_2"); - return hasExt ? (void*)entry_vkCmdEndRenderPass2 : nullptr; + return has1_2OrHigher ? (void*)entry_vkCmdEndRenderPass2 : nullptr; } if (!strcmp(name, "vkResetQueryPool")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_2"); - return hasExt ? (void*)entry_vkResetQueryPool : nullptr; + return has1_2OrHigher ? (void*)entry_vkResetQueryPool : nullptr; } if (!strcmp(name, "vkGetSemaphoreCounterValue")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_2"); - return hasExt ? (void*)entry_vkGetSemaphoreCounterValue : nullptr; + return has1_2OrHigher ? (void*)entry_vkGetSemaphoreCounterValue : nullptr; } if (!strcmp(name, "vkWaitSemaphores")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_2"); - return hasExt ? (void*)entry_vkWaitSemaphores : nullptr; + return has1_2OrHigher ? (void*)entry_vkWaitSemaphores : nullptr; } if (!strcmp(name, "vkSignalSemaphore")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_2"); - return hasExt ? (void*)entry_vkSignalSemaphore : nullptr; + return has1_2OrHigher ? (void*)entry_vkSignalSemaphore : nullptr; } if (!strcmp(name, "vkGetBufferDeviceAddress")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_2"); - return hasExt ? (void*)entry_vkGetBufferDeviceAddress : nullptr; + return has1_2OrHigher ? (void*)entry_vkGetBufferDeviceAddress : nullptr; } if (!strcmp(name, "vkGetBufferOpaqueCaptureAddress")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_2"); - return hasExt ? (void*)entry_vkGetBufferOpaqueCaptureAddress : nullptr; + return has1_2OrHigher ? (void*)entry_vkGetBufferOpaqueCaptureAddress : nullptr; } if (!strcmp(name, "vkGetDeviceMemoryOpaqueCaptureAddress")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_2"); - return hasExt ? (void*)entry_vkGetDeviceMemoryOpaqueCaptureAddress : nullptr; + return has1_2OrHigher ? (void*)entry_vkGetDeviceMemoryOpaqueCaptureAddress : nullptr; } #endif #ifdef VK_VERSION_1_3 if (!strcmp(name, "vkGetPhysicalDeviceToolProperties")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkGetPhysicalDeviceToolProperties : nullptr; + return has1_3OrHigher ? (void*)entry_vkGetPhysicalDeviceToolProperties : nullptr; } if (!strcmp(name, "vkCreatePrivateDataSlot")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCreatePrivateDataSlot : nullptr; + return has1_3OrHigher ? (void*)entry_vkCreatePrivateDataSlot : nullptr; } if (!strcmp(name, "vkDestroyPrivateDataSlot")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkDestroyPrivateDataSlot : nullptr; + return has1_3OrHigher ? (void*)entry_vkDestroyPrivateDataSlot : nullptr; } if (!strcmp(name, "vkSetPrivateData")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkSetPrivateData : nullptr; + return has1_3OrHigher ? (void*)entry_vkSetPrivateData : nullptr; } if (!strcmp(name, "vkGetPrivateData")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkGetPrivateData : nullptr; + return has1_3OrHigher ? (void*)entry_vkGetPrivateData : nullptr; } if (!strcmp(name, "vkCmdSetEvent2")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdSetEvent2 : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdSetEvent2 : nullptr; } if (!strcmp(name, "vkCmdResetEvent2")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdResetEvent2 : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdResetEvent2 : nullptr; } if (!strcmp(name, "vkCmdWaitEvents2")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdWaitEvents2 : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdWaitEvents2 : nullptr; } if (!strcmp(name, "vkCmdPipelineBarrier2")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdPipelineBarrier2 : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdPipelineBarrier2 : nullptr; } if (!strcmp(name, "vkCmdWriteTimestamp2")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdWriteTimestamp2 : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdWriteTimestamp2 : nullptr; } if (!strcmp(name, "vkQueueSubmit2")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkQueueSubmit2 : nullptr; + return has1_3OrHigher ? (void*)entry_vkQueueSubmit2 : nullptr; } if (!strcmp(name, "vkCmdCopyBuffer2")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdCopyBuffer2 : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdCopyBuffer2 : nullptr; } if (!strcmp(name, "vkCmdCopyImage2")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdCopyImage2 : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdCopyImage2 : nullptr; } if (!strcmp(name, "vkCmdCopyBufferToImage2")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdCopyBufferToImage2 : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdCopyBufferToImage2 : nullptr; } if (!strcmp(name, "vkCmdCopyImageToBuffer2")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdCopyImageToBuffer2 : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdCopyImageToBuffer2 : nullptr; } if (!strcmp(name, "vkCmdBlitImage2")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdBlitImage2 : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdBlitImage2 : nullptr; } if (!strcmp(name, "vkCmdResolveImage2")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdResolveImage2 : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdResolveImage2 : nullptr; } if (!strcmp(name, "vkCmdBeginRendering")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdBeginRendering : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdBeginRendering : nullptr; } if (!strcmp(name, "vkCmdEndRendering")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdEndRendering : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdEndRendering : nullptr; } if (!strcmp(name, "vkCmdSetCullMode")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdSetCullMode : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdSetCullMode : nullptr; } if (!strcmp(name, "vkCmdSetFrontFace")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdSetFrontFace : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdSetFrontFace : nullptr; } if (!strcmp(name, "vkCmdSetPrimitiveTopology")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdSetPrimitiveTopology : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdSetPrimitiveTopology : nullptr; } if (!strcmp(name, "vkCmdSetViewportWithCount")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdSetViewportWithCount : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdSetViewportWithCount : nullptr; } if (!strcmp(name, "vkCmdSetScissorWithCount")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdSetScissorWithCount : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdSetScissorWithCount : nullptr; } if (!strcmp(name, "vkCmdBindVertexBuffers2")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdBindVertexBuffers2 : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdBindVertexBuffers2 : nullptr; } if (!strcmp(name, "vkCmdSetDepthTestEnable")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdSetDepthTestEnable : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdSetDepthTestEnable : nullptr; } if (!strcmp(name, "vkCmdSetDepthWriteEnable")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdSetDepthWriteEnable : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdSetDepthWriteEnable : nullptr; } if (!strcmp(name, "vkCmdSetDepthCompareOp")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdSetDepthCompareOp : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdSetDepthCompareOp : nullptr; } if (!strcmp(name, "vkCmdSetDepthBoundsTestEnable")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdSetDepthBoundsTestEnable : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdSetDepthBoundsTestEnable : nullptr; } if (!strcmp(name, "vkCmdSetStencilTestEnable")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdSetStencilTestEnable : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdSetStencilTestEnable : nullptr; } if (!strcmp(name, "vkCmdSetStencilOp")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdSetStencilOp : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdSetStencilOp : nullptr; } if (!strcmp(name, "vkCmdSetRasterizerDiscardEnable")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdSetRasterizerDiscardEnable : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdSetRasterizerDiscardEnable : nullptr; } if (!strcmp(name, "vkCmdSetDepthBiasEnable")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdSetDepthBiasEnable : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdSetDepthBiasEnable : nullptr; } if (!strcmp(name, "vkCmdSetPrimitiveRestartEnable")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkCmdSetPrimitiveRestartEnable : nullptr; + return has1_3OrHigher ? (void*)entry_vkCmdSetPrimitiveRestartEnable : nullptr; } if (!strcmp(name, "vkGetDeviceBufferMemoryRequirements")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkGetDeviceBufferMemoryRequirements : nullptr; + return has1_3OrHigher ? (void*)entry_vkGetDeviceBufferMemoryRequirements : nullptr; } if (!strcmp(name, "vkGetDeviceImageMemoryRequirements")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkGetDeviceImageMemoryRequirements : nullptr; + return has1_3OrHigher ? (void*)entry_vkGetDeviceImageMemoryRequirements : nullptr; } if (!strcmp(name, "vkGetDeviceImageSparseMemoryRequirements")) { - bool hasExt = resources->hasDeviceExtension(device, "VK_VERSION_1_3"); - return hasExt ? (void*)entry_vkGetDeviceImageSparseMemoryRequirements : nullptr; + return has1_3OrHigher ? (void*)entry_vkGetDeviceImageSparseMemoryRequirements : nullptr; } #endif #ifdef VK_KHR_surface @@ -18926,6 +18905,14 @@ void* goldfish_vulkan_get_device_proc_address(VkDevice device, const char* name) bool hasExt = resources->hasDeviceExtension(device, "VK_GOOGLE_gfxstream"); return hasExt ? (void*)entry_vkGetBlobGOOGLE : nullptr; } + if (!strcmp(name, "vkUpdateDescriptorSetWithTemplateSized2GOOGLE")) { + bool hasExt = resources->hasDeviceExtension(device, "VK_GOOGLE_gfxstream"); + return hasExt ? (void*)entry_vkUpdateDescriptorSetWithTemplateSized2GOOGLE : nullptr; + } + if (!strcmp(name, "vkQueueSubmitAsync2GOOGLE")) { + bool hasExt = resources->hasDeviceExtension(device, "VK_GOOGLE_gfxstream"); + return hasExt ? (void*)entry_vkQueueSubmitAsync2GOOGLE : nullptr; + } #endif #ifdef VK_EXT_multi_draw if (!strcmp(name, "vkCmdDrawMultiEXT")) { diff --git a/system/vulkan_enc/goldfish_vk_counting_guest.cpp b/system/vulkan_enc/goldfish_vk_counting_guest.cpp index ed2e2300..e9529d84 100644 --- a/system/vulkan_enc/goldfish_vk_counting_guest.cpp +++ b/system/vulkan_enc/goldfish_vk_counting_guest.cpp @@ -1558,10 +1558,16 @@ void count_VkGraphicsPipelineCreateInfo(uint32_t featureBits, VkStructureType ro (void)count; uint32_t hasRasterization = 1; if (featureBits & VULKAN_STREAM_FEATURE_IGNORED_HANDLES_BIT) { - hasRasterization = (((0 == toCount->pRasterizationState)) - ? (0) - : (!((*(toCount->pRasterizationState)).rasterizerDiscardEnable))); - *count += 4; + hasRasterization = + ((((0 == toCount->pRasterizationState)) + ? (0) + : (!((*(toCount->pRasterizationState)).rasterizerDiscardEnable))) || + (((0 == toCount->pDynamicState)) + ? (0) + : (arrayany((*(toCount->pDynamicState)).pDynamicStates, 0, + (*(toCount->pDynamicState)).dynamicStateCount, [](VkDynamicState s) { + return (s == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE); + })))); } uint32_t hasTessellation = 1; if (featureBits & VULKAN_STREAM_FEATURE_IGNORED_HANDLES_BIT) { diff --git a/system/vulkan_enc/goldfish_vk_marshaling_guest.cpp b/system/vulkan_enc/goldfish_vk_marshaling_guest.cpp index c1f0e8b2..730b8eee 100644 --- a/system/vulkan_enc/goldfish_vk_marshaling_guest.cpp +++ b/system/vulkan_enc/goldfish_vk_marshaling_guest.cpp @@ -2808,9 +2808,16 @@ void marshal_VkGraphicsPipelineCreateInfo(VulkanStreamGuest* vkStream, VkStructu uint32_t hasRasterization = 1; if (vkStream->getFeatureBits() & VULKAN_STREAM_FEATURE_IGNORED_HANDLES_BIT) { hasRasterization = - (((0 == forMarshaling->pRasterizationState)) - ? (0) - : (!((*(forMarshaling->pRasterizationState)).rasterizerDiscardEnable))); + ((((0 == forMarshaling->pRasterizationState)) + ? (0) + : (!((*(forMarshaling->pRasterizationState)).rasterizerDiscardEnable))) || + (((0 == forMarshaling->pDynamicState)) + ? (0) + : (arrayany((*(forMarshaling->pDynamicState)).pDynamicStates, 0, + (*(forMarshaling->pDynamicState)).dynamicStateCount, + [](VkDynamicState s) { + return (s == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE); + })))); uint32_t cgen_var_0 = (uint32_t)hasRasterization; vkStream->putBe32(cgen_var_0); } @@ -40911,6 +40918,11 @@ const char* api_opcode_to_string(const uint32_t opcode) { return "OP_vkCmdWaitEvents2"; } #endif +#ifdef VK_GOOGLE_gfxstream + case OP_vkUpdateDescriptorSetWithTemplateSized2GOOGLE: { + return "OP_vkUpdateDescriptorSetWithTemplateSized2GOOGLE"; + } +#endif #ifdef VK_EXT_extended_dynamic_state3 case OP_vkCmdSetRepresentativeFragmentTestEnableNV: { return "OP_vkCmdSetRepresentativeFragmentTestEnableNV"; @@ -41764,6 +41776,11 @@ const char* api_opcode_to_string(const uint32_t opcode) { return "OP_vkGetQueueCheckpointData2NV"; } #endif +#ifdef VK_GOOGLE_gfxstream + case OP_vkQueueSubmitAsync2GOOGLE: { + return "OP_vkQueueSubmitAsync2GOOGLE"; + } +#endif #ifdef VK_EXT_opacity_micromap case OP_vkCopyMemoryToMicromapEXT: { return "OP_vkCopyMemoryToMicromapEXT"; diff --git a/system/vulkan_enc/goldfish_vk_marshaling_guest.h b/system/vulkan_enc/goldfish_vk_marshaling_guest.h index 8092a4d0..a05b2482 100644 --- a/system/vulkan_enc/goldfish_vk_marshaling_guest.h +++ b/system/vulkan_enc/goldfish_vk_marshaling_guest.h @@ -7756,6 +7756,8 @@ void unmarshal_VkCreateBlobGOOGLE(VulkanStreamGuest* vkStream, VkStructureType r #define OP_vkQueueSignalReleaseImageANDROIDAsyncGOOGLE 243985229 #define OP_vkQueueFlushCommandsFromAuxMemoryGOOGLE 290633483 #define OP_vkGetBlobGOOGLE 20341 +#define OP_vkUpdateDescriptorSetWithTemplateSized2GOOGLE 244782974 +#define OP_vkQueueSubmitAsync2GOOGLE 292092830 #endif #ifdef VK_EXT_global_priority_query DEFINE_ALIAS_FUNCTION(marshal_VkPhysicalDeviceGlobalPriorityQueryFeaturesKHR, diff --git a/system/vulkan_enc/goldfish_vk_reserved_marshaling_guest.cpp b/system/vulkan_enc/goldfish_vk_reserved_marshaling_guest.cpp index d06ebd9f..1676c86a 100644 --- a/system/vulkan_enc/goldfish_vk_reserved_marshaling_guest.cpp +++ b/system/vulkan_enc/goldfish_vk_reserved_marshaling_guest.cpp @@ -2117,9 +2117,16 @@ void reservedmarshal_VkGraphicsPipelineCreateInfo(VulkanStreamGuest* vkStream, uint32_t hasRasterization = 1; if (vkStream->getFeatureBits() & VULKAN_STREAM_FEATURE_IGNORED_HANDLES_BIT) { hasRasterization = - (((0 == forMarshaling->pRasterizationState)) - ? (0) - : (!((*(forMarshaling->pRasterizationState)).rasterizerDiscardEnable))); + ((((0 == forMarshaling->pRasterizationState)) + ? (0) + : (!((*(forMarshaling->pRasterizationState)).rasterizerDiscardEnable))) || + (((0 == forMarshaling->pDynamicState)) + ? (0) + : (arrayany((*(forMarshaling->pDynamicState)).pDynamicStates, 0, + (*(forMarshaling->pDynamicState)).dynamicStateCount, + [](VkDynamicState s) { + return (s == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE); + })))); uint32_t cgen_var_0 = (uint32_t)hasRasterization; memcpy((*ptr), &cgen_var_0, 4); android::base::Stream::toBe32((uint8_t*)(*ptr)); diff --git a/system/vulkan_enc/vk_struct_id.h b/system/vulkan_enc/vk_struct_id.h index 22f23618..355b07fb 100644 --- a/system/vulkan_enc/vk_struct_id.h +++ b/system/vulkan_enc/vk_struct_id.h @@ -77,6 +77,11 @@ REGISTER_VK_STRUCT_ID(VkMemoryAllocateFlagsInfo, VK_STRUCTURE_TYPE_MEMORY_ALLOCA REGISTER_VK_STRUCT_ID(VkMemoryOpaqueCaptureAddressAllocateInfo, VK_STRUCTURE_TYPE_MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO); REGISTER_VK_STRUCT_ID(VkBindImageMemoryInfo, VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO); REGISTER_VK_STRUCT_ID(VkBindImageMemorySwapchainInfoKHR, VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR); +REGISTER_VK_STRUCT_ID(VkBufferOpaqueCaptureAddressCreateInfo, VK_STRUCTURE_TYPE_BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO); +REGISTER_VK_STRUCT_ID(VkBufferDeviceAddressCreateInfoEXT, VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_CREATE_INFO_EXT); +REGISTER_VK_STRUCT_ID(VkGraphicsPipelineCreateInfo, VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO); +REGISTER_VK_STRUCT_ID(VkPipelineRenderingCreateInfo, VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO); +REGISTER_VK_STRUCT_ID(VkPhysicalDeviceExternalSemaphoreInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO); #undef REGISTER_VK_STRUCT_ID diff --git a/system/vulkan_enc/vulkan_gfxstream.h b/system/vulkan_enc/vulkan_gfxstream.h index 060dac5c..c0e23d54 100644 --- a/system/vulkan_enc/vulkan_gfxstream.h +++ b/system/vulkan_enc/vulkan_gfxstream.h @@ -119,6 +119,17 @@ typedef void(VKAPI_PTR* PFN_vkQueueFlushCommandsFromAuxMemoryGOOGLE)(VkQueue que VkDeviceSize dataOffset, VkDeviceSize dataSize); typedef VkResult(VKAPI_PTR* PFN_vkGetBlobGOOGLE)(VkDevice device, VkDeviceMemory memory); +typedef void(VKAPI_PTR* PFN_vkUpdateDescriptorSetWithTemplateSized2GOOGLE)( + VkDevice device, VkDescriptorSet descriptorSet, + VkDescriptorUpdateTemplate descriptorUpdateTemplate, uint32_t imageInfoCount, + uint32_t bufferInfoCount, uint32_t bufferViewCount, uint32_t inlineUniformBlockCount, + const uint32_t* pImageInfoEntryIndices, const uint32_t* pBufferInfoEntryIndices, + const uint32_t* pBufferViewEntryIndices, const VkDescriptorImageInfo* pImageInfos, + const VkDescriptorBufferInfo* pBufferInfos, const VkBufferView* pBufferViews, + const uint8_t* pInlineUniformBlockData); +typedef void(VKAPI_PTR* PFN_vkQueueSubmitAsync2GOOGLE)(VkQueue queue, uint32_t submitCount, + const VkSubmitInfo2* pSubmits, + VkFence fence); #ifndef VK_NO_PROTOTYPES VKAPI_ATTR VkResult VKAPI_CALL vkMapMemoryIntoAddressSpaceGOOGLE(VkDevice device, @@ -208,6 +219,18 @@ VKAPI_ATTR void VKAPI_CALL vkQueueFlushCommandsFromAuxMemoryGOOGLE(VkQueue queue VkDeviceSize dataSize); VKAPI_ATTR VkResult VKAPI_CALL vkGetBlobGOOGLE(VkDevice device, VkDeviceMemory memory); + +VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSetWithTemplateSized2GOOGLE( + VkDevice device, VkDescriptorSet descriptorSet, + VkDescriptorUpdateTemplate descriptorUpdateTemplate, uint32_t imageInfoCount, + uint32_t bufferInfoCount, uint32_t bufferViewCount, uint32_t inlineUniformBlockCount, + const uint32_t* pImageInfoEntryIndices, const uint32_t* pBufferInfoEntryIndices, + const uint32_t* pBufferViewEntryIndices, const VkDescriptorImageInfo* pImageInfos, + const VkDescriptorBufferInfo* pBufferInfos, const VkBufferView* pBufferViews, + const uint8_t* pInlineUniformBlockData); + +VKAPI_ATTR void VKAPI_CALL vkQueueSubmitAsync2GOOGLE(VkQueue queue, uint32_t submitCount, + const VkSubmitInfo2* pSubmits, VkFence fence); #endif #ifdef __cplusplus |