src/common/CompiledShaderState.cpp


Log

Author Commit Date CI Message
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>
Chris Dalton a05a0e15 2024-09-25T22:33:36 Validate PLS shaders against context state Add shader introspection for PLS uniforms and validate that they match context state during draw calls. Bug: angleproject:40096838 Change-Id: I76cdf8add03de8f8b0b3e772c15c0087c1d97e98 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5893962 Commit-Queue: Kenneth Russell <kbr@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Geoff Lang fcf3a1c0 2024-07-02T16:33:28 GL: Allow shader compilation with cached translated source Write the translated shader source when serializing shaders. This does not increase the size of the shader cache because Vulkan only uses the compiledBinary field. Spawn a ShaderTranslateTask for loading shaders so the GL backend can compile the shader on the native driver. Bug: angleproject:350779978 Change-Id: I14413a7ca2a0d99653a1082f2c8b4a94cf58626a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5672740 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
Shahbaz Youssefi 175514c6 2024-01-12T14:43:33 Translator: Bundle metadata flags coming out of the translator In preparation for a follow up change that adds more such metadata. Bundling them together makes it convenient to retrieve, save and load all those flags. Bug: b/320563594 Change-Id: I4f95b32acfb0842cc5d9e72c1788a827bee2c760 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5209450 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 93b97a59 2023-11-03T22:07:23 Make link job directly wait on compile job Previously, program link waited on the compile job on the calling thread before launching the link job. As a result, sequences of intermixed compile and link would get largely serialized as such: Main Thread Thread 1 Thread 2 Thread 3 Thread 4 Compile -------> Compile Compile -----------|----------> Compile Link | | Wait | | | | | |<--------------/--------------/ \------------------------------------------> Link Compile -------> Compile | Compile -----------|----------> Compile | Link | | | Wait | | | | | | | |<--------------/--------------/ | \---------------------------------------------|-----------> Link Compile -------> Compile | | Compile -----------|----------> Compile | | Link | | | | Wait | | | | | | | | | ... With this change, the main thread no longer waits for compilation to finish. It's the link job itself that does the waiting. This allows the main thread to go through Compile and Link commands without blocking, generating as many jobs as needed. The above scenario therefore becomes: Main T1 T2 T3 T4 T5 T6 T7 T8 T9 C ----> C C ------|----> C L ------|------|----> L C ------|------|-------W---> C C ------|------|-------|-----|----> C L ------|------|-------|-----|------|----> L C ------|------|-------|-----|------|-------W---> C C ------|------|-------|-----|------|-------|-----|----> C L ------|------|-------|-----|------|-------|-----|------|----> L . \-----\------>/ | | | | | W . | \-----\------>/ | | | . | | \-----\------>/ . | | | . | | | This greatly improves the amount of parallelism compile and link jobs get. The careful observer may note that the link job being blocked on the compile job is now wasting a thread from the thread pool. While this change is strictly an improvement, parallelism can be further improved if the link job is just not assigned to a thread until the corresponding compile jobs are finished. This is currently not possible, but may be if: - Instead of a thread pool, the operating system's FIFO scheduler is used. Then the operating system would automatically put blocking tasks to sleep and pick up another task. This has the downside of requiring threads to be created for each task. - The thread pool work scheduler is enhanced to be made aware of relationship between tasks and avoid scheduling jobs whose dependencies are not yet met. Alternatively, the number of threads in the pool can be increased by 30% and hope for the best. Bug: angleproject:8297 Change-Id: If4e6540ade47558a10cfab55e2286f073b904928 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5006874 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Shahbaz Youssefi 68bfa1ed 2023-08-22T22:02:15 Support for link to be entirely parallelized The link job is split as such: - Front-end link - Back-end link - Independent back-end link subtasks (typically native driver compile jobs) - Post-link finalization Each step depends on the previous. These steps are executed as such: 1. Program::link calls into ProgramImpl::link - ProgramImpl::link runs whatever needs the Context, such as releasing resources - ProgramImpl::link returns a LinkTask 2. Program::link implements a closure that calls the front-end link and passes the results to the backend's LinkTask. 3. The LinkTask potentially returns a set of LinkSubTasks to be scheduled by the worker pool 4. Once the link is resolved, the post-link finalization is run In the above, steps 1 and 4 are done under the share group lock. Steps 2 and 3 can be done in threads or without holding the share group lock if the backend supports it. Step 2 is not yet made independent of the Context on some backends, and a frontend feature is used to make that step either run on the main thread or as a worker thread. Bug: angleproject:8297 Change-Id: I12f1e6bbaf365543dfcac969e166e0b5aa622104 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4808191 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 962fdf7b 2023-08-31T17:44:51 Add templated BinaryOutputStream::writeVector and writeStruct To avoid repeated code pattern, this CL adds templated BinaryInputStream::readVector and readStruct and BinaryOutputStream::writeVector and writeStruct, that does the static assertion to ensure they are trivially copyable. readIntVector/writeIntVector is removed. This CL also padding warning for ProgramExecutable::PODStruct to avoid potential Msan complain. Bug: b/296433003 Change-Id: I8e718b41cde898960b9e86a2d7d1bc5a837fe561 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4834700 Reviewed-by: Roman Lavrov <romanl@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
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>
Shahbaz Youssefi 10380f4b 2023-06-06T11:52:08 Vulkan: Output SPIR-V ids from compiler In this change, the shader interface variables are given SPIR-V ids by the compiler before SPIR-V generation. Those ids are made available through the ShaderVariable interface. The transformer does not yet rely on this information. A follow up change will rework the backend's name->info map and the transformer to directly use ids instead of names. Bug: angleproject:7220 Change-Id: Ic0a62681d4bcf3ed171c39c3ecd83e438ea068c8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4600609 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Roman Lavrov <romanl@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Mohan Maiya cc34aa73 2022-12-19T14:03:27 Move BinaryStream to common and expose ShaderState to compiler This is a refactor change in preparation for adding support for glShaderBinary. Move BinaryStream to common so that it is accessible by both libANGLE and the Compiler. Extract members that hold the result of compilation from ShaderState and move into new CompiledShaderState struct. Move helper functions & classes relevant to ShaderVar serialization to the CompiledShaderState header. Tests: EGLBlobCacheTest* Bug: angleproject:7833 Change-Id: I7ec575247eccb3afbc6ab6bfa24d36e69d4576f5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4080998 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: mohan maiya <m.maiya@samsung.com>