ensureIncompleteTexturesCreated is called in every syncState and
initializes all types of incomplete textures, even when they are not
used.
Skip it entirely. ContextMtl::getIncompleteTexture already lazily
creates the incomplete textures, per type.
This saves about 1mb (~5% of ANGLE's allocations for Chrome) of
malloc'd memory per context.
Bug: chromium:1329376
Change-Id: I14ab7098ce2e486383d1d0d41039f0e526755878
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4615190
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Quyen Le <lehoangquyen@chromium.org>
Previously, resource binding assignment was done as such:
```
for each shader stage
assign bindings to textures
assign bindings to blocks
assign bindings to images
etc
```
To deduplicate bindings when the same resource was used in multiple
stages, a map was used, keyed by the resource's name, to detect when an
already visited resource is encountered in a future stage. This was
both inefficient and unnecessarily complicated.
With this change, resource binding assignment is done as such:
```
for each texture
assign one binding to all shader stages
for each block
assign one binding to all shader stages
for each image
assign one binding to all shader stages
etc
```
The aforementioned map is removed.
Because the resource bindings are now changed, the rest of the code
(which sets up the pipeline layout, updates descriptor sets, sets
dynamic buffer offsets, etc) are all updated to follow the above
pattern. As a result, nested loops are avoided and duplicate entries in
the variable map are never visited.
Bug: angleproject:7220
Change-Id: Iaff7b5f8b2bada8ac5078d21e5c790bf0d27aca7
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4622011
Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Charlie Lao <cclao@google.com>
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>
On drivers before R530, there are some transient visual glitches in
rendering when using VK_EXT_graphics_pipeline_library. Basically you
might see correct renders for a few frames, very incorrect renders for
about 10-20 frames, and then it would render correctly from then on.
This problem went away either at R530 or slightly after. This change
sets the minimum version to R531, which is the first version I observed
behaving correctly.
Bug: angleproject:8218
Change-Id: I7af4f74c1469ecf2306dec0cab9062eff2ec5f2c
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4627277
Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Not doing so results in VVL errors (you need the GPU-assisted validation
preset enabled to see this error):
[ VUID-VkDrawIndexedIndirectCommand-firstInstance-00554 ]
The drawIndirectFirstInstance feature is not enabled, but the
firstInstance member of the VkDrawIndexedIndirectCommand structure
at index 1 is not zero The Vulkan spec states: If the
drawIndirectFirstInstance feature is not enabled, firstInstance must
be 0
Bug: angleproject:8220
Change-Id: Ia43036584b85e4a7d9c3fcaf793be94b965f708f
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4627278
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
This optimizes for both memory usage and time. Before this change, we
had a redundant copy of the shader source fragments in memory:
- The user application
- The ostringstream buffer
- The final concatenated string
The second one can be avoided by not using ostringstream.
The second issue is that ostringstream will reallocate as we fill it,
and depending on the number of input strings (and their size), it may
reallocate several times. Since we aren't doing anything particularly
fancy with the ostringstream, we can just preallocate the appropriately
sized string and fill it with the input strings all at once.
If we don't mind taking an additional dependency on abseil-cpp, this
could also be implemented with absl::StrJoin, but it seems like a heavy
dependency for something relatively simple.
Tests run: GLSLTest.*ShaderLength*
Bug: angleproject:8219
Change-Id: Idba277e7860116f858e7a86f4b03420dd383a52f
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4627282
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
If you have a multisampled color+depth framebuffer and discard depth
before the end of the render pass, ANGLE skips assigning
pDepthStencilResolveAttachment. Doing so is fine on most vendors, but on
AMD drivers, the application will crash in the user mode driver when
calling vkCreateRenderPass2KHR.
Simply not adding the depth/stencil resolve structure to the PNext chain
avoids the crash and allows the application to function normally.
Bug: angleproject:8217
Change-Id: I0dc14c03d2b999e280a4d363e0296fd10812540c
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4627280
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Some logic already in SpvGetShaderSpirvCode was duplicated for program
pipelines. In particular, this necessitated exposing UniformBindingInfo
which is an internal detail of SpvAssignLocations.
In a follow up, UniformBindingInfo will be removed altogether.
Bug: angleproject:7220
Change-Id: I9fa60c716de6dfb0d3a72c4f4dd3822043bab308
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4622010
Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Reviewed-by: Roman Lavrov <romanl@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
When an app attempts to use the GL backend on Windows, there is
currently an undocumented hard requirement for
EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE. This is caused by
EGL_ANGLE_surface_orientation not being fully implemented, so
instead let ANGLE fall back to the slow WGL pipeline.
See: I012168531d8c2e5b189671533cea9f57ec713538
BUG: angleproject:8201
Change-Id: I28c6a948a5fc0e3ebfff86c4cbf95c666f5c7cd4
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4614646
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Cache Metal render pipelines in a new mtl::PipelineCache which lives
at the context level. This allows us to clean up unused pipelines from
programs that are not actively used.
The cache limits were chosen based on running Chromium. Without a
limit, the total number of pipelines peaks at ~200. With frequent GCs,
the active working set usually sits at ~60 pipelines.
Bug: chromium:1329376
Change-Id: Ifa83b797c893684294e16dd638f6b3a35e1d043f
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4608486
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Quyen Le <lehoangquyen@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Now that the SPIR-V transformer no longer relies on names, we can avoid
generating them in the compiler in the first place.
This both removes the need for stripping them out and makes the shaders
(which are cached) a bit smaller.
Bug: angleproject:7220
Change-Id: Ie636ac0ee62cf2730a409872041d22c066fc22ff
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4615238
Reviewed-by: Roman Lavrov <romanl@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Yuxin Hu <yuxinhu@google.com>
... instead of prefixing them with _u. The transformer no longer relies
on debug info, which means SPIR-V names can be completely arbitrary.
There is no risk of collision with ANGLE internal names because it
doesn't matter for SPIR-V, and SPIR-V Cross is able to handle duplicate
names.
This change makes the output of SPIR-V Cross on generated shaders more
readable as it's not cluttered with _u before every name.
Bug: angleproject:7220
Change-Id: If46f7c82f908b0d65f8be49e297384ab659369e8
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4615237
Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Reviewed-by: Roman Lavrov <romanl@google.com>
Commit-Queue: Roman Lavrov <romanl@google.com>
Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org>
This change removes the SPIR-V transformer's reliance on type and
variable names. As a result:
- String hashing is removed from the info map data structure and the
SPIR-V transformer
- The ID discovery class is entirely removed
- Internal variable names have become a detail of the compiler alone
(and are no longer exposed as part of the compiler interface)
- Some front-end name tracking is removed ("parentStructMappedName",
etc)
This change also properly cleans up xfb emulation types that were
previously left over.
This change allows the SPIR-V compiler to emit user strings as-is
instead of prefixing them with `u_` leading to more readable debug
shaders. Additionally, it will make it possible not to emit debug info
at all. Both of these changes will be done in follow ups.
Bug: angleproject:7220
Change-Id: Iaa127496209a27aaae2e0d14c41b22fffb0b72a2
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4600610
Reviewed-by: Roman Lavrov <romanl@google.com>
Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
This commit adds a check to ensure that the GL backend's functions
have been properly initialized. This may happen with third party
build toolchains, like vcpkg, which reimplement parts of the
existing build system.
Bug: angleproject:8195
Change-Id: Iaca2200a563c5049d90acad57785088c94b4e580
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4614645
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Implements the first part (FrameCapture) of the proposal
go/frame-capture-and-interpreter-testing
Adds a basic test (CapturedTest) with a few frames. This test gets
captured by capture_tests.py into a temporary directory and the
resulting files are diff'ed with the files under expected/
A diff fails the test. When capture changes, the workflow would be to
run the command indicated by the error message in the test which will
overwrite the files with new ones so that they can be added to the CL.
Example test failure on capture change:
https://chromium-swarm.appspot.com/task?id=62b5f4034527c610
when testing https://crrev.com/c/4598046/3
Tests in CI: https://screenshot.googleplex.com/77o8vZVuj8AbFRj
Also adds a "angle_capture_tests_trace" lib with the trace just to test
that this capture also builds, the lib is not currently loaded by
anything.
Bug: b/286067106
Change-Id: I7d5f6eed088d84f9e3eb8a72b24b1d92515fff38
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4545408
Reviewed-by: Cody Northrop <cnorthrop@google.com>
Commit-Queue: Roman Lavrov <romanl@google.com>
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Added `gl::Context::isContextMutexStateConsistent()` method. This method
is primarily used to check if "SharedContextMutex" activation worked
successfully. It is automatically called in the updated
`ScopedContextMutexLock` before unlocking. This is to catch possible
errors using ASSERT during normal ANGLE operation in applications and
tests.
The `ScopedContextMutexLock` is now also used instead of the
`std::lock_guard<egl::ContextMutex>` in the `SCOPED_SHARE_CONTEXT_LOCK`.
No performance regression observed.
Important note: `lockAndActivateSharedContextMutex()` is NOT 100% safe
regardless of the `kActivationDelayMicro` value, so `ASSERT` may still
fail. However, failure does not necessary mean that there will be an
undefined behavior, it means that UB might happen.
Bug: angleproject:6957
Bug: chromium:1336126
Change-Id: Iee7357fede0d37fa315fe2cc7d27a4e30a304194
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4610227
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Igor Nazarov <i.nazarov@samsung.com>
Removes scripts/code_generation_hashes/Test_spec_JSON.json
Instead, run codegen in --verify-only mode and compare content.
This run during presubmits and is fast (~0.2s in my tests)
Similar to https://crrev.com/c/4604579
With this, should be able to auto-resolve conflicts in
infra/specs/angle.json
Also testing/buildbot/mixins.pyl
seems to have had hashes routinely updated by autorolls.
Bug: angleproject:8193
Change-Id: Ic1a657dbf464e6f4a8066ea8c5e18297e27a3b4c
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4605467
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Auto-Submit: Roman Lavrov <romanl@google.com>
Commit-Queue: Roman Lavrov <romanl@google.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>