438 Commits
Author SHA1 Message Date
osy cdea172513 Remove replacement dedicated allocation for macOS
MoltenVK enforces that a single VkImage can be dedicated to a memory
binding. When this code runs it breaks that promise and results in an error
return when `vkBindImageMemory` is called by the client.
2025-10-06 13:57:21 -07:00
osy be4c36b52a Pass detection of emulated extensions on macOS
Just like QNX, macOS does not natively support DMA buffers.
Also indicate that VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME is
emulated in `vkEnumerateDeviceExtensionProperties`.
2025-10-06 13:55:00 -07:00
osy 5c119efce6 Add supportsPortabilityEnumeration flag
On macOS MoltenVK can be installed as part of Vulkan SDK or as standalone.
If standalone, VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME will not be
supported. Therefore, we decouple the detection of portability enumeration
from detection of MoltenVK.
2025-10-05 17:08:32 -07:00
Bo Hu 46da8f3e27 [vulkan snapshot]: simplify vk update descriptor
Currently, we save all the vkUpdateDescriptorSets commands
and replay then during loading.

This leads to very large amount of commands and it is
slowing down both the saving and loading, when the emulator
has run a longer period of time.

Prior work worked around this problem by saving only the
active descriptors, but it only works with VulkanBatchedDescriptorSetUpdate
feature.

This cl improves prior work to make it work without
VulkanBatchedDescriptorSetUpdate feature.

Bug: 417788798

Change-Id: I5b83566db3723135b9d8dd2df56ad1d7f2a751ed
2025-09-11 08:25:45 +00:00
Serdar Kocdemir 74647db33f Add mipLevels argument to vulkan color buffer creation
Android Hardware Buffers can be created with mip levels and
the mismatch is causing errors when importing vulkan images.

Bug: 406456167
Test: CtsNativeHardwareTestCases
Change-Id: I3634bd400574453bf4ff123c149cb5f95409a42f
2025-09-11 08:25:45 +00:00
Jason Macnak 2ac5077203 Address some Werror errors from ag/35389434 2025-09-04 19:31:59 +00:00
Jason Macnak 50be0f8872 Remove redunant std::move 2025-09-04 19:31:59 +00:00
Serdar Kocdemir 298d311939 Handle invalid usage on ycbcr conversion creation
Creation of conversion objects with undefined formats causes driver
crashes on Intel GPUs later on descriptor set layout creation. Failing
early enables booting XR emulator correctly.

Bug: 439619234
Test: run XR emulator on intel GPU
Change-Id: I9d79a0d9bcb6dc7ec1aedf4320547ef93b5604ab
2025-09-04 19:31:59 +00:00
Serdar Kocdemir d8bd31204e Adjustments to some log messages
Reduce usages of stderr printing and use gfxstream logging
functions instead.

Bug: 389637419
Bug: 433496880
Test: CI
Change-Id: I52ad2fe9953cffa1b028b9a388e7f90c7141a9c0
2025-09-04 19:31:59 +00:00
Serdar Kocdemir e7c513c889 Suppress unused variable warnings
Bug: 389637419
Test: CI
Change-Id: Iee49b1defac448b142519f9e4e6cb2cf11c01490
2025-09-04 19:31:59 +00:00
Jason Macnak 81e9cb0616 Add a vkTraceAsyncGOOGLE
... to allow sharing perfetto global flow ids between guest and host
so that combined traces can have an arrow between the guest and host
render threads to aid debugging.

Bug: b/440065361
Test: Capture guest and host trace and inspect in perfetto UI
Change-Id: Id1c34dbee40c8febc9730479d1daed37722fcd09
2025-09-04 19:31:59 +00:00
sergiuferentz f75ca8ea8d Error out if image allocation exceeds driver capacity.
Bug: 432837154
2025-08-26 19:30:23 +00:00
Bo Hu b2887ea2b9 [vulkan snapshot]: save and load semaphore signal state
The semaphore's signal state should be tracked and saved,
and later re-signaled if necessary during load, so that
any subsequent wait on the same semaphore could go ahead
instead of hanging.

Bug: 417788798

Change-Id: I15bd28be70e0582f049fd6cd281290fb37a5d694
2025-07-25 22:20:02 +00:00
Jeongik Cha 8bbf05de37 Emulate coherent memory for udmabuf case as well
for udmabuf case, it's not virtgpuMapped, but still requires 
emulation for coherent memory

Bug: 424729656
Bug: 423003849
Test: check if there is no broken image
Change-Id: I68554700ab086c27a25f4809623273c70ab692c6
2025-07-25 22:20:02 +00:00
Serdar Kocdemir c1c19c7810 Separate external memory metal usage from MoltenVK
Bug: 433496880
Change-Id: I3639bfe9ca555c16c2954bcf96f3703933d0b51f
2025-07-25 22:20:02 +00:00
Aaron Ruby c7ceec9357 Support guest-side SCREEN_BUFFER_BIT_QNX extMem handleTypes in
translations
2025-07-16 20:05:15 +00:00
Bo Hu 6b340cf804 [vulkan snapshot]: handle event save and load
There is currently a problem of missed setevent
and that leads to wait event hangs, or queue becomes
not able to idle, no matter how long it is waited upon.

To solve this problem, this cl follows each event's set,
reset, and save the set status into snapshot.
Later one, during loading, it recovers their set status,
so that subsequent cmd event wait can continue.

specifically, the following steps are taken:
1, set and reset operations from host or
in the queue are tracked.
2, if an event is set, that status will be saved
into snapshot; later during loadiing, the set operation
will be set again from the host or in the same queue
before snapshot.

This is not complete, but it is a first step
to resolve some of the timeout issue.

TODO:
event2

Test: xr should not hang during save due to
queue gets blocked (vkQueueSubmit does not return,
or wait for fence times out)

Bug: 417788798

Change-Id: I991cccfb2f34c6189f6c0759b8abbb365b695719
2025-07-10 23:58:52 +00:00
Jeongik Cha 5aaabf9f72 call vkFlushMappedMemoryRanges just once per one vkQueueSubmit
Bug: 424729656
Change-Id: I39eb7321feccc11f6771aa27d816406a2e965fe3
2025-07-10 23:58:52 +00:00
Jeongik Cha 0f4f3852d9 Add a flag for gfxstream to let cached memory pretend as coherent memory
Test: atest --host gfxstream_vkemulatedphysicaldevicememory_tests
Bug: 424729656
Change-Id: If0a3e931d0fc41002deda099dd471ff8a4197714
2025-07-10 23:58:52 +00:00
Serdar Kocdemir e0b220fa34 Remove debug only imageFormats set from device info tracking
Bug: 389637419
Test: build
Change-Id: I8630b23d2931d8eaef8887ad4bfc11c36fe64b05
2025-06-24 23:54:43 +00:00
Serdar Kocdemir 9b9764017c Fix device info extraction on destroy
Also adjust some of the logs related to the device/instance
info tracking.

Bug: 406456167
Test: dEQP-VK.api.device_init.*
Change-Id: I4cbaf9194a85bce1dd88f7d1ae58cb6912d33cb9
2025-06-24 23:54:43 +00:00
Gurchetan Singh ca371e068d gfxstream: use UdmabufCreator
Make sure it's available to the Vulkan decoder if it
is available on the platform.

BUG=423003060
TEST=CI
2025-06-24 00:51:06 +00:00
Gurchetan Singh 97c745a5bf gfxstream: memory management cleanups
* No udmabuf-like mechanism exists on Windows.

* isImport --> importEmulationExternalMemory.  Host visible
  memory may be emulated via vkImportMemory{Fd, HANDLE}, but
  it's not need for shareable blobs (gralloc buffers) in many
  cases. Even if the shareable blob is host visible.

* uniqueShmemId --> sUniqueShmemId

The allocation logic is very delicate.  A good target for further
refactors.

BUG=423003060
TEST=CI
2025-06-24 00:51:06 +00:00
Gurchetan Singh f1f60942a7 gfxstream: define a shared ALIGN macro
To be used in the next patch ..

BUG=423003060
2025-06-11 02:51:39 +00:00
Serdar Kocdemir 10b2274480 Correctly call destroy on uncompressed images
Fixes a recently introduced bug.

Bug: 406456167
Test: run emulator with VVL
Change-Id: I51bb69848e0959467f4d9a5a96ff3ed77dbf1f67
2025-06-09 20:09:57 +00:00
Joshua Duong d07c1cd519 Wrap vkAllocateDescriptorSets validation with VulkanBatchedDescriptorSetUpdate.
Bug: 420961757
Test: dEQP-GLES31.functional.ssbo.layout.instance_array_basic_type*
Change-Id: I0684f57f01828bf6ce76bdf91e756f73ed04256d
2025-06-09 20:09:57 +00:00
Serdar Kocdemir 7b6585d627 Fix texture gpu compression check on astc textures
Fixes regressions on etc2 texture tests.

Bug: 406456167
Test: dEQP-VK.texture.compressed*
Change-Id: Ie9e2f0864d6e1e745cf88a01e0baef2d51bde7d8
2025-06-09 20:09:57 +00:00
Jason Macnak 0eee5ee942 Ensure host device ops finish before reseting fences
... as otherwise the `VkFence` saved in `DeviceOpTracker` may
become invalid before the `vkGetFenceStatus()` occurs.

Test:

```
bazel test common/end2end:gfxstream_end2end_tests \
  --graphics_drivers=gles_angle_vulkan_swiftshader \
  --test_arg="--gtest_filter=*MultiThreadedResetCommandBuffer*:-*MultiThreadedResetCommandBuffer*VulkanSnapshots*" \
  --test_arg="--gtest_repeat=100" \
  --test_output=streamed
```
2025-06-06 16:41:06 +00:00
Jason Macnak 39330aa245 Use VkSnapshotApiCallHandle outside of VkReconstruction
... as VkSnapshotApiCallInfo* is a pointer into a
std::vector<VkSnapshotApiCallInfo> which can be invalidated during
multi threaded VK usage when the std::vector<> is resized.

Bug: b/422483825
Test: bazel test common/end2end:gfxstream_end2end_tests \
      --graphics_drivers=gles_angle_vulkan_swiftshader \
      --test_arg="--gtest_filter=*MultiThreadedResetCommandBuffer*VulkanSnapshots*" \
      --test_arg="--gtest_repeat=100" \
      --test_output=streamed
Change-Id: I8ea16eea8792b11056d6d7f17e370f9aa045406c
2025-06-05 17:26:09 +00:00
Serdar Kocdemir daf703eee4 Refactor on compressed texture emulation
Avoid calling needEmulatedDecompression from various locations
by holding the compression information inside ImageInfo as a
pointer, which will be valid only when compression is emulated.
This optimizes the memory footprint of image information for
non compressed textures and simplifies various checks by
moving global emulation related flag checks to only image
creation time.

Bug: 389637419
Bug: 420961757
Test: dEQP-GLES31.functional.copy_image.compressed.*
Change-Id: I91288c9d91c7fc9a8ba72d9134c1d23a10f93931
2025-06-04 22:40:43 +00:00
Serdar Kocdemir de69246aba Use host side astc/etc2 emulation on ANGLE devices
Handing over the texture compression work to ANGLE on guest is
causing some GLES31 test failures and does not look helpful.
Always use host side decompression to reduce divergence.

Bug: 420961757
Bug: 406456167
Test: dEQP-GLES31.functional.copy_image.compressed.*
Test: dEQP-GLES31.functional.copy_image.mixed.*
Change-Id: Iabd27ffa5c320716afefcde3f8d921626ad2ba57
2025-06-04 22:40:43 +00:00
Serdar Kocdemir 7975f2df6e Fix some log messages
Move engine and application names inside quotation marks
to make them clear, when the names contain spaces.

Bug: 389637419
Test: CI
Change-Id: Ie73a191d391e7be880ca4a8cc5814a3f5c540a78
2025-06-04 22:40:43 +00:00
Jason Macnak 70caa04e57 Cleanup vkutils
Bug: b/416342919
Test: bazel build ...
Change-Id: Ic7405553b578050cc3e00829f69a6398aff5741e
2025-05-30 10:33:21 -07:00
Serdar Kocdemir f1008b3773 Fix wait-before-signal for timeline semaphores
When using virtual graphics queue, wait-before-signal behavior is
controlled manually on the host to avoid deadlock situations on a single
physical backing queue. Initial implementation was only handling
vkQueueSubmit2 calls.

This CL implements some of the missing parts for the existing feature,
for old style sync routines and structures, by correctly handling the
VkTimelineSemaphoreSubmitInfo data attached to the submissions and
optimizes the copying of submission info structures. Also enables
timeline semaphore feature support on the physical device back.

Bug: 379862480
Bug: 406456167
Bug: 383570894
Test: dEQP-VK.info#device_mandatory_features
Test: dEQP-VK.synchronization.timeline_semaphore.wait_before_signal.*
Change-Id: Ieb3ac75ac45c6ec45df36d0f866f5439e900adbd
2025-05-23 16:14:15 +00:00
Serdar Kocdemir 1069773f64 Remove old todo note
Bug: b/372217918
Test: CI
Change-Id: Ia6079a7adf3d217ba22dfd72937c50e84e8d37e8
2025-05-23 06:03:38 -07:00
Treehugger Robot ff54b5df58 Merge "gfxstream: check the correct return type" into main 2025-05-22 13:12:51 -07:00
Serdar Kocdemir f9c72c215e Merge "Enable private data extension usage" into main 2025-05-22 10:06:31 -07:00
Gurchetan Singh b604be4001 gfxstream: check the correct return type
Shoutout to gkaiser@ for suggestion.

BUG=406513306
TEST=None

Change-Id: I888db6de94ba90e7d86fe62d2cf2a4faf789b26f
2025-05-21 09:57:15 -07:00
Serdar Kocdemir 14807f57c6 Enable private data extension usage
Remove workarounds to disable the support.

Bug: 368009403
Test: dEQP-VK.api.object_management.private_data.*
Change-Id: Ibf6b9522c1aee450a704796310cb4520a841bd1a
2025-05-21 12:23:41 +01:00
Treehugger Robot e250a01ef1 Merge "Fix pool usage for sampler create info copy" into main 2025-05-21 03:45:50 -07:00
Treehugger Robot 28cc03bb0d Merge "Don't report support for VK_IMAGE_USAGE_STORAGE_BIT" into main 2025-05-20 11:17:27 -07:00
sergiuferentz b817ff0b8a Don't report support for VK_IMAGE_USAGE_STORAGE_BIT
Bug: 389597454
Test: atest CtsDeqpTestCases -- --module-arg 'CtsDeqpTestCases:include-filter:dEQP-VK.api.info.unsupported_image_usage.*'

Change-Id: I234a60bf85109eceb4aaaa5d8cba0e9ff5161f31
2025-05-20 04:56:15 -07:00
Serdar Kocdemir 41ec0486c5 Fix pool usage for sampler create info copy
Bug: 389637419
Test: CI
Change-Id: Iff35a850dc4f730ec766bb7e3b1eb3f66f66271a
2025-05-20 12:46:59 +01:00
Gurchetan Singh 0d1f083a7b gfxstream: fix X11 apps again
Follow-up to aosp/3560867.

The current exportMemoryHandle(..) doesn't use the correct Vk
device.  This leads to failures in the export flow.

BUG=406513306
TEST=X11 apps work again

Change-Id: I83ab73a0334481f3226853f4d822267d88db1c71
2025-05-19 13:35:41 -07:00
Serdar Kocdemir ffb4fd8085 Merge "Disable timeline semaphore support with virtual queue" into main 2025-05-19 08:22:46 -07:00
Serdar Kocdemir 7f468c716b Disable timeline semaphore support with virtual queue
The wait_before_signal tests are not stable enough.

Bug: 398986781
Test: dEQP-VK.synchronization.timeline_semaphore.wait_before_signal.*
Change-Id: Icb5490b5372394ad8dd91b9bf0069db9bdb2b48a
2025-05-19 05:09:57 -07:00
Serdar Kocdemir 4e60d6870b Remove unnecessary object mapping tables
Use object information directly to get instance
and physical device mappings instead.
Removes mDeviceToPhysicalDevice and mPhysicalDeviceToInstance

Bug: 389637419
Test: CI
Change-Id: I09ce14dd1f0e04eedc00b2b14c70728c73873cac
2025-05-19 12:24:35 +01:00
Treehugger Robot 7dd96f2215 Merge "Increase colorbuffer sync timeout" into main 2025-05-15 15:41:05 -07:00
Serdar Kocdemir 208f457d61 Increase colorbuffer sync timeout
And do not return an error code for the submission
as this should only cause some composition issues
where the error message would be very visible due
to 5 seconds wait.

Bug: 389637419
Bug: 406456167
Test: run dEQP with lavapipe, debugger attached
Change-Id: I6696a0561bbb4021baeb78b3d1e373d7d51cb846
2025-05-15 18:28:25 +01:00
Jason Macnak f98a2688b9 Merge "Move logging to common" into main 2025-05-15 07:56:40 -07:00