mesa: do not use _glapi_new_nop_table() for DRI builds
[mesa.git] / docs / devinfo.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html lang="en">
3 <head>
4 <meta http-equiv="content-type" content="text/html; charset=utf-8">
5 <title>Development Notes</title>
6 <link rel="stylesheet" type="text/css" href="mesa.css">
7 </head>
8 <body>
9
10 <div class="header">
11 <h1>The Mesa 3D Graphics Library</h1>
12 </div>
13
14 <iframe src="contents.html"></iframe>
15 <div class="content">
16
17 <h1>Development Notes</h1>
18
19
20 <ul>
21 <li><a href="#style">Coding Style</a>
22 <li><a href="#submitting">Submitting Patches</a>
23 <li><a href="#release">Making a New Mesa Release</a>
24 <li><a href="#extensions">Adding Extensions</a>
25 </ul>
26
27
28 <h2 id="style">Coding Style</h2>
29
30 <p>
31 Mesa is over 20 years old and the coding style has evolved over time.
32 Some old parts use a style that's a bit out of date.
33 If the guidelines below don't cover something, try following the format of
34 existing, neighboring code.
35 </p>
36
37 <p>
38 Basic formatting guidelines
39 </p>
40
41 <ul>
42 <li>3-space indentation, no tabs.
43 <li>Limit lines to 78 or fewer characters. The idea is to prevent line
44 wrapping in 80-column editors and terminals. There are exceptions, such
45 as if you're defining a large, static table of information.
46 <li>Opening braces go on the same line as the if/for/while statement.
47 For example:
48 <pre>
49 if (condition) {
50 foo;
51 } else {
52 bar;
53 }
54 </pre>
55
56 <li>Put a space before/after operators. For example, <tt>a = b + c;</tt>
57 and not <tt>a=b+c;</tt>
58
59 <li>This GNU indent command generally does the right thing for formatting:
60 <pre>
61 indent -br -i3 -npcs --no-tabs infile.c -o outfile.c
62 </pre>
63
64 <li>Use comments wherever you think it would be helpful for other developers.
65 Several specific cases and style examples follow. Note that we roughly
66 follow <a href="http://www.stack.nl/~dimitri/doxygen/">Doxygen</a> conventions.
67 <br>
68 <br>
69 Single-line comments:
70 <pre>
71 /* null-out pointer to prevent dangling reference below */
72 bufferObj = NULL;
73 </pre>
74 Or,
75 <pre>
76 bufferObj = NULL; /* prevent dangling reference below */
77 </pre>
78 Multi-line comment:
79 <pre>
80 /* If this is a new buffer object id, or one which was generated but
81 * never used before, allocate a buffer object now.
82 */
83 </pre>
84 We try to quote the OpenGL specification where prudent:
85 <pre>
86 /* Page 38 of the PDF of the OpenGL ES 3.0 spec says:
87 *
88 * "An INVALID_OPERATION error is generated for any of the following
89 * conditions:
90 *
91 * * <length> is zero."
92 *
93 * Additionally, page 94 of the PDF of the OpenGL 4.5 core spec
94 * (30.10.2014) also says this, so it's no longer allowed for desktop GL,
95 * either.
96 */
97 </pre>
98 Function comment example:
99 <pre>
100 /**
101 * Create and initialize a new buffer object. Called via the
102 * ctx->Driver.CreateObject() driver callback function.
103 * \param name integer name of the object
104 * \param type one of GL_FOO, GL_BAR, etc.
105 * \return pointer to new object or NULL if error
106 */
107 struct gl_object *
108 _mesa_create_object(GLuint name, GLenum type)
109 {
110 /* function body */
111 }
112 </pre>
113
114 <li>Put the function return type and qualifiers on one line and the function
115 name and parameters on the next, as seen above. This makes it easy to use
116 <code>grep ^function_name dir/*</code> to find function definitions. Also,
117 the opening brace goes on the next line by itself (see above.)
118
119 <li>Function names follow various conventions depending on the type of function:
120 <pre>
121 glFooBar() - a public GL entry point (in glapi_dispatch.c)
122 _mesa_FooBar() - the internal immediate mode function
123 save_FooBar() - retained mode (display list) function in dlist.c
124 foo_bar() - a static (private) function
125 _mesa_foo_bar() - an internal non-static Mesa function
126 </pre>
127
128 <li>Constants, macros and enumerant names are ALL_UPPERCASE, with _ between
129 words.
130 <li>Mesa usually uses camel case for local variables (Ex: "localVarname")
131 while gallium typically uses underscores (Ex: "local_var_name").
132 <li>Global variables are almost never used because Mesa should be thread-safe.
133
134 <li>Booleans. Places that are not directly visible to the GL API
135 should prefer the use of <tt>bool</tt>, <tt>true</tt>, and
136 <tt>false</tt> over <tt>GLboolean</tt>, <tt>GL_TRUE</tt>, and
137 <tt>GL_FALSE</tt>. In C code, this may mean that
138 <tt>#include &lt;stdbool.h&gt;</tt> needs to be added. The
139 <tt>try_emit_</tt>* methods in src/mesa/program/ir_to_mesa.cpp and
140 src/mesa/state_tracker/st_glsl_to_tgsi.cpp can serve as examples.
141
142 </ul>
143
144
145 <h2 id="submitting">Submitting patches</h2>
146
147 <p>
148 The basic guidelines for submitting patches are:
149 </p>
150
151 <ul>
152 <li>Patches should be sufficiently tested before submitting.
153 <li>Code patches should follow Mesa coding conventions.
154 <li>Whenever possible, patches should only effect individual Mesa/Gallium
155 components.
156 <li>Patches should never introduce build breaks and should be bisectable (see
157 <code>git bisect</code>.)
158 <li>Patches should be properly formatted (see below).
159 <li>Patches should be submitted to mesa-dev for review using
160 <code>git send-email</code>.
161 <li>Patches should not mix code changes with code formatting changes (except,
162 perhaps, in very trivial cases.)
163 </ul>
164
165 <h3>Patch formatting</h3>
166
167 <p>
168 The basic rules for patch formatting are:
169 </p>
170
171 <ul>
172 <li>Lines should be limited to 75 characters or less so that git logs
173 displayed in 80-column terminals avoid line wrapping. Note that git
174 log uses 4 spaces of indentation (4 + 75 &lt; 80).
175 <li>The first line should be a short, concise summary of the change prefixed
176 with a module name. Examples:
177 <pre>
178 mesa: Add support for querying GL_VERTEX_ATTRIB_ARRAY_LONG
179
180 gallium: add PIPE_CAP_DEVICE_RESET_STATUS_QUERY
181
182 i965: Fix missing type in local variable declaration.
183 </pre>
184 <li>Subsequent patch comments should describe the change in more detail,
185 if needed. For example:
186 <pre>
187 i965: Remove end-of-thread SEND alignment code.
188
189 This was present in Eric's initial implementation of the compaction code
190 for Sandybridge (commit 077d01b6). There is no documentation saying this
191 is necessary, and removing it causes no regressions in piglit on any
192 platform.
193 </pre>
194 <li>A "Signed-off-by:" line is not required, but not discouraged either.
195 <li>If a patch address a bugzilla issue, that should be noted in the
196 patch comment. For example:
197 <pre>
198 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89689
199 </pre>
200 <li>If there have been several revisions to a patch during the review
201 process, they should be noted such as in this example:
202 <pre>
203 st/mesa: add ARB_texture_stencil8 support (v4)
204
205 if we support stencil texturing, enable texture_stencil8
206 there is no requirement to support native S8 for this,
207 the texture can be converted to x24s8 fine.
208
209 v2: fold fixes from Marek in:
210 a) put S8 last in the list
211 b) fix renderable to always test for d/s renderable
212 fixup the texture case to use a stencil only format
213 for picking the format for the texture view.
214 v3: hit fallback for getteximage
215 v4: put s8 back in front, it shouldn't get picked now (Ilia)
216 </pre>
217 <li>If someone tested your patch, document it with a line like this:
218 <pre>
219 Tested-by: Joe Hacker &lt;jhacker@foo.com&gt;
220 </pre>
221 <li>If the patch was reviewed (usually the case) or acked by someone,
222 that should be documented with:
223 <pre>
224 Reviewed-by: Joe Hacker &lt;jhacker@foo.com&gt;
225 Acked-by: Joe Hacker &lt;jhacker@foo.com&gt;
226 </pre>
227 </ul>
228
229
230
231 <h3>Testing Patches</h3>
232
233 <p>
234 It should go without saying that patches must be tested. In general,
235 do whatever testing is prudent.
236 </p>
237
238 <p>
239 You should always run the Mesa test suite before submitting patches.
240 The test suite can be run using the 'make check' command. All tests
241 must pass before patches will be accepted, this may mean you have
242 to update the tests themselves.
243 </p>
244
245 <p>
246 Whenever possible and applicable, test the patch with
247 <a href="http://people.freedesktop.org/~nh/piglit/">Piglit</a> to
248 check for regressions.
249 </p>
250
251
252 <h3>Mailing Patches</h3>
253
254 <p>
255 Patches should be sent to the Mesa mailing list for review.
256 When submitting a patch make sure to use git send-email rather than attaching
257 patches to emails. Sending patches as attachments prevents people from being
258 able to provide in-line review comments.
259 </p>
260
261 <p>
262 When submitting follow-up patches you can use --in-reply-to to make v2, v3,
263 etc patches show up as replies to the originals. This usually works well
264 when you're sending out updates to individual patches (as opposed to
265 re-sending the whole series). Using --in-reply-to makes
266 it harder for reviewers to accidentally review old patches.
267 </p>
268
269 <h3>Reviewing Patches</h3>
270
271 <p>
272 When you've reviewed a patch on the mailing list, please be unambiguous
273 about your review. That is, state either
274 <pre>
275 Reviewed-by: Joe Hacker &lt;jhacker@foo.com&gt;
276 </pre>
277 or
278 <pre>
279 Acked-by: Joe Hacker &lt;jhacker@foo.com&gt;
280 </pre>
281 Rather than saying just "LGTM" or "Seems OK".
282 </p>
283
284 <p>
285 If small changes are suggested, it's OK to say something like:
286 <pre>
287 With the above fixes, Reviewed-by: Joe Hacker &lt;jhacker@foo.com&gt;
288 </pre>
289 which tells the patch author that the patch can be committed, as long
290 as the issues are resolved first.
291 </p>
292
293
294 <h3>Marking a commit as a candidate for a stable branch</h3>
295
296 <p>
297 If you want a commit to be applied to a stable branch,
298 you should add an appropriate note to the commit message.
299 </p>
300
301 <p>
302 Here are some examples of such a note:
303 </p>
304 <ul>
305 <li>CC: &lt;mesa-stable@lists.freedesktop.org&gt;</li>
306 <li>CC: "9.2 10.0" &lt;mesa-stable@lists.freedesktop.org&gt;</li>
307 <li>CC: "10.0" &lt;mesa-stable@lists.freedesktop.org&gt;</li>
308 </ul>
309
310 Simply adding the CC to the mesa-stable list address is adequate to nominate
311 the commit for the most-recently-created stable branch. It is only necessary
312 to specify a specific branch name, (such as "9.2 10.0" or "10.0" in the
313 examples above), if you want to nominate the commit for an older stable
314 branch. And, as in these examples, you can nominate the commit for the older
315 branch in addition to the more recent branch, or nominate the commit
316 exclusively for the older branch.
317
318 This "CC" syntax for patch nomination will cause patches to automatically be
319 copied to the mesa-stable@ mailing list when you use "git send-email" to send
320 patches to the mesa-dev@ mailing list. Also, if you realize that a commit
321 should be nominated for the stable branch after it has already been committed,
322 you can send a note directly to the mesa-stable@lists.freedesktop.org where
323 the Mesa stable-branch maintainers will receive it. Be sure to mention the
324 commit ID of the commit of interest (as it appears in the mesa master branch).
325
326 The latest set of patches that have been nominated, accepted, or rejected for
327 the upcoming stable release can always be seen on the
328 <a href="http://cworth.org/~cworth/mesa-stable-queue/">Mesa Stable Queue</a>
329 page.
330
331 <h3>Criteria for accepting patches to the stable branch</h3>
332
333 Mesa has a designated release manager for each stable branch, and the release
334 manager is the only developer that should be pushing changes to these
335 branches. Everyone else should simply nominate patches using the mechanism
336 described above.
337
338 The stable-release manager will work with the list of nominated patches, and
339 for each patch that meets the crtieria below will cherry-pick the patch with:
340 <code>git cherry-pick -x &lt;commit&gt;</code>. The <code>-x</code> option is
341 important so that the picked patch references the comit ID of the original
342 patch.
343
344 The stable-release manager may at times need to force-push changes to the
345 stable branches, for example, to drop a previously-picked patch that was later
346 identified as causing a regression). These force-pushes may cause changes to
347 be lost from the stable branch if developers push things directly. Consider
348 yourself warned.
349
350 The stable-release manager is also given broad discretion in rejecting patches
351 that have been nominated for the stable branch. The most basic rule is that
352 the stable branch is for bug fixes only, (no new features, no
353 regressions). Here is a non-exhaustive list of some reasons that a patch may
354 be rejected:
355
356 <ul>
357 <li>Patch introduces a regression. Any reported build breakage or other
358 regression caused by a particular patch, (game no longer work, piglit test
359 changes from PASS to FAIL), is justification for rejecting a patch.</li>
360
361 <li>Patch is too large, (say, larger than 100 lines)</li>
362
363 <li>Patch is not a fix. For example, a commit that moves code around with no
364 functional change should be rejected.</li>
365
366 <li>Patch fix is not clearly described. For example, a commit message
367 of only a single line, no description of the bug, no mention of bugzilla,
368 etc.</li>
369
370 <li>Patch has not obviously been reviewed, For example, the commit message
371 has no Reviewed-by, Signed-off-by, nor Tested-by tags from anyone but the
372 author.</li>
373
374 <li>Patch has not already been merged to the master branch. As a rule, bug
375 fixes should never be applied first to a stable branch. Patches should land
376 first on the master branch and then be cherry-picked to a stable
377 branch. (This is to avoid future releases causing regressions if the patch
378 is not also applied to master.) The only things that might look like
379 exceptions would be backports of patches from master that happen to look
380 significantly different.</li>
381
382 <li>Patch depends on too many other patches. Ideally, all stable-branch
383 patches should be self-contained. It sometimes occurs that a single, logical
384 bug-fix occurs as two separate patches on master, (such as an original
385 patch, then a subsequent fix-up to that patch). In such a case, these two
386 patches should be squashed into a single, self-contained patch for the
387 stable branch. (Of course, if the squashing makes the patch too large, then
388 that could be a reason to reject the patch.)</li>
389
390 <li>Patch includes new feature development, not bug fixes. New OpenGL
391 features, extensions, etc. should be applied to Mesa master and included in
392 the next major release. Stable releases are intended only for bug fixes.
393
394 Note: As an exception to this rule, the stable-release manager may accept
395 hardware-enabling "features". For example, backports of new code to support
396 a newly-developed hardware product can be accepted if they can be reasonably
397 determined to not have effects on other hardware.</li>
398
399 <li>Patch is a performance optimization. As a rule, performance patches are
400 not candidates for the stable branch. The only exception might be a case
401 where an application's performance was recently severely impacted so as to
402 become unusable. The fix for this performance regression could then be
403 considered for a stable branch. The optimization must also be
404 non-controversial and the patches still need to meet the other criteria of
405 being simple and self-contained</li>
406
407 <li>Patch introduces a new failure mode (such as an assert). While the new
408 assert might technically be correct, for example to make Mesa more
409 conformant, this is not the kind of "bug fix" we want in a stable
410 release. The potential problem here is that an OpenGL program that was
411 previously working, (even if technically non-compliant with the
412 specification), could stop working after this patch. So that would be a
413 regression that is unaacceptable for the stable branch.</li>
414 </ul>
415
416
417 <h2 id="release">Making a New Mesa Release</h2>
418
419 <p>
420 These are the instructions for making a new Mesa release.
421 </p>
422
423 <h3>Get latest source files</h3>
424 <p>
425 Use git to get the latest Mesa files from the git repository, from whatever
426 branch is relevant. This document uses the convention X.Y.Z for the release
427 being created, which should be created from a branch named X.Y.
428 </p>
429
430 <h3>Perform basic testing</h3>
431 <p>
432 The release manager should, at the very least, test the code by compiling it,
433 installing it, and running the latest piglit to ensure that no piglit tests
434 have regressed since the previous release.
435 </p>
436
437 <p>
438 The release manager should do this testing with at least one hardware driver,
439 (say, whatever is contained in the local development machine), as well as on
440 both Gallium and non-Gallium software drivers. The software testing can be
441 performed by running piglit with the following environment-variable set:
442 </p>
443
444 <pre>
445 LIBGL_ALWAYS_SOFTWARE=1
446 </pre>
447
448 And Gallium vs. non-Gallium software drivers can be obtained by using the
449 following configure flags on separate builds:
450
451 <pre>
452 --with-dri-drivers=swrast
453 --with-gallium-drivers=swrast
454 </pre>
455
456 <p>
457 Note: If both options are given in one build, both swrast_dri.so drivers will
458 be compiled, but only one will be installed. The following command can be used
459 to ensure the correct driver is being tested:
460 </p>
461
462 <pre>
463 LIBGL_ALWAYS_SOFTWARE=1 glxinfo | grep "renderer string"
464 </pre>
465
466 If any regressions are found in this testing with piglit, stop here, and do
467 not perform a release until regressions are fixed.
468
469 <h3>Update version in file VERSION</h3>
470
471 <p>
472 Increment the version contained in the file VERSION at Mesa's top-level, then
473 commit this change.
474 </p>
475
476 <h3>Create release notes for the new release</h3>
477
478 <p>
479 Create a new file docs/relnotes/X.Y.Z.html, (follow the style of the previous
480 release notes). Note that the sha256sums section of the release notes should
481 be empty at this point.
482 </p>
483
484 <p>
485 Two scripts are available to help generate portions of the release notes:
486
487 <pre>
488 ./bin/bugzilla_mesa.sh
489 ./bin/shortlog_mesa.sh
490 </pre>
491
492 <p>
493 The first script identifies commits that reference bugzilla bugs and obtains
494 the descriptions of those bugs from bugzilla. The second script generates a
495 log of all commits. In both cases, HTML-formatted lists are printed to stdout
496 to be included in the release notes.
497 </p>
498
499 <p>
500 Commit these changes
501 </p>
502
503 <h3>Make the release archives, signatures, and the release tag</h3>
504 <p>
505 From inside the Mesa directory:
506 <pre>
507 ./autogen.sh
508 make -j1 tarballs
509 </pre>
510
511 <p>
512 After the tarballs are created, the sha256 checksums for the files will
513 be computed and printed. These will be used in a step below.
514 </p>
515
516 <p>
517 It's important at this point to also verify that the constructed tar file
518 actually builds:
519 </p>
520
521 <pre>
522 tar xjf MesaLib-X.Y.Z.tar.bz2
523 cd Mesa-X.Y.Z
524 ./configure --enable-gallium-llvm
525 make -j6
526 make install
527 </pre>
528
529 <p>
530 Some touch testing should also be performed at this point, (run glxgears or
531 more involved OpenGL programs against the installed Mesa).
532 </p>
533
534 <p>
535 Create detached GPG signatures for each of the archive files created above:
536 </p>
537
538 <pre>
539 gpg --sign --detach MesaLib-X.Y.Z.tar.gz
540 gpg --sign --detach MesaLib-X.Y.Z.tar.bz2
541 gpg --sign --detach MesaLib-X.Y.Z.zip
542 </pre>
543
544 <p>
545 Tag the commit used for the build:
546 </p>
547
548 <pre>
549 git tag -s mesa-X.Y.X -m "Mesa X.Y.Z release"
550 </pre>
551
552 <p>
553 Note: It would be nice to investigate and fix the issue that causes the
554 tarballs target to fail with multiple build process, such as with "-j4". It
555 would also be nice to incorporate all of the above commands into a single
556 makefile target. And instead of a custom "tarballs" target, we should
557 incorporate things into the standard "make dist" and "make distcheck" targets.
558 </p>
559
560 <h3>Add the sha256sums to the release notes</h3>
561
562 <p>
563 Edit docs/relnotes/X.Y.Z.html to add the sha256sums printed as part of "make
564 tarballs" in the previous step. Commit this change.
565 </p>
566
567 <h3>Push all commits and the tag creates above</h3>
568
569 <p>
570 This is the first step that cannot easily be undone. The release is going
571 forward from this point:
572 </p>
573
574 <pre>
575 git push origin X.Y --tags
576 </pre>
577
578 <h3>Install the release files and signatures on the distribution server</h3>
579
580 <p>
581 The following commands can be used to copy the release archive files and
582 signatures to the freedesktop.org server:
583 </p>
584
585 <pre>
586 scp MesaLib-X.Y.Z* people.freedesktop.org:
587 ssh people.freedesktop.org
588 cd /srv/ftp.freedesktop.org/pub/mesa
589 mkdir X.Y.Z
590 cd X.Y.Z
591 mv ~/MesaLib-X.Y.Z* .
592 </pre>
593
594 <h3>Back on mesa master, andd the new release notes into the tree</h3>
595
596 <p>
597 Something like the following steps will do the trick:
598 </p>
599
600 <pre>
601 cp docs/relnotes/X.Y.Z.html /tmp
602 git checkout master
603 cp /tmp/X.Y.Z.html docs/relnotes
604 git add docs/relnotes/X.Y.Z.html
605 </pre>
606
607 <p>
608 Also, edit docs/relnotes.html to add a link to the new release notes, and edit
609 docs/index.html to add a news entry. Then commit and push:
610 </p>
611
612 <pre>
613 git commit -a -m "docs: Import X.Y.Z release notes, add news item."
614 git push origin
615 </pre>
616
617 <h3>Update the mesa3d.org website</h3>
618
619 <p>
620 NOTE: The recent release managers have not been performing this step
621 themselves, but leaving this to Brian Paul, (who has access to the
622 sourceforge.net hosting for mesa3d.org). Brian is more than willing to grant
623 the permission necessary to future release managers to do this step on their
624 own.
625 </p>
626
627 <p>
628 Update the web site by copying the docs/ directory's files to
629 /home/users/b/br/brianp/mesa-www/htdocs/ with:
630 <br>
631 <code>
632 sftp USERNAME,mesa3d@web.sourceforge.net
633 </code>
634 </p>
635
636
637 <h3>Announce the release</h3>
638 <p>
639 Make an announcement on the mailing lists:
640
641 <em>mesa-dev@lists.freedesktop.org</em>,
642 and
643 <em>mesa-announce@lists.freedesktop.org</em>
644
645 Follow the template of previously-sent release announcements. The following
646 command can be used to generate the log of changes to be included in the
647 release announcement:
648
649 <pre>
650 git shortlog mesa-X.Y.Z-1..mesa-X.Y.Z
651 </pre>
652 </p>
653
654
655 <h2 id="extensions">Adding Extensions</h2>
656
657 <p>
658 To add a new GL extension to Mesa you have to do at least the following.
659
660 <ul>
661 <li>
662 If glext.h doesn't define the extension, edit include/GL/gl.h and add
663 code like this:
664 <pre>
665 #ifndef GL_EXT_the_extension_name
666 #define GL_EXT_the_extension_name 1
667 /* declare the new enum tokens */
668 /* prototype the new functions */
669 /* TYPEDEFS for the new functions */
670 #endif
671 </pre>
672 </li>
673 <li>
674 In the src/mapi/glapi/gen/ directory, add the new extension functions and
675 enums to the gl_API.xml file.
676 Then, a bunch of source files must be regenerated by executing the
677 corresponding Python scripts.
678 </li>
679 <li>
680 Add a new entry to the <code>gl_extensions</code> struct in mtypes.h
681 </li>
682 <li>
683 Update the <code>extensions.c</code> file.
684 </li>
685 <li>
686 From this point, the best way to proceed is to find another extension,
687 similar to the new one, that's already implemented in Mesa and use it
688 as an example.
689 </li>
690 <li>
691 If the new extension adds new GL state, the functions in get.c, enable.c
692 and attrib.c will most likely require new code.
693 </li>
694 <li>
695 The dispatch tests check_table.cpp and dispatch_sanity.cpp
696 should be updated with details about the new extensions functions. These
697 tests are run using 'make check'
698 </li>
699 </ul>
700
701
702
703
704 </div>
705 </body>
706 </html>