424 Commits

Author SHA1 Message Date
Geoff Lang
9aadc7aacd Metal: Require MSL 2.1.
We had previously shipped both MSL 2.0 and 2.1 shaders to support
MacOS 10.13 (MSL 2.0 only) while also supporting the stencil blit
fast path that MSL 2.1 provides with the has_shader_stencil_output
feature.

Each configuration of precompiled shaders is ~300kb so we will drop
support for MacOS 10.13 and only ship the MSL 2.1 shaders.

Rework of the disablement for NVIDIA and GPU family 1 to be more
readable. The features themselves are always true because "disable on
NVIDIA" is always true and the check for "is NVIDIA" is moved to the
code which fails the initialization.

Bug: angleproject:8258
Change-Id: Icc8c69540e43fd2b0b237fffbfe170bb3422903f
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4681130
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
2023-07-17 22:00:36 +00:00
Phan Quang Minh
4cab5e94fc Vulkan: Enable timeline semaphores if supported by device
This is needed for a similar change in Chromium to function with
`--enable-features=VulkanFromANGLE`.

Bug: angleproject:8253
Change-Id: I422964ea010c650439dd4797ee8ba7b533f26a87
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4675807
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
2023-07-12 11:11:51 +00:00
Geoff Lang
4e6124dae8 GL: Ensure all instanced attributes have a buffer with data
Apple OpenGL drivers sometimes crash when given an instanced draw with
a buffer that has never been given data.

It's not efficient to check if the attribute is both zero-sized and
instanced so just ensure that every time a zero-sized buffer is bound
to an attribute, it gets initialized with some data.

Bug: chromium:1456243
Change-Id: I66b7c7017843153db2df3bc50010cba765d03c5f
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4642048
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
2023-07-11 17:25:50 +00:00
Shahbaz Youssefi
f5ad056b0d GL: Fix ScalarizeVecAndMatConstructorArgs and move to gl/
This transformation was buggy and was disabled.  Originally, it was
intended to be used everywhere.  It is now needed for a GL driver
workaround.

This change reimplements this transformation and uses it as a GL
workaround.

Bug: chromium:1420130
Change-Id: I42d63fa5844bcf683ac41e61925aa637e033ca2e
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4676634
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
2023-07-11 15:08:28 +00:00
Steven Noonan
42c3a9fe3e Vulkan: support creating context with MoltenVK on macOS
The Vulkan loader somewhat recently introduced a requirement that
clients must opt-in to using portability implementations of Vulkan (such
as MoltenVK). Since there is no native Vulkan driver for macOS (and
therefore no alternative), unconditionally enable the portability
enumeration extension there.

Bug: angleproject:8229
Change-Id: I24f0f24e25abd277855ed9ac4de370cfb47d3266
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4639495
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Steven Noonan <steven@uplinklabs.net>
Reviewed-by: Charlie Lao <cclao@google.com>
Auto-Submit: Steven Noonan <steven@uplinklabs.net>
2023-06-27 02:25:34 +00:00
Mohan Maiya
0fe6f28262 Reset and then populate frontend features during display initialize
Overwritten features were never reset even if a display was
terminated. On platforms that reuse displays for all tests
in the end2end suite, overridden feature would leak into
subsequent tests causing unexpected failure.

Bug: angleproject:8235
Change-Id: I1b359bc762a2bca8db4e4dbc7a587604e5bd6a5b
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4643453
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: mohan maiya <m.maiya@samsung.com>
2023-06-26 17:15:59 +00:00
Steven Noonan
ac263582dd Vulkan: add workaround for VK_EXT_full_screen_exclusive on AMD
On outdated (but recent) AMD drivers, the Windows-only Vulkan extension
VK_EXT_full_screen_exclusive appeared to be implicitly enabled and set
to VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT mode. Even though
ANGLE did not enable or interact with this extension at all, the driver
was incorrectly returning VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT
error codes on various swapchain operations when the full screen window
focus was lost (i.e. alt-tab out and back in). Naturally, ANGLE was not
expecting these error codes and did not know how to handle them.
Depending on where the errors occurred, ANGLE might crash or retry
creating the swapchain repeatedly.

Treating the unexpected VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT
error code as VK_ERROR_OUT_OF_DATE_KHR/VK_SUBOPTIMAL_KHR was not
sufficient, because the driver would repeat the error on every swapchain
operation, apparently expecting the error to be handled by
a vkAcquireFullScreenExclusiveModeEXT call (even though that would make
no sense, since the extension was not enabled).

The incorrect driver behavior was reported to AMD and was fixed in
recent driver releases. The earliest driver I've tested and know to be
working is AMD's Adrenaline driver version 23.5.2
(VkPhysicalDeviceProperties calls this driverVersion 2.0.262/0x800106).
The last known bad version was 0x8000e9.

The simplest workaround on these older AMD graphics drivers is to
explicitly enable the extension, but set it to
VK_FULL_SCREEN_EXCLUSIVE_DISALLOWED_EXT mode. On newer drivers we do not
need to do anything with the extension and can ignore it.

Bug: angleproject:8215
Change-Id: I7c58d47a0350f4b0bc1a77f200c1e2f72fcde8d8
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4627279
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Charlie Lao <cclao@google.com>
2023-06-21 20:37:29 +00:00
Kramer Ge
88c6dfcc7d Mali: Make the placeholder FBO complete for timer queries
Change the bindFramebufferForTimerQueries workaround to ensure
the framebuffer is complete.

Bug: chromium:1356053,b/269068358
Change-Id: Ief3198fdc4800468670a3f4323a1ffd3ca083c6f
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4582606
Auto-Submit: Kramer Ge <fangzhoug@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
2023-06-15 15:26:04 +00:00
Roman Lavrov
1572f609c1 Disable hashes for ANGLE features generator
Features autogen files are small, fast to regenerate.
Run the generator in --verify-only mode and check content every time,
instead of using hashes.

Bug: angleproject:8193
Change-Id: I3988ab50a6c33171b7b7252c03f34a74f09fcf18
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4604579
Commit-Queue: Roman Lavrov <romanl@google.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
2023-06-12 22:14:32 +00:00
Roman Lavrov
21f16cb163 Disable clang-format on ANGLE features autogen outputs
Updates the script to produce reasonably formatted code without
clang-format.

Autogen files moved to autogen/ sub-directories because clang-format
does not support per-file settings ;(

This allows to run this codegen very quickly
(~50ms on my machine)

Bug: angleproject:8193
Change-Id: Ie84282090d574ebb4debe3edcfd82f983f27a5ff
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4604578
Commit-Queue: Roman Lavrov <romanl@google.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
2023-06-12 17:52:18 +00:00
Shahbaz Youssefi
b0e9bbd79f Vulkan: Split features for dynamic state
When a driver bug with dynamic state is encountered, it is hard to debug
which dynamic state exactly is causing an issue, due to the current
granularity of disabling all entire state from an extension.  With this
change, every dynamic state gets its own ANGLE feature, and can be
toggled as necessary.

Disabling the supportsExtendedDynamicState* features implicitly
disables all dependent features.

Bug: b/285124778
Bug: b/275210062
Bug: fuchsia:107106
Bug: angleproject:5906
Change-Id: Ic291279872df2d0eb58618ff364ab118bdcc4a9f
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4577553
Reviewed-by: Cody Northrop <cnorthrop@google.com>
Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Yuxin Hu <yuxinhu@google.com>
2023-06-01 00:37:50 +00:00
Yuxin Hu
dfb2bab0bb Apply Aliased Decorators To Image DataTypes
Bug: b/274478912
Bug: b/266235549
Change-Id: I2cd272a1e7481a8803be63efe0be11c61560b23e
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4568287
Commit-Queue: Yuxin Hu <yuxinhu@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
2023-05-31 16:25:55 +00:00
Roman Lavrov
16b9a16ae4 Add supports_legacy_dithering feature
VK_EXT_legacy_dithering =>
VkPhysicalDeviceLegacyDitheringFeaturesEXT.legacyDithering =>
supportsLegacyDithering

Now getting enabled=true on Android master.

Bug: b/284462263
Change-Id: Ibf43184c78d9847044b10413d2050b653e452c9b
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4567572
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
2023-05-26 21:08:32 +00:00
Kenneth Russell
aea8856277 Reland "Metal: Optimized BufferSubData per device"
This reverts commit ee64836f70 ,
relanding the patch stack described there.

Between patchsets 1 and 5:

- The shadow buffer allocation has been replaced with a multimap of
  precisely-sized buffers, rather than rounding up buffer sizes.

- Garbage collection of shadow buffers is triggered in three situations:

  - A certain number of context switches have occurred; this number
    was hand-tuned to avoid GC every frame.

  - A certain number of command buffer submissions has occurred; this
    number was hand-tuned to GC no more often than every few seconds
    on representative workloads.

  - The total size of the allocated shadow buffers is more than 1 MB,
    and either more than twice the size at the last garbage
    collection, or 64 MB more than at the last garbage collection. In
    this case, aggressive GC is performed in order to reclaim shadow
    buffers more quickly.

Performance before and after these changes appears identical on
microbenchmarks. On one Figma test case, comparing GPU memory
allocated inside the BufferManager, peak consumption is decreased by
over 75%, and steady-state consumption decreases by over 88%.

Patchset 6 adds a needed workaround for a bug in the
AMDMTLBronzeDriver affecting uploads of client-side data, and
therefore some dEQP tests. It also streamlines the aggressive GC.

Bug: angleproject:7544
Change-Id: I81b061f0b33c27fa403527fa12d626f4e9c88ebe
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4497413
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
2023-05-25 18:43:45 +00:00
Alexey Knyazev
33e3886213 Vulkan: Limit clampFragDepth workaround to affected drivers
Bug: angleproject:3970
Change-Id: I708591d86b8f2cb10d0cbdc7c14518fda45ac626
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4562134
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
2023-05-24 14:36:44 +00:00
Geoff Lang
6d3e587004 Metal: Disable Metal support on NVIDIA GPUs
NVIDIA GPUs are in a very small number of Macs and we don't have have
adequate test coverage to properly support them.

Add the disable_metal_on_nvidia feature to control support for NVIDIA
at runtime. Also factor the support of GPU family 1 into a feature.

Bug: angleproject:8170
Change-Id: I160036d710cc9e278eb77e351a483b9f5b69e8ce
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4544659
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
2023-05-23 21:19:55 +00:00
Alexey Knyazev
7abc5248d8 Vulkan: Enable VK_EXT_depth_clamp_zero_one
Replaced the 'depth_clamping' workaround
with the dedicated extension or explicit
fragment depth clamping.

Fixed: angleproject:3970
Bug: angleproject:8077
Change-Id: Ia7666fcb3e0e949922c13a3fd11b818cbc5a8e26
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4545084
Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
2023-05-23 17:43:28 +00:00
Brian Ho
ea0b1b7b0e Selectively advertise base vertex and instance fns
On newer Mali GPUs (Valhall), the glDraw*BaseVertex* implementations
seem to be buggy and cause noticable artifacts. Chrome uses the
presence of baseVertexBaseInstanceANGLE and baseInstanceEXT
extensions to determine whether it can draw with a base vertex or to
fallback to manually offsetting the vbo.

This CL disables these extensions on Mali Valhall so that Chrome
takes the fallback path instead to fix the visual artifacts.

Bug: b/280931795
Change-Id: Ic27e37465283ca3338747b53aa7888c7eba4b7b8
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4549682
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
2023-05-19 21:05:57 +00:00
Shahbaz Youssefi
b76166d027 Vulkan: Separate image and sampler 2D view of 3D features
The sampler feature is used to determine if EGL_KHR_gl_texture_3D_image
can be exposed.  The image feature is used to support base GLES 3.1
storage images.

Bug: b/274478146
Change-Id: Ifb283633078ace7ee65f8aafe756d0a02b727bd7
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4545005
Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
2023-05-19 01:32:44 +00:00
Mark Lobodzinski
c9ce8f33a8 Revert "Don't export ANGLE platform methods."
This reverts commit 7a11f4415e.

Reason for revert:
Running Android games using ANGLE results in crashes or hangs.

Original change's description:
> Don't export ANGLE platform methods.
>
> These functions are loaded through eglGetProcAddress. We don't need
> to export these extra symbols and increase our binary size.
>
> Bug: chromium:1445969
> Change-Id: I494bbcb86973f167e8245b56e6eb73da7eab69f5
> Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4538367
> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>

Bug: b/283233503
Change-Id: I42418c0dabc440fb13ce3d48d63b2622b9edd15e
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4544216
Commit-Queue: Mark Łobodziński <mark@lunarg.com>
Reviewed-by: Mark Łobodziński <mark@lunarg.com>
Reviewed-by: Yuxin Hu <yuxinhu@google.com>
2023-05-18 23:17:00 +00:00
Geoff Lang
7a11f4415e Don't export ANGLE platform methods.
These functions are loaded through eglGetProcAddress. We don't need
to export these extra symbols and increase our binary size.

Bug: chromium:1445969
Change-Id: I494bbcb86973f167e8245b56e6eb73da7eab69f5
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4538367
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
2023-05-18 02:26:18 +00:00
Cody Northrop
ec308b3555 Vulkan: Add feature to limit sample count to 2
This CL adds a feature called `limitSampleCountTo2`.  Using it will
have the Vulkan backend limit max samples to 2.

Why 2?  That's the minimum required in Vulkan to multisample without
error.  Here's an example validation error:

    vkCmdResolveImage: srcImage sample count is VK_SAMPLE_COUNT_1_BIT.
    The Vulkan spec states: srcImage must have a sample count equal to
    any valid sample count value other than VK_SAMPLE_COUNT_1_BIT.
    https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdResolveImage-srcImage-00257

Using a limit as opposed to forcing a value allows non-multisampling
(sample count of 1) to continue working.

To see how tests fare when the feature is set, see the following test
results that force the value on:
https://chromium-review.googlesource.com/c/angle/angle/+/4534098/4

Test: adb shell setprop debug.angle.feature_overrides_enabled limitSampleCountTo2
Bug: b/279498079
Bug: angleproject:8162
Change-Id: I1df2822709151e6084c32055b5aff444e0b10db5
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4518562
Commit-Queue: Cody Northrop <cnorthrop@google.com>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Greg Schlomoff <gregschlom@google.com>
Reviewed-by: Charlie Lao <cclao@google.com>
2023-05-16 23:17:32 +00:00
Geoff Lang
b1395bcbac GL: Disable EXT_clip_control on Mali-G72 and G76.
Querying the clip control state from the driver when sychronizing
external contexts generates driver errors.

Simply disable this extension in this configuration for now.
Chrome is currently not using it for rasterization.

This issue was noticed on specific Huawei devices in the wild. It
hasn't been observed on other OEMs.

Bug: chromium:1434317
Change-Id: I88d9bff1933274f61020b75e68aee9c94b0b684a
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4518062
Reviewed-by: Peng Huang <penghuang@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Colin Blundell <blundell@chromium.org>
2023-05-11 16:26:30 +00:00
Hailin Zhang
8b9440b630 Vulkan: add option to control pipeline cache data compression.
Bug: b/258207403
Change-Id: I487b1cadbacfa2f7ee889a8f58278307a126a391
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4497248
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Charlie Lao <cclao@google.com>
Commit-Queue: Hailin Zhang <hailinzhang@google.com>
2023-05-11 02:26:49 +00:00
Scott Violet
b0f9c01ec3 metal: adds feature that minimizes generated shader differences
This adds a feature (enabled by default) that results in
generating the same code regardless of whether emulateAlphaToCoverage
is enabled or addExplicitBoolCasts. This is done to maximize
cache sharing.

Bug: chromium:1423136
Change-Id: Ia491f13469c750fc2c45aecf1f93fed53b782dc5
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4496254
Reviewed-by: Alexey Knyazev <lexa.knyazev@gmail.com>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
2023-05-09 21:20:43 +00:00
Scott Violet
3e28121912 Adds feature to output blob cache key and source for shader
Bug: chromium:1423136
Change-Id: Ic03e1b9971b2f1417c0b2e95c8d3846f28a01572
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4480976
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
2023-04-28 14:53:12 +00:00
Scott Violet
059bfe8909 metal(ish): Adds platform function for logging cache hits/misses
And adds call from metal.
This way chrome can log overall cache stats.

Bug: chromium:1423136
Change-Id: Iba5b3bd138adf15fe5e999d3dee0002f140edac1
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4484260
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
2023-04-28 13:43:45 +00:00
Kimmo Kinnunen
20b6624a88 Metal: Support compiling on iOS without EAGL
Makes EAGL and CGL compilation exclusive to each other. Catalyst would
compile with both on ARM64, but only use EAGL.

Remove use of GLSL generation in MSL. Generating GLSL for MSL
compute and geometry shaders do not make sense.

Remove compilation of RewriteRowMajorMatrices for Metal.
It was removed from Metal in:
  b23bf47c9e
  Reland "Metal: rewrite default uniforms and uniform blocks"

Remove use of ANGLE_ENABLE_APPLE_WORKAROUNDS and gn variable
angle_enable_apple_translator_workarounds. The workarounds are just
unconditional business-as-usual implementation of ANGLE when ANGLE is
compile for PLATFORM_APPLE.

Fixed: angleproject:8129
Change-Id: I3af249708803fba816e2a7c92c35dddb84ce6946
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4428875
Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com>
Reviewed-by: Kyle Piddington <kpiddington@apple.com>
Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com>
Reviewed-by: Dan Glastonbury <djg@apple.com>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
2023-04-19 09:22:51 +00:00
Yuxin Hu
6deca89e69 Add Spirv Instruction to explicitly cast mediump float to 16 bit
If the GLSL shader code expects the comparison between
two mediump float values returning true, but the SpirV
compiler treats one of them as 32-bit, and treats the
other one as 16-bit, the comparison would return false
instead. The SpirV compiler may not automatically cast
the mediump float values to 16 bits, because it may
utilize the RelaxedPrecision decoration to keep a mediump
float as 32-bit, so that the compiler can avoid the
type cast from 32-bit highp to 16-bit mediump.

This change adds an additional OpQuantizeToF16 SpirV
instruction to explicitly cast mediump float scalar
or mediump float vector to 16 bit, if they are assigned
with a highp float value. This ensures that if the
GLSL shader code ever compares two meiump float values,
the SpirV shader compiler is not accidentally comparing
a 16 bit with a 32 bit float value.

This fixe the deqp test failure on Pixel 6 and Pixel 7:
dEQP-GLES2.functional.shaders.algorithm.rgb_to_hsl_vertex.

Bug: b/274859104
Bug: b/274408172
Change-Id: Ifd996cea14c0f77f45ae90f38c8e53cf5035139f
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4400404
Commit-Queue: Yuxin Hu <yuxinhu@google.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Cody Northrop <cnorthrop@google.com>
2023-04-18 21:42:19 +00:00
Scott Violet
65f4d2a45c Adds features to enable loading/saving metallibs to blobcache
CompileMetalShaders results in the appropriate command line tool
being run to generate metallib blobs from shader source.

DisableProgramCaching results in not saving programs to BlobCache

LoadMetalShadersFromBlobCache results in trying to load metallibs
from BlobCache.

Bug: chromium:1423136
Change-Id: I01a4d7a5d60ed5ac978fb99db01b741e0f19e76b
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4434293
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
2023-04-18 17:45:20 +00:00
Alexey Knyazev
7bc4b7e31f Metal: Implement OES_sample_variables
New ESSL built-ins are mapped to their Metal
counterparts and tweaked to follow OpenGL ES
semantics when needed.

Fixed A2C interaction with sample coverage
by emulating the former on non-Apple GPUs.

Bug: angleproject:8097
Fixed: angleproject:5087
Change-Id: I5d28a941af5cbc14743a3930731529f11f55febd
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4404896
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Kyle Piddington <kpiddington@apple.com>
Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
2023-04-15 01:32:19 +00:00
Shahbaz Youssefi
c26011b866 Vulkan: Make advanced blend alpha div workaround permanent
This workaround turned out to affect pretty much every driver, and
numerous GL implementations were found to work around it similarly to
ANGLE.  It seems like this workaround may only be necessary for
colorburn and colordodge, but for now ANGLE applies it to all modes.

Bug: b/274528004
Bug: b/277777623
Change-Id: Id555c981a9775f949a3022b7e92c755accea7cea
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4416158
Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
2023-04-13 02:40:41 +00:00
Shahbaz Youssefi
3aea3cfd1a Vulkan: Workaround depth bias constant factor on ANV
Bug: b/249380591
Change-Id: Iaeda7faf5eb40e0e2086674d3e63bf5bc9911ab4
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4392893
Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
2023-04-04 01:56:36 +00:00
Geoff Lang
f1f80e1e3f Metal: Always prefer staged GPU uploads for textures.
Uploading Metal texture data via MTLTexture::replaceRegion is a source
of lots of CPU hangs and jank. There may be better heuristics to
determine if we should do a CPU vs GPU upload but for now preferring
GPU uploads has better overall performance.

This also improves the MotionMark images test:
 - 40 -> 100 when using Metal.
 - 217 -> 235 when using Metal +
    https://chromium-review.googlesource.com/c/chromium/src/+/4091749

Bug: angleproject:8024, angleproject:8092, angleproject:8109
Change-Id: I36b5f585884391b4cc416365ae65f8542745beee
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4264963
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
2023-04-03 18:56:52 +00:00
Yuxin Hu
29abd5a295 Explicitly Add Aliased Memory Decoration in SpirV
In GLSL, aliased memory qualifier is implicitly available,
unless we explicitly specify the memory is restrict:
https://www.khronos.org/opengl/wiki/Type_Qualifier_(GLSL)#Memory_qualifiers.

However, in SpirV, aliased memory qualifier has to be
explicitly specified:
https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#AliasingSection

This change adds the aliased memory decorations to SSBO
if the GLSL does not specify the restrict memory qualifier.

This is a temporary workaround to fix the deqp test failures
on some android devices. Eventually we would like to waive this
test for ANGLE due to alised memory in Vulkan does not suppose
to affect SSBOs that have different set/binding, please refer
to this Khronos ticket for more details:
https://gitlab.khronos.org/Tracker/vk-gl-cts/-/issues/4321

Bug: b/266235549
Change-Id: Ic7afc417a5d421664b60e0413a011314787e14e7
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4312130
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
2023-03-29 19:56:11 +00:00
Shahbaz Youssefi
97897d92dc Vulkan: Work around driver bug with dynamic primitive restart
This CL forces the state to be static on buggy drivers.

Bug: b/275210062
Change-Id: Ia3391ecb19c3c9d19c05a83e11da8c718513a4e2
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4374104
Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@google.com>
2023-03-29 15:26:32 +00:00
Kramer Ge
888ca8d9e3 Bind FBO before timer query on Mali GL driver.
glBeginQuery(GL_TIME_ELAPSED/GL_TIMESTAMP) on Mali implementation
assumes a complete FrameBuffer. Without it glGetQueryObject will return
a meaningless value, causing some applications to misbehave.

This workaround caches and binds a default FBO in this case.

Bug: chromium:1356053,b/269068358
Change-Id: I756ded948c2c5aada744f9dd428ad77c37a009c6
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4359032
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Kramer Ge <fangzhoug@chromium.org>
2023-03-22 16:49:48 +00:00
Alexey Knyazev
4256c02245 Metal: Implement ANGLE_stencil_texturing
Used texture views to sample stencil values
from combined depth/stencil textures.

Texture2DDepthStencilTestES3.TexSampleModes* tests
were split into swizzled and non-swizzled variants
to suppress only swizzled cases on some platforms.

Added a new avoidStencilTextureSwizzle workaround to
skip creating swizzled texture views of stencil-only
textures on platforms that fail to sample from them.

Fixed: angleproject:8051
Change-Id: I0b1148f8d30fc6459239efcdaeee6c0364633cc8
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4304058
Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
2023-03-07 17:16:56 +00:00
Igor Nazarov
4f87f4e925 Vulkan: Add useResetCommandBufferBitForSecondaryPools feature.
Currently ANGLE does not use "vkResetCommandBuffer()" on Vulkan
Secondary Command Buffers. Instead it uses "vkFreeCommandBuffers()" and
"vkAllocateCommandBuffers".

According to spec, "VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT" is
required only for command buffer reset operations.

However, some ARM drivers may not free memory in
"vkFreeCommandBuffers()" without this flag.

Bug: angleproject:8059
Change-Id: Ibfe45bca345dc48484b625c450369d30805cec77
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4306722
Reviewed-by: Charlie Lao <cclao@google.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Igor Nazarov <i.nazarov@samsung.com>
2023-03-06 19:06:29 +00:00
Alexey Knyazev
3fed0866a8 Implement EXT_texture_mirror_clamp_to_edge
Support GL_MIRROR_CLAMP_TO_EDGE_EXT address
mode when native support is available.

Adjusted validation, sorted switch cases by
target enums order.

Added new TextureMirrorClampToEdge* end2end
tests.

Drive-by: fixed texture address computation
for integer formats with GL_MIRRORED_REPEAT
on D3D11.

Fixed: angleproject:7968
Change-Id: Iaf29c8b4b32a7630c2a871f832d171f4bc4e2672
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4289137
Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Yuxin Hu <yuxinhu@google.com>
2023-03-03 05:30:44 +00:00
Charlie Lao
6d282d62b3 Vulkan: Move retireFinishedCommands/garbageCleanup to worker thread
This CL separate out the logic of mLastCompletedQueueSerial update and
retireFinishedCommands and garbage clean up into different functions. At
submission, previously we are always check fence and update
mLastCompletedQueueSerials and calling reset on finished commands and do
garbage clean up. With this CL, we only do the fence check and update
mLastCompletedQueueSerials. Then it request worker thread to do the
command buffer reset and garbage cleanup. We uses the CommandProcessor's
thread for the reset and cleanup, since async submission path needs to
handle this clean up anyway.

This CL also added a new feature flag asyncCommandBufferReset and it is
disabled right now. This will be enabled in the follow up CL.

Bug: b/255411748
Change-Id: I6da558f8d4c962eb038e2378ccc76c464101cde2
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4244823
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Auto-Submit: Charlie Lao <cclao@google.com>
Commit-Queue: Charlie Lao <cclao@google.com>
Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
2023-02-28 19:17:06 +00:00
Alexey Knyazev
a1f9b9aaa6 Implement more texture border color adjustments
D3D11:
* Exposed EXT_texture_border_clamp extension string,
  to ensure that the relevant CTS tests are running.

* Updated StateManager11::setSamplerState to adjust
  the border color based on the texture format.

* Refactored ShaderConstants11::updateSamplerMetadata to
  correctly adjust the border color for integer formats.

* Removed unused SamplerMetadata.internalFormatBits

D3D9:
* Updated Renderer9::setSamplerState to adjust the border
  color value based on the current texture format.

* Added borderColorSrgb feature required for some drivers.

GL:
* Copy alpha value to green for A and LA legacy formats to
  workaround driver bugs when lumaWorkaround is not used.

Tests:
* Added ES 2.0 tests for texture formats
  that require border color adjustments.

Fixed: angleproject:7969
Change-Id: I3d36cce43e76e6d5069a51865152c2250ecbb017
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4291000
Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
2023-02-28 03:59:22 +00:00
Amirali Abdolrashidi
3a7904e137 Vulkan: Use VMA suballocation for images
There is a maximum limit for device memory object allocation. On some
platforms, there can be an error regarding too many object allocations
when 4096 device memory handles have been allocated. Suballocation can
help mitigate this issue. In this CL, some images will be allocated
using VMA API calls, which use suballocation.

* Added a new feature (useVmaForImageSuballocation).

  * Added VMA allocation for ImageHelper, which is used in initMemory().

    * Suballocation is used for VMA image allocation.

    * If enabled, mVmaAllocation will be initialized in the ImageHelper
      object (instead of mDeviceMemory).

  * It is currently used for all platforms.

* Minor change to the name of an arg in CreateBuffer() declaration.

* Added test to make sure we can allocate at least 4096 images on
  supported platforms (8000 in the test).

* Skipped the test "NonZeroBaseEmulatedClear" when run on Linux/Intel
  if this feature is enabled (due to output color mismatch).

* Skipped several tests for capture/replay on Windows.

Bug: b/218891184
Change-Id: Ibf80c9c8c485b301da7d23b5ba4bcbb1a8e3194f
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4191202
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Charlie Lao <cclao@google.com>
Commit-Queue: Amirali Abdolrashidi <abdolrashidi@google.com>
2023-02-23 20:17:15 +00:00
Geoff Lang
5a77200b3b Metal: Implement parallel shader linking.
Update the Metal library cache to be thread safe. Change
absl::flat_hash_map back to std::unordered_map because the value types
now contain a mutex which must not move.

Only generate async compilation tasks for shaders that were not already
compiled and in the cache.

Collapse some of the link methods in ProgramMtl that only had one call
site. All linking is now done in ProgramMtl::link and
ProgramMtl::load.

Support disabling parallel linking using the new
enableParallelMtlLibraryCompilation feature.

Bug: chromium:1385510
Change-Id: I71ba71a34d994066729df7e4170911f88c89de4a
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4234153
Reviewed-by: Quyen Le <lehoangquyen@chromium.org>
Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
2023-02-14 22:05:11 +00:00
Kenneth Russell
ee64836f70 Revert "Metal: Optimized BufferSubData per device"
This reverts commit 968041b547.

Includes the following patches:

git revert -n 995db1f66b \
  9a6c90c8f8 \
  dbd47e3785 \
  369b320f92 \
  4abae6f975 \
  968041b547

Several conflicts with top-of-tree were resolved during this revert.

The aim is to reland this with additional code which will reduce the
amount of excess buffer memory allocated, and release the resources
associated with temporary buffer allocations.

Bug: angleproject:7544
Change-Id: Ib7a6bc2ab1c2f23cb43112cd980106e2898c3826
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4240556
Reviewed-by: Kimmo Kinnunen <kkinnunen@apple.com>
Reviewed-by: Gregg Tavares <gman@chromium.org>
Commit-Queue: Kenneth Russell <kbr@chromium.org>
2023-02-14 05:13:17 +00:00
Shahbaz Youssefi
54951da226 Vulkan: Refactor extension vs core version checks
Extensions are now grouped based on promotion-to-core status, and
initialization code is generally cleaned up.  ANGLE currently doesn't
attempt to use a core version above Vulkan 1.1, as extensions are always
assumed to be exposed even if promoted to core in later versions.

With this change, it would be simpler to use a newer core version if
ever necessary.

Bug: angleproject:7959
Change-Id: Ia5fd3e06c18f7289e9e5a63af0f039a6dc89c687
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4224582
Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Ian Elliott <ianelliott@google.com>
Reviewed-by: Charlie Lao <cclao@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
2023-02-13 16:09:49 +00:00
Shahbaz Youssefi
b38467147b Vulkan: Feature to make async queue slow for testing
Bug: angleproject:6746
Change-Id: I2573cae2dcf42d177168c55bc2a6d8bb012dde18
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4227986
Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Charlie Lao <cclao@google.com>
2023-02-07 21:05:22 +00:00
Geoff Lang
9b00af5260 Metal: Add an in-memory MTLLibrary cache.
Add a small cache for (msl + compile parameters) -> MTLLibrary at the
egl::Display level. In regular executions of Chrome, the same shaders
(particularly vertex) are compiled multiple times in different programs.

Tested for a regular Chrome startup + open wikipedia + motionmark 1.2:
112/282 (40%) cache hits.

Several different caching methods were profiled (LinkProgram perf test)
 - struct key with std::map                             : 303309
 - struct key with std::unordered_map                   : 308090
 - binary blob key with std::map                        : 263595
 - binary blob key with std::unordered_map              : 286051
 - struct key + is_transparent with std::unordered_map  : 304877
 - struct key + is_transparent with absl::flat_hash_map : 335686

Using is_transparent allows us to search the hash map without
copying the shader source string to construct the key structure.

Bug: chromium:1385510
Change-Id: Ieec4ba526fe286276a4af7114d89cde32a8f9e1d
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4214012
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
2023-02-02 20:35:03 +00:00
Geoff Lang
18657894ba Add features to dump and replace shader source.
dump_shader_source writes shader source strings to files named
with the hash of the source and shader type.

enable_shader_substitution allows subsituting the shader source
with the strings contained in a file. The same file naming scheme
as dump_shader_source is used so shaders can be dumped in one run,
modified and subsititued in the next run.

Use the ANGLE_SHADER_DUMP_PATH and debug.angle.shader_dump_path
environment variables to control where files are written. If they
are unspecified, write to the temp directory.

Based upon Cody's CLs:
https://chromium-review.googlesource.com/c/angle/angle/+/2755841
https://chromium-review.googlesource.com/c/angle/angle/+/3961670

Bug: angleproject:7760, chromium:1385510
Change-Id: I43b9827b977079b88daa794e867637f7a126b080
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4192347
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Cody Northrop <cnorthrop@google.com>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
2023-01-26 16:54:28 +00:00
Shahbaz Youssefi
ffbb65bc9e Vulkan: Use VK_EXT_swapchain_maintenance1 for present fences
Bug: angleproject:7878
Change-Id: Ic3a43c663789a6489cff261848d9ad4a408ca53a
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4088905
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Charlie Lao <cclao@google.com>
Reviewed-by: Ian Elliott <ianelliott@google.com>
2023-01-19 20:13:01 +00:00