aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-03-15Merge remote-tracking branch 'aosp/upstream-swiftshader-master' into ↵android-mainline-12.0.0_r4android-mainline-12.0.0_r36android-12.1.0_r9android-12.1.0_r8android-12.1.0_r7android-12.1.0_r26android-12.1.0_r25android-12.1.0_r24android-12.1.0_r23android-12.1.0_r22android-12.1.0_r21android-12.1.0_r20android-12.1.0_r19android-12.1.0_r18android-12.1.0_r17android-12.1.0_r16android-12.1.0_r15android-12.1.0_r14android-12.1.0_r13android-12.1.0_r12android-12.1.0_r11android-12.1.0_r10android-12.0.0_r32android-12.0.0_r29android-12.0.0_r28android-12.0.0_r27android-12.0.0_r26android-12.0.0_r21android-12.0.0_r20android-12.0.0_r19android-12.0.0_r18android-12.0.0_r16android12L-devandroid12L-d2-s8-releaseandroid12L-d2-s7-releaseandroid12L-d2-s6-releaseandroid12L-d2-s5-releaseandroid12L-d2-s4-releaseandroid12L-d2-s3-releaseandroid12L-d2-s2-releaseandroid12L-d2-s1-releaseandroid12L-d2-releaseandroid12-qpr3-s7-releaseandroid12-qpr3-s6-releaseandroid12-qpr3-s5-releaseandroid12-qpr3-s4-releaseandroid12-qpr3-s3-releaseandroid12-qpr3-s2-releaseandroid12-qpr3-s1-releaseandroid12-qpr3-releaseandroid12-qpr1-releaseandroid12-qpr1-d-s3-releaseandroid12-qpr1-d-s2-releaseandroid12-qpr1-d-s1-releaseandroid12-qpr1-d-releaseandroid12-devandroid12--mainline-releaseJason Macnak
'aosp/master' am: 246a3fe6ab am: 9d4b0361c8 am: 20e983294d Original change: https://android-review.googlesource.com/c/platform/external/swiftshader/+/1634282 Change-Id: Ide2c2a6e42834d13a3275fbd570c0dc1748494f3
2021-03-15Merge remote-tracking branch 'aosp/upstream-swiftshader-master' into ↵Jason Macnak
'aosp/master' am: 246a3fe6ab am: 9d4b0361c8 Original change: https://android-review.googlesource.com/c/platform/external/swiftshader/+/1634282 Change-Id: I8c12aa68d107d58e8f3e8fdc61742f04e4849f5d
2021-03-15Merge remote-tracking branch 'aosp/upstream-swiftshader-master' into ↵Jason Macnak
'aosp/master' am: 246a3fe6ab Original change: https://android-review.googlesource.com/c/platform/external/swiftshader/+/1634282 Change-Id: Icde418034cb12eed4eba2f0f699e3f4ea20fc40b
2021-03-15Merge remote-tracking branch 'aosp/upstream-swiftshader-master' into ↵Jason Macnak
'aosp/master' ... to update SwiftShader for Cuttlefish and to pull in https://swiftshader-review.googlesource.com/c/SwiftShader/+/53568 https://swiftshader-review.googlesource.com/c/SwiftShader/+/53588 https://swiftshader-review.googlesource.com/c/SwiftShader/+/53608 https://swiftshader-review.googlesource.com/c/SwiftShader/+/53648 for SwANGLE Bug: b/182563883 Bug: b/182249080 Bug: b/147738281 Bug: b/182576189 Bug: b/148822450 Test: launch Cuttlefish w/ SwANGLE Test: cts -m CtsGraphicsTestCases -t MediaVulkanGpuTest#testMediaImportAndRendering Test: cts -m CtsMediaTestCases -t DecodeEditEncodeTest#testVideoEdit720p Change-Id: Ib82e79c40c05183ba4cee55ea9e8e414db8649d2
2021-03-15Disable named mmap usage for host/ndk AndroidAlistair Delva
If ANDROID_HOST_BUILD or ANDROID_NDK_BUILD is set, PR_SET_VMA_ANON_NAME may not be available. Disable it on such builds. Bug: b/171498948 Bug: b/174801963 Change-Id: Ia9d9ddbe29a812d678263e5f217f3e5037fa14f9 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53648 Presubmit-Ready: Alistair Delva <adelva@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: Jason Macnak <natsu@google.com> Commit-Queue: Jason Macnak <natsu@google.com>
2021-03-13Remove vkGetInstanceProcAddr from exported symbols on FuchsiaNicolas Capens
Fuchsia only allows access to the ICD's functions, through the Vulkan Loader interface functions. Exporting this function was copied from the android_vk_swiftshader.lds file, but it has been removed from the latter due to causing direct access to methods that should have an overridden implementation. Similar issues are likely to occur on Fuchsia if we keep this function exported. Bug: b/148822450 Change-Id: I12f2dad933abcd9dbf89518ac5714b9f936419e4 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53609 Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: David Turner <digit@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com>
2021-03-12Remove vkGetInstanceProcAddr from exported symbols on AndroidNicolas Capens
Android only allows access to the ICD's functions, through the Vulkan Loader interface functions. This was causing direct access to vkGetPhysicalDeviceSurfaceFormatsKHR, while Android's libvulkan must override it to provide an implementation based on AHardwareBuffer, which affects things like wide-gamut support. Bug: b/182576189 Bug: b/148822450 Change-Id: I64fd5a601f92beca186696d2cd09eee1a09b8ce9 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53608 Reviewed-by: Jason Macnak <natsu@google.com> Reviewed-by: Chris Forbes <chrisforbes@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com>
2021-03-12Handle semaphore update in vkAcquireImageANDROIDJason Macnak
... by casting semaphore to a VkBinarySemaphore. Bug: b/147738281 Test: build and launch Cuttlefish in AOSP Change-Id: I3766cb0fb8bf029c426d43c12cc6754632edcb2b Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53588 Tested-by: Jason Macnak <natsu@google.com> Presubmit-Ready: Jason Macnak <natsu@google.com> Commit-Queue: Jason Macnak <natsu@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com>
2021-03-12Update AHB default YUV range to NARROWJason Macnak
Bug: b/182563883 Bug: b/182249080 Test: launch Cuttlefish w/ SwANGLE Test: cts -m CtsGraphicsTestCases -t MediaVulkanGpuTest#testMediaImportAndRendering Test: cts -m CtsMediaTestCases -t DecodeEditEncodeTest#testVideoEdit720p Change-Id: I2a2056992a1b1bf6085788093f809e1d67289781 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53568 Commit-Queue: Jason Macnak <natsu@google.com> Tested-by: Jason Macnak <natsu@google.com> Presubmit-Ready: Jason Macnak <natsu@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com>
2021-03-12Regres: Roll dEQP to 1.2.5.2-dev revision 288b9ddNicolas Capens
This update advances dEQP to a revision after version 1.2.5.2 is merged into the master branch. It includes the fix for b/180025687 as well as two new timeline semaphore tests. Other notable tests since the last update: - Decrease required subgroup size (https://gitlab.khronos.org/Tracker/vk-gl-cts/-/issues/2698) - Test negative depthBiasClamp values (https://gitlab.khronos.org/Tracker/vk-gl-cts/-/issues/2493) Tests: dEQP-VK.* Change-Id: I502507c33b7a3f1145bfc25401757de3a4ac231d Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53428 Tested-by: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Alexis Hétu <sugoi@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com>
2021-03-12Regres: Update test lists @ 3c4fd15fSwiftShader Regression Bot
Reactor backend: Subzero Change-Id: Ibd9498de9a6da9a3293ae53c412c98031852b322 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53448 Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com>
2021-03-11Implement timestamp query supportNicolas Capens
This change set VkQueueFamilyProperties::timestampValidBits to non-zero (64) to indicate support for timestamps. It also enables the timestampComputeAndGraphics feature to indicate that all graphics and compute queues (we only have a single one at the moment) support timestamp queries. Note that applications often check this aggregate flag instead of the individual queue family properties. timestampPeriod was lowered from 60 to 1, since we're writing timestamps with nanosecond granularity. Actually obtaining the time was already in place, see QueryPool::writeTimestamp(), but it didn't put the query in the 'available' state. The clock was replaced with std::chrono::steady_clock, which typically provides higher resolution than system_clock [1]. While it doesn't offer wall clock related time, this is not a requirement of Vulkan timestamps. Query::INVALID_TYPE was eliminated. Queries belong to a query pool which takes a valid type at construction. This also allowed to eliminate Query::prepare(). [1] https://www.modernescpp.com/index.php/the-three-clocks Bug: b/142643809 Tests: dEQP-VK.pipeline.timestamp.* Change-Id: Icb7c8c5ed78052eba9df630a4c1cb450bda7f85b Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53488 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Alexis Hétu <sugoi@google.com>
2021-03-11Expose Vulkan 1.2 supportSean Risser
Also update the unittests to expect version 1.2. Bug: b/147825369 Tests: dEQP-VK.* Change-Id: Ib3bb07662140fa976ec2532124ab2d7337f34c55 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/47348 Reviewed-by: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Alexis Hétu <sugoi@google.com> Tested-by: Sean Risser <srisser@google.com> Commit-Queue: Sean Risser <srisser@google.com>
2021-03-10Add Vulkan 1.2 entry pointsSean Risser
Vulkan 1.2 added several entry points, and even if SwiftShader doesn't support the features that introduced them, dEQP requires they be implemented regardless. Test: dEQP-VK.api.version_check.entry_points Bug: b/182287812 Change-Id: I0d90532e8e1508b71abc39c723167d9586d2cb84 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53468 Commit-Queue: Sean Risser <srisser@google.com> Tested-by: Sean Risser <srisser@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com>
2021-03-08Add all Vulkan 1.2 feature structsSean Risser
Vulkan 1.2 requires that all implementations support all structs made core by the extension. Tests: dEQP-VK.api.info.get_physical_device_properties2.features Bug: b/181875303 Change-Id: Ib9f307778f77c135bb7415231f7b152b2ea5b06a Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53388 Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: Sean Risser <srisser@google.com> Commit-Queue: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com>
2021-03-08Regres: Update test lists @ de7d5775SwiftShader Regression Bot
Reactor backend: Subzero Change-Id: I7f1c4f5d40a5a3aec94b8b593da021faa52d5776 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53328 Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com>
2021-03-05Fix missing feature from vkCreateDevice case-listSean Risser
Timeline semaphores were added to all the VkPhysicalDevice.cpp case- lists that needed it, but when users signaled they wanted the feature in vkCreateDevice, they could get an assert from a missing feature. Bug: b/147738281 Change-Id: I1871843d0b901347e9636e41e01c96e5e191fc8c Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53408 Reviewed-by: Nicolas Capens <nicolascapens@google.com> Tested-by: Sean Risser <srisser@google.com> Commit-Queue: Sean Risser <srisser@google.com>
2021-03-04Implement VK_KHR_timeline_semaphoreSean Risser
Timeline semaphores track a monotonically increasing uint64_t that serves as a signal to any number of threads on the device or the host. Threads and the host wait on the value of the payload to become a specific value, then unblock. Or they can signal the semaphore and update its value, unblocking all threads waiting on that value in the process. Clang's Thread Safety Analysis is not used for TimelineSemaphore as it has a bug that prevents it from properly analyzing lambdas that access guarded resources. Change-Id: Iafd95b8eac11beea21c00df87ca7ca1e51c77c64 Bug: b/147738281 Test: dEQP-VK.api.info.vulkan1p2_limits_validation.timeline_semaphore Test: dEQP-VK.synchronization.basic.timeline_semaphore.* Test: dEQP-VK.synchronization.timeline_semaphore.* Test: dEQP-VK.synchronization.op.single_queue.timeline_semaphore.* Test: dEQP-VK.synchronization.cross_instance.* Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52148 Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: Sean Risser <srisser@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com> Commit-Queue: Sean Risser <srisser@google.com>
2021-03-03Add support for internal error status checking in regresVihanakangas
This CL adds support for checking if the status is InternalError on deqp when run on regres. This CL also adds support for running deqp-vk with --deqp-validation=enabled if needed. The status for validation errors is InternalError. Bug: b/181718332 Change-Id: I63196f6f6fb244551be8ed03cce7ed79be95ea38 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53268 Tested-by: Venni Ihanakangas <venni.ihanakangas@siru.fi> Reviewed-by: Paul Thomson <paulthomson@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Commit-Queue: Venni Ihanakangas <venni.ihanakangas@siru.fi>
2021-02-26Support LLVM 11+ atomic instruction alignment changeGoogler
Atomic instructions now take an alignment parameter. llvm::MaybeAlign() means undefined alignment, which makes the compiler emit atomic operations that can handle unaligned data. This is probably overly conservative since our use cases typically ensure alignment. But that's an optimization we can prudently make later if/when proven useful. Bug: b/165000222 Change-Id: I2d0f0f0b5ae8ca811e97c2f5e2f34cc06ca7ee09 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53308 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Commit-Queue: Nicolas Capens <nicolascapens@google.com>
2021-02-26Update PhysicalDevice::getProperties(<AHB properties>)Jason Macnak
... to use AHardwareBuffer Usage Equivalence Table from the spec. Bug: b/169439421 Test: launch Cuttlefish with SwANGLE Test: dEQP-VK.api.external.memory.android_hardware_buffer.* Change-Id: Iad6bf6424a1139c623b0fc664b949eb40bbb11bb Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53148 Presubmit-Ready: Jason Macnak <natsu@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: Jason Macnak <natsu@google.com> Commit-Queue: Jason Macnak <natsu@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com>
2021-02-24Conditionally enable the XCB WSI extensionAlexis Hetu
This cl marks VK_KHR_xcb_surface as unsupported if we haven't successfully loaded XCB. Also, an assert was added to make sure vkCreateXcbSurfaceKHR is called with a valid connection. Bug: b/139491466 Change-Id: Id4ed46102cd5c2535e38bf65dedbeea1cd252e6e Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53229 Tested-by: Alexis Hétu <sugoi@google.com> Commit-Queue: Alexis Hétu <sugoi@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com>
2021-02-24Conditionally enable the Xlib WSI extensionAlexis Hetu
This cl marks VK_KHR_xlib_surface as unsupported if we haven't successfully loaded X11. Also, an assert was added to make sure vkCreateXlibSurfaceKHR is called with a valid display. Bug: b/139491466 Change-Id: I6da3755a15e09320e5715b2036043acbb31c0c35 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53168 Tested-by: Alexis Hétu <sugoi@google.com> Commit-Queue: Alexis Hétu <sugoi@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com>
2021-02-24New mechanism to easily disable extensionsAlexis Hetu
This cl adds a mechanism so that extension strings can easily be marked as supported or unsupported base on a boolean value determined at runtime. Bug: b/139491466 Change-Id: I4438a482c92d76025f137a7a77f61863abaae9c9 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53228 Presubmit-Ready: Alexis Hétu <sugoi@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: Alexis Hétu <sugoi@google.com> Commit-Queue: Alexis Hétu <sugoi@google.com>
2021-02-24Remove legacy optimization passes.Nicolas Capens
optimizeSingleBasicBlockLoadsStores() supersedes both eliminateLoadsFollowingSingleStore() and optimizeStoresInSingleBasicBlock(). This was verified by adding asserts the latter when the delete more instructions. They're never hit by dEQP-VK tests. Only the PointerToPointer triggers an assert. It goes away when running optimizeSingleBasicBlockLoadsStores() twice. Since it is very rare to store the address of a pointer in another pointer, and before the new optimization pass was implemented we also did not handle this case, we're not going to pay the cost of running it twice. eliminateUnitializedLoads() was moved earlier because we never produce new loads of uninitialized values in the optimization passes and it's best to eliminate these allocas early. The late eliminateDeadCode() was also removed since we already run it at the end of optimizeSingleBasicBlockLoadsStores(). TODOs for cases where the load/store sizes don't match have been removed because propagating a different type causes issues. Bug: b/179668593 Change-Id: I4b3533057423709cdaa8343301184d8225b0727b Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53128 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-02-24Kokoro: fix Windows builds to correctly use %BUILD_TYPE%Antonio Maiorano
CMake's CMAKE_BUILD_TYPE variable is ignored for multi-config generators,like Visual Studio. Instead, we must specify the config when building. For VulkanTester, needed to add "RelWithDebInfo" to search paths for vk_swiftshader.dll as that's the "Release" config we use for Kokoro builds. Change-Id: I1fbfa3b179e9364462f4ea6e9704120d3a675b4d Bug: b/181019484 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53188 Kokoro-Result: kokoro <noreply+kokoro@google.com> Kokoro-Result: Antonio Maiorano <amaiorano@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com> Tested-by: Antonio Maiorano <amaiorano@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com>
2021-02-24VulkanWrapper: fix failure to load headless surface extensionAntonio Maiorano
Meant to use an "#if" not "#if defined" for USE_HEADLESS_SURFACE. Before this fix, we would always request the headless surface extension, which would usually fail on Windows if no loader is installed since current GPU drivers don't implement this extension yet. Change-Id: I5bcf9e08f467fd85712d1bc3504e3f251e886664 Bug: b/176981107 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53208 Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com> Tested-by: Antonio Maiorano <amaiorano@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-02-22Remove color interpolation from image sampling benchmarkNicolas Capens
Also make the image not a solid color. Bug: b/179897703 Change-Id: Ibe2084c4e9f0d9023269218df1ad467bb24a1ae3 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52750 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-02-22Revert sampling parameter initialization workaroundNicolas Capens
1D image sampling used to be treated as 2D image sampling with the second coordinate being ignored. But a bug was causing us to use the second component of the 'offset' parameter. This was worked around by initializing all parameters provided to the sampling routine. This costs some performance, and since we've fixed the 'offset' bug and have specialized handling of 1D images now, the workaround can be reverted. Change-Id: Id69b68465d7755df35fe12619957971681e4c0b7 Fixes: b/136149446 Bug: b/134669567 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/48930 Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Alexis Hétu <sugoi@google.com>
2021-02-22Eliminate stores succeeded by another storeNicolas Capens
When a store is propagated to all stores succeeding it in the same basic block, and we encounter another store, we can delete the previous one. This optimizes the StoresInMultipleBlocks test's generated code from: sub rsp,38h mov dword ptr [rsp],0Dh cmp ecx,0 je a mov dword ptr [rsp],4 mov eax,4 add eax,3 mov dword ptr [rsp],eax b: mov eax,dword ptr [rsp] add rsp,38h ret a: mov dword ptr [rsp],6 mov eax,6 add eax,5 mov dword ptr [rsp],eax jmp b Into: sub rsp,38h mov dword ptr [rsp],0Dh cmp ecx,0 je a mov eax,4 add eax,3 mov dword ptr [rsp],eax jmp b a: mov eax,6 add eax,5 mov dword ptr [rsp],eax b: mov eax,dword ptr [rsp] add rsp,38h ret Bug: b/179668593 Change-Id: I2036d7b7c97be17ce73ff32234fe51841409a20c Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52568 Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com>
2021-02-22Implement propagation of stores to loads in single basic blocksNicolas Capens
For loads following stores in the same basic block, replace their result with the data that was stored. It transforms the output of the StoresInMultipleBlocks test from: sub rsp,38h mov dword ptr [rsp],0Dh cmp ecx,0 je a mov dword ptr [rsp],4 add dword ptr [rsp],3 b: mov eax,dword ptr [rsp] add rsp,38h ret a: mov dword ptr [rsp],6 add dword ptr [rsp],5 jmp b Into: sub rsp,38h mov dword ptr [rsp],0Dh cmp ecx,0 je a mov dword ptr [rsp],4 mov eax,4 add eax,3 mov dword ptr [rsp],eax b: mov eax,dword ptr [rsp] add rsp,38h ret a: mov dword ptr [rsp],6 mov eax,6 add eax,5 mov dword ptr [rsp],eax jmp b While at first this might seem like a regression, note that `add [rsp],3` performs both a load and a store. The optimization pass eliminated two load operations from this test. The redundant stores will be eliminated by a subsequent change. Also adds a unit test for the case where store-to-load propagation should not be performed due to an indirect store through a pointer happening in between. Bug: b/179668593 Change-Id: I6ca133ac4e77bbbc3efd517dff6e8dee6d2dc147 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52533 Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com> Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-02-20[automerger skipped] Mark ab/7061308 as merged in stage. am: ee24918998 -s ↵Xin Li
ours am: 1613ea4b55 -s ours am skip reason: Change-Id I230b17826558893972915fb67382efeae892cc35 with SHA-1 42a22e3214 is in history Original change: undetermined MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I5add81ee67ffb3c4ea155b6c47540a07fe9a729f
2021-02-20[automerger skipped] Mark ab/7061308 as merged in stage. am: ee24918998 -s oursXin Li
am skip reason: Change-Id I230b17826558893972915fb67382efeae892cc35 with SHA-1 42a22e3214 is in history Original change: undetermined MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Ibfe0d7ab1f8fbf259b9b01ed8d9ec0a9500a3ec5
2021-02-20Mark ab/7061308 as merged in stage.Xin Li
Bug: 180401296 Merged-In: I230b17826558893972915fb67382efeae892cc35 Change-Id: I03f634ad049890e0feb1d017d923b92fe69cd2b3
2021-02-20Simplify If/Else loweringNicolas Capens
Previously we would append the 'begin' basic block with the conditional branch only once we know whether or not there's a 'false' block separate from the 'end' block (namely when executing the Else statement). We can instead treat the 'false' block as the 'end' block itself when no Else is encountered and simply continue emitting instructions in this block. Note this removes the need to explicitly materialize all variables, because that's taken care of by createCondBr(). Bug: b/180131694 Change-Id: I5c5c4373d1dc02991feffa69d4089b2c12054dc0 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52988 Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com> Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Alexis Hétu <sugoi@google.com>
2021-02-20Don't materialize on insertion block changesNicolas Capens
Materializing all variables should be done prior to actual branches, not when changing the insert point. The only reason we did it in the latter too was due to changing insert point before creating the branch for an If statement. Bug: b/180131694 Change-Id: Ic755bf07a098bda4af7e4d5a7d22138bee37d0c6 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52968 Tested-by: Nicolas Capens <nicolascapens@google.com> Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Alexis Hétu <sugoi@google.com>
2021-02-20Implement scalar replacement of aggregatesNicolas Capens
This change implements the Scalar Replacement of Aggregates (SRoA) optimization. Since Reactor only supports array aggregates, this replaces arrays which are only indexed by static indices with individual variables for each element. The ReactorArray test is optimized from: sub rsp,38h mov dword ptr [rsp],1 mov dword ptr [rsp+4],2 mov eax,dword ptr [rsp] mov ecx,dword ptr [rsp+4] mov dword ptr [rsp],ecx mov dword ptr [rsp+4],eax mov eax,dword ptr [rsp+4] add eax,dword ptr [rsp] add rsp,38h ret Into: sub rsp,20h mov eax,2 add eax,1 add rsp,20h ret Which is identical to the CArray test's generated code. Bug: b/179279298 Change-Id: Ie45261f2ac783bdc22fee06adf03ebd588f3ebc3 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52428 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-02-20Report back the Subzero optimizer resultsNicolas Capens
This change adds a callback mechanism to report how many instructions of certain types are left after the optimization passes have been run. This enables unit tests to check that the desired optimization actually took place, instead of just checking correct execution results. Bug: b/180665600 Change-Id: I3916d327138516a0a0778be2b3fdd5b000fc9bdb Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52989 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-02-19Merge "Merge remote-tracking branch 'aosp/upstream-swiftshader-master' into ↵Jason Macnak
'aosp/master'" am: 78cb5cce4c am: 16eb7cd2a9 am: 8512f7bc78 Original change: https://android-review.googlesource.com/c/platform/external/swiftshader/+/1579256 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Ia8592894a29bb478e079a5e781007fee9fb05af5
2021-02-19Fix lowering and optimization of 64-bit absolute addressesNicolas Capens
x86-64 does not support 64-bit immediates as absolute memory addresses. They have to be stored in a register, which can then be used as [base]. Previously we addressed this at the SubzeroReactor level by emitting a Bitcast from an Ice::Operand to an Ice::Variable, for which Subzero already supported 64-bit constants as input. This change implements X86OperandMem creation from a 64-bit constant operand by letting legalize() move it into a GPR and using it as the memory operand's base register. A Reactor unit test is added to exercise this. Another issue was that doLoadOpt() assumed all load instructions are candidates for fusing into a subsequent instruction which takes the result of the load. This isn't true when for 64-bit constant addresses an instruction to copy it into a register is inserted. For now this case is simply skipped. A future optimization could adjust the iterators properly so the load from [base] can be fused with the next instruction. Lastly, it is possible for a 64-bit constant to fit within a 32-bit immediate, in which case legalize() by default does not perform the copy into a GPR (note this is to allow moves and calls with 64-bit immediates, where they are legal), and simply returns the 64-bit constant. So we must not allow legalization to an immediate in this case. Note that while we could replace it with a 32-bit constant, it's rare for absolute addresses to fit in this range, and it would be non-deterministic which path is taken, so for consistency we don't perform this optimization. Bug: b/148272103 Change-Id: I5fcfa971dc93f2307202ee11619e84c65fe46188 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52768 Tested-by: Nicolas Capens <nicolascapens@google.com> Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-02-19Merge "Merge remote-tracking branch 'aosp/upstream-swiftshader-master' into ↵Jason Macnak
'aosp/master'" am: 78cb5cce4c am: 16eb7cd2a9 Original change: https://android-review.googlesource.com/c/platform/external/swiftshader/+/1579256 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I53012ffb877862de3ea2132767eba8ed7ade4c81
2021-02-19Merge "Merge remote-tracking branch 'aosp/upstream-swiftshader-master' into ↵Jason Macnak
'aosp/master'" am: 78cb5cce4c Original change: https://android-review.googlesource.com/c/platform/external/swiftshader/+/1579256 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I55e5d0030a98609faa86fb5a30ce351e7dfaeaa8
2021-02-19Merge "Merge remote-tracking branch 'aosp/upstream-swiftshader-master' into ↵Jason Macnak
'aosp/master'"
2021-02-19Eliminate code randomization support from SubzeroNicolas Capens
SwiftShader has no use for this since shader execution with robustness features enabled can not access memory outside of the graphics resources. For Chromium it also runs in the GPU process, which isolates it from browser-wide and even tab renderer data and code, and also has its own sandboxing. If we ever do need randomization to prevent attacks, and project Bunker doesn't provide the needed site isolation, it should be implemented either at the Reactor level or as separate transformation passes where possible. While previously this feature was already disabled, there might have been inadvertent randomization which could explain our test time variability. It may also improve code generation performance a bit to not have this code around any more. Bug: b/179832693 Change-Id: If1ccb54981edb61f443dd5949c56b75bab07c7c2 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52808 Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com> Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-02-19Fix Win32SurfaceKHR::getSurfaceCapabilities asserting when hwnd is no longer ↵Antonio Maiorano
valid When vkGetPhysicalDeviceSurfaceCapabilitiesKHR is called, we now return VK_ERROR_SURFACE_LOST_KHR on Windows if the window handle (hwnd) is no longer valid. The assert was being tripped by Chromium's compositor_unittests for test LayerWithRealCompositorTest.BackgroundBlur. With this fix, instead of an assert, the test now fails because eglQuerySurface fails with EGL_BAD_SURFACE. Bug: chromium:1174372 Change-Id: I71164c30bddaa41753472389e996cebbff7fbf77 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52928 Tested-by: Antonio Maiorano <amaiorano@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com>
2021-02-19Update requested SPIR-V Tools version to 1.5Sean Risser
SPV_ENV_Vulkan_1_2 denotes support for all SPIR-V versions that are core in Vulkan 1.2. This includes 1.4 and 1.5. Tests: dEQP-VK.* Bug: b/173046235 Change-Id: I7482d1bff6bf3b2c2291538517f6640647ab644c Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/50670 Tested-by: Sean Risser <srisser@google.com> Commit-Queue: Sean Risser <srisser@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com>
2021-02-19Make vkGetPhysicalDeviceSurfaceCapabilitiesKHR provide a return codeAntonio Maiorano
Rather than assume success, allow WSI surface implementations to return a VkResult for getSurfaceCapabilities. Also, made VkSurfaceKHR::getSurfaceCapabilities pure virtual, and moved its implementation to a protected static helper named setCommonSurfaceCapabilities. Bug: chromium:1174372 Change-Id: I75f5f5a30f786f0675d830e4e2a684a4cbcb149c Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53048 Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com> Tested-by: Antonio Maiorano <amaiorano@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-02-19Revert "Revert "Enable named mmap usage on Android""Alistair Delva
We have fixed the original problem requiring the revert. This reverts commit ed7c4d5caf5b53c9358a4a95c0728f46ba7052a4. Bug: b/171498948 Change-Id: I02afbf9df677f6b691d0929a1f577ff355ef08e8 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52668 Reviewed-by: Jason Macnak <natsu@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com> Tested-by: Jason Macnak <natsu@google.com> Presubmit-Ready: Jason Macnak <natsu@google.com> Commit-Queue: Jason Macnak <natsu@google.com>
2021-02-19Fix iterating over instructions following a storeNicolas Capens
Optimizer::eliminateLoadsFollowingSingleStore() was only looking at a single instruction following the store. Subzero derives Ice::Inst from llvm::ilist_node<Inst>, making it a node in a circular linked list. However, we can't iterate until the end because by default ilist_node<> does not provide sentinel node tracking. If the llvm::ilist_node<Inst, llvm::ilist_sentinel_tracking<true>> class is used instead, we can use isSentinel(), but this comes at the cost of each node itself having to indicate whether it's the sentinel, and keeping that up to date. This change instead obtains the basic block's instruction list from the store instruction, to get the iterator of the end node. Bug: b/179668593 Change-Id: I994a7b37d8872380d2668c098d85000120d3e47a Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52753 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-02-19Propagate stores of stack addresses into other local variablesNicolas Capens
Pointers to the base address of arrays often get stored and then loaded multiple time. This change adds an optimization pass to replace these loads with the result of the alloca of the array, and eliminates the allocas of the pointer variables. The PropagateAlloca unit test without this optimization produces: sub rsp,38h mov dword ptr [rsp+8],16h cmp ecx,0 je 000002543C4E407E lea rax,[rsp+8] mov qword ptr [rsp],rax mov rax,qword ptr [rsp] mov eax,dword ptr [rax] add rsp,38h ret With the optimization pass it becomes: sub rsp,38h mov dword ptr [rsp],16h cmp ecx,0 jne 0000015DC3B33074 mov eax,dword ptr [rsp] add rsp,38h ret Also add a couple of unit tests for corner cases where the propagation is not safe to perform. Bug: b/179279298 Change-Id: I784899319bf5360f47c6fbc22fb82134d135dbfc Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52468 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>