src/libANGLE/renderer/metal/mtl_glslang_utils.h


Log

Author Commit Date CI Message
Kyle Piddington d33a2222 2021-04-26T16:56:15 Upstream Apple's direct-to-Metal backend: compile libANGLE. This change is meant to merge the metal backend changes from Apple's direct-to-Metal backend. Taken from Kyle Piddington's CL: https://chromium-review.googlesource.com/c/angle/angle/+/2857366/ The goal of this CL is to merge the metal backend code in a state that compiles, but not to switch the Metal backend over to using the direct-to-metal backend yet. Bug: angleproject:5505 Bug: angleproject:6127 Change-Id: If6783e06e0086b3a1dd25c6f53caca5cfc96cb86 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2950067 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>
Shahbaz Youssefi 776c6015 2021-02-26T00:00:57 Vulkan: Call glslang at compile time With this change, the ANGLE translator immediately compiles the generated GLSL into SPIR-V with glslang and discards the source. This is in preparation for generating SPIR-V directly, by making the frontend and backend already able to digest it. This change also allows the expensive glslang calls to be parallelized, improving the following perf test by about 20%: LinkProgramBenchmark.Run/vulkan_compile_and_link_multi_thread Previously, the test was run as such in the Vulkan backend: Main Thread 1 Thread 2 Compile1 ---> Compile2 ---------------------> Translator Translator <--- <--------------------- Link glslang for shader1 glslang for shader2 Done With this change, it is run as such: Main Thread 1 Thread 2 Compile1 ---> Compile2 ---------------------> Translator Translator glslang glslang <--- <--------------------- Link Done glslang_wrapper_utils no longer interacts with glslang! A rename will follow. Bug: angleproject:4889 Change-Id: If4303e8ba0ba43b1a2f47f8c0a9133d0bee1a19a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2721195 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi c7c38731 2021-03-04T15:04:07 Vulkan: Move SpirvBlob definition to common/ For use by the translator. Bug: angleproject:4889 Change-Id: Ie95cafd3cfcdde50acc5d26d3c00e6574186a805 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2737276 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 77637f2d 2021-02-19T15:18:52 Vulkan: Generate xfb support code in SPIR-V for emulation path This change moves the code generation at link time from source code to SPIR-V. As a result, transform feedback extension and emulation paths are more similarly handled before SPIR-V transformation (they both store information identically in the ShaderInterfaceVariableInfoMap). This change gets rid of the @@ XFB-OUT @@ marker. With no source code generation at link time, shader compilation can be moved to glCompileShader time. Bug: angleproject:4888 Change-Id: I8cdb89c22b57ce48cf5d226b8e41622d9d550d46 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2713269 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Jamie Madill 093250e0 2020-12-23T12:07:46 Vulkan: Make shader variable info maps a class. Instead of using a map type directly we abstract the info maps into an encapsulated class. We can enforce a specific API set instead of using the same API as the map class. This also cleans up a few of the APIs related to these maps. This change will allow future changes to the way the variables are stored in the class without drastically changing the interface. Bug: angleproject:3572 Bug: angleproject:4524 Change-Id: Ic1a63e1776c39f49b895a1274bae8282d7a6b9b5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2600080 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Le Hoang Quyen 6136cbcb 2020-09-23T21:31:05 Metal: Implement transform feedback - XFB is currently emulated by writing to storage buffers. - Metal doesn't allow vertex shader to both write to storage buffers and to stage output (i.e clip position). So if GL_RASTERIZER_DISCARD is NOT enabled, the draw with XFB enabled will have 2 passes: + First pass: vertex shader writes to XFB buffers + not write to stage output + disable rasterizer. + Second pass: vertex shader writes to stage output (i.e. [[position]]) + enable rasterizer. If GL_RASTERIZER_DISCARD is enabled, the second pass is omitted. + This effectively executes the same vertex shader twice. TODO: possible improvement is writing vertex outputs to buffer in first pass then re-use that buffer as input for second pass which has a passthrough vertex shader. - If GL_RASTERIZER_DISCARD is enabled, and XFB is enabled: + Only first pass above will be executed, and the render pass will use an empty 1x1 texture attachment since rasterization is not needed. - If GL_RASTERIZER_DISCARD is enabled, but XFB is NOT enabled: + we still enable Metal rasterizer. + but vertex shader must emulate the discard by writing gl_Position = (-3, -3, -3, 1). This effectively moves the vertex out of clip space's visible area. + This is because GLSL still allows vertex shader to write to stage output when rasterizer is disabled. However, Metal doesn't allow that. In Metal, if rasterizer is disabled, then vertex shader must not write to stage output. - See src/libANGLE/renderer/metal/doc/TransformFeedback.md for more details. Bug: angleproject:2634 Change-Id: I6c700e031052560326b7f660ee7597202d38e6aa Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2408594 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>
Le Hoang Quyen 1677cf14 2020-09-13T20:14:59 Metal: Implement Uniform buffers Uniform buffer is implemented in two forms: - If number of ubo used in shader program is low, each buffer will use one discrete Metal buffer slot. - If number of ubo used is large, they will be embedded into one Metal argument buffer. Argument buffer is similar to Vulkan descriptor set. This is due to limit of number of Metal's discrete buffer slots which is only 31 and over half of them are already used by vertex attributes, default uniforms, driver uniforms, etc. The downside is that whenever a buffer binding is changed, the argument buffer must be updated also. Added empty TransformFeedbackMtl implementation to enable ES3 context creation on Metal. Bug: angleproject:2634 Change-Id: I69325696fac735cb45ab88ab55468c0991abc317 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2408593 Commit-Queue: Le Hoang Quyen <le.hoang.q@gmail.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
Le Hoang Quyen 50704dc3 2020-08-04T12:08:00 Metal: Implement EXT_occlusion_query_boolean. - Metal's occlusion(called visibility) query operates per render pass. Implementation details are in src/libANGLE/renderer/metal/doc/OcclusionQueries.md. - New tests: - OcclusionQueriesTest.ClearNotCounted. - OcclusionQueriesTest.MultiQueries (failure on OpenGL/D3D11 back-end). Bug: angleproject:2634 Change-Id: Idd1327b5472d0e8c2b69307a7f04a1da4a847a40 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2336121 Commit-Queue: Le Hoang Quyen <le.hoang.q@gmail.com> Reviewed-by: back sept 10 - Jamie Madill <jmadill@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
Le Hoang Quyen 5e13757b 2020-05-11T00:50:00 Metal: Fix array of structs containing array of samplers bug. Previously ProgramMtl could try to bind fixed slots to samplers based on layout (set=..., binding=...). However, GLSL layout model is different from Metal slots assignment. For example, The following is valid layout in GLSL: - array samplers A[2] is bound to index 0. - array samplers B[2] is bound to index 1. It is invalid to do so in Metal, since A occupies 2 slots, thus samplers B[2] must be bound to slots starting from 2. New binding method: let spirv-cross auto assigns the texture slots and retrieve them after compilation. Incomplete textures moved to ContextMtl using IncompleteTextureSet. New test added: GLSLTest.ArrayOfStructContainingArrayOfSamplers. Bug: angleproject:2634 Change-Id: Ib0edaaf8b20512e1272c37c1d4b16a88a5b35e75 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2193193 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
Tim Van Patten 913f4f42 2020-04-15T00:54:37 Vulkan: Support VS, FS, and CS in the same PPO This CL adds support for a Program Pipeline Object to have a VS, FS, and CS attached to the same PPO and then using that PPO for both draw and dispatch calls. Bug: angleproject:3570 Test: KHR-GLES31.core.compute_shader.sso* Change-Id: I262cdbdfd442f6db5ba2b45d1308003102b237cb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2150078 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Commit-Queue: Tim Van Patten <timvp@google.com>
Tim Van Patten 85c076ee 2020-02-20T17:54:35 Vulkan: Make mVariableInfoMap a gl::ShaderMap<> The ShaderInterfaceVariableInfoMap information is specific to each shader stage, since the locations are determined for each shader stage. This change makes mVariableInfoMap a gl::ShaderMap<> to handle this, which will make it easier to compile separable programs, determine the variable locations, and transform the SPIR-V. Bug: angleproject:3570 Change-Id: I28b71a37efe54bbcfe1dcd445fa03ee71e74f0a6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2062741 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com>
Shahbaz Youssefi 71e6afb1 2020-01-14T14:12:31 Vulkan: Set set/binding in SPIR-V This change introduces a SPIR-V transformer that modifies shader interface variable decorations directly in SPIR-V instead of manipulating the input GLSL. Currently, descriptor set and binding indices are set by the transformer. The shader translator outputs arbitrary set and binding indices. Once compiled by glslang, the SPIR-V transformer modifies these decorations. The ultimate goal is to be able to modify the SPIR-V again when program pipeline objects decide a different set/binding is necessary. Bug: angleproject:3394 Change-Id: If358265a72bf1fe9f5676562b39a632cb2e05dc4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2001477 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi b36e46ab 2020-01-08T15:49:18 Vulkan: Line raster emulation through specialization constant In preparation for compiling shaders early at link time, this change reworks line raster emulation such that it uses specialization constants instead of a preprocessor condition. This means drawing both triangles and lines with this program will still result in a one-time shader compilation. The compilation is still done at draw time in this change. Bug: angleproject:3394 Change-Id: I0bf91398868d7f7147456533b728906b505192b2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1992365 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Le Quyen a5a04ac0 2019-10-29T22:57:55 Metal backend pt3: shader translator Implementation of GLSL to MSL translator Bug: angleproject:2634 Change-Id: I66e2374b461548fac46163ea79790a488515e6b0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1887251 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Le Quyen fe26bae4 2019-10-29T18:38:53 Metal backend implementation pt 2 This is without Metal specific shader translator implemented yet. Bug: angleproject:2634 Change-Id: I95d589442251c9ba111bd05a2dc379a36739046c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1855069 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>