xref: /aosp_15_r20/external/angle/third_party/spirv-tools/src/CONTRIBUTING.md (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker# Contributing to SPIR-V Tools
2*8975f5c5SAndroid Build Coastguard Worker
3*8975f5c5SAndroid Build Coastguard Worker## For users: Reporting bugs and requesting features
4*8975f5c5SAndroid Build Coastguard Worker
5*8975f5c5SAndroid Build Coastguard WorkerWe organize known future work in GitHub projects. See
6*8975f5c5SAndroid Build Coastguard Worker[Tracking SPIRV-Tools work with GitHub projects](https://github.com/KhronosGroup/SPIRV-Tools/blob/main/docs/projects.md)
7*8975f5c5SAndroid Build Coastguard Workerfor more.
8*8975f5c5SAndroid Build Coastguard Worker
9*8975f5c5SAndroid Build Coastguard WorkerTo report a new bug or request a new feature, please file a GitHub issue. Please
10*8975f5c5SAndroid Build Coastguard Workerensure the bug has not already been reported by searching
11*8975f5c5SAndroid Build Coastguard Worker[issues](https://github.com/KhronosGroup/SPIRV-Tools/issues) and
12*8975f5c5SAndroid Build Coastguard Worker[projects](https://github.com/KhronosGroup/SPIRV-Tools/projects). If the bug has
13*8975f5c5SAndroid Build Coastguard Workernot already been reported open a new one
14*8975f5c5SAndroid Build Coastguard Worker[here](https://github.com/KhronosGroup/SPIRV-Tools/issues/new).
15*8975f5c5SAndroid Build Coastguard Worker
16*8975f5c5SAndroid Build Coastguard WorkerWhen opening a new issue for a bug, make sure you provide the following:
17*8975f5c5SAndroid Build Coastguard Worker
18*8975f5c5SAndroid Build Coastguard Worker*   A clear and descriptive title.
19*8975f5c5SAndroid Build Coastguard Worker    *   We want a title that will make it easy for people to remember what the
20*8975f5c5SAndroid Build Coastguard Worker        issue is about. Simply using "Segfault in spirv-opt" is not helpful
21*8975f5c5SAndroid Build Coastguard Worker        because there could be (but hopefully aren't) multiple bugs with
22*8975f5c5SAndroid Build Coastguard Worker        segmentation faults with different causes.
23*8975f5c5SAndroid Build Coastguard Worker*   A test case that exposes the bug, with the steps and commands to reproduce
24*8975f5c5SAndroid Build Coastguard Worker    it.
25*8975f5c5SAndroid Build Coastguard Worker    *   The easier it is for a developer to reproduce the problem, the quicker a
26*8975f5c5SAndroid Build Coastguard Worker        fix can be found and verified. It will also make it easier for someone
27*8975f5c5SAndroid Build Coastguard Worker        to possibly realize the bug is related to another issue.
28*8975f5c5SAndroid Build Coastguard Worker
29*8975f5c5SAndroid Build Coastguard WorkerFor feature requests, we use
30*8975f5c5SAndroid Build Coastguard Worker[issues](https://github.com/KhronosGroup/SPIRV-Tools/issues) as well. Please
31*8975f5c5SAndroid Build Coastguard Workercreate a new issue, as with bugs. In the issue provide
32*8975f5c5SAndroid Build Coastguard Worker
33*8975f5c5SAndroid Build Coastguard Worker*   A description of the problem that needs to be solved.
34*8975f5c5SAndroid Build Coastguard Worker*   Examples that demonstrate the problem.
35*8975f5c5SAndroid Build Coastguard Worker
36*8975f5c5SAndroid Build Coastguard Worker## For developers: Contributing a patch
37*8975f5c5SAndroid Build Coastguard Worker
38*8975f5c5SAndroid Build Coastguard WorkerBefore we can use your code, you must sign the
39*8975f5c5SAndroid Build Coastguard Worker[Khronos Open Source Contributor License Agreement](https://cla-assistant.io/KhronosGroup/SPIRV-Tools)
40*8975f5c5SAndroid Build Coastguard Worker(CLA), which you can do online. The CLA is necessary mainly because you own the
41*8975f5c5SAndroid Build Coastguard Workercopyright to your changes, even after your contribution becomes part of our
42*8975f5c5SAndroid Build Coastguard Workercodebase, so we need your permission to use and distribute your code. We also
43*8975f5c5SAndroid Build Coastguard Workerneed to be sure of various other things -- for instance that you'll tell us if
44*8975f5c5SAndroid Build Coastguard Workeryou know that your code infringes on other people's patents. You don't have to
45*8975f5c5SAndroid Build Coastguard Workersign the CLA until after you've submitted your code for review and a member has
46*8975f5c5SAndroid Build Coastguard Workerapproved it, but you must do it before we can put your code into our codebase.
47*8975f5c5SAndroid Build Coastguard Worker
48*8975f5c5SAndroid Build Coastguard WorkerSee
49*8975f5c5SAndroid Build Coastguard Worker[README.md](https://github.com/KhronosGroup/SPIRV-Tools/blob/main/README.md)
50*8975f5c5SAndroid Build Coastguard Workerfor instruction on how to get, build, and test the source. Once you have made
51*8975f5c5SAndroid Build Coastguard Workeryour changes:
52*8975f5c5SAndroid Build Coastguard Worker
53*8975f5c5SAndroid Build Coastguard Worker*   Ensure the code follows the
54*8975f5c5SAndroid Build Coastguard Worker    [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html).
55*8975f5c5SAndroid Build Coastguard Worker    Running `clang-format -style=file -i [modified-files]` can help.
56*8975f5c5SAndroid Build Coastguard Worker*   Create a pull request (PR) with your patch.
57*8975f5c5SAndroid Build Coastguard Worker*   Make sure the PR description clearly identified the problem, explains the
58*8975f5c5SAndroid Build Coastguard Worker    solution, and references the issue if applicable.
59*8975f5c5SAndroid Build Coastguard Worker*   If your patch completely fixes bug 1234, the commit message should say
60*8975f5c5SAndroid Build Coastguard Worker    `Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1234` When you do
61*8975f5c5SAndroid Build Coastguard Worker    this, the issue will be closed automatically when the commit goes into
62*8975f5c5SAndroid Build Coastguard Worker    main. Also, this helps us update the [CHANGES](CHANGES) file.
63*8975f5c5SAndroid Build Coastguard Worker*   Watch the continuous builds to make sure they pass.
64*8975f5c5SAndroid Build Coastguard Worker*   Request a code review.
65*8975f5c5SAndroid Build Coastguard Worker
66*8975f5c5SAndroid Build Coastguard WorkerThe reviewer can either approve your PR or request changes. If changes are
67*8975f5c5SAndroid Build Coastguard Workerrequested:
68*8975f5c5SAndroid Build Coastguard Worker
69*8975f5c5SAndroid Build Coastguard Worker*   Please add new commits to your branch, instead of amending your commit.
70*8975f5c5SAndroid Build Coastguard Worker    Adding new commits makes it easier for the reviewer to see what has changed
71*8975f5c5SAndroid Build Coastguard Worker    since the last review.
72*8975f5c5SAndroid Build Coastguard Worker*   Once you are ready for another round of reviews, add a comment at the
73*8975f5c5SAndroid Build Coastguard Worker    bottom, such as "Ready for review" or "Please take a look" (or "PTAL"). This
74*8975f5c5SAndroid Build Coastguard Worker    explicit handoff is useful when responding with multiple small commits.
75*8975f5c5SAndroid Build Coastguard Worker
76*8975f5c5SAndroid Build Coastguard WorkerAfter the PR has been reviewed it is the job of the reviewer to merge the PR.
77*8975f5c5SAndroid Build Coastguard WorkerInstructions for this are given below.
78*8975f5c5SAndroid Build Coastguard Worker
79*8975f5c5SAndroid Build Coastguard Worker## For maintainers: Reviewing a PR
80*8975f5c5SAndroid Build Coastguard Worker
81*8975f5c5SAndroid Build Coastguard WorkerThe formal code reviews are done on GitHub. Reviewers are to look for all of the
82*8975f5c5SAndroid Build Coastguard Workerusual things:
83*8975f5c5SAndroid Build Coastguard Worker
84*8975f5c5SAndroid Build Coastguard Worker*   Coding style follows the
85*8975f5c5SAndroid Build Coastguard Worker    [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html)
86*8975f5c5SAndroid Build Coastguard Worker*   Identify potential functional problems.
87*8975f5c5SAndroid Build Coastguard Worker*   Identify code duplication.
88*8975f5c5SAndroid Build Coastguard Worker*   Ensure the unit tests have enough coverage.
89*8975f5c5SAndroid Build Coastguard Worker*   Ensure continuous integration (CI) bots run on the PR. If not run (in the
90*8975f5c5SAndroid Build Coastguard Worker    case of PRs by external contributors), add the "kokoro:run" label to the
91*8975f5c5SAndroid Build Coastguard Worker    pull request which will trigger running all CI jobs.
92*8975f5c5SAndroid Build Coastguard Worker
93*8975f5c5SAndroid Build Coastguard WorkerWhen looking for functional problems, there are some common problems reviewers
94*8975f5c5SAndroid Build Coastguard Workershould pay particular attention to:
95*8975f5c5SAndroid Build Coastguard Worker
96*8975f5c5SAndroid Build Coastguard Worker*   Does the code work for both Shader (Vulkan and OpenGL) and Kernel (OpenCL)
97*8975f5c5SAndroid Build Coastguard Worker    scenarios? The respective SPIR-V dialects are slightly different.
98*8975f5c5SAndroid Build Coastguard Worker*   Changes are made to a container while iterating through it. You have to be
99*8975f5c5SAndroid Build Coastguard Worker    careful that iterators are not invalidated or that elements are not skipped.
100*8975f5c5SAndroid Build Coastguard Worker*   For SPIR-V transforms: The module is changed, but the analyses are not
101*8975f5c5SAndroid Build Coastguard Worker    updated. For example, a new instruction is added, but the def-use manager is
102*8975f5c5SAndroid Build Coastguard Worker    not updated. Later on, it is possible that the def-use manager will be used,
103*8975f5c5SAndroid Build Coastguard Worker    and give wrong results.
104*8975f5c5SAndroid Build Coastguard Worker*   If a pass gets the id of a type from the type manager, make sure the type is
105*8975f5c5SAndroid Build Coastguard Worker    not a struct or array. It there are two structs that look the same, the type
106*8975f5c5SAndroid Build Coastguard Worker    manager can return the wrong one.
107*8975f5c5SAndroid Build Coastguard Worker
108*8975f5c5SAndroid Build Coastguard Worker## For maintainers: Merging a PR
109*8975f5c5SAndroid Build Coastguard Worker
110*8975f5c5SAndroid Build Coastguard WorkerWe intend to maintain a linear history on the GitHub main branch, and the
111*8975f5c5SAndroid Build Coastguard Workerbuild and its tests should pass at each commit in that history. A linear
112*8975f5c5SAndroid Build Coastguard Workeralways-working history is easier to understand and to bisect in case we want to
113*8975f5c5SAndroid Build Coastguard Workerfind which commit introduced a bug. The
114*8975f5c5SAndroid Build Coastguard Worker[Squash and Merge](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/about-pull-request-merges#squash-and-merge-your-commits)
115*8975f5c5SAndroid Build Coastguard Workerbutton on the GitHub web interface. All other ways of merging on the web
116*8975f5c5SAndroid Build Coastguard Workerinterface have been disabled.
117*8975f5c5SAndroid Build Coastguard Worker
118*8975f5c5SAndroid Build Coastguard WorkerBefore merging, we generally require:
119*8975f5c5SAndroid Build Coastguard Worker
120*8975f5c5SAndroid Build Coastguard Worker1.  All tests except for the smoke test pass. See
121*8975f5c5SAndroid Build Coastguard Worker    [failing smoke test](#failing-smoke-test).
122*8975f5c5SAndroid Build Coastguard Worker1.  The PR is approved by at least one of the maintainers. If the PR modifies
123*8975f5c5SAndroid Build Coastguard Worker    different parts of the code, then multiple reviewers might be necessary.
124*8975f5c5SAndroid Build Coastguard Worker
125*8975f5c5SAndroid Build Coastguard WorkerThe squash-and-merge button will turn green when these requirements are met.
126*8975f5c5SAndroid Build Coastguard WorkerMaintainers have the to power to merge even if the button is not green, but that
127*8975f5c5SAndroid Build Coastguard Workeris discouraged.
128*8975f5c5SAndroid Build Coastguard Worker
129*8975f5c5SAndroid Build Coastguard Worker### Failing smoke test
130*8975f5c5SAndroid Build Coastguard Worker
131*8975f5c5SAndroid Build Coastguard WorkerThe purpose of the smoke test is to let us know if
132*8975f5c5SAndroid Build Coastguard Worker[shaderc](https://github.com/google/shaderc) fails to build with the change. If
133*8975f5c5SAndroid Build Coastguard Workerit fails, the maintainer needs to determine if the reason for the failure is a
134*8975f5c5SAndroid Build Coastguard Workerproblem in the current PR or if another repository needs to be changed. Most of
135*8975f5c5SAndroid Build Coastguard Workerthe time [Glslang](https://github.com/KhronosGroup/glslang) needs to be updated
136*8975f5c5SAndroid Build Coastguard Workerto account for the change in SPIR-V Tools.
137*8975f5c5SAndroid Build Coastguard Worker
138*8975f5c5SAndroid Build Coastguard WorkerThe PR can still be merged if the problem is not with that PR.
139*8975f5c5SAndroid Build Coastguard Worker
140*8975f5c5SAndroid Build Coastguard Worker## For maintainers: Running tests
141*8975f5c5SAndroid Build Coastguard Worker
142*8975f5c5SAndroid Build Coastguard WorkerFor security reasons, not all tests will run automatically. When they do not, a
143*8975f5c5SAndroid Build Coastguard Workermaintainer will have to start the tests.
144*8975f5c5SAndroid Build Coastguard Worker
145*8975f5c5SAndroid Build Coastguard WorkerIf the Github actions tests do not run on a PR, they can be initiated by closing
146*8975f5c5SAndroid Build Coastguard Workerand reopening the PR.
147*8975f5c5SAndroid Build Coastguard Worker
148*8975f5c5SAndroid Build Coastguard WorkerIf the kokoro tests are not run, they can be run by adding the label
149*8975f5c5SAndroid Build Coastguard Worker`kokoro:run` to the PR.
150