src/libANGLE/capture/FrameCapture.cpp


Log

Author Commit Date CI Message
Cody Northrop 1e3e4eb7 2025-08-30T17:25:20 FrameCapture: Don't issue Begin/End for Timestamp queries Timestamp queries are issued with glQueryCounterEXT rather than glBeginQuery/glEndQuery. This CL updates how we generate timestamp queries in MEC. Before this, we were getting the following errors: API, Error, High: Error:glBeginQuery::<target> is not an accepted value API, Error, High: Error:glEndQuery::<target> is not an accepted value Test: Minecraft Vibrant Visuals trace Bug: b/442154222 Change-Id: Ib6dc01c3b57afcbebfdefa38e6abc883564ea6bd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6903038 Reviewed-by: Mark Łobodziński <mark@lunarg.com> Commit-Queue: Mark Łobodziński <mark@lunarg.com> Auto-Submit: Cody Northrop <cnorthrop@google.com>
Igor Nazarov e64b1e54 2025-08-29T15:51:30 FrameCapture: Restore end of trace capture log The log was accidentally removed by: Add long ANGLE traces feature https://crrev.com/c/angle/angle/+/6476924 That was originally added in: FrameCapture: log end of trace capture https://crrev.com/c/angle/angle/+/5557966 Bug: angleproject:343190307 Bug: angleproject:425728227 Change-Id: I68125981a3841c3d5e25aeaab3d792b8b047182a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6898285 Commit-Queue: Igor Nazarov <i.nazarov@samsung.com> Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
Tom Sepez 25390156 2025-08-21T00:13:19 Suppress unsafe buffers on a file-by-file basis in src/ [1 of N] In this CL, we suppress many files but stop short of actually enabling the warning by not removing the line from the unsafe_buffers_paths.txt file. That will happen in a follow-on CL, along with resolving any stragglers missed here. This is mostly a manual change so as to familiarize myself with the kinds of issues faced by the Angle codebase when applying buffer safety warnings. -- Re-generate affected hashes. -- Clang-format applied to all changed files. -- Add a few missing .reserve() calls to vectors as noticed. -- Fix some mismatches between file names and header comments. -- Be more consistent with header comment format (blank lines and trailing //-only lines when a filename comment adjoins license boilerplate). Bug: b/436880895 Change-Id: I3bde5cc2059acbe8345057289214f1a26f1c34aa Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6869022 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Mark Lobodzinski 240f6af8 2025-08-12T14:32:40 Capture/Replay: Pick up API SSBO binding changes GenerateLinkedProgram pulled uniform block bindings from inShaderBindings, but for trace this does not pick up API-side changes to the bindings with glUniformBlockBinding calls for example, resulting in missing geometry in some games. Test: angle_trace_tests --gtest_filter=*onmyoji Bug: b/438231427 Change-Id: I1b95c004c4fd856dc8b3a91cdef3e9251a275ca6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6842217 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Mark Łobodziński <mark@lunarg.com>
Cody Northrop 2eef3701 2025-08-11T20:25:42 FrameCapture: Handle null texture in MEC When interating through a UnsafeResourceMapIter, we need to check for null entries before dereferencing. Test: Fortnite MEC Bug: b/180418810 Change-Id: I0dc234234f9bb219026b2b67febb32e8af19e8b1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6839286 Reviewed-by: Xiang Wang <xwxw@google.com> Auto-Submit: Cody Northrop <cnorthrop@google.com> Commit-Queue: Xiang Wang <xwxw@google.com>
Charlie Lao fa29f604 2025-07-02T13:23:31 Remove sharedContextLock from {Enable|Disable}VertexAttribArray VertexArray objects are per context objects. In theory they do not need to protected by shared context lock. The reason we are taking locks because all these functions end up accessing Buffer object which are shared. In prior CLs we have removed subject observer usage from VertexArray which means VertexArray no longer accessed from other thread. In prior CLs we also split VertexArray into two classes: VertexArrayPrivate which has no buffer, and VertexArray which is subclass from VertexArrayPrivate and owns buffer. In this CL, glEnableVertexAttribArray and glDisableVertexAttribArray calls no longer take shared context lock. ContextPrivateEnableVertexAttribArray and ContextPrivateDisableVertexAttribArray are called from these two APIs and they only have access to StatePrivate. State Private holds a VertexArrayPrivate pointer, which means they do not have anyway to access buffer objects. The main challenge I run into here is mCachedActiveClientAttribsMask, mCachedActiveBufferedAttribsMask, mCachedActiveDefaultAttribsMask, mCachedHasAnyEnabledClientAttrib, mCachedNonInstancedVertexElementLimit, mCachedInstancedVertexElementLimit. These StateCache variable needs to be updated when these two APIs are called, and calculating these variable needs access to buffer object. The solution here is adding a bool mIsCachedActiveAttribMasksValid in the PrivateStateCache so that instead of immediately update these mCached* variable, we just set mIsCachedActiveAttribMasksValid to false. Then whenever any of these mCached* variable is needed, we will check mIsCachedActiveAttribMasksValid and calculate these cached variables. It adds one if check when accessing these caches, but the other benefit is that we may have avoided duplicated calculation when multiple states changed. Bug: b/433331119 Change-Id: I3227c72bc40501712db93fb3d540b835f07150b5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4514436 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
Igor Nazarov 3e52318c 2025-06-26T10:46:00 Vulkan: Ensure always using resolved Window Surface size `WindowSurfaceVk::getWidth/Height()` methods return cached, previously resolved Surface size. Using these methods while current Window Surface size is unresolved may return stale values, causing undesired behavior. Appropriate ASSERTs were added to these methods to prevent such usage. Added ASSERTs revealed few places with incorrect usage: - In `Context::makeCurrent()` to set initial viewport or for capture. - In `IsPartialBlit()` and `ValidateReadPixelsBase()` validations. - In `SerializeFramebufferAttachment()` during capture. Rest of the code was thoroughly checked if it is possible to call `WindowSurfaceVk::getWidth/Height()` when size is unresolved. All other places always call these methods after framebuffer state synchronization, which acquires swapchain images and resolves the surface size. Added `ensureSizeResolved()` method that is called during validation and in the `SerializeFramebufferAttachment()` method. It is possible to use existing `Framebuffer::syncState()` method as alternative, but this solution was discarded since it may potentially interfere with `State::syncDirtyObjects()` method. The `Surface::getUserSize()` replaces old methods as optimization, to prevent calling relatively expensive method twice from `Context::makeCurrent()` to get width and height of the `drawSurface`. Test: angle_trace_tests --gtest_filter=EGLSurfaceTest.ResizeBeforeMakeCurrent/* Test: angle_trace_tests --gtest_filter=EGLSurfaceTest.ResizeBeforeMakeCurrentPostSizeQuery/* Test: angle_trace_tests --gtest_filter=EGLSurfaceTest.ResizeAndReadPixelsRobustANGLE/* Test: angle_trace_tests --gtest_filter=EGLSurfaceTest.ResizeAndBlitFramebufferANGLE/* Bug: angleproject:397848903 Change-Id: I082e13d0b8db5fd7d08ff25b102df1f283e1256d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6792928 Commit-Queue: Igor Nazarov <i.nazarov@samsung.com> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao b4d84458 2025-05-23T18:08:19 Move Buffer from VertexBinding to VertexArray In later CL we will not taking shared context lock for certain VertexArray API calls. VertexArray itself is per context, so this sounds reasonable to do. The main challenge here is a lot of VertexArray function end up accessing gl::Buffer object, which could be modified by other shared contexts. In order to safely not taking the shared context lock, we need to separate out Buffer object out of VertexArray itself so that these lockless APIs will take VertexArray that does not have access to buffer. In this CL, VertexArray is split into two classes: VertexArrayPrivate is everything in VertexArray except buffers. VertexArray is a subclass of VertexArrayPrivate and owns all the buffers. Buffer is removed from gl::VertexBinding class. In order to let back end access to buffers, VertexArrayImpl holds a weak reference to VertexArray::mVertexArrayBuffers (which is a vector of buffers). Further, VertexArrayBufferBindingMask mBufferBindingMask is moved from VertexArrayState into VertexArray class well, since it tracks which index has a non-null buffer. The bulk of change are due to the VertexARrayImpl constructor change, since it now takes vertexArrayBuffers argument. Other bulk of changes are due to VertexBinding no long has the buffer, but you need to get it directly from VertexArray or VertexArrayImpl. This CL also reverts some of the change in crrev.com/c/6758215 that mVertexBindings no longer contains kElementArrayBufferIndex. BYPASS_LARGE_CHANGE_WARNING Bug: b/433331119 Change-Id: I15f4576f7c5c8d8f4d9c9c07d38a60ce539bfeea Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6774702 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Mark Lobodzinski 7181239d 2025-04-04T14:13:58 Add long ANGLE traces feature Enables very long Android captures by swapping binary data chunked buffers to/from disk. Bug: b/425728227 Change-Id: I539f72590eece03cfc69d42fc34be9825a9ff1fe Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6476924 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Mark Łobodziński <mark@lunarg.com>
Geoff Lang b7582680 2025-02-24T18:04:32 Reland: GL: Allow untranslated shaders to pass through on GLES Add an EGL extension EGL_ANGLE_create_context_passthrough_shaders which uses the NULL translator and passes the original shader to the driver. The parser is still used for shader reflection. Always enable the null compiler backend. It has almost no binary size cost and is now potentially used when the null ANGLE backend is not enabled. Bug: angleproject:398857482 Change-Id: Id528189ccbbacb1c444eacb151baadfda9fcc04b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6488609 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
Cody Northrop ab74884c 2025-07-22T20:46:05 FrameCapture: Check current state for indexed buffers When checking whether we need to set per draw buffer blend state, we don't care whether they differ from default, we only care if they differ from each other. The non-indexed commands will set the same state for all buffers. This CL removes default state from the check. Otherwise, we are getting a block of identical indexed commands: glBlendFuncSeparateiEXT(0, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFuncSeparateiEXT(1, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFuncSeparateiEXT(2, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFuncSeparateiEXT(3, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFuncSeparateiEXT(4, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFuncSeparateiEXT(5, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); Which is equivalent to: glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); Test: Honkai Impact 3rd trace Bug: b/433331917 Change-Id: Ie6bd7549d69c1548aace92126312527b8e585046 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6780135 Reviewed-by: Mark Łobodziński <mark@lunarg.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
Cody Northrop de6d58f4 2025-07-13T19:24:34 FrameCapture: Fix blend state per draw buffer in MEC Before this CL, we've never set starting state for draw buffers other than buffer zero. They've always remained at default values, or at least matching the values set for zero. Now when we detect the other buffers differ from buffer zero, we emit indexed calls that set them correctly. Turning a sequence like this: glEnable(GL_BLEND); glBlendFuncSeparate(GL_SRC_ALPHA, ...); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); into this: glEnableiEXT(GL_BLEND, 0); glBlendFuncSeparateiEXT(0, GL_SRC_ALPHA, ...); glBlendFuncSeparateiEXT(1, GL_SRC_ALPHA, ...); glEnableiEXT(GL_BLEND, 2); glBlendFuncSeparateiEXT(2, GL_SRC_ALPHA, ...); glColorMaskiEXT(2, GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); glEnableiEXT(GL_BLEND, 3); glBlendFuncSeparateiEXT(3, GL_SRC_ALPHA, ...); glColorMaskiEXT(3, GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); glColorMaskiEXT(4, GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glColorMaskiEXT(5, GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); Test: Wuthering Waves trace Bug: b/431854319 Change-Id: Ic91d4b8cf50defd8b69ecf6aac697d0df8f69692 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6735677 Reviewed-by: Mark Łobodziński <mark@lunarg.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Cody Northrop <cnorthrop@google.com>
Alexey Knyazev 408f5853 2025-04-04T00:00:00 Make gl::Version data members private * Further simplified gl::Version implementation by making data members private and merging them. * Used proper version struct comparisons instead of accessing individual version components. * Moved known version constants to Version.h for broader availability. * Removed no longer used helpers: * PrivateState::getClientMinorVersion() * State::getClientMinorVersion() * Context::getClientMinorVersion() Bug: angleproject:408843436 Change-Id: I3ae8f495269d649253fa2381ecbfc018a184fa20 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6460787 Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
Yuly Novikov 5dd05578 2025-04-14T07:34:57 Revert "GL: Allow untranslated shaders to pass through on GLES" This reverts commit 4e77552b86a89b449ada6d6c18f84285f5812b1d. Reason for revert: breaks ChromeOS and fuzzers Bug: angleproject:398857482 Original change's description: > GL: Allow untranslated shaders to pass through on GLES > > Add an EGL extension EGL_ANGLE_create_context_passthrough_shaders which > uses the NULL translator and passes the original shader to the driver. > The parser is still used for shader reflection. > > Bug: angleproject:398857482 > Change-Id: I7c5fcc318c7e11931f78c08dcbf4764bf77d397d > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6297527 > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Commit-Queue: Geoff Lang <geofflang@chromium.org> Bug: angleproject:398857482, angleproject:410423936 Bug: chromium:410114655, chromium:410100607, chromium:410121218 Bug: chromium:410052365, chromium:410290507, chromium:410178288 No-Presubmit: true Change-Id: I45b01960637a1cda05d21a7df6d07465f6a8f5e9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6448984 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Auto-Submit: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
Geoff Lang 4e77552b 2025-02-24T18:04:32 GL: Allow untranslated shaders to pass through on GLES Add an EGL extension EGL_ANGLE_create_context_passthrough_shaders which uses the NULL translator and passes the original shader to the driver. The parser is still used for shader reflection. Bug: angleproject:398857482 Change-Id: I7c5fcc318c7e11931f78c08dcbf4764bf77d397d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6297527 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
Kimmo Kinnunen 78048112 2025-01-15T15:13:14 Fix IndexRange::vertexIndexCount calculation Use only one loop. Avoid redundant primitive restart index parameter. Avoid calling GetPrimitiveRestartIndexFromType() because the algorithm relies on the value being numeric_limits<T>::max(). Fixes a bug where primitive restart case would process the value after first primitive restart twice, once in both for loops. This would result in incorrect vertexIndexCount. Fix by removing IndexRange::vertexIndexCount, and instead using IndexRange::mCount == 0 to signify empty range. Bug: angleproject:401284933 Change-Id: Ifaeb9949f2e852fb7c5ef80bc47f72bfabba21a6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6333541 Reviewed-by: Geoff Lang <geofflang@chromium.org> Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com>
Alex Dean 3818d37d 2025-04-04T15:07:59 CL: Add end_capture to capture/replay tool Many different applications don't explicitly make it clear the ending frame of what's being run. With the end_capture utility, when the user sets end_capture to 0, the application automatically finishes the capture immediately. Example OpenCL applications where this is useful: AI-Benchmark, Geekbench Compute, Geekbench AI Bug: angleproject:402174922 Change-Id: I1710ae1b1703f710865a9862c4cf3de753c2ccbd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6339791 Reviewed-by: Roman Lavrov <romanl@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Roman Lavrov <romanl@google.com>
Shahbaz Youssefi c9e90490 2025-03-27T18:26:19 Capture: Keep binary data in memory in chunks This is needed for taking large captures out of Chromium, because its memory allocator refuses to allocate objects bigger than 1~2GB. Incidentally, it also optimizes taking large captures by avoiding frequent calls to `vector::resize` while the vector is very large. Bug: b/381284577 Change-Id: I4ccd3c8ea50df59520334f70e99083847da20c9f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6406214 Reviewed-by: Roman Lavrov <romanl@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Mark Łobodziński <mark@lunarg.com> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Shahbaz Youssefi 1b95a5ae 2025-04-01T16:36:38 Capture: Fake surface size if no surface If a context never uses a surface, create a fake one for the sake of capture/replay. Bug: b/381284577 Change-Id: I42db06d52d0ad17ee9921542e7cb56c910810ae7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6422892 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Alexey Knyazev 64dc6096 2025-03-28T00:00:00 Ensure ValidateDelete{Program|Shader} consistency Deleting program zero is valid. Deleting shader zero is valid. Bug: angleproject:406922380 Change-Id: I2a26be8200585fae3a70c0a904be96ff590ebe7b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6409251 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
Mark Lobodzinski 367541f5 2025-02-05T16:45:13 Capture/Replay: Add multi-capture support to tracer Multiple captures can now be grabbed by setting the trigger value to the desired framecount and then resetting it to zero to trigger a new capture. Captures will be saved in the current capture.out_dir directory and this should be changed between captures to keep traces separate. Note that this feature will not work with apps using persistent coherent memory, and in these cases the tracer will exit, preserving the initial, valid trace. Bug: b/394107532, angleproject:42263521 Change-Id: I9d31d19ec6c3736dbda356405eb91fba2dd5a8d7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6258503 Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Cody Northrop f8493aaa 2025-01-29T15:31:40 FrameCapture: Fix framebuffer setup for multiple contexts In some traces we're seeing garbage in Context specific setup for framebuffers. It seems the context is being lost in the final bind. For instance, we see this bad sequence in SetupReplayContext2: glGenFramebuffers(1, (GLuint *)gReadBuffer); UpdateFramebufferID2(2, 2, 0); glBindFramebuffer(GL_FRAMEBUFFER, gFramebufferMapPerContext[2][2]); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gTextureMap[50], 0); glGenFramebuffers(1, (GLuint *)gReadBuffer); UpdateFramebufferID2(2, 3, 0); glBindFramebuffer(GL_FRAMEBUFFER, gFramebufferMapPerContext[2][3]); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gTextureMap[50], 0); glBindFramebuffer(GL_FRAMEBUFFER, gFramebufferMapPerContext[2863311360][0]); Note the very large number in the last line. That is supposed to be a context number! This is due to a missing call to set the context for that instruction. It was added in one spot, but was needed in several. With the fix in this CL, we get the correct context: glGenFramebuffers(1, (GLuint *)gReadBuffer); UpdateFramebufferID2(2, 2, 0); glBindFramebuffer(GL_FRAMEBUFFER, gFramebufferMapPerContext[2][2]); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gTextureMap[50], 0); glGenFramebuffers(1, (GLuint *)gReadBuffer); UpdateFramebufferID2(2, 3, 0); glBindFramebuffer(GL_FRAMEBUFFER, gFramebufferMapPerContext[2][3]); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gTextureMap[50], 0); glBindFramebuffer(GL_FRAMEBUFFER, gFramebufferMapPerContext[2][0]); Test: Capture apps that set up multiple contexts Bug: b/371985732 Change-Id: Id12d7f0ec0ec9a2cdc2b4bfeca08faf9b8b7e775 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6217081 Reviewed-by: Roman Lavrov <romanl@google.com> Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: Mark Łobodziński <mark@lunarg.com>
Alex Dean c0d806b4 2025-02-10T23:01:33 CL: OpenCL support for ANGLE Capture/Replay Implementation of OpenCL Capture/Replay tool in ANGLE. Brief notes about the change: - Most meaningful changes for the capture process are made in src/libANGLE/capture/ - Most meaningful changes for replay are made in util/capture/ and src/tests/perf_tests/ - Many autogenerated files are changed/added to allow the capture of OpenCL objects & calls - The following applications were captured/replayed: benchmark_model, GeekBench Compute, GeekBench ML, AI-Benchmark, various OCL CTS tests - End2end test added to capture_tests. CapturedTestCL.MultiFrameCL/ES3_Vulkan Bug: angleproject:383841335 Change-Id: I55fdaa6cd6c7ba740aaa2351e4d29050059d6d1d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6102105 Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: Roman Lavrov <romanl@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Cody Northrop 5798be5e 2025-01-13T07:45:11 FrameCapture: Fix framebuffer bindings in MEC While capturing an app, I was crashing on the line reading replayState.getReadFramebuffer()->id() That's because replayState did not have a read framebuffer bound, and we dereferenced nullptr. replayState is a default state that we've created and we're modifying to make it *look* like apiState. We should be updating replayState to match the framebuffers bound in apistate. In this case state*Framebuffer is read from apiState and is the value we want to propagate. AFAICT these have been incorrect since they landed in the initial implementation, but the code is complex: https://chromium-review.googlesource.com/c/angle/angle/+/1689329 Test: Tower of Fantasy capture Bug: b/389808881 Change-Id: Ibf7bc56cd385c34139676c5813926f756bb38f42 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6174746 Reviewed-by: Roman Lavrov <romanl@google.com> Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: Mark Łobodziński <mark@lunarg.com>
Neil Zhang cfe87e34 2024-12-16T16:29:39 Add multisample support for glCopyImageSubDataEXT As GL_TEXTURE_2D_MULTISAMPLE/GL_TEXTURE_2D_MULTISAMPLE_ARRAY been introduced by GLES3.1, glCopyImageSubDataEXT should support those types. Bug: angleproject:381727390 Change-Id: Ib3571ea38dc8d8ceb1bc9ad0c8a6e04d28b0ec33 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6146194 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Amirali Abdolrashidi <abdolrashidi@google.com>
Roman Lavrov 0c7c14eb 2024-11-22T10:31:45 Capture: add a sanity check to InitializeReplay4 args In the case on the bug we were getting maxProgramPipeline = 1684105299 due to an unitialized memory read, which then led to Replay OOM crash as it allocates an array of this size. This is difficult to diagnose in Replay as OOM leads to SIGKILL which cannot be trapped so we can't have a backtrace. Adding a sanity check during capture. Fix the other tests where we hit this (https://anglebug.com/380296979#comment6) One of them visible on red tests on a previous patchset in this CL: https://ci.chromium.org/ui/p/angle/builders/try/linux-trace/9871/overview https://ci.chromium.org/ui/p/angle/builders/try/win-trace/10795/overview Bug: angleproject:380296979 Change-Id: I2879c1947742a9751a122545c8ba8da23ab243cb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6042185 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Roman Lavrov <romanl@google.com>
Cody Northrop b09008fd 2024-11-13T10:28:36 FrameCapture: Warn when shaders are not attached yet Instead of assert, print a warning when we don't have attached shaders on an unlinked program. There's work involved to support it, but also scenarios where it isn't a blocker to capturing a trace. For instance, if the program isn't used, we don't care if it doesn't have attached shaders. Test: SimCity BuildIt Bug: b/334030316 Change-Id: Ied85af433e769ec8f1e436de82e911ff691ea9c0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6017396 Reviewed-by: Mark Łobodziński <mark@lunarg.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
Cody Northrop 14e4435b 2024-11-12T23:08:55 FrameCapture: Start active queries last in MEC Before this CL, we cycle through all queries, Begin and End them, unless they are active, and we skip End. That can give us a sequence like this: glGenQueries(1, (GLuint *)gReadBuffer); UpdateQueryID(1, 0); glBeginQuery(GL_TIME_ELAPSED_EXT, gQueryMap[1]); glEndQuery(GL_TIME_ELAPSED_EXT); glGenQueries(1, (GLuint *)gReadBuffer); UpdateQueryID(2, 0); glBeginQuery(GL_TIME_ELAPSED_EXT, gQueryMap[2]); glGenQueries(1, (GLuint *)gReadBuffer); UpdateQueryID(3, 0); glBeginQuery(GL_TIME_ELAPSED_EXT, gQueryMap[3]); glEndQuery(GL_TIME_ELAPSED_EXT); Note that gQueryMap[2] is not Ended because it is active. That results in a GL error when we try to Begin gQueryMap[3]: INFO: glBeginQuery: GL error: HIGH: Other query is active. To fix this, we need to start active queries last. That results in the following sequence: glGenQueries(1, (GLuint *)gReadBuffer); UpdateQueryID(1, 0); glBeginQuery(GL_TIME_ELAPSED_EXT, gQueryMap[1]); glEndQuery(GL_TIME_ELAPSED_EXT); glGenQueries(1, (GLuint *)gReadBuffer); UpdateQueryID(2, 0); glGenQueries(1, (GLuint *)gReadBuffer); UpdateQueryID(3, 0); glBeginQuery(GL_TIME_ELAPSED_EXT, gQueryMap[3]); glEndQuery(GL_TIME_ELAPSED_EXT); glBeginQuery(GL_TIME_ELAPSED_EXT, gQueryMap[2]); Test: Filament mosquito trace Bug: b/322364529 Change-Id: I4de9401e49bf93b0cfe02ba5ad536f3ab3079b81 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6017473 Reviewed-by: Mark Łobodziński <mark@lunarg.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
Mark Lobodzinski c7a43ec8 2024-10-28T12:26:05 Capture/Replay: Track framebuffers by context Some game titles treat framebuffer objects as shared. Framebuffer objects are now tracked per-context to avoid conflicts. Test: angle_trace_tests --gtest_filter=TraceTest.limbo --offscreen Bug: b/371985732 Change-Id: I34ae5b54d569eec75ad86b7b363f7a84d56d955c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5973639 Commit-Queue: Mark Łobodziński <mark@lunarg.com> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Amirali Abdolrashidi ef55ca0a 2024-10-17T14:44:22 Update copy validation regarding ext textures * Updated the validation functions for the following function to accept TEXTURE_EXTERNAL_OES: glCopyImageSubDataEXT() * Updated unit test CopyTextureTestES3.CopyImageSubDataToEGLImage * Using TEXTURE_EXTERNAL_OES as target for glFramebufferTexture2D() requires EXT_YUV_target. Therefore, the texture related to it is used instead. Bug: angleproject:361372990 Change-Id: I905d4cf89522ae3158516b42b15705d1044c6e97 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5940404 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Amirali Abdolrashidi <abdolrashidi@google.com>
Shahbaz Youssefi b16d105f 2024-10-03T10:25:32 Remove Desktop GL front-end support For Desktop GL applications, please use Zink! Bug: angleproject:370937467 Change-Id: Ie734634bb62a2e98c80e1b32d8b3d34624da3c04 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5905428 Reviewed-by: Geoff Lang <geofflang@chromium.org>
Geoff Lang da572160 2024-07-23T16:36:10 Reland: GL: Forward client-side arrays to the driver when possible The OpenGL driver can handle client-side arrays when the context is OpenGL ES or a desktop GL compatibility profile. When in these situations, use the driver default VAO for all frontend context VAOs and forward client-side data directly to the driver. Fix synchronizing the default VAO state for external contexts. There is no valid VertexArrayStateGL for external VAOs so make sure it's nulled and the VAO dirty bits are set so the correct VAO state is reapplied. Disable syncing to the default VAO for external contexts. The only VAO that they can share with ANGLE's internal state is the default VAO so avoid having to save and restore its state. Bug: angleproject:355034686 Change-Id: I015bbbc854938fe4bc1e92d0ca8fe04628d0db16 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5743284 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
Mark Lobodzinski b98c4d81 2024-07-23T09:09:37 FrameCapture: Add restore of VAO buffer binding If the VAO was changed before the trace started, but no buffers were bound during replay, the VAO buffer binding was not properly reset. Test: angle_trace_tests --gtest_filter=*shovel_knight_pocket_dungeon Bug: b/354888763 Change-Id: I76f94e5d219b88c641528049034d92ee55161f56 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5734653 Commit-Queue: Mark Łobodziński <mark@lunarg.com> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Cody Northrop 93491ae3 2024-06-21T08:04:24 FrameCapture: Handle active texture in MEC When restoring texture bindings and contents, we need to first set the correct GL_ACTIVE_TEXTURE, otherwise it will use existing active texture bindings and update the wrong textures. Test: Grand Mountain Adventure MEC Bug: angleproject:345851268 Change-Id: I7c6c4a918513d4216405efe51774fcce4b49b45e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5647491 Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: Mark Łobodziński <mark@lunarg.com>
Cody Northrop 0e598a0c 2024-07-17T09:49:19 FrameCapture: Unbind PIXEL_UNPACK_BUFFER for texture restore When restoring textures, we need to ensure the PIXEL_UNPACK_BUFFER is not bound, as that will influence where we pull data from. Allow per-context reset to restore the correct binding. Test: Grand Mountain Adventure MEC Bug: angleproject:345851268 Change-Id: I636f3780f8454d04152ff7bf7ba15d039ee41872 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5718285 Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: Mark Łobodziński <mark@lunarg.com>
Cody Northrop 98ff1c14 2024-07-17T09:45:03 FrameCapture: Improve buffer binding reset We aren't correctly tracking and resetting buffer bindings, which are per-context. To restore them, we need to track the bindings at the beginning and mark them dirty. Before this we were doing it in ResetReplayContextShared based on the object dirty state. Test: Grand Mountain Adventure MEC Bug: angleproject:345851268 Change-Id: Ic3db583c88bec9c680197f71ff11fdf69efdf630 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5610332 Reviewed-by: Mark Łobodziński <mark@lunarg.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
Roman Lavrov eda67d7e 2024-07-11T11:16:08 Avoid including fstream from angleutils.h SaveFileHelper is mostly useful for / specific to FrameCapture, so move it there. The other couple of uses just write a string. Bug: angleproject:42266508 Change-Id: Ia1dcd4531f9d5671f40611a1887dcfe7c5dbc1ef Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5696025 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Roman Lavrov <romanl@google.com>
Cody Northrop 1917377f 2024-06-07T17:02:33 Capture/Replay: Write comments to the capture Useful for tracking why things are happening in the frame, from the perspective of the tracer. Allows for entries like this: // DEBUG: AttachShader called, checking for IDs; glAttachShader(gShaderProgramMap2[6943], gShaderProgramMap2[1531]); // DEBUG: AttachShader called, checking for IDs; glAttachShader(gShaderProgramMap2[6943], gShaderProgramMap2[1511]); Good for debugging or knowing we've skipped invalid/unsupported calls. This CL includes one use of comments to mark calls we've skipped, meaning the app or ANGLE submitted them, but omitted from capture. Bug: angleproject:345851268 Change-Id: Ied917c7480704afc3fdfb8cbb617b323eb7403a5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3233876 Reviewed-by: Mark Łobodziński <mark@lunarg.com> Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: Roman Lavrov <romanl@google.com>
Shahbaz Youssefi d193d51b 2024-06-17T22:46:08 Replace issue ids post migration to new issue tracker This change replaces anglebug.com/NNNN links. Bug: None Change-Id: I8ac3aec8d2a8a844b3d7b99fc0a6b2be8da31761 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5637912 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Bruno BELANYI be78da6e 2024-05-22T15:33:46 FrameCapture: log end of trace capture This makes it easy to spot when the capture is done through logcat. Bug: angleproject:343190307 Change-Id: Idf174cbf256242e32cda3c781c8b1092123254bb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5557966 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Cody Northrop <cnorthrop@google.com> Commit-Queue: Bruno BELANYI <ambroisie@google.com>
Shahbaz Youssefi a1665d2f 2024-05-10T00:15:31 Reland "Document thread-unsafe iterator access to resource maps" This is a reland of commit d1bb6ed8399dd12e79484f30f9e9ded95c25625a The crash was due to another issue (disabling EGL validation in Chrome) Original change's description: > Document thread-unsafe iterator access to resource maps > > By using a proxy type, everywhere resource maps are iterated are clearly > marked as not being thread safe. In most cases, only destruction and > capture/replay iterate over these maps, which means thread safety is not > an issue (or is externally enforced). > > The only case where iterators are used in the presence of other contexts > is with ANGLE_request_extension, which is changed to explicitly require > the application to ensure thread safety. In practice, the user is > Chrome which already guarantees this. > > Bug: angleproject:8667 > Change-Id: I7af13c6433b6955d9c36f9088b3aa4c065e1cfc1 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5526428 > Reviewed-by: Charlie Lao <cclao@google.com> > Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Geoff Lang <geofflang@chromium.org> Bug: angleproject:8667 Change-Id: Id539cabac01df5f242150f6684222577003eef3f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5531278 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Shahbaz Youssefi 4e887491 2024-05-11T18:08:03 Revert "Document thread-unsafe iterator access to resource maps" This reverts commit d1bb6ed8399dd12e79484f30f9e9ded95c25625a. Reason for revert: Checking to see if it's the reason for crbug.com/339948886 Original change's description: > Document thread-unsafe iterator access to resource maps > > By using a proxy type, everywhere resource maps are iterated are clearly > marked as not being thread safe. In most cases, only destruction and > capture/replay iterate over these maps, which means thread safety is not > an issue (or is externally enforced). > > The only case where iterators are used in the presence of other contexts > is with ANGLE_request_extension, which is changed to explicitly require > the application to ensure thread safety. In practice, the user is > Chrome which already guarantees this. > > Bug: angleproject:8667 > Change-Id: I7af13c6433b6955d9c36f9088b3aa4c065e1cfc1 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5526428 > Reviewed-by: Charlie Lao <cclao@google.com> > Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Geoff Lang <geofflang@chromium.org> Bug: angleproject:8667 Change-Id: I1245c9e57dfeb27a7f0e5718b1455614c70bc0dc No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5532187 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi d1bb6ed8 2024-05-10T00:15:31 Document thread-unsafe iterator access to resource maps By using a proxy type, everywhere resource maps are iterated are clearly marked as not being thread safe. In most cases, only destruction and capture/replay iterate over these maps, which means thread safety is not an issue (or is externally enforced). The only case where iterators are used in the presence of other contexts is with ANGLE_request_extension, which is changed to explicitly require the application to ensure thread safety. In practice, the user is Chrome which already guarantees this. Bug: angleproject:8667 Change-Id: I7af13c6433b6955d9c36f9088b3aa4c065e1cfc1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5526428 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Shahbaz Youssefi c3a1cae4 2024-04-15T14:58:55 Use angle::SimpleMutex everywhere in libGLESv2 Only cases left that use std::mutex are: - Share group and the context ErrorSet mutexes as they need try_lock() - Anywhere mutexes are used in conjunction with std::condition_variables (as they explicitly require std::mutex) Bug: angleproject:8667 Change-Id: Ib6d68938b0886f9e7c43e023162557990ecfb300 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5453294 Reviewed-by: Roman Lavrov <romanl@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Mark Lobodzinski e3a58b25 2024-04-11T09:33:55 FrameCapture: Support deferred linking of shaders Modern Combat 5 creates and attaches programs and shaders but defers compiling and linking until needed. Added support in the tracer for this corner case and updated CapturedTest to exercise this behavior as well. Test: angle_end2end_tests --gtest_filter=CapturedTest.MultiFrame/ES3_Vulkan Bug: b/334030316 Change-Id: Ib7fdf0fe25b11cdb3df33d50e49501f3a51e9510 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5449599 Commit-Queue: Mark Łobodziński <mark@lunarg.com> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Cody Northrop 71e5a43f 2024-03-26T14:03:14 FrameCapture: Don't use shadow memory on Pixel after Android 14 The platform bug that required shadow memory to track changes to coherent mapped buffers has been fixed in Android 14. mprotect now works on Vulkan surfaces. Test: MEC with title using coherent buffers Bug: angleproject:7402 Bug: b/269535398 Change-Id: I370f29ee7d033b19facf48cfd76576950c39b735 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5399117 Reviewed-by: Mark Łobodziński <mark@lunarg.com> Reviewed-by: Mike Schuchardt <mikes@lunarg.com> Auto-Submit: Cody Northrop <cnorthrop@google.com> Commit-Queue: Mark Łobodziński <mark@lunarg.com>
Mark Lobodzinski 7cb518bc 2024-03-14T18:10:08 Reset shader images modified during trace ANGLE will track and restore texture resources modified during replay by reinitializing them in the Reset function, but shader images resources modified by glDispatchCompute calls were unhandled. Test: angle_trace_tests --gtest_filter=*poppy_playtime Bug: b/329824015 Change-Id: I2852b5a3cecdd2e2213ea457ea43e7cf84741986 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5375541 Commit-Queue: Mark Łobodziński <mark@lunarg.com> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Mike Schuchardt 56a291e8 2024-02-01T02:30:02 Rework external image capture Move external image creation into the trace fixture. Record image size at capture time and then recreate it using a GL staging texture and placeholder data during replay if the original client buffer is missing (MEC) or the image was created from another API (AHB). Track when EGLImages are created and destroyed during capture so they can be restored to their original MEC state at reset time. Clean up the backing GLTexture resources when the corresponding EGLImage is destroyed. In cases where EGL calls are made without an associated GL context, look up and active context to use from the passed in EGLDisplay parameter. Bug: b/300966403 Change-Id: I7033fa25d2cb3a59957887439506f6f6a416c8f1 Test: Trace com.square_enix.android_googleplay.FFVII Test: Trace com.MOBGames.PoppyMobileChap1 Test: Trace com.tocaboca.tocalifeworld Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4903441 Reviewed-by: Cody Northrop <cnorthrop@google.com>
Cody Northrop 9ca81c7e 2024-01-21T13:35:06 FrameCapture: Handle zero vertex count draws Seeing the following from GLES1 (note count = 0): glDrawArrays(context = 1, mode = GL_POINTS, first = 0, count = 0) This crahes in FrameCaptureShared::captureClientArraySnapshot: 'length_error was thrown in -fno-exceptions mode with message "vector"' The function assumes vertexCount will always be greater than zero. This CL updates it to detect the empty case and simply return. Negative counts are already handled as a GL error. Test: Plague Inc MEC Bug: b/321562592 Change-Id: I3613eaac297a3471dc998b023bf2658413cb5d1b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5250427 Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: Mike Schuchardt <mikes@lunarg.com>
Shahbaz Youssefi 0c4d6446 2024-01-24T10:38:45 Rework uniform block <-> uniform buffer mapping In GLES, the shader declares which buffer binding a block (uniform, storage or atomic counter) is bound to. For example: layout(binding = 1) uniform ubo0 { ... }; layout(binding = 2) uniform ubo1 { ... }; layout(binding = 1) uniform ubo2 { ... }; In the above, ubo0 and ubo2 use data from the buffer bound to index 2 (through glBindBufferRange), while ubo1 uses data from the buffer bound to index 1. For uniform blocks in particular, omitting the binding is allowed, in which case it is implicitly bound to buffer 0. GLES allows uniform blocks (and only uniform blocks) to remap their bindings through calls to glUniformBlockBinding. This means that the mapping of uniform blocks in the program (ubo0, ubo1, ubo2) to the buffer bindings is not constant. For storage blocks and atomic counter buffers, this binding _is_ constant and is determined at link time. At link time, the mapping of blocks to buffers is determined based on values specified in the shaders. This info is stored was stored in gl::InterfaceBlock::binding (for UBOs and SSBOs), and gl::AtomicCounterBuffer::binding. For clarity, this change renames these members to ...::inShaderBinding. When glUniformBlockBinding is called, the mapping is updated. Prior to this change, gl::InterfaceBlock::binding was directly updated, trumping the mapping determined at link time. A bug here was that after a call to glProgramBinary, GL expects the mappings to reset to their original link-time values, but instead ANGLE restored the mappings to what was configured at the time the binary was retrieved. This change tracks the uniform block -> buffer binding mapping separately from the link results so that the original values can be restored during glProgramBinary. In the process, the support data structures for tracking this mapping are moved to ProgramExecutable and the algorithms are simplified. Program Pipeline Objects maintain this mapping identically to Programs and no longer require a special and more costly path when a buffer state changes. This change prepares for but does not yet fix the more fundamental bug that the dirty bits are tracked in the program executable instead of the context state, which makes changes not propagate to all contexts correctly. Bug: angleproject:8493 Change-Id: Ib0999f49be24db06ebe9a4917d06b90af899611e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5235883 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Mark Lobodzinski e9aa41f5 2023-11-06T15:00:33 Trace/Replay: Add multi-context call grouping Instead of inserting eglMakeCurrent calls into the command stream where context changes occur in the traced application, track the context for all calls. During trace generation output calls grouped by context while preserving synchronization, reducing the number of context switches and improving performance. Test: Capture Diablo Immortal or Asphalt 9 trace and replay Bug: b/300965096 Change-Id: Ia02e0ddf0440ac8a9a0ef3b6af67788f2f147809 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4909217 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Mark Łobodziński <mark@lunarg.com>
Cody Northrop 35e49df7 2023-12-11T21:16:57 FrameCapture: Skip eglQueryContext We don't use the return value of the call, so it can be omitted from the capture. Test: Flip capture Bug: b/308208067 Change-Id: Ib3dfea2b7bd5638092bd691e66c6b9e2b6fabf15 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5112776 Reviewed-by: Mike Schuchardt <mikes@lunarg.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
Cody Northrop 9b66848f 2023-12-11T20:54:30 FrameCapture: Handle context Reset with no calls The code was assuming that setDefaultResetCalls adds reset calls for an entry point, but it has logic for skipping if the current state is already default. This CL checks to see if we added any calls for the entry point before trying to iterate through them. Test: Flip capture Bug: b/308208067 Change-Id: I8a214b0eb0df068d6b3172c0ca1406f6751f91ea Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5114271 Reviewed-by: Mike Schuchardt <mikes@lunarg.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
Alexey Knyazev bc301691 2023-12-07T00:00:00 Run PackUnpackTest on all backends Fixed negative zero serialization for capture/replay. Bug: angleproject:4092 Change-Id: Ic12a556f56e40064da8bf3a8ce7d01af92c7086a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5106509 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Geoff Lang c27a4a1d 2023-11-27T14:44:07 Re-use EGL sync object allocations. Create a pool of EGL sync objects with their implementations that can be re-used. Update all backend implementations to support multiple calls to initialize/destroy. Pool size of 32 chosen through experimentation using Chrome. Bug: angleproject:8430 Change-Id: I86fea41aed35eddccc953efb3802bf5fdb7f3cb2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5063341 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
Mike Schuchardt 53c5b145 2023-10-10T09:42:08 Capture/Replay: Restore texture bindings on reset Store active texture unit and all bound textures at capture start. Track dirty state for each unit+target pair during capture. Restore bound textures for each dirty binding unit when resetting context state. Also restore active texture unit if necessary. Test: Capture The Sims Mobile Bug: angleproject:4599 Change-Id: Iae3e03e6c5b0a35d5bb95bf07397d7894355502b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4927869 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Mike Schuchardt <mikes@lunarg.com>
Mark Lobodzinski 03eea365 2023-09-25T17:50:51 ANGLE Tracer: Mark FBAttachment texture resources as active If a texture and framebuffer were set up before capture and referenced during a capture, the texture resource would not be set as active and the trace may fail. Test: Capture a Diablo Immortal trace and attempt to replay Bug: b/301999483 Change-Id: I5ea114e65b11479a5cdbf496dc8c5ab4eeadbf55 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4893251 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Mark Łobodziński <mark@lunarg.com>
Igor Nazarov ca4dc52e 2023-06-22T15:20:12 Replace (Single/Shared)ContextMutex classed with ContextMutex This CL removes `SingleContextMutex` class and not 100% safe `Context::lockAndActivateSharedContextMutex()` method. `SharedContextMutex<>` was replaced with `ContextMutex` with static mutex type which is defined in "SharedContextMutex.h": - ContextMutexType = std::mutex Above refactoring also allows storing `State::mContext` by value, instead by pointer. Actual mutex is referenced by `ContextMutex::mRoot` member. This removes extra pointer indirection and slightly improves performance. If newly created Context uses shared textures/samplers, then it uses `Display::mManagersMutex` root as its root. Performance in Single/Shared cases now will be the same, and it should be slightly faster then old Shared case (because of the reduced complexity). Bug: angleproject:8226 Change-Id: I7ca4d9ea008c665cbea98ace1c6e7bbc544f54b5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4632729 Commit-Queue: Igor Nazarov <i.nazarov@samsung.com> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi eb0d5997 2023-09-15T16:41:13 Move set/get uniform machinery to ProgramExecutable This is done because some uniforms are internally added by the compiler (draw ID, base vertex, and base instance) and are automatically set **on the installed executable**. This change fixes scenarios where a draw is done after a program has failed a relink, and therefore is unable to correctly set the uniforms (as it does not have access to the executable that is installed). It also fixes draws that use those uniforms in a PPO. Bug: angleproject:8297 Change-Id: Id74b4984b88aa09b5b81be1c91412d6c91711136 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4864693 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 29561184 2023-09-06T22:08:33 Remove forward-to-executable helpers from program This helps avoid accidental usage of the executable that is in the program instead of the installed executable in the GL context. The program's executable is still accessed in specific cases of: - During link - GL program queries Bug: angleproject:8297 Change-Id: I40a956e740944f2ecfbf6e4a3060aac08c21f7f3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4864448 Commit-Queue: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org>
Roman Lavrov 1249fc1f 2023-09-07T14:39:26 Tests: Support capture_tests on Android and enable on CI Enables angle_with_capture_by_default = true on Android bots similarly to Linux and Windows. Enables the capture test on Pixel 4 and 6 bots (it takes only a few seconds to run) Enables support for capture in android_helper in general. For example, this now works the same way it would on say Linux, but runs the capture on the device an pulls files to OUT_DIR. % ANGLE_CAPTURE_LABEL=gacha_club ANGLE_CAPTURE_OUT_DIR=/tmp/capt2 ANGLE_CAPTURE_FRAME_START=16 ANGLE_CAPTURE_FRAME_END=16 out/AndroidPerformance/angle_trace_tests --gtest_filter=TraceTest.gacha_club --use-angle=vulkan --retrace-mode --max-steps-performed=20 For end2end tests it's a bit trickier as we're still using the Chromium wrappers for e.g. out/AndroidPerformance/angle_end2end_tests - which is why capture_tests.py is currently using angle_android_test_runner.py Bug: b/296397568 Change-Id: I2606e74a17c90e381bb49ec8d555a6d24851b4f7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4850889 Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Roman Lavrov <romanl@google.com>
Cody Northrop fce1e574 2023-09-08T14:21:58 FrameCapture: Skip output dir check if disabled * In order to improve performance and avoid errors when running with capture support, change the output dir checks to be optional. * The checks are expensive on Android due to reading the process name and filesystem locations. * We want want to continue emitting errors if the user wants to capture but didn't create the output dir. Test: Android apps with and without capture enabled via properties Bug: b/296397568 Change-Id: If3adbe0c569db49fd8e8e430b7c57ae8585ca4d7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4854443 Reviewed-by: Roman Lavrov <romanl@google.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
Mark Lobodzinski 9c0748d3 2023-08-16T09:15:22 Capture/Replay: Trim inactive Texture resources As is done with Shader and Program objects, trim inactive Texture objects from default trace execution playback and update CapturedTest with new use cases. Bug: b/297031925 Change-Id: I734d8f1fa66a24be7790391deaeee24cf570d12a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4802281 Reviewed-by: Roman Lavrov <romanl@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Mark Łobodziński <mark@lunarg.com>
Shahbaz Youssefi 7b0bb0f6 2023-09-01T13:52:28 Properly "install" program executables According to GL: - The program has an executable - The executable is overwritten during link. - After a failed link, queries of the executable may return half-linked information - On glUseProgram, the executable is installed in the context - On glUseProgramStages, the executable is installed in the program pipeline - After a successful link, the executable is updated wherever the previous executable of the program was installed. This change implements exactly the above: - The program's and the program pipeline's executables are now shared_ptr. References to an executable in the context and PPO are also through a shared_ptr. Installing an executable thus translates to sharing the executable. - The context and PPOs are made to not reference the program directly, but work solely through the executable. As a result, the program is free to create a new executable for link. With this change, the link job will be free to modify the executable as necessary because that will not be accessed until the link is done. Note that previous changes made the backend executable accessed through the frontend one, and moved all link results to the frontend and backend executables as appropriate. Bug: angleproject:6358 Bug: angleproject:8297 Change-Id: Ie636b23ff7420ad284d18b525ec4f5fb559dd9d1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4823089 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Shahbaz Youssefi 33be2590 2023-08-30T21:58:54 Move transform feedback buffer mode to program state This is link input and should persist between relinks. A copy of it is still left in ProgramExecutable as it is used later after the executable is installed (and the program might get relinked; a future change reworks things so that the installed executable and the originating program are independent). Bug: angleproject:8297 Change-Id: Ifba6ac18ea09fd804b89d8fdb14930ef3d839cf4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4827764 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi f3c1de36 2023-08-17T15:29:24 Make shader recompile while parallel linking safe Prior to this change, Program* objects held references to Shader* objects. This poses a problem where a shader recompile can race with a program link, if the program link is done in parallel. As a result, a good chunk of the link job is done serially and under the share group lock. After this change, that is no longer a problem, and most of the link can be made lockless/parallelized. This change separates out the "compiled state" from the rest of the shader state. This was already done for the front-end state (for the sake of caching), but is also now done for the backends that need it. The compiled state in turn is placed in a shared_ptr, and is shared with the program. When a shader is compiled, its own shared_ptr is replaced with a new object, leaving all programs currently compiling unaffected and using the previous compilation results. Once a program is linked, its references to compiled shader states is updated. Bug: angleproject:8297 Change-Id: Iff7094a37088fbad99c6241f1c48b0bd4c820eb2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4791065 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Mark Lobodzinski d85de0e9 2023-08-09T14:15:56 Capture/Replay: Add optional replay of trimmed resources This CL: - Adds '--include-inactive-resources' option to angle_trace_tests - Removes the 'trim-enabled' option - Outputs all previously trimmed shaders/programs to trace file in a new Setup function, SetupReplayContextSharedInactive() which is executed only if the new option is specified - Modifies CaptureTest to add inactive resources, but does not set the include-inactive-resources flag Bug: b/296055694 Change-Id: I33b18d5da727d55c90c2012c2bf64b1413521429 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4781552 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Mark Łobodziński <mark@lunarg.com> Reviewed-by: Roman Lavrov <romanl@google.com>
Charlie Lao 1e1c9d9d 2023-08-11T15:16:26 Pack and reduce Program::mProgramInput size Right now mProgramInput is std::vector<sh::ShaderVariable>. It really only need a subset of ShaderVariable struct. This CL adds a ProgramInput struct so that we can add data members that actually required. This CL also makes bools into bitfield and some variables to uint16_t to further compact the size. This CL also groups the data memebers other than string to basicDataTypeStruct which only contains basic data types and the entire struct is memcpied during program binary load and save. This not just reduces number of memcpy calls, but also improves reliability so that when someone adds a new member into the struct, it will automatically load/save correctly. Bug: b/275102061 Change-Id: Ic055c986453ed46e56057a0122c9926245fef4d1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4776267 Reviewed-by: Roman Lavrov <romanl@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 719165c8 2023-08-04T12:13:37 Remove "const UniformTypeInfo *typeInfo" from struct LinkedUniform This is a cached pointer to the const kInfoTable. There isn't much of performance benefit to cache here compare to directly retrieve from the table. This cached pointer is removed in this CL, which means we do not need to update the pointer in the ProgramExecutable::load(). This and a few earlier CLs that attempt to do memcpy for entire mUniforms reduced average frame time of blade_and_soul_revolution app trace 3%, from 4.3359 ms to 4.2066ms on pixel 7 pro. Bug: b/275102061 Change-Id: I6fd34d665234e3a5cc85344924049bf5b13aaa80 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4753933 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Charlie Lao eff12c1e 2023-08-03T12:10:05 Move name and mappedName out of LinkedUniform struct These are std::string objects. This CL moves these two data out of LinkedUniform and into ProgramExecutable class, side by side with mUniforms. With these two data moved out, LinkedUniform is now a simple struct with basic data types, and I can memcpy entire vector of uniforms. Bug: b/275102061 Change-Id: I9ae13e7daca85f8e5f3662a4718f190bebb5f5d2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4750442 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 9c588180 2023-08-02T16:39:44 Change LinkedUniform::arraySizes from std::vector to unsigned int We always flatten multiple dimensional arrays in the uniform to a one dimensional array, so the arraySizes can be simplified to unsigned int instead of a vector. With this, we can now move the arraySize into the simple mFixedSizeData struct and the normal memcpy will cover the load/save. Bug: b/275102061 Change-Id: I24c026f783b755f7aa691a5db5746b6309a21227 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4735275 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao ee019f58 2023-08-01T17:03:24 Group fixed sized data of LinkedUniform into a struct Most of gl::LinkedUniform struct is a basic types and can be simply initialized with memcpy. This CL groups these together and encapsulate them with get APIs. The load/save is now a single memcpy for the entire fixed size data structure of basic types. Bug: b/275102061 Change-Id: I49120c06ec941c783790ac0ecb0ee314a4234b26 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4740298 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Roman Lavrov <romanl@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Shahbaz Youssefi 52fe3116 2023-07-17T16:20:54 Vulkan: Deduplicate share group's context set tracking Bug: angleproject:8224 Change-Id: I7a59a37229682fb91ff777f31e02e05d7ab2b80f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4690345 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 40111c68 2023-07-11T14:21:21 Rename context-local to context-private state Bug: angleproject:8224 Change-Id: I1bb39475043f8fb14d683d11a038b4850692a8c6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4678781 Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 72c26926 2023-07-05T16:31:23 Make pack/unpack and hint entry points lockless These entry points only set context-local state and thus don't require locking. Bug: angleproject:8224 Change-Id: I5694d319df61a7a9df1766cf1f723b9a05208209 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4666352 Reviewed-by: Igor Nazarov <i.nazarov@samsung.com> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 44395930 2023-07-05T11:59:23 Make various state setting entry points lockless These entry points only set context-local state and thus don't require locking. Bug: angleproject:8224 Change-Id: I428c23cc862e9356d571bc085b5df0bf48017175 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4661700 Reviewed-by: Igor Nazarov <i.nazarov@samsung.com> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Igor Nazarov 36c3e0f5 2023-01-17T17:42:59 Implement "Shared Context Mutex" functionality. Existing implementation uses single `GlobalMutex` for - EGL calls - GL calls for Contexts with concurrent access. This CL introduces abstract `egl::ContextMutex` with two implementations: - SingleContextMutex; - SharedContextMutex<Mutex>; Note: `std::mutex` is used in this commit. It is very easy to change mutex type either at compile-time or at run-time (single type per Display). When Context: - is not Shared; - does not use `EGLImage`s; - does not use EGL_DISPLAY_TEXTURE_SHARE_GROUP_ANGLE - does not use EGL_DISPLAY_SEMAPHORE_SHARE_GROUP_ANGLE then it will be using `SingleContextMutex` with minimal overhead. Before such Context is used as `shareContext` or uses `EGLImage` its mutex replaced by `SharedContextMutex<Mutex>`. The `GlobalMutex` is only used for EGL calls, while `egl::ContextMutex` implementations for GL calls. Because some EGL calls use Context, explicit `egl::ContextMutex` lock is required. This is implemented by generating "egl_context_mutex_autogen.h" header, and insertion of `ANGLE_EGL_SCOPED_CONTEXT_LOCK()` macro before `ANGLE_EGL_VALIDATE()` in each EGL entry point. Implementation in "egl_context_lock_impl.h" returns lock for required APIs. Special cases of `egl::ContextMutex` lock handled separately. `std::unique_lock<>` is not used for performance reasons. `egl::ContextMutex` explicitly locked when capturing EGL calls. Fixes EGLImage problem: https://chromium.googlesource.com/angle/angle/+/e18240d136d15e5cdfa4fa4a6355ca21c8d807b6 Mark contexts as shared when importing EGL images. Details: - EGLImage inherits Context's mutex when created. Mutex is used when the EGLImage accessed or destroyed. - When EGLImage is used in Context with other `egl::ContextMutex`, two mutexes are merged into one. - After the mutex merge, Context Groups will remain separate, but will not be able to run in parallel. Fixes race when checking `context->isShared()` in the `SCOPED_SHARE_CONTEXT_LOCK()` macro. One Context may start executing GL call while not "Shared", but become "Shared" inside the call. New (second) "Shared" Context may immediately start using GL and potentially corrupt some "Shared" state. Possible performance benefit: allows parallel execution in some cases, when single `GlobalMutex` would block. Important note: Process of replacing the `SingleContextMutex` by `SharedContextMutex<Mutex>` is not 100% safe. This mean that original Context may still be using `SingleContextMutex` after activating `SharedContextMutex<Mutex>`. However, this was always the case before introduction of this CL. Old `Context::mShared` member update was not synchronized in any way at all. In other words, this solution does not 100% fix the original problem. For 100% safe solution `SingleContextMutex` should not be used (always pass `SharedContextMutex<Mutex>` to the `gl::Context` constructor). See `lockAndActivateSharedContextMutex()` for more details. CL adds new build option: angle_enable_shared_context_mutex = true Behavior with other build options: - When: `angle_enable_shared_context_mutex` is disabled or `angle_enable_share_context_lock` is disabled or `angle_force_context_check_every_call` is enabled, Contexts will always have `SingleContextMutex`, however it will be only used in special cases. `SCOPED_SHARE_CONTEXT_LOCK()` will use `GlobalMutex` when applicable. - Otherwise, `SCOPED_SHARE_CONTEXT_LOCK()` will use `egl::ContextMutex`. Some GFXBench "1080p Driver Overhead 2 Offscreen" performance numbers. Tested on S906B (Samsung Galaxy S22+) on old ANGLE base: https://chromium.googlesource.com/angle/angle/+/807c94ea85e046c6f279d081d99f0fb1bcf1191a Capture/Replay: Adjust tests do adhere to capture limits Each test result is an average frame number from 6 runs. SingleContextMutex 6579 ( +0.13%) (old) GetContextLock() (mShared is false) 6570 Forced `mShared = true` or NOT using `SingleContextMutex`. SharedContextMutex<std::mutex> FORCE 5061 (-22.97%) (old) GetContextLock() FORCE 4766 (-27.46%) Bug: angleproject:6957 Bug: chromium:1336126 Change-Id: Idcd919f9d4bf482b9ae489bd8b4415ec96048e32 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4374545 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Steven Noonan a01a566c 2023-06-09T00:31:06 extension xmls: fix incorrect use of <ptype> tags I was having trouble using some GL/EGL loader generators because of some errors in the XML definitions for ANGLE. The first major problem is the content of the <ptype> tags. Let's refer to the Khronos registry XML schema (which is annoyingly a PDF rather than an xsd that we can test against, though I don't know if an xsd would catch this anyway): https://raw.githubusercontent.com/KhronosGroup/OpenGL-Registry/master/xml/readme.pdf In section 12.4.2, "Contents of <param> tags" it states: The <ptype> tag is optional, and contains text which is a valid type name found in <type> tag, and indicates that this type must be previously defined for the definition of the command to succeed. Builtin C types, and any derived types which are expected to be found in other header files, should not be wrapped in <ptype> tags Note that the above is repeated for the contents of <proto> tags as well. The extension XML files currently have a bunch of <ptype> tags which don't meet the expectations described above. The correct transformation for them would be, for example: <ptype>GLfloat *</ptype> -> <ptype>GLfloat</ptype> * <ptype>void *</ptype> -> void * <ptype>const char *</ptype> -> const char * <ptype>EGLAttrib *</ptype> -> <ptype>EGLAttrib</ptype> * The next issue is that some tags have some typos, such as "<pytpe>" instead of "<ptype>". (Now *that* is something an .xsd would catch...) The last issue is the use of the typename "GLvoid" which is not as serious a problem. It is still defined in Khronos' gl.xml <types> block, but Khronos no longer uses it in their XML registries. The comment for the "GLvoid" type in their <types> block states: <type comment="Not an actual GL type, though used in headers in the past">typedef void <name>GLvoid</name>;</type> So we might as well replace those with just plain "void". Anyway, long story short: to apply these transformations, I used Perl regular expressions, and applied these expressions in order: - Fix the tag misspellings: s#<(/?)pytpe>#<\1ptype>#g - Move the const qualifiers (if present) and pointer asterisk(s) (if any) outside the <ptype> tag itself: s#<ptype>(const )?([A-Za-z0-9]+)[ ]?(\*\*?)</ptype> #\1<ptype>\2</ptype> \3#g - Replace "GLvoid", "char", and "void" inside ptype tags to normal C types outside tags: s#<ptype>(GLvoid|void|char)</ptype>#\1#g Bug: angleproject:8190 Change-Id: Ib0bea79fecb7e714910b6e92124bb9f52994d0fb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4603709 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Cody Northrop d8339e78 2023-05-25T08:40:48 FrameCapture: Support EGLSync in MEC This CL starts treating EGLSync as a tracked resource, such that we can detect when they need to be created in Setup, or regenerated in Reset. Test: MEC of infinity_ops trace Test: Replay new kentucky_route_zero trace without error Bug: angleproject:8176 Change-Id: I130212f6edb78d9df29dd6e572843df25493ae09 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4566949 Reviewed-by: Roman Lavrov <romanl@google.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
Mark Lobodzinski 9e47cbd3 2023-05-18T14:40:37 Capture/Replay: Rework trace EGLDisplay handling Refactor the trace-replay EGLDisplay handling to allow initializing the global EGLDisplay handle in the InitializeReplay4() body. This included adding support for eglGetCurrentDisplay() to the EGL-on- WGL shim. Test: angle_trace_tests --gtest_filter=infinity_ops Bug: b/282725258 Change-Id: I2319fd9a35f8fb9c0a7f10547ca39f49ce402b8d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4546267 Reviewed-by: Roman Lavrov <romanl@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Mark Łobodziński <mark@lunarg.com>
Mark Lobodzinski 8fdb164b 2023-05-11T10:03:57 Capture/Replay: Get and use actual EGLDisplay in trace ANGLE traces were using ANGLE_NO_DISPLAY for EGLDisplay args in traces. After the EGLSyncMap was added this caused error messages in Android and Linux playback of some traces. Added a global EGLDisplay to traces and initialized it with the proper value. Test: angle_trace_tests --gtest_filter=infinity_ops Bug: b/282725258 Change-Id: I1e6522cd4fdfee136c1e296805dac9d9f71256f3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4534096 Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Mark Lobodzinski c687078a 2023-05-01T16:45:19 FrameCapture: Add GLES1 case for BlendFunc state init/reset A recent frame capture change added state init/reset for glBlendFunc/glBlendFuncSeparate calls and combined them to avoid complexity, but this caused crashes in GLES1 native trace playback. This CL separates handling of the two calls. Test: angle_trace_tests --gtest_filter=TraceTest.street_fighter_iv_ce Bug: b/280329971 Change-Id: I34d674e2fc051f5af70a60a24e5b65c5ce54fd49 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4494261 Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Roman Lavrov <romanl@google.com> Commit-Queue: Mark Łobodziński <mark@lunarg.com>
Justin Novosad fbff065c 2023-05-03T22:19:07 Replace GetResourceFromHashSet with map lookup Function GetResourceFromHashSet had linear time complexity because it was sweeping through the set until a resource with a matching ID was found. This change replaces hash sets with hash maps to get constant time lookup. This solves, among other things, O(N^2) time complexity for rendering scenes containing a large number of surfaces. Function GetResourceFromHashSet was consuming over 50% of all CPU time on the main thread of Chrome's GPU process while running the MotionMark 1.2 Images test. With this change, the benchmark score increases by 70% on an M1 MacBook running a PGO official build of Chrome. Bug: chromium:1435066 Change-Id: I895ac0141a91d324c63adec2c0efb8e030d9675b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4505950 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Justin Novosad <junov@chromium.org> Reviewed-by: Igor Nazarov <i.nazarov@samsung.com>
Alexey Knyazev 73f9cf00 2023-03-31T00:00:00 GL: Implement polygon mode extensions * Implemented polygon mode extensions on the OpenGL backend * Supported capture and serialization of the new commands and state * Added PolygonModeTest end2end tests Bug: angleproject:1791 Bug: angleproject:8132 Change-Id: I3bc08546a02f110dd739950129bee25ccc507bf6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4492683 Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi cd6a58f2 2023-04-18T12:45:10 Vulkan: Make eglPrepareSwapBuffersANGLE less special This function now uses the UnlockedTailCall mechanism so it doesn't require as much special-case code generation. This change does not fix the bug that this function is doing too much work without holding any locks. That will be done in a follow up. Bug: angleproject:6851 Bug: angleproject:8133 Change-Id: I77f4d514ff4aeef85bc1cc59214f7caa23aca7df Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4443186 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Mark Lobodzinski 1810995c 2023-04-25T13:09:27 Capture/Replay: Initialize MEC alpha test state Fixes Street Fighter IV CE rendering issues when capturing. Test: angle_trace_tests --gtest_filter="*street_figher_iv_ce*" Bug: b/278606770 Change-Id: Ifb44c45b19514e4cabed1e81be99bce5706ac4d3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4475732 Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Mark Łobodziński <mark@lunarg.com>
Constantine Shablya e975f9dc 2022-11-09T06:44:06 Capture/Replay: handle paletted textures Add a method for recompressing paletted textures on capture. Bug: angleproject:7710 Change-Id: I11af0c1cd7c3b63850c5daf96eafcd3efce65f16 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4178311 Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Alexey Knyazev e809e7bd 2023-03-13T00:00:00 Reland "Implement EXT_depth_clamp" This is a reland of commit f8c1418319ac2aef4b3101e322005b1d0f73120f Host GPU bugs are observable in iOS Simulator Original change's description: > Implement EXT_depth_clamp > > * Added depthClamp to the RasterizerState > * Added DepthWriteTest end2end tests covering > both clipped and clamped depth writes > > Capture > * Updated serialized rasterizer state > * Updated CaptureMidExecutionSetup > > OpenGL > * Requires GL 3.2 or ARB_depth_clamp > on desktop contexts > * Maps to EXT_depth_clamp on ES > > D3D11 > * Maps to the opposite of > D3D11_RASTERIZER_DESC.DepthClipEnable > * The new tests uncover several edge cases where > a workaround is needed to implement unextended > OpenGL semantics on top of D3D > > Metal > * Maps to the setDepthClipMode command > > Bug: angleproject:8047 > Bug: angleproject:8077 > Change-Id: I1b3448e5b84443e4be18af9bc22d2f8495ac8267 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4347753 > Reviewed-by: Geoff Lang <geofflang@chromium.org> > Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com> Bug: angleproject:8047 Bug: angleproject:8077 Change-Id: I8c5f8304276c97c51b2c3382cd2764592ee0c3fe Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4349938 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
Yuxin Hu 4a77b0f5 2023-03-18T00:16:24 Revert "Implement EXT_depth_clamp" This reverts commit f8c1418319ac2aef4b3101e322005b1d0f73120f. Reason for revert: This change breaks angle_end2end_tests on Metal backend: https://ci.chromium.org/ui/p/chromium/builders/ci/ios-angle-intel/26035/overview Original change's description: > Implement EXT_depth_clamp > > * Added depthClamp to the RasterizerState > * Added DepthWriteTest end2end tests covering > both clipped and clamped depth writes > > Capture > * Updated serialized rasterizer state > * Updated CaptureMidExecutionSetup > > OpenGL > * Requires GL 3.2 or ARB_depth_clamp > on desktop contexts > * Maps to EXT_depth_clamp on ES > > D3D11 > * Maps to the opposite of > D3D11_RASTERIZER_DESC.DepthClipEnable > * The new tests uncover several edge cases where > a workaround is needed to implement unextended > OpenGL semantics on top of D3D > > Metal > * Maps to the setDepthClipMode command > > Bug: angleproject:8047 > Bug: angleproject:8077 > Change-Id: I1b3448e5b84443e4be18af9bc22d2f8495ac8267 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4347753 > Reviewed-by: Geoff Lang <geofflang@chromium.org> > Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com> Bug: angleproject:8047 Bug: angleproject:8077 Change-Id: I829add68c006c72b7b4acf03aee3efa8a9a16fac No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4350876 Reviewed-by: Alexis Hétu <sugoi@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Yuxin Hu <yuxinhu@google.com>
Alexey Knyazev f8c14183 2023-03-13T00:00:00 Implement EXT_depth_clamp * Added depthClamp to the RasterizerState * Added DepthWriteTest end2end tests covering both clipped and clamped depth writes Capture * Updated serialized rasterizer state * Updated CaptureMidExecutionSetup OpenGL * Requires GL 3.2 or ARB_depth_clamp on desktop contexts * Maps to EXT_depth_clamp on ES D3D11 * Maps to the opposite of D3D11_RASTERIZER_DESC.DepthClipEnable * The new tests uncover several edge cases where a workaround is needed to implement unextended OpenGL semantics on top of D3D Metal * Maps to the setDepthClipMode command Bug: angleproject:8047 Bug: angleproject:8077 Change-Id: I1b3448e5b84443e4be18af9bc22d2f8495ac8267 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4347753 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
Alexey Knyazev bf5e9dbc 2023-03-09T00:00:00 GL: Reset clip origin before scissored clears Clip origin must not affect scissor box but some drivers flip it for clear operations. Added capture/replay support for ClipControl. Bug: angleproject:8066 Change-Id: I9292cb4945b49c56c80da4c5813e89df3453b6b6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4328267 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
Gert Wollny a8ba5112 2023-02-10T10:04:41 Capture/Replay: Deal with swap called in different contexts Move recording the context setup of the main context to the same location where all other context setups are recorded and drop the assertion that checks that swap is always called from the same context. Invoke the context setup at the time the secondary contexts are set up, and make sure the main context is correctly mapped. Bug: angleproject:7911 Change-Id: I327bce318b1a0e26ffdbf096343f99cedd78c116 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4236541 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
Gert Wollny 0e9b8f36 2023-02-08T13:39:09 Capture/Replay: Drop context ID from file and frame func names This is needed when we want to be able to deal with swap called from different contexts. Bug: angleproject:7911 Change-Id: I83023308109852179f434be2290b33b7844ddcda Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4236540 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
Gert Wollny a52c0a6c 2023-02-06T16:01:27 Capture/Replay: Add and handle new resource type for EGLSync So far calls involving EGLSync were not tracking the actual sync objects, and this may lead to race conditions in multi-threaded and multi-context scenarios. This CL adds the type EGLSyncID and some specialized code handling of egl::Sync to distinguish EGLSync from the already existing GLSync objects in order to track them separately. Bug: angleproject:7911 Change-Id: I91b188a41069bc0620f51c55ee516d23b55bdd38 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4200095 Commit-Queue: Gert Wollny <gert.wollny@collabora.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Gert Wollny 111aca40 2023-02-15T14:06:15 Capture/Replay: Emit NULL instead of nullptr in trace When created C traces the value "nullptr" is not defined, so emit NULL instead, because this is supported in both, C and C++. Bug: angleproject:8018 Change-Id: I77584c462b1b02df39871929c1979d7ee7624361 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4254388 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
Gert Wollny 91bd7e6e 2023-01-09T15:57:35 Capture/Replay: VertexArrayState: also track binding index too We have to capture the case when only the binding index is not at the default value. Bug: angleproject:7912 Change-Id: Id08b20788422694db60f38c6e0b8b4a9191890c0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4143841 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Gert Wollny <gert.wollny@collabora.com>
Roman Lavrov a77e8e3a 2023-02-06T16:24:06 Limit logging when invalid calls are not captured. An app was crashing during capture due to a huge volume of such calls: % adb logcat -d | grep 'Not capturing invalid call' | wc -l 20609 There are a couple of cases where validation silently ignores "benign" invalid calls, such as glUniform*(-1, ...): https://crsrc.org/c/third_party/angle/src/libANGLE/validationES.cpp;drc=0c4306fc554c80506eb0f9b833a5d2a5fdd452d5;l=2815 Limit to (separately for active and inactive capture so that we still see these after triggering mid-execution capture). Example log after this CL: 02-07 11:54:45.869 7657 7749 I ANGLE : INFO: FrameCapture (capture inactive): Not capturing invalid call to glUniform1f 02-07 11:54:45.874 7657 7749 I ANGLE : INFO: FrameCapture (capture inactive): Not capturing invalid call to glUniform1f 02-07 11:54:45.882 7657 7749 I ANGLE : INFO: FrameCapture (capture inactive): Not capturing invalid call to glUniform1f (will no longer repeat for this entry point) ... (then I triggered capture) ... 02-07 11:55:13.049 7657 7749 I ANGLE : INFO: FrameCapture (capture active): Not capturing invalid call to glUniform1f 02-07 11:55:13.049 7657 7749 I ANGLE : INFO: FrameCapture (capture active): Not capturing invalid call to glUniform1f 02-07 11:55:13.050 7657 7749 I ANGLE : INFO: FrameCapture (capture active): Not capturing invalid call to glUniform1f (will no longer repeat for this entry point) Bug: b/267795212 Change-Id: I2f150cfa5b4c74fc1ebe5abeb1201cc4caad80e3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4224875 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Roman Lavrov <romanl@google.com>
Cody Northrop 0931b679 2023-01-26T13:20:22 FrameCapture: Update shader capture for CRLF Shaders with CRLF were breaking the way we capture strings after the move to C format, causing compile failures. To fix, strip out carriage returns ("\r") before splitting the string. See previous patchsets on this CL to see other approaches we tried. Test: LIMBO and Pokemon Masters EX traces Bug: angleproject:7945 Bug: angleproject:7953 Change-Id: Ia15d3a098cb4fcad85a7d7dbd365acdbff8346ce Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4159055 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Cody Northrop <cnorthrop@google.com>
Alexey Knyazev ef0fe638 2023-01-16T00:00:00 Implement EXT_polygon_offset_clamp * Added polygonOffsetClamp to the RasterizerState * Adjusted State::setPolygonOffsetParams * Added PolygonOffsetClampTest end2end tests * Added StateChangeTestES3.PolygonOffsetClamp test * Suppressed the affected dEQP test as it has a bug Capture * Updated serialized rasterizer state * Updated CaptureMidExecutionSetup OpenGL * Rely on the EXT extension defined both for desktop and ES contexts * On desktops, might as well use the ARB extension or GL 4.6 once ANGLE supports them D3D11 * Requires FL10_0 or higher * Maps to D3D11_RASTERIZER_DESC.DepthBiasClamp * Drive-by cleanup of extensions init code Vulkan * Requires depthBiasClamp physical device feature * Maps to the depthBiasClamp parameter of the vkCmdSetDepthBias command Metal * Maps to the clamp parameter of the setDepthBias command Bug: angleproject:7957 Change-Id: If6b28df4084f0a81db29f75fb434e75d394c8730 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4169945 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
Roman Lavrov dfcdae3b 2023-01-23T15:59:49 FrameCapture: Add blend state updates to resetCalls. Adds calls to ResetReplay if modified during capture, for example: glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD); glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_SRC_ALPHA, GL_ONE); glBlendFunc and glBlendFuncSeparate need to be "merged" into a single path to avoid both being tracked while using the same underlying state, so I mapped them both to glBlendFuncSeparate. Also handling glBlendEquation the same way, previously only glBlendEquationSeparate calls were tracked. Test: Bubble Shooter with Friends MEC Bug: b/266244734 Change-Id: I02c4a0da46f35aa496308bf9df6ac15f3297de27 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4189035 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>