15bd8deadSopenharmony_ci<!DOCTYPE html>
25bd8deadSopenharmony_ci<html lang="en">
35bd8deadSopenharmony_ci<head>
45bd8deadSopenharmony_ci<meta charset="UTF-8">
55bd8deadSopenharmony_ci<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
65bd8deadSopenharmony_ci<meta name="viewport" content="width=device-width, initial-scale=1.0">
75bd8deadSopenharmony_ci<meta name="generator" content="Asciidoctor 1.5.7.1">
85bd8deadSopenharmony_ci<meta name="author" content="John Kessenich, Google (Editor and Author) ; Dave Baldwin and Randi Rost (Version 1.1 Authors)">
95bd8deadSopenharmony_ci<title>The OpenGL&#174; Shading Language, Version 4.60.7</title>
105bd8deadSopenharmony_ci<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
115bd8deadSopenharmony_ci<style>
125bd8deadSopenharmony_ci/* Asciidoctor default stylesheet | MIT License | http://asciidoctor.org */
135bd8deadSopenharmony_ci/* Uncomment @import statement below to use as custom stylesheet */
145bd8deadSopenharmony_ci/*@import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700";*/
155bd8deadSopenharmony_ciarticle,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}
165bd8deadSopenharmony_ciaudio,canvas,video{display:inline-block}
175bd8deadSopenharmony_ciaudio:not([controls]){display:none;height:0}
185bd8deadSopenharmony_ciscript{display:none!important}
195bd8deadSopenharmony_cihtml{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}
205bd8deadSopenharmony_cia{background:transparent}
215bd8deadSopenharmony_cia:focus{outline:thin dotted}
225bd8deadSopenharmony_cia:active,a:hover{outline:0}
235bd8deadSopenharmony_cih1{font-size:2em;margin:.67em 0}
245bd8deadSopenharmony_ciabbr[title]{border-bottom:1px dotted}
255bd8deadSopenharmony_cib,strong{font-weight:bold}
265bd8deadSopenharmony_cidfn{font-style:italic}
275bd8deadSopenharmony_cihr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}
285bd8deadSopenharmony_cimark{background:#ff0;color:#000}
295bd8deadSopenharmony_cicode,kbd,pre,samp{font-family:monospace;font-size:1em}
305bd8deadSopenharmony_cipre{white-space:pre-wrap}
315bd8deadSopenharmony_ciq{quotes:"\201C" "\201D" "\2018" "\2019"}
325bd8deadSopenharmony_cismall{font-size:80%}
335bd8deadSopenharmony_cisub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
345bd8deadSopenharmony_cisup{top:-.5em}
355bd8deadSopenharmony_cisub{bottom:-.25em}
365bd8deadSopenharmony_ciimg{border:0}
375bd8deadSopenharmony_cisvg:not(:root){overflow:hidden}
385bd8deadSopenharmony_cifigure{margin:0}
395bd8deadSopenharmony_cifieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}
405bd8deadSopenharmony_cilegend{border:0;padding:0}
415bd8deadSopenharmony_cibutton,input,select,textarea{font-family:inherit;font-size:100%;margin:0}
425bd8deadSopenharmony_cibutton,input{line-height:normal}
435bd8deadSopenharmony_cibutton,select{text-transform:none}
445bd8deadSopenharmony_cibutton,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}
455bd8deadSopenharmony_cibutton[disabled],html input[disabled]{cursor:default}
465bd8deadSopenharmony_ciinput[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}
475bd8deadSopenharmony_cibutton::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}
485bd8deadSopenharmony_citextarea{overflow:auto;vertical-align:top}
495bd8deadSopenharmony_citable{border-collapse:collapse;border-spacing:0}
505bd8deadSopenharmony_ci*,*::before,*::after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}
515bd8deadSopenharmony_cihtml,body{font-size:100%}
525bd8deadSopenharmony_cibody{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;font-weight:400;font-style:normal;line-height:1;position:relative;cursor:auto;tab-size:4;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}
535bd8deadSopenharmony_cia:hover{cursor:pointer}
545bd8deadSopenharmony_ciimg,object,embed{max-width:100%;height:auto}
555bd8deadSopenharmony_ciobject,embed{height:100%}
565bd8deadSopenharmony_ciimg{-ms-interpolation-mode:bicubic}
575bd8deadSopenharmony_ci.left{float:left!important}
585bd8deadSopenharmony_ci.right{float:right!important}
595bd8deadSopenharmony_ci.text-left{text-align:left!important}
605bd8deadSopenharmony_ci.text-right{text-align:right!important}
615bd8deadSopenharmony_ci.text-center{text-align:center!important}
625bd8deadSopenharmony_ci.text-justify{text-align:justify!important}
635bd8deadSopenharmony_ci.hide{display:none}
645bd8deadSopenharmony_ciimg,object,svg{display:inline-block;vertical-align:middle}
655bd8deadSopenharmony_citextarea{height:auto;min-height:50px}
665bd8deadSopenharmony_ciselect{width:100%}
675bd8deadSopenharmony_ci.center{margin-left:auto;margin-right:auto}
685bd8deadSopenharmony_ci.stretch{width:100%}
695bd8deadSopenharmony_ci.subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em}
705bd8deadSopenharmony_cidiv,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0;direction:ltr}
715bd8deadSopenharmony_cia{color:#2156a5;text-decoration:underline;line-height:inherit}
725bd8deadSopenharmony_cia:hover,a:focus{color:#1d4b8f}
735bd8deadSopenharmony_cia img{border:none}
745bd8deadSopenharmony_cip{font-family:inherit;font-weight:400;font-size:1em;line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility}
755bd8deadSopenharmony_cip aside{font-size:.875em;line-height:1.35;font-style:italic}
765bd8deadSopenharmony_cih1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em}
775bd8deadSopenharmony_cih1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0}
785bd8deadSopenharmony_cih1{font-size:2.125em}
795bd8deadSopenharmony_cih2{font-size:1.6875em}
805bd8deadSopenharmony_cih3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em}
815bd8deadSopenharmony_cih4,h5{font-size:1.125em}
825bd8deadSopenharmony_cih6{font-size:1em}
835bd8deadSopenharmony_cihr{border:solid #ddddd8;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em;height:0}
845bd8deadSopenharmony_ciem,i{font-style:italic;line-height:inherit}
855bd8deadSopenharmony_cistrong,b{font-weight:bold;line-height:inherit}
865bd8deadSopenharmony_cismall{font-size:60%;line-height:inherit}
875bd8deadSopenharmony_cicode{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)}
885bd8deadSopenharmony_ciul,ol,dl{font-size:1em;line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit}
895bd8deadSopenharmony_ciul,ol{margin-left:1.5em}
905bd8deadSopenharmony_ciul li ul,ul li ol{margin-left:1.25em;margin-bottom:0;font-size:1em}
915bd8deadSopenharmony_ciul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit}
925bd8deadSopenharmony_ciul.square{list-style-type:square}
935bd8deadSopenharmony_ciul.circle{list-style-type:circle}
945bd8deadSopenharmony_ciul.disc{list-style-type:disc}
955bd8deadSopenharmony_ciol li ul,ol li ol{margin-left:1.25em;margin-bottom:0}
965bd8deadSopenharmony_cidl dt{margin-bottom:.3125em;font-weight:bold}
975bd8deadSopenharmony_cidl dd{margin-bottom:1.25em}
985bd8deadSopenharmony_ciabbr,acronym{text-transform:uppercase;font-size:90%;color:rgba(0,0,0,.8);border-bottom:1px dotted #ddd;cursor:help}
995bd8deadSopenharmony_ciabbr{text-transform:none}
1005bd8deadSopenharmony_ciblockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd}
1015bd8deadSopenharmony_ciblockquote cite{display:block;font-size:.9375em;color:rgba(0,0,0,.6)}
1025bd8deadSopenharmony_ciblockquote cite::before{content:"\2014 \0020"}
1035bd8deadSopenharmony_ciblockquote cite a,blockquote cite a:visited{color:rgba(0,0,0,.6)}
1045bd8deadSopenharmony_ciblockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)}
1055bd8deadSopenharmony_ci@media screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2}
1065bd8deadSopenharmony_cih1{font-size:2.75em}
1075bd8deadSopenharmony_cih2{font-size:2.3125em}
1085bd8deadSopenharmony_cih3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em}
1095bd8deadSopenharmony_cih4{font-size:1.4375em}}
1105bd8deadSopenharmony_citable{background:#fff;margin-bottom:1.25em;border:solid 1px #dedede}
1115bd8deadSopenharmony_citable thead,table tfoot{background:#f7f8f7}
1125bd8deadSopenharmony_citable thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left}
1135bd8deadSopenharmony_citable tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)}
1145bd8deadSopenharmony_citable tr.even,table tr.alt,table tr:nth-of-type(even){background:#f8f8f7}
1155bd8deadSopenharmony_citable thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{display:table-cell;line-height:1.6}
1165bd8deadSopenharmony_cih1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em}
1175bd8deadSopenharmony_cih1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400}
1185bd8deadSopenharmony_ci.clearfix::before,.clearfix::after,.float-group::before,.float-group::after{content:" ";display:table}
1195bd8deadSopenharmony_ci.clearfix::after,.float-group::after{clear:both}
1205bd8deadSopenharmony_ci*:not(pre)>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background-color:#f7f7f8;-webkit-border-radius:4px;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed;word-wrap:break-word}
1215bd8deadSopenharmony_ci*:not(pre)>code.nobreak{word-wrap:normal}
1225bd8deadSopenharmony_ci*:not(pre)>code.nowrap{white-space:nowrap}
1235bd8deadSopenharmony_cipre,pre>code{line-height:1.45;color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;text-rendering:optimizeSpeed}
1245bd8deadSopenharmony_ciem em{font-style:normal}
1255bd8deadSopenharmony_cistrong strong{font-weight:400}
1265bd8deadSopenharmony_ci.keyseq{color:rgba(51,51,51,.8)}
1275bd8deadSopenharmony_cikbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background-color:#f7f7f7;border:1px solid #ccc;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em white inset;box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em #fff inset;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap}
1285bd8deadSopenharmony_ci.keyseq kbd:first-child{margin-left:0}
1295bd8deadSopenharmony_ci.keyseq kbd:last-child{margin-right:0}
1305bd8deadSopenharmony_ci.menuseq,.menuref{color:#000}
1315bd8deadSopenharmony_ci.menuseq b:not(.caret),.menuref{font-weight:inherit}
1325bd8deadSopenharmony_ci.menuseq{word-spacing:-.02em}
1335bd8deadSopenharmony_ci.menuseq b.caret{font-size:1.25em;line-height:.8}
1345bd8deadSopenharmony_ci.menuseq i.caret{font-weight:bold;text-align:center;width:.45em}
1355bd8deadSopenharmony_cib.button::before,b.button::after{position:relative;top:-1px;font-weight:400}
1365bd8deadSopenharmony_cib.button::before{content:"[";padding:0 3px 0 2px}
1375bd8deadSopenharmony_cib.button::after{content:"]";padding:0 2px 0 3px}
1385bd8deadSopenharmony_cip a>code:hover{color:rgba(0,0,0,.9)}
1395bd8deadSopenharmony_ci#header,#content,#footnotes,#footer{width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em}
1405bd8deadSopenharmony_ci#header::before,#header::after,#content::before,#content::after,#footnotes::before,#footnotes::after,#footer::before,#footer::after{content:" ";display:table}
1415bd8deadSopenharmony_ci#header::after,#content::after,#footnotes::after,#footer::after{clear:both}
1425bd8deadSopenharmony_ci#content{margin-top:1.25em}
1435bd8deadSopenharmony_ci#content::before{content:none}
1445bd8deadSopenharmony_ci#header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0}
1455bd8deadSopenharmony_ci#header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #ddddd8}
1465bd8deadSopenharmony_ci#header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #ddddd8;padding-bottom:8px}
1475bd8deadSopenharmony_ci#header .details{border-bottom:1px solid #ddddd8;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:-ms-flexbox;display:-webkit-flex;display:flex;-ms-flex-flow:row wrap;-webkit-flex-flow:row wrap;flex-flow:row wrap}
1485bd8deadSopenharmony_ci#header .details span:first-child{margin-left:-.125em}
1495bd8deadSopenharmony_ci#header .details span.email a{color:rgba(0,0,0,.85)}
1505bd8deadSopenharmony_ci#header .details br{display:none}
1515bd8deadSopenharmony_ci#header .details br+span::before{content:"\00a0\2013\00a0"}
1525bd8deadSopenharmony_ci#header .details br+span.author::before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)}
1535bd8deadSopenharmony_ci#header .details br+span#revremark::before{content:"\00a0|\00a0"}
1545bd8deadSopenharmony_ci#header #revnumber{text-transform:capitalize}
1555bd8deadSopenharmony_ci#header #revnumber::after{content:"\00a0"}
1565bd8deadSopenharmony_ci#content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #ddddd8;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem}
1575bd8deadSopenharmony_ci#toc{border-bottom:1px solid #efefed;padding-bottom:.5em}
1585bd8deadSopenharmony_ci#toc>ul{margin-left:.125em}
1595bd8deadSopenharmony_ci#toc ul.sectlevel0>li>a{font-style:italic}
1605bd8deadSopenharmony_ci#toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0}
1615bd8deadSopenharmony_ci#toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none}
1625bd8deadSopenharmony_ci#toc li{line-height:1.3334;margin-top:.3334em}
1635bd8deadSopenharmony_ci#toc a{text-decoration:none}
1645bd8deadSopenharmony_ci#toc a:active{text-decoration:underline}
1655bd8deadSopenharmony_ci#toctitle{color:#7a2518;font-size:1.2em}
1665bd8deadSopenharmony_ci@media screen and (min-width:768px){#toctitle{font-size:1.375em}
1675bd8deadSopenharmony_cibody.toc2{padding-left:15em;padding-right:0}
1685bd8deadSopenharmony_ci#toc.toc2{margin-top:0!important;background-color:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #efefed;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto}
1695bd8deadSopenharmony_ci#toc.toc2 #toctitle{margin-top:0;margin-bottom:.8rem;font-size:1.2em}
1705bd8deadSopenharmony_ci#toc.toc2>ul{font-size:.9em;margin-bottom:0}
1715bd8deadSopenharmony_ci#toc.toc2 ul ul{margin-left:0;padding-left:1em}
1725bd8deadSopenharmony_ci#toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em}
1735bd8deadSopenharmony_cibody.toc2.toc-right{padding-left:0;padding-right:15em}
1745bd8deadSopenharmony_cibody.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #efefed;left:auto;right:0}}
1755bd8deadSopenharmony_ci@media screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0}
1765bd8deadSopenharmony_ci#toc.toc2{width:20em}
1775bd8deadSopenharmony_ci#toc.toc2 #toctitle{font-size:1.375em}
1785bd8deadSopenharmony_ci#toc.toc2>ul{font-size:.95em}
1795bd8deadSopenharmony_ci#toc.toc2 ul ul{padding-left:1.25em}
1805bd8deadSopenharmony_cibody.toc2.toc-right{padding-left:0;padding-right:20em}}
1815bd8deadSopenharmony_ci#content #toc{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
1825bd8deadSopenharmony_ci#content #toc>:first-child{margin-top:0}
1835bd8deadSopenharmony_ci#content #toc>:last-child{margin-bottom:0}
1845bd8deadSopenharmony_ci#footer{max-width:100%;background-color:rgba(0,0,0,.8);padding:1.25em}
1855bd8deadSopenharmony_ci#footer-text{color:rgba(255,255,255,.8);line-height:1.44}
1865bd8deadSopenharmony_ci#content{margin-bottom:.625em}
1875bd8deadSopenharmony_ci.sect1{padding-bottom:.625em}
1885bd8deadSopenharmony_ci@media screen and (min-width:768px){#content{margin-bottom:1.25em}
1895bd8deadSopenharmony_ci.sect1{padding-bottom:1.25em}}
1905bd8deadSopenharmony_ci.sect1:last-child{padding-bottom:0}
1915bd8deadSopenharmony_ci.sect1+.sect1{border-top:1px solid #efefed}
1925bd8deadSopenharmony_ci#content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400}
1935bd8deadSopenharmony_ci#content h1>a.anchor::before,h2>a.anchor::before,h3>a.anchor::before,#toctitle>a.anchor::before,.sidebarblock>.content>.title>a.anchor::before,h4>a.anchor::before,h5>a.anchor::before,h6>a.anchor::before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em}
1945bd8deadSopenharmony_ci#content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible}
1955bd8deadSopenharmony_ci#content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none}
1965bd8deadSopenharmony_ci#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221}
1975bd8deadSopenharmony_ci.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em}
1985bd8deadSopenharmony_ci.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic}
1995bd8deadSopenharmony_citable.tableblock.fit-content>caption.title{white-space:nowrap;width:0}
2005bd8deadSopenharmony_ci.paragraph.lead>p,#preamble>.sectionbody>[class="paragraph"]:first-of-type p{font-size:1.21875em;line-height:1.6;color:rgba(0,0,0,.85)}
2015bd8deadSopenharmony_citable.tableblock #preamble>.sectionbody>[class="paragraph"]:first-of-type p{font-size:inherit}
2025bd8deadSopenharmony_ci.admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%}
2035bd8deadSopenharmony_ci.admonitionblock>table td.icon{text-align:center;width:80px}
2045bd8deadSopenharmony_ci.admonitionblock>table td.icon img{max-width:none}
2055bd8deadSopenharmony_ci.admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase}
2065bd8deadSopenharmony_ci.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #ddddd8;color:rgba(0,0,0,.6)}
2075bd8deadSopenharmony_ci.admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0}
2085bd8deadSopenharmony_ci.exampleblock>.content{border-style:solid;border-width:1px;border-color:#e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;-webkit-border-radius:4px;border-radius:4px}
2095bd8deadSopenharmony_ci.exampleblock>.content>:first-child{margin-top:0}
2105bd8deadSopenharmony_ci.exampleblock>.content>:last-child{margin-bottom:0}
2115bd8deadSopenharmony_ci.sidebarblock{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
2125bd8deadSopenharmony_ci.sidebarblock>:first-child{margin-top:0}
2135bd8deadSopenharmony_ci.sidebarblock>:last-child{margin-bottom:0}
2145bd8deadSopenharmony_ci.sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center}
2155bd8deadSopenharmony_ci.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0}
2165bd8deadSopenharmony_ci.literalblock pre,.listingblock pre:not(.highlight),.listingblock pre[class="highlight"],.listingblock pre[class^="highlight "],.listingblock pre.CodeRay,.listingblock pre.prettyprint{background:#f7f7f8}
2175bd8deadSopenharmony_ci.sidebarblock .literalblock pre,.sidebarblock .listingblock pre:not(.highlight),.sidebarblock .listingblock pre[class="highlight"],.sidebarblock .listingblock pre[class^="highlight "],.sidebarblock .listingblock pre.CodeRay,.sidebarblock .listingblock pre.prettyprint{background:#f2f1f1}
2185bd8deadSopenharmony_ci.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{-webkit-border-radius:4px;border-radius:4px;word-wrap:break-word;padding:1em;font-size:.8125em}
2195bd8deadSopenharmony_ci.literalblock pre.nowrap,.literalblock pre[class].nowrap,.listingblock pre.nowrap,.listingblock pre[class].nowrap{overflow-x:auto;white-space:pre;word-wrap:normal}
2205bd8deadSopenharmony_ci@media screen and (min-width:768px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:.90625em}}
2215bd8deadSopenharmony_ci@media screen and (min-width:1280px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:1em}}
2225bd8deadSopenharmony_ci.literalblock.output pre{color:#f7f7f8;background-color:rgba(0,0,0,.9)}
2235bd8deadSopenharmony_ci.listingblock pre.highlightjs{padding:0}
2245bd8deadSopenharmony_ci.listingblock pre.highlightjs>code{padding:1em;-webkit-border-radius:4px;border-radius:4px}
2255bd8deadSopenharmony_ci.listingblock pre.prettyprint{border-width:0}
2265bd8deadSopenharmony_ci.listingblock>.content{position:relative}
2275bd8deadSopenharmony_ci.listingblock code[data-lang]::before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:#999}
2285bd8deadSopenharmony_ci.listingblock:hover code[data-lang]::before{display:block}
2295bd8deadSopenharmony_ci.listingblock.terminal pre .command::before{content:attr(data-prompt);padding-right:.5em;color:#999}
2305bd8deadSopenharmony_ci.listingblock.terminal pre .command:not([data-prompt])::before{content:"$"}
2315bd8deadSopenharmony_citable.pyhltable{border-collapse:separate;border:0;margin-bottom:0;background:none}
2325bd8deadSopenharmony_citable.pyhltable td{vertical-align:top;padding-top:0;padding-bottom:0;line-height:1.45}
2335bd8deadSopenharmony_citable.pyhltable td.code{padding-left:.75em;padding-right:0}
2345bd8deadSopenharmony_cipre.pygments .lineno,table.pyhltable td:not(.code){color:#999;padding-left:0;padding-right:.5em;border-right:1px solid #ddddd8}
2355bd8deadSopenharmony_cipre.pygments .lineno{display:inline-block;margin-right:.25em}
2365bd8deadSopenharmony_citable.pyhltable .linenodiv{background:none!important;padding-right:0!important}
2375bd8deadSopenharmony_ci.quoteblock{margin:0 1em 1.25em 1.5em;display:table}
2385bd8deadSopenharmony_ci.quoteblock>.title{margin-left:-1.5em;margin-bottom:.75em}
2395bd8deadSopenharmony_ci.quoteblock blockquote,.quoteblock blockquote p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify}
2405bd8deadSopenharmony_ci.quoteblock blockquote{margin:0;padding:0;border:0}
2415bd8deadSopenharmony_ci.quoteblock blockquote::before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)}
2425bd8deadSopenharmony_ci.quoteblock blockquote>.paragraph:last-child p{margin-bottom:0}
2435bd8deadSopenharmony_ci.quoteblock .attribution{margin-top:.5em;margin-right:.5ex;text-align:right}
2445bd8deadSopenharmony_ci.quoteblock .quoteblock{margin-left:0;margin-right:0;padding:.5em 0;border-left:3px solid rgba(0,0,0,.6)}
2455bd8deadSopenharmony_ci.quoteblock .quoteblock blockquote{padding:0 0 0 .75em}
2465bd8deadSopenharmony_ci.quoteblock .quoteblock blockquote::before{display:none}
2475bd8deadSopenharmony_ci.verseblock{margin:0 1em 1.25em}
2485bd8deadSopenharmony_ci.verseblock pre{font-family:"Open Sans","DejaVu Sans",sans;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility}
2495bd8deadSopenharmony_ci.verseblock pre strong{font-weight:400}
2505bd8deadSopenharmony_ci.verseblock .attribution{margin-top:1.25rem;margin-left:.5ex}
2515bd8deadSopenharmony_ci.quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic}
2525bd8deadSopenharmony_ci.quoteblock .attribution br,.verseblock .attribution br{display:none}
2535bd8deadSopenharmony_ci.quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.025em;color:rgba(0,0,0,.6)}
2545bd8deadSopenharmony_ci.quoteblock.abstract{margin:0 1em 1.25em;display:block}
2555bd8deadSopenharmony_ci.quoteblock.abstract>.title{margin:0 0 .375em;font-size:1.15em;text-align:center}
2565bd8deadSopenharmony_ci.quoteblock.abstract blockquote,.quoteblock.abstract blockquote p{word-spacing:0;line-height:1.6}
2575bd8deadSopenharmony_ci.quoteblock.abstract blockquote::before,.quoteblock.abstract p::before{display:none}
2585bd8deadSopenharmony_citable.tableblock{max-width:100%;border-collapse:separate}
2595bd8deadSopenharmony_cip.tableblock:last-child{margin-bottom:0}
2605bd8deadSopenharmony_citd.tableblock>.content{margin-bottom:-1.25em}
2615bd8deadSopenharmony_citable.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede}
2625bd8deadSopenharmony_citable.grid-all>thead>tr>.tableblock,table.grid-all>tbody>tr>.tableblock{border-width:0 1px 1px 0}
2635bd8deadSopenharmony_citable.grid-all>tfoot>tr>.tableblock{border-width:1px 1px 0 0}
2645bd8deadSopenharmony_citable.grid-cols>*>tr>.tableblock{border-width:0 1px 0 0}
2655bd8deadSopenharmony_citable.grid-rows>thead>tr>.tableblock,table.grid-rows>tbody>tr>.tableblock{border-width:0 0 1px}
2665bd8deadSopenharmony_citable.grid-rows>tfoot>tr>.tableblock{border-width:1px 0 0}
2675bd8deadSopenharmony_citable.grid-all>*>tr>.tableblock:last-child,table.grid-cols>*>tr>.tableblock:last-child{border-right-width:0}
2685bd8deadSopenharmony_citable.grid-all>tbody>tr:last-child>.tableblock,table.grid-all>thead:last-child>tr>.tableblock,table.grid-rows>tbody>tr:last-child>.tableblock,table.grid-rows>thead:last-child>tr>.tableblock{border-bottom-width:0}
2695bd8deadSopenharmony_citable.frame-all{border-width:1px}
2705bd8deadSopenharmony_citable.frame-sides{border-width:0 1px}
2715bd8deadSopenharmony_citable.frame-topbot,table.frame-ends{border-width:1px 0}
2725bd8deadSopenharmony_citable.stripes-all tr,table.stripes-odd tr:nth-of-type(odd){background:#f8f8f7}
2735bd8deadSopenharmony_citable.stripes-none tr,table.stripes-odd tr:nth-of-type(even){background:none}
2745bd8deadSopenharmony_cith.halign-left,td.halign-left{text-align:left}
2755bd8deadSopenharmony_cith.halign-right,td.halign-right{text-align:right}
2765bd8deadSopenharmony_cith.halign-center,td.halign-center{text-align:center}
2775bd8deadSopenharmony_cith.valign-top,td.valign-top{vertical-align:top}
2785bd8deadSopenharmony_cith.valign-bottom,td.valign-bottom{vertical-align:bottom}
2795bd8deadSopenharmony_cith.valign-middle,td.valign-middle{vertical-align:middle}
2805bd8deadSopenharmony_citable thead th,table tfoot th{font-weight:bold}
2815bd8deadSopenharmony_citbody tr th{display:table-cell;line-height:1.6;background:#f7f8f7}
2825bd8deadSopenharmony_citbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold}
2835bd8deadSopenharmony_cip.tableblock>code:only-child{background:none;padding:0}
2845bd8deadSopenharmony_cip.tableblock{font-size:1em}
2855bd8deadSopenharmony_citd>div.verse{white-space:pre}
2865bd8deadSopenharmony_ciol{margin-left:1.75em}
2875bd8deadSopenharmony_ciul li ol{margin-left:1.5em}
2885bd8deadSopenharmony_cidl dd{margin-left:1.125em}
2895bd8deadSopenharmony_cidl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
2905bd8deadSopenharmony_ciol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
2915bd8deadSopenharmony_ciul.checklist,ul.none,ol.none,ul.no-bullet,ol.no-bullet,ol.unnumbered,ul.unstyled,ol.unstyled{list-style-type:none}
2925bd8deadSopenharmony_ciul.no-bullet,ol.no-bullet,ol.unnumbered{margin-left:.625em}
2935bd8deadSopenharmony_ciul.unstyled,ol.unstyled{margin-left:0}
2945bd8deadSopenharmony_ciul.checklist{margin-left:.625em}
2955bd8deadSopenharmony_ciul.checklist li>p:first-child>.fa-square-o:first-child,ul.checklist li>p:first-child>.fa-check-square-o:first-child{width:1.25em;font-size:.8em;position:relative;bottom:.125em}
2965bd8deadSopenharmony_ciul.checklist li>p:first-child>input[type="checkbox"]:first-child{margin-right:.25em}
2975bd8deadSopenharmony_ciul.inline{display:-ms-flexbox;display:-webkit-box;display:flex;-ms-flex-flow:row wrap;-webkit-flex-flow:row wrap;flex-flow:row wrap;list-style:none;margin:0 0 .625em -1.25em}
2985bd8deadSopenharmony_ciul.inline>li{margin-left:1.25em}
2995bd8deadSopenharmony_ci.unstyled dl dt{font-weight:400;font-style:normal}
3005bd8deadSopenharmony_ciol.arabic{list-style-type:decimal}
3015bd8deadSopenharmony_ciol.decimal{list-style-type:decimal-leading-zero}
3025bd8deadSopenharmony_ciol.loweralpha{list-style-type:lower-alpha}
3035bd8deadSopenharmony_ciol.upperalpha{list-style-type:upper-alpha}
3045bd8deadSopenharmony_ciol.lowerroman{list-style-type:lower-roman}
3055bd8deadSopenharmony_ciol.upperroman{list-style-type:upper-roman}
3065bd8deadSopenharmony_ciol.lowergreek{list-style-type:lower-greek}
3075bd8deadSopenharmony_ci.hdlist>table,.colist>table{border:0;background:none}
3085bd8deadSopenharmony_ci.hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none}
3095bd8deadSopenharmony_citd.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em}
3105bd8deadSopenharmony_citd.hdlist1{font-weight:bold;padding-bottom:1.25em}
3115bd8deadSopenharmony_ci.literalblock+.colist,.listingblock+.colist{margin-top:-.5em}
3125bd8deadSopenharmony_ci.colist td:not([class]):first-child{padding:.4em .75em 0;line-height:1;vertical-align:top}
3135bd8deadSopenharmony_ci.colist td:not([class]):first-child img{max-width:none}
3145bd8deadSopenharmony_ci.colist td:not([class]):last-child{padding:.25em 0}
3155bd8deadSopenharmony_ci.thumb,.th{line-height:0;display:inline-block;border:solid 4px #fff;-webkit-box-shadow:0 0 0 1px #ddd;box-shadow:0 0 0 1px #ddd}
3165bd8deadSopenharmony_ci.imageblock.left,.imageblock[style*="float: left"]{margin:.25em .625em 1.25em 0}
3175bd8deadSopenharmony_ci.imageblock.right,.imageblock[style*="float: right"]{margin:.25em 0 1.25em .625em}
3185bd8deadSopenharmony_ci.imageblock>.title{margin-bottom:0}
3195bd8deadSopenharmony_ci.imageblock.thumb,.imageblock.th{border-width:6px}
3205bd8deadSopenharmony_ci.imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em}
3215bd8deadSopenharmony_ci.image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0}
3225bd8deadSopenharmony_ci.image.left{margin-right:.625em}
3235bd8deadSopenharmony_ci.image.right{margin-left:.625em}
3245bd8deadSopenharmony_cia.image{text-decoration:none;display:inline-block}
3255bd8deadSopenharmony_cia.image object{pointer-events:none}
3265bd8deadSopenharmony_cisup.footnote,sup.footnoteref{font-size:.875em;position:static;vertical-align:super}
3275bd8deadSopenharmony_cisup.footnote a,sup.footnoteref a{text-decoration:none}
3285bd8deadSopenharmony_cisup.footnote a:active,sup.footnoteref a:active{text-decoration:underline}
3295bd8deadSopenharmony_ci#footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em}
3305bd8deadSopenharmony_ci#footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em;border-width:1px 0 0}
3315bd8deadSopenharmony_ci#footnotes .footnote{padding:0 .375em 0 .225em;line-height:1.3334;font-size:.875em;margin-left:1.2em;margin-bottom:.2em}
3325bd8deadSopenharmony_ci#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none;margin-left:-1.05em}
3335bd8deadSopenharmony_ci#footnotes .footnote:last-of-type{margin-bottom:0}
3345bd8deadSopenharmony_ci#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0}
3355bd8deadSopenharmony_ci.gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0}
3365bd8deadSopenharmony_ci.gist .file-data>table td.line-data{width:99%}
3375bd8deadSopenharmony_cidiv.unbreakable{page-break-inside:avoid}
3385bd8deadSopenharmony_ci.big{font-size:larger}
3395bd8deadSopenharmony_ci.small{font-size:smaller}
3405bd8deadSopenharmony_ci.underline{text-decoration:underline}
3415bd8deadSopenharmony_ci.overline{text-decoration:overline}
3425bd8deadSopenharmony_ci.line-through{text-decoration:line-through}
3435bd8deadSopenharmony_ci.aqua{color:#00bfbf}
3445bd8deadSopenharmony_ci.aqua-background{background-color:#00fafa}
3455bd8deadSopenharmony_ci.black{color:#000}
3465bd8deadSopenharmony_ci.black-background{background-color:#000}
3475bd8deadSopenharmony_ci.blue{color:#0000bf}
3485bd8deadSopenharmony_ci.blue-background{background-color:#0000fa}
3495bd8deadSopenharmony_ci.fuchsia{color:#bf00bf}
3505bd8deadSopenharmony_ci.fuchsia-background{background-color:#fa00fa}
3515bd8deadSopenharmony_ci.gray{color:#606060}
3525bd8deadSopenharmony_ci.gray-background{background-color:#7d7d7d}
3535bd8deadSopenharmony_ci.green{color:#006000}
3545bd8deadSopenharmony_ci.green-background{background-color:#007d00}
3555bd8deadSopenharmony_ci.lime{color:#00bf00}
3565bd8deadSopenharmony_ci.lime-background{background-color:#00fa00}
3575bd8deadSopenharmony_ci.maroon{color:#600000}
3585bd8deadSopenharmony_ci.maroon-background{background-color:#7d0000}
3595bd8deadSopenharmony_ci.navy{color:#000060}
3605bd8deadSopenharmony_ci.navy-background{background-color:#00007d}
3615bd8deadSopenharmony_ci.olive{color:#606000}
3625bd8deadSopenharmony_ci.olive-background{background-color:#7d7d00}
3635bd8deadSopenharmony_ci.purple{color:#600060}
3645bd8deadSopenharmony_ci.purple-background{background-color:#7d007d}
3655bd8deadSopenharmony_ci.red{color:#bf0000}
3665bd8deadSopenharmony_ci.red-background{background-color:#fa0000}
3675bd8deadSopenharmony_ci.silver{color:#909090}
3685bd8deadSopenharmony_ci.silver-background{background-color:#bcbcbc}
3695bd8deadSopenharmony_ci.teal{color:#006060}
3705bd8deadSopenharmony_ci.teal-background{background-color:#007d7d}
3715bd8deadSopenharmony_ci.white{color:#bfbfbf}
3725bd8deadSopenharmony_ci.white-background{background-color:#fafafa}
3735bd8deadSopenharmony_ci.yellow{color:#bfbf00}
3745bd8deadSopenharmony_ci.yellow-background{background-color:#fafa00}
3755bd8deadSopenharmony_cispan.icon>.fa{cursor:default}
3765bd8deadSopenharmony_cia span.icon>.fa{cursor:inherit}
3775bd8deadSopenharmony_ci.admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default}
3785bd8deadSopenharmony_ci.admonitionblock td.icon .icon-note::before{content:"\f05a";color:#19407c}
3795bd8deadSopenharmony_ci.admonitionblock td.icon .icon-tip::before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111}
3805bd8deadSopenharmony_ci.admonitionblock td.icon .icon-warning::before{content:"\f071";color:#bf6900}
3815bd8deadSopenharmony_ci.admonitionblock td.icon .icon-caution::before{content:"\f06d";color:#bf3400}
3825bd8deadSopenharmony_ci.admonitionblock td.icon .icon-important::before{content:"\f06a";color:#bf0000}
3835bd8deadSopenharmony_ci.conum[data-value]{display:inline-block;color:#fff!important;background-color:rgba(0,0,0,.8);-webkit-border-radius:100px;border-radius:100px;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
3845bd8deadSopenharmony_ci.conum[data-value] *{color:#fff!important}
3855bd8deadSopenharmony_ci.conum[data-value]+b{display:none}
3865bd8deadSopenharmony_ci.conum[data-value]::after{content:attr(data-value)}
3875bd8deadSopenharmony_cipre .conum[data-value]{position:relative;top:-.125em}
3885bd8deadSopenharmony_cib.conum *{color:inherit!important}
3895bd8deadSopenharmony_ci.conum:not([data-value]):empty{display:none}
3905bd8deadSopenharmony_cidt,th.tableblock,td.content,div.footnote{text-rendering:optimizeLegibility}
3915bd8deadSopenharmony_cih1,h2,p,td.content,span.alt{letter-spacing:-.01em}
3925bd8deadSopenharmony_cip strong,td.content strong,div.footnote strong{letter-spacing:-.005em}
3935bd8deadSopenharmony_cip,blockquote,dt,td.content,span.alt{font-size:1.0625rem}
3945bd8deadSopenharmony_cip{margin-bottom:1.25rem}
3955bd8deadSopenharmony_ci.sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em}
3965bd8deadSopenharmony_ci.exampleblock>.content{background-color:#fffef7;border-color:#e0e0dc;-webkit-box-shadow:0 1px 4px #e0e0dc;box-shadow:0 1px 4px #e0e0dc}
3975bd8deadSopenharmony_ci.print-only{display:none!important}
3985bd8deadSopenharmony_ci@page{margin:1.25cm .75cm}
3995bd8deadSopenharmony_ci@media print{*{-webkit-box-shadow:none!important;box-shadow:none!important;text-shadow:none!important}
4005bd8deadSopenharmony_cihtml{font-size:80%}
4015bd8deadSopenharmony_cia{color:inherit!important;text-decoration:underline!important}
4025bd8deadSopenharmony_cia.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important}
4035bd8deadSopenharmony_cia[href^="http:"]:not(.bare)::after,a[href^="https:"]:not(.bare)::after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em}
4045bd8deadSopenharmony_ciabbr[title]::after{content:" (" attr(title) ")"}
4055bd8deadSopenharmony_cipre,blockquote,tr,img,object,svg{page-break-inside:avoid}
4065bd8deadSopenharmony_cithead{display:table-header-group}
4075bd8deadSopenharmony_cisvg{max-width:100%}
4085bd8deadSopenharmony_cip,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3}
4095bd8deadSopenharmony_cih2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid}
4105bd8deadSopenharmony_ci#toc,.sidebarblock,.exampleblock>.content{background:none!important}
4115bd8deadSopenharmony_ci#toc{border-bottom:1px solid #ddddd8!important;padding-bottom:0!important}
4125bd8deadSopenharmony_cibody.book #header{text-align:center}
4135bd8deadSopenharmony_cibody.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em}
4145bd8deadSopenharmony_cibody.book #header .details{border:0!important;display:block;padding:0!important}
4155bd8deadSopenharmony_cibody.book #header .details span:first-child{margin-left:0!important}
4165bd8deadSopenharmony_cibody.book #header .details br{display:block}
4175bd8deadSopenharmony_cibody.book #header .details br+span::before{content:none!important}
4185bd8deadSopenharmony_cibody.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important}
4195bd8deadSopenharmony_cibody.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always}
4205bd8deadSopenharmony_ci.listingblock code[data-lang]::before{display:block}
4215bd8deadSopenharmony_ci#footer{padding:0 .9375em}
4225bd8deadSopenharmony_ci.hide-on-print{display:none!important}
4235bd8deadSopenharmony_ci.print-only{display:block!important}
4245bd8deadSopenharmony_ci.hide-for-print{display:none!important}
4255bd8deadSopenharmony_ci.show-for-print{display:inherit!important}}
4265bd8deadSopenharmony_ci@media print,amzn-kf8{#header>h1:first-child{margin-top:1.25rem}
4275bd8deadSopenharmony_ci.sect1{padding:0!important}
4285bd8deadSopenharmony_ci.sect1+.sect1{border:0}
4295bd8deadSopenharmony_ci#footer{background:none}
4305bd8deadSopenharmony_ci#footer-text{color:rgba(0,0,0,.6);font-size:.9em}}
4315bd8deadSopenharmony_ci@media amzn-kf8{#header,#content,#footnotes,#footer{padding:0}}
4325bd8deadSopenharmony_ci</style>
4335bd8deadSopenharmony_ci<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
4345bd8deadSopenharmony_ci<style>
4355bd8deadSopenharmony_ci/* Stylesheet for CodeRay to match GitHub theme | MIT License | http://foundation.zurb.com */
4365bd8deadSopenharmony_ci/*pre.CodeRay {background-color:#f7f7f8;}*/
4375bd8deadSopenharmony_ci.CodeRay .line-numbers{border-right:1px solid #d8d8d8;padding:0 0.5em 0 .25em}
4385bd8deadSopenharmony_ci.CodeRay span.line-numbers{display:inline-block;margin-right:.5em;color:rgba(0,0,0,.3)}
4395bd8deadSopenharmony_ci.CodeRay .line-numbers strong{color:rgba(0,0,0,.4)}
4405bd8deadSopenharmony_citable.CodeRay{border-collapse:separate;border-spacing:0;margin-bottom:0;border:0;background:none}
4415bd8deadSopenharmony_citable.CodeRay td{vertical-align: top;line-height:1.45}
4425bd8deadSopenharmony_citable.CodeRay td.line-numbers{text-align:right}
4435bd8deadSopenharmony_citable.CodeRay td.line-numbers>pre{padding:0;color:rgba(0,0,0,.3)}
4445bd8deadSopenharmony_citable.CodeRay td.code{padding:0 0 0 .5em}
4455bd8deadSopenharmony_citable.CodeRay td.code>pre{padding:0}
4465bd8deadSopenharmony_ci.CodeRay .debug{color:#fff !important;background:#000080 !important}
4475bd8deadSopenharmony_ci.CodeRay .annotation{color:#007}
4485bd8deadSopenharmony_ci.CodeRay .attribute-name{color:#000080}
4495bd8deadSopenharmony_ci.CodeRay .attribute-value{color:#700}
4505bd8deadSopenharmony_ci.CodeRay .binary{color:#509}
4515bd8deadSopenharmony_ci.CodeRay .comment{color:#998;font-style:italic}
4525bd8deadSopenharmony_ci.CodeRay .char{color:#04d}
4535bd8deadSopenharmony_ci.CodeRay .char .content{color:#04d}
4545bd8deadSopenharmony_ci.CodeRay .char .delimiter{color:#039}
4555bd8deadSopenharmony_ci.CodeRay .class{color:#458;font-weight:bold}
4565bd8deadSopenharmony_ci.CodeRay .complex{color:#a08}
4575bd8deadSopenharmony_ci.CodeRay .constant,.CodeRay .predefined-constant{color:#008080}
4585bd8deadSopenharmony_ci.CodeRay .color{color:#099}
4595bd8deadSopenharmony_ci.CodeRay .class-variable{color:#369}
4605bd8deadSopenharmony_ci.CodeRay .decorator{color:#b0b}
4615bd8deadSopenharmony_ci.CodeRay .definition{color:#099}
4625bd8deadSopenharmony_ci.CodeRay .delimiter{color:#000}
4635bd8deadSopenharmony_ci.CodeRay .doc{color:#970}
4645bd8deadSopenharmony_ci.CodeRay .doctype{color:#34b}
4655bd8deadSopenharmony_ci.CodeRay .doc-string{color:#d42}
4665bd8deadSopenharmony_ci.CodeRay .escape{color:#666}
4675bd8deadSopenharmony_ci.CodeRay .entity{color:#800}
4685bd8deadSopenharmony_ci.CodeRay .error{color:#808}
4695bd8deadSopenharmony_ci.CodeRay .exception{color:inherit}
4705bd8deadSopenharmony_ci.CodeRay .filename{color:#099}
4715bd8deadSopenharmony_ci.CodeRay .function{color:#900;font-weight:bold}
4725bd8deadSopenharmony_ci.CodeRay .global-variable{color:#008080}
4735bd8deadSopenharmony_ci.CodeRay .hex{color:#058}
4745bd8deadSopenharmony_ci.CodeRay .integer,.CodeRay .float{color:#099}
4755bd8deadSopenharmony_ci.CodeRay .include{color:#555}
4765bd8deadSopenharmony_ci.CodeRay .inline{color:#000}
4775bd8deadSopenharmony_ci.CodeRay .inline .inline{background:#ccc}
4785bd8deadSopenharmony_ci.CodeRay .inline .inline .inline{background:#bbb}
4795bd8deadSopenharmony_ci.CodeRay .inline .inline-delimiter{color:#d14}
4805bd8deadSopenharmony_ci.CodeRay .inline-delimiter{color:#d14}
4815bd8deadSopenharmony_ci.CodeRay .important{color:#555;font-weight:bold}
4825bd8deadSopenharmony_ci.CodeRay .interpreted{color:#b2b}
4835bd8deadSopenharmony_ci.CodeRay .instance-variable{color:#008080}
4845bd8deadSopenharmony_ci.CodeRay .label{color:#970}
4855bd8deadSopenharmony_ci.CodeRay .local-variable{color:#963}
4865bd8deadSopenharmony_ci.CodeRay .octal{color:#40e}
4875bd8deadSopenharmony_ci.CodeRay .predefined{color:#369}
4885bd8deadSopenharmony_ci.CodeRay .preprocessor{color:#579}
4895bd8deadSopenharmony_ci.CodeRay .pseudo-class{color:#555}
4905bd8deadSopenharmony_ci.CodeRay .directive{font-weight:bold}
4915bd8deadSopenharmony_ci.CodeRay .type{font-weight:bold}
4925bd8deadSopenharmony_ci.CodeRay .predefined-type{color:inherit}
4935bd8deadSopenharmony_ci.CodeRay .reserved,.CodeRay .keyword {color:#000;font-weight:bold}
4945bd8deadSopenharmony_ci.CodeRay .key{color:#808}
4955bd8deadSopenharmony_ci.CodeRay .key .delimiter{color:#606}
4965bd8deadSopenharmony_ci.CodeRay .key .char{color:#80f}
4975bd8deadSopenharmony_ci.CodeRay .value{color:#088}
4985bd8deadSopenharmony_ci.CodeRay .regexp .delimiter{color:#808}
4995bd8deadSopenharmony_ci.CodeRay .regexp .content{color:#808}
5005bd8deadSopenharmony_ci.CodeRay .regexp .modifier{color:#808}
5015bd8deadSopenharmony_ci.CodeRay .regexp .char{color:#d14}
5025bd8deadSopenharmony_ci.CodeRay .regexp .function{color:#404;font-weight:bold}
5035bd8deadSopenharmony_ci.CodeRay .string{color:#d20}
5045bd8deadSopenharmony_ci.CodeRay .string .string .string{background:#ffd0d0}
5055bd8deadSopenharmony_ci.CodeRay .string .content{color:#d14}
5065bd8deadSopenharmony_ci.CodeRay .string .char{color:#d14}
5075bd8deadSopenharmony_ci.CodeRay .string .delimiter{color:#d14}
5085bd8deadSopenharmony_ci.CodeRay .shell{color:#d14}
5095bd8deadSopenharmony_ci.CodeRay .shell .delimiter{color:#d14}
5105bd8deadSopenharmony_ci.CodeRay .symbol{color:#990073}
5115bd8deadSopenharmony_ci.CodeRay .symbol .content{color:#a60}
5125bd8deadSopenharmony_ci.CodeRay .symbol .delimiter{color:#630}
5135bd8deadSopenharmony_ci.CodeRay .tag{color:#008080}
5145bd8deadSopenharmony_ci.CodeRay .tag-special{color:#d70}
5155bd8deadSopenharmony_ci.CodeRay .variable{color:#036}
5165bd8deadSopenharmony_ci.CodeRay .insert{background:#afa}
5175bd8deadSopenharmony_ci.CodeRay .delete{background:#faa}
5185bd8deadSopenharmony_ci.CodeRay .change{color:#aaf;background:#007}
5195bd8deadSopenharmony_ci.CodeRay .head{color:#f8f;background:#505}
5205bd8deadSopenharmony_ci.CodeRay .insert .insert{color:#080}
5215bd8deadSopenharmony_ci.CodeRay .delete .delete{color:#800}
5225bd8deadSopenharmony_ci.CodeRay .change .change{color:#66f}
5235bd8deadSopenharmony_ci.CodeRay .head .head{color:#f4f}
5245bd8deadSopenharmony_ci</style>
5255bd8deadSopenharmony_ci<link rel="stylesheet" href="../katex/katex.min.css">
5265bd8deadSopenharmony_ci<script src="../katex/katex.min.js"></script>
5275bd8deadSopenharmony_ci<script src="../katex/contrib/auto-render.min.js"></script>
5285bd8deadSopenharmony_ci    <!-- Use KaTeX to render math once document is loaded, see
5295bd8deadSopenharmony_ci         https://github.com/Khan/KaTeX/tree/master/contrib/auto-render -->
5305bd8deadSopenharmony_ci<script>
5315bd8deadSopenharmony_ci    document.addEventListener("DOMContentLoaded", function () {
5325bd8deadSopenharmony_ci        renderMathInElement(
5335bd8deadSopenharmony_ci            document.body,
5345bd8deadSopenharmony_ci            {
5355bd8deadSopenharmony_ci                delimiters: [
5365bd8deadSopenharmony_ci                    { left: "$$", right: "$$", display: true},
5375bd8deadSopenharmony_ci                    { left: "\\[", right: "\\]", display: true},
5385bd8deadSopenharmony_ci                    { left: "$", right: "$", display: false},
5395bd8deadSopenharmony_ci                    { left: "\\(", right: "\\)", display: false}
5405bd8deadSopenharmony_ci                ]
5415bd8deadSopenharmony_ci            }
5425bd8deadSopenharmony_ci        );
5435bd8deadSopenharmony_ci    });
5445bd8deadSopenharmony_ci</script></head>
5455bd8deadSopenharmony_ci<body class="book toc2 toc-left" style="max-width: 100;">
5465bd8deadSopenharmony_ci<div id="header">
5475bd8deadSopenharmony_ci<h1>The OpenGL<sup>&#174;</sup> Shading Language, Version 4.60.7</h1>
5485bd8deadSopenharmony_ci<div class="details">
5495bd8deadSopenharmony_ci<span id="author" class="author">John Kessenich, Google (Editor and Author) ; Dave Baldwin and Randi Rost (Version 1.1 Authors)</span><br>
5505bd8deadSopenharmony_ci<span id="revnumber">version 4.60.7,</span>
5515bd8deadSopenharmony_ci<span id="revdate">Wed, 10 Jul 2019 20:42:58 +0000</span>
5525bd8deadSopenharmony_ci<br><span id="revremark">Git branch information not available</span>
5535bd8deadSopenharmony_ci</div>
5545bd8deadSopenharmony_ci<div id="toc" class="toc2">
5555bd8deadSopenharmony_ci<div id="toctitle">Table of Contents</div>
5565bd8deadSopenharmony_ci<ul class="sectlevel1">
5575bd8deadSopenharmony_ci<li><a href="#introduction">1. Introduction</a>
5585bd8deadSopenharmony_ci<ul class="sectlevel2">
5595bd8deadSopenharmony_ci<li><a href="#changes">1.1. Changes</a></li>
5605bd8deadSopenharmony_ci<li><a href="#overview">1.2. Overview</a></li>
5615bd8deadSopenharmony_ci<li><a href="#error-handling">1.3. Error Handling</a></li>
5625bd8deadSopenharmony_ci<li><a href="#typographical-conventions">1.4. Typographical Conventions</a></li>
5635bd8deadSopenharmony_ci<li><a href="#deprecation">1.5. Deprecation</a></li>
5645bd8deadSopenharmony_ci</ul>
5655bd8deadSopenharmony_ci</li>
5665bd8deadSopenharmony_ci<li><a href="#overview-of-opengl-shading">2. Overview of Shading</a>
5675bd8deadSopenharmony_ci<ul class="sectlevel2">
5685bd8deadSopenharmony_ci<li><a href="#vertex-processor">2.1. Vertex Processor</a></li>
5695bd8deadSopenharmony_ci<li><a href="#tessellation-control-processor">2.2. Tessellation Control Processor</a></li>
5705bd8deadSopenharmony_ci<li><a href="#tessellation-evaluation-processor">2.3. Tessellation Evaluation Processor</a></li>
5715bd8deadSopenharmony_ci<li><a href="#geometry-processor">2.4. Geometry Processor</a></li>
5725bd8deadSopenharmony_ci<li><a href="#fragment-processor">2.5. Fragment Processor</a></li>
5735bd8deadSopenharmony_ci<li><a href="#compute-processor">2.6. Compute Processor</a></li>
5745bd8deadSopenharmony_ci</ul>
5755bd8deadSopenharmony_ci</li>
5765bd8deadSopenharmony_ci<li><a href="#basics">3. Basics</a>
5775bd8deadSopenharmony_ci<ul class="sectlevel2">
5785bd8deadSopenharmony_ci<li><a href="#character-set">3.1. Character Set and Phases of Compilation</a></li>
5795bd8deadSopenharmony_ci<li><a href="#source-strings">3.2. Source Strings</a></li>
5805bd8deadSopenharmony_ci<li><a href="#preprocessor">3.3. Preprocessor</a></li>
5815bd8deadSopenharmony_ci<li><a href="#comments">3.4. Comments</a></li>
5825bd8deadSopenharmony_ci<li><a href="#tokens">3.5. Tokens</a></li>
5835bd8deadSopenharmony_ci<li><a href="#keywords">3.6. Keywords</a></li>
5845bd8deadSopenharmony_ci<li><a href="#identifiers">3.7. Identifiers</a></li>
5855bd8deadSopenharmony_ci<li><a href="#definitions">3.8. Definitions</a></li>
5865bd8deadSopenharmony_ci</ul>
5875bd8deadSopenharmony_ci</li>
5885bd8deadSopenharmony_ci<li><a href="#variables-and-types">4. Variables and Types</a>
5895bd8deadSopenharmony_ci<ul class="sectlevel2">
5905bd8deadSopenharmony_ci<li><a href="#basic-types">4.1. Basic Types</a></li>
5915bd8deadSopenharmony_ci<li><a href="#scoping">4.2. Scoping</a></li>
5925bd8deadSopenharmony_ci<li><a href="#storage-qualifiers">4.3. Storage Qualifiers</a></li>
5935bd8deadSopenharmony_ci<li><a href="#layout-qualifiers">4.4. Layout Qualifiers</a></li>
5945bd8deadSopenharmony_ci<li><a href="#interpolation-qualifiers">4.5. Interpolation Qualifiers</a></li>
5955bd8deadSopenharmony_ci<li><a href="#parameter-qualifiers">4.6. Parameter Qualifiers</a></li>
5965bd8deadSopenharmony_ci<li><a href="#precision-and-precision-qualifiers">4.7. Precision and Precision Qualifiers</a></li>
5975bd8deadSopenharmony_ci<li><a href="#variance-and-the-invariant-qualifier">4.8. Variance and the Invariant Qualifier</a></li>
5985bd8deadSopenharmony_ci<li><a href="#the-precise-qualifier">4.9. The Precise Qualifier</a></li>
5995bd8deadSopenharmony_ci<li><a href="#memory-qualifiers">4.10. Memory Qualifiers</a></li>
6005bd8deadSopenharmony_ci<li><a href="#specialization-constant-qualifier">4.11. Specialization-Constant Qualifier</a></li>
6015bd8deadSopenharmony_ci<li><a href="#order-of-qualification">4.12. Order and Repetition of Qualification</a></li>
6025bd8deadSopenharmony_ci<li><a href="#empty-declarations">4.13. Empty Declarations</a></li>
6035bd8deadSopenharmony_ci</ul>
6045bd8deadSopenharmony_ci</li>
6055bd8deadSopenharmony_ci<li><a href="#operators-and-expressions">5. Operators and Expressions</a>
6065bd8deadSopenharmony_ci<ul class="sectlevel2">
6075bd8deadSopenharmony_ci<li><a href="#operators">5.1. Operators</a></li>
6085bd8deadSopenharmony_ci<li><a href="#array-operations">5.2. Array Operations</a></li>
6095bd8deadSopenharmony_ci<li><a href="#function-calls">5.3. Function Calls</a></li>
6105bd8deadSopenharmony_ci<li><a href="#constructors">5.4. Constructors</a></li>
6115bd8deadSopenharmony_ci<li><a href="#vector-components">5.5. Vector and Scalar Components and Length</a></li>
6125bd8deadSopenharmony_ci<li><a href="#matrix-components">5.6. Matrix Components</a></li>
6135bd8deadSopenharmony_ci<li><a href="#structure-and-array-operations">5.7. Structure and Array Operations</a></li>
6145bd8deadSopenharmony_ci<li><a href="#assignments">5.8. Assignments</a></li>
6155bd8deadSopenharmony_ci<li><a href="#expressions">5.9. Expressions</a></li>
6165bd8deadSopenharmony_ci<li><a href="#vector-and-matrix-operations">5.10. Vector and Matrix Operations</a></li>
6175bd8deadSopenharmony_ci<li><a href="#out-of-bounds-accesses">5.11. Out-of-Bounds Accesses</a></li>
6185bd8deadSopenharmony_ci<li><a href="#specialization-constant-operations">5.12. Specialization-Constant Operations</a></li>
6195bd8deadSopenharmony_ci</ul>
6205bd8deadSopenharmony_ci</li>
6215bd8deadSopenharmony_ci<li><a href="#statements-and-structure">6. Statements and Structure</a>
6225bd8deadSopenharmony_ci<ul class="sectlevel2">
6235bd8deadSopenharmony_ci<li><a href="#function-definitions">6.1. Function Definitions</a></li>
6245bd8deadSopenharmony_ci<li><a href="#selection">6.2. Selection</a></li>
6255bd8deadSopenharmony_ci<li><a href="#iteration">6.3. Iteration</a></li>
6265bd8deadSopenharmony_ci<li><a href="#jumps">6.4. Jumps</a></li>
6275bd8deadSopenharmony_ci</ul>
6285bd8deadSopenharmony_ci</li>
6295bd8deadSopenharmony_ci<li><a href="#built-in-variables">7. Built-In Variables</a>
6305bd8deadSopenharmony_ci<ul class="sectlevel2">
6315bd8deadSopenharmony_ci<li><a href="#built-in-language-variables">7.1. Built-In Language Variables</a></li>
6325bd8deadSopenharmony_ci<li><a href="#compatibility-profile-vertex-shader-built-in-inputs">7.2. Compatibility Profile Vertex Shader Built-In Inputs</a></li>
6335bd8deadSopenharmony_ci<li><a href="#built-in-constants">7.3. Built-In Constants</a></li>
6345bd8deadSopenharmony_ci<li><a href="#built-in-uniform-state">7.4. Built-In Uniform State</a></li>
6355bd8deadSopenharmony_ci<li><a href="#redeclaring-built-in-blocks">7.5. Redeclaring Built-In Blocks</a></li>
6365bd8deadSopenharmony_ci</ul>
6375bd8deadSopenharmony_ci</li>
6385bd8deadSopenharmony_ci<li><a href="#built-in-functions">8. Built-In Functions</a>
6395bd8deadSopenharmony_ci<ul class="sectlevel2">
6405bd8deadSopenharmony_ci<li><a href="#angle-and-trigonometry-functions">8.1. Angle and Trigonometry Functions</a></li>
6415bd8deadSopenharmony_ci<li><a href="#exponential-functions">8.2. Exponential Functions</a></li>
6425bd8deadSopenharmony_ci<li><a href="#common-functions">8.3. Common Functions</a></li>
6435bd8deadSopenharmony_ci<li><a href="#floating-point-pack-and-unpack-functions">8.4. Floating-Point Pack and Unpack Functions</a></li>
6445bd8deadSopenharmony_ci<li><a href="#geometric-functions">8.5. Geometric Functions</a></li>
6455bd8deadSopenharmony_ci<li><a href="#matrix-functions">8.6. Matrix Functions</a></li>
6465bd8deadSopenharmony_ci<li><a href="#vector-relational-functions">8.7. Vector Relational Functions</a></li>
6475bd8deadSopenharmony_ci<li><a href="#integer-functions">8.8. Integer Functions</a></li>
6485bd8deadSopenharmony_ci<li><a href="#texture-functions">8.9. Texture Functions</a></li>
6495bd8deadSopenharmony_ci<li><a href="#atomic-counter-functions">8.10. Atomic Counter Functions</a></li>
6505bd8deadSopenharmony_ci<li><a href="#atomic-memory-functions">8.11. Atomic Memory Functions</a></li>
6515bd8deadSopenharmony_ci<li><a href="#image-functions">8.12. Image Functions</a></li>
6525bd8deadSopenharmony_ci<li><a href="#geometry-shader-functions">8.13. Geometry Shader Functions</a></li>
6535bd8deadSopenharmony_ci<li><a href="#fragment-processing-functions">8.14. Fragment Processing Functions</a></li>
6545bd8deadSopenharmony_ci<li><a href="#noise-functions">8.15. Noise Functions</a></li>
6555bd8deadSopenharmony_ci<li><a href="#shader-invocation-control-functions">8.16. Shader Invocation Control Functions</a></li>
6565bd8deadSopenharmony_ci<li><a href="#shader-memory-control-functions">8.17. Shader Memory Control Functions</a></li>
6575bd8deadSopenharmony_ci<li><a href="#_subpass_input_functions">8.18. Subpass-Input Functions</a></li>
6585bd8deadSopenharmony_ci<li><a href="#shader-invocation-group-functions">8.19. Shader Invocation Group Functions</a></li>
6595bd8deadSopenharmony_ci</ul>
6605bd8deadSopenharmony_ci</li>
6615bd8deadSopenharmony_ci<li><a href="#shading-language-grammar">9. Shading Language Grammar</a></li>
6625bd8deadSopenharmony_ci<li><a href="#acknowledgments">10. Acknowledgments</a></li>
6635bd8deadSopenharmony_ci<li><a href="#references">11. Normative References</a></li>
6645bd8deadSopenharmony_ci<li><a href="#_non_normative_spir_v_mappings">12. Non-Normative SPIR-V Mappings</a>
6655bd8deadSopenharmony_ci<ul class="sectlevel2">
6665bd8deadSopenharmony_ci<li><a href="#_feature_comparisons">12.1. Feature Comparisons</a></li>
6675bd8deadSopenharmony_ci<li><a href="#_mapping_from_glsl_to_spir_v">12.2. Mapping from GLSL to SPIR-V</a></li>
6685bd8deadSopenharmony_ci</ul>
6695bd8deadSopenharmony_ci</li>
6705bd8deadSopenharmony_ci</ul>
6715bd8deadSopenharmony_ci</div>
6725bd8deadSopenharmony_ci</div>
6735bd8deadSopenharmony_ci<div id="content">
6745bd8deadSopenharmony_ci<div id="preamble">
6755bd8deadSopenharmony_ci<div class="sectionbody">
6765bd8deadSopenharmony_ci<div style="page-break-after: always;"></div>
6775bd8deadSopenharmony_ci<div class="paragraph">
6785bd8deadSopenharmony_ci<p>Copyright &#169; 2008-2018 The Khronos Group Inc. All Rights Reserved.</p>
6795bd8deadSopenharmony_ci</div>
6805bd8deadSopenharmony_ci<div class="paragraph">
6815bd8deadSopenharmony_ci<p>This specification is protected by copyright laws and contains material
6825bd8deadSopenharmony_ciproprietary to the Khronos Group, Inc. It or any components may not be
6835bd8deadSopenharmony_cireproduced, republished, distributed, transmitted, displayed, broadcast,
6845bd8deadSopenharmony_cior otherwise exploited in any manner without the express prior written
6855bd8deadSopenharmony_cipermission of Khronos Group. You may use this specification for
6865bd8deadSopenharmony_ciimplementing the functionality therein, without altering or removing any
6875bd8deadSopenharmony_citrademark, copyright or other notice from the specification, but the
6885bd8deadSopenharmony_cireceipt or possession of this specification does not convey any rights
6895bd8deadSopenharmony_cito reproduce, disclose, or distribute its contents, or to manufacture,
6905bd8deadSopenharmony_ciuse, or sell anything that it may describe, in whole or in part.</p>
6915bd8deadSopenharmony_ci</div>
6925bd8deadSopenharmony_ci<div class="paragraph">
6935bd8deadSopenharmony_ci<p>Khronos Group grants express permission to any current Promoter,
6945bd8deadSopenharmony_ciContributor or Adopter member of Khronos to copy and redistribute
6955bd8deadSopenharmony_ciUNMODIFIED versions of this specification in any fashion, provided that
6965bd8deadSopenharmony_ciNO CHARGE is made for the specification and the latest available update
6975bd8deadSopenharmony_ciof the specification for any version of the API is used whenever
6985bd8deadSopenharmony_cipossible. Such distributed specification may be reformatted AS LONG AS
6995bd8deadSopenharmony_cithe contents of the specification are not changed in any way. The
7005bd8deadSopenharmony_cispecification may be incorporated into a product that is sold as long as
7015bd8deadSopenharmony_cisuch product includes significant independent work developed by the
7025bd8deadSopenharmony_ciseller. A link to the current version of this specification on the
7035bd8deadSopenharmony_ciKhronos Group website should be included whenever possible with
7045bd8deadSopenharmony_cispecification distributions.</p>
7055bd8deadSopenharmony_ci</div>
7065bd8deadSopenharmony_ci<div class="paragraph">
7075bd8deadSopenharmony_ci<p>Khronos Group makes no, and expressly disclaims any, representations or
7085bd8deadSopenharmony_ciwarranties, express or implied, regarding this specification, including,
7095bd8deadSopenharmony_ciwithout limitation, any implied warranties of merchantability or fitness
7105bd8deadSopenharmony_cifor a particular purpose or noninfringement of any intellectual
7115bd8deadSopenharmony_ciproperty. Khronos Group makes no, and expressly disclaims any,
7125bd8deadSopenharmony_ciwarranties, express or implied, regarding the correctness, accuracy,
7135bd8deadSopenharmony_cicompleteness, timeliness, and reliability of the specification. Under no
7145bd8deadSopenharmony_cicircumstances will the Khronos Group, or any of its Promoters,
7155bd8deadSopenharmony_ciContributors or Members or their respective partners, officers,
7165bd8deadSopenharmony_cidirectors, employees, agents, or representatives be liable for any
7175bd8deadSopenharmony_cidamages, whether direct, indirect, special or consequential damages for
7185bd8deadSopenharmony_cilost revenues, lost profits, or otherwise, arising from or in connection
7195bd8deadSopenharmony_ciwith these materials.</p>
7205bd8deadSopenharmony_ci</div>
7215bd8deadSopenharmony_ci<div class="paragraph">
7225bd8deadSopenharmony_ci<p>Khronos, Vulkan, SYCL, SPIR, WebGL, EGL, COLLADA, StreamInput, OpenVX,
7235bd8deadSopenharmony_ciOpenKCam, glTF, OpenKODE, OpenVG, OpenWF, OpenSL ES, OpenMAX, OpenMAX
7245bd8deadSopenharmony_ciAL, OpenMAX IL and OpenMAX DL are trademarks and WebCL is a
7255bd8deadSopenharmony_cicertification mark of the Khronos Group Inc. OpenCL is a trademark of
7265bd8deadSopenharmony_ciApple Inc. and OpenGL and OpenML are registered trademarks and the
7275bd8deadSopenharmony_ciOpenGL ES and OpenGL SC logos are trademarks of Silicon Graphics
7285bd8deadSopenharmony_ciInternational used under license by Khronos. All other product names,
7295bd8deadSopenharmony_citrademarks, and/or company names are used solely for identification and
7305bd8deadSopenharmony_cibelong to their respective owners.</p>
7315bd8deadSopenharmony_ci</div>
7325bd8deadSopenharmony_ci<div style="page-break-after: always;"></div>
7335bd8deadSopenharmony_ci<!-- toc disabled -->
7345bd8deadSopenharmony_ci</div>
7355bd8deadSopenharmony_ci</div>
7365bd8deadSopenharmony_ci<div class="sect1">
7375bd8deadSopenharmony_ci<h2 id="introduction">1. Introduction</h2>
7385bd8deadSopenharmony_ci<div class="sectionbody">
7395bd8deadSopenharmony_ci<div class="paragraph">
7405bd8deadSopenharmony_ci<p>This document specifies only version 4.60 of the OpenGL Shading Language (GLSL).
7415bd8deadSopenharmony_ciIt requires __VERSION__ to substitute 460, and requires
7425bd8deadSopenharmony_ci<strong>#version</strong> to accept only
7435bd8deadSopenharmony_ci<code>460</code>.
7445bd8deadSopenharmony_ciIf <strong>#version</strong> is declared with a smaller number, the language accepted is a
7455bd8deadSopenharmony_ciprevious version of the shading language, which will be supported depending
7465bd8deadSopenharmony_cion the version and type of context in the API.
7475bd8deadSopenharmony_ciSee the <a href="#references">normative references</a> for details on what language
7485bd8deadSopenharmony_civersions are supported.</p>
7495bd8deadSopenharmony_ci</div>
7505bd8deadSopenharmony_ci<div class="paragraph">
7515bd8deadSopenharmony_ci<p>Previous versions of the OpenGL Shading Language, as well as the OpenGL ES Shading Language,
7525bd8deadSopenharmony_ciare not strict subsets of the version specified here, particularly with
7535bd8deadSopenharmony_cirespect to precision, name-hiding rules, and treatment of interface
7545bd8deadSopenharmony_civariables.
7555bd8deadSopenharmony_ciSee the specification corresponding to a particular language version for
7565bd8deadSopenharmony_cidetails specific to that version of the language.</p>
7575bd8deadSopenharmony_ci</div>
7585bd8deadSopenharmony_ci<div class="paragraph">
7595bd8deadSopenharmony_ci<p>Throughout, when generating SPIR-V for consumption by the Vulkan API
7605bd8deadSopenharmony_ci(see <a href="#references">normative references</a>), this will be said to be
7615bd8deadSopenharmony_ci<em>targeting Vulkan</em>.</p>
7625bd8deadSopenharmony_ci</div>
7635bd8deadSopenharmony_ci<div class="paragraph">
7645bd8deadSopenharmony_ci<p>While this specification and the OpenGL Specification are normative for OpenGL Shading Language, for
7655bd8deadSopenharmony_ciSPIR-V generation it is still the SPIR-V specification and the SPIR-V client
7665bd8deadSopenharmony_ciAPI specification that are normative for the generated SPIR-V.
7675bd8deadSopenharmony_ciSee the <a href="#references">normative references</a> for further detail.</p>
7685bd8deadSopenharmony_ci</div>
7695bd8deadSopenharmony_ci<div class="paragraph">
7705bd8deadSopenharmony_ci<p>For SPIR-V generation, the SPIR-V client API specifies the commands used to
7715bd8deadSopenharmony_cimanipulate SPIR-V shaders.</p>
7725bd8deadSopenharmony_ci</div>
7735bd8deadSopenharmony_ci<div class="paragraph">
7745bd8deadSopenharmony_ci<p>Independent offline tool chains will compile GLSL down to the SPIR-V
7755bd8deadSopenharmony_ciintermediate language.
7765bd8deadSopenharmony_ciSPIR-V generation is not enabled with a <strong>#extension</strong>, <strong>#version</strong>, or a
7775bd8deadSopenharmony_ciprofile.
7785bd8deadSopenharmony_ciInstead, use of GLSL for SPIR-V is determined by offline tool-chain use.
7795bd8deadSopenharmony_ciSee the documentation of such tools to see how to request generation of
7805bd8deadSopenharmony_ciSPIR-V for its client API.</p>
7815bd8deadSopenharmony_ci</div>
7825bd8deadSopenharmony_ci<div class="paragraph">
7835bd8deadSopenharmony_ci<p>GLSL &#8594; SPIR-V compilers must be directed as to what SPIR-V <strong>Capabilities</strong>
7845bd8deadSopenharmony_ciare legal at run-time and give errors for GLSL feature use outside those
7855bd8deadSopenharmony_cicapabilities.
7865bd8deadSopenharmony_ciThis is also true for implementation-dependent limits that can be error
7875bd8deadSopenharmony_cichecked by the front-end against built-in constants present in the GLSL
7885bd8deadSopenharmony_cisource: the front-end can be informed of such limits, and report errors when
7895bd8deadSopenharmony_cithey are exceeded.</p>
7905bd8deadSopenharmony_ci</div>
7915bd8deadSopenharmony_ci<div class="paragraph">
7925bd8deadSopenharmony_ci<p>SPIR-V features that are not controlled by a SPIR-V capability, but do have an
7935bd8deadSopenharmony_ciequivalent GLSL counterpart (stages, built-in functions, types, limits, etc.)
7945bd8deadSopenharmony_ciare only expected to work on OpenGL drivers that support the GLSL counterpart.</p>
7955bd8deadSopenharmony_ci</div>
7965bd8deadSopenharmony_ci<div class="paragraph">
7975bd8deadSopenharmony_ci<p>All references in this specification to the <a href="#references">OpenGL Specification</a> are to
7985bd8deadSopenharmony_cithe Core profile of version 4.6, unless a different profile is
7995bd8deadSopenharmony_cispecified.</p>
8005bd8deadSopenharmony_ci</div>
8015bd8deadSopenharmony_ci<div class="sect2">
8025bd8deadSopenharmony_ci<h3 id="changes">1.1. Changes</h3>
8035bd8deadSopenharmony_ci<div class="sect3">
8045bd8deadSopenharmony_ci<h4 id="_changes_from_revision_6_of_glsl_4_6">1.1.1. Changes from Revision 6 of GLSL 4.6</h4>
8055bd8deadSopenharmony_ci<div class="ulist">
8065bd8deadSopenharmony_ci<ul>
8075bd8deadSopenharmony_ci<li>
8085bd8deadSopenharmony_ci<p>Incorporated the GL_KHR_vulkan_glsl specification.</p>
8095bd8deadSopenharmony_ci</li>
8105bd8deadSopenharmony_ci<li>
8115bd8deadSopenharmony_ci<p>Add note in the introduction about presence in drivers of SPIR-V features,
8125bd8deadSopenharmony_cias they relate to GLSL features.</p>
8135bd8deadSopenharmony_ci</li>
8145bd8deadSopenharmony_ci<li>
8155bd8deadSopenharmony_ci<p>Clarify it is same location that triggers default-uniform block matching
8165bd8deadSopenharmony_cirules.
8175bd8deadSopenharmony_ciSee <a href="#uniform-variable-layout-qualifiers">Uniform Variable Layout Qualifiers</a>.</p>
8185bd8deadSopenharmony_ci</li>
8195bd8deadSopenharmony_ci</ul>
8205bd8deadSopenharmony_ci</div>
8215bd8deadSopenharmony_ci</div>
8225bd8deadSopenharmony_ci<div class="sect3">
8235bd8deadSopenharmony_ci<h4 id="_changes_from_revision_5_of_glsl_4_6">1.1.2. Changes from Revision 5 of GLSL 4.6</h4>
8245bd8deadSopenharmony_ci<div class="ulist">
8255bd8deadSopenharmony_ci<ul>
8265bd8deadSopenharmony_ci<li>
8275bd8deadSopenharmony_ci<p>Private GLSL issue #34: Clarify/consolidate implicit conversion rules from int &#8594; uint
8285bd8deadSopenharmony_cito be the same as explicit construction.</p>
8295bd8deadSopenharmony_ci</li>
8305bd8deadSopenharmony_ci<li>
8315bd8deadSopenharmony_ci<p>Private GLSL issue #24: Clarify that <strong>barrier</strong>() by itself is enough to synchronize
8325bd8deadSopenharmony_ciboth control flow and memory accesses to <strong>shared</strong> variables and tessellation
8335bd8deadSopenharmony_cicontrol output variables. For other memory accesses an additional memory
8345bd8deadSopenharmony_cibarrier is still required.</p>
8355bd8deadSopenharmony_ci</li>
8365bd8deadSopenharmony_ci<li>
8375bd8deadSopenharmony_ci<p>Normatively reference IEEE-754 for definitions of floating-point formats.</p>
8385bd8deadSopenharmony_ci</li>
8395bd8deadSopenharmony_ci<li>
8405bd8deadSopenharmony_ci<p>Private GLSL issue 36: <strong>refract</strong> function on <strong>double</strong> types requires eta
8415bd8deadSopenharmony_ciargument to have type <strong>double</strong>.</p>
8425bd8deadSopenharmony_ci</li>
8435bd8deadSopenharmony_ci<li>
8445bd8deadSopenharmony_ci<p>Clarify restrictions on input variables in tessellation and geometry stages.</p>
8455bd8deadSopenharmony_ci</li>
8465bd8deadSopenharmony_ci<li>
8475bd8deadSopenharmony_ci<p>Private GLSL issue 15: Clarify the ordering of bindings for arrays of arrays.</p>
8485bd8deadSopenharmony_ci</li>
8495bd8deadSopenharmony_ci<li>
8505bd8deadSopenharmony_ci<p>Private GLSL issue 14: Uniform variables need only match at link time if they
8515bd8deadSopenharmony_ciare statically used.</p>
8525bd8deadSopenharmony_ci</li>
8535bd8deadSopenharmony_ci<li>
8545bd8deadSopenharmony_ci<p>For <strong>precise</strong> computations, the controlling expressions for
8555bd8deadSopenharmony_cicontrol flow and ternary operators (<strong>?:</strong>) are not included.</p>
8565bd8deadSopenharmony_ci</li>
8575bd8deadSopenharmony_ci</ul>
8585bd8deadSopenharmony_ci</div>
8595bd8deadSopenharmony_ci</div>
8605bd8deadSopenharmony_ci<div class="sect3">
8615bd8deadSopenharmony_ci<h4 id="_changes_from_revision_4_of_glsl_4_6">1.1.3. Changes from Revision 4 of GLSL 4.6</h4>
8625bd8deadSopenharmony_ci<div class="ulist">
8635bd8deadSopenharmony_ci<ul>
8645bd8deadSopenharmony_ci<li>
8655bd8deadSopenharmony_ci<p>Private bug 13012: Clarified that builtin uniform variables might only
8665bd8deadSopenharmony_cibe available in the fragment stage.</p>
8675bd8deadSopenharmony_ci</li>
8685bd8deadSopenharmony_ci<li>
8695bd8deadSopenharmony_ci<p>Private bug 13837: Ternary and sequence operators may operate on <strong>void</strong> types.</p>
8705bd8deadSopenharmony_ci</li>
8715bd8deadSopenharmony_ci<li>
8725bd8deadSopenharmony_ci<p>Clarified that errors arising from preprocessing must be returned at compile time.</p>
8735bd8deadSopenharmony_ci</li>
8745bd8deadSopenharmony_ci<li>
8755bd8deadSopenharmony_ci<p>Clarified that access to any part of a variable constitutes a static use.</p>
8765bd8deadSopenharmony_ci</li>
8775bd8deadSopenharmony_ci<li>
8785bd8deadSopenharmony_ci<p>Private GLSL issue 19: A statement is required following any label at the end of a <strong>switch</strong>.</p>
8795bd8deadSopenharmony_ci</li>
8805bd8deadSopenharmony_ci<li>
8815bd8deadSopenharmony_ci<p>Private GLSL issue 26: <strong>noise</strong> is not valid when compiling for SPIR-V.</p>
8825bd8deadSopenharmony_ci</li>
8835bd8deadSopenharmony_ci<li>
8845bd8deadSopenharmony_ci<p>Private GLSL issue 20: <strong>length</strong>() expressions returning a constant value may not
8855bd8deadSopenharmony_cicontain side effects.</p>
8865bd8deadSopenharmony_ci</li>
8875bd8deadSopenharmony_ci<li>
8885bd8deadSopenharmony_ci<p>Public OpenGL-API issue 7: Variables can be declared as both <strong>readonly</strong>
8895bd8deadSopenharmony_ciand <strong>writeonly</strong>.</p>
8905bd8deadSopenharmony_ci</li>
8915bd8deadSopenharmony_ci<li>
8925bd8deadSopenharmony_ci<p>Private GLSL issue 16: Use of constant expressions within <strong>#line</strong> directives is undefined.</p>
8935bd8deadSopenharmony_ci</li>
8945bd8deadSopenharmony_ci<li>
8955bd8deadSopenharmony_ci<p>Corrected return type of <strong>imageAtomicExchange</strong> on <strong>float</strong> images.</p>
8965bd8deadSopenharmony_ci</li>
8975bd8deadSopenharmony_ci<li>
8985bd8deadSopenharmony_ci<p>Private GLSL issue 32: Remove <strong>length</strong>() method contradiction:
8995bd8deadSopenharmony_ciNon runtime-sized arrays only support <strong>length</strong>() on explicitly
9005bd8deadSopenharmony_cisized arrays.</p>
9015bd8deadSopenharmony_ci</li>
9025bd8deadSopenharmony_ci<li>
9035bd8deadSopenharmony_ci<p>Private GLSL issue 21: Clarified the l-value restriction on <strong>interpolateAt</strong>.</p>
9045bd8deadSopenharmony_ci</li>
9055bd8deadSopenharmony_ci<li>
9065bd8deadSopenharmony_ci<p>Private OpenGL-API issue 53: Clarified bit-width requirements for location aliasing.</p>
9075bd8deadSopenharmony_ci</li>
9085bd8deadSopenharmony_ci<li>
9095bd8deadSopenharmony_ci<p>Public GLSL issue 15: <strong>gl_in</strong> can be redeclared using unsized-array syntax.</p>
9105bd8deadSopenharmony_ci</li>
9115bd8deadSopenharmony_ci<li>
9125bd8deadSopenharmony_ci<p>Clarification of the formats needed for DEPTH_COMPONENT and
9135bd8deadSopenharmony_ciSTENCIL_COMPONENT for depth/stencil textures.</p>
9145bd8deadSopenharmony_ci</li>
9155bd8deadSopenharmony_ci<li>
9165bd8deadSopenharmony_ci<p>Added image formats to the layout-qualifier table in the
9175bd8deadSopenharmony_ci<a href="#layout-qualifiers">Layout Qualifiers</a> section.</p>
9185bd8deadSopenharmony_ci</li>
9195bd8deadSopenharmony_ci</ul>
9205bd8deadSopenharmony_ci</div>
9215bd8deadSopenharmony_ci</div>
9225bd8deadSopenharmony_ci<div class="sect3">
9235bd8deadSopenharmony_ci<h4 id="_changes_from_revision_3_of_glsl_4_6">1.1.4. Changes from Revision 3 of GLSL 4.6</h4>
9245bd8deadSopenharmony_ci<div class="ulist">
9255bd8deadSopenharmony_ci<ul>
9265bd8deadSopenharmony_ci<li>
9275bd8deadSopenharmony_ci<p>Private GLSL issue 13: Fix misspelling of <strong>allInvocationsEqual</strong>().
9285bd8deadSopenharmony_ci(The one in the table was incorrectly listed as <strong>anyInvocationsEqual</strong>(),
9295bd8deadSopenharmony_ciother spellings were correct.)</p>
9305bd8deadSopenharmony_ci</li>
9315bd8deadSopenharmony_ci</ul>
9325bd8deadSopenharmony_ci</div>
9335bd8deadSopenharmony_ci</div>
9345bd8deadSopenharmony_ci<div class="sect3">
9355bd8deadSopenharmony_ci<h4 id="_summary_of_changes_from_revision_7_of_glsl_version_4_50">1.1.5. Summary of Changes from Revision 7 of GLSL Version 4.50</h4>
9365bd8deadSopenharmony_ci<div class="ulist">
9375bd8deadSopenharmony_ci<ul>
9385bd8deadSopenharmony_ci<li>
9395bd8deadSopenharmony_ci<p>Incorporated the GL_ARB_shader_atomic_counter_ops extension.</p>
9405bd8deadSopenharmony_ci</li>
9415bd8deadSopenharmony_ci<li>
9425bd8deadSopenharmony_ci<p>Incorporated the GL_ARB_shader_draw_parameters extension.</p>
9435bd8deadSopenharmony_ci</li>
9445bd8deadSopenharmony_ci<li>
9455bd8deadSopenharmony_ci<p>Incorporated the GL_ARB_shader_group_vote extension.</p>
9465bd8deadSopenharmony_ci</li>
9475bd8deadSopenharmony_ci<li>
9485bd8deadSopenharmony_ci<p>Incorporated the GL_ARB_gl_spirv extension.</p>
9495bd8deadSopenharmony_ci</li>
9505bd8deadSopenharmony_ci<li>
9515bd8deadSopenharmony_ci<p>Private Bug 16070: Allow extra semi-colons at global scope.</p>
9525bd8deadSopenharmony_ci</li>
9535bd8deadSopenharmony_ci<li>
9545bd8deadSopenharmony_ci<p>Private GLSL Issue 5: Be explicit that &#8220;fail to link&#8221; is really
9555bd8deadSopenharmony_ci&#8220;compile-time or link-time error&#8221;, for some forms of error.</p>
9565bd8deadSopenharmony_ci</li>
9575bd8deadSopenharmony_ci<li>
9585bd8deadSopenharmony_ci<p>Private GLSL Issue 7: Change <em>gl_MaxComputeUniformComponents</em> to 1024.</p>
9595bd8deadSopenharmony_ci</li>
9605bd8deadSopenharmony_ci<li>
9615bd8deadSopenharmony_ci<p>Private OpenGL API Issue 35: Require location on transparent individual
9625bd8deadSopenharmony_ciuniform variables for SPIR-V.</p>
9635bd8deadSopenharmony_ci</li>
9645bd8deadSopenharmony_ci<li>
9655bd8deadSopenharmony_ci<p>Private GLSL Issue 8: Be more clear an <strong>interpolateAt</strong>() interpolant can
9665bd8deadSopenharmony_cibe a structure member.</p>
9675bd8deadSopenharmony_ci</li>
9685bd8deadSopenharmony_ci<li>
9695bd8deadSopenharmony_ci<p>Private GLSL Issue 9: Specify how <strong>xfb_buffer</strong> interacts with a block
9705bd8deadSopenharmony_ciarray: the capturing buffer increments for each block array element.</p>
9715bd8deadSopenharmony_ci</li>
9725bd8deadSopenharmony_ci</ul>
9735bd8deadSopenharmony_ci</div>
9745bd8deadSopenharmony_ci</div>
9755bd8deadSopenharmony_ci</div>
9765bd8deadSopenharmony_ci<div class="sect2">
9775bd8deadSopenharmony_ci<h3 id="overview">1.2. Overview</h3>
9785bd8deadSopenharmony_ci<div class="paragraph">
9795bd8deadSopenharmony_ci<p>This document describes <em>The OpenGL Shading Language, version 4.60</em>.</p>
9805bd8deadSopenharmony_ci</div>
9815bd8deadSopenharmony_ci<div class="paragraph">
9825bd8deadSopenharmony_ci<p>Independent compilation units written in this language are called <em>shaders</em>.
9835bd8deadSopenharmony_ciA <em>program</em> is a set of shaders that are compiled and linked
9845bd8deadSopenharmony_citogether,
9855bd8deadSopenharmony_cicompletely creating one or more of the programmable stages of the
9865bd8deadSopenharmony_ciAPI pipeline.
9875bd8deadSopenharmony_ciAll the shaders for a single programmable stage must be within the same
9885bd8deadSopenharmony_ciprogram.
9895bd8deadSopenharmony_ciA complete set of programmable stages can be put into a single program or
9905bd8deadSopenharmony_cithe stages can be partitioned across multiple programs.
9915bd8deadSopenharmony_ciThe aim of this document is to thoroughly specify the programming language.
9925bd8deadSopenharmony_ciThe <a href="#references">normative references</a> will specify the API entry points
9935bd8deadSopenharmony_ciused to manipulate and communicate with programs and shaders.</p>
9945bd8deadSopenharmony_ci</div>
9955bd8deadSopenharmony_ci</div>
9965bd8deadSopenharmony_ci<div class="sect2">
9975bd8deadSopenharmony_ci<h3 id="error-handling">1.3. Error Handling</h3>
9985bd8deadSopenharmony_ci<div class="paragraph">
9995bd8deadSopenharmony_ci<p>Compilers, in general, accept programs that are ill-formed, due to the
10005bd8deadSopenharmony_ciimpossibility of detecting all ill-formed programs.
10015bd8deadSopenharmony_ciPortability is only ensured for well-formed programs, which this
10025bd8deadSopenharmony_cispecification describes.
10035bd8deadSopenharmony_ciCompilers are encouraged to detect ill-formed programs and issue diagnostic
10045bd8deadSopenharmony_cimessages, but are not required to do so for all cases.
10055bd8deadSopenharmony_ciCompile-time errors must be returned for lexically or grammatically
10065bd8deadSopenharmony_ciincorrect shaders.
10075bd8deadSopenharmony_ciOther errors are reported at compile time or link time as indicated.
10085bd8deadSopenharmony_ciCode that is &#8220;dead&#8221; must still be error checked.
10095bd8deadSopenharmony_ciFor example:</p>
10105bd8deadSopenharmony_ci</div>
10115bd8deadSopenharmony_ci<div class="listingblock">
10125bd8deadSopenharmony_ci<div class="content">
10135bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="keyword">if</span> (<span class="predefined-constant">false</span>)     <span class="comment">// changing false to true cannot uncover additional errors</span>
10145bd8deadSopenharmony_ci    statement; <span class="comment">// statement must be error checked regardless</span></code></pre>
10155bd8deadSopenharmony_ci</div>
10165bd8deadSopenharmony_ci</div>
10175bd8deadSopenharmony_ci</div>
10185bd8deadSopenharmony_ci<div class="sect2">
10195bd8deadSopenharmony_ci<h3 id="typographical-conventions">1.4. Typographical Conventions</h3>
10205bd8deadSopenharmony_ci<div class="paragraph">
10215bd8deadSopenharmony_ci<p>Italic, bold, and font choices have been used in this specification
10225bd8deadSopenharmony_ciprimarily to improve readability.
10235bd8deadSopenharmony_ciCode fragments use a fixed width font.
10245bd8deadSopenharmony_ciIdentifiers embedded in text are italicized.
10255bd8deadSopenharmony_ciKeywords embedded in text are bold.
10265bd8deadSopenharmony_ciOperators are called by their name, followed by their symbol in bold in
10275bd8deadSopenharmony_ciparentheses.
10285bd8deadSopenharmony_ciThe clarifying grammar fragments in the text use bold for literals and
10295bd8deadSopenharmony_ciitalics for non-terminals.
10305bd8deadSopenharmony_ciThe official grammar in &#8220;<a href="#shading-language-grammar">Shading Language
10315bd8deadSopenharmony_ciGrammar</a>&#8221; uses all capitals for terminals and lower case for
10325bd8deadSopenharmony_cinon-terminals.</p>
10335bd8deadSopenharmony_ci</div>
10345bd8deadSopenharmony_ci</div>
10355bd8deadSopenharmony_ci<div class="sect2">
10365bd8deadSopenharmony_ci<h3 id="deprecation">1.5. Deprecation</h3>
10375bd8deadSopenharmony_ci<div class="paragraph">
10385bd8deadSopenharmony_ci<p>The OpenGL Shading Language has deprecated some features.
10395bd8deadSopenharmony_ciThese are clearly called out in this specification as &#8220;deprecated&#8221;.
10405bd8deadSopenharmony_ciThey are still present in this version of the language, but are targeted for
10415bd8deadSopenharmony_cipotential removal in a future version of the shading language.
10425bd8deadSopenharmony_ciThe OpenGL API has a forward compatibility mode that will disallow use of
10435bd8deadSopenharmony_cideprecated features.
10445bd8deadSopenharmony_ciIf compiling in a mode where use of deprecated features is disallowed, their
10455bd8deadSopenharmony_ciuse causes compile-time or link-time errors.
10465bd8deadSopenharmony_ciSee the <a href="#references">OpenGL Specification</a> for details on what causes deprecated
10475bd8deadSopenharmony_cilanguage features to be accepted or to return an error.</p>
10485bd8deadSopenharmony_ci</div>
10495bd8deadSopenharmony_ci</div>
10505bd8deadSopenharmony_ci</div>
10515bd8deadSopenharmony_ci</div>
10525bd8deadSopenharmony_ci<div class="sect1">
10535bd8deadSopenharmony_ci<h2 id="overview-of-opengl-shading">2. Overview of Shading</h2>
10545bd8deadSopenharmony_ci<div class="sectionbody">
10555bd8deadSopenharmony_ci<div class="paragraph">
10565bd8deadSopenharmony_ci<p>The OpenGL Shading Language is actually several closely related languages.
10575bd8deadSopenharmony_ciThese languages are used to create shaders for each of the programmable
10585bd8deadSopenharmony_ciprocessors contained in the API&#8217;s processing pipeline.
10595bd8deadSopenharmony_ciCurrently, these processors are the vertex, tessellation control,
10605bd8deadSopenharmony_citessellation evaluation, geometry, fragment, and compute processors.</p>
10615bd8deadSopenharmony_ci</div>
10625bd8deadSopenharmony_ci<div class="paragraph">
10635bd8deadSopenharmony_ci<p>Unless otherwise noted in this paper, a language feature applies to all
10645bd8deadSopenharmony_cilanguages, and common usage will refer to these languages as a single
10655bd8deadSopenharmony_cilanguage.
10665bd8deadSopenharmony_ciThe specific languages will be referred to by the name of the processor they
10675bd8deadSopenharmony_citarget: vertex, tessellation control, tessellation evaluation, geometry,
10685bd8deadSopenharmony_cifragment, or compute.</p>
10695bd8deadSopenharmony_ci</div>
10705bd8deadSopenharmony_ci<div class="paragraph">
10715bd8deadSopenharmony_ci<p>Most API state is not tracked or made available to shaders.
10725bd8deadSopenharmony_ciTypically, user-defined variables will be used for communicating between
10735bd8deadSopenharmony_cidifferent stages of the API pipeline.
10745bd8deadSopenharmony_ciHowever, a small amount of state is still tracked and automatically made
10755bd8deadSopenharmony_ciavailable to shaders, and there are a few built-in variables for interfaces
10765bd8deadSopenharmony_cibetween different stages of the API pipeline.</p>
10775bd8deadSopenharmony_ci</div>
10785bd8deadSopenharmony_ci<div class="sect2">
10795bd8deadSopenharmony_ci<h3 id="vertex-processor">2.1. Vertex Processor</h3>
10805bd8deadSopenharmony_ci<div class="paragraph">
10815bd8deadSopenharmony_ci<p>The <em>vertex processor</em> is a programmable unit that operates on incoming
10825bd8deadSopenharmony_civertices and their associated data.
10835bd8deadSopenharmony_ciCompilation units written in the OpenGL Shading Language to run on this processor are called
10845bd8deadSopenharmony_ci<em>vertex shaders</em>.
10855bd8deadSopenharmony_ciWhen a set of vertex shaders are successfully compiled and linked, they
10865bd8deadSopenharmony_ciresult in a <em>vertex shader executable</em> that runs on the vertex processor.</p>
10875bd8deadSopenharmony_ci</div>
10885bd8deadSopenharmony_ci<div class="paragraph">
10895bd8deadSopenharmony_ci<p>The vertex processor operates on one vertex at a time.
10905bd8deadSopenharmony_ciIt does not replace graphics operations that require knowledge of several
10915bd8deadSopenharmony_civertices at a time.</p>
10925bd8deadSopenharmony_ci</div>
10935bd8deadSopenharmony_ci</div>
10945bd8deadSopenharmony_ci<div class="sect2">
10955bd8deadSopenharmony_ci<h3 id="tessellation-control-processor">2.2. Tessellation Control Processor</h3>
10965bd8deadSopenharmony_ci<div class="paragraph">
10975bd8deadSopenharmony_ci<p>The <em>tessellation control processor</em> is a programmable unit that operates on
10985bd8deadSopenharmony_cia patch of incoming vertices and their associated data, emitting a new
10995bd8deadSopenharmony_cioutput patch.
11005bd8deadSopenharmony_ciCompilation units written in the OpenGL Shading Language to run on this processor are called
11015bd8deadSopenharmony_citessellation control shaders.
11025bd8deadSopenharmony_ciWhen a set of tessellation control shaders are successfully compiled and
11035bd8deadSopenharmony_cilinked, they result in a <em>tessellation control shader executable</em> that runs
11045bd8deadSopenharmony_cion the tessellation control processor.</p>
11055bd8deadSopenharmony_ci</div>
11065bd8deadSopenharmony_ci<div class="paragraph">
11075bd8deadSopenharmony_ci<p>The tessellation control shader is invoked for each vertex of the output
11085bd8deadSopenharmony_cipatch.
11095bd8deadSopenharmony_ciEach invocation can read the attributes of any vertex in the input or output
11105bd8deadSopenharmony_cipatches, but can only write per-vertex attributes for the corresponding
11115bd8deadSopenharmony_cioutput patch vertex.
11125bd8deadSopenharmony_ciThe shader invocations collectively produce a set of per-patch attributes
11135bd8deadSopenharmony_cifor the output patch.</p>
11145bd8deadSopenharmony_ci</div>
11155bd8deadSopenharmony_ci<div class="paragraph">
11165bd8deadSopenharmony_ci<p>After all tessellation control shader invocations have completed, the output
11175bd8deadSopenharmony_civertices and per-patch attributes are assembled to form a patch to be used
11185bd8deadSopenharmony_ciby subsequent pipeline stages.</p>
11195bd8deadSopenharmony_ci</div>
11205bd8deadSopenharmony_ci<div class="paragraph">
11215bd8deadSopenharmony_ci<p>Tessellation control shader invocations run mostly independently, with
11225bd8deadSopenharmony_ciundefined relative execution order.
11235bd8deadSopenharmony_ciHowever, the built-in function <strong>barrier</strong>() can be used to control execution
11245bd8deadSopenharmony_ciorder by synchronizing invocations, effectively dividing tessellation
11255bd8deadSopenharmony_cicontrol shader execution into a set of phases.
11265bd8deadSopenharmony_ciTessellation control shaders will get undefined results if one invocation
11275bd8deadSopenharmony_cireads from a per-vertex or per-patch attribute written by another invocation
11285bd8deadSopenharmony_ciat any point during the same phase, or if two invocations attempt to write
11295bd8deadSopenharmony_cidifferent values to the same per-patch output
11305bd8deadSopenharmony_ci32-bit component
11315bd8deadSopenharmony_ciin a single phase.</p>
11325bd8deadSopenharmony_ci</div>
11335bd8deadSopenharmony_ci</div>
11345bd8deadSopenharmony_ci<div class="sect2">
11355bd8deadSopenharmony_ci<h3 id="tessellation-evaluation-processor">2.3. Tessellation Evaluation Processor</h3>
11365bd8deadSopenharmony_ci<div class="paragraph">
11375bd8deadSopenharmony_ci<p>The <em>tessellation evaluation processor</em> is a programmable unit that
11385bd8deadSopenharmony_cievaluates the position and other attributes of a vertex generated by the
11395bd8deadSopenharmony_citessellation primitive generator, using a patch of incoming vertices and
11405bd8deadSopenharmony_citheir associated data.
11415bd8deadSopenharmony_ciCompilation units written in the OpenGL Shading Language to run on this processor are called
11425bd8deadSopenharmony_citessellation evaluation shaders.
11435bd8deadSopenharmony_ciWhen a set of tessellation evaluation shaders are successfully compiled and
11445bd8deadSopenharmony_cilinked, they result in a <em>tessellation evaluation shader executable</em> that
11455bd8deadSopenharmony_ciruns on the tessellation evaluation processor.</p>
11465bd8deadSopenharmony_ci</div>
11475bd8deadSopenharmony_ci<div class="paragraph">
11485bd8deadSopenharmony_ci<p>Each invocation of the tessellation evaluation executable computes the
11495bd8deadSopenharmony_ciposition and attributes of a single vertex generated by the tessellation
11505bd8deadSopenharmony_ciprimitive generator.
11515bd8deadSopenharmony_ciThe executable can read the attributes of any vertex in the input patch,
11525bd8deadSopenharmony_ciplus the tessellation coordinate, which is the relative location of the
11535bd8deadSopenharmony_civertex in the primitive being tessellated.
11545bd8deadSopenharmony_ciThe executable writes the position and other attributes of the vertex.</p>
11555bd8deadSopenharmony_ci</div>
11565bd8deadSopenharmony_ci</div>
11575bd8deadSopenharmony_ci<div class="sect2">
11585bd8deadSopenharmony_ci<h3 id="geometry-processor">2.4. Geometry Processor</h3>
11595bd8deadSopenharmony_ci<div class="paragraph">
11605bd8deadSopenharmony_ci<p>The <em>geometry processor</em> is a programmable unit that operates on data for
11615bd8deadSopenharmony_ciincoming vertices for a primitive assembled after vertex processing and
11625bd8deadSopenharmony_cioutputs a sequence of vertices forming output primitives.
11635bd8deadSopenharmony_ciCompilation units written in the OpenGL Shading Language to run on this processor are called
11645bd8deadSopenharmony_ci<em>geometry shaders</em>.
11655bd8deadSopenharmony_ciWhen a set of geometry shaders are successfully compiled and linked, they
11665bd8deadSopenharmony_ciresult in a <em>geometry shader executable</em> that runs on the geometry
11675bd8deadSopenharmony_ciprocessor.</p>
11685bd8deadSopenharmony_ci</div>
11695bd8deadSopenharmony_ci<div class="paragraph">
11705bd8deadSopenharmony_ci<p>A single invocation of the geometry shader executable on the geometry
11715bd8deadSopenharmony_ciprocessor will operate on a declared input primitive with a fixed number of
11725bd8deadSopenharmony_civertices.
11735bd8deadSopenharmony_ciThis single invocation can emit a variable number of vertices that are
11745bd8deadSopenharmony_ciassembled into primitives of a declared output primitive type and passed to
11755bd8deadSopenharmony_cisubsequent pipeline stages.</p>
11765bd8deadSopenharmony_ci</div>
11775bd8deadSopenharmony_ci</div>
11785bd8deadSopenharmony_ci<div class="sect2">
11795bd8deadSopenharmony_ci<h3 id="fragment-processor">2.5. Fragment Processor</h3>
11805bd8deadSopenharmony_ci<div class="paragraph">
11815bd8deadSopenharmony_ci<p>The <em>fragment processor</em> is a programmable unit that operates on fragment
11825bd8deadSopenharmony_civalues and their associated data.
11835bd8deadSopenharmony_ciCompilation units written in the OpenGL Shading Language to run on this processor are called
11845bd8deadSopenharmony_ci<em>fragment shaders</em>.
11855bd8deadSopenharmony_ciWhen a set of fragment shaders are successfully compiled and linked, they
11865bd8deadSopenharmony_ciresult in a <em>fragment shader executable</em> that runs on the fragment
11875bd8deadSopenharmony_ciprocessor.</p>
11885bd8deadSopenharmony_ci</div>
11895bd8deadSopenharmony_ci<div class="paragraph">
11905bd8deadSopenharmony_ci<p>A fragment shader cannot change a fragment&#8217;s (<em>x</em>, <em>y</em>) position.
11915bd8deadSopenharmony_ciAccess to neighboring fragments is not allowed.
11925bd8deadSopenharmony_ciThe values computed by the fragment shader are ultimately used to update
11935bd8deadSopenharmony_ciframebuffer memory or texture memory, depending on the current API
11945bd8deadSopenharmony_cistate and the API command that caused the fragments to be generated.</p>
11955bd8deadSopenharmony_ci</div>
11965bd8deadSopenharmony_ci</div>
11975bd8deadSopenharmony_ci<div class="sect2">
11985bd8deadSopenharmony_ci<h3 id="compute-processor">2.6. Compute Processor</h3>
11995bd8deadSopenharmony_ci<div class="paragraph">
12005bd8deadSopenharmony_ci<p>The <em>compute processor</em> is a programmable unit that operates independently
12015bd8deadSopenharmony_cifrom the other shader processors.
12025bd8deadSopenharmony_ciCompilation units written in the OpenGL Shading Language to run on this processor are called
12035bd8deadSopenharmony_ci<em>compute shaders</em>.
12045bd8deadSopenharmony_ciWhen a set of compute shaders are successfully compiled and linked, they
12055bd8deadSopenharmony_ciresult in a <em>compute shader executable</em> that runs on the compute processor.</p>
12065bd8deadSopenharmony_ci</div>
12075bd8deadSopenharmony_ci<div class="paragraph">
12085bd8deadSopenharmony_ci<p>A compute shader has access to many of the same resources as fragment and
12095bd8deadSopenharmony_ciother shader processors, such as textures, buffers, image variables, and
12105bd8deadSopenharmony_ciatomic counters.
12115bd8deadSopenharmony_ciIt does not have fixed-function outputs.
12125bd8deadSopenharmony_ciIt is not part of the graphics pipeline and its visible side effects are
12135bd8deadSopenharmony_cithrough changes to images, storage buffers, and atomic counters.</p>
12145bd8deadSopenharmony_ci</div>
12155bd8deadSopenharmony_ci<div class="paragraph">
12165bd8deadSopenharmony_ci<p>A compute shader operates on a group of work items called a <em>workgroup</em>.
12175bd8deadSopenharmony_ciA workgroup is a collection of shader invocations that execute the same
12185bd8deadSopenharmony_cicode, potentially in parallel.
12195bd8deadSopenharmony_ciAn invocation within a workgroup may share data with other members of the
12205bd8deadSopenharmony_cisame workgroup through shared variables and issue memory and control flow
12215bd8deadSopenharmony_cibarriers to synchronize with other members of the same workgroup.</p>
12225bd8deadSopenharmony_ci</div>
12235bd8deadSopenharmony_ci</div>
12245bd8deadSopenharmony_ci</div>
12255bd8deadSopenharmony_ci</div>
12265bd8deadSopenharmony_ci<div class="sect1">
12275bd8deadSopenharmony_ci<h2 id="basics">3. Basics</h2>
12285bd8deadSopenharmony_ci<div class="sectionbody">
12295bd8deadSopenharmony_ci<div class="sect2">
12305bd8deadSopenharmony_ci<h3 id="character-set">3.1. Character Set and Phases of Compilation</h3>
12315bd8deadSopenharmony_ci<div class="paragraph">
12325bd8deadSopenharmony_ci<p>The source character set used for the OpenGL Shading Language is Unicode in the UTF-8
12335bd8deadSopenharmony_ciencoding scheme.</p>
12345bd8deadSopenharmony_ci</div>
12355bd8deadSopenharmony_ci<div class="paragraph">
12365bd8deadSopenharmony_ci<p>After preprocessing, only the following characters are allowed in the
12375bd8deadSopenharmony_ciresulting stream of GLSL tokens:</p>
12385bd8deadSopenharmony_ci</div>
12395bd8deadSopenharmony_ci<div class="ulist">
12405bd8deadSopenharmony_ci<ul>
12415bd8deadSopenharmony_ci<li>
12425bd8deadSopenharmony_ci<p>The letters <strong>a-z</strong>, <strong>A-Z</strong>, and the underscore (<strong>_</strong>).</p>
12435bd8deadSopenharmony_ci</li>
12445bd8deadSopenharmony_ci<li>
12455bd8deadSopenharmony_ci<p>The numbers <strong>0-9</strong>.</p>
12465bd8deadSopenharmony_ci</li>
12475bd8deadSopenharmony_ci<li>
12485bd8deadSopenharmony_ci<p>The symbols period (<strong>.</strong>), plus (<strong>+</strong>), dash (<strong>-</strong>), slash (<strong>/</strong>), asterisk
12495bd8deadSopenharmony_ci(<strong>*</strong>), percent (<strong>%</strong>), angled brackets (<strong>&lt;</strong> and <strong>&gt;</strong>), square brackets
12505bd8deadSopenharmony_ci(<strong>[</strong> and <strong>]</strong>), parentheses (<strong>(</strong> and <strong>)</strong>), braces (<strong>{</strong> and <strong>}</strong>), caret
12515bd8deadSopenharmony_ci(<strong>^</strong>), vertical bar (<strong>|</strong>), ampersand (<strong>&amp;</strong>), tilde (<strong>~</strong>), equals (<strong>=</strong>),
12525bd8deadSopenharmony_ciexclamation point (<strong>!</strong>), colon (<strong>:</strong>), semicolon (<strong>;</strong>), comma (<strong>,</strong>), and
12535bd8deadSopenharmony_ciquestion mark (<strong>?</strong>).</p>
12545bd8deadSopenharmony_ci</li>
12555bd8deadSopenharmony_ci</ul>
12565bd8deadSopenharmony_ci</div>
12575bd8deadSopenharmony_ci<div class="paragraph">
12585bd8deadSopenharmony_ci<p>A compile-time error will be given if any other character is used in a GLSL
12595bd8deadSopenharmony_citoken.</p>
12605bd8deadSopenharmony_ci</div>
12615bd8deadSopenharmony_ci<div class="paragraph">
12625bd8deadSopenharmony_ci<p>There are no digraphs or trigraphs.
12635bd8deadSopenharmony_ciThere are no escape sequences or other uses of the backslash beyond use as
12645bd8deadSopenharmony_cithe line-continuation character.</p>
12655bd8deadSopenharmony_ci</div>
12665bd8deadSopenharmony_ci<div class="paragraph">
12675bd8deadSopenharmony_ci<p>Lines are relevant for compiler diagnostic messages and the preprocessor.
12685bd8deadSopenharmony_ciThey are terminated by carriage-return or line-feed.
12695bd8deadSopenharmony_ciIf both are used together, it will count as only a single line termination.
12705bd8deadSopenharmony_ciFor the remainder of this document, any of these combinations is simply
12715bd8deadSopenharmony_cireferred to as a new-line.
12725bd8deadSopenharmony_ciLines may be of arbitrary length.</p>
12735bd8deadSopenharmony_ci</div>
12745bd8deadSopenharmony_ci<div class="paragraph">
12755bd8deadSopenharmony_ci<p>In general, the language&#8217;s use of this character set is case sensitive.</p>
12765bd8deadSopenharmony_ci</div>
12775bd8deadSopenharmony_ci<div class="paragraph">
12785bd8deadSopenharmony_ci<p>There are no character or string data types, so no quoting characters are
12795bd8deadSopenharmony_ciincluded.</p>
12805bd8deadSopenharmony_ci</div>
12815bd8deadSopenharmony_ci<div class="paragraph">
12825bd8deadSopenharmony_ci<p>There is no end-of-file character.</p>
12835bd8deadSopenharmony_ci</div>
12845bd8deadSopenharmony_ci<div class="paragraph">
12855bd8deadSopenharmony_ci<p>More formally, compilation happens as if the following logical phases were
12865bd8deadSopenharmony_ciexecuted in order:</p>
12875bd8deadSopenharmony_ci</div>
12885bd8deadSopenharmony_ci<div class="olist arabic">
12895bd8deadSopenharmony_ci<ol class="arabic">
12905bd8deadSopenharmony_ci<li>
12915bd8deadSopenharmony_ci<p>Source strings are concatenated to form a single input.
12925bd8deadSopenharmony_ciAll provided new-lines are retained.</p>
12935bd8deadSopenharmony_ci</li>
12945bd8deadSopenharmony_ci<li>
12955bd8deadSopenharmony_ci<p>Line numbering is noted, based on all present new-lines, and does not
12965bd8deadSopenharmony_cichange when new-lines are later eliminated.</p>
12975bd8deadSopenharmony_ci</li>
12985bd8deadSopenharmony_ci<li>
12995bd8deadSopenharmony_ci<p>Wherever a backslash ('\') occurs immediately before a new-line, both
13005bd8deadSopenharmony_ciare eliminated.
13015bd8deadSopenharmony_ci(Note no white space is substituted, allowing a single token to span a
13025bd8deadSopenharmony_cinew-line.) Any newly formed backslash followed by a new-line is not
13035bd8deadSopenharmony_cieliminated; only those pairs originally occurring after phase 1 are
13045bd8deadSopenharmony_cieliminated.</p>
13055bd8deadSopenharmony_ci</li>
13065bd8deadSopenharmony_ci<li>
13075bd8deadSopenharmony_ci<p>All comments are replaced with a single space.
13085bd8deadSopenharmony_ci(Note that '//' style comments end before their terminating new-lines
13095bd8deadSopenharmony_ciand white space is generally relevant to preprocessing.)</p>
13105bd8deadSopenharmony_ci</li>
13115bd8deadSopenharmony_ci<li>
13125bd8deadSopenharmony_ci<p>Preprocessing is done, resulting in a sequence of GLSL tokens, formed
13135bd8deadSopenharmony_cifrom the character set stated above.</p>
13145bd8deadSopenharmony_ci</li>
13155bd8deadSopenharmony_ci<li>
13165bd8deadSopenharmony_ci<p>GLSL processing is done on the sequence of GLSL tokens.</p>
13175bd8deadSopenharmony_ci</li>
13185bd8deadSopenharmony_ci</ol>
13195bd8deadSopenharmony_ci</div>
13205bd8deadSopenharmony_ci<div class="paragraph">
13215bd8deadSopenharmony_ci<p>Details that fully define source strings, comments, line numbering, new-line
13225bd8deadSopenharmony_cielimination, and preprocessing are all discussed in upcoming sections.
13235bd8deadSopenharmony_ciSections beyond those describe GLSL processing.</p>
13245bd8deadSopenharmony_ci</div>
13255bd8deadSopenharmony_ci</div>
13265bd8deadSopenharmony_ci<div class="sect2">
13275bd8deadSopenharmony_ci<h3 id="source-strings">3.2. Source Strings</h3>
13285bd8deadSopenharmony_ci<div class="paragraph">
13295bd8deadSopenharmony_ci<p>The source for a single shader is an array of strings of characters from the
13305bd8deadSopenharmony_cicharacter set.
13315bd8deadSopenharmony_ciA single shader is made from the concatenation of these strings.
13325bd8deadSopenharmony_ciEach string can contain multiple lines, separated by new-lines.
13335bd8deadSopenharmony_ciNo new-lines need be present in a string; a single line can be formed from
13345bd8deadSopenharmony_cimultiple strings.
13355bd8deadSopenharmony_ciNo new-lines or other characters are inserted by the implementation when it
13365bd8deadSopenharmony_ciconcatenates the strings to form a single shader.
13375bd8deadSopenharmony_ciMultiple shaders can be linked together to form a single program.</p>
13385bd8deadSopenharmony_ci</div>
13395bd8deadSopenharmony_ci<div class="paragraph">
13405bd8deadSopenharmony_ci<p>Diagnostic messages returned from compiling a shader must identify both the
13415bd8deadSopenharmony_ciline number within a string and which source string the message applies to.
13425bd8deadSopenharmony_ciSource strings are counted sequentially with the first string being string
13435bd8deadSopenharmony_ci0.
13445bd8deadSopenharmony_ciLine numbers are one more than the number of new-lines that have been
13455bd8deadSopenharmony_ciprocessed, including counting the new-lines that will be removed by the
13465bd8deadSopenharmony_ciline-continuation character (<strong>\</strong>).</p>
13475bd8deadSopenharmony_ci</div>
13485bd8deadSopenharmony_ci<div class="paragraph">
13495bd8deadSopenharmony_ci<p>Lines separated by the line-continuation character preceding a new-line are
13505bd8deadSopenharmony_ciconcatenated together before either comment processing or preprocessing.
13515bd8deadSopenharmony_ciThis means that no white space is substituted for the line-continuation
13525bd8deadSopenharmony_cicharacter.
13535bd8deadSopenharmony_ciThat is, a single token could be formed by the concatenation by taking the
13545bd8deadSopenharmony_cicharacters at the end of one line concatenating them with the characters at
13555bd8deadSopenharmony_cithe beginning of the next line.</p>
13565bd8deadSopenharmony_ci</div>
13575bd8deadSopenharmony_ci<div class="listingblock">
13585bd8deadSopenharmony_ci<div class="content">
13595bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">float</span> f\
13605bd8deadSopenharmony_cioo;
13615bd8deadSopenharmony_ci<span class="comment">// forms a single line equivalent to &quot;float foo;&quot;</span>
13625bd8deadSopenharmony_ci<span class="comment">// (assuming '\' is the last character before the new-line and &quot;oo&quot; are</span>
13635bd8deadSopenharmony_ci<span class="comment">// the first two characters of the next line)</span></code></pre>
13645bd8deadSopenharmony_ci</div>
13655bd8deadSopenharmony_ci</div>
13665bd8deadSopenharmony_ci</div>
13675bd8deadSopenharmony_ci<div class="sect2">
13685bd8deadSopenharmony_ci<h3 id="preprocessor">3.3. Preprocessor</h3>
13695bd8deadSopenharmony_ci<div class="paragraph">
13705bd8deadSopenharmony_ci<p>There is a preprocessor that processes the source strings as part of the
13715bd8deadSopenharmony_cicompilation process.
13725bd8deadSopenharmony_ciExcept as noted below, it behaves as the C++ standard preprocessor (see
13735bd8deadSopenharmony_ci&#8220;<a href="#references">Normative References</a>&#8221;).</p>
13745bd8deadSopenharmony_ci</div>
13755bd8deadSopenharmony_ci<div class="paragraph">
13765bd8deadSopenharmony_ci<p>The complete list of preprocessor directives is as follows.</p>
13775bd8deadSopenharmony_ci</div>
13785bd8deadSopenharmony_ci<div class="dlist">
13795bd8deadSopenharmony_ci<dl>
13805bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
13815bd8deadSopenharmony_ci<dd>
13825bd8deadSopenharmony_ci<p>#<br>
13835bd8deadSopenharmony_ci#define<br>
13845bd8deadSopenharmony_ci#undef<br></p>
13855bd8deadSopenharmony_ci</dd>
13865bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
13875bd8deadSopenharmony_ci<dd>
13885bd8deadSopenharmony_ci<p>#if<br>
13895bd8deadSopenharmony_ci#ifdef<br>
13905bd8deadSopenharmony_ci#ifndef<br>
13915bd8deadSopenharmony_ci#else<br>
13925bd8deadSopenharmony_ci#elif<br>
13935bd8deadSopenharmony_ci#endif<br></p>
13945bd8deadSopenharmony_ci</dd>
13955bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
13965bd8deadSopenharmony_ci<dd>
13975bd8deadSopenharmony_ci<p>#error<br>
13985bd8deadSopenharmony_ci#pragma<br></p>
13995bd8deadSopenharmony_ci</dd>
14005bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
14015bd8deadSopenharmony_ci<dd>
14025bd8deadSopenharmony_ci<p>#extension<br>
14035bd8deadSopenharmony_ci#version<br></p>
14045bd8deadSopenharmony_ci</dd>
14055bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
14065bd8deadSopenharmony_ci<dd>
14075bd8deadSopenharmony_ci<p>#line</p>
14085bd8deadSopenharmony_ci</dd>
14095bd8deadSopenharmony_ci</dl>
14105bd8deadSopenharmony_ci</div>
14115bd8deadSopenharmony_ci<div class="paragraph">
14125bd8deadSopenharmony_ci<p>The following
14135bd8deadSopenharmony_cioperators are
14145bd8deadSopenharmony_cialso available:</p>
14155bd8deadSopenharmony_ci</div>
14165bd8deadSopenharmony_ci<div class="dlist">
14175bd8deadSopenharmony_ci<dl>
14185bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
14195bd8deadSopenharmony_ci<dd>
14205bd8deadSopenharmony_ci<p>defined<br>
14215bd8deadSopenharmony_ci##</p>
14225bd8deadSopenharmony_ci</dd>
14235bd8deadSopenharmony_ci</dl>
14245bd8deadSopenharmony_ci</div>
14255bd8deadSopenharmony_ci<div class="paragraph">
14265bd8deadSopenharmony_ci<p>Each number sign (<strong>#</strong>) can be preceded in its line only by spaces or
14275bd8deadSopenharmony_cihorizontal tabs.
14285bd8deadSopenharmony_ciIt may also be followed by spaces and horizontal tabs, preceding the
14295bd8deadSopenharmony_cidirective.
14305bd8deadSopenharmony_ciEach directive is terminated by a new-line.
14315bd8deadSopenharmony_ciPreprocessing does not change the number or relative location of new-lines
14325bd8deadSopenharmony_ciin a source string.
14335bd8deadSopenharmony_ciPreprocessing takes places after new-lines have been removed by the
14345bd8deadSopenharmony_ciline-continuation character.</p>
14355bd8deadSopenharmony_ci</div>
14365bd8deadSopenharmony_ci<div class="paragraph">
14375bd8deadSopenharmony_ci<p>The number sign (<strong>#</strong>) on a line by itself is ignored.
14385bd8deadSopenharmony_ciAny directive not listed above will cause a compile-time error.</p>
14395bd8deadSopenharmony_ci</div>
14405bd8deadSopenharmony_ci<div class="paragraph">
14415bd8deadSopenharmony_ci<p><strong>#define</strong> and <strong>#undef</strong> functionality are defined as is standard for C++
14425bd8deadSopenharmony_cipreprocessors for macro definitions both with and without macro parameters.</p>
14435bd8deadSopenharmony_ci</div>
14445bd8deadSopenharmony_ci<div class="paragraph">
14455bd8deadSopenharmony_ci<p>The following predefined macros are available:</p>
14465bd8deadSopenharmony_ci</div>
14475bd8deadSopenharmony_ci<div class="dlist">
14485bd8deadSopenharmony_ci<dl>
14495bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
14505bd8deadSopenharmony_ci<dd>
14515bd8deadSopenharmony_ci<p>__LINE__<br>
14525bd8deadSopenharmony_ci__FILE__<br>
14535bd8deadSopenharmony_ci__VERSION__<br></p>
14545bd8deadSopenharmony_ci</dd>
14555bd8deadSopenharmony_ci</dl>
14565bd8deadSopenharmony_ci</div>
14575bd8deadSopenharmony_ci<div class="paragraph">
14585bd8deadSopenharmony_ci<p>__LINE__ will substitute a decimal integer constant that is one more than
14595bd8deadSopenharmony_cithe number of preceding new-lines in the current source string.</p>
14605bd8deadSopenharmony_ci</div>
14615bd8deadSopenharmony_ci<div class="paragraph">
14625bd8deadSopenharmony_ci<p>__FILE__ will substitute a decimal integer constant that says which source
14635bd8deadSopenharmony_cistring number is currently being processed.</p>
14645bd8deadSopenharmony_ci</div>
14655bd8deadSopenharmony_ci<div class="paragraph">
14665bd8deadSopenharmony_ci<p>__VERSION__ will substitute a decimal integer reflecting the version
14675bd8deadSopenharmony_cinumber of the OpenGL Shading Language.
14685bd8deadSopenharmony_ciThe version of the shading language described in this document will have
14695bd8deadSopenharmony_ci__VERSION__ substitute the decimal integer 460.</p>
14705bd8deadSopenharmony_ci</div>
14715bd8deadSopenharmony_ci<div class="paragraph">
14725bd8deadSopenharmony_ci<p>By convention, all macro names containing two consecutive underscores (__)
14735bd8deadSopenharmony_ciare reserved for use by underlying software layers.
14745bd8deadSopenharmony_ciDefining
14755bd8deadSopenharmony_cior undefining
14765bd8deadSopenharmony_cisuch a name in a shader does not itself result in an error, but may
14775bd8deadSopenharmony_ciresult in unintended behaviors that stem from having multiple definitions of
14785bd8deadSopenharmony_cithe same name.
14795bd8deadSopenharmony_ciAll macro names prefixed with &#8220;GL_&#8221; (&#8220;GL&#8221; followed by a single
14805bd8deadSopenharmony_ciunderscore) are also reserved, and defining
14815bd8deadSopenharmony_cior undefining
14825bd8deadSopenharmony_cisuch a name results in a compile-time error.</p>
14835bd8deadSopenharmony_ci</div>
14845bd8deadSopenharmony_ci<div class="paragraph">
14855bd8deadSopenharmony_ci<p>Implementations must support macro-name lengths of up to 1024 characters.
14865bd8deadSopenharmony_ciImplementations are allowed to generate an error for a macro name of length
14875bd8deadSopenharmony_cigreater than 1024 characters, but are also allowed to support lengths
14885bd8deadSopenharmony_cigreater than 1024.</p>
14895bd8deadSopenharmony_ci</div>
14905bd8deadSopenharmony_ci<div class="paragraph">
14915bd8deadSopenharmony_ci<p><strong>#if</strong>, <strong>#ifdef</strong>, <strong>#ifndef</strong>, <strong>#else</strong>, <strong>#elif</strong>, and <strong>#endif</strong> are defined to
14925bd8deadSopenharmony_cioperate as is standard for C++ preprocessors except for the following:</p>
14935bd8deadSopenharmony_ci</div>
14945bd8deadSopenharmony_ci<div class="ulist">
14955bd8deadSopenharmony_ci<ul>
14965bd8deadSopenharmony_ci<li>
14975bd8deadSopenharmony_ci<p>Expressions following <strong>#if</strong> and <strong>#elif</strong> are
14985bd8deadSopenharmony_cifurther restricted to
14995bd8deadSopenharmony_ciexpressions operating on literal integer constants, plus identifiers
15005bd8deadSopenharmony_ciconsumed by the <strong>defined</strong> operator.</p>
15015bd8deadSopenharmony_ci</li>
15025bd8deadSopenharmony_ci<li>
15035bd8deadSopenharmony_ci<p>Character constants are not supported.</p>
15045bd8deadSopenharmony_ci</li>
15055bd8deadSopenharmony_ci</ul>
15065bd8deadSopenharmony_ci</div>
15075bd8deadSopenharmony_ci<div class="paragraph">
15085bd8deadSopenharmony_ci<p>The operators available are as follows.</p>
15095bd8deadSopenharmony_ci</div>
15105bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
15115bd8deadSopenharmony_ci<colgroup>
15125bd8deadSopenharmony_ci<col style="width: 25%;">
15135bd8deadSopenharmony_ci<col style="width: 25%;">
15145bd8deadSopenharmony_ci<col style="width: 25%;">
15155bd8deadSopenharmony_ci<col style="width: 25%;">
15165bd8deadSopenharmony_ci</colgroup>
15175bd8deadSopenharmony_ci<thead>
15185bd8deadSopenharmony_ci<tr>
15195bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Precedence</th>
15205bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Operator class</th>
15215bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Operators</th>
15225bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Associativity</th>
15235bd8deadSopenharmony_ci</tr>
15245bd8deadSopenharmony_ci</thead>
15255bd8deadSopenharmony_ci<tbody>
15265bd8deadSopenharmony_ci<tr>
15275bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">1 (highest)</p></td>
15285bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">parenthetical grouping</p></td>
15295bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">( )</p></td>
15305bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">NA</p></td>
15315bd8deadSopenharmony_ci</tr>
15325bd8deadSopenharmony_ci<tr>
15335bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">2</p></td>
15345bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">unary</p></td>
15355bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">defined<br>
15365bd8deadSopenharmony_ci                                         + - ~ !</p></td>
15375bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Right to Left</p></td>
15385bd8deadSopenharmony_ci</tr>
15395bd8deadSopenharmony_ci<tr>
15405bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">3</p></td>
15415bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">multiplicative</p></td>
15425bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">* / %</p></td>
15435bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
15445bd8deadSopenharmony_ci</tr>
15455bd8deadSopenharmony_ci<tr>
15465bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">4</p></td>
15475bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">additive</p></td>
15485bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">+ -</p></td>
15495bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
15505bd8deadSopenharmony_ci</tr>
15515bd8deadSopenharmony_ci<tr>
15525bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">5</p></td>
15535bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bit-wise shift</p></td>
15545bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;&lt; &gt;&gt;</p></td>
15555bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
15565bd8deadSopenharmony_ci</tr>
15575bd8deadSopenharmony_ci<tr>
15585bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">6</p></td>
15595bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">relational</p></td>
15605bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">&lt; &gt; &lt;= &gt;=</p></td>
15615bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
15625bd8deadSopenharmony_ci</tr>
15635bd8deadSopenharmony_ci<tr>
15645bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">7</p></td>
15655bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">equality</p></td>
15665bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">== !=</p></td>
15675bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
15685bd8deadSopenharmony_ci</tr>
15695bd8deadSopenharmony_ci<tr>
15705bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">8</p></td>
15715bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bit-wise and</p></td>
15725bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">&amp;</p></td>
15735bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
15745bd8deadSopenharmony_ci</tr>
15755bd8deadSopenharmony_ci<tr>
15765bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">9</p></td>
15775bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bit-wise exclusive or</p></td>
15785bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">^</p></td>
15795bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
15805bd8deadSopenharmony_ci</tr>
15815bd8deadSopenharmony_ci<tr>
15825bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">10</p></td>
15835bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bit-wise inclusive or</p></td>
15845bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">|</p></td>
15855bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
15865bd8deadSopenharmony_ci</tr>
15875bd8deadSopenharmony_ci<tr>
15885bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">11</p></td>
15895bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">logical and</p></td>
15905bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">&amp;&amp;</p></td>
15915bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
15925bd8deadSopenharmony_ci</tr>
15935bd8deadSopenharmony_ci<tr>
15945bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">12 (lowest)</p></td>
15955bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">logical inclusive or</p></td>
15965bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">||</p></td>
15975bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
15985bd8deadSopenharmony_ci</tr>
15995bd8deadSopenharmony_ci</tbody>
16005bd8deadSopenharmony_ci</table>
16015bd8deadSopenharmony_ci<div class="paragraph">
16025bd8deadSopenharmony_ci<p>The <strong>defined</strong> operator can be used in either of the following ways:</p>
16035bd8deadSopenharmony_ci</div>
16045bd8deadSopenharmony_ci<div class="listingblock">
16055bd8deadSopenharmony_ci<div class="content">
16065bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">defined identifier
16075bd8deadSopenharmony_cidefined ( identifier )</code></pre>
16085bd8deadSopenharmony_ci</div>
16095bd8deadSopenharmony_ci</div>
16105bd8deadSopenharmony_ci<div class="paragraph">
16115bd8deadSopenharmony_ci<p>Two tokens in a macro can be concatenated into one token using the token
16125bd8deadSopenharmony_cipasting (<strong>##</strong>) operator, as is standard for C++ preprocessors.
16135bd8deadSopenharmony_ciThe result must be a valid single token, which will then be subject to macro
16145bd8deadSopenharmony_ciexpansion.
16155bd8deadSopenharmony_ciThat is, macro expansion happens only after token pasting.
16165bd8deadSopenharmony_ciThere are no other number sign based operators (e.g. no <strong>#</strong> or <strong>#@</strong>), nor is
16175bd8deadSopenharmony_cithere a <strong>sizeof</strong> operator.</p>
16185bd8deadSopenharmony_ci</div>
16195bd8deadSopenharmony_ci<div class="paragraph">
16205bd8deadSopenharmony_ci<p>The semantics of applying operators to integer literals in the preprocessor
16215bd8deadSopenharmony_cimatch those standard in the C++ preprocessor, not those in the OpenGL Shading Language.</p>
16225bd8deadSopenharmony_ci</div>
16235bd8deadSopenharmony_ci<div class="paragraph">
16245bd8deadSopenharmony_ci<p>Preprocessor expressions will be evaluated according to the behavior of the
16255bd8deadSopenharmony_cihost processor, not the processor targeted by the shader.</p>
16265bd8deadSopenharmony_ci</div>
16275bd8deadSopenharmony_ci<div class="paragraph">
16285bd8deadSopenharmony_ci<p><strong>#error</strong> will cause the implementation to put a compile-time diagnostic message
16295bd8deadSopenharmony_ciinto the shader object&#8217;s information log (see section 7.12 &#8220;Shader, Program
16305bd8deadSopenharmony_ciand Program Pipeline Queries&#8221; of the <a href="#references">OpenGL Specification</a> for how to
16315bd8deadSopenharmony_ciaccess a shader object&#8217;s information log).
16325bd8deadSopenharmony_ciThe message will be the tokens following the <strong>#error</strong> directive, up to the
16335bd8deadSopenharmony_cifirst new-line.
16345bd8deadSopenharmony_ciThe implementation must treat the presence of a <strong>#error</strong> directive as a
16355bd8deadSopenharmony_cicompile-time error.</p>
16365bd8deadSopenharmony_ci</div>
16375bd8deadSopenharmony_ci<div class="paragraph">
16385bd8deadSopenharmony_ci<p><strong>#pragma</strong> allows implementation-dependent compiler control.
16395bd8deadSopenharmony_ciTokens following <strong>#pragma</strong> are not subject to preprocessor macro expansion.
16405bd8deadSopenharmony_ciIf an implementation does not recognize the tokens following <strong>#pragma</strong>, then
16415bd8deadSopenharmony_ciit will ignore that pragma.
16425bd8deadSopenharmony_ciThe following pragmas are defined as part of the language.</p>
16435bd8deadSopenharmony_ci</div>
16445bd8deadSopenharmony_ci<div class="listingblock">
16455bd8deadSopenharmony_ci<div class="content">
16465bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="preprocessor">#pragma</span> STDGL</code></pre>
16475bd8deadSopenharmony_ci</div>
16485bd8deadSopenharmony_ci</div>
16495bd8deadSopenharmony_ci<div class="paragraph">
16505bd8deadSopenharmony_ci<p>The <strong>STDGL</strong> pragma is used to reserve pragmas for use by future revisions of
16515bd8deadSopenharmony_cithis language.
16525bd8deadSopenharmony_ciNo implementation may use a pragma whose first token is <strong>STDGL</strong>.</p>
16535bd8deadSopenharmony_ci</div>
16545bd8deadSopenharmony_ci<div class="listingblock">
16555bd8deadSopenharmony_ci<div class="content">
16565bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="preprocessor">#pragma</span> optimize(on)
16575bd8deadSopenharmony_ci<span class="preprocessor">#pragma</span> optimize(off)</code></pre>
16585bd8deadSopenharmony_ci</div>
16595bd8deadSopenharmony_ci</div>
16605bd8deadSopenharmony_ci<div class="paragraph">
16615bd8deadSopenharmony_ci<p>can be used to turn off optimizations as an aid in developing and debugging
16625bd8deadSopenharmony_cishaders.
16635bd8deadSopenharmony_ciIt can only be used outside function definitions.
16645bd8deadSopenharmony_ciBy default, optimization is turned on for all shaders.
16655bd8deadSopenharmony_ciThe debug pragma</p>
16665bd8deadSopenharmony_ci</div>
16675bd8deadSopenharmony_ci<div class="listingblock">
16685bd8deadSopenharmony_ci<div class="content">
16695bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="preprocessor">#pragma</span> debug(on)
16705bd8deadSopenharmony_ci<span class="preprocessor">#pragma</span> debug(off)</code></pre>
16715bd8deadSopenharmony_ci</div>
16725bd8deadSopenharmony_ci</div>
16735bd8deadSopenharmony_ci<div class="paragraph">
16745bd8deadSopenharmony_ci<p>can be used to enable compiling and annotating a shader with debug
16755bd8deadSopenharmony_ciinformation, so that it can be used with a debugger.
16765bd8deadSopenharmony_ciIt can only be used outside function definitions.
16775bd8deadSopenharmony_ciBy default, debug is turned off.</p>
16785bd8deadSopenharmony_ci</div>
16795bd8deadSopenharmony_ci<div class="paragraph">
16805bd8deadSopenharmony_ci<p>Shaders should declare the version of the language they are written to.
16815bd8deadSopenharmony_ciThe language version a shader is written to is specified by</p>
16825bd8deadSopenharmony_ci</div>
16835bd8deadSopenharmony_ci<div class="listingblock">
16845bd8deadSopenharmony_ci<div class="content">
16855bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="preprocessor">#version</span> number profile_opt</code></pre>
16865bd8deadSopenharmony_ci</div>
16875bd8deadSopenharmony_ci</div>
16885bd8deadSopenharmony_ci<div class="paragraph">
16895bd8deadSopenharmony_ci<p>where <em>number</em> must be a version of the language, following the same
16905bd8deadSopenharmony_ciconvention as __VERSION__ above.
16915bd8deadSopenharmony_ciThe directive &#8220;<strong>#version 460</strong>&#8221; is required in any shader that
16925bd8deadSopenharmony_ciuses version 4.60 of the language.
16935bd8deadSopenharmony_ciAny <em>number</em> representing a version of the language a compiler does not
16945bd8deadSopenharmony_cisupport will cause a compile-time error to be generated.
16955bd8deadSopenharmony_ciVersion 1.10 of the language does not require shaders to include this
16965bd8deadSopenharmony_cidirective, and shaders that do not include a <strong>#version</strong> directive will be
16975bd8deadSopenharmony_citreated as targeting version 1.10.
16985bd8deadSopenharmony_ciShaders that specify <strong>#version</strong> 100 will be treated as targeting version
16995bd8deadSopenharmony_ci1.00 of the OpenGL ES Shading Language.
17005bd8deadSopenharmony_ciShaders that specify <strong>#version</strong> 300 will be treated as targeting version
17015bd8deadSopenharmony_ci3.00 of the OpenGL ES Shading Language.
17025bd8deadSopenharmony_ciShaders that specify <strong>#version</strong> 310 will be treated as targeting version
17035bd8deadSopenharmony_ci3.10 of the OpenGL ES Shading Language.</p>
17045bd8deadSopenharmony_ci</div>
17055bd8deadSopenharmony_ci<div class="paragraph">
17065bd8deadSopenharmony_ci<p>If the optional <em>profile</em> argument is provided, it must be the name of an
17075bd8deadSopenharmony_ciOpenGL profile.
17085bd8deadSopenharmony_ciCurrently, there are three choices:</p>
17095bd8deadSopenharmony_ci</div>
17105bd8deadSopenharmony_ci<div class="listingblock">
17115bd8deadSopenharmony_ci<div class="content">
17125bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">core
17135bd8deadSopenharmony_cicompatibility
17145bd8deadSopenharmony_cies</code></pre>
17155bd8deadSopenharmony_ci</div>
17165bd8deadSopenharmony_ci</div>
17175bd8deadSopenharmony_ci<div class="paragraph">
17185bd8deadSopenharmony_ci<p>A <em>profile</em> argument can only be used with version 150 or greater.
17195bd8deadSopenharmony_ciIf no profile argument is provided and the version is 150 or greater, the
17205bd8deadSopenharmony_cidefault is <strong>core</strong>.
17215bd8deadSopenharmony_ciIf version 300 or 310 is specified, the profile argument is not optional and
17225bd8deadSopenharmony_cimust be <strong>es</strong>, or a compile-time error results.
17235bd8deadSopenharmony_ciThe Language Specification for the <strong>es</strong> profile is specified in The OpenGL
17245bd8deadSopenharmony_ciES Shading Language specification.</p>
17255bd8deadSopenharmony_ci</div>
17265bd8deadSopenharmony_ci<div class="paragraph">
17275bd8deadSopenharmony_ci<p>Shaders for the <strong>core</strong> or <strong>compatibility</strong> profiles that declare different
17285bd8deadSopenharmony_civersions can be linked together.
17295bd8deadSopenharmony_ciHowever, <strong>es</strong> profile shaders cannot be linked with non-<strong>es</strong> profile shaders
17305bd8deadSopenharmony_cior with <strong>es</strong> profile shaders of a different version, or a link-time error
17315bd8deadSopenharmony_ciwill result.
17325bd8deadSopenharmony_ciWhen linking shaders of versions allowed by these rules, remaining link-time
17335bd8deadSopenharmony_cierrors will be given as per the linking rules in the GLSL version
17345bd8deadSopenharmony_cicorresponding to the version of the context the shaders are linked under.
17355bd8deadSopenharmony_ciShader compile-time errors must still be given strictly based on the version
17365bd8deadSopenharmony_cideclared (or defaulted to) within each shader.</p>
17375bd8deadSopenharmony_ci</div>
17385bd8deadSopenharmony_ci<div class="paragraph">
17395bd8deadSopenharmony_ci<p>Unless otherwise specified, this specification is documenting the core
17405bd8deadSopenharmony_ciprofile, and everything specified for the core profile is also available in
17415bd8deadSopenharmony_cithe compatibility profile.
17425bd8deadSopenharmony_ciFeatures specified as belonging specifically to the compatibility profile
17435bd8deadSopenharmony_ciare not available in the core profile.
17445bd8deadSopenharmony_ciCompatibility-profile features are not available when generating SPIR-V.</p>
17455bd8deadSopenharmony_ci</div>
17465bd8deadSopenharmony_ci<div class="paragraph">
17475bd8deadSopenharmony_ci<p>There is a built-in macro definition for each profile the implementation
17485bd8deadSopenharmony_cisupports.
17495bd8deadSopenharmony_ciAll implementations provide the following macro:</p>
17505bd8deadSopenharmony_ci</div>
17515bd8deadSopenharmony_ci<div class="listingblock">
17525bd8deadSopenharmony_ci<div class="content">
17535bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="preprocessor">#define</span> GL_core_profile <span class="integer">1</span></code></pre>
17545bd8deadSopenharmony_ci</div>
17555bd8deadSopenharmony_ci</div>
17565bd8deadSopenharmony_ci<div class="paragraph">
17575bd8deadSopenharmony_ci<p>Implementations providing the <strong>compatibility</strong> profile provide the following
17585bd8deadSopenharmony_cimacro:</p>
17595bd8deadSopenharmony_ci</div>
17605bd8deadSopenharmony_ci<div class="listingblock">
17615bd8deadSopenharmony_ci<div class="content">
17625bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="preprocessor">#define</span> GL_compatibility_profile <span class="integer">1</span></code></pre>
17635bd8deadSopenharmony_ci</div>
17645bd8deadSopenharmony_ci</div>
17655bd8deadSopenharmony_ci<div class="paragraph">
17665bd8deadSopenharmony_ci<p>Implementations providing the <strong>es</strong> profile provide the following macro:</p>
17675bd8deadSopenharmony_ci</div>
17685bd8deadSopenharmony_ci<div class="listingblock">
17695bd8deadSopenharmony_ci<div class="content">
17705bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="preprocessor">#define</span> GL_es_profile <span class="integer">1</span></code></pre>
17715bd8deadSopenharmony_ci</div>
17725bd8deadSopenharmony_ci</div>
17735bd8deadSopenharmony_ci<div class="paragraph">
17745bd8deadSopenharmony_ci<p>The <strong>#version</strong> directive must occur in a shader before anything else, except
17755bd8deadSopenharmony_cifor comments and white space.</p>
17765bd8deadSopenharmony_ci</div>
17775bd8deadSopenharmony_ci<div class="paragraph">
17785bd8deadSopenharmony_ci<p>By default, compilers of this language must issue compile-time
17795bd8deadSopenharmony_cilexical
17805bd8deadSopenharmony_ciand
17815bd8deadSopenharmony_cigrammatical errors for shaders that do not conform to this specification.
17825bd8deadSopenharmony_ciAny extended behavior must first be enabled.
17835bd8deadSopenharmony_ciDirectives to control the behavior of the compiler with respect to
17845bd8deadSopenharmony_ciextensions are declared with the <strong>#extension</strong> directive</p>
17855bd8deadSopenharmony_ci</div>
17865bd8deadSopenharmony_ci<div class="listingblock">
17875bd8deadSopenharmony_ci<div class="content">
17885bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="preprocessor">#extension</span> extension_name : behavior
17895bd8deadSopenharmony_ci<span class="preprocessor">#extension</span> all : behavior</code></pre>
17905bd8deadSopenharmony_ci</div>
17915bd8deadSopenharmony_ci</div>
17925bd8deadSopenharmony_ci<div class="paragraph">
17935bd8deadSopenharmony_ci<p>where <em>extension_name</em> is the name of an extension.
17945bd8deadSopenharmony_ciExtension names are not documented in this specification.
17955bd8deadSopenharmony_ciThe token <strong>all</strong> means the behavior applies to all extensions supported by
17965bd8deadSopenharmony_cithe compiler.
17975bd8deadSopenharmony_ciThe <em>behavior</em> can be one of the following:</p>
17985bd8deadSopenharmony_ci</div>
17995bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
18005bd8deadSopenharmony_ci<colgroup>
18015bd8deadSopenharmony_ci<col style="width: 50%;">
18025bd8deadSopenharmony_ci<col style="width: 50%;">
18035bd8deadSopenharmony_ci</colgroup>
18045bd8deadSopenharmony_ci<thead>
18055bd8deadSopenharmony_ci<tr>
18065bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Behavior</th>
18075bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Effect</th>
18085bd8deadSopenharmony_ci</tr>
18095bd8deadSopenharmony_ci</thead>
18105bd8deadSopenharmony_ci<tbody>
18115bd8deadSopenharmony_ci<tr>
18125bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>require</strong></p></td>
18135bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Behave as specified by the extension <em>extension_name</em>.<br>
18145bd8deadSopenharmony_ci              Give a compile-time error on the <strong>#extension</strong> if the extension
18155bd8deadSopenharmony_ci              <em>extension_name</em> is not supported, or if <strong>all</strong> is specified.</p></td>
18165bd8deadSopenharmony_ci</tr>
18175bd8deadSopenharmony_ci<tr>
18185bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>enable</strong></p></td>
18195bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Behave as specified by the extension <em>extension_name</em>.<br>
18205bd8deadSopenharmony_ci              Warn on the <strong>#extension</strong> if the extension <em>extension_name</em> is
18215bd8deadSopenharmony_ci              not supported.<br>
18225bd8deadSopenharmony_ci              Give a compile-time error on the <strong>#extension</strong> if <strong>all</strong> is
18235bd8deadSopenharmony_ci              specified.</p></td>
18245bd8deadSopenharmony_ci</tr>
18255bd8deadSopenharmony_ci<tr>
18265bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>warn</strong></p></td>
18275bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Behave as specified by the extension <em>extension_name</em>,
18285bd8deadSopenharmony_ci              except issue warnings on any detectable use of that extension,
18295bd8deadSopenharmony_ci              unless such use is supported by other enabled or required
18305bd8deadSopenharmony_ci              extensions.<br>
18315bd8deadSopenharmony_ci              If <strong>all</strong> is specified, then warn on all detectable uses of any
18325bd8deadSopenharmony_ci              extension used.<br>
18335bd8deadSopenharmony_ci              Warn on the <strong>#extension</strong> if the extension <em>extension_name</em> is
18345bd8deadSopenharmony_ci              not supported.</p></td>
18355bd8deadSopenharmony_ci</tr>
18365bd8deadSopenharmony_ci<tr>
18375bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>disable</strong></p></td>
18385bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Behave (including issuing errors and warnings) as if the
18395bd8deadSopenharmony_ci              extension <em>extension_name</em> is not part of the language
18405bd8deadSopenharmony_ci              definition.<br>
18415bd8deadSopenharmony_ci              If <strong>all</strong> is specified, then behavior must revert back to that
18425bd8deadSopenharmony_ci              of the non-extended core version of the language being
18435bd8deadSopenharmony_ci              compiled to.<br>
18445bd8deadSopenharmony_ci              Warn on the <strong>#extension</strong> if the extension <em>extension_name</em> is
18455bd8deadSopenharmony_ci              not supported.</p></td>
18465bd8deadSopenharmony_ci</tr>
18475bd8deadSopenharmony_ci</tbody>
18485bd8deadSopenharmony_ci</table>
18495bd8deadSopenharmony_ci<div class="paragraph">
18505bd8deadSopenharmony_ci<p>The <strong>extension</strong> directive is a simple, low-level mechanism to set the
18515bd8deadSopenharmony_cibehavior for each extension.
18525bd8deadSopenharmony_ciIt does not define policies such as which combinations are appropriate,
18535bd8deadSopenharmony_cithose must be defined elsewhere.
18545bd8deadSopenharmony_ciOrder of directives matters in setting the behavior for each extension:
18555bd8deadSopenharmony_ciDirectives that occur later override those seen earlier.
18565bd8deadSopenharmony_ciThe <strong>all</strong> variant sets the behavior for all extensions, overriding all
18575bd8deadSopenharmony_cipreviously issued <strong>extension</strong> directives, but only for the <em>behaviors</em>
18585bd8deadSopenharmony_ci<strong>warn</strong> and <strong>disable</strong>.</p>
18595bd8deadSopenharmony_ci</div>
18605bd8deadSopenharmony_ci<div class="paragraph">
18615bd8deadSopenharmony_ci<p>The initial state of the compiler is as if the directive</p>
18625bd8deadSopenharmony_ci</div>
18635bd8deadSopenharmony_ci<div class="listingblock">
18645bd8deadSopenharmony_ci<div class="content">
18655bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="preprocessor">#extension</span> all : disable</code></pre>
18665bd8deadSopenharmony_ci</div>
18675bd8deadSopenharmony_ci</div>
18685bd8deadSopenharmony_ci<div class="paragraph">
18695bd8deadSopenharmony_ci<p>was issued, telling the compiler that all error and warning reporting must
18705bd8deadSopenharmony_cibe done according to this specification, ignoring any extensions.</p>
18715bd8deadSopenharmony_ci</div>
18725bd8deadSopenharmony_ci<div class="paragraph">
18735bd8deadSopenharmony_ci<p>Each extension can define its allowed granularity of scope.
18745bd8deadSopenharmony_ciIf nothing is said, the granularity is a shader (that is, a single
18755bd8deadSopenharmony_cicompilation unit), and the extension directives must occur before any
18765bd8deadSopenharmony_cinon-preprocessor tokens.
18775bd8deadSopenharmony_ciIf necessary, the linker can enforce granularities larger than a single
18785bd8deadSopenharmony_cicompilation unit, in which case each involved shader will have to contain
18795bd8deadSopenharmony_cithe necessary extension directive.</p>
18805bd8deadSopenharmony_ci</div>
18815bd8deadSopenharmony_ci<div class="paragraph">
18825bd8deadSopenharmony_ci<p>Macro expansion is not done on lines containing <strong>#extension</strong> and <strong>#version</strong>
18835bd8deadSopenharmony_cidirectives.</p>
18845bd8deadSopenharmony_ci</div>
18855bd8deadSopenharmony_ci<div class="paragraph">
18865bd8deadSopenharmony_ci<p><strong>#line</strong> must have, after macro substitution, one of the following forms:</p>
18875bd8deadSopenharmony_ci</div>
18885bd8deadSopenharmony_ci<div class="listingblock">
18895bd8deadSopenharmony_ci<div class="content">
18905bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="preprocessor">#line</span> line
18915bd8deadSopenharmony_ci<span class="preprocessor">#line</span> line source-<span class="predefined-type">string</span>-number</code></pre>
18925bd8deadSopenharmony_ci</div>
18935bd8deadSopenharmony_ci</div>
18945bd8deadSopenharmony_ci<div class="paragraph">
18955bd8deadSopenharmony_ci<p>where <em>line</em> and <em>source-string-number</em> are
18965bd8deadSopenharmony_ciconstant integer expressions.
18975bd8deadSopenharmony_ciIf these constant expressions are not integer literals then behavior is undefined.
18985bd8deadSopenharmony_ciAfter processing this directive (including its new-line), the implementation
18995bd8deadSopenharmony_ciwill behave as if it is compiling at line number <em>line</em> and source string
19005bd8deadSopenharmony_cinumber <em>source-string-number</em>.
19015bd8deadSopenharmony_ciSubsequent source strings will be numbered sequentially, until another
19025bd8deadSopenharmony_ci<strong>#line</strong> directive overrides that numbering.</p>
19035bd8deadSopenharmony_ci</div>
19045bd8deadSopenharmony_ci<div class="admonitionblock note">
19055bd8deadSopenharmony_ci<table>
19065bd8deadSopenharmony_ci<tr>
19075bd8deadSopenharmony_ci<td class="icon">
19085bd8deadSopenharmony_ci<i class="fa icon-note" title="Note"></i>
19095bd8deadSopenharmony_ci</td>
19105bd8deadSopenharmony_ci<td class="content">
19115bd8deadSopenharmony_ci<div class="title">Note</div>
19125bd8deadSopenharmony_ci<div class="paragraph">
19135bd8deadSopenharmony_ci<p>Some implementations have allowed constant expressions in #line directives and
19145bd8deadSopenharmony_cisome have not. Even where expressions are supported the grammar is ambiguous and so
19155bd8deadSopenharmony_ciresults are implementation dependent. For example,
19165bd8deadSopenharmony_ci+ #line +2 +2               // Line number set to 4, or file to 2 and line to 2</p>
19175bd8deadSopenharmony_ci</div>
19185bd8deadSopenharmony_ci</td>
19195bd8deadSopenharmony_ci</tr>
19205bd8deadSopenharmony_ci</table>
19215bd8deadSopenharmony_ci</div>
19225bd8deadSopenharmony_ci<div class="paragraph">
19235bd8deadSopenharmony_ci<p>When shaders are compiled for OpenGL SPIR-V, the following predefined
19245bd8deadSopenharmony_cimacro is available:</p>
19255bd8deadSopenharmony_ci</div>
19265bd8deadSopenharmony_ci<div class="listingblock">
19275bd8deadSopenharmony_ci<div class="content">
19285bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="preprocessor">#define</span> GL_SPIRV <span class="integer">100</span></code></pre>
19295bd8deadSopenharmony_ci</div>
19305bd8deadSopenharmony_ci</div>
19315bd8deadSopenharmony_ci<div class="paragraph">
19325bd8deadSopenharmony_ci<p>When targeting Vulkan, the following predefined macro is available:</p>
19335bd8deadSopenharmony_ci</div>
19345bd8deadSopenharmony_ci<div class="listingblock">
19355bd8deadSopenharmony_ci<div class="content">
19365bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="preprocessor">#define</span> VULKAN <span class="integer">100</span></code></pre>
19375bd8deadSopenharmony_ci</div>
19385bd8deadSopenharmony_ci</div>
19395bd8deadSopenharmony_ci</div>
19405bd8deadSopenharmony_ci<div class="sect2">
19415bd8deadSopenharmony_ci<h3 id="comments">3.4. Comments</h3>
19425bd8deadSopenharmony_ci<div class="paragraph">
19435bd8deadSopenharmony_ci<p>Comments are delimited by <strong>/*</strong> and <strong>*/</strong>, or by <strong>//</strong> and a new-line.
19445bd8deadSopenharmony_ciThe begin comment delimiters (/* or //) are not recognized as comment
19455bd8deadSopenharmony_cidelimiters inside of a comment, hence comments cannot be nested.
19465bd8deadSopenharmony_ciA <strong>/*</strong> comment includes its terminating delimiter (*/).
19475bd8deadSopenharmony_ciHowever, a <strong>//</strong> comment does not include (or eliminate) its terminating new
19485bd8deadSopenharmony_ciline.</p>
19495bd8deadSopenharmony_ci</div>
19505bd8deadSopenharmony_ci<div class="paragraph">
19515bd8deadSopenharmony_ci<p>Inside comments, any byte values may be used, except a byte whose value is
19525bd8deadSopenharmony_ci0.
19535bd8deadSopenharmony_ciNo errors will be given for the content of comments and no validation on the
19545bd8deadSopenharmony_cicontent of comments need be done.</p>
19555bd8deadSopenharmony_ci</div>
19565bd8deadSopenharmony_ci<div class="paragraph">
19575bd8deadSopenharmony_ci<p>Removal of new-lines by the line-continuation character (<strong>\</strong>) logically
19585bd8deadSopenharmony_cioccurs before comments are processed.
19595bd8deadSopenharmony_ciThat is, a single-line comment ending in the line-continuation character
19605bd8deadSopenharmony_ci(<strong>\</strong>) includes the next line in the comment.</p>
19615bd8deadSopenharmony_ci</div>
19625bd8deadSopenharmony_ci<div class="listingblock">
19635bd8deadSopenharmony_ci<div class="content">
19645bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="comment">// a single-line comment containing the next line \
19655bd8deadSopenharmony_cia = b; // this is still in the first comment</span></code></pre>
19665bd8deadSopenharmony_ci</div>
19675bd8deadSopenharmony_ci</div>
19685bd8deadSopenharmony_ci</div>
19695bd8deadSopenharmony_ci<div class="sect2">
19705bd8deadSopenharmony_ci<h3 id="tokens">3.5. Tokens</h3>
19715bd8deadSopenharmony_ci<div class="paragraph">
19725bd8deadSopenharmony_ci<p>The language, after preprocessing, is a sequence of tokens.
19735bd8deadSopenharmony_ciA token can be</p>
19745bd8deadSopenharmony_ci</div>
19755bd8deadSopenharmony_ci<div class="openblock bnf">
19765bd8deadSopenharmony_ci<div class="content">
19775bd8deadSopenharmony_ci<div class="dlist">
19785bd8deadSopenharmony_ci<dl>
19795bd8deadSopenharmony_ci<dt class="hdlist1"><em>token</em> : </dt>
19805bd8deadSopenharmony_ci<dd>
19815bd8deadSopenharmony_ci<p><em>keyword</em><br>
19825bd8deadSopenharmony_ci<em>identifier</em><br>
19835bd8deadSopenharmony_ci<em>integer-constant</em><br>
19845bd8deadSopenharmony_ci<em>floating-constant</em><br>
19855bd8deadSopenharmony_ci<em>operator</em><br>
19865bd8deadSopenharmony_ci<strong>;</strong> <strong>{</strong> <strong>}</strong></p>
19875bd8deadSopenharmony_ci</dd>
19885bd8deadSopenharmony_ci</dl>
19895bd8deadSopenharmony_ci</div>
19905bd8deadSopenharmony_ci</div>
19915bd8deadSopenharmony_ci</div>
19925bd8deadSopenharmony_ci</div>
19935bd8deadSopenharmony_ci<div class="sect2">
19945bd8deadSopenharmony_ci<h3 id="keywords">3.6. Keywords</h3>
19955bd8deadSopenharmony_ci<div class="paragraph">
19965bd8deadSopenharmony_ci<p>The following are the keywords in the language and (after
19975bd8deadSopenharmony_cipreprocessing) can only be used as described in this specification,
19985bd8deadSopenharmony_cior a compile-time error results:</p>
19995bd8deadSopenharmony_ci</div>
20005bd8deadSopenharmony_ci<div class="dlist">
20015bd8deadSopenharmony_ci<dl>
20025bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20035bd8deadSopenharmony_ci<dd>
20045bd8deadSopenharmony_ci<p><strong>const</strong> <strong>uniform</strong> <strong>buffer</strong> <strong>shared</strong>
20055bd8deadSopenharmony_ci<strong>attribute</strong> <strong>varying</strong></p>
20065bd8deadSopenharmony_ci</dd>
20075bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20085bd8deadSopenharmony_ci<dd>
20095bd8deadSopenharmony_ci<p><strong>coherent</strong> <strong>volatile</strong> <strong>restrict</strong> <strong>readonly</strong> <strong>writeonly</strong></p>
20105bd8deadSopenharmony_ci</dd>
20115bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20125bd8deadSopenharmony_ci<dd>
20135bd8deadSopenharmony_ci<p><strong>atomic_uint</strong></p>
20145bd8deadSopenharmony_ci</dd>
20155bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20165bd8deadSopenharmony_ci<dd>
20175bd8deadSopenharmony_ci<p><strong>layout</strong></p>
20185bd8deadSopenharmony_ci</dd>
20195bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20205bd8deadSopenharmony_ci<dd>
20215bd8deadSopenharmony_ci<p><strong>centroid</strong> <strong>flat</strong> <strong>smooth</strong>
20225bd8deadSopenharmony_ci<strong>noperspective</strong></p>
20235bd8deadSopenharmony_ci</dd>
20245bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20255bd8deadSopenharmony_ci<dd>
20265bd8deadSopenharmony_ci<p><strong>patch</strong> <strong>sample</strong></p>
20275bd8deadSopenharmony_ci</dd>
20285bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20295bd8deadSopenharmony_ci<dd>
20305bd8deadSopenharmony_ci<p><strong>invariant</strong> <strong>precise</strong></p>
20315bd8deadSopenharmony_ci</dd>
20325bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20335bd8deadSopenharmony_ci<dd>
20345bd8deadSopenharmony_ci<p><strong>break</strong> <strong>continue</strong> <strong>do</strong> <strong>for</strong> <strong>while</strong> <strong>switch</strong> <strong>case</strong> <strong>default</strong></p>
20355bd8deadSopenharmony_ci</dd>
20365bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20375bd8deadSopenharmony_ci<dd>
20385bd8deadSopenharmony_ci<p><strong>if</strong> <strong>else</strong></p>
20395bd8deadSopenharmony_ci</dd>
20405bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20415bd8deadSopenharmony_ci<dd>
20425bd8deadSopenharmony_ci<p><strong>subroutine</strong></p>
20435bd8deadSopenharmony_ci</dd>
20445bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20455bd8deadSopenharmony_ci<dd>
20465bd8deadSopenharmony_ci<p><strong>in</strong> <strong>out</strong> <strong>inout</strong></p>
20475bd8deadSopenharmony_ci</dd>
20485bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20495bd8deadSopenharmony_ci<dd>
20505bd8deadSopenharmony_ci<p><strong>int</strong> <strong>void</strong> <strong>bool</strong> <strong>true</strong> <strong>false</strong> <strong>float</strong>
20515bd8deadSopenharmony_ci<strong>double</strong></p>
20525bd8deadSopenharmony_ci</dd>
20535bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20545bd8deadSopenharmony_ci<dd>
20555bd8deadSopenharmony_ci<p><strong>discard</strong> <strong>return</strong></p>
20565bd8deadSopenharmony_ci</dd>
20575bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20585bd8deadSopenharmony_ci<dd>
20595bd8deadSopenharmony_ci<p><strong>vec2</strong> <strong>vec3</strong> <strong>vec4</strong> <strong>ivec2</strong> <strong>ivec3</strong> <strong>ivec4</strong> <strong>bvec2</strong> <strong>bvec3</strong> <strong>bvec4</strong></p>
20605bd8deadSopenharmony_ci</dd>
20615bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20625bd8deadSopenharmony_ci<dd>
20635bd8deadSopenharmony_ci<p><strong>uint</strong> <strong>uvec2</strong> <strong>uvec3</strong> <strong>uvec4</strong></p>
20645bd8deadSopenharmony_ci</dd>
20655bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20665bd8deadSopenharmony_ci<dd>
20675bd8deadSopenharmony_ci<p><strong>dvec2</strong> <strong>dvec3</strong> <strong>dvec4</strong></p>
20685bd8deadSopenharmony_ci</dd>
20695bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20705bd8deadSopenharmony_ci<dd>
20715bd8deadSopenharmony_ci<p><strong>mat2</strong> <strong>mat3</strong> <strong>mat4</strong></p>
20725bd8deadSopenharmony_ci</dd>
20735bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20745bd8deadSopenharmony_ci<dd>
20755bd8deadSopenharmony_ci<p><strong>mat2x2</strong> <strong>mat2x3</strong> <strong>mat2x4</strong></p>
20765bd8deadSopenharmony_ci</dd>
20775bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20785bd8deadSopenharmony_ci<dd>
20795bd8deadSopenharmony_ci<p><strong>mat3x2</strong> <strong>mat3x3</strong> <strong>mat3x4</strong></p>
20805bd8deadSopenharmony_ci</dd>
20815bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20825bd8deadSopenharmony_ci<dd>
20835bd8deadSopenharmony_ci<p><strong>mat4x2</strong> <strong>mat4x3</strong> <strong>mat4x4</strong></p>
20845bd8deadSopenharmony_ci</dd>
20855bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20865bd8deadSopenharmony_ci<dd>
20875bd8deadSopenharmony_ci<p><strong>dmat2</strong> <strong>dmat3</strong> <strong>dmat4</strong></p>
20885bd8deadSopenharmony_ci</dd>
20895bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20905bd8deadSopenharmony_ci<dd>
20915bd8deadSopenharmony_ci<p><strong>dmat2x2</strong> <strong>dmat2x3</strong> <strong>dmat2x4</strong></p>
20925bd8deadSopenharmony_ci</dd>
20935bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20945bd8deadSopenharmony_ci<dd>
20955bd8deadSopenharmony_ci<p><strong>dmat3x2</strong> <strong>dmat3x3</strong> <strong>dmat3x4</strong></p>
20965bd8deadSopenharmony_ci</dd>
20975bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
20985bd8deadSopenharmony_ci<dd>
20995bd8deadSopenharmony_ci<p><strong>dmat4x2</strong> <strong>dmat4x3</strong> <strong>dmat4x4</strong></p>
21005bd8deadSopenharmony_ci</dd>
21015bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21025bd8deadSopenharmony_ci<dd>
21035bd8deadSopenharmony_ci<p><strong>lowp</strong> <strong>mediump</strong> <strong>highp</strong> <strong>precision</strong></p>
21045bd8deadSopenharmony_ci</dd>
21055bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21065bd8deadSopenharmony_ci<dd>
21075bd8deadSopenharmony_ci<p><strong>sampler1D</strong> <strong>sampler1DShadow</strong> <strong>sampler1DArray</strong> <strong>sampler1DArrayShadow</strong></p>
21085bd8deadSopenharmony_ci</dd>
21095bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21105bd8deadSopenharmony_ci<dd>
21115bd8deadSopenharmony_ci<p><strong>isampler1D</strong> <strong>isampler1DArray</strong> <strong>usampler1D</strong> <strong>usampler1DArray</strong></p>
21125bd8deadSopenharmony_ci</dd>
21135bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21145bd8deadSopenharmony_ci<dd>
21155bd8deadSopenharmony_ci<p><strong>sampler2D</strong> <strong>sampler2DShadow</strong> <strong>sampler2DArray</strong> <strong>sampler2DArrayShadow</strong></p>
21165bd8deadSopenharmony_ci</dd>
21175bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21185bd8deadSopenharmony_ci<dd>
21195bd8deadSopenharmony_ci<p><strong>isampler2D</strong> <strong>isampler2DArray</strong> <strong>usampler2D</strong> <strong>usampler2DArray</strong></p>
21205bd8deadSopenharmony_ci</dd>
21215bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21225bd8deadSopenharmony_ci<dd>
21235bd8deadSopenharmony_ci<p><strong>sampler2DRect</strong> <strong>sampler2DRectShadow</strong> <strong>isampler2DRect</strong> <strong>usampler2DRect</strong></p>
21245bd8deadSopenharmony_ci</dd>
21255bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21265bd8deadSopenharmony_ci<dd>
21275bd8deadSopenharmony_ci<p><strong>sampler2DMS</strong> <strong>isampler2DMS</strong> <strong>usampler2DMS</strong></p>
21285bd8deadSopenharmony_ci</dd>
21295bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21305bd8deadSopenharmony_ci<dd>
21315bd8deadSopenharmony_ci<p><strong>sampler2DMSArray</strong> <strong>isampler2DMSArray</strong> <strong>usampler2DMSArray</strong></p>
21325bd8deadSopenharmony_ci</dd>
21335bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21345bd8deadSopenharmony_ci<dd>
21355bd8deadSopenharmony_ci<p><strong>sampler3D</strong> <strong>isampler3D</strong> <strong>usampler3D</strong></p>
21365bd8deadSopenharmony_ci</dd>
21375bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21385bd8deadSopenharmony_ci<dd>
21395bd8deadSopenharmony_ci<p><strong>samplerCube</strong> <strong>samplerCubeShadow</strong> <strong>isamplerCube</strong> <strong>usamplerCube</strong></p>
21405bd8deadSopenharmony_ci</dd>
21415bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21425bd8deadSopenharmony_ci<dd>
21435bd8deadSopenharmony_ci<p><strong>samplerCubeArray</strong> <strong>samplerCubeArrayShadow</strong></p>
21445bd8deadSopenharmony_ci</dd>
21455bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21465bd8deadSopenharmony_ci<dd>
21475bd8deadSopenharmony_ci<p><strong>isamplerCubeArray</strong> <strong>usamplerCubeArray</strong></p>
21485bd8deadSopenharmony_ci</dd>
21495bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21505bd8deadSopenharmony_ci<dd>
21515bd8deadSopenharmony_ci<p><strong>samplerBuffer</strong> <strong>isamplerBuffer</strong> <strong>usamplerBuffer</strong></p>
21525bd8deadSopenharmony_ci</dd>
21535bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21545bd8deadSopenharmony_ci<dd>
21555bd8deadSopenharmony_ci<p><strong>image1D</strong> <strong>iimage1D</strong> <strong>uimage1D</strong></p>
21565bd8deadSopenharmony_ci</dd>
21575bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21585bd8deadSopenharmony_ci<dd>
21595bd8deadSopenharmony_ci<p><strong>image1DArray</strong> <strong>iimage1DArray</strong> <strong>uimage1DArray</strong></p>
21605bd8deadSopenharmony_ci</dd>
21615bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21625bd8deadSopenharmony_ci<dd>
21635bd8deadSopenharmony_ci<p><strong>image2D</strong> <strong>iimage2D</strong> <strong>uimage2D</strong></p>
21645bd8deadSopenharmony_ci</dd>
21655bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21665bd8deadSopenharmony_ci<dd>
21675bd8deadSopenharmony_ci<p><strong>image2DArray</strong> <strong>iimage2DArray</strong> <strong>uimage2DArray</strong></p>
21685bd8deadSopenharmony_ci</dd>
21695bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21705bd8deadSopenharmony_ci<dd>
21715bd8deadSopenharmony_ci<p><strong>image2DRect</strong> <strong>iimage2DRect</strong> <strong>uimage2DRect</strong></p>
21725bd8deadSopenharmony_ci</dd>
21735bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21745bd8deadSopenharmony_ci<dd>
21755bd8deadSopenharmony_ci<p><strong>image2DMS</strong> <strong>iimage2DMS</strong> <strong>uimage2DMS</strong></p>
21765bd8deadSopenharmony_ci</dd>
21775bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21785bd8deadSopenharmony_ci<dd>
21795bd8deadSopenharmony_ci<p><strong>image2DMSArray</strong> <strong>iimage2DMSArray</strong> <strong>uimage2DMSArray</strong></p>
21805bd8deadSopenharmony_ci</dd>
21815bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21825bd8deadSopenharmony_ci<dd>
21835bd8deadSopenharmony_ci<p><strong>image3D</strong> <strong>iimage3D</strong> <strong>uimage3D</strong></p>
21845bd8deadSopenharmony_ci</dd>
21855bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21865bd8deadSopenharmony_ci<dd>
21875bd8deadSopenharmony_ci<p><strong>imageCube</strong> <strong>iimageCube</strong> <strong>uimageCube</strong></p>
21885bd8deadSopenharmony_ci</dd>
21895bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21905bd8deadSopenharmony_ci<dd>
21915bd8deadSopenharmony_ci<p><strong>imageCubeArray</strong> <strong>iimageCubeArray</strong> <strong>uimageCubeArray</strong></p>
21925bd8deadSopenharmony_ci</dd>
21935bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21945bd8deadSopenharmony_ci<dd>
21955bd8deadSopenharmony_ci<p><strong>imageBuffer</strong> <strong>iimageBuffer</strong> <strong>uimageBuffer</strong></p>
21965bd8deadSopenharmony_ci</dd>
21975bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
21985bd8deadSopenharmony_ci<dd>
21995bd8deadSopenharmony_ci<p><strong>struct</strong></p>
22005bd8deadSopenharmony_ci</dd>
22015bd8deadSopenharmony_ci</dl>
22025bd8deadSopenharmony_ci</div>
22035bd8deadSopenharmony_ci<div class="paragraph">
22045bd8deadSopenharmony_ci<p>In addition, when targeting Vulkan, the following keywords also exist:</p>
22055bd8deadSopenharmony_ci</div>
22065bd8deadSopenharmony_ci<div class="dlist">
22075bd8deadSopenharmony_ci<dl>
22085bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22095bd8deadSopenharmony_ci<dd>
22105bd8deadSopenharmony_ci<p><strong>texture1D</strong> <strong>texture1DArray</strong></p>
22115bd8deadSopenharmony_ci</dd>
22125bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22135bd8deadSopenharmony_ci<dd>
22145bd8deadSopenharmony_ci<p><strong>itexture1D</strong> <strong>itexture1DArray</strong> <strong>utexture1D</strong> <strong>utexture1DArray</strong></p>
22155bd8deadSopenharmony_ci</dd>
22165bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22175bd8deadSopenharmony_ci<dd>
22185bd8deadSopenharmony_ci<p><strong>texture2D</strong> <strong>texture2DArray</strong></p>
22195bd8deadSopenharmony_ci</dd>
22205bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22215bd8deadSopenharmony_ci<dd>
22225bd8deadSopenharmony_ci<p><strong>itexture2D</strong> <strong>itexture2DArray</strong> <strong>utexture2D</strong> <strong>utexture2DArray</strong></p>
22235bd8deadSopenharmony_ci</dd>
22245bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22255bd8deadSopenharmony_ci<dd>
22265bd8deadSopenharmony_ci<p><strong>texture2DRect</strong> <strong>itexture2DRect</strong> <strong>utexture2DRect</strong></p>
22275bd8deadSopenharmony_ci</dd>
22285bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22295bd8deadSopenharmony_ci<dd>
22305bd8deadSopenharmony_ci<p><strong>texture2DMS</strong> <strong>itexture2DMS</strong> <strong>utexture2DMS</strong></p>
22315bd8deadSopenharmony_ci</dd>
22325bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22335bd8deadSopenharmony_ci<dd>
22345bd8deadSopenharmony_ci<p><strong>texture2DMSArray</strong> <strong>itexture2DMSArray</strong> <strong>utexture2DMSArray</strong></p>
22355bd8deadSopenharmony_ci</dd>
22365bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22375bd8deadSopenharmony_ci<dd>
22385bd8deadSopenharmony_ci<p><strong>texture3D</strong> <strong>itexture3D</strong> <strong>utexture3D</strong></p>
22395bd8deadSopenharmony_ci</dd>
22405bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22415bd8deadSopenharmony_ci<dd>
22425bd8deadSopenharmony_ci<p><strong>textureCube</strong> <strong>itextureCube</strong> <strong>utextureCube</strong></p>
22435bd8deadSopenharmony_ci</dd>
22445bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22455bd8deadSopenharmony_ci<dd>
22465bd8deadSopenharmony_ci<p><strong>textureCubeArray</strong> <strong>itextureCubeArray</strong> <strong>utextureCubeArray</strong></p>
22475bd8deadSopenharmony_ci</dd>
22485bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22495bd8deadSopenharmony_ci<dd>
22505bd8deadSopenharmony_ci<p><strong>textureBuffer</strong> <strong>itextureBuffer</strong> <strong>utextureBuffer</strong></p>
22515bd8deadSopenharmony_ci</dd>
22525bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22535bd8deadSopenharmony_ci<dd>
22545bd8deadSopenharmony_ci<p><strong>sampler</strong> <strong>samplerShadow</strong></p>
22555bd8deadSopenharmony_ci</dd>
22565bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22575bd8deadSopenharmony_ci<dd>
22585bd8deadSopenharmony_ci<p><strong>subpassInput</strong> <strong>isubpassInput</strong> <strong>usubpassInput</strong></p>
22595bd8deadSopenharmony_ci</dd>
22605bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22615bd8deadSopenharmony_ci<dd>
22625bd8deadSopenharmony_ci<p><strong>subpassInputMS</strong> <strong>isubpassInputMS</strong> <strong>usubpassInputMS</strong></p>
22635bd8deadSopenharmony_ci</dd>
22645bd8deadSopenharmony_ci</dl>
22655bd8deadSopenharmony_ci</div>
22665bd8deadSopenharmony_ci<div class="paragraph">
22675bd8deadSopenharmony_ci<p>The following are the keywords reserved for future use.
22685bd8deadSopenharmony_ciUsing them will result in a compile-time error:</p>
22695bd8deadSopenharmony_ci</div>
22705bd8deadSopenharmony_ci<div class="dlist">
22715bd8deadSopenharmony_ci<dl>
22725bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22735bd8deadSopenharmony_ci<dd>
22745bd8deadSopenharmony_ci<p><strong>common</strong> <strong>partition</strong> <strong>active</strong></p>
22755bd8deadSopenharmony_ci</dd>
22765bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22775bd8deadSopenharmony_ci<dd>
22785bd8deadSopenharmony_ci<p><strong>asm</strong></p>
22795bd8deadSopenharmony_ci</dd>
22805bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22815bd8deadSopenharmony_ci<dd>
22825bd8deadSopenharmony_ci<p><strong>class</strong> <strong>union</strong> <strong>enum</strong> <strong>typedef</strong> <strong>template</strong> <strong>this</strong></p>
22835bd8deadSopenharmony_ci</dd>
22845bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22855bd8deadSopenharmony_ci<dd>
22865bd8deadSopenharmony_ci<p><strong>resource</strong></p>
22875bd8deadSopenharmony_ci</dd>
22885bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22895bd8deadSopenharmony_ci<dd>
22905bd8deadSopenharmony_ci<p><strong>goto</strong></p>
22915bd8deadSopenharmony_ci</dd>
22925bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22935bd8deadSopenharmony_ci<dd>
22945bd8deadSopenharmony_ci<p><strong>inline</strong> <strong>noinline</strong> <strong>public</strong> <strong>static</strong> <strong>extern</strong> <strong>external</strong> <strong>interface</strong></p>
22955bd8deadSopenharmony_ci</dd>
22965bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
22975bd8deadSopenharmony_ci<dd>
22985bd8deadSopenharmony_ci<p><strong>long</strong> <strong>short</strong> <strong>half</strong> <strong>fixed</strong> <strong>unsigned</strong> <strong>superp</strong></p>
22995bd8deadSopenharmony_ci</dd>
23005bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
23015bd8deadSopenharmony_ci<dd>
23025bd8deadSopenharmony_ci<p><strong>input</strong> <strong>output</strong></p>
23035bd8deadSopenharmony_ci</dd>
23045bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
23055bd8deadSopenharmony_ci<dd>
23065bd8deadSopenharmony_ci<p><strong>hvec2</strong> <strong>hvec3</strong> <strong>hvec4</strong> <strong>fvec2</strong> <strong>fvec3</strong> <strong>fvec4</strong></p>
23075bd8deadSopenharmony_ci</dd>
23085bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
23095bd8deadSopenharmony_ci<dd>
23105bd8deadSopenharmony_ci<p><strong>filter</strong></p>
23115bd8deadSopenharmony_ci</dd>
23125bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
23135bd8deadSopenharmony_ci<dd>
23145bd8deadSopenharmony_ci<p><strong>sizeof</strong> <strong>cast</strong></p>
23155bd8deadSopenharmony_ci</dd>
23165bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
23175bd8deadSopenharmony_ci<dd>
23185bd8deadSopenharmony_ci<p><strong>namespace</strong> <strong>using</strong></p>
23195bd8deadSopenharmony_ci</dd>
23205bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
23215bd8deadSopenharmony_ci<dd>
23225bd8deadSopenharmony_ci<p><strong>sampler3DRect</strong></p>
23235bd8deadSopenharmony_ci</dd>
23245bd8deadSopenharmony_ci</dl>
23255bd8deadSopenharmony_ci</div>
23265bd8deadSopenharmony_ci<div class="paragraph">
23275bd8deadSopenharmony_ci<p>In addition, all identifiers containing two consecutive underscores (__)
23285bd8deadSopenharmony_ciare reserved for use by underlying software layers.
23295bd8deadSopenharmony_ciDefining such a name in a shader does not itself result in an error, but may
23305bd8deadSopenharmony_ciresult in unintended behaviors that stem from having multiple definitions of
23315bd8deadSopenharmony_cithe same name.</p>
23325bd8deadSopenharmony_ci</div>
23335bd8deadSopenharmony_ci</div>
23345bd8deadSopenharmony_ci<div class="sect2">
23355bd8deadSopenharmony_ci<h3 id="identifiers">3.7. Identifiers</h3>
23365bd8deadSopenharmony_ci<div class="paragraph">
23375bd8deadSopenharmony_ci<p>Identifiers are used for variable names, function names, structure names,
23385bd8deadSopenharmony_ciand field selectors (field selectors select components of
23395bd8deadSopenharmony_ci<code><a href="#vector-components">vectors</a></code> and <code><a href="#matrix-components">matrices</a></code>,
23405bd8deadSopenharmony_cisimilarly to structure members).
23415bd8deadSopenharmony_ciIdentifiers have the form:</p>
23425bd8deadSopenharmony_ci</div>
23435bd8deadSopenharmony_ci<div class="openblock bnf">
23445bd8deadSopenharmony_ci<div class="content">
23455bd8deadSopenharmony_ci<div class="dlist">
23465bd8deadSopenharmony_ci<dl>
23475bd8deadSopenharmony_ci<dt class="hdlist1"><em>identifier</em> : </dt>
23485bd8deadSopenharmony_ci<dd>
23495bd8deadSopenharmony_ci<p><em>nondigit</em><br>
23505bd8deadSopenharmony_ci<em>identifier</em> <em>nondigit</em><br>
23515bd8deadSopenharmony_ci<em>identifier</em> <em>digit</em></p>
23525bd8deadSopenharmony_ci</dd>
23535bd8deadSopenharmony_ci<dt class="hdlist1"><em>nondigit</em> : one of </dt>
23545bd8deadSopenharmony_ci<dd>
23555bd8deadSopenharmony_ci<p><strong>_</strong> <strong>a b c d e f g h i j k l m n o p q r s t u v w x y z</strong><br>
23565bd8deadSopenharmony_ci<strong>A B C D E F G H I J K L M N O P Q R S T U V W X Y Z</strong></p>
23575bd8deadSopenharmony_ci</dd>
23585bd8deadSopenharmony_ci<dt class="hdlist1"><em>digit</em> : one of </dt>
23595bd8deadSopenharmony_ci<dd>
23605bd8deadSopenharmony_ci<p><strong>0 1 2 3 4 5 6 7 8 9</strong></p>
23615bd8deadSopenharmony_ci</dd>
23625bd8deadSopenharmony_ci</dl>
23635bd8deadSopenharmony_ci</div>
23645bd8deadSopenharmony_ci</div>
23655bd8deadSopenharmony_ci</div>
23665bd8deadSopenharmony_ci<div class="paragraph">
23675bd8deadSopenharmony_ci<p>Identifiers starting with &#8220;gl_&#8221; are reserved, and
23685bd8deadSopenharmony_ciin general, may not be declared in a shader;
23695bd8deadSopenharmony_cithis results in a compile-time error.
23705bd8deadSopenharmony_ciHowever, as noted in the specification, there are some cases where
23715bd8deadSopenharmony_cipreviously declared variables can be redeclared, and predeclared &#8220;gl_&#8221;
23725bd8deadSopenharmony_cinames are allowed to be redeclared in a shader only for these specific
23735bd8deadSopenharmony_cipurposes.</p>
23745bd8deadSopenharmony_ci</div>
23755bd8deadSopenharmony_ci<div class="paragraph">
23765bd8deadSopenharmony_ci<p>Implementations must support identifier lengths of up to 1024 characters.
23775bd8deadSopenharmony_ciImplementations are allowed to generate an error for an identifier of length
23785bd8deadSopenharmony_cigreater than 1024 characters, but are also allowed to support lengths
23795bd8deadSopenharmony_cigreater than 1024.</p>
23805bd8deadSopenharmony_ci</div>
23815bd8deadSopenharmony_ci</div>
23825bd8deadSopenharmony_ci<div class="sect2">
23835bd8deadSopenharmony_ci<h3 id="definitions">3.8. Definitions</h3>
23845bd8deadSopenharmony_ci<div class="paragraph">
23855bd8deadSopenharmony_ci<p>Some language rules described below depend on the following definitions.</p>
23865bd8deadSopenharmony_ci</div>
23875bd8deadSopenharmony_ci<div class="sect3">
23885bd8deadSopenharmony_ci<h4 id="static-use">3.8.1. Static Use</h4>
23895bd8deadSopenharmony_ci<div class="paragraph">
23905bd8deadSopenharmony_ci<p>A shader contains a <em>static use</em> of a variable <em>x</em> if, after preprocessing,
23915bd8deadSopenharmony_cithe shader contains a statement that would access any part of <em>x</em>,
23925bd8deadSopenharmony_ciwhether or not flow of control will cause that statement to be executed.
23935bd8deadSopenharmony_ciSuch a variable is referred to as being <em>statically used</em>. If the access is a
23945bd8deadSopenharmony_ciwrite then <em>x</em> is further said to be <em>statically assigned</em>.</p>
23955bd8deadSopenharmony_ci</div>
23965bd8deadSopenharmony_ci</div>
23975bd8deadSopenharmony_ci<div class="sect3">
23985bd8deadSopenharmony_ci<h4 id="dynamically-uniform-expressions-and-uniform-control-flow">3.8.2. Dynamically Uniform Expressions and Uniform Control Flow</h4>
23995bd8deadSopenharmony_ci<div class="paragraph">
24005bd8deadSopenharmony_ci<p>Some operations require an expression to be <em>dynamically uniform</em>, or that
24015bd8deadSopenharmony_ciit be located in <em>uniform control flow</em>.
24025bd8deadSopenharmony_ciThese requirements are defined by the following set of definitions.</p>
24035bd8deadSopenharmony_ci</div>
24045bd8deadSopenharmony_ci<div class="paragraph">
24055bd8deadSopenharmony_ci<p>An <em>invocation</em> is a single execution of <em>main()</em> for a particular stage,
24065bd8deadSopenharmony_cioperating only on the amount of data explicitly exposed within that stage&#8217;s
24075bd8deadSopenharmony_cishaders.
24085bd8deadSopenharmony_ci(Any implicit operation on additional instances of data would comprise
24095bd8deadSopenharmony_ciadditional invocations.) For example, in compute execution models, a single
24105bd8deadSopenharmony_ciinvocation operates only on a single work item, or, in a vertex execution
24115bd8deadSopenharmony_cimodel, a single invocation operates only on a single vertex.</p>
24125bd8deadSopenharmony_ci</div>
24135bd8deadSopenharmony_ci<div class="paragraph">
24145bd8deadSopenharmony_ci<p>An <em>invocation group</em> is the complete set of invocations collectively
24155bd8deadSopenharmony_ciprocessing a particular compute workgroup or graphical operation, where the
24165bd8deadSopenharmony_ciscope of a "graphical operation" is implementation-dependent, but at least
24175bd8deadSopenharmony_cias large as a single triangle or patch, and at most as large as a single
24185bd8deadSopenharmony_cirendering command, as defined by the client API.</p>
24195bd8deadSopenharmony_ci</div>
24205bd8deadSopenharmony_ci<div class="paragraph">
24215bd8deadSopenharmony_ci<p>Within a single invocation, a single shader statement can be executed
24225bd8deadSopenharmony_cimultiple times, giving multiple <em>dynamic instances</em> of that instruction.
24235bd8deadSopenharmony_ciThis can happen when the instruction is executed in a loop, or in a function
24245bd8deadSopenharmony_cicalled from multiple call sites, or combinations of multiple of these.
24255bd8deadSopenharmony_ciDifferent loop iterations and different dynamic function-call-site chains
24265bd8deadSopenharmony_ciyield different dynamic instances of such an instruction.
24275bd8deadSopenharmony_ciDynamic instances are distinguished by their control-flow path within an
24285bd8deadSopenharmony_ciinvocation, not by which invocation executed it.
24295bd8deadSopenharmony_ciThat is, different invocations of <em>main()</em> execute the same dynamic
24305bd8deadSopenharmony_ciinstances of an instruction when they follow the same control-flow path.</p>
24315bd8deadSopenharmony_ci</div>
24325bd8deadSopenharmony_ci<div class="paragraph">
24335bd8deadSopenharmony_ci<p>An expression is <em>dynamically uniform</em> for a dynamic instance consuming it
24345bd8deadSopenharmony_ciwhen its value is the same for all invocations (in the invocation group)
24355bd8deadSopenharmony_cithat execute that dynamic instance.</p>
24365bd8deadSopenharmony_ci</div>
24375bd8deadSopenharmony_ci<div class="paragraph">
24385bd8deadSopenharmony_ci<p><em>Uniform control flow</em> (or converged control flow) occurs when all
24395bd8deadSopenharmony_ciinvocations in the invocation group execute the same control-flow path (and
24405bd8deadSopenharmony_cihence the same sequence of dynamic instances of instructions).
24415bd8deadSopenharmony_ciUniform control flow is the initial state at the entry into <em>main()</em>, and
24425bd8deadSopenharmony_cilasts until a conditional branch takes different control paths for different
24435bd8deadSopenharmony_ciinvocations (non-uniform or divergent control flow).
24445bd8deadSopenharmony_ciSuch divergence can reconverge, with all the invocations once again
24455bd8deadSopenharmony_ciexecuting the same control-flow path, and this re-establishes the existence
24465bd8deadSopenharmony_ciof uniform control flow.
24475bd8deadSopenharmony_ciIf control flow is uniform upon entry into a selection or loop, and all
24485bd8deadSopenharmony_ciinvocations in the invocation group subsequently leave that selection or
24495bd8deadSopenharmony_ciloop, then control flow reconverges to be uniform.</p>
24505bd8deadSopenharmony_ci</div>
24515bd8deadSopenharmony_ci<div class="paragraph">
24525bd8deadSopenharmony_ci<p>For example:</p>
24535bd8deadSopenharmony_ci</div>
24545bd8deadSopenharmony_ci<div class="listingblock">
24555bd8deadSopenharmony_ci<div class="content">
24565bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">main()
24575bd8deadSopenharmony_ci{
24585bd8deadSopenharmony_ci    <span class="predefined-type">float</span> a = ...; <span class="comment">// this is uniform control flow</span>
24595bd8deadSopenharmony_ci    <span class="keyword">if</span> (a &lt; b) {   <span class="comment">// this expression is true for some fragments, not all</span>
24605bd8deadSopenharmony_ci        ...;       <span class="comment">// non-uniform control flow</span>
24615bd8deadSopenharmony_ci    } <span class="keyword">else</span> {
24625bd8deadSopenharmony_ci        ...;       <span class="comment">// non-uniform control flow</span>
24635bd8deadSopenharmony_ci    }
24645bd8deadSopenharmony_ci    ...;           <span class="comment">// uniform control flow again</span>
24655bd8deadSopenharmony_ci}</code></pre>
24665bd8deadSopenharmony_ci</div>
24675bd8deadSopenharmony_ci</div>
24685bd8deadSopenharmony_ci<div class="paragraph">
24695bd8deadSopenharmony_ci<p>Note that constant expressions are trivially dynamically uniform.
24705bd8deadSopenharmony_ciIt follows that typical loop counters based on these are also dynamically
24715bd8deadSopenharmony_ciuniform.</p>
24725bd8deadSopenharmony_ci</div>
24735bd8deadSopenharmony_ci</div>
24745bd8deadSopenharmony_ci</div>
24755bd8deadSopenharmony_ci</div>
24765bd8deadSopenharmony_ci</div>
24775bd8deadSopenharmony_ci<div class="sect1">
24785bd8deadSopenharmony_ci<h2 id="variables-and-types">4. Variables and Types</h2>
24795bd8deadSopenharmony_ci<div class="sectionbody">
24805bd8deadSopenharmony_ci<div class="paragraph">
24815bd8deadSopenharmony_ci<p>All variables and functions must be declared before being used.
24825bd8deadSopenharmony_ciVariable and function names are identifiers.</p>
24835bd8deadSopenharmony_ci</div>
24845bd8deadSopenharmony_ci<div class="paragraph">
24855bd8deadSopenharmony_ci<p>There are no default types.
24865bd8deadSopenharmony_ciAll variable and function declarations must have a declared type, and
24875bd8deadSopenharmony_cioptionally qualifiers.
24885bd8deadSopenharmony_ciA variable is declared by specifying its type followed by one or more names
24895bd8deadSopenharmony_ciseparated by commas.
24905bd8deadSopenharmony_ciIn many cases, a variable can be initialized as part of its declaration by
24915bd8deadSopenharmony_ciusing the assignment operator (<strong>=</strong>).</p>
24925bd8deadSopenharmony_ci</div>
24935bd8deadSopenharmony_ci<div class="paragraph">
24945bd8deadSopenharmony_ci<p>User-defined types may be defined using <strong>struct</strong> to aggregate a list of
24955bd8deadSopenharmony_ciexisting types into a single name.</p>
24965bd8deadSopenharmony_ci</div>
24975bd8deadSopenharmony_ci<div class="paragraph">
24985bd8deadSopenharmony_ci<p>The OpenGL Shading Language is type safe.
24995bd8deadSopenharmony_ciThere are some implicit conversions between types.
25005bd8deadSopenharmony_ciExactly how and when this can occur is described in section
25015bd8deadSopenharmony_ci&#8220;<a href="#implicit-conversions">Implicit Conversions</a>&#8221; and as referenced by other
25025bd8deadSopenharmony_cisections in this specification.</p>
25035bd8deadSopenharmony_ci</div>
25045bd8deadSopenharmony_ci<div class="sect2">
25055bd8deadSopenharmony_ci<h3 id="basic-types">4.1. Basic Types</h3>
25065bd8deadSopenharmony_ci<div class="dlist">
25075bd8deadSopenharmony_ci<dl>
25085bd8deadSopenharmony_ci<dt class="hdlist1">Definition</dt>
25095bd8deadSopenharmony_ci<dd>
25105bd8deadSopenharmony_ci<p>A <em>basic type</em> is a type defined by a keyword in the language.</p>
25115bd8deadSopenharmony_ci</dd>
25125bd8deadSopenharmony_ci</dl>
25135bd8deadSopenharmony_ci</div>
25145bd8deadSopenharmony_ci<div class="paragraph">
25155bd8deadSopenharmony_ci<p>The OpenGL Shading Language supports the following basic data types, grouped as follows.</p>
25165bd8deadSopenharmony_ci</div>
25175bd8deadSopenharmony_ci<div class="paragraph">
25185bd8deadSopenharmony_ci<p><strong>Transparent Types</strong></p>
25195bd8deadSopenharmony_ci</div>
25205bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
25215bd8deadSopenharmony_ci<colgroup>
25225bd8deadSopenharmony_ci<col style="width: 50%;">
25235bd8deadSopenharmony_ci<col style="width: 50%;">
25245bd8deadSopenharmony_ci</colgroup>
25255bd8deadSopenharmony_ci<thead>
25265bd8deadSopenharmony_ci<tr>
25275bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Type</th>
25285bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Meaning</th>
25295bd8deadSopenharmony_ci</tr>
25305bd8deadSopenharmony_ci</thead>
25315bd8deadSopenharmony_ci<tbody>
25325bd8deadSopenharmony_ci<tr>
25335bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>void</strong></p></td>
25345bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">for functions that do not return a value</p></td>
25355bd8deadSopenharmony_ci</tr>
25365bd8deadSopenharmony_ci<tr>
25375bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>bool</strong></p></td>
25385bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a conditional type, taking on values of true or false</p></td>
25395bd8deadSopenharmony_ci</tr>
25405bd8deadSopenharmony_ci<tr>
25415bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>int</strong></p></td>
25425bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a signed integer</p></td>
25435bd8deadSopenharmony_ci</tr>
25445bd8deadSopenharmony_ci<tr>
25455bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>uint</strong></p></td>
25465bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">an unsigned integer</p></td>
25475bd8deadSopenharmony_ci</tr>
25485bd8deadSopenharmony_ci<tr>
25495bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>float</strong></p></td>
25505bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a single-precision floating-point scalar</p></td>
25515bd8deadSopenharmony_ci</tr>
25525bd8deadSopenharmony_ci<tr>
25535bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>double</strong></p></td>
25545bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a double-precision floating-point scalar</p></td>
25555bd8deadSopenharmony_ci</tr>
25565bd8deadSopenharmony_ci<tr>
25575bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>vec2</strong></p></td>
25585bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a two-component single-precision floating-point vector</p></td>
25595bd8deadSopenharmony_ci</tr>
25605bd8deadSopenharmony_ci<tr>
25615bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>vec3</strong></p></td>
25625bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a three-component single-precision floating-point vector</p></td>
25635bd8deadSopenharmony_ci</tr>
25645bd8deadSopenharmony_ci<tr>
25655bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>vec4</strong></p></td>
25665bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a four-component single-precision floating-point vector</p></td>
25675bd8deadSopenharmony_ci</tr>
25685bd8deadSopenharmony_ci<tr>
25695bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dvec2</strong></p></td>
25705bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a two-component double-precision floating-point vector</p></td>
25715bd8deadSopenharmony_ci</tr>
25725bd8deadSopenharmony_ci<tr>
25735bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dvec3</strong></p></td>
25745bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a three-component double-precision floating-point vector</p></td>
25755bd8deadSopenharmony_ci</tr>
25765bd8deadSopenharmony_ci<tr>
25775bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dvec4</strong></p></td>
25785bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a four-component double-precision floating-point vector</p></td>
25795bd8deadSopenharmony_ci</tr>
25805bd8deadSopenharmony_ci<tr>
25815bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>bvec2</strong></p></td>
25825bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a two-component Boolean vector</p></td>
25835bd8deadSopenharmony_ci</tr>
25845bd8deadSopenharmony_ci<tr>
25855bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>bvec3</strong></p></td>
25865bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a three-component Boolean vector</p></td>
25875bd8deadSopenharmony_ci</tr>
25885bd8deadSopenharmony_ci<tr>
25895bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>bvec4</strong></p></td>
25905bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a four-component Boolean vector</p></td>
25915bd8deadSopenharmony_ci</tr>
25925bd8deadSopenharmony_ci<tr>
25935bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ivec2</strong></p></td>
25945bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a two-component signed integer vector</p></td>
25955bd8deadSopenharmony_ci</tr>
25965bd8deadSopenharmony_ci<tr>
25975bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ivec3</strong></p></td>
25985bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a three-component signed integer vector</p></td>
25995bd8deadSopenharmony_ci</tr>
26005bd8deadSopenharmony_ci<tr>
26015bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ivec4</strong></p></td>
26025bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a four-component signed integer vector</p></td>
26035bd8deadSopenharmony_ci</tr>
26045bd8deadSopenharmony_ci<tr>
26055bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>uvec2</strong></p></td>
26065bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a two-component unsigned integer vector</p></td>
26075bd8deadSopenharmony_ci</tr>
26085bd8deadSopenharmony_ci<tr>
26095bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>uvec3</strong></p></td>
26105bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a three-component unsigned integer vector</p></td>
26115bd8deadSopenharmony_ci</tr>
26125bd8deadSopenharmony_ci<tr>
26135bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>uvec4</strong></p></td>
26145bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a four-component unsigned integer vector</p></td>
26155bd8deadSopenharmony_ci</tr>
26165bd8deadSopenharmony_ci<tr>
26175bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat2</strong></p></td>
26185bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a 2 × 2 single-precision floating-point matrix</p></td>
26195bd8deadSopenharmony_ci</tr>
26205bd8deadSopenharmony_ci<tr>
26215bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat3</strong></p></td>
26225bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a 3 × 3 single-precision floating-point matrix</p></td>
26235bd8deadSopenharmony_ci</tr>
26245bd8deadSopenharmony_ci<tr>
26255bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat4</strong></p></td>
26265bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a 4 × 4 single-precision floating-point matrix</p></td>
26275bd8deadSopenharmony_ci</tr>
26285bd8deadSopenharmony_ci<tr>
26295bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat2x2</strong></p></td>
26305bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">same as a <strong>mat2</strong></p></td>
26315bd8deadSopenharmony_ci</tr>
26325bd8deadSopenharmony_ci<tr>
26335bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat2x3</strong></p></td>
26345bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a single-precision floating-point matrix with 2 columns and 3 rows</p></td>
26355bd8deadSopenharmony_ci</tr>
26365bd8deadSopenharmony_ci<tr>
26375bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat2x4</strong></p></td>
26385bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a single-precision floating-point matrix with 2 columns and 4 rows</p></td>
26395bd8deadSopenharmony_ci</tr>
26405bd8deadSopenharmony_ci<tr>
26415bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat3x2</strong></p></td>
26425bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a single-precision floating-point matrix with 3 columns and 2 rows</p></td>
26435bd8deadSopenharmony_ci</tr>
26445bd8deadSopenharmony_ci<tr>
26455bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat3x3</strong></p></td>
26465bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">same as a <strong>mat3</strong></p></td>
26475bd8deadSopenharmony_ci</tr>
26485bd8deadSopenharmony_ci<tr>
26495bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat3x4</strong></p></td>
26505bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a single-precision floating-point matrix with 3 columns and 4 rows</p></td>
26515bd8deadSopenharmony_ci</tr>
26525bd8deadSopenharmony_ci<tr>
26535bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat4x2</strong></p></td>
26545bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a single-precision floating-point matrix with 4 columns and 2 rows</p></td>
26555bd8deadSopenharmony_ci</tr>
26565bd8deadSopenharmony_ci<tr>
26575bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat4x3</strong></p></td>
26585bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a single-precision floating-point matrix with 4 columns and 3 rows</p></td>
26595bd8deadSopenharmony_ci</tr>
26605bd8deadSopenharmony_ci<tr>
26615bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat4x4</strong></p></td>
26625bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">same as a <strong>mat4</strong></p></td>
26635bd8deadSopenharmony_ci</tr>
26645bd8deadSopenharmony_ci<tr>
26655bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat2</strong></p></td>
26665bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a 2 × 2 double-precision floating-point matrix</p></td>
26675bd8deadSopenharmony_ci</tr>
26685bd8deadSopenharmony_ci<tr>
26695bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat3</strong></p></td>
26705bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a 3 × 3 double-precision floating-point matrix</p></td>
26715bd8deadSopenharmony_ci</tr>
26725bd8deadSopenharmony_ci<tr>
26735bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat4</strong></p></td>
26745bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a 4 × 4 double-precision floating-point matrix</p></td>
26755bd8deadSopenharmony_ci</tr>
26765bd8deadSopenharmony_ci<tr>
26775bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat2x2</strong></p></td>
26785bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">same as a <strong>dmat2</strong></p></td>
26795bd8deadSopenharmony_ci</tr>
26805bd8deadSopenharmony_ci<tr>
26815bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat2x3</strong></p></td>
26825bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a double-precision floating-point matrix with 2 columns and 3 rows</p></td>
26835bd8deadSopenharmony_ci</tr>
26845bd8deadSopenharmony_ci<tr>
26855bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat2x4</strong></p></td>
26865bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a double-precision floating-point matrix with 2 columns and 4 rows</p></td>
26875bd8deadSopenharmony_ci</tr>
26885bd8deadSopenharmony_ci<tr>
26895bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat3x2</strong></p></td>
26905bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a double-precision floating-point matrix with 3 columns and 2 rows</p></td>
26915bd8deadSopenharmony_ci</tr>
26925bd8deadSopenharmony_ci<tr>
26935bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat3x3</strong></p></td>
26945bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">same as a <strong>dmat3</strong></p></td>
26955bd8deadSopenharmony_ci</tr>
26965bd8deadSopenharmony_ci<tr>
26975bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat3x4</strong></p></td>
26985bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a double-precision floating-point matrix with 3 columns and 4 rows</p></td>
26995bd8deadSopenharmony_ci</tr>
27005bd8deadSopenharmony_ci<tr>
27015bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat4x2</strong></p></td>
27025bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a double-precision floating-point matrix with 4 columns and 2 rows</p></td>
27035bd8deadSopenharmony_ci</tr>
27045bd8deadSopenharmony_ci<tr>
27055bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat4x3</strong></p></td>
27065bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a double-precision floating-point matrix with 4 columns and 3 rows</p></td>
27075bd8deadSopenharmony_ci</tr>
27085bd8deadSopenharmony_ci<tr>
27095bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat4x4</strong></p></td>
27105bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">same as a <strong>dmat4</strong></p></td>
27115bd8deadSopenharmony_ci</tr>
27125bd8deadSopenharmony_ci</tbody>
27135bd8deadSopenharmony_ci</table>
27145bd8deadSopenharmony_ci<div class="paragraph">
27155bd8deadSopenharmony_ci<p>Note that where the following tables say &#8220;accessing a texture&#8221;, the
27165bd8deadSopenharmony_ci<strong>sampler*</strong> opaque types access textures, and the <strong>image*</strong> opaque types
27175bd8deadSopenharmony_ciaccess images, of a specified type.</p>
27185bd8deadSopenharmony_ci</div>
27195bd8deadSopenharmony_ci<div class="paragraph">
27205bd8deadSopenharmony_ci<p><strong>Floating-Point Opaque Types</strong></p>
27215bd8deadSopenharmony_ci</div>
27225bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
27235bd8deadSopenharmony_ci<colgroup>
27245bd8deadSopenharmony_ci<col style="width: 50%;">
27255bd8deadSopenharmony_ci<col style="width: 50%;">
27265bd8deadSopenharmony_ci</colgroup>
27275bd8deadSopenharmony_ci<thead>
27285bd8deadSopenharmony_ci<tr>
27295bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Type</th>
27305bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Meaning</th>
27315bd8deadSopenharmony_ci</tr>
27325bd8deadSopenharmony_ci</thead>
27335bd8deadSopenharmony_ci<tbody>
27345bd8deadSopenharmony_ci<tr>
27355bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sampler1D</strong><br>
27365bd8deadSopenharmony_ci  <strong>texture1D</strong><br>
27375bd8deadSopenharmony_ci  <strong>image1D</strong></p></td>
27385bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a 1D texture</p></td>
27395bd8deadSopenharmony_ci</tr>
27405bd8deadSopenharmony_ci<tr>
27415bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sampler1DShadow</strong></p></td>
27425bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a 1D depth texture with comparison</p></td>
27435bd8deadSopenharmony_ci</tr>
27445bd8deadSopenharmony_ci<tr>
27455bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sampler1DArray</strong><br>
27465bd8deadSopenharmony_ci  <strong>texture1DArray</strong><br>
27475bd8deadSopenharmony_ci  <strong>image1DArray</strong></p></td>
27485bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a 1D array texture</p></td>
27495bd8deadSopenharmony_ci</tr>
27505bd8deadSopenharmony_ci<tr>
27515bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sampler1DArrayShadow</strong></p></td>
27525bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a 1D array depth texture with comparison</p></td>
27535bd8deadSopenharmony_ci</tr>
27545bd8deadSopenharmony_ci<tr>
27555bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sampler2D</strong><br>
27565bd8deadSopenharmony_ci  <strong>texture2D</strong><br>
27575bd8deadSopenharmony_ci  <strong>image2D</strong></p></td>
27585bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a 2D texture</p></td>
27595bd8deadSopenharmony_ci</tr>
27605bd8deadSopenharmony_ci<tr>
27615bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sampler2DShadow</strong></p></td>
27625bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a 2D depth texture with comparison</p></td>
27635bd8deadSopenharmony_ci</tr>
27645bd8deadSopenharmony_ci<tr>
27655bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sampler2DArray</strong><br>
27665bd8deadSopenharmony_ci  <strong>texture2DArray</strong><br>
27675bd8deadSopenharmony_ci  <strong>image2DArray</strong></p></td>
27685bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a 2D array texture</p></td>
27695bd8deadSopenharmony_ci</tr>
27705bd8deadSopenharmony_ci<tr>
27715bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sampler2DArrayShadow</strong></p></td>
27725bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a 2D array depth texture with comparison</p></td>
27735bd8deadSopenharmony_ci</tr>
27745bd8deadSopenharmony_ci<tr>
27755bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sampler2DMS</strong><br>
27765bd8deadSopenharmony_ci  <strong>texture2DMS</strong><br>
27775bd8deadSopenharmony_ci  <strong>image2DMS</strong></p></td>
27785bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a 2D multisample texture</p></td>
27795bd8deadSopenharmony_ci</tr>
27805bd8deadSopenharmony_ci<tr>
27815bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sampler2DMSArray</strong><br>
27825bd8deadSopenharmony_ci  <strong>texture2DMSArray</strong><br>
27835bd8deadSopenharmony_ci  <strong>image2DMSArray</strong></p></td>
27845bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a 2D multisample array texture</p></td>
27855bd8deadSopenharmony_ci</tr>
27865bd8deadSopenharmony_ci<tr>
27875bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sampler2DRect</strong><br>
27885bd8deadSopenharmony_ci  <strong>texture2DRect</strong><br>
27895bd8deadSopenharmony_ci  <strong>image2DRect</strong></p></td>
27905bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a rectangle texture</p></td>
27915bd8deadSopenharmony_ci</tr>
27925bd8deadSopenharmony_ci<tr>
27935bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sampler2DRectShadow</strong></p></td>
27945bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a rectangle texture with comparison</p></td>
27955bd8deadSopenharmony_ci</tr>
27965bd8deadSopenharmony_ci<tr>
27975bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sampler3D</strong><br>
27985bd8deadSopenharmony_ci  <strong>texture3D</strong><br>
27995bd8deadSopenharmony_ci  <strong>image3D</strong></p></td>
28005bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a 3D texture</p></td>
28015bd8deadSopenharmony_ci</tr>
28025bd8deadSopenharmony_ci<tr>
28035bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>samplerCube</strong><br>
28045bd8deadSopenharmony_ci  <strong>textureCube</strong><br>
28055bd8deadSopenharmony_ci  <strong>imageCube</strong></p></td>
28065bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a cube mapped texture</p></td>
28075bd8deadSopenharmony_ci</tr>
28085bd8deadSopenharmony_ci<tr>
28095bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>samplerCubeShadow</strong></p></td>
28105bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a cube map depth texture with comparison</p></td>
28115bd8deadSopenharmony_ci</tr>
28125bd8deadSopenharmony_ci<tr>
28135bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>samplerCubeArray</strong><br>
28145bd8deadSopenharmony_ci  <strong>textureCubeArray</strong><br>
28155bd8deadSopenharmony_ci  <strong>imageCubeArray</strong></p></td>
28165bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a cube map array texture</p></td>
28175bd8deadSopenharmony_ci</tr>
28185bd8deadSopenharmony_ci<tr>
28195bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>samplerCubeArrayShadow</strong></p></td>
28205bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a cube map array depth texture with comparison</p></td>
28215bd8deadSopenharmony_ci</tr>
28225bd8deadSopenharmony_ci<tr>
28235bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>samplerBuffer</strong><br>
28245bd8deadSopenharmony_ci  <strong>textureBuffer</strong><br>
28255bd8deadSopenharmony_ci  <strong>imageBuffer</strong></p></td>
28265bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a buffer texture</p></td>
28275bd8deadSopenharmony_ci</tr>
28285bd8deadSopenharmony_ci<tr>
28295bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>subpassInput</strong></p></td>
28305bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a floating-point subpass input</p></td>
28315bd8deadSopenharmony_ci</tr>
28325bd8deadSopenharmony_ci<tr>
28335bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>subpassInputMS</strong></p></td>
28345bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a multi-sampled floating-point subpass input</p></td>
28355bd8deadSopenharmony_ci</tr>
28365bd8deadSopenharmony_ci</tbody>
28375bd8deadSopenharmony_ci</table>
28385bd8deadSopenharmony_ci<div class="paragraph">
28395bd8deadSopenharmony_ci<p><strong>Signed Integer Opaque Types</strong></p>
28405bd8deadSopenharmony_ci</div>
28415bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
28425bd8deadSopenharmony_ci<colgroup>
28435bd8deadSopenharmony_ci<col style="width: 50%;">
28445bd8deadSopenharmony_ci<col style="width: 50%;">
28455bd8deadSopenharmony_ci</colgroup>
28465bd8deadSopenharmony_ci<thead>
28475bd8deadSopenharmony_ci<tr>
28485bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Type</th>
28495bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Meaning</th>
28505bd8deadSopenharmony_ci</tr>
28515bd8deadSopenharmony_ci</thead>
28525bd8deadSopenharmony_ci<tbody>
28535bd8deadSopenharmony_ci<tr>
28545bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>isampler1D</strong><br>
28555bd8deadSopenharmony_ci  <strong>itexture1D</strong><br>
28565bd8deadSopenharmony_ci  <strong>iimage1D</strong></p></td>
28575bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an integer 1D texture</p></td>
28585bd8deadSopenharmony_ci</tr>
28595bd8deadSopenharmony_ci<tr>
28605bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>isampler1DArray</strong><br>
28615bd8deadSopenharmony_ci  <strong>itexture1DArray</strong><br>
28625bd8deadSopenharmony_ci  <strong>iimage1DArray</strong></p></td>
28635bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an integer 1D array texture</p></td>
28645bd8deadSopenharmony_ci</tr>
28655bd8deadSopenharmony_ci<tr>
28665bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>isampler2D</strong><br>
28675bd8deadSopenharmony_ci  <strong>itexture2D</strong><br>
28685bd8deadSopenharmony_ci  <strong>iimage2D</strong></p></td>
28695bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an integer 2D texture</p></td>
28705bd8deadSopenharmony_ci</tr>
28715bd8deadSopenharmony_ci<tr>
28725bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>isampler2DArray</strong><br>
28735bd8deadSopenharmony_ci  <strong>itexture2DArray</strong><br>
28745bd8deadSopenharmony_ci  <strong>iimage2DArray</strong></p></td>
28755bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an integer 2D array texture</p></td>
28765bd8deadSopenharmony_ci</tr>
28775bd8deadSopenharmony_ci<tr>
28785bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>isampler2DMS</strong><br>
28795bd8deadSopenharmony_ci  <strong>itexture2DMS</strong><br>
28805bd8deadSopenharmony_ci  <strong>iimage2DMS</strong></p></td>
28815bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an integer 2D multisample texture</p></td>
28825bd8deadSopenharmony_ci</tr>
28835bd8deadSopenharmony_ci<tr>
28845bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>isampler2DMSArray</strong><br>
28855bd8deadSopenharmony_ci  <strong>itexture2DMSArray</strong><br>
28865bd8deadSopenharmony_ci  <strong>iimage2DMSArray</strong></p></td>
28875bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an integer 2D multisample array texture</p></td>
28885bd8deadSopenharmony_ci</tr>
28895bd8deadSopenharmony_ci<tr>
28905bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>isampler2DRect</strong><br>
28915bd8deadSopenharmony_ci  <strong>itexture2DRect</strong><br>
28925bd8deadSopenharmony_ci  <strong>iimage2DRect</strong></p></td>
28935bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an integer 2D rectangle texture</p></td>
28945bd8deadSopenharmony_ci</tr>
28955bd8deadSopenharmony_ci<tr>
28965bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>isampler3D</strong><br>
28975bd8deadSopenharmony_ci  <strong>itexture3D</strong><br>
28985bd8deadSopenharmony_ci  <strong>iimage3D</strong></p></td>
28995bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an integer 3D texture</p></td>
29005bd8deadSopenharmony_ci</tr>
29015bd8deadSopenharmony_ci<tr>
29025bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>isamplerCube</strong><br>
29035bd8deadSopenharmony_ci  <strong>itextureCube</strong><br>
29045bd8deadSopenharmony_ci  <strong>iimageCube</strong></p></td>
29055bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an integer cube mapped texture</p></td>
29065bd8deadSopenharmony_ci</tr>
29075bd8deadSopenharmony_ci<tr>
29085bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>isamplerCubeArray</strong><br>
29095bd8deadSopenharmony_ci  <strong>itextureCubeArray</strong><br>
29105bd8deadSopenharmony_ci  <strong>iimageCubeArray</strong></p></td>
29115bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an integer cube map array texture</p></td>
29125bd8deadSopenharmony_ci</tr>
29135bd8deadSopenharmony_ci<tr>
29145bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>isamplerBuffer</strong><br>
29155bd8deadSopenharmony_ci  <strong>itextureBuffer</strong><br>
29165bd8deadSopenharmony_ci  <strong>iimageBuffer</strong></p></td>
29175bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an integer buffer texture</p></td>
29185bd8deadSopenharmony_ci</tr>
29195bd8deadSopenharmony_ci<tr>
29205bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>isubpassInput</strong></p></td>
29215bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an integer subpass input</p></td>
29225bd8deadSopenharmony_ci</tr>
29235bd8deadSopenharmony_ci<tr>
29245bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>isubpassInputMS</strong></p></td>
29255bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a multi-sampled integer subpass input</p></td>
29265bd8deadSopenharmony_ci</tr>
29275bd8deadSopenharmony_ci</tbody>
29285bd8deadSopenharmony_ci</table>
29295bd8deadSopenharmony_ci<div class="paragraph">
29305bd8deadSopenharmony_ci<p><strong>Unsigned Integer Opaque Types</strong></p>
29315bd8deadSopenharmony_ci</div>
29325bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
29335bd8deadSopenharmony_ci<colgroup>
29345bd8deadSopenharmony_ci<col style="width: 50%;">
29355bd8deadSopenharmony_ci<col style="width: 50%;">
29365bd8deadSopenharmony_ci</colgroup>
29375bd8deadSopenharmony_ci<thead>
29385bd8deadSopenharmony_ci<tr>
29395bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Type</th>
29405bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Meaning</th>
29415bd8deadSopenharmony_ci</tr>
29425bd8deadSopenharmony_ci</thead>
29435bd8deadSopenharmony_ci<tbody>
29445bd8deadSopenharmony_ci<tr>
29455bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>usampler1D</strong><br>
29465bd8deadSopenharmony_ci  <strong>utexture1D</strong><br>
29475bd8deadSopenharmony_ci  <strong>uimage1D</strong></p></td>
29485bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an unsigned integer 1D texture</p></td>
29495bd8deadSopenharmony_ci</tr>
29505bd8deadSopenharmony_ci<tr>
29515bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>usampler1DArray</strong><br>
29525bd8deadSopenharmony_ci  <strong>utexture1DArray</strong><br>
29535bd8deadSopenharmony_ci  <strong>uimage1DArray</strong></p></td>
29545bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an unsigned integer 1D array texture</p></td>
29555bd8deadSopenharmony_ci</tr>
29565bd8deadSopenharmony_ci<tr>
29575bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>usampler2D</strong><br>
29585bd8deadSopenharmony_ci  <strong>utexture2D</strong><br>
29595bd8deadSopenharmony_ci  <strong>uimage2D</strong></p></td>
29605bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an unsigned integer 2D texture</p></td>
29615bd8deadSopenharmony_ci</tr>
29625bd8deadSopenharmony_ci<tr>
29635bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>usampler2DArray</strong><br>
29645bd8deadSopenharmony_ci  <strong>utexture1DArray</strong><br>
29655bd8deadSopenharmony_ci  <strong>uimage2DArray</strong></p></td>
29665bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an unsigned integer 2D array texture</p></td>
29675bd8deadSopenharmony_ci</tr>
29685bd8deadSopenharmony_ci<tr>
29695bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>usampler2DMS</strong><br>
29705bd8deadSopenharmony_ci  <strong>utexture2DMS</strong><br>
29715bd8deadSopenharmony_ci  <strong>uimage2DMS</strong></p></td>
29725bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an unsigned integer 2D multisample texture</p></td>
29735bd8deadSopenharmony_ci</tr>
29745bd8deadSopenharmony_ci<tr>
29755bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>usampler2DMSArray</strong><br>
29765bd8deadSopenharmony_ci  <strong>utexture2DMSArray</strong><br>
29775bd8deadSopenharmony_ci  <strong>uimage2DMSArray</strong></p></td>
29785bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an unsigned integer 2D multisample array texture</p></td>
29795bd8deadSopenharmony_ci</tr>
29805bd8deadSopenharmony_ci<tr>
29815bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>usampler2DRect</strong><br>
29825bd8deadSopenharmony_ci  <strong>utexture2DRect</strong><br>
29835bd8deadSopenharmony_ci  <strong>uimage2DRect</strong></p></td>
29845bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an unsigned integer rectangle texture</p></td>
29855bd8deadSopenharmony_ci</tr>
29865bd8deadSopenharmony_ci<tr>
29875bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>usampler3D</strong><br>
29885bd8deadSopenharmony_ci  <strong>utexture3D</strong><br>
29895bd8deadSopenharmony_ci  <strong>uimage3D</strong></p></td>
29905bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an unsigned integer 3D texture</p></td>
29915bd8deadSopenharmony_ci</tr>
29925bd8deadSopenharmony_ci<tr>
29935bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>usamplerCube</strong><br>
29945bd8deadSopenharmony_ci  <strong>utextureCube</strong><br>
29955bd8deadSopenharmony_ci  <strong>uimageCube</strong></p></td>
29965bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an unsigned integer cube mapped texture</p></td>
29975bd8deadSopenharmony_ci</tr>
29985bd8deadSopenharmony_ci<tr>
29995bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>usamplerCubeArray</strong><br>
30005bd8deadSopenharmony_ci  <strong>utextureCubeArray</strong><br>
30015bd8deadSopenharmony_ci  <strong>uimageCubeArray</strong></p></td>
30025bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an unsigned integer cube map array texture</p></td>
30035bd8deadSopenharmony_ci</tr>
30045bd8deadSopenharmony_ci<tr>
30055bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>usamplerBuffer</strong><br>
30065bd8deadSopenharmony_ci  <strong>utextureBuffer</strong><br>
30075bd8deadSopenharmony_ci  <strong>uimageBuffer</strong></p></td>
30085bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an unsigned integer buffer texture</p></td>
30095bd8deadSopenharmony_ci</tr>
30105bd8deadSopenharmony_ci<tr>
30115bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atomic_uint</strong></p></td>
30125bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an unsigned integer atomic counter</p></td>
30135bd8deadSopenharmony_ci</tr>
30145bd8deadSopenharmony_ci<tr>
30155bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>usubpassInput</strong></p></td>
30165bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing an unsigned-integer subpass input</p></td>
30175bd8deadSopenharmony_ci</tr>
30185bd8deadSopenharmony_ci<tr>
30195bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>usubpassInputMS</strong></p></td>
30205bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing a multi-sampled unsigned-integer subpass input</p></td>
30215bd8deadSopenharmony_ci</tr>
30225bd8deadSopenharmony_ci</tbody>
30235bd8deadSopenharmony_ci</table>
30245bd8deadSopenharmony_ci<div class="paragraph">
30255bd8deadSopenharmony_ci<p><strong>Sampler Opaque Types</strong></p>
30265bd8deadSopenharmony_ci</div>
30275bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
30285bd8deadSopenharmony_ci<colgroup>
30295bd8deadSopenharmony_ci<col style="width: 50%;">
30305bd8deadSopenharmony_ci<col style="width: 50%;">
30315bd8deadSopenharmony_ci</colgroup>
30325bd8deadSopenharmony_ci<thead>
30335bd8deadSopenharmony_ci<tr>
30345bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Type</th>
30355bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Meaning</th>
30365bd8deadSopenharmony_ci</tr>
30375bd8deadSopenharmony_ci</thead>
30385bd8deadSopenharmony_ci<tbody>
30395bd8deadSopenharmony_ci<tr>
30405bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sampler</strong></p></td>
30415bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing state describing how to sample a texture</p></td>
30425bd8deadSopenharmony_ci</tr>
30435bd8deadSopenharmony_ci<tr>
30445bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>samplerShadow</strong></p></td>
30455bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a handle for accessing state describing how to sample a depth
30465bd8deadSopenharmony_ci                            texture with comparison</p></td>
30475bd8deadSopenharmony_ci</tr>
30485bd8deadSopenharmony_ci</tbody>
30495bd8deadSopenharmony_ci</table>
30505bd8deadSopenharmony_ci<div class="paragraph">
30515bd8deadSopenharmony_ci<p>In addition, a shader can aggregate these basic types using arrays and
30525bd8deadSopenharmony_cistructures to build more complex types.</p>
30535bd8deadSopenharmony_ci</div>
30545bd8deadSopenharmony_ci<div class="paragraph">
30555bd8deadSopenharmony_ci<p>There are no pointer types.</p>
30565bd8deadSopenharmony_ci</div>
30575bd8deadSopenharmony_ci<div class="paragraph">
30585bd8deadSopenharmony_ci<p>In this specification, an <em>aggregate</em> will mean a structure or array.
30595bd8deadSopenharmony_ci(Matrices and vectors are not by themselves aggregates.) Aggregates,
30605bd8deadSopenharmony_cimatrices, and vectors will collectively be referred to as <em>composites</em>.</p>
30615bd8deadSopenharmony_ci</div>
30625bd8deadSopenharmony_ci<div class="sect3">
30635bd8deadSopenharmony_ci<h4 id="void">4.1.1. Void</h4>
30645bd8deadSopenharmony_ci<div class="paragraph">
30655bd8deadSopenharmony_ci<p>Functions that do not return a value must be declared as <strong>void</strong>.
30665bd8deadSopenharmony_ciThere is no default function return type.
30675bd8deadSopenharmony_ciThe keyword <strong>void</strong> cannot be used in any other declarations (except for
30685bd8deadSopenharmony_ciempty formal or actual parameter lists), or a compile-time error results.</p>
30695bd8deadSopenharmony_ci</div>
30705bd8deadSopenharmony_ci</div>
30715bd8deadSopenharmony_ci<div class="sect3">
30725bd8deadSopenharmony_ci<h4 id="booleans">4.1.2. Booleans</h4>
30735bd8deadSopenharmony_ci<div class="dlist">
30745bd8deadSopenharmony_ci<dl>
30755bd8deadSopenharmony_ci<dt class="hdlist1">Definition</dt>
30765bd8deadSopenharmony_ci<dd>
30775bd8deadSopenharmony_ci<p>A <em>boolean type</em> is any boolean scalar or vector type (<strong>bool</strong>, <strong>bvec2</strong>,
30785bd8deadSopenharmony_ci<strong>bvec3</strong>, <strong>bvec4</strong>)</p>
30795bd8deadSopenharmony_ci</dd>
30805bd8deadSopenharmony_ci</dl>
30815bd8deadSopenharmony_ci</div>
30825bd8deadSopenharmony_ci<div class="paragraph">
30835bd8deadSopenharmony_ci<p>To make conditional execution of code easier to express, the type <strong>bool</strong> is
30845bd8deadSopenharmony_cisupported.
30855bd8deadSopenharmony_ciThere is no expectation that hardware directly supports variables of this
30865bd8deadSopenharmony_citype.
30875bd8deadSopenharmony_ciIt is a genuine Boolean type, holding only one of two values meaning either
30885bd8deadSopenharmony_citrue or false.
30895bd8deadSopenharmony_ciTwo keywords <strong>true</strong> and <strong>false</strong> can be used as literal Boolean constants.
30905bd8deadSopenharmony_ciBooleans are declared and optionally initialized as in the follow example:</p>
30915bd8deadSopenharmony_ci</div>
30925bd8deadSopenharmony_ci<div class="listingblock">
30935bd8deadSopenharmony_ci<div class="content">
30945bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">bool</span> success;      <span class="comment">// declare &quot;success&quot; to be a Boolean</span>
30955bd8deadSopenharmony_ci<span class="predefined-type">bool</span> done = <span class="predefined-constant">false</span>; <span class="comment">// declare and initialize &quot;done&quot;</span></code></pre>
30965bd8deadSopenharmony_ci</div>
30975bd8deadSopenharmony_ci</div>
30985bd8deadSopenharmony_ci<div class="paragraph">
30995bd8deadSopenharmony_ci<p>Expressions used for conditional jumps (<strong>if</strong>, <strong>for</strong>, <strong>?:</strong>, <strong>while</strong>,
31005bd8deadSopenharmony_ci<strong>do</strong>-<strong>while</strong>) must evaluate to the type <strong>bool</strong>.</p>
31015bd8deadSopenharmony_ci</div>
31025bd8deadSopenharmony_ci</div>
31035bd8deadSopenharmony_ci<div class="sect3">
31045bd8deadSopenharmony_ci<h4 id="integers">4.1.3. Integers</h4>
31055bd8deadSopenharmony_ci<div class="dlist">
31065bd8deadSopenharmony_ci<dl>
31075bd8deadSopenharmony_ci<dt class="hdlist1">Definitions</dt>
31085bd8deadSopenharmony_ci<dd>
31095bd8deadSopenharmony_ci<p>An <em>integral type</em> is any signed or unsigned, scalar or vector integer type.
31105bd8deadSopenharmony_ciIt excludes arrays and structures.</p>
31115bd8deadSopenharmony_ci</dd>
31125bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
31135bd8deadSopenharmony_ci<dd>
31145bd8deadSopenharmony_ci<p>A <em>scalar integral type</em> is a scalar signed or unsigned integer type:</p>
31155bd8deadSopenharmony_ci</dd>
31165bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
31175bd8deadSopenharmony_ci<dd>
31185bd8deadSopenharmony_ci<p>A <em>vector integral type</em> is a vector of signed or unsigned integers:</p>
31195bd8deadSopenharmony_ci</dd>
31205bd8deadSopenharmony_ci</dl>
31215bd8deadSopenharmony_ci</div>
31225bd8deadSopenharmony_ci<div class="paragraph">
31235bd8deadSopenharmony_ci<p>Signed and unsigned integer variables are fully supported.
31245bd8deadSopenharmony_ciIn this document, the term <em>integer</em> is meant to generally include both
31255bd8deadSopenharmony_cisigned and unsigned integers.</p>
31265bd8deadSopenharmony_ci</div>
31275bd8deadSopenharmony_ci<div class="paragraph">
31285bd8deadSopenharmony_ci<p>For OpenGL, unsigned integers have exactly 32 bits of precision.
31295bd8deadSopenharmony_ciWhen targeting Vulkan, <strong>highp</strong>
31305bd8deadSopenharmony_ciunsigned integers have exactly 32 bits of precision.</p>
31315bd8deadSopenharmony_ci</div>
31325bd8deadSopenharmony_ci<div class="paragraph">
31335bd8deadSopenharmony_ci<p>For OpenGL, signed integers use 32 bits, including a sign bit, in two&#8217;s complement form.
31345bd8deadSopenharmony_ciWhen targeting Vulkan, <strong>highp</strong>
31355bd8deadSopenharmony_cisigned integers use 32 bits, including a sign bit, in two&#8217;s complement form.</p>
31365bd8deadSopenharmony_ci</div>
31375bd8deadSopenharmony_ci<div class="paragraph">
31385bd8deadSopenharmony_ci<p>When targeting Vulkan, <strong>mediump</strong> and <strong>lowp</strong> integers are as defined by the
31395bd8deadSopenharmony_ciSPIR-V <strong>RelaxedPrecision</strong> decoration.</p>
31405bd8deadSopenharmony_ci</div>
31415bd8deadSopenharmony_ci<div class="paragraph">
31425bd8deadSopenharmony_ci<p>Addition,
31435bd8deadSopenharmony_cisubtraction and multiplication resulting in overflow or
31445bd8deadSopenharmony_ciunderflow will result in the low-order
31455bd8deadSopenharmony_ci32
31465bd8deadSopenharmony_cibits of the correct result R, where
31475bd8deadSopenharmony_ciR is computed with enough precision to avoid overflow or underflow.
31485bd8deadSopenharmony_ciDivision resulting in overflow will result in an undefined value.</p>
31495bd8deadSopenharmony_ci</div>
31505bd8deadSopenharmony_ci<div class="paragraph">
31515bd8deadSopenharmony_ci<p>Integers are declared and optionally initialized with integer expressions,
31525bd8deadSopenharmony_cias in the following example:</p>
31535bd8deadSopenharmony_ci</div>
31545bd8deadSopenharmony_ci<div class="listingblock">
31555bd8deadSopenharmony_ci<div class="content">
31565bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">int</span> i, j = <span class="integer">42</span>; <span class="comment">// default integer literal type is int</span>
31575bd8deadSopenharmony_ciuint k = <span class="integer">3</span>u;   <span class="comment">// &quot;u&quot; establishes the type as uint</span></code></pre>
31585bd8deadSopenharmony_ci</div>
31595bd8deadSopenharmony_ci</div>
31605bd8deadSopenharmony_ci<div class="paragraph">
31615bd8deadSopenharmony_ci<p>Literal integer constants can be expressed in decimal (base 10), octal (base
31625bd8deadSopenharmony_ci8), or hexadecimal (base 16) as follows.</p>
31635bd8deadSopenharmony_ci</div>
31645bd8deadSopenharmony_ci<div class="openblock bnf">
31655bd8deadSopenharmony_ci<div class="content">
31665bd8deadSopenharmony_ci<div class="dlist">
31675bd8deadSopenharmony_ci<dl>
31685bd8deadSopenharmony_ci<dt class="hdlist1"><em>integer-constant</em> : </dt>
31695bd8deadSopenharmony_ci<dd>
31705bd8deadSopenharmony_ci<p><em>decimal-constant</em> <em>integer-suffix<sub>opt</sub></em><br>
31715bd8deadSopenharmony_ci<em>octal-constant</em> <em>integer-suffix<sub>opt</sub></em><br>
31725bd8deadSopenharmony_ci<em>hexadecimal-constant</em> <em>integer-suffix<sub>opt</sub></em></p>
31735bd8deadSopenharmony_ci</dd>
31745bd8deadSopenharmony_ci<dt class="hdlist1"><em>integer-suffix</em> : one of </dt>
31755bd8deadSopenharmony_ci<dd>
31765bd8deadSopenharmony_ci<p><strong>u</strong> <strong>U</strong></p>
31775bd8deadSopenharmony_ci</dd>
31785bd8deadSopenharmony_ci<dt class="hdlist1"><em>decimal-constant</em> : </dt>
31795bd8deadSopenharmony_ci<dd>
31805bd8deadSopenharmony_ci<p><em>nonzero-digit</em><br>
31815bd8deadSopenharmony_ci<em>decimal-constant</em> <em>digit</em></p>
31825bd8deadSopenharmony_ci</dd>
31835bd8deadSopenharmony_ci<dt class="hdlist1"><em>octal-constant</em> : </dt>
31845bd8deadSopenharmony_ci<dd>
31855bd8deadSopenharmony_ci<p><strong>0</strong><br>
31865bd8deadSopenharmony_ci<em>octal-constant</em> <em>octal-digit</em></p>
31875bd8deadSopenharmony_ci</dd>
31885bd8deadSopenharmony_ci<dt class="hdlist1"><em>hexadecimal-constant</em> : </dt>
31895bd8deadSopenharmony_ci<dd>
31905bd8deadSopenharmony_ci<p><strong>0x</strong> <em>hexadecimal-digit</em><br>
31915bd8deadSopenharmony_ci<strong>0X</strong> <em>hexadecimal-digit</em><br>
31925bd8deadSopenharmony_ci<em>hexadecimal-constant</em> <em>hexadecimal-digit</em></p>
31935bd8deadSopenharmony_ci</dd>
31945bd8deadSopenharmony_ci<dt class="hdlist1"><em>digit</em> : </dt>
31955bd8deadSopenharmony_ci<dd>
31965bd8deadSopenharmony_ci<p><strong>0</strong><br>
31975bd8deadSopenharmony_ci<em>nonzero-digit</em></p>
31985bd8deadSopenharmony_ci</dd>
31995bd8deadSopenharmony_ci<dt class="hdlist1"><em>nonzero-digit</em> : one of </dt>
32005bd8deadSopenharmony_ci<dd>
32015bd8deadSopenharmony_ci<p><strong>1 2 3 4 5 6 7 8 9</strong></p>
32025bd8deadSopenharmony_ci</dd>
32035bd8deadSopenharmony_ci<dt class="hdlist1"><em>octal-digit</em> : one of </dt>
32045bd8deadSopenharmony_ci<dd>
32055bd8deadSopenharmony_ci<p><strong>0 1 2 3 4 5 6 7</strong></p>
32065bd8deadSopenharmony_ci</dd>
32075bd8deadSopenharmony_ci<dt class="hdlist1"><em>hexadecimal-digit</em> : one of </dt>
32085bd8deadSopenharmony_ci<dd>
32095bd8deadSopenharmony_ci<p><strong>0 1 2 3 4 5 6 7 8 9<br>
32105bd8deadSopenharmony_cia b c d e f<br>
32115bd8deadSopenharmony_ciA B C D E F</strong></p>
32125bd8deadSopenharmony_ci</dd>
32135bd8deadSopenharmony_ci</dl>
32145bd8deadSopenharmony_ci</div>
32155bd8deadSopenharmony_ci</div>
32165bd8deadSopenharmony_ci</div>
32175bd8deadSopenharmony_ci<div class="paragraph">
32185bd8deadSopenharmony_ci<p>No white space is allowed between the digits of an integer constant,
32195bd8deadSopenharmony_ciincluding after the leading <strong>0</strong> or after the leading <strong>0x</strong> or <strong>0X</strong> of a
32205bd8deadSopenharmony_ciconstant, or before the suffix <strong>u</strong> or <strong>U</strong>.
32215bd8deadSopenharmony_ciWhen tokenizing, the maximal token matching the above will be recognized
32225bd8deadSopenharmony_cibefore a new token is started.
32235bd8deadSopenharmony_ciWhen the suffix <strong>u</strong> or <strong>U</strong> is present, the literal has type <strong>uint</strong>,
32245bd8deadSopenharmony_ciotherwise the type is <strong>int</strong>.
32255bd8deadSopenharmony_ciA leading unary minus sign (-) is interpreted as an arithmetic unary
32265bd8deadSopenharmony_cinegation, not as part of the constant.
32275bd8deadSopenharmony_ciHence, literals themselves are always expressed with non-negative syntax,
32285bd8deadSopenharmony_cithough they could result in a negative value.</p>
32295bd8deadSopenharmony_ci</div>
32305bd8deadSopenharmony_ci<div class="paragraph">
32315bd8deadSopenharmony_ci<p>It is a compile-time error to provide a literal integer whose bit pattern
32325bd8deadSopenharmony_cicannot fit in 32 bits.
32335bd8deadSopenharmony_ciThe bit pattern of the literal is always used unmodified.
32345bd8deadSopenharmony_ciSo a signed literal whose bit pattern includes a set sign bit creates a
32355bd8deadSopenharmony_cinegative value.</p>
32365bd8deadSopenharmony_ci</div>
32375bd8deadSopenharmony_ci<div class="paragraph">
32385bd8deadSopenharmony_ci<p>For example,</p>
32395bd8deadSopenharmony_ci</div>
32405bd8deadSopenharmony_ci<div class="listingblock">
32415bd8deadSopenharmony_ci<div class="content">
32425bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="integer">1</span>             <span class="comment">// OK. Signed integer, value 1</span>
32435bd8deadSopenharmony_ci<span class="integer">1</span>u            <span class="comment">// OK. Unsigned integer, value 1</span>
32445bd8deadSopenharmony_ci-<span class="integer">1</span>            <span class="comment">// OK. Unary minus applied to signed integer.</span>
32455bd8deadSopenharmony_ci              <span class="comment">// result is a signed integer, value -1</span>
32465bd8deadSopenharmony_ci-<span class="integer">1</span>u           <span class="comment">// OK. Unary minus applies to unsigned integer.</span>
32475bd8deadSopenharmony_ci              <span class="comment">// Result is an unsigned integer, value 0xffffffff</span>
32485bd8deadSopenharmony_ci<span class="hex">0xA0000000</span>    <span class="comment">// OK. 32-bit signed hexadecimal</span>
32495bd8deadSopenharmony_ci<span class="hex">0xABcdEF00</span>u   <span class="comment">// OK. 32-bit unsigned hexadecimal</span>
32505bd8deadSopenharmony_ci<span class="hex">0xffffffff</span>    <span class="comment">// OK. Signed integer, value -1</span>
32515bd8deadSopenharmony_ci<span class="hex">0x80000000</span>    <span class="comment">// OK. Evaluates to -2147483648</span>
32525bd8deadSopenharmony_ci<span class="hex">0xffffffff</span>u   <span class="comment">// OK. Unsigned integer, value 0xffffffff</span>
32535bd8deadSopenharmony_ci<span class="hex">0xfffffffff</span>   <span class="comment">// Error: needs more than 32 bits</span>
32545bd8deadSopenharmony_ci<span class="integer">3000000000</span>    <span class="comment">// OK. A signed decimal literal taking 32 bits.</span>
32555bd8deadSopenharmony_ci              <span class="comment">// It evaluates to -1294967296</span>
32565bd8deadSopenharmony_ci<span class="integer">2147483648</span>    <span class="comment">// OK. Evaluates to -2147483648 (the literal set the sign bit)</span>
32575bd8deadSopenharmony_ci<span class="integer">5000000000</span>    <span class="comment">// Error: needs more than 32 bits</span></code></pre>
32585bd8deadSopenharmony_ci</div>
32595bd8deadSopenharmony_ci</div>
32605bd8deadSopenharmony_ci</div>
32615bd8deadSopenharmony_ci<div class="sect3">
32625bd8deadSopenharmony_ci<h4 id="floats">4.1.4. Floats</h4>
32635bd8deadSopenharmony_ci<div class="paragraph">
32645bd8deadSopenharmony_ci<p>Single-precision and double-precision floating-point variables are available
32655bd8deadSopenharmony_cifor use in a variety of scalar calculations.
32665bd8deadSopenharmony_ciGenerally, the term <em>floating-point</em> will refer to both single- and
32675bd8deadSopenharmony_cidouble-precision floating-point.
32685bd8deadSopenharmony_ciFloating-point variables are defined as in the following examples:</p>
32695bd8deadSopenharmony_ci</div>
32705bd8deadSopenharmony_ci<div class="listingblock">
32715bd8deadSopenharmony_ci<div class="content">
32725bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">float</span> a, b = <span class="float">1</span><span class="float">.5</span>;    <span class="comment">// single-precision floating-point</span>
32735bd8deadSopenharmony_ci<span class="predefined-type">double</span> c, d = <span class="float">2</span><span class="float">.0</span>LF; <span class="comment">// double-precision floating-point</span></code></pre>
32745bd8deadSopenharmony_ci</div>
32755bd8deadSopenharmony_ci</div>
32765bd8deadSopenharmony_ci<div class="paragraph">
32775bd8deadSopenharmony_ci<p>As an input value to one of the processing units, a single-precision or
32785bd8deadSopenharmony_cidouble-precision floating-point variable is expected to match the
32795bd8deadSopenharmony_cicorresponding IEEE 754 floating-point definition for precision and dynamic
32805bd8deadSopenharmony_cirange.
32815bd8deadSopenharmony_ciFloating-point variables within a shader are also encoded according to the
32825bd8deadSopenharmony_ciIEEE 754 specification for single-precision floating-point values</p>
32835bd8deadSopenharmony_ci</div>
32845bd8deadSopenharmony_ci<div class="paragraph">
32855bd8deadSopenharmony_ci<p>(logically, not necessarily physically).
32865bd8deadSopenharmony_ciWhile encodings are logically IEEE 754, operations (addition,
32875bd8deadSopenharmony_cimultiplication, etc.) are not necessarily performed as required by IEEE 754.
32885bd8deadSopenharmony_ciSee &#8220;<a href="#range-and-precision">Range and Precision</a>&#8221; for more details on
32895bd8deadSopenharmony_ciprecision and usage of NaNs (Not a Number) and Infs (positive or negative
32905bd8deadSopenharmony_ciinfinities).</p>
32915bd8deadSopenharmony_ci</div>
32925bd8deadSopenharmony_ci<div class="paragraph">
32935bd8deadSopenharmony_ci<p>Floating-point constants are defined as follows.</p>
32945bd8deadSopenharmony_ci</div>
32955bd8deadSopenharmony_ci<div class="openblock bnf">
32965bd8deadSopenharmony_ci<div class="content">
32975bd8deadSopenharmony_ci<div class="dlist">
32985bd8deadSopenharmony_ci<dl>
32995bd8deadSopenharmony_ci<dt class="hdlist1"><em>floating-constant</em> : </dt>
33005bd8deadSopenharmony_ci<dd>
33015bd8deadSopenharmony_ci<p><em>fractional-constant</em> <em>exponent-part<sub>opt</sub></em> <em>floating-suffix<sub>opt</sub></em><br>
33025bd8deadSopenharmony_ci<em>digit-sequence</em> <em>exponent-part</em> <em>floating-suffix<sub>opt</sub></em></p>
33035bd8deadSopenharmony_ci</dd>
33045bd8deadSopenharmony_ci<dt class="hdlist1"><em>fractional-constant</em> : </dt>
33055bd8deadSopenharmony_ci<dd>
33065bd8deadSopenharmony_ci<p><em>digit-sequence</em> <strong>.</strong> <em>digit-sequence</em><br>
33075bd8deadSopenharmony_ci<em>digit-sequence</em> <strong>.</strong><br>
33085bd8deadSopenharmony_ci<strong>.</strong> <em>digit-sequence</em></p>
33095bd8deadSopenharmony_ci</dd>
33105bd8deadSopenharmony_ci<dt class="hdlist1"><em>exponent-part</em> : </dt>
33115bd8deadSopenharmony_ci<dd>
33125bd8deadSopenharmony_ci<p><strong>e</strong> <em>sign<sub>opt</sub></em> <em>digit-sequence</em><br>
33135bd8deadSopenharmony_ci<strong>E</strong> <em>sign<sub>opt</sub></em> <em>digit-sequence</em></p>
33145bd8deadSopenharmony_ci</dd>
33155bd8deadSopenharmony_ci<dt class="hdlist1"><em>sign</em> : one of </dt>
33165bd8deadSopenharmony_ci<dd>
33175bd8deadSopenharmony_ci<p><strong>+</strong> <strong>-</strong></p>
33185bd8deadSopenharmony_ci</dd>
33195bd8deadSopenharmony_ci<dt class="hdlist1"><em>digit-sequence</em> : </dt>
33205bd8deadSopenharmony_ci<dd>
33215bd8deadSopenharmony_ci<p><em>digit</em><br>
33225bd8deadSopenharmony_ci<em>digit-sequence</em> <em>digit</em></p>
33235bd8deadSopenharmony_ci</dd>
33245bd8deadSopenharmony_ci<dt class="hdlist1"><em>floating-suffix</em> : one of </dt>
33255bd8deadSopenharmony_ci<dd>
33265bd8deadSopenharmony_ci<p>    <strong>f</strong> <strong>F</strong>
33275bd8deadSopenharmony_ci<strong>lf</strong> <strong>LF</strong></p>
33285bd8deadSopenharmony_ci</dd>
33295bd8deadSopenharmony_ci</dl>
33305bd8deadSopenharmony_ci</div>
33315bd8deadSopenharmony_ci</div>
33325bd8deadSopenharmony_ci</div>
33335bd8deadSopenharmony_ci<div class="paragraph">
33345bd8deadSopenharmony_ci<p>A decimal point (<strong>.</strong>) is not needed if the exponent part is present.
33355bd8deadSopenharmony_ciNo white space may appear anywhere within a floating-point constant,
33365bd8deadSopenharmony_ciincluding before a suffix.
33375bd8deadSopenharmony_ciWhen tokenizing, the maximal token matching the above will be recognized
33385bd8deadSopenharmony_cibefore a new token is started.
33395bd8deadSopenharmony_ciWhen the suffix "lf" or "LF" is present, the literal has type <strong>double</strong>.
33405bd8deadSopenharmony_ciOtherwise, the literal has type <strong>float</strong>.
33415bd8deadSopenharmony_ciA leading unary minus sign (<strong>-</strong>) is interpreted as a unary operator and is
33425bd8deadSopenharmony_cinot part of the floating-point constant.</p>
33435bd8deadSopenharmony_ci</div>
33445bd8deadSopenharmony_ci</div>
33455bd8deadSopenharmony_ci<div class="sect3">
33465bd8deadSopenharmony_ci<h4 id="vectors">4.1.5. Vectors</h4>
33475bd8deadSopenharmony_ci<div class="paragraph">
33485bd8deadSopenharmony_ci<p>The OpenGL Shading Language includes data types for generic 2-, 3-, and 4-component vectors
33495bd8deadSopenharmony_ciof floating-point values, integers, and Booleans.
33505bd8deadSopenharmony_ciFloating-point vector variables can be used to store colors, normals,
33515bd8deadSopenharmony_cipositions, texture coordinates, texture lookup results and the like.
33525bd8deadSopenharmony_ciBoolean vectors can be used for component-wise comparisons of numeric
33535bd8deadSopenharmony_civectors.
33545bd8deadSopenharmony_ciSome examples of vector declarations are:</p>
33555bd8deadSopenharmony_ci</div>
33565bd8deadSopenharmony_ci<div class="listingblock">
33575bd8deadSopenharmony_ci<div class="content">
33585bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec2 texcoord1, texcoord2;
33595bd8deadSopenharmony_civec3 position;
33605bd8deadSopenharmony_civec4 myRGBA;
33615bd8deadSopenharmony_ciivec2 textureLookup;
33625bd8deadSopenharmony_cibvec3 less;</code></pre>
33635bd8deadSopenharmony_ci</div>
33645bd8deadSopenharmony_ci</div>
33655bd8deadSopenharmony_ci<div class="paragraph">
33665bd8deadSopenharmony_ci<p>Initialization of vectors can be done with constructors.
33675bd8deadSopenharmony_ciSee &#8220;<a href="#vector-and-matrix-constructors">Vector and Matrix Constructors</a>&#8221;.</p>
33685bd8deadSopenharmony_ci</div>
33695bd8deadSopenharmony_ci</div>
33705bd8deadSopenharmony_ci<div class="sect3">
33715bd8deadSopenharmony_ci<h4 id="matrices">4.1.6. Matrices</h4>
33725bd8deadSopenharmony_ci<div class="paragraph">
33735bd8deadSopenharmony_ci<p>The OpenGL Shading Language has built-in types for 2 × 2, 2 × 3, 2 × 4, 3
33745bd8deadSopenharmony_ci× 2, 3 × 3, 3 × 4, 4 × 2, 4 × 3, and 4 ×
33755bd8deadSopenharmony_ci4 matrices of floating-point numbers.
33765bd8deadSopenharmony_ciMatrix types beginning with "<strong>mat</strong>" have single-precision components while
33775bd8deadSopenharmony_cimatrix types beginning with "<strong>dmat</strong>" have double-precision components.
33785bd8deadSopenharmony_ciThe first number in the type is the number of columns, the second is the
33795bd8deadSopenharmony_cinumber of rows.
33805bd8deadSopenharmony_ciIf there is only one number, the matrix is square.
33815bd8deadSopenharmony_ciExample matrix declarations:</p>
33825bd8deadSopenharmony_ci</div>
33835bd8deadSopenharmony_ci<div class="listingblock">
33845bd8deadSopenharmony_ci<div class="content">
33855bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">mat2 mat2D;
33865bd8deadSopenharmony_cimat3 optMatrix;
33875bd8deadSopenharmony_cimat4 view, projection;
33885bd8deadSopenharmony_cimat4x4 view; <span class="comment">// an alternate way of declaring a mat4</span>
33895bd8deadSopenharmony_cimat3x2 m;    <span class="comment">// a matrix with 3 columns and 2 rows</span>
33905bd8deadSopenharmony_cidmat4 highPrecisionMVP;
33915bd8deadSopenharmony_cidmat2x4 dm;</code></pre>
33925bd8deadSopenharmony_ci</div>
33935bd8deadSopenharmony_ci</div>
33945bd8deadSopenharmony_ci<div class="paragraph">
33955bd8deadSopenharmony_ci<p>Initialization of matrix values is done with constructors (described in
33965bd8deadSopenharmony_ci&#8220;<a href="#vector-and-matrix-constructors">Vector and Matrix Constructors</a>&#8221;) in
33975bd8deadSopenharmony_cicolumn-major order.</p>
33985bd8deadSopenharmony_ci</div>
33995bd8deadSopenharmony_ci</div>
34005bd8deadSopenharmony_ci<div class="sect3">
34015bd8deadSopenharmony_ci<h4 id="opaque-types">4.1.7. Opaque Types</h4>
34025bd8deadSopenharmony_ci<div class="dlist">
34035bd8deadSopenharmony_ci<dl>
34045bd8deadSopenharmony_ci<dt class="hdlist1">Definition</dt>
34055bd8deadSopenharmony_ci<dd>
34065bd8deadSopenharmony_ci<p>An <em>opaque type</em> is a type where the internal structure of the type is
34075bd8deadSopenharmony_cihidden from the language.</p>
34085bd8deadSopenharmony_ci</dd>
34095bd8deadSopenharmony_ci</dl>
34105bd8deadSopenharmony_ci</div>
34115bd8deadSopenharmony_ci<div class="paragraph">
34125bd8deadSopenharmony_ci<p>The opaque types, as listed in the following sections, declare variables
34135bd8deadSopenharmony_cithat are effectively opaque handles to other objects.
34145bd8deadSopenharmony_ciThese objects are accessed through built-in functions, not through direct
34155bd8deadSopenharmony_cireading or writing of the declared variable.
34165bd8deadSopenharmony_ciThey can only be declared as function parameters or in <strong>uniform</strong>-qualified
34175bd8deadSopenharmony_civariables (see &#8220;<a href="#uniform-variables">Uniform Variables</a>&#8221;).
34185bd8deadSopenharmony_ciThe only opaque types that take memory qualifiers are the image types.
34195bd8deadSopenharmony_ciExcept for array indexing, structure member selection, and parentheses,
34205bd8deadSopenharmony_ciopaque variables are not allowed to be operands in expressions; such use
34215bd8deadSopenharmony_ciresults in a compile-time error.</p>
34225bd8deadSopenharmony_ci</div>
34235bd8deadSopenharmony_ci<div class="paragraph">
34245bd8deadSopenharmony_ci<p>Opaque variables cannot be treated as l-values; hence cannot be used as
34255bd8deadSopenharmony_ci<strong>out</strong> or <strong>inout</strong> function parameters, nor can they be assigned into.
34265bd8deadSopenharmony_ciAny such use results in a compile-time error.
34275bd8deadSopenharmony_ciHowever, they can be passed as <strong>in</strong> parameters with matching types and
34285bd8deadSopenharmony_cimemory qualifiers.
34295bd8deadSopenharmony_ciThey cannot be declared with an initializer.</p>
34305bd8deadSopenharmony_ci</div>
34315bd8deadSopenharmony_ci<div class="paragraph">
34325bd8deadSopenharmony_ci<p>Because a single opaque type declaration effectively declares two objects,
34335bd8deadSopenharmony_cithe opaque handle itself and the object it is a handle to, there is room for
34345bd8deadSopenharmony_ciboth a storage qualifier and a memory qualifier.
34355bd8deadSopenharmony_ciThe storage qualifier will qualify the opaque handle, while the memory
34365bd8deadSopenharmony_ciqualifier will qualify the object it is a handle to.</p>
34375bd8deadSopenharmony_ci</div>
34385bd8deadSopenharmony_ci<div class="sect4">
34395bd8deadSopenharmony_ci<h5 id="samplers">Texture-Combined Samplers</h5>
34405bd8deadSopenharmony_ci<div class="paragraph">
34415bd8deadSopenharmony_ci<p>Texture-combined sampler types (e.g. <strong>sampler2D</strong>) are the sampler types
34425bd8deadSopenharmony_cidescribed in the Basic Types tables as handles for accessing textures.
34435bd8deadSopenharmony_ci(They do not include <strong>sampler</strong> and <strong>samplerShadow</strong>.)
34445bd8deadSopenharmony_ciThere are distinct texture-combined sampler types for each texture target,
34455bd8deadSopenharmony_ciand for each of float, integer, and unsigned integer data types.
34465bd8deadSopenharmony_ciTexture accesses are done through built-in texture functions (described in
34475bd8deadSopenharmony_ci&#8220;<a href="#texture-functions">Texture Functions</a>&#8221;) and texture-combined samplers
34485bd8deadSopenharmony_ciare used to specify which texture to access and how it is to be filtered.</p>
34495bd8deadSopenharmony_ci</div>
34505bd8deadSopenharmony_ci<div class="paragraph">
34515bd8deadSopenharmony_ci<p>Texture-combined sampler types are opaque types,
34525bd8deadSopenharmony_cideclared and behaving as described above for opaque types.
34535bd8deadSopenharmony_ciWhen aggregated into arrays within a shader, they can only be indexed
34545bd8deadSopenharmony_ciwith a dynamically uniform integral expression, otherwise results are
34555bd8deadSopenharmony_ciundefined.</p>
34565bd8deadSopenharmony_ci</div>
34575bd8deadSopenharmony_ci</div>
34585bd8deadSopenharmony_ci<div class="sect4">
34595bd8deadSopenharmony_ci<h5 id="images">Images</h5>
34605bd8deadSopenharmony_ci<div class="paragraph">
34615bd8deadSopenharmony_ci<p>Image types are opaque types, declared and behaving as described above for
34625bd8deadSopenharmony_ciopaque types.
34635bd8deadSopenharmony_ciThey can be further qualified with memory qualifiers.
34645bd8deadSopenharmony_ciWhen aggregated into arrays within a shader, images can only be indexed with
34655bd8deadSopenharmony_cia dynamically uniform integral expression, otherwise results are undefined.</p>
34665bd8deadSopenharmony_ci</div>
34675bd8deadSopenharmony_ci<div class="paragraph">
34685bd8deadSopenharmony_ci<p>Image variables are handles to
34695bd8deadSopenharmony_cione-,
34705bd8deadSopenharmony_citwo-, or three-dimensional images
34715bd8deadSopenharmony_cicorresponding to all or a portion of a single level of a texture image bound
34725bd8deadSopenharmony_cito an image unit.
34735bd8deadSopenharmony_ciThere are distinct image variable types for each texture target, and for
34745bd8deadSopenharmony_cieach of float, integer, and unsigned integer data types.
34755bd8deadSopenharmony_ciImage accesses should use an image type that matches the target of the
34765bd8deadSopenharmony_citexture whose level is bound to the image unit, or for non-layered bindings
34775bd8deadSopenharmony_ciof 3D or array images should use the image type that matches the
34785bd8deadSopenharmony_cidimensionality of the layer of the image (i.e., a layer of 3D, 2DArray,
34795bd8deadSopenharmony_ciCube, or CubeArray should use
34805bd8deadSopenharmony_ci<strong>image2D</strong>, a layer of 1DArray should use <strong>image1D</strong>, and a layer of 2DMSArray
34815bd8deadSopenharmony_cishould use <strong>image2DMS</strong>).
34825bd8deadSopenharmony_ciIf the image target type does not match the bound image in this manner, if
34835bd8deadSopenharmony_cithe data type does not match the bound image, or if the format layout
34845bd8deadSopenharmony_ciqualifier does not match the image unit format as described in section
34855bd8deadSopenharmony_ci8.25
34865bd8deadSopenharmony_ci&#8220;Texture Image Loads and Stores&#8221; of the <a href="#references">OpenGL Specification</a>, the
34875bd8deadSopenharmony_ciresults of image accesses are undefined but cannot include program
34885bd8deadSopenharmony_citermination.</p>
34895bd8deadSopenharmony_ci</div>
34905bd8deadSopenharmony_ci<div class="paragraph">
34915bd8deadSopenharmony_ci<p>Image variables are used in the image load, store, and atomic functions
34925bd8deadSopenharmony_cidescribed in &#8220;<a href="#image-functions">Image Functions</a>&#8221; to specify an image to
34935bd8deadSopenharmony_ciaccess.</p>
34945bd8deadSopenharmony_ci</div>
34955bd8deadSopenharmony_ci</div>
34965bd8deadSopenharmony_ci<div class="sect4">
34975bd8deadSopenharmony_ci<h5 id="atomic-counters">Atomic Counters</h5>
34985bd8deadSopenharmony_ci<div class="paragraph">
34995bd8deadSopenharmony_ci<p>Atomic counter types (e.g. <strong>atomic_uint</strong>) are opaque handles to counters,
35005bd8deadSopenharmony_cideclared and behaving as described above for opaque types.
35015bd8deadSopenharmony_ciThe variables they declare specify which counter to access when using the
35025bd8deadSopenharmony_cibuilt-in atomic counter functions as described in
35035bd8deadSopenharmony_ci&#8220;<a href="#atomic-counter-functions">Atomic Counter Functions</a>&#8221;.
35045bd8deadSopenharmony_ciThey are bound to buffers as described in
35055bd8deadSopenharmony_ci&#8220;<a href="#atomic-counter-layout-qualifiers">Atomic Counter Layout Qualifiers</a>&#8221;.</p>
35065bd8deadSopenharmony_ci</div>
35075bd8deadSopenharmony_ci<div class="paragraph">
35085bd8deadSopenharmony_ci<p>Atomic counters aggregated into arrays within a shader can only be indexed
35095bd8deadSopenharmony_ciwith dynamically uniform integral expressions, otherwise results are
35105bd8deadSopenharmony_ciundefined.</p>
35115bd8deadSopenharmony_ci</div>
35125bd8deadSopenharmony_ci<div class="paragraph">
35135bd8deadSopenharmony_ci<p>Members of structures cannot be declared as atomic counter types.</p>
35145bd8deadSopenharmony_ci</div>
35155bd8deadSopenharmony_ci<div class="paragraph">
35165bd8deadSopenharmony_ci<p>Atomic counter types are not available when targeting Vulkan.</p>
35175bd8deadSopenharmony_ci</div>
35185bd8deadSopenharmony_ci</div>
35195bd8deadSopenharmony_ci<div class="sect4">
35205bd8deadSopenharmony_ci<h5 id="_texture_sampler_and_samplershadow_types">Texture, <strong>sampler</strong>, and <strong>samplerShadow</strong> Types</h5>
35215bd8deadSopenharmony_ci<div class="paragraph">
35225bd8deadSopenharmony_ci<p>Texture (e.g., <strong>texture2D</strong>), <strong>sampler</strong>, and <strong>samplerShadow</strong> types are opaque
35235bd8deadSopenharmony_citypes, declared and behaving as described above for opaque types.
35245bd8deadSopenharmony_ciThese types are only available when targeting Vulkan.
35255bd8deadSopenharmony_ciWhen aggregated into arrays within a shader, these types can only be indexed
35265bd8deadSopenharmony_ciwith a dynamically uniform expression, or texture lookup will result in
35275bd8deadSopenharmony_ciundefined values.
35285bd8deadSopenharmony_ciTexture variables are handles to one-, two-, and three-dimensional textures,
35295bd8deadSopenharmony_cicube maps, etc., as enumerated in the basic types tables.
35305bd8deadSopenharmony_ciThere are distinct texture types for each texture target, and for each of
35315bd8deadSopenharmony_cifloat, integer, and unsigned integer data types.
35325bd8deadSopenharmony_ciTextures can be combined with a variable of type <strong>sampler</strong> or <strong>samplerShadow</strong>
35335bd8deadSopenharmony_cito create a texture-combined sampler type (e.g., sampler2D, or sampler2DShadow).
35345bd8deadSopenharmony_ciThis is done with a constructor, e.g., <code>sampler2D(texture2D, sampler)</code>,
35355bd8deadSopenharmony_ci<code>sampler2DShadow(texture2D, sampler)</code>, <code>sampler2DShadow(texture2D, samplerShadow)</code>,
35365bd8deadSopenharmony_cior <code>sampler2D(texture2D, samplerShadow)</code> and is described in more detail
35375bd8deadSopenharmony_ciin section 5.4 "Constructors".</p>
35385bd8deadSopenharmony_ci</div>
35395bd8deadSopenharmony_ci</div>
35405bd8deadSopenharmony_ci<div class="sect4">
35415bd8deadSopenharmony_ci<h5 id="_subpass_inputs">Subpass Inputs</h5>
35425bd8deadSopenharmony_ci<div class="paragraph">
35435bd8deadSopenharmony_ci<p>Subpass-input types are only available when targeting Vulkan.</p>
35445bd8deadSopenharmony_ci</div>
35455bd8deadSopenharmony_ci<div class="paragraph">
35465bd8deadSopenharmony_ci<p>Subpass-input types (e.g., <strong>subpassInput</strong>) are opaque types, declared
35475bd8deadSopenharmony_ciand behaving as described above for opaque types.
35485bd8deadSopenharmony_ciWhen aggregated into arrays within a shader, they can only be indexed with a
35495bd8deadSopenharmony_cidynamically uniform integral expression, otherwise results are undefined.</p>
35505bd8deadSopenharmony_ci</div>
35515bd8deadSopenharmony_ci<div class="paragraph">
35525bd8deadSopenharmony_ci<p>Subpass-input types are handles to two-dimensional single sampled or
35535bd8deadSopenharmony_cimulti-sampled images, with distinct types for each of float, integer,
35545bd8deadSopenharmony_ciand unsigned integer data types.</p>
35555bd8deadSopenharmony_ci</div>
35565bd8deadSopenharmony_ci<div class="paragraph">
35575bd8deadSopenharmony_ci<p>Subpass-input types are only available in fragment shaders.  It is
35585bd8deadSopenharmony_cia compile-time error to use them in any other stage.</p>
35595bd8deadSopenharmony_ci</div>
35605bd8deadSopenharmony_ci</div>
35615bd8deadSopenharmony_ci</div>
35625bd8deadSopenharmony_ci<div class="sect3">
35635bd8deadSopenharmony_ci<h4 id="structures">4.1.8. Structures</h4>
35645bd8deadSopenharmony_ci<div class="paragraph">
35655bd8deadSopenharmony_ci<p>User-defined types can be created by aggregating other already defined types
35665bd8deadSopenharmony_ciinto a structure using the <strong>struct</strong> keyword.
35675bd8deadSopenharmony_ciFor example,</p>
35685bd8deadSopenharmony_ci</div>
35695bd8deadSopenharmony_ci<div class="listingblock">
35705bd8deadSopenharmony_ci<div class="content">
35715bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="keyword">struct</span> light {
35725bd8deadSopenharmony_ci    <span class="predefined-type">float</span> intensity;
35735bd8deadSopenharmony_ci    vec3 position;
35745bd8deadSopenharmony_ci} lightVar;</code></pre>
35755bd8deadSopenharmony_ci</div>
35765bd8deadSopenharmony_ci</div>
35775bd8deadSopenharmony_ci<div class="paragraph">
35785bd8deadSopenharmony_ci<p>In this example, <em>light</em> becomes the name of the new type, and <em>lightVar</em>
35795bd8deadSopenharmony_cibecomes a variable of type <em>light</em>.
35805bd8deadSopenharmony_ciTo declare variables of the new type, use its name (without the keyword
35815bd8deadSopenharmony_ci<strong>struct</strong>).</p>
35825bd8deadSopenharmony_ci</div>
35835bd8deadSopenharmony_ci<div class="listingblock">
35845bd8deadSopenharmony_ci<div class="content">
35855bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">light lightVar2;</code></pre>
35865bd8deadSopenharmony_ci</div>
35875bd8deadSopenharmony_ci</div>
35885bd8deadSopenharmony_ci<div class="paragraph">
35895bd8deadSopenharmony_ci<p>More formally, structures are declared as follows.
35905bd8deadSopenharmony_ciHowever, the definitive grammar is as given in
35915bd8deadSopenharmony_ci&#8220;<a href="#shading-language-grammar">Shading Language Grammar</a>&#8221;.</p>
35925bd8deadSopenharmony_ci</div>
35935bd8deadSopenharmony_ci<div class="openblock bnf">
35945bd8deadSopenharmony_ci<div class="content">
35955bd8deadSopenharmony_ci<div class="dlist">
35965bd8deadSopenharmony_ci<dl>
35975bd8deadSopenharmony_ci<dt class="hdlist1"><em>struct-definition</em> : </dt>
35985bd8deadSopenharmony_ci<dd>
35995bd8deadSopenharmony_ci<p><em>qualifier<sub>opt</sub></em> <strong>struct</strong> name<sub>opt</sub>_ <strong>{</strong> <em>member-list</em> <strong>}</strong>
36005bd8deadSopenharmony_ci<em>declarators<sub>opt</sub></em> <strong>;</strong></p>
36015bd8deadSopenharmony_ci</dd>
36025bd8deadSopenharmony_ci<dt class="hdlist1"><em>member-list</em> : </dt>
36035bd8deadSopenharmony_ci<dd>
36045bd8deadSopenharmony_ci<p><em>member-declaration</em> <strong>;</strong><br>
36055bd8deadSopenharmony_ci<em>member-declaration</em> <em>member-list</em> <strong>;</strong></p>
36065bd8deadSopenharmony_ci</dd>
36075bd8deadSopenharmony_ci<dt class="hdlist1"><em>member-declaration</em> : </dt>
36085bd8deadSopenharmony_ci<dd>
36095bd8deadSopenharmony_ci<p><em>basic-type</em> <em>declarators</em> <strong>;</strong></p>
36105bd8deadSopenharmony_ci</dd>
36115bd8deadSopenharmony_ci</dl>
36125bd8deadSopenharmony_ci</div>
36135bd8deadSopenharmony_ci</div>
36145bd8deadSopenharmony_ci</div>
36155bd8deadSopenharmony_ci<div class="paragraph">
36165bd8deadSopenharmony_ci<p>where <em>name</em> becomes the user-defined type, and can be used to declare
36175bd8deadSopenharmony_civariables to be of this new type.
36185bd8deadSopenharmony_ciThe <em>name</em> shares the same name space as other variables, types, and
36195bd8deadSopenharmony_cifunctions.
36205bd8deadSopenharmony_ciAll previously visible variables, types, constructors, or functions with
36215bd8deadSopenharmony_cithat name are hidden.
36225bd8deadSopenharmony_ciThe optional <em>qualifier</em> only applies to any <em>declarators</em>, and is not part
36235bd8deadSopenharmony_ciof the type being defined for <em>name</em>.</p>
36245bd8deadSopenharmony_ci</div>
36255bd8deadSopenharmony_ci<div class="paragraph">
36265bd8deadSopenharmony_ci<p>Structures must have at least one member declaration.
36275bd8deadSopenharmony_ciMember declarators may contain precision qualifiers, but use of any other
36285bd8deadSopenharmony_ciqualifier results in a compile-time error.
36295bd8deadSopenharmony_ciBit fields are not supported.
36305bd8deadSopenharmony_ciMember types must be already defined (there are no forward references).
36315bd8deadSopenharmony_ciA compile-time error results if a member declaration contains an
36325bd8deadSopenharmony_ciinitializer.
36335bd8deadSopenharmony_ciMember declarators can contain arrays.
36345bd8deadSopenharmony_ciSuch arrays must have a size specified, and the size must be a constant
36355bd8deadSopenharmony_ciintegral expression that&#8217;s greater than zero (see
36365bd8deadSopenharmony_ci&#8220;<a href="#constant-expressions">Constant Expressions</a>&#8221;).
36375bd8deadSopenharmony_ciEach level of structure has its own name space for names given in member
36385bd8deadSopenharmony_cideclarators; such names need only be unique within that name space.</p>
36395bd8deadSopenharmony_ci</div>
36405bd8deadSopenharmony_ci<div class="paragraph">
36415bd8deadSopenharmony_ci<p>Anonymous structures are not supported.
36425bd8deadSopenharmony_ciEmbedded structure definitions are not supported.
36435bd8deadSopenharmony_ciThese result in compile-time errors.</p>
36445bd8deadSopenharmony_ci</div>
36455bd8deadSopenharmony_ci<div class="listingblock">
36465bd8deadSopenharmony_ci<div class="content">
36475bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="keyword">struct</span> S { <span class="predefined-type">float</span> f; }; <span class="comment">// Allowed: S is defined as a structure.</span>
36485bd8deadSopenharmony_ci
36495bd8deadSopenharmony_ci<span class="keyword">struct</span> T {
36505bd8deadSopenharmony_ci    S;              <span class="comment">// Error: anonymous structures disallowed</span>
36515bd8deadSopenharmony_ci    <span class="keyword">struct</span> { ... }; <span class="comment">// Error: embedded structures disallowed</span>
36525bd8deadSopenharmony_ci    S s;            <span class="comment">// Allowed: nested structure with a name.</span>
36535bd8deadSopenharmony_ci};</code></pre>
36545bd8deadSopenharmony_ci</div>
36555bd8deadSopenharmony_ci</div>
36565bd8deadSopenharmony_ci<div class="paragraph">
36575bd8deadSopenharmony_ci<p>Structures can be initialized at declaration time using constructors, as
36585bd8deadSopenharmony_cidiscussed in &#8220;<a href="#structure-constructors">Structure Constructors</a>&#8221;.</p>
36595bd8deadSopenharmony_ci</div>
36605bd8deadSopenharmony_ci<div class="paragraph">
36615bd8deadSopenharmony_ci<p>Any restrictions on the usage of a type or qualifier also apply to any
36625bd8deadSopenharmony_cistructure that contains a member of that type or qualifier.
36635bd8deadSopenharmony_ciThis also applies to structure members that are structures, recursively.</p>
36645bd8deadSopenharmony_ci</div>
36655bd8deadSopenharmony_ci</div>
36665bd8deadSopenharmony_ci<div class="sect3">
36675bd8deadSopenharmony_ci<h4 id="arrays">4.1.9. Arrays</h4>
36685bd8deadSopenharmony_ci<div class="paragraph">
36695bd8deadSopenharmony_ci<p>Variables of the same type can be aggregated into arrays by declaring a name
36705bd8deadSopenharmony_cifollowed by brackets (<strong>[ ]</strong>) enclosing an optional size.
36715bd8deadSopenharmony_ciWhen an array size is specified in a declaration, it must be an integral
36725bd8deadSopenharmony_ciconstant expression (see &#8220;<a href="#constant-expressions">Constant Expressions</a>&#8221;)
36735bd8deadSopenharmony_cigreater than zero.
36745bd8deadSopenharmony_ciExcept for the last declared member of a shader storage block (see section
36755bd8deadSopenharmony_ci&#8220;<a href="#interface-blocks">Interface Blocks</a>&#8221;), the size of an array must be
36765bd8deadSopenharmony_cideclared (<em>explicitly sized</em>) before it is indexed with anything other than
36775bd8deadSopenharmony_cia constant integral expression.
36785bd8deadSopenharmony_ciThe size of any array must be declared before passing it as an argument to a
36795bd8deadSopenharmony_cifunction.
36805bd8deadSopenharmony_ciViolation of any of these rules result in compile-time errors.
36815bd8deadSopenharmony_ciIt is legal to declare an array without a size (<em>unsized</em>) and then later
36825bd8deadSopenharmony_ciredeclare the same name as an array of the same type and specify a size, or
36835bd8deadSopenharmony_ciindex it only with constant integral expressions (<em>implicitly sized</em>).
36845bd8deadSopenharmony_ciHowever, unless noted otherwise, blocks cannot be redeclared; an unsized
36855bd8deadSopenharmony_ciarray member in a user-declared block cannot be sized by a block redeclaration.
36865bd8deadSopenharmony_ciIt is a compile-time error to declare an array with a size, and then later
36875bd8deadSopenharmony_ci(in the same shader) index the same array with a constant integral
36885bd8deadSopenharmony_ciexpression greater than or equal to the declared size.
36895bd8deadSopenharmony_ciIt is a compile-time error to redeclare an unsized array with a size equal
36905bd8deadSopenharmony_cito or smaller than any index used earlier in the shader to index the array.
36915bd8deadSopenharmony_ciIt is also a compile-time error to index an array with a negative constant
36925bd8deadSopenharmony_ciexpression.
36935bd8deadSopenharmony_ciArrays declared as formal parameters in a function declaration must specify
36945bd8deadSopenharmony_cia size.
36955bd8deadSopenharmony_ciUndefined behavior results from indexing an array with a non-constant
36965bd8deadSopenharmony_ciexpression that&#8217;s greater than or equal to the array&#8217;s size or less than 0.
36975bd8deadSopenharmony_ciArrays only have a single dimension (a single entry within "[ ]"), however,
36985bd8deadSopenharmony_ciarrays of arrays can be declared.
36995bd8deadSopenharmony_ciAll types (basic types, structures, arrays) can be formed into an array.</p>
37005bd8deadSopenharmony_ci</div>
37015bd8deadSopenharmony_ci<div class="paragraph">
37025bd8deadSopenharmony_ci<p>All arrays are inherently homogeneous; made of elements all having the same
37035bd8deadSopenharmony_citype and size, with one exception.
37045bd8deadSopenharmony_ciThe exception is a shader storage block having an unsized array as its last
37055bd8deadSopenharmony_cimember (<em>run-time sized</em>); an array can be formed from such a shader storage
37065bd8deadSopenharmony_ciblock, even if the storage blocks have differing lengths for their last
37075bd8deadSopenharmony_cimember.</p>
37085bd8deadSopenharmony_ci</div>
37095bd8deadSopenharmony_ci<div class="paragraph">
37105bd8deadSopenharmony_ci<p>Some examples are:</p>
37115bd8deadSopenharmony_ci</div>
37125bd8deadSopenharmony_ci<div class="listingblock">
37135bd8deadSopenharmony_ci<div class="content">
37145bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">float</span> frequencies[<span class="integer">3</span>];
37155bd8deadSopenharmony_ciuniform vec4 lightPosition[<span class="integer">4</span>];
37165bd8deadSopenharmony_cilight lights[];
37175bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> numLights = <span class="integer">2</span>;
37185bd8deadSopenharmony_cilight lights[numLights];
37195bd8deadSopenharmony_ci
37205bd8deadSopenharmony_ci<span class="comment">// a shader storage block, introduced in section 4.3.7 &quot;Buffer Variables&quot;</span>
37215bd8deadSopenharmony_cibuffer b {
37225bd8deadSopenharmony_ci    <span class="predefined-type">float</span> u[]; <span class="comment">// an error, unless u gets statically sized by link time</span>
37235bd8deadSopenharmony_ci    vec4 v[];  <span class="comment">// okay, v will be sized dynamically, if not statically</span>
37245bd8deadSopenharmony_ci} name[<span class="integer">3</span>];     <span class="comment">// when the block is arrayed, all u will be the same size,</span>
37255bd8deadSopenharmony_ci               <span class="comment">// but not necessarily all v, if sized dynamically</span></code></pre>
37265bd8deadSopenharmony_ci</div>
37275bd8deadSopenharmony_ci</div>
37285bd8deadSopenharmony_ci<div class="paragraph">
37295bd8deadSopenharmony_ci<p>An array type can be formed by specifying non-array type followed by an
37305bd8deadSopenharmony_ciarray specifier.
37315bd8deadSopenharmony_ciAll dimensions of such an array specifier must include a size.</p>
37325bd8deadSopenharmony_ci</div>
37335bd8deadSopenharmony_ci<div class="listingblock">
37345bd8deadSopenharmony_ci<div class="content">
37355bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">float</span>[<span class="integer">5</span>]    <span class="comment">// an array of size [5] of float</span>
37365bd8deadSopenharmony_ci<span class="predefined-type">float</span>[<span class="integer">2</span>][<span class="integer">3</span>] <span class="comment">// an array of size [2][3] of float, not size [3] of float[2]</span></code></pre>
37375bd8deadSopenharmony_ci</div>
37385bd8deadSopenharmony_ci</div>
37395bd8deadSopenharmony_ci<div class="paragraph">
37405bd8deadSopenharmony_ci<p>This type can be used anywhere any other type can be used, including as the
37415bd8deadSopenharmony_cireturn value from a function</p>
37425bd8deadSopenharmony_ci</div>
37435bd8deadSopenharmony_ci<div class="listingblock">
37445bd8deadSopenharmony_ci<div class="content">
37455bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">float</span>[<span class="integer">5</span>] foo() { }</code></pre>
37465bd8deadSopenharmony_ci</div>
37475bd8deadSopenharmony_ci</div>
37485bd8deadSopenharmony_ci<div class="paragraph">
37495bd8deadSopenharmony_ci<p>as a constructor of an array:</p>
37505bd8deadSopenharmony_ci</div>
37515bd8deadSopenharmony_ci<div class="listingblock">
37525bd8deadSopenharmony_ci<div class="content">
37535bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">float</span>[<span class="integer">5</span>](<span class="float">3</span><span class="float">.4</span>, <span class="float">4</span><span class="float">.2</span>, <span class="float">5</span><span class="float">.0</span>, <span class="float">5</span><span class="float">.2</span>, <span class="float">1</span><span class="float">.1</span>)</code></pre>
37545bd8deadSopenharmony_ci</div>
37555bd8deadSopenharmony_ci</div>
37565bd8deadSopenharmony_ci<div class="paragraph">
37575bd8deadSopenharmony_ci<p>as an unnamed parameter:</p>
37585bd8deadSopenharmony_ci</div>
37595bd8deadSopenharmony_ci<div class="listingblock">
37605bd8deadSopenharmony_ci<div class="content">
37615bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="directive">void</span> foo(<span class="predefined-type">float</span>[<span class="integer">5</span>])</code></pre>
37625bd8deadSopenharmony_ci</div>
37635bd8deadSopenharmony_ci</div>
37645bd8deadSopenharmony_ci<div class="paragraph">
37655bd8deadSopenharmony_ci<p>and as an alternate way of declaring a variable or function parameter:</p>
37665bd8deadSopenharmony_ci</div>
37675bd8deadSopenharmony_ci<div class="listingblock">
37685bd8deadSopenharmony_ci<div class="content">
37695bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">float</span>[<span class="integer">5</span>] a;</code></pre>
37705bd8deadSopenharmony_ci</div>
37715bd8deadSopenharmony_ci</div>
37725bd8deadSopenharmony_ci<div class="paragraph">
37735bd8deadSopenharmony_ci<p>Arrays can have initializers formed from array constructors:</p>
37745bd8deadSopenharmony_ci</div>
37755bd8deadSopenharmony_ci<div class="listingblock">
37765bd8deadSopenharmony_ci<div class="content">
37775bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">float</span> a[<span class="integer">5</span>] = <span class="predefined-type">float</span>[<span class="integer">5</span>](<span class="float">3</span><span class="float">.4</span>, <span class="float">4</span><span class="float">.2</span>, <span class="float">5</span><span class="float">.0</span>, <span class="float">5</span><span class="float">.2</span>, <span class="float">1</span><span class="float">.1</span>);
37785bd8deadSopenharmony_ci<span class="predefined-type">float</span> a[<span class="integer">5</span>] = <span class="predefined-type">float</span>[](<span class="float">3</span><span class="float">.4</span>, <span class="float">4</span><span class="float">.2</span>, <span class="float">5</span><span class="float">.0</span>, <span class="float">5</span><span class="float">.2</span>, <span class="float">1</span><span class="float">.1</span>);  <span class="comment">// same thing</span></code></pre>
37795bd8deadSopenharmony_ci</div>
37805bd8deadSopenharmony_ci</div>
37815bd8deadSopenharmony_ci<div class="paragraph">
37825bd8deadSopenharmony_ci<p>An array of arrays can be declared as:</p>
37835bd8deadSopenharmony_ci</div>
37845bd8deadSopenharmony_ci<div class="listingblock">
37855bd8deadSopenharmony_ci<div class="content">
37865bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec4 a[<span class="integer">3</span>][<span class="integer">2</span>]; <span class="comment">// size-3 array of size-2 array of vec4</span></code></pre>
37875bd8deadSopenharmony_ci</div>
37885bd8deadSopenharmony_ci</div>
37895bd8deadSopenharmony_ci<div class="paragraph">
37905bd8deadSopenharmony_ci<p>which declares a one-dimensional array of size 3 of one-dimensional arrays
37915bd8deadSopenharmony_ciof size 2 of <strong>vec4</strong>.
37925bd8deadSopenharmony_ciThe following declarations do the same thing:</p>
37935bd8deadSopenharmony_ci</div>
37945bd8deadSopenharmony_ci<div class="listingblock">
37955bd8deadSopenharmony_ci<div class="content">
37965bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec4[<span class="integer">2</span>] a[<span class="integer">3</span>]; <span class="comment">// size-3 array of size-2 array of vec4</span>
37975bd8deadSopenharmony_civec4[<span class="integer">3</span>][<span class="integer">2</span>] a; <span class="comment">// size-3 array of size-2 array of vec4</span></code></pre>
37985bd8deadSopenharmony_ci</div>
37995bd8deadSopenharmony_ci</div>
38005bd8deadSopenharmony_ci<div class="paragraph">
38015bd8deadSopenharmony_ci<p>When in transparent memory (like in a uniform block), the layout is that the
38025bd8deadSopenharmony_ciinner-most (right-most in declaration) dimensions iterate faster than the
38035bd8deadSopenharmony_ciouter dimensions.
38045bd8deadSopenharmony_ciThat is, for the above, the order in memory would be:</p>
38055bd8deadSopenharmony_ci</div>
38065bd8deadSopenharmony_ci<div class="dlist">
38075bd8deadSopenharmony_ci<dl>
38085bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
38095bd8deadSopenharmony_ci<dd>
38105bd8deadSopenharmony_ci<p>Low address : a[0][0] : a[0][1] : a[1][0] : a[1][1] : a[2][0] : a[2][1]
38115bd8deadSopenharmony_ci: High address</p>
38125bd8deadSopenharmony_ci</dd>
38135bd8deadSopenharmony_ci</dl>
38145bd8deadSopenharmony_ci</div>
38155bd8deadSopenharmony_ci<div class="paragraph">
38165bd8deadSopenharmony_ci<p>The type of <em>a</em> needed for both constructors and nameless parameters is
38175bd8deadSopenharmony_ci&#8220;vec4[3][2]&#8221;:</p>
38185bd8deadSopenharmony_ci</div>
38195bd8deadSopenharmony_ci<div class="listingblock">
38205bd8deadSopenharmony_ci<div class="content">
38215bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec4 b[<span class="integer">2</span>] = vec4[<span class="integer">2</span>](vec4(<span class="float">0</span><span class="float">.0</span>), vec4(<span class="float">0</span><span class="float">.1</span>));
38225bd8deadSopenharmony_civec4[<span class="integer">3</span>][<span class="integer">2</span>] a = vec4[<span class="integer">3</span>][<span class="integer">2</span>](b, b, b);        <span class="comment">// constructor</span>
38235bd8deadSopenharmony_ci<span class="directive">void</span> foo(vec4[<span class="integer">3</span>][<span class="integer">2</span>]); <span class="comment">// prototype with unnamed parameter</span></code></pre>
38245bd8deadSopenharmony_ci</div>
38255bd8deadSopenharmony_ci</div>
38265bd8deadSopenharmony_ci<div class="paragraph">
38275bd8deadSopenharmony_ci<p>Alternatively, the initializer-list syntax can be used to initialize an
38285bd8deadSopenharmony_ciarray of arrays:</p>
38295bd8deadSopenharmony_ci</div>
38305bd8deadSopenharmony_ci<div class="listingblock">
38315bd8deadSopenharmony_ci<div class="content">
38325bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec4 a[<span class="integer">3</span>][<span class="integer">2</span>] = { vec4[<span class="integer">2</span>](vec4(<span class="float">0</span><span class="float">.0</span>), vec4(<span class="float">1</span><span class="float">.0</span>)),
38335bd8deadSopenharmony_ci                 vec4[<span class="integer">2</span>](vec4(<span class="float">0</span><span class="float">.0</span>), vec4(<span class="float">1</span><span class="float">.0</span>)),
38345bd8deadSopenharmony_ci                 vec4[<span class="integer">2</span>](vec4(<span class="float">0</span><span class="float">.0</span>), vec4(<span class="float">1</span><span class="float">.0</span>)) };</code></pre>
38355bd8deadSopenharmony_ci</div>
38365bd8deadSopenharmony_ci</div>
38375bd8deadSopenharmony_ci<div class="paragraph">
38385bd8deadSopenharmony_ci<p>Unsized arrays can be explicitly sized by an initializer at declaration
38395bd8deadSopenharmony_citime:</p>
38405bd8deadSopenharmony_ci</div>
38415bd8deadSopenharmony_ci<div class="listingblock">
38425bd8deadSopenharmony_ci<div class="content">
38435bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">float</span> a[<span class="integer">5</span>];
38445bd8deadSopenharmony_ci...
38455bd8deadSopenharmony_ci<span class="predefined-type">float</span> b[] = a;  <span class="comment">// b is explicitly size 5</span>
38465bd8deadSopenharmony_ci<span class="predefined-type">float</span> b[<span class="integer">5</span>] = a; <span class="comment">// means the same thing</span>
38475bd8deadSopenharmony_ci<span class="predefined-type">float</span> b[] = <span class="predefined-type">float</span>[](<span class="integer">1</span>,<span class="integer">2</span>,<span class="integer">3</span>,<span class="integer">4</span>,<span class="integer">5</span>); <span class="comment">// also explicitly sizes to 5</span></code></pre>
38485bd8deadSopenharmony_ci</div>
38495bd8deadSopenharmony_ci</div>
38505bd8deadSopenharmony_ci<div class="paragraph">
38515bd8deadSopenharmony_ci<p>However, it is a compile-time error to assign to an unsized array.
38525bd8deadSopenharmony_ciNote, this is a rare case that initializers and assignments appear to have
38535bd8deadSopenharmony_cidifferent semantics.
38545bd8deadSopenharmony_ciFor arrays of arrays, any unsized dimension is explicitly sized by the
38555bd8deadSopenharmony_ciinitializer:</p>
38565bd8deadSopenharmony_ci</div>
38575bd8deadSopenharmony_ci<div class="listingblock">
38585bd8deadSopenharmony_ci<div class="content">
38595bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec4 a[][] = { vec4[<span class="integer">2</span>](vec4(<span class="float">0</span><span class="float">.0</span>), vec4(<span class="float">1</span><span class="float">.0</span>)), <span class="comment">// okay, size to a[3][2]</span>
38605bd8deadSopenharmony_ci               vec4[<span class="integer">2</span>](vec4(<span class="float">0</span><span class="float">.0</span>), vec4(<span class="float">1</span><span class="float">.0</span>)),
38615bd8deadSopenharmony_ci               vec4[<span class="integer">2</span>](vec4(<span class="float">0</span><span class="float">.0</span>), vec4(<span class="float">1</span><span class="float">.0</span>)) };</code></pre>
38625bd8deadSopenharmony_ci</div>
38635bd8deadSopenharmony_ci</div>
38645bd8deadSopenharmony_ci<div class="paragraph">
38655bd8deadSopenharmony_ci<p>Arrays know the number of elements they contain.
38665bd8deadSopenharmony_ciThis can be obtained by using the <strong>length</strong>() method:</p>
38675bd8deadSopenharmony_ci</div>
38685bd8deadSopenharmony_ci<div class="listingblock">
38695bd8deadSopenharmony_ci<div class="content">
38705bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">float</span> a[<span class="integer">5</span>];
38715bd8deadSopenharmony_cia.length(); <span class="comment">// returns 5</span></code></pre>
38725bd8deadSopenharmony_ci</div>
38735bd8deadSopenharmony_ci</div>
38745bd8deadSopenharmony_ci<div class="paragraph">
38755bd8deadSopenharmony_ci<p>This returns a type <strong>int</strong>.
38765bd8deadSopenharmony_ciIf an array has been explicitly sized, the value returned by the <strong>length</strong>()
38775bd8deadSopenharmony_cimethod is a constant expression.
38785bd8deadSopenharmony_ciIf an array has not been explicitly sized and is the last declared member of
38795bd8deadSopenharmony_cia shader storage block, the value returned will not be a constant expression
38805bd8deadSopenharmony_ciand will be determined at runtime based on the size of the buffer object
38815bd8deadSopenharmony_ciproviding storage for the block.
38825bd8deadSopenharmony_ciSuch arrays are runtime sized.
38835bd8deadSopenharmony_ciFor runtime-sized arrays, the value returned by the <strong>length</strong>() method will be
38845bd8deadSopenharmony_ciundefined if the array is contained in an array of shader storage blocks
38855bd8deadSopenharmony_cithat is indexed with a non-constant expression less than zero or greater
38865bd8deadSopenharmony_cithan or equal to the number of blocks in the array.</p>
38875bd8deadSopenharmony_ci</div>
38885bd8deadSopenharmony_ci<div class="paragraph">
38895bd8deadSopenharmony_ci<p>The <strong>length</strong>() method cannot be called on an array that is not runtime sized
38905bd8deadSopenharmony_ciand also has not yet been explicitly sized;
38915bd8deadSopenharmony_cithis results in a compile-time error.</p>
38925bd8deadSopenharmony_ci</div>
38935bd8deadSopenharmony_ci<div class="paragraph">
38945bd8deadSopenharmony_ci<p>When the <strong>length</strong>() method returns a compile-time constant, the expression the
38955bd8deadSopenharmony_ci<strong>length</strong>() method is applied to cannot contain any side effects, such as writes
38965bd8deadSopenharmony_cito l-values within the expression, or function calls that themselves have side
38975bd8deadSopenharmony_cieffects: only the compile-time constant length itself need be computed.
38985bd8deadSopenharmony_ciBehavior and results, including any compile-time error reporting,
38995bd8deadSopenharmony_ciare undefined if the expression contains other effects.</p>
39005bd8deadSopenharmony_ci</div>
39015bd8deadSopenharmony_ci<div class="listingblock">
39025bd8deadSopenharmony_ci<div class="content">
39035bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">float</span> a, b;
39045bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> s = <span class="predefined-type">float</span>[<span class="integer">2</span>](a=<span class="float">3</span><span class="float">.0</span>, ++b).length(); <span class="comment">// illegal side effects</span></code></pre>
39055bd8deadSopenharmony_ci</div>
39065bd8deadSopenharmony_ci</div>
39075bd8deadSopenharmony_ci<div class="paragraph">
39085bd8deadSopenharmony_ci<p>The <strong>length</strong>() method works equally well for arrays of arrays:</p>
39095bd8deadSopenharmony_ci</div>
39105bd8deadSopenharmony_ci<div class="listingblock">
39115bd8deadSopenharmony_ci<div class="content">
39125bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec4 a[<span class="integer">3</span>][<span class="integer">2</span>];
39135bd8deadSopenharmony_cia.length()    <span class="comment">// this is 3</span>
39145bd8deadSopenharmony_cia[x].length() <span class="comment">// this is 2</span></code></pre>
39155bd8deadSopenharmony_ci</div>
39165bd8deadSopenharmony_ci</div>
39175bd8deadSopenharmony_ci<div class="paragraph">
39185bd8deadSopenharmony_ci<p>When the <strong>length</strong>() method returns a compile-time constant, the expression
39195bd8deadSopenharmony_ciin brackets (<em>x</em> above) will be parsed and subjected to the rules required for
39205bd8deadSopenharmony_ciarray indices, but the array will not be dereferenced.
39215bd8deadSopenharmony_ciThus, behavior is well defined even if the run-time value of the expression
39225bd8deadSopenharmony_ciis out of bounds, as long as the expression contains no side effects.</p>
39235bd8deadSopenharmony_ci</div>
39245bd8deadSopenharmony_ci<div class="paragraph">
39255bd8deadSopenharmony_ci<p>When the <strong>length</strong>() method returns a run-time value
39265bd8deadSopenharmony_ci(not a compile-time constant), the array will be
39275bd8deadSopenharmony_cidereferenced.
39285bd8deadSopenharmony_ciE.g., if <em>x</em> is not a compile-time constant and is out of range, an undefined
39295bd8deadSopenharmony_civalue results.
39305bd8deadSopenharmony_ciMore generally, all involved expressions are fully evaluated and executed.</p>
39315bd8deadSopenharmony_ci</div>
39325bd8deadSopenharmony_ci<div class="listingblock">
39335bd8deadSopenharmony_ci<div class="content">
39345bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="comment">// for a compile time-sized array b containing a member array a:</span>
39355bd8deadSopenharmony_cib[x+<span class="integer">3</span>].a.length(); <span class="comment">// b is never dereferenced, x+3 is evaluated and checked</span>
39365bd8deadSopenharmony_cib[++x].a.length(); <span class="comment">// not allowed; results are undefined</span>
39375bd8deadSopenharmony_ci
39385bd8deadSopenharmony_ci<span class="comment">// for an array s of a shader storage object (run-time sized) containing a member array a:</span>
39395bd8deadSopenharmony_cis[++x].a.length(); <span class="comment">// s is dereferenced; ++x needs to be a valid index</span></code></pre>
39405bd8deadSopenharmony_ci</div>
39415bd8deadSopenharmony_ci</div>
39425bd8deadSopenharmony_ci<div class="paragraph">
39435bd8deadSopenharmony_ci<p>For implicitly-sized or run-time-sized arrays, only the outer-most dimension
39445bd8deadSopenharmony_cican be lacking a size.
39455bd8deadSopenharmony_ciA type that includes an unknown array size cannot be formed into an array
39465bd8deadSopenharmony_ciuntil it gets an explicit size, except for shader storage blocks where the
39475bd8deadSopenharmony_cionly unsized array member is the last member of the block.</p>
39485bd8deadSopenharmony_ci</div>
39495bd8deadSopenharmony_ci<div class="paragraph">
39505bd8deadSopenharmony_ci<p>In a shader storage block, the last member may be declared without an
39515bd8deadSopenharmony_ciexplicit size.
39525bd8deadSopenharmony_ciIn this case, the effective array size is inferred at run-time from the size
39535bd8deadSopenharmony_ciof the data store backing the interface block.
39545bd8deadSopenharmony_ciSuch run-time-sized arrays may be indexed with general integer expressions.
39555bd8deadSopenharmony_ciHowever, it is a compile-time error to pass them as an argument to a
39565bd8deadSopenharmony_cifunction or index them with a negative constant expression.</p>
39575bd8deadSopenharmony_ci</div>
39585bd8deadSopenharmony_ci</div>
39595bd8deadSopenharmony_ci<div class="sect3">
39605bd8deadSopenharmony_ci<h4 id="implicit-conversions">4.1.10. Implicit Conversions</h4>
39615bd8deadSopenharmony_ci<div class="paragraph">
39625bd8deadSopenharmony_ci<p>In some situations, an expression and its type will be implicitly converted
39635bd8deadSopenharmony_cito a different type.
39645bd8deadSopenharmony_ciThe following table shows all allowed implicit conversions:</p>
39655bd8deadSopenharmony_ci</div>
39665bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
39675bd8deadSopenharmony_ci<colgroup>
39685bd8deadSopenharmony_ci<col style="width: 50%;">
39695bd8deadSopenharmony_ci<col style="width: 50%;">
39705bd8deadSopenharmony_ci</colgroup>
39715bd8deadSopenharmony_ci<thead>
39725bd8deadSopenharmony_ci<tr>
39735bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Type of expression</th>
39745bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Can be implicitly converted to</th>
39755bd8deadSopenharmony_ci</tr>
39765bd8deadSopenharmony_ci</thead>
39775bd8deadSopenharmony_ci<tbody>
39785bd8deadSopenharmony_ci<tr>
39795bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>int</strong></p></td>
39805bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>uint</strong></p></td>
39815bd8deadSopenharmony_ci</tr>
39825bd8deadSopenharmony_ci<tr>
39835bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>int</strong><br>
39845bd8deadSopenharmony_ci  <strong>uint</strong></p></td>
39855bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>float</strong></p></td>
39865bd8deadSopenharmony_ci</tr>
39875bd8deadSopenharmony_ci<tr>
39885bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>int</strong><br>
39895bd8deadSopenharmony_ci  <strong>uint</strong><br>
39905bd8deadSopenharmony_ci  <strong>float</strong></p></td>
39915bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>double</strong></p></td>
39925bd8deadSopenharmony_ci</tr>
39935bd8deadSopenharmony_ci<tr>
39945bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ivec2</strong></p></td>
39955bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>uvec2</strong></p></td>
39965bd8deadSopenharmony_ci</tr>
39975bd8deadSopenharmony_ci<tr>
39985bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ivec3</strong></p></td>
39995bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>uvec3</strong></p></td>
40005bd8deadSopenharmony_ci</tr>
40015bd8deadSopenharmony_ci<tr>
40025bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ivec4</strong></p></td>
40035bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>uvec4</strong></p></td>
40045bd8deadSopenharmony_ci</tr>
40055bd8deadSopenharmony_ci<tr>
40065bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ivec2</strong><br>
40075bd8deadSopenharmony_ci  <strong>uvec2</strong></p></td>
40085bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>vec2</strong></p></td>
40095bd8deadSopenharmony_ci</tr>
40105bd8deadSopenharmony_ci<tr>
40115bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ivec3</strong><br>
40125bd8deadSopenharmony_ci  <strong>uvec3</strong></p></td>
40135bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>vec3</strong></p></td>
40145bd8deadSopenharmony_ci</tr>
40155bd8deadSopenharmony_ci<tr>
40165bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ivec4</strong><br>
40175bd8deadSopenharmony_ci  <strong>uvec4</strong></p></td>
40185bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>vec4</strong></p></td>
40195bd8deadSopenharmony_ci</tr>
40205bd8deadSopenharmony_ci<tr>
40215bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ivec2</strong><br>
40225bd8deadSopenharmony_ci  <strong>uvec2</strong><br>
40235bd8deadSopenharmony_ci  <strong>vec2</strong></p></td>
40245bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dvec2</strong></p></td>
40255bd8deadSopenharmony_ci</tr>
40265bd8deadSopenharmony_ci<tr>
40275bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ivec3</strong><br>
40285bd8deadSopenharmony_ci  <strong>uvec3</strong><br>
40295bd8deadSopenharmony_ci  <strong>vec3</strong></p></td>
40305bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dvec3</strong></p></td>
40315bd8deadSopenharmony_ci</tr>
40325bd8deadSopenharmony_ci<tr>
40335bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ivec4</strong><br>
40345bd8deadSopenharmony_ci  <strong>uvec4</strong><br>
40355bd8deadSopenharmony_ci  <strong>vec4</strong></p></td>
40365bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dvec4</strong></p></td>
40375bd8deadSopenharmony_ci</tr>
40385bd8deadSopenharmony_ci<tr>
40395bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat2</strong></p></td>
40405bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat2</strong></p></td>
40415bd8deadSopenharmony_ci</tr>
40425bd8deadSopenharmony_ci<tr>
40435bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat3</strong></p></td>
40445bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat3</strong></p></td>
40455bd8deadSopenharmony_ci</tr>
40465bd8deadSopenharmony_ci<tr>
40475bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat4</strong></p></td>
40485bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat4</strong></p></td>
40495bd8deadSopenharmony_ci</tr>
40505bd8deadSopenharmony_ci<tr>
40515bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat2x3</strong></p></td>
40525bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat2x3</strong></p></td>
40535bd8deadSopenharmony_ci</tr>
40545bd8deadSopenharmony_ci<tr>
40555bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat2x4</strong></p></td>
40565bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat2x4</strong></p></td>
40575bd8deadSopenharmony_ci</tr>
40585bd8deadSopenharmony_ci<tr>
40595bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat3x2</strong></p></td>
40605bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat3x2</strong></p></td>
40615bd8deadSopenharmony_ci</tr>
40625bd8deadSopenharmony_ci<tr>
40635bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat3x4</strong></p></td>
40645bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat3x4</strong></p></td>
40655bd8deadSopenharmony_ci</tr>
40665bd8deadSopenharmony_ci<tr>
40675bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat4x2</strong></p></td>
40685bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat4x2</strong></p></td>
40695bd8deadSopenharmony_ci</tr>
40705bd8deadSopenharmony_ci<tr>
40715bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mat4x3</strong></p></td>
40725bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dmat4x3</strong></p></td>
40735bd8deadSopenharmony_ci</tr>
40745bd8deadSopenharmony_ci</tbody>
40755bd8deadSopenharmony_ci</table>
40765bd8deadSopenharmony_ci<div class="paragraph">
40775bd8deadSopenharmony_ci<p>There are no implicit array or structure conversions.
40785bd8deadSopenharmony_ciFor example, an array of <strong>int</strong> cannot be implicitly converted to an array of
40795bd8deadSopenharmony_ci<strong>float</strong>.</p>
40805bd8deadSopenharmony_ci</div>
40815bd8deadSopenharmony_ci<div class="paragraph">
40825bd8deadSopenharmony_ci<p>When an implicit conversion is done, it is the same conversion that would be
40835bd8deadSopenharmony_cidone under explicit conversion, using a constructor.
40845bd8deadSopenharmony_ciThe explicit conversions via constructors are described in
40855bd8deadSopenharmony_ci<a href="#conversion-and-scalar-constructors">Conversion and Scalar Constructors</a>.</p>
40865bd8deadSopenharmony_ci</div>
40875bd8deadSopenharmony_ci<div class="paragraph">
40885bd8deadSopenharmony_ci<p>When performing implicit conversion for binary operators, there may be
40895bd8deadSopenharmony_cimultiple data types to which the two operands can be converted.
40905bd8deadSopenharmony_ciFor example, when adding an <strong>int</strong> value to a <strong>uint</strong> value, both values can
40915bd8deadSopenharmony_cibe implicitly converted to <strong>uint</strong>, <strong>float</strong>, and <strong>double</strong>.
40925bd8deadSopenharmony_ciIn such cases, a floating-point type is chosen if either operand has a
40935bd8deadSopenharmony_cifloating-point type.
40945bd8deadSopenharmony_ciOtherwise, an unsigned integer type is chosen if either operand has an
40955bd8deadSopenharmony_ciunsigned integer type.
40965bd8deadSopenharmony_ciOtherwise, a signed integer type is chosen.
40975bd8deadSopenharmony_ciIf operands can be implicitly converted to multiple data types deriving from
40985bd8deadSopenharmony_cithe same base data type, the type with the smallest component size is used.</p>
40995bd8deadSopenharmony_ci</div>
41005bd8deadSopenharmony_ci<div class="paragraph">
41015bd8deadSopenharmony_ci<p>The conversions in the table above are done only as indicated by other
41025bd8deadSopenharmony_cisections of this specification.</p>
41035bd8deadSopenharmony_ci</div>
41045bd8deadSopenharmony_ci</div>
41055bd8deadSopenharmony_ci<div class="sect3">
41065bd8deadSopenharmony_ci<h4 id="initializers">4.1.11. Initializers</h4>
41075bd8deadSopenharmony_ci<div class="paragraph">
41085bd8deadSopenharmony_ci<p>At declaration, an initial value for a variable may be provided, specified
41095bd8deadSopenharmony_cias an equals (=) followed by an initializer.
41105bd8deadSopenharmony_ciThe initializer is either an <em>assignment-expression</em> or a list of
41115bd8deadSopenharmony_ciinitializers enclosed in curly braces.
41125bd8deadSopenharmony_ciThe grammar for the initializer is:</p>
41135bd8deadSopenharmony_ci</div>
41145bd8deadSopenharmony_ci<div class="openblock bnf">
41155bd8deadSopenharmony_ci<div class="content">
41165bd8deadSopenharmony_ci<div class="dlist">
41175bd8deadSopenharmony_ci<dl>
41185bd8deadSopenharmony_ci<dt class="hdlist1"><em>initializer</em> : </dt>
41195bd8deadSopenharmony_ci<dd>
41205bd8deadSopenharmony_ci<p><em>assignment-expression</em><br>
41215bd8deadSopenharmony_ci<strong>{</strong> <em>initializer-list</em> <strong>}</strong><br>
41225bd8deadSopenharmony_ci<strong>{</strong> <em>initializer-list</em> <strong>,</strong> <strong>}</strong></p>
41235bd8deadSopenharmony_ci</dd>
41245bd8deadSopenharmony_ci<dt class="hdlist1"><em>initializer-list</em> : </dt>
41255bd8deadSopenharmony_ci<dd>
41265bd8deadSopenharmony_ci<p><em>initializer</em><br>
41275bd8deadSopenharmony_ci<em>initializer-list</em> , <em>initializer</em></p>
41285bd8deadSopenharmony_ci</dd>
41295bd8deadSopenharmony_ci</dl>
41305bd8deadSopenharmony_ci</div>
41315bd8deadSopenharmony_ci</div>
41325bd8deadSopenharmony_ci</div>
41335bd8deadSopenharmony_ci<div class="paragraph">
41345bd8deadSopenharmony_ci<p>The <em>assignment-expression</em> is a normal expression except that a comma (<strong>,</strong>)
41355bd8deadSopenharmony_cioutside parentheses is interpreted as the end of the initializer, not as the
41365bd8deadSopenharmony_cisequence operator.
41375bd8deadSopenharmony_ciAs explained in more detail below, this allows creation of nested
41385bd8deadSopenharmony_ciinitializers: The variable type and its initializer must exactly match in
41395bd8deadSopenharmony_citerms of nesting, number of components/elements/members present at each
41405bd8deadSopenharmony_cilevel, and types of components/elements/members.
41415bd8deadSopenharmony_ciAn <em>assignment-expression</em> at global scope can include calls to user-defined
41425bd8deadSopenharmony_cifunctions.</p>
41435bd8deadSopenharmony_ci</div>
41445bd8deadSopenharmony_ci<div class="paragraph">
41455bd8deadSopenharmony_ci<p>An <em>assignment-expression</em> in an initializer must be either the same type as
41465bd8deadSopenharmony_cithe object it initializes or be a type that can be converted to the object&#8217;s
41475bd8deadSopenharmony_citype according to &#8220;<a href="#implicit-conversions">Implicit Conversions</a>&#8221;.
41485bd8deadSopenharmony_ciSince these include constructors, a composite variable can be initialized by
41495bd8deadSopenharmony_cieither a constructor or an initializer list; and an element in an
41505bd8deadSopenharmony_ciinitializer list can be a constructor.</p>
41515bd8deadSopenharmony_ci</div>
41525bd8deadSopenharmony_ci<div class="paragraph">
41535bd8deadSopenharmony_ci<p>If an initializer is a list of initializers enclosed in curly braces, the
41545bd8deadSopenharmony_civariable being declared must be a vector, a matrix, an array, or a
41555bd8deadSopenharmony_cistructure.</p>
41565bd8deadSopenharmony_ci</div>
41575bd8deadSopenharmony_ci<div class="listingblock">
41585bd8deadSopenharmony_ci<div class="content">
41595bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">int</span> i = { <span class="integer">1</span> }; <span class="comment">// illegal, i is not a composite</span></code></pre>
41605bd8deadSopenharmony_ci</div>
41615bd8deadSopenharmony_ci</div>
41625bd8deadSopenharmony_ci<div class="paragraph">
41635bd8deadSopenharmony_ci<p>A list of initializers enclosed in a matching set of curly braces is applied
41645bd8deadSopenharmony_cito one composite.
41655bd8deadSopenharmony_ciThis may be the variable being declared or a composite contained in the
41665bd8deadSopenharmony_civariable being declared.
41675bd8deadSopenharmony_ciIndividual initializers from the initializer list are applied to the
41685bd8deadSopenharmony_cielements/members of the composite, in order.</p>
41695bd8deadSopenharmony_ci</div>
41705bd8deadSopenharmony_ci<div class="paragraph">
41715bd8deadSopenharmony_ci<p>If the composite has a vector type, initializers from the list are applied
41725bd8deadSopenharmony_cito the components of the vector, in order, starting with component 0.
41735bd8deadSopenharmony_ciThe number of initializers must match the number of components.</p>
41745bd8deadSopenharmony_ci</div>
41755bd8deadSopenharmony_ci<div class="paragraph">
41765bd8deadSopenharmony_ci<p>If the composite has a matrix type, initializers from the list must be
41775bd8deadSopenharmony_civector initializers and are applied to the columns of the matrix, in order,
41785bd8deadSopenharmony_cistarting with column 0.
41795bd8deadSopenharmony_ciThe number of initializers must match the number of columns.</p>
41805bd8deadSopenharmony_ci</div>
41815bd8deadSopenharmony_ci<div class="paragraph">
41825bd8deadSopenharmony_ci<p>If the composite has a structure type, initializers from the list are
41835bd8deadSopenharmony_ciapplied to the members of the structure, in the order declared in the
41845bd8deadSopenharmony_cistructure, starting with the first member.
41855bd8deadSopenharmony_ciThe number of initializers must match the number of members.</p>
41865bd8deadSopenharmony_ci</div>
41875bd8deadSopenharmony_ci<div class="paragraph">
41885bd8deadSopenharmony_ci<p>Applying these rules, the following matrix declarations are equivalent:</p>
41895bd8deadSopenharmony_ci</div>
41905bd8deadSopenharmony_ci<div class="listingblock">
41915bd8deadSopenharmony_ci<div class="content">
41925bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">mat2x2 a = mat2(  vec2( <span class="float">1</span><span class="float">.0</span>, <span class="float">0</span><span class="float">.0</span> ), vec2( <span class="float">0</span><span class="float">.0</span>, <span class="float">1</span><span class="float">.0</span> ) );
41935bd8deadSopenharmony_cimat2x2 b =      { vec2( <span class="float">1</span><span class="float">.0</span>, <span class="float">0</span><span class="float">.0</span> ), vec2( <span class="float">0</span><span class="float">.0</span>, <span class="float">1</span><span class="float">.0</span> ) };
41945bd8deadSopenharmony_cimat2x2 c =      {     { <span class="float">1</span><span class="float">.0</span>, <span class="float">0</span><span class="float">.0</span> },     { <span class="float">0</span><span class="float">.0</span>, <span class="float">1</span><span class="float">.0</span> } };</code></pre>
41955bd8deadSopenharmony_ci</div>
41965bd8deadSopenharmony_ci</div>
41975bd8deadSopenharmony_ci<div class="paragraph">
41985bd8deadSopenharmony_ci<p>All of the following declarations result in a compile-time error.</p>
41995bd8deadSopenharmony_ci</div>
42005bd8deadSopenharmony_ci<div class="listingblock">
42015bd8deadSopenharmony_ci<div class="content">
42025bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">float</span> a[<span class="integer">2</span>] = { <span class="float">3</span><span class="float">.4</span>, <span class="float">4</span><span class="float">.2</span>, <span class="float">5</span><span class="float">.0</span> };         <span class="comment">// illegal</span>
42035bd8deadSopenharmony_civec2 b = { <span class="float">1</span><span class="float">.0</span>, <span class="float">2</span><span class="float">.0</span>, <span class="float">3</span><span class="float">.0</span> };             <span class="comment">// illegal</span>
42045bd8deadSopenharmony_cimat3x3 c = { vec3(<span class="float">0</span><span class="float">.0</span>), vec3(<span class="float">1</span><span class="float">.0</span>), vec3(<span class="float">2</span><span class="float">.0</span>), vec3(<span class="float">3</span><span class="float">.0</span>) }; <span class="comment">// illegal</span>
42055bd8deadSopenharmony_cimat2x2 d = { <span class="float">1</span><span class="float">.0</span>, <span class="float">0</span><span class="float">.0</span>, <span class="float">0</span><span class="float">.0</span>, <span class="float">1</span><span class="float">.0</span> };      <span class="comment">// illegal, can't flatten nesting</span>
42065bd8deadSopenharmony_ci<span class="keyword">struct</span> {
42075bd8deadSopenharmony_ci    <span class="predefined-type">float</span> a;
42085bd8deadSopenharmony_ci    <span class="predefined-type">int</span> b;
42095bd8deadSopenharmony_ci} e = { <span class="float">1</span><span class="float">.2</span>, <span class="integer">2</span>, <span class="integer">3</span> };                    <span class="comment">// illegal</span></code></pre>
42105bd8deadSopenharmony_ci</div>
42115bd8deadSopenharmony_ci</div>
42125bd8deadSopenharmony_ci<div class="paragraph">
42135bd8deadSopenharmony_ci<p>In all cases, the inner-most initializer (i.e., not a list of initializers
42145bd8deadSopenharmony_cienclosed in curly braces) applied to an object must have the same type as
42155bd8deadSopenharmony_cithe object being initialized or be a type that can be converted to the
42165bd8deadSopenharmony_ciobject&#8217;s type according to &#8220;<a href="#implicit-conversions">Implicit
42175bd8deadSopenharmony_ciConversions</a>&#8221;.
42185bd8deadSopenharmony_ciIn the latter case, an implicit conversion will be done on the initializer
42195bd8deadSopenharmony_cibefore the assignment is done.</p>
42205bd8deadSopenharmony_ci</div>
42215bd8deadSopenharmony_ci<div class="listingblock">
42225bd8deadSopenharmony_ci<div class="content">
42235bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="keyword">struct</span> {
42245bd8deadSopenharmony_ci    <span class="predefined-type">float</span> a;
42255bd8deadSopenharmony_ci    <span class="predefined-type">int</span> b;
42265bd8deadSopenharmony_ci} e = { <span class="float">1</span><span class="float">.2</span>, <span class="integer">2</span> }; <span class="comment">// legal, all types match</span>
42275bd8deadSopenharmony_ci<span class="keyword">struct</span> {
42285bd8deadSopenharmony_ci    <span class="predefined-type">float</span> a;
42295bd8deadSopenharmony_ci    <span class="predefined-type">int</span> b;
42305bd8deadSopenharmony_ci} e = { <span class="integer">1</span>, <span class="integer">3</span> };   <span class="comment">// legal, first initializer is converted</span></code></pre>
42315bd8deadSopenharmony_ci</div>
42325bd8deadSopenharmony_ci</div>
42335bd8deadSopenharmony_ci<div class="paragraph">
42345bd8deadSopenharmony_ci<p>All of the following declarations result in a compile-time error.</p>
42355bd8deadSopenharmony_ci</div>
42365bd8deadSopenharmony_ci<div class="listingblock">
42375bd8deadSopenharmony_ci<div class="content">
42385bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">int</span> a = <span class="predefined-constant">true</span>;                         <span class="comment">// illegal</span>
42395bd8deadSopenharmony_civec4 b[<span class="integer">2</span>] = { vec4(<span class="float">0</span><span class="float">.0</span>), <span class="float">1</span><span class="float">.0</span> };       <span class="comment">// illegal</span>
42405bd8deadSopenharmony_cimat4x2 c = { vec3(<span class="float">0</span><span class="float">.0</span>), vec3(<span class="float">1</span><span class="float">.0</span>) };  <span class="comment">// illegal</span>
42415bd8deadSopenharmony_ci
42425bd8deadSopenharmony_ci<span class="keyword">struct</span> S1 {
42435bd8deadSopenharmony_ci    vec4 a;
42445bd8deadSopenharmony_ci    vec4 b;
42455bd8deadSopenharmony_ci};
42465bd8deadSopenharmony_ci
42475bd8deadSopenharmony_ci<span class="keyword">struct</span> {
42485bd8deadSopenharmony_ci    <span class="predefined-type">float</span> s;
42495bd8deadSopenharmony_ci    <span class="predefined-type">float</span> t;
42505bd8deadSopenharmony_ci} d[] = { S1(vec4(<span class="float">0</span><span class="float">.0</span>), vec4(<span class="float">1</span><span class="float">.1</span>)) }; <span class="comment">// illegal</span></code></pre>
42515bd8deadSopenharmony_ci</div>
42525bd8deadSopenharmony_ci</div>
42535bd8deadSopenharmony_ci<div class="paragraph">
42545bd8deadSopenharmony_ci<p>If an initializer (of either form) is provided for an unsized array, the
42555bd8deadSopenharmony_cisize of the array is determined by the number of top-level (non-nested)
42565bd8deadSopenharmony_ciinitializers within the initializer.
42575bd8deadSopenharmony_ciAll of the following declarations create arrays explicitly sized with five
42585bd8deadSopenharmony_cielements:</p>
42595bd8deadSopenharmony_ci</div>
42605bd8deadSopenharmony_ci<div class="listingblock">
42615bd8deadSopenharmony_ci<div class="content">
42625bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">float</span> a[] = <span class="predefined-type">float</span>[](<span class="float">3</span><span class="float">.4</span>, <span class="float">4</span><span class="float">.2</span>, <span class="float">5</span><span class="float">.0</span>, <span class="float">5</span><span class="float">.2</span>, <span class="float">1</span><span class="float">.1</span>);
42635bd8deadSopenharmony_ci<span class="predefined-type">float</span> b[] = { <span class="float">3</span><span class="float">.4</span>, <span class="float">4</span><span class="float">.2</span>, <span class="float">5</span><span class="float">.0</span>, <span class="float">5</span><span class="float">.2</span>, <span class="float">1</span><span class="float">.1</span> };
42645bd8deadSopenharmony_ci<span class="predefined-type">float</span> c[] = a;                          <span class="comment">// c is explicitly size 5</span>
42655bd8deadSopenharmony_ci<span class="predefined-type">float</span> d[<span class="integer">5</span>] = b;                         <span class="comment">// means the same thing</span></code></pre>
42665bd8deadSopenharmony_ci</div>
42675bd8deadSopenharmony_ci</div>
42685bd8deadSopenharmony_ci<div class="paragraph">
42695bd8deadSopenharmony_ci<p>It is a compile-time error to have too few or too many initializers in an
42705bd8deadSopenharmony_ciinitializer list for the composite being initialized.
42715bd8deadSopenharmony_ciThat is, all elements of an array, all members of a structure, all columns
42725bd8deadSopenharmony_ciof a matrix, and all components of a vector must have exactly one
42735bd8deadSopenharmony_ciinitializer expression present, with no unconsumed initializers.</p>
42745bd8deadSopenharmony_ci</div>
42755bd8deadSopenharmony_ci</div>
42765bd8deadSopenharmony_ci</div>
42775bd8deadSopenharmony_ci<div class="sect2">
42785bd8deadSopenharmony_ci<h3 id="scoping">4.2. Scoping</h3>
42795bd8deadSopenharmony_ci<div class="paragraph">
42805bd8deadSopenharmony_ci<p>The scope of a variable is determined by where it is declared.
42815bd8deadSopenharmony_ciIf it is declared outside all function definitions, it has global scope,
42825bd8deadSopenharmony_ciwhich starts from where it is declared and persists to the end of the shader
42835bd8deadSopenharmony_ciit is declared in.
42845bd8deadSopenharmony_ciIf it is declared in a <strong>while</strong> test or a <strong>for</strong> statement, then it is scoped
42855bd8deadSopenharmony_cito the end of the following sub-statement.
42865bd8deadSopenharmony_ciIf it is declared in an <strong>if</strong> or <strong>else</strong> statement, it is scoped to the end of
42875bd8deadSopenharmony_cithat statement.
42885bd8deadSopenharmony_ci(See &#8220;<a href="#selection">Selection</a>&#8221; and &#8220;<a href="#iteration">Iteration</a>&#8221; for the
42895bd8deadSopenharmony_cilocation of statements and sub-statements.) Otherwise, if it is declared as
42905bd8deadSopenharmony_cia statement within a compound statement, it is scoped to the end of that
42915bd8deadSopenharmony_cicompound statement.
42925bd8deadSopenharmony_ciIf it is declared as a parameter in a function definition, it is scoped
42935bd8deadSopenharmony_ciuntil the end of that function definition.
42945bd8deadSopenharmony_ciA function&#8217;s parameter declarations and body together form a single scope
42955bd8deadSopenharmony_cinested in the global scope.
42965bd8deadSopenharmony_ciThe <strong>if</strong> statement&#8217;s expression does not allow new variables to be declared,
42975bd8deadSopenharmony_cihence does not form a new scope.</p>
42985bd8deadSopenharmony_ci</div>
42995bd8deadSopenharmony_ci<div class="paragraph">
43005bd8deadSopenharmony_ci<p>Within a declaration, the scope of a name starts immediately after the
43015bd8deadSopenharmony_ciinitializer if present or immediately after the name being declared if not.
43025bd8deadSopenharmony_ciSeveral examples:</p>
43035bd8deadSopenharmony_ci</div>
43045bd8deadSopenharmony_ci<div class="listingblock">
43055bd8deadSopenharmony_ci<div class="content">
43065bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">int</span> x = <span class="integer">1</span>;
43075bd8deadSopenharmony_ci{
43085bd8deadSopenharmony_ci    <span class="predefined-type">int</span> x = <span class="integer">2</span>, y = x; <span class="comment">// y is initialized to 2</span>
43095bd8deadSopenharmony_ci}
43105bd8deadSopenharmony_ci
43115bd8deadSopenharmony_ci<span class="keyword">struct</span> S
43125bd8deadSopenharmony_ci{
43135bd8deadSopenharmony_ci    <span class="predefined-type">int</span> x;
43145bd8deadSopenharmony_ci};
43155bd8deadSopenharmony_ci
43165bd8deadSopenharmony_ci{
43175bd8deadSopenharmony_ci    S S = S(<span class="integer">0</span>); <span class="comment">// 'S' is only visible as a struct and constructor</span>
43185bd8deadSopenharmony_ci    S;          <span class="comment">// 'S' is now visible as a variable</span>
43195bd8deadSopenharmony_ci}
43205bd8deadSopenharmony_ci
43215bd8deadSopenharmony_ci<span class="predefined-type">int</span> x = x; <span class="comment">// Error if x has not been previously defined.</span>
43225bd8deadSopenharmony_ci           <span class="comment">// If the previous definition of x was in this</span>
43235bd8deadSopenharmony_ci           <span class="comment">// same scope, this causes a redeclaration error.</span>
43245bd8deadSopenharmony_ci
43255bd8deadSopenharmony_ci<span class="predefined-type">int</span> f( <span class="comment">/* nested scope begins here */</span> <span class="predefined-type">int</span> k)
43265bd8deadSopenharmony_ci{
43275bd8deadSopenharmony_ci    <span class="predefined-type">int</span> k = k + <span class="integer">3</span>; <span class="comment">// redeclaration error of the name k</span>
43285bd8deadSopenharmony_ci    ...
43295bd8deadSopenharmony_ci}
43305bd8deadSopenharmony_ci
43315bd8deadSopenharmony_ci<span class="predefined-type">int</span> f(<span class="predefined-type">int</span> k)
43325bd8deadSopenharmony_ci{
43335bd8deadSopenharmony_ci    {
43345bd8deadSopenharmony_ci        <span class="predefined-type">int</span> k = k + <span class="integer">3</span>; <span class="comment">// 2nd k is parameter, initializing nested first k</span>
43355bd8deadSopenharmony_ci        <span class="predefined-type">int</span> m = k;     <span class="comment">// use of new k, which is hiding the parameter</span>
43365bd8deadSopenharmony_ci    }
43375bd8deadSopenharmony_ci}</code></pre>
43385bd8deadSopenharmony_ci</div>
43395bd8deadSopenharmony_ci</div>
43405bd8deadSopenharmony_ci<div class="paragraph">
43415bd8deadSopenharmony_ci<p>For both <strong>for</strong> and <strong>while</strong> loops, the sub-statement itself does not
43425bd8deadSopenharmony_ciintroduce a new scope for variable names, so the following has a
43435bd8deadSopenharmony_ciredeclaration compile-time error:</p>
43445bd8deadSopenharmony_ci</div>
43455bd8deadSopenharmony_ci<div class="listingblock">
43465bd8deadSopenharmony_ci<div class="content">
43475bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="keyword">for</span> ( <span class="comment">/* nested scope begins here */</span> <span class="predefined-type">int</span> i = <span class="integer">0</span>; i &lt; <span class="integer">10</span>; i++) {
43485bd8deadSopenharmony_ci    <span class="predefined-type">int</span> i; <span class="comment">// redeclaration error</span>
43495bd8deadSopenharmony_ci}</code></pre>
43505bd8deadSopenharmony_ci</div>
43515bd8deadSopenharmony_ci</div>
43525bd8deadSopenharmony_ci<div class="paragraph">
43535bd8deadSopenharmony_ci<p>The body of a <strong>do</strong>-<strong>while</strong> loop introduces a new scope lasting only between
43545bd8deadSopenharmony_cithe <strong>do</strong> and <strong>while</strong> (not including the while test expression), whether or
43555bd8deadSopenharmony_cinot the body is simple or compound:</p>
43565bd8deadSopenharmony_ci</div>
43575bd8deadSopenharmony_ci<div class="listingblock">
43585bd8deadSopenharmony_ci<div class="content">
43595bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">int</span> i = <span class="integer">17</span>;
43605bd8deadSopenharmony_ci<span class="keyword">do</span>
43615bd8deadSopenharmony_ci    <span class="predefined-type">int</span> i = <span class="integer">4</span>;  <span class="comment">// okay, in nested scope_</span>
43625bd8deadSopenharmony_ci<span class="keyword">while</span> (i == <span class="integer">0</span>); <span class="comment">// i is 17, scoped outside the do-while body</span></code></pre>
43635bd8deadSopenharmony_ci</div>
43645bd8deadSopenharmony_ci</div>
43655bd8deadSopenharmony_ci<div class="paragraph">
43665bd8deadSopenharmony_ci<p>The statement following a <strong>switch</strong> (&#8230;&#8203;) forms a nested scope.</p>
43675bd8deadSopenharmony_ci</div>
43685bd8deadSopenharmony_ci<div class="paragraph">
43695bd8deadSopenharmony_ci<p>All variable names, structure type names, and function names in a given
43705bd8deadSopenharmony_ciscope share the same name space.
43715bd8deadSopenharmony_ciFunction names can be redeclared in the same scope, with the same or
43725bd8deadSopenharmony_cidifferent parameters, without error.
43735bd8deadSopenharmony_ciAn implicitly-sized array can be redeclared in the same scope as an array of
43745bd8deadSopenharmony_cithe same base type.
43755bd8deadSopenharmony_ciOtherwise, within one compilation unit, a declared name cannot be redeclared
43765bd8deadSopenharmony_ciin the same scope; doing so results in a redeclaration compile-time error.
43775bd8deadSopenharmony_ciIf a nested scope redeclares a name used in an outer scope, it hides all
43785bd8deadSopenharmony_ciexisting uses of that name.
43795bd8deadSopenharmony_ciThere is no way to access the hidden name or make it unhidden, without
43805bd8deadSopenharmony_ciexiting the scope that hid it.</p>
43815bd8deadSopenharmony_ci</div>
43825bd8deadSopenharmony_ci<div class="paragraph">
43835bd8deadSopenharmony_ci<p>The built-in functions are scoped in a scope outside the global scope that
43845bd8deadSopenharmony_ciusers declare global variables in.
43855bd8deadSopenharmony_ciThat is, a shader&#8217;s global scope, available for user-defined functions and
43865bd8deadSopenharmony_ciglobal variables, is nested inside the scope containing the built-in
43875bd8deadSopenharmony_cifunctions.
43885bd8deadSopenharmony_ciWhen a function name is redeclared in a nested scope, it hides all functions
43895bd8deadSopenharmony_cideclared with that name in the outer scope.
43905bd8deadSopenharmony_ciFunction declarations (prototypes) cannot occur inside of functions; they
43915bd8deadSopenharmony_cimust be at global scope, or for the built-in functions, outside the global
43925bd8deadSopenharmony_ciscope, otherwise a compile-time error results.</p>
43935bd8deadSopenharmony_ci</div>
43945bd8deadSopenharmony_ci<div class="paragraph">
43955bd8deadSopenharmony_ci<p>Shared globals are global variables declared with the same name in
43965bd8deadSopenharmony_ciindependently compiled units (shaders) within the same language (i.e., same
43975bd8deadSopenharmony_cistage, e.g. vertex) that are linked together when making a single program.
43985bd8deadSopenharmony_ci(Globals forming the interface between two different shader languages are
43995bd8deadSopenharmony_cidiscussed in other sections.) Shared globals share the same name space, and
44005bd8deadSopenharmony_cimust be declared with the same type.
44015bd8deadSopenharmony_ciThey will share the same storage.</p>
44025bd8deadSopenharmony_ci</div>
44035bd8deadSopenharmony_ci<div class="paragraph">
44045bd8deadSopenharmony_ci<p>Shared global arrays must have the same base type and the same explicit
44055bd8deadSopenharmony_cisize.
44065bd8deadSopenharmony_ciAn array implicitly sized in one shader can be explicitly sized by another
44075bd8deadSopenharmony_cishader in the same stage.
44085bd8deadSopenharmony_ciIf no shader in a stage has an explicit size for the array, the largest
44095bd8deadSopenharmony_ciimplicit size (one more than the largest index used) in that stage is used.
44105bd8deadSopenharmony_ciThere is no cross-stage array sizing.
44115bd8deadSopenharmony_ciIf there is no static access to an implicitly sized array within the stage
44125bd8deadSopenharmony_cideclaring it, then the array is given a size of 1, which is relevant when
44135bd8deadSopenharmony_cithe array is declared within an interface block that is shared with other
44145bd8deadSopenharmony_cistages or the application (other unused arrays might be eliminated by the
44155bd8deadSopenharmony_cioptimizer).</p>
44165bd8deadSopenharmony_ci</div>
44175bd8deadSopenharmony_ci<div class="paragraph">
44185bd8deadSopenharmony_ci<p>Shared global scalars must have exactly the same type name and type
44195bd8deadSopenharmony_cidefinition.
44205bd8deadSopenharmony_ciStructures must have the same name, sequence of type names, and type
44215bd8deadSopenharmony_cidefinitions, and member names to be considered the same type.
44225bd8deadSopenharmony_ciThis rule applies recursively for nested or embedded types.
44235bd8deadSopenharmony_ciIf a shared global has multiple initializers, the initializers must all be
44245bd8deadSopenharmony_ciconstant expressions, and they must all have the same value.
44255bd8deadSopenharmony_ciOtherwise, a link-time error will result.
44265bd8deadSopenharmony_ci(A shared global having only one initializer does not require that
44275bd8deadSopenharmony_ciinitializer to be a constant expression.)</p>
44285bd8deadSopenharmony_ci</div>
44295bd8deadSopenharmony_ci</div>
44305bd8deadSopenharmony_ci<div class="sect2">
44315bd8deadSopenharmony_ci<h3 id="storage-qualifiers">4.3. Storage Qualifiers</h3>
44325bd8deadSopenharmony_ci<div class="paragraph">
44335bd8deadSopenharmony_ci<p>Variable declarations may have at most one storage qualifier specified in
44345bd8deadSopenharmony_cifront of the type.
44355bd8deadSopenharmony_ciThese are summarized as</p>
44365bd8deadSopenharmony_ci</div>
44375bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
44385bd8deadSopenharmony_ci<colgroup>
44395bd8deadSopenharmony_ci<col style="width: 50%;">
44405bd8deadSopenharmony_ci<col style="width: 50%;">
44415bd8deadSopenharmony_ci</colgroup>
44425bd8deadSopenharmony_ci<thead>
44435bd8deadSopenharmony_ci<tr>
44445bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Storage Qualifier</th>
44455bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Meaning</th>
44465bd8deadSopenharmony_ci</tr>
44475bd8deadSopenharmony_ci</thead>
44485bd8deadSopenharmony_ci<tbody>
44495bd8deadSopenharmony_ci<tr>
44505bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;none: default&gt;</p></td>
44515bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">local read/write memory, or an input parameter to a
44525bd8deadSopenharmony_ci                      function</p></td>
44535bd8deadSopenharmony_ci</tr>
44545bd8deadSopenharmony_ci<tr>
44555bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>const</strong></p></td>
44565bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">a variable whose value cannot be changed</p></td>
44575bd8deadSopenharmony_ci</tr>
44585bd8deadSopenharmony_ci<tr>
44595bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>in</strong></p></td>
44605bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">linkage into a shader from a previous stage, variable
44615bd8deadSopenharmony_ci                      is copied in</p></td>
44625bd8deadSopenharmony_ci</tr>
44635bd8deadSopenharmony_ci<tr>
44645bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>out</strong></p></td>
44655bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">linkage out of a shader to a subsequent stage,
44665bd8deadSopenharmony_ci                      variable is copied out</p></td>
44675bd8deadSopenharmony_ci</tr>
44685bd8deadSopenharmony_ci<tr>
44695bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>attribute</strong></p></td>
44705bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">compatibility profile only and vertex language only;
44715bd8deadSopenharmony_ci                      same as <strong>in</strong> when in a vertex shader</p></td>
44725bd8deadSopenharmony_ci</tr>
44735bd8deadSopenharmony_ci<tr>
44745bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>uniform</strong></p></td>
44755bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">value does not change across the primitive being
44765bd8deadSopenharmony_ci                      processed, uniforms form the linkage between a shader,
44775bd8deadSopenharmony_ci                      API, and the application</p></td>
44785bd8deadSopenharmony_ci</tr>
44795bd8deadSopenharmony_ci<tr>
44805bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>varying</strong></p></td>
44815bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">compatibility profile only and vertex and fragment
44825bd8deadSopenharmony_ci                      languages only; same as <strong>out</strong> when in a vertex shader
44835bd8deadSopenharmony_ci                      and same as <strong>in</strong> when in a fragment shader</p></td>
44845bd8deadSopenharmony_ci</tr>
44855bd8deadSopenharmony_ci<tr>
44865bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>buffer</strong></p></td>
44875bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">value is stored in a buffer object, and can be read or
44885bd8deadSopenharmony_ci                      written both by shader invocations and the API</p></td>
44895bd8deadSopenharmony_ci</tr>
44905bd8deadSopenharmony_ci<tr>
44915bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>shared</strong></p></td>
44925bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">compute shader only; variable storage is shared across
44935bd8deadSopenharmony_ci                      all work items in a workgroup</p></td>
44945bd8deadSopenharmony_ci</tr>
44955bd8deadSopenharmony_ci</tbody>
44965bd8deadSopenharmony_ci</table>
44975bd8deadSopenharmony_ci<div class="paragraph">
44985bd8deadSopenharmony_ci<p>Some input and output qualified variables can be qualified with at most one
44995bd8deadSopenharmony_ciadditional auxiliary storage qualifier:</p>
45005bd8deadSopenharmony_ci</div>
45015bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
45025bd8deadSopenharmony_ci<colgroup>
45035bd8deadSopenharmony_ci<col style="width: 50%;">
45045bd8deadSopenharmony_ci<col style="width: 50%;">
45055bd8deadSopenharmony_ci</colgroup>
45065bd8deadSopenharmony_ci<thead>
45075bd8deadSopenharmony_ci<tr>
45085bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Auxiliary Storage Qualifier</th>
45095bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Meaning</th>
45105bd8deadSopenharmony_ci</tr>
45115bd8deadSopenharmony_ci</thead>
45125bd8deadSopenharmony_ci<tbody>
45135bd8deadSopenharmony_ci<tr>
45145bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>centroid</strong></p></td>
45155bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">centroid-based interpolation</p></td>
45165bd8deadSopenharmony_ci</tr>
45175bd8deadSopenharmony_ci<tr>
45185bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sample</strong></p></td>
45195bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">per-sample interpolation</p></td>
45205bd8deadSopenharmony_ci</tr>
45215bd8deadSopenharmony_ci<tr>
45225bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>patch</strong></p></td>
45235bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">per-tessellation-patch attributes</p></td>
45245bd8deadSopenharmony_ci</tr>
45255bd8deadSopenharmony_ci</tbody>
45265bd8deadSopenharmony_ci</table>
45275bd8deadSopenharmony_ci<div class="paragraph">
45285bd8deadSopenharmony_ci<p>Not all combinations of qualification are allowed.
45295bd8deadSopenharmony_ciAuxiliary storage qualifiers can only be used with the <strong>in</strong> or <strong>out</strong> storage
45305bd8deadSopenharmony_ciqualifiers.
45315bd8deadSopenharmony_ciAdditional qualifier rules are defined in upcoming sections.</p>
45325bd8deadSopenharmony_ci</div>
45335bd8deadSopenharmony_ci<div class="paragraph">
45345bd8deadSopenharmony_ci<p>Local variables can only use the <strong>const</strong> storage qualifier (or use no
45355bd8deadSopenharmony_cistorage qualifier).</p>
45365bd8deadSopenharmony_ci</div>
45375bd8deadSopenharmony_ci<div class="paragraph">
45385bd8deadSopenharmony_ci<p>Note that function parameters can use <strong>const</strong>, <strong>in</strong>, and <strong>out</strong> qualifiers,
45395bd8deadSopenharmony_cibut as <em>parameter qualifiers</em>.
45405bd8deadSopenharmony_ciParameter qualifiers are discussed in
45415bd8deadSopenharmony_ci&#8220;<a href="#function-calling-conventions">Function Calling Conventions</a>&#8221;.</p>
45425bd8deadSopenharmony_ci</div>
45435bd8deadSopenharmony_ci<div class="paragraph">
45445bd8deadSopenharmony_ci<p>Function return types and structure members do not use storage qualifiers.</p>
45455bd8deadSopenharmony_ci</div>
45465bd8deadSopenharmony_ci<div class="paragraph">
45475bd8deadSopenharmony_ci<p>Initializers in global declarations may only be used in declarations of
45485bd8deadSopenharmony_ciglobal variables with no storage qualifier, with a <strong>const</strong> qualifier, or
45495bd8deadSopenharmony_ciwith a <strong>uniform</strong> qualifier.</p>
45505bd8deadSopenharmony_ci</div>
45515bd8deadSopenharmony_ci<div class="paragraph">
45525bd8deadSopenharmony_ci<p>Global variables without storage qualifiers that are not initialized in
45535bd8deadSopenharmony_citheir declaration or by the application will not be initialized,
45545bd8deadSopenharmony_cibut rather will enter <em>main()</em> with undefined values.</p>
45555bd8deadSopenharmony_ci</div>
45565bd8deadSopenharmony_ci<div class="paragraph">
45575bd8deadSopenharmony_ci<p>When comparing an output from one shader stage to an input of a subsequent
45585bd8deadSopenharmony_cishader stage, the input and output don&#8217;t match if their auxiliary qualifiers
45595bd8deadSopenharmony_ci(or lack thereof) are not the same.</p>
45605bd8deadSopenharmony_ci</div>
45615bd8deadSopenharmony_ci<div class="sect3">
45625bd8deadSopenharmony_ci<h4 id="default-storage-qualifier">4.3.1. Default Storage Qualifier</h4>
45635bd8deadSopenharmony_ci<div class="paragraph">
45645bd8deadSopenharmony_ci<p>If no qualifier is present on a global variable, then the variable has no
45655bd8deadSopenharmony_cilinkage to the application or shaders running on other pipeline stages.
45665bd8deadSopenharmony_ciFor either global or local unqualified variables, the declaration will
45675bd8deadSopenharmony_ciappear to allocate memory associated with the processor it targets.
45685bd8deadSopenharmony_ciThis variable will provide read/write access to this allocated memory.</p>
45695bd8deadSopenharmony_ci</div>
45705bd8deadSopenharmony_ci</div>
45715bd8deadSopenharmony_ci<div class="sect3">
45725bd8deadSopenharmony_ci<h4 id="constant-qualifier">4.3.2. Constant Qualifier</h4>
45735bd8deadSopenharmony_ci<div class="paragraph">
45745bd8deadSopenharmony_ci<p>Named compile-time constants
45755bd8deadSopenharmony_cior read-only variables
45765bd8deadSopenharmony_cican be declared using
45775bd8deadSopenharmony_cithe <strong>const</strong> qualifier.
45785bd8deadSopenharmony_ciThe <strong>const</strong> qualifier can be used with any of the non-void transparent basic
45795bd8deadSopenharmony_cidata types, as well as with structures and arrays of these.
45805bd8deadSopenharmony_ciIt is a compile-time error to write to a <strong>const</strong> variable outside of its
45815bd8deadSopenharmony_cideclaration, so they must be initialized when declared.
45825bd8deadSopenharmony_ciFor example,</p>
45835bd8deadSopenharmony_ci</div>
45845bd8deadSopenharmony_ci<div class="listingblock">
45855bd8deadSopenharmony_ci<div class="content">
45865bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="directive">const</span> vec3 zAxis = vec3 (<span class="float">0</span><span class="float">.0</span>, <span class="float">0</span><span class="float">.0</span>, <span class="float">1</span><span class="float">.0</span>);
45875bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">float</span> ceiling = a + b; <span class="comment">// a and b not necessarily constants</span></code></pre>
45885bd8deadSopenharmony_ci</div>
45895bd8deadSopenharmony_ci</div>
45905bd8deadSopenharmony_ci<div class="paragraph">
45915bd8deadSopenharmony_ci<p>Structure members may not be qualified with <strong>const</strong>.
45925bd8deadSopenharmony_ciStructure variables can be declared as <strong>const</strong>, and initialized with a
45935bd8deadSopenharmony_cistructure
45945bd8deadSopenharmony_ciconstructor or initializer.</p>
45955bd8deadSopenharmony_ci</div>
45965bd8deadSopenharmony_ci<div class="paragraph">
45975bd8deadSopenharmony_ci<p>Initializers for <strong>const</strong> declarations
45985bd8deadSopenharmony_ciat global scope
45995bd8deadSopenharmony_cimust be constant expressions, as defined in
46005bd8deadSopenharmony_ci&#8220;<a href="#constant-expressions">Constant Expressions</a>&#8221;.</p>
46015bd8deadSopenharmony_ci</div>
46025bd8deadSopenharmony_ci</div>
46035bd8deadSopenharmony_ci<div class="sect3">
46045bd8deadSopenharmony_ci<h4 id="constant-expressions">4.3.3. Constant Expressions</h4>
46055bd8deadSopenharmony_ci<div class="paragraph">
46065bd8deadSopenharmony_ci<p>SPIR-V specialization constants are expressed in GLSL as <strong>const</strong> with the
46075bd8deadSopenharmony_cilayout qualifier <strong>constant_id</strong>, as described in
46085bd8deadSopenharmony_ci&#8220;<a href="#specialization-constant-qualifier">Specialization-Constant
46095bd8deadSopenharmony_ciQualifier.</a>&#8221;</p>
46105bd8deadSopenharmony_ci</div>
46115bd8deadSopenharmony_ci<div class="paragraph">
46125bd8deadSopenharmony_ci<p>A <em>constant expression</em> is one of</p>
46135bd8deadSopenharmony_ci</div>
46145bd8deadSopenharmony_ci<div class="ulist">
46155bd8deadSopenharmony_ci<ul>
46165bd8deadSopenharmony_ci<li>
46175bd8deadSopenharmony_ci<p>A literal value (e.g. <strong>5</strong> or <strong>true</strong>).</p>
46185bd8deadSopenharmony_ci</li>
46195bd8deadSopenharmony_ci<li>
46205bd8deadSopenharmony_ci<p>A variable declared with the <strong>const</strong> qualifier and an initializer, where
46215bd8deadSopenharmony_cithe initializer is a constant expression.
46225bd8deadSopenharmony_ciThis includes both <strong>const</strong> declared with a specialization-constant
46235bd8deadSopenharmony_cilayout qualifier, e.g. <strong>layout</strong>(<strong>constant_id</strong> = &#8230;&#8203;), and those declared
46245bd8deadSopenharmony_ciwithout a specialization-constant layout qualifier.</p>
46255bd8deadSopenharmony_ci</li>
46265bd8deadSopenharmony_ci<li>
46275bd8deadSopenharmony_ci<p>Built-in variables qualified as <strong>const</strong>.</p>
46285bd8deadSopenharmony_ci</li>
46295bd8deadSopenharmony_ci<li>
46305bd8deadSopenharmony_ci<p>An expression formed by an operator on operands that are all constant
46315bd8deadSopenharmony_ciexpressions, including getting an element of a constant array, or a
46325bd8deadSopenharmony_cimember of a constant structure, or components of a constant vector.
46335bd8deadSopenharmony_ciHowever, the lowest precedence operators of the sequence operator (<strong>,</strong>)
46345bd8deadSopenharmony_ciand the assignment operators (<strong>=</strong>, <strong>+=</strong>, <strong>&#8230;&#8203;</strong>) are not included in the
46355bd8deadSopenharmony_cioperators that can create a constant expression.
46365bd8deadSopenharmony_ciAlso, an array access with a specialization constant as an index does
46375bd8deadSopenharmony_cinot result in a constant expression.</p>
46385bd8deadSopenharmony_ci</li>
46395bd8deadSopenharmony_ci<li>
46405bd8deadSopenharmony_ci<p>Valid use of the <strong>length</strong>() method on an explicitly sized object,
46415bd8deadSopenharmony_ciwhether or not the object itself is constant (implicitly sized or
46425bd8deadSopenharmony_cirun-time sized arrays do not return a constant expression).</p>
46435bd8deadSopenharmony_ci</li>
46445bd8deadSopenharmony_ci<li>
46455bd8deadSopenharmony_ci<p>A constructor whose arguments are all constant expressions.</p>
46465bd8deadSopenharmony_ci</li>
46475bd8deadSopenharmony_ci<li>
46485bd8deadSopenharmony_ci<p>For non-specialization constants only: The value returned by certain
46495bd8deadSopenharmony_cibuilt-in function calls whose arguments are all constant expressions,
46505bd8deadSopenharmony_ciincluding at least the list below.
46515bd8deadSopenharmony_ciAny other built-in function that does not access memory (not the texture
46525bd8deadSopenharmony_cilookup functions, image access, atomic counter, etc.), that has a
46535bd8deadSopenharmony_cinon-<strong>void</strong> return type, that has no <strong>out</strong> parameter, and is not a noise
46545bd8deadSopenharmony_cifunction might also be considered a constant.
46555bd8deadSopenharmony_ciWhen a function is called with an argument that is a specialization
46565bd8deadSopenharmony_ciconstant, the result is not a constant expression.</p>
46575bd8deadSopenharmony_ci<div class="ulist">
46585bd8deadSopenharmony_ci<ul>
46595bd8deadSopenharmony_ci<li>
46605bd8deadSopenharmony_ci<p>Angle and Trigonometric Functions</p>
46615bd8deadSopenharmony_ci<div class="ulist">
46625bd8deadSopenharmony_ci<ul>
46635bd8deadSopenharmony_ci<li>
46645bd8deadSopenharmony_ci<p><strong>radians</strong></p>
46655bd8deadSopenharmony_ci</li>
46665bd8deadSopenharmony_ci<li>
46675bd8deadSopenharmony_ci<p><strong>degrees</strong></p>
46685bd8deadSopenharmony_ci</li>
46695bd8deadSopenharmony_ci<li>
46705bd8deadSopenharmony_ci<p><strong>sin</strong></p>
46715bd8deadSopenharmony_ci</li>
46725bd8deadSopenharmony_ci<li>
46735bd8deadSopenharmony_ci<p><strong>cos</strong></p>
46745bd8deadSopenharmony_ci</li>
46755bd8deadSopenharmony_ci<li>
46765bd8deadSopenharmony_ci<p><strong>asin</strong></p>
46775bd8deadSopenharmony_ci</li>
46785bd8deadSopenharmony_ci<li>
46795bd8deadSopenharmony_ci<p><strong>acos</strong></p>
46805bd8deadSopenharmony_ci</li>
46815bd8deadSopenharmony_ci</ul>
46825bd8deadSopenharmony_ci</div>
46835bd8deadSopenharmony_ci</li>
46845bd8deadSopenharmony_ci<li>
46855bd8deadSopenharmony_ci<p>Exponential Functions</p>
46865bd8deadSopenharmony_ci<div class="ulist">
46875bd8deadSopenharmony_ci<ul>
46885bd8deadSopenharmony_ci<li>
46895bd8deadSopenharmony_ci<p><strong>pow</strong></p>
46905bd8deadSopenharmony_ci</li>
46915bd8deadSopenharmony_ci<li>
46925bd8deadSopenharmony_ci<p><strong>exp</strong></p>
46935bd8deadSopenharmony_ci</li>
46945bd8deadSopenharmony_ci<li>
46955bd8deadSopenharmony_ci<p><strong>log</strong></p>
46965bd8deadSopenharmony_ci</li>
46975bd8deadSopenharmony_ci<li>
46985bd8deadSopenharmony_ci<p><strong>exp2</strong></p>
46995bd8deadSopenharmony_ci</li>
47005bd8deadSopenharmony_ci<li>
47015bd8deadSopenharmony_ci<p><strong>log2</strong></p>
47025bd8deadSopenharmony_ci</li>
47035bd8deadSopenharmony_ci<li>
47045bd8deadSopenharmony_ci<p><strong>sqrt</strong></p>
47055bd8deadSopenharmony_ci</li>
47065bd8deadSopenharmony_ci<li>
47075bd8deadSopenharmony_ci<p><strong>inversesqrt</strong></p>
47085bd8deadSopenharmony_ci</li>
47095bd8deadSopenharmony_ci</ul>
47105bd8deadSopenharmony_ci</div>
47115bd8deadSopenharmony_ci</li>
47125bd8deadSopenharmony_ci<li>
47135bd8deadSopenharmony_ci<p>Common Functions</p>
47145bd8deadSopenharmony_ci<div class="ulist">
47155bd8deadSopenharmony_ci<ul>
47165bd8deadSopenharmony_ci<li>
47175bd8deadSopenharmony_ci<p><strong>abs</strong></p>
47185bd8deadSopenharmony_ci</li>
47195bd8deadSopenharmony_ci<li>
47205bd8deadSopenharmony_ci<p><strong>sign</strong></p>
47215bd8deadSopenharmony_ci</li>
47225bd8deadSopenharmony_ci<li>
47235bd8deadSopenharmony_ci<p><strong>floor</strong></p>
47245bd8deadSopenharmony_ci</li>
47255bd8deadSopenharmony_ci<li>
47265bd8deadSopenharmony_ci<p><strong>trunc</strong></p>
47275bd8deadSopenharmony_ci</li>
47285bd8deadSopenharmony_ci<li>
47295bd8deadSopenharmony_ci<p><strong>round</strong></p>
47305bd8deadSopenharmony_ci</li>
47315bd8deadSopenharmony_ci<li>
47325bd8deadSopenharmony_ci<p><strong>ceil</strong></p>
47335bd8deadSopenharmony_ci</li>
47345bd8deadSopenharmony_ci<li>
47355bd8deadSopenharmony_ci<p><strong>mod</strong></p>
47365bd8deadSopenharmony_ci</li>
47375bd8deadSopenharmony_ci<li>
47385bd8deadSopenharmony_ci<p><strong>min</strong></p>
47395bd8deadSopenharmony_ci</li>
47405bd8deadSopenharmony_ci<li>
47415bd8deadSopenharmony_ci<p><strong>max</strong></p>
47425bd8deadSopenharmony_ci</li>
47435bd8deadSopenharmony_ci<li>
47445bd8deadSopenharmony_ci<p><strong>clamp</strong></p>
47455bd8deadSopenharmony_ci</li>
47465bd8deadSopenharmony_ci</ul>
47475bd8deadSopenharmony_ci</div>
47485bd8deadSopenharmony_ci</li>
47495bd8deadSopenharmony_ci<li>
47505bd8deadSopenharmony_ci<p>Geometric Functions</p>
47515bd8deadSopenharmony_ci<div class="ulist">
47525bd8deadSopenharmony_ci<ul>
47535bd8deadSopenharmony_ci<li>
47545bd8deadSopenharmony_ci<p><strong>length</strong></p>
47555bd8deadSopenharmony_ci</li>
47565bd8deadSopenharmony_ci<li>
47575bd8deadSopenharmony_ci<p><strong>dot</strong></p>
47585bd8deadSopenharmony_ci</li>
47595bd8deadSopenharmony_ci<li>
47605bd8deadSopenharmony_ci<p><strong>normalize</strong></p>
47615bd8deadSopenharmony_ci</li>
47625bd8deadSopenharmony_ci</ul>
47635bd8deadSopenharmony_ci</div>
47645bd8deadSopenharmony_ci</li>
47655bd8deadSopenharmony_ci</ul>
47665bd8deadSopenharmony_ci</div>
47675bd8deadSopenharmony_ci</li>
47685bd8deadSopenharmony_ci<li>
47695bd8deadSopenharmony_ci<p>Function calls to user-defined functions (non-built-in functions) cannot
47705bd8deadSopenharmony_cibe used to form constant expressions.</p>
47715bd8deadSopenharmony_ci</li>
47725bd8deadSopenharmony_ci</ul>
47735bd8deadSopenharmony_ci</div>
47745bd8deadSopenharmony_ci<div class="paragraph">
47755bd8deadSopenharmony_ci<p>A <em>constant integral expression</em> is a constant expression that evaluates to
47765bd8deadSopenharmony_cia scalar signed or unsigned integer.</p>
47775bd8deadSopenharmony_ci</div>
47785bd8deadSopenharmony_ci<div class="paragraph">
47795bd8deadSopenharmony_ci<p>Constant expressions will be evaluated in an invariant way so as to create
47805bd8deadSopenharmony_cithe same value in multiple shaders when the same constant expressions appear
47815bd8deadSopenharmony_ciin those shaders.
47825bd8deadSopenharmony_ciSee &#8220;<a href="#the-invariant-qualifier">The Invariant Qualifier</a>&#8221; for more details
47835bd8deadSopenharmony_cion how to create invariant expressions and
47845bd8deadSopenharmony_ci&#8220;<a href="#precision-qualifiers">Precision Qualifiers</a>&#8221; for detail on how
47855bd8deadSopenharmony_ciexpressions are evaluated.</p>
47865bd8deadSopenharmony_ci</div>
47875bd8deadSopenharmony_ci<div class="paragraph">
47885bd8deadSopenharmony_ci<p>Constant expressions respect the <strong>precise</strong> and <strong>invariant</strong> qualifiers but
47895bd8deadSopenharmony_ciwill be always be evaluated in an invariant way, independent of the use of
47905bd8deadSopenharmony_cisuch qualification, so as to create the same value in multiple shaders when
47915bd8deadSopenharmony_cithe same constant expressions appear in those shaders.
47925bd8deadSopenharmony_ciSee &#8220;<a href="#the-invariant-qualifier">The Invariant Qualifier</a>&#8221; and
47935bd8deadSopenharmony_ci&#8220;<a href="#the-precise-qualifier">The Precise Qualifier</a>&#8221; for more details on how
47945bd8deadSopenharmony_cito create invariant expressions.</p>
47955bd8deadSopenharmony_ci</div>
47965bd8deadSopenharmony_ci<div class="paragraph">
47975bd8deadSopenharmony_ci<p>Constant-expressions may be evaluated by a
47985bd8deadSopenharmony_cihost platform, and are therefore not required to compute the same value that
47995bd8deadSopenharmony_cithe same expression would evaluate to on the shader execution target.
48005bd8deadSopenharmony_ciHowever, the host must use the same or greater precision than the target
48015bd8deadSopenharmony_ciwould use.
48025bd8deadSopenharmony_ciWhen the precision qualification cannot be determined, the expression is
48035bd8deadSopenharmony_cievaluated at <strong>highp</strong>.
48045bd8deadSopenharmony_ciSee &#8220;<a href="#default-precision-qualifiers">Default Precision Qualifiers</a>&#8221;.</p>
48055bd8deadSopenharmony_ci</div>
48065bd8deadSopenharmony_ci<div class="paragraph">
48075bd8deadSopenharmony_ci<p>Specialization-constant expressions are never evaluated by the compiler
48085bd8deadSopenharmony_cifront end, but instead retain the expression&#8217;s operations needed to evaluate
48095bd8deadSopenharmony_cithem later on the host.</p>
48105bd8deadSopenharmony_ci</div>
48115bd8deadSopenharmony_ci</div>
48125bd8deadSopenharmony_ci<div class="sect3">
48135bd8deadSopenharmony_ci<h4 id="input-variables">4.3.4. Input Variables</h4>
48145bd8deadSopenharmony_ci<div class="paragraph">
48155bd8deadSopenharmony_ci<p>Shader input variables are declared with the <strong>in</strong> storage qualifier.
48165bd8deadSopenharmony_ciThey form the input interface between previous stages of the API
48175bd8deadSopenharmony_cipipeline and the declaring shader.
48185bd8deadSopenharmony_ciInput variables must be declared at global scope.
48195bd8deadSopenharmony_ciValues from the previous pipeline stage are copied into input variables at
48205bd8deadSopenharmony_cithe beginning of shader execution.
48215bd8deadSopenharmony_ciIt is a compile-time error to write to a variable declared as an input.</p>
48225bd8deadSopenharmony_ci</div>
48235bd8deadSopenharmony_ci<div class="paragraph">
48245bd8deadSopenharmony_ci<p>Only the input variables that are
48255bd8deadSopenharmony_cistatically
48265bd8deadSopenharmony_ciread need to be written by the
48275bd8deadSopenharmony_ciprevious stage; it is allowed to have superfluous declarations of input
48285bd8deadSopenharmony_civariables.
48295bd8deadSopenharmony_ciThis is shown in the following table.</p>
48305bd8deadSopenharmony_ci</div>
48315bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all fit-content">
48325bd8deadSopenharmony_ci<colgroup>
48335bd8deadSopenharmony_ci<col>
48345bd8deadSopenharmony_ci<col>
48355bd8deadSopenharmony_ci<col>
48365bd8deadSopenharmony_ci<col>
48375bd8deadSopenharmony_ci<col>
48385bd8deadSopenharmony_ci</colgroup>
48395bd8deadSopenharmony_ci<tbody>
48405bd8deadSopenharmony_ci<tr>
48415bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top" colspan="2" rowspan="2"><p class="tableblock">Treatment of Mismatched Input Variables</p></td>
48425bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top" colspan="3"><p class="tableblock">Consuming Shader (input variables)</p></td>
48435bd8deadSopenharmony_ci</tr>
48445bd8deadSopenharmony_ci<tr>
48455bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">No Declaration</p></td>
48465bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Declared but no Static Use</p></td>
48475bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Declared and Static Use</p></td>
48485bd8deadSopenharmony_ci</tr>
48495bd8deadSopenharmony_ci<tr>
48505bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top" rowspan="3"><p class="tableblock">Generating Shader (output variables)</p></td>
48515bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">No Declaration</p></td>
48525bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Allowed</p></td>
48535bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Allowed</p></td>
48545bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Link-Time Error</p></td>
48555bd8deadSopenharmony_ci</tr>
48565bd8deadSopenharmony_ci<tr>
48575bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Declared but no Static Use</p></td>
48585bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Allowed</p></td>
48595bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Allowed</p></td>
48605bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Allowed (values are undefined)</p></td>
48615bd8deadSopenharmony_ci</tr>
48625bd8deadSopenharmony_ci<tr>
48635bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Declared and Static Use</p></td>
48645bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Allowed</p></td>
48655bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Allowed</p></td>
48665bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Allowed (values are potentially undefined)</p></td>
48675bd8deadSopenharmony_ci</tr>
48685bd8deadSopenharmony_ci</tbody>
48695bd8deadSopenharmony_ci</table>
48705bd8deadSopenharmony_ci<div class="paragraph">
48715bd8deadSopenharmony_ci<p>Consumption errors are based on static use only.
48725bd8deadSopenharmony_ciCompilation may generate a warning, but not an error, for any dynamic use
48735bd8deadSopenharmony_cithe compiler can deduce that might cause consumption of undefined values.</p>
48745bd8deadSopenharmony_ci</div>
48755bd8deadSopenharmony_ci<div class="paragraph">
48765bd8deadSopenharmony_ci<p>See &#8220;<a href="#built-in-variables">Built-In Variables</a>&#8221; for a list of the built-in
48775bd8deadSopenharmony_ciinput names.</p>
48785bd8deadSopenharmony_ci</div>
48795bd8deadSopenharmony_ci<div class="paragraph">
48805bd8deadSopenharmony_ci<p>Vertex shader input variables (or attributes) receive per-vertex data.
48815bd8deadSopenharmony_ciIt is a compile-time error to use auxiliary storage or interpolation qualifiers
48825bd8deadSopenharmony_cion a vertex shader input.
48835bd8deadSopenharmony_ciThe values copied in are established by the API or through the use
48845bd8deadSopenharmony_ciof the layout identifier <strong>location</strong>.</p>
48855bd8deadSopenharmony_ci</div>
48865bd8deadSopenharmony_ci<div class="paragraph">
48875bd8deadSopenharmony_ci<p>It is a compile-time error to declare a vertex shader input with, or that
48885bd8deadSopenharmony_cicontains, any of the following types:</p>
48895bd8deadSopenharmony_ci</div>
48905bd8deadSopenharmony_ci<div class="ulist">
48915bd8deadSopenharmony_ci<ul>
48925bd8deadSopenharmony_ci<li>
48935bd8deadSopenharmony_ci<p>A <a href="#booleans">boolean type</a></p>
48945bd8deadSopenharmony_ci</li>
48955bd8deadSopenharmony_ci<li>
48965bd8deadSopenharmony_ci<p>An <a href="#opaque-types">opaque type</a></p>
48975bd8deadSopenharmony_ci</li>
48985bd8deadSopenharmony_ci<li>
48995bd8deadSopenharmony_ci<p>A structure</p>
49005bd8deadSopenharmony_ci</li>
49015bd8deadSopenharmony_ci</ul>
49025bd8deadSopenharmony_ci</div>
49035bd8deadSopenharmony_ci<div class="paragraph">
49045bd8deadSopenharmony_ci<p>Example declarations in a vertex shader:</p>
49055bd8deadSopenharmony_ci</div>
49065bd8deadSopenharmony_ci<div class="listingblock">
49075bd8deadSopenharmony_ci<div class="content">
49085bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">in vec4 position;
49095bd8deadSopenharmony_ciin vec3 normal;
49105bd8deadSopenharmony_ciin vec2 texCoord[<span class="integer">4</span>];</code></pre>
49115bd8deadSopenharmony_ci</div>
49125bd8deadSopenharmony_ci</div>
49135bd8deadSopenharmony_ci<div class="paragraph">
49145bd8deadSopenharmony_ci<p>It is expected that graphics hardware will have a small number of fixed
49155bd8deadSopenharmony_civector locations for passing vertex inputs.
49165bd8deadSopenharmony_ciTherefore, the OpenGL Shading Language defines each non-matrix input variable as taking up
49175bd8deadSopenharmony_cione such vector location.
49185bd8deadSopenharmony_ciThere is an implementation-dependent limit on the number of locations that
49195bd8deadSopenharmony_cican be used, and if this is exceeded it will cause a link-time error.
49205bd8deadSopenharmony_ci(Declared input variables that are not statically used do not count against
49215bd8deadSopenharmony_cithis limit.) A scalar input counts the same amount against this limit as a
49225bd8deadSopenharmony_ci<strong>vec4</strong>, so applications may want to consider packing groups of four
49235bd8deadSopenharmony_ciunrelated float inputs together into a vector to better utilize the
49245bd8deadSopenharmony_cicapabilities of the underlying hardware.
49255bd8deadSopenharmony_ciA matrix input will use up multiple locations.
49265bd8deadSopenharmony_ciThe number of locations used will equal the number of columns in the matrix.</p>
49275bd8deadSopenharmony_ci</div>
49285bd8deadSopenharmony_ci<div class="paragraph">
49295bd8deadSopenharmony_ci<p>Tessellation control, evaluation, and geometry shader input variables get
49305bd8deadSopenharmony_cithe per-vertex values written out by output variables of the same names in
49315bd8deadSopenharmony_cithe previous active shader stage.
49325bd8deadSopenharmony_ciFor these inputs, <strong>centroid</strong> and interpolation qualifiers are allowed, but
49335bd8deadSopenharmony_cihave no effect.
49345bd8deadSopenharmony_ciSince tessellation control, tessellation evaluation, and geometry shaders
49355bd8deadSopenharmony_cioperate on a set of vertices, each input variable (or input block, see
49365bd8deadSopenharmony_ciinterface blocks below) needs to be declared as an array.
49375bd8deadSopenharmony_ciFor example,</p>
49385bd8deadSopenharmony_ci</div>
49395bd8deadSopenharmony_ci<div class="listingblock">
49405bd8deadSopenharmony_ci<div class="content">
49415bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">in <span class="predefined-type">float</span> foo[]; <span class="comment">// geometry shader input for vertex &quot;out float foo&quot;</span></code></pre>
49425bd8deadSopenharmony_ci</div>
49435bd8deadSopenharmony_ci</div>
49445bd8deadSopenharmony_ci<div class="paragraph">
49455bd8deadSopenharmony_ci<p>Each element of such an array corresponds to one vertex of the primitive
49465bd8deadSopenharmony_cibeing processed.
49475bd8deadSopenharmony_ciEach array can optionally have a size declared.
49485bd8deadSopenharmony_ciFor geometry shaders, the array size will be set by, (or if provided must be
49495bd8deadSopenharmony_ciconsistent with) the input <strong>layout</strong> declaration(s) establishing the type of
49505bd8deadSopenharmony_ciinput primitive, as described later in &#8220;<a href="#input-layout-qualifiers">Input
49515bd8deadSopenharmony_ciLayout Qualifiers</a>&#8221;.</p>
49525bd8deadSopenharmony_ci</div>
49535bd8deadSopenharmony_ci<div class="paragraph">
49545bd8deadSopenharmony_ci<p>Some inputs and outputs are <em>arrayed</em>, meaning that for an interface between
49555bd8deadSopenharmony_citwo shader stages either the input or output declaration requires an extra
49565bd8deadSopenharmony_cilevel of array indexing for the declarations to match.
49575bd8deadSopenharmony_ciFor example, with the interface between a vertex shader and a geometry
49585bd8deadSopenharmony_cishader, vertex shader output variables and geometry shader input variables
49595bd8deadSopenharmony_ciof the same name must have matching types, except that the geometry shader
49605bd8deadSopenharmony_ciwill have one more array dimension than the vertex shader, to allow for
49615bd8deadSopenharmony_civertex indexing.
49625bd8deadSopenharmony_ciIf such an arrayed interface variable is not declared with the necessary
49635bd8deadSopenharmony_ciadditional input or output array dimension, a link-time error will result.
49645bd8deadSopenharmony_ciGeometry shader inputs, tessellation control shader inputs and outputs, and
49655bd8deadSopenharmony_citessellation evaluation inputs all have an additional level of arrayness
49665bd8deadSopenharmony_cirelative to other shader inputs and outputs.
49675bd8deadSopenharmony_ciThese inputs and outputs are known as <em>per-vertex-arrayed</em> inputs and
49685bd8deadSopenharmony_cioutputs.
49695bd8deadSopenharmony_ciComponent limits for arrayed interfaces (e.g.
49705bd8deadSopenharmony_ci<em>gl_MaxTessControlInputComponents</em>) are limits per vertex, not limits for
49715bd8deadSopenharmony_cithe entire interface.</p>
49725bd8deadSopenharmony_ci</div>
49735bd8deadSopenharmony_ci<div class="paragraph">
49745bd8deadSopenharmony_ci<p>For non-arrayed interfaces (meaning array dimensionally stays the same
49755bd8deadSopenharmony_cibetween stages), it is a link-time error if the input variable is not
49765bd8deadSopenharmony_cideclared with the same type, including array dimensionality, as the matching
49775bd8deadSopenharmony_cioutput variable.</p>
49785bd8deadSopenharmony_ci</div>
49795bd8deadSopenharmony_ci<div class="paragraph">
49805bd8deadSopenharmony_ci<p>The link-time type-matching rules apply to all declared input and output
49815bd8deadSopenharmony_civariables, whether or not they are used.</p>
49825bd8deadSopenharmony_ci</div>
49835bd8deadSopenharmony_ci<div class="paragraph">
49845bd8deadSopenharmony_ci<p>Additionally, tessellation evaluation shaders support per-patch input
49855bd8deadSopenharmony_civariables declared with the <strong>patch</strong> and <strong>in</strong> qualifiers.
49865bd8deadSopenharmony_ciPer-patch input variables are filled with the values of per-patch output
49875bd8deadSopenharmony_civariables written by the tessellation control shader.
49885bd8deadSopenharmony_ciPer-patch inputs may be declared as one-dimensional arrays, but are not
49895bd8deadSopenharmony_ciindexed by vertex number.
49905bd8deadSopenharmony_ciApplying the <strong>patch</strong> qualifier to inputs can only be done in tessellation
49915bd8deadSopenharmony_cievaluation shaders.
49925bd8deadSopenharmony_ciAs with other input variables, per-patch inputs must be declared using the
49935bd8deadSopenharmony_cisame type and qualification as per-patch outputs from the previous
49945bd8deadSopenharmony_ci(tessellation control) shader stage.
49955bd8deadSopenharmony_ciIt is a compile-time error to use <strong>patch</strong> with inputs in any other stage.</p>
49965bd8deadSopenharmony_ci</div>
49975bd8deadSopenharmony_ci<div class="paragraph">
49985bd8deadSopenharmony_ci<p>It is a compile-time error to declare a tessellation control, tessellation
49995bd8deadSopenharmony_cievaluation or geometry shader input with, or that contains, any of the
50005bd8deadSopenharmony_cifollowing types:</p>
50015bd8deadSopenharmony_ci</div>
50025bd8deadSopenharmony_ci<div class="ulist">
50035bd8deadSopenharmony_ci<ul>
50045bd8deadSopenharmony_ci<li>
50055bd8deadSopenharmony_ci<p>A <a href="#booleans">boolean type</a></p>
50065bd8deadSopenharmony_ci</li>
50075bd8deadSopenharmony_ci<li>
50085bd8deadSopenharmony_ci<p>An <a href="#opaque-types">opaque type</a></p>
50095bd8deadSopenharmony_ci</li>
50105bd8deadSopenharmony_ci</ul>
50115bd8deadSopenharmony_ci</div>
50125bd8deadSopenharmony_ci<div class="paragraph">
50135bd8deadSopenharmony_ci<p>Fragment shader inputs get per-fragment values, typically interpolated from
50145bd8deadSopenharmony_cia previous stage&#8217;s outputs.
50155bd8deadSopenharmony_ciThe auxiliary storage qualifiers <strong>centroid</strong> and <strong>sample</strong> can also be
50165bd8deadSopenharmony_ciapplied, as well as the interpolation qualifiers <strong>flat</strong>, <strong>noperspective</strong>,
50175bd8deadSopenharmony_ciand <strong>smooth.</strong></p>
50185bd8deadSopenharmony_ci</div>
50195bd8deadSopenharmony_ci<div class="paragraph">
50205bd8deadSopenharmony_ci<p>It is a compile-time error to declare a fragment shader input with, or that
50215bd8deadSopenharmony_cicontains, any of the following types:</p>
50225bd8deadSopenharmony_ci</div>
50235bd8deadSopenharmony_ci<div class="ulist">
50245bd8deadSopenharmony_ci<ul>
50255bd8deadSopenharmony_ci<li>
50265bd8deadSopenharmony_ci<p>A <a href="#booleans">boolean type</a></p>
50275bd8deadSopenharmony_ci</li>
50285bd8deadSopenharmony_ci<li>
50295bd8deadSopenharmony_ci<p>An <a href="#opaque-types">opaque type</a></p>
50305bd8deadSopenharmony_ci</li>
50315bd8deadSopenharmony_ci</ul>
50325bd8deadSopenharmony_ci</div>
50335bd8deadSopenharmony_ci<div class="paragraph">
50345bd8deadSopenharmony_ci<p>Fragment shader inputs that are, or contain, integral
50355bd8deadSopenharmony_cior double-precision floating-point
50365bd8deadSopenharmony_citypes must be
50375bd8deadSopenharmony_ciqualified with the interpolation qualifier <strong>flat</strong>.</p>
50385bd8deadSopenharmony_ci</div>
50395bd8deadSopenharmony_ci<div class="paragraph">
50405bd8deadSopenharmony_ci<p>Fragment inputs are declared as in the following examples:</p>
50415bd8deadSopenharmony_ci</div>
50425bd8deadSopenharmony_ci<div class="listingblock">
50435bd8deadSopenharmony_ci<div class="content">
50445bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">in vec3 normal;
50455bd8deadSopenharmony_cicentroid in vec2 TexCoord;
50465bd8deadSopenharmony_ciinvariant centroid in vec4 Color;
50475bd8deadSopenharmony_cinoperspective in <span class="predefined-type">float</span> temperature;
50485bd8deadSopenharmony_ciflat in vec3 myColor;
50495bd8deadSopenharmony_cinoperspective centroid in vec2 myTexCoord;</code></pre>
50505bd8deadSopenharmony_ci</div>
50515bd8deadSopenharmony_ci</div>
50525bd8deadSopenharmony_ci<div class="paragraph">
50535bd8deadSopenharmony_ci<p>The fragment shader inputs form an interface with the last active shader in
50545bd8deadSopenharmony_cithe vertex processing pipeline.
50555bd8deadSopenharmony_ciFor this interface, the last active shader stage output variables and
50565bd8deadSopenharmony_cifragment shader input variables of the same name must match in type and
50575bd8deadSopenharmony_ciqualification, with a few exceptions: The storage qualifiers must, of
50585bd8deadSopenharmony_cicourse, differ (one is <strong>in</strong> and one is <strong>out</strong>).
50595bd8deadSopenharmony_ciAlso,
50605bd8deadSopenharmony_ciinterpolation qualification (e.g. <strong>flat</strong>) and
50615bd8deadSopenharmony_ciauxiliary qualification (e.g. <strong>centroid</strong>) may differ.
50625bd8deadSopenharmony_ciThese mismatches are allowed between any pair of stages.
50635bd8deadSopenharmony_ciWhen
50645bd8deadSopenharmony_ciinterpolation or
50655bd8deadSopenharmony_ciauxiliary qualifiers do not match, those provided in
50665bd8deadSopenharmony_cithe fragment shader supersede those provided in previous stages.
50675bd8deadSopenharmony_ciIf any such qualifiers are completely missing in the fragment shaders, then
50685bd8deadSopenharmony_cithe default is used, rather than any qualifiers that may have been declared
50695bd8deadSopenharmony_ciin previous stages.
50705bd8deadSopenharmony_ciThat is, what matters is what is declared in the fragment shaders, not what
50715bd8deadSopenharmony_ciis declared in shaders in previous stages.</p>
50725bd8deadSopenharmony_ci</div>
50735bd8deadSopenharmony_ci<div class="paragraph">
50745bd8deadSopenharmony_ci<p>When an interface between shader stages is formed using shaders from two
50755bd8deadSopenharmony_ciseparate program objects, it is not possible to detect mismatches between
50765bd8deadSopenharmony_ciinputs and outputs when the programs are linked.
50775bd8deadSopenharmony_ciWhen there are mismatches between inputs and outputs on such interfaces,
50785bd8deadSopenharmony_cithe values passed across the interface will be partially or completely
50795bd8deadSopenharmony_ciundefined.</p>
50805bd8deadSopenharmony_ci</div>
50815bd8deadSopenharmony_ci<div class="paragraph">
50825bd8deadSopenharmony_ci<p>Shaders can ensure matches across such interfaces either by using input and
50835bd8deadSopenharmony_cioutput layout qualifiers (sections &#8220;<a href="#input-layout-qualifiers">Input Layout
50845bd8deadSopenharmony_ciQualifiers</a>&#8221; and &#8220;<a href="#output-layout-qualifiers">Output Layout
50855bd8deadSopenharmony_ciQualifiers</a>&#8221;) or by using identical input and output declarations of
50865bd8deadSopenharmony_ciblocks or variables.
50875bd8deadSopenharmony_ciComplete rules for interface matching are found in section 7.4.1 &#8220;Shader
50885bd8deadSopenharmony_ciInterface Matching&#8221; of the <a href="#references">OpenGL Specification</a>.</p>
50895bd8deadSopenharmony_ci</div>
50905bd8deadSopenharmony_ci<div class="paragraph">
50915bd8deadSopenharmony_ci<p>Compute shaders do not permit user-defined input variables and do not form a
50925bd8deadSopenharmony_ciformal interface with any other shader stage.
50935bd8deadSopenharmony_ciSee &#8220;<a href="#compute-shader-special-variables">Compute Shader Special
50945bd8deadSopenharmony_ciVariables</a>&#8221; for a description of built-in compute shader input variables.
50955bd8deadSopenharmony_ciAll other input to a compute shader is retrieved explicitly through image
50965bd8deadSopenharmony_ciloads, texture fetches, loads from uniforms or uniform buffers, or other
50975bd8deadSopenharmony_ciuser supplied code.
50985bd8deadSopenharmony_ciRedeclaration of built-in input variables in compute shaders is not
50995bd8deadSopenharmony_cipermitted.</p>
51005bd8deadSopenharmony_ci</div>
51015bd8deadSopenharmony_ci</div>
51025bd8deadSopenharmony_ci<div class="sect3">
51035bd8deadSopenharmony_ci<h4 id="uniform-variables">4.3.5. Uniform Variables</h4>
51045bd8deadSopenharmony_ci<div class="paragraph">
51055bd8deadSopenharmony_ci<p>The <strong>uniform</strong> qualifier is used to declare global variables whose values are
51065bd8deadSopenharmony_cithe same across the entire primitive being processed.
51075bd8deadSopenharmony_ciAll <strong>uniform</strong> variables are read-only and are initialized externally either
51085bd8deadSopenharmony_ciat link time or through the API.
51095bd8deadSopenharmony_ciThe link-time initial value is either the value of the variable&#8217;s
51105bd8deadSopenharmony_ciinitializer, if present, or 0 if no initializer is present.
51115bd8deadSopenharmony_ciOpaque types cannot have initializers, or a compile-time error results.
51125bd8deadSopenharmony_ciWhen targeting Vulkan, it is a compile-time error to declare <strong>uniform</strong>
51135bd8deadSopenharmony_civariables outside a block.</p>
51145bd8deadSopenharmony_ci</div>
51155bd8deadSopenharmony_ci<div class="paragraph">
51165bd8deadSopenharmony_ci<p>Example declarations are:</p>
51175bd8deadSopenharmony_ci</div>
51185bd8deadSopenharmony_ci<div class="listingblock">
51195bd8deadSopenharmony_ci<div class="content">
51205bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">uniform vec4 lightPosition;
51215bd8deadSopenharmony_ciuniform vec3 color = vec3(<span class="float">0</span><span class="float">.7</span>, <span class="float">0</span><span class="float">.7</span>, <span class="float">0</span><span class="float">.2</span>); <span class="comment">// value assigned at link time</span></code></pre>
51225bd8deadSopenharmony_ci</div>
51235bd8deadSopenharmony_ci</div>
51245bd8deadSopenharmony_ci<div class="paragraph">
51255bd8deadSopenharmony_ci<p>The <strong>uniform</strong> qualifier can be used with any of the basic data types, or
51265bd8deadSopenharmony_ciwhen declaring a variable whose type is a structure, or an array of any of
51275bd8deadSopenharmony_cithese.</p>
51285bd8deadSopenharmony_ci</div>
51295bd8deadSopenharmony_ci<div class="paragraph">
51305bd8deadSopenharmony_ci<p>There is an implementation-dependent limit on the amount of storage for
51315bd8deadSopenharmony_ciuniforms that can be used for each type of shader and if this is exceeded it
51325bd8deadSopenharmony_ciwill cause a compile-time or link-time error.
51335bd8deadSopenharmony_ciUniform variables that are declared but not
51345bd8deadSopenharmony_ciused do not count against this limit.
51355bd8deadSopenharmony_ciThe number of user-defined uniform variables and the number of built-in
51365bd8deadSopenharmony_ciuniform variables that are used within a shader are added together to
51375bd8deadSopenharmony_cidetermine whether available uniform storage has been exceeded.</p>
51385bd8deadSopenharmony_ci</div>
51395bd8deadSopenharmony_ci<div class="paragraph">
51405bd8deadSopenharmony_ci<p>Uniforms in shaders all share a single global name space when linked into a
51415bd8deadSopenharmony_ciprogram or separable program.
51425bd8deadSopenharmony_ciHence, the types,
51435bd8deadSopenharmony_ciinitializers,
51445bd8deadSopenharmony_ciand any location specifiers of all statically used uniform variables with the
51455bd8deadSopenharmony_cisame name must match across all shaders that are linked into a single program.
51465bd8deadSopenharmony_ciHowever it is not required to repeat the
51475bd8deadSopenharmony_ciinitializer or
51485bd8deadSopenharmony_cilocation specifier in all the linked shaders.
51495bd8deadSopenharmony_ciWhile this single uniform name space is cross stage, a uniform variable
51505bd8deadSopenharmony_ciname&#8217;s scope is per stage: If a uniform variable name is declared in one
51515bd8deadSopenharmony_cistage (e.g. a vertex shader) but not in another (e.g. a fragment shader),
51525bd8deadSopenharmony_cithen that name is still available in the other stage for a different use.</p>
51535bd8deadSopenharmony_ci</div>
51545bd8deadSopenharmony_ci</div>
51555bd8deadSopenharmony_ci<div class="sect3">
51565bd8deadSopenharmony_ci<h4 id="output-variables">4.3.6. Output Variables</h4>
51575bd8deadSopenharmony_ci<div class="paragraph">
51585bd8deadSopenharmony_ci<p>Shader output variables are declared with the <strong>out</strong> storage qualifier.
51595bd8deadSopenharmony_ciThey form the output interface between the declaring shader and the
51605bd8deadSopenharmony_cisubsequent stages of the API pipeline.
51615bd8deadSopenharmony_ciOutput variables must be declared at global scope.
51625bd8deadSopenharmony_ciDuring shader execution they will behave as normal unqualified global
51635bd8deadSopenharmony_civariables.
51645bd8deadSopenharmony_ciTheir values are copied out to the subsequent pipeline stage on shader exit.
51655bd8deadSopenharmony_ciOnly output variables that are read by the subsequent pipeline stage need to
51665bd8deadSopenharmony_cibe written; it is allowed to have superfluous declarations of output
51675bd8deadSopenharmony_civariables.</p>
51685bd8deadSopenharmony_ci</div>
51695bd8deadSopenharmony_ci<div class="paragraph">
51705bd8deadSopenharmony_ci<p>There is <em>not</em> an <strong>inout</strong> storage qualifier for declaring a single variable
51715bd8deadSopenharmony_ciname as both input and output to a shader.
51725bd8deadSopenharmony_ciAlso, a variable cannot be declared with both the <strong>in</strong> and the <strong>out</strong>
51735bd8deadSopenharmony_ciqualifiers, this will result in a compile-time or link-time error.
51745bd8deadSopenharmony_ciOutput variables must be declared with different names than input variables.
51755bd8deadSopenharmony_ciHowever, nesting an input or output inside an interface block with an
51765bd8deadSopenharmony_ciinstance name allows the same names with one referenced through a block
51775bd8deadSopenharmony_ciinstance name.</p>
51785bd8deadSopenharmony_ci</div>
51795bd8deadSopenharmony_ci<div class="paragraph">
51805bd8deadSopenharmony_ci<p>Vertex, tessellation evaluation, and geometry output variables output
51815bd8deadSopenharmony_ciper-vertex data and are declared using the <strong>out</strong> storage qualifier.
51825bd8deadSopenharmony_ciApplying <strong>patch</strong> to an output can only be done in a tessellation control
51835bd8deadSopenharmony_cishader.
51845bd8deadSopenharmony_ciIt is a compile-time error to use <strong>patch</strong> on outputs in any other stage.</p>
51855bd8deadSopenharmony_ci</div>
51865bd8deadSopenharmony_ci<div class="paragraph">
51875bd8deadSopenharmony_ci<p>It is a compile-time error to declare a vertex, tessellation evaluation,
51885bd8deadSopenharmony_citessellation control, or geometry shader output with, or that contains, any
51895bd8deadSopenharmony_ciof the following types:</p>
51905bd8deadSopenharmony_ci</div>
51915bd8deadSopenharmony_ci<div class="ulist">
51925bd8deadSopenharmony_ci<ul>
51935bd8deadSopenharmony_ci<li>
51945bd8deadSopenharmony_ci<p>A <a href="#booleans">boolean type</a></p>
51955bd8deadSopenharmony_ci</li>
51965bd8deadSopenharmony_ci<li>
51975bd8deadSopenharmony_ci<p>An <a href="#opaque-types">opaque type</a></p>
51985bd8deadSopenharmony_ci</li>
51995bd8deadSopenharmony_ci</ul>
52005bd8deadSopenharmony_ci</div>
52015bd8deadSopenharmony_ci<div class="paragraph">
52025bd8deadSopenharmony_ci<p>Individual outputs are declared as in the following examples:</p>
52035bd8deadSopenharmony_ci</div>
52045bd8deadSopenharmony_ci<div class="listingblock">
52055bd8deadSopenharmony_ci<div class="content">
52065bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">out vec3 normal;
52075bd8deadSopenharmony_cicentroid out vec2 TexCoord;
52085bd8deadSopenharmony_ciinvariant centroid out vec4 Color;
52095bd8deadSopenharmony_ciflat out vec3 myColor;
52105bd8deadSopenharmony_cisample out vec4 perSampleColor;</code></pre>
52115bd8deadSopenharmony_ci</div>
52125bd8deadSopenharmony_ci</div>
52135bd8deadSopenharmony_ci<div class="paragraph">
52145bd8deadSopenharmony_ci<p>These can also appear in interface blocks, as described in
52155bd8deadSopenharmony_ci&#8220;<a href="#interface-blocks">Interface Blocks</a>&#8221;.
52165bd8deadSopenharmony_ciInterface blocks allow simpler addition of arrays to the interface from
52175bd8deadSopenharmony_civertex to geometry shader.
52185bd8deadSopenharmony_ciThey also allow a fragment shader to have the same input interface as a
52195bd8deadSopenharmony_cigeometry shader for a given vertex shader.</p>
52205bd8deadSopenharmony_ci</div>
52215bd8deadSopenharmony_ci<div class="paragraph">
52225bd8deadSopenharmony_ci<p>Tessellation control shader output variables are used to output
52235bd8deadSopenharmony_ciper-vertex and per-patch data.
52245bd8deadSopenharmony_ciPer-vertex output variables are arrayed (see <em>arrayed</em> under
52255bd8deadSopenharmony_ci&#8220;<a href="#input-variables">Input Variables</a>&#8221;) and declared using the <strong>out</strong>
52265bd8deadSopenharmony_ciqualifier without the <strong>patch</strong> qualifier.
52275bd8deadSopenharmony_ciPer-patch output variables are declared using the <strong>patch</strong> and <strong>out</strong>
52285bd8deadSopenharmony_ciqualifiers.</p>
52295bd8deadSopenharmony_ci</div>
52305bd8deadSopenharmony_ci<div class="paragraph">
52315bd8deadSopenharmony_ci<p>Since tessellation control shaders produce an arrayed primitive comprising
52325bd8deadSopenharmony_cimultiple vertices, each per-vertex output variable (or output block, see
52335bd8deadSopenharmony_ciinterface blocks below) needs to be declared as an array.
52345bd8deadSopenharmony_ciFor example,</p>
52355bd8deadSopenharmony_ci</div>
52365bd8deadSopenharmony_ci<div class="listingblock">
52375bd8deadSopenharmony_ci<div class="content">
52385bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">out <span class="predefined-type">float</span> foo[]; <span class="comment">// feeds next stage input &quot;in float foo[]&quot;</span></code></pre>
52395bd8deadSopenharmony_ci</div>
52405bd8deadSopenharmony_ci</div>
52415bd8deadSopenharmony_ci<div class="paragraph">
52425bd8deadSopenharmony_ci<p>Each element of such an array corresponds to one vertex of the primitive
52435bd8deadSopenharmony_cibeing produced.
52445bd8deadSopenharmony_ciEach array can optionally have a size declared.
52455bd8deadSopenharmony_ciThe array size will be set by (or if provided must be consistent with) the
52465bd8deadSopenharmony_cioutput layout declaration(s) establishing the number of vertices in the
52475bd8deadSopenharmony_cioutput patch, as described later in
52485bd8deadSopenharmony_ci&#8220;<a href="#tessellation-control-outputs">Tessellation Control Outputs</a>&#8221;.</p>
52495bd8deadSopenharmony_ci</div>
52505bd8deadSopenharmony_ci<div class="paragraph">
52515bd8deadSopenharmony_ci<p>Each tessellation control shader invocation has a corresponding output patch
52525bd8deadSopenharmony_civertex, and may assign values to per-vertex outputs only if they belong to
52535bd8deadSopenharmony_cithat corresponding vertex.
52545bd8deadSopenharmony_ciIf a per-vertex output variable is used as an l-value, it is a compile-time
52555bd8deadSopenharmony_cior link-time error if the expression indicating the vertex index is not the
52565bd8deadSopenharmony_ciidentifier <em>gl_InvocationID</em>.</p>
52575bd8deadSopenharmony_ci</div>
52585bd8deadSopenharmony_ci<div class="paragraph">
52595bd8deadSopenharmony_ci<p>The order of execution of a tessellation control shader invocation relative
52605bd8deadSopenharmony_cito the other invocations for the same input patch is undefined unless the
52615bd8deadSopenharmony_cibuilt-in function <strong>barrier</strong>() is used.
52625bd8deadSopenharmony_ciThis provides some control over relative execution order.
52635bd8deadSopenharmony_ciWhen a shader invocation calls <strong>barrier</strong>(), its execution pauses until all
52645bd8deadSopenharmony_ciother invocations have reached the same point of execution.
52655bd8deadSopenharmony_ciOutput variable assignments performed by any invocation executed prior to
52665bd8deadSopenharmony_cicalling <strong>barrier</strong>() will be visible to any other invocation after the call
52675bd8deadSopenharmony_cito <strong>barrier</strong>() returns.</p>
52685bd8deadSopenharmony_ci</div>
52695bd8deadSopenharmony_ci<div class="paragraph">
52705bd8deadSopenharmony_ci<p>Because tessellation control shader invocations execute in undefined order
52715bd8deadSopenharmony_cibetween barriers, the values of per-vertex or per-patch output variables
52725bd8deadSopenharmony_ciwill sometimes be undefined.
52735bd8deadSopenharmony_ciConsider the beginning and end of shader execution and each call to
52745bd8deadSopenharmony_ci<strong>barrier</strong>() as synchronization points.
52755bd8deadSopenharmony_ciThe value of an output variable will be undefined in any of the three
52765bd8deadSopenharmony_cifollowing cases:</p>
52775bd8deadSopenharmony_ci</div>
52785bd8deadSopenharmony_ci<div class="olist arabic">
52795bd8deadSopenharmony_ci<ol class="arabic">
52805bd8deadSopenharmony_ci<li>
52815bd8deadSopenharmony_ci<p>At the beginning of execution.</p>
52825bd8deadSopenharmony_ci</li>
52835bd8deadSopenharmony_ci<li>
52845bd8deadSopenharmony_ci<p>At each synchronization point, unless</p>
52855bd8deadSopenharmony_ci<div class="openblock">
52865bd8deadSopenharmony_ci<div class="content">
52875bd8deadSopenharmony_ci<div class="ulist">
52885bd8deadSopenharmony_ci<ul>
52895bd8deadSopenharmony_ci<li>
52905bd8deadSopenharmony_ci<p>the value was well-defined after the previous synchronization point and
52915bd8deadSopenharmony_ciwas not written by any invocation since, or</p>
52925bd8deadSopenharmony_ci</li>
52935bd8deadSopenharmony_ci<li>
52945bd8deadSopenharmony_ci<p>the value was written by exactly one shader invocation since the previous
52955bd8deadSopenharmony_cisynchronization point, or</p>
52965bd8deadSopenharmony_ci</li>
52975bd8deadSopenharmony_ci<li>
52985bd8deadSopenharmony_ci<p>the value was written by multiple shader invocations since the previous
52995bd8deadSopenharmony_cisynchronization point, and the last write performed by all such
53005bd8deadSopenharmony_ciinvocations wrote the same value.</p>
53015bd8deadSopenharmony_ci</li>
53025bd8deadSopenharmony_ci</ul>
53035bd8deadSopenharmony_ci</div>
53045bd8deadSopenharmony_ci</div>
53055bd8deadSopenharmony_ci</div>
53065bd8deadSopenharmony_ci</li>
53075bd8deadSopenharmony_ci<li>
53085bd8deadSopenharmony_ci<p>When read by a shader invocation, if</p>
53095bd8deadSopenharmony_ci<div class="openblock">
53105bd8deadSopenharmony_ci<div class="content">
53115bd8deadSopenharmony_ci<div class="ulist">
53125bd8deadSopenharmony_ci<ul>
53135bd8deadSopenharmony_ci<li>
53145bd8deadSopenharmony_ci<p>the value was undefined at the previous synchronization point and has not
53155bd8deadSopenharmony_cibeen written by the same shader invocation since, or</p>
53165bd8deadSopenharmony_ci</li>
53175bd8deadSopenharmony_ci<li>
53185bd8deadSopenharmony_ci<p>the output variable is written to by any other shader invocation between
53195bd8deadSopenharmony_cithe previous and next synchronization points, even if that assignment
53205bd8deadSopenharmony_cioccurs in code following the read.</p>
53215bd8deadSopenharmony_ci</li>
53225bd8deadSopenharmony_ci</ul>
53235bd8deadSopenharmony_ci</div>
53245bd8deadSopenharmony_ci</div>
53255bd8deadSopenharmony_ci</div>
53265bd8deadSopenharmony_ci</li>
53275bd8deadSopenharmony_ci</ol>
53285bd8deadSopenharmony_ci</div>
53295bd8deadSopenharmony_ci<div class="paragraph">
53305bd8deadSopenharmony_ci<p>Fragment outputs output per-fragment data and are declared using the <strong>out</strong>
53315bd8deadSopenharmony_cistorage qualifier.
53325bd8deadSopenharmony_ciIt is a compile-time error to use auxiliary storage qualifiers or
53335bd8deadSopenharmony_ciinterpolation qualifiers in a fragment shader output declaration.
53345bd8deadSopenharmony_ciIt is a compile-time error to declare a fragment shader output with, or that
53355bd8deadSopenharmony_cicontains, any of the following types:</p>
53365bd8deadSopenharmony_ci</div>
53375bd8deadSopenharmony_ci<div class="ulist">
53385bd8deadSopenharmony_ci<ul>
53395bd8deadSopenharmony_ci<li>
53405bd8deadSopenharmony_ci<p>A <a href="#booleans">boolean type</a></p>
53415bd8deadSopenharmony_ci</li>
53425bd8deadSopenharmony_ci<li>
53435bd8deadSopenharmony_ci<p>A double-precision scalar or vector (<strong>double</strong>, <strong>dvec2</strong>, <strong>dvec3</strong>,
53445bd8deadSopenharmony_ci<strong>dvec4</strong>)</p>
53455bd8deadSopenharmony_ci</li>
53465bd8deadSopenharmony_ci<li>
53475bd8deadSopenharmony_ci<p>An <a href="#opaque-types">opaque type</a></p>
53485bd8deadSopenharmony_ci</li>
53495bd8deadSopenharmony_ci<li>
53505bd8deadSopenharmony_ci<p>A matrix type</p>
53515bd8deadSopenharmony_ci</li>
53525bd8deadSopenharmony_ci<li>
53535bd8deadSopenharmony_ci<p>A structure</p>
53545bd8deadSopenharmony_ci</li>
53555bd8deadSopenharmony_ci</ul>
53565bd8deadSopenharmony_ci</div>
53575bd8deadSopenharmony_ci<div class="paragraph">
53585bd8deadSopenharmony_ci<p>Fragment outputs are declared as in the following examples:</p>
53595bd8deadSopenharmony_ci</div>
53605bd8deadSopenharmony_ci<div class="listingblock">
53615bd8deadSopenharmony_ci<div class="content">
53625bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">out vec4 FragmentColor;
53635bd8deadSopenharmony_ciout uint Luminosity;</code></pre>
53645bd8deadSopenharmony_ci</div>
53655bd8deadSopenharmony_ci</div>
53665bd8deadSopenharmony_ci<div class="paragraph">
53675bd8deadSopenharmony_ci<p>Compute shaders have no built-in output variables, do not support
53685bd8deadSopenharmony_ciuser-defined output variables and do not form a formal interface with any
53695bd8deadSopenharmony_ciother shader stage.
53705bd8deadSopenharmony_ciAll outputs from a compute shader take the form of the side effects such as
53715bd8deadSopenharmony_ciimage stores and operations on atomic counters.</p>
53725bd8deadSopenharmony_ci</div>
53735bd8deadSopenharmony_ci</div>
53745bd8deadSopenharmony_ci<div class="sect3">
53755bd8deadSopenharmony_ci<h4 id="buffer-variables">4.3.7. Buffer Variables</h4>
53765bd8deadSopenharmony_ci<div class="paragraph">
53775bd8deadSopenharmony_ci<p>The <strong>buffer</strong> qualifier is used to declare global variables whose values are
53785bd8deadSopenharmony_cistored in the data store of a buffer object bound through the API.
53795bd8deadSopenharmony_ciBuffer variables can be read and written, with the underlying storage shared
53805bd8deadSopenharmony_ciamong all active shader invocations.
53815bd8deadSopenharmony_ciBuffer variable memory reads and writes within a single shader invocation
53825bd8deadSopenharmony_ciare processed in order.
53835bd8deadSopenharmony_ciHowever, the order of reads and writes performed in one invocation relative
53845bd8deadSopenharmony_cito those performed by another invocation is largely undefined.
53855bd8deadSopenharmony_ciBuffer variables may be qualified with memory qualifiers affecting how the
53865bd8deadSopenharmony_ciunderlying memory is accessed, as described in &#8220;<a href="#memory-qualifiers">Memory
53875bd8deadSopenharmony_ciQualifiers</a>&#8221;.</p>
53885bd8deadSopenharmony_ci</div>
53895bd8deadSopenharmony_ci<div class="paragraph">
53905bd8deadSopenharmony_ci<p>The <strong>buffer</strong> qualifier can be used to declare interface blocks (see
53915bd8deadSopenharmony_ci&#8220;<a href="#interface-blocks">Interface Blocks</a>&#8221;), which are then referred to as
53925bd8deadSopenharmony_cishader storage blocks.
53935bd8deadSopenharmony_ciIt is a compile-time error to declare buffer variables outside a block.</p>
53945bd8deadSopenharmony_ci</div>
53955bd8deadSopenharmony_ci<div class="listingblock">
53965bd8deadSopenharmony_ci<div class="content">
53975bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="comment">// use buffer to create a buffer block (shader storage block)</span>
53985bd8deadSopenharmony_cibuffer BufferName { <span class="comment">// externally visible name of buffer</span>
53995bd8deadSopenharmony_ci    <span class="predefined-type">int</span> count;      <span class="comment">// typed, shared memory...</span>
54005bd8deadSopenharmony_ci    ...             <span class="comment">// ...</span>
54015bd8deadSopenharmony_ci    vec4 v[];       <span class="comment">// last member may be an array that is not sized</span>
54025bd8deadSopenharmony_ci                    <span class="comment">// until after link time (dynamically sized)</span>
54035bd8deadSopenharmony_ci} Name;             <span class="comment">// name of block within the shader</span></code></pre>
54045bd8deadSopenharmony_ci</div>
54055bd8deadSopenharmony_ci</div>
54065bd8deadSopenharmony_ci<div class="paragraph">
54075bd8deadSopenharmony_ci<p>There are implementation-dependent limits on the number of shader storage
54085bd8deadSopenharmony_ciblocks used for each type of shader, the combined number of shader storage
54095bd8deadSopenharmony_ciblocks used for a program, and the amount of storage required by each
54105bd8deadSopenharmony_ciindividual shader storage block.
54115bd8deadSopenharmony_ciIf any of these limits are exceeded, it will cause a compile-time or
54125bd8deadSopenharmony_cilink-time error.</p>
54135bd8deadSopenharmony_ci</div>
54145bd8deadSopenharmony_ci<div class="paragraph">
54155bd8deadSopenharmony_ci<p>If multiple shaders are linked together, then they will share a single
54165bd8deadSopenharmony_ciglobal buffer variable name space.
54175bd8deadSopenharmony_ciHence, the types of all declared buffer variables with the same name must
54185bd8deadSopenharmony_cimatch across all shaders that are linked into a single program.</p>
54195bd8deadSopenharmony_ci</div>
54205bd8deadSopenharmony_ci</div>
54215bd8deadSopenharmony_ci<div class="sect3">
54225bd8deadSopenharmony_ci<h4 id="shared-variables">4.3.8. Shared Variables</h4>
54235bd8deadSopenharmony_ci<div class="paragraph">
54245bd8deadSopenharmony_ci<p>The <strong>shared</strong> qualifier is used to declare global variables that have storage
54255bd8deadSopenharmony_cishared between all work items in a compute shader workgroup.
54265bd8deadSopenharmony_ciVariables declared as <strong>shared</strong> may only be used in compute shaders (see
54275bd8deadSopenharmony_ci&#8220;<a href="#compute-processor">Compute Processor</a>&#8221;).
54285bd8deadSopenharmony_ciAny other declaration of a <strong>shared</strong> variable is a compile-time error.
54295bd8deadSopenharmony_ciShared variables are implicitly coherent (see
54305bd8deadSopenharmony_ci&#8220;<a href="#memory-qualifiers">Memory Qualifiers</a>&#8221;).</p>
54315bd8deadSopenharmony_ci</div>
54325bd8deadSopenharmony_ci<div class="paragraph">
54335bd8deadSopenharmony_ci<p>Variables declared as <strong>shared</strong> may not have initializers and their contents
54345bd8deadSopenharmony_ciare undefined at the beginning of shader execution.
54355bd8deadSopenharmony_ciAny data written to <strong>shared</strong> variables will be visible to other work items
54365bd8deadSopenharmony_ci(executing the same shader) within the same workgroup.</p>
54375bd8deadSopenharmony_ci</div>
54385bd8deadSopenharmony_ci<div class="paragraph">
54395bd8deadSopenharmony_ci<p>In the absence of synchronization, the order of reads and writes to the same
54405bd8deadSopenharmony_ci<strong>shared</strong> variable by different invocations of a shader is not defined.</p>
54415bd8deadSopenharmony_ci</div>
54425bd8deadSopenharmony_ci<div class="paragraph">
54435bd8deadSopenharmony_ci<p>In order to achieve ordering with respect to reads and writes to <strong>shared</strong>
54445bd8deadSopenharmony_civariables, control flow barriers must be employed using the <strong>barrier</strong>() function
54455bd8deadSopenharmony_ci(see &#8220;<a href="#shader-invocation-control-functions">Shader Invocation Control
54465bd8deadSopenharmony_ciFunctions</a>&#8221;).</p>
54475bd8deadSopenharmony_ci</div>
54485bd8deadSopenharmony_ci<div class="paragraph">
54495bd8deadSopenharmony_ci<p>There is a limit to the total size of all variables declared as <strong>shared</strong> in a
54505bd8deadSopenharmony_cisingle program.
54515bd8deadSopenharmony_ciThis limit, expressed in units of basic machine units may be determined by
54525bd8deadSopenharmony_ciusing the OpenGL API to query the value of
54535bd8deadSopenharmony_ciMAX_COMPUTE_SHARED_MEMORY_SIZE.</p>
54545bd8deadSopenharmony_ci</div>
54555bd8deadSopenharmony_ci</div>
54565bd8deadSopenharmony_ci<div class="sect3">
54575bd8deadSopenharmony_ci<h4 id="interface-blocks">4.3.9. Interface Blocks</h4>
54585bd8deadSopenharmony_ci<div class="paragraph">
54595bd8deadSopenharmony_ci<p>Input, output, uniform, and buffer variable declarations can be grouped into
54605bd8deadSopenharmony_cinamed interface blocks to provide coarser granularity backing than is
54615bd8deadSopenharmony_ciachievable with individual declarations.
54625bd8deadSopenharmony_ciThey can have an optional instance name, used in the shader to reference
54635bd8deadSopenharmony_citheir members.
54645bd8deadSopenharmony_ciAn output block of one programmable stage is backed by a corresponding input
54655bd8deadSopenharmony_ciblock in the subsequent programmable stage.
54665bd8deadSopenharmony_ciA <em>uniform block</em> is backed by the application with a buffer object.
54675bd8deadSopenharmony_ciA block of buffer variables, called a <em>shader storage block</em>, is also backed
54685bd8deadSopenharmony_ciby the application with a buffer object.
54695bd8deadSopenharmony_ciIt is a compile-time error to have an input block in a vertex shader or an
54705bd8deadSopenharmony_cioutput block in a fragment shader.
54715bd8deadSopenharmony_ciThese uses are reserved for future use.</p>
54725bd8deadSopenharmony_ci</div>
54735bd8deadSopenharmony_ci<div class="paragraph">
54745bd8deadSopenharmony_ci<p>An interface block is started by an <strong>in</strong>, <strong>out</strong>, <strong>uniform</strong>, or <strong>buffer</strong>
54755bd8deadSopenharmony_cikeyword, followed by a block name, followed by an open curly brace (<strong>{</strong>) as
54765bd8deadSopenharmony_cifollows:</p>
54775bd8deadSopenharmony_ci</div>
54785bd8deadSopenharmony_ci<div class="openblock bnf">
54795bd8deadSopenharmony_ci<div class="content">
54805bd8deadSopenharmony_ci<div class="dlist">
54815bd8deadSopenharmony_ci<dl>
54825bd8deadSopenharmony_ci<dt class="hdlist1"><em>interface-block</em> : </dt>
54835bd8deadSopenharmony_ci<dd>
54845bd8deadSopenharmony_ci<p><em>layout-qualifier<sub>opt</sub></em> <em>interface-qualifier</em> <em>block-name</em> <strong>{</strong>
54855bd8deadSopenharmony_ci<em>member-list</em> <strong>}</strong> <em>instance-name<sub>opt</sub></em> <strong>;</strong></p>
54865bd8deadSopenharmony_ci</dd>
54875bd8deadSopenharmony_ci</dl>
54885bd8deadSopenharmony_ci</div>
54895bd8deadSopenharmony_ci<div class="dlist">
54905bd8deadSopenharmony_ci<dl>
54915bd8deadSopenharmony_ci<dt class="hdlist1"><em>interface-qualifier</em> : </dt>
54925bd8deadSopenharmony_ci<dd>
54935bd8deadSopenharmony_ci<p><strong>in</strong><br>
54945bd8deadSopenharmony_ci<strong>out</strong><br>
54955bd8deadSopenharmony_ci<strong>patch</strong> <strong>in</strong> // Note: Qualifiers can be in any order.<br>
54965bd8deadSopenharmony_ci<strong>patch</strong> <strong>out</strong><br>
54975bd8deadSopenharmony_ci<strong>uniform</strong><br>
54985bd8deadSopenharmony_ci<strong>buffer</strong></p>
54995bd8deadSopenharmony_ci</dd>
55005bd8deadSopenharmony_ci</dl>
55015bd8deadSopenharmony_ci</div>
55025bd8deadSopenharmony_ci<div class="dlist">
55035bd8deadSopenharmony_ci<dl>
55045bd8deadSopenharmony_ci<dt class="hdlist1"><em>member-list</em> : </dt>
55055bd8deadSopenharmony_ci<dd>
55065bd8deadSopenharmony_ci<p><em>member-declaration</em><br>
55075bd8deadSopenharmony_ci<em>member-declaration</em> <em>member-list</em></p>
55085bd8deadSopenharmony_ci</dd>
55095bd8deadSopenharmony_ci<dt class="hdlist1"><em>member-declaration</em> : </dt>
55105bd8deadSopenharmony_ci<dd>
55115bd8deadSopenharmony_ci<p><em>layout-qualifier<sub>opt</sub></em> <em>qualifiers<sub>opt</sub></em> <em>type</em> <em>declarators</em> <strong>;</strong></p>
55125bd8deadSopenharmony_ci</dd>
55135bd8deadSopenharmony_ci</dl>
55145bd8deadSopenharmony_ci</div>
55155bd8deadSopenharmony_ci<div class="dlist">
55165bd8deadSopenharmony_ci<dl>
55175bd8deadSopenharmony_ci<dt class="hdlist1"><em>instance-name</em> : </dt>
55185bd8deadSopenharmony_ci<dd>
55195bd8deadSopenharmony_ci<p><em>identifier</em><br>
55205bd8deadSopenharmony_ci<em>identifier</em> <strong>[</strong> <strong>]</strong><br>
55215bd8deadSopenharmony_ci<em>identifier</em> <strong>[</strong> <em>constant-integral-expression</em> <strong>]</strong></p>
55225bd8deadSopenharmony_ci</dd>
55235bd8deadSopenharmony_ci</dl>
55245bd8deadSopenharmony_ci</div>
55255bd8deadSopenharmony_ci</div>
55265bd8deadSopenharmony_ci</div>
55275bd8deadSopenharmony_ci<div class="paragraph">
55285bd8deadSopenharmony_ci<p>Each of the above elements is discussed below, with the exception of layout
55295bd8deadSopenharmony_ciqualifiers (<em>layout-qualifier</em>), which are defined in the next section.</p>
55305bd8deadSopenharmony_ci</div>
55315bd8deadSopenharmony_ci<div class="paragraph">
55325bd8deadSopenharmony_ci<p>First, an example,</p>
55335bd8deadSopenharmony_ci</div>
55345bd8deadSopenharmony_ci<div class="listingblock">
55355bd8deadSopenharmony_ci<div class="content">
55365bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">uniform Transform {
55375bd8deadSopenharmony_ci    mat4 ModelViewMatrix;
55385bd8deadSopenharmony_ci    mat4 ModelViewProjectionMatrix;
55395bd8deadSopenharmony_ci    uniform mat3 NormalMatrix;      <span class="comment">// allowed restatement of qualifier</span>
55405bd8deadSopenharmony_ci    <span class="predefined-type">float</span> Deformation;
55415bd8deadSopenharmony_ci};</code></pre>
55425bd8deadSopenharmony_ci</div>
55435bd8deadSopenharmony_ci</div>
55445bd8deadSopenharmony_ci<div class="paragraph">
55455bd8deadSopenharmony_ci<p>The above establishes a uniform block named &#8220;Transform&#8221; with four uniforms
55465bd8deadSopenharmony_cigrouped inside it.</p>
55475bd8deadSopenharmony_ci</div>
55485bd8deadSopenharmony_ci<div class="paragraph">
55495bd8deadSopenharmony_ci<p>Types and declarators are the same as for other input, output, uniform, and
55505bd8deadSopenharmony_cibuffer variable declarations outside blocks, with these exceptions:</p>
55515bd8deadSopenharmony_ci</div>
55525bd8deadSopenharmony_ci<div class="ulist">
55535bd8deadSopenharmony_ci<ul>
55545bd8deadSopenharmony_ci<li>
55555bd8deadSopenharmony_ci<p>Initializers are not allowed</p>
55565bd8deadSopenharmony_ci</li>
55575bd8deadSopenharmony_ci<li>
55585bd8deadSopenharmony_ci<p>Opaque types are not allowed</p>
55595bd8deadSopenharmony_ci</li>
55605bd8deadSopenharmony_ci<li>
55615bd8deadSopenharmony_ci<p>Structure definitions cannot be nested inside a block</p>
55625bd8deadSopenharmony_ci</li>
55635bd8deadSopenharmony_ci</ul>
55645bd8deadSopenharmony_ci</div>
55655bd8deadSopenharmony_ci<div class="paragraph">
55665bd8deadSopenharmony_ci<p>Any of these would result in a compile-time error.</p>
55675bd8deadSopenharmony_ci</div>
55685bd8deadSopenharmony_ci<div class="paragraph">
55695bd8deadSopenharmony_ci<p>If no optional qualifier is used in a member-declaration, the qualification
55705bd8deadSopenharmony_ciof the member includes all <strong>in</strong>, <strong>out</strong>, <strong>patch</strong>, <strong>uniform</strong>, or <strong>buffer</strong> as
55715bd8deadSopenharmony_cidetermined by <em>interface-qualifier</em>.
55725bd8deadSopenharmony_ciIf optional qualifiers are used, they can include interpolation qualifiers,
55735bd8deadSopenharmony_ciauxiliary storage qualifiers,
55745bd8deadSopenharmony_ciand storage qualifiers and they must declare
55755bd8deadSopenharmony_cian input, output, or uniform member consistent with the interface qualifier
55765bd8deadSopenharmony_ciof the block: Input variables, output variables, uniform variables, and
55775bd8deadSopenharmony_ci<strong>buffer</strong> members can only be in <strong>in</strong> blocks, <strong>out</strong> blocks, <strong>uniform</strong> blocks,
55785bd8deadSopenharmony_ciand shader storage blocks, respectively.</p>
55795bd8deadSopenharmony_ci</div>
55805bd8deadSopenharmony_ci<div class="paragraph">
55815bd8deadSopenharmony_ci<p>Repeating the <strong>in</strong>, <strong>out</strong>, <strong>patch</strong>, <strong>uniform</strong>, or <strong>buffer</strong> interface
55825bd8deadSopenharmony_ciqualifier for a member&#8217;s storage qualifier is optional.
55835bd8deadSopenharmony_ciFor example,</p>
55845bd8deadSopenharmony_ci</div>
55855bd8deadSopenharmony_ci<div class="listingblock">
55865bd8deadSopenharmony_ci<div class="content">
55875bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">in Material {
55885bd8deadSopenharmony_ci    smooth in vec4 Color1; <span class="comment">// legal, input inside in block</span>
55895bd8deadSopenharmony_ci    smooth vec4 Color2;    <span class="comment">// legal, 'in' inherited from 'in Material'</span>
55905bd8deadSopenharmony_ci    vec2 TexCoord;         <span class="comment">// legal, TexCoord is an input</span>
55915bd8deadSopenharmony_ci    uniform <span class="predefined-type">float</span> Atten;   <span class="comment">// illegal, mismatched storage qualifier</span>
55925bd8deadSopenharmony_ci};</code></pre>
55935bd8deadSopenharmony_ci</div>
55945bd8deadSopenharmony_ci</div>
55955bd8deadSopenharmony_ci<div class="paragraph">
55965bd8deadSopenharmony_ci<p>A <em>shader interface</em> is defined to be one of these:</p>
55975bd8deadSopenharmony_ci</div>
55985bd8deadSopenharmony_ci<div class="ulist">
55995bd8deadSopenharmony_ci<ul>
56005bd8deadSopenharmony_ci<li>
56015bd8deadSopenharmony_ci<p>All the uniform variables and uniform blocks declared in a program.
56025bd8deadSopenharmony_ciThis spans all compilation units linked together within one program.</p>
56035bd8deadSopenharmony_ci</li>
56045bd8deadSopenharmony_ci<li>
56055bd8deadSopenharmony_ci<p>All the <strong>buffer</strong> blocks declared in a program.</p>
56065bd8deadSopenharmony_ci</li>
56075bd8deadSopenharmony_ci<li>
56085bd8deadSopenharmony_ci<p>The boundary between adjacent programmable pipeline stages: This spans
56095bd8deadSopenharmony_ciall the outputs declared in all compilation units of the first stage and
56105bd8deadSopenharmony_ciall the inputs declared in all compilation units of the second stage.
56115bd8deadSopenharmony_ciNote that for the purposes of this definition, the fragment shader and
56125bd8deadSopenharmony_cithe preceding shader are considered to have a shared boundary even
56135bd8deadSopenharmony_cithough in practice, all values passed to the fragment shader first pass
56145bd8deadSopenharmony_cithrough the rasterizer and interpolator.</p>
56155bd8deadSopenharmony_ci</li>
56165bd8deadSopenharmony_ci</ul>
56175bd8deadSopenharmony_ci</div>
56185bd8deadSopenharmony_ci<div class="paragraph">
56195bd8deadSopenharmony_ci<p>The block name (<em>block-name</em>) is used to match within shader interfaces: an
56205bd8deadSopenharmony_cioutput block of one pipeline stage will be matched to an input block with
56215bd8deadSopenharmony_cithe same name in the subsequent pipeline stage.
56225bd8deadSopenharmony_ciFor uniform or shader storage blocks, the application uses the block name to
56235bd8deadSopenharmony_ciidentify the block.
56245bd8deadSopenharmony_ciBlock names have no other use within a shader beyond interface matching; it
56255bd8deadSopenharmony_ciis a compile-time error
56265bd8deadSopenharmony_cito use a block name at global scope for anything other than as a
56275bd8deadSopenharmony_ciblock name (e.g. use of a block name for a global variable name or function
56285bd8deadSopenharmony_ciname is currently reserved).
56295bd8deadSopenharmony_ciIt is a compile-time error to use the same block name for more than one
56305bd8deadSopenharmony_ciblock declaration in the same shader interface (as defined above) within one
56315bd8deadSopenharmony_cishader, even if the block contents are identical.</p>
56325bd8deadSopenharmony_ci</div>
56335bd8deadSopenharmony_ci<div class="paragraph">
56345bd8deadSopenharmony_ci<p>Matched block names within a shader interface (as defined above) must match
56355bd8deadSopenharmony_ciin terms of having the same number of declarations with the same sequence of
56365bd8deadSopenharmony_citypes and the same sequence of member names, as well as having matching
56375bd8deadSopenharmony_cimember-wise layout qualification
56385bd8deadSopenharmony_ci(see next section).
56395bd8deadSopenharmony_ciMatched uniform or shader storage block names (but not input or output block
56405bd8deadSopenharmony_cinames) must also either all be lacking an instance name or all having an
56415bd8deadSopenharmony_ciinstance name, putting their members at the same scoping level.
56425bd8deadSopenharmony_ciWhen instance names are present on matched block names, it is allowed for
56435bd8deadSopenharmony_cithe instance names to differ; they need not match for the blocks to match.
56445bd8deadSopenharmony_ciFurthermore, if a matching block is declared as an array, then the array
56455bd8deadSopenharmony_cisizes must also match (or follow array matching rules for the shader
56465bd8deadSopenharmony_ciinterface between consecutive shader stages).
56475bd8deadSopenharmony_ciAny mismatch will generate a link-time error.
56485bd8deadSopenharmony_ciA block name is allowed to have different definitions in different shader
56495bd8deadSopenharmony_ciinterfaces within the same shader, allowing, for example, an input block and
56505bd8deadSopenharmony_cioutput block to have the same name.</p>
56515bd8deadSopenharmony_ci</div>
56525bd8deadSopenharmony_ci<div class="paragraph">
56535bd8deadSopenharmony_ci<p>If an instance name (<em>instance-name</em>) is not used, the names declared inside
56545bd8deadSopenharmony_cithe block are scoped at the global level and accessed as if they were
56555bd8deadSopenharmony_cideclared outside the block.
56565bd8deadSopenharmony_ciIf an instance name (<em>instance-name</em>) is used, then it puts all the members
56575bd8deadSopenharmony_ciinside a scope within its own name space, accessed with the field selector
56585bd8deadSopenharmony_ci(<strong>.</strong>) operator (analogously to structures).
56595bd8deadSopenharmony_ciFor example,</p>
56605bd8deadSopenharmony_ci</div>
56615bd8deadSopenharmony_ci<div class="listingblock">
56625bd8deadSopenharmony_ci<div class="content">
56635bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">in Light {
56645bd8deadSopenharmony_ci    vec4 LightPos;
56655bd8deadSopenharmony_ci    vec3 LightColor;
56665bd8deadSopenharmony_ci};
56675bd8deadSopenharmony_ciin ColoredTexture {
56685bd8deadSopenharmony_ci    vec4 Color;
56695bd8deadSopenharmony_ci    vec2 TexCoord;
56705bd8deadSopenharmony_ci} Material;           <span class="comment">// instance name</span>
56715bd8deadSopenharmony_civec3 Color;           <span class="comment">// different Color than Material.Color</span>
56725bd8deadSopenharmony_civec4 LightPos;        <span class="comment">// illegal, already defined</span>
56735bd8deadSopenharmony_ci...
56745bd8deadSopenharmony_ci... = LightPos;       <span class="comment">// accessing LightPos</span>
56755bd8deadSopenharmony_ci... = Material.Color; <span class="comment">// accessing Color in ColoredTexture block</span></code></pre>
56765bd8deadSopenharmony_ci</div>
56775bd8deadSopenharmony_ci</div>
56785bd8deadSopenharmony_ci<div class="paragraph">
56795bd8deadSopenharmony_ci<p>Outside the shading language (i.e., in the API), members are similarly
56805bd8deadSopenharmony_ciidentified except the block name is always used in place of the instance
56815bd8deadSopenharmony_ciname (API accesses are to shader interfaces, not to shaders).
56825bd8deadSopenharmony_ciIf there is no instance name, then the API does not use the block name to
56835bd8deadSopenharmony_ciaccess a member, just the member name.</p>
56845bd8deadSopenharmony_ci</div>
56855bd8deadSopenharmony_ci<div class="paragraph">
56865bd8deadSopenharmony_ci<p>Within a shader interface, all declarations of the same global name must be
56875bd8deadSopenharmony_cifor the same object and must match in type and in whether they declare a
56885bd8deadSopenharmony_civariable or member of a block with no instance name.
56895bd8deadSopenharmony_ciThe API also needs this name to uniquely identify an object in the shader
56905bd8deadSopenharmony_ciinterface.
56915bd8deadSopenharmony_ciIt is a link-time error if any particular shader interface contains</p>
56925bd8deadSopenharmony_ci</div>
56935bd8deadSopenharmony_ci<div class="ulist">
56945bd8deadSopenharmony_ci<ul>
56955bd8deadSopenharmony_ci<li>
56965bd8deadSopenharmony_ci<p>two different blocks, each having no instance name, and each having a
56975bd8deadSopenharmony_cimember of the same name, or</p>
56985bd8deadSopenharmony_ci</li>
56995bd8deadSopenharmony_ci<li>
57005bd8deadSopenharmony_ci<p>a variable outside a block, and a block with no instance name, where the
57015bd8deadSopenharmony_civariable has the same name as a member in the block.</p>
57025bd8deadSopenharmony_ci</li>
57035bd8deadSopenharmony_ci</ul>
57045bd8deadSopenharmony_ci</div>
57055bd8deadSopenharmony_ci<div class="listingblock">
57065bd8deadSopenharmony_ci<div class="content">
57075bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">out Vertex {
57085bd8deadSopenharmony_ci    vec4 Position;  <span class="comment">// API transform/feedback will use &quot;Vertex.Position&quot;</span>
57095bd8deadSopenharmony_ci    vec2 Texture;
57105bd8deadSopenharmony_ci} Coords;           <span class="comment">// shader will use &quot;Coords.Position&quot;</span>
57115bd8deadSopenharmony_ciout Vertex2 {
57125bd8deadSopenharmony_ci    vec4 Color;     <span class="comment">// API will use &quot;Color&quot;</span>
57135bd8deadSopenharmony_ci    <span class="predefined-type">float</span> Color2;
57145bd8deadSopenharmony_ci};
57155bd8deadSopenharmony_ci
57165bd8deadSopenharmony_ci<span class="comment">// in same program as Vertex2 above:</span>
57175bd8deadSopenharmony_ciout Vertex3 {
57185bd8deadSopenharmony_ci    <span class="predefined-type">float</span> Intensity;
57195bd8deadSopenharmony_ci    vec4 Color;     <span class="comment">// ERROR, name collision with Color in Vertex2</span>
57205bd8deadSopenharmony_ci};
57215bd8deadSopenharmony_ci<span class="predefined-type">float</span> Color2;       <span class="comment">// ERROR, collides with Color2 in Vertex2</span></code></pre>
57225bd8deadSopenharmony_ci</div>
57235bd8deadSopenharmony_ci</div>
57245bd8deadSopenharmony_ci<div class="paragraph">
57255bd8deadSopenharmony_ci<p>For blocks declared as arrays, the array index must also be included when
57265bd8deadSopenharmony_ciaccessing members, as in this example</p>
57275bd8deadSopenharmony_ci</div>
57285bd8deadSopenharmony_ci<div class="listingblock">
57295bd8deadSopenharmony_ci<div class="content">
57305bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">uniform Transform { <span class="comment">// API uses &quot;Transform[2]&quot; to refer to instance 2</span>
57315bd8deadSopenharmony_ci    mat4 ModelViewMatrix;
57325bd8deadSopenharmony_ci    mat4 ModelViewProjectionMatrix;
57335bd8deadSopenharmony_ci    vec4 a[]; <span class="comment">// array will get implicitly sized</span>
57345bd8deadSopenharmony_ci    <span class="predefined-type">float</span> Deformation;
57355bd8deadSopenharmony_ci} transforms[<span class="integer">4</span>];
57365bd8deadSopenharmony_ci...
57375bd8deadSopenharmony_ci... = transforms[<span class="integer">2</span>].ModelViewMatrix; <span class="comment">// shader access of instance 2</span>
57385bd8deadSopenharmony_ci<span class="comment">// API uses &quot;Transform.ModelViewMatrix&quot; to query an offset or other query</span>
57395bd8deadSopenharmony_citransforms[x].a.length(); <span class="comment">// same length for 'a' for all x</span>
57405bd8deadSopenharmony_ciTransform[x];             <span class="comment">// illegal, must use 'transforms'</span>
57415bd8deadSopenharmony_ciTransform.a.length();     <span class="comment">// illegal, must use 'transforms'</span>
57425bd8deadSopenharmony_ci...transforms[<span class="integer">2</span>].a[<span class="integer">3</span>]...  <span class="comment">// if these are the only two dereferences of 'a',</span>
57435bd8deadSopenharmony_ci...transforms[<span class="integer">3</span>].a[<span class="integer">7</span>]...  <span class="comment">// then 'a' must be size 8, for all</span>
57445bd8deadSopenharmony_citransforms[x]</code></pre>
57455bd8deadSopenharmony_ci</div>
57465bd8deadSopenharmony_ci</div>
57475bd8deadSopenharmony_ci<div class="paragraph">
57485bd8deadSopenharmony_ci<p>For uniform or shader storage blocks declared as an array, each individual
57495bd8deadSopenharmony_ciarray element corresponds to a separate buffer object bind range, backing
57505bd8deadSopenharmony_cione instance of the block.
57515bd8deadSopenharmony_ciAs the array size indicates the number of buffer objects needed, uniform and
57525bd8deadSopenharmony_cishader storage block array declarations must specify an array size.
57535bd8deadSopenharmony_ciA uniform or shader storage block array can only be indexed with a
57545bd8deadSopenharmony_cidynamically uniform integral expression, otherwise results are undefined.</p>
57555bd8deadSopenharmony_ci</div>
57565bd8deadSopenharmony_ci<div class="paragraph">
57575bd8deadSopenharmony_ci<p>When using OpenGL API entry points to identify the name of an individual
57585bd8deadSopenharmony_ciblock in an array of blocks, the name string may include an array index
57595bd8deadSopenharmony_ci(e.g. <em>Transform[2]</em>).
57605bd8deadSopenharmony_ciWhen using OpenGL API entry points to refer to offsets or other
57615bd8deadSopenharmony_cicharacteristics of a block member, an array index must not be specified
57625bd8deadSopenharmony_ci(e.g. <em>Transform.ModelViewMatrix</em>).</p>
57635bd8deadSopenharmony_ci</div>
57645bd8deadSopenharmony_ci<div class="paragraph">
57655bd8deadSopenharmony_ci<p>Tessellation control, tessellation evaluation and geometry shader input
57665bd8deadSopenharmony_ciblocks must be declared as arrays and follow the array declaration and
57675bd8deadSopenharmony_cilinking rules for all shader inputs for the respective stages.
57685bd8deadSopenharmony_ciAll other input and output block arrays must specify an array size.</p>
57695bd8deadSopenharmony_ci</div>
57705bd8deadSopenharmony_ci<div class="paragraph">
57715bd8deadSopenharmony_ci<p>There are implementation-dependent limits on the number of uniform blocks
57725bd8deadSopenharmony_ciand the number of shader storage blocks that can be used per stage.
57735bd8deadSopenharmony_ciIf either limit is exceeded, it will cause a link-time error.</p>
57745bd8deadSopenharmony_ci</div>
57755bd8deadSopenharmony_ci</div>
57765bd8deadSopenharmony_ci</div>
57775bd8deadSopenharmony_ci<div class="sect2">
57785bd8deadSopenharmony_ci<h3 id="layout-qualifiers">4.4. Layout Qualifiers</h3>
57795bd8deadSopenharmony_ci<div class="paragraph">
57805bd8deadSopenharmony_ci<p>Layout qualifiers can appear in several forms of declaration.
57815bd8deadSopenharmony_ciThey can appear as part of an interface block definition or block member, as
57825bd8deadSopenharmony_cishown in the grammar in the previous section.
57835bd8deadSopenharmony_ciThey can also appear with just an <em>interface-qualifier</em> to establish layouts
57845bd8deadSopenharmony_ciof other declarations made with that qualifier:</p>
57855bd8deadSopenharmony_ci</div>
57865bd8deadSopenharmony_ci<div class="openblock bnf">
57875bd8deadSopenharmony_ci<div class="content">
57885bd8deadSopenharmony_ci<div class="paragraph">
57895bd8deadSopenharmony_ci<p><em>layout-qualifier</em> <em>interface-qualifier</em> <strong>;</strong></p>
57905bd8deadSopenharmony_ci</div>
57915bd8deadSopenharmony_ci</div>
57925bd8deadSopenharmony_ci</div>
57935bd8deadSopenharmony_ci<div class="paragraph">
57945bd8deadSopenharmony_ci<p>Or, they can appear with an individual variable declared with an interface
57955bd8deadSopenharmony_ciqualifier:</p>
57965bd8deadSopenharmony_ci</div>
57975bd8deadSopenharmony_ci<div class="openblock bnf">
57985bd8deadSopenharmony_ci<div class="content">
57995bd8deadSopenharmony_ci<div class="paragraph">
58005bd8deadSopenharmony_ci<p><em>layout-qualifier</em> <em>interface-qualifier</em> <em>declaration</em> <strong>;</strong></p>
58015bd8deadSopenharmony_ci</div>
58025bd8deadSopenharmony_ci</div>
58035bd8deadSopenharmony_ci</div>
58045bd8deadSopenharmony_ci<div class="paragraph">
58055bd8deadSopenharmony_ci<p>Declarations of layouts can only be made at global scope or block members,
58065bd8deadSopenharmony_ciand only where indicated in the following subsections; their details are
58075bd8deadSopenharmony_cispecific to what the interface qualifier is, and are discussed individually.</p>
58085bd8deadSopenharmony_ci</div>
58095bd8deadSopenharmony_ci<div class="paragraph">
58105bd8deadSopenharmony_ci<p>The <em>layout-qualifier</em> expands to:</p>
58115bd8deadSopenharmony_ci</div>
58125bd8deadSopenharmony_ci<div class="openblock bnf">
58135bd8deadSopenharmony_ci<div class="content">
58145bd8deadSopenharmony_ci<div class="dlist">
58155bd8deadSopenharmony_ci<dl>
58165bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier</em> : </dt>
58175bd8deadSopenharmony_ci<dd>
58185bd8deadSopenharmony_ci<p><strong>layout</strong> <strong>(</strong> <em>layout-qualifier-id-list</em> <strong>)</strong></p>
58195bd8deadSopenharmony_ci</dd>
58205bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-id-list</em> : </dt>
58215bd8deadSopenharmony_ci<dd>
58225bd8deadSopenharmony_ci<p><em>layout-qualifier-id</em><br>
58235bd8deadSopenharmony_ci<em>layout-qualifier-id</em> <strong>,</strong> <em>layout-qualifier-id-list</em></p>
58245bd8deadSopenharmony_ci</dd>
58255bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-id</em> : </dt>
58265bd8deadSopenharmony_ci<dd>
58275bd8deadSopenharmony_ci<p><em>layout-qualifier-name</em><br>
58285bd8deadSopenharmony_ci<em>layout-qualifier-name</em> <strong>=</strong> <em>layout-qualifier-value</em><br>
58295bd8deadSopenharmony_ci<strong>shared</strong></p>
58305bd8deadSopenharmony_ci</dd>
58315bd8deadSopenharmony_ci</dl>
58325bd8deadSopenharmony_ci</div>
58335bd8deadSopenharmony_ci</div>
58345bd8deadSopenharmony_ci</div>
58355bd8deadSopenharmony_ci<div class="openblock bnf">
58365bd8deadSopenharmony_ci<div class="content">
58375bd8deadSopenharmony_ci<div class="dlist">
58385bd8deadSopenharmony_ci<dl>
58395bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-value</em> : </dt>
58405bd8deadSopenharmony_ci<dd>
58415bd8deadSopenharmony_ci<p><em>integer-constant-expression</em></p>
58425bd8deadSopenharmony_ci</dd>
58435bd8deadSopenharmony_ci</dl>
58445bd8deadSopenharmony_ci</div>
58455bd8deadSopenharmony_ci</div>
58465bd8deadSopenharmony_ci</div>
58475bd8deadSopenharmony_ci<div class="paragraph">
58485bd8deadSopenharmony_ci<p>The tokens used for <em>layout-qualifier-name</em> are identifiers, not keywords,
58495bd8deadSopenharmony_cihowever, the <strong>shared</strong> keyword is allowed as a <em>layout-qualifier-id</em>.
58505bd8deadSopenharmony_ciGenerally, they can be listed in any order.
58515bd8deadSopenharmony_ciOrder-dependent meanings exist only if explicitly called out below.
58525bd8deadSopenharmony_ciSimilarly, these identifiers are not case sensitive, unless explicitly noted
58535bd8deadSopenharmony_ciotherwise.</p>
58545bd8deadSopenharmony_ci</div>
58555bd8deadSopenharmony_ci<div class="paragraph">
58565bd8deadSopenharmony_ci<p>More than one layout qualifier may appear in a single declaration.
58575bd8deadSopenharmony_ciAdditionally, the same <em>layout-qualifier-name</em> can occur multiple times
58585bd8deadSopenharmony_ciwithin a layout qualifier or across multiple layout qualifiers in the same
58595bd8deadSopenharmony_cideclaration.
58605bd8deadSopenharmony_ciWhen the same <em>layout-qualifier-name</em> occurs multiple times, in a single
58615bd8deadSopenharmony_cideclaration, the last occurrence overrides the former occurrence(s).
58625bd8deadSopenharmony_ciFurther, if such a <em>layout-qualifier-name</em> will affect subsequent
58635bd8deadSopenharmony_cideclarations or other observable behavior, it is only the last occurrence
58645bd8deadSopenharmony_cithat will have any effect, behaving as if the earlier occurrence(s) within
58655bd8deadSopenharmony_cithe declaration are not present.
58665bd8deadSopenharmony_ciThis is also true for overriding <em>layout-qualifier-name</em>, where one
58675bd8deadSopenharmony_cioverrides the other (e.g. <strong>row_major</strong> vs.
58685bd8deadSopenharmony_ci<strong>column_major</strong>); only the last occurrence has any effect.</p>
58695bd8deadSopenharmony_ci</div>
58705bd8deadSopenharmony_ci<div class="paragraph">
58715bd8deadSopenharmony_ci<p><em>integer-constant-expression</em> is defined in
58725bd8deadSopenharmony_ci&#8220;<a href="#constant-expressions">Constant Expressions</a>&#8221; as <em>constant integral
58735bd8deadSopenharmony_ciexpression</em>, with it being a compile-time error for
58745bd8deadSopenharmony_ci<em>integer-constant-expression</em> to be a specialization constant.</p>
58755bd8deadSopenharmony_ci</div>
58765bd8deadSopenharmony_ci<div class="paragraph">
58775bd8deadSopenharmony_ci<p>The following table summarizes the use of layout qualifiers.
58785bd8deadSopenharmony_ciIt shows for each one what kinds of declarations it may be applied to.
58795bd8deadSopenharmony_ciThese are all discussed in detail in the following sections.</p>
58805bd8deadSopenharmony_ci</div>
58815bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
58825bd8deadSopenharmony_ci<colgroup>
58835bd8deadSopenharmony_ci<col style="width: 16.6666%;">
58845bd8deadSopenharmony_ci<col style="width: 16.6666%;">
58855bd8deadSopenharmony_ci<col style="width: 16.6666%;">
58865bd8deadSopenharmony_ci<col style="width: 16.6666%;">
58875bd8deadSopenharmony_ci<col style="width: 16.6666%;">
58885bd8deadSopenharmony_ci<col style="width: 16.667%;">
58895bd8deadSopenharmony_ci</colgroup>
58905bd8deadSopenharmony_ci<thead>
58915bd8deadSopenharmony_ci<tr>
58925bd8deadSopenharmony_ci<th class="tableblock halign-left valign-middle">Layout Qualifier</th>
58935bd8deadSopenharmony_ci<th class="tableblock halign-center valign-middle">Qualifier Only</th>
58945bd8deadSopenharmony_ci<th class="tableblock halign-center valign-middle">Individual Variable</th>
58955bd8deadSopenharmony_ci<th class="tableblock halign-center valign-middle">Block</th>
58965bd8deadSopenharmony_ci<th class="tableblock halign-center valign-middle">Block Member</th>
58975bd8deadSopenharmony_ci<th class="tableblock halign-left valign-middle">Allowed Interfaces</th>
58985bd8deadSopenharmony_ci</tr>
58995bd8deadSopenharmony_ci</thead>
59005bd8deadSopenharmony_ci<tbody>
59015bd8deadSopenharmony_ci<tr>
59025bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>shared</strong><br>
59035bd8deadSopenharmony_ci  <strong>packed</strong><br>
59045bd8deadSopenharmony_ci  <strong>std140</strong><br>
59055bd8deadSopenharmony_ci  <strong>std430</strong></p></td>
59065bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
59075bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59085bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
59095bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59105bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle" rowspan="5"><p class="tableblock"><strong>uniform</strong> / <strong>buffer</strong></p></td>
59115bd8deadSopenharmony_ci</tr>
59125bd8deadSopenharmony_ci<tr>
59135bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>row_major</strong><br>
59145bd8deadSopenharmony_ci  <strong>column_major</strong></p></td>
59155bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
59165bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59175bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
59185bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
59195bd8deadSopenharmony_ci</tr>
59205bd8deadSopenharmony_ci<tr>
59215bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>binding</strong> =</p></td>
59225bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59235bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">opaque types only</p></td>
59245bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
59255bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59265bd8deadSopenharmony_ci</tr>
59275bd8deadSopenharmony_ci<tr>
59285bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>offset</strong> =</p></td>
59295bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59305bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">atomic counters only</p></td>
59315bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59325bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
59335bd8deadSopenharmony_ci</tr>
59345bd8deadSopenharmony_ci<tr>
59355bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>align</strong> =</p></td>
59365bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59375bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59385bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
59395bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
59405bd8deadSopenharmony_ci</tr>
59415bd8deadSopenharmony_ci<tr>
59425bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>set</strong> =</p></td>
59435bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59445bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">opaque types only</p></td>
59455bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
59465bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59475bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>uniform</strong> / <strong>buffer</strong> (Vulkan only)</p></td>
59485bd8deadSopenharmony_ci</tr>
59495bd8deadSopenharmony_ci<tr>
59505bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>push_constant</strong></p></td>
59515bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59525bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59535bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
59545bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59555bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>uniform</strong> (Vulkan only)</p></td>
59565bd8deadSopenharmony_ci</tr>
59575bd8deadSopenharmony_ci<tr>
59585bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>input_attachment_index</strong> =</p></td>
59595bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59605bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">subpass types only</p></td>
59615bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59625bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59635bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>uniform</strong> (Vulkan only)</p></td>
59645bd8deadSopenharmony_ci</tr>
59655bd8deadSopenharmony_ci<tr>
59665bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>location</strong> =</p></td>
59675bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59685bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
59695bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59705bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59715bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>uniform</strong> / <strong>buffer</strong> and subroutine variables</p></td>
59725bd8deadSopenharmony_ci</tr>
59735bd8deadSopenharmony_ci<tr>
59745bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>location</strong> =</p></td>
59755bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59765bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
59775bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
59785bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
59795bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle" rowspan="2"><p class="tableblock">all <strong>in</strong> / <strong>out</strong>, except for compute</p></td>
59805bd8deadSopenharmony_ci</tr>
59815bd8deadSopenharmony_ci<tr>
59825bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>component</strong> =</p></td>
59835bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59845bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
59855bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59865bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
59875bd8deadSopenharmony_ci</tr>
59885bd8deadSopenharmony_ci<tr>
59895bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>index</strong> =</p></td>
59905bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59915bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
59925bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59935bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
59945bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock">fragment <strong>out</strong> and subroutine functions</p></td>
59955bd8deadSopenharmony_ci</tr>
59965bd8deadSopenharmony_ci<tr>
59975bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>triangles</strong><br>
59985bd8deadSopenharmony_ci  <strong>quads</strong><br>
59995bd8deadSopenharmony_ci  <strong>isolines</strong></p></td>
60005bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
60015bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60025bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60035bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60045bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock">tessellation evaluation <strong>in</strong></p></td>
60055bd8deadSopenharmony_ci</tr>
60065bd8deadSopenharmony_ci<tr>
60075bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>equal_spacing</strong><br>
60085bd8deadSopenharmony_ci  <strong>fractional_even_spacing</strong><br>
60095bd8deadSopenharmony_ci  <strong>fractional_odd_spacing</strong></p></td>
60105bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
60115bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60125bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60135bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60145bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock">tessellation evaluation <strong>in</strong></p></td>
60155bd8deadSopenharmony_ci</tr>
60165bd8deadSopenharmony_ci<tr>
60175bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>cw</strong><br>
60185bd8deadSopenharmony_ci  <strong>ccw</strong></p></td>
60195bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
60205bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60215bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60225bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60235bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock">tessellation evaluation <strong>in</strong></p></td>
60245bd8deadSopenharmony_ci</tr>
60255bd8deadSopenharmony_ci<tr>
60265bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>point_mode</strong></p></td>
60275bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
60285bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60295bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60305bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60315bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock">tessellation evaluation <strong>in</strong></p></td>
60325bd8deadSopenharmony_ci</tr>
60335bd8deadSopenharmony_ci<tr>
60345bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>points</strong></p></td>
60355bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
60365bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60375bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60385bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60395bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock">geometry <strong>in</strong>/<strong>out</strong></p></td>
60405bd8deadSopenharmony_ci</tr>
60415bd8deadSopenharmony_ci<tr>
60425bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock">[ <strong>points</strong> ]<br>
60435bd8deadSopenharmony_ci  <strong>lines</strong><br>
60445bd8deadSopenharmony_ci  <strong>lines_adjacency</strong><br>
60455bd8deadSopenharmony_ci  <strong>triangles</strong><br>
60465bd8deadSopenharmony_ci  <strong>triangles_adjacency</strong></p></td>
60475bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
60485bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60495bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60505bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60515bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock">geometry <strong>in</strong></p></td>
60525bd8deadSopenharmony_ci</tr>
60535bd8deadSopenharmony_ci<tr>
60545bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>invocations</strong> =</p></td>
60555bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
60565bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60575bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60585bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60595bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock">geometry <strong>in</strong></p></td>
60605bd8deadSopenharmony_ci</tr>
60615bd8deadSopenharmony_ci<tr>
60625bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>origin_upper_left</strong><br>
60635bd8deadSopenharmony_ci  <strong>pixel_center_integer</strong></p></td>
60645bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60655bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock"><em>gl_FragCoord</em> only</p></td>
60665bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60675bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60685bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle" rowspan="2"><p class="tableblock">fragment <strong>in</strong></p></td>
60695bd8deadSopenharmony_ci</tr>
60705bd8deadSopenharmony_ci<tr>
60715bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>early_fragment_tests</strong></p></td>
60725bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
60735bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60745bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60755bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60765bd8deadSopenharmony_ci</tr>
60775bd8deadSopenharmony_ci<tr>
60785bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>local_size_x</strong> =<br>
60795bd8deadSopenharmony_ci  <strong>local_size_y</strong> =<br>
60805bd8deadSopenharmony_ci  <strong>local_size_z</strong> =</p></td>
60815bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
60825bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60835bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60845bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60855bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock">compute <strong>in</strong></p></td>
60865bd8deadSopenharmony_ci</tr>
60875bd8deadSopenharmony_ci<tr>
60885bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>local_size_x_id</strong> =<br>
60895bd8deadSopenharmony_ci  <strong>local_size_y_id</strong> =<br>
60905bd8deadSopenharmony_ci  <strong>local_size_z_id</strong> =</p></td>
60915bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
60925bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60935bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60945bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
60955bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock">compute <strong>in</strong> (SPIR-V only)</p></td>
60965bd8deadSopenharmony_ci</tr>
60975bd8deadSopenharmony_ci<tr>
60985bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>xfb_buffer</strong> =<br>
60995bd8deadSopenharmony_ci  <strong>xfb_stride</strong> =</p></td>
61005bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
61015bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
61025bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
61035bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
61045bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle" rowspan="2"><p class="tableblock">vertex, tessellation, and geometry <strong>out</strong></p></td>
61055bd8deadSopenharmony_ci</tr>
61065bd8deadSopenharmony_ci<tr>
61075bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>xfb_offset</strong> =</p></td>
61085bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
61095bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
61105bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
61115bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
61125bd8deadSopenharmony_ci</tr>
61135bd8deadSopenharmony_ci<tr>
61145bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>vertices</strong> =</p></td>
61155bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
61165bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
61175bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
61185bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
61195bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock">tessellation control <strong>out</strong></p></td>
61205bd8deadSopenharmony_ci</tr>
61215bd8deadSopenharmony_ci<tr>
61225bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock">[ <strong>points</strong> ]<br>
61235bd8deadSopenharmony_ci  <strong>line_strip</strong><br>
61245bd8deadSopenharmony_ci  <strong>triangle_strip</strong></p></td>
61255bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
61265bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
61275bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
61285bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
61295bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle" rowspan="3"><p class="tableblock">geometry <strong>out</strong></p></td>
61305bd8deadSopenharmony_ci</tr>
61315bd8deadSopenharmony_ci<tr>
61325bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>max_vertices</strong> =</p></td>
61335bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
61345bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
61355bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
61365bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
61375bd8deadSopenharmony_ci</tr>
61385bd8deadSopenharmony_ci<tr>
61395bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>stream</strong> =</p></td>
61405bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
61415bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
61425bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
61435bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">X</p></td>
61445bd8deadSopenharmony_ci</tr>
61455bd8deadSopenharmony_ci<tr>
61465bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>depth_any</strong><br>
61475bd8deadSopenharmony_ci  <strong>depth_greater</strong><br>
61485bd8deadSopenharmony_ci  <strong>depth_less</strong><br>
61495bd8deadSopenharmony_ci  <strong>depth_unchanged</strong></p></td>
61505bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
61515bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock"><em>gl_FragDepth</em> only</p></td>
61525bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
61535bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
61545bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock">fragment <strong>out</strong></p></td>
61555bd8deadSopenharmony_ci</tr>
61565bd8deadSopenharmony_ci<tr>
61575bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>constant_id</strong> =</p></td>
61585bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
61595bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">scalar only</p></td>
61605bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
61615bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
61625bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>const</strong> (SPIR-V only)</p></td>
61635bd8deadSopenharmony_ci</tr>
61645bd8deadSopenharmony_ci<tr>
61655bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>rgba32f</strong><br>
61665bd8deadSopenharmony_ci  <strong>rgba16f</strong><br>
61675bd8deadSopenharmony_ci  <strong>rg32f</strong><br>
61685bd8deadSopenharmony_ci  <strong>rg16f</strong><br>
61695bd8deadSopenharmony_ci  <strong>r11f_g11f_b10f</strong><br>
61705bd8deadSopenharmony_ci  <strong>r32f</strong><br>
61715bd8deadSopenharmony_ci  <strong>r16f</strong><br>
61725bd8deadSopenharmony_ci  <strong>rgba16</strong><br>
61735bd8deadSopenharmony_ci  <strong>rgb10_a2</strong><br>
61745bd8deadSopenharmony_ci  <strong>rgba8</strong><br>
61755bd8deadSopenharmony_ci  <strong>rg16</strong><br>
61765bd8deadSopenharmony_ci  <strong>rg8</strong><br>
61775bd8deadSopenharmony_ci  <strong>r16</strong><br>
61785bd8deadSopenharmony_ci  <strong>r8</strong><br>
61795bd8deadSopenharmony_ci  <strong>rgba16_snorm</strong><br>
61805bd8deadSopenharmony_ci  <strong>rgba8_snorm</strong><br>
61815bd8deadSopenharmony_ci  <strong>rg16_snorm</strong><br>
61825bd8deadSopenharmony_ci  <strong>rg8_snorm</strong><br>
61835bd8deadSopenharmony_ci  <strong>r16_snorm</strong><br>
61845bd8deadSopenharmony_ci  <strong>r8_snorm</strong><br>
61855bd8deadSopenharmony_ci  <strong>rgba32i</strong><br>
61865bd8deadSopenharmony_ci  <strong>rgba16i</strong><br>
61875bd8deadSopenharmony_ci  <strong>rgba8i</strong><br>
61885bd8deadSopenharmony_ci  <strong>rg32i</strong><br>
61895bd8deadSopenharmony_ci  <strong>rg16i</strong><br>
61905bd8deadSopenharmony_ci  <strong>rg8i</strong><br>
61915bd8deadSopenharmony_ci  <strong>r32i</strong><br>
61925bd8deadSopenharmony_ci  <strong>r16i</strong><br>
61935bd8deadSopenharmony_ci  <strong>r8i</strong><br>
61945bd8deadSopenharmony_ci  <strong>rgba32ui</strong><br>
61955bd8deadSopenharmony_ci  <strong>rgba16ui</strong><br>
61965bd8deadSopenharmony_ci<strong>rgb10_a2ui</strong><br>
61975bd8deadSopenharmony_ci  <strong>rgba8ui</strong><br>
61985bd8deadSopenharmony_ci  <strong>rg32ui</strong><br>
61995bd8deadSopenharmony_ci  <strong>rg16ui</strong><br>
62005bd8deadSopenharmony_ci  <strong>rg8ui</strong><br>
62015bd8deadSopenharmony_ci  <strong>r32ui</strong><br>
62025bd8deadSopenharmony_ci  <strong>r16ui</strong><br>
62035bd8deadSopenharmony_ci  <strong>r8ui</strong></p></td>
62045bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
62055bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"><p class="tableblock">image types only</p></td>
62065bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
62075bd8deadSopenharmony_ci<td class="tableblock halign-center valign-middle"></td>
62085bd8deadSopenharmony_ci<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>uniform</strong></p></td>
62095bd8deadSopenharmony_ci</tr>
62105bd8deadSopenharmony_ci</tbody>
62115bd8deadSopenharmony_ci</table>
62125bd8deadSopenharmony_ci<div class="sect3">
62135bd8deadSopenharmony_ci<h4 id="input-layout-qualifiers">4.4.1. Input Layout Qualifiers</h4>
62145bd8deadSopenharmony_ci<div class="paragraph">
62155bd8deadSopenharmony_ci<p>Layout qualifiers specific to a particular shader language are discussed in
62165bd8deadSopenharmony_ciseparate sections below.</p>
62175bd8deadSopenharmony_ci</div>
62185bd8deadSopenharmony_ci<div class="paragraph">
62195bd8deadSopenharmony_ci<p>All shaders except compute shaders allow <strong>location</strong> layout qualifiers on
62205bd8deadSopenharmony_ciinput variable declarations, input block declarations, and input block
62215bd8deadSopenharmony_cimember declarations.
62225bd8deadSopenharmony_ciOf these, variables and block members (but not blocks) additionally allow
62235bd8deadSopenharmony_cithe <strong>component</strong> layout qualifier.</p>
62245bd8deadSopenharmony_ci</div>
62255bd8deadSopenharmony_ci<div class="openblock bnf">
62265bd8deadSopenharmony_ci<div class="content">
62275bd8deadSopenharmony_ci<div class="dlist">
62285bd8deadSopenharmony_ci<dl>
62295bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-id</em> : </dt>
62305bd8deadSopenharmony_ci<dd>
62315bd8deadSopenharmony_ci<p><strong>location</strong> <strong>=</strong> <em>layout-qualifier-value</em><br>
62325bd8deadSopenharmony_ci<strong>component</strong> <strong>=</strong> <em>layout-qualifier-value</em></p>
62335bd8deadSopenharmony_ci</dd>
62345bd8deadSopenharmony_ci</dl>
62355bd8deadSopenharmony_ci</div>
62365bd8deadSopenharmony_ci</div>
62375bd8deadSopenharmony_ci</div>
62385bd8deadSopenharmony_ci<div class="paragraph">
62395bd8deadSopenharmony_ci<p>For example,</p>
62405bd8deadSopenharmony_ci</div>
62415bd8deadSopenharmony_ci<div class="listingblock">
62425bd8deadSopenharmony_ci<div class="content">
62435bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(location = <span class="integer">3</span>) in vec4 normal;
62445bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> start = <span class="integer">6</span>;
62455bd8deadSopenharmony_cilayout(location = start + <span class="integer">2</span>) <span class="predefined-type">int</span> vec4 v;</code></pre>
62465bd8deadSopenharmony_ci</div>
62475bd8deadSopenharmony_ci</div>
62485bd8deadSopenharmony_ci<div class="paragraph">
62495bd8deadSopenharmony_ci<p>will establish that the shader input <em>normal</em> is assigned to vector location
62505bd8deadSopenharmony_cinumber
62515bd8deadSopenharmony_ci3 and <em>v</em> is assigned location number 8.
62525bd8deadSopenharmony_ciFor vertex shader inputs, the location specifies the number of the
62535bd8deadSopenharmony_civertex attribute from which input values are taken.
62545bd8deadSopenharmony_ciFor inputs of all other shader types, the location specifies a vector number
62555bd8deadSopenharmony_cithat can be used to match against outputs from a previous shader stage, even
62565bd8deadSopenharmony_ciif that shader is in a different program object.</p>
62575bd8deadSopenharmony_ci</div>
62585bd8deadSopenharmony_ci<div class="paragraph">
62595bd8deadSopenharmony_ci<p>The following language describes how many locations are consumed by a given
62605bd8deadSopenharmony_citype.
62615bd8deadSopenharmony_ciHowever, geometry shader inputs, tessellation control shader inputs and
62625bd8deadSopenharmony_cioutputs, and tessellation evaluation inputs all have an additional level of
62635bd8deadSopenharmony_ciarrayness relative to other shader inputs and outputs.
62645bd8deadSopenharmony_ciThis outer array level is removed from the type before considering how many
62655bd8deadSopenharmony_cilocations the type consumes.</p>
62665bd8deadSopenharmony_ci</div>
62675bd8deadSopenharmony_ci<div class="paragraph">
62685bd8deadSopenharmony_ci<p>Except when targeting Vulkan,
62695bd8deadSopenharmony_ciif a vertex shader input is any scalar or vector type, it will consume a
62705bd8deadSopenharmony_cisingle location.
62715bd8deadSopenharmony_ciIf a non-vertex shader input, or any stage input when targeting Vulkan,
62725bd8deadSopenharmony_ciis a scalar or vector type other than <strong>dvec3</strong>
62735bd8deadSopenharmony_cior <strong>dvec4</strong>, it will consume a single location, while types <strong>dvec3</strong> or
62745bd8deadSopenharmony_ci<strong>dvec4</strong> will consume two consecutive locations.
62755bd8deadSopenharmony_ciInputs of type <strong>double</strong> and <strong>dvec2</strong> will consume only a single location, in
62765bd8deadSopenharmony_ciall stages.</p>
62775bd8deadSopenharmony_ci</div>
62785bd8deadSopenharmony_ci<div class="paragraph">
62795bd8deadSopenharmony_ci<p>If the declared input (after potentially removing an outer array level as
62805bd8deadSopenharmony_cijust described above) is an array of size <em>n</em> and each of the elements takes
62815bd8deadSopenharmony_ci<em>m</em> locations, it will be assigned <em>m</em> * <em>n</em> consecutive locations starting
62825bd8deadSopenharmony_ciwith the location specified.
62835bd8deadSopenharmony_ciFor example,</p>
62845bd8deadSopenharmony_ci</div>
62855bd8deadSopenharmony_ci<div class="listingblock">
62865bd8deadSopenharmony_ci<div class="content">
62875bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(location = <span class="integer">6</span>) in vec4 colors[<span class="integer">3</span>];</code></pre>
62885bd8deadSopenharmony_ci</div>
62895bd8deadSopenharmony_ci</div>
62905bd8deadSopenharmony_ci<div class="paragraph">
62915bd8deadSopenharmony_ci<p>will establish that the shader input <em>colors</em> is assigned to vector location
62925bd8deadSopenharmony_cinumbers 6, 7, and 8.</p>
62935bd8deadSopenharmony_ci</div>
62945bd8deadSopenharmony_ci<div class="paragraph">
62955bd8deadSopenharmony_ci<p>If the declared input is an <em>n</em> × <em>m</em>
62965bd8deadSopenharmony_cimatrix, it will be assigned multiple locations starting with the location
62975bd8deadSopenharmony_cispecified.
62985bd8deadSopenharmony_ciThe number of locations assigned for each matrix will be the same as for an
62995bd8deadSopenharmony_ci<em>n</em>-element array of <em>m</em>-component vectors.
63005bd8deadSopenharmony_ciFor example,</p>
63015bd8deadSopenharmony_ci</div>
63025bd8deadSopenharmony_ci<div class="listingblock">
63035bd8deadSopenharmony_ci<div class="content">
63045bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(location = <span class="integer">9</span>) in mat4 transforms[<span class="integer">2</span>];</code></pre>
63055bd8deadSopenharmony_ci</div>
63065bd8deadSopenharmony_ci</div>
63075bd8deadSopenharmony_ci<div class="paragraph">
63085bd8deadSopenharmony_ci<p>will establish that shader input <em>transforms</em> is assigned to vector
63095bd8deadSopenharmony_cilocations 9-16, with <em>transforms[0]</em> being assigned to locations 9-12, and
63105bd8deadSopenharmony_ci<em>transforms[1]</em> being assigned to locations 13-16.</p>
63115bd8deadSopenharmony_ci</div>
63125bd8deadSopenharmony_ci<div class="paragraph">
63135bd8deadSopenharmony_ci<p>If the declared input is a structure or block, its members will be assigned
63145bd8deadSopenharmony_ciconsecutive locations in their order of declaration, with the first member
63155bd8deadSopenharmony_ciassigned the location provided in the layout qualifier.
63165bd8deadSopenharmony_ciFor a structure, this process applies to the entire structure.
63175bd8deadSopenharmony_ciIt is a compile-time error to use a <strong>location</strong> qualifier on a member of a
63185bd8deadSopenharmony_cistructure.
63195bd8deadSopenharmony_ciFor a block, this process applies to the entire block, or until the first
63205bd8deadSopenharmony_cimember is reached that has a <strong>location</strong> layout qualifier.</p>
63215bd8deadSopenharmony_ci</div>
63225bd8deadSopenharmony_ci<div class="paragraph">
63235bd8deadSopenharmony_ci<p>When a block member is declared with a <strong>location</strong> qualifier, its location
63245bd8deadSopenharmony_cicomes from that qualifier; the member&#8217;s <strong>location</strong> qualifier overrides the
63255bd8deadSopenharmony_ciblock-level declaration.
63265bd8deadSopenharmony_ciSubsequent members are again assigned consecutive locations, based on the
63275bd8deadSopenharmony_cinewest location, until the next member declared with a <strong>location</strong> qualifier.
63285bd8deadSopenharmony_ciThe values used for locations do not have to be declared in increasing
63295bd8deadSopenharmony_ciorder.</p>
63305bd8deadSopenharmony_ci</div>
63315bd8deadSopenharmony_ci<div class="paragraph">
63325bd8deadSopenharmony_ci<p>If a block has no block-level <strong>location</strong> layout qualifier, it is required
63335bd8deadSopenharmony_cithat either all or none of its members have a <strong>location</strong> layout qualifier,
63345bd8deadSopenharmony_cior a compile-time error results.
63355bd8deadSopenharmony_ciFor some blocks declared as arrays, the <strong>location</strong> can only be applied at
63365bd8deadSopenharmony_cithe block level: When a block is declared as an array where additional
63375bd8deadSopenharmony_cilocations are needed for each member for each block array element, it is a
63385bd8deadSopenharmony_cicompile-time error to specify locations on the block members.
63395bd8deadSopenharmony_ciThat is, when locations would be under specified by applying them on block
63405bd8deadSopenharmony_cimembers, they are not allowed on block members.
63415bd8deadSopenharmony_ciFor <em>arrayed</em> interfaces (those generally having an extra level of arrayness
63425bd8deadSopenharmony_cidue to interface expansion), the outer array is stripped before applying
63435bd8deadSopenharmony_cithis rule.</p>
63445bd8deadSopenharmony_ci</div>
63455bd8deadSopenharmony_ci<div class="paragraph">
63465bd8deadSopenharmony_ci<p>When generating SPIR-V, all <strong>in</strong> and <strong>out</strong> qualified user-declared (non
63475bd8deadSopenharmony_cibuilt-in) variables and blocks (or all their members) must have a
63485bd8deadSopenharmony_cishader-specified <strong>location</strong>.
63495bd8deadSopenharmony_ciOtherwise, a compile-time error is generated.</p>
63505bd8deadSopenharmony_ci</div>
63515bd8deadSopenharmony_ci<div class="paragraph">
63525bd8deadSopenharmony_ci<p>The locations consumed by block and structure members are determined by
63535bd8deadSopenharmony_ciapplying the rules above recursively as though the structure member were
63545bd8deadSopenharmony_cideclared as an input variable of the same type.
63555bd8deadSopenharmony_ciFor example:</p>
63565bd8deadSopenharmony_ci</div>
63575bd8deadSopenharmony_ci<div class="listingblock">
63585bd8deadSopenharmony_ci<div class="content">
63595bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(location = <span class="integer">3</span>) in <span class="keyword">struct</span> S
63605bd8deadSopenharmony_ci{
63615bd8deadSopenharmony_ci    vec3 a;                      <span class="comment">// gets location 3</span>
63625bd8deadSopenharmony_ci    mat2 b;                      <span class="comment">// gets locations 4 and 5</span>
63635bd8deadSopenharmony_ci    vec4 c[<span class="integer">2</span>];                   <span class="comment">// gets locations 6 and 7</span>
63645bd8deadSopenharmony_ci    layout(location = <span class="integer">8</span>) vec2 A; <span class="comment">// ERROR, can't use on struct member</span>
63655bd8deadSopenharmony_ci} s;
63665bd8deadSopenharmony_cilayout(location = <span class="integer">4</span>) in block
63675bd8deadSopenharmony_ci{
63685bd8deadSopenharmony_ci    vec4 d;                      <span class="comment">// gets location 4</span>
63695bd8deadSopenharmony_ci    vec4 e;                      <span class="comment">// gets location 5</span>
63705bd8deadSopenharmony_ci    layout(location = <span class="integer">7</span>) vec4 f; <span class="comment">// gets location 7</span>
63715bd8deadSopenharmony_ci    vec4 g;                      <span class="comment">// gets location 8</span>
63725bd8deadSopenharmony_ci    layout(location = <span class="integer">1</span>) vec4 h; <span class="comment">// gets location 1</span>
63735bd8deadSopenharmony_ci    vec4 i;                      <span class="comment">// gets location 2</span>
63745bd8deadSopenharmony_ci    vec4 j;                      <span class="comment">// gets location 3</span>
63755bd8deadSopenharmony_ci    vec4 k;                      <span class="comment">// ERROR, location 4 already used</span>
63765bd8deadSopenharmony_ci};</code></pre>
63775bd8deadSopenharmony_ci</div>
63785bd8deadSopenharmony_ci</div>
63795bd8deadSopenharmony_ci<div class="paragraph">
63805bd8deadSopenharmony_ci<p>The number of input locations available to a shader is limited.
63815bd8deadSopenharmony_ciFor vertex shaders, the limit is the advertised number of vertex attributes.
63825bd8deadSopenharmony_ciFor all other shaders, the limit is implementation-dependent and must be no
63835bd8deadSopenharmony_ciless than one fourth of the advertised maximum input component count.</p>
63845bd8deadSopenharmony_ci</div>
63855bd8deadSopenharmony_ci<div class="paragraph">
63865bd8deadSopenharmony_ci<p>A program will fail to link if any attached shader uses a location greater
63875bd8deadSopenharmony_cithan or equal to the number of supported locations, unless device-dependent
63885bd8deadSopenharmony_cioptimizations are able to make the program fit within available hardware
63895bd8deadSopenharmony_ciresources.</p>
63905bd8deadSopenharmony_ci</div>
63915bd8deadSopenharmony_ci<div class="paragraph">
63925bd8deadSopenharmony_ci<p>A program will fail to link if explicit location assignments leave the
63935bd8deadSopenharmony_cilinker unable to find space for other variables without explicit
63945bd8deadSopenharmony_ciassignments.</p>
63955bd8deadSopenharmony_ci</div>
63965bd8deadSopenharmony_ci<div class="paragraph">
63975bd8deadSopenharmony_ci<p>For the purposes of determining if a non-vertex input matches an output from
63985bd8deadSopenharmony_cia previous shader stage, the <strong>location</strong> layout qualifier (if any) must
63995bd8deadSopenharmony_cimatch.</p>
64005bd8deadSopenharmony_ci</div>
64015bd8deadSopenharmony_ci<div class="paragraph">
64025bd8deadSopenharmony_ci<p>If a vertex shader input variable with no location assigned in the shader
64035bd8deadSopenharmony_citext has a location specified through the OpenGL API, the API-assigned
64045bd8deadSopenharmony_cilocation will be used.
64055bd8deadSopenharmony_ciOtherwise, such variables will be assigned a location by the linker.
64065bd8deadSopenharmony_ciSee section 11.1.1 &#8220;Vertex Attributes&#8221; of the <a href="#references">OpenGL Specification</a> for
64075bd8deadSopenharmony_cimore details.
64085bd8deadSopenharmony_ciA link-time error will occur if an input variable is declared in multiple
64095bd8deadSopenharmony_cishaders of the same language with conflicting locations.</p>
64105bd8deadSopenharmony_ci</div>
64115bd8deadSopenharmony_ci<div class="paragraph">
64125bd8deadSopenharmony_ci<p>The <strong>component</strong> qualifier allows the location to be more finely specified
64135bd8deadSopenharmony_cifor scalars and vectors, down to the individual components within a location
64145bd8deadSopenharmony_cithat are consumed.
64155bd8deadSopenharmony_ciIt is a compile-time error to use <strong>component</strong> without also specifying the
64165bd8deadSopenharmony_ci<strong>location</strong> qualifier (order does not matter).
64175bd8deadSopenharmony_ciThe components within a location are 0, 1, 2, and 3.
64185bd8deadSopenharmony_ciA variable or block member starting at component <em>N</em> will consume components
64195bd8deadSopenharmony_ci<em>N</em>, <em>N+1</em>, <em>N+2</em>, &#8230;&#8203;
64205bd8deadSopenharmony_ciup through its size.
64215bd8deadSopenharmony_ciIt is a compile-time error if this sequence of components gets larger than
64225bd8deadSopenharmony_ci3.
64235bd8deadSopenharmony_ciA scalar <strong>double</strong> will consume two of these components, and a <strong>dvec2</strong> will
64245bd8deadSopenharmony_ciconsume all four components available within a location.
64255bd8deadSopenharmony_ciA <strong>dvec3</strong> or <strong>dvec4</strong> can only be declared without specifying a <strong>component</strong>.
64265bd8deadSopenharmony_ciA <strong>dvec3</strong> will consume all four components of the first location and
64275bd8deadSopenharmony_cicomponents 0 and 1 of the second location.
64285bd8deadSopenharmony_ciThis leaves components 2 and 3 available for other component-qualified
64295bd8deadSopenharmony_cideclarations.</p>
64305bd8deadSopenharmony_ci</div>
64315bd8deadSopenharmony_ci<div class="paragraph">
64325bd8deadSopenharmony_ci<p>For example:</p>
64335bd8deadSopenharmony_ci</div>
64345bd8deadSopenharmony_ci<div class="listingblock">
64355bd8deadSopenharmony_ci<div class="content">
64365bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="comment">// a consumes components 2 and 3 of location 4</span>
64375bd8deadSopenharmony_cilayout(location = <span class="integer">4</span>, component = <span class="integer">2</span>) in vec2 a;
64385bd8deadSopenharmony_ci
64395bd8deadSopenharmony_ci<span class="comment">// b consumes component 1 of location 4</span>
64405bd8deadSopenharmony_cilayout(location = <span class="integer">4</span>, component = <span class="integer">1</span>) in <span class="predefined-type">float</span> b;
64415bd8deadSopenharmony_ci
64425bd8deadSopenharmony_ci<span class="comment">// ERROR: c overflows component 3</span>
64435bd8deadSopenharmony_cilayout(location = <span class="integer">3</span>, component = <span class="integer">2</span>) in vec3 c;
64445bd8deadSopenharmony_ci
64455bd8deadSopenharmony_ci<span class="comment">// d consumes components 2 and 3 of location 5</span>
64465bd8deadSopenharmony_cilayout(location = <span class="integer">5</span>, component = <span class="integer">2</span>) in <span class="predefined-type">double</span> d;
64475bd8deadSopenharmony_ci
64485bd8deadSopenharmony_ci<span class="comment">// ERROR: e overflows component 3 of location 6</span>
64495bd8deadSopenharmony_cilayout(location = <span class="integer">6</span>, component = <span class="integer">2</span>) in dvec2 e;
64505bd8deadSopenharmony_ci
64515bd8deadSopenharmony_ci<span class="comment">// ERROR: f overlaps with g</span>
64525bd8deadSopenharmony_cilayout(location = <span class="integer">7</span>, component = <span class="integer">0</span>) <span class="predefined-type">double</span> f;
64535bd8deadSopenharmony_cilayout(location = <span class="integer">7</span>, component = <span class="integer">1</span>) <span class="predefined-type">float</span> g;
64545bd8deadSopenharmony_ci
64555bd8deadSopenharmony_cilayout(location = <span class="integer">8</span>) in dvec3 h; <span class="comment">// components 0,1,2 and 3 of location 8</span>
64565bd8deadSopenharmony_ci                                 <span class="comment">// and components 0 and 1 of location 9</span>
64575bd8deadSopenharmony_cilayout(location = <span class="integer">9</span>, component = <span class="integer">2</span>) in <span class="predefined-type">float</span> i; <span class="comment">// okay, compts 2 and 3</span></code></pre>
64585bd8deadSopenharmony_ci</div>
64595bd8deadSopenharmony_ci</div>
64605bd8deadSopenharmony_ci<div class="paragraph">
64615bd8deadSopenharmony_ci<p>If the variable is an array, each element of the array, in order, is
64625bd8deadSopenharmony_ciassigned to consecutive locations, but all at the same specified component
64635bd8deadSopenharmony_ciwithin each location.
64645bd8deadSopenharmony_ciFor example:</p>
64655bd8deadSopenharmony_ci</div>
64665bd8deadSopenharmony_ci<div class="listingblock">
64675bd8deadSopenharmony_ci<div class="content">
64685bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="comment">// component 3 in 6 locations are consumed</span>
64695bd8deadSopenharmony_cilayout(location = <span class="integer">2</span>, component = <span class="integer">3</span>) in <span class="predefined-type">float</span> d[<span class="integer">6</span>];</code></pre>
64705bd8deadSopenharmony_ci</div>
64715bd8deadSopenharmony_ci</div>
64725bd8deadSopenharmony_ci<div class="paragraph">
64735bd8deadSopenharmony_ci<p>That is, location 2 component 3 will hold <em>d[0]</em>, location 3 component 3
64745bd8deadSopenharmony_ciwill hold <em>d[1]</em>, &#8230;&#8203;, up through location 7 component 3 holding <em>d[5]</em>.</p>
64755bd8deadSopenharmony_ci</div>
64765bd8deadSopenharmony_ci<div class="paragraph">
64775bd8deadSopenharmony_ci<p>This allows packing of two arrays into the same set of locations:</p>
64785bd8deadSopenharmony_ci</div>
64795bd8deadSopenharmony_ci<div class="listingblock">
64805bd8deadSopenharmony_ci<div class="content">
64815bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="comment">// e consumes beginning (components 0, 1 and 2) of each of 6 slots</span>
64825bd8deadSopenharmony_cilayout(location = <span class="integer">0</span>, component = <span class="integer">0</span>) in vec3 e[<span class="integer">6</span>];
64835bd8deadSopenharmony_ci
64845bd8deadSopenharmony_ci<span class="comment">// f consumes last component of the same 6 slots</span>
64855bd8deadSopenharmony_cilayout(location = <span class="integer">0</span>, component = <span class="integer">3</span>) in <span class="predefined-type">float</span> f[<span class="integer">6</span>];</code></pre>
64865bd8deadSopenharmony_ci</div>
64875bd8deadSopenharmony_ci</div>
64885bd8deadSopenharmony_ci<div class="paragraph">
64895bd8deadSopenharmony_ci<p>If applying this to an array of arrays, all levels of arrayness are removed
64905bd8deadSopenharmony_cito get to the elements that are assigned per location to the specified
64915bd8deadSopenharmony_cicomponent.
64925bd8deadSopenharmony_ciThese non-arrayed elements will fill the locations in the order specified
64935bd8deadSopenharmony_cifor arrays of arrays in &#8220;<a href="#arrays">Arrays</a>&#8221;.</p>
64945bd8deadSopenharmony_ci</div>
64955bd8deadSopenharmony_ci<div class="paragraph">
64965bd8deadSopenharmony_ci<p>It is a compile-time error to apply the <strong>component</strong> qualifier to a matrix, a
64975bd8deadSopenharmony_cistructure, a block, or an array containing any of these.
64985bd8deadSopenharmony_ciIt is a compile-time error to use <strong>component</strong> 1 or 3 as the beginning of a
64995bd8deadSopenharmony_ci<strong>double</strong> or <strong>dvec2</strong>.
65005bd8deadSopenharmony_ciIt is a link-time error to specify different components for the same
65015bd8deadSopenharmony_civariable within a program.</p>
65025bd8deadSopenharmony_ci</div>
65035bd8deadSopenharmony_ci<div class="paragraph">
65045bd8deadSopenharmony_ci<p><em>Location aliasing</em> is causing two variables or block members to have the
65055bd8deadSopenharmony_cisame location number.
65065bd8deadSopenharmony_ci<em>Component aliasing</em> is assigning the same (or overlapping) component
65075bd8deadSopenharmony_cinumbers for two location aliases.
65085bd8deadSopenharmony_ci(Recall if <strong>component</strong> is not used, components are assigned starting with
65095bd8deadSopenharmony_ci0.)
65105bd8deadSopenharmony_ciWith one exception, location aliasing is allowed only if it does not
65115bd8deadSopenharmony_cicause component aliasing; it is a compile-time or link-time error to cause
65125bd8deadSopenharmony_cicomponent aliasing.
65135bd8deadSopenharmony_ciFurther, when location aliasing, the aliases sharing the location must have
65145bd8deadSopenharmony_cithe same underlying numerical type and bit width  (floating-point or integer,
65155bd8deadSopenharmony_ci32-bit versus 64-bit, etc.) and the same
65165bd8deadSopenharmony_ciauxiliary storage and interpolation qualification.
65175bd8deadSopenharmony_ciThe one exception where component aliasing is permitted is
65185bd8deadSopenharmony_ciwhen targeting OpenGL for two input
65195bd8deadSopenharmony_civariables (not block members) to a vertex shader, which are allowed to have
65205bd8deadSopenharmony_cicomponent aliasing.
65215bd8deadSopenharmony_ciThis vertex-variable component aliasing is intended only to support vertex
65225bd8deadSopenharmony_cishaders where each execution path accesses at most one input per each
65235bd8deadSopenharmony_cialiased component.
65245bd8deadSopenharmony_ciImplementations are permitted, but not required, to generate link-time
65255bd8deadSopenharmony_cierrors if they detect that every path through the vertex shader executable
65265bd8deadSopenharmony_ciaccesses multiple inputs aliased to any single component.</p>
65275bd8deadSopenharmony_ci</div>
65285bd8deadSopenharmony_ci<div class="sect4">
65295bd8deadSopenharmony_ci<h5 id="tessellation-evaluation-inputs">Tessellation Evaluation Inputs</h5>
65305bd8deadSopenharmony_ci<div class="paragraph">
65315bd8deadSopenharmony_ci<p>Additional input layout qualifier identifiers allowed for tessellation
65325bd8deadSopenharmony_cievaluation shaders are described below.</p>
65335bd8deadSopenharmony_ci</div>
65345bd8deadSopenharmony_ci<div class="openblock bnf">
65355bd8deadSopenharmony_ci<div class="content">
65365bd8deadSopenharmony_ci<div class="dlist">
65375bd8deadSopenharmony_ci<dl>
65385bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-id</em> : </dt>
65395bd8deadSopenharmony_ci<dd>
65405bd8deadSopenharmony_ci<p><em>primitive_mode</em><br>
65415bd8deadSopenharmony_ci<em>vertex_spacing</em><br>
65425bd8deadSopenharmony_ci<em>ordering</em><br>
65435bd8deadSopenharmony_ci<em>point_mode</em></p>
65445bd8deadSopenharmony_ci</dd>
65455bd8deadSopenharmony_ci</dl>
65465bd8deadSopenharmony_ci</div>
65475bd8deadSopenharmony_ci</div>
65485bd8deadSopenharmony_ci</div>
65495bd8deadSopenharmony_ci<div class="paragraph">
65505bd8deadSopenharmony_ci<p>The <strong>primitive-mode</strong> is used to specify a tessellation primitive mode to be
65515bd8deadSopenharmony_ciused by the tessellation primitive generator.</p>
65525bd8deadSopenharmony_ci</div>
65535bd8deadSopenharmony_ci<div class="openblock bnf">
65545bd8deadSopenharmony_ci<div class="content">
65555bd8deadSopenharmony_ci<div class="dlist">
65565bd8deadSopenharmony_ci<dl>
65575bd8deadSopenharmony_ci<dt class="hdlist1"><em>primitive-mode</em>: </dt>
65585bd8deadSopenharmony_ci<dd>
65595bd8deadSopenharmony_ci<p><strong>triangles</strong><br>
65605bd8deadSopenharmony_ci<strong>quads</strong><br>
65615bd8deadSopenharmony_ci<strong>isolines</strong></p>
65625bd8deadSopenharmony_ci</dd>
65635bd8deadSopenharmony_ci</dl>
65645bd8deadSopenharmony_ci</div>
65655bd8deadSopenharmony_ci</div>
65665bd8deadSopenharmony_ci</div>
65675bd8deadSopenharmony_ci<div class="paragraph">
65685bd8deadSopenharmony_ci<p>If present, the <em>primitive-mode</em> specifies that the tessellation primitive
65695bd8deadSopenharmony_cigenerator should subdivide a triangle into smaller triangles, a quad into
65705bd8deadSopenharmony_citriangles, or a quad into a collection of lines, respectively.</p>
65715bd8deadSopenharmony_ci</div>
65725bd8deadSopenharmony_ci<div class="paragraph">
65735bd8deadSopenharmony_ci<p>A second group of layout identifiers, <em>vertex spacing</em>, is used to specify
65745bd8deadSopenharmony_cithe spacing used by the tessellation primitive generator when subdividing an
65755bd8deadSopenharmony_ciedge.</p>
65765bd8deadSopenharmony_ci</div>
65775bd8deadSopenharmony_ci<div class="openblock bnf">
65785bd8deadSopenharmony_ci<div class="content">
65795bd8deadSopenharmony_ci<div class="dlist">
65805bd8deadSopenharmony_ci<dl>
65815bd8deadSopenharmony_ci<dt class="hdlist1"><em>vertex-spacing</em>: </dt>
65825bd8deadSopenharmony_ci<dd>
65835bd8deadSopenharmony_ci<p><strong>equal_spacing</strong><br>
65845bd8deadSopenharmony_ci<strong>fractional_even_spacing</strong><br>
65855bd8deadSopenharmony_ci<strong>fractional_odd_spacing</strong></p>
65865bd8deadSopenharmony_ci</dd>
65875bd8deadSopenharmony_ci</dl>
65885bd8deadSopenharmony_ci</div>
65895bd8deadSopenharmony_ci</div>
65905bd8deadSopenharmony_ci</div>
65915bd8deadSopenharmony_ci<div class="paragraph">
65925bd8deadSopenharmony_ci<p><strong>equal_spacing</strong> specifies that edges should be divided into a collection of
65935bd8deadSopenharmony_ciequal-sized segments;</p>
65945bd8deadSopenharmony_ci</div>
65955bd8deadSopenharmony_ci<div class="paragraph">
65965bd8deadSopenharmony_ci<p><strong>fractional_even_spacing</strong> specifies that edges should be divided into an
65975bd8deadSopenharmony_cieven number of equal-length segments plus two additional shorter
65985bd8deadSopenharmony_ci&#8220;fractional&#8221; segments; or</p>
65995bd8deadSopenharmony_ci</div>
66005bd8deadSopenharmony_ci<div class="paragraph">
66015bd8deadSopenharmony_ci<p><strong>fractional_odd_spacing</strong> specifies that edges should be divided into an odd
66025bd8deadSopenharmony_cinumber of equal-length segments plus two additional shorter &#8220;fractional&#8221;
66035bd8deadSopenharmony_cisegments.</p>
66045bd8deadSopenharmony_ci</div>
66055bd8deadSopenharmony_ci<div class="paragraph">
66065bd8deadSopenharmony_ci<p>A third group of layout identifiers, <em>ordering</em>, specifies whether the
66075bd8deadSopenharmony_citessellation primitive generator produces triangles in clockwise or
66085bd8deadSopenharmony_cicounter-clockwise order, according to the coordinate system depicted in the
66095bd8deadSopenharmony_ci<a href="#references">OpenGL Specification</a>.</p>
66105bd8deadSopenharmony_ci</div>
66115bd8deadSopenharmony_ci<div class="openblock bnf">
66125bd8deadSopenharmony_ci<div class="content">
66135bd8deadSopenharmony_ci<div class="dlist">
66145bd8deadSopenharmony_ci<dl>
66155bd8deadSopenharmony_ci<dt class="hdlist1"><em>ordering</em>: </dt>
66165bd8deadSopenharmony_ci<dd>
66175bd8deadSopenharmony_ci<p><strong>cw</strong><br>
66185bd8deadSopenharmony_ci<strong>ccw</strong></p>
66195bd8deadSopenharmony_ci</dd>
66205bd8deadSopenharmony_ci</dl>
66215bd8deadSopenharmony_ci</div>
66225bd8deadSopenharmony_ci</div>
66235bd8deadSopenharmony_ci</div>
66245bd8deadSopenharmony_ci<div class="paragraph">
66255bd8deadSopenharmony_ci<p>The identifiers <strong>cw</strong> and <strong>ccw</strong> indicate clockwise and counter-clockwise
66265bd8deadSopenharmony_citriangles, respectively.
66275bd8deadSopenharmony_ciIf the tessellation primitive generator does not produce triangles, the
66285bd8deadSopenharmony_ciorder is ignored.</p>
66295bd8deadSopenharmony_ci</div>
66305bd8deadSopenharmony_ci<div class="paragraph">
66315bd8deadSopenharmony_ci<p>Finally, <em>point mode</em> indicates that the tessellation primitive generator
66325bd8deadSopenharmony_cishould produce one point for each distinct vertex in the subdivided
66335bd8deadSopenharmony_ciprimitive, rather than generating lines or triangles.</p>
66345bd8deadSopenharmony_ci</div>
66355bd8deadSopenharmony_ci<div class="openblock bnf">
66365bd8deadSopenharmony_ci<div class="content">
66375bd8deadSopenharmony_ci<div class="dlist">
66385bd8deadSopenharmony_ci<dl>
66395bd8deadSopenharmony_ci<dt class="hdlist1"><em>point-mode</em>: </dt>
66405bd8deadSopenharmony_ci<dd>
66415bd8deadSopenharmony_ci<p><strong>point_mode</strong></p>
66425bd8deadSopenharmony_ci</dd>
66435bd8deadSopenharmony_ci</dl>
66445bd8deadSopenharmony_ci</div>
66455bd8deadSopenharmony_ci</div>
66465bd8deadSopenharmony_ci</div>
66475bd8deadSopenharmony_ci<div class="paragraph">
66485bd8deadSopenharmony_ci<p>Any or all of these identifiers may be specified one or more times in a
66495bd8deadSopenharmony_cisingle input layout declaration.
66505bd8deadSopenharmony_ciIf primitive mode, vertex spacing, or ordering is declared more than once in
66515bd8deadSopenharmony_cithe tessellation evaluation shaders of a program, all such declarations must
66525bd8deadSopenharmony_ciuse the same identifier.</p>
66535bd8deadSopenharmony_ci</div>
66545bd8deadSopenharmony_ci<div class="paragraph">
66555bd8deadSopenharmony_ci<p>At least one tessellation evaluation shader (compilation unit) in a program
66565bd8deadSopenharmony_cimust declare a primitive mode in its input layout.
66575bd8deadSopenharmony_ciDeclaring vertex spacing, ordering, or point mode identifiers is optional.
66585bd8deadSopenharmony_ciIt is not required that all tessellation evaluation shaders in a program
66595bd8deadSopenharmony_cideclare a primitive mode.
66605bd8deadSopenharmony_ciIf spacing or vertex ordering declarations are omitted, the tessellation
66615bd8deadSopenharmony_ciprimitive generator will use equal spacing or counter-clockwise vertex
66625bd8deadSopenharmony_ciordering, respectively.
66635bd8deadSopenharmony_ciIf a point mode declaration is omitted, the tessellation primitive generator
66645bd8deadSopenharmony_ciwill produce lines or triangles according to the primitive mode.</p>
66655bd8deadSopenharmony_ci</div>
66665bd8deadSopenharmony_ci</div>
66675bd8deadSopenharmony_ci<div class="sect4">
66685bd8deadSopenharmony_ci<h5 id="geometry-shader-inputs">Geometry Shader Inputs</h5>
66695bd8deadSopenharmony_ci<div class="paragraph">
66705bd8deadSopenharmony_ci<p>Additional layout qualifier identifiers for geometry shader inputs include
66715bd8deadSopenharmony_ci<em>primitive</em> identifiers and an <em>invocation count</em> identifier:</p>
66725bd8deadSopenharmony_ci</div>
66735bd8deadSopenharmony_ci<div class="openblock bnf">
66745bd8deadSopenharmony_ci<div class="content">
66755bd8deadSopenharmony_ci<div class="dlist">
66765bd8deadSopenharmony_ci<dl>
66775bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-id</em> : </dt>
66785bd8deadSopenharmony_ci<dd>
66795bd8deadSopenharmony_ci<p><strong>points</strong><br>
66805bd8deadSopenharmony_ci<strong>lines</strong><br>
66815bd8deadSopenharmony_ci<strong>lines_adjacency</strong><br>
66825bd8deadSopenharmony_ci<strong>triangles</strong><br>
66835bd8deadSopenharmony_ci<strong>triangles_adjacency</strong><br>
66845bd8deadSopenharmony_ci<strong>invocations</strong> <strong>=</strong> <em>layout-qualifier-value</em></p>
66855bd8deadSopenharmony_ci</dd>
66865bd8deadSopenharmony_ci</dl>
66875bd8deadSopenharmony_ci</div>
66885bd8deadSopenharmony_ci</div>
66895bd8deadSopenharmony_ci</div>
66905bd8deadSopenharmony_ci<div class="paragraph">
66915bd8deadSopenharmony_ci<p>The identifiers <strong>points</strong>, <strong>lines</strong>, <strong>lines_adjacency</strong>, <strong>triangles</strong>, and
66925bd8deadSopenharmony_ci<strong>triangles_adjacency</strong> are used to specify the type of input primitive
66935bd8deadSopenharmony_ciaccepted by the geometry shader, and only one of these is accepted.
66945bd8deadSopenharmony_ciAt least one geometry shader (compilation unit) in a program must declare
66955bd8deadSopenharmony_cithis input primitive layout, and all geometry shader input layout
66965bd8deadSopenharmony_cideclarations in a program must declare the same layout.
66975bd8deadSopenharmony_ciIt is not required that all geometry shaders in a program declare an input
66985bd8deadSopenharmony_ciprimitive layout.</p>
66995bd8deadSopenharmony_ci</div>
67005bd8deadSopenharmony_ci<div class="paragraph">
67015bd8deadSopenharmony_ci<p>The identifier <strong>invocations</strong> is used to specify the number of times the
67025bd8deadSopenharmony_cigeometry shader executable is invoked for each input primitive received.
67035bd8deadSopenharmony_ciInvocation count declarations are optional.
67045bd8deadSopenharmony_ciIf no invocation count is declared in any geometry shader in a program, the
67055bd8deadSopenharmony_cigeometry shader will be run once for each input primitive.
67065bd8deadSopenharmony_ciIf an invocation count is declared, all such declarations must specify the
67075bd8deadSopenharmony_cisame count.
67085bd8deadSopenharmony_ciIf a shader specifies an invocation count greater than the
67095bd8deadSopenharmony_ciimplementation-dependent maximum, or less than or equal to zero,
67105bd8deadSopenharmony_cia compile-time error results.</p>
67115bd8deadSopenharmony_ci</div>
67125bd8deadSopenharmony_ci<div class="paragraph">
67135bd8deadSopenharmony_ci<p>For example,</p>
67145bd8deadSopenharmony_ci</div>
67155bd8deadSopenharmony_ci<div class="listingblock">
67165bd8deadSopenharmony_ci<div class="content">
67175bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(triangles, invocations = <span class="integer">6</span>) in;</code></pre>
67185bd8deadSopenharmony_ci</div>
67195bd8deadSopenharmony_ci</div>
67205bd8deadSopenharmony_ci<div class="paragraph">
67215bd8deadSopenharmony_ci<p>will establish that all inputs to the geometry shader are triangles and that
67225bd8deadSopenharmony_cithe geometry shader executable is run six times for each triangle processed.</p>
67235bd8deadSopenharmony_ci</div>
67245bd8deadSopenharmony_ci<div class="paragraph">
67255bd8deadSopenharmony_ci<p>All geometry shader input unsized array declarations will be sized by an
67265bd8deadSopenharmony_ciearlier input primitive layout qualifier, when present, as per the following
67275bd8deadSopenharmony_citable.</p>
67285bd8deadSopenharmony_ci</div>
67295bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
67305bd8deadSopenharmony_ci<colgroup>
67315bd8deadSopenharmony_ci<col style="width: 50%;">
67325bd8deadSopenharmony_ci<col style="width: 50%;">
67335bd8deadSopenharmony_ci</colgroup>
67345bd8deadSopenharmony_ci<thead>
67355bd8deadSopenharmony_ci<tr>
67365bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Layout</th>
67375bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Size of Input Arrays</th>
67385bd8deadSopenharmony_ci</tr>
67395bd8deadSopenharmony_ci</thead>
67405bd8deadSopenharmony_ci<tbody>
67415bd8deadSopenharmony_ci<tr>
67425bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>points</strong></p></td>
67435bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">1</p></td>
67445bd8deadSopenharmony_ci</tr>
67455bd8deadSopenharmony_ci<tr>
67465bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>lines</strong></p></td>
67475bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">2</p></td>
67485bd8deadSopenharmony_ci</tr>
67495bd8deadSopenharmony_ci<tr>
67505bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>lines_adjacency</strong></p></td>
67515bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">4</p></td>
67525bd8deadSopenharmony_ci</tr>
67535bd8deadSopenharmony_ci<tr>
67545bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>triangles</strong></p></td>
67555bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">3</p></td>
67565bd8deadSopenharmony_ci</tr>
67575bd8deadSopenharmony_ci<tr>
67585bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>triangles_adjacency</strong></p></td>
67595bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">6</p></td>
67605bd8deadSopenharmony_ci</tr>
67615bd8deadSopenharmony_ci</tbody>
67625bd8deadSopenharmony_ci</table>
67635bd8deadSopenharmony_ci<div class="paragraph">
67645bd8deadSopenharmony_ci<p>The intrinsically declared input array <em>gl_in[]</em> will also be sized by any
67655bd8deadSopenharmony_ciinput primitive-layout declaration.
67665bd8deadSopenharmony_ciHence, the expression</p>
67675bd8deadSopenharmony_ci</div>
67685bd8deadSopenharmony_ci<div class="listingblock">
67695bd8deadSopenharmony_ci<div class="content">
67705bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">gl_in.length()</code></pre>
67715bd8deadSopenharmony_ci</div>
67725bd8deadSopenharmony_ci</div>
67735bd8deadSopenharmony_ci<div class="paragraph">
67745bd8deadSopenharmony_ci<p>will return the value from the table above.</p>
67755bd8deadSopenharmony_ci</div>
67765bd8deadSopenharmony_ci<div class="paragraph">
67775bd8deadSopenharmony_ci<p>For inputs declared without an array size, including intrinsically declared
67785bd8deadSopenharmony_ciinputs (i.e., <em>gl_in</em>), a layout must be declared before any use of the
67795bd8deadSopenharmony_cimethod <strong>length</strong>() or other any array use that requires the array size to be
67805bd8deadSopenharmony_ciknown.</p>
67815bd8deadSopenharmony_ci</div>
67825bd8deadSopenharmony_ci<div class="paragraph">
67835bd8deadSopenharmony_ci<p>It is a compile-time error if a layout declaration&#8217;s array size (from the
67845bd8deadSopenharmony_citable above) does not match all the explicit array sizes specified in
67855bd8deadSopenharmony_cideclarations of an input variables in the same shader.
67865bd8deadSopenharmony_ciThe following includes examples of compile-time errors:</p>
67875bd8deadSopenharmony_ci</div>
67885bd8deadSopenharmony_ci<div class="listingblock">
67895bd8deadSopenharmony_ci<div class="content">
67905bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="comment">// code sequence within one shader...</span>
67915bd8deadSopenharmony_ciin vec4 Color1[];     <span class="comment">// legal, size still unknown</span>
67925bd8deadSopenharmony_ciin vec4 Color2[<span class="integer">2</span>];    <span class="comment">// legal, size is 2</span>
67935bd8deadSopenharmony_ciin vec4 Color3[<span class="integer">3</span>];    <span class="comment">// illegal, input sizes are inconsistent</span>
67945bd8deadSopenharmony_cilayout(lines) in;     <span class="comment">// legal for Color2, input size is 2, matching Color2</span>
67955bd8deadSopenharmony_ciin vec4 Color4[<span class="integer">3</span>];    <span class="comment">// illegal, contradicts layout of lines</span>
67965bd8deadSopenharmony_cilayout(lines) in;     <span class="comment">// legal, matches other layout() declaration</span>
67975bd8deadSopenharmony_cilayout(triangles) in; <span class="comment">// illegal, does not match earlier layout() declaration</span></code></pre>
67985bd8deadSopenharmony_ci</div>
67995bd8deadSopenharmony_ci</div>
68005bd8deadSopenharmony_ci<div class="paragraph">
68015bd8deadSopenharmony_ci<p>It is a link-time error if not all provided sizes (sized input arrays and
68025bd8deadSopenharmony_cilayout size) match across all geometry shaders in a program.</p>
68035bd8deadSopenharmony_ci</div>
68045bd8deadSopenharmony_ci</div>
68055bd8deadSopenharmony_ci<div class="sect4">
68065bd8deadSopenharmony_ci<h5 id="fragment-shader-inputs">Fragment Shader Inputs</h5>
68075bd8deadSopenharmony_ci<div class="paragraph">
68085bd8deadSopenharmony_ci<p>Additional fragment layout qualifier identifiers include the following for
68095bd8deadSopenharmony_ci<em>gl_FragCoord</em> :</p>
68105bd8deadSopenharmony_ci</div>
68115bd8deadSopenharmony_ci<div class="openblock bnf">
68125bd8deadSopenharmony_ci<div class="content">
68135bd8deadSopenharmony_ci<div class="dlist">
68145bd8deadSopenharmony_ci<dl>
68155bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-id</em> : </dt>
68165bd8deadSopenharmony_ci<dd>
68175bd8deadSopenharmony_ci<p><strong>origin_upper_left</strong><br>
68185bd8deadSopenharmony_ci<strong>pixel_center_integer</strong></p>
68195bd8deadSopenharmony_ci</dd>
68205bd8deadSopenharmony_ci</dl>
68215bd8deadSopenharmony_ci</div>
68225bd8deadSopenharmony_ci</div>
68235bd8deadSopenharmony_ci</div>
68245bd8deadSopenharmony_ci<div class="paragraph">
68255bd8deadSopenharmony_ci<p>By default, <em>gl_FragCoord</em> in OpenGL assumes a lower-left origin for window
68265bd8deadSopenharmony_cicoordinates and assumes pixel centers are located at half-pixel coordinates.
68275bd8deadSopenharmony_ciFor example, the (<em>x, y</em>) location (0.5, 0.5) is returned for the
68285bd8deadSopenharmony_cilower-left-most pixel in a window.
68295bd8deadSopenharmony_ciThe origin can be changed by redeclaring <em>gl_FragCoord</em> with the
68305bd8deadSopenharmony_ci<strong>origin_upper_left</strong> qualifier, moving the origin of <em>gl_FragCoord</em> to the
68315bd8deadSopenharmony_ciupper left of the window, with <em>y</em> increasing in value toward the bottom of
68325bd8deadSopenharmony_cithe window.
68335bd8deadSopenharmony_ciThe values returned can also be shifted by half a pixel in both <em>x</em> and <em>y</em>
68345bd8deadSopenharmony_ciby <strong>pixel_center_integer</strong> so it appears the pixels are centered at whole
68355bd8deadSopenharmony_cinumber pixel offsets.
68365bd8deadSopenharmony_ciThis moves the (<em>x</em>, <em>y</em>) value returned by <em>gl_FragCoord</em> of (0.5, 0.5) by
68375bd8deadSopenharmony_cidefault, to (0.0, 0.0) with <strong>pixel_center_integer</strong>.</p>
68385bd8deadSopenharmony_ci</div>
68395bd8deadSopenharmony_ci<div class="paragraph">
68405bd8deadSopenharmony_ci<p>Targeting Vulkan will assume and require an upper-left origin for <em>gl_FragCoord</em>
68415bd8deadSopenharmony_ciwith pixel centers located at half-pixel coordinates.
68425bd8deadSopenharmony_ciThis origin can be explicitly set by redeclaring <em>gl_FragCoord</em> with the
68435bd8deadSopenharmony_ci<strong>origin_upper_left</strong> identifier.</p>
68445bd8deadSopenharmony_ci</div>
68455bd8deadSopenharmony_ci<div class="paragraph">
68465bd8deadSopenharmony_ci<p>Redeclarations are done as follows</p>
68475bd8deadSopenharmony_ci</div>
68485bd8deadSopenharmony_ci<div class="listingblock">
68495bd8deadSopenharmony_ci<div class="content">
68505bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">in vec4 gl_FragCoord; <span class="comment">// redeclaration that changes nothing is allowed</span>
68515bd8deadSopenharmony_ci
68525bd8deadSopenharmony_ci<span class="comment">// All the following are allowed redeclaration that change behavior</span>
68535bd8deadSopenharmony_cilayout(origin_upper_left) in vec4 gl_FragCoord;
68545bd8deadSopenharmony_cilayout(pixel_center_integer) in vec4 gl_FragCoord;
68555bd8deadSopenharmony_cilayout(origin_upper_left, pixel_center_integer) in vec4 gl_FragCoord;</code></pre>
68565bd8deadSopenharmony_ci</div>
68575bd8deadSopenharmony_ci</div>
68585bd8deadSopenharmony_ci<div class="paragraph">
68595bd8deadSopenharmony_ci<p>If <em>gl_FragCoord</em> is redeclared in any fragment shader in a program, it must
68605bd8deadSopenharmony_cibe redeclared in all the fragment shaders in that program that have a static
68615bd8deadSopenharmony_ciuse <em>gl_FragCoord</em>.
68625bd8deadSopenharmony_ciAll redeclarations of <em>gl_FragCoord in all fragment shaders in a single
68635bd8deadSopenharmony_ciprogram must have the same set of qualifiers.
68645bd8deadSopenharmony_ciWithin any shader, the first redeclarations of _glFragCoord</em> must appear
68655bd8deadSopenharmony_cibefore any use of <em>gl_FragCoord</em>.
68665bd8deadSopenharmony_ciThe built-in <em>gl_FragCoord</em> is only predeclared in fragment shaders, so
68675bd8deadSopenharmony_ciredeclaring it in any other shader language results in a compile-time error.</p>
68685bd8deadSopenharmony_ci</div>
68695bd8deadSopenharmony_ci<div class="paragraph">
68705bd8deadSopenharmony_ci<p>Redeclaring <em>glFragCoord</em> with <strong>origin_upper_left</strong> and/or
68715bd8deadSopenharmony_ci<strong>pixel_center_integer</strong> qualifiers only affects <em>gl_FragCoord.x</em> and
68725bd8deadSopenharmony_ci<em>gl_FragCoord.y</em>.
68735bd8deadSopenharmony_ciIt has no effect on rasterization, transformation, or any other part of the
68745bd8deadSopenharmony_ciAPI pipeline or language features.</p>
68755bd8deadSopenharmony_ci</div>
68765bd8deadSopenharmony_ci<div class="paragraph">
68775bd8deadSopenharmony_ci<p>Fragment shaders allow the following layout qualifier on <strong>in</strong> only (not with
68785bd8deadSopenharmony_civariable declarations):</p>
68795bd8deadSopenharmony_ci</div>
68805bd8deadSopenharmony_ci<div class="openblock bnf">
68815bd8deadSopenharmony_ci<div class="content">
68825bd8deadSopenharmony_ci<div class="dlist">
68835bd8deadSopenharmony_ci<dl>
68845bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-id</em> : </dt>
68855bd8deadSopenharmony_ci<dd>
68865bd8deadSopenharmony_ci<p><strong>early_fragment_tests</strong></p>
68875bd8deadSopenharmony_ci</dd>
68885bd8deadSopenharmony_ci</dl>
68895bd8deadSopenharmony_ci</div>
68905bd8deadSopenharmony_ci</div>
68915bd8deadSopenharmony_ci</div>
68925bd8deadSopenharmony_ci<div class="paragraph">
68935bd8deadSopenharmony_ci<p>to request that fragment tests be performed before fragment shader
68945bd8deadSopenharmony_ciexecution, as described in section 15.2.4 &#8220;Early Fragment Tests&#8221; of the
68955bd8deadSopenharmony_ci<a href="#references">OpenGL Specification</a>.</p>
68965bd8deadSopenharmony_ci</div>
68975bd8deadSopenharmony_ci<div class="paragraph">
68985bd8deadSopenharmony_ci<p>For example,</p>
68995bd8deadSopenharmony_ci</div>
69005bd8deadSopenharmony_ci<div class="listingblock">
69015bd8deadSopenharmony_ci<div class="content">
69025bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(early_fragment_tests) in;</code></pre>
69035bd8deadSopenharmony_ci</div>
69045bd8deadSopenharmony_ci</div>
69055bd8deadSopenharmony_ci<div class="paragraph">
69065bd8deadSopenharmony_ci<p>Specifying this will make per-fragment tests be performed before fragment
69075bd8deadSopenharmony_cishader execution.
69085bd8deadSopenharmony_ciIf this is not declared, per-fragment tests will be performed after fragment
69095bd8deadSopenharmony_cishader execution.
69105bd8deadSopenharmony_ciOnly one fragment shader (compilation unit) need declare this, though more
69115bd8deadSopenharmony_cithan one can.
69125bd8deadSopenharmony_ciIf at least one declares this, then it is enabled.</p>
69135bd8deadSopenharmony_ci</div>
69145bd8deadSopenharmony_ci</div>
69155bd8deadSopenharmony_ci<div class="sect4">
69165bd8deadSopenharmony_ci<h5 id="compute-shader-inputs">Compute Shader Inputs</h5>
69175bd8deadSopenharmony_ci<div class="paragraph">
69185bd8deadSopenharmony_ci<p>There are no layout location qualifiers for compute shader inputs.</p>
69195bd8deadSopenharmony_ci</div>
69205bd8deadSopenharmony_ci<div class="paragraph">
69215bd8deadSopenharmony_ci<p>Layout qualifier identifiers for compute shader inputs are the workgroup
69225bd8deadSopenharmony_cisize qualifiers:</p>
69235bd8deadSopenharmony_ci</div>
69245bd8deadSopenharmony_ci<div class="openblock bnf">
69255bd8deadSopenharmony_ci<div class="content">
69265bd8deadSopenharmony_ci<div class="dlist">
69275bd8deadSopenharmony_ci<dl>
69285bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-id</em> : </dt>
69295bd8deadSopenharmony_ci<dd>
69305bd8deadSopenharmony_ci<p><strong>local_size_x</strong> <strong>=</strong> <em>layout-qualifier-value</em><br>
69315bd8deadSopenharmony_ci<strong>local_size_y</strong> <strong>=</strong> <em>layout-qualifier-value</em><br>
69325bd8deadSopenharmony_ci<strong>local_size_z</strong> <strong>=</strong> <em>layout-qualifier-value</em></p>
69335bd8deadSopenharmony_ci</dd>
69345bd8deadSopenharmony_ci</dl>
69355bd8deadSopenharmony_ci</div>
69365bd8deadSopenharmony_ci</div>
69375bd8deadSopenharmony_ci</div>
69385bd8deadSopenharmony_ci<div class="paragraph">
69395bd8deadSopenharmony_ci<p>The <strong>local_size_x</strong>, <strong>local_size_y</strong>, and <strong>local_size_z</strong> qualifiers are used
69405bd8deadSopenharmony_cito declare a fixed workgroup size by the compute shader in the first,
69415bd8deadSopenharmony_cisecond, and third dimension, respectively.
69425bd8deadSopenharmony_ciIf a shader does not specify a size for one of the dimensions, that
69435bd8deadSopenharmony_cidimension will have a size of 1.</p>
69445bd8deadSopenharmony_ci</div>
69455bd8deadSopenharmony_ci<div class="paragraph">
69465bd8deadSopenharmony_ci<p>For example, the following declaration in a compute shader</p>
69475bd8deadSopenharmony_ci</div>
69485bd8deadSopenharmony_ci<div class="listingblock">
69495bd8deadSopenharmony_ci<div class="content">
69505bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(local_size_x = <span class="integer">32</span>, local_size_y = <span class="integer">32</span>) in;</code></pre>
69515bd8deadSopenharmony_ci</div>
69525bd8deadSopenharmony_ci</div>
69535bd8deadSopenharmony_ci<div class="paragraph">
69545bd8deadSopenharmony_ci<p>is used to declare a two-dimensional compute shader with a workgroup size of 32
69555bd8deadSopenharmony_ciX 32 elements, which is equivalent to a three-dimensional compute shader
69565bd8deadSopenharmony_ciwhere the third dimension has size one.</p>
69575bd8deadSopenharmony_ci</div>
69585bd8deadSopenharmony_ci<div class="paragraph">
69595bd8deadSopenharmony_ci<p>As another example, the declaration</p>
69605bd8deadSopenharmony_ci</div>
69615bd8deadSopenharmony_ci<div class="listingblock">
69625bd8deadSopenharmony_ci<div class="content">
69635bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(local_size_x = <span class="integer">8</span>) in;</code></pre>
69645bd8deadSopenharmony_ci</div>
69655bd8deadSopenharmony_ci</div>
69665bd8deadSopenharmony_ci<div class="paragraph">
69675bd8deadSopenharmony_ci<p>effectively specifies that a one-dimensional compute shader is being
69685bd8deadSopenharmony_cicompiled, and its size is 8 elements.</p>
69695bd8deadSopenharmony_ci</div>
69705bd8deadSopenharmony_ci<div class="paragraph">
69715bd8deadSopenharmony_ci<p>If the fixed workgroup size of the shader in any dimension is less than
69725bd8deadSopenharmony_cior equal to zero or greater than the maximum size supported by the
69735bd8deadSopenharmony_ciimplementation for that dimension, a compile-time error results.
69745bd8deadSopenharmony_ciAlso, if such a layout qualifier is declared more than once in the same
69755bd8deadSopenharmony_cishader, all those declarations must set the same set of workgroup
69765bd8deadSopenharmony_cisizes and set them to the same values; otherwise a compile-time error
69775bd8deadSopenharmony_ciresults.
69785bd8deadSopenharmony_ciIf multiple compute shaders attached to a single program object declare a
69795bd8deadSopenharmony_cifixed workgroup size, the declarations must be identical; otherwise a
69805bd8deadSopenharmony_cilink-time error results.</p>
69815bd8deadSopenharmony_ci</div>
69825bd8deadSopenharmony_ci<div class="paragraph">
69835bd8deadSopenharmony_ci<p>Furthermore, if a program object contains any compute shaders, at least one
69845bd8deadSopenharmony_cimust contain an input layout qualifier specifying a fixed workgroup size
69855bd8deadSopenharmony_cifor the program, or a link-time error will occur.</p>
69865bd8deadSopenharmony_ci</div>
69875bd8deadSopenharmony_ci</div>
69885bd8deadSopenharmony_ci</div>
69895bd8deadSopenharmony_ci<div class="sect3">
69905bd8deadSopenharmony_ci<h4 id="output-layout-qualifiers">4.4.2. Output Layout Qualifiers</h4>
69915bd8deadSopenharmony_ci<div class="paragraph">
69925bd8deadSopenharmony_ci<p>Some output layout qualifiers apply to all shader stages and some apply only
69935bd8deadSopenharmony_cito specific stages.
69945bd8deadSopenharmony_ciThe latter are discussed in separate sections below.</p>
69955bd8deadSopenharmony_ci</div>
69965bd8deadSopenharmony_ci<div class="paragraph">
69975bd8deadSopenharmony_ci<p>As with input layout qualifiers, all shaders except compute shaders allow
69985bd8deadSopenharmony_ci<strong>location</strong> layout qualifiers on output variable declarations, output block
69995bd8deadSopenharmony_cideclarations, and output block member declarations.
70005bd8deadSopenharmony_ciOf these, variables and block members (but not blocks) additionally allow
70015bd8deadSopenharmony_cithe <strong>component</strong> layout qualifier.</p>
70025bd8deadSopenharmony_ci</div>
70035bd8deadSopenharmony_ci<div class="openblock bnf">
70045bd8deadSopenharmony_ci<div class="content">
70055bd8deadSopenharmony_ci<div class="dlist">
70065bd8deadSopenharmony_ci<dl>
70075bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-id</em> : </dt>
70085bd8deadSopenharmony_ci<dd>
70095bd8deadSopenharmony_ci<p><strong>location</strong> <strong>=</strong> <em>layout-qualifier-value</em><br>
70105bd8deadSopenharmony_ci<strong>component</strong> <strong>=</strong> <em>layout-qualifier-value</em></p>
70115bd8deadSopenharmony_ci</dd>
70125bd8deadSopenharmony_ci</dl>
70135bd8deadSopenharmony_ci</div>
70145bd8deadSopenharmony_ci</div>
70155bd8deadSopenharmony_ci</div>
70165bd8deadSopenharmony_ci<div class="paragraph">
70175bd8deadSopenharmony_ci<p>The usage and rules for applying the <strong>location</strong> qualifier
70185bd8deadSopenharmony_ciand the <strong>component</strong> qualifier
70195bd8deadSopenharmony_cito blocks and structures are exactly as described in
70205bd8deadSopenharmony_ci&#8220;<a href="#input-layout-qualifiers">Input Layout Qualifiers</a>&#8221;.
70215bd8deadSopenharmony_ciAdditionally, for fragment shader outputs, if two variables are placed
70225bd8deadSopenharmony_ciwithin the same location, they must have the same underlying type
70235bd8deadSopenharmony_ci(floating-point or integer).
70245bd8deadSopenharmony_ciNo component aliasing of output variables or members is allowed.</p>
70255bd8deadSopenharmony_ci</div>
70265bd8deadSopenharmony_ci<div class="paragraph">
70275bd8deadSopenharmony_ci<p>Fragment shaders allow an additional <strong>index</strong> output layout qualifier:</p>
70285bd8deadSopenharmony_ci</div>
70295bd8deadSopenharmony_ci<div class="openblock bnf">
70305bd8deadSopenharmony_ci<div class="content">
70315bd8deadSopenharmony_ci<div class="dlist">
70325bd8deadSopenharmony_ci<dl>
70335bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-id</em> : </dt>
70345bd8deadSopenharmony_ci<dd>
70355bd8deadSopenharmony_ci<p><strong>index</strong> <strong>=</strong> <em>layout-qualifier-value</em></p>
70365bd8deadSopenharmony_ci</dd>
70375bd8deadSopenharmony_ci</dl>
70385bd8deadSopenharmony_ci</div>
70395bd8deadSopenharmony_ci</div>
70405bd8deadSopenharmony_ci</div>
70415bd8deadSopenharmony_ci<div class="paragraph">
70425bd8deadSopenharmony_ci<p>Each of these qualifiers may appear at most once.
70435bd8deadSopenharmony_ciIf <strong>index</strong> is specified, <strong>location</strong> must also be specified.
70445bd8deadSopenharmony_ciIf <strong>index</strong> is not specified, the value 0 is used.
70455bd8deadSopenharmony_ciFor example, in a fragment shader,</p>
70465bd8deadSopenharmony_ci</div>
70475bd8deadSopenharmony_ci<div class="listingblock">
70485bd8deadSopenharmony_ci<div class="content">
70495bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(location = <span class="integer">3</span>) out vec4 color;</code></pre>
70505bd8deadSopenharmony_ci</div>
70515bd8deadSopenharmony_ci</div>
70525bd8deadSopenharmony_ci<div class="paragraph">
70535bd8deadSopenharmony_ci<p>will establish that the fragment shader output <em>color</em> is assigned to
70545bd8deadSopenharmony_cifragment color 3 as the first (index zero) input to the blend equation.
70555bd8deadSopenharmony_ciAnd,</p>
70565bd8deadSopenharmony_ci</div>
70575bd8deadSopenharmony_ci<div class="listingblock">
70585bd8deadSopenharmony_ci<div class="content">
70595bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(location = <span class="integer">3</span>, index = <span class="integer">1</span>) out vec4 factor;</code></pre>
70605bd8deadSopenharmony_ci</div>
70615bd8deadSopenharmony_ci</div>
70625bd8deadSopenharmony_ci<div class="paragraph">
70635bd8deadSopenharmony_ci<p>will establish that the fragment shader output <em>factor</em> is assigned to
70645bd8deadSopenharmony_cifragment color 3 as the second (index one) input to the blend equation.</p>
70655bd8deadSopenharmony_ci</div>
70665bd8deadSopenharmony_ci<div class="paragraph">
70675bd8deadSopenharmony_ci<p>For fragment shader outputs, the location
70685bd8deadSopenharmony_ciand index specify
70695bd8deadSopenharmony_cithe color output number
70705bd8deadSopenharmony_ciand index
70715bd8deadSopenharmony_cireceiving the values of the output.
70725bd8deadSopenharmony_ciFor outputs of all other shader stages, the location specifies a vector
70735bd8deadSopenharmony_cinumber that can be used to match against inputs in a subsequent shader
70745bd8deadSopenharmony_cistage, even if that shader is in a different program object.</p>
70755bd8deadSopenharmony_ci</div>
70765bd8deadSopenharmony_ci<div class="paragraph">
70775bd8deadSopenharmony_ci<p>If a declared output is a scalar or vector type other than <strong>dvec3</strong> or
70785bd8deadSopenharmony_ci<strong>dvec4</strong>, it will consume a single location.
70795bd8deadSopenharmony_ciOutputs of type <strong>dvec3</strong> or <strong>dvec4</strong> will consume two consecutive locations.
70805bd8deadSopenharmony_ciOutputs of type <strong>double</strong> and <strong>dvec2</strong> will consume only a single location, in
70815bd8deadSopenharmony_ciall stages.</p>
70825bd8deadSopenharmony_ci</div>
70835bd8deadSopenharmony_ci<div class="paragraph">
70845bd8deadSopenharmony_ci<p>If the declared output is an array, it will be assigned consecutive
70855bd8deadSopenharmony_cilocations starting with the location specified.
70865bd8deadSopenharmony_ciFor example,</p>
70875bd8deadSopenharmony_ci</div>
70885bd8deadSopenharmony_ci<div class="listingblock">
70895bd8deadSopenharmony_ci<div class="content">
70905bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(location = <span class="integer">2</span>) out vec4 colors[<span class="integer">3</span>];</code></pre>
70915bd8deadSopenharmony_ci</div>
70925bd8deadSopenharmony_ci</div>
70935bd8deadSopenharmony_ci<div class="paragraph">
70945bd8deadSopenharmony_ci<p>will establish that <em>colors</em> is assigned to vector location numbers 2, 3,
70955bd8deadSopenharmony_ciand 4.</p>
70965bd8deadSopenharmony_ci</div>
70975bd8deadSopenharmony_ci<div class="paragraph">
70985bd8deadSopenharmony_ci<p>If the declared output is an <em>n</em> × <em>m</em>
70995bd8deadSopenharmony_cimatrix, it will be assigned multiple locations starting with the location
71005bd8deadSopenharmony_cispecified.
71015bd8deadSopenharmony_ciThe number of locations assigned will be the same as for an <em>n</em>-element
71025bd8deadSopenharmony_ciarray of <em>m</em>-component vectors.</p>
71035bd8deadSopenharmony_ci</div>
71045bd8deadSopenharmony_ci<div class="paragraph">
71055bd8deadSopenharmony_ci<p>If the declared output is a structure, its members will be assigned
71065bd8deadSopenharmony_ciconsecutive locations in the order of declaration, with the first member
71075bd8deadSopenharmony_ciassigned the location specified for the structure.
71085bd8deadSopenharmony_ciThe number of locations consumed by a structure member is determined by
71095bd8deadSopenharmony_ciapplying the rules above recursively as though the structure member were
71105bd8deadSopenharmony_cideclared as an output variable of the same type.</p>
71115bd8deadSopenharmony_ci</div>
71125bd8deadSopenharmony_ci<div class="paragraph">
71135bd8deadSopenharmony_ci<p><strong>location</strong> layout qualifiers may be used on output variables declared as
71145bd8deadSopenharmony_cistructures.
71155bd8deadSopenharmony_ciHowever, it is a compile-time error to use a <strong>location</strong> qualifier on a
71165bd8deadSopenharmony_cistructure member.
71175bd8deadSopenharmony_ciLocation layout qualifiers may be used on output blocks and output block
71185bd8deadSopenharmony_cimembers.</p>
71195bd8deadSopenharmony_ci</div>
71205bd8deadSopenharmony_ci<div class="paragraph">
71215bd8deadSopenharmony_ci<p>The number of output locations available to a shader is limited.
71225bd8deadSopenharmony_ciFor fragment shaders, the limit is the advertised number of draw buffers.</p>
71235bd8deadSopenharmony_ci</div>
71245bd8deadSopenharmony_ci<div class="paragraph">
71255bd8deadSopenharmony_ci<p>For all other shaders, the limit is implementation-dependent and must be no
71265bd8deadSopenharmony_ciless than one fourth of the advertised maximum output component count
71275bd8deadSopenharmony_ci(compute shaders have no outputs).
71285bd8deadSopenharmony_ciA program will fail to link if any attached shader uses a location greater
71295bd8deadSopenharmony_cithan or equal to the number of supported locations, unless device-dependent
71305bd8deadSopenharmony_cioptimizations are able to make the program fit within available hardware
71315bd8deadSopenharmony_ciresources.</p>
71325bd8deadSopenharmony_ci</div>
71335bd8deadSopenharmony_ci<div class="paragraph">
71345bd8deadSopenharmony_ci<p>Compile-time errors may also be given if at compile time it is known the
71355bd8deadSopenharmony_cilink will fail.
71365bd8deadSopenharmony_ciA negative output location will result in a compile-time error.
71375bd8deadSopenharmony_ciIt is also a compile-time error if a fragment shader sets a layout index to
71385bd8deadSopenharmony_ciless than 0 or greater than 1.</p>
71395bd8deadSopenharmony_ci</div>
71405bd8deadSopenharmony_ci<div class="paragraph">
71415bd8deadSopenharmony_ci<p>It is a compile-time or link-time error if any of the following occur:</p>
71425bd8deadSopenharmony_ci</div>
71435bd8deadSopenharmony_ci<div class="ulist">
71445bd8deadSopenharmony_ci<ul>
71455bd8deadSopenharmony_ci<li>
71465bd8deadSopenharmony_ci<p>any two fragment shader output variables are assigned to the same
71475bd8deadSopenharmony_cilocation and index.</p>
71485bd8deadSopenharmony_ci</li>
71495bd8deadSopenharmony_ci<li>
71505bd8deadSopenharmony_ci<p>if any two output variables from the same vertex, tessellation or
71515bd8deadSopenharmony_cigeometry shader stage are assigned to the same location.</p>
71525bd8deadSopenharmony_ci</li>
71535bd8deadSopenharmony_ci</ul>
71545bd8deadSopenharmony_ci</div>
71555bd8deadSopenharmony_ci<div class="paragraph">
71565bd8deadSopenharmony_ci<p>For fragment shader outputs, locations can be assigned using either a
71575bd8deadSopenharmony_ci<strong>layout</strong> qualifier or via the OpenGL API.</p>
71585bd8deadSopenharmony_ci</div>
71595bd8deadSopenharmony_ci<div class="paragraph">
71605bd8deadSopenharmony_ci<p>For all shader types, a program will fail to link if explicit location
71615bd8deadSopenharmony_ciassignments leave the linker unable to find space for other variables
71625bd8deadSopenharmony_ciwithout explicit assignments.</p>
71635bd8deadSopenharmony_ci</div>
71645bd8deadSopenharmony_ci<div class="paragraph">
71655bd8deadSopenharmony_ci<p>If an output variable with no location or index assigned in the shader text
71665bd8deadSopenharmony_cihas a location specified through the OpenGL API, the API-assigned
71675bd8deadSopenharmony_cilocation will be used.
71685bd8deadSopenharmony_ciOtherwise, such variables will be assigned a location by the linker.
71695bd8deadSopenharmony_ciAll such assignments will have a color index of zero.
71705bd8deadSopenharmony_ciSee section 15.2 &#8220;Shader Execution&#8221; of the <a href="#references">OpenGL Specification</a> for
71715bd8deadSopenharmony_cimore details.
71725bd8deadSopenharmony_ciA link-time error will occur if an output variable is declared in multiple
71735bd8deadSopenharmony_cishaders of the same language with conflicting location or index values.</p>
71745bd8deadSopenharmony_ci</div>
71755bd8deadSopenharmony_ci<div class="paragraph">
71765bd8deadSopenharmony_ci<p>For the purposes of determining if a non-fragment output matches an input
71775bd8deadSopenharmony_cifrom a subsequent shader stage, the <strong>location</strong> layout qualifier (if any)
71785bd8deadSopenharmony_cimust match.</p>
71795bd8deadSopenharmony_ci</div>
71805bd8deadSopenharmony_ci<div class="sect4">
71815bd8deadSopenharmony_ci<h5 id="transform-feedback-layout-qualifiers">Transform Feedback Layout Qualifiers</h5>
71825bd8deadSopenharmony_ci<div class="paragraph">
71835bd8deadSopenharmony_ci<p>The vertex, tessellation, and geometry stages allow shaders to control
71845bd8deadSopenharmony_citransform feedback.
71855bd8deadSopenharmony_ciWhen doing this, shaders will dictate which transform feedback buffers are
71865bd8deadSopenharmony_ciin use, which output variables will be written to which buffers, and how
71875bd8deadSopenharmony_cieach buffer is laid out.
71885bd8deadSopenharmony_ciTo accomplish this, shaders allow the following layout qualifier identifiers
71895bd8deadSopenharmony_cion output declarations:</p>
71905bd8deadSopenharmony_ci</div>
71915bd8deadSopenharmony_ci<div class="openblock bnf">
71925bd8deadSopenharmony_ci<div class="content">
71935bd8deadSopenharmony_ci<div class="dlist">
71945bd8deadSopenharmony_ci<dl>
71955bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-id</em> : </dt>
71965bd8deadSopenharmony_ci<dd>
71975bd8deadSopenharmony_ci<p><strong>xfb_buffer</strong> <strong>=</strong> <em>layout-qualifier-value</em><br>
71985bd8deadSopenharmony_ci<strong>xfb_offset</strong> <strong>=</strong> <em>layout-qualifier-value</em><br>
71995bd8deadSopenharmony_ci<strong>xfb_stride</strong> <strong>=</strong> <em>layout-qualifier-value</em></p>
72005bd8deadSopenharmony_ci</dd>
72015bd8deadSopenharmony_ci</dl>
72025bd8deadSopenharmony_ci</div>
72035bd8deadSopenharmony_ci</div>
72045bd8deadSopenharmony_ci</div>
72055bd8deadSopenharmony_ci<div class="paragraph">
72065bd8deadSopenharmony_ci<p>Any shader making any static use (after preprocessing) of any of these
72075bd8deadSopenharmony_ci<strong>xfb_</strong> qualifiers will cause the shader to be in a transform feedback
72085bd8deadSopenharmony_cicapturing mode and hence responsible for describing the transform feedback
72095bd8deadSopenharmony_cisetup.
72105bd8deadSopenharmony_ciThis mode will capture any output selected by <strong>xfb_offset</strong>, directly or
72115bd8deadSopenharmony_ciindirectly, to a transform feedback buffer.</p>
72125bd8deadSopenharmony_ci</div>
72135bd8deadSopenharmony_ci<div class="paragraph">
72145bd8deadSopenharmony_ci<p>The <strong>xfb_buffer</strong> qualifier specifies which transform feedback buffer will
72155bd8deadSopenharmony_cicapture outputs selected with <strong>xfb_offset</strong>.
72165bd8deadSopenharmony_ciThe <strong>xfb_buffer</strong> qualifier can be applied to the qualifier <strong>out</strong>, to output
72175bd8deadSopenharmony_civariables, to output blocks, and to output block members.
72185bd8deadSopenharmony_ciShaders in the transform feedback capturing mode have an initial global
72195bd8deadSopenharmony_cidefault of</p>
72205bd8deadSopenharmony_ci</div>
72215bd8deadSopenharmony_ci<div class="listingblock">
72225bd8deadSopenharmony_ci<div class="content">
72235bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(xfb_buffer = <span class="integer">0</span>) out;</code></pre>
72245bd8deadSopenharmony_ci</div>
72255bd8deadSopenharmony_ci</div>
72265bd8deadSopenharmony_ci<div class="paragraph">
72275bd8deadSopenharmony_ci<p>This default can be changed by declaring a different buffer with
72285bd8deadSopenharmony_ci<strong>xfb_buffer</strong> on the interface qualifier <strong>out</strong>.
72295bd8deadSopenharmony_ciThis is the only way the global default can be changed.
72305bd8deadSopenharmony_ciWhen a variable or output block is declared without an <strong>xfb_buffer</strong>
72315bd8deadSopenharmony_ciqualifier, it inherits the global default buffer.
72325bd8deadSopenharmony_ciWhen a variable or output block is declared with an <strong>xfb_buffer</strong> qualifier,
72335bd8deadSopenharmony_ciit has that declared buffer.
72345bd8deadSopenharmony_ciAll members of a block inherit the block&#8217;s buffer.
72355bd8deadSopenharmony_ciA member is allowed to declare an <strong>xfb_buffer</strong>, but it must match the buffer
72365bd8deadSopenharmony_ciinherited from its block, or a compile-time error results.</p>
72375bd8deadSopenharmony_ci</div>
72385bd8deadSopenharmony_ci<div class="listingblock">
72395bd8deadSopenharmony_ci<div class="content">
72405bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(xfb_buffer=<span class="integer">2</span>, xfb_offset=<span class="integer">0</span>) out block { <span class="comment">// block's buffer is 2</span>
72415bd8deadSopenharmony_ci    layout(xfb_buffer = <span class="integer">2</span>) vec4 v; <span class="comment">// okay, matches the inherited 2</span>
72425bd8deadSopenharmony_ci    layout(xfb_buffer = <span class="integer">3</span>) vec4 u; <span class="comment">// ERROR, mismatched buffer</span>
72435bd8deadSopenharmony_ci    vec4 w; <span class="comment">// inherited</span>
72445bd8deadSopenharmony_ci};
72455bd8deadSopenharmony_cilayout(xfb_offset=<span class="integer">16</span>) out vec4 t;  <span class="comment">// initial default is buffer 0</span>
72465bd8deadSopenharmony_cilayout(xfb_buffer=<span class="integer">1</span>) out;          <span class="comment">// new global default of 1</span>
72475bd8deadSopenharmony_ciout block {                        <span class="comment">// block has buffer 1</span>
72485bd8deadSopenharmony_ci    vec4 x;                        <span class="comment">// x has buffer 1 (not captured)</span>
72495bd8deadSopenharmony_ci    layout(xfb_buffer = <span class="integer">1</span>) vec4 y; <span class="comment">// okay (not captured)</span>
72505bd8deadSopenharmony_ci    layout(xfb_buffer = <span class="integer">0</span>) vec4 z; <span class="comment">// ERROR, mismatched buffer</span>
72515bd8deadSopenharmony_ci};
72525bd8deadSopenharmony_cilayout(xfb_offset=<span class="integer">0</span>) out vec4 g;   <span class="comment">// g has buffer 1</span>
72535bd8deadSopenharmony_cilayout(xfb_buffer=<span class="integer">2</span>) out vec4 h;   <span class="comment">// does not change global default</span>
72545bd8deadSopenharmony_cilayout(xfb_offset=<span class="integer">16</span>) out vec4 j;  <span class="comment">// j has buffer 1</span></code></pre>
72555bd8deadSopenharmony_ci</div>
72565bd8deadSopenharmony_ci</div>
72575bd8deadSopenharmony_ci<div class="paragraph">
72585bd8deadSopenharmony_ci<p>Note this means all members of a block that go to a transform feedback
72595bd8deadSopenharmony_cibuffer will go to the same buffer.</p>
72605bd8deadSopenharmony_ci</div>
72615bd8deadSopenharmony_ci<div class="paragraph">
72625bd8deadSopenharmony_ci<p>When a block is declared as an array, all members of block array-element 0
72635bd8deadSopenharmony_ciare captured, as previously described, by the declared or inherited
72645bd8deadSopenharmony_ci<strong>xfb_buffer</strong>.
72655bd8deadSopenharmony_ciGenerally, an array of size <em>N</em> of blocks is captured by <em>N</em> consecutive
72665bd8deadSopenharmony_cibuffers, with all members of block array-element <em>E</em> captured by buffer <em>B</em>,
72675bd8deadSopenharmony_ciwhere <em>B</em> equals the declared or inherited <strong>xfb_buffer</strong> plus <em>E</em>.</p>
72685bd8deadSopenharmony_ci</div>
72695bd8deadSopenharmony_ci<div class="paragraph">
72705bd8deadSopenharmony_ci<p>It is a compile-time or link-time error to specify an <strong>xfb_buffer</strong>,
72715bd8deadSopenharmony_ciincluding any additional buffers needed to capture an arrays of blocks, that
72725bd8deadSopenharmony_ciis less than zero or greater than or equal to the implementation-dependent
72735bd8deadSopenharmony_ciconstant <em>gl_MaxTransformFeedbackBuffers</em>.</p>
72745bd8deadSopenharmony_ci</div>
72755bd8deadSopenharmony_ci<div class="paragraph">
72765bd8deadSopenharmony_ci<p>The <strong>xfb_offset</strong> qualifier assigns a byte offset within a transform feedback
72775bd8deadSopenharmony_cibuffer.
72785bd8deadSopenharmony_ciOnly variables, block members, or blocks can be qualified with <strong>xfb_offset</strong>.
72795bd8deadSopenharmony_ciIf a block is qualified with <strong>xfb_offset</strong>, all its members are assigned
72805bd8deadSopenharmony_citransform feedback buffer offsets.
72815bd8deadSopenharmony_ciIf a block is not qualified with <strong>xfb_offset</strong>, any members of that block not
72825bd8deadSopenharmony_ciqualified with an <strong>xfb_offset</strong> will not be assigned transform feedback
72835bd8deadSopenharmony_cibuffer offsets.
72845bd8deadSopenharmony_ciOnly variables and block members that are assigned offsets will be captured
72855bd8deadSopenharmony_ci(thus, a proper subset of a block can be captured).
72865bd8deadSopenharmony_ciEach time such a variable or block member is written in a shader, the
72875bd8deadSopenharmony_ciwritten value is captured at the assigned offset.
72885bd8deadSopenharmony_ciIf such a block member or variable is not written during a shader
72895bd8deadSopenharmony_ciinvocation, the buffer contents at the assigned offset will be undefined.
72905bd8deadSopenharmony_ciEven if there are no static writes to a variable or member that is assigned
72915bd8deadSopenharmony_cia transform feedback offset, the space is still allocated in the buffer and
72925bd8deadSopenharmony_cistill affects the stride.</p>
72935bd8deadSopenharmony_ci</div>
72945bd8deadSopenharmony_ci<div class="paragraph">
72955bd8deadSopenharmony_ci<p>Variables and block members qualified with <strong>xfb_offset</strong> can be scalars,
72965bd8deadSopenharmony_civectors, matrices, structures, and (sized) arrays of these.
72975bd8deadSopenharmony_ciThe offset must be a multiple of the size of the first component of the
72985bd8deadSopenharmony_cifirst qualified variable or block member, or a compile-time error results.
72995bd8deadSopenharmony_ciFurther, if applied to an aggregate containing a <strong>double</strong>, the offset must
73005bd8deadSopenharmony_cialso be a multiple of 8, and the space taken in the buffer will be a
73015bd8deadSopenharmony_cimultiple of 8.
73025bd8deadSopenharmony_ciThe given offset applies to the first component of the first member of the
73035bd8deadSopenharmony_ciqualified entity.
73045bd8deadSopenharmony_ciThen, within the qualified entity, subsequent components are each assigned,
73055bd8deadSopenharmony_ciin order, to the next available offset aligned to a multiple of that
73065bd8deadSopenharmony_cicomponent&#8217;s size.
73075bd8deadSopenharmony_ciAggregate types are flattened down to the component level to get this
73085bd8deadSopenharmony_cisequence of components.
73095bd8deadSopenharmony_ciIt is a compile-time error to apply <strong>xfb_offset</strong> to the declaration of an
73105bd8deadSopenharmony_ciunsized array.</p>
73115bd8deadSopenharmony_ci</div>
73125bd8deadSopenharmony_ci<div class="paragraph">
73135bd8deadSopenharmony_ci<p>No aliasing in output buffers is allowed: It is a compile-time or link-time
73145bd8deadSopenharmony_cierror to specify variables with overlapping transform feedback offsets.</p>
73155bd8deadSopenharmony_ci</div>
73165bd8deadSopenharmony_ci<div class="paragraph">
73175bd8deadSopenharmony_ci<p>The <strong>xfb_stride</strong> qualifier specifies how many bytes are consumed by each
73185bd8deadSopenharmony_cicaptured vertex.
73195bd8deadSopenharmony_ciIt applies to the transform feedback buffer for that declaration, whether it
73205bd8deadSopenharmony_ciis inherited or explicitly declared.
73215bd8deadSopenharmony_ciIt can be applied to variables, blocks, block members, or just the qualifier
73225bd8deadSopenharmony_ci<strong>out</strong>.
73235bd8deadSopenharmony_ciIf the buffer is capturing any outputs with double-precision components, the
73245bd8deadSopenharmony_cistride must be a multiple of 8, otherwise it must be a multiple of 4, or a
73255bd8deadSopenharmony_cicompile-time or link-time error results.
73265bd8deadSopenharmony_ciIt is a compile-time or link-time error to have any <strong>xfb_offset</strong> that
73275bd8deadSopenharmony_cioverflows <strong>xfb_stride</strong>, whether stated on declarations before or after the
73285bd8deadSopenharmony_ci<strong>xfb_stride</strong>, or in different compilation units.
73295bd8deadSopenharmony_ciWhile <strong>xfb_stride</strong> can be declared multiple times for the same buffer, it is
73305bd8deadSopenharmony_cia compile-time or link-time error to have different values specified for the
73315bd8deadSopenharmony_cistride for the same buffer.</p>
73325bd8deadSopenharmony_ci</div>
73335bd8deadSopenharmony_ci<div class="paragraph">
73345bd8deadSopenharmony_ci<p>For example:</p>
73355bd8deadSopenharmony_ci</div>
73365bd8deadSopenharmony_ci<div class="listingblock">
73375bd8deadSopenharmony_ci<div class="content">
73385bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="comment">// buffer 1 has 32-byte stride</span>
73395bd8deadSopenharmony_cilayout(xfb_buffer = <span class="integer">1</span>, xfb_stride = <span class="integer">32</span>) out;
73405bd8deadSopenharmony_ci
73415bd8deadSopenharmony_ci<span class="comment">// same as previous example; order within layout does not matter</span>
73425bd8deadSopenharmony_cilayout(xfb_stride = <span class="integer">32</span>, xfb_buffer = <span class="integer">1</span>) out;
73435bd8deadSopenharmony_ci
73445bd8deadSopenharmony_ci<span class="comment">// everything in this block goes to buffer 0</span>
73455bd8deadSopenharmony_cilayout(xfb_buffer = <span class="integer">0</span>, xfb_stride = <span class="integer">32</span>) out block1 {
73465bd8deadSopenharmony_ci    layout(xfb_offset = <span class="integer">0</span>) vec4 a;  <span class="comment">// a goes to byte offset 0 of buffer 0</span>
73475bd8deadSopenharmony_ci    layout(xfb_offset = <span class="integer">16</span>) vec4 b; <span class="comment">// b goes to offset 16 of buffer 0</span>
73485bd8deadSopenharmony_ci};
73495bd8deadSopenharmony_ci
73505bd8deadSopenharmony_cilayout(xfb_buffer = <span class="integer">3</span>, xfb_offset = <span class="integer">12</span>) out block2 {
73515bd8deadSopenharmony_ci    vec4 v;  <span class="comment">// v will be written to byte offsets 12 through 27 of buffer</span>
73525bd8deadSopenharmony_ci    <span class="predefined-type">float</span> u; <span class="comment">// u will be written to offset 28</span>
73535bd8deadSopenharmony_ci    layout(xfb_offset = <span class="integer">40</span>) vec4 w;
73545bd8deadSopenharmony_ci    vec4 x;  <span class="comment">// x will be written to offset 56, the next available offset</span>
73555bd8deadSopenharmony_ci};
73565bd8deadSopenharmony_ci
73575bd8deadSopenharmony_cilayout(xfb_buffer = <span class="integer">2</span>, xfb_stride = <span class="integer">32</span>) out block3 {
73585bd8deadSopenharmony_ci    layout(xfb_offset = <span class="integer">12</span>) vec3 c;
73595bd8deadSopenharmony_ci    layout(xfb_offset = <span class="integer">24</span>) vec3 d; <span class="comment">// ERROR, requires stride of 36</span>
73605bd8deadSopenharmony_ci    layout(xfb_offset = <span class="integer">0</span>) vec3 g;  <span class="comment">// okay, increasing order not required</span>
73615bd8deadSopenharmony_ci};</code></pre>
73625bd8deadSopenharmony_ci</div>
73635bd8deadSopenharmony_ci</div>
73645bd8deadSopenharmony_ci<div class="paragraph">
73655bd8deadSopenharmony_ci<p>When no <strong>xfb_stride</strong> is specified for a buffer, the stride of the buffer
73665bd8deadSopenharmony_ciwill be the smallest needed to hold the variable placed at the highest
73675bd8deadSopenharmony_cioffset, including any required padding.
73685bd8deadSopenharmony_ciFor example:</p>
73695bd8deadSopenharmony_ci</div>
73705bd8deadSopenharmony_ci<div class="listingblock">
73715bd8deadSopenharmony_ci<div class="content">
73725bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="comment">// if there no other declarations for buffer 3, it has stride 32</span>
73735bd8deadSopenharmony_cilayout(xfb_buffer = <span class="integer">3</span>) out block4 {
73745bd8deadSopenharmony_ci    layout(xfb_offset = <span class="integer">0</span>) vec4 e;
73755bd8deadSopenharmony_ci    layout(xfb_offset = <span class="integer">16</span>) vec4 f;
73765bd8deadSopenharmony_ci};</code></pre>
73775bd8deadSopenharmony_ci</div>
73785bd8deadSopenharmony_ci</div>
73795bd8deadSopenharmony_ci<div class="paragraph">
73805bd8deadSopenharmony_ci<p>The resulting stride (implicit or explicit), when divided by 4, must be less
73815bd8deadSopenharmony_cithan or equal to the implementation-dependent constant
73825bd8deadSopenharmony_ci<em>gl_MaxTransformFeedbackInterleavedComponents</em>.</p>
73835bd8deadSopenharmony_ci</div>
73845bd8deadSopenharmony_ci</div>
73855bd8deadSopenharmony_ci<div class="sect4">
73865bd8deadSopenharmony_ci<h5 id="tessellation-control-outputs">Tessellation Control Outputs</h5>
73875bd8deadSopenharmony_ci<div class="paragraph">
73885bd8deadSopenharmony_ci<p>Other than for the transform feedback layout qualifiers, tessellation
73895bd8deadSopenharmony_cicontrol shaders allow output layout qualifiers only on the interface
73905bd8deadSopenharmony_ciqualifier <strong>out</strong>, not on an output block, block member, or variable
73915bd8deadSopenharmony_cideclaration.
73925bd8deadSopenharmony_ciThe output layout qualifier identifiers allowed for tessellation control
73935bd8deadSopenharmony_cishaders are:</p>
73945bd8deadSopenharmony_ci</div>
73955bd8deadSopenharmony_ci<div class="openblock bnf">
73965bd8deadSopenharmony_ci<div class="content">
73975bd8deadSopenharmony_ci<div class="dlist">
73985bd8deadSopenharmony_ci<dl>
73995bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-id</em> : </dt>
74005bd8deadSopenharmony_ci<dd>
74015bd8deadSopenharmony_ci<p><strong>vertices</strong> <strong>=</strong> <em>layout-qualifier-value</em></p>
74025bd8deadSopenharmony_ci</dd>
74035bd8deadSopenharmony_ci</dl>
74045bd8deadSopenharmony_ci</div>
74055bd8deadSopenharmony_ci</div>
74065bd8deadSopenharmony_ci</div>
74075bd8deadSopenharmony_ci<div class="paragraph">
74085bd8deadSopenharmony_ci<p>The identifier <strong>vertices</strong> specifies the number of vertices in the output
74095bd8deadSopenharmony_cipatch produced by the tessellation control shader, which also specifies the
74105bd8deadSopenharmony_cinumber of times the tessellation control shader is invoked.
74115bd8deadSopenharmony_ciIt is a compile- or link-time error for the output vertex count to be less
74125bd8deadSopenharmony_cithan or equal to zero, or greater than the implementation-dependent maximum
74135bd8deadSopenharmony_cipatch size.</p>
74145bd8deadSopenharmony_ci</div>
74155bd8deadSopenharmony_ci<div class="paragraph">
74165bd8deadSopenharmony_ci<p>The intrinsically declared tessellation control output array <em>gl_out[]</em> will
74175bd8deadSopenharmony_cialso be sized by any output layout declaration.
74185bd8deadSopenharmony_ciHence, the expression</p>
74195bd8deadSopenharmony_ci</div>
74205bd8deadSopenharmony_ci<div class="listingblock">
74215bd8deadSopenharmony_ci<div class="content">
74225bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">gl_out.length()</code></pre>
74235bd8deadSopenharmony_ci</div>
74245bd8deadSopenharmony_ci</div>
74255bd8deadSopenharmony_ci<div class="paragraph">
74265bd8deadSopenharmony_ci<p>will return the output patch vertex count specified in a previous output
74275bd8deadSopenharmony_cilayout qualifier.
74285bd8deadSopenharmony_ciFor outputs declared without an array size, including intrinsically declared
74295bd8deadSopenharmony_cioutputs (i.e., <em>gl_out</em>), a layout must be declared before any use of the
74305bd8deadSopenharmony_cimethod <strong>length</strong>() or other array use that requires its size to be known.</p>
74315bd8deadSopenharmony_ci</div>
74325bd8deadSopenharmony_ci<div class="paragraph">
74335bd8deadSopenharmony_ci<p>It is a compile-time error if the output patch vertex count specified in an
74345bd8deadSopenharmony_cioutput layout qualifier does not match the array size specified in any
74355bd8deadSopenharmony_cioutput variable declaration in the same shader.</p>
74365bd8deadSopenharmony_ci</div>
74375bd8deadSopenharmony_ci<div class="paragraph">
74385bd8deadSopenharmony_ci<p>All tessellation control shader layout declarations in a program must
74395bd8deadSopenharmony_cispecify the same output patch vertex count.
74405bd8deadSopenharmony_ciThere must be at least one layout qualifier specifying an output patch
74415bd8deadSopenharmony_civertex count in any program containing tessellation control shaders;
74425bd8deadSopenharmony_cihowever, such a declaration is not required in all tessellation control
74435bd8deadSopenharmony_cishaders.</p>
74445bd8deadSopenharmony_ci</div>
74455bd8deadSopenharmony_ci</div>
74465bd8deadSopenharmony_ci<div class="sect4">
74475bd8deadSopenharmony_ci<h5 id="geometry-outputs">Geometry Outputs</h5>
74485bd8deadSopenharmony_ci<div class="paragraph">
74495bd8deadSopenharmony_ci<p>Geometry shaders can have three additional types of output layout
74505bd8deadSopenharmony_ciidentifiers: an output <em>primitive type</em>, a maximum output <em>vertex count</em>,
74515bd8deadSopenharmony_ciand per-output <em>stream</em> numbers.
74525bd8deadSopenharmony_ciThe primitive type and vertex count identifiers are allowed only on the
74535bd8deadSopenharmony_ciinterface qualifier <strong>out</strong>, not on an output block, block member, or variable
74545bd8deadSopenharmony_cideclaration.
74555bd8deadSopenharmony_ciThe stream identifier is allowed on the interface qualifier <strong>out</strong>, on output
74565bd8deadSopenharmony_ciblocks, and on variable declarations.</p>
74575bd8deadSopenharmony_ci</div>
74585bd8deadSopenharmony_ci<div class="paragraph">
74595bd8deadSopenharmony_ci<p>The layout qualifier identifiers for geometry shader outputs are</p>
74605bd8deadSopenharmony_ci</div>
74615bd8deadSopenharmony_ci<div class="openblock bnf">
74625bd8deadSopenharmony_ci<div class="content">
74635bd8deadSopenharmony_ci<div class="dlist">
74645bd8deadSopenharmony_ci<dl>
74655bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-id</em> : </dt>
74665bd8deadSopenharmony_ci<dd>
74675bd8deadSopenharmony_ci<p><strong>points</strong><br>
74685bd8deadSopenharmony_ci<strong>line_strip</strong><br>
74695bd8deadSopenharmony_ci<strong>triangle_strip</strong><br>
74705bd8deadSopenharmony_ci<strong>max_vertices</strong> <strong>=</strong> <em>layout-qualifier-value</em><br>
74715bd8deadSopenharmony_ci<strong>stream</strong> <strong>=</strong> <em>layout-qualifier-value</em></p>
74725bd8deadSopenharmony_ci</dd>
74735bd8deadSopenharmony_ci</dl>
74745bd8deadSopenharmony_ci</div>
74755bd8deadSopenharmony_ci</div>
74765bd8deadSopenharmony_ci</div>
74775bd8deadSopenharmony_ci<div class="paragraph">
74785bd8deadSopenharmony_ci<p>The primitive type identifiers <strong>points</strong>, <strong>line_strip</strong>, and <strong>triangle_strip</strong>
74795bd8deadSopenharmony_ciare used to specify the type of output primitive produced by the geometry
74805bd8deadSopenharmony_cishader, and only one of these is accepted.
74815bd8deadSopenharmony_ciAt least one geometry shader (compilation unit) in a program must declare an
74825bd8deadSopenharmony_cioutput primitive type, and all geometry shader output primitive type
74835bd8deadSopenharmony_cideclarations in a program must declare the same primitive type.
74845bd8deadSopenharmony_ciIt is not required that all geometry shaders in a program declare an output
74855bd8deadSopenharmony_ciprimitive type.</p>
74865bd8deadSopenharmony_ci</div>
74875bd8deadSopenharmony_ci<div class="paragraph">
74885bd8deadSopenharmony_ci<p>The vertex count identifier <strong>max_vertices</strong> is used to specify the maximum
74895bd8deadSopenharmony_cinumber of vertices the shader will ever emit in a single invocation.
74905bd8deadSopenharmony_ciAt least one geometry shader (compilation unit) in a program must declare a
74915bd8deadSopenharmony_cimaximum output vertex count, and all geometry shader output vertex count
74925bd8deadSopenharmony_cideclarations in a program must declare the same count.
74935bd8deadSopenharmony_ciIt is not required that all geometry shaders in a program declare a count.</p>
74945bd8deadSopenharmony_ci</div>
74955bd8deadSopenharmony_ci<div class="paragraph">
74965bd8deadSopenharmony_ci<p>In this example,</p>
74975bd8deadSopenharmony_ci</div>
74985bd8deadSopenharmony_ci<div class="listingblock">
74995bd8deadSopenharmony_ci<div class="content">
75005bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(triangle_strip, max_vertices = <span class="integer">60</span>) out; <span class="comment">// order does not matter</span>
75015bd8deadSopenharmony_cilayout(max_vertices = <span class="integer">60</span>) out;  <span class="comment">// redeclaration okay</span>
75025bd8deadSopenharmony_cilayout(triangle_strip) out;     <span class="comment">// redeclaration okay</span>
75035bd8deadSopenharmony_cilayout(points) out;             <span class="comment">// error, contradicts triangle_strip</span>
75045bd8deadSopenharmony_cilayout(max_vertices = <span class="integer">30</span>) out;  <span class="comment">// error, contradicts 60</span></code></pre>
75055bd8deadSopenharmony_ci</div>
75065bd8deadSopenharmony_ci</div>
75075bd8deadSopenharmony_ci<div class="paragraph">
75085bd8deadSopenharmony_ci<p>all outputs from the geometry shader are triangles and at most 60 vertices
75095bd8deadSopenharmony_ciwill be emitted by the shader.
75105bd8deadSopenharmony_ciIt is an error for the maximum number of vertices to be greater than
75115bd8deadSopenharmony_ci<em>gl_MaxGeometryOutputVertices</em>.</p>
75125bd8deadSopenharmony_ci</div>
75135bd8deadSopenharmony_ci<div class="paragraph">
75145bd8deadSopenharmony_ci<p>The identifier <strong>stream</strong> is used to specify that a geometry shader output
75155bd8deadSopenharmony_civariable or block is associated with a particular vertex stream (numbered
75165bd8deadSopenharmony_cibeginning with zero).
75175bd8deadSopenharmony_ciA default stream number may be declared at global scope by qualifying
75185bd8deadSopenharmony_ciinterface qualifier <strong>out</strong> as in this example:</p>
75195bd8deadSopenharmony_ci</div>
75205bd8deadSopenharmony_ci<div class="listingblock">
75215bd8deadSopenharmony_ci<div class="content">
75225bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(stream = <span class="integer">1</span>) out;</code></pre>
75235bd8deadSopenharmony_ci</div>
75245bd8deadSopenharmony_ci</div>
75255bd8deadSopenharmony_ci<div class="paragraph">
75265bd8deadSopenharmony_ci<p>The stream number specified in such a declaration replaces any previous
75275bd8deadSopenharmony_cidefault and applies to all subsequent block and variable declarations until
75285bd8deadSopenharmony_cia new default is established.
75295bd8deadSopenharmony_ciThe initial default stream number is zero.</p>
75305bd8deadSopenharmony_ci</div>
75315bd8deadSopenharmony_ci<div class="paragraph">
75325bd8deadSopenharmony_ci<p>Each output block or non-block output variable is associated with a vertex
75335bd8deadSopenharmony_cistream.
75345bd8deadSopenharmony_ciIf the block or variable is declared with the stream identifier, it is
75355bd8deadSopenharmony_ciassociated with the specified stream; otherwise, it is associated with the
75365bd8deadSopenharmony_cicurrent default stream.
75375bd8deadSopenharmony_ciA block member may be declared with a stream identifier, but the specified
75385bd8deadSopenharmony_cistream must match the stream associated with the containing block.
75395bd8deadSopenharmony_ciOne example:</p>
75405bd8deadSopenharmony_ci</div>
75415bd8deadSopenharmony_ci<div class="listingblock">
75425bd8deadSopenharmony_ci<div class="content">
75435bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(stream=<span class="integer">1</span>) out;           <span class="comment">// default is now stream 1</span>
75445bd8deadSopenharmony_ciout vec4 var1;                  <span class="comment">// var1 gets default stream (1)</span>
75455bd8deadSopenharmony_cilayout(stream=<span class="integer">2</span>) out Block1 {   <span class="comment">// &quot;Block1&quot; belongs to stream 2</span>
75465bd8deadSopenharmony_ci    layout(stream=<span class="integer">2</span>) vec4 var2; <span class="comment">// redundant block member stream decl</span>
75475bd8deadSopenharmony_ci    layout(stream=<span class="integer">3</span>) vec2 var3; <span class="comment">// ILLEGAL (must match block stream)</span>
75485bd8deadSopenharmony_ci    vec3 var4;                  <span class="comment">// belongs to stream 2</span>
75495bd8deadSopenharmony_ci};
75505bd8deadSopenharmony_cilayout(stream=<span class="integer">0</span>) out;           <span class="comment">// default is now stream 0</span>
75515bd8deadSopenharmony_ciout vec4 var5;                  <span class="comment">// var5 gets default stream (0)</span>
75525bd8deadSopenharmony_ciout Block2 {                    <span class="comment">// &quot;Block2&quot; gets default stream (0)</span>
75535bd8deadSopenharmony_ci    vec4 var6;
75545bd8deadSopenharmony_ci};
75555bd8deadSopenharmony_cilayout(stream=<span class="integer">3</span>) out vec4 var7; <span class="comment">// var7 belongs to stream 3</span></code></pre>
75565bd8deadSopenharmony_ci</div>
75575bd8deadSopenharmony_ci</div>
75585bd8deadSopenharmony_ci<div class="paragraph">
75595bd8deadSopenharmony_ci<p>Each vertex emitted by the geometry shader is assigned to a specific stream,
75605bd8deadSopenharmony_ciand the attributes of the emitted vertex are taken from the set of output
75615bd8deadSopenharmony_ciblocks and variables assigned to the targeted stream.
75625bd8deadSopenharmony_ciAfter each vertex is emitted, the values of all output variables become
75635bd8deadSopenharmony_ciundefined.
75645bd8deadSopenharmony_ciAdditionally, the output variables associated with each vertex stream may
75655bd8deadSopenharmony_cishare storage.
75665bd8deadSopenharmony_ciWriting to an output variable associated with one stream may overwrite
75675bd8deadSopenharmony_cioutput variables associated with any other stream.
75685bd8deadSopenharmony_ciWhen emitting each vertex, a geometry shader should write to all outputs
75695bd8deadSopenharmony_ciassociated with the stream to which the vertex will be emitted and to no
75705bd8deadSopenharmony_cioutputs associated with any other stream.</p>
75715bd8deadSopenharmony_ci</div>
75725bd8deadSopenharmony_ci<div class="paragraph">
75735bd8deadSopenharmony_ci<p>If a geometry shader output block or variable is declared more than once,
75745bd8deadSopenharmony_ciall such declarations must associate the variable with the same vertex
75755bd8deadSopenharmony_cistream.
75765bd8deadSopenharmony_ciIf any stream declaration specifies a non-existent stream number, the shader
75775bd8deadSopenharmony_ciwill fail to compile.</p>
75785bd8deadSopenharmony_ci</div>
75795bd8deadSopenharmony_ci<div class="paragraph">
75805bd8deadSopenharmony_ci<p>Built-in geometry shader outputs are always associated with vertex stream
75815bd8deadSopenharmony_cizero.</p>
75825bd8deadSopenharmony_ci</div>
75835bd8deadSopenharmony_ci<div class="paragraph">
75845bd8deadSopenharmony_ci<p>All geometry shader output layout declarations in a program must declare the
75855bd8deadSopenharmony_cisame layout and same value for <strong>max_vertices</strong>.
75865bd8deadSopenharmony_ciIf geometry shaders are in a program, there must be at least one geometry
75875bd8deadSopenharmony_cioutput layout declaration somewhere in that
75885bd8deadSopenharmony_ciprogram, but not all geometry
75895bd8deadSopenharmony_cishaders (compilation units) are required to declare it.</p>
75905bd8deadSopenharmony_ci</div>
75915bd8deadSopenharmony_ci</div>
75925bd8deadSopenharmony_ci<div class="sect4">
75935bd8deadSopenharmony_ci<h5 id="fragment-outputs">Fragment Outputs</h5>
75945bd8deadSopenharmony_ci<div class="paragraph">
75955bd8deadSopenharmony_ci<p>The built-in fragment shader variable <em>gl_FragDepth</em> may be redeclared using
75965bd8deadSopenharmony_cione of the following layout qualifiers.</p>
75975bd8deadSopenharmony_ci</div>
75985bd8deadSopenharmony_ci<div class="openblock bnf">
75995bd8deadSopenharmony_ci<div class="content">
76005bd8deadSopenharmony_ci<div class="dlist">
76015bd8deadSopenharmony_ci<dl>
76025bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-id</em> : </dt>
76035bd8deadSopenharmony_ci<dd>
76045bd8deadSopenharmony_ci<p><strong>depth_any</strong><br>
76055bd8deadSopenharmony_ci<strong>depth_greater</strong><br>
76065bd8deadSopenharmony_ci<strong>depth_less</strong><br>
76075bd8deadSopenharmony_ci<strong>depth_unchanged</strong></p>
76085bd8deadSopenharmony_ci</dd>
76095bd8deadSopenharmony_ci</dl>
76105bd8deadSopenharmony_ci</div>
76115bd8deadSopenharmony_ci</div>
76125bd8deadSopenharmony_ci</div>
76135bd8deadSopenharmony_ci<div class="paragraph">
76145bd8deadSopenharmony_ci<p>The layout qualifier for <em>gl_FragDepth</em> constrains intentions of the final
76155bd8deadSopenharmony_civalue of <em>gl_FragDepth</em> written by any shader invocation.
76165bd8deadSopenharmony_ciGL implementations are allowed to perform optimizations assuming that the
76175bd8deadSopenharmony_cidepth test fails (or passes) for a given fragment if all values of
76185bd8deadSopenharmony_ci<em>gl_FragDepth</em> consistent with the layout qualifier would fail (or pass).
76195bd8deadSopenharmony_ciThis potentially includes skipping shader execution if the fragment is
76205bd8deadSopenharmony_cidiscarded because it is occluded and the shader has no side effects.
76215bd8deadSopenharmony_ciIf the final value of <em>gl_FragDepth</em> is inconsistent with its layout
76225bd8deadSopenharmony_ciqualifier, the result of the depth test for the corresponding fragment is
76235bd8deadSopenharmony_ciundefined.
76245bd8deadSopenharmony_ciHowever, no error will be generated in this case.
76255bd8deadSopenharmony_ciIf the depth test passes and depth writes are enabled, the value written to
76265bd8deadSopenharmony_cithe depth buffer is always the value of <em>gl_FragDepth</em>, whether or not it is
76275bd8deadSopenharmony_ciconsistent with the layout qualifier.</p>
76285bd8deadSopenharmony_ci</div>
76295bd8deadSopenharmony_ci<div class="paragraph">
76305bd8deadSopenharmony_ci<p>By default, <em>gl_FragDepth</em> is qualified as <em>depth_any</em>.
76315bd8deadSopenharmony_ciWhen the layout qualifier for <em>gl_FragDepth</em> is <em>depth_any</em>, the shader
76325bd8deadSopenharmony_cicompiler will note any assignment to <em>gl_FragDepth</em> modifying it in an
76335bd8deadSopenharmony_ciunknown way, and depth testing will always be performed after the shader has
76345bd8deadSopenharmony_ciexecuted.
76355bd8deadSopenharmony_ciWhen the layout qualifier is <em>depth_greater</em>, the GL can assume that the
76365bd8deadSopenharmony_cifinal value of <em>gl_FragDepth</em> is greater than or equal to the fragment&#8217;s
76375bd8deadSopenharmony_ciinterpolated depth value, as given by the <em>z</em> component of <em>gl_FragCoord</em>.
76385bd8deadSopenharmony_ciWhen the layout qualifier is <em>depth_less</em>, the GL can assume that any
76395bd8deadSopenharmony_cimodification of <em>gl_FragDepth</em> will only decrease its value.
76405bd8deadSopenharmony_ciWhen the layout qualifier is <em>depth_unchanged</em>, the shader compiler will
76415bd8deadSopenharmony_cihonor any modification to <em>gl_FragDepth</em>, but the rest of the GL can assume
76425bd8deadSopenharmony_cithat <em>gl_FragDepth</em> is not assigned a new value.</p>
76435bd8deadSopenharmony_ci</div>
76445bd8deadSopenharmony_ci<div class="paragraph">
76455bd8deadSopenharmony_ci<p>Redeclarations of <em>gl_FragDepth</em> are performed as follows:</p>
76465bd8deadSopenharmony_ci</div>
76475bd8deadSopenharmony_ci<div class="listingblock">
76485bd8deadSopenharmony_ci<div class="content">
76495bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="comment">// redeclaration that changes nothing is allowed +</span>
76505bd8deadSopenharmony_ciout <span class="predefined-type">float</span> gl_FragDepth;
76515bd8deadSopenharmony_ci
76525bd8deadSopenharmony_ci<span class="comment">// assume it may be modified in any way</span>
76535bd8deadSopenharmony_cilayout(depth_any) out <span class="predefined-type">float</span> gl_FragDepth;
76545bd8deadSopenharmony_ci
76555bd8deadSopenharmony_ci<span class="comment">// assume it may be modified such that its value will only increase</span>
76565bd8deadSopenharmony_cilayout(depth_greater) out <span class="predefined-type">float</span> gl_FragDepth;
76575bd8deadSopenharmony_ci
76585bd8deadSopenharmony_ci<span class="comment">// assume it may be modified such that its value will only decrease</span>
76595bd8deadSopenharmony_cilayout(depth_less) out <span class="predefined-type">float</span> gl_FragDepth;
76605bd8deadSopenharmony_ci
76615bd8deadSopenharmony_ci<span class="comment">// assume it will not be modified</span>
76625bd8deadSopenharmony_cilayout(depth_unchanged) out <span class="predefined-type">float</span> gl_FragDepth;</code></pre>
76635bd8deadSopenharmony_ci</div>
76645bd8deadSopenharmony_ci</div>
76655bd8deadSopenharmony_ci<div class="paragraph">
76665bd8deadSopenharmony_ci<p>If <em>gl_FragDepth</em> is redeclared in any fragment shader in a program, it must
76675bd8deadSopenharmony_cibe redeclared in all fragment shaders in that program that have static
76685bd8deadSopenharmony_ciassignments to <em>gl_FragDepth</em>.
76695bd8deadSopenharmony_ciAll redeclarations of <em>gl_FragDepth</em> in all fragment shaders in a single
76705bd8deadSopenharmony_ciprogram must have the same set of qualifiers.
76715bd8deadSopenharmony_ciWithin any shader, the first redeclarations of <em>gl_FragDepth</em> must appear
76725bd8deadSopenharmony_cibefore any use of <em>gl_FragDepth</em>.
76735bd8deadSopenharmony_ciThe built-in <em>gl_FragDepth</em> is only predeclared in fragment shaders, so
76745bd8deadSopenharmony_ciredeclaring it in any other shader language results in a compile-time error.</p>
76755bd8deadSopenharmony_ci</div>
76765bd8deadSopenharmony_ci</div>
76775bd8deadSopenharmony_ci</div>
76785bd8deadSopenharmony_ci<div class="sect3">
76795bd8deadSopenharmony_ci<h4 id="uniform-variable-layout-qualifiers">4.4.3. Uniform Variable Layout Qualifiers</h4>
76805bd8deadSopenharmony_ci<div class="paragraph">
76815bd8deadSopenharmony_ci<p>Layout qualifiers can be used for uniform variables and subroutine uniforms.
76825bd8deadSopenharmony_ciThe layout qualifier identifiers for uniform variables and subroutine
76835bd8deadSopenharmony_ciuniforms are:</p>
76845bd8deadSopenharmony_ci</div>
76855bd8deadSopenharmony_ci<div class="openblock bnf">
76865bd8deadSopenharmony_ci<div class="content">
76875bd8deadSopenharmony_ci<div class="dlist">
76885bd8deadSopenharmony_ci<dl>
76895bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-id</em> : </dt>
76905bd8deadSopenharmony_ci<dd>
76915bd8deadSopenharmony_ci<p><strong>location</strong> <strong>=</strong> <em>layout-qualifier-value</em></p>
76925bd8deadSopenharmony_ci</dd>
76935bd8deadSopenharmony_ci</dl>
76945bd8deadSopenharmony_ci</div>
76955bd8deadSopenharmony_ci</div>
76965bd8deadSopenharmony_ci</div>
76975bd8deadSopenharmony_ci<div class="paragraph">
76985bd8deadSopenharmony_ci<p>The location identifier can be used with default-block uniform variables and
76995bd8deadSopenharmony_cisubroutine uniforms.
77005bd8deadSopenharmony_ciThe location specifies the location by which the API can reference
77015bd8deadSopenharmony_cithe uniform and update its value.
77025bd8deadSopenharmony_ciIndividual elements of a uniform array are assigned consecutive locations
77035bd8deadSopenharmony_ciwith the first element taking location <strong>location</strong>.
77045bd8deadSopenharmony_ciDefault-block uniform variable declarations sharing the same location
77055bd8deadSopenharmony_cilinked in the program have to match by name, type, qualifiers and arrayness.
77065bd8deadSopenharmony_ciFor arrays their array dimensionality and array sizes must match.
77075bd8deadSopenharmony_ciFor structs this rule applies recursively to all members.
77085bd8deadSopenharmony_ciNo two subroutine uniform variables can have the same location in the same
77095bd8deadSopenharmony_cishader stage, otherwise a compile-time or link-time error will be generated.
77105bd8deadSopenharmony_ciValid locations for default-block uniform variable locations are in the
77115bd8deadSopenharmony_cirange of 0 to the implementation-defined maximum number of uniform locations
77125bd8deadSopenharmony_ciminus one.
77135bd8deadSopenharmony_ciValid locations for subroutine uniforms are in the range of 0 to the
77145bd8deadSopenharmony_ciimplementation-defined per-stage maximum number of subroutine uniform
77155bd8deadSopenharmony_cilocations minus one.</p>
77165bd8deadSopenharmony_ci</div>
77175bd8deadSopenharmony_ci<div class="paragraph">
77185bd8deadSopenharmony_ci<p>Locations can be assigned to default-block uniform arrays and structures.
77195bd8deadSopenharmony_ciThe first inner-most scalar, vector or matrix member or element takes the
77205bd8deadSopenharmony_cispecified <strong>location</strong> and the compiler assigns the next inner-most member or
77215bd8deadSopenharmony_cielement the next incremental location value.
77225bd8deadSopenharmony_ciEach subsequent inner-most member or element gets incremental locations for
77235bd8deadSopenharmony_cithe entire structure or array.
77245bd8deadSopenharmony_ciThis rule applies to nested structures and arrays and gives each inner-most
77255bd8deadSopenharmony_ciscalar, vector, or matrix member a unique location.
77265bd8deadSopenharmony_ciFor arrays without an explicit size, the size is calculated based on its
77275bd8deadSopenharmony_cistatic usage.
77285bd8deadSopenharmony_ciWhen the linker generates locations for uniforms without an explicit
77295bd8deadSopenharmony_cilocation, it assumes for all uniforms with an explicit location all their
77305bd8deadSopenharmony_ciarray elements and structure members are used and the linker will not
77315bd8deadSopenharmony_cigenerate a conflicting location, even if that element or member is deemed
77325bd8deadSopenharmony_ciunused.</p>
77335bd8deadSopenharmony_ci</div>
77345bd8deadSopenharmony_ci<div class="paragraph">
77355bd8deadSopenharmony_ci<p>When generating SPIR-V for API&#8217;s that accept individual (default block)
77365bd8deadSopenharmony_cinon-opaque uniform variables, it is a compile-time error to not
77375bd8deadSopenharmony_ciinclude a location when declaring them.</p>
77385bd8deadSopenharmony_ci</div>
77395bd8deadSopenharmony_ci<div class="paragraph">
77405bd8deadSopenharmony_ci<p>When targeting Vulkan, the <strong>push_constant</strong> qualifier is used to
77415bd8deadSopenharmony_cideclare an entire block, and represents a set of <em>push constants</em>, as defined
77425bd8deadSopenharmony_ciby the Vulkan API.
77435bd8deadSopenharmony_ciIt is a compile-time error to apply this to anything other than a uniform block
77445bd8deadSopenharmony_cideclaration, or when not targeting Vulkan.
77455bd8deadSopenharmony_ciThe values in the block will be initialized as per the Vulkan API specification.
77465bd8deadSopenharmony_ciA block declared with <code>layout(push_constant)</code> may optionally include an
77475bd8deadSopenharmony_ci<em>instance-name</em>.
77485bd8deadSopenharmony_ciThere can be only one <strong>push_constant</strong> block per stage, or a compile-time or
77495bd8deadSopenharmony_cilink-time error will result.
77505bd8deadSopenharmony_ciA push-constant array can only be indexed with dynamically uniform indices.
77515bd8deadSopenharmony_ciUniform blocks declared with <strong>push_constant</strong> use different resources
77525bd8deadSopenharmony_cithan those without; and are accounted for separately.</p>
77535bd8deadSopenharmony_ci</div>
77545bd8deadSopenharmony_ci</div>
77555bd8deadSopenharmony_ci<div class="sect3">
77565bd8deadSopenharmony_ci<h4 id="subroutine-function-layout-qualifiers">4.4.4. Subroutine Function Layout Qualifiers</h4>
77575bd8deadSopenharmony_ci<div class="paragraph">
77585bd8deadSopenharmony_ci<p>Layout qualifiers can be used for subroutine functions.
77595bd8deadSopenharmony_ciThe layout qualifier identifiers for subroutine functions are:</p>
77605bd8deadSopenharmony_ci</div>
77615bd8deadSopenharmony_ci<div class="openblock bnf">
77625bd8deadSopenharmony_ci<div class="content">
77635bd8deadSopenharmony_ci<div class="dlist">
77645bd8deadSopenharmony_ci<dl>
77655bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-id</em> : </dt>
77665bd8deadSopenharmony_ci<dd>
77675bd8deadSopenharmony_ci<p><strong>index</strong> <strong>=</strong> <em>layout-qualifier-value</em></p>
77685bd8deadSopenharmony_ci</dd>
77695bd8deadSopenharmony_ci</dl>
77705bd8deadSopenharmony_ci</div>
77715bd8deadSopenharmony_ci</div>
77725bd8deadSopenharmony_ci</div>
77735bd8deadSopenharmony_ci<div class="paragraph">
77745bd8deadSopenharmony_ci<p>Each subroutine with an index qualifier in the shader must be given a unique
77755bd8deadSopenharmony_ciindex, otherwise a compile- or link-time error will be generated.
77765bd8deadSopenharmony_ciThe indices must be in the range of 0 to the implementation defined maximum
77775bd8deadSopenharmony_cinumber of subroutines minus one.
77785bd8deadSopenharmony_ciIt is recommended, but not required, that the shader assigns a range of
77795bd8deadSopenharmony_citightly packed <em>index</em> values starting from zero so that the OpenGL
77805bd8deadSopenharmony_cisubroutine function enumeration API returns a non-empty name for all active
77815bd8deadSopenharmony_ciindices.</p>
77825bd8deadSopenharmony_ci</div>
77835bd8deadSopenharmony_ci</div>
77845bd8deadSopenharmony_ci<div class="sect3">
77855bd8deadSopenharmony_ci<h4 id="uniform-and-shader-storage-block-layout-qualifiers">4.4.5. Uniform and Shader Storage Block Layout Qualifiers</h4>
77865bd8deadSopenharmony_ci<div class="paragraph">
77875bd8deadSopenharmony_ci<p>Layout qualifiers can be used for uniform and shader storage blocks, but not
77885bd8deadSopenharmony_cifor non-block uniform declarations.
77895bd8deadSopenharmony_ciThe layout qualifier identifiers (and <strong>shared</strong> keyword) for uniform and
77905bd8deadSopenharmony_cishader storage blocks are:</p>
77915bd8deadSopenharmony_ci</div>
77925bd8deadSopenharmony_ci<div class="openblock bnf">
77935bd8deadSopenharmony_ci<div class="content">
77945bd8deadSopenharmony_ci<div class="dlist">
77955bd8deadSopenharmony_ci<dl>
77965bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-id</em> : </dt>
77975bd8deadSopenharmony_ci<dd>
77985bd8deadSopenharmony_ci<p><strong>shared</strong><br>
77995bd8deadSopenharmony_ci<strong>packed</strong><br>
78005bd8deadSopenharmony_ci<strong>std140</strong><br>
78015bd8deadSopenharmony_ci<strong>std430</strong><br>
78025bd8deadSopenharmony_ci<strong>row_major</strong><br>
78035bd8deadSopenharmony_ci<strong>column_major</strong><br>
78045bd8deadSopenharmony_ci<strong>binding</strong> <strong>=</strong> <em>layout-qualifier-value</em><br>
78055bd8deadSopenharmony_ci<strong>offset</strong> <strong>=</strong> <em>layout-qualifier-value</em><br>
78065bd8deadSopenharmony_ci<strong>align</strong> <strong>=</strong> <em>layout-qualifier-value</em></p>
78075bd8deadSopenharmony_ci</dd>
78085bd8deadSopenharmony_ci</dl>
78095bd8deadSopenharmony_ci</div>
78105bd8deadSopenharmony_ci</div>
78115bd8deadSopenharmony_ci</div>
78125bd8deadSopenharmony_ci<div class="paragraph">
78135bd8deadSopenharmony_ci<p>None of these have any semantic effect at all on the usage of the variables
78145bd8deadSopenharmony_cibeing declared; they only describe how data is laid out in memory.
78155bd8deadSopenharmony_ciFor example, matrix semantics are always column-based, as described in the
78165bd8deadSopenharmony_cirest of this specification, no matter what layout qualifiers are being used.</p>
78175bd8deadSopenharmony_ci</div>
78185bd8deadSopenharmony_ci<div class="paragraph">
78195bd8deadSopenharmony_ci<p>Uniform and shader storage block layout qualifiers can be declared for
78205bd8deadSopenharmony_ciglobal scope, on a single uniform or shader storage block, or on a single
78215bd8deadSopenharmony_ciblock member declaration.</p>
78225bd8deadSopenharmony_ci</div>
78235bd8deadSopenharmony_ci<div class="paragraph">
78245bd8deadSopenharmony_ci<p>Default layouts are established at global scope for uniform blocks as:</p>
78255bd8deadSopenharmony_ci</div>
78265bd8deadSopenharmony_ci<div class="listingblock">
78275bd8deadSopenharmony_ci<div class="content">
78285bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(layout-qualifier-id-list) uniform;</code></pre>
78295bd8deadSopenharmony_ci</div>
78305bd8deadSopenharmony_ci</div>
78315bd8deadSopenharmony_ci<div class="paragraph">
78325bd8deadSopenharmony_ci<p>and for shader storage blocks as:</p>
78335bd8deadSopenharmony_ci</div>
78345bd8deadSopenharmony_ci<div class="listingblock">
78355bd8deadSopenharmony_ci<div class="content">
78365bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(layout-qualifier-id-list) buffer;</code></pre>
78375bd8deadSopenharmony_ci</div>
78385bd8deadSopenharmony_ci</div>
78395bd8deadSopenharmony_ci<div class="paragraph">
78405bd8deadSopenharmony_ci<p>When this is done, the previous default qualification is first inherited and
78415bd8deadSopenharmony_cithen overridden as per the override rules listed below for each qualifier
78425bd8deadSopenharmony_cilisted in the declaration.
78435bd8deadSopenharmony_ciThe result becomes the new default qualification scoped to subsequent
78445bd8deadSopenharmony_ciuniform or shader storage block definitions.</p>
78455bd8deadSopenharmony_ci</div>
78465bd8deadSopenharmony_ci<div class="paragraph">
78475bd8deadSopenharmony_ci<p>The initial state of compilation when generating SPIR-V is as if the
78485bd8deadSopenharmony_cifollowing were declared:</p>
78495bd8deadSopenharmony_ci</div>
78505bd8deadSopenharmony_ci<div class="listingblock">
78515bd8deadSopenharmony_ci<div class="content">
78525bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(std140, column_major) uniform;
78535bd8deadSopenharmony_cilayout(std430, column_major) buffer;</code></pre>
78545bd8deadSopenharmony_ci</div>
78555bd8deadSopenharmony_ci</div>
78565bd8deadSopenharmony_ci<div class="paragraph">
78575bd8deadSopenharmony_ci<p>However, when <strong>push_constant</strong> is declared, the default layout of the
78585bd8deadSopenharmony_cibuffer will be <strong>std430</strong>. There is no method to globally set this default.</p>
78595bd8deadSopenharmony_ci</div>
78605bd8deadSopenharmony_ci<div class="paragraph">
78615bd8deadSopenharmony_ci<p>The initial state of compilation when not generating SPIR-V is as if the
78625bd8deadSopenharmony_cifollowing were declared:</p>
78635bd8deadSopenharmony_ci</div>
78645bd8deadSopenharmony_ci<div class="listingblock">
78655bd8deadSopenharmony_ci<div class="content">
78665bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(shared, column_major) uniform;
78675bd8deadSopenharmony_cilayout(shared, column_major) buffer;</code></pre>
78685bd8deadSopenharmony_ci</div>
78695bd8deadSopenharmony_ci</div>
78705bd8deadSopenharmony_ci<div class="paragraph">
78715bd8deadSopenharmony_ci<p>Uniform and shader storage blocks can be declared with optional layout
78725bd8deadSopenharmony_ciqualifiers, and so can their individual member declarations.
78735bd8deadSopenharmony_ciSuch block layout qualification is scoped only to the content of the block.
78745bd8deadSopenharmony_ciAs with global layout declarations, block layout qualification first
78755bd8deadSopenharmony_ciinherits from the current default qualification and then overrides it.
78765bd8deadSopenharmony_ciSimilarly, individual member layout qualification is scoped just to the
78775bd8deadSopenharmony_cimember declaration, and inherits from and overrides the block&#8217;s
78785bd8deadSopenharmony_ciqualification.</p>
78795bd8deadSopenharmony_ci</div>
78805bd8deadSopenharmony_ci<div class="paragraph">
78815bd8deadSopenharmony_ci<p>The <strong>shared</strong> qualifier overrides only the <strong>std140</strong>, <strong>std430</strong>, and <strong>packed</strong>
78825bd8deadSopenharmony_ciqualifiers; other qualifiers are inherited.
78835bd8deadSopenharmony_ciThe compiler/linker will ensure that multiple programs and programmable
78845bd8deadSopenharmony_cistages containing this definition will share the same memory layout for this
78855bd8deadSopenharmony_ciblock, as long as all arrays are declared with explicit sizes and all
78865bd8deadSopenharmony_cimatrices have matching <strong>row_major</strong> and/or <strong>column_major</strong> qualifications
78875bd8deadSopenharmony_ci(which may come from a declaration outside the block definition).
78885bd8deadSopenharmony_ciThis allows use of the same buffer to back the same block definition across
78895bd8deadSopenharmony_cidifferent programs.
78905bd8deadSopenharmony_ciIt is a compile-time error to use the <strong>shared</strong> qualifier when generating
78915bd8deadSopenharmony_ciSPIR-V.</p>
78925bd8deadSopenharmony_ci</div>
78935bd8deadSopenharmony_ci<div class="paragraph">
78945bd8deadSopenharmony_ci<p>The <strong>packed</strong> qualifier overrides only <strong>std140</strong>, <strong>std430</strong>, and <strong>shared</strong>;
78955bd8deadSopenharmony_ciother qualifiers are inherited.
78965bd8deadSopenharmony_ciWhen <strong>packed</strong> is used, no shareable layout is guaranteed.
78975bd8deadSopenharmony_ciThe compiler and linker can optimize memory use based on what variables
78985bd8deadSopenharmony_ciactively get used and on other criteria.
78995bd8deadSopenharmony_ciOffsets must be queried, as there is no other way of guaranteeing where (and
79005bd8deadSopenharmony_ciwhich) variables reside within the block.</p>
79015bd8deadSopenharmony_ci</div>
79025bd8deadSopenharmony_ci<div class="paragraph">
79035bd8deadSopenharmony_ci<p>It is a link-time error to access the same packed uniform or shader storage
79045bd8deadSopenharmony_ciblock in multiple stages within a program.
79055bd8deadSopenharmony_ciAttempts to access the same packed uniform or shader storage block across
79065bd8deadSopenharmony_ciprograms can result in conflicting member offsets and in undefined values
79075bd8deadSopenharmony_cibeing read.
79085bd8deadSopenharmony_ciHowever, implementations may aid application management of packed blocks by
79095bd8deadSopenharmony_ciusing canonical layouts for packed blocks.
79105bd8deadSopenharmony_ciIt is a compile-time error to use the <strong>packed</strong> qualifier when generating
79115bd8deadSopenharmony_ciSPIR-V.</p>
79125bd8deadSopenharmony_ci</div>
79135bd8deadSopenharmony_ci<div class="paragraph">
79145bd8deadSopenharmony_ci<p>The <strong>std140</strong> and <strong>std430</strong> qualifiers override only the <strong>packed</strong>, <strong>shared</strong>,
79155bd8deadSopenharmony_ci<strong>std140</strong>, and <strong>std430</strong> qualifiers; other qualifiers are inherited.
79165bd8deadSopenharmony_ciThe <strong>std430</strong> qualifier is supported only for shader storage blocks; a shader
79175bd8deadSopenharmony_ciusing the <strong>std430</strong> qualifier on a uniform block will result in
79185bd8deadSopenharmony_cia compile-time error, unless it is also declared with <strong>push_constant</strong>.</p>
79195bd8deadSopenharmony_ci</div>
79205bd8deadSopenharmony_ci<div class="paragraph">
79215bd8deadSopenharmony_ci<p>The layout is explicitly determined by this, as described in section 7.6.2.2
79225bd8deadSopenharmony_ci&#8220;Standard Uniform Block Layout&#8221; of the <a href="#references">OpenGL Specification</a>.
79235bd8deadSopenharmony_ciHence, as in <strong>shared</strong> above, the resulting layout is shareable across
79245bd8deadSopenharmony_ciprograms.</p>
79255bd8deadSopenharmony_ci</div>
79265bd8deadSopenharmony_ci<div class="paragraph">
79275bd8deadSopenharmony_ci<p>Layout qualifiers on member declarations cannot use the <strong>shared</strong>, <strong>packed</strong>,
79285bd8deadSopenharmony_ci<strong>std140</strong>, or <strong>std430</strong> qualifiers.
79295bd8deadSopenharmony_ciThese can only be used at global scope (without an object) or on a block
79305bd8deadSopenharmony_cideclaration, or a compile-time error results.</p>
79315bd8deadSopenharmony_ci</div>
79325bd8deadSopenharmony_ci<div class="paragraph">
79335bd8deadSopenharmony_ci<p>The <strong>row_major</strong> and <strong>column_major</strong> qualifiers only affect the layout of
79345bd8deadSopenharmony_cimatrices, including all matrices contained in structures and arrays they are
79355bd8deadSopenharmony_ciapplied to, to all depths of nesting.
79365bd8deadSopenharmony_ciThese qualifiers can be applied to other types, but will have no effect.</p>
79375bd8deadSopenharmony_ci</div>
79385bd8deadSopenharmony_ci<div class="paragraph">
79395bd8deadSopenharmony_ci<p>The <strong>row_major</strong> qualifier overrides only the <strong>column_major</strong> qualifier; other
79405bd8deadSopenharmony_ciqualifiers are inherited.
79415bd8deadSopenharmony_ciElements within a matrix row will be contiguous in memory.</p>
79425bd8deadSopenharmony_ci</div>
79435bd8deadSopenharmony_ci<div class="paragraph">
79445bd8deadSopenharmony_ci<p>The <strong>column_major</strong> qualifier overrides only the <strong>row_major</strong> qualifier; other
79455bd8deadSopenharmony_ciqualifiers are inherited.
79465bd8deadSopenharmony_ciElements within a matrix column will be contiguous in memory.</p>
79475bd8deadSopenharmony_ci</div>
79485bd8deadSopenharmony_ci<div class="paragraph">
79495bd8deadSopenharmony_ci<p>The <strong>binding</strong> qualifier specifies the uniform buffer binding point
79505bd8deadSopenharmony_cicorresponding to the uniform or shader storage block, which will be used to
79515bd8deadSopenharmony_ciobtain the values of the member variables of the block.
79525bd8deadSopenharmony_ciIt is a compile-time error to specify the <strong>binding</strong> qualifier for the global
79535bd8deadSopenharmony_ciscope or for block member declarations.
79545bd8deadSopenharmony_ciAny uniform or shader storage block declared without a <strong>binding</strong> qualifier
79555bd8deadSopenharmony_ciis initially assigned to block binding point zero.
79565bd8deadSopenharmony_ciAfter a program is linked, the binding points used for uniform
79575bd8deadSopenharmony_ciand shader storage blocks
79585bd8deadSopenharmony_cideclared with or without a <strong>binding</strong> qualifier can be updated
79595bd8deadSopenharmony_ciby the API.</p>
79605bd8deadSopenharmony_ci</div>
79615bd8deadSopenharmony_ci<div class="paragraph">
79625bd8deadSopenharmony_ci<p>When used with OpenGL,
79635bd8deadSopenharmony_ciif the <strong>binding</strong> qualifier is used with a uniform block or shader storage
79645bd8deadSopenharmony_ciblock instanced as an array, the first element of the array takes the
79655bd8deadSopenharmony_cispecified block binding and each subsequent element takes the next
79665bd8deadSopenharmony_ciconsecutive binding point.
79675bd8deadSopenharmony_ciFor an array of arrays, each element (e.g. 6 elements for a[2][3]) gets a
79685bd8deadSopenharmony_cibinding point, and they are ordered per the array of array ordering
79695bd8deadSopenharmony_cidescribed in &#8220;<a href="#arrays">Arrays.</a>&#8221;</p>
79705bd8deadSopenharmony_ci</div>
79715bd8deadSopenharmony_ci<div class="paragraph">
79725bd8deadSopenharmony_ci<p>When targeting Vulkan,
79735bd8deadSopenharmony_ciif the <strong>binding</strong> qualifier is used with a uniform block or buffer block
79745bd8deadSopenharmony_ciinstanced as an array, the entire array takes only the provided binding
79755bd8deadSopenharmony_cinumber.
79765bd8deadSopenharmony_ciThe next consecutive binding number is available for a different
79775bd8deadSopenharmony_ciobject.
79785bd8deadSopenharmony_ciFor an array of arrays, descriptor set array element numbers used
79795bd8deadSopenharmony_ciin descriptor set accesses are ordered per the array-of-array ordering
79805bd8deadSopenharmony_cidescribed in &#8220;<a href="#arrays">Arrays.</a>&#8221;</p>
79815bd8deadSopenharmony_ci</div>
79825bd8deadSopenharmony_ci<div class="paragraph">
79835bd8deadSopenharmony_ci<p>If the binding point for any uniform or shader storage block instance is
79845bd8deadSopenharmony_ciless than zero, or greater than or equal to the corresponding
79855bd8deadSopenharmony_ciimplementation-dependent maximum number of buffer bindings, a compile-time
79865bd8deadSopenharmony_cierror will occur.
79875bd8deadSopenharmony_ciWhen the <strong>binding</strong> qualifier is used with a uniform or shader storage block
79885bd8deadSopenharmony_ciinstanced as an array of size <em>N</em>, all elements of the array from <strong>binding</strong>
79895bd8deadSopenharmony_cithrough <em>binding + N - 1</em> must be within this range.
79905bd8deadSopenharmony_ciIt is a compile-time or link-time error to use the same binding number for
79915bd8deadSopenharmony_cimore than one uniform block or for more than one buffer block.</p>
79925bd8deadSopenharmony_ci</div>
79935bd8deadSopenharmony_ci<div class="paragraph">
79945bd8deadSopenharmony_ci<p>The <strong>set</strong> qualifier is only available when targeting Vulkan.
79955bd8deadSopenharmony_ciIt specifies the descriptor set this object belongs to.
79965bd8deadSopenharmony_ciIt is a compile-time error to apply <strong>set</strong> to a standalone qualifier, to
79975bd8deadSopenharmony_cia member of a block, or when not targeting an API that supports descriptor sets.
79985bd8deadSopenharmony_ciIt is a compile-time error to apply <strong>set</strong> to a block qualified as <strong>push_constant</strong>.
79995bd8deadSopenharmony_ciBy default, any non-push-constant uniform or shader storage block declared
80005bd8deadSopenharmony_ciwithout a <strong>set</strong> identifier is assigned to descriptor set 0.
80015bd8deadSopenharmony_ciSimilarly, any sampler, texture, or subpass-input type declared as a uniform
80025bd8deadSopenharmony_ciwithout a <strong>set</strong> identifier is also assigned to descriptor set 0.</p>
80035bd8deadSopenharmony_ci</div>
80045bd8deadSopenharmony_ci<div class="paragraph">
80055bd8deadSopenharmony_ci<p>If applied to an object declared as an array, all elements of the array
80065bd8deadSopenharmony_cibelong to the specified <strong>set</strong>.</p>
80075bd8deadSopenharmony_ci</div>
80085bd8deadSopenharmony_ci<div class="paragraph">
80095bd8deadSopenharmony_ci<p>When generating SPIR-V, it is a compile-time error for either the <strong>set</strong> or
80105bd8deadSopenharmony_ci<strong>binding</strong> value to exceed a front-end-configuration supplied maximum value.</p>
80115bd8deadSopenharmony_ci</div>
80125bd8deadSopenharmony_ci<div class="paragraph">
80135bd8deadSopenharmony_ci<p>When multiple arguments are listed in a <strong>layout</strong> declaration, the effect
80145bd8deadSopenharmony_ciwill be the same as if they were declared one at a time, in order from left
80155bd8deadSopenharmony_cito right, each in turn inheriting from and overriding the result from the
80165bd8deadSopenharmony_ciprevious qualification.</p>
80175bd8deadSopenharmony_ci</div>
80185bd8deadSopenharmony_ci<div class="paragraph">
80195bd8deadSopenharmony_ci<p>For example</p>
80205bd8deadSopenharmony_ci</div>
80215bd8deadSopenharmony_ci<div class="listingblock">
80225bd8deadSopenharmony_ci<div class="content">
80235bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(row_major, column_major)</code></pre>
80245bd8deadSopenharmony_ci</div>
80255bd8deadSopenharmony_ci</div>
80265bd8deadSopenharmony_ci<div class="paragraph">
80275bd8deadSopenharmony_ci<p>results in the qualification being <strong>column_major</strong>.
80285bd8deadSopenharmony_ciOther examples:</p>
80295bd8deadSopenharmony_ci</div>
80305bd8deadSopenharmony_ci<div class="listingblock">
80315bd8deadSopenharmony_ci<div class="content">
80325bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(shared, row_major) uniform; <span class="comment">// default is now shared and row_major</span>
80335bd8deadSopenharmony_ci
80345bd8deadSopenharmony_cilayout(std140) uniform Transform { <span class="comment">// layout of this block is std140</span>
80355bd8deadSopenharmony_ci    mat4 M1;                       <span class="comment">// row major</span>
80365bd8deadSopenharmony_ci    layout(column_major) mat4 M2;  <span class="comment">// column major</span>
80375bd8deadSopenharmony_ci    mat3 N1;                       <span class="comment">// row major</span>
80385bd8deadSopenharmony_ci};
80395bd8deadSopenharmony_ci
80405bd8deadSopenharmony_ciuniform T2 {                       <span class="comment">// layout of this block is shared</span>
80415bd8deadSopenharmony_ci    ...
80425bd8deadSopenharmony_ci};
80435bd8deadSopenharmony_ci
80445bd8deadSopenharmony_cilayout(column_major) uniform T3 {  <span class="comment">// shared and column major</span>
80455bd8deadSopenharmony_ci    mat4 M3;                       <span class="comment">// column major</span>
80465bd8deadSopenharmony_ci    layout(row_major) mat4 m4;     <span class="comment">// row major</span>
80475bd8deadSopenharmony_ci    mat3 N2;                       <span class="comment">// column major</span>
80485bd8deadSopenharmony_ci};</code></pre>
80495bd8deadSopenharmony_ci</div>
80505bd8deadSopenharmony_ci</div>
80515bd8deadSopenharmony_ci<div class="paragraph">
80525bd8deadSopenharmony_ci<p>When targeting Vulkan, the <strong>offset</strong> and <strong>align</strong> qualifiers for blocks and
80535bd8deadSopenharmony_ciblock members can only be used with <strong>uniform</strong> and <strong>buffer</strong> blocks.
80545bd8deadSopenharmony_ciWhen not targeting Vulkan, they can only be used with blocks declared with
80555bd8deadSopenharmony_ci<strong>std140</strong> or <strong>std430</strong> layouts.</p>
80565bd8deadSopenharmony_ci</div>
80575bd8deadSopenharmony_ci<div class="paragraph">
80585bd8deadSopenharmony_ci<p>The <strong>offset</strong> qualifier can only be used on block members.
80595bd8deadSopenharmony_ciThe <strong>offset</strong> qualifier forces the qualified member to start at or after the
80605bd8deadSopenharmony_cispecified <em>layout-qualifier-value</em>, which will be its byte offset from
80615bd8deadSopenharmony_cithe beginning of the buffer.
80625bd8deadSopenharmony_ciIt is a compile-time error to have any offset, explicit or assigned, that
80635bd8deadSopenharmony_cilies within another member of the block.
80645bd8deadSopenharmony_ciWhen not generating SPIR-V, it is a compile-time error to specify an offset
80655bd8deadSopenharmony_cithat is smaller than the offset of the previous member in the block.
80665bd8deadSopenharmony_ciTwo blocks linked together in the same program with the same block name must
80675bd8deadSopenharmony_cihave the exact same set of members qualified with <strong>offset</strong> and their
80685bd8deadSopenharmony_ci<em>layout-qualifier-value</em> values must be the same, or a link-time error
80695bd8deadSopenharmony_ciresults.
80705bd8deadSopenharmony_ciThe specified offset must be a multiple of the base alignment of the type of
80715bd8deadSopenharmony_cithe block member it qualifies, or a compile-time error results.</p>
80725bd8deadSopenharmony_ci</div>
80735bd8deadSopenharmony_ci<div class="paragraph">
80745bd8deadSopenharmony_ci<p>The <strong>align</strong> qualifier makes the start of each block member have a minimum
80755bd8deadSopenharmony_cibyte alignment.
80765bd8deadSopenharmony_ciIt does not affect the internal layout within each member, which will still
80775bd8deadSopenharmony_cifollow the <strong>std140</strong> or <strong>std430</strong> rules.
80785bd8deadSopenharmony_ciThe specified alignment must be greater than 0 and a power of 2, or a
80795bd8deadSopenharmony_cicompile-time error results.</p>
80805bd8deadSopenharmony_ci</div>
80815bd8deadSopenharmony_ci<div class="paragraph">
80825bd8deadSopenharmony_ci<p>The <em>actual alignment</em> of a member will be the greater of the specified
80835bd8deadSopenharmony_ci<strong>align</strong> alignment and the standard (e.g. <strong>std140</strong>) base alignment for the
80845bd8deadSopenharmony_cimember&#8217;s type.
80855bd8deadSopenharmony_ciThe <em>actual offset</em> of a member is computed as follows: If <strong>offset</strong> was
80865bd8deadSopenharmony_cideclared, start with that offset, otherwise start with the offset immediately
80875bd8deadSopenharmony_cifollowing the preceding member (in declaration order).
80885bd8deadSopenharmony_ciIf the resulting offset is not a multiple of the <em>actual alignment</em>,
80895bd8deadSopenharmony_ciincrease it to the first offset that is a multiple of the <em>actual
80905bd8deadSopenharmony_cialignment</em>.
80915bd8deadSopenharmony_ciThis results in the <em>actual offset</em> the member will have.</p>
80925bd8deadSopenharmony_ci</div>
80935bd8deadSopenharmony_ci<div class="paragraph">
80945bd8deadSopenharmony_ci<p>When <strong>align</strong> is applied to an array, it affects only the start of the array,
80955bd8deadSopenharmony_cinot the array&#8217;s internal stride.
80965bd8deadSopenharmony_ciBoth an <strong>offset</strong> and an <strong>align</strong> qualifier can be specified on a declaration.</p>
80975bd8deadSopenharmony_ci</div>
80985bd8deadSopenharmony_ci<div class="paragraph">
80995bd8deadSopenharmony_ci<p>The <strong>align</strong> qualifier, when used on a block, has the same effect as
81005bd8deadSopenharmony_ciqualifying each member with the same <strong>align</strong> value as declared on the block,
81015bd8deadSopenharmony_ciand gets the same compile-time results and errors as if this had been done.
81025bd8deadSopenharmony_ciAs described in general earlier, an individual member can specify its own
81035bd8deadSopenharmony_ci<strong>align</strong>, which overrides the block-level <strong>align</strong>, but just for that member.</p>
81045bd8deadSopenharmony_ci</div>
81055bd8deadSopenharmony_ci<div class="paragraph">
81065bd8deadSopenharmony_ci<p>Examples:</p>
81075bd8deadSopenharmony_ci</div>
81085bd8deadSopenharmony_ci<div class="listingblock">
81095bd8deadSopenharmony_ci<div class="content">
81105bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(std140) uniform block {
81115bd8deadSopenharmony_ci vec4 a;                         <span class="comment">// a takes offsets 0-15</span>
81125bd8deadSopenharmony_ci layout(offset = <span class="integer">32</span>) vec3 b;     <span class="comment">// b takes offsets 32-43</span>
81135bd8deadSopenharmony_ci layout(offset = <span class="integer">40</span>) vec2 c;     <span class="comment">// ERROR, lies within previous member</span>
81145bd8deadSopenharmony_ci layout(offset = <span class="integer">48</span>) vec2 d;     <span class="comment">// d takes offsets 48-55</span>
81155bd8deadSopenharmony_ci layout(align = <span class="integer">16</span>) <span class="predefined-type">float</span> e;     <span class="comment">// e takes offsets 64-67</span>
81165bd8deadSopenharmony_ci layout(align = <span class="integer">2</span>) <span class="predefined-type">double</span> f;     <span class="comment">// f takes offsets 72-79</span>
81175bd8deadSopenharmony_ci layout(align = <span class="integer">6</span>) <span class="predefined-type">double</span> g;     <span class="comment">// ERROR, 6 is not a power of 2</span>
81185bd8deadSopenharmony_ci layout(offset = <span class="integer">80</span>) <span class="predefined-type">float</span> h;    <span class="comment">// h takes offsets 80-83</span>
81195bd8deadSopenharmony_ci layout(align = <span class="integer">64</span>) dvec3 i;     <span class="comment">// i takes offsets 128-151</span>
81205bd8deadSopenharmony_ci layout(offset = <span class="integer">164</span>, align = <span class="integer">8</span>)
81215bd8deadSopenharmony_ci <span class="predefined-type">float</span> j;                        <span class="comment">// j takes offsets 168-171</span>
81225bd8deadSopenharmony_ci};</code></pre>
81235bd8deadSopenharmony_ci</div>
81245bd8deadSopenharmony_ci</div>
81255bd8deadSopenharmony_ci</div>
81265bd8deadSopenharmony_ci<div class="sect3">
81275bd8deadSopenharmony_ci<h4 id="opaque-uniform-layout-qualifiers">4.4.6. Opaque Uniform Layout Qualifiers</h4>
81285bd8deadSopenharmony_ci<div class="paragraph">
81295bd8deadSopenharmony_ci<p>Opaque uniform variables can take the uniform layout qualifier for binding:</p>
81305bd8deadSopenharmony_ci</div>
81315bd8deadSopenharmony_ci<div class="openblock bnf">
81325bd8deadSopenharmony_ci<div class="content">
81335bd8deadSopenharmony_ci<div class="dlist">
81345bd8deadSopenharmony_ci<dl>
81355bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-id</em> : </dt>
81365bd8deadSopenharmony_ci<dd>
81375bd8deadSopenharmony_ci<p><strong>binding</strong> <strong>=</strong> <em>layout-qualifier-value</em></p>
81385bd8deadSopenharmony_ci</dd>
81395bd8deadSopenharmony_ci</dl>
81405bd8deadSopenharmony_ci</div>
81415bd8deadSopenharmony_ci</div>
81425bd8deadSopenharmony_ci</div>
81435bd8deadSopenharmony_ci<div class="paragraph">
81445bd8deadSopenharmony_ci<p>The <strong>binding</strong> qualifier specifies the point where the variable will be bound.
81455bd8deadSopenharmony_ciAny opaque variable declared without a binding qualifier has a default binding
81465bd8deadSopenharmony_ciof zero.</p>
81475bd8deadSopenharmony_ci</div>
81485bd8deadSopenharmony_ci<div class="paragraph">
81495bd8deadSopenharmony_ci<p>When used with OpenGL,
81505bd8deadSopenharmony_ciif the <strong>binding</strong> qualifier is used with an array, the first element of the
81515bd8deadSopenharmony_ciarray takes the specified binding point and each subsequent element takes the
81525bd8deadSopenharmony_cinext consecutive binding point.
81535bd8deadSopenharmony_ciFor an array of arrays, each element (e.g. 6 elements for a[2][3]) gets a
81545bd8deadSopenharmony_cibinding point, and they are ordered per the array of array ordering
81555bd8deadSopenharmony_cidescribed in &#8220;<a href="#arrays">Arrays.</a>&#8221;</p>
81565bd8deadSopenharmony_ci</div>
81575bd8deadSopenharmony_ci<div class="paragraph">
81585bd8deadSopenharmony_ci<p>When targeting Vulkan,
81595bd8deadSopenharmony_ciif the <strong>binding</strong> qualifier is used with an array, the entire array
81605bd8deadSopenharmony_citakes only the provided binding number. The next consecutive binding
81615bd8deadSopenharmony_cinumber is available for a different object.</p>
81625bd8deadSopenharmony_ci</div>
81635bd8deadSopenharmony_ci<div class="paragraph">
81645bd8deadSopenharmony_ci<p>If the <strong>binding</strong> is less than zero, or greater than or equal to the
81655bd8deadSopenharmony_ciimplementation-dependent maximum supported number of binding points,
81665bd8deadSopenharmony_cia compile-time error will occur.
81675bd8deadSopenharmony_ciWhen the <strong>binding</strong> qualifier is used with an array of size <em>N</em>, all elements
81685bd8deadSopenharmony_ciof the array from <strong>binding</strong> through <em>binding + N - 1</em> must be within this
81695bd8deadSopenharmony_cirange.
81705bd8deadSopenharmony_ciIt is a compile-time or link-time error to use the same <strong>binding</strong> number for
81715bd8deadSopenharmony_cimore than one atomic counter, unless the <em>offset</em> for the atomic counters
81725bd8deadSopenharmony_cisharing the same binding are all different.</p>
81735bd8deadSopenharmony_ci</div>
81745bd8deadSopenharmony_ci<div class="paragraph">
81755bd8deadSopenharmony_ci<p>A link-time error will result if two shaders in a program specify different
81765bd8deadSopenharmony_ci<em>layout-qualifier-value</em> bindings for the same opaque-uniform name.
81775bd8deadSopenharmony_ciHowever, it is not an error to specify a binding on some but not all
81785bd8deadSopenharmony_cideclarations for the same name, as shown in the examples below.</p>
81795bd8deadSopenharmony_ci</div>
81805bd8deadSopenharmony_ci<div class="listingblock">
81815bd8deadSopenharmony_ci<div class="content">
81825bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="comment">// in one shader...</span>
81835bd8deadSopenharmony_cilayout(binding=<span class="integer">3</span>) uniform sampler2D s; <span class="comment">// s bound to point 3</span>
81845bd8deadSopenharmony_ci
81855bd8deadSopenharmony_ci<span class="comment">// in another shader...</span>
81865bd8deadSopenharmony_ciuniform sampler2D s;                   <span class="comment">// okay, s still bound at 3</span>
81875bd8deadSopenharmony_ci
81885bd8deadSopenharmony_ci<span class="comment">// in another shader...</span>
81895bd8deadSopenharmony_cilayout(binding=<span class="integer">4</span>) uniform sampler2D s; <span class="comment">// ERROR: contradictory bindings</span></code></pre>
81905bd8deadSopenharmony_ci</div>
81915bd8deadSopenharmony_ci</div>
81925bd8deadSopenharmony_ci</div>
81935bd8deadSopenharmony_ci<div class="sect3">
81945bd8deadSopenharmony_ci<h4 id="atomic-counter-layout-qualifiers">4.4.7. Atomic Counter Layout Qualifiers</h4>
81955bd8deadSopenharmony_ci<div class="paragraph">
81965bd8deadSopenharmony_ci<p>Atomic counters are not available when targeting Vulkan.</p>
81975bd8deadSopenharmony_ci</div>
81985bd8deadSopenharmony_ci<div class="paragraph">
81995bd8deadSopenharmony_ci<p>Atomic counter layout qualifiers can be used on atomic counter declarations.
82005bd8deadSopenharmony_ciThe atomic counter qualifiers are:</p>
82015bd8deadSopenharmony_ci</div>
82025bd8deadSopenharmony_ci<div class="openblock bnf">
82035bd8deadSopenharmony_ci<div class="content">
82045bd8deadSopenharmony_ci<div class="dlist">
82055bd8deadSopenharmony_ci<dl>
82065bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-id</em> : </dt>
82075bd8deadSopenharmony_ci<dd>
82085bd8deadSopenharmony_ci<p><strong>binding</strong> <strong>=</strong> <em>layout-qualifier-value</em><br>
82095bd8deadSopenharmony_ci<strong>offset</strong> <strong>=</strong> <em>layout-qualifier-value</em></p>
82105bd8deadSopenharmony_ci</dd>
82115bd8deadSopenharmony_ci</dl>
82125bd8deadSopenharmony_ci</div>
82135bd8deadSopenharmony_ci</div>
82145bd8deadSopenharmony_ci</div>
82155bd8deadSopenharmony_ci<div class="paragraph">
82165bd8deadSopenharmony_ci<p>For example,</p>
82175bd8deadSopenharmony_ci</div>
82185bd8deadSopenharmony_ci<div class="listingblock">
82195bd8deadSopenharmony_ci<div class="content">
82205bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(binding = <span class="integer">2</span>, offset = <span class="integer">4</span>) uniform atomic_uint a;</code></pre>
82215bd8deadSopenharmony_ci</div>
82225bd8deadSopenharmony_ci</div>
82235bd8deadSopenharmony_ci<div class="paragraph">
82245bd8deadSopenharmony_ci<p>will establish that the opaque handle to the atomic counter <em>a</em> will be
82255bd8deadSopenharmony_cibound to atomic counter buffer binding point 2 at an offset of 4 basic
82265bd8deadSopenharmony_cimachine units into that buffer.
82275bd8deadSopenharmony_ciThe default <em>offset</em> for binding point 2 will be post incremented by 4 (the
82285bd8deadSopenharmony_cisize of an atomic counter).</p>
82295bd8deadSopenharmony_ci</div>
82305bd8deadSopenharmony_ci<div class="paragraph">
82315bd8deadSopenharmony_ci<p>A subsequent atomic counter declaration will inherit the previous (post
82325bd8deadSopenharmony_ciincremented) offset.
82335bd8deadSopenharmony_ciFor example, a subsequent declaration of</p>
82345bd8deadSopenharmony_ci</div>
82355bd8deadSopenharmony_ci<div class="listingblock">
82365bd8deadSopenharmony_ci<div class="content">
82375bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(binding = <span class="integer">2</span>) uniform atomic_uint bar;</code></pre>
82385bd8deadSopenharmony_ci</div>
82395bd8deadSopenharmony_ci</div>
82405bd8deadSopenharmony_ci<div class="paragraph">
82415bd8deadSopenharmony_ci<p>will establish that the atomic counter <em>bar</em> has a binding to buffer binding
82425bd8deadSopenharmony_cipoint 2 at an offset of 8 basic machine units into that buffer.
82435bd8deadSopenharmony_ciThe offset for binding point 2 will again be post-incremented by 4 (the size
82445bd8deadSopenharmony_ciof an atomic counter).</p>
82455bd8deadSopenharmony_ci</div>
82465bd8deadSopenharmony_ci<div class="paragraph">
82475bd8deadSopenharmony_ci<p>When multiple variables are listed in a layout declaration, the effect will
82485bd8deadSopenharmony_cibe the same as if they were declared one at a time, in order from left to
82495bd8deadSopenharmony_ciright.</p>
82505bd8deadSopenharmony_ci</div>
82515bd8deadSopenharmony_ci<div class="paragraph">
82525bd8deadSopenharmony_ci<p>Binding points are not inherited, only offsets.
82535bd8deadSopenharmony_ciEach binding point tracks its own current default <em>offset</em> for inheritance
82545bd8deadSopenharmony_ciof subsequent variables using the same <strong>binding</strong>.
82555bd8deadSopenharmony_ciThe initial state of compilation is that all <strong>binding</strong> points have an
82565bd8deadSopenharmony_ci<em>offset</em> of 0.
82575bd8deadSopenharmony_ciThe <em>offset</em> can be set per binding point at global scope (without declaring
82585bd8deadSopenharmony_cia variable).
82595bd8deadSopenharmony_ciFor example,</p>
82605bd8deadSopenharmony_ci</div>
82615bd8deadSopenharmony_ci<div class="listingblock">
82625bd8deadSopenharmony_ci<div class="content">
82635bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(binding = <span class="integer">2</span>, offset = <span class="integer">4</span>) uniform atomic_uint;</code></pre>
82645bd8deadSopenharmony_ci</div>
82655bd8deadSopenharmony_ci</div>
82665bd8deadSopenharmony_ci<div class="paragraph">
82675bd8deadSopenharmony_ci<p>Establishes that the next <strong>atomic_uint</strong> declaration for binding point 2 will
82685bd8deadSopenharmony_ciinherit <em>offset</em> 4 (but does not establish a default <strong>binding</strong>):</p>
82695bd8deadSopenharmony_ci</div>
82705bd8deadSopenharmony_ci<div class="listingblock">
82715bd8deadSopenharmony_ci<div class="content">
82725bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(binding = <span class="integer">2</span>) uniform atomic_uint bar; <span class="comment">// offset is 4</span>
82735bd8deadSopenharmony_cilayout(offset = <span class="integer">8</span>) uniform atomic_uint bar;  <span class="comment">// error, no default binding</span></code></pre>
82745bd8deadSopenharmony_ci</div>
82755bd8deadSopenharmony_ci</div>
82765bd8deadSopenharmony_ci<div class="paragraph">
82775bd8deadSopenharmony_ci<p>Atomic counters may share the same binding point, but if a binding is
82785bd8deadSopenharmony_cishared, their offsets must be either explicitly or implicitly (from
82795bd8deadSopenharmony_ciinheritance) unique and non overlapping.</p>
82805bd8deadSopenharmony_ci</div>
82815bd8deadSopenharmony_ci<div class="paragraph">
82825bd8deadSopenharmony_ci<p>Example valid uniform declarations, assuming top of shader:</p>
82835bd8deadSopenharmony_ci</div>
82845bd8deadSopenharmony_ci<div class="listingblock">
82855bd8deadSopenharmony_ci<div class="content">
82865bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(binding=<span class="integer">3</span>, offset=<span class="integer">4</span>) uniform atomic_uint a; <span class="comment">// offset = 4</span>
82875bd8deadSopenharmony_cilayout(binding=<span class="integer">2</span>) uniform atomic_uint b;           <span class="comment">// offset = 0</span>
82885bd8deadSopenharmony_cilayout(binding=<span class="integer">3</span>) uniform atomic_uint c;           <span class="comment">// offset = 8</span>
82895bd8deadSopenharmony_cilayout(binding=<span class="integer">2</span>) uniform atomic_uint d;           <span class="comment">// offset = 4</span></code></pre>
82905bd8deadSopenharmony_ci</div>
82915bd8deadSopenharmony_ci</div>
82925bd8deadSopenharmony_ci<div class="paragraph">
82935bd8deadSopenharmony_ci<p>Example of an invalid uniform declaration:</p>
82945bd8deadSopenharmony_ci</div>
82955bd8deadSopenharmony_ci<div class="listingblock">
82965bd8deadSopenharmony_ci<div class="content">
82975bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(offset=<span class="integer">4</span>) ...               <span class="comment">// error, must include binding</span>
82985bd8deadSopenharmony_cilayout(binding=<span class="integer">1</span>, offset=<span class="integer">0</span>) ... a; <span class="comment">// okay</span>
82995bd8deadSopenharmony_cilayout(binding=<span class="integer">2</span>, offset=<span class="integer">0</span>) ... b; <span class="comment">// okay</span>
83005bd8deadSopenharmony_cilayout(binding=<span class="integer">1</span>, offset=<span class="integer">0</span>) ... c; <span class="comment">// error, offsets must not be shared</span>
83015bd8deadSopenharmony_ci                                   <span class="comment">// between a and c</span>
83025bd8deadSopenharmony_cilayout(binding=<span class="integer">1</span>, offset=<span class="integer">2</span>) ... d; <span class="comment">// error, overlaps offset 0 of a</span></code></pre>
83035bd8deadSopenharmony_ci</div>
83045bd8deadSopenharmony_ci</div>
83055bd8deadSopenharmony_ci<div class="paragraph">
83065bd8deadSopenharmony_ci<p>It is a compile-time error to bind an atomic counter with a binding value
83075bd8deadSopenharmony_cigreater than or equal to <em>gl_MaxAtomicCounterBindings</em>.
83085bd8deadSopenharmony_ciIt is a compile-time error to declare an unsized array of <strong>atomic_uint</strong>.</p>
83095bd8deadSopenharmony_ci</div>
83105bd8deadSopenharmony_ci</div>
83115bd8deadSopenharmony_ci<div class="sect3">
83125bd8deadSopenharmony_ci<h4 id="format-layout-qualifiers">4.4.8. Format Layout Qualifiers</h4>
83135bd8deadSopenharmony_ci<div class="paragraph">
83145bd8deadSopenharmony_ci<p>Format layout qualifiers can be used on image variable declarations (those
83155bd8deadSopenharmony_cideclared with a basic type having &#8220;<strong>image</strong>&#8221; in its keyword).
83165bd8deadSopenharmony_ciThe format layout qualifier identifiers for image variable declarations are:</p>
83175bd8deadSopenharmony_ci</div>
83185bd8deadSopenharmony_ci<div class="openblock bnf">
83195bd8deadSopenharmony_ci<div class="content">
83205bd8deadSopenharmony_ci<div class="dlist">
83215bd8deadSopenharmony_ci<dl>
83225bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout-qualifier-id</em> : </dt>
83235bd8deadSopenharmony_ci<dd>
83245bd8deadSopenharmony_ci<p><em>float-image-format-qualifier</em><br>
83255bd8deadSopenharmony_ci<em>int-image-format-qualifier</em><br>
83265bd8deadSopenharmony_ci<em>uint-image-format-qualifier</em><br>
83275bd8deadSopenharmony_ci<strong>binding</strong> <strong>=</strong> <em>layout-qualifier-value</em></p>
83285bd8deadSopenharmony_ci</dd>
83295bd8deadSopenharmony_ci</dl>
83305bd8deadSopenharmony_ci</div>
83315bd8deadSopenharmony_ci</div>
83325bd8deadSopenharmony_ci</div>
83335bd8deadSopenharmony_ci<div class="openblock bnf">
83345bd8deadSopenharmony_ci<div class="content">
83355bd8deadSopenharmony_ci<div class="dlist">
83365bd8deadSopenharmony_ci<dl>
83375bd8deadSopenharmony_ci<dt class="hdlist1"><em>float-image-format-qualifier</em> : </dt>
83385bd8deadSopenharmony_ci<dd>
83395bd8deadSopenharmony_ci<p><strong>rgba32f</strong><br>
83405bd8deadSopenharmony_ci<strong>rgba16f</strong><br>
83415bd8deadSopenharmony_ci<strong>rg32f</strong><br>
83425bd8deadSopenharmony_ci<strong>rg16f</strong><br>
83435bd8deadSopenharmony_ci<strong>r11f_g11f_b10f</strong><br>
83445bd8deadSopenharmony_ci<strong>r32f</strong><br>
83455bd8deadSopenharmony_ci<strong>r16f</strong><br>
83465bd8deadSopenharmony_ci<strong>rgba16</strong><br>
83475bd8deadSopenharmony_ci<strong>rgb10_a2</strong><br>
83485bd8deadSopenharmony_ci<strong>rgba8</strong><br>
83495bd8deadSopenharmony_ci<strong>rg16</strong><br>
83505bd8deadSopenharmony_ci<strong>rg8</strong><br>
83515bd8deadSopenharmony_ci<strong>r16</strong><br>
83525bd8deadSopenharmony_ci<strong>r8</strong><br>
83535bd8deadSopenharmony_ci<strong>rgba16_snorm</strong><br>
83545bd8deadSopenharmony_ci<strong>rgba8_snorm</strong><br>
83555bd8deadSopenharmony_ci<strong>rg16_snorm</strong><br>
83565bd8deadSopenharmony_ci<strong>rg8_snorm</strong><br>
83575bd8deadSopenharmony_ci<strong>r16_snorm</strong><br>
83585bd8deadSopenharmony_ci<strong>r8_snorm</strong></p>
83595bd8deadSopenharmony_ci</dd>
83605bd8deadSopenharmony_ci<dt class="hdlist1"><em>int-image-format-qualifier</em> : </dt>
83615bd8deadSopenharmony_ci<dd>
83625bd8deadSopenharmony_ci<p><strong>rgba32i</strong><br>
83635bd8deadSopenharmony_ci<strong>rgba16i</strong><br>
83645bd8deadSopenharmony_ci<strong>rgba8i</strong><br>
83655bd8deadSopenharmony_ci<strong>rg32i</strong><br>
83665bd8deadSopenharmony_ci<strong>rg16i</strong><br>
83675bd8deadSopenharmony_ci<strong>rg8i</strong><br>
83685bd8deadSopenharmony_ci<strong>r32i</strong><br>
83695bd8deadSopenharmony_ci<strong>r16i</strong><br>
83705bd8deadSopenharmony_ci<strong>r8i</strong></p>
83715bd8deadSopenharmony_ci</dd>
83725bd8deadSopenharmony_ci<dt class="hdlist1"><em>uint-image-format-qualifier</em> : </dt>
83735bd8deadSopenharmony_ci<dd>
83745bd8deadSopenharmony_ci<p><strong>rgba32ui</strong><br>
83755bd8deadSopenharmony_ci<strong>rgba16ui</strong><br>
83765bd8deadSopenharmony_ci<strong>rgb10_a2ui</strong><br>
83775bd8deadSopenharmony_ci<strong>rgba8ui</strong><br>
83785bd8deadSopenharmony_ci<strong>rg32ui</strong><br>
83795bd8deadSopenharmony_ci<strong>rg16ui</strong><br>
83805bd8deadSopenharmony_ci<strong>rg8ui</strong><br>
83815bd8deadSopenharmony_ci<strong>r32ui</strong><br>
83825bd8deadSopenharmony_ci<strong>r16ui</strong><br>
83835bd8deadSopenharmony_ci<strong>r8ui</strong></p>
83845bd8deadSopenharmony_ci</dd>
83855bd8deadSopenharmony_ci</dl>
83865bd8deadSopenharmony_ci</div>
83875bd8deadSopenharmony_ci</div>
83885bd8deadSopenharmony_ci</div>
83895bd8deadSopenharmony_ci<div class="paragraph">
83905bd8deadSopenharmony_ci<p>A format layout qualifier specifies the image format associated with a
83915bd8deadSopenharmony_cideclared image variable.
83925bd8deadSopenharmony_ciOnly one format qualifier may be specified for any image variable
83935bd8deadSopenharmony_cideclaration.
83945bd8deadSopenharmony_ciFor image variables with floating-point component types (keywords starting
83955bd8deadSopenharmony_ciwith &#8220;<strong>image</strong>&#8221;), signed integer component types (keywords starting with
83965bd8deadSopenharmony_ci&#8220;<strong>iimage</strong>&#8221;), or unsigned integer component types (keywords starting with
83975bd8deadSopenharmony_ci&#8220;<strong>uimage</strong>&#8221;), the format qualifier used must match the
83985bd8deadSopenharmony_ci<em>float-image-format-qualifier</em>, <em>int-image-format-qualifier</em>, or
83995bd8deadSopenharmony_ci<em>uint-image-format-qualifier</em> grammar rules, respectively.
84005bd8deadSopenharmony_ciIt is a compile-time error to declare an image variable where the format
84015bd8deadSopenharmony_ciqualifier does not match the image variable type.</p>
84025bd8deadSopenharmony_ci</div>
84035bd8deadSopenharmony_ci<div class="paragraph">
84045bd8deadSopenharmony_ci<p>Any image variable used for image loads or atomic operations must specify a
84055bd8deadSopenharmony_ciformat layout qualifier; it is a compile-time error to pass an image uniform
84065bd8deadSopenharmony_civariable or function parameter declared without a format layout qualifier to
84075bd8deadSopenharmony_cian image load or atomic function.</p>
84085bd8deadSopenharmony_ci</div>
84095bd8deadSopenharmony_ci<div class="paragraph">
84105bd8deadSopenharmony_ci<p>Uniforms not qualified with <strong>writeonly</strong> must have a format layout qualifier.
84115bd8deadSopenharmony_ciNote that an image variable passed to a function for read access cannot be
84125bd8deadSopenharmony_cideclared as <strong>writeonly</strong> and hence must have been declared with a format
84135bd8deadSopenharmony_cilayout qualifier.</p>
84145bd8deadSopenharmony_ci</div>
84155bd8deadSopenharmony_ci<div class="paragraph">
84165bd8deadSopenharmony_ci<p>The <strong>binding</strong> qualifier was described in
84175bd8deadSopenharmony_ci&#8220;<a href="#opaque-uniform-layout-qualifiers">Opaque Uniform Layout Qualifiers</a>&#8221;.</p>
84185bd8deadSopenharmony_ci</div>
84195bd8deadSopenharmony_ci</div>
84205bd8deadSopenharmony_ci<div class="sect3">
84215bd8deadSopenharmony_ci<h4 id="_subpass_input_qualifier">4.4.9. Subpass Input Qualifier</h4>
84225bd8deadSopenharmony_ci<div class="paragraph">
84235bd8deadSopenharmony_ci<p>Subpass inputs are only available when targeting Vulkan.</p>
84245bd8deadSopenharmony_ci</div>
84255bd8deadSopenharmony_ci<div class="paragraph">
84265bd8deadSopenharmony_ci<p>Subpass inputs are declared with the basic <strong>subpassInput</strong> types.
84275bd8deadSopenharmony_ciThey must be declared with the layout qualifier
84285bd8deadSopenharmony_ci<strong>input_attachment_index</strong>, or a compile-time error results.
84295bd8deadSopenharmony_ciFor example:</p>
84305bd8deadSopenharmony_ci</div>
84315bd8deadSopenharmony_ci<div class="listingblock">
84325bd8deadSopenharmony_ci<div class="content">
84335bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(input_attachment_index = <span class="integer">2</span>) uniform subpassInput t;</code></pre>
84345bd8deadSopenharmony_ci</div>
84355bd8deadSopenharmony_ci</div>
84365bd8deadSopenharmony_ci<div class="paragraph">
84375bd8deadSopenharmony_ci<p>This selects which subpass input is being read from. The value assigned
84385bd8deadSopenharmony_cito <strong>input_attachment_index</strong>, say <em>i</em> (<code>input_attachment_index = i</code>), selects
84395bd8deadSopenharmony_cithat entry (<em>i</em> th entry) in the input list for the pass.  See the API
84405bd8deadSopenharmony_cidocumentation for more detail about passes and the input list.</p>
84415bd8deadSopenharmony_ci</div>
84425bd8deadSopenharmony_ci<div class="paragraph">
84435bd8deadSopenharmony_ci<p>If an array of size <em>N</em> is declared, it consumes <em>N</em> consecutive
84445bd8deadSopenharmony_ci<strong>input_attachment_index</strong> values, starting with the one provided.</p>
84455bd8deadSopenharmony_ci</div>
84465bd8deadSopenharmony_ci<div class="paragraph">
84475bd8deadSopenharmony_ci<p>It is a compile-time or link-time error to have different variables
84485bd8deadSopenharmony_cideclared with the same <strong>input_attachment_index</strong>.
84495bd8deadSopenharmony_ciThis includes any overlap in the implicit <strong>input_attachment_index</strong> consumed by
84505bd8deadSopenharmony_ciarray declarations.</p>
84515bd8deadSopenharmony_ci</div>
84525bd8deadSopenharmony_ci<div class="paragraph">
84535bd8deadSopenharmony_ci<p>It is a compile-time error if the value assigned to an <strong>input_attachment_index</strong>
84545bd8deadSopenharmony_ciis greater than or equal to <em>gl_MaxInputAttachments</em>.</p>
84555bd8deadSopenharmony_ci</div>
84565bd8deadSopenharmony_ci</div>
84575bd8deadSopenharmony_ci</div>
84585bd8deadSopenharmony_ci<div class="sect2">
84595bd8deadSopenharmony_ci<h3 id="interpolation-qualifiers">4.5. Interpolation Qualifiers</h3>
84605bd8deadSopenharmony_ci<div class="paragraph">
84615bd8deadSopenharmony_ci<p>Inputs and outputs that could be interpolated can be further qualified by at
84625bd8deadSopenharmony_cimost one of the following interpolation qualifiers:</p>
84635bd8deadSopenharmony_ci</div>
84645bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
84655bd8deadSopenharmony_ci<colgroup>
84665bd8deadSopenharmony_ci<col style="width: 50%;">
84675bd8deadSopenharmony_ci<col style="width: 50%;">
84685bd8deadSopenharmony_ci</colgroup>
84695bd8deadSopenharmony_ci<thead>
84705bd8deadSopenharmony_ci<tr>
84715bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Qualifier</th>
84725bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Meaning</th>
84735bd8deadSopenharmony_ci</tr>
84745bd8deadSopenharmony_ci</thead>
84755bd8deadSopenharmony_ci<tbody>
84765bd8deadSopenharmony_ci<tr>
84775bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>smooth</strong></p></td>
84785bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">perspective correct interpolation</p></td>
84795bd8deadSopenharmony_ci</tr>
84805bd8deadSopenharmony_ci<tr>
84815bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>flat</strong></p></td>
84825bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">no interpolation</p></td>
84835bd8deadSopenharmony_ci</tr>
84845bd8deadSopenharmony_ci<tr>
84855bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>noperspective</strong></p></td>
84865bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">linear interpolation</p></td>
84875bd8deadSopenharmony_ci</tr>
84885bd8deadSopenharmony_ci</tbody>
84895bd8deadSopenharmony_ci</table>
84905bd8deadSopenharmony_ci<div class="paragraph">
84915bd8deadSopenharmony_ci<p>The presence of and type of interpolation is controlled by the above
84925bd8deadSopenharmony_ciinterpolation qualifiers as well as the auxiliary storage qualifiers
84935bd8deadSopenharmony_ci<strong>centroid</strong> and <strong>sample</strong>.
84945bd8deadSopenharmony_ciWhen no interpolation qualifier is present, smooth interpolation is used.
84955bd8deadSopenharmony_ciIt is a compile-time error to use more than one interpolation qualifier.
84965bd8deadSopenharmony_ciThe auxiliary storage qualifier <strong>patch</strong> is not used for interpolation; it is
84975bd8deadSopenharmony_cia compile-time error to use interpolation qualifiers with <strong>patch</strong>.</p>
84985bd8deadSopenharmony_ci</div>
84995bd8deadSopenharmony_ci<div class="paragraph">
85005bd8deadSopenharmony_ci<p>A variable qualified as <strong>flat</strong> will not be interpolated.
85015bd8deadSopenharmony_ciInstead, it will have the same value for every fragment within a primitive.
85025bd8deadSopenharmony_ciThis value will come from a single provoking vertex, as described by the
85035bd8deadSopenharmony_ci<a href="#references">API</a>.
85045bd8deadSopenharmony_ciA variable qualified as <strong>flat</strong> may also be qualified as <strong>centroid</strong> or
85055bd8deadSopenharmony_ci<strong>sample</strong>, which will mean the same thing as qualifying it only as <strong>flat</strong>.</p>
85065bd8deadSopenharmony_ci</div>
85075bd8deadSopenharmony_ci<div class="paragraph">
85085bd8deadSopenharmony_ci<p>A variable qualified as <strong>smooth</strong> will be interpolated in a
85095bd8deadSopenharmony_ciperspective-correct manner over the primitive being rendered.
85105bd8deadSopenharmony_ciInterpolation in a perspective correct manner is specified in equation 14.7
85115bd8deadSopenharmony_ciof the <a href="#references">OpenGL Specification</a>, section 14.5 &#8220;Line Segments&#8221;.</p>
85125bd8deadSopenharmony_ci</div>
85135bd8deadSopenharmony_ci<div class="paragraph">
85145bd8deadSopenharmony_ci<p>A variable qualified as <strong>noperspective</strong> must be interpolated linearly in
85155bd8deadSopenharmony_ciscreen space, as described in equation 3.7 of the <a href="#references">OpenGL Specification</a>,
85165bd8deadSopenharmony_cisection 3.5 &#8220;Line Segments&#8221;.</p>
85175bd8deadSopenharmony_ci</div>
85185bd8deadSopenharmony_ci<div class="paragraph">
85195bd8deadSopenharmony_ci<p>When multisample rasterization is disabled, or for fragment shader input
85205bd8deadSopenharmony_civariables qualified with neither <strong>centroid</strong> nor <strong>sample</strong>, the value of the
85215bd8deadSopenharmony_ciassigned variable may be interpolated anywhere within the pixel and a single
85225bd8deadSopenharmony_civalue may be assigned to each sample within the pixel, to the extent
85235bd8deadSopenharmony_cipermitted by the <a href="#references">OpenGL Specification</a>.</p>
85245bd8deadSopenharmony_ci</div>
85255bd8deadSopenharmony_ci<div class="paragraph">
85265bd8deadSopenharmony_ci<p>When multisample rasterization is enabled, <strong>centroid</strong> and <strong>sample</strong> may be
85275bd8deadSopenharmony_ciused to control the location and frequency of the sampling of the qualified
85285bd8deadSopenharmony_cifragment shader input.
85295bd8deadSopenharmony_ciIf a fragment shader input is qualified with <strong>centroid</strong>, a single value may
85305bd8deadSopenharmony_cibe assigned to that variable for all samples in the pixel, but that value
85315bd8deadSopenharmony_cimust be interpolated at a location that lies in both the pixel and in the
85325bd8deadSopenharmony_ciprimitive being rendered, including any of the pixel&#8217;s samples covered by
85335bd8deadSopenharmony_cithe primitive.
85345bd8deadSopenharmony_ciBecause the location at which the variable is interpolated may be different
85355bd8deadSopenharmony_ciin neighboring pixels, and derivatives may be computed by computing
85365bd8deadSopenharmony_cidifferences between neighboring pixels, derivatives of centroid-sampled
85375bd8deadSopenharmony_ciinputs may be less accurate than those for non-centroid interpolated
85385bd8deadSopenharmony_civariables.
85395bd8deadSopenharmony_ciIf a fragment shader input is qualified with <strong>sample</strong>, a separate value must
85405bd8deadSopenharmony_cibe assigned to that variable for each covered sample in the pixel, and that
85415bd8deadSopenharmony_civalue must be sampled at the location of the individual sample.</p>
85425bd8deadSopenharmony_ci</div>
85435bd8deadSopenharmony_ci<div class="paragraph">
85445bd8deadSopenharmony_ci<p>It is a link-time error if, within the same stage, the interpolation
85455bd8deadSopenharmony_ciqualifiers of variables of the same name do not match.</p>
85465bd8deadSopenharmony_ci</div>
85475bd8deadSopenharmony_ci<div class="sect3">
85485bd8deadSopenharmony_ci<h4 id="redeclaring-built-in-interpolation-variables-in-the-compatibility-profile">4.5.1. Redeclaring Built-In Interpolation Variables in the Compatibility Profile</h4>
85495bd8deadSopenharmony_ci<div class="paragraph">
85505bd8deadSopenharmony_ci<p>The following predeclared variables can be redeclared with an interpolation
85515bd8deadSopenharmony_ciqualifier when using the compatibility profile:</p>
85525bd8deadSopenharmony_ci</div>
85535bd8deadSopenharmony_ci<div class="paragraph">
85545bd8deadSopenharmony_ci<p>Vertex, tessellation control, tessellation evaluation, and geometry
85555bd8deadSopenharmony_cilanguages:</p>
85565bd8deadSopenharmony_ci</div>
85575bd8deadSopenharmony_ci<div class="listingblock">
85585bd8deadSopenharmony_ci<div class="content">
85595bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">gl_FrontColor
85605bd8deadSopenharmony_cigl_BackColor
85615bd8deadSopenharmony_cigl_FrontSecondaryColor
85625bd8deadSopenharmony_cigl_BackSecondaryColor</code></pre>
85635bd8deadSopenharmony_ci</div>
85645bd8deadSopenharmony_ci</div>
85655bd8deadSopenharmony_ci<div class="paragraph">
85665bd8deadSopenharmony_ci<p>Fragment language:</p>
85675bd8deadSopenharmony_ci</div>
85685bd8deadSopenharmony_ci<div class="listingblock">
85695bd8deadSopenharmony_ci<div class="content">
85705bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">gl_Color
85715bd8deadSopenharmony_cigl_SecondaryColor</code></pre>
85725bd8deadSopenharmony_ci</div>
85735bd8deadSopenharmony_ci</div>
85745bd8deadSopenharmony_ci<div class="paragraph">
85755bd8deadSopenharmony_ci<p>For example,</p>
85765bd8deadSopenharmony_ci</div>
85775bd8deadSopenharmony_ci<div class="listingblock">
85785bd8deadSopenharmony_ci<div class="content">
85795bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">in vec4 gl_Color;            <span class="comment">// predeclared by the fragment language</span>
85805bd8deadSopenharmony_ciflat in vec4 gl_Color;       <span class="comment">// redeclared by user to be flat</span>
85815bd8deadSopenharmony_ciflat in vec4 gl_FrontColor;  <span class="comment">// input to geometry shader, no &quot;gl_in[]&quot;</span>
85825bd8deadSopenharmony_ciflat out vec4 gl_FrontColor; <span class="comment">// output from geometry shader</span></code></pre>
85835bd8deadSopenharmony_ci</div>
85845bd8deadSopenharmony_ci</div>
85855bd8deadSopenharmony_ci<div class="paragraph">
85865bd8deadSopenharmony_ci<p>Ideally, these are redeclared as part of the redeclaration of an interface
85875bd8deadSopenharmony_ciblock, as described in
85885bd8deadSopenharmony_ci&#8220;<a href="#compatibility-profile-built-in-language-variables">Compatibility Profile
85895bd8deadSopenharmony_ciBuilt-In Language Variables</a>&#8221;.
85905bd8deadSopenharmony_ciHowever, for the above purpose, they can be redeclared as individual
85915bd8deadSopenharmony_civariables at global scope, outside an interface block.
85925bd8deadSopenharmony_ciSuch redeclarations also allow adding the transform-feedback qualifiers
85935bd8deadSopenharmony_ci<strong>xfb_buffer</strong>, <strong>xfb_stride</strong>, and <strong>xfb_offset</strong> to output variables.
85945bd8deadSopenharmony_ci(Using <strong>xfb_buffer</strong> on a variable does not change the global default
85955bd8deadSopenharmony_cibuffer.) A compile-time error will result if a shader has both an interface
85965bd8deadSopenharmony_ciblock redeclaration and a separate redeclaration of a member of that
85975bd8deadSopenharmony_ciinterface block outside the interface block redeclaration.</p>
85985bd8deadSopenharmony_ci</div>
85995bd8deadSopenharmony_ci<div class="paragraph">
86005bd8deadSopenharmony_ci<p>If <em>gl_Color</em> is redeclared with an interpolation qualifier, then
86015bd8deadSopenharmony_ci<em>gl_FrontColor</em> and <em>gl_BackColor</em> (if they are written to) must also be
86025bd8deadSopenharmony_ciredeclared with the same interpolation qualifier, and vice versa.
86035bd8deadSopenharmony_ciIf <em>gl_SecondaryColor</em> is redeclared with an interpolation qualifier, then
86045bd8deadSopenharmony_ci<em>gl_FrontSecondaryColor</em> and _gl_BackSecondaryColor _(if they are written
86055bd8deadSopenharmony_cito) must also be redeclared with the same interpolation qualifier, and vice
86065bd8deadSopenharmony_civersa.
86075bd8deadSopenharmony_ciThis qualifier matching on predeclared variables is only required for
86085bd8deadSopenharmony_civariables that are statically used within the shaders in a program.</p>
86095bd8deadSopenharmony_ci</div>
86105bd8deadSopenharmony_ci</div>
86115bd8deadSopenharmony_ci</div>
86125bd8deadSopenharmony_ci<div class="sect2">
86135bd8deadSopenharmony_ci<h3 id="parameter-qualifiers">4.6. Parameter Qualifiers</h3>
86145bd8deadSopenharmony_ci<div class="paragraph">
86155bd8deadSopenharmony_ci<p>In addition to precision qualifiers and memory qualifiers, parameters can
86165bd8deadSopenharmony_cihave these parameter qualifiers.</p>
86175bd8deadSopenharmony_ci</div>
86185bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
86195bd8deadSopenharmony_ci<colgroup>
86205bd8deadSopenharmony_ci<col style="width: 50%;">
86215bd8deadSopenharmony_ci<col style="width: 50%;">
86225bd8deadSopenharmony_ci</colgroup>
86235bd8deadSopenharmony_ci<thead>
86245bd8deadSopenharmony_ci<tr>
86255bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Qualifier</th>
86265bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Meaning</th>
86275bd8deadSopenharmony_ci</tr>
86285bd8deadSopenharmony_ci</thead>
86295bd8deadSopenharmony_ci<tbody>
86305bd8deadSopenharmony_ci<tr>
86315bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;none: default&gt;</p></td>
86325bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">same as <strong>in</strong></p></td>
86335bd8deadSopenharmony_ci</tr>
86345bd8deadSopenharmony_ci<tr>
86355bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>const</strong></p></td>
86365bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">for function parameters that cannot be written to</p></td>
86375bd8deadSopenharmony_ci</tr>
86385bd8deadSopenharmony_ci<tr>
86395bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>in</strong></p></td>
86405bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">for function parameters passed into a function</p></td>
86415bd8deadSopenharmony_ci</tr>
86425bd8deadSopenharmony_ci<tr>
86435bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>out</strong></p></td>
86445bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">for function parameters passed back out of a function,
86455bd8deadSopenharmony_ci                   but not initialized for use when passed in</p></td>
86465bd8deadSopenharmony_ci</tr>
86475bd8deadSopenharmony_ci<tr>
86485bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>inout</strong></p></td>
86495bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">for function parameters passed both into and out of a
86505bd8deadSopenharmony_ci                   function</p></td>
86515bd8deadSopenharmony_ci</tr>
86525bd8deadSopenharmony_ci</tbody>
86535bd8deadSopenharmony_ci</table>
86545bd8deadSopenharmony_ci<div class="paragraph">
86555bd8deadSopenharmony_ci<p>Parameter qualifiers are discussed in more detail in
86565bd8deadSopenharmony_ci&#8220;<a href="#function-calling-conventions">Function Calling Conventions</a>&#8221;.</p>
86575bd8deadSopenharmony_ci</div>
86585bd8deadSopenharmony_ci</div>
86595bd8deadSopenharmony_ci<div class="sect2">
86605bd8deadSopenharmony_ci<h3 id="precision-and-precision-qualifiers">4.7. Precision and Precision Qualifiers</h3>
86615bd8deadSopenharmony_ci<div class="paragraph">
86625bd8deadSopenharmony_ci<p>When not targeting Vulkan:
86635bd8deadSopenharmony_ciPrecision qualifiers are added for code portability with OpenGL ES, not for
86645bd8deadSopenharmony_cifunctionality.
86655bd8deadSopenharmony_ciThey have the same syntax as in OpenGL ES, as described below, but they have
86665bd8deadSopenharmony_cino semantic meaning, which includes no effect on the precision used to store
86675bd8deadSopenharmony_cior operate on variables.
86685bd8deadSopenharmony_ciIf an extension adds in the same semantics and functionality in the OpenGL
86695bd8deadSopenharmony_ciES 2.0 specification for precision qualifiers, then the extension is allowed
86705bd8deadSopenharmony_cito reuse the keywords below for that purpose.</p>
86715bd8deadSopenharmony_ci</div>
86725bd8deadSopenharmony_ci<div class="paragraph">
86735bd8deadSopenharmony_ci<p>When targeting Vulkan:
86745bd8deadSopenharmony_ciFor interface matching, uniform variables and uniform and buffer block
86755bd8deadSopenharmony_cimembers must have the same precision qualification.
86765bd8deadSopenharmony_ciGlobal variables declared in different compilation units linked into the
86775bd8deadSopenharmony_cisame shader stage must be declared with the same precision qualification.</p>
86785bd8deadSopenharmony_ci</div>
86795bd8deadSopenharmony_ci<div class="paragraph">
86805bd8deadSopenharmony_ci<p>For the purposes of determining if an output from one shader stage matches
86815bd8deadSopenharmony_cian input of the next stage, the precision qualifier need not match.</p>
86825bd8deadSopenharmony_ci</div>
86835bd8deadSopenharmony_ci<div class="sect3">
86845bd8deadSopenharmony_ci<h4 id="range-and-precision">4.7.1. Range and Precision</h4>
86855bd8deadSopenharmony_ci<div class="paragraph">
86865bd8deadSopenharmony_ci<p>The precision of <strong>highp</strong>
86875bd8deadSopenharmony_cisingle- and double-precision
86885bd8deadSopenharmony_cifloating-point variables is defined by the IEEE 754 standard for
86895bd8deadSopenharmony_ci32-bit
86905bd8deadSopenharmony_ciand 64-bit
86915bd8deadSopenharmony_cifloating-point numbers.</p>
86925bd8deadSopenharmony_ci</div>
86935bd8deadSopenharmony_ci<div class="paragraph">
86945bd8deadSopenharmony_ci<p>This includes support for NaNs (Not a Number) and Infs (positive or negative
86955bd8deadSopenharmony_ciinfinities) and positive and negative zeros.</p>
86965bd8deadSopenharmony_ci</div>
86975bd8deadSopenharmony_ci<div class="paragraph">
86985bd8deadSopenharmony_ci<p>The following rules apply to <strong>highp</strong>
86995bd8deadSopenharmony_cifor both single and double-precision
87005bd8deadSopenharmony_cioperations:
87015bd8deadSopenharmony_ciSigned infinities and zeros are generated as dictated by IEEE, but subject
87025bd8deadSopenharmony_cito the precisions allowed in the following table.
87035bd8deadSopenharmony_ciAny subnormal (denormalized) value input into a shader or potentially
87045bd8deadSopenharmony_cigenerated by any operation in a shader can be flushed to 0.
87055bd8deadSopenharmony_ciThe rounding mode cannot be set and is undefined but must not affect the
87065bd8deadSopenharmony_ciresult by more than 1 ULP.
87075bd8deadSopenharmony_ciNaNs are not required to be generated.
87085bd8deadSopenharmony_ciSupport for signaling NaNs is not required and exceptions are never raised.
87095bd8deadSopenharmony_ciOperations including built-in functions that operate on a NaN are not
87105bd8deadSopenharmony_cirequired to return a NaN as the result.
87115bd8deadSopenharmony_ciHowever if NaNs are generated, <strong>isnan</strong>() must return the correct value.</p>
87125bd8deadSopenharmony_ci</div>
87135bd8deadSopenharmony_ci<div class="paragraph">
87145bd8deadSopenharmony_ci<p>Precisions are expressed in terms of maximum relative error in units of ULP
87155bd8deadSopenharmony_ci(units in the last place), unless otherwise noted.</p>
87165bd8deadSopenharmony_ci</div>
87175bd8deadSopenharmony_ci<div class="paragraph">
87185bd8deadSopenharmony_ci<p>For single precision operations, precisions are required as follows:</p>
87195bd8deadSopenharmony_ci</div>
87205bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
87215bd8deadSopenharmony_ci<colgroup>
87225bd8deadSopenharmony_ci<col style="width: 50%;">
87235bd8deadSopenharmony_ci<col style="width: 50%;">
87245bd8deadSopenharmony_ci</colgroup>
87255bd8deadSopenharmony_ci<thead>
87265bd8deadSopenharmony_ci<tr>
87275bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Operation</th>
87285bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Precision</th>
87295bd8deadSopenharmony_ci</tr>
87305bd8deadSopenharmony_ci</thead>
87315bd8deadSopenharmony_ci<tbody>
87325bd8deadSopenharmony_ci<tr>
87335bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><em>a</em> + <em>b</em>, <em>a</em> - <em>b</em>, <em>a</em> * <em>b</em></p></td>
87345bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded.</p></td>
87355bd8deadSopenharmony_ci</tr>
87365bd8deadSopenharmony_ci<tr>
87375bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;, &lt;=, ==, &gt;, &gt;=</p></td>
87385bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Correct result.</p></td>
87395bd8deadSopenharmony_ci</tr>
87405bd8deadSopenharmony_ci<tr>
87415bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><em>a</em> / <em>b</em>, 1.0 / <em>b</em></p></td>
87425bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">2.5 ULP for <span class="eq">|b|</span> in the range <span class="eq">[2<sup>-126</sup>, 2<sup>126</sup>]</span>.</p></td>
87435bd8deadSopenharmony_ci</tr>
87445bd8deadSopenharmony_ci<tr>
87455bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><em>a</em> * <em>b</em> + <em>c</em></p></td>
87465bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded single operation or
87475bd8deadSopenharmony_ci                                    sequence of two correctly rounded operations.</p></td>
87485bd8deadSopenharmony_ci</tr>
87495bd8deadSopenharmony_ci<tr>
87505bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fma</strong>()</p></td>
87515bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Inherited from <em>a</em> * <em>b</em> + <em>c</em>.</p></td>
87525bd8deadSopenharmony_ci</tr>
87535bd8deadSopenharmony_ci<tr>
87545bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>pow</strong>(<em>x</em>, <em>y</em>)</p></td>
87555bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Inherited from <strong>exp2</strong>(<em>y</em> * <strong>log2</strong>(<em>x</em>)).</p></td>
87565bd8deadSopenharmony_ci</tr>
87575bd8deadSopenharmony_ci<tr>
87585bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>exp</strong>(<em>x</em>), <strong>exp2</strong>(<em>x</em>)</p></td>
87595bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><span class="eq">(3 + 2 · |x|)</span> ULP.</p></td>
87605bd8deadSopenharmony_ci</tr>
87615bd8deadSopenharmony_ci<tr>
87625bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log</strong>(), <strong>log2</strong>()</p></td>
87635bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">3 ULP outside the range <span class="eq">[0.5,2.0]</span>.<br>
87645bd8deadSopenharmony_ci                                    Absolute error &lt; 2<sup>-21</sup> inside the range
87655bd8deadSopenharmony_ci                                    <span class="eq">[0.5,2.0]</span>.</p></td>
87665bd8deadSopenharmony_ci</tr>
87675bd8deadSopenharmony_ci<tr>
87685bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sqrt</strong>()</p></td>
87695bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Inherited from 1.0 / <strong>inversesqrt</strong>().</p></td>
87705bd8deadSopenharmony_ci</tr>
87715bd8deadSopenharmony_ci<tr>
87725bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>inversesqrt</strong>()</p></td>
87735bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">2 ULP.</p></td>
87745bd8deadSopenharmony_ci</tr>
87755bd8deadSopenharmony_ci<tr>
87765bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">implicit and explicit
87775bd8deadSopenharmony_ci  conversions between types</p></td>
87785bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded.</p></td>
87795bd8deadSopenharmony_ci</tr>
87805bd8deadSopenharmony_ci</tbody>
87815bd8deadSopenharmony_ci</table>
87825bd8deadSopenharmony_ci<div class="paragraph">
87835bd8deadSopenharmony_ci<p>Built-in functions defined in the specification with an equation built from
87845bd8deadSopenharmony_cithe above operations inherit the above errors.
87855bd8deadSopenharmony_ciThese include, for example, the geometric functions, the common functions,
87865bd8deadSopenharmony_ciand many of the matrix functions.
87875bd8deadSopenharmony_ciBuilt-in functions not listed above and not defined as equations of the
87885bd8deadSopenharmony_ciabove have undefined precision.
87895bd8deadSopenharmony_ciThese include, for example, the trigonometric functions and determinant.</p>
87905bd8deadSopenharmony_ci</div>
87915bd8deadSopenharmony_ci<div class="paragraph">
87925bd8deadSopenharmony_ci<p>The precision of double-precision operations is at least that of single
87935bd8deadSopenharmony_ciprecision.</p>
87945bd8deadSopenharmony_ci</div>
87955bd8deadSopenharmony_ci</div>
87965bd8deadSopenharmony_ci<div class="sect3">
87975bd8deadSopenharmony_ci<h4 id="precision-qualifiers">4.7.2. Precision Qualifiers</h4>
87985bd8deadSopenharmony_ci<div class="paragraph">
87995bd8deadSopenharmony_ci<p>Any
88005bd8deadSopenharmony_cisingle-precision
88015bd8deadSopenharmony_cifloating-point, integer, or opaque-type declaration can have the type
88025bd8deadSopenharmony_cipreceded by one of these precision qualifiers:</p>
88035bd8deadSopenharmony_ci</div>
88045bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
88055bd8deadSopenharmony_ci<colgroup>
88065bd8deadSopenharmony_ci<col style="width: 50%;">
88075bd8deadSopenharmony_ci<col style="width: 50%;">
88085bd8deadSopenharmony_ci</colgroup>
88095bd8deadSopenharmony_ci<thead>
88105bd8deadSopenharmony_ci<tr>
88115bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Qualifier</th>
88125bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Meaning</th>
88135bd8deadSopenharmony_ci</tr>
88145bd8deadSopenharmony_ci</thead>
88155bd8deadSopenharmony_ci<tbody>
88165bd8deadSopenharmony_ci<tr>
88175bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>highp</strong></p></td>
88185bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">32-bit two&#8217;s complement for integers,
88195bd8deadSopenharmony_ci              32-bit IEEE 754 floating-point for <strong>float</strong></p></td>
88205bd8deadSopenharmony_ci</tr>
88215bd8deadSopenharmony_ci<tr>
88225bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mediump</strong></p></td>
88235bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">SPIR-V <strong>RelaxedPrecision</strong> when targeting Vulkan, otherwise none.</p></td>
88245bd8deadSopenharmony_ci</tr>
88255bd8deadSopenharmony_ci<tr>
88265bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>lowp</strong></p></td>
88275bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">SPIR-V <strong>RelaxedPrecision</strong> when targeting Vulkan, otherwise none.</p></td>
88285bd8deadSopenharmony_ci</tr>
88295bd8deadSopenharmony_ci</tbody>
88305bd8deadSopenharmony_ci</table>
88315bd8deadSopenharmony_ci<div class="paragraph">
88325bd8deadSopenharmony_ci<p>For example:</p>
88335bd8deadSopenharmony_ci</div>
88345bd8deadSopenharmony_ci<div class="listingblock">
88355bd8deadSopenharmony_ci<div class="content">
88365bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">lowp <span class="predefined-type">float</span> color;
88375bd8deadSopenharmony_ciout mediump vec2 P;
88385bd8deadSopenharmony_cilowp ivec2 foo(lowp mat3);
88395bd8deadSopenharmony_cihighp mat4 m;</code></pre>
88405bd8deadSopenharmony_ci</div>
88415bd8deadSopenharmony_ci</div>
88425bd8deadSopenharmony_ci<div class="paragraph">
88435bd8deadSopenharmony_ci<p>Literal constants do not have precision qualifiers.
88445bd8deadSopenharmony_ciNeither do Boolean variables.
88455bd8deadSopenharmony_ciNeither do constructors.</p>
88465bd8deadSopenharmony_ci</div>
88475bd8deadSopenharmony_ci<div class="paragraph">
88485bd8deadSopenharmony_ci<p>For this paragraph, &#8220;operation&#8221; includes operators, built-in functions,
88495bd8deadSopenharmony_ciand constructors, and &#8220;operand&#8221; includes function arguments and
88505bd8deadSopenharmony_ciconstructor arguments.
88515bd8deadSopenharmony_ciThe precision used to internally evaluate an operation, and the precision
88525bd8deadSopenharmony_ciqualification subsequently associated with any resulting intermediate
88535bd8deadSopenharmony_civalues, must be at least as high as the highest precision qualification of
88545bd8deadSopenharmony_cithe operands consumed by the operation.</p>
88555bd8deadSopenharmony_ci</div>
88565bd8deadSopenharmony_ci<div class="paragraph">
88575bd8deadSopenharmony_ci<p>In cases where operands do not have a precision qualifier, the precision
88585bd8deadSopenharmony_ciqualification will come from the other operands.
88595bd8deadSopenharmony_ciIf no operands have a precision qualifier, then the precision qualifications
88605bd8deadSopenharmony_ciof the operands of the next consuming operation in the expression will be
88615bd8deadSopenharmony_ciused.
88625bd8deadSopenharmony_ciThis rule can be applied recursively until a precision qualified operand is
88635bd8deadSopenharmony_cifound.
88645bd8deadSopenharmony_ciIf necessary, it will also include the precision qualification of l-values
88655bd8deadSopenharmony_cifor assignments, of the declared variable for initializers, of formal
88665bd8deadSopenharmony_ciparameters for function call arguments, or of function return types for
88675bd8deadSopenharmony_cifunction return values.
88685bd8deadSopenharmony_ciIf the precision cannot be determined by this method e.g. if an entire
88695bd8deadSopenharmony_ciexpression is composed only of operands with no precision qualifier, and the
88705bd8deadSopenharmony_ciresult is not assigned or passed as an argument, then it is evaluated at the
88715bd8deadSopenharmony_cidefault precision of the type or greater.
88725bd8deadSopenharmony_ciWhen this occurs in the fragment shader, the default precision must be
88735bd8deadSopenharmony_cidefined.</p>
88745bd8deadSopenharmony_ci</div>
88755bd8deadSopenharmony_ci<div class="paragraph">
88765bd8deadSopenharmony_ci<p>For example, consider the statements:</p>
88775bd8deadSopenharmony_ci</div>
88785bd8deadSopenharmony_ci<div class="listingblock">
88795bd8deadSopenharmony_ci<div class="content">
88805bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">uniform highp <span class="predefined-type">float</span> h1;
88815bd8deadSopenharmony_cihighp <span class="predefined-type">float</span> h2 = <span class="float">2</span><span class="float">.3</span> * <span class="float">4</span><span class="float">.7</span>; <span class="comment">// operation and result are highp</span>
88825bd8deadSopenharmony_ciprecision
88835bd8deadSopenharmony_cimediump <span class="predefined-type">float</span> m;
88845bd8deadSopenharmony_cim = <span class="float">3</span><span class="float">.7</span> * h1 * h2; <span class="comment">// all operations are highp precision</span>
88855bd8deadSopenharmony_cih2 = m * h1; <span class="comment">// operation is highp precision</span>
88865bd8deadSopenharmony_cim = h2 - h1; <span class="comment">// operation is highp precision</span>
88875bd8deadSopenharmony_cih2 = m + m; <span class="comment">// addition and result at mediump precision</span>
88885bd8deadSopenharmony_ci<span class="directive">void</span> f(highp <span class="predefined-type">float</span> p);
88895bd8deadSopenharmony_cif(<span class="float">3</span><span class="float">.3</span>); <span class="comment">// 3.3 will be passed in at highp precision</span></code></pre>
88905bd8deadSopenharmony_ci</div>
88915bd8deadSopenharmony_ci</div>
88925bd8deadSopenharmony_ci<div class="paragraph">
88935bd8deadSopenharmony_ci<p>Precision qualifiers, as with other qualifiers, do not affect the basic type
88945bd8deadSopenharmony_ciof the variable.
88955bd8deadSopenharmony_ciIn particular, there are no constructors for precision conversions;
88965bd8deadSopenharmony_ciconstructors only convert types.
88975bd8deadSopenharmony_ciSimilarly, precision qualifiers, as with other qualifiers, do not contribute
88985bd8deadSopenharmony_cito function overloading based on parameter types.
88995bd8deadSopenharmony_ciAs discussed in &#8220;<a href="#function-calling-conventions">Function Calling
89005bd8deadSopenharmony_ciConventions</a>&#8221;, function input and output is done through copies, and
89015bd8deadSopenharmony_citherefore qualifiers do not have to match.</p>
89025bd8deadSopenharmony_ci</div>
89035bd8deadSopenharmony_ci<div class="paragraph">
89045bd8deadSopenharmony_ci<p>The precision of a variable is determined when the variable is declared and
89055bd8deadSopenharmony_cicannot be subsequently changed.</p>
89065bd8deadSopenharmony_ci</div>
89075bd8deadSopenharmony_ci<div class="paragraph">
89085bd8deadSopenharmony_ci<p>Where the precision of a constant integral or constant floating-point
89095bd8deadSopenharmony_ciexpression is not specified, evaluation is performed at <strong>highp</strong>.
89105bd8deadSopenharmony_ciThis rule does not affect the precision qualification of the expression.</p>
89115bd8deadSopenharmony_ci</div>
89125bd8deadSopenharmony_ci<div class="paragraph">
89135bd8deadSopenharmony_ci<p>The evaluation of constant expressions must be invariant and will usually be
89145bd8deadSopenharmony_ciperformed at compile time.</p>
89155bd8deadSopenharmony_ci</div>
89165bd8deadSopenharmony_ci</div>
89175bd8deadSopenharmony_ci<div class="sect3">
89185bd8deadSopenharmony_ci<h4 id="default-precision-qualifiers">4.7.3. Default Precision Qualifiers</h4>
89195bd8deadSopenharmony_ci<div class="paragraph">
89205bd8deadSopenharmony_ci<p>The precision statement</p>
89215bd8deadSopenharmony_ci</div>
89225bd8deadSopenharmony_ci<div class="listingblock">
89235bd8deadSopenharmony_ci<div class="content">
89245bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">precision precision-qualifier type;</code></pre>
89255bd8deadSopenharmony_ci</div>
89265bd8deadSopenharmony_ci</div>
89275bd8deadSopenharmony_ci<div class="paragraph">
89285bd8deadSopenharmony_ci<p>can be used to establish a default precision qualifier.
89295bd8deadSopenharmony_ciThe <em>type</em> field can be either <strong>int</strong>, <strong>float</strong>, or any of the opaque types,
89305bd8deadSopenharmony_ciand the <em>precision-qualifier</em> can be <strong>lowp</strong>, <strong>mediump</strong>, or <strong>highp</strong>.</p>
89315bd8deadSopenharmony_ci</div>
89325bd8deadSopenharmony_ci<div class="paragraph">
89335bd8deadSopenharmony_ci<p>Any other types or qualifiers will result in a compile-time error.
89345bd8deadSopenharmony_ciIf <em>type</em> is <strong>float</strong>, the directive applies to non-precision-qualified
89355bd8deadSopenharmony_cisingle-precision
89365bd8deadSopenharmony_cifloating-point type (scalar, vector, and matrix) declarations.
89375bd8deadSopenharmony_ciIf <em>type</em> is <strong>int</strong>, the directive applies to all non-precision-qualified
89385bd8deadSopenharmony_ciinteger type (scalar, vector, signed, and unsigned) declarations.
89395bd8deadSopenharmony_ciThis includes global variable declarations, function return declarations,
89405bd8deadSopenharmony_cifunction parameter declarations, and local variable declarations.</p>
89415bd8deadSopenharmony_ci</div>
89425bd8deadSopenharmony_ci<div class="paragraph">
89435bd8deadSopenharmony_ci<p>Non-precision qualified declarations will use the precision qualifier
89445bd8deadSopenharmony_cispecified in the most recent <strong>precision</strong> statement that is still in scope.
89455bd8deadSopenharmony_ciThe <strong>precision</strong> statement has the same scoping rules as variable
89465bd8deadSopenharmony_cideclarations.
89475bd8deadSopenharmony_ciIf it is declared inside a compound statement, its effect stops at the end
89485bd8deadSopenharmony_ciof the inner-most statement it was declared in.
89495bd8deadSopenharmony_ciPrecision statements in nested scopes override precision statements in outer
89505bd8deadSopenharmony_ciscopes.
89515bd8deadSopenharmony_ciMultiple precision statements for the same basic type can appear inside the
89525bd8deadSopenharmony_cisame scope, with later statements overriding earlier statements within that
89535bd8deadSopenharmony_ciscope.</p>
89545bd8deadSopenharmony_ci</div>
89555bd8deadSopenharmony_ci<div class="paragraph">
89565bd8deadSopenharmony_ci<p>For any type that accepts a precision qualifier,
89575bd8deadSopenharmony_cithe default precision qualification will be <strong>highp</strong>.
89585bd8deadSopenharmony_ciBecause all types requiring a precision qualifier have a default precision,
89595bd8deadSopenharmony_cithere are no errors for omission of a precision qualifier.</p>
89605bd8deadSopenharmony_ci</div>
89615bd8deadSopenharmony_ci</div>
89625bd8deadSopenharmony_ci<div class="sect3">
89635bd8deadSopenharmony_ci<h4 id="available-precision-qualifiers">4.7.4. Available Precision Qualifiers</h4>
89645bd8deadSopenharmony_ci<div class="paragraph">
89655bd8deadSopenharmony_ci<p>The built-in macro GL_FRAGMENT_PRECISION_HIGH is defined to one:</p>
89665bd8deadSopenharmony_ci</div>
89675bd8deadSopenharmony_ci<div class="listingblock">
89685bd8deadSopenharmony_ci<div class="content">
89695bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="preprocessor">#define</span> GL_FRAGMENT_PRECISION_HIGH <span class="integer">1</span></code></pre>
89705bd8deadSopenharmony_ci</div>
89715bd8deadSopenharmony_ci</div>
89725bd8deadSopenharmony_ci<div class="paragraph">
89735bd8deadSopenharmony_ci<p>This macro is available in all languages except compute.</p>
89745bd8deadSopenharmony_ci</div>
89755bd8deadSopenharmony_ci</div>
89765bd8deadSopenharmony_ci</div>
89775bd8deadSopenharmony_ci<div class="sect2">
89785bd8deadSopenharmony_ci<h3 id="variance-and-the-invariant-qualifier">4.8. Variance and the Invariant Qualifier</h3>
89795bd8deadSopenharmony_ci<div class="paragraph">
89805bd8deadSopenharmony_ci<p>In this section, <em>variance</em> refers to the possibility of getting different
89815bd8deadSopenharmony_civalues from the same expression in different programs.
89825bd8deadSopenharmony_ciFor example, consider the situation where two vertex shaders, in different
89835bd8deadSopenharmony_ciprograms, each set <em>gl_Position</em> with the same expression, and the input
89845bd8deadSopenharmony_civalues into that expression are the same when both shaders run.
89855bd8deadSopenharmony_ciIt is possible, due to independent compilation of the two shaders, that the
89865bd8deadSopenharmony_civalues assigned to <em>gl_Position</em> are not exactly the same when the two
89875bd8deadSopenharmony_cishaders run.
89885bd8deadSopenharmony_ciIn this example, this can cause problems with alignment of geometry in a
89895bd8deadSopenharmony_cimulti-pass algorithm.</p>
89905bd8deadSopenharmony_ci</div>
89915bd8deadSopenharmony_ci<div class="paragraph">
89925bd8deadSopenharmony_ci<p>In general, such variance between shaders is allowed.
89935bd8deadSopenharmony_ciWhen such variance does not exist for a particular output variable, that
89945bd8deadSopenharmony_civariable is said to be <em>invariant</em>.</p>
89955bd8deadSopenharmony_ci</div>
89965bd8deadSopenharmony_ci<div class="sect3">
89975bd8deadSopenharmony_ci<h4 id="the-invariant-qualifier">4.8.1. The Invariant Qualifier</h4>
89985bd8deadSopenharmony_ci<div class="paragraph">
89995bd8deadSopenharmony_ci<p>To ensure that a particular output variable is invariant, it is necessary to
90005bd8deadSopenharmony_ciuse the <strong>invariant</strong> qualifier.
90015bd8deadSopenharmony_ciIt can either be used to qualify a previously declared variable as being
90025bd8deadSopenharmony_ciinvariant:</p>
90035bd8deadSopenharmony_ci</div>
90045bd8deadSopenharmony_ci<div class="listingblock">
90055bd8deadSopenharmony_ci<div class="content">
90065bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">invariant gl_Position; <span class="comment">// make existing gl_Position be invariant</span>
90075bd8deadSopenharmony_ciout vec3 Color;
90085bd8deadSopenharmony_ciinvariant Color;       <span class="comment">// make existing Color be invariant</span></code></pre>
90095bd8deadSopenharmony_ci</div>
90105bd8deadSopenharmony_ci</div>
90115bd8deadSopenharmony_ci<div class="paragraph">
90125bd8deadSopenharmony_ci<p>or as part of a declaration when a variable is declared:</p>
90135bd8deadSopenharmony_ci</div>
90145bd8deadSopenharmony_ci<div class="listingblock">
90155bd8deadSopenharmony_ci<div class="content">
90165bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">invariant centroid out vec3 Color;</code></pre>
90175bd8deadSopenharmony_ci</div>
90185bd8deadSopenharmony_ci</div>
90195bd8deadSopenharmony_ci<div class="paragraph">
90205bd8deadSopenharmony_ci<p>Only variables output from a shader can be candidates for invariance.
90215bd8deadSopenharmony_ciThis includes user-defined output variables and the built-in output
90225bd8deadSopenharmony_civariables.
90235bd8deadSopenharmony_ciAs only outputs can be declared as invariant, an output from one shader
90245bd8deadSopenharmony_cistage will still match an input of a subsequent stage without the input
90255bd8deadSopenharmony_cibeing declared as invariant.</p>
90265bd8deadSopenharmony_ci</div>
90275bd8deadSopenharmony_ci<div class="paragraph">
90285bd8deadSopenharmony_ci<p>Input or output instance names on blocks are not used when redeclaring
90295bd8deadSopenharmony_cibuilt-in variables.</p>
90305bd8deadSopenharmony_ci</div>
90315bd8deadSopenharmony_ci<div class="paragraph">
90325bd8deadSopenharmony_ci<p>The <strong>invariant</strong> keyword can be followed by a comma separated list of
90335bd8deadSopenharmony_cipreviously declared identifiers.
90345bd8deadSopenharmony_ciAll uses of <strong>invariant</strong> must be at global scope or on block
90355bd8deadSopenharmony_cimembers, and before any use of the variables being declared as invariant.</p>
90365bd8deadSopenharmony_ci</div>
90375bd8deadSopenharmony_ci<div class="paragraph">
90385bd8deadSopenharmony_ci<p>To guarantee invariance of a particular output variable across two programs,
90395bd8deadSopenharmony_cithe following must also be true:</p>
90405bd8deadSopenharmony_ci</div>
90415bd8deadSopenharmony_ci<div class="ulist">
90425bd8deadSopenharmony_ci<ul>
90435bd8deadSopenharmony_ci<li>
90445bd8deadSopenharmony_ci<p>The output variable is declared as invariant in both programs.</p>
90455bd8deadSopenharmony_ci</li>
90465bd8deadSopenharmony_ci<li>
90475bd8deadSopenharmony_ci<p>The same values must be input to all shader input variables consumed by
90485bd8deadSopenharmony_ciexpressions and control flow contributing to the value assigned to the
90495bd8deadSopenharmony_cioutput variable.</p>
90505bd8deadSopenharmony_ci</li>
90515bd8deadSopenharmony_ci<li>
90525bd8deadSopenharmony_ci<p>The texture formats, texel values, and texture filtering are set the
90535bd8deadSopenharmony_cisame way for any texture function calls contributing to the value of the
90545bd8deadSopenharmony_cioutput variable.</p>
90555bd8deadSopenharmony_ci</li>
90565bd8deadSopenharmony_ci<li>
90575bd8deadSopenharmony_ci<p>All input values are all operated on in the same way.
90585bd8deadSopenharmony_ci    All operations in the consuming expressions and any intermediate
90595bd8deadSopenharmony_ci    expressions must be the same, with the same order of operands and same
90605bd8deadSopenharmony_ci    associativity, to give the same order of evaluation.
90615bd8deadSopenharmony_ci    Intermediate variables and functions must be declared as the same type
90625bd8deadSopenharmony_ci    with the same explicit or implicit precision
90635bd8deadSopenharmony_ciqualifiers.
90645bd8deadSopenharmony_ci    Any control flow affecting the output value must be the same, and any
90655bd8deadSopenharmony_ci    expressions consumed to determine this control flow must also follow
90665bd8deadSopenharmony_ci    these invariance rules.</p>
90675bd8deadSopenharmony_ci</li>
90685bd8deadSopenharmony_ci<li>
90695bd8deadSopenharmony_ci<p>All the data flow and control flow leading to setting the invariant
90705bd8deadSopenharmony_cioutput variable reside in a single compilation unit.</p>
90715bd8deadSopenharmony_ci</li>
90725bd8deadSopenharmony_ci</ul>
90735bd8deadSopenharmony_ci</div>
90745bd8deadSopenharmony_ci<div class="paragraph">
90755bd8deadSopenharmony_ci<p>Essentially, all the data flow and control flow leading to an invariant
90765bd8deadSopenharmony_cioutput must match.</p>
90775bd8deadSopenharmony_ci</div>
90785bd8deadSopenharmony_ci<div class="paragraph">
90795bd8deadSopenharmony_ci<p>Initially, by default, all output variables are allowed to be variant.
90805bd8deadSopenharmony_ciTo force all output variables to be invariant, use the pragma</p>
90815bd8deadSopenharmony_ci</div>
90825bd8deadSopenharmony_ci<div class="listingblock">
90835bd8deadSopenharmony_ci<div class="content">
90845bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="preprocessor">#pragma</span> STDGL invariant(all)</code></pre>
90855bd8deadSopenharmony_ci</div>
90865bd8deadSopenharmony_ci</div>
90875bd8deadSopenharmony_ci<div class="paragraph">
90885bd8deadSopenharmony_ci<p>before all declarations in a shader.
90895bd8deadSopenharmony_ciIf this pragma is used after the declaration of any variables or functions,
90905bd8deadSopenharmony_cithen the set of outputs that behave as invariant is undefined.</p>
90915bd8deadSopenharmony_ci</div>
90925bd8deadSopenharmony_ci<div class="paragraph">
90935bd8deadSopenharmony_ci<p>Generally, invariance is ensured at the cost of flexibility in optimization,
90945bd8deadSopenharmony_ciso performance can be degraded by use of invariance.
90955bd8deadSopenharmony_ciHence, use of this pragma is intended as a debug aid, to avoid individually
90965bd8deadSopenharmony_cideclaring all output variables as invariant.</p>
90975bd8deadSopenharmony_ci</div>
90985bd8deadSopenharmony_ci</div>
90995bd8deadSopenharmony_ci<div class="sect3">
91005bd8deadSopenharmony_ci<h4 id="invariance-of-constant-expressions">4.8.2. Invariance of Constant Expressions</h4>
91015bd8deadSopenharmony_ci<div class="paragraph">
91025bd8deadSopenharmony_ci<p>Invariance must be guaranteed for constant expressions.
91035bd8deadSopenharmony_ciA particular constant expression must evaluate to the same result if it
91045bd8deadSopenharmony_ciappears again in the same shader or a different shader.
91055bd8deadSopenharmony_ciThis includes the same expression appearing in two shaders of the same
91065bd8deadSopenharmony_cilanguage or shaders of two different languages.</p>
91075bd8deadSopenharmony_ci</div>
91085bd8deadSopenharmony_ci<div class="paragraph">
91095bd8deadSopenharmony_ci<p>Constant expressions must evaluate to the same result when operated on as
91105bd8deadSopenharmony_cialready described above for invariant variables.</p>
91115bd8deadSopenharmony_ci</div>
91125bd8deadSopenharmony_ci</div>
91135bd8deadSopenharmony_ci</div>
91145bd8deadSopenharmony_ci<div class="sect2">
91155bd8deadSopenharmony_ci<h3 id="the-precise-qualifier">4.9. The Precise Qualifier</h3>
91165bd8deadSopenharmony_ci<div class="paragraph">
91175bd8deadSopenharmony_ci<p>Some algorithms require floating-point computations to exactly follow the
91185bd8deadSopenharmony_ciorder of operations specified in the source code and to treat all operations
91195bd8deadSopenharmony_ciconsistently, even if the implementation supports optimizations that could
91205bd8deadSopenharmony_ciproduce nearly equivalent results with higher performance.
91215bd8deadSopenharmony_ciFor example, many GL implementations support a &#8220;multiply-add&#8221; instruction
91225bd8deadSopenharmony_cithat can compute a floating-point expression such as</p>
91235bd8deadSopenharmony_ci</div>
91245bd8deadSopenharmony_ci<div class="listingblock">
91255bd8deadSopenharmony_ci<div class="content">
91265bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">result = (a * b) + (c * d);</code></pre>
91275bd8deadSopenharmony_ci</div>
91285bd8deadSopenharmony_ci</div>
91295bd8deadSopenharmony_ci<div class="paragraph">
91305bd8deadSopenharmony_ci<p>in two operations instead of three operations; one multiply and one
91315bd8deadSopenharmony_cimultiply-add instead of two multiplies and one add.
91325bd8deadSopenharmony_ciThe result of a floating-point multiply-add might not always be identical to
91335bd8deadSopenharmony_cifirst doing a multiply yielding a floating-point result and then doing a
91345bd8deadSopenharmony_cifloating-point add.
91355bd8deadSopenharmony_ciHence, in this example, the two multiply operations would not be treated
91365bd8deadSopenharmony_ciconsistently; the two multiplies could effectively appear to have differing
91375bd8deadSopenharmony_ciprecisions.</p>
91385bd8deadSopenharmony_ci</div>
91395bd8deadSopenharmony_ci<div class="paragraph">
91405bd8deadSopenharmony_ci<p>The key computation that needs to be made consistent appears when
91415bd8deadSopenharmony_citessellating, where intermediate points for subdivision are synthesized in
91425bd8deadSopenharmony_cidifferent directions, yet need to yield the same result, as shown in the
91435bd8deadSopenharmony_cidiagram below.</p>
91445bd8deadSopenharmony_ci</div>
91455bd8deadSopenharmony_ci<div id="img-precise" class="imageblock">
91465bd8deadSopenharmony_ci<div class="content">
91475bd8deadSopenharmony_ci<img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KCjxzdmcgdmVyc2lvbj0iMS4yIiBiYXNlUHJvZmlsZT0idGlueSIgd2lkdGg9IjIxMG1tIiBoZWlnaHQ9IjI5N21tIiB2aWV3Qm94PSIwIDAgMjEwMDAgMjk3MDAiIHByZXNlcnZlQXNwZWN0UmF0aW89InhNaWRZTWlkIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcGF0aD0idXJsKCNwcmVzZW50YXRpb25fY2xpcF9wYXRoKSIgc3Ryb2tlLXdpZHRoPSIyOC4yMjIiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6b29vPSJodHRwOi8veG1sLm9wZW5vZmZpY2Uub3JnL3N2Zy9leHBvcnQiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWw6c3BhY2U9InByZXNlcnZlIj4KIDxkZWZzIGNsYXNzPSJDbGlwUGF0aEdyb3VwIj4KICA8Y2xpcFBhdGggaWQ9InByZXNlbnRhdGlvbl9jbGlwX3BhdGgiIGNsaXBQYXRoVW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KICAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjIxMDAwIiBoZWlnaHQ9IjI5NzAwIi8+CiAgPC9jbGlwUGF0aD4KIDwvZGVmcz4KIDxkZWZzPgogIDxmb250IGlkPSJFbWJlZGRlZEZvbnRfMSIgaG9yaXotYWR2LXg9IjIwNDgiPgogICA8Zm9udC1mYWNlIGZvbnQtZmFtaWx5PSJMaWJlcmF0aW9uIFNhbnMgZW1iZWRkZWQiIHVuaXRzLXBlci1lbT0iMjA0OCIgZm9udC13ZWlnaHQ9Im5vcm1hbCIgZm9udC1zdHlsZT0ibm9ybWFsIiBhc2NlbnQ9IjE4NTIiIGRlc2NlbnQ9IjQyMyIvPgogICA8bWlzc2luZy1nbHlwaCBob3Jpei1hZHYteD0iMjA0OCIgZD0iTSAwLDAgTCAyMDQ3LDAgMjA0NywyMDQ3IDAsMjA0NyAwLDAgWiIvPgogICA8Z2x5cGggdW5pY29kZT0idyIgaG9yaXotYWR2LXg9IjE1MDkiIGQ9Ik0gMTE3NCwwIEwgOTY1LDAgNzkyLDY5OCBDIDc4Nyw3MTYgNzgxLDczOCA3NzYsNzY1IDc3MCw3OTIgNzY0LDgxOCA3NTksODQzIDc1Miw4NzIgNzQ2LDkwMyA3NDAsOTM0IDczNCw5MDQgNzI4LDg3NCA3MjEsODQ1IDcxNiw4MjAgNzEwLDc5MyA3MDQsNzY2IDY5Nyw3MzkgNjkxLDcxNSA2ODYsNjk0IEwgNTA4LDAgMzAwLDAgLTMsMTA4MiAxNzUsMTA4MiAzNTgsMzQ3IEMgMzYzLDMzMiAzNjcsMzEzIDM3MiwyOTEgMzc3LDI2OCAzODEsMjQ2IDM4NiwyMjUgMzkxLDIwMCAzOTYsMTc1IDQwMSwxNDkgNDA2LDE3NCA0MTIsMTk5IDQxOCwyMjMgNDIzLDI0NCA0MjksMjY1IDQzNCwyODYgNDM5LDMwNyA0NDQsMzI1IDQ0OCwzMzkgTCA2NDQsMTA4MiA4MzcsMTA4MiAxMDI2LDMzOSBDIDEwMzEsMzIyIDEwMzYsMzAyIDEwNDEsMjgwIDEwNDYsMjU4IDEwNTEsMjM3IDEwNTYsMjE4IDEwNjEsMTk1IDEwNjcsMTcyIDEwNzIsMTQ5IDEwNzcsMTc0IDEwODMsMTk5IDEwODgsMjIzIDEwOTMsMjQ0IDEwOTgsMjY1IDExMDMsMjg4IDExMDgsMzEwIDExMTIsMzMwIDExMTcsMzQ3IEwgMTMwOCwxMDgyIDE0ODQsMTA4MiAxMTc0LDAgWiIvPgogICA8Z2x5cGggdW5pY29kZT0idiIgaG9yaXotYWR2LXg9IjEwMzMiIGQ9Ik0gNjEzLDAgTCA0MDAsMCA3LDEwODIgMTk5LDEwODIgNDM3LDM3OCBDIDQ0MiwzNjMgNDQ3LDM0NiA0NTQsMzI1IDQ2MCwzMDQgNDY2LDI4MiA0NzMsMjU5IDQ4MCwyMzYgNDg2LDIxNSA0OTIsMTk0IDQ5NywxNzMgNTAyLDE1NSA1MDYsMTQxIDUxMCwxNTUgNTE1LDE3MyA1MjIsMTk0IDUyOCwyMTUgNTM0LDIzNiA1NDEsMjU4IDU0OCwyODAgNTU1LDMwMiA1NjIsMzIzIDU2OSwzNDQgNTc1LDM2MSA1ODAsMzc2IEwgODI2LDEwODIgMTAxNywxMDgyIDYxMywwIFoiLz4KICAgPGdseXBoIHVuaWNvZGU9InUiIGhvcml6LWFkdi14PSI4NzQiIGQ9Ik0gMzE0LDEwODIgTCAzMTQsMzk2IEMgMzE0LDM0MyAzMTgsMjk5IDMyNiwyNjQgMzMzLDIyOSAzNDYsMjAwIDM2MywxNzkgMzgwLDE1NyA0MDMsMTQyIDQzMiwxMzMgNDYwLDEyNCA0OTUsMTE5IDUzNywxMTkgNTgwLDExOSA2MTgsMTI3IDY1MywxNDIgNjg3LDE1NyA3MTYsMTc4IDc0MSwyMDcgNzY1LDIzNSA3ODQsMjcwIDc5NywzMTIgODEwLDM1MyA4MTcsNDAxIDgxNyw0NTUgTCA4MTcsMTA4MiA5OTcsMTA4MiA5OTcsMjMxIEMgOTk3LDIwOCA5OTcsMTg1IDk5OCwxNjAgOTk4LDEzNSA5OTgsMTExIDk5OSw4OSAxMDAwLDY2IDEwMDAsNDcgMTAwMSwzMSAxMDAyLDE1IDEwMDIsNSAxMDAzLDAgTCA4MzMsMCBDIDgzMiwzIDgzMiwxMiA4MzEsMjcgODMwLDQyIDgzMCw1OSA4MjksNzggODI4LDk3IDgyNywxMTYgODI2LDEzNiA4MjUsMTU1IDgyNSwxNzIgODI1LDE4NSBMIDgyMiwxODUgQyA4MDUsMTU0IDc4NiwxMjUgNzY1LDEwMCA3NDQsNzUgNzIwLDUzIDY5MywzNiA2NjYsMTggNjM0LDQgNTk5LC02IDU2NCwtMTUgNTIzLC0yMCA0NzYsLTIwIDQxNiwtMjAgMzY0LC0xMyAzMjEsMiAyNzgsMTcgMjQyLDM5IDIxNCw3MCAxODYsMTAxIDE2NiwxNDAgMTUzLDE4OCAxNDAsMjM2IDEzMywyOTQgMTMzLDM2MSBMIDEzMywxMDgyIDMxNCwxMDgyIFoiLz4KICAgPGdseXBoIHVuaWNvZGU9InQiIGhvcml6LWFkdi14PSI1MzEiIGQ9Ik0gNTU0LDggQyA1MjcsMSA0OTksLTUgNDcxLC0xMCA0NDIsLTE0IDQwOSwtMTYgMzcyLC0xNiAyMjgsLTE2IDE1Niw2NiAxNTYsMjI5IEwgMTU2LDk1MSAzMSw5NTEgMzEsMTA4MiAxNjMsMTA4MiAyMTYsMTMyNCAzMzYsMTMyNCAzMzYsMTA4MiA1MzYsMTA4MiA1MzYsOTUxIDMzNiw5NTEgMzM2LDI2OCBDIDMzNiwyMTYgMzQ1LDE4MCAzNjIsMTU5IDM3OSwxMzggNDA4LDEyNyA0NTAsMTI3IDQ2NywxMjcgNDg0LDEyOCA1MDEsMTMxIDUxNywxMzQgNTM1LDEzNyA1NTQsMTQxIEwgNTU0LDggWiIvPgogICA8Z2x5cGggdW5pY29kZT0icyIgaG9yaXotYWR2LXg9IjkwMSIgZD0iTSA5NTAsMjk5IEMgOTUwLDI0OCA5NDAsMjAzIDkyMSwxNjQgOTAxLDEyNCA4NzIsOTEgODM1LDY0IDc5OCwzNyA3NTIsMTYgNjk4LDIgNjQzLC0xMyA1ODEsLTIwIDUxMSwtMjAgNDQ4LC0yMCAzOTIsLTE1IDM0MiwtNiAyOTEsNCAyNDcsMjAgMjA5LDQxIDE3MSw2MiAxMzksOTEgMTE0LDEyNiA4OCwxNjEgNjksMjAzIDU3LDI1NCBMIDIxNiwyODUgQyAyMzEsMjI3IDI2MywxODUgMzExLDE1OCAzNTksMTMxIDQyNiwxMTcgNTExLDExNyA1NTAsMTE3IDU4NSwxMjAgNjE4LDEyNSA2NTAsMTMwIDY3OCwxNDAgNzAxLDE1MyA3MjQsMTY2IDc0MywxODMgNzU2LDIwNSA3NjksMjI2IDc3NSwyNTMgNzc1LDI4NSA3NzUsMzE4IDc2NywzNDUgNzUyLDM2NiA3MzcsMzg3IDcxNSw0MDQgNjg4LDQxOCA2NjEsNDMyIDYyOCw0NDQgNTg5LDQ1NSA1NTAsNDY1IDUwNyw0NzYgNDYwLDQ4OSA0MTcsNTAwIDM3NCw1MTMgMzMxLDUyNyAyODgsNTQxIDI1MCw1NjAgMjE2LDU4MyAxODEsNjA2IDE1Myw2MzQgMTMyLDY2OCAxMTEsNzAyIDEwMCw3NDUgMTAwLDc5NiAxMDAsODk1IDEzNSw5NzAgMjA2LDEwMjIgMjc2LDEwNzMgMzc4LDEwOTkgNTEzLDEwOTkgNjMyLDEwOTkgNzI3LDEwNzggNzk4LDEwMzYgODY4LDk5NCA5MTIsOTI3IDkzMSw4MzQgTCA3NjksODE0IEMgNzYzLDg0MiA3NTIsODY2IDczNiw4ODUgNzIwLDkwNCA3MDEsOTE5IDY3OCw5MzEgNjU1LDk0MiA2MzAsOTUxIDYwMiw5NTYgNTczLDk2MSA1NDQsOTYzIDUxMyw5NjMgNDMyLDk2MyAzNzIsOTUxIDMzMyw5MjYgMjk0LDkwMSAyNzUsODY0IDI3NSw4MTQgMjc1LDc4NSAyODIsNzYxIDI5Nyw3NDIgMzExLDcyMyAzMzEsNzA3IDM1Nyw2OTQgMzgyLDY4MSA0MTMsNjY5IDQ0OSw2NjAgNDg1LDY1MCA1MjUsNjQwIDU2OCw2MjkgNTk3LDYyMiA2MjYsNjE0IDY1Niw2MDYgNjg2LDU5NyA3MTUsNTg3IDc0NCw1NzYgNzcyLDU2NCA3OTksNTUwIDgyNCw1MzUgODQ5LDUxOSA4NzAsNTAwIDg4OSw0NzggOTA4LDQ1NiA5MjMsNDMwIDkzNCw0MDEgOTQ1LDM3MiA5NTAsMzM4IDk1MCwyOTkgWiIvPgogICA8Z2x5cGggdW5pY29kZT0iciIgaG9yaXotYWR2LXg9IjUzMCIgZD0iTSAxNDIsMCBMIDE0Miw4MzAgQyAxNDIsODUzIDE0Miw4NzYgMTQyLDkwMCAxNDEsOTIzIDE0MSw5NDYgMTQwLDk2OCAxMzksOTkwIDEzOSwxMDExIDEzOCwxMDMwIDEzNywxMDQ5IDEzNywxMDY3IDEzNiwxMDgyIEwgMzA2LDEwODIgQyAzMDcsMTA2NyAzMDgsMTA0OSAzMDksMTAzMCAzMTAsMTAxMCAzMTEsOTkwIDMxMiw5NjkgMzEzLDk0OCAzMTMsOTI5IDMxNCw5MTAgMzE0LDg5MSAzMTQsODc0IDMxNCw4NjEgTCAzMTgsODYxIEMgMzMxLDkwMiAzNDQsOTM4IDM1OSw5NjkgMzczLDk5OSAzOTAsMTAyNCA0MDksMTA0NCA0MjgsMTA2MyA0NTEsMTA3OCA0NzgsMTA4OCA1MDUsMTA5NyA1MzcsMTEwMiA1NzUsMTEwMiA1OTAsMTEwMiA2MDQsMTEwMSA2MTcsMTA5OSA2MzAsMTA5NiA2NDEsMTA5NCA2NDgsMTA5MiBMIDY0OCw5MjcgQyA2MzYsOTMwIDYyMiw5MzMgNjA2LDkzNSA1OTAsOTM2IDU3Miw5MzcgNTUyLDkzNyA1MTEsOTM3IDQ3Niw5MjggNDQ3LDkwOSA0MTgsODkwIDM5NCw4NjUgMzc2LDgzMiAzNTcsNzk5IDM0NCw3NTkgMzM1LDcxNCAzMjYsNjY4IDMyMiw2MTggMzIyLDU2NCBMIDMyMiwwIDE0MiwwIFoiLz4KICAgPGdseXBoIHVuaWNvZGU9InAiIGhvcml6LWFkdi14PSI5NTMiIGQ9Ik0gMTA1Myw1NDYgQyAxMDUzLDQ2NCAxMDQ2LDM4OCAxMDMzLDMxOSAxMDIwLDI1MCA5OTgsMTkwIDk2NywxNDAgOTM2LDkwIDg5NSw1MSA4NDQsMjMgNzkzLC02IDczMCwtMjAgNjU1LC0yMCA1NzgsLTIwIDUxMCwtNSA0NTIsMjQgMzk0LDUzIDM1MCwxMDEgMzE5LDE2OCBMIDMxNCwxNjggQyAzMTUsMTY3IDMxNSwxNjEgMzE2LDE1MCAzMTYsMTM5IDMxNiwxMjYgMzE3LDExMCAzMTcsOTQgMzE3LDc2IDMxOCw1NyAzMTgsMzcgMzE4LDE3IDMxOCwtMiBMIDMxOCwtNDI1IDEzOCwtNDI1IDEzOCw4NjEgQyAxMzgsODg3IDEzOCw5MTIgMTM4LDkzNiAxMzcsOTYwIDEzNyw5ODIgMTM2LDEwMDIgMTM1LDEwMjEgMTM1LDEwMzggMTM0LDEwNTIgMTMzLDEwNjYgMTMzLDEwNzYgMTMyLDEwODIgTCAzMDYsMTA4MiBDIDMwNywxMDgwIDMwOCwxMDczIDMwOSwxMDYxIDMxMCwxMDQ5IDMxMSwxMDM1IDMxMiwxMDE4IDMxMywxMDAxIDMxNCw5ODIgMzE1LDk2MyAzMTYsOTQ0IDMxNiw5MjUgMzE2LDkwOCBMIDMyMCw5MDggQyAzMzcsOTQzIDM1Niw5NzIgMzc3LDk5NyAzOTgsMTAyMSA0MjMsMTA0MSA0NTAsMTA1NyA0NzcsMTA3MiA1MDgsMTA4NCA1NDIsMTA5MSA1NzUsMTA5OCA2MTMsMTEwMSA2NTUsMTEwMSA3MzAsMTEwMSA3OTMsMTA4OCA4NDQsMTA2MSA4OTUsMTAzNCA5MzYsOTk3IDk2Nyw5NDkgOTk4LDkwMCAxMDIwLDg0MiAxMDMzLDc3NCAxMDQ2LDcwNSAxMDUzLDYyOSAxMDUzLDU0NiBaIE0gODY0LDU0MiBDIDg2NCw2MDkgODYwLDY2OCA4NTIsNzIwIDg0NCw3NzIgODMwLDgxNiA4MTEsODUyIDc5MSw4ODggNzY1LDkxNSA3MzIsOTM0IDY5OSw5NTMgNjU4LDk2MiA2MDksOTYyIDU2OSw5NjIgNTMxLDk1NiA0OTYsOTQ1IDQ2MSw5MzQgNDMwLDkxMiA0MDQsODgwIDM3Nyw4NDggMzU2LDgwNCAzNDEsNzQ4IDMyNiw2OTEgMzE4LDYxOCAzMTgsNTI4IDMxOCw0NTEgMzI0LDM4NyAzMzcsMzM0IDM1MCwyODEgMzY4LDIzOCAzOTMsMjA1IDQxNywxNzIgNDQ3LDE0OSA0ODMsMTM1IDUxOSwxMjAgNTYwLDExMyA2MDcsMTEzIDY1NywxMTMgNjk5LDEyMyA3MzIsMTQyIDc2NSwxNjEgNzkxLDE4OSA4MTEsMjI2IDgzMCwyNjMgODQ0LDMwOCA4NTIsMzYxIDg2MCw0MTQgODY0LDQ3NCA4NjQsNTQyIFoiLz4KICAgPGdseXBoIHVuaWNvZGU9Im8iIGhvcml6LWFkdi14PSI5ODAiIGQ9Ik0gMTA1Myw1NDIgQyAxMDUzLDM1MyAxMDExLDIxMiA5MjgsMTE5IDg0NSwyNiA3MjQsLTIwIDU2NSwtMjAgNDkwLC0yMCA0MjIsLTkgMzYzLDE0IDMwNCwzNyAyNTQsNzEgMjEzLDExOCAxNzIsMTY1IDE0MCwyMjMgMTE5LDI5NCA5NywzNjQgODYsNDQ3IDg2LDU0MiA4Niw5MTUgMjQ4LDExMDIgNTcxLDExMDIgNjU1LDExMDIgNzI4LDEwOTAgNzg5LDEwNjcgODUwLDEwNDQgOTAwLDEwMDkgOTM5LDk2MiA5NzgsOTE1IDEwMDYsODU3IDEwMjUsNzg3IDEwNDQsNzE3IDEwNTMsNjM1IDEwNTMsNTQyIFogTSA4NjQsNTQyIEMgODY0LDYyNiA4NTgsNjk1IDg0NSw3NTAgODMyLDgwNSA4MTMsODQ4IDc4OCw4ODEgNzYzLDkxNCA3MzIsOTM3IDY5Niw5NTAgNjYwLDk2MyA2MTksOTY5IDU3NCw5NjkgNTI4LDk2OSA0ODcsOTYyIDQ1MCw5NDkgNDEzLDkzNSAzODEsOTEyIDM1NSw4NzkgMzI5LDg0NiAzMDksODAyIDI5Niw3NDcgMjgyLDY5MiAyNzUsNjI0IDI3NSw1NDIgMjc1LDQ1OCAyODIsMzg5IDI5NywzMzQgMzEyLDI3OSAzMzIsMjM1IDM1OCwyMDIgMzgzLDE2OSA0MTQsMTQ2IDQ0OSwxMzMgNDg0LDEyMCA1MjIsMTEzIDU2MywxMTMgNjA5LDExMyA2NTEsMTIwIDY4OCwxMzMgNzI1LDE0NiA3NTcsMTY4IDc4MywyMDEgODA5LDIzNCA4MjksMjc4IDg0MywzMzMgODU3LDM4OCA4NjQsNDU4IDg2NCw1NDIgWiIvPgogICA8Z2x5cGggdW5pY29kZT0ibiIgaG9yaXotYWR2LXg9Ijg3NCIgZD0iTSA4MjUsMCBMIDgyNSw2ODYgQyA4MjUsNzM5IDgyMSw3ODMgODE0LDgxOCA4MDYsODUzIDc5Myw4ODIgNzc2LDkwNCA3NTksOTI1IDczNiw5NDEgNzA4LDk1MCA2NzksOTU5IDY0NCw5NjMgNjAyLDk2MyA1NTksOTYzIDUyMSw5NTYgNDg3LDk0MSA0NTIsOTI2IDQyMyw5MDQgMzk5LDg3NiAzNzQsODQ3IDM1NSw4MTIgMzQyLDc3MSAzMjksNzI5IDMyMiw2ODEgMzIyLDYyNyBMIDMyMiwwIDE0MiwwIDE0Miw4NTEgQyAxNDIsODc0IDE0Miw4OTggMTQyLDkyMyAxNDEsOTQ4IDE0MSw5NzEgMTQwLDk5NCAxMzksMTAxNiAxMzksMTAzNSAxMzgsMTA1MSAxMzcsMTA2NyAxMzcsMTA3NyAxMzYsMTA4MiBMIDMwNiwxMDgyIEMgMzA3LDEwNzkgMzA3LDEwNzAgMzA4LDEwNTUgMzA5LDEwNDAgMzEwLDEwMjQgMzExLDEwMDUgMzEyLDk4NiAzMTIsOTY2IDMxMyw5NDcgMzE0LDkyNyAzMTQsOTEwIDMxNCw4OTcgTCAzMTcsODk3IEMgMzM0LDkyOCAzNTMsOTU3IDM3NCw5ODIgMzk1LDEwMDcgNDE5LDEwMjkgNDQ2LDEwNDcgNDczLDEwNjQgNTA1LDEwNzggNTQwLDEwODggNTc1LDEwOTcgNjE2LDExMDIgNjYzLDExMDIgNzIzLDExMDIgNzc1LDEwOTUgODE4LDEwODAgODYxLDEwNjUgODk3LDEwNDMgOTI1LDEwMTIgOTUzLDk4MSA5NzQsOTQyIDk4Nyw4OTQgMTAwMCw4NDUgMTAwNiw3ODggMTAwNiw3MjEgTCAxMDA2LDAgODI1LDAgWiIvPgogICA8Z2x5cGggdW5pY29kZT0ibSIgaG9yaXotYWR2LXg9IjE0NTciIGQ9Ik0gNzY4LDAgTCA3NjgsNjg2IEMgNzY4LDczOSA3NjUsNzgzIDc1OCw4MTggNzUxLDg1MyA3NDAsODgyIDcyNSw5MDQgNzA5LDkyNSA2ODgsOTQxIDY2Myw5NTAgNjM4LDk1OSA2MDcsOTYzIDU3MCw5NjMgNTMyLDk2MyA0OTgsOTU2IDQ2Nyw5NDEgNDM2LDkyNiA0MTAsOTA0IDM4OSw4NzYgMzY3LDg0NyAzNTAsODEyIDMzOSw3NzEgMzI3LDcyOSAzMjEsNjgxIDMyMSw2MjcgTCAzMjEsMCAxNDIsMCAxNDIsODUxIEMgMTQyLDg3NCAxNDIsODk4IDE0Miw5MjMgMTQxLDk0OCAxNDEsOTcxIDE0MCw5OTQgMTM5LDEwMTYgMTM5LDEwMzUgMTM4LDEwNTEgMTM3LDEwNjcgMTM3LDEwNzcgMTM2LDEwODIgTCAzMDYsMTA4MiBDIDMwNywxMDc5IDMwNywxMDcwIDMwOCwxMDU1IDMwOSwxMDQwIDMxMCwxMDI0IDMxMSwxMDA1IDMxMiw5ODYgMzEyLDk2NiAzMTMsOTQ3IDMxNCw5MjcgMzE0LDkxMCAzMTQsODk3IEwgMzE3LDg5NyBDIDMzMyw5MjggMzUwLDk1NyAzNjksOTgyIDM4OCwxMDA3IDQxMCwxMDI5IDQzNSwxMDQ3IDQ2MCwxMDY0IDQ4OCwxMDc4IDUyMSwxMDg4IDU1MywxMDk3IDU5MCwxMTAyIDYzMywxMTAyIDcxNSwxMTAyIDc4MCwxMDg2IDgyOCwxMDUzIDg3NSwxMDIwIDkwOCw5NjggOTI3LDg5NyBMIDkzMCw4OTcgQyA5NDYsOTI4IDk2NCw5NTcgOTg0LDk4MiAxMDA0LDEwMDcgMTAyNywxMDI5IDEwNTQsMTA0NyAxMDgxLDEwNjQgMTExMSwxMDc4IDExNDQsMTA4OCAxMTc3LDEwOTcgMTIxNSwxMTAyIDEyNTgsMTEwMiAxMzEzLDExMDIgMTM2MCwxMDk1IDE0MDAsMTA4MCAxNDM5LDEwNjUgMTQ3MiwxMDQzIDE0OTcsMTAxMiAxNTIyLDk4MSAxNTQxLDk0MiAxNTUzLDg5NCAxNTY1LDg0NSAxNTcxLDc4OCAxNTcxLDcyMSBMIDE1NzEsMCAxMzkzLDAgMTM5Myw2ODYgQyAxMzkzLDczOSAxMzkwLDc4MyAxMzgzLDgxOCAxMzc2LDg1MyAxMzY1LDg4MiAxMzUwLDkwNCAxMzM0LDkyNSAxMzEzLDk0MSAxMjg4LDk1MCAxMjYzLDk1OSAxMjMyLDk2MyAxMTk1LDk2MyAxMTU3LDk2MyAxMTIzLDk1NiAxMDkyLDk0MiAxMDYxLDkyNyAxMDM1LDkwNiAxMDE0LDg3OCA5OTIsODUwIDk3NSw4MTUgOTY0LDc3MyA5NTIsNzMxIDk0Niw2ODIgOTQ2LDYyNyBMIDk0NiwwIDc2OCwwIFoiLz4KICAgPGdseXBoIHVuaWNvZGU9ImwiIGhvcml6LWFkdi14PSIxODciIGQ9Ik0gMTM4LDAgTCAxMzgsMTQ4NCAzMTgsMTQ4NCAzMTgsMCAxMzgsMCBaIi8+CiAgIDxnbHlwaCB1bmljb2RlPSJrIiBob3Jpei1hZHYteD0iOTAxIiBkPSJNIDgxNiwwIEwgNDUwLDQ5NCAzMTgsMzg1IDMxOCwwIDEzOCwwIDEzOCwxNDg0IDMxOCwxNDg0IDMxOCw1NTcgNzkzLDEwODIgMTAwNCwxMDgyIDU2NSw2MTcgMTAyNywwIDgxNiwwIFoiLz4KICAgPGdseXBoIHVuaWNvZGU9ImkiIGhvcml6LWFkdi14PSIxODciIGQ9Ik0gMTM3LDEzMTIgTCAxMzcsMTQ4NCAzMTcsMTQ4NCAzMTcsMTMxMiAxMzcsMTMxMiBaIE0gMTM3LDAgTCAxMzcsMTA4MiAzMTcsMTA4MiAzMTcsMCAxMzcsMCBaIi8+CiAgIDxnbHlwaCB1bmljb2RlPSJoIiBob3Jpei1hZHYteD0iODc0IiBkPSJNIDMxNyw4OTcgQyAzMzcsOTM0IDM1OSw5NjUgMzgyLDk5MSA0MDUsMTAxNiA0MzEsMTAzNyA0NTksMTA1NCA0ODcsMTA3MSA1MTgsMTA4MyA1NTEsMTA5MSA1ODQsMTA5OCA2MjIsMTEwMiA2NjMsMTEwMiA3MzIsMTEwMiA3ODksMTA5MyA4MzQsMTA3NCA4NzgsMTA1NSA5MTMsMTAyOSA5MzksOTk2IDk2NCw5NjIgOTgyLDkyMiA5OTIsODc1IDEwMDEsODI4IDEwMDYsNzc3IDEwMDYsNzIxIEwgMTAwNiwwIDgyNSwwIDgyNSw2ODYgQyA4MjUsNzMyIDgyMiw3NzIgODE3LDgwNyA4MTEsODQyIDgwMCw4NzEgNzg0LDg5NCA3NjgsOTE3IDc0NSw5MzQgNzE2LDk0NiA2ODcsOTU3IDY0OSw5NjMgNjAyLDk2MyA1NTksOTYzIDUyMSw5NTUgNDg3LDk0MCA0NTIsOTI1IDQyMyw5MDMgMzk5LDg3NSAzNzQsODQ3IDM1NSw4MTMgMzQyLDc3MyAzMjksNzMzIDMyMiw2ODggMzIyLDYzOCBMIDMyMiwwIDE0MiwwIDE0MiwxNDg0IDMyMiwxNDg0IDMyMiwxMDk4IEMgMzIyLDEwNzYgMzIyLDEwNTQgMzIxLDEwMzIgMzIwLDEwMTAgMzIwLDk5MCAzMTksOTcxIDMxOCw5NTIgMzE3LDkzNyAzMTYsOTI0IDMxNSw5MTEgMzE1LDkwMiAzMTQsODk3IEwgMzE3LDg5NyBaIi8+CiAgIDxnbHlwaCB1bmljb2RlPSJnIiBob3Jpei1hZHYteD0iOTI3IiBkPSJNIDU0OCwtNDI1IEMgNDg2LC00MjUgNDMxLC00MTkgMzgzLC00MDYgMzM1LC0zOTMgMjk0LC0zNzUgMjYwLC0zNTIgMjI2LC0zMjggMTk4LC0zMDAgMTc3LC0yNjcgMTU2LC0yMzQgMTQwLC0xOTggMTMxLC0xNTggTCAzMTIsLTEzMiBDIDMyNCwtMTgyIDM1MSwtMjIwIDM5MiwtMjQ4IDQzMywtMjc0IDQ4NiwtMjg4IDU1MywtMjg4IDU5NCwtMjg4IDYzMSwtMjgyIDY2NCwtMjcxIDY5NywtMjYwIDcyNiwtMjQxIDc0OSwtMjE3IDc3MiwtMTkxIDc5MCwtMTU5IDgwMywtMTE5IDgxNiwtNzkgODIyLC0zMCA4MjIsMjcgTCA4MjIsMjAxIDgyMCwyMDEgQyA4MDcsMTc0IDc5MCwxNDggNzcxLDEyMyA3NTEsOTggNzI3LDc1IDY5OSw1NiA2NzAsMzcgNjM3LDIxIDYwMCwxMCA1NjMsLTIgNTIwLC04IDQ3MiwtOCA0MDMsLTggMzQ1LDQgMjk2LDI3IDI0Nyw1MCAyMDcsODQgMTc2LDEzMCAxNDUsMTc2IDEyMiwyMzMgMTA4LDMwMiA5MywzNzAgODYsNDQ5IDg2LDUzOSA4Niw2MjYgOTMsNzA0IDEwOCw3NzMgMTIyLDg0MiAxNDUsOTAxIDE3OCw5NTAgMjEwLDk5OCAyNTIsMTAzNSAzMDQsMTA2MSAzNTUsMTA4NiA0MTgsMTA5OSA0OTIsMTA5OSA1NjksMTA5OSA2MzUsMTA4MiA2OTIsMTA0NyA3NDgsMTAxMiA3OTEsOTYyIDgyMiw4OTcgTCA4MjQsODk3IEMgODI0LDkxNCA4MjUsOTMyIDgyNiw5NTMgODI3LDk3NCA4MjgsOTkzIDgyOSwxMDEyIDgzMCwxMDMwIDgzMSwxMDQ2IDgzMiwxMDU5IDgzMywxMDcyIDgzNSwxMDgwIDgzNiwxMDgyIEwgMTAwNywxMDgyIEMgMTAwNiwxMDc2IDEwMDYsMTA2NiAxMDA1LDEwNTIgMTAwNCwxMDM3IDEwMDQsMTAyMCAxMDAzLDEwMDAgMTAwMiw5ODAgMTAwMiw5NTggMTAwMiw5MzQgMTAwMSw5MDkgMTAwMSw4ODQgMTAwMSw4NTggTCAxMDAxLDMxIEMgMTAwMSwtMTIwIDk2NCwtMjM0IDg5MCwtMzExIDgxNSwtMzg3IDcwMSwtNDI1IDU0OCwtNDI1IFogTSA4MjIsNTQxIEMgODIyLDYxNiA4MTQsNjgxIDc5OCw3MzUgNzgxLDc4OCA3NjAsODMyIDczMyw4NjYgNzA2LDkwMCA2NzYsOTI1IDY0Miw5NDEgNjA3LDk1NyA1NzIsOTY1IDUzNiw5NjUgNDkwLDk2NSA0NTEsOTU3IDQxOCw5NDEgMzg1LDkyNSAzNTcsOTAwIDMzNiw4NjYgMzE0LDgzMSAyOTgsNzg3IDI4OCw3MzQgMjc3LDY4MCAyNzIsNjE2IDI3Miw1NDEgMjcyLDQ2MyAyNzcsMzk4IDI4OCwzNDUgMjk4LDI5MiAzMTQsMjQ5IDMzNSwyMTYgMzU2LDE4MyAzODMsMTYwIDQxNiwxNDYgNDQ5LDEzMiA0ODgsMTI1IDUzMywxMjUgNTY5LDEyNSA2MDQsMTMzIDYzOSwxNDggNjczLDE2MyA3MDQsMTg4IDczMSwyMjEgNzU4LDI1NCA3ODAsMjk3IDc5NywzNTAgODE0LDQwMyA4MjIsNDY2IDgyMiw1NDEgWiIvPgogICA8Z2x5cGggdW5pY29kZT0iZiIgaG9yaXotYWR2LXg9IjU1NyIgZD0iTSAzNjEsOTUxIEwgMzYxLDAgMTgxLDAgMTgxLDk1MSAyOSw5NTEgMjksMTA4MiAxODEsMTA4MiAxODEsMTIwNCBDIDE4MSwxMjQzIDE4NSwxMjgwIDE5MiwxMzE0IDE5OSwxMzQ3IDIxMywxMzc3IDIzMywxNDAyIDI1MiwxNDI3IDI3OSwxNDQ2IDMxMywxNDYxIDM0NywxNDc1IDM5MSwxNDgyIDQ0NSwxNDgyIDQ2NiwxNDgyIDQ4OSwxNDgxIDUxMiwxNDc5IDUzNSwxNDc3IDU1NSwxNDc0IDU3MiwxNDcwIEwgNTcyLDEzMzMgQyA1NjEsMTMzNSA1NDgsMTMzNyA1MzMsMTMzOSA1MTgsMTM0MCA1MDQsMTM0MSA0OTIsMTM0MSA0NjUsMTM0MSA0NDQsMTMzNyA0MjcsMTMzMCA0MTAsMTMyMyAzOTYsMTMxMiAzODcsMTI5OSAzNzcsMTI4NSAzNzAsMTI2OCAzNjcsMTI0OCAzNjMsMTIyOCAzNjEsMTIwNSAzNjEsMTE3OSBMIDM2MSwxMDgyIDU3MiwxMDgyIDU3Miw5NTEgMzYxLDk1MSBaIi8+CiAgIDxnbHlwaCB1bmljb2RlPSJlIiBob3Jpei1hZHYteD0iOTgwIiBkPSJNIDI3Niw1MDMgQyAyNzYsNDQ2IDI4MiwzOTQgMjk0LDM0NyAzMDUsMjk5IDMyMywyNTggMzQ4LDIyNCAzNzIsMTg5IDQwMywxNjMgNDQxLDE0NCA0NzksMTI1IDUyNSwxMTUgNTc4LDExNSA2NTYsMTE1IDcxOSwxMzEgNzY2LDE2MiA4MTMsMTkzIDg0NCwyMzMgODYxLDI4MSBMIDEwMTksMjM2IEMgMTAwOCwyMDYgOTkyLDE3NiA5NzIsMTQ2IDk1MSwxMTUgOTI0LDg4IDg5MCw2NCA4NTYsMzkgODE0LDE5IDc2Myw0IDcxMiwtMTIgNjUwLC0yMCA1NzgsLTIwIDQxOCwtMjAgMjk2LDI4IDIxMywxMjMgMTI5LDIxOCA4NywzNjAgODcsNTQ4IDg3LDY0OSAxMDAsNzM1IDEyNSw4MDYgMTUwLDg3NiAxODUsOTMzIDIyOSw5NzcgMjczLDEwMjEgMzI0LDEwNTMgMzgzLDEwNzMgNDQyLDEwOTIgNTA0LDExMDIgNTcxLDExMDIgNjYyLDExMDIgNzM4LDEwODcgNzk5LDEwNTggODYwLDEwMjkgOTA5LDk4OCA5NDYsOTM3IDk4Myw4ODUgMTAwOSw4MjQgMTAyNSw3NTQgMTA0MCw2ODQgMTA0OCw2MDggMTA0OCw1MjcgTCAxMDQ4LDUwMyAyNzYsNTAzIFogTSA4NjIsNjQxIEMgODUyLDc1NSA4MjMsODM4IDc3NSw4OTEgNzI3LDk0MyA2NTgsOTY5IDU2OCw5NjkgNTM4LDk2OSA1MDcsOTY0IDQ3NCw5NTUgNDQxLDk0NSA0MTAsOTI4IDM4Miw5MDMgMzU0LDg3OCAzMzAsODQ1IDMxMSw4MDMgMjkyLDc2MCAyODEsNzA2IDI3OCw2NDEgTCA4NjIsNjQxIFoiLz4KICAgPGdseXBoIHVuaWNvZGU9ImQiIGhvcml6LWFkdi14PSI5MjciIGQ9Ik0gODIxLDE3NCBDIDc4OCwxMDUgNzQ0LDU1IDY4OSwyNSA2MzQsLTUgNTY1LC0yMCA0ODQsLTIwIDM0NywtMjAgMjQ3LDI2IDE4MywxMTggMTE4LDIxMCA4NiwzNDkgODYsNTM2IDg2LDkxMyAyMTksMTEwMiA0ODQsMTEwMiA1NjYsMTEwMiA2MzQsMTA4NyA2ODksMTA1NyA3NDQsMTAyNyA3ODgsOTc5IDgyMSw5MTQgTCA4MjMsOTE0IEMgODIzLDkyMSA4MjMsOTMxIDgyMyw5NDYgODIyLDk2MCA4MjIsOTc1IDgyMiw5OTEgODIxLDEwMDYgODIxLDEwMjEgODIxLDEwMzUgODIxLDEwNDkgODIxLDEwNTkgODIxLDEwNjUgTCA4MjEsMTQ4NCAxMDAxLDE0ODQgMTAwMSwyMjMgQyAxMDAxLDE5NyAxMDAxLDE3MiAxMDAyLDE0OCAxMDAyLDEyNCAxMDAyLDEwMiAxMDAzLDgyIDEwMDQsNjIgMTAwNCw0NSAxMDA1LDMxIDEwMDYsMTYgMTAwNiw2IDEwMDcsMCBMIDgzNSwwIEMgODM0LDcgODMzLDE2IDgzMiwyOSA4MzEsNDEgODMwLDU1IDgyOSw3MSA4MjgsODcgODI3LDEwNCA4MjYsMTIyIDgyNSwxMzkgODI1LDE1NyA4MjUsMTc0IEwgODIxLDE3NCBaIE0gMjc1LDU0MiBDIDI3NSw0NjcgMjgwLDQwMyAyODksMzUwIDI5OCwyOTcgMzEzLDI1MyAzMzQsMjE5IDM1NSwxODQgMzgxLDE1OSA0MTMsMTQzIDQ0NSwxMjcgNDg0LDExOSA1MzAsMTE5IDU3NywxMTkgNjE5LDEyNyA2NTYsMTQyIDY5MiwxNTcgNzIyLDE4MiA3NDcsMjE3IDc3MSwyNTEgNzg5LDI5NiA4MDIsMzUxIDgxNSw0MDYgODIxLDQ3NCA4MjEsNTU0IDgyMSw2MzEgODE1LDY5NiA4MDIsNzQ5IDc4OSw4MDIgNzcxLDg0NCA3NDYsODc3IDcyMSw5MTAgNjkxLDkzMyA2NTYsOTQ4IDYyMCw5NjIgNTc5LDk2OSA1MzIsOTY5IDQ4OCw5NjkgNDUwLDk2MSA0MTgsOTQ2IDM4Niw5MzEgMzU5LDkwNiAzMzgsODcyIDMxNyw4MzggMzAxLDc5NCAyOTEsNzQwIDI4MCw2ODUgMjc1LDYxOSAyNzUsNTQyIFoiLz4KICAgPGdseXBoIHVuaWNvZGU9ImMiIGhvcml6LWFkdi14PSI5MDEiIGQ9Ik0gMjc1LDU0NiBDIDI3NSw0ODQgMjgwLDQyNyAyODksMzc1IDI5OCwzMjMgMzEzLDI3OCAzMzQsMjQxIDM1NSwyMDMgMzg0LDE3NCA0MTksMTUzIDQ1NCwxMzIgNDk3LDEyMiA1NDgsMTIyIDYxMiwxMjIgNjY2LDEzOSA3MDksMTczIDc1MiwyMDYgNzc4LDI1OCA3ODgsMzI4IEwgOTcwLDMyOCBDIDk2NCwyODMgOTUxLDIzOSA5MzEsMTk3IDkxMSwxNTUgODg0LDExOCA4NTAsODYgODE1LDU0IDc3MywyOCA3MjQsOSA2NzUsLTEwIDYxOCwtMjAgNTUzLC0yMCA0NjgsLTIwIDM5NiwtNiAzMzcsMjMgMjc4LDUyIDIzMCw5MSAxOTMsMTQyIDE1NiwxOTIgMTI5LDI1MSAxMTIsMzIwIDk1LDM4OCA4Nyw0NjIgODcsNTQyIDg3LDYxNSA5Myw2NzkgMTA1LDczNSAxMTcsNzkwIDEzNCw4MzkgMTU2LDg4MSAxNzcsOTIyIDIwMyw5NTcgMjMyLDk4NiAyNjEsMTAxNCAyOTMsMTAzNyAzMjgsMTA1NCAzNjIsMTA3MSAzOTgsMTA4MyA0MzYsMTA5MSA0NzQsMTA5OCA1MTIsMTEwMiA1NTEsMTEwMiA2MTIsMTEwMiA2NjYsMTA5NCA3MTMsMTA3NyA3NjAsMTA2MCA4MDEsMTAzOCA4MzYsMTAwOSA4NzAsOTgwIDg5OCw5NDUgOTE5LDkwNiA5NDAsODY3IDk1NSw4MjQgOTY0LDc3OSBMIDc3OSw3NjUgQyA3NzAsODI1IDc0Niw4NzMgNzA4LDkwOCA2NzAsOTQzIDYxNiw5NjEgNTQ2LDk2MSA0OTUsOTYxIDQ1Miw5NTMgNDE4LDkzNiAzODMsOTE5IDM1NSw4OTMgMzM0LDg1OSAzMTMsODI0IDI5OCw3ODEgMjg5LDcyOSAyODAsNjc3IDI3NSw2MTYgMjc1LDU0NiBaIi8+CiAgIDxnbHlwaCB1bmljb2RlPSJiIiBob3Jpei1hZHYteD0iOTUzIiBkPSJNIDEwNTMsNTQ2IEMgMTA1MywxNjkgOTIwLC0yMCA2NTUsLTIwIDU3MywtMjAgNTA1LC01IDQ1MSwyNSAzOTYsNTQgMzUyLDEwMiAzMTgsMTY4IEwgMzE2LDE2OCBDIDMxNiwxNTEgMzE2LDEzMyAzMTUsMTE0IDMxNCw5NSAzMTMsNzggMzEyLDYyIDMxMSw0NiAzMTAsMzIgMzA5LDIxIDMwOCwxMCAzMDcsMyAzMDYsMCBMIDEzMiwwIEMgMTMzLDYgMTMzLDE2IDEzNCwzMSAxMzUsNDUgMTM1LDYyIDEzNiw4MiAxMzcsMTAyIDEzNywxMjQgMTM4LDE0OCAxMzgsMTcyIDEzOCwxOTcgMTM4LDIyMyBMIDEzOCwxNDg0IDMxOCwxNDg0IDMxOCwxMDYxIEMgMzE4LDEwNDEgMzE4LDEwMjIgMzE4LDEwMDQgMzE3LDk4NSAzMTcsOTY5IDMxNiw5NTUgMzE1LDkzOCAzMTUsOTIzIDMxNCw5MDggTCAzMTgsOTA4IEMgMzUxLDk3NyAzOTYsMTAyNyA0NTEsMTA1NyA1MDYsMTA4NyA1NzQsMTEwMiA2NTUsMTEwMiA3OTIsMTEwMiA4OTIsMTA1NiA5NTcsOTY0IDEwMjEsODcyIDEwNTMsNzMzIDEwNTMsNTQ2IFogTSA4NjQsNTQwIEMgODY0LDYxNSA4NTksNjc5IDg1MCw3MzIgODQxLDc4NSA4MjYsODI5IDgwNSw4NjQgNzg0LDg5OCA3NTgsOTIzIDcyNiw5MzkgNjk0LDk1NSA2NTUsOTYzIDYwOSw5NjMgNTYyLDk2MyA1MjAsOTU1IDQ4NCw5NDAgNDQ3LDkyNSA0MTcsOTAwIDM5Myw4NjYgMzY4LDgzMiAzNTAsNzg3IDMzNyw3MzIgMzI0LDY3NyAzMTgsNjA5IDMxOCw1MjkgMzE4LDQ1MiAzMjQsMzg3IDMzNywzMzQgMzUwLDI4MSAzNjgsMjM5IDM5MywyMDYgNDE3LDE3MyA0NDcsMTQ5IDQ4MywxMzUgNTE5LDEyMCA1NjAsMTEzIDYwNywxMTMgNjUxLDExMyA2ODksMTIxIDcyMSwxMzYgNzUzLDE1MSA3ODAsMTc2IDgwMSwyMTAgODIyLDI0NCA4MzgsMjg4IDg0OSwzNDMgODU5LDM5NyA4NjQsNDYzIDg2NCw1NDAgWiIvPgogICA8Z2x5cGggdW5pY29kZT0iYSIgaG9yaXotYWR2LXg9IjEwNjAiIGQ9Ik0gNDE0LC0yMCBDIDMwNSwtMjAgMjI0LDkgMTY5LDY2IDExNCwxMjQgODcsMjAzIDg3LDMwMyA4NywzNzUgMTAxLDQzNCAxMjgsNDgwIDE1NSw1MjYgMTkwLDU2MiAyMzQsNTg4IDI3Nyw2MTQgMzI3LDYzMiAzODMsNjQyIDQzOSw2NTIgNDk2LDY1NyA1NTQsNjU3IEwgNzk3LDY1NyA3OTcsNzE3IEMgNzk3LDc2MiA3OTIsODAwIDc4Myw4MzIgNzc0LDg2MyA3NTksODg5IDc0MCw5MDggNzIxLDkyOCA2OTcsOTQyIDY2OCw5NTEgNjM5LDk2MCA2MDQsOTY1IDU2NSw5NjUgNTMwLDk2NSA0OTksOTYzIDQ3MSw5NTggNDQzLDk1MyA0MTksOTQ0IDM5OCw5MzEgMzc3LDkxOCAzNjEsOTAwIDM0OCw4NzggMzM1LDg1NSAzMjcsODI3IDMyMyw3OTMgTCAxMzUsODEwIEMgMTQyLDg1MyAxNTQsODkyIDE3Myw5MjggMTkyLDk2MyAyMTgsOTk0IDI1MywxMDIwIDI4NywxMDQ2IDMzMCwxMDY2IDM4MiwxMDgxIDQzMywxMDk1IDQ5NiwxMTAyIDU2OSwxMTAyIDcwNSwxMTAyIDgwNywxMDcxIDg3NiwxMDA5IDk0NSw5NDYgOTc5LDg1NiA5NzksNzM4IEwgOTc5LDI3MiBDIDk3OSwyMTkgOTg2LDE3OSAxMDAwLDE1MiAxMDE0LDEyNSAxMDQxLDExMSAxMDgwLDExMSAxMDkwLDExMSAxMTAwLDExMiAxMTEwLDExMyAxMTIwLDExNCAxMTMwLDExNiAxMTM5LDExOCBMIDExMzksNiBDIDExMTYsMSAxMDk0LC0zIDEwNzIsLTYgMTA0OSwtOSAxMDI1LC0xMCAxMDAwLC0xMCA5NjYsLTEwIDkzNywtNSA5MTMsNCA4ODgsMTMgODY4LDI2IDg1Myw0NSA4MzgsNjMgODI2LDg2IDgxOCwxMTMgODEwLDE0MCA4MDUsMTcxIDgwMywyMDcgTCA3OTcsMjA3IEMgNzc4LDE3MiA3NTcsMTQxIDczNCwxMTMgNzExLDg1IDY4NCw2MSA2NTMsNDIgNjIyLDIyIDU4OCw3IDU0OSwtNCA1MTAsLTE1IDQ2NSwtMjAgNDE0LC0yMCBaIE0gNDU1LDExNSBDIDUxMiwxMTUgNTYzLDEyNSA2MDYsMTQ2IDY0OSwxNjcgNjg0LDE5NCA3MTMsMjI2IDc0MSwyNTkgNzYyLDI5NCA3NzYsMzMyIDc5MCwzNzEgNzk3LDQwOCA3OTcsNDQzIEwgNzk3LDUzMSA2MDAsNTMxIEMgNTU2LDUzMSA1MTQsNTI4IDQ3NSw1MjIgNDM1LDUxNyA0MDAsNTA2IDM3MCw0ODkgMzQwLDQ3MiAzMTYsNDQ5IDI5OSw0MTggMjgxLDM4OCAyNzIsMzQ5IDI3MiwzMDAgMjcyLDI0MSAyODgsMTk1IDMyMCwxNjMgMzUxLDEzMSAzOTYsMTE1IDQ1NSwxMTUgWiIvPgogICA8Z2x5cGggdW5pY29kZT0iUyIgaG9yaXotYWR2LXg9IjExOTIiIGQ9Ik0gMTI3MiwzODkgQyAxMjcyLDMzMCAxMjYxLDI3NSAxMjM4LDIyNSAxMjE1LDE3NSAxMTc5LDEzMiAxMTMxLDk2IDEwODMsNTkgMTAyMywzMSA5NTAsMTEgODc3LC0xMCA3OTAsLTIwIDY5MCwtMjAgNTE1LC0yMCAzNzgsMTEgMjgwLDcyIDE4MiwxMzMgMTIwLDIyMiA5MywzMzggTCAyNzgsMzc1IEMgMjg3LDMzOCAzMDIsMzA1IDMyMSwyNzUgMzQwLDI0NSAzNjcsMjE5IDQwMCwxOTggNDMzLDE3NiA0NzMsMTU5IDUyMiwxNDcgNTcxLDEzNSA2MjksMTI5IDY5NywxMjkgNzU0LDEyOSA4MDYsMTM0IDg1MywxNDQgOTAwLDE1MyA5NDEsMTY4IDk3NSwxODggMTAwOSwyMDggMTAzNiwyMzQgMTA1NSwyNjYgMTA3NCwyOTcgMTA4MywzMzUgMTA4MywzNzkgMTA4Myw0MjUgMTA3Myw0NjIgMTA1Miw0OTEgMTAzMSw1MjAgMTAwMSw1NDMgOTYzLDU2MiA5MjUsNTgxIDg4MCw1OTYgODI3LDYwOSA3NzQsNjIyIDcxNiw2MzUgNjUyLDY1MCA2MTMsNjU5IDU3Myw2NjggNTM0LDY3OSA0OTQsNjg5IDQ1Niw3MDEgNDIwLDcxNiAzODMsNzMwIDM0OSw3NDcgMzE3LDc2NiAyODUsNzg1IDI1Nyw4MDkgMjM0LDgzNiAyMTEsODYzIDE5Miw4OTQgMTc5LDkzMCAxNjYsOTY1IDE1OSwxMDA2IDE1OSwxMDUzIDE1OSwxMTIwIDE3MywxMTc3IDIwMCwxMjI1IDIyNywxMjcyIDI2NCwxMzExIDMxMiwxMzQyIDM2MCwxMzczIDQxNywxMzk1IDQ4MiwxNDA5IDU0NywxNDIzIDYxOCwxNDMwIDY5NCwxNDMwIDc4MSwxNDMwIDg1NiwxNDIzIDkxOCwxNDEwIDk4MCwxMzk2IDEwMzIsMTM3NSAxMDc1LDEzNDggMTExOCwxMzIxIDExNTIsMTI4NyAxMTc4LDEyNDcgMTIwMywxMjA2IDEyMjQsMTE1OSAxMjM5LDExMDYgTCAxMDUxLDEwNzMgQyAxMDQyLDExMDcgMTAyOCwxMTM3IDEwMTEsMTE2NCA5OTMsMTE5MSA5NzAsMTIxMyA5NDEsMTIzMSA5MTIsMTI0OSA4NzgsMTI2MyA4MzcsMTI3MiA3OTYsMTI4MSA3NDcsMTI4NiA2OTIsMTI4NiA2MjcsMTI4NiA1NzIsMTI4MCA1MjgsMTI2OSA0ODMsMTI1NyA0NDgsMTI0MSA0MjEsMTIyMSAzOTQsMTIwMSAzNzQsMTE3OCAzNjMsMTE1MSAzNTEsMTEyNCAzNDUsMTA5NCAzNDUsMTA2MyAzNDUsMTAyMSAzNTYsOTg3IDM3Nyw5NjAgMzk4LDkzMyA0MjYsOTEwIDQ2Miw4OTIgNDk4LDg3NCA1NDAsODU5IDU4Nyw4NDcgNjM0LDgzNSA2ODUsODIzIDczOCw4MTEgNzgxLDgwMSA4MjUsNzkxIDg2OCw3ODEgOTExLDc3MCA5NTIsNzU4IDk5MSw3NDQgMTAzMCw3MjkgMTA2Nyw3MTIgMTEwMiw2OTMgMTEzNiw2NzQgMTE2Niw2NTAgMTE5MSw2MjIgMTIxNiw1OTQgMTIzNiw1NjEgMTI1MSw1MjMgMTI2NSw0ODUgMTI3Miw0NDAgMTI3MiwzODkgWiIvPgogICA8Z2x5cGggdW5pY29kZT0iTyIgaG9yaXotYWR2LXg9IjE0MzAiIGQ9Ik0gMTQ5NSw3MTEgQyAxNDk1LDYwMSAxNDc5LDUwMSAxNDQ4LDQxMSAxNDE2LDMyMSAxMzcwLDI0NCAxMzEwLDE4MCAxMjUwLDExNiAxMTc3LDY3IDEwOTAsMzIgMTAwMywtMyA5MDUsLTIwIDc5NSwtMjAgNjc5LC0yMCA1NzcsLTIgNDkwLDM1IDQwMyw3MSAzMzAsMTIyIDI3MiwxODcgMjE0LDI1MiAxNzAsMzI5IDE0MSw0MTggMTEyLDUwNyA5Nyw2MDUgOTcsNzExIDk3LDgyMSAxMTIsOTIwIDE0MywxMDA5IDE3NCwxMDk4IDIxOSwxMTczIDI3OCwxMjM2IDMzNywxMjk4IDQxMSwxMzQ2IDQ5OCwxMzgwIDU4NSwxNDEzIDY4NCwxNDMwIDc5NywxNDMwIDkwOSwxNDMwIDEwMDksMTQxMyAxMDk2LDEzNzkgMTE4MywxMzQ1IDEyNTYsMTI5NyAxMzE1LDEyMzQgMTM3NCwxMTcxIDE0MTgsMTA5NiAxNDQ5LDEwMDcgMTQ4MCw5MTggMTQ5NSw4MjAgMTQ5NSw3MTEgWiBNIDEzMDAsNzExIEMgMTMwMCw3OTYgMTI4OSw4NzMgMTI2OCw5NDIgMTI0NiwxMDExIDEyMTQsMTA3MSAxMTcyLDExMjAgMTEyOSwxMTY5IDEwNzcsMTIwNyAxMDE0LDEyMzQgOTUxLDEyNjEgODc5LDEyNzQgNzk3LDEyNzQgNzEzLDEyNzQgNjM5LDEyNjEgNTc2LDEyMzQgNTEzLDEyMDcgNDYwLDExNjkgNDE4LDExMjAgMzc1LDEwNzEgMzQ0LDEwMTEgMzIzLDk0MiAzMDIsODczIDI5MSw3OTYgMjkxLDcxMSAyOTEsNjI2IDMwMiw1NDkgMzI0LDQ3OSAzNDUsNDA4IDM3NywzNDggNDIwLDI5NyA0NjIsMjQ2IDUxNSwyMDYgNTc4LDE3OCA2NDEsMTQ5IDcxMywxMzUgNzk1LDEzNSA4ODMsMTM1IDk1OSwxNDkgMTAyMywxNzggMTA4NiwyMDcgMTEzOSwyNDcgMTE4MCwyOTggMTIyMSwzNDkgMTI1MSw0MDkgMTI3MSw0ODAgMTI5MCw1NTEgMTMwMCw2MjggMTMwMCw3MTEgWiIvPgogICA8Z2x5cGggdW5pY29kZT0iQyIgaG9yaXotYWR2LXg9IjEzMjQiIGQ9Ik0gNzkyLDEyNzQgQyA3MTIsMTI3NCA2NDEsMTI2MSA1ODAsMTIzNCA1MTgsMTIwNyA0NjYsMTE2OSA0MjUsMTEyMCAzODMsMTA3MSAzNTEsMTAxMSAzMzAsOTQyIDMwOSw4NzMgMjk4LDc5NiAyOTgsNzExIDI5OCw2MjYgMzEwLDU0OSAzMzMsNDc5IDM1Niw0MDggMzg5LDM0OCA0MzIsMjk3IDQ3NSwyNDYgNTI3LDIwNyA1OTAsMTc5IDY1MiwxNTEgNzIyLDEzNyA4MDAsMTM3IDg1NSwxMzcgOTA1LDE0NCA5NTAsMTU5IDk5NSwxNzMgMTAzNSwxOTMgMTA3MiwyMTkgMTEwOCwyNDUgMTE0MCwyNzYgMTE2OSwzMTIgMTE5OCwzNDcgMTIyMywzODcgMTI0NSw0MzAgTCAxNDAxLDM1MiBDIDEzNzYsMjk5IDEzNDQsMjUwIDEzMDcsMjA1IDEyNzAsMTYwIDEyMjYsMTIwIDExNzYsODcgMTEyNSw1NCAxMDY4LDI4IDEwMDUsOSA5NDEsLTEwIDg3MCwtMjAgNzkxLC0yMCA2NzcsLTIwIDU3NywtMiA0OTIsMzUgNDA2LDcxIDMzNCwxMjIgMjc3LDE4NyAyMTksMjUyIDE3NiwzMjkgMTQ3LDQxOCAxMTgsNTA3IDEwNCw2MDUgMTA0LDcxMSAxMDQsODIxIDExOSw5MjAgMTUwLDEwMDkgMTgwLDEwOTggMjI0LDExNzMgMjgzLDEyMzYgMzQxLDEyOTggNDEzLDEzNDYgNDk4LDEzODAgNTgzLDE0MTMgNjgxLDE0MzAgNzkwLDE0MzAgOTQwLDE0MzAgMTA2NSwxNDAxIDExNjYsMTM0MiAxMjY3LDEyODMgMTM0MSwxMTk2IDEzODgsMTA4MSBMIDEyMDcsMTAyMSBDIDExOTQsMTA1NCAxMTc2LDEwODYgMTE1MywxMTE3IDExMzAsMTE0NyAxMTAyLDExNzQgMTA2OCwxMTk3IDEwMzQsMTIyMCA5OTQsMTIzOSA5NDksMTI1MyA5MDMsMTI2NyA4NTEsMTI3NCA3OTIsMTI3NCBaIi8+CiAgIDxnbHlwaCB1bmljb2RlPSIgIiBob3Jpei1hZHYteD0iNTU2Ii8+CiAgPC9mb250PgogPC9kZWZzPgogPGRlZnMgY2xhc3M9IlRleHRTaGFwZUluZGV4Ij4KICA8ZyBvb286c2xpZGU9ImlkMSIgb29vOmlkLWxpc3Q9ImlkMyBpZDQgaWQ1IGlkNiBpZDcgaWQ4IGlkOSBpZDEwIGlkMTEgaWQxMiBpZDEzIGlkMTQgaWQxNSBpZDE2IGlkMTcgaWQxOCBpZDE5Ii8+CiA8L2RlZnM+CiA8ZGVmcyBjbGFzcz0iRW1iZWRkZWRCdWxsZXRDaGFycyI+CiAgPGcgaWQ9ImJ1bGxldC1jaGFyLXRlbXBsYXRlKDU3MzU2KSIgdHJhbnNmb3JtPSJzY2FsZSgwLjAwMDQ4ODI4MTI1LC0wLjAwMDQ4ODI4MTI1KSI+CiAgIDxwYXRoIGQ9Ik0gNTgwLDExNDEgTCAxMTYzLDU3MSA1ODAsMCAtNCw1NzEgNTgwLDExNDEgWiIvPgogIDwvZz4KICA8ZyBpZD0iYnVsbGV0LWNoYXItdGVtcGxhdGUoNTczNTQpIiB0cmFuc2Zvcm09InNjYWxlKDAuMDAwNDg4MjgxMjUsLTAuMDAwNDg4MjgxMjUpIj4KICAgPHBhdGggZD0iTSA4LDExMjggTCAxMTM3LDExMjggMTEzNywwIDgsMCA4LDExMjggWiIvPgogIDwvZz4KICA8ZyBpZD0iYnVsbGV0LWNoYXItdGVtcGxhdGUoMTAxNDYpIiB0cmFuc2Zvcm09InNjYWxlKDAuMDAwNDg4MjgxMjUsLTAuMDAwNDg4MjgxMjUpIj4KICAgPHBhdGggZD0iTSAxNzQsMCBMIDYwMiw3MzkgMTc0LDE0ODEgMTQ1Niw3MzkgMTc0LDAgWiBNIDEzNTgsNzM5IEwgMzA5LDEzNDYgNjU5LDczOSAxMzU4LDczOSBaIi8+CiAgPC9nPgogIDxnIGlkPSJidWxsZXQtY2hhci10ZW1wbGF0ZSgxMDEzMikiIHRyYW5zZm9ybT0ic2NhbGUoMC4wMDA0ODgyODEyNSwtMC4wMDA0ODgyODEyNSkiPgogICA8cGF0aCBkPSJNIDIwMTUsNzM5IEwgMTI3NiwwIDcxNywwIDEyNjAsNTQzIDE3NCw1NDMgMTc0LDkzNiAxMjYwLDkzNiA3MTcsMTQ4MSAxMjc0LDE0ODEgMjAxNSw3MzkgWiIvPgogIDwvZz4KICA8ZyBpZD0iYnVsbGV0LWNoYXItdGVtcGxhdGUoMTAwMDcpIiB0cmFuc2Zvcm09InNjYWxlKDAuMDAwNDg4MjgxMjUsLTAuMDAwNDg4MjgxMjUpIj4KICAgPHBhdGggZD0iTSAwLC0yIEMgLTcsMTQgLTE2LDI3IC0yNSwzNyBMIDM1Niw1NjcgQyAyNjIsODIzIDIxNSw5NTIgMjE1LDk1NCAyMTUsOTc5IDIyOCw5OTIgMjU1LDk5MiAyNjQsOTkyIDI3Niw5OTAgMjg5LDk4NyAzMTAsOTkxIDMzMSw5OTkgMzU0LDEwMTIgTCAzODEsOTk5IDQ5Miw3NDggNzcyLDEwNDkgODM2LDEwMjQgODYwLDEwNDkgQyA4ODEsMTAzOSA5MDEsMTAyNSA5MjIsMTAwNiA4ODYsOTM3IDgzNSw4NjMgNzcwLDc4NCA3NjksNzgzIDcxMCw3MTYgNTk0LDU4NCBMIDc3NCwyMjMgQyA3NzQsMTk2IDc1MywxNjggNzExLDEzOSBMIDcyNywxMTkgQyA3MTcsOTAgNjk5LDc2IDY3Miw3NiA2NDEsNzYgNTcwLDE3OCA0NTcsMzgxIEwgMTY0LC03NiBDIDE0MiwtMTEwIDExMSwtMTI3IDcyLC0xMjcgMzAsLTEyNyA5LC0xMTAgOCwtNzYgMSwtNjcgLTIsLTUyIC0yLC0zMiAtMiwtMjMgLTEsLTEzIDAsLTIgWiIvPgogIDwvZz4KICA8ZyBpZD0iYnVsbGV0LWNoYXItdGVtcGxhdGUoMTAwMDQpIiB0cmFuc2Zvcm09InNjYWxlKDAuMDAwNDg4MjgxMjUsLTAuMDAwNDg4MjgxMjUpIj4KICAgPHBhdGggZD0iTSAyODUsLTMzIEMgMTgyLC0zMyAxMTEsMzAgNzQsMTU2IDUyLDIyOCA0MSwzMzMgNDEsNDcxIDQxLDU0OSA1NSw2MTYgODIsNjcyIDExNiw3NDMgMTY5LDc3OCAyNDAsNzc4IDI5Myw3NzggMzI4LDc0NyAzNDYsNjg0IEwgMzY5LDUwOCBDIDM3Nyw0NDQgMzk3LDQxMSA0MjgsNDEwIEwgMTE2MywxMTE2IEMgMTE3NCwxMTI3IDExOTYsMTEzMyAxMjI5LDExMzMgMTI3MSwxMTMzIDEyOTIsMTExOCAxMjkyLDEwODcgTCAxMjkyLDk2NSBDIDEyOTIsOTI5IDEyODIsOTAxIDEyNjIsODgxIEwgNDQyLDQ3IEMgMzkwLC02IDMzOCwtMzMgMjg1LC0zMyBaIi8+CiAgPC9nPgogIDxnIGlkPSJidWxsZXQtY2hhci10ZW1wbGF0ZSg5Njc5KSIgdHJhbnNmb3JtPSJzY2FsZSgwLjAwMDQ4ODI4MTI1LC0wLjAwMDQ4ODI4MTI1KSI+CiAgIDxwYXRoIGQ9Ik0gODEzLDAgQyA2MzIsMCA0ODksNTQgMzgzLDE2MSAyNzYsMjY4IDIyMyw0MTEgMjIzLDU5MiAyMjMsNzczIDI3Niw5MTYgMzgzLDEwMjMgNDg5LDExMzAgNjMyLDExODQgODEzLDExODQgOTkyLDExODQgMTEzNiwxMTMwIDEyNDUsMTAyMyAxMzUzLDkxNiAxNDA3LDc3MiAxNDA3LDU5MiAxNDA3LDQxMiAxMzUzLDI2OCAxMjQ1LDE2MSAxMTM2LDU0IDk5MiwwIDgxMywwIFoiLz4KICA8L2c+CiAgPGcgaWQ9ImJ1bGxldC1jaGFyLXRlbXBsYXRlKDgyMjYpIiB0cmFuc2Zvcm09InNjYWxlKDAuMDAwNDg4MjgxMjUsLTAuMDAwNDg4MjgxMjUpIj4KICAgPHBhdGggZD0iTSAzNDYsNDU3IEMgMjczLDQ1NyAyMDksNDgzIDE1NSw1MzUgMTAxLDU4NiA3NCw2NDkgNzQsNzIzIDc0LDc5NiAxMDEsODU5IDE1NSw5MTEgMjA5LDk2MyAyNzMsOTg5IDM0Niw5ODkgNDE5LDk4OSA0ODAsOTYzIDUzMSw5MTAgNTgyLDg1OSA2MDgsNzk2IDYwOCw3MjMgNjA4LDY0OCA1ODMsNTg2IDUzMiw1MzUgNDgyLDQ4MyA0MjAsNDU3IDM0Niw0NTcgWiIvPgogIDwvZz4KICA8ZyBpZD0iYnVsbGV0LWNoYXItdGVtcGxhdGUoODIxMSkiIHRyYW5zZm9ybT0ic2NhbGUoMC4wMDA0ODgyODEyNSwtMC4wMDA0ODgyODEyNSkiPgogICA8cGF0aCBkPSJNIC00LDQ1OSBMIDExMzUsNDU5IDExMzUsNjA2IC00LDYwNiAtNCw0NTkgWiIvPgogIDwvZz4KIDwvZGVmcz4KIDxkZWZzIGNsYXNzPSJUZXh0RW1iZWRkZWRCaXRtYXBzIi8+CiA8Zz4KICA8ZyBpZD0iaWQyIiBjbGFzcz0iTWFzdGVyX1NsaWRlIj4KICAgPGcgaWQ9ImJnLWlkMiIgY2xhc3M9IkJhY2tncm91bmQiLz4KICAgPGcgaWQ9ImJvLWlkMiIgY2xhc3M9IkJhY2tncm91bmRPYmplY3RzIi8+CiAgPC9nPgogPC9nPgogPGcgY2xhc3M9IlNsaWRlR3JvdXAiPgogIDxnPgogICA8ZyBpZD0iaWQxIiBjbGFzcz0iU2xpZGUiIGNsaXAtcGF0aD0idXJsKCNwcmVzZW50YXRpb25fY2xpcF9wYXRoKSI+CiAgICA8ZyBjbGFzcz0iUGFnZSI+CiAgICAgPGcgY2xhc3M9ImNvbS5zdW4uc3Rhci5kcmF3aW5nLlJlY3RhbmdsZVNoYXBlIj4KICAgICAgPGcgaWQ9ImlkMyI+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gODQ1MCw3MDAwIEwgNzAwMCw3MDAwIDcwMDAsMzAwMCA5OTAwLDMwMDAgOTkwMCw3MDAwIDg0NTAsNzAwMCBaIi8+CiAgICAgIDwvZz4KICAgICA8L2c+CiAgICAgPGcgY2xhc3M9ImNvbS5zdW4uc3Rhci5kcmF3aW5nLlJlY3RhbmdsZVNoYXBlIj4KICAgICAgPGcgaWQ9ImlkNCI+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gMTIwNTAsNzAwMCBMIDEwMTAwLDcwMDAgMTAxMDAsMzAwMCAxNDAwMCwzMDAwIDE0MDAwLDcwMDAgMTIwNTAsNzAwMCBaIi8+CiAgICAgIDwvZz4KICAgICA8L2c+CiAgICAgPGcgY2xhc3M9ImNvbS5zdW4uc3Rhci5kcmF3aW5nLkVsbGlwc2VTaGFwZSI+CiAgICAgIDxnIGlkPSJpZDUiPgogICAgICAgPHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSJyZ2IoMCwwLDApIiBkPSJNIDg5OTksMzMwMCBDIDkxMDUsMzMxMiA5MTk1LDMzODMgOTI4OCwzNTMxIDkzODcsMzY5MCA5NDU5LDM4ODkgOTUxNiw0MTY1IDk1NzQsNDQ0MSA5NjAwLDQ3MTIgOTYwMCw1MDMxIDk2MDAsNTM1MCA5NTc0LDU2MjEgOTUxNiw1ODk3IDk0NTksNjE3MyA5NDAyLDYzMjggOTMxOSw2NDc4Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJyZ2IoMCwwLDApIiBzdHJva2U9Im5vbmUiIGQ9Ik0gOTE0MSw2NzAxIEwgOTQwNSw2NTI2IDkyNDgsNjQwMyA5MTQxLDY3MDEgWiIvPgogICAgICA8L2c+CiAgICAgPC9nPgogICAgIDxnIGNsYXNzPSJjb20uc3VuLnN0YXIuZHJhd2luZy5FbGxpcHNlU2hhcGUiPgogICAgICA8ZyBpZD0iaWQ2Ij4KICAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0icmdiKDAsMCwwKSIgZD0iTSAxMDc5NCw2NzEwIEMgMTA3NDgsNjY2OSAxMDcxMCw2NjE4IDEwNjY4LDY1NDAgMTA1ODMsNjM4MCAxMDUyMSw2MTgxIDEwNDcyLDU5MDUgMTA0MjIsNTYyOCAxMDQwMCw1MzU2IDEwNDAwLDUwMzYgMTA0MDAsNDcxNiAxMDQyMiw0NDQ0IDEwNDcyLDQxNjggMTA1MjEsMzg5MSAxMDU4MywzNjkyIDEwNjY4LDM1MzIgMTA3NDgsMzM4MyAxMDY5MCwzNDkyIDEwNzAxLDM0NzQiLz4KICAgICAgIDxwYXRoIGZpbGw9InJnYigwLDAsMCkiIHN0cm9rZT0ibm9uZSIgZD0iTSAxMDkxNiwzMzAwIEwgMTA2MjIsMzQxNiAxMDc1MCwzNTY5IDEwOTE2LDMzMDAgWiIvPgogICAgICA8L2c+CiAgICAgPC9nPgogICAgIDxnIGNsYXNzPSJjb20uc3VuLnN0YXIuZHJhd2luZy5DdXN0b21TaGFwZSI+CiAgICAgIDxnIGlkPSJpZDciPgogICAgICAgPHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSJyZ2IoMCwwLDApIiBkPSJNIDk4OTksNjkwMCBDIDk5NTUsNjkwMCA5OTk5LDY5NDMgOTk5OSw2OTk5IDk5OTksNzA1NSA5OTU1LDcwOTkgOTg5OSw3MDk5IDk4NDMsNzA5OSA5ODAwLDcwNTUgOTgwMCw2OTk5IDk4MDAsNjk0MyA5ODQzLDY5MDAgOTg5OSw2OTAwIFoiLz4KICAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0icmdiKDAsMCwwKSIgZD0iTSA5ODAwLDY5MDAgTCA5ODAwLDY5MDAgWiIvPgogICAgICAgPHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSJyZ2IoMCwwLDApIiBkPSJNIDEwMDAxLDcxMDEgTCAxMDAwMSw3MTAxIFoiLz4KICAgICAgPC9nPgogICAgIDwvZz4KICAgICA8ZyBjbGFzcz0iY29tLnN1bi5zdGFyLmRyYXdpbmcuQ3VzdG9tU2hhcGUiPgogICAgICA8ZyBpZD0iaWQ4Ij4KICAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0icmdiKDAsMCwwKSIgZD0iTSAxMDA5OSwyOTAwIEMgMTAxNTUsMjkwMCAxMDE5OSwyOTQzIDEwMTk5LDI5OTkgMTAxOTksMzA1NSAxMDE1NSwzMDk5IDEwMDk5LDMwOTkgMTAwNDMsMzA5OSAxMDAwMCwzMDU1IDEwMDAwLDI5OTkgMTAwMDAsMjk0MyAxMDA0MywyOTAwIDEwMDk5LDI5MDAgWiIvPgogICAgICAgPHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSJyZ2IoMCwwLDApIiBkPSJNIDEwMDAwLDI5MDAgTCAxMDAwMCwyOTAwIFoiLz4KICAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0icmdiKDAsMCwwKSIgZD0iTSAxMDIwMSwzMTAxIEwgMTAyMDEsMzEwMSBaIi8+CiAgICAgIDwvZz4KICAgICA8L2c+CiAgICAgPGcgY2xhc3M9ImNvbS5zdW4uc3Rhci5kcmF3aW5nLkN1c3RvbVNoYXBlIj4KICAgICAgPGcgaWQ9ImlkOSI+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gOTg5OSwyOTAwIEMgOTk1NSwyOTAwIDk5OTksMjk0MyA5OTk5LDI5OTkgOTk5OSwzMDU1IDk5NTUsMzA5OSA5ODk5LDMwOTkgOTg0MywzMDk5IDk4MDAsMzA1NSA5ODAwLDI5OTkgOTgwMCwyOTQzIDk4NDMsMjkwMCA5ODk5LDI5MDAgWiIvPgogICAgICAgPHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSJyZ2IoMCwwLDApIiBkPSJNIDk4MDAsMjkwMCBMIDk4MDAsMjkwMCBaIi8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gMTAwMDEsMzEwMSBMIDEwMDAxLDMxMDEgWiIvPgogICAgICA8L2c+CiAgICAgPC9nPgogICAgIDxnIGNsYXNzPSJjb20uc3VuLnN0YXIuZHJhd2luZy5DdXN0b21TaGFwZSI+CiAgICAgIDxnIGlkPSJpZDEwIj4KICAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0icmdiKDAsMCwwKSIgZD0iTSA5ODk5LDQ5MDAgQyA5OTU1LDQ5MDAgOTk5OSw0OTQzIDk5OTksNDk5OSA5OTk5LDUwNTUgOTk1NSw1MDk5IDk4OTksNTA5OSA5ODQzLDUwOTkgOTgwMCw1MDU1IDk4MDAsNDk5OSA5ODAwLDQ5NDMgOTg0Myw0OTAwIDk4OTksNDkwMCBaIi8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gOTgwMCw0OTAwIEwgOTgwMCw0OTAwIFoiLz4KICAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0icmdiKDAsMCwwKSIgZD0iTSAxMDAwMSw1MTAxIEwgMTAwMDEsNTEwMSBaIi8+CiAgICAgIDwvZz4KICAgICA8L2c+CiAgICAgPGcgY2xhc3M9ImNvbS5zdW4uc3Rhci5kcmF3aW5nLkN1c3RvbVNoYXBlIj4KICAgICAgPGcgaWQ9ImlkMTEiPgogICAgICAgPHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSJyZ2IoMCwwLDApIiBkPSJNIDEwMDk5LDQ5MDAgQyAxMDE1NSw0OTAwIDEwMTk5LDQ5NDMgMTAxOTksNDk5OSAxMDE5OSw1MDU1IDEwMTU1LDUwOTkgMTAwOTksNTA5OSAxMDA0Myw1MDk5IDEwMDAwLDUwNTUgMTAwMDAsNDk5OSAxMDAwMCw0OTQzIDEwMDQzLDQ5MDAgMTAwOTksNDkwMCBaIi8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gMTAwMDAsNDkwMCBMIDEwMDAwLDQ5MDAgWiIvPgogICAgICAgPHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSJyZ2IoMCwwLDApIiBkPSJNIDEwMjAxLDUxMDEgTCAxMDIwMSw1MTAxIFoiLz4KICAgICAgPC9nPgogICAgIDwvZz4KICAgICA8ZyBjbGFzcz0iY29tLnN1bi5zdGFyLmRyYXdpbmcuQ3VzdG9tU2hhcGUiPgogICAgICA8ZyBpZD0iaWQxMiI+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gMTAwOTksNjkwMCBDIDEwMTU1LDY5MDAgMTAxOTksNjk0MyAxMDE5OSw2OTk5IDEwMTk5LDcwNTUgMTAxNTUsNzA5OSAxMDA5OSw3MDk5IDEwMDQzLDcwOTkgMTAwMDAsNzA1NSAxMDAwMCw2OTk5IDEwMDAwLDY5NDMgMTAwNDMsNjkwMCAxMDA5OSw2OTAwIFoiLz4KICAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0icmdiKDAsMCwwKSIgZD0iTSAxMDAwMCw2OTAwIEwgMTAwMDAsNjkwMCBaIi8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gMTAyMDEsNzEwMSBMIDEwMjAxLDcxMDEgWiIvPgogICAgICA8L2c+CiAgICAgPC9nPgogICAgIDxnIGNsYXNzPSJjb20uc3VuLnN0YXIuZHJhd2luZy5DdXN0b21TaGFwZSI+CiAgICAgIDxnIGlkPSJpZDEzIj4KICAgICAgIDxwYXRoIGZpbGw9InJnYigyNTUsMjU1LDI1NSkiIHN0cm9rZT0ibm9uZSIgZD0iTSA1MTAwLDUyMDAgTCAzNTAwLDUyMDAgMzUwMCwzMDAwIDY3MDAsMzAwMCA2NzAwLDUyMDAgNTEwMCw1MjAwIFoiLz4KICAgICAgIDx0ZXh0IGNsYXNzPSJUZXh0U2hhcGUiPjx0c3BhbiBjbGFzcz0iVGV4dFBhcmFncmFwaCIgZm9udC1mYW1pbHk9IkxpYmVyYXRpb24gU2Fucywgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIzNTNweCIgZm9udC13ZWlnaHQ9IjQwMCI+PHRzcGFuIGNsYXNzPSJUZXh0UG9zaXRpb24iIHg9IjM3NTAiIHk9IjM0MzMiPjx0c3BhbiBmaWxsPSJyZ2IoMCwwLDApIiBzdHJva2U9Im5vbmUiPlN1YmRpdmlzaW9uIDwvdHNwYW4+PC90c3Bhbj48dHNwYW4gY2xhc3M9IlRleHRQb3NpdGlvbiIgeD0iMzc1MCIgeT0iMzgyNyI+PHRzcGFuIGZpbGw9InJnYigwLDAsMCkiIHN0cm9rZT0ibm9uZSI+cG9pbnRzIG5lZWQgdG8gPC90c3Bhbj48L3RzcGFuPjx0c3BhbiBjbGFzcz0iVGV4dFBvc2l0aW9uIiB4PSIzNzUwIiB5PSI0MjIxIj48dHNwYW4gZmlsbD0icmdiKDAsMCwwKSIgc3Ryb2tlPSJub25lIj5sYW5kIG9uIHRoZSBzYW1lIDwvdHNwYW4+PC90c3Bhbj48dHNwYW4gY2xhc3M9IlRleHRQb3NpdGlvbiIgeD0iMzc1MCIgeT0iNDYxNSI+PHRzcGFuIGZpbGw9InJnYigwLDAsMCkiIHN0cm9rZT0ibm9uZSI+bG9jYXRpb24gdG8gPC90c3Bhbj48L3RzcGFuPjx0c3BhbiBjbGFzcz0iVGV4dFBvc2l0aW9uIiB4PSIzNzUwIiB5PSI1MDA5Ij48dHNwYW4gZmlsbD0icmdiKDAsMCwwKSIgc3Ryb2tlPSJub25lIj5wcmV2ZW50IGNyYWNraW5nPC90c3Bhbj48L3RzcGFuPjwvdHNwYW4+PC90ZXh0PgogICAgICA8L2c+CiAgICAgPC9nPgogICAgIDxnIGNsYXNzPSJjb20uc3VuLnN0YXIuZHJhd2luZy5MaW5lU2hhcGUiPgogICAgICA8ZyBpZD0iaWQxNCI+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gNjYwMCw0MjAwIEwgNjY1MSw0MjEzIi8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gNjcwMyw0MjI3IEwgNjc1NCw0MjQwIi8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gNjgwNiw0MjUzIEwgNjg1Nyw0MjY2Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gNjkwOCw0MjgwIEwgNjk2MCw0MjkzIi8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gNzAxMSw0MzA2IEwgNzA2Myw0MzE5Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gNzExNCw0MzMzIEwgNzE2NSw0MzQ2Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gNzIxNyw0MzU5IEwgNzI2OCw0MzcyIi8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gNzMyMCw0Mzg2IEwgNzM3MSw0Mzk5Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gNzQyMyw0NDEyIEwgNzQ3NCw0NDI2Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gNzUyNSw0NDM5IEwgNzU3Nyw0NDUyIi8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gNzYyOCw0NDY1IEwgNzY4MCw0NDc5Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gNzczMSw0NDkyIEwgNzc4Miw0NTA1Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gNzgzNCw0NTE4IEwgNzg4NSw0NTMyIi8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gNzkzNyw0NTQ1IEwgNzk4OCw0NTU4Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gODAzOSw0NTcxIEwgODA5MSw0NTg1Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gODE0Miw0NTk4IEwgODE5NCw0NjExIi8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gODI0NSw0NjI1IEwgODI5Niw0NjM4Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gODM0OCw0NjUxIEwgODM5OSw0NjY0Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gODQ1MSw0Njc4IEwgODUwMiw0NjkxIi8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gODU1Myw0NzA0IEwgODYwNSw0NzE3Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gODY1Niw0NzMxIEwgODcwOCw0NzQ0Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gODc1OSw0NzU3IEwgODgxMSw0NzcwIi8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gODg2Miw0Nzg0IEwgODkxMyw0Nzk3Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gODk2NSw0ODEwIEwgOTAxNiw0ODI0Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gOTA2OCw0ODM3IEwgOTExOSw0ODUwIi8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gOTE3MCw0ODYzIEwgOTIyMiw0ODc3Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gOTI3Myw0ODkwIEwgOTMyNSw0OTAzIi8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gOTM3Niw0OTE2IEwgOTQyNyw0OTMwIi8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gOTQ3OSw0OTQzIEwgOTUzMCw0OTU2Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gOTU4Miw0OTY5IEwgOTYzMyw0OTgzIi8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gOTY4NCw0OTk2IEwgOTcwMCw1MDAwIi8+CiAgICAgIDwvZz4KICAgICA8L2c+CiAgICAgPGcgY2xhc3M9ImNvbS5zdW4uc3Rhci5kcmF3aW5nLkN1c3RvbVNoYXBlIj4KICAgICAgPGcgaWQ9ImlkMTUiPgogICAgICAgPHBhdGggZmlsbD0icmdiKDI1NSwyNTUsMjU1KSIgc3Ryb2tlPSJub25lIiBkPSJNIDEyNjUwLDI3MDAgTCAxMDcwMCwyNzAwIDEwNzAwLDE1MDAgMTQ2MDAsMTUwMCAxNDYwMCwyNzAwIDEyNjUwLDI3MDAgWiIvPgogICAgICAgPHRleHQgY2xhc3M9IlRleHRTaGFwZSI+PHRzcGFuIGNsYXNzPSJUZXh0UGFyYWdyYXBoIiBmb250LWZhbWlseT0iTGliZXJhdGlvbiBTYW5zLCBzYW5zLXNlcmlmIiBmb250LXNpemU9IjM1M3B4IiBmb250LXdlaWdodD0iNDAwIj48dHNwYW4gY2xhc3M9IlRleHRQb3NpdGlvbiIgeD0iMTA5NTAiIHk9IjIwMjQiPjx0c3BhbiBmaWxsPSJyZ2IoMCwwLDApIiBzdHJva2U9Im5vbmUiPkNvcm5lciBwb2ludHMgc3RhcnQgPC90c3Bhbj48L3RzcGFuPjx0c3BhbiBjbGFzcz0iVGV4dFBvc2l0aW9uIiB4PSIxMDk1MCIgeT0iMjQxOCI+PHRzcGFuIGZpbGw9InJnYigwLDAsMCkiIHN0cm9rZT0ibm9uZSI+d2l0aCB0aGUgc2FtZSB2YWx1ZXM8L3RzcGFuPjwvdHNwYW4+PC90c3Bhbj48L3RleHQ+CiAgICAgIDwvZz4KICAgICA8L2c+CiAgICAgPGcgY2xhc3M9ImNvbS5zdW4uc3Rhci5kcmF3aW5nLkN1c3RvbVNoYXBlIj4KICAgICAgPGcgaWQ9ImlkMTYiPgogICAgICAgPHBhdGggZmlsbD0icmdiKDI1NSwyNTUsMjU1KSIgc3Ryb2tlPSJub25lIiBkPSJNIDEyODUwLDg1MDAgTCAxMDkwMCw4NTAwIDEwOTAwLDczMDAgMTQ4MDAsNzMwMCAxNDgwMCw4NTAwIDEyODUwLDg1MDAgWiIvPgogICAgICAgPHRleHQgY2xhc3M9IlRleHRTaGFwZSI+PHRzcGFuIGNsYXNzPSJUZXh0UGFyYWdyYXBoIiBmb250LWZhbWlseT0iTGliZXJhdGlvbiBTYW5zLCBzYW5zLXNlcmlmIiBmb250LXNpemU9IjM1M3B4IiBmb250LXdlaWdodD0iNDAwIj48dHNwYW4gY2xhc3M9IlRleHRQb3NpdGlvbiIgeD0iMTExNTAiIHk9Ijc4MjQiPjx0c3BhbiBmaWxsPSJyZ2IoMCwwLDApIiBzdHJva2U9Im5vbmUiPkNvcm5lciBwb2ludHMgc3RhcnQgPC90c3Bhbj48L3RzcGFuPjx0c3BhbiBjbGFzcz0iVGV4dFBvc2l0aW9uIiB4PSIxMTE1MCIgeT0iODIxOCI+PHRzcGFuIGZpbGw9InJnYigwLDAsMCkiIHN0cm9rZT0ibm9uZSI+d2l0aCB0aGUgc2FtZSB2YWx1ZXM8L3RzcGFuPjwvdHNwYW4+PC90c3Bhbj48L3RleHQ+CiAgICAgIDwvZz4KICAgICA8L2c+CiAgICAgPGcgY2xhc3M9ImNvbS5zdW4uc3Rhci5kcmF3aW5nLkN1c3RvbVNoYXBlIj4KICAgICAgPGcgaWQ9ImlkMTciPgogICAgICAgPHBhdGggZmlsbD0icmdiKDI1NSwyNTUsMjU1KSIgc3Ryb2tlPSJub25lIiBkPSJNIDEyNDAwLDUyMDAgTCAxMDkwMCw1MjAwIDEwOTAwLDMzMDAgMTM5MDAsMzMwMCAxMzkwMCw1MjAwIDEyNDAwLDUyMDAgWiIvPgogICAgICAgPHRleHQgY2xhc3M9IlRleHRTaGFwZSI+PHRzcGFuIGNsYXNzPSJUZXh0UGFyYWdyYXBoIiBmb250LWZhbWlseT0iTGliZXJhdGlvbiBTYW5zLCBzYW5zLXNlcmlmIiBmb250LXNpemU9IjM1M3B4IiBmb250LXdlaWdodD0iNDAwIj48dHNwYW4gY2xhc3M9IlRleHRQb3NpdGlvbiIgeD0iMTExNTAiIHk9IjM3ODAiPjx0c3BhbiBmaWxsPSJyZ2IoMCwwLDApIiBzdHJva2U9Im5vbmUiPk9wcG9zaW5nIDwvdHNwYW4+PC90c3Bhbj48dHNwYW4gY2xhc3M9IlRleHRQb3NpdGlvbiIgeD0iMTExNTAiIHk9IjQxNzQiPjx0c3BhbiBmaWxsPSJyZ2IoMCwwLDApIiBzdHJva2U9Im5vbmUiPmRpcmVjdGlvbnMgb2YgPC90c3Bhbj48L3RzcGFuPjx0c3BhbiBjbGFzcz0iVGV4dFBvc2l0aW9uIiB4PSIxMTE1MCIgeT0iNDU2OCI+PHRzcGFuIGZpbGw9InJnYigwLDAsMCkiIHN0cm9rZT0ibm9uZSI+ZWRnZSB3YWxraW5nIDwvdHNwYW4+PC90c3Bhbj48dHNwYW4gY2xhc3M9IlRleHRQb3NpdGlvbiIgeD0iMTExNTAiIHk9IjQ5NjIiPjx0c3BhbiBmaWxsPSJyZ2IoMCwwLDApIiBzdHJva2U9Im5vbmUiPmZvciBzdWJkaXZpc2lvbjwvdHNwYW4+PC90c3Bhbj48L3RzcGFuPjwvdGV4dD4KICAgICAgPC9nPgogICAgIDwvZz4KICAgICA8ZyBjbGFzcz0iY29tLnN1bi5zdGFyLmRyYXdpbmcuTGluZVNoYXBlIj4KICAgICAgPGcgaWQ9ImlkMTgiPgogICAgICAgPHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSJyZ2IoMCwwLDApIiBkPSJNIDEwMzAwLDI5MDAgTCAxMDM0MSwyODY3Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gMTAzODMsMjgzNCBMIDEwNDI0LDI4MDEiLz4KICAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0icmdiKDAsMCwwKSIgZD0iTSAxMDQ2NiwyNzY3IEwgMTA1MDcsMjczNCIvPgogICAgICAgPHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSJyZ2IoMCwwLDApIiBkPSJNIDEwNTQ5LDI3MDEgTCAxMDU5MCwyNjY4Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gMTA2MzIsMjYzNSBMIDEwNjczLDI2MDIiLz4KICAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0icmdiKDAsMCwwKSIgZD0iTSAxMDcxNSwyNTY4IEwgMTA3NTYsMjUzNSIvPgogICAgICAgPHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSJyZ2IoMCwwLDApIiBkPSJNIDEwNzk3LDI1MDIgTCAxMDgwMCwyNTAwIi8+CiAgICAgIDwvZz4KICAgICA8L2c+CiAgICAgPGcgY2xhc3M9ImNvbS5zdW4uc3Rhci5kcmF3aW5nLkxpbmVTaGFwZSI+CiAgICAgIDxnIGlkPSJpZDE5Ij4KICAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0icmdiKDAsMCwwKSIgZD0iTSAxMDIwMCw3MTAwIEwgMTAyNDMsNzEzMSIvPgogICAgICAgPHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSJyZ2IoMCwwLDApIiBkPSJNIDEwMjg2LDcxNjIgTCAxMDMzMCw3MTkzIi8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gMTAzNzMsNzIyMyBMIDEwNDE2LDcyNTQiLz4KICAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0icmdiKDAsMCwwKSIgZD0iTSAxMDQ1OSw3Mjg1IEwgMTA1MDIsNzMxNiIvPgogICAgICAgPHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSJyZ2IoMCwwLDApIiBkPSJNIDEwNTQ2LDczNDcgTCAxMDU4OSw3Mzc4Ii8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gMTA2MzIsNzQwOSBMIDEwNjc1LDc0MzkiLz4KICAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0icmdiKDAsMCwwKSIgZD0iTSAxMDcxOCw3NDcwIEwgMTA3NjIsNzUwMSIvPgogICAgICAgPHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSJyZ2IoMCwwLDApIiBkPSJNIDEwODA1LDc1MzIgTCAxMDg0OCw3NTYzIi8+CiAgICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9InJnYigwLDAsMCkiIGQ9Ik0gMTA4OTEsNzU5NCBMIDEwOTAwLDc2MDAiLz4KICAgICAgPC9nPgogICAgIDwvZz4KICAgIDwvZz4KICAgPC9nPgogIDwvZz4KIDwvZz4KPC9zdmc+" alt="precise">
91485bd8deadSopenharmony_ci</div>
91495bd8deadSopenharmony_ci</div>
91505bd8deadSopenharmony_ci<div class="paragraph">
91515bd8deadSopenharmony_ci<p>Without any qualifiers, implementations are permitted to perform
91525bd8deadSopenharmony_cioptimizations that effectively modify the order or number of operations used
91535bd8deadSopenharmony_cito evaluate an expression, even if those optimizations may produce slightly
91545bd8deadSopenharmony_cidifferent results relative to unoptimized code.</p>
91555bd8deadSopenharmony_ci</div>
91565bd8deadSopenharmony_ci<div class="paragraph">
91575bd8deadSopenharmony_ci<p>The <strong>precise</strong> qualifier ensures that operations contributing to a
91585bd8deadSopenharmony_civariable&#8217;s value are done in their stated order and with operator consistency.
91595bd8deadSopenharmony_ciThe order is determined by operator precedence and parenthesis, as described in
91605bd8deadSopenharmony_ci&#8220;<a href="#operators">Operators</a>&#8221;.
91615bd8deadSopenharmony_ciOperator consistency means for each particular operator, for example the
91625bd8deadSopenharmony_cimultiply operator (<strong>*</strong>), its operation is always computed with the same
91635bd8deadSopenharmony_ciprecision.
91645bd8deadSopenharmony_ciSpecifically, values computed by compiler-generated code must adhere to the
91655bd8deadSopenharmony_cifollowing identities:</p>
91665bd8deadSopenharmony_ci</div>
91675bd8deadSopenharmony_ci<div class="olist arabic">
91685bd8deadSopenharmony_ci<ol class="arabic">
91695bd8deadSopenharmony_ci<li>
91705bd8deadSopenharmony_ci<p>a + b = b + a</p>
91715bd8deadSopenharmony_ci</li>
91725bd8deadSopenharmony_ci<li>
91735bd8deadSopenharmony_ci<p>a * b = b * a</p>
91745bd8deadSopenharmony_ci</li>
91755bd8deadSopenharmony_ci<li>
91765bd8deadSopenharmony_ci<p>a * b + c * d = b * a + c* d = d * c + b * a = &lt;any other mathematically
91775bd8deadSopenharmony_civalid combination&gt;</p>
91785bd8deadSopenharmony_ci</li>
91795bd8deadSopenharmony_ci</ol>
91805bd8deadSopenharmony_ci</div>
91815bd8deadSopenharmony_ci<div class="paragraph">
91825bd8deadSopenharmony_ci<p>While the following are prevented:</p>
91835bd8deadSopenharmony_ci</div>
91845bd8deadSopenharmony_ci<div class="olist arabic">
91855bd8deadSopenharmony_ci<ol class="arabic">
91865bd8deadSopenharmony_ci<li>
91875bd8deadSopenharmony_ci<p>a + (b + c) is not allowed to become (a + b) + c</p>
91885bd8deadSopenharmony_ci</li>
91895bd8deadSopenharmony_ci<li>
91905bd8deadSopenharmony_ci<p>a * (b * c) is not allowed to become (a * b) * c</p>
91915bd8deadSopenharmony_ci</li>
91925bd8deadSopenharmony_ci<li>
91935bd8deadSopenharmony_ci<p>a * b + c is not allowed to become a single operation <strong>fma</strong>(a, b, c)</p>
91945bd8deadSopenharmony_ci</li>
91955bd8deadSopenharmony_ci</ol>
91965bd8deadSopenharmony_ci</div>
91975bd8deadSopenharmony_ci<div class="paragraph">
91985bd8deadSopenharmony_ci<p>Where <em>a</em>, <em>b</em>, <em>c</em>, and <em>d</em>, are scalars or vectors, not matrices.
91995bd8deadSopenharmony_ci(Matrix multiplication generally does not commute.) It is the shader
92005bd8deadSopenharmony_ciwriter&#8217;s responsibility to express the computation in terms of these rules
92015bd8deadSopenharmony_ciand the compiler&#8217;s responsibility to follow these rules.
92025bd8deadSopenharmony_ciSee the description of <em>gl_TessCoord</em> for the rules the tessellation stages
92035bd8deadSopenharmony_ciare responsible for following, which in conjunction with the above allow
92045bd8deadSopenharmony_ciavoiding cracking when subdividing.</p>
92055bd8deadSopenharmony_ci</div>
92065bd8deadSopenharmony_ci<div class="paragraph">
92075bd8deadSopenharmony_ci<p>For example,</p>
92085bd8deadSopenharmony_ci</div>
92095bd8deadSopenharmony_ci<div class="listingblock">
92105bd8deadSopenharmony_ci<div class="content">
92115bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">precise out vec4 position;</code></pre>
92125bd8deadSopenharmony_ci</div>
92135bd8deadSopenharmony_ci</div>
92145bd8deadSopenharmony_ci<div class="paragraph">
92155bd8deadSopenharmony_ci<p>declares that operations used to produce the value of <em>position</em> must be
92165bd8deadSopenharmony_ciperformed in exactly the order specified in the source code and with all
92175bd8deadSopenharmony_cioperators being treated consistently.
92185bd8deadSopenharmony_ciAs with the <strong>invariant</strong> qualifier (see &#8220;<a href="#the-invariant-qualifier">The
92195bd8deadSopenharmony_ciInvariant Qualifier</a>&#8221;), the <strong>precise</strong> qualifier may be used to qualify a
92205bd8deadSopenharmony_cibuilt-in or previously declared user-defined variable as being precise:</p>
92215bd8deadSopenharmony_ci</div>
92225bd8deadSopenharmony_ci<div class="listingblock">
92235bd8deadSopenharmony_ci<div class="content">
92245bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">out vec3 Color;
92255bd8deadSopenharmony_ciprecise Color; <span class="comment">// make existing Color be precise</span></code></pre>
92265bd8deadSopenharmony_ci</div>
92275bd8deadSopenharmony_ci</div>
92285bd8deadSopenharmony_ci<div class="paragraph">
92295bd8deadSopenharmony_ci<p>When applied to a block, a structure type, or a variable of structure type,
92305bd8deadSopenharmony_ci<strong>precise</strong> applies to each contained member, recursively.</p>
92315bd8deadSopenharmony_ci</div>
92325bd8deadSopenharmony_ci<div class="paragraph">
92335bd8deadSopenharmony_ci<p>This qualifier will affect the evaluation of an r-value in a particular
92345bd8deadSopenharmony_cifunction if and only if the result is eventually consumed in the same
92355bd8deadSopenharmony_cifunction by an l-value qualified as <strong>precise</strong>.
92365bd8deadSopenharmony_ciAny other expressions within a function are not affected, including return
92375bd8deadSopenharmony_civalues and output parameters not declared as <strong>precise</strong> but that are
92385bd8deadSopenharmony_cieventually consumed outside the function by a variable qualified as
92395bd8deadSopenharmony_ci<strong>precise</strong>. Unaffected expressions also include the controlling expressions
92405bd8deadSopenharmony_ciin selection and iteration statements and the condition in ternary
92415bd8deadSopenharmony_cioperators (<strong>?:</strong>).</p>
92425bd8deadSopenharmony_ci</div>
92435bd8deadSopenharmony_ci<div class="paragraph">
92445bd8deadSopenharmony_ci<p>Some examples of the use of <strong>precise</strong>:</p>
92455bd8deadSopenharmony_ci</div>
92465bd8deadSopenharmony_ci<div class="listingblock">
92475bd8deadSopenharmony_ci<div class="content">
92485bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">in vec4 a, b, c, d;
92495bd8deadSopenharmony_ciprecise out vec4 v;
92505bd8deadSopenharmony_ci
92515bd8deadSopenharmony_ci<span class="predefined-type">float</span> func(<span class="predefined-type">float</span> e, <span class="predefined-type">float</span> f, <span class="predefined-type">float</span> g, <span class="predefined-type">float</span> h)
92525bd8deadSopenharmony_ci{
92535bd8deadSopenharmony_ci    <span class="keyword">return</span> (e*f) + (g*h); <span class="comment">// no constraint on order or operator consistency</span>
92545bd8deadSopenharmony_ci}
92555bd8deadSopenharmony_ci
92565bd8deadSopenharmony_ci<span class="predefined-type">float</span> func2(<span class="predefined-type">float</span> e, <span class="predefined-type">float</span> f, <span class="predefined-type">float</span> g, <span class="predefined-type">float</span> h)
92575bd8deadSopenharmony_ci{
92585bd8deadSopenharmony_ci    precise <span class="predefined-type">float</span> result = (e*f) + (g*h); <span class="comment">// ensures same precision for the two multiplies</span>
92595bd8deadSopenharmony_ci    <span class="keyword">return</span> result;
92605bd8deadSopenharmony_ci}
92615bd8deadSopenharmony_ci
92625bd8deadSopenharmony_ci<span class="predefined-type">float</span> func3(<span class="predefined-type">float</span> i, <span class="predefined-type">float</span> j, precise out <span class="predefined-type">float</span> k)
92635bd8deadSopenharmony_ci{
92645bd8deadSopenharmony_ci    k = i * i + j;        <span class="comment">// precise, due to &lt;k&gt; declaration</span>
92655bd8deadSopenharmony_ci}
92665bd8deadSopenharmony_ci
92675bd8deadSopenharmony_ci<span class="directive">void</span> main()
92685bd8deadSopenharmony_ci{
92695bd8deadSopenharmony_ci    vec3 r = vec3(a * b);             <span class="comment">// precise, used to compute v.xyz</span>
92705bd8deadSopenharmony_ci    vec3 s = vec3(c * d);             <span class="comment">// precise, used to compute v.xyz</span>
92715bd8deadSopenharmony_ci    v.xyz = r + s;                    <span class="comment">// precise</span>
92725bd8deadSopenharmony_ci    v.w = (a.w * b.w) + (c.w * d.w);  <span class="comment">// precise</span>
92735bd8deadSopenharmony_ci    v.x = func(a.x, b.x, c.x, d.x);   <span class="comment">// values computed in func() are NOT precise</span>
92745bd8deadSopenharmony_ci    v.x = func2(a.x, b.x, c.x, d.x);  <span class="comment">// precise!</span>
92755bd8deadSopenharmony_ci    func3(a.x * b.x, c.x * d.x, v.x); <span class="comment">// precise!</span>
92765bd8deadSopenharmony_ci}</code></pre>
92775bd8deadSopenharmony_ci</div>
92785bd8deadSopenharmony_ci</div>
92795bd8deadSopenharmony_ci<div class="paragraph">
92805bd8deadSopenharmony_ci<p>For the purposes of determining if an output from one shader stage matches
92815bd8deadSopenharmony_cian input of the next stage, the <strong>precise</strong> qualifier need not match between
92825bd8deadSopenharmony_cithe input and the output.</p>
92835bd8deadSopenharmony_ci</div>
92845bd8deadSopenharmony_ci<div class="paragraph">
92855bd8deadSopenharmony_ci<p>All constant expressions are evaluated as if <strong>precise</strong> was present, whether
92865bd8deadSopenharmony_cior not it is present.
92875bd8deadSopenharmony_ciHowever, as described in &#8220;<a href="#constant-expressions">Constant Expressions</a>&#8221;,
92885bd8deadSopenharmony_cithere is no requirement that a compile-time constant expression evaluates to
92895bd8deadSopenharmony_cithe same value as a corresponding non-constant expression.</p>
92905bd8deadSopenharmony_ci</div>
92915bd8deadSopenharmony_ci</div>
92925bd8deadSopenharmony_ci<div class="sect2">
92935bd8deadSopenharmony_ci<h3 id="memory-qualifiers">4.10. Memory Qualifiers</h3>
92945bd8deadSopenharmony_ci<div class="paragraph">
92955bd8deadSopenharmony_ci<p>Shader storage blocks, variables declared within shader storage blocks and
92965bd8deadSopenharmony_civariables declared as image types (the basic opaque types with &#8220;<strong>image</strong>&#8221;
92975bd8deadSopenharmony_ciin their keyword), can be further qualified with one or more of the
92985bd8deadSopenharmony_cifollowing memory qualifiers:</p>
92995bd8deadSopenharmony_ci</div>
93005bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
93015bd8deadSopenharmony_ci<colgroup>
93025bd8deadSopenharmony_ci<col style="width: 50%;">
93035bd8deadSopenharmony_ci<col style="width: 50%;">
93045bd8deadSopenharmony_ci</colgroup>
93055bd8deadSopenharmony_ci<thead>
93065bd8deadSopenharmony_ci<tr>
93075bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Qualifier</th>
93085bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Meaning</th>
93095bd8deadSopenharmony_ci</tr>
93105bd8deadSopenharmony_ci</thead>
93115bd8deadSopenharmony_ci<tbody>
93125bd8deadSopenharmony_ci<tr>
93135bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>coherent</strong></p></td>
93145bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">memory variable where reads and writes are coherent with
93155bd8deadSopenharmony_ci                reads and writes from other shader invocations</p></td>
93165bd8deadSopenharmony_ci</tr>
93175bd8deadSopenharmony_ci<tr>
93185bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>volatile</strong></p></td>
93195bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">memory variable whose underlying value may be changed at any
93205bd8deadSopenharmony_ci                point during shader execution by some source other than the
93215bd8deadSopenharmony_ci                current shader invocation</p></td>
93225bd8deadSopenharmony_ci</tr>
93235bd8deadSopenharmony_ci<tr>
93245bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>restrict</strong></p></td>
93255bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">memory variable where use of that variable is the only way
93265bd8deadSopenharmony_ci                to read and write the underlying memory in the relevant
93275bd8deadSopenharmony_ci                shader stage</p></td>
93285bd8deadSopenharmony_ci</tr>
93295bd8deadSopenharmony_ci<tr>
93305bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>readonly</strong></p></td>
93315bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">memory variable that can be used to read the underlying
93325bd8deadSopenharmony_ci                memory, but cannot be used to write the underlying memory</p></td>
93335bd8deadSopenharmony_ci</tr>
93345bd8deadSopenharmony_ci<tr>
93355bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>writeonly</strong></p></td>
93365bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">memory variable that can be used to write the underlying
93375bd8deadSopenharmony_ci                memory, but cannot be used to read the underlying memory</p></td>
93385bd8deadSopenharmony_ci</tr>
93395bd8deadSopenharmony_ci</tbody>
93405bd8deadSopenharmony_ci</table>
93415bd8deadSopenharmony_ci<div class="paragraph">
93425bd8deadSopenharmony_ci<p>Memory accesses to image variables declared using the <strong>coherent</strong> qualifier
93435bd8deadSopenharmony_ciare performed coherently with accesses to the same location from other
93445bd8deadSopenharmony_cishader invocations.
93455bd8deadSopenharmony_ciIn particular, when reading a variable declared as <strong>coherent</strong>, the values
93465bd8deadSopenharmony_cireturned will reflect the results of previously completed writes performed
93475bd8deadSopenharmony_ciby other shader invocations.
93485bd8deadSopenharmony_ciWhen writing a variable declared as <strong>coherent</strong>, the values written will be
93495bd8deadSopenharmony_cireflected in subsequent coherent reads performed by other shader
93505bd8deadSopenharmony_ciinvocations.</p>
93515bd8deadSopenharmony_ci</div>
93525bd8deadSopenharmony_ci<div class="paragraph">
93535bd8deadSopenharmony_ci<p>As described in section
93545bd8deadSopenharmony_ci7.12
93555bd8deadSopenharmony_ci&#8220;Shader Memory Access&#8221; of the
93565bd8deadSopenharmony_ci<a href="#references">OpenGL Specification</a>, shader memory reads and writes complete in a
93575bd8deadSopenharmony_cilargely undefined order.
93585bd8deadSopenharmony_ciThe built-in function <strong>memoryBarrier</strong>() can be used if needed to guarantee
93595bd8deadSopenharmony_cithe completion and relative ordering of memory accesses performed by a
93605bd8deadSopenharmony_cisingle shader invocation.</p>
93615bd8deadSopenharmony_ci</div>
93625bd8deadSopenharmony_ci<div class="paragraph">
93635bd8deadSopenharmony_ci<p>When accessing memory using variables not declared as <strong>coherent</strong>, the memory
93645bd8deadSopenharmony_ciaccessed by a shader may be cached by the implementation to service future
93655bd8deadSopenharmony_ciaccesses to the same address.
93665bd8deadSopenharmony_ciMemory stores may be cached in such a way that the values written may not be
93675bd8deadSopenharmony_civisible to other shader invocations accessing the same memory.
93685bd8deadSopenharmony_ciThe implementation may cache the values fetched by memory reads and return
93695bd8deadSopenharmony_cithe same values to any shader invocation accessing the same memory, even if
93705bd8deadSopenharmony_cithe underlying memory has been modified since the first memory read.
93715bd8deadSopenharmony_ciWhile variables not declared as <strong>coherent</strong> may not be useful for
93725bd8deadSopenharmony_cicommunicating between shader invocations, using non-coherent accesses may
93735bd8deadSopenharmony_ciresult in higher performance.</p>
93745bd8deadSopenharmony_ci</div>
93755bd8deadSopenharmony_ci<div class="paragraph">
93765bd8deadSopenharmony_ci<p>Memory accesses to image variables declared using the <strong>volatile</strong> qualifier
93775bd8deadSopenharmony_cimust treat the underlying memory as though it could be read or written at
93785bd8deadSopenharmony_ciany point during shader execution by some source other than the executing
93795bd8deadSopenharmony_cishader invocation.
93805bd8deadSopenharmony_ciWhen a volatile variable is read, its value must be re-fetched from the
93815bd8deadSopenharmony_ciunderlying memory, even if the shader invocation performing the read had
93825bd8deadSopenharmony_cipreviously fetched its value from the same memory.
93835bd8deadSopenharmony_ciWhen a volatile variable is written, its value must be written to the
93845bd8deadSopenharmony_ciunderlying memory, even if the compiler can conclusively determine that its
93855bd8deadSopenharmony_civalue will be overwritten by a subsequent write.
93865bd8deadSopenharmony_ciSince the external source reading or writing a <strong>volatile</strong> variable may be
93875bd8deadSopenharmony_cianother shader invocation, variables declared as <strong>volatile</strong> are
93885bd8deadSopenharmony_ciautomatically treated as coherent.</p>
93895bd8deadSopenharmony_ci</div>
93905bd8deadSopenharmony_ci<div class="paragraph">
93915bd8deadSopenharmony_ci<p>Memory accesses to image variables declared using the <strong>restrict</strong> qualifier
93925bd8deadSopenharmony_cimay be compiled assuming that the variable used to perform the memory access
93935bd8deadSopenharmony_ciis the only way to access the underlying memory using the shader stage in
93945bd8deadSopenharmony_ciquestion.
93955bd8deadSopenharmony_ciThis allows the compiler to coalesce or reorder loads and stores using
93965bd8deadSopenharmony_ci<strong>restrict</strong>-qualified image variables in ways that wouldn&#8217;t be permitted
93975bd8deadSopenharmony_cifor image variables not so qualified, because the compiler can assume that
93985bd8deadSopenharmony_cithe underlying image won&#8217;t be read or written by other code.
93995bd8deadSopenharmony_ciApplications are responsible for ensuring that image memory referenced by
94005bd8deadSopenharmony_civariables qualified with <strong>restrict</strong> will not be referenced using other
94015bd8deadSopenharmony_civariables in the same scope; otherwise, accesses to <strong>restrict</strong>-qualified
94025bd8deadSopenharmony_civariables will have undefined results.</p>
94035bd8deadSopenharmony_ci</div>
94045bd8deadSopenharmony_ci<div class="paragraph">
94055bd8deadSopenharmony_ci<p>Memory accesses to image variables declared using the <strong>readonly</strong> qualifier
94065bd8deadSopenharmony_cimay only read the underlying memory, which is treated as read-only memory
94075bd8deadSopenharmony_ciand cannot be written to.
94085bd8deadSopenharmony_ciIt is a compile-time error to pass an image variable qualified with
94095bd8deadSopenharmony_ci<strong>readonly</strong> to <strong>imageStore</strong>() or other built-in functions that modify image
94105bd8deadSopenharmony_cimemory.</p>
94115bd8deadSopenharmony_ci</div>
94125bd8deadSopenharmony_ci<div class="paragraph">
94135bd8deadSopenharmony_ci<p>Memory accesses to image variables declared using the <strong>writeonly</strong> qualifier
94145bd8deadSopenharmony_cimay only write the underlying memory; the underlying memory cannot be read.
94155bd8deadSopenharmony_ciIt is a compile-time error to pass an image variable qualified with
94165bd8deadSopenharmony_ci<strong>writeonly</strong> to <strong>imageLoad</strong>() or other built-in functions that read image
94175bd8deadSopenharmony_cimemory.</p>
94185bd8deadSopenharmony_ci</div>
94195bd8deadSopenharmony_ci<div class="paragraph">
94205bd8deadSopenharmony_ci<p>A variable could be qualified as both <strong>readonly</strong> and <strong>writeonly</strong>, disallowing
94215bd8deadSopenharmony_ciboth read and write. Such variables can still be used with some queries, for
94225bd8deadSopenharmony_ciexample <strong>imageSize</strong>() and <strong>.length</strong>().</p>
94235bd8deadSopenharmony_ci</div>
94245bd8deadSopenharmony_ci<div class="paragraph">
94255bd8deadSopenharmony_ci<p>The memory qualifiers <strong>coherent</strong>, <strong>volatile</strong>, <strong>restrict</strong>, <strong>readonly</strong>, and
94265bd8deadSopenharmony_ci<strong>writeonly</strong> may be used in the declaration of buffer variables (i.e.,
94275bd8deadSopenharmony_cimembers of shader storage blocks).
94285bd8deadSopenharmony_ciWhen a buffer variable is declared with a memory qualifier, the behavior
94295bd8deadSopenharmony_cispecified for memory accesses involving image variables described above
94305bd8deadSopenharmony_ciapplies identically to memory accesses involving that buffer variable.
94315bd8deadSopenharmony_ciIt is a compile-time error to assign to a buffer variable qualified with
94325bd8deadSopenharmony_ci<strong>readonly</strong> or to read from a buffer variable qualified with <strong>writeonly</strong>.
94335bd8deadSopenharmony_ciThe combination <strong>readonly</strong> <strong>writeonly</strong> is allowed.</p>
94345bd8deadSopenharmony_ci</div>
94355bd8deadSopenharmony_ci<div class="paragraph">
94365bd8deadSopenharmony_ci<p>Additionally, memory qualifiers may be used at the block-level declaration
94375bd8deadSopenharmony_ciof a shader storage block, including the combination <strong>readonly</strong> <strong>writeonly</strong>.
94385bd8deadSopenharmony_ciWhen a block declaration is qualified with a memory qualifier, it is as if
94395bd8deadSopenharmony_ciall of its members were declared with the same memory qualifier.
94405bd8deadSopenharmony_ciFor example, the block declaration</p>
94415bd8deadSopenharmony_ci</div>
94425bd8deadSopenharmony_ci<div class="listingblock">
94435bd8deadSopenharmony_ci<div class="content">
94445bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">coherent buffer Block {
94455bd8deadSopenharmony_ci    readonly vec4 member1;
94465bd8deadSopenharmony_ci    vec4 member2;
94475bd8deadSopenharmony_ci};</code></pre>
94485bd8deadSopenharmony_ci</div>
94495bd8deadSopenharmony_ci</div>
94505bd8deadSopenharmony_ci<div class="paragraph">
94515bd8deadSopenharmony_ci<p>is equivalent to</p>
94525bd8deadSopenharmony_ci</div>
94535bd8deadSopenharmony_ci<div class="listingblock">
94545bd8deadSopenharmony_ci<div class="content">
94555bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">buffer Block {
94565bd8deadSopenharmony_ci    coherent readonly vec4 member1;
94575bd8deadSopenharmony_ci    coherent vec4 member2;
94585bd8deadSopenharmony_ci};</code></pre>
94595bd8deadSopenharmony_ci</div>
94605bd8deadSopenharmony_ci</div>
94615bd8deadSopenharmony_ci<div class="paragraph">
94625bd8deadSopenharmony_ci<p>Memory qualifiers are only supported in the declarations of image variables,
94635bd8deadSopenharmony_cibuffer variables, and shader storage blocks; it is an error to use such
94645bd8deadSopenharmony_ciqualifiers in any other declarations.</p>
94655bd8deadSopenharmony_ci</div>
94665bd8deadSopenharmony_ci<div class="paragraph">
94675bd8deadSopenharmony_ci<p>When calling user-defined functions, variables qualified with <strong>coherent</strong>,
94685bd8deadSopenharmony_ci<strong>volatile</strong>, <strong>readonly</strong>, or <strong>writeonly</strong> may not be passed to functions whose
94695bd8deadSopenharmony_ciformal parameters lack such qualifiers.
94705bd8deadSopenharmony_ci(See &#8220;<a href="#function-definitions">Function Definitions</a>&#8221; for more detail on
94715bd8deadSopenharmony_cifunction calling.) It is legal to have any additional memory qualifiers on a
94725bd8deadSopenharmony_ciformal parameter, but only <strong>restrict</strong> can be taken away from a calling
94735bd8deadSopenharmony_ciargument, by a formal parameter that lacks the <strong>restrict</strong> qualifier.</p>
94745bd8deadSopenharmony_ci</div>
94755bd8deadSopenharmony_ci<div class="paragraph">
94765bd8deadSopenharmony_ci<p>When a built-in function is called, the code generated is to be based on the
94775bd8deadSopenharmony_ciactual qualification of the calling argument, not on the list of memory
94785bd8deadSopenharmony_ciqualifiers specified on the formal parameter in the prototype.</p>
94795bd8deadSopenharmony_ci</div>
94805bd8deadSopenharmony_ci<div class="listingblock">
94815bd8deadSopenharmony_ci<div class="content">
94825bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec4 funcA(restrict image2D a) { ... }
94835bd8deadSopenharmony_civec4 funcB(image2D a) { ... }
94845bd8deadSopenharmony_cilayout(rgba32f) uniform image2D img1;
94855bd8deadSopenharmony_cilayout(rgba32f) coherent uniform image2D img2;
94865bd8deadSopenharmony_ci
94875bd8deadSopenharmony_cifuncA(img1);        <span class="comment">// OK, adding &quot;restrict&quot; is allowed</span>
94885bd8deadSopenharmony_cifuncB(img2);        <span class="comment">// illegal, stripping &quot;coherent&quot; is not</span></code></pre>
94895bd8deadSopenharmony_ci</div>
94905bd8deadSopenharmony_ci</div>
94915bd8deadSopenharmony_ci<div class="paragraph">
94925bd8deadSopenharmony_ci<p>Layout qualifiers cannot be used on formal function parameters, and layout
94935bd8deadSopenharmony_ciqualification is not included in parameter matching.</p>
94945bd8deadSopenharmony_ci</div>
94955bd8deadSopenharmony_ci<div class="paragraph">
94965bd8deadSopenharmony_ci<p>Note that the use of <strong>const</strong> in an image variable declaration is qualifying
94975bd8deadSopenharmony_cithe const-ness of the variable being declared, not the image it refers to.
94985bd8deadSopenharmony_ciThe qualifier <strong>readonly</strong> qualifies the image memory (as accessed through
94995bd8deadSopenharmony_cithat variable) while <strong>const</strong> qualifies the variable itself.</p>
95005bd8deadSopenharmony_ci</div>
95015bd8deadSopenharmony_ci</div>
95025bd8deadSopenharmony_ci<div class="sect2">
95035bd8deadSopenharmony_ci<h3 id="specialization-constant-qualifier">4.11. Specialization-Constant Qualifier</h3>
95045bd8deadSopenharmony_ci<div class="paragraph">
95055bd8deadSopenharmony_ci<p>Specialization constants are used only for SPIR-V and declared using the
95065bd8deadSopenharmony_ci<strong>constant_id</strong> layout qualifier.
95075bd8deadSopenharmony_ciFor example:</p>
95085bd8deadSopenharmony_ci</div>
95095bd8deadSopenharmony_ci<div class="listingblock">
95105bd8deadSopenharmony_ci<div class="content">
95115bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(constant_id = <span class="integer">17</span>) <span class="directive">const</span> <span class="predefined-type">int</span> arraySize = <span class="integer">12</span>;</code></pre>
95125bd8deadSopenharmony_ci</div>
95135bd8deadSopenharmony_ci</div>
95145bd8deadSopenharmony_ci<div class="paragraph">
95155bd8deadSopenharmony_ci<p>The above makes a specialization constant with a default value of 12.
95165bd8deadSopenharmony_ciThe number 17 is an example author-chosen id by which the API or other tools
95175bd8deadSopenharmony_cican later refer to this specific specialization constant.
95185bd8deadSopenharmony_ciIf it is never changed before final lowering, it will retain the value of
95195bd8deadSopenharmony_ci12.
95205bd8deadSopenharmony_ciIt is a compile-time error to use the <strong>constant_id</strong> qualifier on anything
95215bd8deadSopenharmony_cibut SPIR-V generation of a scalar <strong>bool</strong>, <strong>int</strong>, <strong>uint</strong>, <strong>float</strong>, or
95225bd8deadSopenharmony_ci<strong>double</strong>.</p>
95235bd8deadSopenharmony_ci</div>
95245bd8deadSopenharmony_ci<div class="paragraph">
95255bd8deadSopenharmony_ci<p>Built-in constants can be declared to be specialization constants.
95265bd8deadSopenharmony_ciFor example:</p>
95275bd8deadSopenharmony_ci</div>
95285bd8deadSopenharmony_ci<div class="listingblock">
95295bd8deadSopenharmony_ci<div class="content">
95305bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(constant_id = <span class="integer">31</span>) gl_MaxClipDistances; <span class="comment">// add specialization_id</span></code></pre>
95315bd8deadSopenharmony_ci</div>
95325bd8deadSopenharmony_ci</div>
95335bd8deadSopenharmony_ci<div class="paragraph">
95345bd8deadSopenharmony_ci<p>The declaration uses just the name of the previously declared built-in
95355bd8deadSopenharmony_civariable, with a <strong>constant_id</strong> layout-qualifier declaration.
95365bd8deadSopenharmony_ciIt is a compile-time error to do this after the constant has been used:
95375bd8deadSopenharmony_ciConstants are strictly either non-specialization constants or specialization
95385bd8deadSopenharmony_ciconstants, not both.</p>
95395bd8deadSopenharmony_ci</div>
95405bd8deadSopenharmony_ci<div class="paragraph">
95415bd8deadSopenharmony_ci<p>The built-in constant vector <em>gl_WorkGroupSize</em> can be specialized using the
95425bd8deadSopenharmony_ci<strong>local_size_{xyz}_id</strong> qualifiers, to individually give the components an id.
95435bd8deadSopenharmony_ciFor example:</p>
95445bd8deadSopenharmony_ci</div>
95455bd8deadSopenharmony_ci<div class="listingblock">
95465bd8deadSopenharmony_ci<div class="content">
95475bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(local_size_x_id = <span class="integer">18</span>, local_size_z_id = <span class="integer">19</span>) in;</code></pre>
95485bd8deadSopenharmony_ci</div>
95495bd8deadSopenharmony_ci</div>
95505bd8deadSopenharmony_ci<div class="paragraph">
95515bd8deadSopenharmony_ci<p>This leaves <em>gl_WorkGroupSize.y</em> as a non-specialization constant, with
95525bd8deadSopenharmony_ci<em>gl_WorkGroupSize</em> being a partially specialized vector.
95535bd8deadSopenharmony_ciIts <em>x</em> and <em>z</em> components can be later specialized, after generating
95545bd8deadSopenharmony_ciSPIR-V, using the ids 18 and 19.
95555bd8deadSopenharmony_ciThese ids are declared independently from declaring the workgroup size:</p>
95565bd8deadSopenharmony_ci</div>
95575bd8deadSopenharmony_ci<div class="listingblock">
95585bd8deadSopenharmony_ci<div class="content">
95595bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(local_size_x = <span class="integer">32</span>, local_size_y = <span class="integer">32</span>) in;   <span class="comment">// size is (32,32,1)</span>
95605bd8deadSopenharmony_cilayout(local_size_x_id = <span class="integer">18</span>) in;                   <span class="comment">// constant_id for x</span>
95615bd8deadSopenharmony_cilayout(local_size_z_id = <span class="integer">19</span>) in;                   <span class="comment">// constant_id for z</span></code></pre>
95625bd8deadSopenharmony_ci</div>
95635bd8deadSopenharmony_ci</div>
95645bd8deadSopenharmony_ci<div class="paragraph">
95655bd8deadSopenharmony_ci<p>Existing rules for declaring <strong>local_size_x</strong>, <strong>local_size_y</strong>, and
95665bd8deadSopenharmony_ci<strong>local_size_z</strong> are not changed.
95675bd8deadSopenharmony_ciFor the local-size ids, it is a compile-time error to provide different id
95685bd8deadSopenharmony_civalues for the same local-size id, or to provide them after any use.
95695bd8deadSopenharmony_ciOtherwise, order, placement, number of statements, and replication do not
95705bd8deadSopenharmony_cicause errors.</p>
95715bd8deadSopenharmony_ci</div>
95725bd8deadSopenharmony_ci<div class="paragraph">
95735bd8deadSopenharmony_ci<p>Two arrays sized with specialization constants are the same type only if
95745bd8deadSopenharmony_cisized with the same symbol, and involving no operations.
95755bd8deadSopenharmony_ciFor example:</p>
95765bd8deadSopenharmony_ci</div>
95775bd8deadSopenharmony_ci<div class="listingblock">
95785bd8deadSopenharmony_ci<div class="content">
95795bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">layout(constant_id = <span class="integer">51</span>) <span class="directive">const</span> <span class="predefined-type">int</span> aSize = <span class="integer">20</span>;
95805bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> pad = <span class="integer">2</span>;
95815bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> total = aSize + pad; <span class="comment">// specialization constant</span>
95825bd8deadSopenharmony_ci<span class="predefined-type">int</span> a[total], b[total];        <span class="comment">// a and b have the same type</span>
95835bd8deadSopenharmony_ci<span class="predefined-type">int</span> c[<span class="integer">22</span>];                     <span class="comment">// different type than a or b</span>
95845bd8deadSopenharmony_ci<span class="predefined-type">int</span> d[aSize + pad];            <span class="comment">// different type than a, b, or c</span>
95855bd8deadSopenharmony_ci<span class="predefined-type">int</span> e[aSize + <span class="integer">2</span>];              <span class="comment">// different type than a, b, c, or d</span></code></pre>
95865bd8deadSopenharmony_ci</div>
95875bd8deadSopenharmony_ci</div>
95885bd8deadSopenharmony_ci<div class="paragraph">
95895bd8deadSopenharmony_ci<p>Types containing arrays sized with a specialization constant cannot be
95905bd8deadSopenharmony_cicompared, assigned as aggregates, declared with an initializer, or used as
95915bd8deadSopenharmony_cian initializer.
95925bd8deadSopenharmony_ciThey can, however, be passed as arguments to functions having formal
95935bd8deadSopenharmony_ciparameters of the same type.
95945bd8deadSopenharmony_ciOnly the outer-most dimension of a variable declared as an array of arrays
95955bd8deadSopenharmony_cican be a specialization constant, otherwise a compile-time error results.</p>
95965bd8deadSopenharmony_ci</div>
95975bd8deadSopenharmony_ci<div class="paragraph">
95985bd8deadSopenharmony_ci<p>Arrays inside a block may be sized with a specialization constant, but the
95995bd8deadSopenharmony_ciblock will have a static layout.
96005bd8deadSopenharmony_ciChanging the specialized size will not re-layout the block.
96015bd8deadSopenharmony_ciIn the absence of explicit offsets, the layout will be based on the default
96025bd8deadSopenharmony_cisize of the array.</p>
96035bd8deadSopenharmony_ci</div>
96045bd8deadSopenharmony_ci</div>
96055bd8deadSopenharmony_ci<div class="sect2">
96065bd8deadSopenharmony_ci<h3 id="order-of-qualification">4.12. Order and Repetition of Qualification</h3>
96075bd8deadSopenharmony_ci<div class="paragraph">
96085bd8deadSopenharmony_ci<p>When multiple qualifiers are present in a declaration, they may appear in
96095bd8deadSopenharmony_ciany order, but they must all appear before the type.
96105bd8deadSopenharmony_ciThe <strong>layout</strong> qualifier is the only qualifier that can appear more than once.
96115bd8deadSopenharmony_ciFurther, a declaration can have at most one storage qualifier, at most one
96125bd8deadSopenharmony_ciauxiliary storage qualifier, and at most one interpolation qualifier.
96135bd8deadSopenharmony_ciIf <strong>inout</strong> is used, neither <strong>in</strong> nor <strong>out</strong> may be used.
96145bd8deadSopenharmony_ciMultiple memory qualifiers can be used.
96155bd8deadSopenharmony_ciAny violation of these rules will cause a compile-time error.</p>
96165bd8deadSopenharmony_ci</div>
96175bd8deadSopenharmony_ci</div>
96185bd8deadSopenharmony_ci<div class="sect2">
96195bd8deadSopenharmony_ci<h3 id="empty-declarations">4.13. Empty Declarations</h3>
96205bd8deadSopenharmony_ci<div class="paragraph">
96215bd8deadSopenharmony_ci<p><em>Empty declarations</em> are declarations without a variable name, meaning no
96225bd8deadSopenharmony_ciobject is instantiated by the declaration.
96235bd8deadSopenharmony_ciGenerally, empty declarations are allowed.
96245bd8deadSopenharmony_ciSome are useful when declaring structures, while many others have no effect.
96255bd8deadSopenharmony_ciFor example:</p>
96265bd8deadSopenharmony_ci</div>
96275bd8deadSopenharmony_ci<div class="listingblock">
96285bd8deadSopenharmony_ci<div class="content">
96295bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">int</span>;               <span class="comment">// No effect</span>
96305bd8deadSopenharmony_ci<span class="keyword">struct</span> S {<span class="predefined-type">int</span> x;}; <span class="comment">// Defines a struct S</span></code></pre>
96315bd8deadSopenharmony_ci</div>
96325bd8deadSopenharmony_ci</div>
96335bd8deadSopenharmony_ci<div class="paragraph">
96345bd8deadSopenharmony_ci<p>The combinations of qualifiers that cause compile-time or link-time errors
96355bd8deadSopenharmony_ciare the same whether or not the declaration is empty, for example:</p>
96365bd8deadSopenharmony_ci</div>
96375bd8deadSopenharmony_ci<div class="listingblock">
96385bd8deadSopenharmony_ci<div class="content">
96395bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">invariant in <span class="predefined-type">float</span> x; <span class="comment">// Error. An input cannot be invariant.</span>
96405bd8deadSopenharmony_ciinvariant in <span class="predefined-type">float</span>;   <span class="comment">// Error even though no variable is declared.</span></code></pre>
96415bd8deadSopenharmony_ci</div>
96425bd8deadSopenharmony_ci</div>
96435bd8deadSopenharmony_ci</div>
96445bd8deadSopenharmony_ci</div>
96455bd8deadSopenharmony_ci</div>
96465bd8deadSopenharmony_ci<div class="sect1">
96475bd8deadSopenharmony_ci<h2 id="operators-and-expressions">5. Operators and Expressions</h2>
96485bd8deadSopenharmony_ci<div class="sectionbody">
96495bd8deadSopenharmony_ci<div class="sect2">
96505bd8deadSopenharmony_ci<h3 id="operators">5.1. Operators</h3>
96515bd8deadSopenharmony_ci<div class="paragraph">
96525bd8deadSopenharmony_ci<p>The OpenGL Shading Language has the following operators.</p>
96535bd8deadSopenharmony_ci</div>
96545bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
96555bd8deadSopenharmony_ci<colgroup>
96565bd8deadSopenharmony_ci<col style="width: 25%;">
96575bd8deadSopenharmony_ci<col style="width: 25%;">
96585bd8deadSopenharmony_ci<col style="width: 25%;">
96595bd8deadSopenharmony_ci<col style="width: 25%;">
96605bd8deadSopenharmony_ci</colgroup>
96615bd8deadSopenharmony_ci<thead>
96625bd8deadSopenharmony_ci<tr>
96635bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Precedence</th>
96645bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Operator Class</th>
96655bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Operators</th>
96665bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Associativity</th>
96675bd8deadSopenharmony_ci</tr>
96685bd8deadSopenharmony_ci</thead>
96695bd8deadSopenharmony_ci<tbody>
96705bd8deadSopenharmony_ci<tr>
96715bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">1 (highest)</p></td>
96725bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">parenthetical grouping</p></td>
96735bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">( )</p></td>
96745bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">NA</p></td>
96755bd8deadSopenharmony_ci</tr>
96765bd8deadSopenharmony_ci<tr>
96775bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">2</p></td>
96785bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">array subscript<br>
96795bd8deadSopenharmony_ci                 function call and constructor structure<br>
96805bd8deadSopenharmony_ci                 field or method selector, swizzle<br>
96815bd8deadSopenharmony_ci                 post fix increment and decrement</p></td>
96825bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">[ ]<br>
96835bd8deadSopenharmony_ci                                                  ( )<br>
96845bd8deadSopenharmony_ci                                                  .<br>
96855bd8deadSopenharmony_ci                                                  ++ --</p></td>
96865bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
96875bd8deadSopenharmony_ci</tr>
96885bd8deadSopenharmony_ci<tr>
96895bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">3</p></td>
96905bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">prefix increment and decrement<br>
96915bd8deadSopenharmony_ci                 unary</p></td>
96925bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">++ --<br>
96935bd8deadSopenharmony_ci                                                  + - ~ !</p></td>
96945bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Right to Left</p></td>
96955bd8deadSopenharmony_ci</tr>
96965bd8deadSopenharmony_ci<tr>
96975bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">4</p></td>
96985bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">multiplicative</p></td>
96995bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">* / %</p></td>
97005bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
97015bd8deadSopenharmony_ci</tr>
97025bd8deadSopenharmony_ci<tr>
97035bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">5</p></td>
97045bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">additive</p></td>
97055bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">+ -</p></td>
97065bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
97075bd8deadSopenharmony_ci</tr>
97085bd8deadSopenharmony_ci<tr>
97095bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">6</p></td>
97105bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bit-wise shift</p></td>
97115bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;&lt; &gt;&gt;</p></td>
97125bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
97135bd8deadSopenharmony_ci</tr>
97145bd8deadSopenharmony_ci<tr>
97155bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">7</p></td>
97165bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">relational</p></td>
97175bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">&lt; &gt; &lt;= &gt;=</p></td>
97185bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
97195bd8deadSopenharmony_ci</tr>
97205bd8deadSopenharmony_ci<tr>
97215bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">8</p></td>
97225bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">equality</p></td>
97235bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">== !=</p></td>
97245bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
97255bd8deadSopenharmony_ci</tr>
97265bd8deadSopenharmony_ci<tr>
97275bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">9</p></td>
97285bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bit-wise and</p></td>
97295bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">&amp;</p></td>
97305bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
97315bd8deadSopenharmony_ci</tr>
97325bd8deadSopenharmony_ci<tr>
97335bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">10</p></td>
97345bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bit-wise exclusive or</p></td>
97355bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">^</p></td>
97365bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
97375bd8deadSopenharmony_ci</tr>
97385bd8deadSopenharmony_ci<tr>
97395bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">11</p></td>
97405bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bit-wise inclusive or</p></td>
97415bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">|</p></td>
97425bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
97435bd8deadSopenharmony_ci</tr>
97445bd8deadSopenharmony_ci<tr>
97455bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">12</p></td>
97465bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">logical and</p></td>
97475bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">&amp;&amp;</p></td>
97485bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
97495bd8deadSopenharmony_ci</tr>
97505bd8deadSopenharmony_ci<tr>
97515bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">13</p></td>
97525bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">logical exclusive or</p></td>
97535bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">^^</p></td>
97545bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
97555bd8deadSopenharmony_ci</tr>
97565bd8deadSopenharmony_ci<tr>
97575bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">14</p></td>
97585bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">logical inclusive or</p></td>
97595bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">||</p></td>
97605bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
97615bd8deadSopenharmony_ci</tr>
97625bd8deadSopenharmony_ci<tr>
97635bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">15</p></td>
97645bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">selection</p></td>
97655bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">? :</p></td>
97665bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Right to Left</p></td>
97675bd8deadSopenharmony_ci</tr>
97685bd8deadSopenharmony_ci<tr>
97695bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">16</p></td>
97705bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Assignment<br>
97715bd8deadSopenharmony_ci                 arithmetic assignments</p></td>
97725bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">=<br>
97735bd8deadSopenharmony_ci                                                  += -=<br>
97745bd8deadSopenharmony_ci                                                  *= /=<br>
97755bd8deadSopenharmony_ci                                                  %= &lt;&lt;= &gt;&gt;=<br>
97765bd8deadSopenharmony_ci                                                  &amp;= ^= |=</p></td>
97775bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Right to Left</p></td>
97785bd8deadSopenharmony_ci</tr>
97795bd8deadSopenharmony_ci<tr>
97805bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">17 (lowest)</p></td>
97815bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">sequence</p></td>
97825bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">,</p></td>
97835bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Left to Right</p></td>
97845bd8deadSopenharmony_ci</tr>
97855bd8deadSopenharmony_ci</tbody>
97865bd8deadSopenharmony_ci</table>
97875bd8deadSopenharmony_ci<div class="paragraph">
97885bd8deadSopenharmony_ci<p>There is no address-of operator nor a dereference operator.
97895bd8deadSopenharmony_ciThere is no typecast operator; constructors are used instead.</p>
97905bd8deadSopenharmony_ci</div>
97915bd8deadSopenharmony_ci</div>
97925bd8deadSopenharmony_ci<div class="sect2">
97935bd8deadSopenharmony_ci<h3 id="array-operations">5.2. Array Operations</h3>
97945bd8deadSopenharmony_ci<div class="paragraph">
97955bd8deadSopenharmony_ci<p>These are now described in &#8220;<a href="#structure-and-array-operations">Structure and
97965bd8deadSopenharmony_ciArray Operations</a>&#8221;.</p>
97975bd8deadSopenharmony_ci</div>
97985bd8deadSopenharmony_ci</div>
97995bd8deadSopenharmony_ci<div class="sect2">
98005bd8deadSopenharmony_ci<h3 id="function-calls">5.3. Function Calls</h3>
98015bd8deadSopenharmony_ci<div class="paragraph">
98025bd8deadSopenharmony_ci<p>If a function returns a value, then a call to that function may be used as
98035bd8deadSopenharmony_cian expression, whose type will be the type that was used to declare or
98045bd8deadSopenharmony_cidefine the function.</p>
98055bd8deadSopenharmony_ci</div>
98065bd8deadSopenharmony_ci<div class="paragraph">
98075bd8deadSopenharmony_ci<p>Function definitions and calling conventions are discussed in
98085bd8deadSopenharmony_ci&#8220;<a href="#function-definitions">Function Definitions</a>&#8221;.</p>
98095bd8deadSopenharmony_ci</div>
98105bd8deadSopenharmony_ci</div>
98115bd8deadSopenharmony_ci<div class="sect2">
98125bd8deadSopenharmony_ci<h3 id="constructors">5.4. Constructors</h3>
98135bd8deadSopenharmony_ci<div class="paragraph">
98145bd8deadSopenharmony_ci<p>Constructors use the function call syntax, where the function name is a
98155bd8deadSopenharmony_citype, and the call makes an object of that type.
98165bd8deadSopenharmony_ciConstructors are used the same way in both initializers and expressions.
98175bd8deadSopenharmony_ci(See &#8220;<a href="#shading-language-grammar">Shading Language Grammar</a>&#8221; for details.)
98185bd8deadSopenharmony_ciThe parameters are used to initialize the constructed value.
98195bd8deadSopenharmony_ciConstructors can be used to request a data type conversion to change from
98205bd8deadSopenharmony_cione scalar type to another scalar type, or to build larger types out of
98215bd8deadSopenharmony_cismaller types, or to reduce a larger type to a smaller type.</p>
98225bd8deadSopenharmony_ci</div>
98235bd8deadSopenharmony_ci<div class="paragraph">
98245bd8deadSopenharmony_ci<p>In general, constructors are not built-in functions with predetermined
98255bd8deadSopenharmony_ciprototypes.
98265bd8deadSopenharmony_ciFor arrays and structures, there must be exactly one argument in the
98275bd8deadSopenharmony_ciconstructor for each element or member.
98285bd8deadSopenharmony_ciFor the other types, the arguments must provide a sufficient number of
98295bd8deadSopenharmony_cicomponents to perform the initialization, and it is a compile-time error to
98305bd8deadSopenharmony_ciinclude so many arguments that they cannot all be used.
98315bd8deadSopenharmony_ciDetailed rules follow.
98325bd8deadSopenharmony_ciThe prototypes actually listed below are merely a subset of examples.</p>
98335bd8deadSopenharmony_ci</div>
98345bd8deadSopenharmony_ci<div class="sect3">
98355bd8deadSopenharmony_ci<h4 id="conversion-and-scalar-constructors">5.4.1. Conversion and Scalar Constructors</h4>
98365bd8deadSopenharmony_ci<div class="paragraph">
98375bd8deadSopenharmony_ci<p>Converting between scalar types is done as the following prototypes
98385bd8deadSopenharmony_ciindicate:</p>
98395bd8deadSopenharmony_ci</div>
98405bd8deadSopenharmony_ci<div class="listingblock">
98415bd8deadSopenharmony_ci<div class="content">
98425bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">int</span>(uint)     <span class="comment">// converts an unsigned integer to a signed integer</span>
98435bd8deadSopenharmony_ci<span class="predefined-type">int</span>(<span class="predefined-type">bool</span>)     <span class="comment">// converts a Boolean value to an int</span>
98445bd8deadSopenharmony_ci<span class="predefined-type">int</span>(<span class="predefined-type">float</span>)    <span class="comment">// converts a float value to an int</span>
98455bd8deadSopenharmony_ci<span class="predefined-type">int</span>(<span class="predefined-type">double</span>)   <span class="comment">// converts a double value to a signed integer</span>
98465bd8deadSopenharmony_ciuint(<span class="predefined-type">int</span>)     <span class="comment">// converts a signed integer value to an unsigned integer</span>
98475bd8deadSopenharmony_ciuint(<span class="predefined-type">bool</span>)    <span class="comment">// converts a Boolean value to an unsigned integer</span>
98485bd8deadSopenharmony_ciuint(<span class="predefined-type">float</span>)   <span class="comment">// converts a float value to an unsigned integer</span>
98495bd8deadSopenharmony_ciuint(<span class="predefined-type">double</span>)  <span class="comment">// converts a double value to an unsigned integer</span>
98505bd8deadSopenharmony_ci<span class="predefined-type">bool</span>(<span class="predefined-type">int</span>)     <span class="comment">// converts a signed integer value to a Boolean</span>
98515bd8deadSopenharmony_ci<span class="predefined-type">bool</span>(uint)    <span class="comment">// converts an unsigned integer value to a Boolean value</span>
98525bd8deadSopenharmony_ci<span class="predefined-type">bool</span>(<span class="predefined-type">float</span>)   <span class="comment">// converts a float value to a Boolean</span>
98535bd8deadSopenharmony_ci<span class="predefined-type">bool</span>(<span class="predefined-type">double</span>)  <span class="comment">// converts a double value to a Boolean</span>
98545bd8deadSopenharmony_ci<span class="predefined-type">float</span>(<span class="predefined-type">int</span>)    <span class="comment">// converts a signed integer value to a float</span>
98555bd8deadSopenharmony_ci<span class="predefined-type">float</span>(uint)   <span class="comment">// converts an unsigned integer value to a float value</span>
98565bd8deadSopenharmony_ci<span class="predefined-type">float</span>(<span class="predefined-type">bool</span>)   <span class="comment">// converts a Boolean value to a float</span>
98575bd8deadSopenharmony_ci<span class="predefined-type">float</span>(<span class="predefined-type">double</span>) <span class="comment">// converts a double value to a float</span>
98585bd8deadSopenharmony_ci<span class="predefined-type">double</span>(<span class="predefined-type">int</span>)   <span class="comment">// converts a signed integer value to a double</span>
98595bd8deadSopenharmony_ci<span class="predefined-type">double</span>(uint)  <span class="comment">// converts an unsigned integer value to a double</span>
98605bd8deadSopenharmony_ci<span class="predefined-type">double</span>(<span class="predefined-type">bool</span>)  <span class="comment">// converts a Boolean value to a double</span>
98615bd8deadSopenharmony_ci<span class="predefined-type">double</span>(<span class="predefined-type">float</span>) <span class="comment">// converts a float value to a double</span></code></pre>
98625bd8deadSopenharmony_ci</div>
98635bd8deadSopenharmony_ci</div>
98645bd8deadSopenharmony_ci<div class="paragraph">
98655bd8deadSopenharmony_ci<p>When constructors are used to convert a floating-point type to an integer
98665bd8deadSopenharmony_citype, the fractional part of the floating-point value is dropped.
98675bd8deadSopenharmony_ciIt is undefined to convert a negative floating-point value to an <strong>uint</strong>.</p>
98685bd8deadSopenharmony_ci</div>
98695bd8deadSopenharmony_ci<div class="paragraph">
98705bd8deadSopenharmony_ci<p>Integer values having more bits of precision than a single-precision
98715bd8deadSopenharmony_cifloating-point mantissa will lose precision when converted to <strong>float</strong>.</p>
98725bd8deadSopenharmony_ci</div>
98735bd8deadSopenharmony_ci<div class="paragraph">
98745bd8deadSopenharmony_ci<p>When a constructor is used to convert any integer or floating-point type to
98755bd8deadSopenharmony_cia <strong>bool</strong>, 0 and 0.0 are converted to <strong>false</strong>, and non-zero values are
98765bd8deadSopenharmony_ciconverted to <strong>true</strong>.
98775bd8deadSopenharmony_ciWhen a constructor is used to convert a <strong>bool</strong> to any integer or
98785bd8deadSopenharmony_cifloating-point type, <strong>false</strong> is converted to 0 or 0.0, and <strong>true</strong> is
98795bd8deadSopenharmony_ciconverted to 1 or 1.0.</p>
98805bd8deadSopenharmony_ci</div>
98815bd8deadSopenharmony_ci<div class="paragraph">
98825bd8deadSopenharmony_ci<p>The constructor <strong>int</strong>(<strong>uint</strong>) preserves the bit pattern in the argument,
98835bd8deadSopenharmony_ciwhich will change the argument&#8217;s value if its sign bit is set.
98845bd8deadSopenharmony_ciThe constructor <strong>uint</strong>(<strong>int</strong>) preserves the bit pattern in the argument,
98855bd8deadSopenharmony_ciwhich will change its value if it is negative.</p>
98865bd8deadSopenharmony_ci</div>
98875bd8deadSopenharmony_ci<div class="paragraph">
98885bd8deadSopenharmony_ci<p>Identity constructors, like <strong>float</strong>(<strong>float</strong>) are also legal, but of little
98895bd8deadSopenharmony_ciuse.</p>
98905bd8deadSopenharmony_ci</div>
98915bd8deadSopenharmony_ci<div class="paragraph">
98925bd8deadSopenharmony_ci<p>Scalar constructors with non-scalar parameters can be used to take the first
98935bd8deadSopenharmony_cielement from a non-scalar.
98945bd8deadSopenharmony_ciFor example, the constructor <strong>float</strong>(<strong>vec3</strong>) will select the first component
98955bd8deadSopenharmony_ciof the <strong>vec3</strong> parameter.</p>
98965bd8deadSopenharmony_ci</div>
98975bd8deadSopenharmony_ci</div>
98985bd8deadSopenharmony_ci<div class="sect3">
98995bd8deadSopenharmony_ci<h4 id="vector-and-matrix-constructors">5.4.2. Vector and Matrix Constructors</h4>
99005bd8deadSopenharmony_ci<div class="paragraph">
99015bd8deadSopenharmony_ci<p>Constructors can be used to create vectors or matrices from a set of
99025bd8deadSopenharmony_ciscalars, vectors, or matrices.
99035bd8deadSopenharmony_ciThis includes the ability to shorten vectors.</p>
99045bd8deadSopenharmony_ci</div>
99055bd8deadSopenharmony_ci<div class="paragraph">
99065bd8deadSopenharmony_ci<p>If there is a single scalar parameter to a vector constructor, it is used to
99075bd8deadSopenharmony_ciinitialize all components of the constructed vector to that scalar&#8217;s value.
99085bd8deadSopenharmony_ciIf there is a single scalar parameter to a matrix constructor, it is used to
99095bd8deadSopenharmony_ciinitialize all the components on the matrix&#8217;s diagonal, with the remaining
99105bd8deadSopenharmony_cicomponents initialized to 0.0.</p>
99115bd8deadSopenharmony_ci</div>
99125bd8deadSopenharmony_ci<div class="paragraph">
99135bd8deadSopenharmony_ci<p>If a vector is constructed from multiple scalars, one or more vectors, or
99145bd8deadSopenharmony_cione or more matrices, or a mixture of these, the vector&#8217;s components will be
99155bd8deadSopenharmony_ciconstructed in order from the components of the arguments.
99165bd8deadSopenharmony_ciThe arguments will be consumed left to right, and each argument will have
99175bd8deadSopenharmony_ciall its components consumed, in order, before any components from the next
99185bd8deadSopenharmony_ciargument are consumed.
99195bd8deadSopenharmony_ciSimilarly for constructing a matrix from multiple scalars or vectors, or a
99205bd8deadSopenharmony_cimixture of these.
99215bd8deadSopenharmony_ciMatrix components will be constructed and consumed in column major order.
99225bd8deadSopenharmony_ciIn these cases, there must be enough components provided in the arguments to
99235bd8deadSopenharmony_ciprovide an initializer for every component in the constructed value.
99245bd8deadSopenharmony_ciIt is a compile-time error to provide extra arguments beyond this last used
99255bd8deadSopenharmony_ciargument.</p>
99265bd8deadSopenharmony_ci</div>
99275bd8deadSopenharmony_ci<div class="paragraph">
99285bd8deadSopenharmony_ci<p>If a matrix is constructed from a matrix, then each component (column <em>i</em>,
99295bd8deadSopenharmony_cirow <em>j</em>) in the result that has a corresponding component (column <em>i</em>, row
99305bd8deadSopenharmony_ci<em>j</em>) in the argument will be initialized from there.
99315bd8deadSopenharmony_ciAll other components will be initialized to the identity matrix.
99325bd8deadSopenharmony_ciIf a matrix argument is given to a matrix constructor, it is
99335bd8deadSopenharmony_cia compile-time error to have any other arguments.</p>
99345bd8deadSopenharmony_ci</div>
99355bd8deadSopenharmony_ci<div class="paragraph">
99365bd8deadSopenharmony_ci<p>If the basic type (<strong>bool</strong>, <strong>int</strong>,
99375bd8deadSopenharmony_ci<strong>float</strong>, or <strong>double</strong>)
99385bd8deadSopenharmony_ciof a parameter to a
99395bd8deadSopenharmony_ciconstructor does not match the basic type of the object being constructed,
99405bd8deadSopenharmony_cithe scalar construction rules (above) are used to convert the parameters.</p>
99415bd8deadSopenharmony_ci</div>
99425bd8deadSopenharmony_ci<div class="paragraph">
99435bd8deadSopenharmony_ci<p>Some useful vector constructors are as follows:</p>
99445bd8deadSopenharmony_ci</div>
99455bd8deadSopenharmony_ci<div class="listingblock">
99465bd8deadSopenharmony_ci<div class="content">
99475bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec3(<span class="predefined-type">float</span>)          <span class="comment">// initializes each component of the vec3 with the float</span>
99485bd8deadSopenharmony_civec4(ivec4)          <span class="comment">// makes a vec4 with component-wise conversion</span>
99495bd8deadSopenharmony_civec4(mat2)           <span class="comment">// the vec4 is column 0 followed by column 1</span>
99505bd8deadSopenharmony_civec2(<span class="predefined-type">float</span>, <span class="predefined-type">float</span>)   <span class="comment">// initializes a vec2 with 2 floats</span>
99515bd8deadSopenharmony_ciivec3(<span class="predefined-type">int</span>, <span class="predefined-type">int</span>, <span class="predefined-type">int</span>) <span class="comment">// initializes an ivec3 with 3 ints</span>
99525bd8deadSopenharmony_cibvec4(<span class="predefined-type">int</span>, <span class="predefined-type">int</span>, <span class="predefined-type">float</span>, <span class="predefined-type">float</span>) <span class="comment">// uses 4 Boolean conversions</span>
99535bd8deadSopenharmony_civec2(vec3)           <span class="comment">// drops the third component of a vec3</span>
99545bd8deadSopenharmony_civec3(vec4)           <span class="comment">// drops the fourth component of a vec4</span>
99555bd8deadSopenharmony_civec3(vec2, <span class="predefined-type">float</span>)    <span class="comment">// vec3.x = vec2.x, vec3.y = vec2.y, vec3.z = float</span>
99565bd8deadSopenharmony_civec3(<span class="predefined-type">float</span>, vec2)    <span class="comment">// vec3.x = float, vec3.y = vec2.x, vec3.z = vec2.y</span>
99575bd8deadSopenharmony_civec4(vec3, <span class="predefined-type">float</span>)
99585bd8deadSopenharmony_civec4(<span class="predefined-type">float</span>, vec3)
99595bd8deadSopenharmony_civec4(vec2, vec2)</code></pre>
99605bd8deadSopenharmony_ci</div>
99615bd8deadSopenharmony_ci</div>
99625bd8deadSopenharmony_ci<div class="paragraph">
99635bd8deadSopenharmony_ci<p>Some examples of these are:</p>
99645bd8deadSopenharmony_ci</div>
99655bd8deadSopenharmony_ci<div class="listingblock">
99665bd8deadSopenharmony_ci<div class="content">
99675bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec4 color = vec4(<span class="float">0</span><span class="float">.0</span>, <span class="float">1</span><span class="float">.0</span>, <span class="float">0</span><span class="float">.0</span>, <span class="float">1</span><span class="float">.0</span>);
99685bd8deadSopenharmony_civec4 rgba = vec4(<span class="float">1</span><span class="float">.0</span>);      <span class="comment">// sets each component to 1.0</span>
99695bd8deadSopenharmony_civec3 rgb = vec3(color);     <span class="comment">// drop the 4th component</span></code></pre>
99705bd8deadSopenharmony_ci</div>
99715bd8deadSopenharmony_ci</div>
99725bd8deadSopenharmony_ci<div class="paragraph">
99735bd8deadSopenharmony_ci<p>To initialize the diagonal of a matrix with all other elements set to zero:</p>
99745bd8deadSopenharmony_ci</div>
99755bd8deadSopenharmony_ci<div class="listingblock">
99765bd8deadSopenharmony_ci<div class="content">
99775bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">mat2(<span class="predefined-type">float</span>)
99785bd8deadSopenharmony_cimat3(<span class="predefined-type">float</span>)
99795bd8deadSopenharmony_cimat4(<span class="predefined-type">float</span>)</code></pre>
99805bd8deadSopenharmony_ci</div>
99815bd8deadSopenharmony_ci</div>
99825bd8deadSopenharmony_ci<div class="paragraph">
99835bd8deadSopenharmony_ci<p>That is, <em>result[i][j]</em> is set to the <em>float</em> argument for all \(i
99845bd8deadSopenharmony_ci= j\) and set to 0 for all \(i \neq j\).</p>
99855bd8deadSopenharmony_ci</div>
99865bd8deadSopenharmony_ci<div class="paragraph">
99875bd8deadSopenharmony_ci<p>To initialize a matrix by specifying vectors or scalars, the components are
99885bd8deadSopenharmony_ciassigned to the matrix elements in column-major order.</p>
99895bd8deadSopenharmony_ci</div>
99905bd8deadSopenharmony_ci<div class="listingblock">
99915bd8deadSopenharmony_ci<div class="content">
99925bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">mat2(vec2, vec2);                 <span class="comment">// one column per argument</span>
99935bd8deadSopenharmony_cimat3(vec3, vec3, vec3);           <span class="comment">// one column per argument</span>
99945bd8deadSopenharmony_cimat4(vec4, vec4, vec4, vec4);     <span class="comment">// one column per argument</span>
99955bd8deadSopenharmony_cimat3x2(vec2, vec2, vec2);         <span class="comment">// one column per argument</span>
99965bd8deadSopenharmony_cidmat2(dvec2, dvec2);
99975bd8deadSopenharmony_cidmat3(dvec3, dvec3, dvec3);
99985bd8deadSopenharmony_cidmat4(dvec4, dvec4, dvec4, dvec4);
99995bd8deadSopenharmony_cimat2(<span class="predefined-type">float</span>, <span class="predefined-type">float</span>,                <span class="comment">// first column</span>
100005bd8deadSopenharmony_ci     <span class="predefined-type">float</span>, <span class="predefined-type">float</span>);               <span class="comment">// second column</span>
100015bd8deadSopenharmony_cimat3(<span class="predefined-type">float</span>, <span class="predefined-type">float</span>, <span class="predefined-type">float</span>,         <span class="comment">// first column</span>
100025bd8deadSopenharmony_ci     <span class="predefined-type">float</span>, <span class="predefined-type">float</span>, <span class="predefined-type">float</span>,         <span class="comment">// second column</span>
100035bd8deadSopenharmony_ci     <span class="predefined-type">float</span>, <span class="predefined-type">float</span>, <span class="predefined-type">float</span>);        <span class="comment">// third column</span>
100045bd8deadSopenharmony_cimat4(<span class="predefined-type">float</span>, <span class="predefined-type">float</span>, <span class="predefined-type">float</span>, <span class="predefined-type">float</span>,  <span class="comment">// first column</span>
100055bd8deadSopenharmony_ci     <span class="predefined-type">float</span>, <span class="predefined-type">float</span>, <span class="predefined-type">float</span>, <span class="predefined-type">float</span>,  <span class="comment">// second column</span>
100065bd8deadSopenharmony_ci     <span class="predefined-type">float</span>, <span class="predefined-type">float</span>, <span class="predefined-type">float</span>, <span class="predefined-type">float</span>,  <span class="comment">// third column</span>
100075bd8deadSopenharmony_ci     <span class="predefined-type">float</span>, <span class="predefined-type">float</span>, <span class="predefined-type">float</span>, <span class="predefined-type">float</span>); <span class="comment">// fourth column</span>
100085bd8deadSopenharmony_cimat2x3(vec2, <span class="predefined-type">float</span>,               <span class="comment">// first column</span>
100095bd8deadSopenharmony_ci       vec2, <span class="predefined-type">float</span>);              <span class="comment">// second column</span>
100105bd8deadSopenharmony_cidmat2x4(dvec3, <span class="predefined-type">double</span>,            <span class="comment">// first column</span>
100115bd8deadSopenharmony_ci        <span class="predefined-type">double</span>, dvec3);           <span class="comment">// second column</span></code></pre>
100125bd8deadSopenharmony_ci</div>
100135bd8deadSopenharmony_ci</div>
100145bd8deadSopenharmony_ci<div class="paragraph">
100155bd8deadSopenharmony_ci<p>A wide range of other possibilities exist, to construct a matrix from
100165bd8deadSopenharmony_civectors and scalars, as long as enough components are present to initialize
100175bd8deadSopenharmony_cithe matrix.
100185bd8deadSopenharmony_ciTo construct a matrix from a matrix:</p>
100195bd8deadSopenharmony_ci</div>
100205bd8deadSopenharmony_ci<div class="listingblock">
100215bd8deadSopenharmony_ci<div class="content">
100225bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">mat3x3(mat4x4); <span class="comment">// takes the upper-left 3x3 of the mat4x4</span>
100235bd8deadSopenharmony_cimat2x3(mat4x2); <span class="comment">// takes the upper-left 2x2 of the mat4x4, last row is 0,0</span>
100245bd8deadSopenharmony_cimat4x4(mat3x3); <span class="comment">// puts the mat3x3 in the upper-left, sets the lower right</span>
100255bd8deadSopenharmony_ci                <span class="comment">// component to 1, and the rest to 0</span></code></pre>
100265bd8deadSopenharmony_ci</div>
100275bd8deadSopenharmony_ci</div>
100285bd8deadSopenharmony_ci</div>
100295bd8deadSopenharmony_ci<div class="sect3">
100305bd8deadSopenharmony_ci<h4 id="structure-constructors">5.4.3. Structure Constructors</h4>
100315bd8deadSopenharmony_ci<div class="paragraph">
100325bd8deadSopenharmony_ci<p>Once a structure is defined, and its type is given a name, a constructor is
100335bd8deadSopenharmony_ciavailable with the same name to construct instances of that structure.
100345bd8deadSopenharmony_ciFor example:</p>
100355bd8deadSopenharmony_ci</div>
100365bd8deadSopenharmony_ci<div class="listingblock">
100375bd8deadSopenharmony_ci<div class="content">
100385bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="keyword">struct</span> light {
100395bd8deadSopenharmony_ci    <span class="predefined-type">float</span> intensity;
100405bd8deadSopenharmony_ci    vec3 position;
100415bd8deadSopenharmony_ci};
100425bd8deadSopenharmony_ci
100435bd8deadSopenharmony_cilight lightVar = light(<span class="float">3</span><span class="float">.0</span>, vec3(<span class="float">1</span><span class="float">.0</span>, <span class="float">2</span><span class="float">.0</span>, <span class="float">3</span><span class="float">.0</span>));</code></pre>
100445bd8deadSopenharmony_ci</div>
100455bd8deadSopenharmony_ci</div>
100465bd8deadSopenharmony_ci<div class="paragraph">
100475bd8deadSopenharmony_ci<p>The arguments to the constructor will be used to set the structure&#8217;s
100485bd8deadSopenharmony_cimembers, in order, using one argument per member.
100495bd8deadSopenharmony_ciEach argument must be the same type as the member it
100505bd8deadSopenharmony_cisets, or be a type that can be converted to the member&#8217;s type according to
100515bd8deadSopenharmony_cisection &#8220;<a href="#implicit-conversions">Implicit Conversions</a>&#8221;.</p>
100525bd8deadSopenharmony_ci</div>
100535bd8deadSopenharmony_ci<div class="paragraph">
100545bd8deadSopenharmony_ci<p>Structure constructors can be used as initializers or in expressions.</p>
100555bd8deadSopenharmony_ci</div>
100565bd8deadSopenharmony_ci</div>
100575bd8deadSopenharmony_ci<div class="sect3">
100585bd8deadSopenharmony_ci<h4 id="array-constructors">5.4.4. Array Constructors</h4>
100595bd8deadSopenharmony_ci<div class="paragraph">
100605bd8deadSopenharmony_ci<p>Array types can also be used as constructor names, which can then be used in
100615bd8deadSopenharmony_ciexpressions or initializers.
100625bd8deadSopenharmony_ciFor example,</p>
100635bd8deadSopenharmony_ci</div>
100645bd8deadSopenharmony_ci<div class="listingblock">
100655bd8deadSopenharmony_ci<div class="content">
100665bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="directive">const</span> <span class="predefined-type">float</span> c[<span class="integer">3</span>] = <span class="predefined-type">float</span>[<span class="integer">3</span>](<span class="float">5</span><span class="float">.0</span>, <span class="float">7</span><span class="float">.2</span>, <span class="float">1</span><span class="float">.1</span>);
100675bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">float</span> d[<span class="integer">3</span>] = <span class="predefined-type">float</span>[](<span class="float">5</span><span class="float">.0</span>, <span class="float">7</span><span class="float">.2</span>, <span class="float">1</span><span class="float">.1</span>);
100685bd8deadSopenharmony_ci
100695bd8deadSopenharmony_ci<span class="predefined-type">float</span> g;
100705bd8deadSopenharmony_ci...
100715bd8deadSopenharmony_ci<span class="predefined-type">float</span> a[<span class="integer">5</span>] = <span class="predefined-type">float</span>[<span class="integer">5</span>](g, <span class="integer">1</span>, g, <span class="float">2</span><span class="float">.3</span>, g);
100725bd8deadSopenharmony_ci<span class="predefined-type">float</span> b[<span class="integer">3</span>];
100735bd8deadSopenharmony_ci
100745bd8deadSopenharmony_cib = <span class="predefined-type">float</span>[<span class="integer">3</span>](g, g + <span class="float">1</span><span class="float">.0</span>, g + <span class="float">2</span><span class="float">.0</span>);</code></pre>
100755bd8deadSopenharmony_ci</div>
100765bd8deadSopenharmony_ci</div>
100775bd8deadSopenharmony_ci<div class="paragraph">
100785bd8deadSopenharmony_ci<p>There must be exactly the same number of arguments as the size of the array
100795bd8deadSopenharmony_cibeing constructed.
100805bd8deadSopenharmony_ciIf no size is present in the constructor, then the array is explicitly sized
100815bd8deadSopenharmony_cito the number of arguments provided.
100825bd8deadSopenharmony_ciThe arguments are assigned in order, starting at element 0, to the elements
100835bd8deadSopenharmony_ciof the constructed array.
100845bd8deadSopenharmony_ciEach argument must be the same type as the element type of the
100855bd8deadSopenharmony_ciarray, or be
100865bd8deadSopenharmony_cia type that can be converted to the element type of the array according to
100875bd8deadSopenharmony_ci&#8220;<a href="#implicit-conversions">Implicit Conversions</a>&#8221;.</p>
100885bd8deadSopenharmony_ci</div>
100895bd8deadSopenharmony_ci<div class="paragraph">
100905bd8deadSopenharmony_ci<p>Arrays of arrays are similarly constructed, and the size for any dimension
100915bd8deadSopenharmony_ciis <strong class="purple">optional</strong></p>
100925bd8deadSopenharmony_ci</div>
100935bd8deadSopenharmony_ci<div class="listingblock">
100945bd8deadSopenharmony_ci<div class="content">
100955bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec4 b[<span class="integer">2</span>] = ...;
100965bd8deadSopenharmony_civec4[<span class="integer">3</span>][<span class="integer">2</span>](b, b, b);    <span class="comment">// constructor</span>
100975bd8deadSopenharmony_civec4[][<span class="integer">2</span>](b, b, b);     <span class="comment">// constructor, valid, size deduced</span>
100985bd8deadSopenharmony_civec4[<span class="integer">3</span>][](b, b, b);     <span class="comment">// constructor, valid, size deduced</span>
100995bd8deadSopenharmony_civec4[][](b, b, b);      <span class="comment">// constructor, valid, both sizes deduced</span></code></pre>
101005bd8deadSopenharmony_ci</div>
101015bd8deadSopenharmony_ci</div>
101025bd8deadSopenharmony_ci</div>
101035bd8deadSopenharmony_ci<div class="sect3">
101045bd8deadSopenharmony_ci<h4 id="_texture_combined_sampler_constructors">5.4.5. Texture-Combined Sampler Constructors</h4>
101055bd8deadSopenharmony_ci<div class="paragraph">
101065bd8deadSopenharmony_ci<p>Texture-combined sampler constructors are only available when targeting Vulkan.</p>
101075bd8deadSopenharmony_ci</div>
101085bd8deadSopenharmony_ci<div class="paragraph">
101095bd8deadSopenharmony_ci<p>Texture-combined sampler types, like <strong>sampler2D</strong>, can be declared with an
101105bd8deadSopenharmony_ciinitializer
101115bd8deadSopenharmony_cithat is a constructor of the same type, and consuming a texture and a
101125bd8deadSopenharmony_ci<strong>sampler</strong> or <strong>samplerShadow</strong>.
101135bd8deadSopenharmony_ciFor example:</p>
101145bd8deadSopenharmony_ci</div>
101155bd8deadSopenharmony_ci<div class="listingblock">
101165bd8deadSopenharmony_ci<div class="content">
101175bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">    layout(...) uniform sampler s;   <span class="comment">// handle to filtering information</span>
101185bd8deadSopenharmony_ci    layout(...) uniform texture2D t; <span class="comment">// handle to a texture</span>
101195bd8deadSopenharmony_ci    layout(...) in vec2 tCoord;
101205bd8deadSopenharmony_ci    ...
101215bd8deadSopenharmony_ci    texture(sampler2D(t, s), tCoord);</code></pre>
101225bd8deadSopenharmony_ci</div>
101235bd8deadSopenharmony_ci</div>
101245bd8deadSopenharmony_ci<div class="paragraph">
101255bd8deadSopenharmony_ci<p>The result of a texture-combined sampler constructor cannot be assigned to a
101265bd8deadSopenharmony_civariable:</p>
101275bd8deadSopenharmony_ci</div>
101285bd8deadSopenharmony_ci<div class="listingblock">
101295bd8deadSopenharmony_ci<div class="content">
101305bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">    ... sampler2D sConstruct = sampler2D(t, s);  <span class="comment">// ERROR</span></code></pre>
101315bd8deadSopenharmony_ci</div>
101325bd8deadSopenharmony_ci</div>
101335bd8deadSopenharmony_ci<div class="paragraph">
101345bd8deadSopenharmony_ci<p>Texture-combined sampler constructors can only be consumed by a function parameter.</p>
101355bd8deadSopenharmony_ci</div>
101365bd8deadSopenharmony_ci<div class="paragraph">
101375bd8deadSopenharmony_ci<p>Texture-combined sampler constructors of arrays are illegal:</p>
101385bd8deadSopenharmony_ci</div>
101395bd8deadSopenharmony_ci<div class="listingblock">
101405bd8deadSopenharmony_ci<div class="content">
101415bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">    layout(...) uniform texture2D tArray[<span class="integer">6</span>];
101425bd8deadSopenharmony_ci    ...
101435bd8deadSopenharmony_ci    ... sampler2D[](tArray, s) ...  <span class="comment">// ERROR</span></code></pre>
101445bd8deadSopenharmony_ci</div>
101455bd8deadSopenharmony_ci</div>
101465bd8deadSopenharmony_ci<div class="paragraph">
101475bd8deadSopenharmony_ci<p>Formally:</p>
101485bd8deadSopenharmony_ci</div>
101495bd8deadSopenharmony_ci<div class="ulist">
101505bd8deadSopenharmony_ci<ul>
101515bd8deadSopenharmony_ci<li>
101525bd8deadSopenharmony_ci<p>every texture-combined sampler type can be used as a constructor</p>
101535bd8deadSopenharmony_ci</li>
101545bd8deadSopenharmony_ci<li>
101555bd8deadSopenharmony_ci<p>the type of the constructor must match the type of the variable being declared</p>
101565bd8deadSopenharmony_ci</li>
101575bd8deadSopenharmony_ci<li>
101585bd8deadSopenharmony_ci<p>the constructor&#8217;s first argument must be a texture type</p>
101595bd8deadSopenharmony_ci</li>
101605bd8deadSopenharmony_ci<li>
101615bd8deadSopenharmony_ci<p>the constructor&#8217;s second argument must be a scalar of type <strong>sampler</strong>
101625bd8deadSopenharmony_cior <strong>samplerShadow</strong></p>
101635bd8deadSopenharmony_ci</li>
101645bd8deadSopenharmony_ci<li>
101655bd8deadSopenharmony_ci<p>the dimensionality (1D, 2D, 3D, Cube, Rect, Buffer, MS, and Array)
101665bd8deadSopenharmony_ciof the texture type must match that of the constructed type
101675bd8deadSopenharmony_ci(that is, the suffixes of the type of the first argument and the
101685bd8deadSopenharmony_citype of the constructor will be spelled the same way)</p>
101695bd8deadSopenharmony_ci</li>
101705bd8deadSopenharmony_ci<li>
101715bd8deadSopenharmony_ci<p>there is no control flow construct (e.g., <code>?:</code>) that consumes any sampler type</p>
101725bd8deadSopenharmony_ci</li>
101735bd8deadSopenharmony_ci</ul>
101745bd8deadSopenharmony_ci</div>
101755bd8deadSopenharmony_ci<div class="paragraph">
101765bd8deadSopenharmony_ci<p>Note: Shadow mismatches are allowed between constructors and the second argument.
101775bd8deadSopenharmony_ciTexture-combined non-shadow samplers can be constructed from <strong>samplerShadow</strong> and
101785bd8deadSopenharmony_citexture-combined shadow samplers can be constructed from <strong>sampler</strong>.</p>
101795bd8deadSopenharmony_ci</div>
101805bd8deadSopenharmony_ci</div>
101815bd8deadSopenharmony_ci</div>
101825bd8deadSopenharmony_ci<div class="sect2">
101835bd8deadSopenharmony_ci<h3 id="vector-components">5.5. Vector and Scalar Components and Length</h3>
101845bd8deadSopenharmony_ci<div class="paragraph">
101855bd8deadSopenharmony_ci<p>The names of the components of a vector
101865bd8deadSopenharmony_cior scalar
101875bd8deadSopenharmony_ciare denoted by a single letter.
101885bd8deadSopenharmony_ciAs a notational convenience, several letters are associated with each
101895bd8deadSopenharmony_cicomponent based on common usage of position, color or texture coordinate
101905bd8deadSopenharmony_civectors.
101915bd8deadSopenharmony_ciThe individual components can be selected by following the variable name
101925bd8deadSopenharmony_ciwith period (<strong>.</strong>) and then the component name.</p>
101935bd8deadSopenharmony_ci</div>
101945bd8deadSopenharmony_ci<div class="paragraph">
101955bd8deadSopenharmony_ci<p>The component names supported are:</p>
101965bd8deadSopenharmony_ci</div>
101975bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all fit-content">
101985bd8deadSopenharmony_ci<colgroup>
101995bd8deadSopenharmony_ci<col>
102005bd8deadSopenharmony_ci<col>
102015bd8deadSopenharmony_ci</colgroup>
102025bd8deadSopenharmony_ci<tbody>
102035bd8deadSopenharmony_ci<tr>
102045bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><em>{ x, y, z, w }</em></p></td>
102055bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Useful when accessing vectors that represent points or normals</p></td>
102065bd8deadSopenharmony_ci</tr>
102075bd8deadSopenharmony_ci<tr>
102085bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><em>{ r, g, b, a }</em></p></td>
102095bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Useful when accessing vectors that represent colors</p></td>
102105bd8deadSopenharmony_ci</tr>
102115bd8deadSopenharmony_ci<tr>
102125bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><em>{ s, t, p, q }</em></p></td>
102135bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Useful when accessing vectors that represent texture coordinates</p></td>
102145bd8deadSopenharmony_ci</tr>
102155bd8deadSopenharmony_ci</tbody>
102165bd8deadSopenharmony_ci</table>
102175bd8deadSopenharmony_ci<div class="paragraph">
102185bd8deadSopenharmony_ci<p>The component names <em>x</em>, <em>r</em>, and <em>s</em> are, for example, synonyms for the
102195bd8deadSopenharmony_cisame (first) component in a vector.
102205bd8deadSopenharmony_ciThey are also the names of the only component in a scalar.</p>
102215bd8deadSopenharmony_ci</div>
102225bd8deadSopenharmony_ci<div class="paragraph">
102235bd8deadSopenharmony_ci<p>Note that the third component of the texture coordinate set
102245bd8deadSopenharmony_cihas been renamed <em>p</em> so as to avoid the confusion with <em>r</em> (for
102255bd8deadSopenharmony_cired) in a color.</p>
102265bd8deadSopenharmony_ci</div>
102275bd8deadSopenharmony_ci<div class="paragraph">
102285bd8deadSopenharmony_ci<p>Accessing components beyond those declared for the type is
102295bd8deadSopenharmony_cia compile-time error so, for example:</p>
102305bd8deadSopenharmony_ci</div>
102315bd8deadSopenharmony_ci<div class="listingblock">
102325bd8deadSopenharmony_ci<div class="content">
102335bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec2 pos;
102345bd8deadSopenharmony_ci<span class="predefined-type">float</span> height;
102355bd8deadSopenharmony_cipos.x       <span class="comment">// is legal</span>
102365bd8deadSopenharmony_cipos.z       <span class="comment">// is illegal</span>
102375bd8deadSopenharmony_ciheight.x    <span class="comment">// is legal</span>
102385bd8deadSopenharmony_ciheight.y    <span class="comment">// is illegal</span></code></pre>
102395bd8deadSopenharmony_ci</div>
102405bd8deadSopenharmony_ci</div>
102415bd8deadSopenharmony_ci<div class="paragraph">
102425bd8deadSopenharmony_ci<p>The component selection syntax allows multiple components to be selected by
102435bd8deadSopenharmony_ciappending their names (from the same name set) after the period (<strong>.</strong>).</p>
102445bd8deadSopenharmony_ci</div>
102455bd8deadSopenharmony_ci<div class="listingblock">
102465bd8deadSopenharmony_ci<div class="content">
102475bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec4 v4;
102485bd8deadSopenharmony_civ4.rgba;    <span class="comment">// is a vec4 and the same as just using v4,</span>
102495bd8deadSopenharmony_civ4.rgb;     <span class="comment">// is a vec3,</span>
102505bd8deadSopenharmony_civ4.b;       <span class="comment">// is a float,</span>
102515bd8deadSopenharmony_civ4.xy;      <span class="comment">// is a vec2,</span>
102525bd8deadSopenharmony_civ4.xgba;    <span class="comment">// is illegal - the component names do not come from the same set</span></code></pre>
102535bd8deadSopenharmony_ci</div>
102545bd8deadSopenharmony_ci</div>
102555bd8deadSopenharmony_ci<div class="paragraph">
102565bd8deadSopenharmony_ci<p>No more than 4 components can be selected.</p>
102575bd8deadSopenharmony_ci</div>
102585bd8deadSopenharmony_ci<div class="listingblock">
102595bd8deadSopenharmony_ci<div class="content">
102605bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec4 v4;
102615bd8deadSopenharmony_civ4.xyzwxy;      <span class="comment">// is illegal since it has 6 components</span>
102625bd8deadSopenharmony_ci(v4.xyzwxy).xy; <span class="comment">// is illegal since the intermediate value has 6</span>
102635bd8deadSopenharmony_cicomponents</code></pre>
102645bd8deadSopenharmony_ci</div>
102655bd8deadSopenharmony_ci</div>
102665bd8deadSopenharmony_ci<div class="paragraph">
102675bd8deadSopenharmony_ci<p>The order of the components can be different to swizzle them, or replicated:</p>
102685bd8deadSopenharmony_ci</div>
102695bd8deadSopenharmony_ci<div class="listingblock">
102705bd8deadSopenharmony_ci<div class="content">
102715bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec4 pos = vec4(<span class="float">1</span><span class="float">.0</span>, <span class="float">2</span><span class="float">.0</span>, <span class="float">3</span><span class="float">.0</span>, <span class="float">4</span><span class="float">.0</span>);
102725bd8deadSopenharmony_civec4 swiz = pos.wzyx;   <span class="comment">// swiz = (4.0, 3.0, 2.0, 1.0)</span>
102735bd8deadSopenharmony_civec4 dup = pos.xxyy;    <span class="comment">// dup = (1.0, 1.0, 2.0, 2.0)</span></code></pre>
102745bd8deadSopenharmony_ci</div>
102755bd8deadSopenharmony_ci</div>
102765bd8deadSopenharmony_ci<div class="paragraph">
102775bd8deadSopenharmony_ci<p>This notation is more concise than the constructor syntax.
102785bd8deadSopenharmony_ciTo form an r-value, it can be applied to any expression that results in a
102795bd8deadSopenharmony_civector or scalar r-value.</p>
102805bd8deadSopenharmony_ci</div>
102815bd8deadSopenharmony_ci<div class="paragraph">
102825bd8deadSopenharmony_ci<p>The component group notation can occur on the left hand side of an
102835bd8deadSopenharmony_ciexpression.</p>
102845bd8deadSopenharmony_ci</div>
102855bd8deadSopenharmony_ci<div class="listingblock">
102865bd8deadSopenharmony_ci<div class="content">
102875bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec4 pos = vec4(<span class="float">1</span><span class="float">.0</span>, <span class="float">2</span><span class="float">.0</span>, <span class="float">3</span><span class="float">.0</span>, <span class="float">4</span><span class="float">.0</span>);
102885bd8deadSopenharmony_cipos.xw = vec2(<span class="float">5</span><span class="float">.0</span>, <span class="float">6</span><span class="float">.0</span>);        <span class="comment">// pos = (5.0, 2.0, 3.0, 6.0)</span>
102895bd8deadSopenharmony_cipos.wx = vec2(<span class="float">7</span><span class="float">.0</span>, <span class="float">8</span><span class="float">.0</span>);        <span class="comment">// pos = (8.0, 2.0, 3.0, 7.0)</span>
102905bd8deadSopenharmony_cipos.xx = vec2(<span class="float">3</span><span class="float">.0</span>, <span class="float">4</span><span class="float">.0</span>);        <span class="comment">// illegal - 'x' used twice</span>
102915bd8deadSopenharmony_cipos.xy = vec3(<span class="float">1</span><span class="float">.0</span>, <span class="float">2</span><span class="float">.0</span>, <span class="float">3</span><span class="float">.0</span>);   <span class="comment">// illegal - mismatch between vec2 and vec3</span></code></pre>
102925bd8deadSopenharmony_ci</div>
102935bd8deadSopenharmony_ci</div>
102945bd8deadSopenharmony_ci<div class="paragraph">
102955bd8deadSopenharmony_ci<p>To form an l-value, swizzling must further be applied to an l-value and
102965bd8deadSopenharmony_cicontain no duplicate components. It results in an l-value of scalar or
102975bd8deadSopenharmony_civector type, depending on number of components specified.</p>
102985bd8deadSopenharmony_ci</div>
102995bd8deadSopenharmony_ci<div class="paragraph">
103005bd8deadSopenharmony_ci<p>Array subscripting syntax can also be applied to vectors (but not to
103015bd8deadSopenharmony_ciscalars) to provide numeric indexing.
103025bd8deadSopenharmony_ciSo in</p>
103035bd8deadSopenharmony_ci</div>
103045bd8deadSopenharmony_ci<div class="listingblock">
103055bd8deadSopenharmony_ci<div class="content">
103065bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec4 pos;</code></pre>
103075bd8deadSopenharmony_ci</div>
103085bd8deadSopenharmony_ci</div>
103095bd8deadSopenharmony_ci<div class="paragraph">
103105bd8deadSopenharmony_ci<p><em>pos[2]</em> refers to the third element of <em>pos</em> and is equivalent to <em>pos.z</em>.
103115bd8deadSopenharmony_ciThis allows variable indexing into a vector, as well as a generic way of
103125bd8deadSopenharmony_ciaccessing components.
103135bd8deadSopenharmony_ciAny integer expression can be used as the subscript.
103145bd8deadSopenharmony_ciThe first component is at index zero.
103155bd8deadSopenharmony_ciReading from or writing to a vector using a constant integral expression
103165bd8deadSopenharmony_ciwith a value that is negative or greater than or equal to the size of the
103175bd8deadSopenharmony_civector results in a compile-time error.
103185bd8deadSopenharmony_ciWhen indexing with non-constant expressions, behavior is undefined if the
103195bd8deadSopenharmony_ciindex is negative, or greater than or equal to the size of the vector.</p>
103205bd8deadSopenharmony_ci</div>
103215bd8deadSopenharmony_ci<div class="paragraph">
103225bd8deadSopenharmony_ci<p>The <strong>length</strong>() method may be applied to vectors (but not scalars).
103235bd8deadSopenharmony_ciThe result is the number of components in the vector.
103245bd8deadSopenharmony_ciFor example,</p>
103255bd8deadSopenharmony_ci</div>
103265bd8deadSopenharmony_ci<div class="listingblock">
103275bd8deadSopenharmony_ci<div class="content">
103285bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec3 v;
103295bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> L = v.length();</code></pre>
103305bd8deadSopenharmony_ci</div>
103315bd8deadSopenharmony_ci</div>
103325bd8deadSopenharmony_ci<div class="paragraph">
103335bd8deadSopenharmony_ci<p>sets the constant <em>L</em> to 3.
103345bd8deadSopenharmony_ciThe type returned by <strong>.length</strong>() on a vector is <strong>int</strong>, and the value
103355bd8deadSopenharmony_cireturned is a constant expression.</p>
103365bd8deadSopenharmony_ci</div>
103375bd8deadSopenharmony_ci</div>
103385bd8deadSopenharmony_ci<div class="sect2">
103395bd8deadSopenharmony_ci<h3 id="matrix-components">5.6. Matrix Components</h3>
103405bd8deadSopenharmony_ci<div class="paragraph">
103415bd8deadSopenharmony_ci<p>The components of a matrix can be accessed using array subscripting syntax.
103425bd8deadSopenharmony_ciApplying a single subscript to a matrix treats the matrix as an array of
103435bd8deadSopenharmony_cicolumn vectors, and selects a single column, whose type is a vector of the
103445bd8deadSopenharmony_cisame size as the (column size of the) matrix.
103455bd8deadSopenharmony_ciThe leftmost column is column 0.
103465bd8deadSopenharmony_ciA second subscript would then operate on the resulting vector, as defined
103475bd8deadSopenharmony_ciearlier for vectors.
103485bd8deadSopenharmony_ciHence, two subscripts select a column and then a row.</p>
103495bd8deadSopenharmony_ci</div>
103505bd8deadSopenharmony_ci<div class="listingblock">
103515bd8deadSopenharmony_ci<div class="content">
103525bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">mat4 m;
103535bd8deadSopenharmony_cim[<span class="integer">1</span>] = vec4(<span class="float">2</span><span class="float">.0</span>);   <span class="comment">// sets the second column to all 2.0</span>
103545bd8deadSopenharmony_cim[<span class="integer">0</span>][<span class="integer">0</span>] = <span class="float">1</span><span class="float">.0</span>;      <span class="comment">// sets the upper left element to 1.0</span>
103555bd8deadSopenharmony_cim[<span class="integer">2</span>][<span class="integer">3</span>] = <span class="float">2</span><span class="float">.0</span>;      <span class="comment">// sets the 4th element of the third column to 2.0</span></code></pre>
103565bd8deadSopenharmony_ci</div>
103575bd8deadSopenharmony_ci</div>
103585bd8deadSopenharmony_ci<div class="paragraph">
103595bd8deadSopenharmony_ci<p>Behavior is undefined when accessing a component outside the bounds of a
103605bd8deadSopenharmony_cimatrix with a non-constant expression.
103615bd8deadSopenharmony_ciIt is a compile-time error to access a matrix with a constant expression
103625bd8deadSopenharmony_cithat is outside the bounds of the matrix.</p>
103635bd8deadSopenharmony_ci</div>
103645bd8deadSopenharmony_ci<div class="paragraph">
103655bd8deadSopenharmony_ci<p>The <strong>length</strong>() method may be applied to matrices.
103665bd8deadSopenharmony_ciThe result is the number of columns of the matrix.
103675bd8deadSopenharmony_ciFor example,</p>
103685bd8deadSopenharmony_ci</div>
103695bd8deadSopenharmony_ci<div class="listingblock">
103705bd8deadSopenharmony_ci<div class="content">
103715bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">mat3x4 v;
103725bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> L = v.length();</code></pre>
103735bd8deadSopenharmony_ci</div>
103745bd8deadSopenharmony_ci</div>
103755bd8deadSopenharmony_ci<div class="paragraph">
103765bd8deadSopenharmony_ci<p>sets the constant <em>L</em> to 3.
103775bd8deadSopenharmony_ciThe type returned by <strong>.length</strong>() on a matrix is <strong>int</strong>, and the value
103785bd8deadSopenharmony_cireturned is a constant expression.</p>
103795bd8deadSopenharmony_ci</div>
103805bd8deadSopenharmony_ci</div>
103815bd8deadSopenharmony_ci<div class="sect2">
103825bd8deadSopenharmony_ci<h3 id="structure-and-array-operations">5.7. Structure and Array Operations</h3>
103835bd8deadSopenharmony_ci<div class="paragraph">
103845bd8deadSopenharmony_ci<p>The members of a structure and the <strong>length</strong>() method of an array are
103855bd8deadSopenharmony_ciselected using the period (<strong>.</strong>).</p>
103865bd8deadSopenharmony_ci</div>
103875bd8deadSopenharmony_ci<div class="paragraph">
103885bd8deadSopenharmony_ci<p>In total, only the following operators are allowed to operate on arrays and
103895bd8deadSopenharmony_cistructures as whole entities:</p>
103905bd8deadSopenharmony_ci</div>
103915bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all fit-content">
103925bd8deadSopenharmony_ci<colgroup>
103935bd8deadSopenharmony_ci<col>
103945bd8deadSopenharmony_ci<col>
103955bd8deadSopenharmony_ci</colgroup>
103965bd8deadSopenharmony_ci<tbody>
103975bd8deadSopenharmony_ci<tr>
103985bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">field selector</p></td>
103995bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>.</strong></p></td>
104005bd8deadSopenharmony_ci</tr>
104015bd8deadSopenharmony_ci<tr>
104025bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">equality</p></td>
104035bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>==</strong> <strong>!=</strong></p></td>
104045bd8deadSopenharmony_ci</tr>
104055bd8deadSopenharmony_ci<tr>
104065bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">assignment</p></td>
104075bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>=</strong></p></td>
104085bd8deadSopenharmony_ci</tr>
104095bd8deadSopenharmony_ci<tr>
104105bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Ternary operator</p></td>
104115bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>?:</strong></p></td>
104125bd8deadSopenharmony_ci</tr>
104135bd8deadSopenharmony_ci<tr>
104145bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Sequence operator</p></td>
104155bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>,</strong></p></td>
104165bd8deadSopenharmony_ci</tr>
104175bd8deadSopenharmony_ci<tr>
104185bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">indexing (arrays only)</p></td>
104195bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>[</strong> <strong>]</strong></p></td>
104205bd8deadSopenharmony_ci</tr>
104215bd8deadSopenharmony_ci</tbody>
104225bd8deadSopenharmony_ci</table>
104235bd8deadSopenharmony_ci<div class="paragraph">
104245bd8deadSopenharmony_ci<p>The equality operators and assignment operator are only allowed if the two
104255bd8deadSopenharmony_cioperands are same size and type.
104265bd8deadSopenharmony_ciThe operands cannot contain any opaque types.
104275bd8deadSopenharmony_ciStructure types must be of the same declared structure.
104285bd8deadSopenharmony_ciBoth array operands must be
104295bd8deadSopenharmony_ciexplicitly
104305bd8deadSopenharmony_cisized.
104315bd8deadSopenharmony_ciWhen using the equality operators, two structures are equal if and only if
104325bd8deadSopenharmony_ciall the members are component-wise equal, and two arrays are equal if and
104335bd8deadSopenharmony_cionly if all the elements are element-wise equal.</p>
104345bd8deadSopenharmony_ci</div>
104355bd8deadSopenharmony_ci<div class="paragraph">
104365bd8deadSopenharmony_ci<p>Array elements are accessed using the array subscript operator (<strong>[ ]</strong>).
104375bd8deadSopenharmony_ciAn example of accessing an array element is</p>
104385bd8deadSopenharmony_ci</div>
104395bd8deadSopenharmony_ci<div class="listingblock">
104405bd8deadSopenharmony_ci<div class="content">
104415bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">diffuseColor += lightIntensity[<span class="integer">3</span>] * NdotL;</code></pre>
104425bd8deadSopenharmony_ci</div>
104435bd8deadSopenharmony_ci</div>
104445bd8deadSopenharmony_ci<div class="paragraph">
104455bd8deadSopenharmony_ci<p>Array indices start at zero.
104465bd8deadSopenharmony_ciArray elements are accessed using an expression whose type is <strong>int</strong> or
104475bd8deadSopenharmony_ci<strong>uint</strong>.</p>
104485bd8deadSopenharmony_ci</div>
104495bd8deadSopenharmony_ci<div class="paragraph">
104505bd8deadSopenharmony_ci<p>Behavior is undefined if a shader subscripts an array with an index less
104515bd8deadSopenharmony_cithan 0 or greater than or equal to the size the array was declared with.</p>
104525bd8deadSopenharmony_ci</div>
104535bd8deadSopenharmony_ci<div class="paragraph">
104545bd8deadSopenharmony_ci<p>Arrays can also be accessed with the method operator (<strong>.</strong>) and the <strong>length</strong>
104555bd8deadSopenharmony_cimethod to query the size of the array:</p>
104565bd8deadSopenharmony_ci</div>
104575bd8deadSopenharmony_ci<div class="listingblock">
104585bd8deadSopenharmony_ci<div class="content">
104595bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">lightIntensity.length() <span class="comment">// return the size of the array</span></code></pre>
104605bd8deadSopenharmony_ci</div>
104615bd8deadSopenharmony_ci</div>
104625bd8deadSopenharmony_ci</div>
104635bd8deadSopenharmony_ci<div class="sect2">
104645bd8deadSopenharmony_ci<h3 id="assignments">5.8. Assignments</h3>
104655bd8deadSopenharmony_ci<div class="paragraph">
104665bd8deadSopenharmony_ci<p>Assignments of values to variable names are done with the assignment
104675bd8deadSopenharmony_cioperator (<strong>=</strong>):</p>
104685bd8deadSopenharmony_ci</div>
104695bd8deadSopenharmony_ci<div class="dlist">
104705bd8deadSopenharmony_ci<dl>
104715bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
104725bd8deadSopenharmony_ci<dd>
104735bd8deadSopenharmony_ci<p><em>lvalue-expression</em> = <em>rvalue-expression</em></p>
104745bd8deadSopenharmony_ci</dd>
104755bd8deadSopenharmony_ci</dl>
104765bd8deadSopenharmony_ci</div>
104775bd8deadSopenharmony_ci<div class="paragraph">
104785bd8deadSopenharmony_ci<p>The <em>lvalue-expression</em> evaluates to an l-value.
104795bd8deadSopenharmony_ciThe assignment operator stores the value of <em>rvalue-expression</em> into the
104805bd8deadSopenharmony_cil-value and returns an r-value with the type and precision of
104815bd8deadSopenharmony_ci<em>lvalue-expression</em>.
104825bd8deadSopenharmony_ciThe <em>lvalue-expression</em> and <em>rvalue-expression</em> must have the same
104835bd8deadSopenharmony_citype, or the expression must have a type in the table in section
104845bd8deadSopenharmony_ci&#8220;<a href="#implicit-conversions">Implicit Conversions</a>&#8221; that converts to the type
104855bd8deadSopenharmony_ciof <em>lvalue-expression</em>, in which case an implicit conversion will be done on
104865bd8deadSopenharmony_cithe <em>rvalue-expression</em> before the assignment is done.
104875bd8deadSopenharmony_ciAny other desired type-conversions must be specified explicitly via a
104885bd8deadSopenharmony_ciconstructor.
104895bd8deadSopenharmony_ciIt is a compile-time error if the l-value is not writable.
104905bd8deadSopenharmony_ciVariables that are built-in types, entire structures or arrays, structure
104915bd8deadSopenharmony_cimembers, l-values with the field selector (<strong>.</strong>) applied to select components
104925bd8deadSopenharmony_cior swizzles without repeated fields, l-values within parentheses, and
104935bd8deadSopenharmony_cil-values dereferenced with the array subscript operator (<strong>[ ]</strong>) are all
104945bd8deadSopenharmony_cil-values.
104955bd8deadSopenharmony_ciOther binary or unary expressions, function names, swizzles with repeated
104965bd8deadSopenharmony_cifields, and constants cannot be l-values.
104975bd8deadSopenharmony_ciThe ternary operator (<strong>?:</strong>) is also not allowed as an l-value.
104985bd8deadSopenharmony_ciUsing an incorrect expression as an l-value results in a compile-time error.</p>
104995bd8deadSopenharmony_ci</div>
105005bd8deadSopenharmony_ci<div class="paragraph">
105015bd8deadSopenharmony_ci<p>Expressions on the left of an assignment are evaluated before expressions on
105025bd8deadSopenharmony_cithe right of the assignment.</p>
105035bd8deadSopenharmony_ci</div>
105045bd8deadSopenharmony_ci<div class="paragraph">
105055bd8deadSopenharmony_ci<p>The other assignment operators are</p>
105065bd8deadSopenharmony_ci</div>
105075bd8deadSopenharmony_ci<div class="ulist">
105085bd8deadSopenharmony_ci<ul>
105095bd8deadSopenharmony_ci<li>
105105bd8deadSopenharmony_ci<p>add into (<strong>+=</strong>)</p>
105115bd8deadSopenharmony_ci</li>
105125bd8deadSopenharmony_ci<li>
105135bd8deadSopenharmony_ci<p>subtract from (<strong>-=</strong>)</p>
105145bd8deadSopenharmony_ci</li>
105155bd8deadSopenharmony_ci<li>
105165bd8deadSopenharmony_ci<p>multiply into (<strong>*=</strong>)</p>
105175bd8deadSopenharmony_ci</li>
105185bd8deadSopenharmony_ci<li>
105195bd8deadSopenharmony_ci<p>divide into (<strong>/=</strong>)</p>
105205bd8deadSopenharmony_ci</li>
105215bd8deadSopenharmony_ci<li>
105225bd8deadSopenharmony_ci<p>modulus into (<strong>%=</strong>)</p>
105235bd8deadSopenharmony_ci</li>
105245bd8deadSopenharmony_ci<li>
105255bd8deadSopenharmony_ci<p>left shift by (<strong>&lt;&lt;=</strong>)</p>
105265bd8deadSopenharmony_ci</li>
105275bd8deadSopenharmony_ci<li>
105285bd8deadSopenharmony_ci<p>right shift by (<strong>&gt;&gt;=</strong>)</p>
105295bd8deadSopenharmony_ci</li>
105305bd8deadSopenharmony_ci<li>
105315bd8deadSopenharmony_ci<p>and into (<strong>&amp;=</strong>)</p>
105325bd8deadSopenharmony_ci</li>
105335bd8deadSopenharmony_ci<li>
105345bd8deadSopenharmony_ci<p>inclusive-or into (<strong>|=</strong>)</p>
105355bd8deadSopenharmony_ci</li>
105365bd8deadSopenharmony_ci<li>
105375bd8deadSopenharmony_ci<p>exclusive-or into (<strong>^=</strong>)</p>
105385bd8deadSopenharmony_ci</li>
105395bd8deadSopenharmony_ci</ul>
105405bd8deadSopenharmony_ci</div>
105415bd8deadSopenharmony_ci<div class="paragraph">
105425bd8deadSopenharmony_ci<p>where the general expression</p>
105435bd8deadSopenharmony_ci</div>
105445bd8deadSopenharmony_ci<div class="dlist">
105455bd8deadSopenharmony_ci<dl>
105465bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
105475bd8deadSopenharmony_ci<dd>
105485bd8deadSopenharmony_ci<p><em>lvalue</em> <em>op</em>= <em>expression</em></p>
105495bd8deadSopenharmony_ci</dd>
105505bd8deadSopenharmony_ci</dl>
105515bd8deadSopenharmony_ci</div>
105525bd8deadSopenharmony_ci<div class="paragraph">
105535bd8deadSopenharmony_ci<p>is equivalent to</p>
105545bd8deadSopenharmony_ci</div>
105555bd8deadSopenharmony_ci<div class="dlist">
105565bd8deadSopenharmony_ci<dl>
105575bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
105585bd8deadSopenharmony_ci<dd>
105595bd8deadSopenharmony_ci<p><em>lvalue</em> = <em>lvalue</em> <em>op</em> <em>expression</em></p>
105605bd8deadSopenharmony_ci</dd>
105615bd8deadSopenharmony_ci</dl>
105625bd8deadSopenharmony_ci</div>
105635bd8deadSopenharmony_ci<div class="paragraph">
105645bd8deadSopenharmony_ci<p>where <em>lvalue</em> is the value returned by <em>lvalue-expression</em>, <em>op</em> is as
105655bd8deadSopenharmony_cidescribed below, and the <em>lvalue-expression</em> and <em>expression</em> must satisfy
105665bd8deadSopenharmony_cithe semantic requirements of both <em>op</em> and equals (<strong>=</strong>).</p>
105675bd8deadSopenharmony_ci</div>
105685bd8deadSopenharmony_ci<div class="paragraph">
105695bd8deadSopenharmony_ci<p>Reading a variable before writing (or initializing) it is legal, however the
105705bd8deadSopenharmony_civalue is undefined.</p>
105715bd8deadSopenharmony_ci</div>
105725bd8deadSopenharmony_ci</div>
105735bd8deadSopenharmony_ci<div class="sect2">
105745bd8deadSopenharmony_ci<h3 id="expressions">5.9. Expressions</h3>
105755bd8deadSopenharmony_ci<div class="paragraph">
105765bd8deadSopenharmony_ci<p>Expressions in the shading language are built from the following:</p>
105775bd8deadSopenharmony_ci</div>
105785bd8deadSopenharmony_ci<div class="ulist">
105795bd8deadSopenharmony_ci<ul>
105805bd8deadSopenharmony_ci<li>
105815bd8deadSopenharmony_ci<p>Constants of type <strong>bool</strong>, all integral types, all floating-point types,
105825bd8deadSopenharmony_ciall vector types, and all matrix types.</p>
105835bd8deadSopenharmony_ci</li>
105845bd8deadSopenharmony_ci<li>
105855bd8deadSopenharmony_ci<p>Constructors of all types.</p>
105865bd8deadSopenharmony_ci</li>
105875bd8deadSopenharmony_ci<li>
105885bd8deadSopenharmony_ci<p>Variable names of all types.</p>
105895bd8deadSopenharmony_ci</li>
105905bd8deadSopenharmony_ci<li>
105915bd8deadSopenharmony_ci<p>An array, vector, or matrix expression with the <strong>length</strong>() method
105925bd8deadSopenharmony_ciapplied.</p>
105935bd8deadSopenharmony_ci</li>
105945bd8deadSopenharmony_ci<li>
105955bd8deadSopenharmony_ci<p>Subscripted arrays.</p>
105965bd8deadSopenharmony_ci</li>
105975bd8deadSopenharmony_ci<li>
105985bd8deadSopenharmony_ci<p>Function calls that return values.
105995bd8deadSopenharmony_ciIn some cases, function calls returning <strong>void</strong> are also allowed in
106005bd8deadSopenharmony_ciexpressions as specified below.</p>
106015bd8deadSopenharmony_ci</li>
106025bd8deadSopenharmony_ci<li>
106035bd8deadSopenharmony_ci<p>Component field selectors and array subscript results.</p>
106045bd8deadSopenharmony_ci</li>
106055bd8deadSopenharmony_ci<li>
106065bd8deadSopenharmony_ci<p>Parenthesized expressions.
106075bd8deadSopenharmony_ciAny expression, including expressions with void type can be
106085bd8deadSopenharmony_ciparenthesized.
106095bd8deadSopenharmony_ciParentheses can be used to group operations.
106105bd8deadSopenharmony_ciOperations within parentheses are done before operations across
106115bd8deadSopenharmony_ciparentheses.</p>
106125bd8deadSopenharmony_ci</li>
106135bd8deadSopenharmony_ci<li>
106145bd8deadSopenharmony_ci<p>The arithmetic binary operators add (<strong>+</strong>), subtract (<strong>-</strong>), multiply
106155bd8deadSopenharmony_ci(<strong>*</strong>), and divide (<strong>/</strong>) operate on integer and floating-point scalars,
106165bd8deadSopenharmony_civectors, and matrices.
106175bd8deadSopenharmony_ciIf the fundamental types in the operands do not match, then the
106185bd8deadSopenharmony_ciconversions from &#8220;<a href="#implicit-conversions">Implicit Conversions</a>&#8221; are
106195bd8deadSopenharmony_ciapplied to create matching types.
106205bd8deadSopenharmony_ciAll arithmetic binary operators result in the same fundamental type
106215bd8deadSopenharmony_ci(signed integer, unsigned integer, single-precision floating-point, or
106225bd8deadSopenharmony_cidouble-precision floating-point) as the operands they operate on, after
106235bd8deadSopenharmony_cioperand type conversion.
106245bd8deadSopenharmony_ciAfter conversion, the following cases are valid</p>
106255bd8deadSopenharmony_ci<div class="ulist">
106265bd8deadSopenharmony_ci<ul>
106275bd8deadSopenharmony_ci<li>
106285bd8deadSopenharmony_ci<p>The two operands are scalars.
106295bd8deadSopenharmony_ciIn this case the operation is applied, resulting in a scalar.</p>
106305bd8deadSopenharmony_ci</li>
106315bd8deadSopenharmony_ci<li>
106325bd8deadSopenharmony_ci<p>One operand is a scalar, and the other is a vector or matrix.
106335bd8deadSopenharmony_ciIn this case, the scalar operation is applied independently to each
106345bd8deadSopenharmony_cicomponent of the vector or matrix, resulting in the same size vector or
106355bd8deadSopenharmony_cimatrix.</p>
106365bd8deadSopenharmony_ci</li>
106375bd8deadSopenharmony_ci<li>
106385bd8deadSopenharmony_ci<p>The two operands are vectors of the same size.
106395bd8deadSopenharmony_ciIn this case, the operation is done component-wise resulting in the
106405bd8deadSopenharmony_cisame size vector.</p>
106415bd8deadSopenharmony_ci</li>
106425bd8deadSopenharmony_ci<li>
106435bd8deadSopenharmony_ci<p>The operator is add (<strong>+</strong>), subtract (<strong>-</strong>), or divide (<strong>/</strong>), and the
106445bd8deadSopenharmony_cioperands are matrices with the same number of rows and the same number
106455bd8deadSopenharmony_ciof columns.
106465bd8deadSopenharmony_ciIn this case, the operation is done component-wise resulting in the
106475bd8deadSopenharmony_cisame size matrix.</p>
106485bd8deadSopenharmony_ci</li>
106495bd8deadSopenharmony_ci<li>
106505bd8deadSopenharmony_ci<p>The operator is multiply (<strong>*</strong>), where both operands are matrices or one
106515bd8deadSopenharmony_cioperand is a vector and the other a matrix.
106525bd8deadSopenharmony_ciA right vector operand is treated as a column vector and a left vector
106535bd8deadSopenharmony_cioperand as a row vector.
106545bd8deadSopenharmony_ciIn all these cases, it is required that the number of columns of the
106555bd8deadSopenharmony_cileft operand is equal to the number of rows of the right operand.
106565bd8deadSopenharmony_ciThen, the multiply (<strong>*</strong>) operation does a linear algebraic multiply,
106575bd8deadSopenharmony_ciyielding an object that has the same number of rows as the left operand
106585bd8deadSopenharmony_ciand the same number of columns as the right operand.
106595bd8deadSopenharmony_ci&#8220;<a href="#vector-and-matrix-operations">Vector and Matrix Operations</a>&#8221;
106605bd8deadSopenharmony_ciexplains in more detail how vectors and matrices are operated on.</p>
106615bd8deadSopenharmony_ci<div class="openblock">
106625bd8deadSopenharmony_ci<div class="content">
106635bd8deadSopenharmony_ci<div class="paragraph">
106645bd8deadSopenharmony_ci<p>All other cases result in a compile-time error.</p>
106655bd8deadSopenharmony_ci</div>
106665bd8deadSopenharmony_ci<div class="paragraph">
106675bd8deadSopenharmony_ci<p>Use the built-in functions <strong>dot</strong>, <strong>cross</strong>, <strong>matrixCompMult</strong>, and
106685bd8deadSopenharmony_ci<strong>outerProduct</strong>, to get, respectively, vector dot product, vector cross
106695bd8deadSopenharmony_ciproduct, matrix component-wise multiplication, and the matrix product of a
106705bd8deadSopenharmony_cicolumn vector times a row vector.</p>
106715bd8deadSopenharmony_ci</div>
106725bd8deadSopenharmony_ci</div>
106735bd8deadSopenharmony_ci</div>
106745bd8deadSopenharmony_ci</li>
106755bd8deadSopenharmony_ci</ul>
106765bd8deadSopenharmony_ci</div>
106775bd8deadSopenharmony_ci</li>
106785bd8deadSopenharmony_ci<li>
106795bd8deadSopenharmony_ci<p>The operator modulus (<strong>%</strong>) operates on signed or unsigned integers or
106805bd8deadSopenharmony_ciinteger vectors.
106815bd8deadSopenharmony_ciIf the fundamental types in the operands do not match, then the
106825bd8deadSopenharmony_ciconversions from &#8220;<a href="#implicit-conversions">Implicit Conversions</a>&#8221; are
106835bd8deadSopenharmony_ciapplied to create matching types.
106845bd8deadSopenharmony_ciThe operands cannot be vectors of differing size; this is
106855bd8deadSopenharmony_cia compile-time error.
106865bd8deadSopenharmony_ciIf one operand is a scalar and the other vector, then the scalar is
106875bd8deadSopenharmony_ciapplied component-wise to the vector, resulting in the same type as the
106885bd8deadSopenharmony_civector.
106895bd8deadSopenharmony_ciIf both are vectors of the same size, the result is computed
106905bd8deadSopenharmony_cicomponent-wise.
106915bd8deadSopenharmony_ciThe resulting value is undefined for any component computed with a
106925bd8deadSopenharmony_cisecond operand that is zero, while results for other components with
106935bd8deadSopenharmony_cinon-zero second operands remain defined.
106945bd8deadSopenharmony_ciIf both operands are non-negative, then the remainder is non-negative.
106955bd8deadSopenharmony_ciResults are undefined if one or both operands are negative.
106965bd8deadSopenharmony_ciThe operator modulus (<strong>%</strong>) is not defined for any other data types
106975bd8deadSopenharmony_ci(non-integer types).</p>
106985bd8deadSopenharmony_ci</li>
106995bd8deadSopenharmony_ci<li>
107005bd8deadSopenharmony_ci<p>The arithmetic unary operators negate (<strong>-</strong>), post- and pre-increment and
107015bd8deadSopenharmony_cidecrement (<strong>--</strong> and <strong>++</strong>) operate on integer or floating-point values
107025bd8deadSopenharmony_ci(including vectors and matrices).
107035bd8deadSopenharmony_ciAll unary operators work component-wise on their operands.
107045bd8deadSopenharmony_ciThese result with the same type they operated on.
107055bd8deadSopenharmony_ciFor post- and pre-increment and decrement, the expression must be a writable
107065bd8deadSopenharmony_cil-value.
107075bd8deadSopenharmony_ciPre-increment and pre-decrement add or subtract 1 or 1.0 to the contents
107085bd8deadSopenharmony_ciof the expression they operate on, and the value of the pre-increment or
107095bd8deadSopenharmony_cipre-decrement expression is the resulting value of that modification.
107105bd8deadSopenharmony_ciPost-increment and post-decrement expressions add or subtract 1 or 1.0
107115bd8deadSopenharmony_cito the contents of the expression they operate on, but the resulting
107125bd8deadSopenharmony_ciexpression has the expression&#8217;s value before the post-increment or
107135bd8deadSopenharmony_cipost-decrement was executed.</p>
107145bd8deadSopenharmony_ci</li>
107155bd8deadSopenharmony_ci<li>
107165bd8deadSopenharmony_ci<p>The relational operators greater than (<strong>&gt;</strong>), less than (<strong>&lt;</strong>), greater
107175bd8deadSopenharmony_cithan or equal (<strong>&gt;=</strong>), and less than or equal (<strong>&lt;=</strong>) operate only on
107185bd8deadSopenharmony_ciscalar integer and scalar floating-point expressions.
107195bd8deadSopenharmony_ciThe result is scalar Boolean.
107205bd8deadSopenharmony_ciEither the operands' types must match, or the conversions from section
107215bd8deadSopenharmony_ci&#8220;<a href="#implicit-conversions">Implicit Conversions</a>&#8221; will be applied to
107225bd8deadSopenharmony_ciobtain matching types.
107235bd8deadSopenharmony_ciTo do component-wise relational comparisons on vectors, use the built-in
107245bd8deadSopenharmony_cifunctions <strong>lessThan</strong>, <strong>lessThanEqual</strong>, <strong>greaterThan</strong>, and
107255bd8deadSopenharmony_ci<strong>greaterThanEqual.</strong></p>
107265bd8deadSopenharmony_ci</li>
107275bd8deadSopenharmony_ci<li>
107285bd8deadSopenharmony_ci<p>The equality operators <strong>equal</strong> (<strong>==</strong>), and not equal (<strong>!=</strong>) operate on
107295bd8deadSopenharmony_ciall types except opaque types, aggregates that contain opaque types,
107305bd8deadSopenharmony_cisubroutine uniforms, and aggregates that contain subroutine uniforms.
107315bd8deadSopenharmony_ciThey result in a scalar Boolean.
107325bd8deadSopenharmony_ciIf the operand types do not match, then there must be a conversion from
107335bd8deadSopenharmony_ci&#8220;<a href="#implicit-conversions">Implicit Conversions</a>&#8221; applied to one operand
107345bd8deadSopenharmony_cithat can make them match, in which case this conversion is done.
107355bd8deadSopenharmony_ciFor vectors, matrices, structures, and arrays, all components, members,
107365bd8deadSopenharmony_cior elements of one operand must equal the corresponding components,
107375bd8deadSopenharmony_cimembers, or elements in the other operand for the operands to be
107385bd8deadSopenharmony_ciconsidered equal.
107395bd8deadSopenharmony_ciTo get a vector of component-wise equality results for vectors, use the
107405bd8deadSopenharmony_cibuilt-in functions <strong>equal</strong> and <strong>notEqual</strong>.</p>
107415bd8deadSopenharmony_ci</li>
107425bd8deadSopenharmony_ci<li>
107435bd8deadSopenharmony_ci<p>The logical binary operators and (<strong>&amp;&amp;</strong>), or (<strong>||</strong>), and exclusive or
107445bd8deadSopenharmony_ci(<strong>^^</strong>) operate only on two Boolean expressions and result in a Boolean
107455bd8deadSopenharmony_ciexpression.
107465bd8deadSopenharmony_ciAnd (<strong>&amp;&amp;</strong>) will only evaluate the right hand operand if the left hand
107475bd8deadSopenharmony_cioperand evaluated to <strong>true</strong>.
107485bd8deadSopenharmony_ciOr (<strong>||</strong>) will only evaluate the right hand operand if the left hand
107495bd8deadSopenharmony_cioperand evaluated to <strong>false</strong>.
107505bd8deadSopenharmony_ciExclusive or (<strong>^^</strong>) will always evaluate both operands.</p>
107515bd8deadSopenharmony_ci</li>
107525bd8deadSopenharmony_ci<li>
107535bd8deadSopenharmony_ci<p>The logical unary operator not (<strong>!</strong>).
107545bd8deadSopenharmony_ciIt operates only on a Boolean expression and results in a Boolean
107555bd8deadSopenharmony_ciexpression.
107565bd8deadSopenharmony_ciTo operate on a vector, use the built-in function <strong>not</strong>.</p>
107575bd8deadSopenharmony_ci</li>
107585bd8deadSopenharmony_ci<li>
107595bd8deadSopenharmony_ci<p>The sequence (<strong>,</strong>) operator that operates on expressions by returning
107605bd8deadSopenharmony_cithe type and value of the right-most expression in a comma separated
107615bd8deadSopenharmony_cilist of expressions.
107625bd8deadSopenharmony_ciAll expressions are evaluated, in order, from left to right.
107635bd8deadSopenharmony_ciThe operands to the sequence operator may have <strong>void</strong> type.
107645bd8deadSopenharmony_ciOpaque types cannot be used with the sequence (,) operator.</p>
107655bd8deadSopenharmony_ci</li>
107665bd8deadSopenharmony_ci<li>
107675bd8deadSopenharmony_ci<p>The ternary selection operator (<strong>?:</strong>).
107685bd8deadSopenharmony_ciIt operates on three expressions (<em>exp1</em> <strong>?</strong> <em>exp2</em> <strong>:</strong> <em>exp3</em>).
107695bd8deadSopenharmony_ciThis operator evaluates the first expression, which must result in a
107705bd8deadSopenharmony_ciscalar Boolean.
107715bd8deadSopenharmony_ciIf the result is true, it selects to evaluate the second expression,
107725bd8deadSopenharmony_ciotherwise it selects to evaluate the third expression.
107735bd8deadSopenharmony_ciOnly one of the second and third expressions is evaluated.
107745bd8deadSopenharmony_ciThe second and third expressions cannot be opaque types,
107755bd8deadSopenharmony_cior there will be a compile-time error.
107765bd8deadSopenharmony_ciOtherwise,
107775bd8deadSopenharmony_cithe second and third expressions can be any type, including <strong>void</strong>, as
107785bd8deadSopenharmony_cilong their types match, or there is a conversion in section
107795bd8deadSopenharmony_ci&#8220;<a href="#implicit-conversions">Implicit Conversions</a>&#8221; that can be applied to
107805bd8deadSopenharmony_cione of the expressions to make their types match.
107815bd8deadSopenharmony_ciThis resulting matching type is the type of the entire expression.</p>
107825bd8deadSopenharmony_ci</li>
107835bd8deadSopenharmony_ci<li>
107845bd8deadSopenharmony_ci<p>The one&#8217;s complement operator (<strong>~</strong>).
107855bd8deadSopenharmony_ciThe operand must be of type signed or unsigned integer or integer
107865bd8deadSopenharmony_civector, and the result is the one&#8217;s complement of its operand; each bit
107875bd8deadSopenharmony_ciof each component is complemented, including any sign bits.</p>
107885bd8deadSopenharmony_ci</li>
107895bd8deadSopenharmony_ci<li>
107905bd8deadSopenharmony_ci<p>The shift operators (<strong>&lt;&lt;</strong>) and (<strong>&gt;&gt;</strong>).
107915bd8deadSopenharmony_ciFor both operators, the operands must be signed or unsigned integers or
107925bd8deadSopenharmony_ciinteger vectors.
107935bd8deadSopenharmony_ciOne operand can be signed while the other is unsigned.
107945bd8deadSopenharmony_ciIn all cases, the resulting type will be the same type as the left
107955bd8deadSopenharmony_cioperand.
107965bd8deadSopenharmony_ciIf the first operand is a scalar, the second operand has to be a scalar
107975bd8deadSopenharmony_cias well.
107985bd8deadSopenharmony_ciIf the first operand is a vector, the second operand must be a scalar or
107995bd8deadSopenharmony_cia vector with the same size as the first operand, and the result is
108005bd8deadSopenharmony_cicomputed component-wise.
108015bd8deadSopenharmony_ciThe result is undefined if the right operand is negative, or greater
108025bd8deadSopenharmony_cithan or equal to the number of bits in the left expression&#8217;s base type.
108035bd8deadSopenharmony_ciThe value of E1 &lt;&lt; E2 is E1 (interpreted as a bit pattern) left-shifted
108045bd8deadSopenharmony_ciby E2 bits.
108055bd8deadSopenharmony_ciThe value of E1 &gt;&gt; E2 is E1 right-shifted by E2 bit positions.
108065bd8deadSopenharmony_ciIf E1 is a signed integer, the right-shift will extend the sign bit.
108075bd8deadSopenharmony_ciIf E1 is an unsigned integer, the right-shift will zero-extend.</p>
108085bd8deadSopenharmony_ci</li>
108095bd8deadSopenharmony_ci<li>
108105bd8deadSopenharmony_ci<p>The bitwise operators and (<strong>&amp;</strong>), exclusive-or (<strong>^</strong>), and inclusive-or
108115bd8deadSopenharmony_ci(<strong>|</strong>).
108125bd8deadSopenharmony_ciThe operands must be of type signed or unsigned integers or integer
108135bd8deadSopenharmony_civectors.
108145bd8deadSopenharmony_ciThe operands cannot be vectors of differing size; this is a compile-time error.
108155bd8deadSopenharmony_ciIf one operand is a scalar and the other a vector, the scalar is applied
108165bd8deadSopenharmony_cicomponent-wise to the vector, resulting in the same type as the vector.
108175bd8deadSopenharmony_ciIf the fundamental types in the operands do not match, then the
108185bd8deadSopenharmony_ciconversions from &#8220;<a href="#implicit-conversions">Implicit Conversions</a>&#8221; are
108195bd8deadSopenharmony_ciapplied to create matching types, and this will be the resulting
108205bd8deadSopenharmony_cifundamental type.
108215bd8deadSopenharmony_ciFor and (<strong>&amp;</strong>), the result is the bitwise-and function of the operands.
108225bd8deadSopenharmony_ciFor exclusive-or (<strong>^</strong>), the result is the bitwise exclusive-or function
108235bd8deadSopenharmony_ciof the operands.
108245bd8deadSopenharmony_ciFor inclusive-or (<strong>|</strong>), the result is the bitwise inclusive-or function
108255bd8deadSopenharmony_ciof the operands.</p>
108265bd8deadSopenharmony_ci</li>
108275bd8deadSopenharmony_ci</ul>
108285bd8deadSopenharmony_ci</div>
108295bd8deadSopenharmony_ci<div class="paragraph">
108305bd8deadSopenharmony_ci<p>For a complete specification of the syntax of expressions, see
108315bd8deadSopenharmony_ci&#8220;<a href="#shading-language-grammar">Shading Language Grammar</a>&#8221;.</p>
108325bd8deadSopenharmony_ci</div>
108335bd8deadSopenharmony_ci</div>
108345bd8deadSopenharmony_ci<div class="sect2">
108355bd8deadSopenharmony_ci<h3 id="vector-and-matrix-operations">5.10. Vector and Matrix Operations</h3>
108365bd8deadSopenharmony_ci<div class="paragraph">
108375bd8deadSopenharmony_ci<p>With a few exceptions, operations are component-wise.
108385bd8deadSopenharmony_ciUsually, when an operator operates on a vector or matrix, it is operating
108395bd8deadSopenharmony_ciindependently on each component of the vector or matrix, in a component-wise
108405bd8deadSopenharmony_cifashion.
108415bd8deadSopenharmony_ciFor example,</p>
108425bd8deadSopenharmony_ci</div>
108435bd8deadSopenharmony_ci<div class="listingblock">
108445bd8deadSopenharmony_ci<div class="content">
108455bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec3 v, u;
108465bd8deadSopenharmony_ci<span class="predefined-type">float</span> f;
108475bd8deadSopenharmony_civ = u + f;</code></pre>
108485bd8deadSopenharmony_ci</div>
108495bd8deadSopenharmony_ci</div>
108505bd8deadSopenharmony_ci<div class="paragraph">
108515bd8deadSopenharmony_ci<p>will be equivalent to</p>
108525bd8deadSopenharmony_ci</div>
108535bd8deadSopenharmony_ci<div class="listingblock">
108545bd8deadSopenharmony_ci<div class="content">
108555bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">v.x = u.x + f;
108565bd8deadSopenharmony_civ.y = u.y + f;
108575bd8deadSopenharmony_civ.z = u.z + f;</code></pre>
108585bd8deadSopenharmony_ci</div>
108595bd8deadSopenharmony_ci</div>
108605bd8deadSopenharmony_ci<div class="paragraph">
108615bd8deadSopenharmony_ci<p>And</p>
108625bd8deadSopenharmony_ci</div>
108635bd8deadSopenharmony_ci<div class="listingblock">
108645bd8deadSopenharmony_ci<div class="content">
108655bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec3 v, u, w;
108665bd8deadSopenharmony_ciw = v + u;</code></pre>
108675bd8deadSopenharmony_ci</div>
108685bd8deadSopenharmony_ci</div>
108695bd8deadSopenharmony_ci<div class="paragraph">
108705bd8deadSopenharmony_ci<p>will be equivalent to</p>
108715bd8deadSopenharmony_ci</div>
108725bd8deadSopenharmony_ci<div class="listingblock">
108735bd8deadSopenharmony_ci<div class="content">
108745bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">w.x = v.x + u.x;
108755bd8deadSopenharmony_ciw.y = v.y + u.y;
108765bd8deadSopenharmony_ciw.z = v.z + u.z;</code></pre>
108775bd8deadSopenharmony_ci</div>
108785bd8deadSopenharmony_ci</div>
108795bd8deadSopenharmony_ci<div class="paragraph">
108805bd8deadSopenharmony_ci<p>and likewise for most operators and all integer and floating-point vector
108815bd8deadSopenharmony_ciand matrix types.
108825bd8deadSopenharmony_ciThe exceptions are matrix multiplied by vector, vector multiplied by matrix,
108835bd8deadSopenharmony_ciand matrix multiplied by matrix.
108845bd8deadSopenharmony_ciThese do not operate component-wise, but rather perform the correct linear
108855bd8deadSopenharmony_cialgebraic multiply.</p>
108865bd8deadSopenharmony_ci</div>
108875bd8deadSopenharmony_ci<div class="listingblock">
108885bd8deadSopenharmony_ci<div class="content">
108895bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec3 v, u;
108905bd8deadSopenharmony_cimat3 m;
108915bd8deadSopenharmony_ciu = v * m;</code></pre>
108925bd8deadSopenharmony_ci</div>
108935bd8deadSopenharmony_ci</div>
108945bd8deadSopenharmony_ci<div class="paragraph">
108955bd8deadSopenharmony_ci<p>is equivalent to</p>
108965bd8deadSopenharmony_ci</div>
108975bd8deadSopenharmony_ci<div class="listingblock">
108985bd8deadSopenharmony_ci<div class="content">
108995bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">u.x = dot(v, m[<span class="integer">0</span>]); <span class="comment">// m[0] is the left column of m</span>
109005bd8deadSopenharmony_ciu.y = dot(v, m[<span class="integer">1</span>]); <span class="comment">// dot(a,b) is the inner (dot) product of a and b</span>
109015bd8deadSopenharmony_ciu.z = dot(v, m[<span class="integer">2</span>]);</code></pre>
109025bd8deadSopenharmony_ci</div>
109035bd8deadSopenharmony_ci</div>
109045bd8deadSopenharmony_ci<div class="paragraph">
109055bd8deadSopenharmony_ci<p>And</p>
109065bd8deadSopenharmony_ci</div>
109075bd8deadSopenharmony_ci<div class="listingblock">
109085bd8deadSopenharmony_ci<div class="content">
109095bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">u = m * v;</code></pre>
109105bd8deadSopenharmony_ci</div>
109115bd8deadSopenharmony_ci</div>
109125bd8deadSopenharmony_ci<div class="paragraph">
109135bd8deadSopenharmony_ci<p>is equivalent to</p>
109145bd8deadSopenharmony_ci</div>
109155bd8deadSopenharmony_ci<div class="listingblock">
109165bd8deadSopenharmony_ci<div class="content">
109175bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">u.x = m[<span class="integer">0</span>].x * v.x + m[<span class="integer">1</span>].x * v.y + m[<span class="integer">2</span>].x * v.z;
109185bd8deadSopenharmony_ciu.y = m[<span class="integer">0</span>].y * v.x + m[<span class="integer">1</span>].y * v.y + m[<span class="integer">2</span>].y * v.z;
109195bd8deadSopenharmony_ciu.z = m[<span class="integer">0</span>].z * v.x + m[<span class="integer">1</span>].z * v.y + m[<span class="integer">2</span>].z * v.z;</code></pre>
109205bd8deadSopenharmony_ci</div>
109215bd8deadSopenharmony_ci</div>
109225bd8deadSopenharmony_ci<div class="paragraph">
109235bd8deadSopenharmony_ci<p>And</p>
109245bd8deadSopenharmony_ci</div>
109255bd8deadSopenharmony_ci<div class="listingblock">
109265bd8deadSopenharmony_ci<div class="content">
109275bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">mat3 m, n, r;
109285bd8deadSopenharmony_cir = m * n;</code></pre>
109295bd8deadSopenharmony_ci</div>
109305bd8deadSopenharmony_ci</div>
109315bd8deadSopenharmony_ci<div class="paragraph">
109325bd8deadSopenharmony_ci<p>is equivalent to</p>
109335bd8deadSopenharmony_ci</div>
109345bd8deadSopenharmony_ci<div class="listingblock">
109355bd8deadSopenharmony_ci<div class="content">
109365bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">r[<span class="integer">0</span>].x = m[<span class="integer">0</span>].x * n[<span class="integer">0</span>].x + m[<span class="integer">1</span>].x * n[<span class="integer">0</span>].y + m[<span class="integer">2</span>].x * n[<span class="integer">0</span>].z;
109375bd8deadSopenharmony_cir[<span class="integer">1</span>].x = m[<span class="integer">0</span>].x * n[<span class="integer">1</span>].x + m[<span class="integer">1</span>].x * n[<span class="integer">1</span>].y + m[<span class="integer">2</span>].x * n[<span class="integer">1</span>].z;
109385bd8deadSopenharmony_cir[<span class="integer">2</span>].x = m[<span class="integer">0</span>].x * n[<span class="integer">2</span>].x + m[<span class="integer">1</span>].x * n[<span class="integer">2</span>].y + m[<span class="integer">2</span>].x * n[<span class="integer">2</span>].z;
109395bd8deadSopenharmony_cir[<span class="integer">0</span>].y = m[<span class="integer">0</span>].y * n[<span class="integer">0</span>].x + m[<span class="integer">1</span>].y * n[<span class="integer">0</span>].y + m[<span class="integer">2</span>].y * n[<span class="integer">0</span>].z;
109405bd8deadSopenharmony_cir[<span class="integer">1</span>].y = m[<span class="integer">0</span>].y * n[<span class="integer">1</span>].x + m[<span class="integer">1</span>].y * n[<span class="integer">1</span>].y + m[<span class="integer">2</span>].y * n[<span class="integer">1</span>].z;
109415bd8deadSopenharmony_cir[<span class="integer">2</span>].y = m[<span class="integer">0</span>].y * n[<span class="integer">2</span>].x + m[<span class="integer">1</span>].y * n[<span class="integer">2</span>].y + m[<span class="integer">2</span>].y * n[<span class="integer">2</span>].z;
109425bd8deadSopenharmony_cir[<span class="integer">0</span>].z = m[<span class="integer">0</span>].z * n[<span class="integer">0</span>].x + m[<span class="integer">1</span>].z * n[<span class="integer">0</span>].y + m[<span class="integer">2</span>].z * n[<span class="integer">0</span>].z;
109435bd8deadSopenharmony_cir[<span class="integer">1</span>].z = m[<span class="integer">0</span>].z * n[<span class="integer">1</span>].x + m[<span class="integer">1</span>].z * n[<span class="integer">1</span>].y + m[<span class="integer">2</span>].z * n[<span class="integer">1</span>].z;
109445bd8deadSopenharmony_cir[<span class="integer">2</span>].z = m[<span class="integer">0</span>].z * n[<span class="integer">2</span>].x + m[<span class="integer">1</span>].z * n[<span class="integer">2</span>].y + m[<span class="integer">2</span>].z * n[<span class="integer">2</span>].z;</code></pre>
109455bd8deadSopenharmony_ci</div>
109465bd8deadSopenharmony_ci</div>
109475bd8deadSopenharmony_ci<div class="paragraph">
109485bd8deadSopenharmony_ci<p>and similarly for other sizes of vectors and matrices.</p>
109495bd8deadSopenharmony_ci</div>
109505bd8deadSopenharmony_ci</div>
109515bd8deadSopenharmony_ci<div class="sect2">
109525bd8deadSopenharmony_ci<h3 id="out-of-bounds-accesses">5.11. Out-of-Bounds Accesses</h3>
109535bd8deadSopenharmony_ci<div class="paragraph">
109545bd8deadSopenharmony_ci<p>In the subsections described above for array, vector, matrix and structure
109555bd8deadSopenharmony_ciaccesses, any out-of-bounds access produced undefined behavior.
109565bd8deadSopenharmony_ciHowever, if robust buffer access is enabled via the API, such
109575bd8deadSopenharmony_ciaccesses will be bound within the memory extent of the active program.
109585bd8deadSopenharmony_ciIt will not be possible to access memory from other programs, and accesses
109595bd8deadSopenharmony_ciwill not result in abnormal program termination.
109605bd8deadSopenharmony_ciOut-of-bounds reads return undefined values, which include values from other
109615bd8deadSopenharmony_civariables of the active program or zero.
109625bd8deadSopenharmony_ciOut-of-bounds writes may be discarded or overwrite other variables of the
109635bd8deadSopenharmony_ciactive program, depending on the value of the computed index and how this
109645bd8deadSopenharmony_cirelates to the extent of the active program&#8217;s memory.
109655bd8deadSopenharmony_ciApplications that require defined behavior for out-of-bounds accesses should
109665bd8deadSopenharmony_cirange check all computed indices before dereferencing an array.</p>
109675bd8deadSopenharmony_ci</div>
109685bd8deadSopenharmony_ci</div>
109695bd8deadSopenharmony_ci<div class="sect2">
109705bd8deadSopenharmony_ci<h3 id="specialization-constant-operations">5.12. Specialization-Constant Operations</h3>
109715bd8deadSopenharmony_ci<div class="paragraph">
109725bd8deadSopenharmony_ci<p>Specialization-constant operations are only available when targeting SPIR-V.</p>
109735bd8deadSopenharmony_ci</div>
109745bd8deadSopenharmony_ci<div class="paragraph">
109755bd8deadSopenharmony_ci<p>Only some operations discussed in this section may be applied to a
109765bd8deadSopenharmony_cispecialization constant and still yield a result that is a specialization
109775bd8deadSopenharmony_ciconstant.
109785bd8deadSopenharmony_ciThe operations that do so are listed below.
109795bd8deadSopenharmony_ciWhen a specialization constant is operated on with one of these operators
109805bd8deadSopenharmony_ciand with another constant or specialization constant, the result is
109815bd8deadSopenharmony_ciimplicitly a specialization constant.</p>
109825bd8deadSopenharmony_ci</div>
109835bd8deadSopenharmony_ci<div class="ulist">
109845bd8deadSopenharmony_ci<ul>
109855bd8deadSopenharmony_ci<li>
109865bd8deadSopenharmony_ci<p><strong>int</strong>(), <strong>uint</strong>(), and <strong>bool</strong>() constructors for type conversions from
109875bd8deadSopenharmony_ciany of the following types to any of the following types:</p>
109885bd8deadSopenharmony_ci<div class="ulist">
109895bd8deadSopenharmony_ci<ul>
109905bd8deadSopenharmony_ci<li>
109915bd8deadSopenharmony_ci<p><strong>int</strong></p>
109925bd8deadSopenharmony_ci</li>
109935bd8deadSopenharmony_ci<li>
109945bd8deadSopenharmony_ci<p><strong>uint</strong></p>
109955bd8deadSopenharmony_ci</li>
109965bd8deadSopenharmony_ci<li>
109975bd8deadSopenharmony_ci<p><strong>bool</strong></p>
109985bd8deadSopenharmony_ci</li>
109995bd8deadSopenharmony_ci</ul>
110005bd8deadSopenharmony_ci</div>
110015bd8deadSopenharmony_ci</li>
110025bd8deadSopenharmony_ci<li>
110035bd8deadSopenharmony_ci<p>vector versions of the above conversion constructors</p>
110045bd8deadSopenharmony_ci</li>
110055bd8deadSopenharmony_ci<li>
110065bd8deadSopenharmony_ci<p>allowed implicit conversions of the above</p>
110075bd8deadSopenharmony_ci</li>
110085bd8deadSopenharmony_ci<li>
110095bd8deadSopenharmony_ci<p>swizzles (e.g. <code>foo.yx</code>)</p>
110105bd8deadSopenharmony_ci</li>
110115bd8deadSopenharmony_ci<li>
110125bd8deadSopenharmony_ci<p>the following when applied to integer or unsigned integer types:</p>
110135bd8deadSopenharmony_ci<div class="ulist">
110145bd8deadSopenharmony_ci<ul>
110155bd8deadSopenharmony_ci<li>
110165bd8deadSopenharmony_ci<p>unary negative (<strong>-</strong>)</p>
110175bd8deadSopenharmony_ci</li>
110185bd8deadSopenharmony_ci<li>
110195bd8deadSopenharmony_ci<p>binary operations (<strong>+</strong>, <strong>-</strong>, <strong>*</strong>, <strong>/</strong>, <strong>%</strong>)</p>
110205bd8deadSopenharmony_ci</li>
110215bd8deadSopenharmony_ci<li>
110225bd8deadSopenharmony_ci<p>shift (<strong>&lt;&lt;</strong>, <strong>&gt;&gt;</strong>)</p>
110235bd8deadSopenharmony_ci</li>
110245bd8deadSopenharmony_ci<li>
110255bd8deadSopenharmony_ci<p>bitwise operations (<strong>&amp;</strong>, <strong>|</strong>, <strong>^</strong>)</p>
110265bd8deadSopenharmony_ci</li>
110275bd8deadSopenharmony_ci</ul>
110285bd8deadSopenharmony_ci</div>
110295bd8deadSopenharmony_ci</li>
110305bd8deadSopenharmony_ci<li>
110315bd8deadSopenharmony_ci<p>the following when applied to integer or unsigned integer scalar types:</p>
110325bd8deadSopenharmony_ci<div class="ulist">
110335bd8deadSopenharmony_ci<ul>
110345bd8deadSopenharmony_ci<li>
110355bd8deadSopenharmony_ci<p>comparison (<strong>==</strong>, <strong>!=</strong>, <strong>&gt;</strong>, <strong>&gt;=</strong>, <strong>&lt;</strong>, <strong>&#8656;</strong>)</p>
110365bd8deadSopenharmony_ci</li>
110375bd8deadSopenharmony_ci</ul>
110385bd8deadSopenharmony_ci</div>
110395bd8deadSopenharmony_ci</li>
110405bd8deadSopenharmony_ci<li>
110415bd8deadSopenharmony_ci<p>The following when applied to the Boolean scalar type:</p>
110425bd8deadSopenharmony_ci<div class="ulist">
110435bd8deadSopenharmony_ci<ul>
110445bd8deadSopenharmony_ci<li>
110455bd8deadSopenharmony_ci<p>not (<strong>!</strong>)</p>
110465bd8deadSopenharmony_ci</li>
110475bd8deadSopenharmony_ci<li>
110485bd8deadSopenharmony_ci<p>logical operations (<strong>&amp;&amp;</strong>, <strong>||</strong>, <strong>^^</strong>)</p>
110495bd8deadSopenharmony_ci</li>
110505bd8deadSopenharmony_ci<li>
110515bd8deadSopenharmony_ci<p>comparison (<strong>==</strong>, <strong>!=</strong>)</p>
110525bd8deadSopenharmony_ci</li>
110535bd8deadSopenharmony_ci</ul>
110545bd8deadSopenharmony_ci</div>
110555bd8deadSopenharmony_ci</li>
110565bd8deadSopenharmony_ci<li>
110575bd8deadSopenharmony_ci<p>the ternary operator (<strong>?:</strong>)</p>
110585bd8deadSopenharmony_ci</li>
110595bd8deadSopenharmony_ci</ul>
110605bd8deadSopenharmony_ci</div>
110615bd8deadSopenharmony_ci</div>
110625bd8deadSopenharmony_ci</div>
110635bd8deadSopenharmony_ci</div>
110645bd8deadSopenharmony_ci<div class="sect1">
110655bd8deadSopenharmony_ci<h2 id="statements-and-structure">6. Statements and Structure</h2>
110665bd8deadSopenharmony_ci<div class="sectionbody">
110675bd8deadSopenharmony_ci<div class="paragraph">
110685bd8deadSopenharmony_ci<p>The fundamental building blocks of the OpenGL Shading Language are:</p>
110695bd8deadSopenharmony_ci</div>
110705bd8deadSopenharmony_ci<div class="ulist">
110715bd8deadSopenharmony_ci<ul>
110725bd8deadSopenharmony_ci<li>
110735bd8deadSopenharmony_ci<p>statements and declarations</p>
110745bd8deadSopenharmony_ci</li>
110755bd8deadSopenharmony_ci<li>
110765bd8deadSopenharmony_ci<p>function definitions</p>
110775bd8deadSopenharmony_ci</li>
110785bd8deadSopenharmony_ci<li>
110795bd8deadSopenharmony_ci<p>selection (<strong>if</strong>-<strong>else</strong> and <strong>switch</strong>-<strong>case</strong>-<strong>default</strong>)</p>
110805bd8deadSopenharmony_ci</li>
110815bd8deadSopenharmony_ci<li>
110825bd8deadSopenharmony_ci<p>iteration (<strong>for</strong>, <strong>while</strong>, and <strong>do</strong>-<strong>while</strong>)</p>
110835bd8deadSopenharmony_ci</li>
110845bd8deadSopenharmony_ci<li>
110855bd8deadSopenharmony_ci<p>jumps (<strong>discard</strong>, <strong>return</strong>, <strong>break</strong>, and <strong>continue</strong>)</p>
110865bd8deadSopenharmony_ci</li>
110875bd8deadSopenharmony_ci</ul>
110885bd8deadSopenharmony_ci</div>
110895bd8deadSopenharmony_ci<div class="paragraph">
110905bd8deadSopenharmony_ci<p>The overall structure of a shader is as follows</p>
110915bd8deadSopenharmony_ci</div>
110925bd8deadSopenharmony_ci<div class="openblock bnf">
110935bd8deadSopenharmony_ci<div class="content">
110945bd8deadSopenharmony_ci<div class="dlist">
110955bd8deadSopenharmony_ci<dl>
110965bd8deadSopenharmony_ci<dt class="hdlist1"><em>translation-unit</em> : </dt>
110975bd8deadSopenharmony_ci<dd>
110985bd8deadSopenharmony_ci<p><em>global-declaration</em><br>
110995bd8deadSopenharmony_ci<em>translation-unit</em> <em>global-declaration</em></p>
111005bd8deadSopenharmony_ci</dd>
111015bd8deadSopenharmony_ci<dt class="hdlist1"><em>global-declaration</em> : </dt>
111025bd8deadSopenharmony_ci<dd>
111035bd8deadSopenharmony_ci<p><em>function-definition</em><br>
111045bd8deadSopenharmony_ci<em>declaration</em></p>
111055bd8deadSopenharmony_ci</dd>
111065bd8deadSopenharmony_ci</dl>
111075bd8deadSopenharmony_ci</div>
111085bd8deadSopenharmony_ci</div>
111095bd8deadSopenharmony_ci</div>
111105bd8deadSopenharmony_ci<div class="paragraph">
111115bd8deadSopenharmony_ci<p>That is, a shader is a sequence of declarations and function bodies.
111125bd8deadSopenharmony_ciFunction bodies are defined as</p>
111135bd8deadSopenharmony_ci</div>
111145bd8deadSopenharmony_ci<div class="openblock bnf">
111155bd8deadSopenharmony_ci<div class="content">
111165bd8deadSopenharmony_ci<div class="dlist">
111175bd8deadSopenharmony_ci<dl>
111185bd8deadSopenharmony_ci<dt class="hdlist1"><em>function-definition</em> : </dt>
111195bd8deadSopenharmony_ci<dd>
111205bd8deadSopenharmony_ci<p><em>function-prototype</em> <strong>{</strong> <em>statement-list</em> <strong>}</strong></p>
111215bd8deadSopenharmony_ci</dd>
111225bd8deadSopenharmony_ci<dt class="hdlist1"><em>statement-list</em> : </dt>
111235bd8deadSopenharmony_ci<dd>
111245bd8deadSopenharmony_ci<p><em>statement</em><br>
111255bd8deadSopenharmony_ci<em>statement-list</em> <em>statement</em></p>
111265bd8deadSopenharmony_ci</dd>
111275bd8deadSopenharmony_ci<dt class="hdlist1"><em>statement</em> : </dt>
111285bd8deadSopenharmony_ci<dd>
111295bd8deadSopenharmony_ci<p><em>compound-statement</em><br>
111305bd8deadSopenharmony_ci<em>simple-statement</em></p>
111315bd8deadSopenharmony_ci</dd>
111325bd8deadSopenharmony_ci</dl>
111335bd8deadSopenharmony_ci</div>
111345bd8deadSopenharmony_ci</div>
111355bd8deadSopenharmony_ci</div>
111365bd8deadSopenharmony_ci<div class="paragraph">
111375bd8deadSopenharmony_ci<p>Curly braces are used to group sequences of statements into compound
111385bd8deadSopenharmony_cistatements.</p>
111395bd8deadSopenharmony_ci</div>
111405bd8deadSopenharmony_ci<div class="openblock bnf">
111415bd8deadSopenharmony_ci<div class="content">
111425bd8deadSopenharmony_ci<div class="dlist">
111435bd8deadSopenharmony_ci<dl>
111445bd8deadSopenharmony_ci<dt class="hdlist1"><em>compound-statement</em> : </dt>
111455bd8deadSopenharmony_ci<dd>
111465bd8deadSopenharmony_ci<p><strong>{</strong> <em>statement-list</em> <strong>}</strong></p>
111475bd8deadSopenharmony_ci</dd>
111485bd8deadSopenharmony_ci<dt class="hdlist1"><em>simple-statement</em> : </dt>
111495bd8deadSopenharmony_ci<dd>
111505bd8deadSopenharmony_ci<p><em>declaration-statement</em><br>
111515bd8deadSopenharmony_ci<em>expression-statement</em><br>
111525bd8deadSopenharmony_ci<em>selection-statement</em><br>
111535bd8deadSopenharmony_ci<em>iteration-statement</em><br>
111545bd8deadSopenharmony_ci<em>jump-statement</em></p>
111555bd8deadSopenharmony_ci</dd>
111565bd8deadSopenharmony_ci</dl>
111575bd8deadSopenharmony_ci</div>
111585bd8deadSopenharmony_ci</div>
111595bd8deadSopenharmony_ci</div>
111605bd8deadSopenharmony_ci<div class="paragraph">
111615bd8deadSopenharmony_ci<p>Simple declaration, expression, and jump statements end in a semi-colon.</p>
111625bd8deadSopenharmony_ci</div>
111635bd8deadSopenharmony_ci<div class="paragraph">
111645bd8deadSopenharmony_ci<p>This above is slightly simplified, and the complete grammar specified in
111655bd8deadSopenharmony_ci&#8220;<a href="#shading-language-grammar">Shading Language Grammar</a>&#8221; should be used as
111665bd8deadSopenharmony_cithe definitive specification.</p>
111675bd8deadSopenharmony_ci</div>
111685bd8deadSopenharmony_ci<div class="paragraph">
111695bd8deadSopenharmony_ci<p>Declarations and expressions have already been discussed.</p>
111705bd8deadSopenharmony_ci</div>
111715bd8deadSopenharmony_ci<div class="sect2">
111725bd8deadSopenharmony_ci<h3 id="function-definitions">6.1. Function Definitions</h3>
111735bd8deadSopenharmony_ci<div class="paragraph">
111745bd8deadSopenharmony_ci<p>As indicated by the grammar above, a valid shader is a sequence of global
111755bd8deadSopenharmony_cideclarations and function definitions.
111765bd8deadSopenharmony_ciA function is declared as the following example shows:</p>
111775bd8deadSopenharmony_ci</div>
111785bd8deadSopenharmony_ci<div class="listingblock">
111795bd8deadSopenharmony_ci<div class="content">
111805bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="comment">// prototype</span>
111815bd8deadSopenharmony_cireturnType functionName (type0 arg0, type1 arg1, ..., typen argn);</code></pre>
111825bd8deadSopenharmony_ci</div>
111835bd8deadSopenharmony_ci</div>
111845bd8deadSopenharmony_ci<div class="paragraph">
111855bd8deadSopenharmony_ci<p>and a function is defined like</p>
111865bd8deadSopenharmony_ci</div>
111875bd8deadSopenharmony_ci<div class="listingblock">
111885bd8deadSopenharmony_ci<div class="content">
111895bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="comment">// definition</span>
111905bd8deadSopenharmony_cireturnType functionName (type0 arg0, type1 arg1, ..., typen argn)
111915bd8deadSopenharmony_ci{
111925bd8deadSopenharmony_ci    <span class="comment">// do some computation</span>
111935bd8deadSopenharmony_ci    <span class="keyword">return</span> returnValue;
111945bd8deadSopenharmony_ci}</code></pre>
111955bd8deadSopenharmony_ci</div>
111965bd8deadSopenharmony_ci</div>
111975bd8deadSopenharmony_ci<div class="paragraph">
111985bd8deadSopenharmony_ci<p>where <em>returnType</em> must be present and cannot be void, or:</p>
111995bd8deadSopenharmony_ci</div>
112005bd8deadSopenharmony_ci<div class="listingblock">
112015bd8deadSopenharmony_ci<div class="content">
112025bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="directive">void</span> functionName (type0 arg0, type1 arg1, ..., typen argn)
112035bd8deadSopenharmony_ci{
112045bd8deadSopenharmony_ci    <span class="comment">// do some computation</span>
112055bd8deadSopenharmony_ci    <span class="keyword">return</span>; <span class="comment">// optional</span>
112065bd8deadSopenharmony_ci}</code></pre>
112075bd8deadSopenharmony_ci</div>
112085bd8deadSopenharmony_ci</div>
112095bd8deadSopenharmony_ci<div class="paragraph">
112105bd8deadSopenharmony_ci<p>If the type of <em>returnValue</em> does not match <em>returnType</em>, there must be an
112115bd8deadSopenharmony_ciimplicit conversion in &#8220;<a href="#implicit-conversions">Implicit Conversions</a>&#8221;
112125bd8deadSopenharmony_cithat converts the type of <em>returnValue</em> to <em>returnType</em>, or a compile-time
112135bd8deadSopenharmony_cierror will result.</p>
112145bd8deadSopenharmony_ci</div>
112155bd8deadSopenharmony_ci<div class="paragraph">
112165bd8deadSopenharmony_ci<p>Each of the <em>typeN</em> must include a type and can optionally include parameter
112175bd8deadSopenharmony_ciqualifiers.
112185bd8deadSopenharmony_ciThe formal argument names (<em>args</em> above) in the declarations are optional
112195bd8deadSopenharmony_cifor both the declaration and definition forms.</p>
112205bd8deadSopenharmony_ci</div>
112215bd8deadSopenharmony_ci<div class="paragraph">
112225bd8deadSopenharmony_ci<p>A function is called by using its name followed by a list of arguments in
112235bd8deadSopenharmony_ciparentheses.</p>
112245bd8deadSopenharmony_ci</div>
112255bd8deadSopenharmony_ci<div class="paragraph">
112265bd8deadSopenharmony_ci<p>Arrays are allowed as arguments and as the return type.
112275bd8deadSopenharmony_ciIn both cases, the array must be
112285bd8deadSopenharmony_ciexplicitly
112295bd8deadSopenharmony_cisized.
112305bd8deadSopenharmony_ciAn array is passed or returned by using just its name, without brackets, and
112315bd8deadSopenharmony_cithe size of the array must match the size specified in the function&#8217;s
112325bd8deadSopenharmony_cideclaration.</p>
112335bd8deadSopenharmony_ci</div>
112345bd8deadSopenharmony_ci<div class="paragraph">
112355bd8deadSopenharmony_ci<p>Structures are also allowed as argument types.
112365bd8deadSopenharmony_ciThe return type can also be a structure.</p>
112375bd8deadSopenharmony_ci</div>
112385bd8deadSopenharmony_ci<div class="paragraph">
112395bd8deadSopenharmony_ci<p>See &#8220;<a href="#shading-language-grammar">Shading Language Grammar</a>&#8221; for the
112405bd8deadSopenharmony_cidefinitive reference on the syntax to declare and define functions.</p>
112415bd8deadSopenharmony_ci</div>
112425bd8deadSopenharmony_ci<div class="paragraph">
112435bd8deadSopenharmony_ci<p>All functions must be either declared with a prototype or defined with a
112445bd8deadSopenharmony_cibody before they are called.
112455bd8deadSopenharmony_ciFor example:</p>
112465bd8deadSopenharmony_ci</div>
112475bd8deadSopenharmony_ci<div class="listingblock">
112485bd8deadSopenharmony_ci<div class="content">
112495bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">float</span> myfunc (<span class="predefined-type">float</span> f,      <span class="comment">// f is an input parameter</span>
112505bd8deadSopenharmony_ci              out <span class="predefined-type">float</span> g); <span class="comment">// g is an output parameter</span></code></pre>
112515bd8deadSopenharmony_ci</div>
112525bd8deadSopenharmony_ci</div>
112535bd8deadSopenharmony_ci<div class="paragraph">
112545bd8deadSopenharmony_ci<p>Functions that return no value must be declared as <strong>void</strong>.
112555bd8deadSopenharmony_ciA <strong>void</strong> function can only use <strong>return</strong> without a return argument, even if
112565bd8deadSopenharmony_cithe return argument has <strong>void</strong> type.
112575bd8deadSopenharmony_ciReturn statements only accept values:</p>
112585bd8deadSopenharmony_ci</div>
112595bd8deadSopenharmony_ci<div class="listingblock">
112605bd8deadSopenharmony_ci<div class="content">
112615bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="directive">void</span> func1() { }
112625bd8deadSopenharmony_ci<span class="directive">void</span> func2() { <span class="keyword">return</span> func1(); } <span class="comment">// illegal return statement</span></code></pre>
112635bd8deadSopenharmony_ci</div>
112645bd8deadSopenharmony_ci</div>
112655bd8deadSopenharmony_ci<div class="paragraph">
112665bd8deadSopenharmony_ci<p>Only a precision qualifier is allowed on the return type of a function.
112675bd8deadSopenharmony_ciFormal parameters can have parameter, precision, and memory qualifiers, but
112685bd8deadSopenharmony_cino other qualifiers.</p>
112695bd8deadSopenharmony_ci</div>
112705bd8deadSopenharmony_ci<div class="paragraph">
112715bd8deadSopenharmony_ci<p>Functions that accept no input arguments need not use <strong>void</strong> in the argument
112725bd8deadSopenharmony_cilist because prototypes (or definitions) are required and therefore there is
112735bd8deadSopenharmony_cino ambiguity when an empty argument list &#8220;( )&#8221; is declared.
112745bd8deadSopenharmony_ciThe idiom &#8220;(<strong>void</strong>)&#8221; as a parameter list is provided for convenience.</p>
112755bd8deadSopenharmony_ci</div>
112765bd8deadSopenharmony_ci<div class="paragraph">
112775bd8deadSopenharmony_ci<p>Function names can be overloaded.
112785bd8deadSopenharmony_ciThe same function name can be used for multiple functions, as long as the
112795bd8deadSopenharmony_ciparameter types differ.
112805bd8deadSopenharmony_ciIf a function name is declared twice with the same parameter types, then the
112815bd8deadSopenharmony_cireturn types and all qualifiers must also match, and it is the same function
112825bd8deadSopenharmony_cibeing declared.</p>
112835bd8deadSopenharmony_ci</div>
112845bd8deadSopenharmony_ci<div class="paragraph">
112855bd8deadSopenharmony_ci<p>For example,</p>
112865bd8deadSopenharmony_ci</div>
112875bd8deadSopenharmony_ci<div class="listingblock">
112885bd8deadSopenharmony_ci<div class="content">
112895bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec4 f(in vec4 x, out vec4 y);       <span class="comment">// (A)</span>
112905bd8deadSopenharmony_civec4 f(in vec4 x, out uvec4 y);      <span class="comment">// (B) okay, different argument type</span>
112915bd8deadSopenharmony_civec4 f(in ivec4 x, out dvec4 y);     <span class="comment">// (C) okay, different argument type</span>
112925bd8deadSopenharmony_ci<span class="predefined-type">int</span> f(in vec4 x, out vec4 y);        <span class="comment">// error, only return type differs</span>
112935bd8deadSopenharmony_civec4 f(in vec4 x, in vec4 y);        <span class="comment">// error, only qualifier differs</span>
112945bd8deadSopenharmony_civec4 f(<span class="directive">const</span> in vec4 x, out vec4 y); <span class="comment">// error, only qualifier differs</span></code></pre>
112955bd8deadSopenharmony_ci</div>
112965bd8deadSopenharmony_ci</div>
112975bd8deadSopenharmony_ci<div class="paragraph">
112985bd8deadSopenharmony_ci<p>When function calls are resolved, an exact type match for all the arguments
112995bd8deadSopenharmony_ciis sought.
113005bd8deadSopenharmony_ciIf an exact match is found, all other functions are ignored, and the exact
113015bd8deadSopenharmony_cimatch is used.
113025bd8deadSopenharmony_ciIf no exact match is found, then the implicit conversions in section
113035bd8deadSopenharmony_ci&#8220;<a href="#implicit-conversions">Implicit Conversions</a>&#8221; will be applied to find a
113045bd8deadSopenharmony_cimatch.
113055bd8deadSopenharmony_ciMismatched types on input parameters (<strong>in</strong> or <strong>inout</strong> or default) <strong>must</strong>
113065bd8deadSopenharmony_cihave a conversion from the calling argument type to the formal parameter
113075bd8deadSopenharmony_citype.
113085bd8deadSopenharmony_ciMismatched types on output parameters (<strong>out</strong> or <strong>inout</strong>) must have a
113095bd8deadSopenharmony_ciconversion from the formal parameter type to the calling argument type.</p>
113105bd8deadSopenharmony_ci</div>
113115bd8deadSopenharmony_ci<div class="paragraph">
113125bd8deadSopenharmony_ci<p>If implicit conversions can be used to find more than one matching function,
113135bd8deadSopenharmony_cia single best-matching function is sought.
113145bd8deadSopenharmony_ciTo determine a best match, the conversions between calling argument and
113155bd8deadSopenharmony_ciformal parameter types are compared for each function argument and pair of
113165bd8deadSopenharmony_cimatching functions.
113175bd8deadSopenharmony_ciAfter these comparisons are performed, each pair of matching functions are
113185bd8deadSopenharmony_cicompared.
113195bd8deadSopenharmony_ciA function declaration <em>A</em> is considered a better match than function
113205bd8deadSopenharmony_cideclaration <em>B</em> if</p>
113215bd8deadSopenharmony_ci</div>
113225bd8deadSopenharmony_ci<div class="ulist">
113235bd8deadSopenharmony_ci<ul>
113245bd8deadSopenharmony_ci<li>
113255bd8deadSopenharmony_ci<p>for at least one function argument, the conversion for that argument in
113265bd8deadSopenharmony_ci<em>A</em> is better than the corresponding conversion in <em>B</em>; and</p>
113275bd8deadSopenharmony_ci</li>
113285bd8deadSopenharmony_ci<li>
113295bd8deadSopenharmony_ci<p>there is no function argument for which the conversion in <em>B</em> is better
113305bd8deadSopenharmony_cithan the corresponding conversion in <em>A</em>.</p>
113315bd8deadSopenharmony_ci</li>
113325bd8deadSopenharmony_ci</ul>
113335bd8deadSopenharmony_ci</div>
113345bd8deadSopenharmony_ci<div class="paragraph">
113355bd8deadSopenharmony_ci<p>If a single function declaration is considered a better match than every
113365bd8deadSopenharmony_ciother matching function declaration, it will be used.
113375bd8deadSopenharmony_ciOtherwise, a compile-time semantic error for an ambiguous overloaded
113385bd8deadSopenharmony_cifunction call occurs.</p>
113395bd8deadSopenharmony_ci</div>
113405bd8deadSopenharmony_ci<div class="paragraph">
113415bd8deadSopenharmony_ci<p>To determine whether the conversion for a single argument in one match is
113425bd8deadSopenharmony_cibetter than that for another match, the following rules are applied, in
113435bd8deadSopenharmony_ciorder:</p>
113445bd8deadSopenharmony_ci</div>
113455bd8deadSopenharmony_ci<div class="olist arabic">
113465bd8deadSopenharmony_ci<ol class="arabic">
113475bd8deadSopenharmony_ci<li>
113485bd8deadSopenharmony_ci<p>An exact match is better than a match involving any implicit conversion.</p>
113495bd8deadSopenharmony_ci</li>
113505bd8deadSopenharmony_ci<li>
113515bd8deadSopenharmony_ci<p>A match involving an implicit conversion from <strong>float</strong> to <strong>double</strong> is
113525bd8deadSopenharmony_cibetter than a match involving any other implicit conversion.</p>
113535bd8deadSopenharmony_ci</li>
113545bd8deadSopenharmony_ci<li>
113555bd8deadSopenharmony_ci<p>A match involving an implicit conversion from either <strong>int</strong> or <strong>uint</strong> to
113565bd8deadSopenharmony_ci<strong>float</strong> is better than a match involving an implicit conversion from
113575bd8deadSopenharmony_cieither <strong>int</strong> or <strong>uint</strong> to <strong>double</strong>.</p>
113585bd8deadSopenharmony_ci</li>
113595bd8deadSopenharmony_ci</ol>
113605bd8deadSopenharmony_ci</div>
113615bd8deadSopenharmony_ci<div class="paragraph">
113625bd8deadSopenharmony_ci<p>If none of the rules above apply to a particular pair of conversions,
113635bd8deadSopenharmony_cineither conversion is considered better than the other.</p>
113645bd8deadSopenharmony_ci</div>
113655bd8deadSopenharmony_ci<div class="paragraph">
113665bd8deadSopenharmony_ci<p>For the example function prototypes (A), (B), and &#169; above, the following
113675bd8deadSopenharmony_ciexamples show how the rules apply to different sets of calling argument
113685bd8deadSopenharmony_citypes:</p>
113695bd8deadSopenharmony_ci</div>
113705bd8deadSopenharmony_ci<div class="listingblock">
113715bd8deadSopenharmony_ci<div class="content">
113725bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">f(vec4, vec4)   <span class="comment">// exact match of vec4 f(in vec4 x, out vec4 y)</span>
113735bd8deadSopenharmony_cif(vec4, uvec4)  <span class="comment">// exact match of vec4 f(in vec4 x, out uvec4 y)</span>
113745bd8deadSopenharmony_cif(vec4, ivec4)  <span class="comment">// matched to vec4 f(in vec4 x, out vec4 y)</span>
113755bd8deadSopenharmony_ci                <span class="comment">// (C) not relevant, can't convert vec4 to</span>
113765bd8deadSopenharmony_ci                <span class="comment">// ivec4. (A) better than (B) for 2nd</span>
113775bd8deadSopenharmony_ci                <span class="comment">// argument (rule 3), same on first argument.</span>
113785bd8deadSopenharmony_cif(ivec4, vec4); <span class="comment">// NOT matched. All three match by implicit</span>
113795bd8deadSopenharmony_ci                <span class="comment">// conversion. (C) is better than (A) and (B)</span>
113805bd8deadSopenharmony_ci                <span class="comment">// on the first argument. (A) is better than</span>
113815bd8deadSopenharmony_ci                <span class="comment">// (B) and (C).</span></code></pre>
113825bd8deadSopenharmony_ci</div>
113835bd8deadSopenharmony_ci</div>
113845bd8deadSopenharmony_ci<div class="paragraph">
113855bd8deadSopenharmony_ci<p>User-defined functions can have multiple declarations, but only one
113865bd8deadSopenharmony_cidefinition.</p>
113875bd8deadSopenharmony_ci</div>
113885bd8deadSopenharmony_ci<div class="paragraph">
113895bd8deadSopenharmony_ci<p>A shader can redefine built-in functions.
113905bd8deadSopenharmony_ciIf a built-in function is redeclared in a shader (i.e., a prototype is
113915bd8deadSopenharmony_civisible) before a call to it, then the linker will only attempt to resolve
113925bd8deadSopenharmony_cithat call within the set of shaders that are linked with it.</p>
113935bd8deadSopenharmony_ci</div>
113945bd8deadSopenharmony_ci<div class="paragraph">
113955bd8deadSopenharmony_ci<p>The function <em>main</em> is used as the entry point to a shader executable.
113965bd8deadSopenharmony_ciA shader need not contain a function named <em>main</em>, but one shader in a set
113975bd8deadSopenharmony_ciof shaders linked together to form a single shader executable must, or a
113985bd8deadSopenharmony_cilink-time error results.
113995bd8deadSopenharmony_ciThis function takes no arguments, returns no value, and must be declared as
114005bd8deadSopenharmony_citype <strong>void</strong>:</p>
114015bd8deadSopenharmony_ci</div>
114025bd8deadSopenharmony_ci<div class="listingblock">
114035bd8deadSopenharmony_ci<div class="content">
114045bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="directive">void</span> main()
114055bd8deadSopenharmony_ci{
114065bd8deadSopenharmony_ci    ...
114075bd8deadSopenharmony_ci}</code></pre>
114085bd8deadSopenharmony_ci</div>
114095bd8deadSopenharmony_ci</div>
114105bd8deadSopenharmony_ci<div class="paragraph">
114115bd8deadSopenharmony_ci<p>The function <em>main</em> can contain uses of <strong>return</strong>.
114125bd8deadSopenharmony_ciSee &#8220;<a href="#jumps">Jumps</a>&#8221; for more details.</p>
114135bd8deadSopenharmony_ci</div>
114145bd8deadSopenharmony_ci<div class="paragraph">
114155bd8deadSopenharmony_ci<p>It is a compile-time or link-time error to declare or define a function
114165bd8deadSopenharmony_ci<strong>main</strong> with any other parameters or return type.</p>
114175bd8deadSopenharmony_ci</div>
114185bd8deadSopenharmony_ci<div class="sect3">
114195bd8deadSopenharmony_ci<h4 id="function-calling-conventions">6.1.1. Function Calling Conventions</h4>
114205bd8deadSopenharmony_ci<div class="paragraph">
114215bd8deadSopenharmony_ci<p>Functions are called by value-return.
114225bd8deadSopenharmony_ciThis means input arguments are copied into the function at call time, and
114235bd8deadSopenharmony_cioutput arguments are copied back to the caller before function exit.
114245bd8deadSopenharmony_ciBecause the function works with local copies of parameters, there are no
114255bd8deadSopenharmony_ciissues regarding aliasing of variables within a function.
114265bd8deadSopenharmony_ciTo control what parameters are copied in and/or out through a function
114275bd8deadSopenharmony_cidefinition or declaration:</p>
114285bd8deadSopenharmony_ci</div>
114295bd8deadSopenharmony_ci<div class="ulist">
114305bd8deadSopenharmony_ci<ul>
114315bd8deadSopenharmony_ci<li>
114325bd8deadSopenharmony_ci<p>The keyword <strong>in</strong> is used as a qualifier to denote a parameter is to be
114335bd8deadSopenharmony_cicopied in, but not copied out.</p>
114345bd8deadSopenharmony_ci</li>
114355bd8deadSopenharmony_ci<li>
114365bd8deadSopenharmony_ci<p>The keyword <strong>out</strong> is used as a qualifier to denote a parameter is to be
114375bd8deadSopenharmony_cicopied out, but not copied in.
114385bd8deadSopenharmony_ciThis should be used whenever possible to avoid unnecessarily copying
114395bd8deadSopenharmony_ciparameters in.</p>
114405bd8deadSopenharmony_ci</li>
114415bd8deadSopenharmony_ci<li>
114425bd8deadSopenharmony_ci<p>The keyword <strong>inout</strong> is used as a qualifier to denote the parameter is to
114435bd8deadSopenharmony_cibe both copied in and copied out.
114445bd8deadSopenharmony_ciIt means the same thing as specifying both <strong>in</strong> and <strong>out</strong>.</p>
114455bd8deadSopenharmony_ci</li>
114465bd8deadSopenharmony_ci<li>
114475bd8deadSopenharmony_ci<p>A function parameter declared with no such qualifier means the same
114485bd8deadSopenharmony_cithing as specifying <strong>in</strong>.</p>
114495bd8deadSopenharmony_ci</li>
114505bd8deadSopenharmony_ci</ul>
114515bd8deadSopenharmony_ci</div>
114525bd8deadSopenharmony_ci<div class="paragraph">
114535bd8deadSopenharmony_ci<p>All arguments are evaluated at call time, exactly once, in order, from left
114545bd8deadSopenharmony_cito right.
114555bd8deadSopenharmony_ciEvaluation of an <strong>in</strong> parameter results in a value that is copied to the
114565bd8deadSopenharmony_ciformal parameter.
114575bd8deadSopenharmony_ciEvaluation of an <strong>out</strong> parameter results in an l-value that is used to copy
114585bd8deadSopenharmony_ciout a value when the function returns.
114595bd8deadSopenharmony_ciEvaluation of an <strong>inout</strong> parameter results in both a value and an l-value;
114605bd8deadSopenharmony_cithe value is copied to the formal parameter at call time and the l-value is
114615bd8deadSopenharmony_ciused to copy out a value when the function returns.</p>
114625bd8deadSopenharmony_ci</div>
114635bd8deadSopenharmony_ci<div class="paragraph">
114645bd8deadSopenharmony_ci<p>The order in which output parameters are copied back to the caller is
114655bd8deadSopenharmony_ciundefined.</p>
114665bd8deadSopenharmony_ci</div>
114675bd8deadSopenharmony_ci<div class="paragraph">
114685bd8deadSopenharmony_ci<p>If the function matching described in the previous section required argument
114695bd8deadSopenharmony_citype conversions, these conversions are applied at copy-in and copy-out
114705bd8deadSopenharmony_citimes.</p>
114715bd8deadSopenharmony_ci</div>
114725bd8deadSopenharmony_ci<div class="paragraph">
114735bd8deadSopenharmony_ci<p>In a function, writing to an input-only parameter is allowed.
114745bd8deadSopenharmony_ciOnly the function&#8217;s copy is modified.
114755bd8deadSopenharmony_ciThis can be prevented by declaring a parameter with the <strong>const</strong> qualifier.</p>
114765bd8deadSopenharmony_ci</div>
114775bd8deadSopenharmony_ci<div class="paragraph">
114785bd8deadSopenharmony_ci<p>When calling a function, expressions that do not evaluate to l-values cannot
114795bd8deadSopenharmony_cibe passed to parameters declared as <strong>out</strong> or <strong>inout</strong>, or a compile-time error
114805bd8deadSopenharmony_ciresults.</p>
114815bd8deadSopenharmony_ci</div>
114825bd8deadSopenharmony_ci<div class="openblock bnf">
114835bd8deadSopenharmony_ci<div class="content">
114845bd8deadSopenharmony_ci<div class="dlist">
114855bd8deadSopenharmony_ci<dl>
114865bd8deadSopenharmony_ci<dt class="hdlist1"><em>function-prototype</em> : </dt>
114875bd8deadSopenharmony_ci<dd>
114885bd8deadSopenharmony_ci<p><em>precision-qualifier</em> <em>type</em> <em>function-name</em> <strong>(</strong> <em>parameter-qualifiers</em>
114895bd8deadSopenharmony_ci<em>precision-qualifier</em> <em>type</em> <em>name</em> <em>array-specifier</em> <strong>,</strong> &#8230;&#8203;
114905bd8deadSopenharmony_ci<strong>)</strong></p>
114915bd8deadSopenharmony_ci</dd>
114925bd8deadSopenharmony_ci<dt class="hdlist1"><em>type</em> : </dt>
114935bd8deadSopenharmony_ci<dd>
114945bd8deadSopenharmony_ci<p>any basic type, array type, structure name, or structure definition</p>
114955bd8deadSopenharmony_ci</dd>
114965bd8deadSopenharmony_ci<dt class="hdlist1"><em>parameter-qualifiers</em> : </dt>
114975bd8deadSopenharmony_ci<dd>
114985bd8deadSopenharmony_ci<p><em>empty</em><br>
114995bd8deadSopenharmony_cilist of <em>parameter-qualifier</em></p>
115005bd8deadSopenharmony_ci</dd>
115015bd8deadSopenharmony_ci<dt class="hdlist1"><em>parameter-qualifier</em> : </dt>
115025bd8deadSopenharmony_ci<dd>
115035bd8deadSopenharmony_ci<p><strong>const</strong><br>
115045bd8deadSopenharmony_ci<strong>in</strong><br>
115055bd8deadSopenharmony_ci<strong>out</strong><br>
115065bd8deadSopenharmony_ci<strong>inout</strong><br>
115075bd8deadSopenharmony_ci<strong>precise</strong><br>
115085bd8deadSopenharmony_ci<em>memory-qualifier</em><br>
115095bd8deadSopenharmony_ci<em>precision-qualifier</em></p>
115105bd8deadSopenharmony_ci</dd>
115115bd8deadSopenharmony_ci<dt class="hdlist1"><em>name</em> : </dt>
115125bd8deadSopenharmony_ci<dd>
115135bd8deadSopenharmony_ci<p>empty<br>
115145bd8deadSopenharmony_ciidentifier</p>
115155bd8deadSopenharmony_ci</dd>
115165bd8deadSopenharmony_ci<dt class="hdlist1"><em>array-specifier</em> : </dt>
115175bd8deadSopenharmony_ci<dd>
115185bd8deadSopenharmony_ci<p>empty<br>
115195bd8deadSopenharmony_ci<strong>[</strong> <em>integral-constant-expression</em> <strong>]</strong></p>
115205bd8deadSopenharmony_ci</dd>
115215bd8deadSopenharmony_ci</dl>
115225bd8deadSopenharmony_ci</div>
115235bd8deadSopenharmony_ci</div>
115245bd8deadSopenharmony_ci</div>
115255bd8deadSopenharmony_ci<div class="paragraph">
115265bd8deadSopenharmony_ci<p>The <strong>const</strong> qualifier cannot be used with <strong>out</strong> or <strong>inout</strong>, or
115275bd8deadSopenharmony_cia compile-time error results.
115285bd8deadSopenharmony_ciThe above is used both for function declarations (i.e., prototypes) and for
115295bd8deadSopenharmony_cifunction definitions.
115305bd8deadSopenharmony_ciHence, function definitions can have unnamed arguments.</p>
115315bd8deadSopenharmony_ci</div>
115325bd8deadSopenharmony_ci<div class="paragraph">
115335bd8deadSopenharmony_ci<p>Recursion is not allowed, not even statically.
115345bd8deadSopenharmony_ciStatic recursion is present if the static function-call graph of a program
115355bd8deadSopenharmony_cicontains cycles.
115365bd8deadSopenharmony_ciThis includes all potential function calls through variables declared as
115375bd8deadSopenharmony_ci<strong>subroutine</strong> <strong>uniform</strong> (described below).
115385bd8deadSopenharmony_ciIt is a compile-time or link-time error if a single compilation unit
115395bd8deadSopenharmony_ci(shader) contains either static recursion or the potential for recursion
115405bd8deadSopenharmony_cithrough subroutine variables.</p>
115415bd8deadSopenharmony_ci</div>
115425bd8deadSopenharmony_ci</div>
115435bd8deadSopenharmony_ci<div class="sect3">
115445bd8deadSopenharmony_ci<h4 id="subroutines">6.1.2. Subroutines</h4>
115455bd8deadSopenharmony_ci<div class="paragraph">
115465bd8deadSopenharmony_ci<p>Subroutines provide a mechanism allowing shaders to be compiled in a manner
115475bd8deadSopenharmony_ciwhere the target of one or more function calls can be changed at run-time
115485bd8deadSopenharmony_ciwithout requiring any shader recompilation.
115495bd8deadSopenharmony_ciFor example, a single shader may be compiled with support for multiple
115505bd8deadSopenharmony_ciillumination algorithms to handle different kinds of lights or surface
115515bd8deadSopenharmony_cimaterials.
115525bd8deadSopenharmony_ciAn application using such a shader may switch illumination algorithms by
115535bd8deadSopenharmony_cichanging the value of its subroutine uniforms.
115545bd8deadSopenharmony_ciTo use subroutines, a subroutine type is declared, one or more functions are
115555bd8deadSopenharmony_ciassociated with that subroutine type, and a subroutine variable of that type
115565bd8deadSopenharmony_ciis declared.
115575bd8deadSopenharmony_ciThe function currently assigned to the variable function is then called by
115585bd8deadSopenharmony_ciusing function calling syntax replacing a function name with the name of the
115595bd8deadSopenharmony_cisubroutine variable.
115605bd8deadSopenharmony_ciSubroutine variables are uniforms, and are assigned to specific functions
115615bd8deadSopenharmony_cionly through commands (<strong>UniformSubroutinesuiv</strong>) in the OpenGL API.</p>
115625bd8deadSopenharmony_ci</div>
115635bd8deadSopenharmony_ci<div class="paragraph">
115645bd8deadSopenharmony_ci<p>Subroutine functionality is not available when generating SPIR-V.</p>
115655bd8deadSopenharmony_ci</div>
115665bd8deadSopenharmony_ci<div class="paragraph">
115675bd8deadSopenharmony_ci<p>Subroutine types are declared using a statement similar to a function
115685bd8deadSopenharmony_cideclaration, with the <strong>subroutine</strong> keyword, as follows:</p>
115695bd8deadSopenharmony_ci</div>
115705bd8deadSopenharmony_ci<div class="listingblock">
115715bd8deadSopenharmony_ci<div class="content">
115725bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">subroutine returnType subroutineTypeName(type0 arg0, type1 arg1,
115735bd8deadSopenharmony_ci                                         ..., typen argn);</code></pre>
115745bd8deadSopenharmony_ci</div>
115755bd8deadSopenharmony_ci</div>
115765bd8deadSopenharmony_ci<div class="paragraph">
115775bd8deadSopenharmony_ci<p>As with function declarations, the formal argument names (<em>args</em> above) are
115785bd8deadSopenharmony_cioptional.
115795bd8deadSopenharmony_ciFunctions are associated with subroutine types of matching declarations by
115805bd8deadSopenharmony_cidefining the function with the <strong>subroutine</strong> keyword and a list of subroutine
115815bd8deadSopenharmony_citypes the function matches:</p>
115825bd8deadSopenharmony_ci</div>
115835bd8deadSopenharmony_ci<div class="listingblock">
115845bd8deadSopenharmony_ci<div class="content">
115855bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">subroutine(subroutineTypeName0, ..., subroutineTypeNameN)
115865bd8deadSopenharmony_cireturnType functionName(type0 arg0, type1 arg1, ..., typen argn)
115875bd8deadSopenharmony_ci{ ... } <span class="comment">// function body</span></code></pre>
115885bd8deadSopenharmony_ci</div>
115895bd8deadSopenharmony_ci</div>
115905bd8deadSopenharmony_ci<div class="paragraph">
115915bd8deadSopenharmony_ci<p>It is a compile-time error if arguments and return type don&#8217;t match between
115925bd8deadSopenharmony_cithe function and each associated subroutine type.</p>
115935bd8deadSopenharmony_ci</div>
115945bd8deadSopenharmony_ci<div class="paragraph">
115955bd8deadSopenharmony_ci<p>Functions declared with <strong>subroutine</strong> must include a body.
115965bd8deadSopenharmony_ciAn overloaded function cannot be declared with <strong>subroutine</strong>; a program will
115975bd8deadSopenharmony_cifail to compile or link if any shader or stage contains two or more
115985bd8deadSopenharmony_cifunctions with the same name if the name is associated with a subroutine
115995bd8deadSopenharmony_citype.</p>
116005bd8deadSopenharmony_ci</div>
116015bd8deadSopenharmony_ci<div class="paragraph">
116025bd8deadSopenharmony_ci<p>A function declared with <strong>subroutine</strong> can also be called directly with a
116035bd8deadSopenharmony_cistatic use of <em>functionName</em>, as is done with non-subroutine function
116045bd8deadSopenharmony_cideclarations and calls.</p>
116055bd8deadSopenharmony_ci</div>
116065bd8deadSopenharmony_ci<div class="paragraph">
116075bd8deadSopenharmony_ci<p>Subroutine type variables are required to be <em>subroutine uniforms</em>, and are
116085bd8deadSopenharmony_cideclared with a specific subroutine type in a subroutine uniform variable
116095bd8deadSopenharmony_cideclaration:</p>
116105bd8deadSopenharmony_ci</div>
116115bd8deadSopenharmony_ci<div class="listingblock">
116125bd8deadSopenharmony_ci<div class="content">
116135bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">subroutine uniform subroutineTypeName subroutineVarName;</code></pre>
116145bd8deadSopenharmony_ci</div>
116155bd8deadSopenharmony_ci</div>
116165bd8deadSopenharmony_ci<div class="paragraph">
116175bd8deadSopenharmony_ci<p>Subroutine uniform variables are called the same way functions are called.
116185bd8deadSopenharmony_ciWhen a subroutine variable (or an element of a subroutine variable array) is
116195bd8deadSopenharmony_ciassociated with a particular function, all function calls through that
116205bd8deadSopenharmony_civariable will call that particular function.</p>
116215bd8deadSopenharmony_ci</div>
116225bd8deadSopenharmony_ci<div class="paragraph">
116235bd8deadSopenharmony_ci<p>Unlike other uniform variables, subroutine uniform variables are scoped to
116245bd8deadSopenharmony_cithe shader execution stage the variable is declared in.</p>
116255bd8deadSopenharmony_ci</div>
116265bd8deadSopenharmony_ci<div class="paragraph">
116275bd8deadSopenharmony_ci<p>Subroutine variables may be declared as explicitly-sized arrays, which can
116285bd8deadSopenharmony_cibe indexed only with dynamically uniform expressions.</p>
116295bd8deadSopenharmony_ci</div>
116305bd8deadSopenharmony_ci<div class="paragraph">
116315bd8deadSopenharmony_ci<p>It is a compile-time error to use the <strong>subroutine</strong> keyword in any places
116325bd8deadSopenharmony_ciother than (as shown above) to</p>
116335bd8deadSopenharmony_ci</div>
116345bd8deadSopenharmony_ci<div class="ulist">
116355bd8deadSopenharmony_ci<ul>
116365bd8deadSopenharmony_ci<li>
116375bd8deadSopenharmony_ci<p>declare a subroutine type at global scope,</p>
116385bd8deadSopenharmony_ci</li>
116395bd8deadSopenharmony_ci<li>
116405bd8deadSopenharmony_ci<p>declare a function as a subroutine, or</p>
116415bd8deadSopenharmony_ci</li>
116425bd8deadSopenharmony_ci<li>
116435bd8deadSopenharmony_ci<p>declare a subroutine variable at global scope.</p>
116445bd8deadSopenharmony_ci</li>
116455bd8deadSopenharmony_ci</ul>
116465bd8deadSopenharmony_ci</div>
116475bd8deadSopenharmony_ci</div>
116485bd8deadSopenharmony_ci</div>
116495bd8deadSopenharmony_ci<div class="sect2">
116505bd8deadSopenharmony_ci<h3 id="selection">6.2. Selection</h3>
116515bd8deadSopenharmony_ci<div class="paragraph">
116525bd8deadSopenharmony_ci<p>Conditional control flow in the shading language is done by either <strong>if</strong>,
116535bd8deadSopenharmony_ci<strong>if</strong>-<strong>else</strong>, or <strong>switch</strong> statements:</p>
116545bd8deadSopenharmony_ci</div>
116555bd8deadSopenharmony_ci<div class="openblock bnf">
116565bd8deadSopenharmony_ci<div class="content">
116575bd8deadSopenharmony_ci<div class="dlist">
116585bd8deadSopenharmony_ci<dl>
116595bd8deadSopenharmony_ci<dt class="hdlist1"><em>selection-statement</em> : </dt>
116605bd8deadSopenharmony_ci<dd>
116615bd8deadSopenharmony_ci<p><strong>if</strong> <strong>(</strong> <em>bool-expression</em> <strong>)</strong> <em>statement</em><br>
116625bd8deadSopenharmony_ci<strong>if</strong> <strong>(</strong> <em>bool-expression</em> <strong>)</strong> <em>statement</em> <strong>else</strong> <em>statement</em><br>
116635bd8deadSopenharmony_ci<strong>switch</strong> <strong>(</strong> <em>init-expression</em> <strong>)</strong> <strong>{</strong> <em>switch-statement-list<sub>opt</sub></em> <strong>}</strong></p>
116645bd8deadSopenharmony_ci</dd>
116655bd8deadSopenharmony_ci</dl>
116665bd8deadSopenharmony_ci</div>
116675bd8deadSopenharmony_ci</div>
116685bd8deadSopenharmony_ci</div>
116695bd8deadSopenharmony_ci<div class="paragraph">
116705bd8deadSopenharmony_ci<p>Where <em>switch-statement-list</em> is a nested scope containing a list of zero or
116715bd8deadSopenharmony_cimore <em>switch-statement</em> and other statements defined by the language, where
116725bd8deadSopenharmony_ci<em>switch-statement</em> adds some forms of labels.
116735bd8deadSopenharmony_ciThat is</p>
116745bd8deadSopenharmony_ci</div>
116755bd8deadSopenharmony_ci<div class="openblock bnf">
116765bd8deadSopenharmony_ci<div class="content">
116775bd8deadSopenharmony_ci<div class="dlist">
116785bd8deadSopenharmony_ci<dl>
116795bd8deadSopenharmony_ci<dt class="hdlist1"><em>switch-statement-list</em> : </dt>
116805bd8deadSopenharmony_ci<dd>
116815bd8deadSopenharmony_ci<p><em>switch-statement</em><br>
116825bd8deadSopenharmony_ci<em>switch-statement-list</em> <em>switch-statement</em></p>
116835bd8deadSopenharmony_ci</dd>
116845bd8deadSopenharmony_ci<dt class="hdlist1"><em>switch-statement</em> : </dt>
116855bd8deadSopenharmony_ci<dd>
116865bd8deadSopenharmony_ci<p><strong>case</strong> <em>constant-expression</em> <strong>:</strong><br>
116875bd8deadSopenharmony_ci<strong>default</strong> <strong>:</strong> <em>statement</em></p>
116885bd8deadSopenharmony_ci</dd>
116895bd8deadSopenharmony_ci</dl>
116905bd8deadSopenharmony_ci</div>
116915bd8deadSopenharmony_ci</div>
116925bd8deadSopenharmony_ci</div>
116935bd8deadSopenharmony_ci<div class="paragraph">
116945bd8deadSopenharmony_ci<p>Note the above grammar&#8217;s purpose is to aid discussion in this section; the
116955bd8deadSopenharmony_cinormative grammar is in &#8220;<a href="#shading-language-grammar">Shading Language
116965bd8deadSopenharmony_ciGrammar</a>&#8221;.</p>
116975bd8deadSopenharmony_ci</div>
116985bd8deadSopenharmony_ci<div class="paragraph">
116995bd8deadSopenharmony_ci<p>If an <strong>if</strong>-expression evaluates to <strong>true</strong>, then the first <em>statement</em> is
117005bd8deadSopenharmony_ciexecuted.
117015bd8deadSopenharmony_ciIf it evaluates to <strong>false</strong> and there is an <strong>else</strong> part then the second
117025bd8deadSopenharmony_ci<em>statement</em> is executed.</p>
117035bd8deadSopenharmony_ci</div>
117045bd8deadSopenharmony_ci<div class="paragraph">
117055bd8deadSopenharmony_ci<p>Any expression whose type evaluates to a Boolean can be used as the
117065bd8deadSopenharmony_ciconditional expression <em>bool-expression</em>.
117075bd8deadSopenharmony_ciVector types are not accepted as the expression to <strong>if</strong>.</p>
117085bd8deadSopenharmony_ci</div>
117095bd8deadSopenharmony_ci<div class="paragraph">
117105bd8deadSopenharmony_ci<p>Conditionals can be nested.</p>
117115bd8deadSopenharmony_ci</div>
117125bd8deadSopenharmony_ci<div class="paragraph">
117135bd8deadSopenharmony_ci<p>The type of <em>init-expression</em> in a <strong>switch</strong> statement must be a scalar
117145bd8deadSopenharmony_ciinteger.
117155bd8deadSopenharmony_ciThe type of the <em>constant-expression</em> value in a case label also must be a
117165bd8deadSopenharmony_ciscalar integer.
117175bd8deadSopenharmony_ciWhen any pair of these values is tested for &#8220;equal value&#8221; and the types do
117185bd8deadSopenharmony_cinot match, an implicit conversion will be done to convert the <strong>int</strong> to a
117195bd8deadSopenharmony_ci<strong>uint</strong> (see &#8220;<a href="#implicit-conversions">Implicit Conversions</a>&#8221;) before the
117205bd8deadSopenharmony_cicompare is done.
117215bd8deadSopenharmony_ciIf a <strong>case</strong> label has a <em>constant-expression</em> of equal value to
117225bd8deadSopenharmony_ci<em>init-expression</em>, execution will continue after that label.
117235bd8deadSopenharmony_ciOtherwise, if there is a <strong>default</strong> label, execution will continue after that
117245bd8deadSopenharmony_cilabel.
117255bd8deadSopenharmony_ciOtherwise, execution skips the rest of the switch statement.
117265bd8deadSopenharmony_ciIt is a compile-time error to have more than one <strong>default</strong> or a replicated
117275bd8deadSopenharmony_ci<em>constant-expression</em>.
117285bd8deadSopenharmony_ciA <strong>break</strong> statement not nested in a loop or other switch statement (either
117295bd8deadSopenharmony_cinot nested or nested only in <strong>if</strong> or <strong>if</strong>-<strong>else</strong> statements) will also skip
117305bd8deadSopenharmony_cithe rest of the switch statement.
117315bd8deadSopenharmony_ciFall through labels are allowed, but it is a compile-time error to have no
117325bd8deadSopenharmony_cistatement between a label and the end of the switch statement.
117335bd8deadSopenharmony_ciNo statements are allowed in a switch statement before the first <strong>case</strong>
117345bd8deadSopenharmony_cistatement.</p>
117355bd8deadSopenharmony_ci</div>
117365bd8deadSopenharmony_ci<div class="paragraph">
117375bd8deadSopenharmony_ci<p>The <strong>case</strong> and <strong>default</strong> labels can only appear within a <strong>switch</strong> statement.
117385bd8deadSopenharmony_ciNo <strong>case</strong> or <strong>default</strong> labels can be nested inside other statements or
117395bd8deadSopenharmony_cicompound statements within their corresponding <strong>switch</strong>.</p>
117405bd8deadSopenharmony_ci</div>
117415bd8deadSopenharmony_ci</div>
117425bd8deadSopenharmony_ci<div class="sect2">
117435bd8deadSopenharmony_ci<h3 id="iteration">6.3. Iteration</h3>
117445bd8deadSopenharmony_ci<div class="paragraph">
117455bd8deadSopenharmony_ci<p>For, while, and do loops are allowed as follows:</p>
117465bd8deadSopenharmony_ci</div>
117475bd8deadSopenharmony_ci<div class="listingblock">
117485bd8deadSopenharmony_ci<div class="content">
117495bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="keyword">for</span> (init-expression; condition-expression; loop-expression)
117505bd8deadSopenharmony_ci    sub-statement
117515bd8deadSopenharmony_ci<span class="keyword">while</span> (condition-expression)
117525bd8deadSopenharmony_ci    sub-statement
117535bd8deadSopenharmony_ci<span class="keyword">do</span>
117545bd8deadSopenharmony_ci    statement
117555bd8deadSopenharmony_ci<span class="keyword">while</span> (condition-expression)</code></pre>
117565bd8deadSopenharmony_ci</div>
117575bd8deadSopenharmony_ci</div>
117585bd8deadSopenharmony_ci<div class="paragraph">
117595bd8deadSopenharmony_ci<p>See &#8220;<a href="#shading-language-grammar">Shading Language Grammar</a>&#8221; for the
117605bd8deadSopenharmony_cidefinitive specification of loops.</p>
117615bd8deadSopenharmony_ci</div>
117625bd8deadSopenharmony_ci<div class="paragraph">
117635bd8deadSopenharmony_ci<p>The <strong>for</strong> loop first evaluates the <em>init-expression</em>, then the
117645bd8deadSopenharmony_ci<em>condition-expression</em>.
117655bd8deadSopenharmony_ciIf the <em>condition-expression</em> evaluates to <strong>true</strong>, then the body of the loop
117665bd8deadSopenharmony_ciis executed.
117675bd8deadSopenharmony_ciAfter the body is executed, a <strong>for</strong> loop will then evaluate the
117685bd8deadSopenharmony_ci<em>loop-expression</em>, and then loop back to evaluate the
117695bd8deadSopenharmony_ci<em>condition-expression</em>, repeating until the <em>condition-expression</em> evaluates
117705bd8deadSopenharmony_cito <strong>false</strong>.
117715bd8deadSopenharmony_ciThe loop is then exited, skipping its body and skipping its
117725bd8deadSopenharmony_ci<em>loop-expression</em>.
117735bd8deadSopenharmony_ciVariables modified by the <em>loop-expression</em> maintain their value after the
117745bd8deadSopenharmony_ciloop is exited, provided they are still in scope.
117755bd8deadSopenharmony_ciVariables declared in <em>init-expression</em> or <em>condition-expression</em> are only
117765bd8deadSopenharmony_ciin scope until the end of the sub-statement of the <strong>for</strong> loop.</p>
117775bd8deadSopenharmony_ci</div>
117785bd8deadSopenharmony_ci<div class="paragraph">
117795bd8deadSopenharmony_ci<p>The <strong>while</strong> loop first evaluates the <em>condition-expression</em>.
117805bd8deadSopenharmony_ciIf <strong>true</strong>, then the body is executed.
117815bd8deadSopenharmony_ciThis is then repeated, until the <em>condition-expression</em> evaluates to
117825bd8deadSopenharmony_ci<strong>false</strong>, exiting the loop and skipping its body.
117835bd8deadSopenharmony_ciVariables declared in the <em>condition-expression</em> are only in scope until the
117845bd8deadSopenharmony_ciend of the sub-statement of the <strong>while</strong> loop.</p>
117855bd8deadSopenharmony_ci</div>
117865bd8deadSopenharmony_ci<div class="paragraph">
117875bd8deadSopenharmony_ci<p>The <strong>do</strong>-<strong>while</strong> loop first executes the body, then executes the
117885bd8deadSopenharmony_ci<em>condition-expression</em>.
117895bd8deadSopenharmony_ciThis is repeated until <em>condition-expression</em> evaluates to <strong>false</strong>, and then
117905bd8deadSopenharmony_cithe loop is exited.</p>
117915bd8deadSopenharmony_ci</div>
117925bd8deadSopenharmony_ci<div class="paragraph">
117935bd8deadSopenharmony_ci<p>Expressions for <em>condition-expression</em> must evaluate to a Boolean.</p>
117945bd8deadSopenharmony_ci</div>
117955bd8deadSopenharmony_ci<div class="paragraph">
117965bd8deadSopenharmony_ci<p>Both the <em>condition-expression</em> and the <em>init-expression</em> can declare and
117975bd8deadSopenharmony_ciinitialize a variable, except in the <strong>do</strong>-<strong>while</strong> loop, which cannot declare
117985bd8deadSopenharmony_cia variable in its <em>condition-expression</em>.
117995bd8deadSopenharmony_ciThe variable&#8217;s scope lasts only until the end of the sub-statement that
118005bd8deadSopenharmony_ciforms the body of the loop.</p>
118015bd8deadSopenharmony_ci</div>
118025bd8deadSopenharmony_ci<div class="paragraph">
118035bd8deadSopenharmony_ci<p>Loops can be nested.</p>
118045bd8deadSopenharmony_ci</div>
118055bd8deadSopenharmony_ci<div class="paragraph">
118065bd8deadSopenharmony_ci<p>Non-terminating loops are allowed.
118075bd8deadSopenharmony_ciThe consequences of very long or non-terminating loops are platform
118085bd8deadSopenharmony_cidependent.</p>
118095bd8deadSopenharmony_ci</div>
118105bd8deadSopenharmony_ci</div>
118115bd8deadSopenharmony_ci<div class="sect2">
118125bd8deadSopenharmony_ci<h3 id="jumps">6.4. Jumps</h3>
118135bd8deadSopenharmony_ci<div class="paragraph">
118145bd8deadSopenharmony_ci<p>These are the jumps:</p>
118155bd8deadSopenharmony_ci</div>
118165bd8deadSopenharmony_ci<div class="openblock bnf">
118175bd8deadSopenharmony_ci<div class="content">
118185bd8deadSopenharmony_ci<div class="dlist">
118195bd8deadSopenharmony_ci<dl>
118205bd8deadSopenharmony_ci<dt class="hdlist1"><em>jump_statement</em> : </dt>
118215bd8deadSopenharmony_ci<dd>
118225bd8deadSopenharmony_ci<p><strong>continue</strong> <strong>;</strong><br>
118235bd8deadSopenharmony_ci<strong>break</strong> <strong>;</strong><br>
118245bd8deadSopenharmony_ci<strong>return</strong> <strong>;</strong><br>
118255bd8deadSopenharmony_ci<strong>return</strong> <em>expression</em> <strong>;</strong><br>
118265bd8deadSopenharmony_ci<strong>discard</strong> <strong>;</strong> // in the fragment shader language only</p>
118275bd8deadSopenharmony_ci</dd>
118285bd8deadSopenharmony_ci</dl>
118295bd8deadSopenharmony_ci</div>
118305bd8deadSopenharmony_ci</div>
118315bd8deadSopenharmony_ci</div>
118325bd8deadSopenharmony_ci<div class="paragraph">
118335bd8deadSopenharmony_ci<p>There is no &#8220;goto&#8221; or other non-structured flow of control.</p>
118345bd8deadSopenharmony_ci</div>
118355bd8deadSopenharmony_ci<div class="paragraph">
118365bd8deadSopenharmony_ci<p>The <strong>continue</strong> jump is used only in loops.
118375bd8deadSopenharmony_ciIt skips the remainder of the body of the inner-most loop of which it is
118385bd8deadSopenharmony_ciinside.
118395bd8deadSopenharmony_ciFor <strong>while</strong> and <strong>do</strong>-<strong>while</strong> loops, this jump is to the next evaluation of
118405bd8deadSopenharmony_cithe loop <em>condition-expression</em> from which the loop continues as previously
118415bd8deadSopenharmony_cidefined.
118425bd8deadSopenharmony_ciFor <strong>for</strong> loops, the jump is to the <em>loop-expression</em>, followed by the
118435bd8deadSopenharmony_ci<em>condition-expression</em>.</p>
118445bd8deadSopenharmony_ci</div>
118455bd8deadSopenharmony_ci<div class="paragraph">
118465bd8deadSopenharmony_ci<p>The <strong>break</strong> jump can also be used only in loops and <strong>switch</strong> statements.
118475bd8deadSopenharmony_ciIt is simply an immediate exit of the inner-most loop or <strong>switch</strong> statements
118485bd8deadSopenharmony_cicontaining the <strong>break</strong>.
118495bd8deadSopenharmony_ciNo further execution of <em>condition-expression</em>, <em>loop-expression</em>, or
118505bd8deadSopenharmony_ci<em>switch-statement</em> is done.</p>
118515bd8deadSopenharmony_ci</div>
118525bd8deadSopenharmony_ci<div class="paragraph">
118535bd8deadSopenharmony_ci<p>The <strong>discard</strong> keyword is only allowed within fragment shaders.
118545bd8deadSopenharmony_ciIt can be used within a fragment shader to abandon the operation on the
118555bd8deadSopenharmony_cicurrent fragment.
118565bd8deadSopenharmony_ciThis keyword causes the fragment to be discarded and no updates to any
118575bd8deadSopenharmony_cibuffers will occur.
118585bd8deadSopenharmony_ciAny prior writes to other buffers such as shader storage buffers are
118595bd8deadSopenharmony_ciunaffected.
118605bd8deadSopenharmony_ciControl flow exits the shader, and subsequent implicit or explicit
118615bd8deadSopenharmony_ciderivatives are undefined when this control flow is non-uniform (meaning
118625bd8deadSopenharmony_cidifferent fragments within the primitive take different control paths).
118635bd8deadSopenharmony_ciIt would typically be used within a conditional statement, for example:</p>
118645bd8deadSopenharmony_ci</div>
118655bd8deadSopenharmony_ci<div class="listingblock">
118665bd8deadSopenharmony_ci<div class="content">
118675bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="keyword">if</span> (intensity &lt; <span class="float">0</span><span class="float">.0</span>)
118685bd8deadSopenharmony_ci    discard;</code></pre>
118695bd8deadSopenharmony_ci</div>
118705bd8deadSopenharmony_ci</div>
118715bd8deadSopenharmony_ci<div class="paragraph">
118725bd8deadSopenharmony_ci<p>A fragment shader may test a fragment&#8217;s alpha value and discard the fragment
118735bd8deadSopenharmony_cibased on that test.
118745bd8deadSopenharmony_ciHowever, it should be noted that coverage testing occurs after the fragment
118755bd8deadSopenharmony_cishader runs, and the coverage test can change the alpha value.</p>
118765bd8deadSopenharmony_ci</div>
118775bd8deadSopenharmony_ci<div class="paragraph">
118785bd8deadSopenharmony_ci<p>The <strong>return</strong> jump causes immediate exit of the current function.
118795bd8deadSopenharmony_ciIf it has <em>expression</em> then that is the return value for the function.</p>
118805bd8deadSopenharmony_ci</div>
118815bd8deadSopenharmony_ci<div class="paragraph">
118825bd8deadSopenharmony_ci<p>The function <em>main</em> can use <strong>return</strong>.
118835bd8deadSopenharmony_ciThis simply causes <em>main</em> to exit in the same way as when the end of the
118845bd8deadSopenharmony_cifunction had been reached.
118855bd8deadSopenharmony_ciIt does not imply a use of <strong>discard</strong> in a fragment shader.
118865bd8deadSopenharmony_ciUsing <strong>return</strong> in <em>main</em> before defining outputs will have the same behavior
118875bd8deadSopenharmony_cias reaching the end of <em>main</em> before defining outputs.</p>
118885bd8deadSopenharmony_ci</div>
118895bd8deadSopenharmony_ci</div>
118905bd8deadSopenharmony_ci</div>
118915bd8deadSopenharmony_ci</div>
118925bd8deadSopenharmony_ci<div class="sect1">
118935bd8deadSopenharmony_ci<h2 id="built-in-variables">7. Built-In Variables</h2>
118945bd8deadSopenharmony_ci<div class="sectionbody">
118955bd8deadSopenharmony_ci<div class="sect2">
118965bd8deadSopenharmony_ci<h3 id="built-in-language-variables">7.1. Built-In Language Variables</h3>
118975bd8deadSopenharmony_ci<div class="paragraph">
118985bd8deadSopenharmony_ci<p>Some operations occur outside shader functionality and need to provide
118995bd8deadSopenharmony_civalues to or receive values from shader executables.
119005bd8deadSopenharmony_ciShaders communicate with fixed-function pipeline stages, and
119015bd8deadSopenharmony_cioptionally with other shader executables, through the use of built-in input
119025bd8deadSopenharmony_ciand output variables.</p>
119035bd8deadSopenharmony_ci</div>
119045bd8deadSopenharmony_ci<div class="sect3">
119055bd8deadSopenharmony_ci<h4 id="vertex-shader-special-variables">7.1.1. Vertex Shader Special Variables</h4>
119065bd8deadSopenharmony_ci<div class="paragraph">
119075bd8deadSopenharmony_ci<p>The built-in vertex shader variables are intrinsically declared as follows:</p>
119085bd8deadSopenharmony_ci</div>
119095bd8deadSopenharmony_ci<div class="listingblock">
119105bd8deadSopenharmony_ci<div class="content">
119115bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">in <span class="predefined-type">int</span> gl_VertexID;       <span class="comment">// only present when not targeting Vulkan</span>
119125bd8deadSopenharmony_ciin <span class="predefined-type">int</span> gl_InstanceID;     <span class="comment">// only present when not targeting Vulkan</span>
119135bd8deadSopenharmony_ciin <span class="predefined-type">int</span> gl_VertexIndex;    <span class="comment">// only present when targeting Vulkan</span>
119145bd8deadSopenharmony_ciin <span class="predefined-type">int</span> gl_InstanceIndex;  <span class="comment">// only present when targeting Vulkan</span>
119155bd8deadSopenharmony_ciin <span class="predefined-type">int</span> gl_DrawID;
119165bd8deadSopenharmony_ciin <span class="predefined-type">int</span> gl_BaseVertex;
119175bd8deadSopenharmony_ciin <span class="predefined-type">int</span> gl_BaseInstance;
119185bd8deadSopenharmony_ci
119195bd8deadSopenharmony_ciout gl_PerVertex {
119205bd8deadSopenharmony_ci    vec4 gl_Position;
119215bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_PointSize;
119225bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_ClipDistance[];
119235bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_CullDistance[];
119245bd8deadSopenharmony_ci};</code></pre>
119255bd8deadSopenharmony_ci</div>
119265bd8deadSopenharmony_ci</div>
119275bd8deadSopenharmony_ci<div class="paragraph">
119285bd8deadSopenharmony_ci<p>The variable <em>gl_Position</em> is intended for writing the homogeneous vertex
119295bd8deadSopenharmony_ciposition.
119305bd8deadSopenharmony_ciIt can be written at any time during shader execution.
119315bd8deadSopenharmony_ciThis value will be used by primitive assembly, clipping, culling, and other
119325bd8deadSopenharmony_cifixed functionality operations, if present, that operate on primitives after
119335bd8deadSopenharmony_civertex processing has occurred.
119345bd8deadSopenharmony_ciIts value is undefined after the vertex processing stage if the vertex
119355bd8deadSopenharmony_cishader executable does not write <em>gl_Position</em>.</p>
119365bd8deadSopenharmony_ci</div>
119375bd8deadSopenharmony_ci<div class="paragraph">
119385bd8deadSopenharmony_ci<p>The variable <em>gl_PointSize</em> is intended for a shader to write the size of
119395bd8deadSopenharmony_cithe point to be rasterized.
119405bd8deadSopenharmony_ciIt is measured in pixels.
119415bd8deadSopenharmony_ciIf <em>gl_PointSize</em> is not written to, its value is undefined in subsequent
119425bd8deadSopenharmony_cipipe stages.</p>
119435bd8deadSopenharmony_ci</div>
119445bd8deadSopenharmony_ci<div class="paragraph">
119455bd8deadSopenharmony_ci<p>The variable <em>gl_ClipDistance</em> is intended for writing clip distances, and
119465bd8deadSopenharmony_ciprovides the forward compatible mechanism for controlling user clipping.
119475bd8deadSopenharmony_ciThe element <em>gl_ClipDistance[i]</em> specifies a clip distance for each plane
119485bd8deadSopenharmony_ci<em>i</em>.
119495bd8deadSopenharmony_ciA distance of 0 means the vertex is on the plane, a positive distance means
119505bd8deadSopenharmony_cithe vertex is inside the clip plane, and a negative distance means the point
119515bd8deadSopenharmony_ciis outside the clip plane.
119525bd8deadSopenharmony_ciThe clip distances will be linearly interpolated across the primitive and
119535bd8deadSopenharmony_cithe portion of the primitive with interpolated distances less than 0 will be
119545bd8deadSopenharmony_ciclipped.</p>
119555bd8deadSopenharmony_ci</div>
119565bd8deadSopenharmony_ci<div class="paragraph">
119575bd8deadSopenharmony_ci<p>The <em>gl_ClipDistance</em> array is predeclared as unsized and must be explicitly
119585bd8deadSopenharmony_cisized by the shader either redeclaring it with a size or implicitly sized by
119595bd8deadSopenharmony_ciindexing it only with constant integral expressions.
119605bd8deadSopenharmony_ciThis needs to size the array to include all the clip planes that are enabled
119615bd8deadSopenharmony_civia the API; if the size does not include all enabled planes,
119625bd8deadSopenharmony_ciresults are undefined.
119635bd8deadSopenharmony_ciThe size can be at most <em>gl_MaxClipDistances</em>.
119645bd8deadSopenharmony_ciThe number of varying components (see <em>gl_MaxVaryingComponents)</em> consumed by
119655bd8deadSopenharmony_ci<em>gl_ClipDistance</em> will match the size of the array, no matter how many
119665bd8deadSopenharmony_ciplanes are enabled.
119675bd8deadSopenharmony_ciThe shader must also set all values in <em>gl_ClipDistance</em> that have been
119685bd8deadSopenharmony_cienabled via the API, or results are undefined.
119695bd8deadSopenharmony_ciValues written into <em>gl_ClipDistance</em> for planes that are not enabled have
119705bd8deadSopenharmony_cino effect.</p>
119715bd8deadSopenharmony_ci</div>
119725bd8deadSopenharmony_ci<div class="paragraph">
119735bd8deadSopenharmony_ci<p>The variable <em>gl_CullDistance</em> provides a mechanism for controlling user
119745bd8deadSopenharmony_ciculling.
119755bd8deadSopenharmony_ciThe element <em>gl_CullDistance[i]</em> specifies a cull distance for plane <em>i</em>.
119765bd8deadSopenharmony_ciA distance of 0 means the vertex is on the plane, a positive distance means
119775bd8deadSopenharmony_cithe vertex is inside the cull volume, and a negative distance means the
119785bd8deadSopenharmony_cipoint is outside the cull volume.
119795bd8deadSopenharmony_ciPrimitives whose vertices all have a negative cull distance for plane <em>i</em>
119805bd8deadSopenharmony_ciwill be discarded.</p>
119815bd8deadSopenharmony_ci</div>
119825bd8deadSopenharmony_ci<div class="paragraph">
119835bd8deadSopenharmony_ci<p>The <em>gl_CullDistance</em> array is predeclared as unsized and must be sized by
119845bd8deadSopenharmony_cithe shader either redeclaring it with a size or indexing it only with
119855bd8deadSopenharmony_ciconstant integral expressions.
119865bd8deadSopenharmony_ciThe size determines the number and set of enabled cull distances and can be
119875bd8deadSopenharmony_ciat most <em>gl_MaxCullDistances</em>.
119885bd8deadSopenharmony_ciThe number of varying components (see <em>gl_MaxVaryingComponents</em>) consumed by
119895bd8deadSopenharmony_ci<em>gl_CullDistance</em> will match the size of the array.
119905bd8deadSopenharmony_ciShaders writing <em>gl_CullDistance</em> must write all enabled distances, or
119915bd8deadSopenharmony_ciculling results are undefined.</p>
119925bd8deadSopenharmony_ci</div>
119935bd8deadSopenharmony_ci<div class="paragraph">
119945bd8deadSopenharmony_ci<p>As an output variable, <em>gl_CullDistance</em> provides the place for the shader
119955bd8deadSopenharmony_cito write these distances.
119965bd8deadSopenharmony_ciAs an input in all but the fragment language, it reads the values written in
119975bd8deadSopenharmony_cithe previous shader stage.
119985bd8deadSopenharmony_ciIn the fragment language, <em>gl_CullDistance</em> array contains linearly
119995bd8deadSopenharmony_ciinterpolated values for the vertex values written by a shader to the
120005bd8deadSopenharmony_ci<em>gl_CullDistance</em> vertex output variable.</p>
120015bd8deadSopenharmony_ci</div>
120025bd8deadSopenharmony_ci<div class="paragraph">
120035bd8deadSopenharmony_ci<p>It is a compile-time or link-time error for the set of shaders forming a
120045bd8deadSopenharmony_ciprogram to have the sum of the sizes of the <em>gl_ClipDistance</em> and
120055bd8deadSopenharmony_ci<em>gl_CullDistance</em> arrays to be larger than
120065bd8deadSopenharmony_ci<em>gl_MaxCombinedClipAndCullDistances</em>.</p>
120075bd8deadSopenharmony_ci</div>
120085bd8deadSopenharmony_ci<div class="paragraph">
120095bd8deadSopenharmony_ci<p>The variable <em>gl_VertexID</em> is a vertex shader input variable that holds an
120105bd8deadSopenharmony_ciinteger index for the vertex, as defined under &#8220;Shader Inputs&#8221; in section
120115bd8deadSopenharmony_ci11.1.3.9 &#8220;Shader Inputs&#8221; of the <a href="#references">OpenGL Specification</a>.
120125bd8deadSopenharmony_ciIt is only present when not targeting Vulkan.
120135bd8deadSopenharmony_ciEven when present, the value of <em>gl_VertexID</em> is not always defined.</p>
120145bd8deadSopenharmony_ci</div>
120155bd8deadSopenharmony_ci<div class="paragraph">
120165bd8deadSopenharmony_ci<p>The variable <em>gl_InstanceID</em> is a vertex shader input variable that holds
120175bd8deadSopenharmony_cithe instance number of the current primitive in an instanced draw call (see
120185bd8deadSopenharmony_ci&#8220;Shader Inputs&#8221; in section 11.1.3.9 &#8220;Shader Inputs&#8221; of the
120195bd8deadSopenharmony_ci<a href="#references">OpenGL Specification</a>).
120205bd8deadSopenharmony_ciIt is only present when not targeting Vulkan.
120215bd8deadSopenharmony_ciIf the current primitive does not come from an instanced draw call, the
120225bd8deadSopenharmony_civalue of <em>gl_InstanceID</em> is zero.</p>
120235bd8deadSopenharmony_ci</div>
120245bd8deadSopenharmony_ci<div class="paragraph">
120255bd8deadSopenharmony_ci<p>The variable <em>gl_VertexIndex</em> is a vertex language input variable that
120265bd8deadSopenharmony_ciholds an integer index for the vertex, relative to a base.
120275bd8deadSopenharmony_ciIt is only present when targeting Vulkan.
120285bd8deadSopenharmony_ciEven when present, the value of <em>gl_VertexIndex</em> is not always defined.</p>
120295bd8deadSopenharmony_ci</div>
120305bd8deadSopenharmony_ci<div class="paragraph">
120315bd8deadSopenharmony_ci<p>The variable <em>gl_InstanceIndex</em> is a vertex language input variable that
120325bd8deadSopenharmony_ciholds the instance number of the current primitive in an instanced draw
120335bd8deadSopenharmony_cicall, relative to a base.
120345bd8deadSopenharmony_ciIt is only present when targeting Vulkan.
120355bd8deadSopenharmony_ciIf the current primitive does not come from an instanced draw call,
120365bd8deadSopenharmony_cithe value of gl_InstanceIndex is zero.</p>
120375bd8deadSopenharmony_ci</div>
120385bd8deadSopenharmony_ci<div class="paragraph">
120395bd8deadSopenharmony_ci<p>The variable <em>gl_DrawID</em> is a vertex shader input variable that holds the
120405bd8deadSopenharmony_ciinteger index of the drawing command to which the current vertex belongs
120415bd8deadSopenharmony_ci(see &#8220;Shader Inputs&#8221; in section 11.1.3.9 of the <a href="#references">OpenGL Specification</a>).
120425bd8deadSopenharmony_ciIf the vertex is not invoked by a <strong>Multi</strong>* form of a draw command, then the
120435bd8deadSopenharmony_civalue of <em>gl_DrawID</em> is zero.</p>
120445bd8deadSopenharmony_ci</div>
120455bd8deadSopenharmony_ci<div class="paragraph">
120465bd8deadSopenharmony_ci<p>The variable <em>gl_BaseVertex</em> is a vertex shader input variable that holds
120475bd8deadSopenharmony_cithe integer value passed to the baseVertex parameter of the command that
120485bd8deadSopenharmony_ciresulted in the current shader invocation (see &#8220;Shader Inputs&#8221; in section
120495bd8deadSopenharmony_ci11.1.3.9 of the <a href="#references">OpenGL Specification</a>).</p>
120505bd8deadSopenharmony_ci</div>
120515bd8deadSopenharmony_ci<div class="paragraph">
120525bd8deadSopenharmony_ci<p>The variable <em>gl_BaseInstance</em> is a vertex shader input variable that holds
120535bd8deadSopenharmony_cithe integer value passed to the baseInstance parameter of the command that
120545bd8deadSopenharmony_ciresulted in the current shader invocation (see &#8220;Shader Inputs&#8221; in section
120555bd8deadSopenharmony_ci11.1.3.9 of the <a href="#references">OpenGL Specification</a>).</p>
120565bd8deadSopenharmony_ci</div>
120575bd8deadSopenharmony_ci</div>
120585bd8deadSopenharmony_ci<div class="sect3">
120595bd8deadSopenharmony_ci<h4 id="tessellation-control-shader-special-variables">7.1.2. Tessellation Control Shader Special Variables</h4>
120605bd8deadSopenharmony_ci<div class="paragraph">
120615bd8deadSopenharmony_ci<p>In the tessellation control shader, built-in variables are intrinsically
120625bd8deadSopenharmony_cideclared as:</p>
120635bd8deadSopenharmony_ci</div>
120645bd8deadSopenharmony_ci<div class="listingblock">
120655bd8deadSopenharmony_ci<div class="content">
120665bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">in gl_PerVertex {
120675bd8deadSopenharmony_ci    vec4 gl_Position;
120685bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_PointSize;
120695bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_ClipDistance[];
120705bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_CullDistance[];
120715bd8deadSopenharmony_ci} gl_in[gl_MaxPatchVertices];
120725bd8deadSopenharmony_ci
120735bd8deadSopenharmony_ciin <span class="predefined-type">int</span> gl_PatchVerticesIn;
120745bd8deadSopenharmony_ciin <span class="predefined-type">int</span> gl_PrimitiveID;
120755bd8deadSopenharmony_ciin <span class="predefined-type">int</span> gl_InvocationID;
120765bd8deadSopenharmony_ci
120775bd8deadSopenharmony_ciout gl_PerVertex {
120785bd8deadSopenharmony_ci    vec4 gl_Position;
120795bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_PointSize;
120805bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_ClipDistance[];
120815bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_CullDistance[];
120825bd8deadSopenharmony_ci} gl_out[];
120835bd8deadSopenharmony_ci
120845bd8deadSopenharmony_cipatch out <span class="predefined-type">float</span> gl_TessLevelOuter[<span class="integer">4</span>];
120855bd8deadSopenharmony_cipatch out <span class="predefined-type">float</span> gl_TessLevelInner[<span class="integer">2</span>];</code></pre>
120865bd8deadSopenharmony_ci</div>
120875bd8deadSopenharmony_ci</div>
120885bd8deadSopenharmony_ci<div class="sect4">
120895bd8deadSopenharmony_ci<h5 id="tessellation-control-input-variables">Tessellation Control Input Variables</h5>
120905bd8deadSopenharmony_ci<div class="paragraph">
120915bd8deadSopenharmony_ci<p><em>gl_Position</em>, <em>gl_PointSize</em>, <em>gl_ClipDistance</em>, and <em>gl_CullDistance</em>
120925bd8deadSopenharmony_cicontain the values written in the previous shader stage to the corresponding
120935bd8deadSopenharmony_cioutputs.</p>
120945bd8deadSopenharmony_ci</div>
120955bd8deadSopenharmony_ci<div class="paragraph">
120965bd8deadSopenharmony_ci<p><em>gl_PatchVerticesIn</em> contains the number of vertices in the input patch
120975bd8deadSopenharmony_cibeing processed by the shader.
120985bd8deadSopenharmony_ciA single shader can read patches of differing sizes, so the value of
120995bd8deadSopenharmony_ci<em>gl_PatchVerticesIn</em> may differ between patches.</p>
121005bd8deadSopenharmony_ci</div>
121015bd8deadSopenharmony_ci<div class="paragraph">
121025bd8deadSopenharmony_ci<p><em>gl_PrimitiveID</em> contains the number of primitives processed by the shader
121035bd8deadSopenharmony_cisince the current set of rendering primitives was started.</p>
121045bd8deadSopenharmony_ci</div>
121055bd8deadSopenharmony_ci<div class="paragraph">
121065bd8deadSopenharmony_ci<p><em>gl_InvocationID</em> contains the number of the output patch vertex assigned to
121075bd8deadSopenharmony_cithe tessellation control shader invocation.
121085bd8deadSopenharmony_ciIt is assigned integer values in the range [0, N-1], where N is the number
121095bd8deadSopenharmony_ciof output patch vertices per primitive.</p>
121105bd8deadSopenharmony_ci</div>
121115bd8deadSopenharmony_ci</div>
121125bd8deadSopenharmony_ci<div class="sect4">
121135bd8deadSopenharmony_ci<h5 id="tessellation-control-output-variables">Tessellation Control Output Variables</h5>
121145bd8deadSopenharmony_ci<div class="paragraph">
121155bd8deadSopenharmony_ci<p><em>gl_Position</em>, <em>gl_PointSize</em>, <em>gl_ClipDistance</em>, and <em>gl_CullDistance</em> are
121165bd8deadSopenharmony_ciused in the same fashion as the corresponding output variables in the vertex
121175bd8deadSopenharmony_cishader.</p>
121185bd8deadSopenharmony_ci</div>
121195bd8deadSopenharmony_ci<div class="paragraph">
121205bd8deadSopenharmony_ci<p>The values written to <em>gl_TessLevelOuter</em> and <em>gl_TessLevelInner</em> are
121215bd8deadSopenharmony_ciassigned to the corresponding outer and inner tessellation levels of the
121225bd8deadSopenharmony_cioutput patch.
121235bd8deadSopenharmony_ciThey are used by the tessellation primitive generator to control primitive
121245bd8deadSopenharmony_citessellation and may be read by tessellation evaluation shaders.</p>
121255bd8deadSopenharmony_ci</div>
121265bd8deadSopenharmony_ci</div>
121275bd8deadSopenharmony_ci</div>
121285bd8deadSopenharmony_ci<div class="sect3">
121295bd8deadSopenharmony_ci<h4 id="tessellation-evaluation-shader-special-variables">7.1.3. Tessellation Evaluation Shader Special Variables</h4>
121305bd8deadSopenharmony_ci<div class="paragraph">
121315bd8deadSopenharmony_ci<p>In the tessellation evaluation shader, built-in variables are intrinsically
121325bd8deadSopenharmony_cideclared as:</p>
121335bd8deadSopenharmony_ci</div>
121345bd8deadSopenharmony_ci<div class="listingblock">
121355bd8deadSopenharmony_ci<div class="content">
121365bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">in gl_PerVertex {
121375bd8deadSopenharmony_ci    vec4 gl_Position;
121385bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_PointSize;
121395bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_ClipDistance[];
121405bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_CullDistance[];
121415bd8deadSopenharmony_ci} gl_in[gl_MaxPatchVertices];
121425bd8deadSopenharmony_ci
121435bd8deadSopenharmony_ciin <span class="predefined-type">int</span> gl_PatchVerticesIn;
121445bd8deadSopenharmony_ciin <span class="predefined-type">int</span> gl_PrimitiveID;
121455bd8deadSopenharmony_ciin vec3 gl_TessCoord;
121465bd8deadSopenharmony_cipatch in <span class="predefined-type">float</span> gl_TessLevelOuter[<span class="integer">4</span>];
121475bd8deadSopenharmony_cipatch in <span class="predefined-type">float</span> gl_TessLevelInner[<span class="integer">2</span>];
121485bd8deadSopenharmony_ci
121495bd8deadSopenharmony_ciout gl_PerVertex {
121505bd8deadSopenharmony_ci    vec4 gl_Position;
121515bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_PointSize;
121525bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_ClipDistance[];
121535bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_CullDistance[];
121545bd8deadSopenharmony_ci};</code></pre>
121555bd8deadSopenharmony_ci</div>
121565bd8deadSopenharmony_ci</div>
121575bd8deadSopenharmony_ci<div class="sect4">
121585bd8deadSopenharmony_ci<h5 id="tessellation-evaluation-input-variables">Tessellation Evaluation Input Variables</h5>
121595bd8deadSopenharmony_ci<div class="paragraph">
121605bd8deadSopenharmony_ci<p><em>gl_Position</em>, <em>gl_PointSize</em>, <em>gl_ClipDistance</em>, and <em>gl_CullDistance</em>
121615bd8deadSopenharmony_cicontain the values written in the previous shader stage to the corresponding
121625bd8deadSopenharmony_cioutputs.</p>
121635bd8deadSopenharmony_ci</div>
121645bd8deadSopenharmony_ci<div class="paragraph">
121655bd8deadSopenharmony_ci<p><em>gl_PatchVerticesIn</em> and <em>gl_PrimitiveID</em> are defined in the same fashion as
121665bd8deadSopenharmony_cithe corresponding input variables in the tessellation control shader.</p>
121675bd8deadSopenharmony_ci</div>
121685bd8deadSopenharmony_ci<div class="paragraph">
121695bd8deadSopenharmony_ci<p><em>gl_TessCoord</em> specifies a three-component <em>(u,v,w)</em> vector identifying the
121705bd8deadSopenharmony_ciposition of the vertex being processed by the shader relative to the
121715bd8deadSopenharmony_ciprimitive being tessellated.
121725bd8deadSopenharmony_ciIts values will obey the properties</p>
121735bd8deadSopenharmony_ci</div>
121745bd8deadSopenharmony_ci<div class="listingblock">
121755bd8deadSopenharmony_ci<div class="content">
121765bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">gl_TessCoord.x == <span class="float">1</span><span class="float">.0</span> - (<span class="float">1</span><span class="float">.0</span> - gl_TessCoord.x) <span class="comment">// two operations performed</span>
121775bd8deadSopenharmony_cigl_TessCoord.y == <span class="float">1</span><span class="float">.0</span> - (<span class="float">1</span><span class="float">.0</span> - gl_TessCoord.y) <span class="comment">// two operations performed</span>
121785bd8deadSopenharmony_cigl_TessCoord.z == <span class="float">1</span><span class="float">.0</span> - (<span class="float">1</span><span class="float">.0</span> - gl_TessCoord.z) <span class="comment">// two operations performed</span></code></pre>
121795bd8deadSopenharmony_ci</div>
121805bd8deadSopenharmony_ci</div>
121815bd8deadSopenharmony_ci<div class="paragraph">
121825bd8deadSopenharmony_ci<p>to aid in replicating subdivision computations.</p>
121835bd8deadSopenharmony_ci</div>
121845bd8deadSopenharmony_ci<div class="paragraph">
121855bd8deadSopenharmony_ci<p>If a tessellation control shader is active, the input variables
121865bd8deadSopenharmony_ci<em>gl_TessLevelOuter</em> and <em>gl_TessLevelInner</em> are filled with the
121875bd8deadSopenharmony_cicorresponding outputs written by the tessellation control shader.
121885bd8deadSopenharmony_ciOtherwise, they are assigned with default tessellation levels specified in
121895bd8deadSopenharmony_cisection 11.2.3.3 &#8220;Tessellation Evaluation Shader Inputs&#8221; of the
121905bd8deadSopenharmony_ci<a href="#references">OpenGL Specification</a>.</p>
121915bd8deadSopenharmony_ci</div>
121925bd8deadSopenharmony_ci</div>
121935bd8deadSopenharmony_ci<div class="sect4">
121945bd8deadSopenharmony_ci<h5 id="tessellation-evaluation-output-variables">Tessellation Evaluation Output Variables</h5>
121955bd8deadSopenharmony_ci<div class="paragraph">
121965bd8deadSopenharmony_ci<p><em>gl_Position</em>, <em>gl_PointSize</em>, <em>gl_ClipDistance</em>, and <em>gl_CullDistance</em> are
121975bd8deadSopenharmony_ciused in the same fashion as the corresponding output variables in the vertex
121985bd8deadSopenharmony_cishader.</p>
121995bd8deadSopenharmony_ci</div>
122005bd8deadSopenharmony_ci</div>
122015bd8deadSopenharmony_ci</div>
122025bd8deadSopenharmony_ci<div class="sect3">
122035bd8deadSopenharmony_ci<h4 id="geometry-shader-special-variables">7.1.4. Geometry Shader Special Variables</h4>
122045bd8deadSopenharmony_ci<div class="paragraph">
122055bd8deadSopenharmony_ci<p>In the geometry shader, built-in variables are intrinsically declared as:</p>
122065bd8deadSopenharmony_ci</div>
122075bd8deadSopenharmony_ci<div class="listingblock">
122085bd8deadSopenharmony_ci<div class="content">
122095bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">in gl_PerVertex {
122105bd8deadSopenharmony_ci    vec4 gl_Position;
122115bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_PointSize;
122125bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_ClipDistance[];
122135bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_CullDistance[];
122145bd8deadSopenharmony_ci} gl_in[];
122155bd8deadSopenharmony_ci
122165bd8deadSopenharmony_ciin <span class="predefined-type">int</span> gl_PrimitiveIDIn;
122175bd8deadSopenharmony_ciin <span class="predefined-type">int</span> gl_InvocationID;
122185bd8deadSopenharmony_ci
122195bd8deadSopenharmony_ciout gl_PerVertex {
122205bd8deadSopenharmony_ci    vec4 gl_Position;
122215bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_PointSize;
122225bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_ClipDistance[];
122235bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_CullDistance[];
122245bd8deadSopenharmony_ci};
122255bd8deadSopenharmony_ci
122265bd8deadSopenharmony_ciout <span class="predefined-type">int</span> gl_PrimitiveID;
122275bd8deadSopenharmony_ciout <span class="predefined-type">int</span> gl_Layer;
122285bd8deadSopenharmony_ciout <span class="predefined-type">int</span> gl_ViewportIndex;</code></pre>
122295bd8deadSopenharmony_ci</div>
122305bd8deadSopenharmony_ci</div>
122315bd8deadSopenharmony_ci<div class="sect4">
122325bd8deadSopenharmony_ci<h5 id="geometry-shader-input-variables">Geometry Shader Input Variables</h5>
122335bd8deadSopenharmony_ci<div class="paragraph">
122345bd8deadSopenharmony_ci<p><em>gl_Position</em>, <em>gl_PointSize</em>, <em>gl_ClipDistance</em>, and <em>gl_CullDistance</em>
122355bd8deadSopenharmony_cicontain the values written in the previous shader stage to the corresponding
122365bd8deadSopenharmony_cioutputs.</p>
122375bd8deadSopenharmony_ci</div>
122385bd8deadSopenharmony_ci<div class="paragraph">
122395bd8deadSopenharmony_ci<p><em>gl_PrimitiveIDIn</em> contains the number of primitives processed by the shader
122405bd8deadSopenharmony_cisince the current set of rendering primitives was started.</p>
122415bd8deadSopenharmony_ci</div>
122425bd8deadSopenharmony_ci<div class="paragraph">
122435bd8deadSopenharmony_ci<p><em>gl_InvocationID</em> contains the invocation number assigned to the geometry
122445bd8deadSopenharmony_cishader invocation.
122455bd8deadSopenharmony_ciIt is assigned integer values in the range [0, N-1], where N is the number
122465bd8deadSopenharmony_ciof geometry shader invocations per primitive.</p>
122475bd8deadSopenharmony_ci</div>
122485bd8deadSopenharmony_ci</div>
122495bd8deadSopenharmony_ci<div class="sect4">
122505bd8deadSopenharmony_ci<h5 id="geometry-shader-output-variables">Geometry Shader Output Variables</h5>
122515bd8deadSopenharmony_ci<div class="paragraph">
122525bd8deadSopenharmony_ci<p><em>gl_Position</em>, <em>gl_PointSize</em>, <em>gl_ClipDistance</em>, and <em>gl_CullDistance</em> are
122535bd8deadSopenharmony_ciused in the same fashion as the corresponding output variables in the vertex
122545bd8deadSopenharmony_cishader.</p>
122555bd8deadSopenharmony_ci</div>
122565bd8deadSopenharmony_ci<div class="paragraph">
122575bd8deadSopenharmony_ci<p><em>gl_PrimitiveID</em> is filled with a single integer that serves as a primitive
122585bd8deadSopenharmony_ciidentifier to the fragment shader.
122595bd8deadSopenharmony_ciThis is then available to fragment shaders, which will select the written
122605bd8deadSopenharmony_ciprimitive ID from the provoking vertex of the primitive being shaded.
122615bd8deadSopenharmony_ciIf a fragment shader using <em>gl_PrimitiveID</em> is active and a geometry shader
122625bd8deadSopenharmony_ciis also active, the geometry shader must write to <em>gl_PrimitiveID</em> or the
122635bd8deadSopenharmony_cifragment shader input <em>gl_PrimitiveID</em> is undefined.
122645bd8deadSopenharmony_ciSee section 11.3.4.5 &#8220;Geometry Shader Outputs&#8221; of the
122655bd8deadSopenharmony_ci<a href="#references">OpenGL Specification</a> for more information.</p>
122665bd8deadSopenharmony_ci</div>
122675bd8deadSopenharmony_ci<div class="paragraph">
122685bd8deadSopenharmony_ci<p><em>gl_Layer</em> is used to select a specific layer (or face and layer of a cube
122695bd8deadSopenharmony_cimap) of a multi-layer framebuffer attachment.
122705bd8deadSopenharmony_ciThe actual layer used will come from one of the vertices in the primitive
122715bd8deadSopenharmony_cibeing shaded.
122725bd8deadSopenharmony_ciWhich vertex the layer comes from is determined as discussed in section
122735bd8deadSopenharmony_ci11.3.4.6 &#8220;Layer and Viewport Selection&#8221; of the <a href="#references">OpenGL Specification</a>
122745bd8deadSopenharmony_cibut may be undefined, so it is best to write the same layer value for all
122755bd8deadSopenharmony_civertices of a primitive.
122765bd8deadSopenharmony_ciIf a shader statically assigns a value to <em>gl_Layer</em>, layered rendering mode
122775bd8deadSopenharmony_ciis enabled.
122785bd8deadSopenharmony_ciSee section 11.3.4.5 &#8220;Geometry Shader Outputs&#8221; and section 9.4.9 &#8220;Layered
122795bd8deadSopenharmony_ciFramebuffers&#8221; of the <a href="#references">OpenGL Specification</a> for more information.
122805bd8deadSopenharmony_ciIf a shader statically assigns a value to <em>gl_Layer</em>, and there is an
122815bd8deadSopenharmony_ciexecution path through the shader that does not set <em>gl_Layer</em>, then the
122825bd8deadSopenharmony_civalue of <em>gl_Layer</em> is undefined for executions of the shader that take that
122835bd8deadSopenharmony_cipath.</p>
122845bd8deadSopenharmony_ci</div>
122855bd8deadSopenharmony_ci<div class="paragraph">
122865bd8deadSopenharmony_ci<p>The output variable <em>gl_Layer</em> takes on a special value when used with an
122875bd8deadSopenharmony_ciarray of cube map textures.
122885bd8deadSopenharmony_ciInstead of only referring to the layer, it is used to select a cube map face
122895bd8deadSopenharmony_ciand a layer.
122905bd8deadSopenharmony_ciSetting <em>gl_Layer</em> to the value <em>layer*6+face</em> will render to face <em>face</em> of
122915bd8deadSopenharmony_cithe cube defined in layer <em>layer</em>.
122925bd8deadSopenharmony_ciThe face values are defined in table 9.3 of section 9.4.9 &#8220;Layered
122935bd8deadSopenharmony_ciFramebuffers&#8221; of the <a href="#references">OpenGL Specification</a>,
122945bd8deadSopenharmony_cibut repeated below for clarity.</p>
122955bd8deadSopenharmony_ci</div>
122965bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
122975bd8deadSopenharmony_ci<colgroup>
122985bd8deadSopenharmony_ci<col style="width: 50%;">
122995bd8deadSopenharmony_ci<col style="width: 50%;">
123005bd8deadSopenharmony_ci</colgroup>
123015bd8deadSopenharmony_ci<thead>
123025bd8deadSopenharmony_ci<tr>
123035bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Face Value</th>
123045bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Resulting Target</th>
123055bd8deadSopenharmony_ci</tr>
123065bd8deadSopenharmony_ci</thead>
123075bd8deadSopenharmony_ci<tbody>
123085bd8deadSopenharmony_ci<tr>
123095bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">0</p></td>
123105bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">TEXTURE_CUBE_MAP_POSITIVE_X</p></td>
123115bd8deadSopenharmony_ci</tr>
123125bd8deadSopenharmony_ci<tr>
123135bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">1</p></td>
123145bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">TEXTURE_CUBE_MAP_NEGATIVE_X</p></td>
123155bd8deadSopenharmony_ci</tr>
123165bd8deadSopenharmony_ci<tr>
123175bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">2</p></td>
123185bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">TEXTURE_CUBE_MAP_POSITIVE_Y</p></td>
123195bd8deadSopenharmony_ci</tr>
123205bd8deadSopenharmony_ci<tr>
123215bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">3</p></td>
123225bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">TEXTURE_CUBE_MAP_NEGATIVE_Y</p></td>
123235bd8deadSopenharmony_ci</tr>
123245bd8deadSopenharmony_ci<tr>
123255bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">4</p></td>
123265bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">TEXTURE_CUBE_MAP_POSITIVE_Z</p></td>
123275bd8deadSopenharmony_ci</tr>
123285bd8deadSopenharmony_ci<tr>
123295bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">5</p></td>
123305bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">TEXTURE_CUBE_MAP_NEGATIVE_Z</p></td>
123315bd8deadSopenharmony_ci</tr>
123325bd8deadSopenharmony_ci</tbody>
123335bd8deadSopenharmony_ci</table>
123345bd8deadSopenharmony_ci<div class="paragraph">
123355bd8deadSopenharmony_ci<p>For example, to render to the positive <em>y</em> cube map face located in the 5th
123365bd8deadSopenharmony_cilayer of the cube map array, <em>gl_Layer</em> should be set to <em>5 * 6 + 2</em>.</p>
123375bd8deadSopenharmony_ci</div>
123385bd8deadSopenharmony_ci<div class="paragraph">
123395bd8deadSopenharmony_ci<p>The output variable <em>gl_ViewportIndex</em> provides the index of the viewport to
123405bd8deadSopenharmony_ciwhich the next primitive emitted from the geometry shader should be drawn.
123415bd8deadSopenharmony_ciPrimitives generated by the geometry shader will undergo viewport
123425bd8deadSopenharmony_citransformation and scissor testing using the viewport transformation and
123435bd8deadSopenharmony_ciscissor rectangle selected by the value of <em>gl_ViewportIndex</em>.
123445bd8deadSopenharmony_ciThe viewport index used will come from one of the vertices in the primitive
123455bd8deadSopenharmony_cibeing shaded.
123465bd8deadSopenharmony_ciHowever, which vertex the viewport index comes from is
123475bd8deadSopenharmony_ciimplementation-dependent, so it is best to use the same viewport index for
123485bd8deadSopenharmony_ciall vertices of the primitive.
123495bd8deadSopenharmony_ciIf a geometry shader does not assign a value to <em>gl_ViewportIndex</em>, viewport
123505bd8deadSopenharmony_citransform and scissor rectangle zero will be used.
123515bd8deadSopenharmony_ciIf a geometry shader statically assigns a value to <em>gl_ViewportIndex</em> and
123525bd8deadSopenharmony_cithere is a path through the shader that does not assign a value to
123535bd8deadSopenharmony_ci<em>gl_ViewportIndex</em>, the value of <em>gl_ViewportIndex</em> is undefined for
123545bd8deadSopenharmony_ciexecutions of the shader that take that path.
123555bd8deadSopenharmony_ciSee section 11.3.4.6 &#8220;Layer and Viewport Selection&#8221; of the
123565bd8deadSopenharmony_ci<a href="#references">OpenGL Specification</a> for more information.</p>
123575bd8deadSopenharmony_ci</div>
123585bd8deadSopenharmony_ci</div>
123595bd8deadSopenharmony_ci</div>
123605bd8deadSopenharmony_ci<div class="sect3">
123615bd8deadSopenharmony_ci<h4 id="fragment-shader-special-variables">7.1.5. Fragment Shader Special Variables</h4>
123625bd8deadSopenharmony_ci<div class="paragraph">
123635bd8deadSopenharmony_ci<p>The built-in special variables that are accessible from a fragment shader
123645bd8deadSopenharmony_ciare intrinsically declared as follows:</p>
123655bd8deadSopenharmony_ci</div>
123665bd8deadSopenharmony_ci<div class="listingblock">
123675bd8deadSopenharmony_ci<div class="content">
123685bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">in vec4 gl_FragCoord;
123695bd8deadSopenharmony_ciin <span class="predefined-type">bool</span> gl_FrontFacing;
123705bd8deadSopenharmony_ciin <span class="predefined-type">float</span> gl_ClipDistance[];
123715bd8deadSopenharmony_ciin <span class="predefined-type">float</span> gl_CullDistance[];
123725bd8deadSopenharmony_ciin vec2 gl_PointCoord;
123735bd8deadSopenharmony_ciin <span class="predefined-type">int</span> gl_PrimitiveID;
123745bd8deadSopenharmony_ciin <span class="predefined-type">int</span> gl_SampleID;
123755bd8deadSopenharmony_ciin vec2 gl_SamplePosition;
123765bd8deadSopenharmony_ciin <span class="predefined-type">int</span> gl_SampleMaskIn[];
123775bd8deadSopenharmony_ciin <span class="predefined-type">int</span> gl_Layer;
123785bd8deadSopenharmony_ciin <span class="predefined-type">int</span> gl_ViewportIndex;
123795bd8deadSopenharmony_ciin <span class="predefined-type">bool</span> gl_HelperInvocation;
123805bd8deadSopenharmony_ci
123815bd8deadSopenharmony_ciout <span class="predefined-type">float</span> gl_FragDepth;
123825bd8deadSopenharmony_ciout <span class="predefined-type">int</span> gl_SampleMask[];</code></pre>
123835bd8deadSopenharmony_ci</div>
123845bd8deadSopenharmony_ci</div>
123855bd8deadSopenharmony_ci<div class="paragraph">
123865bd8deadSopenharmony_ci<p>The output of the fragment shader executable is processed by the fixed
123875bd8deadSopenharmony_cifunction operations at the back end of the API pipeline.</p>
123885bd8deadSopenharmony_ci</div>
123895bd8deadSopenharmony_ci<div class="paragraph">
123905bd8deadSopenharmony_ci<p>The fixed functionality computed depth for a fragment may be obtained by
123915bd8deadSopenharmony_cireading <em>gl_FragCoord.z</em>, described below.</p>
123925bd8deadSopenharmony_ci</div>
123935bd8deadSopenharmony_ci<div class="paragraph">
123945bd8deadSopenharmony_ci<p>Writing to <em>gl_FragDepth</em> will establish the depth value for the fragment
123955bd8deadSopenharmony_cibeing processed.
123965bd8deadSopenharmony_ciIf depth buffering is enabled, and no shader writes <em>gl_FragDepth</em>, then the
123975bd8deadSopenharmony_cifixed function value for depth will be used as the fragment&#8217;s depth value.
123985bd8deadSopenharmony_ciIf a shader statically assigns a value to <em>gl_FragDepth</em>, and there is an
123995bd8deadSopenharmony_ciexecution path through the shader that does not set <em>gl_FragDepth</em>, then the
124005bd8deadSopenharmony_civalue of the fragment&#8217;s depth may be undefined for executions of the shader
124015bd8deadSopenharmony_cithat take that path.
124025bd8deadSopenharmony_ciThat is, if the set of linked fragment shaders statically contain a write to
124035bd8deadSopenharmony_ci<em>gl_FragDepth</em>, then it is responsible for always writing it.</p>
124045bd8deadSopenharmony_ci</div>
124055bd8deadSopenharmony_ci<div class="paragraph">
124065bd8deadSopenharmony_ci<p>If a shader executes the <strong>discard</strong> keyword, the fragment is discarded, and
124075bd8deadSopenharmony_cithe values of any user-defined fragment outputs, <em>gl_FragDepth</em>, and
124085bd8deadSopenharmony_ci<em>gl_SampleMask</em> become irrelevant.</p>
124095bd8deadSopenharmony_ci</div>
124105bd8deadSopenharmony_ci<div class="paragraph">
124115bd8deadSopenharmony_ci<p>The variable <em>gl_FragCoord</em> is available as an input variable from within
124125bd8deadSopenharmony_cifragment shaders and it holds the window relative coordinates (<em>x</em>, <em>y</em>,
124135bd8deadSopenharmony_ci<em>z</em>, <em>1/w</em>) values for the fragment.
124145bd8deadSopenharmony_ciIf multi-sampling, this value can be for any location within the pixel, or
124155bd8deadSopenharmony_cione of the fragment samples.
124165bd8deadSopenharmony_ciThe use of <strong>centroid</strong> does not further restrict this value to be inside the
124175bd8deadSopenharmony_cicurrent primitive.
124185bd8deadSopenharmony_ciThis value is the result of the fixed functionality that interpolates
124195bd8deadSopenharmony_ciprimitives after vertex processing to generate fragments.
124205bd8deadSopenharmony_ciThe <em>z</em> component is the depth value that would be used for the fragment&#8217;s
124215bd8deadSopenharmony_cidepth if no shader contained any writes to <em>gl_FragDepth</em>.
124225bd8deadSopenharmony_ciThis is useful for invariance if a shader conditionally computes
124235bd8deadSopenharmony_ci<em>gl_FragDepth</em> but otherwise wants the fixed functionality fragment depth.</p>
124245bd8deadSopenharmony_ci</div>
124255bd8deadSopenharmony_ci<div class="paragraph">
124265bd8deadSopenharmony_ci<p>Fragment shaders have access to the input built-in variable
124275bd8deadSopenharmony_ci<em>gl_FrontFacing</em>, whose value is <strong>true</strong> if the fragment belongs to a
124285bd8deadSopenharmony_cifront-facing primitive.
124295bd8deadSopenharmony_ciOne use of this is to emulate two-sided lighting by selecting one of two
124305bd8deadSopenharmony_cicolors calculated by a vertex or geometry shader.</p>
124315bd8deadSopenharmony_ci</div>
124325bd8deadSopenharmony_ci<div class="paragraph">
124335bd8deadSopenharmony_ci<p>The values in <em>gl_PointCoord</em> are two-dimensional coordinates indicating
124345bd8deadSopenharmony_ciwhere within a point primitive the current fragment is located, when point
124355bd8deadSopenharmony_cisprites are enabled.
124365bd8deadSopenharmony_ciThey range from 0.0 to 1.0 across the point.
124375bd8deadSopenharmony_ciIf the current primitive is not a point, or if point sprites are not
124385bd8deadSopenharmony_cienabled, then the values read from <em>gl_PointCoord</em> are undefined.</p>
124395bd8deadSopenharmony_ci</div>
124405bd8deadSopenharmony_ci<div class="paragraph">
124415bd8deadSopenharmony_ci<p>For both the input array <em>gl_SampleMaskIn[]</em> and the output array
124425bd8deadSopenharmony_ci<em>gl_SampleMask[]</em>, bit <em>B</em> of mask <em>M</em> (<em>gl_SampleMaskIn[M]</em> or
124435bd8deadSopenharmony_ci<em>gl_SampleMask[M]</em>) corresponds to sample <em>32*M+B</em>.
124445bd8deadSopenharmony_ciThese arrays have <strong>ceil</strong>(<em>s</em>/32) elements, where <em>s</em> is the maximum number
124455bd8deadSopenharmony_ciof color samples supported by the implementation.</p>
124465bd8deadSopenharmony_ci</div>
124475bd8deadSopenharmony_ci<div class="paragraph">
124485bd8deadSopenharmony_ci<p>The input variable <em>gl_SampleMaskIn</em> indicates the set of samples covered by
124495bd8deadSopenharmony_cithe primitive generating the fragment during multisample rasterization.
124505bd8deadSopenharmony_ciIt has a sample bit set if and only if the sample is considered covered for
124515bd8deadSopenharmony_cithis fragment shader invocation.</p>
124525bd8deadSopenharmony_ci</div>
124535bd8deadSopenharmony_ci<div class="paragraph">
124545bd8deadSopenharmony_ci<p>The output array <em>gl_SampleMask[]</em> sets the sample mask for the fragment
124555bd8deadSopenharmony_cibeing processed.
124565bd8deadSopenharmony_ciCoverage for the current fragment will become the logical AND of the
124575bd8deadSopenharmony_cicoverage mask and the output <em>gl_SampleMask</em>.
124585bd8deadSopenharmony_ciThis array must be sized in the fragment shader either implicitly or
124595bd8deadSopenharmony_ciexplicitly, to be no larger than the implementation-dependent maximum
124605bd8deadSopenharmony_cisample-mask (as an array of 32bit elements), determined by the maximum
124615bd8deadSopenharmony_cinumber of samples..
124625bd8deadSopenharmony_ciIf the fragment shader statically assigns a value to <em>gl_SampleMask</em>, the
124635bd8deadSopenharmony_cisample mask will be undefined for any array elements of any fragment shader
124645bd8deadSopenharmony_ciinvocations that fail to assign a value.
124655bd8deadSopenharmony_ciIf a shader does not statically assign a value to <em>gl_SampleMask</em>, the
124665bd8deadSopenharmony_cisample mask has no effect on the processing of a fragment.</p>
124675bd8deadSopenharmony_ci</div>
124685bd8deadSopenharmony_ci<div class="paragraph">
124695bd8deadSopenharmony_ci<p>The input variable <em>gl_SampleID</em> is filled with the sample number of the
124705bd8deadSopenharmony_cisample currently being processed.
124715bd8deadSopenharmony_ciThis variable is in the range <em>0</em> to <em>gl_NumSamples-1</em>, where
124725bd8deadSopenharmony_ci<em>gl_NumSamples</em> is the total number of samples in the framebuffer, or 1 if
124735bd8deadSopenharmony_cirendering to a non-multisample framebuffer.
124745bd8deadSopenharmony_ciAny static use of this variable in a fragment shader causes the entire
124755bd8deadSopenharmony_cishader to be evaluated per-sample.</p>
124765bd8deadSopenharmony_ci</div>
124775bd8deadSopenharmony_ci<div class="paragraph">
124785bd8deadSopenharmony_ci<p>The input variable <em>gl_SamplePosition</em> contains the position of the current
124795bd8deadSopenharmony_cisample within the multisample draw buffer.
124805bd8deadSopenharmony_ciThe <em>x</em> and <em>y</em> components of <em>gl_SamplePosition</em> contain the sub-pixel
124815bd8deadSopenharmony_cicoordinate of the current sample and will have values in the range 0.0 to
124825bd8deadSopenharmony_ci1.0.
124835bd8deadSopenharmony_ciAny static use of this variable in a fragment shader causes the entire
124845bd8deadSopenharmony_cishader to be evaluated per sample.</p>
124855bd8deadSopenharmony_ci</div>
124865bd8deadSopenharmony_ci<div class="paragraph">
124875bd8deadSopenharmony_ci<p>The value <em>gl_HelperInvocation</em> is <strong>true</strong> if the fragment shader invocation
124885bd8deadSopenharmony_ciis considered a <em>helper invocation</em> and is <strong>false</strong> otherwise.
124895bd8deadSopenharmony_ciA helper invocation is a fragment shader invocation that is created solely
124905bd8deadSopenharmony_cifor the purposes of evaluating derivatives for use in non-helper fragment
124915bd8deadSopenharmony_cishader invocations.
124925bd8deadSopenharmony_ciSuch derivatives are computed implicitly in the built-in function
124935bd8deadSopenharmony_ci<strong>texture</strong>() (see &#8220;<a href="#texture-functions">Texture Functions</a>&#8221;), and
124945bd8deadSopenharmony_ciexplicitly in the derivative functions in
124955bd8deadSopenharmony_ci&#8220;<a href="#derivative-functions">Derivative Functions</a>&#8221;, for example <strong>dFdx</strong>() and
124965bd8deadSopenharmony_ci<strong>dFdy</strong>().</p>
124975bd8deadSopenharmony_ci</div>
124985bd8deadSopenharmony_ci<div class="paragraph">
124995bd8deadSopenharmony_ci<p>Fragment shader helper invocations execute the same shader code as
125005bd8deadSopenharmony_cinon-helper invocations, but will not have side effects that modify the
125015bd8deadSopenharmony_ciframebuffer or other shader-accessible memory.
125025bd8deadSopenharmony_ciIn particular:</p>
125035bd8deadSopenharmony_ci</div>
125045bd8deadSopenharmony_ci<div class="ulist">
125055bd8deadSopenharmony_ci<ul>
125065bd8deadSopenharmony_ci<li>
125075bd8deadSopenharmony_ci<p>Fragments corresponding to helper invocations are discarded when shader
125085bd8deadSopenharmony_ciexecution is complete, without updating the framebuffer.</p>
125095bd8deadSopenharmony_ci</li>
125105bd8deadSopenharmony_ci<li>
125115bd8deadSopenharmony_ci<p>Stores to image and buffer variables performed by helper invocations
125125bd8deadSopenharmony_cihave no effect on the underlying image or buffer memory.</p>
125135bd8deadSopenharmony_ci</li>
125145bd8deadSopenharmony_ci<li>
125155bd8deadSopenharmony_ci<p>Atomic operations to image, buffer, or atomic counter variables
125165bd8deadSopenharmony_ciperformed by helper invocations have no effect on the underlying image
125175bd8deadSopenharmony_cior buffer memory.
125185bd8deadSopenharmony_ciThe values returned by such atomic operations are undefined.</p>
125195bd8deadSopenharmony_ci</li>
125205bd8deadSopenharmony_ci</ul>
125215bd8deadSopenharmony_ci</div>
125225bd8deadSopenharmony_ci<div class="paragraph">
125235bd8deadSopenharmony_ci<p>Helper invocations may be generated for pixels not covered by a primitive
125245bd8deadSopenharmony_cibeing rendered.
125255bd8deadSopenharmony_ciWhile fragment shader inputs qualified with <strong>centroid</strong> are normally required
125265bd8deadSopenharmony_cito be sampled in the intersection of the pixel and the primitive, the
125275bd8deadSopenharmony_cirequirement is ignored for such pixels since there is no intersection
125285bd8deadSopenharmony_cibetween the pixel and primitive.</p>
125295bd8deadSopenharmony_ci</div>
125305bd8deadSopenharmony_ci<div class="paragraph">
125315bd8deadSopenharmony_ci<p>Helper invocations may also be generated for fragments that are covered by a
125325bd8deadSopenharmony_ciprimitive being rendered when the fragment is killed by early fragment tests
125335bd8deadSopenharmony_ci(using the <strong>early_fragment_tests</strong> qualifier) or where the implementation is
125345bd8deadSopenharmony_ciable to determine that executing the fragment shader would have no effect
125355bd8deadSopenharmony_ciother than assisting in computing derivatives for other fragment shader
125365bd8deadSopenharmony_ciinvocations.</p>
125375bd8deadSopenharmony_ci</div>
125385bd8deadSopenharmony_ci<div class="paragraph">
125395bd8deadSopenharmony_ci<p>The set of helper invocations generated when processing any set of
125405bd8deadSopenharmony_ciprimitives is implementation-dependent.</p>
125415bd8deadSopenharmony_ci</div>
125425bd8deadSopenharmony_ci<div class="paragraph">
125435bd8deadSopenharmony_ci<p><em>gl_ClipDistance</em> contains linearly interpolated values for the vertex-
125445bd8deadSopenharmony_cipipeline values written by a shader to the <em>gl_ClipDistance</em> output
125455bd8deadSopenharmony_civariable. Only elements in this array that have clipping enabled will
125465bd8deadSopenharmony_cihave defined values.</p>
125475bd8deadSopenharmony_ci</div>
125485bd8deadSopenharmony_ci<div class="paragraph">
125495bd8deadSopenharmony_ci<p>The input variable <em>gl_PrimitiveID</em> is filled with the value written to the
125505bd8deadSopenharmony_ci<em>gl_PrimitiveID</em> geometry shader output, if a geometry shader is present.
125515bd8deadSopenharmony_ciOtherwise, it is filled with the number of primitives processed by the
125525bd8deadSopenharmony_cishader since the current set of rendering primitives was started.</p>
125535bd8deadSopenharmony_ci</div>
125545bd8deadSopenharmony_ci<div class="paragraph">
125555bd8deadSopenharmony_ci<p>The input variable <em>gl_Layer</em> is filled with the value written to the
125565bd8deadSopenharmony_ci<em>gl_Layer</em> geometry shader output, if a geometry shader is present.
125575bd8deadSopenharmony_ciIf the geometry stage does not dynamically assign a value to <em>gl_Layer</em>, the
125585bd8deadSopenharmony_civalue of <em>gl_Layer</em> in the fragment stage will be undefined.
125595bd8deadSopenharmony_ciIf the geometry stage makes no static assignment to <em>gl_Layer</em>, the input
125605bd8deadSopenharmony_civalue in the fragment stage will be zero.
125615bd8deadSopenharmony_ciOtherwise, the fragment stage will read the same value written by the
125625bd8deadSopenharmony_cigeometry stage, even if that value is out of range.
125635bd8deadSopenharmony_ciIf a fragment shader contains a static access to <em>gl_Layer</em>, it will count
125645bd8deadSopenharmony_ciagainst the implementation defined limit for the maximum number of inputs to
125655bd8deadSopenharmony_cithe fragment stage.</p>
125665bd8deadSopenharmony_ci</div>
125675bd8deadSopenharmony_ci<div class="paragraph">
125685bd8deadSopenharmony_ci<p>The input variable <em>gl_ViewportIndex</em> is filled with the value written to
125695bd8deadSopenharmony_cithe output variable <em>gl_ViewportIndex</em> in the geometry stage, if a geometry
125705bd8deadSopenharmony_cishader is present.
125715bd8deadSopenharmony_ciIf the geometry stage does not dynamically assign a value to
125725bd8deadSopenharmony_ci<em>gl_ViewportIndex</em>, the value of <em>gl_ViewportIndex</em> in the fragment shader
125735bd8deadSopenharmony_ciwill be undefined.
125745bd8deadSopenharmony_ciIf the geometry stage makes no static assignment to <em>gl_ViewportIndex</em>, the
125755bd8deadSopenharmony_cifragment stage will read zero.
125765bd8deadSopenharmony_ciOtherwise, the fragment stage will read the same value written by the
125775bd8deadSopenharmony_cigeometry stage, even if that value is out of range.
125785bd8deadSopenharmony_ciIf a fragment shader contains a static access to <em>gl_ViewportIndex</em>, it will
125795bd8deadSopenharmony_cicount against the implementation defined limit for the maximum number of
125805bd8deadSopenharmony_ciinputs to the fragment stage.</p>
125815bd8deadSopenharmony_ci</div>
125825bd8deadSopenharmony_ci</div>
125835bd8deadSopenharmony_ci<div class="sect3">
125845bd8deadSopenharmony_ci<h4 id="compute-shader-special-variables">7.1.6. Compute Shader Special Variables</h4>
125855bd8deadSopenharmony_ci<div class="paragraph">
125865bd8deadSopenharmony_ci<p>In the compute shader, built-in variables are declared as follows:</p>
125875bd8deadSopenharmony_ci</div>
125885bd8deadSopenharmony_ci<div class="listingblock">
125895bd8deadSopenharmony_ci<div class="content">
125905bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="comment">// workgroup dimensions</span>
125915bd8deadSopenharmony_ciin uvec3 gl_NumWorkGroups;
125925bd8deadSopenharmony_ci<span class="directive">const</span> uvec3 gl_WorkGroupSize;
125935bd8deadSopenharmony_ci
125945bd8deadSopenharmony_ci<span class="comment">// workgroup and invocation IDs</span>
125955bd8deadSopenharmony_ciin uvec3 gl_WorkGroupID;
125965bd8deadSopenharmony_ciin uvec3 gl_LocalInvocationID;
125975bd8deadSopenharmony_ci
125985bd8deadSopenharmony_ci<span class="comment">// derived variables</span>
125995bd8deadSopenharmony_ciin uvec3 gl_GlobalInvocationID;
126005bd8deadSopenharmony_ciin uint gl_LocalInvocationIndex;</code></pre>
126015bd8deadSopenharmony_ci</div>
126025bd8deadSopenharmony_ci</div>
126035bd8deadSopenharmony_ci<div class="paragraph">
126045bd8deadSopenharmony_ci<p>The built-in variable <em>gl_NumWorkGroups</em> is a compute-shader input variable
126055bd8deadSopenharmony_cicontaining the number of workgroups in each dimension of the dispatch that
126065bd8deadSopenharmony_ciwill execute the compute shader.
126075bd8deadSopenharmony_ciIts content is equal to the values specified in the <em>num_groups_x</em>,
126085bd8deadSopenharmony_ci<em>num_groups_y</em>, and <em>num_groups_z</em> parameters passed to the
126095bd8deadSopenharmony_ci<em>DispatchCompute</em> API entry point.</p>
126105bd8deadSopenharmony_ci</div>
126115bd8deadSopenharmony_ci<div class="paragraph">
126125bd8deadSopenharmony_ci<p>The built-in constant <em>gl_WorkGroupSize</em> is a compute-shader constant
126135bd8deadSopenharmony_cicontaining the workgroup size of the shader.
126145bd8deadSopenharmony_ciThe size of the workgroup in the <em>X</em>, <em>Y</em>, and <em>Z</em> dimensions is stored in
126155bd8deadSopenharmony_cithe <em>x</em>, <em>y</em>, and <em>z</em> components.
126165bd8deadSopenharmony_ciThe constants values in <em>gl_WorkGroupSize</em> will match those specified in the
126175bd8deadSopenharmony_cirequired <strong>local_size_x</strong>, <strong>local_size_y</strong>, and <strong>local_size_z</strong> layout
126185bd8deadSopenharmony_ciqualifiers for the current shader.
126195bd8deadSopenharmony_ciThis is a constant so that it can be used to size arrays of memory that can
126205bd8deadSopenharmony_cibe shared within the workgroup.
126215bd8deadSopenharmony_ciIt is a compile-time error to use <em>gl_WorkGroupSize</em> in a shader that does
126225bd8deadSopenharmony_cinot declare a fixed workgroup size, or before that shader has declared a
126235bd8deadSopenharmony_cifixed workgroup size, using <strong>local_size_x</strong>, <strong>local_size_y</strong>, and
126245bd8deadSopenharmony_ci<strong>local_size_z</strong>.</p>
126255bd8deadSopenharmony_ci</div>
126265bd8deadSopenharmony_ci<div class="paragraph">
126275bd8deadSopenharmony_ci<p>The built-in variable <em>gl_WorkGroupID</em> is a compute-shader input variable
126285bd8deadSopenharmony_cicontaining the three-dimensional index of the workgroup that the
126295bd8deadSopenharmony_cicurrent invocation is executing in.
126305bd8deadSopenharmony_ciThe possible values range across the parameters passed into
126315bd8deadSopenharmony_ci<em>DispatchCompute</em>, i.e., from (0, 0, 0) to (<em>gl_NumWorkGroups.x</em> - 1,
126325bd8deadSopenharmony_ci<em>gl_NumWorkGroups.y</em> - 1, <em>gl_NumWorkGroups.z</em> -1).</p>
126335bd8deadSopenharmony_ci</div>
126345bd8deadSopenharmony_ci<div class="paragraph">
126355bd8deadSopenharmony_ci<p>The built-in variable <em>gl_LocalInvocationID</em> is a compute-shader input
126365bd8deadSopenharmony_civariable containing the three-dimensional index of the current work item
126375bd8deadSopenharmony_ciwithin the workgroup.
126385bd8deadSopenharmony_ciThe possible values for this variable range across the workgroup
126395bd8deadSopenharmony_cisize, i.e., (0,0,0) to (<em>gl_WorkGroupSize.x</em> - 1, <em>gl_WorkGroupSize.y</em> - 1,
126405bd8deadSopenharmony_ci<em>gl_WorkGroupSize.z</em> - 1). Use of <em>gl_LocalInvocationID</em> is allowed
126415bd8deadSopenharmony_cibefore declarations of <strong>local_size_x</strong>, <strong>local_size_y</strong>, and <strong>local_size_z</strong>.</p>
126425bd8deadSopenharmony_ci</div>
126435bd8deadSopenharmony_ci<div class="paragraph">
126445bd8deadSopenharmony_ci<p>The built-in variable <em>gl_GlobalInvocationID</em> is a compute shader input
126455bd8deadSopenharmony_civariable containing the global index of the current work item.
126465bd8deadSopenharmony_ciThis value uniquely identifies this invocation from all other invocations
126475bd8deadSopenharmony_ciacross all workgroups initiated by the current <em>DispatchCompute</em> call.
126485bd8deadSopenharmony_ciThis is computed as:</p>
126495bd8deadSopenharmony_ci</div>
126505bd8deadSopenharmony_ci<div class="listingblock">
126515bd8deadSopenharmony_ci<div class="content">
126525bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">gl_GlobalInvocationID =
126535bd8deadSopenharmony_ci    gl_WorkGroupID * gl_WorkGroupSize + gl_LocalInvocationID;</code></pre>
126545bd8deadSopenharmony_ci</div>
126555bd8deadSopenharmony_ci</div>
126565bd8deadSopenharmony_ci<div class="paragraph">
126575bd8deadSopenharmony_ci<p>The built-in variable <em>gl_LocalInvocationIndex</em> is a compute shader input
126585bd8deadSopenharmony_civariable that contains the one-dimensional representation of the
126595bd8deadSopenharmony_ci<em>gl_LocalInvocationID</em>.
126605bd8deadSopenharmony_ciThis is computed as:</p>
126615bd8deadSopenharmony_ci</div>
126625bd8deadSopenharmony_ci<div class="listingblock">
126635bd8deadSopenharmony_ci<div class="content">
126645bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">gl_LocalInvocationIndex =
126655bd8deadSopenharmony_ci    gl_LocalInvocationID.z * gl_WorkGroupSize.x * gl_WorkGroupSize.y +
126665bd8deadSopenharmony_ci    gl_LocalInvocationID.y * gl_WorkGroupSize.x +
126675bd8deadSopenharmony_ci    gl_LocalInvocationID.x;</code></pre>
126685bd8deadSopenharmony_ci</div>
126695bd8deadSopenharmony_ci</div>
126705bd8deadSopenharmony_ci<div class="paragraph">
126715bd8deadSopenharmony_ci<p>Use of <em>gl_LocalInvocationIndex</em> is allowed before declarations of
126725bd8deadSopenharmony_ci<strong>local_size_x</strong>, <strong>local_size_y</strong>, and <strong>local_size_z</strong>.</p>
126735bd8deadSopenharmony_ci</div>
126745bd8deadSopenharmony_ci</div>
126755bd8deadSopenharmony_ci<div class="sect3">
126765bd8deadSopenharmony_ci<h4 id="compatibility-profile-built-in-language-variables">7.1.7. Compatibility Profile Built-In Language Variables</h4>
126775bd8deadSopenharmony_ci<div class="paragraph">
126785bd8deadSopenharmony_ci<p>When using the compatibility profile, the GL can provide fixed functionality
126795bd8deadSopenharmony_cibehavior for the vertex and fragment programmable pipeline stages.
126805bd8deadSopenharmony_ciFor example, mixing a fixed functionality vertex stage with a programmable
126815bd8deadSopenharmony_cifragment stage.</p>
126825bd8deadSopenharmony_ci</div>
126835bd8deadSopenharmony_ci<div class="paragraph">
126845bd8deadSopenharmony_ci<p>The following built-in vertex, tessellation control, tessellation
126855bd8deadSopenharmony_cievaluation, and geometry output variables are available to specify inputs
126865bd8deadSopenharmony_cifor the subsequent programmable shader stage or the fixed functionality
126875bd8deadSopenharmony_cifragment stage.
126885bd8deadSopenharmony_ciA particular one should be written to if any functionality in a
126895bd8deadSopenharmony_cicorresponding fragment shader or fixed pipeline uses it or state derived
126905bd8deadSopenharmony_cifrom it.
126915bd8deadSopenharmony_ciOtherwise, behavior is undefined.
126925bd8deadSopenharmony_ciThe following members are added to the output <em>gl_PerVertex</em> block in these
126935bd8deadSopenharmony_cilanguages:</p>
126945bd8deadSopenharmony_ci</div>
126955bd8deadSopenharmony_ci<div class="listingblock">
126965bd8deadSopenharmony_ci<div class="content">
126975bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">out gl_PerVertex { <span class="comment">// part of the gl_PerVertex block described in 7.1</span>
126985bd8deadSopenharmony_ci    <span class="comment">// in addition to other gl_PerVertex members...</span>
126995bd8deadSopenharmony_ci    vec4  gl_ClipVertex;
127005bd8deadSopenharmony_ci    vec4  gl_FrontColor;
127015bd8deadSopenharmony_ci    vec4  gl_BackColor;
127025bd8deadSopenharmony_ci    vec4  gl_FrontSecondaryColor;
127035bd8deadSopenharmony_ci    vec4  gl_BackSecondaryColor;
127045bd8deadSopenharmony_ci    vec4  gl_TexCoord[];
127055bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_FogFragCoord;
127065bd8deadSopenharmony_ci};</code></pre>
127075bd8deadSopenharmony_ci</div>
127085bd8deadSopenharmony_ci</div>
127095bd8deadSopenharmony_ci<div class="paragraph">
127105bd8deadSopenharmony_ci<p>The output variable <em>gl_ClipVertex</em> provides a place for vertex and geometry
127115bd8deadSopenharmony_cishaders to write the coordinate to be used with the user clipping planes.
127125bd8deadSopenharmony_ciWriting to <em>gl_ClipDistance</em> is the preferred method for user clipping.
127135bd8deadSopenharmony_ciIt is a compile-time or link-time error for the set of shaders forming a
127145bd8deadSopenharmony_ciprogram to statically read or write both <em>gl_ClipVertex</em> and either
127155bd8deadSopenharmony_ci<em>gl_ClipDistance</em> or <em>gl_CullDistance</em>.
127165bd8deadSopenharmony_ciIf neither <em>gl_ClipVertex</em> nor <em>gl_ClipDistance</em> is written, their values
127175bd8deadSopenharmony_ciare undefined and any clipping against user clip planes is also undefined.</p>
127185bd8deadSopenharmony_ci</div>
127195bd8deadSopenharmony_ci<div class="paragraph">
127205bd8deadSopenharmony_ci<p>Similarly to what was previously described for the core profile, the
127215bd8deadSopenharmony_ci<em>gl_PerVertex</em> block can be redeclared in a shader to explicitly include
127225bd8deadSopenharmony_cithese additional members.
127235bd8deadSopenharmony_ciFor example:</p>
127245bd8deadSopenharmony_ci</div>
127255bd8deadSopenharmony_ci<div class="listingblock">
127265bd8deadSopenharmony_ci<div class="content">
127275bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">out gl_PerVertex {
127285bd8deadSopenharmony_ci    vec4 gl_Position;    <span class="comment">// will use gl_Position</span>
127295bd8deadSopenharmony_ci    vec4 gl_FrontColor;  <span class="comment">// will consume gl_color in the fragment shader</span>
127305bd8deadSopenharmony_ci    vec4 gl_BackColor;
127315bd8deadSopenharmony_ci    vec4 gl_TexCoord[<span class="integer">3</span>]; <span class="comment">// 3 elements of gl_TexCoord will be used</span>
127325bd8deadSopenharmony_ci}; <span class="comment">// no other aspects of the fixed interface will be used</span></code></pre>
127335bd8deadSopenharmony_ci</div>
127345bd8deadSopenharmony_ci</div>
127355bd8deadSopenharmony_ci<div class="paragraph">
127365bd8deadSopenharmony_ci<p>The user must ensure the clip vertex and user clipping planes are defined in
127375bd8deadSopenharmony_cithe same coordinate space.
127385bd8deadSopenharmony_ciUser clip planes work properly only under linear transform.
127395bd8deadSopenharmony_ciIt is undefined what happens under non-linear transform.</p>
127405bd8deadSopenharmony_ci</div>
127415bd8deadSopenharmony_ci<div class="paragraph">
127425bd8deadSopenharmony_ci<p>The output variables <em>gl_FrontColor</em>, <em>glFrontSecondaryColor</em>,
127435bd8deadSopenharmony_ci<em>gl_BackColor</em>, and <em>glBackSecondaryColor</em> assign primary and secondary
127445bd8deadSopenharmony_cicolors for front and back faces of primitives containing the vertex being
127455bd8deadSopenharmony_ciprocessed.
127465bd8deadSopenharmony_ciThe output variable <em>gl_TexCoord</em> assigns texture coordinates for the vertex
127475bd8deadSopenharmony_cibeing processed.</p>
127485bd8deadSopenharmony_ci</div>
127495bd8deadSopenharmony_ci<div class="paragraph">
127505bd8deadSopenharmony_ci<p>For <em>gl_FogFragCoord</em>, the value written will be used as the &#8220;c&#8221; value in
127515bd8deadSopenharmony_cisection 16.4 &#8220;Fog&#8221; of the Compatibility profile of the
127525bd8deadSopenharmony_ci<a href="#references">OpenGL Specification</a>, by the fixed functionality pipeline.
127535bd8deadSopenharmony_ciFor example, if the z-coordinate of the fragment in eye space is desired as
127545bd8deadSopenharmony_ci&#8220;c&#8221;, then that&#8217;s what the vertex shader executable should write into
127555bd8deadSopenharmony_ci<em>gl_FogFragCoord</em>.</p>
127565bd8deadSopenharmony_ci</div>
127575bd8deadSopenharmony_ci<div class="paragraph">
127585bd8deadSopenharmony_ci<p>As with all arrays, indices used to subscript <em>gl_TexCoord</em> must either be a
127595bd8deadSopenharmony_ciconstant integral expressions, or this array must be redeclared by the
127605bd8deadSopenharmony_cishader with a size.
127615bd8deadSopenharmony_ciThe size can be at most <em>gl_MaxTextureCoords</em>.
127625bd8deadSopenharmony_ciUsing indices close to 0 may aid the implementation in preserving varying
127635bd8deadSopenharmony_ciresources.
127645bd8deadSopenharmony_ciThe redeclaration of <em>gl_TexCoord</em> can also be done at global scope as, for
127655bd8deadSopenharmony_ciexample:</p>
127665bd8deadSopenharmony_ci</div>
127675bd8deadSopenharmony_ci<div class="listingblock">
127685bd8deadSopenharmony_ci<div class="content">
127695bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">in vec4 gl_TexCoord[<span class="integer">3</span>];
127705bd8deadSopenharmony_ciout vec4 gl_TexCoord[<span class="integer">4</span>];</code></pre>
127715bd8deadSopenharmony_ci</div>
127725bd8deadSopenharmony_ci</div>
127735bd8deadSopenharmony_ci<div class="paragraph">
127745bd8deadSopenharmony_ci<p>(This treatment is a special case for <em>gl_TexCoord[]</em>, not a general method
127755bd8deadSopenharmony_cifor redeclaring members of blocks.) It is a compile-time error to redeclare
127765bd8deadSopenharmony_ci<em>gl_TexCoord[]</em> at global scope if there is a redeclaration of the
127775bd8deadSopenharmony_cicorresponding built-in block; only one form of redeclaration is allowed
127785bd8deadSopenharmony_ciwithin a shader (and hence within a stage, as block redeclarations must
127795bd8deadSopenharmony_cimatch across all shaders using it).</p>
127805bd8deadSopenharmony_ci</div>
127815bd8deadSopenharmony_ci<div class="paragraph">
127825bd8deadSopenharmony_ci<p>In the tessellation control, evaluation, and geometry shaders, the outputs
127835bd8deadSopenharmony_ciof the previous stage described above are also available in the input
127845bd8deadSopenharmony_ci<em>gl_PerVertex</em> block in these languages.</p>
127855bd8deadSopenharmony_ci</div>
127865bd8deadSopenharmony_ci<div class="listingblock">
127875bd8deadSopenharmony_ci<div class="content">
127885bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">in gl_PerVertex { <span class="comment">// part of the gl_PerVertex block described in 7.1</span>
127895bd8deadSopenharmony_ci    <span class="comment">// in addition to other gl_PerVertex members...</span>
127905bd8deadSopenharmony_ci    vec4  gl_ClipVertex;
127915bd8deadSopenharmony_ci    vec4  gl_FrontColor;
127925bd8deadSopenharmony_ci    vec4  gl_BackColor;
127935bd8deadSopenharmony_ci    vec4  gl_FrontSecondaryColor;
127945bd8deadSopenharmony_ci    vec4  gl_BackSecondaryColor;
127955bd8deadSopenharmony_ci    vec4  gl_TexCoord[];
127965bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_FogFragCoord;
127975bd8deadSopenharmony_ci} gl_in[];</code></pre>
127985bd8deadSopenharmony_ci</div>
127995bd8deadSopenharmony_ci</div>
128005bd8deadSopenharmony_ci<div class="paragraph">
128015bd8deadSopenharmony_ci<p>These can be redeclared to establish an explicit pipeline interface, the
128025bd8deadSopenharmony_cisame way as described above for the output block <em>gl_PerVertex</em>, and the
128035bd8deadSopenharmony_ciinput redeclaration must match the output redeclaration of the previous
128045bd8deadSopenharmony_cistage.
128055bd8deadSopenharmony_ciHowever, when a built-in interface block with an instance name is redeclared
128065bd8deadSopenharmony_ci(e.g. <em>gl_in</em>), the instance name must be included in the redeclaration.
128075bd8deadSopenharmony_ciIt is a compile-time error to not include the built-in instance name or to
128085bd8deadSopenharmony_cichange its name.
128095bd8deadSopenharmony_ciFor example,</p>
128105bd8deadSopenharmony_ci</div>
128115bd8deadSopenharmony_ci<div class="listingblock">
128125bd8deadSopenharmony_ci<div class="content">
128135bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">in gl_PerVertex {
128145bd8deadSopenharmony_ci    vec4 gl_ClipVertex;
128155bd8deadSopenharmony_ci    vec4 gl_FrontColor;
128165bd8deadSopenharmony_ci} gl_in[]; <span class="comment">// must be present and must be &quot;gl_in[]&quot;</span></code></pre>
128175bd8deadSopenharmony_ci</div>
128185bd8deadSopenharmony_ci</div>
128195bd8deadSopenharmony_ci<div class="paragraph">
128205bd8deadSopenharmony_ci<p>Built-in block arrays predeclared with a size can be redeclared with unsized syntax.
128215bd8deadSopenharmony_ciThis keeps their size equal to the original predeclared size.</p>
128225bd8deadSopenharmony_ci</div>
128235bd8deadSopenharmony_ci<div class="paragraph">
128245bd8deadSopenharmony_ci<p>Treatment of <em>gl_TexCoord[]</em> redeclaration is also identical to that
128255bd8deadSopenharmony_cidescribed for the output block <em>gl_TexCoord[]</em> redeclaration.</p>
128265bd8deadSopenharmony_ci</div>
128275bd8deadSopenharmony_ci<div class="paragraph">
128285bd8deadSopenharmony_ci<p>The following fragment input block is also available in a fragment shader
128295bd8deadSopenharmony_ciwhen using the compatibility profile:</p>
128305bd8deadSopenharmony_ci</div>
128315bd8deadSopenharmony_ci<div class="listingblock">
128325bd8deadSopenharmony_ci<div class="content">
128335bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">in gl_PerFragment {
128345bd8deadSopenharmony_ci    in <span class="predefined-type">float</span> gl_FogFragCoord;
128355bd8deadSopenharmony_ci    in vec4  gl_TexCoord[];
128365bd8deadSopenharmony_ci    in vec4  gl_Color;
128375bd8deadSopenharmony_ci    in vec4  gl_SecondaryColor;
128385bd8deadSopenharmony_ci};</code></pre>
128395bd8deadSopenharmony_ci</div>
128405bd8deadSopenharmony_ci</div>
128415bd8deadSopenharmony_ci<div class="paragraph">
128425bd8deadSopenharmony_ci<p>The values in <em>gl_Color</em> and <em>gl_SecondaryColor</em> will be derived
128435bd8deadSopenharmony_ciautomatically by the system from <em>gl_FrontColor</em>, <em>gl_BackColor</em>,
128445bd8deadSopenharmony_ci<em>gl_FrontSecondaryColor</em>, and <em>gl_BackSecondaryColor</em> based on which face is
128455bd8deadSopenharmony_civisible in the primitive producing the fragment.
128465bd8deadSopenharmony_ciIf fixed functionality is used for vertex processing, then <em>gl_FogFragCoord</em>
128475bd8deadSopenharmony_ciwill either be the z-coordinate of the fragment in eye space, or the
128485bd8deadSopenharmony_ciinterpolation of the fog coordinate, as described in section 16.4 &#8220;Fog&#8221; of
128495bd8deadSopenharmony_cithe Compatibility profile of the <a href="#references">OpenGL Specification</a>.
128505bd8deadSopenharmony_ciThe <em>gl_TexCoord[]</em> values are the interpolated <em>gl_TexCoord[]</em> values from
128515bd8deadSopenharmony_cia vertex shader or the texture coordinates of any fixed pipeline based
128525bd8deadSopenharmony_civertex functionality.</p>
128535bd8deadSopenharmony_ci</div>
128545bd8deadSopenharmony_ci<div class="paragraph">
128555bd8deadSopenharmony_ci<p>Indices to the fragment shader <em>gl_TexCoord</em> array are as described above in
128565bd8deadSopenharmony_cithe vertex shader text.</p>
128575bd8deadSopenharmony_ci</div>
128585bd8deadSopenharmony_ci<div class="paragraph">
128595bd8deadSopenharmony_ci<p>As described above for the input and output <em>gl_PerVertex</em> blocks, the
128605bd8deadSopenharmony_ci<em>gl_PerFragment</em> block can be redeclared to create an explicit interface to
128615bd8deadSopenharmony_cianother program.
128625bd8deadSopenharmony_ciWhen matching these interfaces between separate programs, members in the
128635bd8deadSopenharmony_ci<em>gl_PerVertex</em> output block must be declared if and only if the
128645bd8deadSopenharmony_cicorresponding fragment shader members generated from them are present in the
128655bd8deadSopenharmony_ci<em>gl_PerFragment</em> input block.
128665bd8deadSopenharmony_ciThese matches are described in detail in section 7.4.1 &#8220;Shader Interface
128675bd8deadSopenharmony_ciMatching&#8221; of the <a href="#references">OpenGL Specification</a>.
128685bd8deadSopenharmony_ciIf they don&#8217;t match within a program, a link-time error will result.
128695bd8deadSopenharmony_ciIf the mismatch is between two programs, values passed between programs are
128705bd8deadSopenharmony_ciundefined.
128715bd8deadSopenharmony_ciUnlike with all other block matching, the order of declaration within
128725bd8deadSopenharmony_ci<em>gl_PerFragment</em> does not have to match across shaders and does not have to
128735bd8deadSopenharmony_cicorrespond with order of declaration in a matching <em>gl_PerVertex</em>
128745bd8deadSopenharmony_ciredeclaration.</p>
128755bd8deadSopenharmony_ci</div>
128765bd8deadSopenharmony_ci<div class="paragraph">
128775bd8deadSopenharmony_ci<p>The following fragment output variables are available in a fragment shader
128785bd8deadSopenharmony_ciwhen using the compatibility profile:</p>
128795bd8deadSopenharmony_ci</div>
128805bd8deadSopenharmony_ci<div class="listingblock">
128815bd8deadSopenharmony_ci<div class="content">
128825bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">out vec4 gl_FragColor;
128835bd8deadSopenharmony_ciout vec4 gl_FragData[gl_MaxDrawBuffers];</code></pre>
128845bd8deadSopenharmony_ci</div>
128855bd8deadSopenharmony_ci</div>
128865bd8deadSopenharmony_ci<div class="paragraph">
128875bd8deadSopenharmony_ci<p>Writing to <em>gl_FragColor</em> specifies the fragment color that will be used by
128885bd8deadSopenharmony_cithe subsequent fixed functionality pipeline.
128895bd8deadSopenharmony_ciIf subsequent fixed functionality consumes fragment color and an execution
128905bd8deadSopenharmony_ciof the fragment shader executable does not write a value to <em>gl_FragColor</em>
128915bd8deadSopenharmony_cithen the fragment color consumed is undefined.</p>
128925bd8deadSopenharmony_ci</div>
128935bd8deadSopenharmony_ci<div class="paragraph">
128945bd8deadSopenharmony_ci<p>The variable <em>gl_FragData</em> is an array.
128955bd8deadSopenharmony_ciWriting to <em>gl_FragData[n]</em> specifies the fragment data that will be used by
128965bd8deadSopenharmony_cithe subsequent fixed functionality pipeline for data <em>n</em>.
128975bd8deadSopenharmony_ciIf subsequent fixed functionality consumes fragment data and an execution of
128985bd8deadSopenharmony_cia fragment shader executable does not write a value to it, then the fragment
128995bd8deadSopenharmony_cidata consumed is undefined.</p>
129005bd8deadSopenharmony_ci</div>
129015bd8deadSopenharmony_ci<div class="paragraph">
129025bd8deadSopenharmony_ci<p>If a shader statically assigns a value to <em>gl_FragColor</em>, it may not assign
129035bd8deadSopenharmony_cia value to any element of <em>gl_FragData</em>.
129045bd8deadSopenharmony_ciIf a shader statically writes a value to any element of <em>gl_FragData</em>, it
129055bd8deadSopenharmony_cimay not assign a value to <em>gl_FragColor</em>.
129065bd8deadSopenharmony_ciThat is, a shader may assign values to either <em>gl_FragColor</em> or
129075bd8deadSopenharmony_ci<em>gl_FragData</em>, but not both.
129085bd8deadSopenharmony_ciMultiple shaders linked together must also consistently write just one of
129095bd8deadSopenharmony_cithese variables.
129105bd8deadSopenharmony_ciSimilarly, if user-declared output variables are in use (statically assigned
129115bd8deadSopenharmony_cito), then the built-in variables <em>gl_FragColor</em> and <em>gl_FragData</em> may not be
129125bd8deadSopenharmony_ciassigned to.
129135bd8deadSopenharmony_ciThese incorrect usages all generate compile-time or link-time errors.</p>
129145bd8deadSopenharmony_ci</div>
129155bd8deadSopenharmony_ci<div class="paragraph">
129165bd8deadSopenharmony_ci<p>If a shader executes the <strong>discard</strong> keyword, the fragment is discarded, and
129175bd8deadSopenharmony_cithe values of <em>gl_FragDepth</em> and <em>gl_FragColor</em> become irrelevant.</p>
129185bd8deadSopenharmony_ci</div>
129195bd8deadSopenharmony_ci</div>
129205bd8deadSopenharmony_ci</div>
129215bd8deadSopenharmony_ci<div class="sect2">
129225bd8deadSopenharmony_ci<h3 id="compatibility-profile-vertex-shader-built-in-inputs">7.2. Compatibility Profile Vertex Shader Built-In Inputs</h3>
129235bd8deadSopenharmony_ci<div class="paragraph">
129245bd8deadSopenharmony_ci<p>The following predeclared input names can be used from within a vertex
129255bd8deadSopenharmony_cishader to access the current values of OpenGL state when using the
129265bd8deadSopenharmony_cicompatibility profile.</p>
129275bd8deadSopenharmony_ci</div>
129285bd8deadSopenharmony_ci<div class="listingblock">
129295bd8deadSopenharmony_ci<div class="content">
129305bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">in vec4 gl_Color;
129315bd8deadSopenharmony_ciin vec4 gl_SecondaryColor;
129325bd8deadSopenharmony_ciin vec3 gl_Normal;
129335bd8deadSopenharmony_ciin vec4 gl_Vertex;
129345bd8deadSopenharmony_ciin vec4 gl_MultiTexCoord0;
129355bd8deadSopenharmony_ciin vec4 gl_MultiTexCoord1;
129365bd8deadSopenharmony_ciin vec4 gl_MultiTexCoord2;
129375bd8deadSopenharmony_ciin vec4 gl_MultiTexCoord3;
129385bd8deadSopenharmony_ciin vec4 gl_MultiTexCoord4;
129395bd8deadSopenharmony_ciin vec4 gl_MultiTexCoord5;
129405bd8deadSopenharmony_ciin vec4 gl_MultiTexCoord6;
129415bd8deadSopenharmony_ciin vec4 gl_MultiTexCoord7;
129425bd8deadSopenharmony_ciin <span class="predefined-type">float</span> gl_FogCoord;</code></pre>
129435bd8deadSopenharmony_ci</div>
129445bd8deadSopenharmony_ci</div>
129455bd8deadSopenharmony_ci</div>
129465bd8deadSopenharmony_ci<div class="sect2">
129475bd8deadSopenharmony_ci<h3 id="built-in-constants">7.3. Built-In Constants</h3>
129485bd8deadSopenharmony_ci<div class="paragraph">
129495bd8deadSopenharmony_ci<p>The following built-in constants are declared in all shaders.
129505bd8deadSopenharmony_ciThe actual values used are implementation-dependent, but must be at least
129515bd8deadSopenharmony_cithe value shown.</p>
129525bd8deadSopenharmony_ci</div>
129535bd8deadSopenharmony_ci<div class="listingblock">
129545bd8deadSopenharmony_ci<div class="content">
129555bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="comment">//</span>
129565bd8deadSopenharmony_ci<span class="comment">// Implementation-dependent constants. The example values below</span>
129575bd8deadSopenharmony_ci<span class="comment">// are the minimum values allowed for these maximums.</span>
129585bd8deadSopenharmony_ci<span class="comment">//</span></code></pre>
129595bd8deadSopenharmony_ci</div>
129605bd8deadSopenharmony_ci</div>
129615bd8deadSopenharmony_ci<div class="listingblock">
129625bd8deadSopenharmony_ci<div class="content">
129635bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxVertexAttribs = <span class="integer">16</span>;
129645bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxVertexUniformVectors = <span class="integer">256</span>;
129655bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxVertexUniformComponents = <span class="integer">1024</span>;
129665bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxVertexOutputComponents = <span class="integer">64</span>;
129675bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxVaryingComponents = <span class="integer">60</span>;
129685bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxVaryingVectors = <span class="integer">15</span>;
129695bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxVertexTextureImageUnits = <span class="integer">16</span>;
129705bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxVertexImageUniforms = <span class="integer">0</span>;
129715bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxVertexAtomicCounters = <span class="integer">0</span>;
129725bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxVertexAtomicCounterBuffers = <span class="integer">0</span>;
129735bd8deadSopenharmony_ci
129745bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTessPatchComponents = <span class="integer">120</span>;
129755bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxPatchVertices = <span class="integer">32</span>;
129765bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTessGenLevel = <span class="integer">64</span>;
129775bd8deadSopenharmony_ci
129785bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTessControlInputComponents = <span class="integer">128</span>;
129795bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTessControlOutputComponents = <span class="integer">128</span>;
129805bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTessControlTextureImageUnits = <span class="integer">16</span>;
129815bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTessControlUniformComponents = <span class="integer">1024</span>;
129825bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTessControlTotalOutputComponents = <span class="integer">4096</span>;
129835bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTessControlImageUniforms = <span class="integer">0</span>;
129845bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTessControlAtomicCounters = <span class="integer">0</span>;
129855bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTessControlAtomicCounterBuffers = <span class="integer">0</span>;
129865bd8deadSopenharmony_ci
129875bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTessEvaluationInputComponents = <span class="integer">128</span>;
129885bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTessEvaluationOutputComponents = <span class="integer">128</span>;
129895bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTessEvaluationTextureImageUnits = <span class="integer">16</span>;
129905bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTessEvaluationUniformComponents = <span class="integer">1024</span>;
129915bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTessEvaluationImageUniforms = <span class="integer">0</span>;
129925bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTessEvaluationAtomicCounters = <span class="integer">0</span>;
129935bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTessEvaluationAtomicCounterBuffers = <span class="integer">0</span>;
129945bd8deadSopenharmony_ci
129955bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxGeometryInputComponents = <span class="integer">64</span>;
129965bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxGeometryOutputComponents = <span class="integer">128</span>;
129975bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxGeometryImageUniforms = <span class="integer">0</span>;
129985bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxGeometryTextureImageUnits = <span class="integer">16</span>;
129995bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxGeometryOutputVertices = <span class="integer">256</span>;
130005bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxGeometryTotalOutputComponents = <span class="integer">1024</span>;
130015bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxGeometryUniformComponents = <span class="integer">1024</span>;
130025bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxGeometryVaryingComponents = <span class="integer">64</span>;            <span class="comment">// deprecated</span>
130035bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxGeometryAtomicCounters = <span class="integer">0</span>;
130045bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxGeometryAtomicCounterBuffers = <span class="integer">0</span>;
130055bd8deadSopenharmony_ci
130065bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxFragmentImageUniforms = <span class="integer">8</span>;
130075bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxFragmentInputComponents = <span class="integer">128</span>;
130085bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxFragmentUniformVectors = <span class="integer">256</span>;
130095bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxFragmentUniformComponents = <span class="integer">1024</span>;
130105bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxFragmentAtomicCounters = <span class="integer">8</span>;
130115bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxFragmentAtomicCounterBuffers = <span class="integer">1</span>;
130125bd8deadSopenharmony_ci
130135bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxDrawBuffers = <span class="integer">8</span>;
130145bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTextureImageUnits = <span class="integer">16</span>;
130155bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MinProgramTexelOffset = -<span class="integer">8</span>;
130165bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxProgramTexelOffset = <span class="integer">7</span>;
130175bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxImageUnits = <span class="integer">8</span>;
130185bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxSamples = <span class="integer">4</span>;
130195bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxImageSamples = <span class="integer">0</span>;
130205bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxClipDistances = <span class="integer">8</span>;
130215bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxCullDistances = <span class="integer">8</span>;
130225bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxViewports = <span class="integer">16</span>;
130235bd8deadSopenharmony_ci
130245bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxComputeImageUniforms = <span class="integer">8</span>;
130255bd8deadSopenharmony_ci<span class="directive">const</span> ivec3 gl_MaxComputeWorkGroupCount = { <span class="integer">65535</span>, <span class="integer">65535</span>, <span class="integer">65535</span> };
130265bd8deadSopenharmony_ci<span class="directive">const</span> ivec3 gl_MaxComputeWorkGroupSize = { <span class="integer">1024</span>, <span class="integer">1024</span>, <span class="integer">64</span> };
130275bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxComputeUniformComponents = <span class="integer">1024</span>;
130285bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxComputeTextureImageUnits = <span class="integer">16</span>;
130295bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxComputeAtomicCounters = <span class="integer">8</span>;
130305bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxComputeAtomicCounterBuffers = <span class="integer">8</span>;
130315bd8deadSopenharmony_ci
130325bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxCombinedTextureImageUnits = <span class="integer">96</span>;
130335bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxCombinedImageUniforms = <span class="integer">48</span>;
130345bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxCombinedImageUnitsAndFragmentOutputs = <span class="integer">8</span>;  <span class="comment">// deprecated</span>
130355bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxCombinedShaderOutputResources = <span class="integer">16</span>;
130365bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxCombinedAtomicCounters = <span class="integer">8</span>;
130375bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxCombinedAtomicCounterBuffers = <span class="integer">1</span>;
130385bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxCombinedClipAndCullDistances = <span class="integer">8</span>;
130395bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxAtomicCounterBindings = <span class="integer">1</span>;
130405bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxAtomicCounterBufferSize = <span class="integer">32</span>;
130415bd8deadSopenharmony_ci
130425bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTransformFeedbackBuffers = <span class="integer">4</span>;
130435bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTransformFeedbackInterleavedComponents = <span class="integer">64</span>;
130445bd8deadSopenharmony_ci
130455bd8deadSopenharmony_ci<span class="directive">const</span> highp <span class="predefined-type">int</span> gl_MaxInputAttachments = <span class="integer">1</span>;  <span class="comment">// only present when targeting Vulkan</span></code></pre>
130465bd8deadSopenharmony_ci</div>
130475bd8deadSopenharmony_ci</div>
130485bd8deadSopenharmony_ci<div class="paragraph">
130495bd8deadSopenharmony_ci<p>The constant <em>gl_MaxVaryingFloats</em> is removed in the core profile, use
130505bd8deadSopenharmony_ci<em>gl_MaxVaryingComponents</em> instead.</p>
130515bd8deadSopenharmony_ci</div>
130525bd8deadSopenharmony_ci<div class="sect3">
130535bd8deadSopenharmony_ci<h4 id="compatibility-profile-built-in-constants">7.3.1. Compatibility Profile Built-In Constants</h4>
130545bd8deadSopenharmony_ci<div class="listingblock">
130555bd8deadSopenharmony_ci<div class="content">
130565bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTextureUnits = <span class="integer">2</span>;
130575bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxTextureCoords = <span class="integer">8</span>;
130585bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxClipPlanes = <span class="integer">8</span>;
130595bd8deadSopenharmony_ci<span class="directive">const</span> <span class="predefined-type">int</span> gl_MaxVaryingFloats = <span class="integer">60</span>;</code></pre>
130605bd8deadSopenharmony_ci</div>
130615bd8deadSopenharmony_ci</div>
130625bd8deadSopenharmony_ci</div>
130635bd8deadSopenharmony_ci</div>
130645bd8deadSopenharmony_ci<div class="sect2">
130655bd8deadSopenharmony_ci<h3 id="built-in-uniform-state">7.4. Built-In Uniform State</h3>
130665bd8deadSopenharmony_ci<div class="paragraph">
130675bd8deadSopenharmony_ci<p>Built-in uniform state is not available when generating SPIR-V.
130685bd8deadSopenharmony_ciOtherwise, as an aid to accessing OpenGL processing state, the following
130695bd8deadSopenharmony_ciuniform variables are built into the OpenGL Shading Language.</p>
130705bd8deadSopenharmony_ci</div>
130715bd8deadSopenharmony_ci<div class="listingblock">
130725bd8deadSopenharmony_ci<div class="content">
130735bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="comment">//</span>
130745bd8deadSopenharmony_ci<span class="comment">// Depth range in window coordinates,</span>
130755bd8deadSopenharmony_ci<span class="comment">// section 13.6.1 &quot;Controlling the Viewport&quot; in the</span>
130765bd8deadSopenharmony_ci<span class="comment">// OpenGL Specification.</span>
130775bd8deadSopenharmony_ci<span class="comment">//</span>
130785bd8deadSopenharmony_ci<span class="comment">// Note: Depth-range state is only for viewport 0.</span>
130795bd8deadSopenharmony_ci<span class="comment">//</span>
130805bd8deadSopenharmony_ci<span class="keyword">struct</span> gl_DepthRangeParameters {
130815bd8deadSopenharmony_ci    <span class="predefined-type">float</span> near; <span class="comment">// n</span>
130825bd8deadSopenharmony_ci    <span class="predefined-type">float</span> far;  <span class="comment">// f</span>
130835bd8deadSopenharmony_ci    <span class="predefined-type">float</span> diff; <span class="comment">// f - n</span>
130845bd8deadSopenharmony_ci};
130855bd8deadSopenharmony_ciuniform gl_DepthRangeParameters gl_DepthRange;
130865bd8deadSopenharmony_ciuniform <span class="predefined-type">int</span> gl_NumSamples;</code></pre>
130875bd8deadSopenharmony_ci</div>
130885bd8deadSopenharmony_ci</div>
130895bd8deadSopenharmony_ci<div class="paragraph">
130905bd8deadSopenharmony_ci<p>These variables are only guaranteed to be available in the fragment stage.
130915bd8deadSopenharmony_ciIn other stages, their presence and function is implementation-defined.</p>
130925bd8deadSopenharmony_ci</div>
130935bd8deadSopenharmony_ci<div class="sect3">
130945bd8deadSopenharmony_ci<h4 id="compatibility-profile-state">7.4.1. Compatibility Profile State</h4>
130955bd8deadSopenharmony_ci<div class="paragraph">
130965bd8deadSopenharmony_ci<p>These variables are present only in the compatibility profile.
130975bd8deadSopenharmony_ciThey are not available to compute shaders, but are available to all other
130985bd8deadSopenharmony_cishaders.</p>
130995bd8deadSopenharmony_ci</div>
131005bd8deadSopenharmony_ci<div class="listingblock">
131015bd8deadSopenharmony_ci<div class="content">
131025bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="comment">//</span>
131035bd8deadSopenharmony_ci<span class="comment">// compatibility profile only</span>
131045bd8deadSopenharmony_ci<span class="comment">//</span>
131055bd8deadSopenharmony_ciuniform mat4 gl_ModelViewMatrix;
131065bd8deadSopenharmony_ciuniform mat4 gl_ProjectionMatrix;
131075bd8deadSopenharmony_ciuniform mat4 gl_ModelViewProjectionMatrix;
131085bd8deadSopenharmony_ciuniform mat4 gl_TextureMatrix[gl_MaxTextureCoords];
131095bd8deadSopenharmony_ci
131105bd8deadSopenharmony_ci<span class="comment">//</span>
131115bd8deadSopenharmony_ci<span class="comment">// compatibility profile only</span>
131125bd8deadSopenharmony_ci<span class="comment">//</span>
131135bd8deadSopenharmony_ciuniform mat3 gl_NormalMatrix; <span class="comment">// transpose of the inverse of the</span>
131145bd8deadSopenharmony_ci                              <span class="comment">// upper leftmost 3x3 of gl_ModelViewMatrix</span>
131155bd8deadSopenharmony_ci
131165bd8deadSopenharmony_ciuniform mat4 gl_ModelViewMatrixInverse;
131175bd8deadSopenharmony_ciuniform mat4 gl_ProjectionMatrixInverse;
131185bd8deadSopenharmony_ciuniform mat4 gl_ModelViewProjectionMatrixInverse;
131195bd8deadSopenharmony_ciuniform mat4 gl_TextureMatrixInverse[gl_MaxTextureCoords];
131205bd8deadSopenharmony_ci
131215bd8deadSopenharmony_ciuniform mat4 gl_ModelViewMatrixTranspose;
131225bd8deadSopenharmony_ciuniform mat4 gl_ProjectionMatrixTranspose;
131235bd8deadSopenharmony_ciuniform mat4 gl_ModelViewProjectionMatrixTranspose;
131245bd8deadSopenharmony_ciuniform mat4 gl_TextureMatrixTranspose[gl_MaxTextureCoords];
131255bd8deadSopenharmony_ci
131265bd8deadSopenharmony_ciuniform mat4 gl_ModelViewMatrixInverseTranspose;
131275bd8deadSopenharmony_ciuniform mat4 gl_ProjectionMatrixInverseTranspose;
131285bd8deadSopenharmony_ciuniform mat4 gl_ModelViewProjectionMatrixInverseTranspose;
131295bd8deadSopenharmony_ciuniform mat4 gl_TextureMatrixInverseTranspose[gl_MaxTextureCoords];
131305bd8deadSopenharmony_ci
131315bd8deadSopenharmony_ci<span class="comment">//</span>
131325bd8deadSopenharmony_ci<span class="comment">// compatibility profile only</span>
131335bd8deadSopenharmony_ci<span class="comment">//</span>
131345bd8deadSopenharmony_ciuniform <span class="predefined-type">float</span> gl_NormalScale;
131355bd8deadSopenharmony_ci
131365bd8deadSopenharmony_ci<span class="comment">//</span>
131375bd8deadSopenharmony_ci<span class="comment">// compatibility profile only</span>
131385bd8deadSopenharmony_ci<span class="comment">//</span>
131395bd8deadSopenharmony_ciuniform vec4 gl_ClipPlane[gl_MaxClipPlanes];
131405bd8deadSopenharmony_ci
131415bd8deadSopenharmony_ci<span class="comment">//</span>
131425bd8deadSopenharmony_ci<span class="comment">// compatibility profile only</span>
131435bd8deadSopenharmony_ci<span class="comment">//</span>
131445bd8deadSopenharmony_ci<span class="keyword">struct</span> gl_PointParameters {
131455bd8deadSopenharmony_ci    <span class="predefined-type">float</span> size;
131465bd8deadSopenharmony_ci    <span class="predefined-type">float</span> sizeMin;
131475bd8deadSopenharmony_ci    <span class="predefined-type">float</span> sizeMax;
131485bd8deadSopenharmony_ci    <span class="predefined-type">float</span> fadeThresholdSize;
131495bd8deadSopenharmony_ci    <span class="predefined-type">float</span> distanceConstantAttenuation;
131505bd8deadSopenharmony_ci    <span class="predefined-type">float</span> distanceLinearAttenuation;
131515bd8deadSopenharmony_ci    <span class="predefined-type">float</span> distanceQuadraticAttenuation;
131525bd8deadSopenharmony_ci};
131535bd8deadSopenharmony_ci
131545bd8deadSopenharmony_ciuniform gl_PointParameters gl_Point;
131555bd8deadSopenharmony_ci
131565bd8deadSopenharmony_ci<span class="comment">//</span>
131575bd8deadSopenharmony_ci<span class="comment">// compatibility profile only</span>
131585bd8deadSopenharmony_ci<span class="comment">//</span>
131595bd8deadSopenharmony_ci<span class="keyword">struct</span> gl_MaterialParameters {
131605bd8deadSopenharmony_ci vec4 emission;   <span class="comment">// Ecm</span>
131615bd8deadSopenharmony_ci vec4 ambient;    <span class="comment">// Acm</span>
131625bd8deadSopenharmony_ci vec4 diffuse;    <span class="comment">// Dcm</span>
131635bd8deadSopenharmony_ci vec4 specular;   <span class="comment">// Scm</span>
131645bd8deadSopenharmony_ci <span class="predefined-type">float</span> shininess; <span class="comment">// Srm</span>
131655bd8deadSopenharmony_ci};
131665bd8deadSopenharmony_ciuniform gl_MaterialParameters gl_FrontMaterial;
131675bd8deadSopenharmony_ciuniform gl_MaterialParameters gl_BackMaterial;
131685bd8deadSopenharmony_ci
131695bd8deadSopenharmony_ci<span class="comment">//</span>
131705bd8deadSopenharmony_ci<span class="comment">// compatibility profile only</span>
131715bd8deadSopenharmony_ci<span class="comment">//</span>
131725bd8deadSopenharmony_ci<span class="keyword">struct</span> gl_LightSourceParameters {
131735bd8deadSopenharmony_ci    vec4 ambient;               <span class="comment">// Acli</span>
131745bd8deadSopenharmony_ci    vec4 diffuse;               <span class="comment">// Dcli</span>
131755bd8deadSopenharmony_ci    vec4 specular;              <span class="comment">// Scli</span>
131765bd8deadSopenharmony_ci    vec4 position;              <span class="comment">// Ppli</span>
131775bd8deadSopenharmony_ci    vec4 halfVector;            <span class="comment">// Derived: Hi</span>
131785bd8deadSopenharmony_ci    vec3 spotDirection;         <span class="comment">// Sdli</span>
131795bd8deadSopenharmony_ci    <span class="predefined-type">float</span> spotExponent;         <span class="comment">// Srli</span>
131805bd8deadSopenharmony_ci    <span class="predefined-type">float</span> spotCutoff;           <span class="comment">// Crli</span>
131815bd8deadSopenharmony_ci                                <span class="comment">// (range: [0.0,90.0], 180.0)</span>
131825bd8deadSopenharmony_ci    <span class="predefined-type">float</span> spotCosCutoff;        <span class="comment">// Derived: cos(Crli)</span>
131835bd8deadSopenharmony_ci                                <span class="comment">// (range: [1.0,0.0],-1.0)</span>
131845bd8deadSopenharmony_ci    <span class="predefined-type">float</span> constantAttenuation;  <span class="comment">// K0</span>
131855bd8deadSopenharmony_ci    <span class="predefined-type">float</span> linearAttenuation;    <span class="comment">// K1</span>
131865bd8deadSopenharmony_ci    <span class="predefined-type">float</span> quadraticAttenuation; <span class="comment">// K2</span>
131875bd8deadSopenharmony_ci};
131885bd8deadSopenharmony_ci
131895bd8deadSopenharmony_ciuniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];
131905bd8deadSopenharmony_ci
131915bd8deadSopenharmony_ci<span class="keyword">struct</span> gl_LightModelParameters {
131925bd8deadSopenharmony_ci    vec4 ambient;                  <span class="comment">// Acs</span>
131935bd8deadSopenharmony_ci};
131945bd8deadSopenharmony_ci
131955bd8deadSopenharmony_ciuniform gl_LightModelParameters gl_LightModel;
131965bd8deadSopenharmony_ci
131975bd8deadSopenharmony_ci<span class="comment">//</span>
131985bd8deadSopenharmony_ci<span class="comment">// compatibility profile only</span>
131995bd8deadSopenharmony_ci<span class="comment">//</span>
132005bd8deadSopenharmony_ci<span class="comment">// Derived state from products of light and material.</span>
132015bd8deadSopenharmony_ci<span class="comment">//</span>
132025bd8deadSopenharmony_ci
132035bd8deadSopenharmony_ci<span class="keyword">struct</span> gl_LightModelProducts {
132045bd8deadSopenharmony_ci    vec4 sceneColor; <span class="comment">// Derived. Ecm + Acm * Acs</span>
132055bd8deadSopenharmony_ci};
132065bd8deadSopenharmony_ci
132075bd8deadSopenharmony_ciuniform gl_LightModelProducts gl_FrontLightModelProduct;
132085bd8deadSopenharmony_ciuniform gl_LightModelProducts gl_BackLightModelProduct;
132095bd8deadSopenharmony_ci
132105bd8deadSopenharmony_ci<span class="keyword">struct</span> gl_LightProducts {
132115bd8deadSopenharmony_ci    vec4 ambient; <span class="comment">// Acm * Acli</span>
132125bd8deadSopenharmony_ci    vec4 diffuse; <span class="comment">// Dcm * Dcli</span>
132135bd8deadSopenharmony_ci    vec4 specular; <span class="comment">// Scm * Scli</span>
132145bd8deadSopenharmony_ci};
132155bd8deadSopenharmony_ci
132165bd8deadSopenharmony_ciuniform gl_LightProducts gl_FrontLightProduct[gl_MaxLights];
132175bd8deadSopenharmony_ciuniform gl_LightProducts gl_BackLightProduct[gl_MaxLights];
132185bd8deadSopenharmony_ci
132195bd8deadSopenharmony_ci<span class="comment">//</span>
132205bd8deadSopenharmony_ci<span class="comment">// compatibility profile only</span>
132215bd8deadSopenharmony_ci<span class="comment">//</span>
132225bd8deadSopenharmony_ciuniform vec4 gl_TextureEnvColor[gl_MaxTextureUnits];
132235bd8deadSopenharmony_ciuniform vec4 gl_EyePlaneS[gl_MaxTextureCoords];
132245bd8deadSopenharmony_ciuniform vec4 gl_EyePlaneT[gl_MaxTextureCoords];
132255bd8deadSopenharmony_ciuniform vec4 gl_EyePlaneR[gl_MaxTextureCoords];
132265bd8deadSopenharmony_ciuniform vec4 gl_EyePlaneQ[gl_MaxTextureCoords];
132275bd8deadSopenharmony_ciuniform vec4 gl_ObjectPlaneS[gl_MaxTextureCoords];
132285bd8deadSopenharmony_ciuniform vec4 gl_ObjectPlaneT[gl_MaxTextureCoords];
132295bd8deadSopenharmony_ciuniform vec4 gl_ObjectPlaneR[gl_MaxTextureCoords];
132305bd8deadSopenharmony_ciuniform vec4 gl_ObjectPlaneQ[gl_MaxTextureCoords];
132315bd8deadSopenharmony_ci
132325bd8deadSopenharmony_ci<span class="comment">//</span>
132335bd8deadSopenharmony_ci<span class="comment">// compatibility profile only</span>
132345bd8deadSopenharmony_ci<span class="comment">//</span>
132355bd8deadSopenharmony_ci<span class="keyword">struct</span> gl_FogParameters {
132365bd8deadSopenharmony_ci    vec4 color;
132375bd8deadSopenharmony_ci    <span class="predefined-type">float</span> density;
132385bd8deadSopenharmony_ci    <span class="predefined-type">float</span> start;
132395bd8deadSopenharmony_ci    <span class="predefined-type">float</span> end;
132405bd8deadSopenharmony_ci    <span class="predefined-type">float</span> scale; <span class="comment">// Derived: 1.0 / (end - start)</span>
132415bd8deadSopenharmony_ci};
132425bd8deadSopenharmony_ci
132435bd8deadSopenharmony_ciuniform gl_FogParameters gl_Fog;</code></pre>
132445bd8deadSopenharmony_ci</div>
132455bd8deadSopenharmony_ci</div>
132465bd8deadSopenharmony_ci</div>
132475bd8deadSopenharmony_ci</div>
132485bd8deadSopenharmony_ci<div class="sect2">
132495bd8deadSopenharmony_ci<h3 id="redeclaring-built-in-blocks">7.5. Redeclaring Built-In Blocks</h3>
132505bd8deadSopenharmony_ci<div class="paragraph">
132515bd8deadSopenharmony_ci<p>The <em>gl_PerVertex</em> block can be redeclared in a shader to explicitly
132525bd8deadSopenharmony_ciindicate what subset of the fixed pipeline interface will be used.
132535bd8deadSopenharmony_ciThis is necessary to establish the interface between multiple programs.
132545bd8deadSopenharmony_ciFor example:</p>
132555bd8deadSopenharmony_ci</div>
132565bd8deadSopenharmony_ci<div class="listingblock">
132575bd8deadSopenharmony_ci<div class="content">
132585bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">out gl_PerVertex {
132595bd8deadSopenharmony_ci    vec4 gl_Position;   <span class="comment">// will use gl_Position</span>
132605bd8deadSopenharmony_ci    <span class="predefined-type">float</span> gl_PointSize; <span class="comment">// will use gl_PointSize</span>
132615bd8deadSopenharmony_ci    vec4 t;             <span class="comment">// error, only gl_PerVertex members allowed</span>
132625bd8deadSopenharmony_ci}; <span class="comment">// no other members of gl_PerVertex will be used</span></code></pre>
132635bd8deadSopenharmony_ci</div>
132645bd8deadSopenharmony_ci</div>
132655bd8deadSopenharmony_ci<div class="paragraph">
132665bd8deadSopenharmony_ci<p>This establishes the output interface the shader will use with the
132675bd8deadSopenharmony_cisubsequent pipeline stage.
132685bd8deadSopenharmony_ciIt must be a subset of the built-in members of <em>gl_PerVertex</em>.
132695bd8deadSopenharmony_ciSuch a redeclaration can also add the <strong>invariant</strong> qualifier, interpolation
132705bd8deadSopenharmony_ciqualifiers, and the layout qualifiers <strong>xfb_offset</strong>, <strong>xfb_buffer</strong>, and
132715bd8deadSopenharmony_ci<strong>xfb_stride</strong>.
132725bd8deadSopenharmony_ciIt can also add an array size for unsized arrays.
132735bd8deadSopenharmony_ciFor example:</p>
132745bd8deadSopenharmony_ci</div>
132755bd8deadSopenharmony_ci<div class="listingblock">
132765bd8deadSopenharmony_ci<div class="content">
132775bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">out layout(xfb_buffer = <span class="integer">1</span>, xfb_stride = <span class="integer">16</span>) gl_PerVertex {
132785bd8deadSopenharmony_ci    vec4 gl_Position;
132795bd8deadSopenharmony_ci    layout(xfb_offset = <span class="integer">0</span>) <span class="predefined-type">float</span> gl_ClipDistance[<span class="integer">4</span>];
132805bd8deadSopenharmony_ci};</code></pre>
132815bd8deadSopenharmony_ci</div>
132825bd8deadSopenharmony_ci</div>
132835bd8deadSopenharmony_ci<div class="paragraph">
132845bd8deadSopenharmony_ci<p>Other layout qualifiers, like <strong>location</strong>, cannot be added to such a
132855bd8deadSopenharmony_ciredeclaration, unless specifically stated.</p>
132865bd8deadSopenharmony_ci</div>
132875bd8deadSopenharmony_ci<div class="paragraph">
132885bd8deadSopenharmony_ci<p>If a built-in interface block is redeclared, it must appear in the shader
132895bd8deadSopenharmony_cibefore any use of any member included in the built-in declaration, or a
132905bd8deadSopenharmony_cicompile-time error will result.
132915bd8deadSopenharmony_ciIt is also a compile-time error to redeclare the block more than once or to
132925bd8deadSopenharmony_ciredeclare a built-in block and then use a member from that built-in block
132935bd8deadSopenharmony_cithat was not included in the redeclaration.
132945bd8deadSopenharmony_ciAlso, if a built-in interface block is redeclared, no member of the built-in
132955bd8deadSopenharmony_cideclaration can be redeclared outside the block redeclaration.
132965bd8deadSopenharmony_ciIf multiple shaders using members of a built-in block belonging to the same
132975bd8deadSopenharmony_ciinterface are linked together in the same program, they must all redeclare
132985bd8deadSopenharmony_cithe built-in block in the same way, as described in
132995bd8deadSopenharmony_ci&#8220;<a href="#interface-blocks">Interface Blocks</a>&#8221; for interface block matching, or a
133005bd8deadSopenharmony_cilink-time error will result.
133015bd8deadSopenharmony_ciIt will also be a link-time error if some shaders in a program redeclare a
133025bd8deadSopenharmony_cispecific built-in interface block while another shader in that program does
133035bd8deadSopenharmony_cinot redeclare that interface block yet still uses a member of that interface
133045bd8deadSopenharmony_ciblock.
133055bd8deadSopenharmony_ciIf a built-in block interface is formed across shaders in different
133065bd8deadSopenharmony_ciprograms, the shaders must all redeclare the built-in block in the same way
133075bd8deadSopenharmony_ci(as described for a single program), or the values passed along the
133085bd8deadSopenharmony_ciinterface are undefined.</p>
133095bd8deadSopenharmony_ci</div>
133105bd8deadSopenharmony_ci</div>
133115bd8deadSopenharmony_ci</div>
133125bd8deadSopenharmony_ci</div>
133135bd8deadSopenharmony_ci<div class="sect1">
133145bd8deadSopenharmony_ci<h2 id="built-in-functions">8. Built-In Functions</h2>
133155bd8deadSopenharmony_ci<div class="sectionbody">
133165bd8deadSopenharmony_ci<div class="paragraph">
133175bd8deadSopenharmony_ci<p>The OpenGL Shading Language defines an assortment of built-in convenience functions for
133185bd8deadSopenharmony_ciscalar and vector operations.
133195bd8deadSopenharmony_ciMany of these built-in functions can be used in more than one type of
133205bd8deadSopenharmony_cishader, but some are intended to provide a direct mapping to hardware and so
133215bd8deadSopenharmony_ciare available only for a specific type of shader.</p>
133225bd8deadSopenharmony_ci</div>
133235bd8deadSopenharmony_ci<div class="paragraph">
133245bd8deadSopenharmony_ci<p>The built-in functions basically fall into three categories:</p>
133255bd8deadSopenharmony_ci</div>
133265bd8deadSopenharmony_ci<div class="ulist">
133275bd8deadSopenharmony_ci<ul>
133285bd8deadSopenharmony_ci<li>
133295bd8deadSopenharmony_ci<p>They expose some necessary hardware functionality in a convenient way
133305bd8deadSopenharmony_cisuch as accessing a texture map.
133315bd8deadSopenharmony_ciThere is no way in the language for these functions to be emulated by a
133325bd8deadSopenharmony_cishader.</p>
133335bd8deadSopenharmony_ci</li>
133345bd8deadSopenharmony_ci<li>
133355bd8deadSopenharmony_ci<p>They represent a trivial operation (clamp, mix, etc.) that is very
133365bd8deadSopenharmony_cisimple for the user to write, but they are very common and may have
133375bd8deadSopenharmony_cidirect hardware support.
133385bd8deadSopenharmony_ciIt is a very hard problem for the compiler to map expressions to complex
133395bd8deadSopenharmony_ciassembler instructions.</p>
133405bd8deadSopenharmony_ci</li>
133415bd8deadSopenharmony_ci<li>
133425bd8deadSopenharmony_ci<p>They represent an operation graphics hardware is likely to accelerate at
133435bd8deadSopenharmony_cisome point.
133445bd8deadSopenharmony_ciThe trigonometry functions fall into this category.</p>
133455bd8deadSopenharmony_ci</li>
133465bd8deadSopenharmony_ci</ul>
133475bd8deadSopenharmony_ci</div>
133485bd8deadSopenharmony_ci<div class="paragraph">
133495bd8deadSopenharmony_ci<p>Many of the functions are similar to the same named ones in common C
133505bd8deadSopenharmony_cilibraries, but they support vector input as well as the more traditional
133515bd8deadSopenharmony_ciscalar input.</p>
133525bd8deadSopenharmony_ci</div>
133535bd8deadSopenharmony_ci<div class="paragraph">
133545bd8deadSopenharmony_ci<p>Applications should be encouraged to use the built-in functions rather than
133555bd8deadSopenharmony_cido the equivalent computations in their own shader code since the built-in
133565bd8deadSopenharmony_cifunctions are assumed to be optimal (e.g. perhaps supported directly in
133575bd8deadSopenharmony_cihardware).</p>
133585bd8deadSopenharmony_ci</div>
133595bd8deadSopenharmony_ci<div class="paragraph">
133605bd8deadSopenharmony_ci<p>User code can replace built-in functions with their own if they choose, by
133615bd8deadSopenharmony_cisimply redeclaring and defining the same name and argument list.
133625bd8deadSopenharmony_ciBecause built-in functions are in a more outer scope than user built-in
133635bd8deadSopenharmony_cifunctions, doing this will hide all built-in functions with the same name as
133645bd8deadSopenharmony_cithe redeclared function.</p>
133655bd8deadSopenharmony_ci</div>
133665bd8deadSopenharmony_ci<div class="paragraph">
133675bd8deadSopenharmony_ci<p>When the built-in functions are specified below, where the input arguments
133685bd8deadSopenharmony_ci(and corresponding output) can be <strong>float</strong>, <strong>vec2</strong>, <strong>vec3</strong>, or <strong>vec4</strong>,
133695bd8deadSopenharmony_ci<em>genFType</em> is used as the argument.
133705bd8deadSopenharmony_ciWhere the input arguments (and corresponding output) can be <strong>int</strong>, <strong>ivec2</strong>,
133715bd8deadSopenharmony_ci<strong>ivec3</strong>, or <strong>ivec4</strong>, <em>genIType</em> is used as the argument.
133725bd8deadSopenharmony_ciWhere the input arguments (and corresponding output) can be <strong>uint</strong>, <strong>uvec2</strong>,
133735bd8deadSopenharmony_ci<strong>uvec3</strong>, or <strong>uvec4</strong>, <em>genUType</em> is used as the argument.
133745bd8deadSopenharmony_ciWhere the input arguments (or corresponding output) can be <strong>bool</strong>, <strong>bvec2</strong>,
133755bd8deadSopenharmony_ci<strong>bvec3</strong>, or <strong>bvec4</strong>, <em>genBType</em> is used as the argument.
133765bd8deadSopenharmony_ciWhere the input arguments (and corresponding output) can be <strong>double</strong>,
133775bd8deadSopenharmony_ci<strong>dvec2</strong>, <strong>dvec3</strong>, <strong>dvec4</strong>, <em>genDType</em> is used as the argument.
133785bd8deadSopenharmony_ciFor any specific use of a function, the actual types substituted for
133795bd8deadSopenharmony_ci<em>genFType</em>, <em>genIType</em>, <em>genUType</em>, or <em>genBType</em> have to have the same
133805bd8deadSopenharmony_cinumber of components for all arguments and for the return type.
133815bd8deadSopenharmony_ciSimilarly, <em>mat</em> is used for any matrix basic
133825bd8deadSopenharmony_citype with single-precision
133835bd8deadSopenharmony_cicomponents and <em>dmat</em> is used for any matrix basic type with
133845bd8deadSopenharmony_cidouble-precision components.</p>
133855bd8deadSopenharmony_ci</div>
133865bd8deadSopenharmony_ci<div class="paragraph">
133875bd8deadSopenharmony_ci<p>Built-in functions have an effective precision qualification.
133885bd8deadSopenharmony_ciThis qualification cannot be set explicitly and may be different from the
133895bd8deadSopenharmony_ciprecision qualification of the result.</p>
133905bd8deadSopenharmony_ci</div>
133915bd8deadSopenharmony_ci<div class="paragraph">
133925bd8deadSopenharmony_ci<p>Note: In general, as has been noted, precision qualification is ignored
133935bd8deadSopenharmony_ciunless targeting Vulkan.</p>
133945bd8deadSopenharmony_ci</div>
133955bd8deadSopenharmony_ci<div class="paragraph">
133965bd8deadSopenharmony_ci<p>The precision qualification of the operation of a built-in function is based
133975bd8deadSopenharmony_cion the precision qualification of its formal parameters and actual
133985bd8deadSopenharmony_ciparameters (input arguments): When a formal parameter specifies a precision
133995bd8deadSopenharmony_ciqualifier, that is used, otherwise, the precision qualification of the
134005bd8deadSopenharmony_ciactual (calling) argument is used.
134015bd8deadSopenharmony_ciThe highest precision of these will be the precision of the operation of the
134025bd8deadSopenharmony_cibuilt-in function.
134035bd8deadSopenharmony_ciGenerally, this is applied across all arguments to a built-in function, with
134045bd8deadSopenharmony_cithe exceptions being:</p>
134055bd8deadSopenharmony_ci</div>
134065bd8deadSopenharmony_ci<div class="ulist">
134075bd8deadSopenharmony_ci<ul>
134085bd8deadSopenharmony_ci<li>
134095bd8deadSopenharmony_ci<p><strong>bitfieldExtract</strong> and <strong>bitfieldInsert</strong> ignore the <em>offset</em> and <em>bits</em>
134105bd8deadSopenharmony_ciarguments.</p>
134115bd8deadSopenharmony_ci</li>
134125bd8deadSopenharmony_ci<li>
134135bd8deadSopenharmony_ci<p><strong>interpolateAt</strong> functions only look at the <em>interpolant</em> argument.</p>
134145bd8deadSopenharmony_ci</li>
134155bd8deadSopenharmony_ci</ul>
134165bd8deadSopenharmony_ci</div>
134175bd8deadSopenharmony_ci<div class="paragraph">
134185bd8deadSopenharmony_ci<p>The precision qualification of the result of a built-in function is
134195bd8deadSopenharmony_cidetermined in one of the following ways:</p>
134205bd8deadSopenharmony_ci</div>
134215bd8deadSopenharmony_ci<div class="paragraph">
134225bd8deadSopenharmony_ci<p>For the texture sampling, image load and image store functions, the
134235bd8deadSopenharmony_ciprecision of the return type matches the precision of the
134245bd8deadSopenharmony_citexture-combined sampler type:</p>
134255bd8deadSopenharmony_ci</div>
134265bd8deadSopenharmony_ci<div class="listingblock">
134275bd8deadSopenharmony_ci<div class="content">
134285bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">uniform lowp sampler2D texSampler;
134295bd8deadSopenharmony_cihighp vec2 coord;
134305bd8deadSopenharmony_ci...
134315bd8deadSopenharmony_cilowp vec4 col = texture (texSampler, coord); <span class="comment">// texture() returns lowp</span></code></pre>
134325bd8deadSopenharmony_ci</div>
134335bd8deadSopenharmony_ci</div>
134345bd8deadSopenharmony_ci<div class="paragraph">
134355bd8deadSopenharmony_ci<p>Otherwise:</p>
134365bd8deadSopenharmony_ci</div>
134375bd8deadSopenharmony_ci<div class="ulist">
134385bd8deadSopenharmony_ci<ul>
134395bd8deadSopenharmony_ci<li>
134405bd8deadSopenharmony_ci<p>For prototypes that do not specify a resulting precision qualifier, the
134415bd8deadSopenharmony_ciprecision will be the same as the precision of the operation (as defined
134425bd8deadSopenharmony_ciearlier).</p>
134435bd8deadSopenharmony_ci</li>
134445bd8deadSopenharmony_ci<li>
134455bd8deadSopenharmony_ci<p>For prototypes that do specify a resulting precision qualifier, the
134465bd8deadSopenharmony_cispecified precision qualifier is the precision qualification of the
134475bd8deadSopenharmony_ciresult.</p>
134485bd8deadSopenharmony_ci</li>
134495bd8deadSopenharmony_ci</ul>
134505bd8deadSopenharmony_ci</div>
134515bd8deadSopenharmony_ci<div class="paragraph">
134525bd8deadSopenharmony_ci<p>Where the built-in functions in the following sections specify an equation,
134535bd8deadSopenharmony_cithe entire equation will be evaluated at the operation&#8217;s precision.
134545bd8deadSopenharmony_ciThis may lead to underflow or overflow in the result, even when the correct
134555bd8deadSopenharmony_ciresult could be represented in the operation precision.</p>
134565bd8deadSopenharmony_ci</div>
134575bd8deadSopenharmony_ci<div class="sect2">
134585bd8deadSopenharmony_ci<h3 id="angle-and-trigonometry-functions">8.1. Angle and Trigonometry Functions</h3>
134595bd8deadSopenharmony_ci<div class="paragraph">
134605bd8deadSopenharmony_ci<p>Function parameters specified as <em>angle</em> are assumed to be in units of
134615bd8deadSopenharmony_ciradians.
134625bd8deadSopenharmony_ciIn no case will any of these functions result in a divide by zero error.
134635bd8deadSopenharmony_ciIf the divisor of a ratio is 0, then results will be undefined.</p>
134645bd8deadSopenharmony_ci</div>
134655bd8deadSopenharmony_ci<div class="paragraph">
134665bd8deadSopenharmony_ci<p>These all operate component-wise.
134675bd8deadSopenharmony_ciThe description is per component.</p>
134685bd8deadSopenharmony_ci</div>
134695bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
134705bd8deadSopenharmony_ci<colgroup>
134715bd8deadSopenharmony_ci<col style="width: 50%;">
134725bd8deadSopenharmony_ci<col style="width: 50%;">
134735bd8deadSopenharmony_ci</colgroup>
134745bd8deadSopenharmony_ci<thead>
134755bd8deadSopenharmony_ci<tr>
134765bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
134775bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
134785bd8deadSopenharmony_ci</tr>
134795bd8deadSopenharmony_ci</thead>
134805bd8deadSopenharmony_ci<tbody>
134815bd8deadSopenharmony_ci<tr>
134825bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>radians</strong>(genFType <em>degrees</em>)</p></td>
134835bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Converts <em>degrees</em> to radians, i.e.,
134845bd8deadSopenharmony_ci      <span class="eq">(π / 180) · degrees</span>.</p></td>
134855bd8deadSopenharmony_ci</tr>
134865bd8deadSopenharmony_ci<tr>
134875bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>degrees</strong>(genFType <em>radians</em>)</p></td>
134885bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Converts <em>radians</em> to degrees, i.e.,
134895bd8deadSopenharmony_ci      <span class="eq">(180 / π) · radians</span>.</p></td>
134905bd8deadSopenharmony_ci</tr>
134915bd8deadSopenharmony_ci<tr>
134925bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>sin</strong>(genFType <em>angle</em>)</p></td>
134935bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">The standard trigonometric sine function.</p></td>
134945bd8deadSopenharmony_ci</tr>
134955bd8deadSopenharmony_ci<tr>
134965bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>cos</strong>(genFType <em>angle</em>)</p></td>
134975bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">The standard trigonometric cosine function.</p></td>
134985bd8deadSopenharmony_ci</tr>
134995bd8deadSopenharmony_ci<tr>
135005bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>tan</strong>(genFType <em>angle</em>)</p></td>
135015bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">The standard trigonometric tangent.</p></td>
135025bd8deadSopenharmony_ci</tr>
135035bd8deadSopenharmony_ci<tr>
135045bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>asin</strong>(genFType <em>x</em>)</p></td>
135055bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Arc sine.
135065bd8deadSopenharmony_ci      Returns an angle whose sine is <em>x</em>.
135075bd8deadSopenharmony_ci      The range of values returned by this function is
135085bd8deadSopenharmony_ci      <span class="eq">[-π / 2, π / 2]</span>.
135095bd8deadSopenharmony_ci      Results are undefined if <span class="eq">|x| &gt; 1</span>.</p></td>
135105bd8deadSopenharmony_ci</tr>
135115bd8deadSopenharmony_ci<tr>
135125bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>acos</strong>(genFType <em>x</em>)</p></td>
135135bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Arc cosine.
135145bd8deadSopenharmony_ci      Returns an angle whose cosine is <em>x</em>.
135155bd8deadSopenharmony_ci      The range of values returned by this function is <span class="eq">[0,π]</span>.
135165bd8deadSopenharmony_ci      Results are undefined if <span class="eq">|x| &gt; 1</span>.</p></td>
135175bd8deadSopenharmony_ci</tr>
135185bd8deadSopenharmony_ci<tr>
135195bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>atan</strong>(genFType <em>y</em>, genFType <em>x</em>)</p></td>
135205bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Arc tangent.
135215bd8deadSopenharmony_ci      Returns an angle whose tangent is <span class="eq">y / x</span>.
135225bd8deadSopenharmony_ci      The signs of <em>x</em> and <em>y</em> are used to determine what quadrant the angle
135235bd8deadSopenharmony_ci      is in.
135245bd8deadSopenharmony_ci      The range of values returned by this function is <span class="eq">[-π, π</span>.
135255bd8deadSopenharmony_ci      Results are undefined if <em>x</em> and <em>y</em> are both 0.</p></td>
135265bd8deadSopenharmony_ci</tr>
135275bd8deadSopenharmony_ci<tr>
135285bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>atan</strong>(genFType <em>y_over_x</em>)</p></td>
135295bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Arc tangent.
135305bd8deadSopenharmony_ci      Returns an angle whose tangent is <em>y_over_x</em>.
135315bd8deadSopenharmony_ci      The range of values returned by this function is
135325bd8deadSopenharmony_ci      <span class="eq">[-π / 2, π / 2]</span>.</p></td>
135335bd8deadSopenharmony_ci</tr>
135345bd8deadSopenharmony_ci<tr>
135355bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>sinh</strong>(genFType <em>x</em>)</p></td>
135365bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the hyperbolic sine function <span class="eq">(e<sup>x</sup> - e<sup>-x</sup>) / 2</span>.</p></td>
135375bd8deadSopenharmony_ci</tr>
135385bd8deadSopenharmony_ci<tr>
135395bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>cosh</strong>(genFType <em>x</em>)</p></td>
135405bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the hyperbolic cosine function <span class="eq">(e<sup>x</sup> + e<sup>-x</sup>) / 2</span>.</p></td>
135415bd8deadSopenharmony_ci</tr>
135425bd8deadSopenharmony_ci<tr>
135435bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>tanh</strong>(genFType <em>x</em>)</p></td>
135445bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the hyperbolic tangent function <span class="eq">sinh(x) / cosh(x)</span>.</p></td>
135455bd8deadSopenharmony_ci</tr>
135465bd8deadSopenharmony_ci<tr>
135475bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>asinh</strong>(genFType <em>x</em>)</p></td>
135485bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Arc hyperbolic sine; returns the inverse of <strong>sinh</strong>.</p></td>
135495bd8deadSopenharmony_ci</tr>
135505bd8deadSopenharmony_ci<tr>
135515bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>acosh</strong>(genFType <em>x</em>)</p></td>
135525bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Arc hyperbolic cosine; returns the non-negative inverse of <strong>cosh</strong>.
135535bd8deadSopenharmony_ci      Results are undefined if <span class="eq">x &lt; 1</span>.</p></td>
135545bd8deadSopenharmony_ci</tr>
135555bd8deadSopenharmony_ci<tr>
135565bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>atanh</strong>(genFType <em>x</em>)</p></td>
135575bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Arc hyperbolic tangent; returns the inverse of <strong>tanh</strong>.
135585bd8deadSopenharmony_ci      Results are undefined if <span class="eq">x ≥ 1</span>.</p></td>
135595bd8deadSopenharmony_ci</tr>
135605bd8deadSopenharmony_ci</tbody>
135615bd8deadSopenharmony_ci</table>
135625bd8deadSopenharmony_ci</div>
135635bd8deadSopenharmony_ci<div class="sect2">
135645bd8deadSopenharmony_ci<h3 id="exponential-functions">8.2. Exponential Functions</h3>
135655bd8deadSopenharmony_ci<div class="paragraph">
135665bd8deadSopenharmony_ci<p>These all operate component-wise.
135675bd8deadSopenharmony_ciThe description is per component.</p>
135685bd8deadSopenharmony_ci</div>
135695bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
135705bd8deadSopenharmony_ci<colgroup>
135715bd8deadSopenharmony_ci<col style="width: 50%;">
135725bd8deadSopenharmony_ci<col style="width: 50%;">
135735bd8deadSopenharmony_ci</colgroup>
135745bd8deadSopenharmony_ci<thead>
135755bd8deadSopenharmony_ci<tr>
135765bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
135775bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
135785bd8deadSopenharmony_ci</tr>
135795bd8deadSopenharmony_ci</thead>
135805bd8deadSopenharmony_ci<tbody>
135815bd8deadSopenharmony_ci<tr>
135825bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>pow</strong>(genFType <em>x</em>, genFType <em>y</em>)</p></td>
135835bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>x</em> raised to the <em>y</em> power, i.e., <span class="eq">x<sup>y</sup></span>.
135845bd8deadSopenharmony_ci      Results are undefined if <span class="eq">x &lt; 0</span>.
135855bd8deadSopenharmony_ci      Results are undefined if <span class="eq">x = 0</span> and <span class="eq">y ≤ 0</span>.</p></td>
135865bd8deadSopenharmony_ci</tr>
135875bd8deadSopenharmony_ci<tr>
135885bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>exp</strong>(genFType <em>x</em>)</p></td>
135895bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the natural exponentiation of <em>x</em>, i.e., <span class="eq">e<sup>x</sup></span>.</p></td>
135905bd8deadSopenharmony_ci</tr>
135915bd8deadSopenharmony_ci<tr>
135925bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>log</strong>(genFType <em>x</em>)</p></td>
135935bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the natural logarithm of <em>x</em>, i.e., returns the value <em>y</em>
135945bd8deadSopenharmony_ci      which satisfies the equation <span class="eq">x = e<sup>y</sup></span>.
135955bd8deadSopenharmony_ci      Results are undefined if <span class="eq">x ≤ 0</span>.</p></td>
135965bd8deadSopenharmony_ci</tr>
135975bd8deadSopenharmony_ci<tr>
135985bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>exp2</strong>(genFType <em>x</em>)</p></td>
135995bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns 2 raised to the <em>x</em> power, i.e., <span class="eq">2<sup>x</sup></span>.</p></td>
136005bd8deadSopenharmony_ci</tr>
136015bd8deadSopenharmony_ci<tr>
136025bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>log2</strong>(genFType <em>x</em>)</p></td>
136035bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the base 2 logarithm of <em>x</em>, i.e., returns the value <em>y</em> which
136045bd8deadSopenharmony_ci      satisfies the equation <span class="eq">x = 2<sup>y</sup></span>.
136055bd8deadSopenharmony_ci      Results are undefined if <span class="eq">x ≤ 0</span>.</p></td>
136065bd8deadSopenharmony_ci</tr>
136075bd8deadSopenharmony_ci<tr>
136085bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>sqrt</strong>(genFType <em>x</em>)<br>
136095bd8deadSopenharmony_ci  genDType <strong>sqrt</strong>(genDType <em>x</em>)</p></td>
136105bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <span class="eq">sqrt(x)</span>.
136115bd8deadSopenharmony_ci      Results are undefined if <span class="eq">x &lt; 0</span>.</p></td>
136125bd8deadSopenharmony_ci</tr>
136135bd8deadSopenharmony_ci<tr>
136145bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>inversesqrt</strong>(genFType <em>x</em>)<br>
136155bd8deadSopenharmony_ci  genDType <strong>inversesqrt</strong>(genDType <em>x</em>)</p></td>
136165bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <span class="eq">1 / sqrt(x)</span>.
136175bd8deadSopenharmony_ci      Results are undefined if <span class="eq">x ≤ 0</span>.</p></td>
136185bd8deadSopenharmony_ci</tr>
136195bd8deadSopenharmony_ci</tbody>
136205bd8deadSopenharmony_ci</table>
136215bd8deadSopenharmony_ci</div>
136225bd8deadSopenharmony_ci<div class="sect2">
136235bd8deadSopenharmony_ci<h3 id="common-functions">8.3. Common Functions</h3>
136245bd8deadSopenharmony_ci<div class="paragraph">
136255bd8deadSopenharmony_ci<p>These all operate component-wise.
136265bd8deadSopenharmony_ciThe description is per component.</p>
136275bd8deadSopenharmony_ci</div>
136285bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
136295bd8deadSopenharmony_ci<colgroup>
136305bd8deadSopenharmony_ci<col style="width: 50%;">
136315bd8deadSopenharmony_ci<col style="width: 50%;">
136325bd8deadSopenharmony_ci</colgroup>
136335bd8deadSopenharmony_ci<thead>
136345bd8deadSopenharmony_ci<tr>
136355bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
136365bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
136375bd8deadSopenharmony_ci</tr>
136385bd8deadSopenharmony_ci</thead>
136395bd8deadSopenharmony_ci<tbody>
136405bd8deadSopenharmony_ci<tr>
136415bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>abs</strong>(genFType <em>x</em>)<br>
136425bd8deadSopenharmony_ci  genIType <strong>abs</strong>(genIType <em>x</em>)<br>
136435bd8deadSopenharmony_ci  genDType <strong>abs</strong>(genDType <em>x</em>)</p></td>
136445bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>x</em> if <span class="eq">x ≥ 0</span>; otherwise it returns -<em>x</em>.</p></td>
136455bd8deadSopenharmony_ci</tr>
136465bd8deadSopenharmony_ci<tr>
136475bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>sign</strong>(genFType <em>x</em>)<br>
136485bd8deadSopenharmony_ci  genIType <strong>sign</strong>(genIType <em>x</em>)<br>
136495bd8deadSopenharmony_ci  genDType <strong>sign</strong>(genDType <em>x</em>)</p></td>
136505bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns 1.0 if <em>x</em> &gt; 0, 0.0 if <em>x</em> = 0, or -1.0 if <em>x</em> &lt; 0.</p></td>
136515bd8deadSopenharmony_ci</tr>
136525bd8deadSopenharmony_ci<tr>
136535bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>floor</strong>(genFType <em>x</em>)<br>
136545bd8deadSopenharmony_ci  genDType <strong>floor</strong>(genDType <em>x</em>)</p></td>
136555bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a value equal to the nearest integer that is less than or
136565bd8deadSopenharmony_ci      equal to <em>x</em>.</p></td>
136575bd8deadSopenharmony_ci</tr>
136585bd8deadSopenharmony_ci<tr>
136595bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>trunc</strong>(genFType <em>x</em>)<br>
136605bd8deadSopenharmony_ci  genDType <strong>trunc</strong>(genDType <em>x</em>)</p></td>
136615bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a value equal to the nearest integer to <em>x</em> whose absolute
136625bd8deadSopenharmony_ci      value is not larger than the absolute value of <em>x</em>.</p></td>
136635bd8deadSopenharmony_ci</tr>
136645bd8deadSopenharmony_ci<tr>
136655bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>round</strong>(genFType <em>x</em>)<br>
136665bd8deadSopenharmony_ci  genDType <strong>round</strong>(genDType <em>x</em>)</p></td>
136675bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a value equal to the nearest integer to <em>x</em>.
136685bd8deadSopenharmony_ci      The fraction 0.5 will round in a direction chosen by the
136695bd8deadSopenharmony_ci      implementation, presumably the direction that is fastest.
136705bd8deadSopenharmony_ci      This includes the possibility that <strong>round</strong>(<em>x</em>) returns the same value
136715bd8deadSopenharmony_ci      as <strong>roundEven</strong>(<em>x</em>) for all values of <em>x</em>.</p></td>
136725bd8deadSopenharmony_ci</tr>
136735bd8deadSopenharmony_ci<tr>
136745bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>roundEven</strong>(genFType <em>x</em>)<br>
136755bd8deadSopenharmony_ci  genDType <strong>roundEven</strong>(genDType <em>x</em>)</p></td>
136765bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a value equal to the nearest integer to <em>x</em>.
136775bd8deadSopenharmony_ci      A fractional part of 0.5 will round toward the nearest even integer.
136785bd8deadSopenharmony_ci      (Both 3.5 and 4.5 for x will return 4.0.)</p></td>
136795bd8deadSopenharmony_ci</tr>
136805bd8deadSopenharmony_ci<tr>
136815bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>ceil</strong>(genFType <em>x</em>)<br>
136825bd8deadSopenharmony_ci  genDType <strong>ceil</strong>(genDType <em>x</em>)</p></td>
136835bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a value equal to the nearest integer that is greater than or
136845bd8deadSopenharmony_ci      equal to <em>x</em>.</p></td>
136855bd8deadSopenharmony_ci</tr>
136865bd8deadSopenharmony_ci<tr>
136875bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>fract</strong>(genFType <em>x</em>)<br>
136885bd8deadSopenharmony_ci  genDType <strong>fract</strong>(genDType <em>x</em>)<br></p></td>
136895bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>x</em> - <strong>floor</strong>(<em>x</em>).</p></td>
136905bd8deadSopenharmony_ci</tr>
136915bd8deadSopenharmony_ci<tr>
136925bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>mod</strong>(genFType <em>x</em>, float <em>y</em>)<br>
136935bd8deadSopenharmony_ci  genFType <strong>mod</strong>(genFType <em>x</em>, genFType <em>y</em>)<br>
136945bd8deadSopenharmony_ci  genDType <strong>mod</strong>(genDType <em>x</em>, double <em>y</em>)<br>
136955bd8deadSopenharmony_ci  genDType <strong>mod</strong>(genDType <em>x</em>, genDType <em>y</em>)<br></p></td>
136965bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Modulus.
136975bd8deadSopenharmony_ci      Returns <span class="eq">x - y · <strong>floor</strong>(x / y)</span>.</p></td>
136985bd8deadSopenharmony_ci</tr>
136995bd8deadSopenharmony_ci<tr>
137005bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>modf</strong>(genFType <em>x</em>, out genFType <em>i</em>)<br>
137015bd8deadSopenharmony_ci  genDType <strong>modf</strong>(genDType <em>x</em>, out genDType <em>i</em>)</p></td>
137025bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the fractional part of <em>x</em> and sets <em>i</em> to the integer part (as
137035bd8deadSopenharmony_ci      a whole number floating-point value).
137045bd8deadSopenharmony_ci      Both the return value and the output parameter will have the same sign
137055bd8deadSopenharmony_ci      as <em>x</em>.</p></td>
137065bd8deadSopenharmony_ci</tr>
137075bd8deadSopenharmony_ci<tr>
137085bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>min</strong>(genFType <em>x</em>, genFType <em>y</em>)<br>
137095bd8deadSopenharmony_ci  genFType <strong>min</strong>(genFType <em>x</em>, float <em>y</em>)<br>
137105bd8deadSopenharmony_ci  genDType <strong>min</strong>(genDType <em>x</em>, genDType <em>y</em>)<br>
137115bd8deadSopenharmony_ci  genDType <strong>min</strong>(genDType <em>x</em>, double <em>y</em>)<br>
137125bd8deadSopenharmony_ci  genIType <strong>min</strong>(genIType <em>x</em>, genIType <em>y</em>)<br>
137135bd8deadSopenharmony_ci  genIType <strong>min</strong>(genIType <em>x</em>, int <em>y</em>)<br>
137145bd8deadSopenharmony_ci  genUType <strong>min</strong>(genUType <em>x</em>, genUType <em>y</em>)<br>
137155bd8deadSopenharmony_ci  genUType <strong>min</strong>(genUType <em>x</em>, uint <em>y</em>)</p></td>
137165bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>y</em> if <em>y</em> &lt; <em>x;</em> otherwise it returns <em>x</em>.</p></td>
137175bd8deadSopenharmony_ci</tr>
137185bd8deadSopenharmony_ci<tr>
137195bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>max</strong>(genFType <em>x</em>, genFType <em>y</em>)<br>
137205bd8deadSopenharmony_ci  genFType <strong>max</strong>(genFType <em>x</em>, float <em>y</em>)<br>
137215bd8deadSopenharmony_ci  genDType <strong>max</strong>(genDType <em>x</em>, genDType <em>y</em>)<br>
137225bd8deadSopenharmony_ci  genDType <strong>max</strong>(genDType <em>x</em>, double <em>y</em>)<br>
137235bd8deadSopenharmony_ci  genIType <strong>max</strong>(genIType <em>x</em>, genIType <em>y</em>)<br>
137245bd8deadSopenharmony_ci  genIType <strong>max</strong>(genIType <em>x</em>, int <em>y</em>)<br>
137255bd8deadSopenharmony_ci  genUType <strong>max</strong>(genUType <em>x</em>, genUType <em>y</em>)<br>
137265bd8deadSopenharmony_ci  genUType <strong>max</strong>(genUType <em>x</em>, uint <em>y</em>)</p></td>
137275bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>y</em> if <em>x</em> &lt; <em>y;</em> otherwise it returns <em>x</em>.</p></td>
137285bd8deadSopenharmony_ci</tr>
137295bd8deadSopenharmony_ci<tr>
137305bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>clamp</strong>(genFType <em>x</em>, genFType <em>minVal</em>, genFType <em>maxVal</em>)<br>
137315bd8deadSopenharmony_ci  genFType <strong>clamp</strong>(genFType <em>x</em>, float <em>minVal</em>, float <em>maxVal</em>)<br>
137325bd8deadSopenharmony_ci  genDType <strong>clamp</strong>(genDType <em>x</em>, genDType <em>minVal</em>, genDType <em>maxVal</em>)<br>
137335bd8deadSopenharmony_ci  genDType <strong>clamp</strong>(genDType <em>x</em>, double <em>minVal</em>, double <em>maxVal</em>)<br>
137345bd8deadSopenharmony_ci  genIType <strong>clamp</strong>(genIType <em>x</em>, genIType <em>minVal</em>, genIType <em>maxVal</em>)<br>
137355bd8deadSopenharmony_ci  genIType <strong>clamp</strong>(genIType <em>x</em>, int <em>minVal</em>, int <em>maxVal</em>)<br>
137365bd8deadSopenharmony_ci  genUType <strong>clamp</strong>(genUType <em>x</em>, genUType <em>minVal</em>, genUType <em>maxVal</em>)<br>
137375bd8deadSopenharmony_ci  genUType <strong>clamp</strong>(genUType <em>x</em>, uint <em>minVal</em>, uint <em>maxVal</em>)</p></td>
137385bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <strong>min</strong>(<strong>max</strong>(<em>x</em>, <em>minVal</em>), <em>maxVal</em>).
137395bd8deadSopenharmony_ci      Results are undefined if <em>minVal</em> &gt; <em>maxVal</em>.</p></td>
137405bd8deadSopenharmony_ci</tr>
137415bd8deadSopenharmony_ci<tr>
137425bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>mix</strong>(genFType <em>x</em>, genFType <em>y</em>, genFType <em>a</em>)<br>
137435bd8deadSopenharmony_ci  genFType <strong>mix</strong>(genFType <em>x</em>, genFType <em>y</em>, float <em>a</em>)<br>
137445bd8deadSopenharmony_ci  genDType <strong>mix</strong>(genDType <em>x</em>, genDType <em>y</em>, genDType <em>a</em>)<br>
137455bd8deadSopenharmony_ci  genDType <strong>mix</strong>(genDType <em>x</em>, genDType <em>y</em>, double <em>a</em>)<br></p></td>
137465bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the linear blend of <em>x</em> and <em>y</em>, i.e.,
137475bd8deadSopenharmony_ci      <span class="eq">x · (1 - a) + y · a</span>.</p></td>
137485bd8deadSopenharmony_ci</tr>
137495bd8deadSopenharmony_ci<tr>
137505bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>mix</strong>(genFType <em>x</em>, genFType <em>y</em>,  genBType <em>a</em>)<br>
137515bd8deadSopenharmony_ci  genDType <strong>mix</strong>(genDType <em>x</em>, genDType <em>y</em>, genBType <em>a</em>)<br>
137525bd8deadSopenharmony_ci  genIType <strong>mix</strong>(genIType <em>x</em>, genIType <em>y</em>, genBType <em>a</em>)<br>
137535bd8deadSopenharmony_ci  genUType <strong>mix</strong>(genUType <em>x</em>, genUType <em>y</em>, genBType <em>a</em>)<br>
137545bd8deadSopenharmony_ci  genBType <strong>mix</strong>(genBType <em>x</em>, genBType <em>y</em>, genBType <em>a</em>)</p></td>
137555bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Selects which vector each returned component comes from.
137565bd8deadSopenharmony_ci      For a component of <em>a</em> that is <strong>false</strong>, the corresponding component of
137575bd8deadSopenharmony_ci      <em>x</em> is returned.
137585bd8deadSopenharmony_ci      For a component of <em>a</em> that is <strong>true</strong>, the corresponding component of
137595bd8deadSopenharmony_ci      <em>y</em> is returned.
137605bd8deadSopenharmony_ci      Components of <em>x</em> and <em>y</em> that are not selected are allowed to be
137615bd8deadSopenharmony_ci      invalid floating-point values and will have no effect on the results.
137625bd8deadSopenharmony_ci      Thus, this provides different functionality than, for example,<br>
137635bd8deadSopenharmony_ci      genFType <strong>mix</strong>(genFType <em>x</em>, genFType <em>y</em>, genFType(<em>a</em>))<br>
137645bd8deadSopenharmony_ci      where <em>a</em> is a Boolean vector.</p></td>
137655bd8deadSopenharmony_ci</tr>
137665bd8deadSopenharmony_ci<tr>
137675bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>step</strong>(genFType <em>edge</em>, genFType <em>x</em>)<br>
137685bd8deadSopenharmony_ci  genFType <strong>step</strong>(float <em>edge</em>, genFType <em>x</em>)<br>
137695bd8deadSopenharmony_ci  genDType <strong>step</strong>(genDType <em>edge</em>, genDType <em>x</em>)<br>
137705bd8deadSopenharmony_ci  genDType <strong>step</strong>(double <em>edge</em>, genDType <em>x</em>)</p></td>
137715bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns 0.0 if <em>x</em> &lt; <em>edge;</em> otherwise it returns 1.0.</p></td>
137725bd8deadSopenharmony_ci</tr>
137735bd8deadSopenharmony_ci<tr>
137745bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>smoothstep</strong>(genFType <em>edge0</em>, genFType <em>edge1</em>, genFType <em>x</em>)<br>
137755bd8deadSopenharmony_ci  genFType <strong>smoothstep</strong>(float <em>edge0</em>, float <em>edge1</em>, genFType <em>x</em>)<br>
137765bd8deadSopenharmony_ci  genDType <strong>smoothstep</strong>(genDType <em>edge0</em>, genDType <em>edge1</em>, genDType <em>x</em>)<br>
137775bd8deadSopenharmony_ci  genDType <strong>smoothstep</strong>(double <em>edge0</em>, double <em>edge1</em>, genDType <em>x</em>)<br></p></td>
137785bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
137795bd8deadSopenharmony_ci<p>Returns 0.0 if <span class="eq">x ≤ edge0</span> and 1.0 if <span class="eq">x ≥ edge1</span>, and
137805bd8deadSopenharmony_ci      performs smooth Hermite interpolation between 0 and 1 when <span class="eq">edge0
137815bd8deadSopenharmony_ci      &lt; x &lt; edge1</span>.
137825bd8deadSopenharmony_ci      This is useful in cases where you would want a threshold function with
137835bd8deadSopenharmony_ci      a smooth transition.
137845bd8deadSopenharmony_ci      This is equivalent to:</p>
137855bd8deadSopenharmony_ci</div>
137865bd8deadSopenharmony_ci<div class="openblock">
137875bd8deadSopenharmony_ci<div class="content">
137885bd8deadSopenharmony_ci<div class="listingblock">
137895bd8deadSopenharmony_ci<div class="content">
137905bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">genFType t;
137915bd8deadSopenharmony_cit = clamp ((x - edge0) / (edge1 - edge0), <span class="integer">0</span>, <span class="integer">1</span>);
137925bd8deadSopenharmony_ci<span class="keyword">return</span> t * t * (<span class="integer">3</span> - <span class="integer">2</span> * t);</code></pre>
137935bd8deadSopenharmony_ci</div>
137945bd8deadSopenharmony_ci</div>
137955bd8deadSopenharmony_ci<div class="paragraph">
137965bd8deadSopenharmony_ci<p>(And similarly for doubles.) Results are undefined if <span class="eq">edge0 ≥
137975bd8deadSopenharmony_ciedge1</span>.</p>
137985bd8deadSopenharmony_ci</div>
137995bd8deadSopenharmony_ci</div>
138005bd8deadSopenharmony_ci</div></div></td>
138015bd8deadSopenharmony_ci</tr>
138025bd8deadSopenharmony_ci<tr>
138035bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genBType <strong>isnan</strong>(genFType <em>x</em>)<br>
138045bd8deadSopenharmony_ci  genBType <strong>isnan</strong>(genDType <em>x</em>)</p></td>
138055bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <strong>true</strong> if <em>x</em> holds a NaN.
138065bd8deadSopenharmony_ci      Returns <strong>false</strong> otherwise.
138075bd8deadSopenharmony_ci      Always returns <strong>false</strong> if NaNs are not implemented.</p></td>
138085bd8deadSopenharmony_ci</tr>
138095bd8deadSopenharmony_ci<tr>
138105bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genBType <strong>isinf</strong>(genFType <em>x</em>)<br>
138115bd8deadSopenharmony_ci  genBType <strong>isinf</strong>(genDType <em>x</em>)</p></td>
138125bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <strong>true</strong> if <em>x</em> holds a positive infinity or negative infinity.
138135bd8deadSopenharmony_ci      Returns <strong>false</strong> otherwise.</p></td>
138145bd8deadSopenharmony_ci</tr>
138155bd8deadSopenharmony_ci<tr>
138165bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genIType <strong>floatBitsToInt</strong>(highp genFType <em>value</em>)<br>
138175bd8deadSopenharmony_ci  genUType <strong>floatBitsToUint</strong>(highp genFType <em>value</em>)</p></td>
138185bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a signed or unsigned integer value representing the encoding
138195bd8deadSopenharmony_ci      of a floating-point value.
138205bd8deadSopenharmony_ci      The <strong>float</strong> value&#8217;s bit-level representation is preserved.</p></td>
138215bd8deadSopenharmony_ci</tr>
138225bd8deadSopenharmony_ci<tr>
138235bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>intBitsToFloat</strong>(highp genIType <em>value</em>)<br>
138245bd8deadSopenharmony_ci  genFType <strong>uintBitsToFloat</strong>(highp genUType <em>value</em>)</p></td>
138255bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a floating-point value corresponding to a signed or unsigned
138265bd8deadSopenharmony_ci      integer encoding of a floating-point value.
138275bd8deadSopenharmony_ci      If a NaN is passed in, it will not signal, and the resulting value is
138285bd8deadSopenharmony_ci      unspecified.
138295bd8deadSopenharmony_ci      If an Inf is passed in, the resulting value is the corresponding Inf.
138305bd8deadSopenharmony_ci      Otherwise, the bit-level representation is preserved.</p></td>
138315bd8deadSopenharmony_ci</tr>
138325bd8deadSopenharmony_ci<tr>
138335bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>fma</strong>(genFType <em>a</em>, genFType <em>b</em>, genFType <em>c</em>)<br>
138345bd8deadSopenharmony_ci  genDType <strong>fma</strong>(genDType <em>a</em>, genDType <em>b</em>, genDType <em>c</em>)</p></td>
138355bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
138365bd8deadSopenharmony_ci<p>Computes and returns <code>a * b + c</code>.
138375bd8deadSopenharmony_ci      In uses where the return value is eventually consumed by a variable
138385bd8deadSopenharmony_ci      declared as <strong>precise</strong>:</p>
138395bd8deadSopenharmony_ci</div>
138405bd8deadSopenharmony_ci<div class="openblock">
138415bd8deadSopenharmony_ci<div class="content">
138425bd8deadSopenharmony_ci<div class="ulist">
138435bd8deadSopenharmony_ci<ul>
138445bd8deadSopenharmony_ci<li>
138455bd8deadSopenharmony_ci<p><strong>fma</strong>() is considered a single operation, whereas the expression <code>a * b
138465bd8deadSopenharmony_ci+ c</code> consumed by a variable declared <strong>precise</strong> is considered two
138475bd8deadSopenharmony_cioperations.</p>
138485bd8deadSopenharmony_ci</li>
138495bd8deadSopenharmony_ci<li>
138505bd8deadSopenharmony_ci<p>The precision of <strong>fma</strong>() can differ from the precision of the expression
138515bd8deadSopenharmony_ci<code>a * b + c</code>.</p>
138525bd8deadSopenharmony_ci</li>
138535bd8deadSopenharmony_ci<li>
138545bd8deadSopenharmony_ci<p><strong>fma</strong>() will be computed with the same precision as any other <strong>fma</strong>()
138555bd8deadSopenharmony_ciconsumed by a precise variable, giving invariant results for the same
138565bd8deadSopenharmony_ciinput values of <em>a</em>, <em>b</em>, and <em>c</em>.</p>
138575bd8deadSopenharmony_ci</li>
138585bd8deadSopenharmony_ci</ul>
138595bd8deadSopenharmony_ci</div>
138605bd8deadSopenharmony_ci<div class="paragraph">
138615bd8deadSopenharmony_ci<p>Otherwise, in the absence of <strong>precise</strong> consumption, there are no special
138625bd8deadSopenharmony_ciconstraints on the number of operations or difference in precision between
138635bd8deadSopenharmony_ci<strong>fma</strong>() and the expression <code>a * b + c</code>.</p>
138645bd8deadSopenharmony_ci</div>
138655bd8deadSopenharmony_ci</div>
138665bd8deadSopenharmony_ci</div></div></td>
138675bd8deadSopenharmony_ci</tr>
138685bd8deadSopenharmony_ci<tr>
138695bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>frexp</strong>(highp genFType <em>x</em>, out highp genIType <em>exp</em>)
138705bd8deadSopenharmony_ci  genDType <strong>frexp</strong>(genDType <em>x</em>, out genIType <em>exp</em>)<br></p></td>
138715bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Splits <em>x</em> into a floating-point significand in the range
138725bd8deadSopenharmony_ci      <span class="eq">[0.5,1.0]</span>, and an integral exponent of two, such that</p>
138735bd8deadSopenharmony_ci<p class="tableblock">      <span class="eq">x = significant · 2<sup>exponent</sup></span></p>
138745bd8deadSopenharmony_ci<p class="tableblock">      The significand is returned by the function and the exponent is
138755bd8deadSopenharmony_ci      returned in the parameter <em>exp</em>.
138765bd8deadSopenharmony_ci      For a floating-point value of zero, the significand and exponent are
138775bd8deadSopenharmony_ci      both zero.</p>
138785bd8deadSopenharmony_ci<p class="tableblock">      If an implementation supports signed zero, an input value of minus
138795bd8deadSopenharmony_ci      zero should return a significand of minus zero.
138805bd8deadSopenharmony_ci      For a floating-point value that is an infinity or is not a number, the
138815bd8deadSopenharmony_ci      results are undefined.</p>
138825bd8deadSopenharmony_ci<p class="tableblock">      If the input <em>x</em> is a vector, this operation is performed in a
138835bd8deadSopenharmony_ci      component-wise manner; the value returned by the function and the
138845bd8deadSopenharmony_ci      value written to <em>exp</em> are vectors with the same number of components
138855bd8deadSopenharmony_ci      as <em>x</em>.</p></td>
138865bd8deadSopenharmony_ci</tr>
138875bd8deadSopenharmony_ci<tr>
138885bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>ldexp</strong>(highp genFType <em>x</em>, highp genIType <em>exp</em>)<br>
138895bd8deadSopenharmony_ci  genDType <strong>ldexp</strong>(genDType <em>x</em>, genIType <em>exp</em>)</p></td>
138905bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Builds a floating-point number from <em>x</em> and the corresponding integral
138915bd8deadSopenharmony_ci      exponent of two in <em>exp</em>, returning:</p>
138925bd8deadSopenharmony_ci<p class="tableblock">      <span class="eq">significand · 2<sup>exponent</sup></span></p>
138935bd8deadSopenharmony_ci<p class="tableblock">      If this product is too large to be represented in the floating-point
138945bd8deadSopenharmony_ci      type, the result is undefined.</p>
138955bd8deadSopenharmony_ci<p class="tableblock">      If <em>exp</em> is greater than +128 (single-precision) or +1024
138965bd8deadSopenharmony_ci      (double-precision), the value returned is undefined.
138975bd8deadSopenharmony_ci      If <em>exp</em> is less than -126 (single-precision) or -1022
138985bd8deadSopenharmony_ci      (double-precision), the value returned may be flushed to zero.
138995bd8deadSopenharmony_ci      Additionally, splitting the value into a significand and exponent
139005bd8deadSopenharmony_ci      using <strong>frexp</strong>() and then reconstructing a floating-point value using
139015bd8deadSopenharmony_ci      <strong>ldexp</strong>() should yield the original input for zero and all finite
139025bd8deadSopenharmony_ci      non-denormalized values.<br>
139035bd8deadSopenharmony_ci      If the input <em>x</em> is a vector, this operation is performed in a
139045bd8deadSopenharmony_ci      component-wise manner; the value passed in <em>exp</em> and returned by the
139055bd8deadSopenharmony_ci      function are vectors with the same number of components as <em>x</em>.</p></td>
139065bd8deadSopenharmony_ci</tr>
139075bd8deadSopenharmony_ci</tbody>
139085bd8deadSopenharmony_ci</table>
139095bd8deadSopenharmony_ci</div>
139105bd8deadSopenharmony_ci<div class="sect2">
139115bd8deadSopenharmony_ci<h3 id="floating-point-pack-and-unpack-functions">8.4. Floating-Point Pack and Unpack Functions</h3>
139125bd8deadSopenharmony_ci<div class="paragraph">
139135bd8deadSopenharmony_ci<p>These functions do not operate component-wise, rather, as described in each
139145bd8deadSopenharmony_cicase.</p>
139155bd8deadSopenharmony_ci</div>
139165bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
139175bd8deadSopenharmony_ci<colgroup>
139185bd8deadSopenharmony_ci<col style="width: 50%;">
139195bd8deadSopenharmony_ci<col style="width: 50%;">
139205bd8deadSopenharmony_ci</colgroup>
139215bd8deadSopenharmony_ci<thead>
139225bd8deadSopenharmony_ci<tr>
139235bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
139245bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
139255bd8deadSopenharmony_ci</tr>
139265bd8deadSopenharmony_ci</thead>
139275bd8deadSopenharmony_ci<tbody>
139285bd8deadSopenharmony_ci<tr>
139295bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">highp uint <strong>packUnorm2x16</strong>(vec2 <em>v</em>)<br>
139305bd8deadSopenharmony_ci  highp uint <strong>packSnorm2x16</strong>(vec2 <em>v</em>)<br>
139315bd8deadSopenharmony_ci   uint <strong>packUnorm4x8</strong>(vec4 <em>v</em>)<br>
139325bd8deadSopenharmony_ci   uint <strong>packSnorm4x8</strong>(vec4 <em>v</em>)</p></td>
139335bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">First, converts each component of the normalized floating-point value
139345bd8deadSopenharmony_ci      <em>v</em> into 16-bit (<strong>2x16</strong>) or 8-bit (<strong>4x8</strong>) integer values.
139355bd8deadSopenharmony_ci      Then, the results are packed into the returned 32-bit unsigned
139365bd8deadSopenharmony_ci      integer.</p>
139375bd8deadSopenharmony_ci<p class="tableblock">      The conversion for component <em>c</em> of <em>v</em> to fixed point is done as
139385bd8deadSopenharmony_ci      follows:</p>
139395bd8deadSopenharmony_ci<p class="tableblock">      <strong>packUnorm2x16</strong>: <strong>round</strong>(<strong>clamp</strong>(<em>c</em>, 0, +1) * 65535.0)<br>
139405bd8deadSopenharmony_ci      <strong>packSnorm2x16:</strong> <strong>round</strong>(<strong>clamp</strong>(<em>c</em>, -1, +1) * 32767.0)<br>
139415bd8deadSopenharmony_ci      <strong>packUnorm4x8</strong>: <strong>round</strong>(<strong>clamp</strong>(<em>c</em>, 0, +1) * 255.0)<br>
139425bd8deadSopenharmony_ci      <strong>packSnorm4x8</strong>: <strong>round</strong>(<strong>clamp</strong>(<em>c</em>, -1, +1) * 127.0)</p>
139435bd8deadSopenharmony_ci<p class="tableblock">      The first component of the vector will be written to the least
139445bd8deadSopenharmony_ci      significant bits of the output; the last component will be written to
139455bd8deadSopenharmony_ci      the most significant bits.</p></td>
139465bd8deadSopenharmony_ci</tr>
139475bd8deadSopenharmony_ci<tr>
139485bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"> vec2 <strong>unpackUnorm2x16</strong>(highp uint <em>p</em>)<br>
139495bd8deadSopenharmony_ci   vec2 <strong>unpackSnorm2x16</strong>(highp uint <em>p</em>)<br>
139505bd8deadSopenharmony_ci   vec4 <strong>unpackUnorm4x8</strong>(highp uint <em>p</em>)<br>
139515bd8deadSopenharmony_ci   vec4 <strong>unpackSnorm4x8</strong>(highp uint <em>p</em>)</p></td>
139525bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">First, unpacks a single 32-bit unsigned integer <em>p</em> into a pair of
139535bd8deadSopenharmony_ci      16-bit unsigned integers, a pair of 16-bit signed integers, four 8-bit
139545bd8deadSopenharmony_ci      unsigned integers, or four 8-bit signed integers, respectively.
139555bd8deadSopenharmony_ci      Then, each component is converted to a normalized floating-point value
139565bd8deadSopenharmony_ci      to generate the returned two- or four-component vector.</p>
139575bd8deadSopenharmony_ci<p class="tableblock">      The conversion for unpacked fixed-point value <em>f</em> to floating-point is
139585bd8deadSopenharmony_ci      done as follows:</p>
139595bd8deadSopenharmony_ci<p class="tableblock">      <strong>unpackUnorm2x16</strong>: <em>f</em> / 65535.0<br>
139605bd8deadSopenharmony_ci      <strong>unpackSnorm2x16</strong>: <strong>clamp</strong>(<em>f</em> / 32767.0, -1, +1)<br>
139615bd8deadSopenharmony_ci      <strong>unpackUnorm4x8</strong>: <em>f</em> / 255.0<br>
139625bd8deadSopenharmony_ci      <strong>unpackSnorm4x8</strong>: <strong>clamp</strong>(<em>f</em> / 127.0, -1, +1)</p>
139635bd8deadSopenharmony_ci<p class="tableblock">      The first component of the returned vector will be extracted from the
139645bd8deadSopenharmony_ci      least significant bits of the input; the last component will be
139655bd8deadSopenharmony_ci      extracted from the most significant bits.</p></td>
139665bd8deadSopenharmony_ci</tr>
139675bd8deadSopenharmony_ci<tr>
139685bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"> uint <strong>packHalf2x16</strong>(vec2 <em>v</em>)</p></td>
139695bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns an unsigned integer obtained by converting the components of a
139705bd8deadSopenharmony_ci      two-component floating-point vector to the 16-bit floating-point
139715bd8deadSopenharmony_ci      representation of the <a href="#references">API</a>, and
139725bd8deadSopenharmony_ci      then packing these two 16-bit integers into a 32-bit unsigned integer.</p>
139735bd8deadSopenharmony_ci<p class="tableblock">      The first vector component specifies the 16 least-significant bits of
139745bd8deadSopenharmony_ci      the result; the second component specifies the 16 most-significant
139755bd8deadSopenharmony_ci      bits.</p></td>
139765bd8deadSopenharmony_ci</tr>
139775bd8deadSopenharmony_ci<tr>
139785bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"> vec2 <strong>unpackHalf2x16</strong>( uint <em>v</em>)</p></td>
139795bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a two-component floating-point vector with components obtained
139805bd8deadSopenharmony_ci      by unpacking a 32-bit unsigned integer into a pair of 16-bit values,
139815bd8deadSopenharmony_ci      interpreting those values as 16-bit floating-point numbers according
139825bd8deadSopenharmony_ci      to the <a href="#references">API</a>, and converting them to
139835bd8deadSopenharmony_ci      32-bit floating-point values.</p>
139845bd8deadSopenharmony_ci<p class="tableblock">      The first component of the vector is obtained from the 16
139855bd8deadSopenharmony_ci      least-significant bits of <em>v</em>; the second component is obtained from
139865bd8deadSopenharmony_ci      the 16 most-significant bits of <em>v</em>.</p></td>
139875bd8deadSopenharmony_ci</tr>
139885bd8deadSopenharmony_ci<tr>
139895bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">double <strong>packDouble2x32</strong>(uvec2 <em>v</em>)<br></p></td>
139905bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a double-precision value obtained by packing the components of
139915bd8deadSopenharmony_ci      <em>v</em> into a 64-bit value.
139925bd8deadSopenharmony_ci      If an IEEE 754 Inf or NaN is created, it will not signal, and the
139935bd8deadSopenharmony_ci      resulting floating-point value is unspecified.
139945bd8deadSopenharmony_ci      Otherwise, the bit-level representation of <em>v</em> is preserved.
139955bd8deadSopenharmony_ci      The first vector component specifies the 32 least significant bits;
139965bd8deadSopenharmony_ci      the second component specifies the 32 most significant bits.</p></td>
139975bd8deadSopenharmony_ci</tr>
139985bd8deadSopenharmony_ci<tr>
139995bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uvec2 <strong>unpackDouble2x32</strong>(double <em>v</em>)</p></td>
140005bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a two-component unsigned integer vector representation of <em>v</em>.
140015bd8deadSopenharmony_ci      The bit-level representation of <em>v</em> is preserved.
140025bd8deadSopenharmony_ci      The first component of the vector contains the 32 least significant
140035bd8deadSopenharmony_ci      bits of the double; the second component consists of the 32 most
140045bd8deadSopenharmony_ci      significant bits.</p></td>
140055bd8deadSopenharmony_ci</tr>
140065bd8deadSopenharmony_ci</tbody>
140075bd8deadSopenharmony_ci</table>
140085bd8deadSopenharmony_ci</div>
140095bd8deadSopenharmony_ci<div class="sect2">
140105bd8deadSopenharmony_ci<h3 id="geometric-functions">8.5. Geometric Functions</h3>
140115bd8deadSopenharmony_ci<div class="paragraph">
140125bd8deadSopenharmony_ci<p>These operate on vectors as vectors, not component-wise.</p>
140135bd8deadSopenharmony_ci</div>
140145bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
140155bd8deadSopenharmony_ci<colgroup>
140165bd8deadSopenharmony_ci<col style="width: 50%;">
140175bd8deadSopenharmony_ci<col style="width: 50%;">
140185bd8deadSopenharmony_ci</colgroup>
140195bd8deadSopenharmony_ci<thead>
140205bd8deadSopenharmony_ci<tr>
140215bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
140225bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
140235bd8deadSopenharmony_ci</tr>
140245bd8deadSopenharmony_ci</thead>
140255bd8deadSopenharmony_ci<tbody>
140265bd8deadSopenharmony_ci<tr>
140275bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">float <strong>length</strong>(genFType <em>x</em>)<br>
140285bd8deadSopenharmony_ci  double <strong>length</strong>(genDType <em>x</em>)</p></td>
140295bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
140305bd8deadSopenharmony_ci<p>Returns the length of vector <em>x</em>, i.e.,
140315bd8deadSopenharmony_ci      <span class="eq">sqrt( x<sub>0</sub><sup>2</sup> + x<sub>1</sub><sup>2</sup> + &#8230;&#8203; )</span>.</p>
140325bd8deadSopenharmony_ci</div></div></td>
140335bd8deadSopenharmony_ci</tr>
140345bd8deadSopenharmony_ci<tr>
140355bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">float <strong>distance</strong>(genFType <em>p0</em>, genFType <em>p1</em>)<br>
140365bd8deadSopenharmony_ci  double <strong>distance</strong>(genDType <em>p0</em>, genDType <em>p1</em>)</p></td>
140375bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the distance between <em>p0</em> and <em>p1</em>, i.e.,
140385bd8deadSopenharmony_ci      <strong>length</strong>(<em>p0</em> - <em>p1</em>)</p></td>
140395bd8deadSopenharmony_ci</tr>
140405bd8deadSopenharmony_ci<tr>
140415bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">float <strong>dot</strong>(genFType <em>x</em>, genFType <em>y</em>)<br>
140425bd8deadSopenharmony_ci  double <strong>dot</strong>(genDType <em>x</em>, genDType <em>y</em>)</p></td>
140435bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the dot product of <em>x</em> and <em>y</em>, i.e.,
140445bd8deadSopenharmony_ci      <span class="eq">x<sub>0</sub> · y<sub>0</sub> + x<sub>1</sub> · y<sub>1</sub> + &#8230;&#8203;</span></p></td>
140455bd8deadSopenharmony_ci</tr>
140465bd8deadSopenharmony_ci<tr>
140475bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">vec3 <strong>cross</strong>(vec3 <em>x</em>, vec3 <em>y</em>)<br>
140485bd8deadSopenharmony_ci  dvec3 <strong>cross</strong>(dvec3 <em>x</em>, dvec3 <em>y</em>)</p></td>
140495bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
140505bd8deadSopenharmony_ci<p>Returns the cross product of <em>x</em> and <em>y</em>, i.e.,
140515bd8deadSopenharmony_ci      <span class="eq">(x<sub>1</sub> · y<sub>2</sub> - y<sub>1</sub> · x<sub>2</sub>,
140525bd8deadSopenharmony_ci            x<sub>2</sub> · y<sub>0</sub> - y<sub>2</sub> · x<sub>0</sub>,
140535bd8deadSopenharmony_ci            x<sub>0</sub> · y<sub>1</sub> - y<sub>0</sub> · x<sub>1</sub>)</span>.</p>
140545bd8deadSopenharmony_ci</div></div></td>
140555bd8deadSopenharmony_ci</tr>
140565bd8deadSopenharmony_ci<tr>
140575bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>normalize</strong>(genFType <em>x</em>)<br>
140585bd8deadSopenharmony_ci  genDType <strong>normalize</strong>(genDType <em>x</em>)</p></td>
140595bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a vector in the same direction as <em>x</em> but with a length of 1,
140605bd8deadSopenharmony_ci      i.e. <em>x</em> / <strong>length</strong>(x).</p></td>
140615bd8deadSopenharmony_ci</tr>
140625bd8deadSopenharmony_ci<tr>
140635bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">compatibility profile only<br>
140645bd8deadSopenharmony_ci  vec4 <strong>ftransform</strong>()</p></td>
140655bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
140665bd8deadSopenharmony_ci<p>Available only when using the compatibility profile.
140675bd8deadSopenharmony_ci      For core OpenGL, use <strong>invariant</strong>.<br>
140685bd8deadSopenharmony_ci      For vertex shaders only.
140695bd8deadSopenharmony_ci      This function will ensure that the incoming vertex value will be
140705bd8deadSopenharmony_ci      transformed in a way that produces exactly the same result as would be
140715bd8deadSopenharmony_ci      produced by OpenGL&#8217;s fixed functionality transform.
140725bd8deadSopenharmony_ci      It is intended to be used to compute <em>gl_Position</em>, e.g.</p>
140735bd8deadSopenharmony_ci</div>
140745bd8deadSopenharmony_ci<div class="openblock">
140755bd8deadSopenharmony_ci<div class="content">
140765bd8deadSopenharmony_ci<div class="dlist">
140775bd8deadSopenharmony_ci<dl>
140785bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
140795bd8deadSopenharmony_ci<dd>
140805bd8deadSopenharmony_ci<p><em>gl_Position</em> = <strong>ftransform</strong>()</p>
140815bd8deadSopenharmony_ci</dd>
140825bd8deadSopenharmony_ci</dl>
140835bd8deadSopenharmony_ci</div>
140845bd8deadSopenharmony_ci<div class="paragraph">
140855bd8deadSopenharmony_ci<p>This function should be used, for example, when an application is rendering
140865bd8deadSopenharmony_cithe same geometry in separate passes, and one pass uses the fixed
140875bd8deadSopenharmony_cifunctionality path to render and another pass uses programmable shaders.</p>
140885bd8deadSopenharmony_ci</div>
140895bd8deadSopenharmony_ci</div>
140905bd8deadSopenharmony_ci</div></div></td>
140915bd8deadSopenharmony_ci</tr>
140925bd8deadSopenharmony_ci<tr>
140935bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>faceforward</strong>(genFType <em>N</em>, genFType <em>I</em>, genFType <em>Nref</em>)<br>
140945bd8deadSopenharmony_ci  genDType <strong>faceforward</strong>(genDType <em>N</em>, genDType <em>I</em>, genDType <em>Nref</em>)</p></td>
140955bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">If <strong>dot</strong>(<em>Nref</em>, <em>I</em>) &lt; 0 return <em>N</em>, otherwise return -<em>N</em>.</p></td>
140965bd8deadSopenharmony_ci</tr>
140975bd8deadSopenharmony_ci<tr>
140985bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>reflect</strong>(genFType <em>I</em>, genFType <em>N</em>)<br>
140995bd8deadSopenharmony_ci  genDType <strong>reflect</strong>(genDType <em>I</em>, genDType <em>N</em>)</p></td>
141005bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">For the incident vector <em>I</em> and surface orientation <em>N</em>, returns the
141015bd8deadSopenharmony_ci      reflection direction: <span class="eq">I - 2 · <strong>dot</strong>(N, I) · N</span>.
141025bd8deadSopenharmony_ci      <em>N</em> must already be normalized in order to achieve the desired result.</p></td>
141035bd8deadSopenharmony_ci</tr>
141045bd8deadSopenharmony_ci<tr>
141055bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>refract</strong>(genFType <em>I</em>, genFType <em>N</em>, float <em>eta</em>)<br>
141065bd8deadSopenharmony_ci  genDType <strong>refract</strong>(genDType <em>I</em>, genDType <em>N</em>, double <em>eta</em>)</p></td>
141075bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
141085bd8deadSopenharmony_ci<p>For the incident vector <em>I</em> and surface normal <em>N</em>, and the ratio of
141095bd8deadSopenharmony_ci      indices of refraction <em>eta</em>, return the refraction vector.
141105bd8deadSopenharmony_ci      The result is computed by the <a href="#refraction-equation">refraction
141115bd8deadSopenharmony_ci      equation</a> shown below.</p>
141125bd8deadSopenharmony_ci</div>
141135bd8deadSopenharmony_ci<div class="literalblock">
141145bd8deadSopenharmony_ci<div class="content">
141155bd8deadSopenharmony_ci<pre>The input parameters for the incident vector _I_ and the surface
141165bd8deadSopenharmony_cinormal _N_ must already be normalized to get the desired results.</pre>
141175bd8deadSopenharmony_ci</div>
141185bd8deadSopenharmony_ci</div></div></td>
141195bd8deadSopenharmony_ci</tr>
141205bd8deadSopenharmony_ci</tbody>
141215bd8deadSopenharmony_ci</table>
141225bd8deadSopenharmony_ci<div class="sect3">
141235bd8deadSopenharmony_ci<h4 id="refraction-equation">8.5.1. Refraction Equation</h4>
141245bd8deadSopenharmony_ci<div class="stemblock">
141255bd8deadSopenharmony_ci<div class="content">
141265bd8deadSopenharmony_ci\[k = 1.0 - eta * eta * (1.0 - \textbf{dot}(N,I) \cdot \textbf{dot}(N,I))\]
141275bd8deadSopenharmony_ci</div>
141285bd8deadSopenharmony_ci</div>
141295bd8deadSopenharmony_ci<div class="stemblock">
141305bd8deadSopenharmony_ci<div class="content">
141315bd8deadSopenharmony_ci\[\begin{aligned}
141325bd8deadSopenharmony_ciresult &amp;=
141335bd8deadSopenharmony_ci  \begin{cases}
141345bd8deadSopenharmony_ci    genFType(0.0), &amp; k &lt; 0.0 \\
141355bd8deadSopenharmony_ci    eta * I - (eta * \textbf{dot}(N,I) + \sqrt { k }) * N, &amp; \textbf{otherwise}
141365bd8deadSopenharmony_ci  \end{cases}
141375bd8deadSopenharmony_ci\end{aligned}\]
141385bd8deadSopenharmony_ci</div>
141395bd8deadSopenharmony_ci</div>
141405bd8deadSopenharmony_ci</div>
141415bd8deadSopenharmony_ci</div>
141425bd8deadSopenharmony_ci<div class="sect2">
141435bd8deadSopenharmony_ci<h3 id="matrix-functions">8.6. Matrix Functions</h3>
141445bd8deadSopenharmony_ci<div class="paragraph">
141455bd8deadSopenharmony_ci<p>For each of the following built-in matrix functions, there is both a
141465bd8deadSopenharmony_cisingle-precision floating-point version, where all arguments and return
141475bd8deadSopenharmony_civalues are single precision, and a double-precision floating-point version,
141485bd8deadSopenharmony_ciwhere all arguments and return values are double precision.
141495bd8deadSopenharmony_ciOnly the single-precision floating-point version is shown.</p>
141505bd8deadSopenharmony_ci</div>
141515bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
141525bd8deadSopenharmony_ci<colgroup>
141535bd8deadSopenharmony_ci<col style="width: 50%;">
141545bd8deadSopenharmony_ci<col style="width: 50%;">
141555bd8deadSopenharmony_ci</colgroup>
141565bd8deadSopenharmony_ci<thead>
141575bd8deadSopenharmony_ci<tr>
141585bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
141595bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
141605bd8deadSopenharmony_ci</tr>
141615bd8deadSopenharmony_ci</thead>
141625bd8deadSopenharmony_ci<tbody>
141635bd8deadSopenharmony_ci<tr>
141645bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">mat <strong>matrixCompMult</strong>(mat <em>x</em>, mat <em>y</em>)</p></td>
141655bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Multiply matrix <em>x</em> by matrix <em>y</em> component-wise, i.e., result[i][j]
141665bd8deadSopenharmony_ci      is the scalar product of <em>x</em>[i][j] and <em>y</em>[i][j].<br></p>
141675bd8deadSopenharmony_ci<p class="tableblock">      Note: to get linear algebraic matrix multiplication, use the multiply
141685bd8deadSopenharmony_ci      operator (<strong>*</strong>).</p></td>
141695bd8deadSopenharmony_ci</tr>
141705bd8deadSopenharmony_ci<tr>
141715bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">mat2 <strong>outerProduct</strong>(vec2 <em>c</em>, vec2 <em>r</em>)<br>
141725bd8deadSopenharmony_ci  mat3 <strong>outerProduct</strong>(vec3 <em>c</em>, vec3 <em>r</em>)<br>
141735bd8deadSopenharmony_ci  mat4 <strong>outerProduct</strong>(vec4 <em>c</em>, vec4 <em>r</em>)<br>
141745bd8deadSopenharmony_ci  mat2x3 <strong>outerProduct</strong>(vec3 <em>c</em>, vec2 <em>r</em>)<br>
141755bd8deadSopenharmony_ci  mat3x2 <strong>outerProduct</strong>(vec2 <em>c</em>, vec3 <em>r</em>)<br>
141765bd8deadSopenharmony_ci  mat2x4 <strong>outerProduct</strong>(vec4 <em>c</em>, vec2 <em>r</em>)<br>
141775bd8deadSopenharmony_ci  mat4x2 <strong>outerProduct</strong>(vec2 <em>c</em>, vec4 <em>r</em>)<br>
141785bd8deadSopenharmony_ci  mat3x4 <strong>outerProduct</strong>(vec4 <em>c</em>, vec3 <em>r</em>)<br>
141795bd8deadSopenharmony_ci  mat4x3 <strong>outerProduct</strong>(vec3 <em>c</em>, vec4 <em>r</em>)</p></td>
141805bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Treats the first parameter <em>c</em> as a column vector (matrix with one
141815bd8deadSopenharmony_ci      column) and the second parameter <em>r</em> as a row vector (matrix with one
141825bd8deadSopenharmony_ci      row) and does a linear algebraic matrix multiply <em>c</em> * <em>r</em>, yielding a
141835bd8deadSopenharmony_ci      matrix whose number of rows is the number of components in <em>c</em> and
141845bd8deadSopenharmony_ci      whose number of columns is the number of components in <em>r</em>.</p></td>
141855bd8deadSopenharmony_ci</tr>
141865bd8deadSopenharmony_ci<tr>
141875bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">mat2 <strong>transpose</strong>(mat2 <em>m</em>)<br>
141885bd8deadSopenharmony_ci  mat3 <strong>transpose</strong>(mat3 <em>m</em>)<br>
141895bd8deadSopenharmony_ci  mat4 <strong>transpose</strong>(mat4 <em>m</em>)<br>
141905bd8deadSopenharmony_ci  mat2x3 <strong>transpose</strong>(mat3x2 <em>m</em>)<br>
141915bd8deadSopenharmony_ci  mat3x2 <strong>transpose</strong>(mat2x3 <em>m</em>)<br>
141925bd8deadSopenharmony_ci  mat2x4 <strong>transpose</strong>(mat4x2 <em>m</em>)<br>
141935bd8deadSopenharmony_ci  mat4x2 <strong>transpose</strong>(mat2x4 <em>m</em>)<br>
141945bd8deadSopenharmony_ci  mat3x4 <strong>transpose</strong>(mat4x3 <em>m</em>)<br>
141955bd8deadSopenharmony_ci  mat4x3 <strong>transpose</strong>(mat3x4 <em>m</em>)</p></td>
141965bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a matrix that is the transpose of <em>m</em>.
141975bd8deadSopenharmony_ci      The input matrix <em>m</em> is not modified.</p></td>
141985bd8deadSopenharmony_ci</tr>
141995bd8deadSopenharmony_ci<tr>
142005bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">float <strong>determinant</strong>(mat2 <em>m</em>)<br>
142015bd8deadSopenharmony_ci  float <strong>determinant</strong>(mat3 <em>m</em>)<br>
142025bd8deadSopenharmony_ci  float <strong>determinant</strong>(mat4 <em>m</em>)</p></td>
142035bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the determinant of <em>m</em>.</p></td>
142045bd8deadSopenharmony_ci</tr>
142055bd8deadSopenharmony_ci<tr>
142065bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">mat2 <strong>inverse</strong>(mat2 <em>m</em>)<br>
142075bd8deadSopenharmony_ci  mat3 <strong>inverse</strong>(mat3 <em>m</em>)<br>
142085bd8deadSopenharmony_ci  mat4 <strong>inverse</strong>(mat4 <em>m</em>)</p></td>
142095bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a matrix that is the inverse of <em>m</em>.
142105bd8deadSopenharmony_ci      The input matrix <em>m</em> is not modified.
142115bd8deadSopenharmony_ci      The values in the returned matrix are undefined if <em>m</em> is singular or
142125bd8deadSopenharmony_ci      poorly-conditioned (nearly singular).</p></td>
142135bd8deadSopenharmony_ci</tr>
142145bd8deadSopenharmony_ci</tbody>
142155bd8deadSopenharmony_ci</table>
142165bd8deadSopenharmony_ci</div>
142175bd8deadSopenharmony_ci<div class="sect2">
142185bd8deadSopenharmony_ci<h3 id="vector-relational-functions">8.7. Vector Relational Functions</h3>
142195bd8deadSopenharmony_ci<div class="paragraph">
142205bd8deadSopenharmony_ci<p>Relational and equality operators (<strong>&lt;</strong>, <strong>&lt;=</strong>, <strong>&gt;</strong>, <strong>&gt;=</strong>, <strong>==</strong>, <strong>!=</strong>) are
142215bd8deadSopenharmony_cidefined to operate on scalars and produce scalar Boolean results.
142225bd8deadSopenharmony_ciFor vector results, use the following built-in functions.
142235bd8deadSopenharmony_ciBelow, the following placeholders are used for the listed specific types:</p>
142245bd8deadSopenharmony_ci</div>
142255bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
142265bd8deadSopenharmony_ci<colgroup>
142275bd8deadSopenharmony_ci<col style="width: 50%;">
142285bd8deadSopenharmony_ci<col style="width: 50%;">
142295bd8deadSopenharmony_ci</colgroup>
142305bd8deadSopenharmony_ci<thead>
142315bd8deadSopenharmony_ci<tr>
142325bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Placeholder</th>
142335bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Specific Types Allowed</th>
142345bd8deadSopenharmony_ci</tr>
142355bd8deadSopenharmony_ci</thead>
142365bd8deadSopenharmony_ci<tbody>
142375bd8deadSopenharmony_ci<tr>
142385bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bvec</p></td>
142395bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bvec2, bvec3, bvec4</p></td>
142405bd8deadSopenharmony_ci</tr>
142415bd8deadSopenharmony_ci<tr>
142425bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">ivec</p></td>
142435bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">ivec2, ivec3, ivec4</p></td>
142445bd8deadSopenharmony_ci</tr>
142455bd8deadSopenharmony_ci<tr>
142465bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uvec</p></td>
142475bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uvec2, uvec3, uvec4</p></td>
142485bd8deadSopenharmony_ci</tr>
142495bd8deadSopenharmony_ci<tr>
142505bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">vec</p></td>
142515bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">vec2, vec3, vec4, dvec2, dvec3, dvec4</p></td>
142525bd8deadSopenharmony_ci</tr>
142535bd8deadSopenharmony_ci</tbody>
142545bd8deadSopenharmony_ci</table>
142555bd8deadSopenharmony_ci<div class="paragraph">
142565bd8deadSopenharmony_ci<p>In all cases, the sizes of all the input and return vectors for any
142575bd8deadSopenharmony_ciparticular call must match.</p>
142585bd8deadSopenharmony_ci</div>
142595bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
142605bd8deadSopenharmony_ci<colgroup>
142615bd8deadSopenharmony_ci<col style="width: 50%;">
142625bd8deadSopenharmony_ci<col style="width: 50%;">
142635bd8deadSopenharmony_ci</colgroup>
142645bd8deadSopenharmony_ci<thead>
142655bd8deadSopenharmony_ci<tr>
142665bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
142675bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
142685bd8deadSopenharmony_ci</tr>
142695bd8deadSopenharmony_ci</thead>
142705bd8deadSopenharmony_ci<tbody>
142715bd8deadSopenharmony_ci<tr>
142725bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bvec <strong>lessThan</strong>(vec x, vec y)<br>
142735bd8deadSopenharmony_ci  bvec <strong>lessThan</strong>(ivec x, ivec y)<br>
142745bd8deadSopenharmony_ci  bvec <strong>lessThan</strong>(uvec x, uvec y)</p></td>
142755bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the component-wise compare of <span class="eq">x &lt; y</span>.</p></td>
142765bd8deadSopenharmony_ci</tr>
142775bd8deadSopenharmony_ci<tr>
142785bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bvec <strong>lessThanEqual</strong>(vec x, vec y)<br>
142795bd8deadSopenharmony_ci  bvec <strong>lessThanEqual</strong>(ivec x, ivec y)<br>
142805bd8deadSopenharmony_ci  bvec <strong>lessThanEqual</strong>(uvec x, uvec y)</p></td>
142815bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the component-wise compare of <span class="eq">x ≤ y</span>.</p></td>
142825bd8deadSopenharmony_ci</tr>
142835bd8deadSopenharmony_ci<tr>
142845bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bvec <strong>greaterThan</strong>(vec x, vec y)<br>
142855bd8deadSopenharmony_ci  bvec <strong>greaterThan</strong>(ivec x, ivec y)<br>
142865bd8deadSopenharmony_ci  bvec <strong>greaterThan</strong>(uvec x, uvec y)</p></td>
142875bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the component-wise compare of <span class="eq">x &gt; y</span>.</p></td>
142885bd8deadSopenharmony_ci</tr>
142895bd8deadSopenharmony_ci<tr>
142905bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bvec <strong>greaterThanEqual</strong>(vec x, vec y)<br>
142915bd8deadSopenharmony_ci  bvec <strong>greaterThanEqual</strong>(ivec x, ivec y)<br>
142925bd8deadSopenharmony_ci  bvec <strong>greaterThanEqual</strong>(uvec x, uvec y)</p></td>
142935bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the component-wise compare of <span class="eq">x ≥ y</span>.</p></td>
142945bd8deadSopenharmony_ci</tr>
142955bd8deadSopenharmony_ci<tr>
142965bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bvec <strong>equal</strong>(vec x, vec y)<br>
142975bd8deadSopenharmony_ci  bvec <strong>equal</strong>(ivec x, ivec y)<br>
142985bd8deadSopenharmony_ci  bvec <strong>equal</strong>(uvec x, uvec y)<br>
142995bd8deadSopenharmony_ci  bvec <strong>equal</strong>(bvec x, bvec y)</p></td>
143005bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the component-wise compare of <span class="eq">x == y</span>.</p></td>
143015bd8deadSopenharmony_ci</tr>
143025bd8deadSopenharmony_ci<tr>
143035bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bvec <strong>notEqual</strong>(vec x, vec y)<br>
143045bd8deadSopenharmony_ci  bvec <strong>notEqual</strong>(ivec x, ivec y)<br>
143055bd8deadSopenharmony_ci  bvec <strong>notEqual</strong>(uvec x, uvec y)<br>
143065bd8deadSopenharmony_ci  bvec <strong>notEqual</strong>(bvec x, bvec y)</p></td>
143075bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the component-wise compare of <span class="eq">x ≠ y</span>.</p></td>
143085bd8deadSopenharmony_ci</tr>
143095bd8deadSopenharmony_ci<tr>
143105bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bool <strong>any</strong>(bvec x)</p></td>
143115bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <strong>true</strong> if any component of <em>x</em> is <strong>true</strong>.</p></td>
143125bd8deadSopenharmony_ci</tr>
143135bd8deadSopenharmony_ci<tr>
143145bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bool <strong>all</strong>(bvec x)</p></td>
143155bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <strong>true</strong> only if all components of <em>x</em> are <strong>true</strong>.</p></td>
143165bd8deadSopenharmony_ci</tr>
143175bd8deadSopenharmony_ci<tr>
143185bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bvec <strong>not</strong>(bvec x)</p></td>
143195bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the component-wise logical complement of <em>x</em>.</p></td>
143205bd8deadSopenharmony_ci</tr>
143215bd8deadSopenharmony_ci</tbody>
143225bd8deadSopenharmony_ci</table>
143235bd8deadSopenharmony_ci</div>
143245bd8deadSopenharmony_ci<div class="sect2">
143255bd8deadSopenharmony_ci<h3 id="integer-functions">8.8. Integer Functions</h3>
143265bd8deadSopenharmony_ci<div class="paragraph">
143275bd8deadSopenharmony_ci<p>These all operate component-wise.
143285bd8deadSopenharmony_ciThe description is per component.
143295bd8deadSopenharmony_ciThe notation [<em>a</em>, <em>b</em>] means the set of bits from bit-number <em>a</em> through
143305bd8deadSopenharmony_cibit-number <em>b</em>, inclusive.
143315bd8deadSopenharmony_ciThe lowest-order bit is bit 0.
143325bd8deadSopenharmony_ci&#8220;Bit number&#8221; will always refer to counting up from the lowest-order bit as
143335bd8deadSopenharmony_cibit 0.</p>
143345bd8deadSopenharmony_ci</div>
143355bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
143365bd8deadSopenharmony_ci<colgroup>
143375bd8deadSopenharmony_ci<col style="width: 50%;">
143385bd8deadSopenharmony_ci<col style="width: 50%;">
143395bd8deadSopenharmony_ci</colgroup>
143405bd8deadSopenharmony_ci<thead>
143415bd8deadSopenharmony_ci<tr>
143425bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
143435bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
143445bd8deadSopenharmony_ci</tr>
143455bd8deadSopenharmony_ci</thead>
143465bd8deadSopenharmony_ci<tbody>
143475bd8deadSopenharmony_ci<tr>
143485bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genUType <strong>uaddCarry</strong>(highp genUType <em>x</em>, highp genUType <em>y</em>, out lowp genUType <em>carry</em>)</p></td>
143495bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Adds 32-bit unsigned integers <em>x</em> and <em>y</em>, returning the sum modulo
143505bd8deadSopenharmony_ci      2<sup>32</sup>.
143515bd8deadSopenharmony_ci      The value <em>carry</em> is set to zero if the sum was less than 2<sup>32</sup>, or
143525bd8deadSopenharmony_ci      one otherwise.</p></td>
143535bd8deadSopenharmony_ci</tr>
143545bd8deadSopenharmony_ci<tr>
143555bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genUType <strong>usubBorrow</strong>(highp genUType <em>x</em>, highp genUType <em>y</em>, out lowp genUType <em>borrow</em>)</p></td>
143565bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Subtracts the 32-bit unsigned integer <em>y</em> from <em>x</em>, returning the
143575bd8deadSopenharmony_ci      difference if non-negative, or 2<sup>32</sup> plus the difference otherwise.
143585bd8deadSopenharmony_ci      The value <em>borrow</em> is set to zero if <span class="eq">x ≥ y</span>, or one
143595bd8deadSopenharmony_ci      otherwise.</p></td>
143605bd8deadSopenharmony_ci</tr>
143615bd8deadSopenharmony_ci<tr>
143625bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>umulExtended</strong>(highp genUType <em>x</em>, highp genUType <em>y</em>, out highp genUType <em>msb</em>, out highp genUType <em>lsb</em>)<br>
143635bd8deadSopenharmony_ci  void <strong>imulExtended</strong>(highp genIType <em>x</em>, highp genIType <em>y</em>, out highp genIType <em>msb</em>, out highp genIType <em>lsb</em>)</p></td>
143645bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Multiplies 32-bit unsigned or signed integers <em>x</em> and <em>y</em>, producing a
143655bd8deadSopenharmony_ci      64-bit result.
143665bd8deadSopenharmony_ci      The 32 least-significant bits are returned in <em>lsb</em>.
143675bd8deadSopenharmony_ci      The 32 most-significant bits are returned in <em>msb</em>.</p></td>
143685bd8deadSopenharmony_ci</tr>
143695bd8deadSopenharmony_ci<tr>
143705bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genIType <strong>bitfieldExtract</strong>(genIType <em>value</em>, int <em>offset</em>, int <em>bits</em>)<br>
143715bd8deadSopenharmony_ci  genUType <strong>bitfieldExtract</strong>(genUType <em>value</em>, int <em>offset</em>, int <em>bits</em>)</p></td>
143725bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Extracts bits <span class="eq">[offset, offset + bits - 1]</span> from <em>value</em>,
143735bd8deadSopenharmony_ci      returning them in the least significant bits of the result.<br></p>
143745bd8deadSopenharmony_ci<p class="tableblock">      For unsigned data types, the most significant bits of the result will
143755bd8deadSopenharmony_ci      be set to zero.
143765bd8deadSopenharmony_ci      For signed data types, the most significant bits will be set to the
143775bd8deadSopenharmony_ci      value of bit <span class="eq">offset + bits - 1</span>.<br></p>
143785bd8deadSopenharmony_ci<p class="tableblock">      If <em>bits</em> is zero, the result will be zero.
143795bd8deadSopenharmony_ci      The result will be undefined if <em>offset</em> or <em>bits</em> is negative, or if
143805bd8deadSopenharmony_ci      the sum of <em>offset</em> and <em>bits</em> is greater than the number of bits used
143815bd8deadSopenharmony_ci      to store the operand.
143825bd8deadSopenharmony_ci      Note that for vector versions of <strong>bitfieldExtract</strong>(), a single pair of
143835bd8deadSopenharmony_ci      <em>offset</em> and <em>bits</em> values is shared for all components.</p></td>
143845bd8deadSopenharmony_ci</tr>
143855bd8deadSopenharmony_ci<tr>
143865bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genIType <strong>bitfieldInsert</strong>(genIType <em>base</em>, genIType <em>insert</em>, int <em>offset</em>, int <em>bits</em>)<br>
143875bd8deadSopenharmony_ci  genUType <strong>bitfieldInsert</strong>(genUType <em>base</em>, genUType <em>insert</em>, int <em>offset</em>, int <em>bits</em>)</p></td>
143885bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Inserts the <em>bits</em> least significant bits of <em>insert</em> into <em>base</em>.</p>
143895bd8deadSopenharmony_ci<p class="tableblock">      The result will have bits <span class="eq">[offset, offset + bits - 1]</span> taken from
143905bd8deadSopenharmony_ci      bits <span class="eq">[0, bits - 1]</span> of <em>insert</em>, and all other bits taken
143915bd8deadSopenharmony_ci      directly from the corresponding bits of <em>base</em>.
143925bd8deadSopenharmony_ci      If <em>bits</em> is zero, the result will simply be <em>base</em>.
143935bd8deadSopenharmony_ci      The result will be undefined if <em>offset</em> or <em>bits</em> is negative, or if
143945bd8deadSopenharmony_ci      the sum of <em>offset</em> and <em>bits</em> is greater than the number of bits used
143955bd8deadSopenharmony_ci      to store the operand.<br>
143965bd8deadSopenharmony_ci      Note that for vector versions of <strong>bitfieldInsert</strong>(), a single pair of
143975bd8deadSopenharmony_ci      <em>offset</em> and <em>bits</em> values is shared for all components.</p></td>
143985bd8deadSopenharmony_ci</tr>
143995bd8deadSopenharmony_ci<tr>
144005bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genIType <strong>bitfieldReverse</strong>(highp genIType <em>value</em>)<br>
144015bd8deadSopenharmony_ci  genUType <strong>bitfieldReverse</strong>(highp genUType <em>value</em>)</p></td>
144025bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Reverses the bits of <em>value</em>.
144035bd8deadSopenharmony_ci      The bit numbered <em>n</em> of the result will be taken from bit <span class="eq">(bits -
144045bd8deadSopenharmony_ci      1) - n</span> of <em>value</em>, where <em>bits</em> is the total number of bits used to
144055bd8deadSopenharmony_ci      represent <em>value</em>.</p></td>
144065bd8deadSopenharmony_ci</tr>
144075bd8deadSopenharmony_ci<tr>
144085bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"> genIType <strong>bitCount</strong>(genIType <em>value</em>)<br>
144095bd8deadSopenharmony_ci   genIType <strong>bitCount</strong>(genUType <em>value</em>)</p></td>
144105bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the number of one bits in the binary representation of
144115bd8deadSopenharmony_ci      <em>value</em>.</p></td>
144125bd8deadSopenharmony_ci</tr>
144135bd8deadSopenharmony_ci<tr>
144145bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"> genIType <strong>findLSB</strong>(genIType <em>value</em>)<br>
144155bd8deadSopenharmony_ci   genIType <strong>findLSB</strong>(genUType <em>value</em>)</p></td>
144165bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the bit number of the least significant one bit in the binary
144175bd8deadSopenharmony_ci      representation of <em>value</em>.
144185bd8deadSopenharmony_ci      If <em>value</em> is zero, -1 will be returned.</p></td>
144195bd8deadSopenharmony_ci</tr>
144205bd8deadSopenharmony_ci<tr>
144215bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"> genIType <strong>findMSB</strong>(highp genIType <em>value</em>)<br>
144225bd8deadSopenharmony_ci   genIType <strong>findMSB</strong>(highp genUType <em>value</em>)</p></td>
144235bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the bit number of the most significant bit in the binary
144245bd8deadSopenharmony_ci      representation of <em>value</em>.</p>
144255bd8deadSopenharmony_ci<p class="tableblock">      For positive integers, the result will be the bit number of the most
144265bd8deadSopenharmony_ci      significant one bit.
144275bd8deadSopenharmony_ci      For negative integers, the result will be the bit number of the most
144285bd8deadSopenharmony_ci      significant zero bit.
144295bd8deadSopenharmony_ci      For a <em>value</em> of zero or negative one, -1 will be returned.</p></td>
144305bd8deadSopenharmony_ci</tr>
144315bd8deadSopenharmony_ci</tbody>
144325bd8deadSopenharmony_ci</table>
144335bd8deadSopenharmony_ci</div>
144345bd8deadSopenharmony_ci<div class="sect2">
144355bd8deadSopenharmony_ci<h3 id="texture-functions">8.9. Texture Functions</h3>
144365bd8deadSopenharmony_ci<div class="paragraph">
144375bd8deadSopenharmony_ci<p>Texture lookup functions are available in all shading stages.
144385bd8deadSopenharmony_ciHowever, level-of-detail is implicitly computed only for fragment shaders.
144395bd8deadSopenharmony_ciOther shaders operate as though the base level-of-detail were computed as
144405bd8deadSopenharmony_cizero.
144415bd8deadSopenharmony_ciThe functions in the table below provide access to textures through
144425bd8deadSopenharmony_citexture-combined samplers, as set up through the API.
144435bd8deadSopenharmony_ciTexture properties such as size, pixel format, number of dimensions,
144445bd8deadSopenharmony_cifiltering method, number of mipmap levels, depth comparison, and so on are
144455bd8deadSopenharmony_cialso defined by API calls.
144465bd8deadSopenharmony_ciSuch properties are taken into account as the texture is accessed via the
144475bd8deadSopenharmony_cibuilt-in functions defined below.</p>
144485bd8deadSopenharmony_ci</div>
144495bd8deadSopenharmony_ci<div class="paragraph">
144505bd8deadSopenharmony_ci<p>Texture data can be stored by the GL as single-precision floating-point,
144515bd8deadSopenharmony_ciunsigned normalized integer, unsigned integer or signed integer data.
144525bd8deadSopenharmony_ciThis is determined by the type of the internal format of the texture.</p>
144535bd8deadSopenharmony_ci</div>
144545bd8deadSopenharmony_ci<div class="paragraph">
144555bd8deadSopenharmony_ci<p>Texture lookup functions are provided that can return their result as
144565bd8deadSopenharmony_cifloating-point, unsigned integer or signed integer, depending on the sampler
144575bd8deadSopenharmony_citype passed to the lookup function.
144585bd8deadSopenharmony_ciCare must be taken to use the right sampler type for texture access.
144595bd8deadSopenharmony_ciThe following table lists the supported combinations of sampler types and
144605bd8deadSopenharmony_citexture internal formats.
144615bd8deadSopenharmony_ciBlank entries are unsupported.
144625bd8deadSopenharmony_ciDoing a texture lookup will return undefined values for unsupported
144635bd8deadSopenharmony_cicombinations.</p>
144645bd8deadSopenharmony_ci</div>
144655bd8deadSopenharmony_ci<div class="paragraph">
144665bd8deadSopenharmony_ci<p>For depth/stencil textures, the internal texture format is determined by the
144675bd8deadSopenharmony_cicomponent being accessed as set through the API.
144685bd8deadSopenharmony_ciWhen the depth/stencil texture mode is set to DEPTH_COMPONENT, the internal
144695bd8deadSopenharmony_ciformat of the depth component should be used.
144705bd8deadSopenharmony_ciWhen the depth/stencil texture mode is set to STENCIL_INDEX, the internal format
144715bd8deadSopenharmony_ciof the stencil component should be used.</p>
144725bd8deadSopenharmony_ci</div>
144735bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
144745bd8deadSopenharmony_ci<colgroup>
144755bd8deadSopenharmony_ci<col style="width: 25%;">
144765bd8deadSopenharmony_ci<col style="width: 25%;">
144775bd8deadSopenharmony_ci<col style="width: 25%;">
144785bd8deadSopenharmony_ci<col style="width: 25%;">
144795bd8deadSopenharmony_ci</colgroup>
144805bd8deadSopenharmony_ci<thead>
144815bd8deadSopenharmony_ci<tr>
144825bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Internal Texture Format</th>
144835bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Floating-Point Sampler Types</th>
144845bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Signed Integer Sampler Types</th>
144855bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Unsigned Integer Sampler Types</th>
144865bd8deadSopenharmony_ci</tr>
144875bd8deadSopenharmony_ci</thead>
144885bd8deadSopenharmony_ci<tbody>
144895bd8deadSopenharmony_ci<tr>
144905bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Floating-point</p></td>
144915bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Supported</p></td>
144925bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"></td>
144935bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"></td>
144945bd8deadSopenharmony_ci</tr>
144955bd8deadSopenharmony_ci<tr>
144965bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Normalized Integer</p></td>
144975bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Supported</p></td>
144985bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"></td>
144995bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"></td>
145005bd8deadSopenharmony_ci</tr>
145015bd8deadSopenharmony_ci<tr>
145025bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Signed Integer</p></td>
145035bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"></td>
145045bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Supported</p></td>
145055bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"></td>
145065bd8deadSopenharmony_ci</tr>
145075bd8deadSopenharmony_ci<tr>
145085bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Unsigned Integer</p></td>
145095bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"></td>
145105bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"></td>
145115bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Supported</p></td>
145125bd8deadSopenharmony_ci</tr>
145135bd8deadSopenharmony_ci</tbody>
145145bd8deadSopenharmony_ci</table>
145155bd8deadSopenharmony_ci<div class="paragraph">
145165bd8deadSopenharmony_ci<p>If an integer sampler type is used, the result of a texture lookup is an
145175bd8deadSopenharmony_ci<strong>ivec4</strong>.
145185bd8deadSopenharmony_ciIf an unsigned integer sampler type is used, the result of a texture lookup
145195bd8deadSopenharmony_ciis a <strong>uvec4</strong>.
145205bd8deadSopenharmony_ciIf a floating-point sampler type is used, the result of a texture lookup is
145215bd8deadSopenharmony_cia <strong>vec4</strong>.</p>
145225bd8deadSopenharmony_ci</div>
145235bd8deadSopenharmony_ci<div class="paragraph">
145245bd8deadSopenharmony_ci<p>In the prototypes below, the <code>g</code> in the return type <code>gvec4</code> is used
145255bd8deadSopenharmony_cias a placeholder for either nothing, <code>i</code>, or <code>u</code> making a return type of
145265bd8deadSopenharmony_ci<strong>vec4</strong>, <strong>ivec4</strong>, or <strong>uvec4</strong>.
145275bd8deadSopenharmony_ciIn these cases, the sampler argument type also starts with <code>g</code>,
145285bd8deadSopenharmony_ciindicating the same substitution done on the return type; it is either a
145295bd8deadSopenharmony_cisingle-precision
145305bd8deadSopenharmony_cifloating-point, signed integer, or unsigned integer sampler, matching the
145315bd8deadSopenharmony_cibasic type of the return type, as described above.</p>
145325bd8deadSopenharmony_ci</div>
145335bd8deadSopenharmony_ci<div class="paragraph">
145345bd8deadSopenharmony_ci<p>For shadow forms (the sampler parameter is a shadow-type), a depth
145355bd8deadSopenharmony_cicomparison lookup on the depth texture bound to <em>sampler</em> is done as
145365bd8deadSopenharmony_cidescribed in section
145375bd8deadSopenharmony_ci8.23
145385bd8deadSopenharmony_ci&#8220;Texture Comparison Modes&#8221; of the
145395bd8deadSopenharmony_ci<a href="#references">OpenGL Specification</a>.
145405bd8deadSopenharmony_ciSee the table below for which component specifies <em>D<sub>ref</sub></em>.
145415bd8deadSopenharmony_ciThe texture bound to <em>sampler</em> must be a depth texture, or results are
145425bd8deadSopenharmony_ciundefined.
145435bd8deadSopenharmony_ciIf a non-shadow texture call is made to a sampler that represents a depth
145445bd8deadSopenharmony_citexture with depth comparisons turned on, then results are undefined.
145455bd8deadSopenharmony_ciIf a shadow texture call is made to a sampler that represents a depth
145465bd8deadSopenharmony_citexture with depth comparisons turned off, then results are undefined.
145475bd8deadSopenharmony_ciIf a shadow texture call is made to a sampler that does not represent a
145485bd8deadSopenharmony_cidepth texture, then results are undefined.</p>
145495bd8deadSopenharmony_ci</div>
145505bd8deadSopenharmony_ci<div class="paragraph">
145515bd8deadSopenharmony_ci<p>In all functions below, the <em>bias</em> parameter is optional for fragment
145525bd8deadSopenharmony_cishaders.
145535bd8deadSopenharmony_ciThe <em>bias</em> parameter is not accepted in any other shader stage.
145545bd8deadSopenharmony_ciFor a fragment shader, if <em>bias</em> is present, it is added to the implicit
145555bd8deadSopenharmony_cilevel-of-detail prior to performing the texture access operation.
145565bd8deadSopenharmony_ciNo <em>bias</em> or <em>lod</em> parameters for
145575bd8deadSopenharmony_cirectangle textures,
145585bd8deadSopenharmony_cimultisample textures, or texture buffers
145595bd8deadSopenharmony_ciare supported because mipmaps are not allowed for these types of textures.</p>
145605bd8deadSopenharmony_ci</div>
145615bd8deadSopenharmony_ci<div class="paragraph">
145625bd8deadSopenharmony_ci<p>The implicit level-of-detail is selected as follows: For a texture that is
145635bd8deadSopenharmony_cinot mipmapped, the texture is used directly.
145645bd8deadSopenharmony_ciIf it is mipmapped and running in a fragment shader, the level-of-detail
145655bd8deadSopenharmony_cicomputed by the implementation is used to do the texture lookup.
145665bd8deadSopenharmony_ciIf it is mipmapped and running in a non-fragment shader, then the base
145675bd8deadSopenharmony_citexture is used.</p>
145685bd8deadSopenharmony_ci</div>
145695bd8deadSopenharmony_ci<div class="paragraph">
145705bd8deadSopenharmony_ci<p>Some texture functions (non-&#8220;<strong>Lod</strong>&#8221; and non-&#8220;<strong>Grad</strong>&#8221; versions) may
145715bd8deadSopenharmony_cirequire implicit derivatives.
145725bd8deadSopenharmony_ciImplicit derivatives are undefined within non-uniform control flow and for
145735bd8deadSopenharmony_cinon-fragment shader texture fetches.</p>
145745bd8deadSopenharmony_ci</div>
145755bd8deadSopenharmony_ci<div class="paragraph">
145765bd8deadSopenharmony_ci<p>For <strong>Cube</strong> forms, the direction of <em>P</em> is used to select which face to do a
145775bd8deadSopenharmony_ci2-dimensional texture lookup in, as described in section 8.13 &#8220;Cube Map
145785bd8deadSopenharmony_ciTexture Selection&#8221; of the <a href="#references">OpenGL Specification</a>.</p>
145795bd8deadSopenharmony_ci</div>
145805bd8deadSopenharmony_ci<div class="paragraph">
145815bd8deadSopenharmony_ci<p>For <strong>Array</strong> forms, the array layer used will be</p>
145825bd8deadSopenharmony_ci</div>
145835bd8deadSopenharmony_ci<div class="paragraph">
145845bd8deadSopenharmony_ci<p>\(\max(0,\min(d-1,\left\lfloor layer + 0.5\right\rfloor))\)</p>
145855bd8deadSopenharmony_ci</div>
145865bd8deadSopenharmony_ci<div class="paragraph">
145875bd8deadSopenharmony_ci<p>where <em>d</em> is the depth of the texture array and <em>layer</em> comes from the
145885bd8deadSopenharmony_cicomponent indicated in the tables below.</p>
145895bd8deadSopenharmony_ci</div>
145905bd8deadSopenharmony_ci<div class="sect3">
145915bd8deadSopenharmony_ci<h4 id="texture-query-functions">8.9.1. Texture Query Functions</h4>
145925bd8deadSopenharmony_ci<div class="paragraph">
145935bd8deadSopenharmony_ci<p>The <strong>textureSize</strong> functions query the dimensions of a specific texture level
145945bd8deadSopenharmony_cifor a texture-combined sampler.</p>
145955bd8deadSopenharmony_ci</div>
145965bd8deadSopenharmony_ci<div class="paragraph">
145975bd8deadSopenharmony_ci<p>The <strong>textureQueryLod</strong> functions are available only in a fragment shader.
145985bd8deadSopenharmony_ciThey take the components of <em>P</em> and compute the level-of-detail information
145995bd8deadSopenharmony_cithat the texture pipe would use to access that texture through a normal
146005bd8deadSopenharmony_citexture lookup.
146015bd8deadSopenharmony_ciThe level-of-detail \(\lambda^{'}\) (equation 3.18 of the
146025bd8deadSopenharmony_ci<a href="#references">OpenGL Specification</a>) is obtained after any level-of-detail bias, but
146035bd8deadSopenharmony_ciprior to clamping to [TEXTURE_MIN_LOD, TEXTURE_MAX_LOD].
146045bd8deadSopenharmony_ciThe mipmap array(s) that would be accessed are also computed.
146055bd8deadSopenharmony_ciIf a single level-of-detail would be accessed, the level-of-detail number
146065bd8deadSopenharmony_cirelative to the base level is returned.
146075bd8deadSopenharmony_ciIf multiple levels-of-detail would be accessed, a floating-point number
146085bd8deadSopenharmony_cibetween the two levels is returned, with the fractional part equal to the
146095bd8deadSopenharmony_cifractional part of the computed and clamped level-of-detail.</p>
146105bd8deadSopenharmony_ci</div>
146115bd8deadSopenharmony_ci<div class="paragraph">
146125bd8deadSopenharmony_ci<p>The algorithm used is given by the following pseudo-code:</p>
146135bd8deadSopenharmony_ci</div>
146145bd8deadSopenharmony_ci<div class="listingblock">
146155bd8deadSopenharmony_ci<div class="content">
146165bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++"><span class="predefined-type">float</span> ComputeAccessedLod(<span class="predefined-type">float</span> computedLod)
146175bd8deadSopenharmony_ci{
146185bd8deadSopenharmony_ci    <span class="comment">// Clamp the computed LOD according to the texture LOD clamps.</span>
146195bd8deadSopenharmony_ci    <span class="keyword">if</span> (computedLod &lt; TEXTURE_MIN_LOD) computedLod = TEXTURE_MIN_LOD;
146205bd8deadSopenharmony_ci    <span class="keyword">if</span> (computedLod &gt; TEXTURE_MAX_LOD) computedLod = TEXTURE_MAX_LOD;
146215bd8deadSopenharmony_ci
146225bd8deadSopenharmony_ci    <span class="comment">// Clamp the computed LOD to the range of accessible levels.</span>
146235bd8deadSopenharmony_ci    <span class="keyword">if</span> (computedLod &lt; <span class="float">0</span><span class="float">.0</span>)
146245bd8deadSopenharmony_ci        computedLod = <span class="float">0</span><span class="float">.0</span>;
146255bd8deadSopenharmony_ci    <span class="keyword">if</span> (computedLod &gt; (<span class="predefined-type">float</span>) maxAccessibleLevel)
146265bd8deadSopenharmony_ci        computedLod = (<span class="predefined-type">float</span>) maxAccessibleLevel;
146275bd8deadSopenharmony_ci
146285bd8deadSopenharmony_ci    <span class="comment">// Return a value according to the min filter.</span>
146295bd8deadSopenharmony_ci    <span class="keyword">if</span> (TEXTURE_MIN_FILTER is LINEAR <span class="keyword">or</span> NEAREST) {
146305bd8deadSopenharmony_ci        <span class="keyword">return</span> <span class="float">0</span><span class="float">.0</span>;
146315bd8deadSopenharmony_ci    } <span class="keyword">else</span> <span class="keyword">if</span> (TEXTURE_MIN_FILTER is NEAREST_MIPMAP_NEAREST
146325bd8deadSopenharmony_ci               <span class="keyword">or</span> LINEAR_MIPMAP_NEAREST) {
146335bd8deadSopenharmony_ci        <span class="keyword">return</span> ceil(computedLod + <span class="float">0</span><span class="float">.5</span>) - <span class="float">1</span><span class="float">.0</span>;
146345bd8deadSopenharmony_ci    } <span class="keyword">else</span> {
146355bd8deadSopenharmony_ci        <span class="keyword">return</span> computedLod;
146365bd8deadSopenharmony_ci    }
146375bd8deadSopenharmony_ci}</code></pre>
146385bd8deadSopenharmony_ci</div>
146395bd8deadSopenharmony_ci</div>
146405bd8deadSopenharmony_ci<div class="paragraph">
146415bd8deadSopenharmony_ci<p>The value <em>maxAccessibleLevel</em> is the level number of the smallest
146425bd8deadSopenharmony_ciaccessible level of the mipmap array (the value <em>q</em> in section 8.14.3
146435bd8deadSopenharmony_ci&#8220;Mipmapping&#8221; of the <a href="#references">OpenGL Specification</a>) minus the base level.</p>
146445bd8deadSopenharmony_ci</div>
146455bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
146465bd8deadSopenharmony_ci<colgroup>
146475bd8deadSopenharmony_ci<col style="width: 50%;">
146485bd8deadSopenharmony_ci<col style="width: 50%;">
146495bd8deadSopenharmony_ci</colgroup>
146505bd8deadSopenharmony_ci<thead>
146515bd8deadSopenharmony_ci<tr>
146525bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
146535bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
146545bd8deadSopenharmony_ci</tr>
146555bd8deadSopenharmony_ci</thead>
146565bd8deadSopenharmony_ci<tbody>
146575bd8deadSopenharmony_ci<tr>
146585bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"> int <strong>textureSize</strong>(gsampler1D <em>sampler</em>, int <em>lod</em>)<br>
146595bd8deadSopenharmony_ci   ivec2 <strong>textureSize</strong>(gsampler2D <em>sampler</em>, int <em>lod</em>)<br>
146605bd8deadSopenharmony_ci   ivec3 <strong>textureSize</strong>(gsampler3D <em>sampler</em>, int <em>lod</em>)<br>
146615bd8deadSopenharmony_ci   ivec2 <strong>textureSize</strong>(gsamplerCube <em>sampler</em>, int <em>lod</em>)<br>
146625bd8deadSopenharmony_ci   int <strong>textureSize</strong>(sampler1DShadow <em>sampler</em>, int <em>lod</em>)<br>
146635bd8deadSopenharmony_ci   ivec2 <strong>textureSize</strong>(sampler2DShadow <em>sampler</em>, int <em>lod</em>)<br>
146645bd8deadSopenharmony_ci   ivec2 <strong>textureSize</strong>(samplerCubeShadow <em>sampler</em>, int <em>lod</em>)
146655bd8deadSopenharmony_ci   ivec3 <strong>textureSize</strong>(gsamplerCubeArray <em>sampler</em>, int <em>lod</em>)<br>
146665bd8deadSopenharmony_ci   ivec3 <strong>textureSize</strong>(samplerCubeArrayShadow <em>sampler</em>, int <em>lod</em>)<br>
146675bd8deadSopenharmony_ci   ivec2 <strong>textureSize</strong>(gsampler2DRect <em>sampler</em>)<br>
146685bd8deadSopenharmony_ci   ivec2 <strong>textureSize</strong>(sampler2DRectShadow <em>sampler</em>)<br>
146695bd8deadSopenharmony_ci   ivec2 <strong>textureSize</strong>(gsampler1DArray <em>sampler</em>, int <em>lod</em>)<br>
146705bd8deadSopenharmony_ci   ivec2 <strong>textureSize</strong>(sampler1DArrayShadow <em>sampler</em>, int <em>lod</em>)<br>
146715bd8deadSopenharmony_ci   ivec3 <strong>textureSize</strong>(gsampler2DArray <em>sampler</em>, int <em>lod</em>)<br>
146725bd8deadSopenharmony_ci   ivec3 <strong>textureSize</strong>(sampler2DArrayShadow <em>sampler</em>, int <em>lod</em>)<br>
146735bd8deadSopenharmony_ci   int <strong>textureSize</strong>(gsamplerBuffer <em>sampler</em>)<br>
146745bd8deadSopenharmony_ci   ivec2 <strong>textureSize</strong>(gsampler2DMS <em>sampler</em>)<br>
146755bd8deadSopenharmony_ci   ivec3 <strong>textureSize</strong>(gsampler2DMSArray <em>sampler</em>)</p></td>
146765bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the dimensions of level <em>lod</em> (if present) for the texture
146775bd8deadSopenharmony_ci      bound to <em>sampler</em>, as described in section
146785bd8deadSopenharmony_ci      8.11 &#8220;Texture Queries&#8221; of the <a href="#references">OpenGL Specification</a>.<br>
146795bd8deadSopenharmony_ci      The components in the return value are filled in, in order, with the
146805bd8deadSopenharmony_ci      width, height, and depth of the texture.</p>
146815bd8deadSopenharmony_ci<p class="tableblock">      For the array forms, the last component of the return value is the
146825bd8deadSopenharmony_ci      number of layers in the texture array, or the number of cubes in the
146835bd8deadSopenharmony_ci      texture cube map array.</p></td>
146845bd8deadSopenharmony_ci</tr>
146855bd8deadSopenharmony_ci<tr>
146865bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">vec2 <strong>textureQueryLod</strong>(gsampler1D <em>sampler</em>, float <em>P</em>)<br>
146875bd8deadSopenharmony_ci  vec2 <strong>textureQueryLod</strong>(gsampler2D <em>sampler</em>, vec2 <em>P</em>)<br>
146885bd8deadSopenharmony_ci  vec2 <strong>textureQueryLod</strong>(gsampler3D <em>sampler</em>, vec3 <em>P</em>)<br>
146895bd8deadSopenharmony_ci  vec2 <strong>textureQueryLod</strong>(gsamplerCube <em>sampler</em>, vec3 <em>P</em>)<br>
146905bd8deadSopenharmony_ci  vec2 <strong>textureQueryLod</strong>(gsampler1DArray <em>sampler</em>, float <em>P</em>)<br>
146915bd8deadSopenharmony_ci  vec2 <strong>textureQueryLod</strong>(gsampler2DArray <em>sampler</em>, vec2 <em>P</em>)<br>
146925bd8deadSopenharmony_ci  vec2 <strong>textureQueryLod</strong>(gsamplerCubeArray <em>sampler</em>, vec3 <em>P</em>)<br>
146935bd8deadSopenharmony_ci  vec2 <strong>textureQueryLod</strong>(sampler1DShadow <em>sampler</em>, float <em>P</em>)<br>
146945bd8deadSopenharmony_ci  vec2 <strong>textureQueryLod</strong>(sampler2DShadow <em>sampler</em>, vec2 <em>P</em>)<br>
146955bd8deadSopenharmony_ci  vec2 <strong>textureQueryLod</strong>(samplerCubeShadow <em>sampler</em>, vec3 <em>P</em>)<br>
146965bd8deadSopenharmony_ci  vec2 <strong>textureQueryLod</strong>(sampler1DArrayShadow <em>sampler</em>, float <em>P</em>)<br>
146975bd8deadSopenharmony_ci  vec2 <strong>textureQueryLod</strong>(sampler2DArrayShadow <em>sampler</em>, vec2 <em>P</em>)<br>
146985bd8deadSopenharmony_ci  vec2 <strong>textureQueryLod</strong>(samplerCubeArrayShadow <em>sampler</em>, vec3 <em>P</em>)</p></td>
146995bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the mipmap array(s) that would be accessed in the <em>x</em>
147005bd8deadSopenharmony_ci      component of the return value.</p>
147015bd8deadSopenharmony_ci<p class="tableblock">      Returns the computed level-of-detail relative to the base level in the
147025bd8deadSopenharmony_ci      <em>y</em> component of the return value.</p>
147035bd8deadSopenharmony_ci<p class="tableblock">      If called on an incomplete texture, the results are undefined.</p></td>
147045bd8deadSopenharmony_ci</tr>
147055bd8deadSopenharmony_ci<tr>
147065bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>textureQueryLevels</strong>(gsampler1D <em>sampler</em>)<br>
147075bd8deadSopenharmony_ci  int <strong>textureQueryLevels</strong>(gsampler2D <em>sampler</em>)<br>
147085bd8deadSopenharmony_ci  int <strong>textureQueryLevels</strong>(gsampler3D <em>sampler</em>)<br>
147095bd8deadSopenharmony_ci  int <strong>textureQueryLevels</strong>(gsamplerCube <em>sampler</em>)<br>
147105bd8deadSopenharmony_ci  int <strong>textureQueryLevels</strong>(gsampler1DArray <em>sampler</em>)<br>
147115bd8deadSopenharmony_ci  int <strong>textureQueryLevels</strong>(gsampler2DArray <em>sampler</em>)<br>
147125bd8deadSopenharmony_ci  int <strong>textureQueryLevels</strong>(gsamplerCubeArray <em>sampler</em>)<br>
147135bd8deadSopenharmony_ci  int <strong>textureQueryLevels</strong>(sampler1DShadow <em>sampler</em>)<br>
147145bd8deadSopenharmony_ci  int <strong>textureQueryLevels</strong>(sampler2DShadow <em>sampler</em>)<br>
147155bd8deadSopenharmony_ci  int <strong>textureQueryLevels</strong>(samplerCubeShadow <em>sampler</em>)<br>
147165bd8deadSopenharmony_ci  int <strong>textureQueryLevels</strong>(sampler1DArrayShadow <em>sampler</em>)<br>
147175bd8deadSopenharmony_ci  int <strong>textureQueryLevels</strong>(sampler2DArrayShadow <em>sampler</em>)<br>
147185bd8deadSopenharmony_ci  int <strong>textureQueryLevels</strong>(samplerCubeArrayShadow <em>sampler</em>)</p></td>
147195bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the number of mipmap levels accessible in the texture
147205bd8deadSopenharmony_ci      associated with <em>sampler</em>, as defined in the <a href="#references">OpenGL Specification.</a></p>
147215bd8deadSopenharmony_ci<p class="tableblock">      The value zero will be returned if no texture or an incomplete texture
147225bd8deadSopenharmony_ci      is associated with <em>sampler</em>.</p>
147235bd8deadSopenharmony_ci<p class="tableblock">      Available in all shader stages.</p></td>
147245bd8deadSopenharmony_ci</tr>
147255bd8deadSopenharmony_ci<tr>
147265bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>textureSamples</strong>(gsampler2DMS <em>sampler</em>)<br>
147275bd8deadSopenharmony_ci  int <strong>textureSamples</strong>(gsampler2DMSArray <em>sampler</em>)</p></td>
147285bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the number of samples of the texture or textures bound to
147295bd8deadSopenharmony_ci      <em>sampler</em>.</p></td>
147305bd8deadSopenharmony_ci</tr>
147315bd8deadSopenharmony_ci</tbody>
147325bd8deadSopenharmony_ci</table>
147335bd8deadSopenharmony_ci</div>
147345bd8deadSopenharmony_ci<div class="sect3">
147355bd8deadSopenharmony_ci<h4 id="texel-lookup-functions">8.9.2. Texel Lookup Functions</h4>
147365bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
147375bd8deadSopenharmony_ci<colgroup>
147385bd8deadSopenharmony_ci<col style="width: 50%;">
147395bd8deadSopenharmony_ci<col style="width: 50%;">
147405bd8deadSopenharmony_ci</colgroup>
147415bd8deadSopenharmony_ci<thead>
147425bd8deadSopenharmony_ci<tr>
147435bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
147445bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
147455bd8deadSopenharmony_ci</tr>
147465bd8deadSopenharmony_ci</thead>
147475bd8deadSopenharmony_ci<tbody>
147485bd8deadSopenharmony_ci<tr>
147495bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">gvec4 <strong>texture</strong>(gsampler1D <em>sampler</em>, float <em>P</em> [, float <em>bias</em>] )<br>
147505bd8deadSopenharmony_ci  gvec4 <strong>texture</strong>(gsampler2D <em>sampler</em>, vec2 <em>P</em> [, float <em>bias</em>] )<br>
147515bd8deadSopenharmony_ci  gvec4 <strong>texture</strong>(gsampler3D <em>sampler</em>, vec3 <em>P</em> [, float <em>bias</em>] )<br>
147525bd8deadSopenharmony_ci  gvec4 <strong>texture</strong>(gsamplerCube <em>sampler</em>, vec3 <em>P</em>[, float <em>bias</em>] )<br>
147535bd8deadSopenharmony_ci  float <strong>texture</strong>(sampler1DShadow <em>sampler</em>, vec3 <em>P</em> [, float <em>bias</em>])<br>
147545bd8deadSopenharmony_ci  float <strong>texture</strong>(sampler2DShadow <em>sampler</em>, vec3 <em>P</em> [, float <em>bias</em>])<br>
147555bd8deadSopenharmony_ci  float <strong>texture</strong>(samplerCubeShadow <em>sampler</em>, vec4 <em>P</em> [, float <em>bias</em>] )<br>
147565bd8deadSopenharmony_ci  gvec4 <strong>texture</strong>(gsampler2DArray <em>sampler</em>, vec3 <em>P</em> [, float <em>bias</em>] )<br>
147575bd8deadSopenharmony_ci  gvec4 <strong>texture</strong>(gsamplerCubeArray <em>sampler</em>, vec4 <em>P</em> [, float <em>bias</em>] )<br>
147585bd8deadSopenharmony_ci  gvec4 <strong>texture</strong>(gsampler1DArray <em>sampler</em>, vec2 <em>P</em> [, float <em>bias</em>] )<br>
147595bd8deadSopenharmony_ci  float <strong>texture</strong>(sampler1DArrayShadow <em>sampler</em>, vec3 <em>P</em> [, float <em>bias</em>] )<br>
147605bd8deadSopenharmony_ci  float <strong>texture</strong>(sampler2DArrayShadow <em>sampler</em>, vec4 <em>P</em>)<br>
147615bd8deadSopenharmony_ci  gvec4 <strong>texture</strong>(gsampler2DRect <em>sampler</em>, vec2 <em>P</em>)<br>
147625bd8deadSopenharmony_ci  float <strong>texture</strong>(sampler2DRectShadow <em>sampler</em>, vec3 <em>P</em>)<br>
147635bd8deadSopenharmony_ci  float <strong>texture</strong>(samplerCubeArrayShadow <em>sampler</em>, vec4 <em>P</em>, float <em>compare</em>)</p></td>
147645bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Use the texture coordinate <em>P</em> to do a texture lookup in the texture
147655bd8deadSopenharmony_ci      currently bound to <em>sampler</em>.</p>
147665bd8deadSopenharmony_ci<p class="tableblock">      For shadow forms: When <em>compare</em> is present, it is used as <em>D<sub>ref</sub></em>
147675bd8deadSopenharmony_ci      and the array layer comes from the last component of <em>P</em>.
147685bd8deadSopenharmony_ci      When <em>compare</em> is not present, the last component of <em>P</em> is used as
147695bd8deadSopenharmony_ci      <em>D<sub>ref</sub></em> and the array layer comes from the second to last component
147705bd8deadSopenharmony_ci      of <em>P</em>.
147715bd8deadSopenharmony_ci      (The second component of <em>P</em> is unused for <strong>1D</strong> shadow lookups.)</p>
147725bd8deadSopenharmony_ci<p class="tableblock">      For non-shadow forms: the array layer comes from the last component of
147735bd8deadSopenharmony_ci      <em>P</em>.</p></td>
147745bd8deadSopenharmony_ci</tr>
147755bd8deadSopenharmony_ci<tr>
147765bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">gvec4 <strong>textureProj</strong>(gsampler1D <em>sampler</em>, vec2 <em>P</em> [, float <em>bias</em>] )<br>
147775bd8deadSopenharmony_ci  gvec4 <strong>textureProj</strong>(gsampler1D <em>sampler</em>, vec4 <em>P</em> [, float <em>bias</em>] )<br>
147785bd8deadSopenharmony_ci  gvec4 <strong>textureProj</strong>(gsampler2D <em>sampler</em>, vec3 <em>P</em> [, float <em>bias</em>] )<br>
147795bd8deadSopenharmony_ci  gvec4 <strong>textureProj</strong>(gsampler2D <em>sampler</em>, vec4 <em>P</em> [, float <em>bias</em>] )<br>
147805bd8deadSopenharmony_ci  gvec4 <strong>textureProj</strong>(gsampler3D <em>sampler</em>, vec4 <em>P</em> [, float <em>bias</em>] )<br>
147815bd8deadSopenharmony_ci  float <strong>textureProj</strong>(sampler1DShadow <em>sampler</em>, vec4 <em>P</em> [, float <em>bias</em>] )<br>
147825bd8deadSopenharmony_ci  float <strong>textureProj</strong>(sampler2DShadow <em>sampler</em>, vec4 <em>P</em> [, float <em>bias</em>] )<br>
147835bd8deadSopenharmony_ci  gvec4 <strong>textureProj</strong>(gsampler2DRect <em>sampler</em>, vec3 <em>P</em>)<br>
147845bd8deadSopenharmony_ci  gvec4 <strong>textureProj</strong>(gsampler2DRect <em>sampler</em>, vec4 <em>P</em>)<br>
147855bd8deadSopenharmony_ci  float <strong>textureProj</strong>(sampler2DRectShadow <em>sampler</em>, vec4 <em>P</em>)<br></p></td>
147865bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Do a texture lookup with projection.
147875bd8deadSopenharmony_ci      The texture coordinates consumed from <em>P</em>, not including the last
147885bd8deadSopenharmony_ci      component of <em>P</em>, are divided by the last component of <em>P</em> to
147895bd8deadSopenharmony_ci      form projected coordinates <em>P'</em>.
147905bd8deadSopenharmony_ci      The resulting third component of <em>P</em> in the shadow forms is used as
147915bd8deadSopenharmony_ci      <em>D<sub>ref</sub></em>.
147925bd8deadSopenharmony_ci      The third component of <em>P</em> is ignored when <em>sampler</em> has type
147935bd8deadSopenharmony_ci      <strong>gsampler2D</strong> and <em>P</em> has type <strong>vec4</strong>.
147945bd8deadSopenharmony_ci      After these values are computed, texture lookup proceeds as in
147955bd8deadSopenharmony_ci      <strong>texture</strong>.</p></td>
147965bd8deadSopenharmony_ci</tr>
147975bd8deadSopenharmony_ci<tr>
147985bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">gvec4 <strong>textureLod</strong>(gsampler1D <em>sampler</em>, float <em>P</em>, float <em>lod</em>)<br>
147995bd8deadSopenharmony_ci  gvec4 <strong>textureLod</strong>(gsampler2D <em>sampler</em>, vec2 <em>P</em>, float <em>lod</em>)<br>
148005bd8deadSopenharmony_ci  gvec4 <strong>textureLod</strong>(gsampler3D <em>sampler</em>, vec3 <em>P</em>, float <em>lod</em>)<br>
148015bd8deadSopenharmony_ci  gvec4 <strong>textureLod</strong>(gsamplerCube <em>sampler</em>, vec3 <em>P</em>, float <em>lod</em>)<br>
148025bd8deadSopenharmony_ci  float <strong>textureLod</strong>(sampler2DShadow <em>sampler</em>, vec3 <em>P</em>, float <em>lod</em>)<br>
148035bd8deadSopenharmony_ci  float <strong>textureLod</strong>(sampler1DShadow <em>sampler</em>, vec3 <em>P</em>, float <em>lod</em>)<br>
148045bd8deadSopenharmony_ci  gvec4 <strong>textureLod</strong>(gsampler1DArray <em>sampler</em>, vec2 <em>P</em>, float <em>lod</em>)<br>
148055bd8deadSopenharmony_ci  float <strong>textureLod</strong>(sampler1DArrayShadow <em>sampler</em>, vec3 <em>P</em>, float <em>lod</em>)<br>
148065bd8deadSopenharmony_ci  gvec4 <strong>textureLod</strong>(gsampler2DArray <em>sampler</em>, vec3 <em>P</em>, float <em>lod</em>)<br>
148075bd8deadSopenharmony_ci  gvec4 <strong>textureLod</strong>(gsamplerCubeArray <em>sampler</em>, vec4 <em>P</em>, float <em>lod</em>)</p></td>
148085bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
148095bd8deadSopenharmony_ci<p>Do a texture lookup as in <strong>texture</strong> but with explicit level-of-detail;
148105bd8deadSopenharmony_ci      <em>lod</em> specifies <span class="eq">λ<sub>base</sub>]</span> and sets the partial derivatives
148115bd8deadSopenharmony_ci      as follows:<br>
148125bd8deadSopenharmony_ci      (See section 8.14 &#8220;Texture Minification&#8221; and equations 8.4-8.6 of
148135bd8deadSopenharmony_ci      the <a href="#references">OpenGL Specification</a>.)<br>
148145bd8deadSopenharmony_ci     <br>
148155bd8deadSopenharmony_ci      <span class="eq">∂u / ∂x =
148165bd8deadSopenharmony_ci           ∂v / ∂x =
148175bd8deadSopenharmony_ci           ∂w / ∂x = 0</span>
148185bd8deadSopenharmony_ci     <br>
148195bd8deadSopenharmony_ci      <span class="eq">∂u / ∂y =
148205bd8deadSopenharmony_ci           ∂v / ∂y =
148215bd8deadSopenharmony_ci           ∂w / ∂y = 0</span></p>
148225bd8deadSopenharmony_ci</div></div></td>
148235bd8deadSopenharmony_ci</tr>
148245bd8deadSopenharmony_ci<tr>
148255bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">gvec4 <strong>textureOffset</strong>(gsampler1D <em>sampler</em>, float <em>P</em>, int <em>offset</em> [, float <em>bias</em>] )<br>
148265bd8deadSopenharmony_ci  gvec4 <strong>textureOffset</strong>(gsampler2D <em>sampler</em>, vec2 <em>P</em>, ivec2 <em>offset</em> [, float <em>bias</em>] )<br>
148275bd8deadSopenharmony_ci  gvec4 <strong>textureOffset</strong>(gsampler3D <em>sampler</em>, vec3 <em>P</em>, ivec3 <em>offset</em> [, float <em>bias</em>] )<br>
148285bd8deadSopenharmony_ci  float <strong>textureOffset</strong>(sampler2DShadow <em>sampler</em>, vec3 <em>P</em>, ivec2 <em>offset</em> [, float <em>bias</em>] )<br>
148295bd8deadSopenharmony_ci  gvec4 <strong>textureOffset</strong>(gsampler2DRect <em>sampler</em>, vec2 <em>P</em>, ivec2 <em>offset</em>)<br>
148305bd8deadSopenharmony_ci  float <strong>textureOffset</strong>(sampler2DRectShadow <em>sampler</em>, vec3 <em>P</em>, ivec2 <em>offset</em>)<br>
148315bd8deadSopenharmony_ci  float <strong>textureOffset</strong>(sampler1DShadow <em>sampler</em>, vec3 <em>P</em>, int <em>offset</em> [, float <em>bias</em>] )<br>
148325bd8deadSopenharmony_ci  gvec4 <strong>textureOffset</strong>(gsampler1DArray <em>sampler</em>, vec2 <em>P</em>, int <em>offset</em> [, float <em>bias</em>] )<br>
148335bd8deadSopenharmony_ci  gvec4 <strong>textureOffset</strong>(gsampler2DArray <em>sampler</em>, vec3 <em>P</em>, ivec2 <em>offset</em> [, float <em>bias</em>] )<br>
148345bd8deadSopenharmony_ci  float <strong>textureOffset</strong>(sampler1DArrayShadow <em>sampler</em>, vec3 <em>P</em>, int <em>offset</em> [, float <em>bias</em>] )<br>
148355bd8deadSopenharmony_ci  float <strong>textureOffset</strong>(sampler2DArrayShadow <em>sampler</em>, vec4 <em>P</em>, ivec2 <em>offset</em>)</p></td>
148365bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Do a texture lookup as in <strong>texture</strong> but with <em>offset</em> added to the
148375bd8deadSopenharmony_ci      <span class="eq">(u,v,w)</span> texel coordinates before looking up each texel.
148385bd8deadSopenharmony_ci      The offset value must be a constant expression.
148395bd8deadSopenharmony_ci      A limited range of offset values are supported; the minimum and
148405bd8deadSopenharmony_ci      maximum offset values are implementation-dependent and given by
148415bd8deadSopenharmony_ci      <em>gl_MinProgramTexelOffset</em> and <em>gl_MaxProgramTexelOffset</em>,
148425bd8deadSopenharmony_ci      respectively.</p>
148435bd8deadSopenharmony_ci<p class="tableblock">      Note that <em>offset</em> does not apply to the layer coordinate for texture
148445bd8deadSopenharmony_ci      arrays.
148455bd8deadSopenharmony_ci      This is explained in detail in section 8.14.2 &#8220;Coordinate Wrapping
148465bd8deadSopenharmony_ci      and Texel Selection&#8221; of the <a href="#references">OpenGL Specification</a>, where <em>offset</em>
148475bd8deadSopenharmony_ci      is <span class="eq">(δ<sub>u</sub>, δ<sub>v</sub>, δ<sub>w</sub>)</span>.<br>
148485bd8deadSopenharmony_ci      Note that texel offsets are also not supported for cube maps.</p></td>
148495bd8deadSopenharmony_ci</tr>
148505bd8deadSopenharmony_ci<tr>
148515bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">gvec4 <strong>texelFetch</strong>(gsampler1D <em>sampler</em>, int <em>P</em>, int <em>lod</em>)<br>
148525bd8deadSopenharmony_ci  gvec4 <strong>texelFetch</strong>(gsampler2D <em>sampler</em>, ivec2 <em>P</em>, int <em>lod</em>)<br>
148535bd8deadSopenharmony_ci  gvec4 <strong>texelFetch</strong>(gsampler3D <em>sampler</em>, ivec3 <em>P</em>, int <em>lod</em>)
148545bd8deadSopenharmony_ci  gvec4 <strong>texelFetch</strong>(gsampler2DRect <em>sampler</em>, ivec2 <em>P</em>)<br>
148555bd8deadSopenharmony_ci  gvec4 <strong>texelFetch</strong>(gsampler1DArray <em>sampler</em>, ivec2 <em>P</em>, int <em>lod</em>)<br>
148565bd8deadSopenharmony_ci  gvec4 <strong>texelFetch</strong>(gsampler2DArray <em>sampler</em>, ivec3 <em>P</em>, int <em>lod</em>)<br>
148575bd8deadSopenharmony_ci  gvec4 <strong>texelFetch</strong>(gsamplerBuffer <em>sampler</em>, int <em>P</em>)<br>
148585bd8deadSopenharmony_ci  gvec4 <strong>texelFetch</strong>(gsampler2DMS <em>sampler</em>, ivec2 <em>P</em>, int <em>sample</em>)<br>
148595bd8deadSopenharmony_ci  gvec4 <strong>texelFetch</strong>(gsampler2DMSArray <em>sampler</em>, ivec3 <em>P</em>, int <em>sample</em>)</p></td>
148605bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Use integer texture coordinate <em>P</em> to lookup a single texel from
148615bd8deadSopenharmony_ci      <em>sampler</em>.
148625bd8deadSopenharmony_ci      The array layer comes from the last component of <em>P</em> for the array
148635bd8deadSopenharmony_ci      forms.
148645bd8deadSopenharmony_ci      The level-of-detail <em>lod</em> (if present) is as described in sections
148655bd8deadSopenharmony_ci      11.1.3.2 &#8220;Texel Fetches&#8221; and 8.14.1 &#8220;Scale Factor and Level of
148665bd8deadSopenharmony_ci      Detail&#8221; of the <a href="#references">OpenGL Specification</a>.</p></td>
148675bd8deadSopenharmony_ci</tr>
148685bd8deadSopenharmony_ci<tr>
148695bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">gvec4 <strong>texelFetchOffset</strong>(gsampler1D <em>sampler</em>, int <em>P</em>, int <em>lod</em>, int <em>offset</em>)<br>
148705bd8deadSopenharmony_ci  gvec4 <strong>texelFetchOffset</strong>(gsampler2D <em>sampler</em>, ivec2 <em>P</em>, int <em>lod</em>, ivec2 <em>offset</em>)<br>
148715bd8deadSopenharmony_ci  gvec4 <strong>texelFetchOffset</strong>(gsampler3D <em>sampler</em>, ivec3 <em>P</em>, int <em>lod</em>, ivec3 <em>offset</em>)<br>
148725bd8deadSopenharmony_ci  gvec4 <strong>texelFetchOffset</strong>(gsampler2DRect <em>sampler</em>, ivec2 <em>P</em>, ivec2 <em>offset</em>)<br>
148735bd8deadSopenharmony_ci  gvec4 <strong>texelFetchOffset</strong>(gsampler1DArray <em>sampler</em>, ivec2 <em>P</em>, int <em>lod</em>, int <em>offset</em>)<br>
148745bd8deadSopenharmony_ci  gvec4 <strong>texelFetchOffset</strong>(gsampler2DArray <em>sampler</em>, ivec3 <em>P</em>, int <em>lod</em>, ivec2 <em>offset</em>)</p></td>
148755bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Fetch a single texel as in <strong>texelFetch</strong>, offset by <em>offset</em> as
148765bd8deadSopenharmony_ci      described in <strong>textureOffset</strong>.</p></td>
148775bd8deadSopenharmony_ci</tr>
148785bd8deadSopenharmony_ci<tr>
148795bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">gvec4 <strong>textureProjOffset</strong>(gsampler1D <em>sampler</em>, vec2 <em>P</em>, int <em>offset</em> [, float <em>bias</em>] )<br>
148805bd8deadSopenharmony_ci  gvec4 <strong>textureProjOffset</strong>(gsampler1D <em>sampler</em>, vec4 <em>P</em>, int <em>offset</em> [, float <em>bias</em>] )<br>
148815bd8deadSopenharmony_ci  gvec4 <strong>textureProjOffset</strong>(gsampler2D <em>sampler</em>, vec3 <em>P</em>, ivec2 <em>offset</em> [, float <em>bias</em>] )<br>
148825bd8deadSopenharmony_ci  gvec4 <strong>textureProjOffset</strong>(gsampler2D <em>sampler</em>, vec4 <em>P</em>, ivec2 <em>offset</em> [, float <em>bias</em>] )<br>
148835bd8deadSopenharmony_ci  gvec4 <strong>textureProjOffset</strong>(gsampler3D <em>sampler</em>, vec4 <em>P</em>, ivec3 <em>offset</em> [, float <em>bias</em>] )<br>
148845bd8deadSopenharmony_ci  gvec4 <strong>textureProjOffset</strong>(gsampler2DRect <em>sampler</em>, vec3 <em>P</em>, ivec2 <em>offset</em>)<br>
148855bd8deadSopenharmony_ci  gvec4 <strong>textureProjOffset</strong>(gsampler2DRect <em>sampler</em>, vec4 <em>P</em>, ivec2 <em>offset</em>)<br>
148865bd8deadSopenharmony_ci  float <strong>textureProjOffset</strong>(sampler2DRectShadow <em>sampler</em>, vec4 <em>P</em>, ivec2 <em>offset</em>)<br>
148875bd8deadSopenharmony_ci  float <strong>textureProjOffset</strong>(sampler1DShadow <em>sampler</em>, vec4 <em>P</em>, int <em>offset</em> [, float <em>bias</em>] )<br>
148885bd8deadSopenharmony_ci  float <strong>textureProjOffset</strong>(sampler2DShadow <em>sampler</em>, vec4 <em>P</em>, ivec2 <em>offset</em> [, float <em>bias</em>] )</p></td>
148895bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Do a projective texture lookup as described in <strong>textureProj</strong>, offset
148905bd8deadSopenharmony_ci      by <em>offset</em> as described in <strong>textureOffset</strong>.</p></td>
148915bd8deadSopenharmony_ci</tr>
148925bd8deadSopenharmony_ci<tr>
148935bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">gvec4 <strong>textureLodOffset</strong>(gsampler1D <em>sampler</em>, float <em>P</em>, float <em>lod</em>, int <em>offset</em>)<br>
148945bd8deadSopenharmony_ci  gvec4 <strong>textureLodOffset</strong>(gsampler2D <em>sampler</em>, vec2 <em>P</em>, float <em>lod</em>, ivec2 <em>offset</em>)<br>
148955bd8deadSopenharmony_ci  gvec4 <strong>textureLodOffset</strong>(gsampler3D <em>sampler</em>, vec3 <em>P</em>, float <em>lod</em>, ivec3 <em>offset</em>)<br>
148965bd8deadSopenharmony_ci  float <strong>textureLodOffset</strong>(sampler1DShadow <em>sampler</em>, vec3 <em>P</em>, float <em>lod</em>, int <em>offset</em>)<br>
148975bd8deadSopenharmony_ci  float <strong>textureLodOffset</strong>(sampler2DShadow <em>sampler</em>,  vec3 <em>P</em>, float <em>lod</em>, ivec2 <em>offset</em>)<br>
148985bd8deadSopenharmony_ci  gvec4 <strong>textureLodOffset</strong>(gsampler1DArray <em>sampler</em>, vec2 <em>P</em>, float <em>lod</em>, int <em>offset</em>)<br>
148995bd8deadSopenharmony_ci  gvec4 <strong>textureLodOffset</strong>(gsampler2DArray <em>sampler</em>, vec3 <em>P</em>, float <em>lod</em>, ivec2 <em>offset</em>)<br>
149005bd8deadSopenharmony_ci  float <strong>textureLodOffset</strong>(sampler1DArrayShadow <em>sampler</em>, vec3 <em>P</em>, float <em>lod</em>, int <em>offset</em>)</p></td>
149015bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Do an offset texture lookup with explicit level-of-detail.
149025bd8deadSopenharmony_ci      See <strong>textureLod</strong> and <strong>textureOffset</strong>.</p></td>
149035bd8deadSopenharmony_ci</tr>
149045bd8deadSopenharmony_ci<tr>
149055bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">gvec4 <strong>textureProjLod</strong>(gsampler1D <em>sampler</em>, vec2 <em>P</em>, float <em>lod</em>)<br>
149065bd8deadSopenharmony_ci  gvec4 <strong>textureProjLod</strong>(gsampler1D <em>sampler</em>, vec4 <em>P</em>, float <em>lod</em>)<br>
149075bd8deadSopenharmony_ci  gvec4 <strong>textureProjLod</strong>(gsampler2D <em>sampler</em>, vec3 <em>P</em>, float <em>lod</em>)<br>
149085bd8deadSopenharmony_ci  gvec4 <strong>textureProjLod</strong>(gsampler2D <em>sampler</em>, vec4 <em>P</em>, float <em>lod</em>)<br>
149095bd8deadSopenharmony_ci  gvec4 <strong>textureProjLod</strong>(gsampler3D <em>sampler</em>, vec4 <em>P</em>, float <em>lod</em>)<br>
149105bd8deadSopenharmony_ci  float <strong>textureProjLod</strong>(sampler1DShadow <em>sampler</em>, vec4 <em>P</em>, float <em>lod</em>)<br>
149115bd8deadSopenharmony_ci  float <strong>textureProjLod</strong>(sampler2DShadow <em>sampler</em>, vec4 <em>P</em>, float <em>lod</em>)</p></td>
149125bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Do a projective texture lookup with explicit level-of-detail.
149135bd8deadSopenharmony_ci      See <strong>textureProj</strong> and <strong>textureLod</strong>.</p></td>
149145bd8deadSopenharmony_ci</tr>
149155bd8deadSopenharmony_ci<tr>
149165bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">gvec4 <strong>textureProjLodOffset</strong>(gsampler1D <em>sampler</em>, vec2 <em>P</em>, float <em>lod</em>, int <em>offset</em>)<br>
149175bd8deadSopenharmony_ci  gvec4 <strong>textureProjLodOffset</strong>(gsampler1D <em>sampler</em>, vec4 <em>P</em>, float <em>lod</em>, int <em>offset</em>)<br>
149185bd8deadSopenharmony_ci  gvec4 <strong>textureProjLodOffset</strong>(gsampler2D <em>sampler</em>, vec3 <em>P</em>, float <em>lod</em>, ivec2 <em>offset</em>)<br>
149195bd8deadSopenharmony_ci  gvec4 <strong>textureProjLodOffset</strong>(gsampler2D <em>sampler</em>, vec4 <em>P</em>, float <em>lod</em>, ivec2 <em>offset</em>)<br>
149205bd8deadSopenharmony_ci  gvec4 <strong>textureProjLodOffset</strong>(gsampler3D <em>sampler</em>, vec4 <em>P</em>, float <em>lod</em>, ivec3 <em>offset</em>)<br>
149215bd8deadSopenharmony_ci  float <strong>textureProjLodOffset</strong>(sampler1DShadow <em>sampler</em>, vec4 <em>P</em>, float <em>lod</em>, int <em>offset</em>)<br>
149225bd8deadSopenharmony_ci  float <strong>textureProjLodOffset</strong>(sampler2DShadow <em>sampler</em>, vec4 <em>P</em>, float <em>lod</em>, ivec2 <em>offset</em>)</p></td>
149235bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Do an offset projective texture lookup with explicit level-of-detail.
149245bd8deadSopenharmony_ci      See <strong>textureProj</strong>, <strong>textureLod</strong>, and <strong>textureOffset</strong>.</p></td>
149255bd8deadSopenharmony_ci</tr>
149265bd8deadSopenharmony_ci<tr>
149275bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">gvec4 <strong>textureGrad</strong>(gsampler1D <em>sampler</em>, <em>float _P</em>, float <em>dPdx</em>, float <em>dPdy</em>)<br>
149285bd8deadSopenharmony_ci  gvec4 <strong>textureGrad</strong>(gsampler2D <em>sampler</em>, vec2 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>)<br>
149295bd8deadSopenharmony_ci  gvec4 <strong>textureGrad</strong>(gsampler3D <em>sampler</em>,  <em>P</em>, vec3 <em>dPdx</em>, vec3 <em>dPdy</em>)<br>
149305bd8deadSopenharmony_ci  gvec4 <strong>textureGrad</strong>(gsamplerCube <em>sampler</em>, vec3 <em>P</em>, vec3 <em>dPdx</em>, vec3 <em>dPdy</em>)<br>
149315bd8deadSopenharmony_ci  gvec4 <strong>textureGrad</strong>(gsampler2DRect <em>sampler</em>, vec2 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>)<br>
149325bd8deadSopenharmony_ci  float <strong>textureGrad</strong>(sampler2DRectShadow <em>sampler</em>, vec3 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>)<br>
149335bd8deadSopenharmony_ci  float <strong>textureGrad</strong>(sampler1DShadow <em>sampler</em>, vec3 <em>P</em>, float <em>dPdx</em>, float <em>dPdy</em>)<br>
149345bd8deadSopenharmony_ci  gvec4 <strong>textureGrad</strong>(gsampler1DArray <em>sampler</em>, vec2 <em>P</em>, float <em>dPdx</em>, float <em>dPdy</em>)<br>
149355bd8deadSopenharmony_ci  gvec4 <strong>textureGrad</strong>(gsampler2DArray <em>sampler</em>, vec3 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>)<br>
149365bd8deadSopenharmony_ci  float <strong>textureGrad</strong>(sampler1DArrayShadow <em>sampler</em>, vec3 <em>P</em>, float <em>dPdx</em>, float <em>dPdy</em>)<br>
149375bd8deadSopenharmony_ci  float <strong>textureGrad</strong>(sampler2DShadow <em>sampler</em>, vec3 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>)<br>
149385bd8deadSopenharmony_ci  float <strong>textureGrad</strong>(samplerCubeShadow <em>sampler</em>, vec4 <em>P</em>, vec3 <em>dPdx</em>, vec3 <em>dPdy</em>)<br>
149395bd8deadSopenharmony_ci  float <strong>textureGrad</strong>(sampler2DArrayShadow <em>sampler</em>, vec4 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>)<br>
149405bd8deadSopenharmony_ci  gvec4 <strong>textureGrad</strong>(gsamplerCubeArray <em>sampler</em>, vec4 <em>P</em>, vec3 <em>dPdx</em>, vec3 <em>dPdy</em>)<br></p></td>
149415bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
149425bd8deadSopenharmony_ci<p>Do a texture lookup as in <strong>texture</strong> but with <a href="#explicit-gradients">explicit gradients</a> as shown below.
149435bd8deadSopenharmony_ci      The partial derivatives of <em>P</em> are with respect to window <em>x</em> and
149445bd8deadSopenharmony_ci      window <em>y</em>.
149455bd8deadSopenharmony_ci      For the cube version, the partial derivatives of <em>P</em> are assumed to be
149465bd8deadSopenharmony_ci      in the coordinate system used before texture coordinates are projected
149475bd8deadSopenharmony_ci      onto the appropriate cube face.</p>
149485bd8deadSopenharmony_ci</div></div></td>
149495bd8deadSopenharmony_ci</tr>
149505bd8deadSopenharmony_ci<tr>
149515bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">gvec4 <strong>textureGradOffset</strong>(gsampler1D <em>sampler</em>, float <em>P</em>, float <em>dPdx</em>, float <em>dPdy</em>, int <em>offset</em>)<br>
149525bd8deadSopenharmony_ci  gvec4 <strong>textureGradOffset</strong>(gsampler2D <em>sampler</em>, vec2 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>, ivec2 <em>offset</em>)<br>
149535bd8deadSopenharmony_ci  gvec4 <strong>textureGradOffset</strong>(gsampler3D <em>sampler</em>, vec3 <em>P</em>, vec3 <em>dPdx</em>, vec3 <em>dPdy</em>, ivec3 <em>offset</em>)<br>
149545bd8deadSopenharmony_ci  gvec4 <strong>textureGradOffset</strong>(gsampler2DRect <em>sampler</em>, vec2 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>, ivec2 <em>offset</em>)<br>
149555bd8deadSopenharmony_ci  float <strong>textureGradOffset</strong>(sampler2DRectShadow <em>sampler</em>, vec3 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>, ivec2 <em>offset</em>)<br>
149565bd8deadSopenharmony_ci  float <strong>textureGradOffset</strong>(sampler1DShadow <em>sampler</em>, vec3 <em>P</em>, float <em>dPdx</em>, float <em>dPdy</em>, int <em>offset</em>)<br>
149575bd8deadSopenharmony_ci  float <strong>textureGradOffset</strong>(sampler2DShadow <em>sampler</em>, vec3 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>, ivec2 <em>offset</em>)<br>
149585bd8deadSopenharmony_ci  gvec4 <strong>textureGradOffset</strong>(gsampler2DArray <em>sampler</em>, vec3 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>, ivec2 <em>offset</em>)<br>
149595bd8deadSopenharmony_ci  gvec4 <strong>textureGradOffset</strong>(gsampler1DArray <em>sampler</em>, vec2 <em>P</em>, float <em>dPdx</em>, float <em>dPdy</em>, int <em>offset</em>)<br>
149605bd8deadSopenharmony_ci  float <strong>textureGradOffset</strong>(sampler1DArrayShadow <em>sampler</em>, vec3 <em>P</em>, float <em>dPdx</em>, float <em>dPdy</em>, int <em>offset</em>)<br>
149615bd8deadSopenharmony_ci  float <strong>textureGradOffset</strong>(sampler2DArrayShadow <em>sampler</em>, vec4 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>, ivec2 <em>offset</em>)<br></p></td>
149625bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Do a texture lookup with both explicit gradient and offset, as
149635bd8deadSopenharmony_ci      described in <strong>textureGrad</strong> and <strong>textureOffset</strong>.</p></td>
149645bd8deadSopenharmony_ci</tr>
149655bd8deadSopenharmony_ci<tr>
149665bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">gvec4 <strong>textureProjGrad</strong>(gsampler1D <em>sampler</em>, vec2 <em>P</em>, float <em>dPdx</em>, float <em>dPdy</em>)<br>
149675bd8deadSopenharmony_ci  gvec4 <strong>textureProjGrad</strong>(gsampler1D <em>sampler</em>, vec4 <em>P</em>, float <em>dPdx</em>, float <em>dPdy</em>)<br>
149685bd8deadSopenharmony_ci  gvec4 <strong>textureProjGrad</strong>(gsampler2D <em>sampler</em>, vec3 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>)<br>
149695bd8deadSopenharmony_ci  gvec4 <strong>textureProjGrad</strong>(gsampler2D <em>sampler</em>, vec4 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>)<br>
149705bd8deadSopenharmony_ci  gvec4 <strong>textureProjGrad</strong>(gsampler3D <em>sampler</em>, vec4 <em>P</em>, vec3 <em>dPdx</em>, vec3 <em>dPdy</em>)<br>
149715bd8deadSopenharmony_ci  gvec4 <strong>textureProjGrad</strong>(gsampler2DRect <em>sampler</em>, vec3 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>)<br>
149725bd8deadSopenharmony_ci  gvec4 <strong>textureProjGrad</strong>(gsampler2DRect <em>sampler</em>, vec4 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>)<br>
149735bd8deadSopenharmony_ci  float <strong>textureProjGrad</strong>(sampler2DRectShadow <em>sampler</em>, vec4 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>)<br>
149745bd8deadSopenharmony_ci  float <strong>textureProjGrad</strong>(sampler1DShadow <em>sampler</em>, vec4 <em>P</em>, float <em>dPdx</em>, float <em>dPdy</em>)<br>
149755bd8deadSopenharmony_ci  float <strong>textureProjGrad</strong>(sampler2DShadow <em>sampler</em>, vec4 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>)</p></td>
149765bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Do a texture lookup both projectively, as described in <strong>textureProj</strong>,
149775bd8deadSopenharmony_ci      and with explicit gradient as described in <strong>textureGrad</strong>.
149785bd8deadSopenharmony_ci      The partial derivatives <em>dPdx</em> and <em>dPdy</em> are assumed to be already
149795bd8deadSopenharmony_ci      projected.</p></td>
149805bd8deadSopenharmony_ci</tr>
149815bd8deadSopenharmony_ci<tr>
149825bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">gvec4 <strong>textureProjGradOffset</strong>(gsampler1D <em>sampler</em>, vec2 <em>P</em>, float <em>dPdx</em>, float <em>dPdy</em>, int <em>offset</em>)<br>
149835bd8deadSopenharmony_ci  gvec4 <strong>textureProjGradOffset</strong>(gsampler1D <em>sampler</em>, vec4 <em>P</em>, float <em>dPdx</em>, float <em>dPdy</em>, int <em>offset</em>)<br>
149845bd8deadSopenharmony_ci  gvec4 <strong>textureProjGradOffset</strong>(gsampler2D <em>sampler</em>, vec3 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>, ivec2 <em>offset</em>)<br>
149855bd8deadSopenharmony_ci  gvec4 <strong>textureProjGradOffset</strong>(gsampler2D <em>sampler</em>, vec4 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>, ivec2 <em>offset</em>)<br>
149865bd8deadSopenharmony_ci  gvec4 <strong>textureProjGradOffset</strong>(gsampler3D <em>sampler</em>, vec4 <em>P</em>, vec3 <em>dPdx</em>, vec3 <em>dPdy</em>, ivec3 <em>offset</em>)<br>
149875bd8deadSopenharmony_ci  gvec4 <strong>textureProjGradOffset</strong>(gsampler2DRect <em>sampler</em>, vec3 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>, ivec2 <em>offset</em>)<br>
149885bd8deadSopenharmony_ci  gvec4 <strong>textureProjGradOffset</strong>(gsampler2DRect <em>sampler</em>, vec4 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>, ivec2 <em>offset</em>)<br>
149895bd8deadSopenharmony_ci  float <strong>textureProjGradOffset</strong>(sampler2DRectShadow <em>sampler</em>, vec4 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>, ivec2 <em>offset</em>)<br>
149905bd8deadSopenharmony_ci  float <strong>textureProjGradOffset</strong>(sampler1DShadow <em>sampler</em>, vec4 <em>P</em>, float <em>dPdx</em>, float <em>dPdy</em>, int <em>offset</em>)<br>
149915bd8deadSopenharmony_ci  float <strong>textureProjGradOffset</strong>(sampler2DShadow <em>sampler</em>, vec4 <em>P</em>, vec2 <em>dPdx</em>, vec2 <em>dPdy</em>, ivec2 <em>offset</em>)</p></td>
149925bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Do a texture lookup projectively and with explicit gradient as
149935bd8deadSopenharmony_ci      described in <strong>textureProjGrad</strong>, as well as with offset, as described in
149945bd8deadSopenharmony_ci      <strong>textureOffset</strong>.</p></td>
149955bd8deadSopenharmony_ci</tr>
149965bd8deadSopenharmony_ci</tbody>
149975bd8deadSopenharmony_ci</table>
149985bd8deadSopenharmony_ci</div>
149995bd8deadSopenharmony_ci<div class="sect3">
150005bd8deadSopenharmony_ci<h4 id="explicit-gradients">8.9.3. Explicit Gradients</h4>
150015bd8deadSopenharmony_ci<div class="paragraph">
150025bd8deadSopenharmony_ci<p>In the <strong>textureGrad</strong> functions described above, explicit gradients control
150035bd8deadSopenharmony_citexture lookups as follows:</p>
150045bd8deadSopenharmony_ci</div>
150055bd8deadSopenharmony_ci<div class="stemblock">
150065bd8deadSopenharmony_ci<div class="content">
150075bd8deadSopenharmony_ci\[\begin{aligned}
150085bd8deadSopenharmony_ci  \frac{\partial{s}}{\partial{x}} &amp; =
150095bd8deadSopenharmony_ci    \begin{cases}
150105bd8deadSopenharmony_ci      \frac{\partial{P}}{\partial{x}}, &amp; \text{for a 1D texture} \\[0.8em]
150115bd8deadSopenharmony_ci      \frac{\partial{P.s}}{\partial{x}}, &amp; \text{otherwise}
150125bd8deadSopenharmony_ci    \end{cases} \\[2.5em]
150135bd8deadSopenharmony_ci  \frac{\partial{s}}{\partial{y}} &amp; =
150145bd8deadSopenharmony_ci    \begin{cases}
150155bd8deadSopenharmony_ci      \frac{\partial{P}}{\partial{y}}, &amp; \text{for a 1D texture} \\[0.8em]
150165bd8deadSopenharmony_ci      \frac{\partial{P.s}}{\partial{y}}, &amp; \text{otherwise}
150175bd8deadSopenharmony_ci    \end{cases} \\[2.5em]
150185bd8deadSopenharmony_ci  \frac{\partial{t}}{\partial{x}} &amp; =
150195bd8deadSopenharmony_ci    \begin{cases}
150205bd8deadSopenharmony_ci      0.0,                               &amp; \text{for a 1D texture} \\[0.8em]
150215bd8deadSopenharmony_ci      \frac{\partial{P.t}}{\partial{x}}, &amp; \text{otherwise}
150225bd8deadSopenharmony_ci    \end{cases} \\[2.5em]
150235bd8deadSopenharmony_ci  \frac{\partial{t}}{\partial{y}} &amp; =
150245bd8deadSopenharmony_ci    \begin{cases}
150255bd8deadSopenharmony_ci      0.0,                               &amp; \text{for a 1D texture} \\[0.8em]
150265bd8deadSopenharmony_ci      \frac{\partial{P.t}}{\partial{y}}, &amp; \text{otherwise}
150275bd8deadSopenharmony_ci    \end{cases} \\[2.5em]
150285bd8deadSopenharmony_ci  \frac{\partial{r}}{\partial{x}} &amp; =
150295bd8deadSopenharmony_ci    \begin{cases}
150305bd8deadSopenharmony_ci      0.0,                               &amp; \text{for 1D or 2D} \\[0.8em]
150315bd8deadSopenharmony_ci      \frac{\partial{P.p}}{\partial{x}}, &amp; \text{cube, other}
150325bd8deadSopenharmony_ci    \end{cases} \\[2.5em]
150335bd8deadSopenharmony_ci  \frac{\partial{r}}{\partial{y}} &amp; =
150345bd8deadSopenharmony_ci    \begin{cases}
150355bd8deadSopenharmony_ci      0.0,                               &amp; \text{for 1D or 2D} \\[0.8em]
150365bd8deadSopenharmony_ci      \frac{\partial{P.p}}{\partial{y}}, &amp; \text{cube, other}
150375bd8deadSopenharmony_ci    \end{cases}
150385bd8deadSopenharmony_ci\end{aligned}\]
150395bd8deadSopenharmony_ci</div>
150405bd8deadSopenharmony_ci</div>
150415bd8deadSopenharmony_ci</div>
150425bd8deadSopenharmony_ci<div class="sect3">
150435bd8deadSopenharmony_ci<h4 id="texture-gather-functions">8.9.4. Texture Gather Functions</h4>
150445bd8deadSopenharmony_ci<div class="paragraph">
150455bd8deadSopenharmony_ci<p>The texture gather functions take components of a single floating-point
150465bd8deadSopenharmony_civector operand as a texture coordinate, determine a set of four texels to
150475bd8deadSopenharmony_cisample from the base level-of-detail of the specified texture image, and
150485bd8deadSopenharmony_cireturn one component from each texel in a four-component result vector.</p>
150495bd8deadSopenharmony_ci</div>
150505bd8deadSopenharmony_ci<div class="paragraph">
150515bd8deadSopenharmony_ci<p>When performing a texture gather operation, the minification and
150525bd8deadSopenharmony_cimagnification filters are ignored, and the rules for LINEAR filtering in the
150535bd8deadSopenharmony_ci<a href="#references">OpenGL Specification</a> are applied to the base level of the texture image
150545bd8deadSopenharmony_cito identify the four texels <em>i<sub>0</sub> j<sub>1</sub></em>, <em>i<sub>1</sub> j<sub>1</sub></em>, <em>i<sub>1</sub> j<sub>0</sub></em>, and <em>i<sub>0</sub>
150555bd8deadSopenharmony_cij<sub>0</sub></em>.
150565bd8deadSopenharmony_ciThe texels are then converted to texture base colors (<em>R<sub>s</sub></em>, <em>G<sub>s</sub></em>,
150575bd8deadSopenharmony_ci<em>B<sub>s</sub></em>, <em>A<sub>s</sub></em>) according to table 15.1, followed by application of the
150585bd8deadSopenharmony_citexture swizzle as described in section 15.2.1 &#8220;Texture Access&#8221; of the
150595bd8deadSopenharmony_ci<a href="#references">OpenGL Specification</a>.
150605bd8deadSopenharmony_ciA four-component vector is assembled by taking the selected component from
150615bd8deadSopenharmony_cieach of the post-swizzled texture source colors in the order (<em>i<sub>0</sub> j<sub>1</sub></em>,
150625bd8deadSopenharmony_ci<em>i<sub>1</sub> j<sub>1</sub></em>, <em>i<sub>1</sub> j<sub>0</sub></em>, <em>i<sub>0</sub> j<sub>0</sub></em>).</p>
150635bd8deadSopenharmony_ci</div>
150645bd8deadSopenharmony_ci<div class="paragraph">
150655bd8deadSopenharmony_ci<p>For texture gather functions using a texture-combined shadow sampler type,
150665bd8deadSopenharmony_cieach of the four
150675bd8deadSopenharmony_citexel lookups perform a depth comparison against the depth reference value
150685bd8deadSopenharmony_cipassed in (<em>refZ</em>), and returns the result of that comparison in the
150695bd8deadSopenharmony_ciappropriate component of the result vector.</p>
150705bd8deadSopenharmony_ci</div>
150715bd8deadSopenharmony_ci<div class="paragraph">
150725bd8deadSopenharmony_ci<p>As with other texture lookup functions, the results of a texture gather are
150735bd8deadSopenharmony_ciundefined for shadow samplers if the texture referenced is not a depth
150745bd8deadSopenharmony_citexture or has depth comparisons disabled; or for non-shadow samplers if the
150755bd8deadSopenharmony_citexture referenced is a depth texture with depth comparisons enabled.</p>
150765bd8deadSopenharmony_ci</div>
150775bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
150785bd8deadSopenharmony_ci<colgroup>
150795bd8deadSopenharmony_ci<col style="width: 50%;">
150805bd8deadSopenharmony_ci<col style="width: 50%;">
150815bd8deadSopenharmony_ci</colgroup>
150825bd8deadSopenharmony_ci<thead>
150835bd8deadSopenharmony_ci<tr>
150845bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
150855bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
150865bd8deadSopenharmony_ci</tr>
150875bd8deadSopenharmony_ci</thead>
150885bd8deadSopenharmony_ci<tbody>
150895bd8deadSopenharmony_ci<tr>
150905bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">gvec4 <strong>textureGather</strong>(gsampler2D <em>sampler</em>, vec2 <em>P</em> [, int <em>comp</em>])<br>
150915bd8deadSopenharmony_ci  gvec4 <strong>textureGather</strong>(gsampler2DArray <em>sampler</em>, vec3 <em>P</em> [, int <em>comp</em>])<br>
150925bd8deadSopenharmony_ci  gvec4 <strong>textureGather</strong>(gsamplerCube <em>sampler</em>, vec3 <em>P</em> [, int <em>comp</em>])<br>
150935bd8deadSopenharmony_ci  gvec4 <strong>textureGather</strong>(gsamplerCubeArray <em>sampler</em>, vec4 <em>P</em>[, int <em>comp</em>])<br>
150945bd8deadSopenharmony_ci  gvec4 <strong>textureGather</strong>(gsampler2DRect <em>sampler</em>, vec2 <em>P</em>[, int <em>comp</em>])<br>
150955bd8deadSopenharmony_ci  vec4 <strong>textureGather</strong>(sampler2DShadow <em>sampler</em>, vec2 <em>P</em>, float <em>refZ</em>)<br>
150965bd8deadSopenharmony_ci  vec4 <strong>textureGather</strong>(sampler2DArrayShadow <em>sampler</em>, vec3 <em>P</em>, float <em>refZ</em>)<br>
150975bd8deadSopenharmony_ci  vec4 <strong>textureGather</strong>(samplerCubeShadow <em>sampler</em>, vec3 <em>P</em>, float <em>refZ</em>)<br>
150985bd8deadSopenharmony_ci  vec4 <strong>textureGather</strong>(samplerCubeArrayShadow <em>sampler</em>, vec4 <em>P</em>, float <em>refZ</em>)<br>
150995bd8deadSopenharmony_ci  vec4 <strong>textureGather</strong>(sampler2DRectShadow <em>sampler</em>, vec2 <em>P</em>, float <em>refZ</em>)</p></td>
151005bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
151015bd8deadSopenharmony_ci<p>Returns the value<br></p>
151025bd8deadSopenharmony_ci</div>
151035bd8deadSopenharmony_ci<div class="openblock">
151045bd8deadSopenharmony_ci<div class="content">
151055bd8deadSopenharmony_ci<div class="listingblock">
151065bd8deadSopenharmony_ci<div class="content">
151075bd8deadSopenharmony_ci<pre class="CodeRay highlight"><code data-lang="c++">vec4(Sample_i0_j1(P, base).comp,
151085bd8deadSopenharmony_ci     Sample_i1_j1(P, base).comp,
151095bd8deadSopenharmony_ci     Sample_i1_j0(P, base).comp,
151105bd8deadSopenharmony_ci     Sample_i0_j0(P, base).comp)</code></pre>
151115bd8deadSopenharmony_ci</div>
151125bd8deadSopenharmony_ci</div>
151135bd8deadSopenharmony_ci<div class="paragraph">
151145bd8deadSopenharmony_ci<p>If specified, the value of <em>comp</em> must be a constant integer expression with
151155bd8deadSopenharmony_cia value of 0, 1, 2, or 3, identifying the <em>x</em>, <em>y</em>, <em>z</em>, or <em>w</em>
151165bd8deadSopenharmony_cipost-swizzled component of the four-component vector lookup result for each
151175bd8deadSopenharmony_citexel, respectively.
151185bd8deadSopenharmony_ciIf <em>comp</em> is not specified, it is treated as 0, selecting the <em>x</em> component
151195bd8deadSopenharmony_ciof each texel to generate the result.</p>
151205bd8deadSopenharmony_ci</div>
151215bd8deadSopenharmony_ci</div>
151225bd8deadSopenharmony_ci</div></div></td>
151235bd8deadSopenharmony_ci</tr>
151245bd8deadSopenharmony_ci<tr>
151255bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">gvec4 <strong>textureGatherOffset</strong>(gsampler2D <em>sampler</em>, vec2 <em>P</em>, ivec2 <em>offset</em>, [ int <em>comp</em>])<br>
151265bd8deadSopenharmony_ci  gvec4 <strong>textureGatherOffset</strong>(gsampler2DArray <em>sampler</em>, vec3 <em>P</em>, ivec2 <em>offset</em> [ int <em>comp</em>])<br>
151275bd8deadSopenharmony_ci  vec4 <strong>textureGatherOffset</strong>(sampler2DShadow <em>sampler</em>, vec2 <em>P</em>, float <em>refZ</em>, ivec2 <em>offset</em>)<br>
151285bd8deadSopenharmony_ci  vec4 <strong>textureGatherOffset</strong>(sampler2DArrayShadow <em>sampler</em>, vec3 <em>P</em>, float <em>refZ</em>, ivec2 <em>offset</em>)<br>
151295bd8deadSopenharmony_ci  gvec4 <strong>textureGatherOffset</strong>(gsampler2DRect <em>sampler</em>, vec2 <em>P</em>, ivec2 <em>offset</em> [ int <em>comp</em>])<br>
151305bd8deadSopenharmony_ci  vec4 <strong>textureGatherOffset</strong>(sampler2DRectShadow <em>sampler</em>, vec2 <em>P</em>, float <em>refZ</em>, ivec2 <em>offset</em>)</p></td>
151315bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Perform a texture gather operation as in <strong>textureGather</strong> by <em>offset</em>
151325bd8deadSopenharmony_ci      as described in <strong>textureOffset</strong> except that the <em>offset</em> can be
151335bd8deadSopenharmony_ci      variable (non constant) and the implementation-dependent minimum and
151345bd8deadSopenharmony_ci      maximum offset values are given by MIN_PROGRAM_TEXTURE_GATHER_OFFSET
151355bd8deadSopenharmony_ci      and MAX_PROGRAM_TEXTURE_GATHER_OFFSET, respectively.</p></td>
151365bd8deadSopenharmony_ci</tr>
151375bd8deadSopenharmony_ci<tr>
151385bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">gvec4 <strong>textureGatherOffsets</strong>(gsampler2D <em>sampler</em>, vec2 <em>P</em>, ivec2 <em>offsets</em>[4] [, int <em>comp</em>])<br>
151395bd8deadSopenharmony_ci  gvec4 <strong>textureGatherOffsets</strong>(gsampler2DArray <em>sampler</em>, vec3 <em>P</em>, ivec2 <em>offsets</em>[4]   [, int <em>comp</em>])<br>
151405bd8deadSopenharmony_ci  vec4 <strong>textureGatherOffsets</strong>(sampler2DShadow <em>sampler</em>, vec2 <em>P</em>, float <em>refZ</em>, ivec2 <em>offsets</em>[4])<br>
151415bd8deadSopenharmony_ci  vec4 <strong>textureGatherOffsets</strong>(sampler2DArrayShadow <em>sampler</em>, vec3 <em>P</em>, float <em>refZ</em>, ivec2 <em>offsets</em>[4])<br>
151425bd8deadSopenharmony_ci  gvec4 <strong>textureGatherOffsets</strong>(gsampler2DRect <em>sampler</em>, vec2 <em>P</em>, ivec2 <em>offsets</em>[4] [, int <em>comp</em>])<br>
151435bd8deadSopenharmony_ci  vec4 <strong>textureGatherOffsets</strong>(sampler2DRectShadow <em>sampler</em>, vec2 <em>P</em>, float <em>refZ</em>, ivec2 <em>offsets</em>[4])</p></td>
151445bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Operate identically to <strong>textureGatherOffset</strong> except that <em>offsets</em> is
151455bd8deadSopenharmony_ci      used to determine the location of the four texels to sample.
151465bd8deadSopenharmony_ci      Each of the four texels is obtained by applying the corresponding
151475bd8deadSopenharmony_ci      offset in <em>offsets</em> as a (<em>u</em>, <em>v</em>) coordinate offset to <em>P</em>,
151485bd8deadSopenharmony_ci      identifying the four-texel LINEAR footprint, and then selecting the
151495bd8deadSopenharmony_ci      texel <em>i<sub>0</sub> j<sub>0</sub></em> of that footprint.
151505bd8deadSopenharmony_ci      The specified values in <em>offsets</em> must be constant integral
151515bd8deadSopenharmony_ci      expressions.</p></td>
151525bd8deadSopenharmony_ci</tr>
151535bd8deadSopenharmony_ci</tbody>
151545bd8deadSopenharmony_ci</table>
151555bd8deadSopenharmony_ci</div>
151565bd8deadSopenharmony_ci<div class="sect3">
151575bd8deadSopenharmony_ci<h4 id="compatibility-profile-texture-functions">8.9.5. Compatibility Profile Texture Functions</h4>
151585bd8deadSopenharmony_ci<div class="paragraph">
151595bd8deadSopenharmony_ci<p>The following texture functions are only in the compatibility profile.</p>
151605bd8deadSopenharmony_ci</div>
151615bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
151625bd8deadSopenharmony_ci<colgroup>
151635bd8deadSopenharmony_ci<col style="width: 50%;">
151645bd8deadSopenharmony_ci<col style="width: 50%;">
151655bd8deadSopenharmony_ci</colgroup>
151665bd8deadSopenharmony_ci<thead>
151675bd8deadSopenharmony_ci<tr>
151685bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
151695bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
151705bd8deadSopenharmony_ci</tr>
151715bd8deadSopenharmony_ci</thead>
151725bd8deadSopenharmony_ci<tbody>
151735bd8deadSopenharmony_ci<tr>
151745bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">vec4 <strong>texture1D</strong>(sampler1D <em>sampler</em>, float <em>coord</em> [, float <em>bias</em>] )<br>
151755bd8deadSopenharmony_ci  vec4 <strong>texture1DProj</strong>(sampler1D <em>sampler</em>, vec2 <em>coord</em> [, float <em>bias</em>] )<br>
151765bd8deadSopenharmony_ci  vec4 <strong>texture1DProj</strong>(sampler1D <em>sampler</em>, vec4 <em>coord</em> [, float <em>bias</em>] )<br>
151775bd8deadSopenharmony_ci  vec4 <strong>texture1DLod</strong>(sampler1D <em>sampler</em>, float <em>coord</em>, float <em>lod</em>)<br>
151785bd8deadSopenharmony_ci  vec4 <strong>texture1DProjLod</strong>(sampler1D <em>sampler</em>, vec2 <em>coord</em>, float <em>lod</em>)<br>
151795bd8deadSopenharmony_ci  vec4 <strong>texture1DProjLod</strong>(sampler1D <em>sampler</em>, vec4 <em>coord</em>, float <em>lod</em>)</p></td>
151805bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">See corresponding signature above without &#8220;1D&#8221; in the name.</p></td>
151815bd8deadSopenharmony_ci</tr>
151825bd8deadSopenharmony_ci<tr>
151835bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">vec4 <strong>texture2D</strong>(sampler2D <em>sampler</em>, vec2 <em>coord</em> [, float <em>bias</em>] )<br>
151845bd8deadSopenharmony_ci  vec4 <strong>texture2DProj</strong>(sampler2D <em>sampler</em>, vec3 <em>coord</em> [, float <em>bias</em>] )<br>
151855bd8deadSopenharmony_ci  vec4 <strong>texture2DProj</strong>(sampler2D <em>sampler</em>, vec4 <em>coord</em> [, float <em>bias</em>] )<br>
151865bd8deadSopenharmony_ci  vec4 <strong>texture2DLod</strong>(sampler2D <em>sampler</em>, vec2 <em>coord</em>, float <em>lod</em>)<br>
151875bd8deadSopenharmony_ci  vec4 <strong>texture2DProjLod</strong>(sampler2D <em>sampler</em>, vec3 <em>coord</em>, float <em>lod</em>)<br>
151885bd8deadSopenharmony_ci  vec4 <strong>texture2DProjLod</strong>(sampler2D <em>sampler</em>, vec4 <em>coord</em>, float <em>lod</em>)</p></td>
151895bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">See corresponding signature above without &#8220;2D&#8221; in the name.</p></td>
151905bd8deadSopenharmony_ci</tr>
151915bd8deadSopenharmony_ci<tr>
151925bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">vec4 <strong>texture3D</strong>(sampler3D <em>sampler</em>, vec3 <em>coord</em> [, float <em>bias</em>] )<br>
151935bd8deadSopenharmony_ci  vec4 <strong>texture3DProj</strong>(sampler3D <em>sampler</em>, vec4 <em>coord</em> [, float <em>bias</em>] )<br>
151945bd8deadSopenharmony_ci  vec4 <strong>texture3DLod</strong>(sampler3D <em>sampler</em>, vec3 <em>coord</em>, float <em>lod</em>)<br>
151955bd8deadSopenharmony_ci  vec4 <strong>texture3DProjLod</strong>(sampler3D <em>sampler</em>, vec4 <em>coord</em>, float <em>lod</em>)</p></td>
151965bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">See corresponding signature above without &#8220;3D&#8221; in the name.<br>
151975bd8deadSopenharmony_ci      Use the texture coordinate <em>coord</em> to do a texture lookup in the 3D
151985bd8deadSopenharmony_ci      texture currently bound to <em>sampler</em>.
151995bd8deadSopenharmony_ci      For the projective (&#8220;<strong>Proj</strong>&#8221;) versions, the texture coordinate is
152005bd8deadSopenharmony_ci      divided by <em>coord.q</em>.</p></td>
152015bd8deadSopenharmony_ci</tr>
152025bd8deadSopenharmony_ci<tr>
152035bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">vec4 <strong>textureCube</strong>(samplerCube <em>sampler</em>, vec3 <em>coord</em> [, float <em>bias</em>] )<br>
152045bd8deadSopenharmony_ci  vec4 <strong>textureCubeLod</strong>(samplerCube <em>sampler</em>, vec3 <em>coord</em>, float <em>lod</em>)</p></td>
152055bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">See corresponding signature above without &#8220;Cube&#8221; in the name.</p></td>
152065bd8deadSopenharmony_ci</tr>
152075bd8deadSopenharmony_ci<tr>
152085bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">vec4 <strong>shadow1D</strong>(sampler1DShadow <em>sampler</em>, vec3 <em>coord</em> [, float <em>bias</em>] )<br>
152095bd8deadSopenharmony_ci  vec4 <strong>shadow2D</strong>(sampler2DShadow <em>sampler</em>, vec3 <em>coord</em> [, float <em>bias</em>] )<br>
152105bd8deadSopenharmony_ci  vec4 <strong>shadow1DProj</strong>(sampler1DShadow <em>sampler</em>, vec4 <em>coord</em> [, float <em>bias</em>] )<br>
152115bd8deadSopenharmony_ci  vec4 <strong>shadow2DProj</strong>(sampler2DShadow <em>sampler</em>, vec4 <em>coord</em> [, float <em>bias</em>] )<br>
152125bd8deadSopenharmony_ci  vec4 <strong>shadow1DLod</strong>(sampler1DShadow <em>sampler</em>, vec3 <em>coord</em>, float <em>lod</em>)<br>
152135bd8deadSopenharmony_ci  vec4 <strong>shadow2DLod</strong>(sampler2DShadow <em>sampler</em>, vec3 <em>coord</em>, float <em>lod</em>)<br>
152145bd8deadSopenharmony_ci  vec4 <strong>shadow1DProjLod</strong>(sampler1DShadow <em>sampler</em>, vec4 <em>coord</em>, float <em>lod</em>)<br>
152155bd8deadSopenharmony_ci  vec4 <strong>shadow2DProjLod</strong>(sampler2DShadow <em>sampler</em>, vec4 coord, float <em>lod</em>)</p></td>
152165bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Same functionality as the &#8220;<strong>texture</strong>&#8221; based names above with the
152175bd8deadSopenharmony_ci      same signature.</p></td>
152185bd8deadSopenharmony_ci</tr>
152195bd8deadSopenharmony_ci</tbody>
152205bd8deadSopenharmony_ci</table>
152215bd8deadSopenharmony_ci</div>
152225bd8deadSopenharmony_ci</div>
152235bd8deadSopenharmony_ci<div class="sect2">
152245bd8deadSopenharmony_ci<h3 id="atomic-counter-functions">8.10. Atomic Counter Functions</h3>
152255bd8deadSopenharmony_ci<div class="paragraph">
152265bd8deadSopenharmony_ci<p>The atomic-counter operations in this section operate atomically with
152275bd8deadSopenharmony_cirespect to each other.
152285bd8deadSopenharmony_ciThey are atomic for any single counter, meaning any of these operations on a
152295bd8deadSopenharmony_cispecific counter in one shader instantiation will be indivisible by any of
152305bd8deadSopenharmony_cithese operations on the same counter from another shader instantiation.
152315bd8deadSopenharmony_ciThere is no guarantee that these operations are atomic with respect to other
152325bd8deadSopenharmony_ciforms of access to the counter or that they are serialized when applied to
152335bd8deadSopenharmony_ciseparate counters.
152345bd8deadSopenharmony_ciSuch cases would require additional use of fences, barriers, or other forms
152355bd8deadSopenharmony_ciof synchronization, if atomicity or serialization is desired.</p>
152365bd8deadSopenharmony_ci</div>
152375bd8deadSopenharmony_ci<div class="paragraph">
152385bd8deadSopenharmony_ci<p>The underlying counter is a 32-bit unsigned integer.
152395bd8deadSopenharmony_ciThe result of operations will wrap to [0, 2<sup>32</sup>-1].</p>
152405bd8deadSopenharmony_ci</div>
152415bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
152425bd8deadSopenharmony_ci<colgroup>
152435bd8deadSopenharmony_ci<col style="width: 50%;">
152445bd8deadSopenharmony_ci<col style="width: 50%;">
152455bd8deadSopenharmony_ci</colgroup>
152465bd8deadSopenharmony_ci<thead>
152475bd8deadSopenharmony_ci<tr>
152485bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
152495bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
152505bd8deadSopenharmony_ci</tr>
152515bd8deadSopenharmony_ci</thead>
152525bd8deadSopenharmony_ci<tbody>
152535bd8deadSopenharmony_ci<tr>
152545bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>atomicCounterIncrement</strong>(atomic_uint <em>c</em>)</p></td>
152555bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
152565bd8deadSopenharmony_ci<p>Atomically<br></p>
152575bd8deadSopenharmony_ci</div>
152585bd8deadSopenharmony_ci<div class="openblock">
152595bd8deadSopenharmony_ci<div class="content">
152605bd8deadSopenharmony_ci<div class="olist arabic">
152615bd8deadSopenharmony_ci<ol class="arabic">
152625bd8deadSopenharmony_ci<li>
152635bd8deadSopenharmony_ci<p>increments the counter for <em>c</em>, and</p>
152645bd8deadSopenharmony_ci</li>
152655bd8deadSopenharmony_ci<li>
152665bd8deadSopenharmony_ci<p>returns its value prior to the increment operation.</p>
152675bd8deadSopenharmony_ci</li>
152685bd8deadSopenharmony_ci</ol>
152695bd8deadSopenharmony_ci</div>
152705bd8deadSopenharmony_ci<div class="paragraph">
152715bd8deadSopenharmony_ci<p>These two steps are done atomically with respect to the atomic counter
152725bd8deadSopenharmony_cifunctions in this table.</p>
152735bd8deadSopenharmony_ci</div>
152745bd8deadSopenharmony_ci</div>
152755bd8deadSopenharmony_ci</div></div></td>
152765bd8deadSopenharmony_ci</tr>
152775bd8deadSopenharmony_ci<tr>
152785bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>atomicCounterDecrement</strong>(atomic_uint <em>c</em>)</p></td>
152795bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
152805bd8deadSopenharmony_ci<p>Atomically<br></p>
152815bd8deadSopenharmony_ci</div>
152825bd8deadSopenharmony_ci<div class="openblock">
152835bd8deadSopenharmony_ci<div class="content">
152845bd8deadSopenharmony_ci<div class="olist arabic">
152855bd8deadSopenharmony_ci<ol class="arabic">
152865bd8deadSopenharmony_ci<li>
152875bd8deadSopenharmony_ci<p>decrements the counter for <em>c</em>, and</p>
152885bd8deadSopenharmony_ci</li>
152895bd8deadSopenharmony_ci<li>
152905bd8deadSopenharmony_ci<p>returns the value resulting from the decrement operation.</p>
152915bd8deadSopenharmony_ci</li>
152925bd8deadSopenharmony_ci</ol>
152935bd8deadSopenharmony_ci</div>
152945bd8deadSopenharmony_ci<div class="paragraph">
152955bd8deadSopenharmony_ci<p>These two steps are done atomically with respect to the atomic counter
152965bd8deadSopenharmony_cifunctions in this table.</p>
152975bd8deadSopenharmony_ci</div>
152985bd8deadSopenharmony_ci</div>
152995bd8deadSopenharmony_ci</div></div></td>
153005bd8deadSopenharmony_ci</tr>
153015bd8deadSopenharmony_ci<tr>
153025bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>atomicCounter</strong>(atomic_uint <em>c</em>)</p></td>
153035bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the counter value for <em>c</em>.</p></td>
153045bd8deadSopenharmony_ci</tr>
153055bd8deadSopenharmony_ci<tr>
153065bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>atomicCounterAdd</strong>(atomic_uint <em>c</em>, uint <em>data</em>)</p></td>
153075bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
153085bd8deadSopenharmony_ci<p>Atomically<br></p>
153095bd8deadSopenharmony_ci</div>
153105bd8deadSopenharmony_ci<div class="openblock">
153115bd8deadSopenharmony_ci<div class="content">
153125bd8deadSopenharmony_ci<div class="olist arabic">
153135bd8deadSopenharmony_ci<ol class="arabic">
153145bd8deadSopenharmony_ci<li>
153155bd8deadSopenharmony_ci<p>adds the value of <em>data</em> to the counter for <em>c</em>, and</p>
153165bd8deadSopenharmony_ci</li>
153175bd8deadSopenharmony_ci<li>
153185bd8deadSopenharmony_ci<p>returns its value prior to the operation.</p>
153195bd8deadSopenharmony_ci</li>
153205bd8deadSopenharmony_ci</ol>
153215bd8deadSopenharmony_ci</div>
153225bd8deadSopenharmony_ci<div class="paragraph">
153235bd8deadSopenharmony_ci<p>These two steps are done atomically with respect to the atomic counter
153245bd8deadSopenharmony_cifunctions in this table.</p>
153255bd8deadSopenharmony_ci</div>
153265bd8deadSopenharmony_ci</div>
153275bd8deadSopenharmony_ci</div></div></td>
153285bd8deadSopenharmony_ci</tr>
153295bd8deadSopenharmony_ci<tr>
153305bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>atomicCounterSubtract</strong>(atomic_uint <em>c</em>, uint <em>data</em>)</p></td>
153315bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
153325bd8deadSopenharmony_ci<p>Atomically<br></p>
153335bd8deadSopenharmony_ci</div>
153345bd8deadSopenharmony_ci<div class="openblock">
153355bd8deadSopenharmony_ci<div class="content">
153365bd8deadSopenharmony_ci<div class="olist arabic">
153375bd8deadSopenharmony_ci<ol class="arabic">
153385bd8deadSopenharmony_ci<li>
153395bd8deadSopenharmony_ci<p>subtracts the value of <em>data</em> from the counter for <em>c</em>, and</p>
153405bd8deadSopenharmony_ci</li>
153415bd8deadSopenharmony_ci<li>
153425bd8deadSopenharmony_ci<p>returns its value prior to the operation.</p>
153435bd8deadSopenharmony_ci</li>
153445bd8deadSopenharmony_ci</ol>
153455bd8deadSopenharmony_ci</div>
153465bd8deadSopenharmony_ci<div class="paragraph">
153475bd8deadSopenharmony_ci<p>These two steps are done atomically with respect to the atomic counter
153485bd8deadSopenharmony_cifunctions in this table.</p>
153495bd8deadSopenharmony_ci</div>
153505bd8deadSopenharmony_ci</div>
153515bd8deadSopenharmony_ci</div></div></td>
153525bd8deadSopenharmony_ci</tr>
153535bd8deadSopenharmony_ci<tr>
153545bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>atomicCounterMin</strong>(atomic_uint <em>c</em>, uint <em>data</em>)</p></td>
153555bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
153565bd8deadSopenharmony_ci<p>Atomically<br></p>
153575bd8deadSopenharmony_ci</div>
153585bd8deadSopenharmony_ci<div class="openblock">
153595bd8deadSopenharmony_ci<div class="content">
153605bd8deadSopenharmony_ci<div class="olist arabic">
153615bd8deadSopenharmony_ci<ol class="arabic">
153625bd8deadSopenharmony_ci<li>
153635bd8deadSopenharmony_ci<p>sets the counter for <em>c</em> to the minimum of the value of the counter and
153645bd8deadSopenharmony_cithe value of <em>data</em>, and</p>
153655bd8deadSopenharmony_ci</li>
153665bd8deadSopenharmony_ci<li>
153675bd8deadSopenharmony_ci<p>returns the value prior to the operation.</p>
153685bd8deadSopenharmony_ci</li>
153695bd8deadSopenharmony_ci</ol>
153705bd8deadSopenharmony_ci</div>
153715bd8deadSopenharmony_ci<div class="paragraph">
153725bd8deadSopenharmony_ci<p>These two steps are done atomically with respect to the atomic counter
153735bd8deadSopenharmony_cifunctions in this table.</p>
153745bd8deadSopenharmony_ci</div>
153755bd8deadSopenharmony_ci</div>
153765bd8deadSopenharmony_ci</div></div></td>
153775bd8deadSopenharmony_ci</tr>
153785bd8deadSopenharmony_ci<tr>
153795bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>atomicCounterMax</strong>(atomic_uint <em>c</em>, uint <em>data</em>)</p></td>
153805bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
153815bd8deadSopenharmony_ci<p>Atomically<br></p>
153825bd8deadSopenharmony_ci</div>
153835bd8deadSopenharmony_ci<div class="openblock">
153845bd8deadSopenharmony_ci<div class="content">
153855bd8deadSopenharmony_ci<div class="olist arabic">
153865bd8deadSopenharmony_ci<ol class="arabic">
153875bd8deadSopenharmony_ci<li>
153885bd8deadSopenharmony_ci<p>sets the counter for <em>c</em> to the maximum of the value of the counter and
153895bd8deadSopenharmony_cithe value of <em>data</em>, and</p>
153905bd8deadSopenharmony_ci</li>
153915bd8deadSopenharmony_ci<li>
153925bd8deadSopenharmony_ci<p>returns the value prior to the operation.</p>
153935bd8deadSopenharmony_ci</li>
153945bd8deadSopenharmony_ci</ol>
153955bd8deadSopenharmony_ci</div>
153965bd8deadSopenharmony_ci<div class="paragraph">
153975bd8deadSopenharmony_ci<p>These two steps are done atomically with respect to the atomic counter
153985bd8deadSopenharmony_cifunctions in this table.</p>
153995bd8deadSopenharmony_ci</div>
154005bd8deadSopenharmony_ci</div>
154015bd8deadSopenharmony_ci</div></div></td>
154025bd8deadSopenharmony_ci</tr>
154035bd8deadSopenharmony_ci<tr>
154045bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>atomicCounterAnd</strong>(atomic_uint <em>c</em>, uint <em>data</em>)</p></td>
154055bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
154065bd8deadSopenharmony_ci<p>Atomically<br></p>
154075bd8deadSopenharmony_ci</div>
154085bd8deadSopenharmony_ci<div class="openblock">
154095bd8deadSopenharmony_ci<div class="content">
154105bd8deadSopenharmony_ci<div class="olist arabic">
154115bd8deadSopenharmony_ci<ol class="arabic">
154125bd8deadSopenharmony_ci<li>
154135bd8deadSopenharmony_ci<p>sets the counter for <em>c</em> to the bitwise AND of the value of the counter
154145bd8deadSopenharmony_ciand the value of <em>data</em>, and</p>
154155bd8deadSopenharmony_ci</li>
154165bd8deadSopenharmony_ci<li>
154175bd8deadSopenharmony_ci<p>returns the value prior to the operation.</p>
154185bd8deadSopenharmony_ci</li>
154195bd8deadSopenharmony_ci</ol>
154205bd8deadSopenharmony_ci</div>
154215bd8deadSopenharmony_ci<div class="paragraph">
154225bd8deadSopenharmony_ci<p>These two steps are done atomically with respect to the atomic counter
154235bd8deadSopenharmony_cifunctions in this table.</p>
154245bd8deadSopenharmony_ci</div>
154255bd8deadSopenharmony_ci</div>
154265bd8deadSopenharmony_ci</div></div></td>
154275bd8deadSopenharmony_ci</tr>
154285bd8deadSopenharmony_ci<tr>
154295bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>atomicCounterOr</strong>(atomic_uint <em>c</em>, uint <em>data</em>)</p></td>
154305bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
154315bd8deadSopenharmony_ci<p>Atomically<br></p>
154325bd8deadSopenharmony_ci</div>
154335bd8deadSopenharmony_ci<div class="openblock">
154345bd8deadSopenharmony_ci<div class="content">
154355bd8deadSopenharmony_ci<div class="olist arabic">
154365bd8deadSopenharmony_ci<ol class="arabic">
154375bd8deadSopenharmony_ci<li>
154385bd8deadSopenharmony_ci<p>sets the counter for <em>c</em> to the bitwise OR of the value of the counter
154395bd8deadSopenharmony_ciand the value of <em>data</em>, and</p>
154405bd8deadSopenharmony_ci</li>
154415bd8deadSopenharmony_ci<li>
154425bd8deadSopenharmony_ci<p>returns the value prior to the operation.</p>
154435bd8deadSopenharmony_ci</li>
154445bd8deadSopenharmony_ci</ol>
154455bd8deadSopenharmony_ci</div>
154465bd8deadSopenharmony_ci<div class="paragraph">
154475bd8deadSopenharmony_ci<p>These two steps are done atomically with respect to the atomic counter
154485bd8deadSopenharmony_cifunctions in this table.</p>
154495bd8deadSopenharmony_ci</div>
154505bd8deadSopenharmony_ci</div>
154515bd8deadSopenharmony_ci</div></div></td>
154525bd8deadSopenharmony_ci</tr>
154535bd8deadSopenharmony_ci<tr>
154545bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>atomicCounterXor</strong>(atomic_uint <em>c</em>, uint <em>data</em>)</p></td>
154555bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
154565bd8deadSopenharmony_ci<p>Atomically<br></p>
154575bd8deadSopenharmony_ci</div>
154585bd8deadSopenharmony_ci<div class="openblock">
154595bd8deadSopenharmony_ci<div class="content">
154605bd8deadSopenharmony_ci<div class="olist arabic">
154615bd8deadSopenharmony_ci<ol class="arabic">
154625bd8deadSopenharmony_ci<li>
154635bd8deadSopenharmony_ci<p>sets the counter for <em>c</em> to the bitwise XOR of the value of the counter
154645bd8deadSopenharmony_ciand the value of <em>data</em>, and</p>
154655bd8deadSopenharmony_ci</li>
154665bd8deadSopenharmony_ci<li>
154675bd8deadSopenharmony_ci<p>returns the value prior to the operation.</p>
154685bd8deadSopenharmony_ci</li>
154695bd8deadSopenharmony_ci</ol>
154705bd8deadSopenharmony_ci</div>
154715bd8deadSopenharmony_ci<div class="paragraph">
154725bd8deadSopenharmony_ci<p>These two steps are done atomically with respect to the atomic counter
154735bd8deadSopenharmony_cifunctions in this table.</p>
154745bd8deadSopenharmony_ci</div>
154755bd8deadSopenharmony_ci</div>
154765bd8deadSopenharmony_ci</div></div></td>
154775bd8deadSopenharmony_ci</tr>
154785bd8deadSopenharmony_ci<tr>
154795bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>atomicCounterExchange</strong>(atomic_uint <em>c</em>, uint <em>data</em>)</p></td>
154805bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
154815bd8deadSopenharmony_ci<p>Atomically<br></p>
154825bd8deadSopenharmony_ci</div>
154835bd8deadSopenharmony_ci<div class="openblock">
154845bd8deadSopenharmony_ci<div class="content">
154855bd8deadSopenharmony_ci<div class="olist arabic">
154865bd8deadSopenharmony_ci<ol class="arabic">
154875bd8deadSopenharmony_ci<li>
154885bd8deadSopenharmony_ci<p>sets the counter value for <em>c</em> to the value of <em>data</em>, and</p>
154895bd8deadSopenharmony_ci</li>
154905bd8deadSopenharmony_ci<li>
154915bd8deadSopenharmony_ci<p>returns its value prior to the operation.</p>
154925bd8deadSopenharmony_ci</li>
154935bd8deadSopenharmony_ci</ol>
154945bd8deadSopenharmony_ci</div>
154955bd8deadSopenharmony_ci<div class="paragraph">
154965bd8deadSopenharmony_ci<p>These two steps are done atomically with respect to the atomic counter
154975bd8deadSopenharmony_cifunctions in this table.</p>
154985bd8deadSopenharmony_ci</div>
154995bd8deadSopenharmony_ci</div>
155005bd8deadSopenharmony_ci</div></div></td>
155015bd8deadSopenharmony_ci</tr>
155025bd8deadSopenharmony_ci<tr>
155035bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>atomicCounterCompSwap</strong>(atomic_uint <em>c</em>, uint <em>compare</em>, uint <em>data</em>)</p></td>
155045bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
155055bd8deadSopenharmony_ci<p>Atomically<br></p>
155065bd8deadSopenharmony_ci</div>
155075bd8deadSopenharmony_ci<div class="openblock">
155085bd8deadSopenharmony_ci<div class="content">
155095bd8deadSopenharmony_ci<div class="olist arabic">
155105bd8deadSopenharmony_ci<ol class="arabic">
155115bd8deadSopenharmony_ci<li>
155125bd8deadSopenharmony_ci<p>compares the value of <em>compare</em> and the counter value for <em>c</em></p>
155135bd8deadSopenharmony_ci</li>
155145bd8deadSopenharmony_ci<li>
155155bd8deadSopenharmony_ci<p>if the values are equal, sets the counter value for <em>c</em> to the value of
155165bd8deadSopenharmony_ci<em>data</em>, and</p>
155175bd8deadSopenharmony_ci</li>
155185bd8deadSopenharmony_ci<li>
155195bd8deadSopenharmony_ci<p>returns its value prior to the operation.</p>
155205bd8deadSopenharmony_ci</li>
155215bd8deadSopenharmony_ci</ol>
155225bd8deadSopenharmony_ci</div>
155235bd8deadSopenharmony_ci<div class="paragraph">
155245bd8deadSopenharmony_ci<p>These three steps are done atomically with respect to the atomic counter
155255bd8deadSopenharmony_cifunctions in this table.</p>
155265bd8deadSopenharmony_ci</div>
155275bd8deadSopenharmony_ci</div>
155285bd8deadSopenharmony_ci</div></div></td>
155295bd8deadSopenharmony_ci</tr>
155305bd8deadSopenharmony_ci</tbody>
155315bd8deadSopenharmony_ci</table>
155325bd8deadSopenharmony_ci</div>
155335bd8deadSopenharmony_ci<div class="sect2">
155345bd8deadSopenharmony_ci<h3 id="atomic-memory-functions">8.11. Atomic Memory Functions</h3>
155355bd8deadSopenharmony_ci<div class="paragraph">
155365bd8deadSopenharmony_ci<p>Atomic memory functions perform atomic operations on an individual signed or
155375bd8deadSopenharmony_ciunsigned integer stored in buffer object or shared variable storage.
155385bd8deadSopenharmony_ciAll of the atomic memory operations read a value from memory, compute a new
155395bd8deadSopenharmony_civalue using one of the operations described below, write the new value to
155405bd8deadSopenharmony_cimemory, and return the original value read.
155415bd8deadSopenharmony_ciThe contents of the memory being updated by the atomic operation are
155425bd8deadSopenharmony_ciguaranteed not to be modified by any other assignment or atomic memory
155435bd8deadSopenharmony_cifunction in any shader invocation between the time the original value is
155445bd8deadSopenharmony_ciread and the time the new value is written.</p>
155455bd8deadSopenharmony_ci</div>
155465bd8deadSopenharmony_ci<div class="paragraph">
155475bd8deadSopenharmony_ci<p>Atomic memory functions are supported only for a limited set of variables.
155485bd8deadSopenharmony_ciA shader will fail to compile if the value passed to the <em>mem</em> argument of
155495bd8deadSopenharmony_cian atomic memory function does not correspond to a buffer or shared
155505bd8deadSopenharmony_civariable.
155515bd8deadSopenharmony_ciIt is acceptable to pass an element of an array or a single component of a
155525bd8deadSopenharmony_civector to the <em>mem</em> argument of an atomic memory function, as long as the
155535bd8deadSopenharmony_ciunderlying array or vector is a buffer or shared variable.</p>
155545bd8deadSopenharmony_ci</div>
155555bd8deadSopenharmony_ci<div class="paragraph">
155565bd8deadSopenharmony_ci<p>All the built-in functions in this section accept arguments with
155575bd8deadSopenharmony_cicombinations of <strong>restrict</strong>, <strong>coherent</strong>, and <strong>volatile</strong> memory qualification,
155585bd8deadSopenharmony_cidespite not having them listed in the prototypes.
155595bd8deadSopenharmony_ciThe atomic operation will operate as required by the calling argument&#8217;s
155605bd8deadSopenharmony_cimemory qualification, not by the built-in function&#8217;s formal parameter memory
155615bd8deadSopenharmony_ciqualification.</p>
155625bd8deadSopenharmony_ci</div>
155635bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
155645bd8deadSopenharmony_ci<colgroup>
155655bd8deadSopenharmony_ci<col style="width: 50%;">
155665bd8deadSopenharmony_ci<col style="width: 50%;">
155675bd8deadSopenharmony_ci</colgroup>
155685bd8deadSopenharmony_ci<thead>
155695bd8deadSopenharmony_ci<tr>
155705bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
155715bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
155725bd8deadSopenharmony_ci</tr>
155735bd8deadSopenharmony_ci</thead>
155745bd8deadSopenharmony_ci<tbody>
155755bd8deadSopenharmony_ci<tr>
155765bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>atomicAdd</strong>(inout uint <em>mem</em>, uint <em>data</em>)<br>
155775bd8deadSopenharmony_ci  int <strong>atomicAdd</strong>(inout int <em>mem</em>, int <em>data</em>)</p></td>
155785bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Computes a new value by adding the value of <em>data</em> to the contents
155795bd8deadSopenharmony_ci      <em>mem</em>.</p></td>
155805bd8deadSopenharmony_ci</tr>
155815bd8deadSopenharmony_ci<tr>
155825bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>atomicMin</strong>(inout uint <em>mem</em>, uint <em>data</em>)<br>
155835bd8deadSopenharmony_ci  int <strong>atomicMin</strong>(inout int <em>mem</em>, int <em>data</em>)</p></td>
155845bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Computes a new value by taking the minimum of the value of <em>data</em> and
155855bd8deadSopenharmony_ci      the contents of <em>mem</em>.</p></td>
155865bd8deadSopenharmony_ci</tr>
155875bd8deadSopenharmony_ci<tr>
155885bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>atomicMax</strong>(inout uint <em>mem</em>, uint <em>data</em>)<br>
155895bd8deadSopenharmony_ci  int <strong>atomicMax</strong>(inout int <em>mem</em>, int <em>data</em>)</p></td>
155905bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Computes a new value by taking the maximum of the value of <em>data</em> and
155915bd8deadSopenharmony_ci      the contents of <em>mem</em>.</p></td>
155925bd8deadSopenharmony_ci</tr>
155935bd8deadSopenharmony_ci<tr>
155945bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>atomicAnd</strong>(inout uint <em>mem</em>, uint <em>data</em>)<br>
155955bd8deadSopenharmony_ci  int <strong>atomicAnd</strong>(inout int <em>mem</em>, int <em>data</em>)</p></td>
155965bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Computes a new value by performing a bit-wise AND of the value of
155975bd8deadSopenharmony_ci      <em>data</em> and the contents of <em>mem</em>.</p></td>
155985bd8deadSopenharmony_ci</tr>
155995bd8deadSopenharmony_ci<tr>
156005bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>atomicOr</strong>(inout uint <em>mem</em>, uint <em>data</em>)<br>
156015bd8deadSopenharmony_ci  int <strong>atomicOr</strong>(inout int <em>mem</em>, int <em>data</em>)</p></td>
156025bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Computes a new value by performing a bit-wise OR of the value of
156035bd8deadSopenharmony_ci      <em>data</em> and the contents of <em>mem</em>.</p></td>
156045bd8deadSopenharmony_ci</tr>
156055bd8deadSopenharmony_ci<tr>
156065bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>atomicXor</strong>(inout uint <em>mem</em>, uint <em>data</em>)<br>
156075bd8deadSopenharmony_ci  int <strong>atomicXor</strong>(inout int <em>mem</em>, int <em>data</em>)</p></td>
156085bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Computes a new value by performing a bit-wise EXCLUSIVE OR of the
156095bd8deadSopenharmony_ci      value of <em>data</em> and the contents of <em>mem</em>.</p></td>
156105bd8deadSopenharmony_ci</tr>
156115bd8deadSopenharmony_ci<tr>
156125bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>atomicExchange</strong>(inout uint <em>mem</em>, uint <em>data</em>)<br>
156135bd8deadSopenharmony_ci  int <strong>atomicExchange</strong>(inout int <em>mem</em>, int <em>data</em>)</p></td>
156145bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Computes a new value by simply copying the value of <em>data</em>.</p></td>
156155bd8deadSopenharmony_ci</tr>
156165bd8deadSopenharmony_ci<tr>
156175bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>atomicCompSwap</strong>(inout uint <em>mem</em>, uint <em>compare</em>, uint <em>data</em>)<br>
156185bd8deadSopenharmony_ci  int <strong>atomicCompSwap</strong>(inout int <em>mem</em>, int <em>compare</em>, int <em>data</em>)</p></td>
156195bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Compares the value of <em>compare</em> and the contents of <em>mem</em>.
156205bd8deadSopenharmony_ci      If the values are equal, the new value is given by <em>data</em>; otherwise,
156215bd8deadSopenharmony_ci      it is taken from the original contents of <em>mem</em>.</p></td>
156225bd8deadSopenharmony_ci</tr>
156235bd8deadSopenharmony_ci</tbody>
156245bd8deadSopenharmony_ci</table>
156255bd8deadSopenharmony_ci</div>
156265bd8deadSopenharmony_ci<div class="sect2">
156275bd8deadSopenharmony_ci<h3 id="image-functions">8.12. Image Functions</h3>
156285bd8deadSopenharmony_ci<div class="paragraph">
156295bd8deadSopenharmony_ci<p>Variables using one of the image basic types may be used by the built-in
156305bd8deadSopenharmony_cishader image memory functions defined in this section to read and write
156315bd8deadSopenharmony_ciindividual texels of a texture.
156325bd8deadSopenharmony_ciEach image variable references an image unit, which has a texture image
156335bd8deadSopenharmony_ciattached.</p>
156345bd8deadSopenharmony_ci</div>
156355bd8deadSopenharmony_ci<div class="paragraph">
156365bd8deadSopenharmony_ci<p>When image memory functions below access memory, an individual texel in the
156375bd8deadSopenharmony_ciimage is identified using an (<em>i</em>), (<em>i, j</em>), or (<em>i, j, k</em>) coordinate
156385bd8deadSopenharmony_cicorresponding to the values of <em>P</em>.
156395bd8deadSopenharmony_ciFor <strong>image2DMS</strong> and <strong>image2DMSArray</strong> variables (and the corresponding
156405bd8deadSopenharmony_ciint/unsigned int types) corresponding to multisample textures, each texel
156415bd8deadSopenharmony_cimay have multiple samples and an individual sample is identified using the
156425bd8deadSopenharmony_ciinteger <em>sample</em> parameter.
156435bd8deadSopenharmony_ciThe coordinates
156445bd8deadSopenharmony_ciand sample number
156455bd8deadSopenharmony_ciare used to select an individual texel in the manner described in section
156465bd8deadSopenharmony_ci8.26
156475bd8deadSopenharmony_ci&#8220;Texture Image Loads and Stores&#8221; of the <a href="#references">OpenGL Specification</a>.</p>
156485bd8deadSopenharmony_ci</div>
156495bd8deadSopenharmony_ci<div class="paragraph">
156505bd8deadSopenharmony_ci<p>Loads and stores support float, integer, and unsigned integer types.
156515bd8deadSopenharmony_ciThe data types below starting <code>gimage</code> serve as placeholders meaning
156525bd8deadSopenharmony_citypes starting either &#8220;<strong>image</strong>&#8221;, &#8220;<strong>iimage</strong>&#8221;, or &#8220;<strong>uimage</strong>&#8221; in the same
156535bd8deadSopenharmony_ciway as "<strong>gvec</strong>" or "<strong>gsampler</strong>" in earlier sections.</p>
156545bd8deadSopenharmony_ci</div>
156555bd8deadSopenharmony_ci<div class="paragraph">
156565bd8deadSopenharmony_ci<p>The <em>IMAGE_PARAMS</em> in the prototypes below is a placeholder representing
156575bd8deadSopenharmony_ci33
156585bd8deadSopenharmony_ciseparate functions, each for a different type of image variable.
156595bd8deadSopenharmony_ciThe <em>IMAGE_PARAMS</em> placeholder is replaced by one of the following parameter
156605bd8deadSopenharmony_cilists:</p>
156615bd8deadSopenharmony_ci</div>
156625bd8deadSopenharmony_ci<div class="dlist">
156635bd8deadSopenharmony_ci<dl>
156645bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
156655bd8deadSopenharmony_ci<dd>
156665bd8deadSopenharmony_ci<p>gimage2D <em>image</em>, ivec2 <em>P</em></p>
156675bd8deadSopenharmony_ci</dd>
156685bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
156695bd8deadSopenharmony_ci<dd>
156705bd8deadSopenharmony_ci<p>gimage3D <em>image</em>, ivec3 <em>P</em></p>
156715bd8deadSopenharmony_ci</dd>
156725bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
156735bd8deadSopenharmony_ci<dd>
156745bd8deadSopenharmony_ci<p>gimageCube <em>image</em>, ivec3 <em>P</em></p>
156755bd8deadSopenharmony_ci</dd>
156765bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
156775bd8deadSopenharmony_ci<dd>
156785bd8deadSopenharmony_ci<p>gimageBuffer <em>image</em>, int <em>P</em></p>
156795bd8deadSopenharmony_ci</dd>
156805bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
156815bd8deadSopenharmony_ci<dd>
156825bd8deadSopenharmony_ci<p>gimage2DArray <em>image</em>, ivec3 <em>P</em></p>
156835bd8deadSopenharmony_ci</dd>
156845bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
156855bd8deadSopenharmony_ci<dd>
156865bd8deadSopenharmony_ci<p>gimageCubeArray <em>image</em>, ivec3 <em>P</em></p>
156875bd8deadSopenharmony_ci</dd>
156885bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
156895bd8deadSopenharmony_ci<dd>
156905bd8deadSopenharmony_ci<p>gimage1D <em>image</em>, int <em>P</em></p>
156915bd8deadSopenharmony_ci</dd>
156925bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
156935bd8deadSopenharmony_ci<dd>
156945bd8deadSopenharmony_ci<p>gimage1DArray <em>image</em>, ivec2 <em>P</em></p>
156955bd8deadSopenharmony_ci</dd>
156965bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
156975bd8deadSopenharmony_ci<dd>
156985bd8deadSopenharmony_ci<p>gimage2DRect <em>image</em>, ivec2 <em>P</em></p>
156995bd8deadSopenharmony_ci</dd>
157005bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
157015bd8deadSopenharmony_ci<dd>
157025bd8deadSopenharmony_ci<p>gimage2DMS <em>image</em>, ivec2 <em>P</em>, int <em>sample</em></p>
157035bd8deadSopenharmony_ci</dd>
157045bd8deadSopenharmony_ci<dt class="hdlist1"></dt>
157055bd8deadSopenharmony_ci<dd>
157065bd8deadSopenharmony_ci<p>gimage2DMSArray <em>image</em>, ivec3 <em>P</em>, int <em>sample</em></p>
157075bd8deadSopenharmony_ci</dd>
157085bd8deadSopenharmony_ci</dl>
157095bd8deadSopenharmony_ci</div>
157105bd8deadSopenharmony_ci<div class="paragraph">
157115bd8deadSopenharmony_ci<p>where each of the lines represents one of three different image variable
157125bd8deadSopenharmony_citypes, and <em>image</em>,
157135bd8deadSopenharmony_ci<em>P</em>, and <em>sample</em>
157145bd8deadSopenharmony_cispecify the individual texel to operate on.
157155bd8deadSopenharmony_ciThe method for identifying the individual texel operated on from <em>image</em>,
157165bd8deadSopenharmony_ci<em>P</em>,
157175bd8deadSopenharmony_ciand <em>sample</em>,
157185bd8deadSopenharmony_ciand the method for reading and writing the texel are specified in section
157195bd8deadSopenharmony_ci8.26
157205bd8deadSopenharmony_ci&#8220;Texture Image Loads and Stores&#8221; of the <a href="#references">OpenGL Specification</a>.</p>
157215bd8deadSopenharmony_ci</div>
157225bd8deadSopenharmony_ci<div class="paragraph">
157235bd8deadSopenharmony_ci<p>The atomic functions perform operations on individual texels or samples of
157245bd8deadSopenharmony_cian image variable.
157255bd8deadSopenharmony_ciAtomic memory operations read a value from the selected texel, compute a new
157265bd8deadSopenharmony_civalue using one of the operations described below, write the new value to
157275bd8deadSopenharmony_cithe selected texel, and return the original value read.
157285bd8deadSopenharmony_ciThe contents of the texel being updated by the atomic operation are
157295bd8deadSopenharmony_ciguaranteed not to be modified by any other image store or atomic function
157305bd8deadSopenharmony_cibetween the time the original value is read and the time the new value is
157315bd8deadSopenharmony_ciwritten.</p>
157325bd8deadSopenharmony_ci</div>
157335bd8deadSopenharmony_ci<div class="paragraph">
157345bd8deadSopenharmony_ci<p>Atomic memory operations are supported on only a subset of all image
157355bd8deadSopenharmony_civariable types; <em>image</em> must be either:</p>
157365bd8deadSopenharmony_ci</div>
157375bd8deadSopenharmony_ci<div class="ulist">
157385bd8deadSopenharmony_ci<ul>
157395bd8deadSopenharmony_ci<li>
157405bd8deadSopenharmony_ci<p>a signed integer image variable (type starts &#8220;<strong>iimage</strong>&#8221;) and a format
157415bd8deadSopenharmony_ciqualifier of <strong>r32i</strong>, used with a <em>data</em> argument of type <strong>int</strong>, or</p>
157425bd8deadSopenharmony_ci</li>
157435bd8deadSopenharmony_ci<li>
157445bd8deadSopenharmony_ci<p>an unsigned integer image variable (type starts &#8220;<strong>uimage</strong>&#8221;) and a
157455bd8deadSopenharmony_ciformat qualifier of <strong>r32ui</strong>, used with a <em>data</em> argument of type <strong>uint</strong>,
157465bd8deadSopenharmony_cior</p>
157475bd8deadSopenharmony_ci</li>
157485bd8deadSopenharmony_ci<li>
157495bd8deadSopenharmony_ci<p>a float image variable (type starts &#8220;<strong>image</strong>&#8221;) and a format qualifier
157505bd8deadSopenharmony_ciof <strong>r32f</strong>, used with a <em>data</em> argument of type <strong>float</strong>
157515bd8deadSopenharmony_ci(<strong>imageAtomicExchange</strong> only).</p>
157525bd8deadSopenharmony_ci</li>
157535bd8deadSopenharmony_ci</ul>
157545bd8deadSopenharmony_ci</div>
157555bd8deadSopenharmony_ci<div class="paragraph">
157565bd8deadSopenharmony_ci<p>All the built-in functions in this section accept arguments with
157575bd8deadSopenharmony_cicombinations of <strong>restrict</strong>, <strong>coherent</strong>, and <strong>volatile</strong> memory qualification,
157585bd8deadSopenharmony_cidespite not having them listed in the prototypes.
157595bd8deadSopenharmony_ciThe image operation will operate as required by the calling argument&#8217;s
157605bd8deadSopenharmony_cimemory qualification, not by the built-in function&#8217;s formal parameter memory
157615bd8deadSopenharmony_ciqualification.</p>
157625bd8deadSopenharmony_ci</div>
157635bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
157645bd8deadSopenharmony_ci<colgroup>
157655bd8deadSopenharmony_ci<col style="width: 50%;">
157665bd8deadSopenharmony_ci<col style="width: 50%;">
157675bd8deadSopenharmony_ci</colgroup>
157685bd8deadSopenharmony_ci<thead>
157695bd8deadSopenharmony_ci<tr>
157705bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
157715bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
157725bd8deadSopenharmony_ci</tr>
157735bd8deadSopenharmony_ci</thead>
157745bd8deadSopenharmony_ci<tbody>
157755bd8deadSopenharmony_ci<tr>
157765bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">   int <strong>imageSize</strong>(readonly writeonly gimage1D <em>image</em>)<br>
157775bd8deadSopenharmony_ci   ivec2 <strong>imageSize</strong>(readonly writeonly gimage2D <em>image</em>)<br>
157785bd8deadSopenharmony_ci   ivec3 <strong>imageSize</strong>(readonly writeonly gimage3D <em>image</em>)<br>
157795bd8deadSopenharmony_ci   ivec2 <strong>imageSize</strong>(readonly writeonly gimageCube <em>image</em>)<br>
157805bd8deadSopenharmony_ci   ivec3 <strong>imageSize</strong>(readonly writeonly gimageCubeArray <em>image</em>)<br>
157815bd8deadSopenharmony_ci   ivec3 <strong>imageSize</strong>(readonly writeonly gimage2DArray <em>image</em>)<br>
157825bd8deadSopenharmony_ci   ivec2 <strong>imageSize</strong>(readonly writeonly gimageRect <em>image</em>)<br>
157835bd8deadSopenharmony_ci   ivec2 <strong>imageSize</strong>(readonly writeonly gimage1DArray <em>image</em>)<br>
157845bd8deadSopenharmony_ci   ivec2 <strong>imageSize</strong>(readonly writeonly gimage2DMS <em>image</em>)<br>
157855bd8deadSopenharmony_ci   ivec3 <strong>imageSize</strong>(readonly writeonly gimage2DMSArray <em>image</em>)<br>
157865bd8deadSopenharmony_ci     int <strong>imageSize</strong>(readonly writeonly gimageBuffer <em>image</em>)</p></td>
157875bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the dimensions of the image or images bound to <em>image</em>.
157885bd8deadSopenharmony_ci      For arrayed images, the last component of the return value will hold
157895bd8deadSopenharmony_ci      the size of the array.
157905bd8deadSopenharmony_ci      Cube images only return the dimensions of one face, and the number of
157915bd8deadSopenharmony_ci      cubes in the cube map array, if arrayed.<br>
157925bd8deadSopenharmony_ci      Note: The qualification <strong>readonly writeonly</strong> accepts a variable
157935bd8deadSopenharmony_ci      qualified with <strong>readonly</strong>, <strong>writeonly</strong>, both, or neither.
157945bd8deadSopenharmony_ci      It means the formal argument will be used for neither reading nor
157955bd8deadSopenharmony_ci      writing to the underlying memory.</p></td>
157965bd8deadSopenharmony_ci</tr>
157975bd8deadSopenharmony_ci<tr>
157985bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>imageSamples</strong>(readonly writeonly gimage2DMS <em>image</em>)<br>
157995bd8deadSopenharmony_ci  int <strong>imageSamples</strong>(readonly writeonly gimage2DMSArray <em>image</em>)</p></td>
158005bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the number of samples of the image or images bound to <em>image</em>.</p></td>
158015bd8deadSopenharmony_ci</tr>
158025bd8deadSopenharmony_ci<tr>
158035bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"> gvec4 <strong>imageLoad</strong>(readonly <em>IMAGE_PARAMS</em>)</p></td>
158045bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Loads the texel at the coordinate <em>P</em> from the image unit <em>image</em> (in
158055bd8deadSopenharmony_ci      <em>IMAGE_PARAMS</em>).
158065bd8deadSopenharmony_ci      For multisample loads, the sample number is given by <em>sample</em>.
158075bd8deadSopenharmony_ci      When <em>image</em>, <em>P</em>, and <em>sample</em>
158085bd8deadSopenharmony_ci      identify a valid texel, the bits used to represent the selected texel in
158095bd8deadSopenharmony_ci      memory are converted to a <strong>vec4</strong>, <strong>ivec4</strong>, or <strong>uvec4</strong> in the manner
158105bd8deadSopenharmony_ci      described in section
158115bd8deadSopenharmony_ci8.26
158125bd8deadSopenharmony_ci      &#8220;Texture Image Loads and Stores&#8221; of the
158135bd8deadSopenharmony_ci      <a href="#references">OpenGL Specification</a> and returned.</p></td>
158145bd8deadSopenharmony_ci</tr>
158155bd8deadSopenharmony_ci<tr>
158165bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>imageStore</strong>(writeonly <em>IMAGE_PARAMS</em>, gvec4 <em>data</em>)</p></td>
158175bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Stores <em>data</em> into the texel at the coordinate <em>P</em> from the image
158185bd8deadSopenharmony_ci      specified by <em>image</em>.
158195bd8deadSopenharmony_ci      For multisample stores, the sample number is given by <em>sample</em>.
158205bd8deadSopenharmony_ci      When <em>image</em>, <em>P</em>, and <em>sample</em>
158215bd8deadSopenharmony_ci      identify a valid texel, the bits used to represent <em>data</em> are converted
158225bd8deadSopenharmony_ci      to the format of the image unit in the manner described in section
158235bd8deadSopenharmony_ci8.26
158245bd8deadSopenharmony_ci      &#8220;Texture Image Loads and Stores&#8221; of the <a href="#references">OpenGL Specification</a>
158255bd8deadSopenharmony_ci      and stored to the specified texel.</p></td>
158265bd8deadSopenharmony_ci</tr>
158275bd8deadSopenharmony_ci<tr>
158285bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"> uint <strong>imageAtomicAdd</strong>(<em>IMAGE_PARAMS</em>, uint <em>data</em>)<br>
158295bd8deadSopenharmony_ci   int <strong>imageAtomicAdd</strong>(<em>IMAGE_PARAMS</em>, int <em>data</em>)</p></td>
158305bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Computes a new value by adding the value of <em>data</em> to the contents of
158315bd8deadSopenharmony_ci      the selected texel.</p></td>
158325bd8deadSopenharmony_ci</tr>
158335bd8deadSopenharmony_ci<tr>
158345bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"> uint <strong>imageAtomicMin</strong>(<em>IMAGE_PARAMS</em>, uint <em>data</em>)<br>
158355bd8deadSopenharmony_ci   int <strong>imageAtomicMin</strong>(<em>IMAGE_PARAMS</em>, int <em>data</em>)</p></td>
158365bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Computes a new value by taking the minimum of the value of <em>data</em> and
158375bd8deadSopenharmony_ci      the contents of the selected texel.</p></td>
158385bd8deadSopenharmony_ci</tr>
158395bd8deadSopenharmony_ci<tr>
158405bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"> uint <strong>imageAtomicMax</strong>(<em>IMAGE_PARAMS</em>, uint <em>data</em>)<br>
158415bd8deadSopenharmony_ci   int <strong>imageAtomicMax</strong>(<em>IMAGE_PARAMS</em>, int <em>data</em>)</p></td>
158425bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Computes a new value by taking the maximum of the value <em>data</em> and the
158435bd8deadSopenharmony_ci      contents of the selected texel.</p></td>
158445bd8deadSopenharmony_ci</tr>
158455bd8deadSopenharmony_ci<tr>
158465bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"> uint <strong>imageAtomicAnd</strong>(<em>IMAGE_PARAMS</em>, uint <em>data</em>)<br>
158475bd8deadSopenharmony_ci   int <strong>imageAtomicAnd</strong>(<em>IMAGE_PARAMS</em>, int <em>data</em>)</p></td>
158485bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Computes a new value by performing a bit-wise AND of the value of
158495bd8deadSopenharmony_ci      <em>data</em> and the contents of the selected texel.</p></td>
158505bd8deadSopenharmony_ci</tr>
158515bd8deadSopenharmony_ci<tr>
158525bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"> uint <strong>imageAtomicOr</strong>(<em>IMAGE_PARAMS</em>, uint <em>data</em>)<br>
158535bd8deadSopenharmony_ci   int <strong>imageAtomicOr</strong>(<em>IMAGE_PARAMS</em>, int <em>data</em>)</p></td>
158545bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Computes a new value by performing a bit-wise OR of the value of
158555bd8deadSopenharmony_ci      <em>data</em> and the contents of the selected texel.</p></td>
158565bd8deadSopenharmony_ci</tr>
158575bd8deadSopenharmony_ci<tr>
158585bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"> uint <strong>imageAtomicXor</strong>(<em>IMAGE_PARAMS</em>, uint <em>data</em>)<br>
158595bd8deadSopenharmony_ci   int <strong>imageAtomicXor</strong>(<em>IMAGE_PARAMS</em>, int <em>data</em>)</p></td>
158605bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Computes a new value by performing a bit-wise EXCLUSIVE OR of the
158615bd8deadSopenharmony_ci      value of <em>data</em> and the contents of the selected texel.</p></td>
158625bd8deadSopenharmony_ci</tr>
158635bd8deadSopenharmony_ci<tr>
158645bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"> uint <strong>imageAtomicExchange</strong>(<em>IMAGE_PARAMS</em>, uint <em>data</em>)<br>
158655bd8deadSopenharmony_ci   int <strong>imageAtomicExchange</strong>(<em>IMAGE_PARAMS</em>, int <em>data</em>)<br>
158665bd8deadSopenharmony_ci   float <strong>imageAtomicExchange</strong>(<em>IMAGE_PARAMS</em>, float <em>data</em>)</p></td>
158675bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Computes a new value by simply copying the value of <em>data</em>.</p></td>
158685bd8deadSopenharmony_ci</tr>
158695bd8deadSopenharmony_ci<tr>
158705bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock"> uint <strong>imageAtomicCompSwap</strong>(<em>IMAGE_PARAMS</em>, uint <em>compare</em>, uint <em>data</em>)<br>
158715bd8deadSopenharmony_ci   int <strong>imageAtomicCompSwap</strong>(<em>IMAGE_PARAMS</em>, int <em>compare</em>, int <em>data</em>)</p></td>
158725bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Compares the value of <em>compare</em> and the contents of the selected
158735bd8deadSopenharmony_ci      texel.
158745bd8deadSopenharmony_ci      If the values are equal, the new value is given by <em>data</em>; otherwise,
158755bd8deadSopenharmony_ci      it is taken from the original value loaded from the texel.</p></td>
158765bd8deadSopenharmony_ci</tr>
158775bd8deadSopenharmony_ci</tbody>
158785bd8deadSopenharmony_ci</table>
158795bd8deadSopenharmony_ci</div>
158805bd8deadSopenharmony_ci<div class="sect2">
158815bd8deadSopenharmony_ci<h3 id="geometry-shader-functions">8.13. Geometry Shader Functions</h3>
158825bd8deadSopenharmony_ci<div class="paragraph">
158835bd8deadSopenharmony_ci<p>These functions are only available in geometry shaders.
158845bd8deadSopenharmony_ciThey are described in more depth following the table.</p>
158855bd8deadSopenharmony_ci</div>
158865bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
158875bd8deadSopenharmony_ci<colgroup>
158885bd8deadSopenharmony_ci<col style="width: 50%;">
158895bd8deadSopenharmony_ci<col style="width: 50%;">
158905bd8deadSopenharmony_ci</colgroup>
158915bd8deadSopenharmony_ci<thead>
158925bd8deadSopenharmony_ci<tr>
158935bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
158945bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
158955bd8deadSopenharmony_ci</tr>
158965bd8deadSopenharmony_ci</thead>
158975bd8deadSopenharmony_ci<tbody>
158985bd8deadSopenharmony_ci<tr>
158995bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>EmitStreamVertex</strong>(int <em>stream</em>)</p></td>
159005bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Emits the current values of output variables to the current output
159015bd8deadSopenharmony_ci      primitive on stream <em>stream</em>.
159025bd8deadSopenharmony_ci      The argument to <em>stream</em> must be a constant integral expression.
159035bd8deadSopenharmony_ci      On return from this call, the values of all output variables are
159045bd8deadSopenharmony_ci      undefined.<br>
159055bd8deadSopenharmony_ci      Can only be used if multiple output streams are supported.</p></td>
159065bd8deadSopenharmony_ci</tr>
159075bd8deadSopenharmony_ci<tr>
159085bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>EndStreamPrimitive</strong>(int <em>stream</em>)</p></td>
159095bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Completes the current output primitive on stream <em>stream</em> and starts a
159105bd8deadSopenharmony_ci      new one.
159115bd8deadSopenharmony_ci      The argument to <em>stream</em> must be a constant integral expression.
159125bd8deadSopenharmony_ci      No vertex is emitted.<br>
159135bd8deadSopenharmony_ci      Can only be used if multiple output streams are supported.</p></td>
159145bd8deadSopenharmony_ci</tr>
159155bd8deadSopenharmony_ci<tr>
159165bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>EmitVertex</strong>()<br></p></td>
159175bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Emits the current values of output variables to the current output
159185bd8deadSopenharmony_ci      primitive.
159195bd8deadSopenharmony_ci      When multiple output streams are supported, this is equivalent to
159205bd8deadSopenharmony_ci      calling <strong>EmitStreamVertex</strong>(0).<br>
159215bd8deadSopenharmony_ci      On return from this call, the values of output variables are
159225bd8deadSopenharmony_ci      undefined.</p></td>
159235bd8deadSopenharmony_ci</tr>
159245bd8deadSopenharmony_ci<tr>
159255bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>EndPrimitive</strong>()</p></td>
159265bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Completes the current output primitive and starts a new one.
159275bd8deadSopenharmony_ci      When multiple output streams are supported, this is equivalent to
159285bd8deadSopenharmony_ci      calling <strong>EndStreamPrimitive</strong>(0).<br>
159295bd8deadSopenharmony_ci      No vertex is emitted.</p></td>
159305bd8deadSopenharmony_ci</tr>
159315bd8deadSopenharmony_ci</tbody>
159325bd8deadSopenharmony_ci</table>
159335bd8deadSopenharmony_ci<div class="paragraph">
159345bd8deadSopenharmony_ci<p>The function <strong>EmitStreamVertex</strong>() specifies that a vertex is completed.
159355bd8deadSopenharmony_ciA vertex is added to the current output primitive in vertex stream <em>stream</em>
159365bd8deadSopenharmony_ciusing the current values of all built-in and user-defined output variables
159375bd8deadSopenharmony_ciassociated with <em>stream</em>.
159385bd8deadSopenharmony_ciThe values of all output variables for all output streams are undefined
159395bd8deadSopenharmony_ciafter a call to <strong>EmitStreamVertex</strong>().
159405bd8deadSopenharmony_ciIf a geometry shader invocation has emitted more vertices than permitted by
159415bd8deadSopenharmony_cithe output layout qualifier <strong>max_vertices</strong>, the results of calling
159425bd8deadSopenharmony_ci<strong>EmitStreamVertex</strong>() are undefined.</p>
159435bd8deadSopenharmony_ci</div>
159445bd8deadSopenharmony_ci<div class="paragraph">
159455bd8deadSopenharmony_ci<p>The function <strong>EndStreamPrimitive</strong>() specifies that the current output
159465bd8deadSopenharmony_ciprimitive for vertex stream <em>stream</em> is completed and a new output primitive
159475bd8deadSopenharmony_ci(of the same type) will be started by any subsequent <strong>EmitStreamVertex</strong>().
159485bd8deadSopenharmony_ciThis function does not emit a vertex.
159495bd8deadSopenharmony_ciIf the output layout is declared to be <strong>points</strong>, calling
159505bd8deadSopenharmony_ci<strong>EndStreamPrimitive</strong>() is optional.</p>
159515bd8deadSopenharmony_ci</div>
159525bd8deadSopenharmony_ci<div class="paragraph">
159535bd8deadSopenharmony_ci<p>A geometry shader starts with an output primitive containing no vertices for
159545bd8deadSopenharmony_cieach stream.
159555bd8deadSopenharmony_ciWhen a geometry shader terminates, the current output primitive for each
159565bd8deadSopenharmony_cistream is automatically completed.
159575bd8deadSopenharmony_ciIt is not necessary to call <strong>EndStreamPrimitive</strong>() if the geometry shader
159585bd8deadSopenharmony_ciwrites only a single primitive.</p>
159595bd8deadSopenharmony_ci</div>
159605bd8deadSopenharmony_ci<div class="paragraph">
159615bd8deadSopenharmony_ci<p>Multiple output streams are supported only if the output primitive type is
159625bd8deadSopenharmony_cideclared to be <strong>points</strong>.
159635bd8deadSopenharmony_ciIt is a compile-time or link-time error if a program contains a geometry
159645bd8deadSopenharmony_cishader calling <strong>EmitStreamVertex</strong>() or <strong>EndStreamPrimitive</strong>() if its output
159655bd8deadSopenharmony_ciprimitive type is not <strong>points</strong>.</p>
159665bd8deadSopenharmony_ci</div>
159675bd8deadSopenharmony_ci</div>
159685bd8deadSopenharmony_ci<div class="sect2">
159695bd8deadSopenharmony_ci<h3 id="fragment-processing-functions">8.14. Fragment Processing Functions</h3>
159705bd8deadSopenharmony_ci<div class="paragraph">
159715bd8deadSopenharmony_ci<p>Fragment processing functions are only available in fragment shaders.</p>
159725bd8deadSopenharmony_ci</div>
159735bd8deadSopenharmony_ci<div class="sect3">
159745bd8deadSopenharmony_ci<h4 id="derivative-functions">8.14.1. Derivative Functions</h4>
159755bd8deadSopenharmony_ci<div class="paragraph">
159765bd8deadSopenharmony_ci<p>Derivatives may be computationally expensive and/or numerically unstable.
159775bd8deadSopenharmony_ciTherefore, an implementation may approximate the true derivatives
159785bd8deadSopenharmony_ciby using a fast but not entirely accurate derivative computation.
159795bd8deadSopenharmony_ciDerivatives are undefined within non-uniform control flow.</p>
159805bd8deadSopenharmony_ci</div>
159815bd8deadSopenharmony_ci<div class="paragraph">
159825bd8deadSopenharmony_ci<p>The expected behavior of a derivative is specified using forward/backward
159835bd8deadSopenharmony_cidifferencing.</p>
159845bd8deadSopenharmony_ci</div>
159855bd8deadSopenharmony_ci<div class="paragraph">
159865bd8deadSopenharmony_ci<p>Forward differencing:</p>
159875bd8deadSopenharmony_ci</div>
159885bd8deadSopenharmony_ci<div class="paragraph">
159895bd8deadSopenharmony_ci<p>\(F(x+dx) - F(x) \sim dFdx(x) \cdot dx (1a)\)</p>
159905bd8deadSopenharmony_ci</div>
159915bd8deadSopenharmony_ci<div class="paragraph">
159925bd8deadSopenharmony_ci<p>\(dFdx(x) \sim \frac{F(x+dx) - F(x)}{dx} (1b)\)</p>
159935bd8deadSopenharmony_ci</div>
159945bd8deadSopenharmony_ci<div class="paragraph">
159955bd8deadSopenharmony_ci<p>Backward differencing:</p>
159965bd8deadSopenharmony_ci</div>
159975bd8deadSopenharmony_ci<div class="paragraph">
159985bd8deadSopenharmony_ci<p>\(F(x-dx) - F(x) \sim -dFdx(x) \cdot dx (2a)\)</p>
159995bd8deadSopenharmony_ci</div>
160005bd8deadSopenharmony_ci<div class="paragraph">
160015bd8deadSopenharmony_ci<p>\(dFdx(x) \sim \frac{F(x) - F(x-dx)}{dx} (2b)\)</p>
160025bd8deadSopenharmony_ci</div>
160035bd8deadSopenharmony_ci<div class="paragraph">
160045bd8deadSopenharmony_ci<p>With single-sample rasterization, \(dx \leq 1.0\) in equations 1b
160055bd8deadSopenharmony_ciand 2b.
160065bd8deadSopenharmony_ciFor multisample rasterization, \(dx &lt; 2.0\) in equations 1b and 2b.</p>
160075bd8deadSopenharmony_ci</div>
160085bd8deadSopenharmony_ci<div class="paragraph">
160095bd8deadSopenharmony_ci<p>\(dFdy\) is approximated similarly, with <em>y</em> replacing <em>x</em>.</p>
160105bd8deadSopenharmony_ci</div>
160115bd8deadSopenharmony_ci<div class="paragraph">
160125bd8deadSopenharmony_ci<p>With multisample rasterization, for any given fragment or sample, either
160135bd8deadSopenharmony_cineighboring fragments or samples may be considered.</p>
160145bd8deadSopenharmony_ci</div>
160155bd8deadSopenharmony_ci<div class="paragraph">
160165bd8deadSopenharmony_ci<p>It is typical to consider a 2x2 square of fragments or samples, and compute
160175bd8deadSopenharmony_ciindependent <strong>dFdxFine</strong> per row and independent <strong>dFdyFine</strong> per column, while
160185bd8deadSopenharmony_cicomputing only a single <strong>dFdxCoarse</strong> and a single <strong>dFdyCoarse</strong> for the
160195bd8deadSopenharmony_cientire 2x2 square.
160205bd8deadSopenharmony_ciThus, all second-order coarse derivatives, e.g.
160215bd8deadSopenharmony_ci<strong>dFdxCoarse</strong>(<strong>dFdxCoarse</strong>(<em>x</em>)), may be 0, even for non-linear arguments.
160225bd8deadSopenharmony_ciHowever, second-order fine derivatives, e.g. <strong>dFdxFine</strong>(<strong>dFdyFine</strong>(<em>x</em>))
160235bd8deadSopenharmony_ciwill properly reflect the difference between the independent fine
160245bd8deadSopenharmony_ciderivatives computed within the 2x2 square.</p>
160255bd8deadSopenharmony_ci</div>
160265bd8deadSopenharmony_ci<div class="paragraph">
160275bd8deadSopenharmony_ci<p>The method may differ per fragment, subject to the constraint that the
160285bd8deadSopenharmony_cimethod may vary by window coordinates, not screen coordinates.
160295bd8deadSopenharmony_ciThe invariance requirement described in section 14.2 &#8220;Invariance&#8221; of the
160305bd8deadSopenharmony_ci<a href="#references">OpenGL Specification</a>, is relaxed for derivative calculations, because
160315bd8deadSopenharmony_cithe method may be a function of fragment location.</p>
160325bd8deadSopenharmony_ci</div>
160335bd8deadSopenharmony_ci<div class="paragraph">
160345bd8deadSopenharmony_ci<p>In some implementations, varying degrees of derivative accuracy for <strong>dFdx</strong>
160355bd8deadSopenharmony_ciand <strong>dFdy</strong> may be obtained by providing GL hints (see section 21.4 &#8220;Hints&#8221;
160365bd8deadSopenharmony_ciof the <a href="#references">OpenGL Specification</a>), allowing a user to make an image quality
160375bd8deadSopenharmony_civersus speed trade off.
160385bd8deadSopenharmony_ciThese hints have no effect on <strong>dFdxCoarse</strong>, <strong>dFdyCoarse</strong>, <strong>dFdxFine</strong> and
160395bd8deadSopenharmony_ci<strong>dFdyFine</strong>.</p>
160405bd8deadSopenharmony_ci</div>
160415bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
160425bd8deadSopenharmony_ci<colgroup>
160435bd8deadSopenharmony_ci<col style="width: 50%;">
160445bd8deadSopenharmony_ci<col style="width: 50%;">
160455bd8deadSopenharmony_ci</colgroup>
160465bd8deadSopenharmony_ci<thead>
160475bd8deadSopenharmony_ci<tr>
160485bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
160495bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
160505bd8deadSopenharmony_ci</tr>
160515bd8deadSopenharmony_ci</thead>
160525bd8deadSopenharmony_ci<tbody>
160535bd8deadSopenharmony_ci<tr>
160545bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>dFdx</strong>(genFType <em>p</em>)</p></td>
160555bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns either <strong>dFdxFine</strong>(<em>p</em>) or <strong>dFdxCoarse</strong>(<em>p</em>), based on
160565bd8deadSopenharmony_ci      implementation choice, presumably whichever is the faster, or by whichever
160575bd8deadSopenharmony_ci      is selected in the API through quality-versus-speed hints.</p></td>
160585bd8deadSopenharmony_ci</tr>
160595bd8deadSopenharmony_ci<tr>
160605bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>dFdy</strong>(genFType <em>p</em>)</p></td>
160615bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns either <strong>dFdyFine</strong>(<em>p</em>) or <strong>dFdyCoarse</strong>(<em>p</em>), based on
160625bd8deadSopenharmony_ci      implementation choice, presumably whichever is the faster, or by
160635bd8deadSopenharmony_ci      whichever is selected in the API through quality-versus-speed hints.</p></td>
160645bd8deadSopenharmony_ci</tr>
160655bd8deadSopenharmony_ci<tr>
160665bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>dFdxFine</strong>(genFType <em>p</em>)</p></td>
160675bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the partial derivative of <em>p</em> with respect to the window x
160685bd8deadSopenharmony_ci      coordinate.
160695bd8deadSopenharmony_ci      Will use local differencing based on the value of <em>p</em> for the current
160705bd8deadSopenharmony_ci      fragment and its immediate neighbor(s).</p></td>
160715bd8deadSopenharmony_ci</tr>
160725bd8deadSopenharmony_ci<tr>
160735bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>dFdyFine</strong>(genFType <em>p</em>)</p></td>
160745bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the partial derivative of <em>p</em> with respect to the window y
160755bd8deadSopenharmony_ci      coordinate.
160765bd8deadSopenharmony_ci      Will use local differencing based on the value of <em>p</em> for the current
160775bd8deadSopenharmony_ci      fragment and its immediate neighbor(s).</p></td>
160785bd8deadSopenharmony_ci</tr>
160795bd8deadSopenharmony_ci<tr>
160805bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>dFdxCoarse</strong>(genFType <em>p</em>)</p></td>
160815bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the partial derivative of <em>p</em> with respect to the window x
160825bd8deadSopenharmony_ci      coordinate.
160835bd8deadSopenharmony_ci      Will use local differencing based on the value of <em>p</em> for the current
160845bd8deadSopenharmony_ci      fragment&#8217;s neighbors, and will possibly, but not necessarily, include
160855bd8deadSopenharmony_ci      the value of <em>p</em> for the current fragment.
160865bd8deadSopenharmony_ci      That is, over a given area, the implementation can x compute
160875bd8deadSopenharmony_ci      derivatives in fewer unique locations than would be allowed for
160885bd8deadSopenharmony_ci      <strong>dFdxFine</strong>(<em>p</em>).</p></td>
160895bd8deadSopenharmony_ci</tr>
160905bd8deadSopenharmony_ci<tr>
160915bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>dFdyCoarse</strong>(genFType <em>p</em>)</p></td>
160925bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the partial derivative of <em>p</em> with respect to the window y
160935bd8deadSopenharmony_ci      coordinate.
160945bd8deadSopenharmony_ci      Will use local differencing based on the value of <em>p</em> for the current
160955bd8deadSopenharmony_ci      fragment&#8217;s neighbors, and will possibly, but not necessarily, include
160965bd8deadSopenharmony_ci      the value of <em>p</em> for the current fragment.
160975bd8deadSopenharmony_ci      That is, over a given area, the implementation can compute y
160985bd8deadSopenharmony_ci      derivatives in fewer unique locations than would be allowed for
160995bd8deadSopenharmony_ci      <strong>dFdyFine</strong>(<em>p</em>).</p></td>
161005bd8deadSopenharmony_ci</tr>
161015bd8deadSopenharmony_ci<tr>
161025bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>fwidth</strong>(genFType <em>p</em>)</p></td>
161035bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <strong>abs</strong>(<strong>dFdx</strong>(<em>p</em>)) + <strong>abs</strong>(<strong>dFdy</strong>(<em>p</em>)).</p></td>
161045bd8deadSopenharmony_ci</tr>
161055bd8deadSopenharmony_ci<tr>
161065bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>fwidthFine</strong>(genFType <em>p</em>)</p></td>
161075bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <strong>abs</strong>(<strong>dFdxFine</strong>(<em>p</em>)) + <strong>abs</strong>(<strong>dFdyFine</strong>(<em>p</em>)).</p></td>
161085bd8deadSopenharmony_ci</tr>
161095bd8deadSopenharmony_ci<tr>
161105bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">genFType <strong>fwidthCoarse</strong>(genFType <em>p</em>)</p></td>
161115bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <strong>abs</strong>(<strong>dFdxCoarse</strong>(<em>p</em>)) + <strong>abs</strong>(<strong>dFdyCoarse</strong>(<em>p</em>)).</p></td>
161125bd8deadSopenharmony_ci</tr>
161135bd8deadSopenharmony_ci</tbody>
161145bd8deadSopenharmony_ci</table>
161155bd8deadSopenharmony_ci</div>
161165bd8deadSopenharmony_ci<div class="sect3">
161175bd8deadSopenharmony_ci<h4 id="interpolation-functions">8.14.2. Interpolation Functions</h4>
161185bd8deadSopenharmony_ci<div class="paragraph">
161195bd8deadSopenharmony_ci<p>Built-in interpolation functions are available to compute an interpolated
161205bd8deadSopenharmony_civalue of a fragment shader input variable at a shader-specified (<em>x</em>, <em>y</em>)
161215bd8deadSopenharmony_cilocation.
161225bd8deadSopenharmony_ciA separate (<em>x</em>, <em>y</em>) location may be used for each invocation of the
161235bd8deadSopenharmony_cibuilt-in function, and those locations may differ from the default (<em>x</em>,
161245bd8deadSopenharmony_ci<em>y</em>) location used to produce the default value of the input.</p>
161255bd8deadSopenharmony_ci</div>
161265bd8deadSopenharmony_ci<div class="paragraph">
161275bd8deadSopenharmony_ci<p>For all of the interpolation functions, <em>interpolant</em> must be an l-value
161285bd8deadSopenharmony_cifrom an <strong>in</strong> declaration;
161295bd8deadSopenharmony_cithis can include a variable, a block or structure member, an array element, or
161305bd8deadSopenharmony_cisome combination of these.
161315bd8deadSopenharmony_ciAdditionally, component selection operators (e.g. <strong>.xy</strong>, <strong>.xxz</strong>) may be applied
161325bd8deadSopenharmony_cito <em>interpolant</em>, in which case the interpolation function will return the
161335bd8deadSopenharmony_ciresult of applying the component selection operator to the interpolated value
161345bd8deadSopenharmony_ciof <em>interpolant</em> (for example, interpolateAt(v.xxz) is defined to return
161355bd8deadSopenharmony_ciinterpolateAt(v).xxz).
161365bd8deadSopenharmony_ciArrayed inputs can be indexed with general (nonuniform) integer expressions.</p>
161375bd8deadSopenharmony_ci</div>
161385bd8deadSopenharmony_ci<div class="paragraph">
161395bd8deadSopenharmony_ci<p>If <em>interpolant</em> is declared with the <strong>flat</strong> qualifier, the interpolated
161405bd8deadSopenharmony_civalue will have the same value everywhere for a single primitive, so the
161415bd8deadSopenharmony_cilocation used for interpolation has no effect and the functions just return
161425bd8deadSopenharmony_cithat same value.
161435bd8deadSopenharmony_ciIf <em>interpolant</em> is declared with the <strong>centroid</strong> qualifier, the value
161445bd8deadSopenharmony_cireturned by <strong>interpolateAtSample</strong>() and <strong>interpolateAtOffset</strong>() will be
161455bd8deadSopenharmony_cievaluated at the specified location, ignoring the location normally used
161465bd8deadSopenharmony_ciwith the <strong>centroid</strong> qualifier.
161475bd8deadSopenharmony_ciIf <em>interpolant</em> is declared with the <strong>noperspective</strong> qualifier, the
161485bd8deadSopenharmony_ciinterpolated value will be computed without perspective correction.</p>
161495bd8deadSopenharmony_ci</div>
161505bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
161515bd8deadSopenharmony_ci<colgroup>
161525bd8deadSopenharmony_ci<col style="width: 50%;">
161535bd8deadSopenharmony_ci<col style="width: 50%;">
161545bd8deadSopenharmony_ci</colgroup>
161555bd8deadSopenharmony_ci<thead>
161565bd8deadSopenharmony_ci<tr>
161575bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
161585bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
161595bd8deadSopenharmony_ci</tr>
161605bd8deadSopenharmony_ci</thead>
161615bd8deadSopenharmony_ci<tbody>
161625bd8deadSopenharmony_ci<tr>
161635bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">float <strong>interpolateAtCentroid</strong>(float <em>interpolant</em>)<br>
161645bd8deadSopenharmony_ci  vec2 <strong>interpolateAtCentroid</strong>(vec2 <em>interpolant</em>)<br>
161655bd8deadSopenharmony_ci  vec3 <strong>interpolateAtCentroid</strong>(vec3 <em>interpolant</em>)<br>
161665bd8deadSopenharmony_ci  vec4 <strong>interpolateAtCentroid</strong>(vec4 <em>interpolant</em>)</p></td>
161675bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the value of the input <em>interpolant</em> sampled at a location
161685bd8deadSopenharmony_ci      inside both the pixel and the primitive being processed.
161695bd8deadSopenharmony_ci      The value obtained would be the same value assigned to the input
161705bd8deadSopenharmony_ci      variable if declared with the <strong>centroid</strong> qualifier.</p></td>
161715bd8deadSopenharmony_ci</tr>
161725bd8deadSopenharmony_ci<tr>
161735bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">float <strong>interpolateAtSample</strong>(float <em>interpolant</em>, int <em>sample</em>)<br>
161745bd8deadSopenharmony_ci  vec2 <strong>interpolateAtSample</strong>(vec2 <em>interpolant</em>, int <em>sample</em>)<br>
161755bd8deadSopenharmony_ci  vec3 <strong>interpolateAtSample</strong>(vec3 <em>interpolant</em>, int <em>sample</em>)<br>
161765bd8deadSopenharmony_ci  vec4 <strong>interpolateAtSample</strong>(vec4 <em>interpolant</em>, int <em>sample</em>)</p></td>
161775bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the value of the input <em>interpolant</em> variable at the location
161785bd8deadSopenharmony_ci      of sample number <em>sample</em>.
161795bd8deadSopenharmony_ci      If multisample buffers are not available, the input variable will be
161805bd8deadSopenharmony_ci      evaluated at the center of the pixel.
161815bd8deadSopenharmony_ci      If sample <em>sample</em> does not exist, the position used to interpolate
161825bd8deadSopenharmony_ci      the input variable is undefined.</p></td>
161835bd8deadSopenharmony_ci</tr>
161845bd8deadSopenharmony_ci<tr>
161855bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">float <strong>interpolateAtOffset</strong>(float <em>interpolant</em>, vec2 offset)<br>
161865bd8deadSopenharmony_ci  vec2 <strong>interpolateAtOffset</strong>(vec2 <em>interpolant</em>, vec2 offset)<br>
161875bd8deadSopenharmony_ci  vec3 <strong>interpolateAtOffset</strong>(vec3 <em>interpolant</em>, vec2 offset)<br>
161885bd8deadSopenharmony_ci  vec4 <strong>interpolateAtOffset</strong>(vec4 <em>interpolant</em>, vec2 offset)</p></td>
161895bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the value of the input <em>interpolant</em> variable sampled at an
161905bd8deadSopenharmony_ci      offset from the center of the pixel specified by <em>offset</em>.
161915bd8deadSopenharmony_ci      The two floating-point components of <em>offset</em>, give the offset in
161925bd8deadSopenharmony_ci      pixels in the <em>x</em> and <em>y</em> directions, respectively.<br>
161935bd8deadSopenharmony_ci      An offset of (0, 0) identifies the center of the pixel.
161945bd8deadSopenharmony_ci      The range and granularity of offsets supported by this function is
161955bd8deadSopenharmony_ci      implementation-dependent.</p></td>
161965bd8deadSopenharmony_ci</tr>
161975bd8deadSopenharmony_ci</tbody>
161985bd8deadSopenharmony_ci</table>
161995bd8deadSopenharmony_ci</div>
162005bd8deadSopenharmony_ci</div>
162015bd8deadSopenharmony_ci<div class="sect2">
162025bd8deadSopenharmony_ci<h3 id="noise-functions">8.15. Noise Functions</h3>
162035bd8deadSopenharmony_ci<div class="paragraph">
162045bd8deadSopenharmony_ci<p>The noise functions <strong>noise1</strong>, <strong>noise2</strong>, <strong>noise3</strong>, and <strong>noise4</strong> have been
162055bd8deadSopenharmony_cideprecated starting with version 4.4 of GLSL.
162065bd8deadSopenharmony_ciWhen not generating SPIR-V they are defined to return the value 0.0 or a vector
162075bd8deadSopenharmony_ciwhose components are all 0.0. When generating SPIR-V the noise functions are
162085bd8deadSopenharmony_cinot declared and may not be used.</p>
162095bd8deadSopenharmony_ci</div>
162105bd8deadSopenharmony_ci<div class="paragraph">
162115bd8deadSopenharmony_ci<p>As in previous releases, the noise functions are not semantically considered to
162125bd8deadSopenharmony_cibe compile-time constant expressions.</p>
162135bd8deadSopenharmony_ci</div>
162145bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
162155bd8deadSopenharmony_ci<colgroup>
162165bd8deadSopenharmony_ci<col style="width: 50%;">
162175bd8deadSopenharmony_ci<col style="width: 50%;">
162185bd8deadSopenharmony_ci</colgroup>
162195bd8deadSopenharmony_ci<thead>
162205bd8deadSopenharmony_ci<tr>
162215bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax (deprecated)</th>
162225bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description (deprecated)</th>
162235bd8deadSopenharmony_ci</tr>
162245bd8deadSopenharmony_ci</thead>
162255bd8deadSopenharmony_ci<tbody>
162265bd8deadSopenharmony_ci<tr>
162275bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">float <strong>noise1</strong>(genFType <em>x</em>)</p></td>
162285bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a 1D noise value based on the input value <em>x</em>.</p></td>
162295bd8deadSopenharmony_ci</tr>
162305bd8deadSopenharmony_ci<tr>
162315bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">vec2 <strong>noise2</strong>(genFType <em>x</em>)</p></td>
162325bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a 2D noise value based on the input value <em>x</em>.</p></td>
162335bd8deadSopenharmony_ci</tr>
162345bd8deadSopenharmony_ci<tr>
162355bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">vec3 <strong>noise3</strong>(genFType <em>x</em>)</p></td>
162365bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a 3D noise value based on the input value <em>x</em>.</p></td>
162375bd8deadSopenharmony_ci</tr>
162385bd8deadSopenharmony_ci<tr>
162395bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">vec4 <strong>noise4</strong>(genFType <em>x</em>)</p></td>
162405bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a 4D noise value based on the input value <em>x</em>.</p></td>
162415bd8deadSopenharmony_ci</tr>
162425bd8deadSopenharmony_ci</tbody>
162435bd8deadSopenharmony_ci</table>
162445bd8deadSopenharmony_ci</div>
162455bd8deadSopenharmony_ci<div class="sect2">
162465bd8deadSopenharmony_ci<h3 id="shader-invocation-control-functions">8.16. Shader Invocation Control Functions</h3>
162475bd8deadSopenharmony_ci<div class="paragraph">
162485bd8deadSopenharmony_ci<p>The shader invocation control function is only available in tessellation
162495bd8deadSopenharmony_cicontrol and compute shaders.
162505bd8deadSopenharmony_ciIt is used to control the relative execution order of multiple shader
162515bd8deadSopenharmony_ciinvocations used to process a patch (in the case of tessellation control
162525bd8deadSopenharmony_cishaders) or a workgroup (in the case of compute shaders), which are
162535bd8deadSopenharmony_ciotherwise executed with an undefined relative order.</p>
162545bd8deadSopenharmony_ci</div>
162555bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
162565bd8deadSopenharmony_ci<colgroup>
162575bd8deadSopenharmony_ci<col style="width: 50%;">
162585bd8deadSopenharmony_ci<col style="width: 50%;">
162595bd8deadSopenharmony_ci</colgroup>
162605bd8deadSopenharmony_ci<thead>
162615bd8deadSopenharmony_ci<tr>
162625bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
162635bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
162645bd8deadSopenharmony_ci</tr>
162655bd8deadSopenharmony_ci</thead>
162665bd8deadSopenharmony_ci<tbody>
162675bd8deadSopenharmony_ci<tr>
162685bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>barrier</strong>()</p></td>
162695bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">For any given static instance of <strong>barrier</strong>(), all tessellation control
162705bd8deadSopenharmony_ci      shader invocations for a single input patch must enter it before any
162715bd8deadSopenharmony_ci      will be allowed to continue beyond it, or all compute shader
162725bd8deadSopenharmony_ci      invocations for a single workgroup must enter it before any will
162735bd8deadSopenharmony_ci      continue beyond it.</p></td>
162745bd8deadSopenharmony_ci</tr>
162755bd8deadSopenharmony_ci</tbody>
162765bd8deadSopenharmony_ci</table>
162775bd8deadSopenharmony_ci<div class="paragraph">
162785bd8deadSopenharmony_ci<p>The function <strong>barrier</strong>() provides a partially defined order of execution
162795bd8deadSopenharmony_cibetween shader invocations.
162805bd8deadSopenharmony_ciThe ensures that, for some types of memory accesses, values written by one
162815bd8deadSopenharmony_ciinvocation prior to a given static instance of <strong>barrier</strong>() can be safely read
162825bd8deadSopenharmony_ciby other invocations after their call to the same static instance <strong>barrier</strong>().
162835bd8deadSopenharmony_ciBecause invocations may execute in an undefined order between these barrier
162845bd8deadSopenharmony_cicalls, the values of a per-vertex or per-patch output variable for tessellation
162855bd8deadSopenharmony_cicontrol shaders, or the values of <strong>shared</strong> variables for compute shaders will be
162865bd8deadSopenharmony_ciundefined in a number of cases enumerated in
162875bd8deadSopenharmony_ci&#8220;<a href="#output-variables">Output Variables</a>&#8221; (for tessellation control shaders)
162885bd8deadSopenharmony_ciand &#8220;<a href="#shared-variables">Shared Variables</a>&#8221; (for compute shaders).</p>
162895bd8deadSopenharmony_ci</div>
162905bd8deadSopenharmony_ci<div class="paragraph">
162915bd8deadSopenharmony_ci<p>For tessellation control shaders, the <strong>barrier</strong>() function may only be
162925bd8deadSopenharmony_ciplaced inside the function <strong>main</strong>() of the shader and may not be called
162935bd8deadSopenharmony_ciwithin any control flow.
162945bd8deadSopenharmony_ciBarriers are also disallowed after a return statement in the function
162955bd8deadSopenharmony_ci<strong>main</strong>().
162965bd8deadSopenharmony_ciAny such misplaced barriers result in a compile-time error.</p>
162975bd8deadSopenharmony_ci</div>
162985bd8deadSopenharmony_ci<div class="paragraph">
162995bd8deadSopenharmony_ci<p>A <strong>barrier</strong>() affects control flow but only synchronizes memory accesses
163005bd8deadSopenharmony_cito <strong>shared</strong> variables and tessellation control output variables.
163015bd8deadSopenharmony_ciFor other memory accesses, it does not ensure that values written by one invocation
163025bd8deadSopenharmony_ciprior to a given static instance of <strong>barrier</strong>() can be safely read by other
163035bd8deadSopenharmony_ciinvocations after their call to the same static instance of <strong>barrier</strong>().
163045bd8deadSopenharmony_ciTo achieve this requires the use of both <strong>barrier</strong>() and a memory barrier.</p>
163055bd8deadSopenharmony_ci</div>
163065bd8deadSopenharmony_ci<div class="paragraph">
163075bd8deadSopenharmony_ci<p>For compute shaders, the <strong>barrier</strong>() function may be placed within control
163085bd8deadSopenharmony_ciflow, but that control flow must be uniform control flow.
163095bd8deadSopenharmony_ciThat is, all the controlling expressions that lead to execution of the
163105bd8deadSopenharmony_cibarrier must be dynamically uniform expressions.
163115bd8deadSopenharmony_ciThis ensures that if any shader invocation enters a conditional statement,
163125bd8deadSopenharmony_cithen all invocations will enter it.
163135bd8deadSopenharmony_ciWhile compilers are encouraged to give warnings if they can detect this
163145bd8deadSopenharmony_cimight not happen, compilers cannot completely determine this.
163155bd8deadSopenharmony_ciHence, it is the author&#8217;s responsibility to ensure <strong>barrier</strong>() only exists
163165bd8deadSopenharmony_ciinside uniform control flow.
163175bd8deadSopenharmony_ciOtherwise, some shader invocations will stall indefinitely, waiting for a
163185bd8deadSopenharmony_cibarrier that is never reached by other invocations.</p>
163195bd8deadSopenharmony_ci</div>
163205bd8deadSopenharmony_ci</div>
163215bd8deadSopenharmony_ci<div class="sect2">
163225bd8deadSopenharmony_ci<h3 id="shader-memory-control-functions">8.17. Shader Memory Control Functions</h3>
163235bd8deadSopenharmony_ci<div class="paragraph">
163245bd8deadSopenharmony_ci<p>Within a single shader invocation, the visibility and order of writes made
163255bd8deadSopenharmony_ciby that invocation are well-defined.
163265bd8deadSopenharmony_ciHowever, the relative order of reads and writes to a single shared memory
163275bd8deadSopenharmony_ciaddress from multiple separate shader invocations is largely undefined.
163285bd8deadSopenharmony_ciAdditionally, the order of accesses to multiple memory addresses performed
163295bd8deadSopenharmony_ciby a single shader invocation, as observed by other shader invocations, is
163305bd8deadSopenharmony_cialso undefined.</p>
163315bd8deadSopenharmony_ci</div>
163325bd8deadSopenharmony_ci<div class="paragraph">
163335bd8deadSopenharmony_ci<p>The following built-in functions can be used to control the ordering of
163345bd8deadSopenharmony_cireads and writes:</p>
163355bd8deadSopenharmony_ci</div>
163365bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
163375bd8deadSopenharmony_ci<colgroup>
163385bd8deadSopenharmony_ci<col style="width: 50%;">
163395bd8deadSopenharmony_ci<col style="width: 50%;">
163405bd8deadSopenharmony_ci</colgroup>
163415bd8deadSopenharmony_ci<thead>
163425bd8deadSopenharmony_ci<tr>
163435bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
163445bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
163455bd8deadSopenharmony_ci</tr>
163465bd8deadSopenharmony_ci</thead>
163475bd8deadSopenharmony_ci<tbody>
163485bd8deadSopenharmony_ci<tr>
163495bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>memoryBarrier</strong>()</p></td>
163505bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Control the ordering of memory transactions issued by a single shader
163515bd8deadSopenharmony_ci      invocation.</p></td>
163525bd8deadSopenharmony_ci</tr>
163535bd8deadSopenharmony_ci<tr>
163545bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>memoryBarrierAtomicCounter</strong>()</p></td>
163555bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Control the ordering of accesses to atomic-counter variables issued by
163565bd8deadSopenharmony_ci      a single shader invocation.</p></td>
163575bd8deadSopenharmony_ci</tr>
163585bd8deadSopenharmony_ci<tr>
163595bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>memoryBarrierBuffer</strong>()</p></td>
163605bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Control the ordering of memory transactions to buffer variables issued
163615bd8deadSopenharmony_ci      within a single shader invocation.</p></td>
163625bd8deadSopenharmony_ci</tr>
163635bd8deadSopenharmony_ci<tr>
163645bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>memoryBarrierShared</strong>()</p></td>
163655bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Control the ordering of memory transactions to shared variables issued
163665bd8deadSopenharmony_ci      within a single shader invocation, as viewed by other invocations in
163675bd8deadSopenharmony_ci      the same workgroup.<br>
163685bd8deadSopenharmony_ci      Only available in compute shaders.</p></td>
163695bd8deadSopenharmony_ci</tr>
163705bd8deadSopenharmony_ci<tr>
163715bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>memoryBarrierImage</strong>()</p></td>
163725bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Control the ordering of memory transactions to images issued within a
163735bd8deadSopenharmony_ci      single shader invocation.</p></td>
163745bd8deadSopenharmony_ci</tr>
163755bd8deadSopenharmony_ci<tr>
163765bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>groupMemoryBarrier</strong>()</p></td>
163775bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Control the ordering of all memory transactions issued within a single
163785bd8deadSopenharmony_ci      shader invocation, as viewed by other invocations in the same workgroup.<br>
163795bd8deadSopenharmony_ci      Only available in compute shaders.</p></td>
163805bd8deadSopenharmony_ci</tr>
163815bd8deadSopenharmony_ci</tbody>
163825bd8deadSopenharmony_ci</table>
163835bd8deadSopenharmony_ci<div class="paragraph">
163845bd8deadSopenharmony_ci<p>The memory barrier built-in functions can be used to order reads and writes
163855bd8deadSopenharmony_cito variables stored in memory accessible to other shader invocations.
163865bd8deadSopenharmony_ciWhen called, these functions will wait for the completion of all reads and
163875bd8deadSopenharmony_ciwrites previously performed by the caller that access selected variable
163885bd8deadSopenharmony_citypes, and then return with no other effect.
163895bd8deadSopenharmony_ciThe built-in functions <strong>memoryBarrierAtomicCounter</strong>(),
163905bd8deadSopenharmony_ci<strong>memoryBarrierBuffer</strong>(), <strong>memoryBarrierImage</strong>(), and <strong>memoryBarrierShared</strong>()
163915bd8deadSopenharmony_ciwait for the completion of accesses to atomic counter, buffer, image, and
163925bd8deadSopenharmony_cishared variables, respectively.
163935bd8deadSopenharmony_ciThe built-in functions <strong>memoryBarrier</strong>() and <strong>groupMemoryBarrier</strong>() wait for
163945bd8deadSopenharmony_cithe completion of accesses to all of the above variable types.
163955bd8deadSopenharmony_ciThe functions <strong>memoryBarrierShared</strong>() and <strong>groupMemoryBarrier</strong>() are
163965bd8deadSopenharmony_ciavailable only in compute shaders; the other functions are available in all
163975bd8deadSopenharmony_cishader types.</p>
163985bd8deadSopenharmony_ci</div>
163995bd8deadSopenharmony_ci<div class="paragraph">
164005bd8deadSopenharmony_ci<p>When these functions return, the effects of any memory stores performed
164015bd8deadSopenharmony_ciusing coherent variables prior to the call will be visible to any
164025bd8deadSopenharmony_cifuture<sup>1</sup> coherent access to the same memory performed by any other shader
164035bd8deadSopenharmony_ciinvocation.
164045bd8deadSopenharmony_ciIn particular, the values written this way in one shader stage are
164055bd8deadSopenharmony_ciguaranteed to be visible to coherent memory accesses performed by shader
164065bd8deadSopenharmony_ciinvocations in subsequent stages when those invocations were triggered by
164075bd8deadSopenharmony_cithe execution of the original shader invocation (e.g. fragment shader
164085bd8deadSopenharmony_ciinvocations for a primitive resulting from a particular geometry
164095bd8deadSopenharmony_cishader invocation).</p>
164105bd8deadSopenharmony_ci</div>
164115bd8deadSopenharmony_ci<div class="dlist">
164125bd8deadSopenharmony_ci<dl>
164135bd8deadSopenharmony_ci<dt class="hdlist1">1</dt>
164145bd8deadSopenharmony_ci<dd>
164155bd8deadSopenharmony_ci<p>An access is only a <em>future</em> access if a <em>happens-before</em> relation can
164165bd8deadSopenharmony_cibe established between the store and the load.</p>
164175bd8deadSopenharmony_ci</dd>
164185bd8deadSopenharmony_ci</dl>
164195bd8deadSopenharmony_ci</div>
164205bd8deadSopenharmony_ci<div class="paragraph">
164215bd8deadSopenharmony_ci<p>Additionally, memory barrier functions order stores performed by the calling
164225bd8deadSopenharmony_ciinvocation, as observed by other shader invocations.
164235bd8deadSopenharmony_ciWithout memory barriers, if one shader invocation performs two stores to
164245bd8deadSopenharmony_cicoherent variables, a second shader invocation might see the values written
164255bd8deadSopenharmony_ciby the second store prior to seeing those written by the first.
164265bd8deadSopenharmony_ciHowever, if the first shader invocation calls a memory barrier function
164275bd8deadSopenharmony_cibetween the two stores, selected other shader invocations will never see the
164285bd8deadSopenharmony_ciresults of the second store before seeing those of the first.
164295bd8deadSopenharmony_ciWhen using the functions <strong>groupMemoryBarrier</strong>() or <strong>memoryBarrierShared</strong>(),
164305bd8deadSopenharmony_cithis ordering guarantee applies only to other shader invocations in the same
164315bd8deadSopenharmony_cicompute shader workgroup; all other memory barrier functions provide the
164325bd8deadSopenharmony_ciguarantee to all other shader invocations.
164335bd8deadSopenharmony_ciNo memory barrier is required to guarantee the order of memory stores as
164345bd8deadSopenharmony_ciobserved by the invocation performing the stores; an invocation reading from
164355bd8deadSopenharmony_cia variable that it previously wrote will always see the most recently
164365bd8deadSopenharmony_ciwritten value unless another shader invocation also wrote to the same
164375bd8deadSopenharmony_cimemory.</p>
164385bd8deadSopenharmony_ci</div>
164395bd8deadSopenharmony_ci</div>
164405bd8deadSopenharmony_ci<div class="sect2">
164415bd8deadSopenharmony_ci<h3 id="_subpass_input_functions">8.18. Subpass-Input Functions</h3>
164425bd8deadSopenharmony_ci<div class="paragraph">
164435bd8deadSopenharmony_ci<p>Subpass-input functions are only available when targeting a Vulkan fragment stage.</p>
164445bd8deadSopenharmony_ci</div>
164455bd8deadSopenharmony_ci<div class="paragraph">
164465bd8deadSopenharmony_ci<p>Subpass inputs are read through the built-in functions below. The <code>g</code> is again
164475bd8deadSopenharmony_cia placeholder for either nothing, <code>i</code>, or <code>u</code>, indicating either a floating-point,
164485bd8deadSopenharmony_cisigned integer, or unsigned integer, and these must match between argument type
164495bd8deadSopenharmony_ciand return type.</p>
164505bd8deadSopenharmony_ci</div>
164515bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
164525bd8deadSopenharmony_ci<colgroup>
164535bd8deadSopenharmony_ci<col style="width: 50%;">
164545bd8deadSopenharmony_ci<col style="width: 50%;">
164555bd8deadSopenharmony_ci</colgroup>
164565bd8deadSopenharmony_ci<thead>
164575bd8deadSopenharmony_ci<tr>
164585bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
164595bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
164605bd8deadSopenharmony_ci</tr>
164615bd8deadSopenharmony_ci</thead>
164625bd8deadSopenharmony_ci<tbody>
164635bd8deadSopenharmony_ci<tr>
164645bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">gvec4 <strong>subpassLoad</strong>(gsubpassInput subpass)<br>
164655bd8deadSopenharmony_ci  gvec4 <strong>subpassLoad</strong>(gsubpassInputMS subpass, int sample)</p></td>
164665bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Read from a subpass input, from the implicit location <em>(x, y, layer)</em>
164675bd8deadSopenharmony_ci      of the current fragment coordinate.</p></td>
164685bd8deadSopenharmony_ci</tr>
164695bd8deadSopenharmony_ci</tbody>
164705bd8deadSopenharmony_ci</table>
164715bd8deadSopenharmony_ci</div>
164725bd8deadSopenharmony_ci<div class="sect2">
164735bd8deadSopenharmony_ci<h3 id="shader-invocation-group-functions">8.19. Shader Invocation Group Functions</h3>
164745bd8deadSopenharmony_ci<div class="paragraph">
164755bd8deadSopenharmony_ci<p>Implementations of the OpenGL Shading Language may optionally group multiple shader
164765bd8deadSopenharmony_ciinvocations for a single shader stage into a single SIMD invocation group,
164775bd8deadSopenharmony_ciwhere invocations are assigned to groups in an undefined,
164785bd8deadSopenharmony_ciimplementation-dependent manner.
164795bd8deadSopenharmony_ciShader algorithms on such implementations may benefit from being able to
164805bd8deadSopenharmony_cievaluate a composite of Boolean values over all active invocations in a
164815bd8deadSopenharmony_cigroup.</p>
164825bd8deadSopenharmony_ci</div>
164835bd8deadSopenharmony_ci<table class="tableblock frame-all grid-all stretch">
164845bd8deadSopenharmony_ci<colgroup>
164855bd8deadSopenharmony_ci<col style="width: 50%;">
164865bd8deadSopenharmony_ci<col style="width: 50%;">
164875bd8deadSopenharmony_ci</colgroup>
164885bd8deadSopenharmony_ci<thead>
164895bd8deadSopenharmony_ci<tr>
164905bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Syntax</th>
164915bd8deadSopenharmony_ci<th class="tableblock halign-left valign-top">Description</th>
164925bd8deadSopenharmony_ci</tr>
164935bd8deadSopenharmony_ci</thead>
164945bd8deadSopenharmony_ci<tbody>
164955bd8deadSopenharmony_ci<tr>
164965bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bool <strong>anyInvocation</strong>(bool <em>value</em>)</p></td>
164975bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <strong>true</strong> if and only if <em>value</em> is <strong>true</strong> for at least one
164985bd8deadSopenharmony_ci      active invocation in the group.</p></td>
164995bd8deadSopenharmony_ci</tr>
165005bd8deadSopenharmony_ci<tr>
165015bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bool <strong>allInvocations</strong>(bool <em>value</em>)</p></td>
165025bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <strong>true</strong> if and only if <em>value</em> is <strong>true</strong> for all active
165035bd8deadSopenharmony_ci      invocations in the group.</p></td>
165045bd8deadSopenharmony_ci</tr>
165055bd8deadSopenharmony_ci<tr>
165065bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">bool <strong>allInvocationsEqual</strong>(bool <em>value</em>)</p></td>
165075bd8deadSopenharmony_ci<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <strong>true</strong> if <em>value</em> is the same for all active invocations in
165085bd8deadSopenharmony_ci      the group.</p></td>
165095bd8deadSopenharmony_ci</tr>
165105bd8deadSopenharmony_ci</tbody>
165115bd8deadSopenharmony_ci</table>
165125bd8deadSopenharmony_ci<div class="paragraph">
165135bd8deadSopenharmony_ci<p>For all of these functions, the same result is returned to all active
165145bd8deadSopenharmony_ciinvocations in the group.</p>
165155bd8deadSopenharmony_ci</div>
165165bd8deadSopenharmony_ci<div class="paragraph">
165175bd8deadSopenharmony_ci<p>These functions may be called within conditionally executed code.
165185bd8deadSopenharmony_ciIn groups where some invocations do not execute the function call, the value
165195bd8deadSopenharmony_cireturned by the function is not affected by any invocation not calling the
165205bd8deadSopenharmony_cifunction, even when value is well-defined for that invocation.</p>
165215bd8deadSopenharmony_ci</div>
165225bd8deadSopenharmony_ci<div class="paragraph">
165235bd8deadSopenharmony_ci<p>Because these functions depend on the values of <em>value</em> in an undefined
165245bd8deadSopenharmony_cigroup of invocations, the value returned by these functions is largely
165255bd8deadSopenharmony_ciundefined.
165265bd8deadSopenharmony_ciHowever, <strong>anyInvocation</strong>() is guaranteed to return <strong>true</strong> if <em>value</em> is
165275bd8deadSopenharmony_ci<strong>true</strong>, and <strong>allInvocations</strong>() is guaranteed to return <strong>false</strong> if <em>value</em> is
165285bd8deadSopenharmony_ci<strong>false</strong>.</p>
165295bd8deadSopenharmony_ci</div>
165305bd8deadSopenharmony_ci<div class="paragraph">
165315bd8deadSopenharmony_ci<p>Because implementations are not required to combine invocations into groups,
165325bd8deadSopenharmony_cisimply returning <em>value</em> for <strong>anyInvocation</strong>() and <strong>allInvocations</strong>() and
165335bd8deadSopenharmony_cireturning true for <strong>allInvocationsEqual</strong>() is a legal implementation of
165345bd8deadSopenharmony_cithese functions.</p>
165355bd8deadSopenharmony_ci</div>
165365bd8deadSopenharmony_ci<div class="paragraph">
165375bd8deadSopenharmony_ci<p>For fragment shaders, invocations in a SIMD invocation group may include
165385bd8deadSopenharmony_ciinvocations corresponding to pixels that are covered by a primitive being
165395bd8deadSopenharmony_cirasterized, as well as invocations corresponding to neighboring pixels not
165405bd8deadSopenharmony_cicovered by the primitive.
165415bd8deadSopenharmony_ci<em>Helper invocations</em> (see &#8220;<a href="#built-in-language-variables">Built-In Language
165425bd8deadSopenharmony_ciVariables</a>&#8221;) may be created and the value of <em>value</em> for such
165435bd8deadSopenharmony_cihelper-invocation pixels may affect the value returned by <strong>anyInvocation</strong>(),
165445bd8deadSopenharmony_ci<strong>allInvocations</strong>(), and <strong>allInvocationsEqual</strong>().</p>
165455bd8deadSopenharmony_ci</div>
165465bd8deadSopenharmony_ci</div>
165475bd8deadSopenharmony_ci</div>
165485bd8deadSopenharmony_ci</div>
165495bd8deadSopenharmony_ci<div class="sect1">
165505bd8deadSopenharmony_ci<h2 id="shading-language-grammar">9. Shading Language Grammar</h2>
165515bd8deadSopenharmony_ci<div class="sectionbody">
165525bd8deadSopenharmony_ci<div class="paragraph">
165535bd8deadSopenharmony_ci<p>The grammar is fed from the output of lexical analysis.
165545bd8deadSopenharmony_ciThe tokens returned from lexical analysis are</p>
165555bd8deadSopenharmony_ci</div>
165565bd8deadSopenharmony_ci<div class="openblock bnf">
165575bd8deadSopenharmony_ci<div class="content">
165585bd8deadSopenharmony_ci<div class="paragraph">
165595bd8deadSopenharmony_ci<p>CONST BOOL FLOAT INT UINT
165605bd8deadSopenharmony_ciDOUBLE</p>
165615bd8deadSopenharmony_ci</div>
165625bd8deadSopenharmony_ci<div class="paragraph">
165635bd8deadSopenharmony_ci<p>BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 UVEC2 UVEC3 UVEC4 VEC2 VEC3 VEC4</p>
165645bd8deadSopenharmony_ci</div>
165655bd8deadSopenharmony_ci<div class="paragraph">
165665bd8deadSopenharmony_ci<p>MAT2 MAT3 MAT4
165675bd8deadSopenharmony_ciMAT2X2 MAT2X3 MAT2X4
165685bd8deadSopenharmony_ciMAT3X2 MAT3X3 MAT3X4
165695bd8deadSopenharmony_ciMAT4X2 MAT4X3 MAT4X4</p>
165705bd8deadSopenharmony_ci</div>
165715bd8deadSopenharmony_ci<div class="paragraph">
165725bd8deadSopenharmony_ci<p>DVEC2 DVEC3 DVEC4 DMAT2 DMAT3 DMAT4
165735bd8deadSopenharmony_ciDMAT2X2 DMAT2X3 DMAT2X4
165745bd8deadSopenharmony_ciDMAT3X2 DMAT3X3 DMAT3X4
165755bd8deadSopenharmony_ciDMAT4X2 DMAT4X3 DMAT4X4</p>
165765bd8deadSopenharmony_ci</div>
165775bd8deadSopenharmony_ci<div class="paragraph">
165785bd8deadSopenharmony_ci<p>CENTROID IN OUT INOUT UNIFORM PATCH SAMPLE BUFFER SHARED
165795bd8deadSopenharmony_ciCOHERENT VOLATILE RESTRICT READONLY WRITEONLY
165805bd8deadSopenharmony_ciNOPERSPECTIVE
165815bd8deadSopenharmony_ciFLAT SMOOTH LAYOUT</p>
165825bd8deadSopenharmony_ci</div>
165835bd8deadSopenharmony_ci<div class="paragraph">
165845bd8deadSopenharmony_ci<p>ATOMIC_UINT</p>
165855bd8deadSopenharmony_ci</div>
165865bd8deadSopenharmony_ci<div class="paragraph">
165875bd8deadSopenharmony_ci<p>SAMPLER2D SAMPLER3D SAMPLERCUBE SAMPLER2DSHADOW
165885bd8deadSopenharmony_ciSAMPLERCUBESHADOW SAMPLER2DARRAY SAMPLER2DARRAYSHADOW
165895bd8deadSopenharmony_ciISAMPLER2D ISAMPLER3D ISAMPLERCUBE ISAMPLER2DARRAY
165905bd8deadSopenharmony_ciUSAMPLER2D USAMPLER3D USAMPLERCUBE USAMPLER2DARRAY</p>
165915bd8deadSopenharmony_ci</div>
165925bd8deadSopenharmony_ci<div class="paragraph">
165935bd8deadSopenharmony_ci<p>SAMPLER1D SAMPLER1DSHADOW
165945bd8deadSopenharmony_ciSAMPLER1DARRAY SAMPLER1DARRAYSHADOW
165955bd8deadSopenharmony_ciISAMPLER1D ISAMPLER1DARRAY
165965bd8deadSopenharmony_ciUSAMPLER1D USAMPLER1DARRAY
165975bd8deadSopenharmony_ciSAMPLER2DRECT SAMPLER2DRECTSHADOW ISAMPLER2DRECT USAMPLER2DRECT</p>
165985bd8deadSopenharmony_ci</div>
165995bd8deadSopenharmony_ci<div class="paragraph">
166005bd8deadSopenharmony_ci<p>SAMPLERBUFFER ISAMPLERBUFFER USAMPLERBUFFER
166015bd8deadSopenharmony_ciSAMPLERCUBEARRAY SAMPLERCUBEARRAYSHADOW
166025bd8deadSopenharmony_ciISAMPLERCUBEARRAY USAMPLERCUBEARRAY
166035bd8deadSopenharmony_ciSAMPLER2DMS ISAMPLER2DMS USAMPLER2DMS
166045bd8deadSopenharmony_ciSAMPLER2DMSARRAY ISAMPLER2DMSARRAY USAMPLER2DMSARRAY
166055bd8deadSopenharmony_ciIMAGE2D IIMAGE2D UIMAGE2D
166065bd8deadSopenharmony_ciIMAGE3D IIMAGE3D UIMAGE3D
166075bd8deadSopenharmony_ciIMAGECUBE IIMAGECUBE UIMAGECUBE
166085bd8deadSopenharmony_ciIMAGEBUFFER IIMAGEBUFFER UIMAGEBUFFER
166095bd8deadSopenharmony_ciIMAGE2DARRAY IIMAGE2DARRAY UIMAGE2DARRAY
166105bd8deadSopenharmony_ciIMAGECUBEARRAY IIMAGECUBEARRAY UIMAGECUBEARRAY</p>
166115bd8deadSopenharmony_ci</div>
166125bd8deadSopenharmony_ci<div class="paragraph">
166135bd8deadSopenharmony_ci<p>IMAGE1D IIMAGE1D UIMAGE1D
166145bd8deadSopenharmony_ciIMAGE1DARRAY IIMAGE1DARRAY UIMAGE1DARRAY
166155bd8deadSopenharmony_ciIMAGE2DRECT IIMAGE2DRECT UIMAGE2DRECT
166165bd8deadSopenharmony_ciIMAGE2DMS IIMAGE2DMS UIMAGE2DMS
166175bd8deadSopenharmony_ciIMAGE2DMSARRAY IIMAGE2DMSARRAY UIMAGE2DMSARRAY</p>
166185bd8deadSopenharmony_ci</div>
166195bd8deadSopenharmony_ci<div class="paragraph">
166205bd8deadSopenharmony_ci<p>STRUCT VOID</p>
166215bd8deadSopenharmony_ci</div>
166225bd8deadSopenharmony_ci<div class="paragraph">
166235bd8deadSopenharmony_ci<p>WHILE BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT
166245bd8deadSopenharmony_ciSUBROUTINE</p>
166255bd8deadSopenharmony_ci</div>
166265bd8deadSopenharmony_ci<div class="paragraph">
166275bd8deadSopenharmony_ci<p>IDENTIFIER TYPE_NAME
166285bd8deadSopenharmony_ciFLOATCONSTANT INTCONSTANT UINTCONSTANT BOOLCONSTANT
166295bd8deadSopenharmony_ciDOUBLECONSTANT
166305bd8deadSopenharmony_ciFIELD_SELECTION</p>
166315bd8deadSopenharmony_ci</div>
166325bd8deadSopenharmony_ci<div class="paragraph">
166335bd8deadSopenharmony_ci<p>LEFT_OP RIGHT_OP
166345bd8deadSopenharmony_ciINC_OP DEC_OP LE_OP GE_OP EQ_OP NE_OP
166355bd8deadSopenharmony_ciAND_OP OR_OP XOR_OP MUL_ASSIGN DIV_ASSIGN ADD_ASSIGN
166365bd8deadSopenharmony_ciMOD_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN
166375bd8deadSopenharmony_ciSUB_ASSIGN
166385bd8deadSopenharmony_ciLEFT_PAREN RIGHT_PAREN LEFT_BRACKET RIGHT_BRACKET LEFT_BRACE RIGHT_BRACE DOT
166395bd8deadSopenharmony_ciCOMMA COLON EQUAL SEMICOLON BANG DASH TILDE PLUS STAR SLASH PERCENT
166405bd8deadSopenharmony_ciLEFT_ANGLE RIGHT_ANGLE VERTICAL_BAR CARET AMPERSAND QUESTION</p>
166415bd8deadSopenharmony_ci</div>
166425bd8deadSopenharmony_ci<div class="paragraph">
166435bd8deadSopenharmony_ci<p>INVARIANT PRECISE
166445bd8deadSopenharmony_ciHIGH_PRECISION MEDIUM_PRECISION LOW_PRECISION PRECISION</p>
166455bd8deadSopenharmony_ci</div>
166465bd8deadSopenharmony_ci</div>
166475bd8deadSopenharmony_ci</div>
166485bd8deadSopenharmony_ci<div class="paragraph">
166495bd8deadSopenharmony_ci<p>The following describes the grammar for the OpenGL Shading Language in terms of the above
166505bd8deadSopenharmony_citokens.
166515bd8deadSopenharmony_ciThe starting rule is <em>translation_unit</em>.
166525bd8deadSopenharmony_ciAn empty shader (one having no tokens to parse, after pre-processing) is
166535bd8deadSopenharmony_civalid, resulting in no compile-time errors, even though the grammar below
166545bd8deadSopenharmony_cidoes not have a rule to accept an empty token stream.</p>
166555bd8deadSopenharmony_ci</div>
166565bd8deadSopenharmony_ci<div class="openblock bnf">
166575bd8deadSopenharmony_ci<div class="content">
166585bd8deadSopenharmony_ci<div class="dlist">
166595bd8deadSopenharmony_ci<dl>
166605bd8deadSopenharmony_ci<dt class="hdlist1"><em>variable_identifier</em> : </dt>
166615bd8deadSopenharmony_ci<dd>
166625bd8deadSopenharmony_ci<p><em>IDENTIFIER</em></p>
166635bd8deadSopenharmony_ci</dd>
166645bd8deadSopenharmony_ci<dt class="hdlist1"><em>primary_expression</em> : </dt>
166655bd8deadSopenharmony_ci<dd>
166665bd8deadSopenharmony_ci<p><em>variable_identifier</em><br>
166675bd8deadSopenharmony_ci<em>INTCONSTANT</em><br>
166685bd8deadSopenharmony_ci<em>UINTCONSTANT</em><br>
166695bd8deadSopenharmony_ci<em>FLOATCONSTANT</em><br>
166705bd8deadSopenharmony_ci<em>BOOLCONSTANT</em><br>
166715bd8deadSopenharmony_ci<em>DOUBLECONSTANT</em><br>
166725bd8deadSopenharmony_ci<em>LEFT_PAREN</em> <em>expression</em> <em>RIGHT_PAREN</em></p>
166735bd8deadSopenharmony_ci</dd>
166745bd8deadSopenharmony_ci<dt class="hdlist1"><em>postfix_expression</em> : </dt>
166755bd8deadSopenharmony_ci<dd>
166765bd8deadSopenharmony_ci<p><em>primary_expression</em><br>
166775bd8deadSopenharmony_ci<em>postfix_expression</em> <em>LEFT_BRACKET</em> <em>integer_expression</em> <em>RIGHT_BRACKET</em><br>
166785bd8deadSopenharmony_ci<em>function_call</em><br>
166795bd8deadSopenharmony_ci<em>postfix_expression</em> <em>DOT</em> <em>FIELD_SELECTION</em><br>
166805bd8deadSopenharmony_ci<em>postfix_expression</em> <em>INC_OP</em><br>
166815bd8deadSopenharmony_ci<em>postfix_expression</em> <em>DEC_OP</em></p>
166825bd8deadSopenharmony_ci</dd>
166835bd8deadSopenharmony_ci</dl>
166845bd8deadSopenharmony_ci</div>
166855bd8deadSopenharmony_ci<div class="admonitionblock note">
166865bd8deadSopenharmony_ci<table>
166875bd8deadSopenharmony_ci<tr>
166885bd8deadSopenharmony_ci<td class="icon">
166895bd8deadSopenharmony_ci<i class="fa icon-note" title="Note"></i>
166905bd8deadSopenharmony_ci</td>
166915bd8deadSopenharmony_ci<td class="content">
166925bd8deadSopenharmony_ci<div class="paragraph">
166935bd8deadSopenharmony_ci<p>FIELD_SELECTION includes members in structures, component selection for
166945bd8deadSopenharmony_civectors and the 'length' identifier for the length() method</p>
166955bd8deadSopenharmony_ci</div>
166965bd8deadSopenharmony_ci</td>
166975bd8deadSopenharmony_ci</tr>
166985bd8deadSopenharmony_ci</table>
166995bd8deadSopenharmony_ci</div>
167005bd8deadSopenharmony_ci<div class="dlist">
167015bd8deadSopenharmony_ci<dl>
167025bd8deadSopenharmony_ci<dt class="hdlist1"><em>integer_expression</em> : </dt>
167035bd8deadSopenharmony_ci<dd>
167045bd8deadSopenharmony_ci<p><em>expression</em></p>
167055bd8deadSopenharmony_ci</dd>
167065bd8deadSopenharmony_ci<dt class="hdlist1"><em>function_call</em> : </dt>
167075bd8deadSopenharmony_ci<dd>
167085bd8deadSopenharmony_ci<p><em>function_call_or_method</em></p>
167095bd8deadSopenharmony_ci</dd>
167105bd8deadSopenharmony_ci<dt class="hdlist1"><em>function_call_or_method</em> : </dt>
167115bd8deadSopenharmony_ci<dd>
167125bd8deadSopenharmony_ci<p><em>function_call_generic</em></p>
167135bd8deadSopenharmony_ci</dd>
167145bd8deadSopenharmony_ci<dt class="hdlist1"><em>function_call_generic</em> : </dt>
167155bd8deadSopenharmony_ci<dd>
167165bd8deadSopenharmony_ci<p><em>function_call_header_with_parameters</em> <em>RIGHT_PAREN</em><br>
167175bd8deadSopenharmony_ci<em>function_call_header_no_parameters</em> <em>RIGHT_PAREN</em></p>
167185bd8deadSopenharmony_ci</dd>
167195bd8deadSopenharmony_ci<dt class="hdlist1"><em>function_call_header_no_parameters</em> : </dt>
167205bd8deadSopenharmony_ci<dd>
167215bd8deadSopenharmony_ci<p><em>function_call_header</em> <em>VOID</em><br>
167225bd8deadSopenharmony_ci<em>function_call_header</em></p>
167235bd8deadSopenharmony_ci</dd>
167245bd8deadSopenharmony_ci<dt class="hdlist1"><em>function_call_header_with_parameters</em> : </dt>
167255bd8deadSopenharmony_ci<dd>
167265bd8deadSopenharmony_ci<p><em>function_call_header</em> <em>assignment_expression</em><br>
167275bd8deadSopenharmony_ci<em>function_call_header_with_parameters</em> <em>COMMA</em> <em>assignment_expression</em></p>
167285bd8deadSopenharmony_ci</dd>
167295bd8deadSopenharmony_ci<dt class="hdlist1"><em>function_call_header</em> : </dt>
167305bd8deadSopenharmony_ci<dd>
167315bd8deadSopenharmony_ci<p><em>function_identifier</em> <em>LEFT_PAREN</em></p>
167325bd8deadSopenharmony_ci</dd>
167335bd8deadSopenharmony_ci</dl>
167345bd8deadSopenharmony_ci</div>
167355bd8deadSopenharmony_ci<div class="admonitionblock note">
167365bd8deadSopenharmony_ci<table>
167375bd8deadSopenharmony_ci<tr>
167385bd8deadSopenharmony_ci<td class="icon">
167395bd8deadSopenharmony_ci<i class="fa icon-note" title="Note"></i>
167405bd8deadSopenharmony_ci</td>
167415bd8deadSopenharmony_ci<td class="content">
167425bd8deadSopenharmony_ci<div class="paragraph">
167435bd8deadSopenharmony_ci<p>Grammar Note: Constructors look like functions, but lexical analysis
167445bd8deadSopenharmony_cirecognized most of them as keywords.
167455bd8deadSopenharmony_ciThey are now recognized through <em>type_specifier</em>.</p>
167465bd8deadSopenharmony_ci</div>
167475bd8deadSopenharmony_ci</td>
167485bd8deadSopenharmony_ci</tr>
167495bd8deadSopenharmony_ci</table>
167505bd8deadSopenharmony_ci</div>
167515bd8deadSopenharmony_ci<div class="admonitionblock note">
167525bd8deadSopenharmony_ci<table>
167535bd8deadSopenharmony_ci<tr>
167545bd8deadSopenharmony_ci<td class="icon">
167555bd8deadSopenharmony_ci<i class="fa icon-note" title="Note"></i>
167565bd8deadSopenharmony_ci</td>
167575bd8deadSopenharmony_ci<td class="content">
167585bd8deadSopenharmony_ci<div class="paragraph">
167595bd8deadSopenharmony_ci<p>Methods (<strong>.length</strong>), subroutine array calls, and identifiers are recognized
167605bd8deadSopenharmony_cithrough <em>postfix_expression</em>.</p>
167615bd8deadSopenharmony_ci</div>
167625bd8deadSopenharmony_ci</td>
167635bd8deadSopenharmony_ci</tr>
167645bd8deadSopenharmony_ci</table>
167655bd8deadSopenharmony_ci</div>
167665bd8deadSopenharmony_ci<div class="dlist">
167675bd8deadSopenharmony_ci<dl>
167685bd8deadSopenharmony_ci<dt class="hdlist1"><em>function_identifier</em> : </dt>
167695bd8deadSopenharmony_ci<dd>
167705bd8deadSopenharmony_ci<p><em>type_specifier</em><br>
167715bd8deadSopenharmony_ci<em>postfix_expression</em></p>
167725bd8deadSopenharmony_ci</dd>
167735bd8deadSopenharmony_ci<dt class="hdlist1"><em>unary_expression</em> : </dt>
167745bd8deadSopenharmony_ci<dd>
167755bd8deadSopenharmony_ci<p><em>postfix_expression</em><br>
167765bd8deadSopenharmony_ci<em>INC_OP</em> <em>unary_expression</em><br>
167775bd8deadSopenharmony_ci<em>DEC_OP</em> <em>unary_expression</em><br>
167785bd8deadSopenharmony_ci<em>unary_operator</em> <em>unary_expression</em></p>
167795bd8deadSopenharmony_ci</dd>
167805bd8deadSopenharmony_ci</dl>
167815bd8deadSopenharmony_ci</div>
167825bd8deadSopenharmony_ci<div class="admonitionblock note">
167835bd8deadSopenharmony_ci<table>
167845bd8deadSopenharmony_ci<tr>
167855bd8deadSopenharmony_ci<td class="icon">
167865bd8deadSopenharmony_ci<i class="fa icon-note" title="Note"></i>
167875bd8deadSopenharmony_ci</td>
167885bd8deadSopenharmony_ci<td class="content">
167895bd8deadSopenharmony_ci<div class="paragraph">
167905bd8deadSopenharmony_ci<p>Grammar Note: No traditional style type casts.</p>
167915bd8deadSopenharmony_ci</div>
167925bd8deadSopenharmony_ci</td>
167935bd8deadSopenharmony_ci</tr>
167945bd8deadSopenharmony_ci</table>
167955bd8deadSopenharmony_ci</div>
167965bd8deadSopenharmony_ci<div class="dlist">
167975bd8deadSopenharmony_ci<dl>
167985bd8deadSopenharmony_ci<dt class="hdlist1"><em>unary_operator</em> : </dt>
167995bd8deadSopenharmony_ci<dd>
168005bd8deadSopenharmony_ci<p><em>PLUS</em><br>
168015bd8deadSopenharmony_ci<em>DASH</em><br>
168025bd8deadSopenharmony_ci<em>BANG</em><br>
168035bd8deadSopenharmony_ci<em>TILDE</em></p>
168045bd8deadSopenharmony_ci</dd>
168055bd8deadSopenharmony_ci</dl>
168065bd8deadSopenharmony_ci</div>
168075bd8deadSopenharmony_ci<div class="admonitionblock note">
168085bd8deadSopenharmony_ci<table>
168095bd8deadSopenharmony_ci<tr>
168105bd8deadSopenharmony_ci<td class="icon">
168115bd8deadSopenharmony_ci<i class="fa icon-note" title="Note"></i>
168125bd8deadSopenharmony_ci</td>
168135bd8deadSopenharmony_ci<td class="content">
168145bd8deadSopenharmony_ci<div class="paragraph">
168155bd8deadSopenharmony_ci<p>Grammar Note: No '*' or '&amp;' unary ops.
168165bd8deadSopenharmony_ciPointers are not supported.</p>
168175bd8deadSopenharmony_ci</div>
168185bd8deadSopenharmony_ci</td>
168195bd8deadSopenharmony_ci</tr>
168205bd8deadSopenharmony_ci</table>
168215bd8deadSopenharmony_ci</div>
168225bd8deadSopenharmony_ci<div class="dlist">
168235bd8deadSopenharmony_ci<dl>
168245bd8deadSopenharmony_ci<dt class="hdlist1"><em>multiplicative_expression</em> : </dt>
168255bd8deadSopenharmony_ci<dd>
168265bd8deadSopenharmony_ci<p><em>unary_expression</em><br>
168275bd8deadSopenharmony_ci<em>multiplicative_expression</em> <em>STAR</em> <em>unary_expression</em><br>
168285bd8deadSopenharmony_ci<em>multiplicative_expression</em> <em>SLASH</em> <em>unary_expression</em><br>
168295bd8deadSopenharmony_ci<em>multiplicative_expression</em> <em>PERCENT</em> <em>unary_expression</em></p>
168305bd8deadSopenharmony_ci</dd>
168315bd8deadSopenharmony_ci<dt class="hdlist1"><em>additive_expression</em> : </dt>
168325bd8deadSopenharmony_ci<dd>
168335bd8deadSopenharmony_ci<p><em>multiplicative_expression</em><br>
168345bd8deadSopenharmony_ci<em>additive_expression</em> <em>PLUS</em> <em>multiplicative_expression</em><br>
168355bd8deadSopenharmony_ci<em>additive_expression</em> <em>DASH</em> <em>multiplicative_expression</em></p>
168365bd8deadSopenharmony_ci</dd>
168375bd8deadSopenharmony_ci<dt class="hdlist1"><em>shift_expression</em> : </dt>
168385bd8deadSopenharmony_ci<dd>
168395bd8deadSopenharmony_ci<p><em>additive_expression</em><br>
168405bd8deadSopenharmony_ci<em>shift_expression</em> <em>LEFT_OP</em> <em>additive_expression</em><br>
168415bd8deadSopenharmony_ci<em>shift_expression</em> <em>RIGHT_OP</em> <em>additive_expression</em></p>
168425bd8deadSopenharmony_ci</dd>
168435bd8deadSopenharmony_ci<dt class="hdlist1"><em>relational_expression</em> : </dt>
168445bd8deadSopenharmony_ci<dd>
168455bd8deadSopenharmony_ci<p><em>shift_expression</em><br>
168465bd8deadSopenharmony_ci<em>relational_expression</em> <em>LEFT_ANGLE</em> <em>shift_expression</em><br>
168475bd8deadSopenharmony_ci<em>relational_expression</em> <em>RIGHT_ANGLE</em> <em>shift_expression</em><br>
168485bd8deadSopenharmony_ci<em>relational_expression</em> <em>LE_OP</em> <em>shift_expression</em><br>
168495bd8deadSopenharmony_ci<em>relational_expression</em> <em>GE_OP</em> <em>shift_expression</em></p>
168505bd8deadSopenharmony_ci</dd>
168515bd8deadSopenharmony_ci<dt class="hdlist1"><em>equality_expression</em> : </dt>
168525bd8deadSopenharmony_ci<dd>
168535bd8deadSopenharmony_ci<p><em>relational_expression</em><br>
168545bd8deadSopenharmony_ci<em>equality_expression</em> <em>EQ_OP</em> <em>relational_expression</em><br>
168555bd8deadSopenharmony_ci<em>equality_expression</em> <em>NE_OP</em> <em>relational_expression</em></p>
168565bd8deadSopenharmony_ci</dd>
168575bd8deadSopenharmony_ci<dt class="hdlist1"><em>and_expression</em> : </dt>
168585bd8deadSopenharmony_ci<dd>
168595bd8deadSopenharmony_ci<p><em>equality_expression</em><br>
168605bd8deadSopenharmony_ci<em>and_expression</em> <em>AMPERSAND</em> <em>equality_expression</em></p>
168615bd8deadSopenharmony_ci</dd>
168625bd8deadSopenharmony_ci<dt class="hdlist1"><em>exclusive_or_expression</em> : </dt>
168635bd8deadSopenharmony_ci<dd>
168645bd8deadSopenharmony_ci<p><em>and_expression</em><br>
168655bd8deadSopenharmony_ci<em>exclusive_or_expression</em> <em>CARET</em> <em>and_expression</em></p>
168665bd8deadSopenharmony_ci</dd>
168675bd8deadSopenharmony_ci<dt class="hdlist1"><em>inclusive_or_expression</em> : </dt>
168685bd8deadSopenharmony_ci<dd>
168695bd8deadSopenharmony_ci<p><em>exclusive_or_expression</em><br>
168705bd8deadSopenharmony_ci<em>inclusive_or_expression</em> <em>VERTICAL_BAR</em> <em>exclusive_or_expression</em></p>
168715bd8deadSopenharmony_ci</dd>
168725bd8deadSopenharmony_ci<dt class="hdlist1"><em>logical_and_expression</em> : </dt>
168735bd8deadSopenharmony_ci<dd>
168745bd8deadSopenharmony_ci<p><em>inclusive_or_expression</em><br>
168755bd8deadSopenharmony_ci<em>logical_and_expression</em> <em>AND_OP</em> <em>inclusive_or_expression</em></p>
168765bd8deadSopenharmony_ci</dd>
168775bd8deadSopenharmony_ci<dt class="hdlist1"><em>logical_xor_expression</em> : </dt>
168785bd8deadSopenharmony_ci<dd>
168795bd8deadSopenharmony_ci<p><em>logical_and_expression</em><br>
168805bd8deadSopenharmony_ci<em>logical_xor_expression</em> <em>XOR_OP</em> <em>logical_and_expression</em></p>
168815bd8deadSopenharmony_ci</dd>
168825bd8deadSopenharmony_ci<dt class="hdlist1"><em>logical_or_expression</em> : </dt>
168835bd8deadSopenharmony_ci<dd>
168845bd8deadSopenharmony_ci<p><em>logical_xor_expression</em><br>
168855bd8deadSopenharmony_ci<em>logical_or_expression</em> <em>OR_OP</em> <em>logical_xor_expression</em></p>
168865bd8deadSopenharmony_ci</dd>
168875bd8deadSopenharmony_ci<dt class="hdlist1"><em>conditional_expression</em> : </dt>
168885bd8deadSopenharmony_ci<dd>
168895bd8deadSopenharmony_ci<p><em>logical_or_expression</em><br>
168905bd8deadSopenharmony_ci<em>logical_or_expression</em> <em>QUESTION</em> <em>expression</em> <em>COLON</em>
168915bd8deadSopenharmony_ci<em>assignment_expression</em></p>
168925bd8deadSopenharmony_ci</dd>
168935bd8deadSopenharmony_ci<dt class="hdlist1"><em>assignment_expression</em> : </dt>
168945bd8deadSopenharmony_ci<dd>
168955bd8deadSopenharmony_ci<p><em>conditional_expression</em><br>
168965bd8deadSopenharmony_ci<em>unary_expression</em> <em>assignment_operator</em> <em>assignment_expression</em></p>
168975bd8deadSopenharmony_ci</dd>
168985bd8deadSopenharmony_ci<dt class="hdlist1"><em>assignment_operator</em> : </dt>
168995bd8deadSopenharmony_ci<dd>
169005bd8deadSopenharmony_ci<p><em>EQUAL</em><br>
169015bd8deadSopenharmony_ci<em>MUL_ASSIGN</em><br>
169025bd8deadSopenharmony_ci<em>DIV_ASSIGN</em><br>
169035bd8deadSopenharmony_ci<em>MOD_ASSIGN</em><br>
169045bd8deadSopenharmony_ci<em>ADD_ASSIGN</em><br>
169055bd8deadSopenharmony_ci<em>SUB_ASSIGN</em><br>
169065bd8deadSopenharmony_ci<em>LEFT_ASSIGN</em><br>
169075bd8deadSopenharmony_ci<em>RIGHT_ASSIGN</em><br>
169085bd8deadSopenharmony_ci<em>AND_ASSIGN</em><br>
169095bd8deadSopenharmony_ci<em>XOR_ASSIGN</em><br>
169105bd8deadSopenharmony_ci<em>OR_ASSIGN</em></p>
169115bd8deadSopenharmony_ci</dd>
169125bd8deadSopenharmony_ci<dt class="hdlist1"><em>expression</em> : </dt>
169135bd8deadSopenharmony_ci<dd>
169145bd8deadSopenharmony_ci<p><em>assignment_expression</em><br>
169155bd8deadSopenharmony_ci<em>expression</em> <em>COMMA</em> <em>assignment_expression</em></p>
169165bd8deadSopenharmony_ci</dd>
169175bd8deadSopenharmony_ci<dt class="hdlist1"><em>constant_expression</em> : </dt>
169185bd8deadSopenharmony_ci<dd>
169195bd8deadSopenharmony_ci<p><em>conditional_expression</em></p>
169205bd8deadSopenharmony_ci</dd>
169215bd8deadSopenharmony_ci<dt class="hdlist1"><em>declaration</em> : </dt>
169225bd8deadSopenharmony_ci<dd>
169235bd8deadSopenharmony_ci<p><em>function_prototype</em> <em>SEMICOLON</em><br>
169245bd8deadSopenharmony_ci<em>init_declarator_list</em> <em>SEMICOLON</em><br>
169255bd8deadSopenharmony_ci<em>PRECISION</em> <em>precision_qualifier</em> <em>type_specifier</em> <em>SEMICOLON</em><br>
169265bd8deadSopenharmony_ci<em>type_qualifier</em> <em>IDENTIFIER</em> <em>LEFT_BRACE</em> <em>struct_declaration_list</em>
169275bd8deadSopenharmony_ci<em>RIGHT_BRACE</em> <em>SEMICOLON</em><br>
169285bd8deadSopenharmony_ci<em>type_qualifier</em> <em>IDENTIFIER</em> <em>LEFT_BRACE</em> <em>struct_declaration_list</em>
169295bd8deadSopenharmony_ci<em>RIGHT_BRACE</em> <em>IDENTIFIER</em> <em>SEMICOLON</em><br>
169305bd8deadSopenharmony_ci<em>type_qualifier</em> <em>IDENTIFIER</em> <em>LEFT_BRACE</em> <em>struct_declaration_list</em>
169315bd8deadSopenharmony_ci<em>RIGHT_BRACE</em> <em>IDENTIFIER</em> <em>array_specifier</em> <em>SEMICOLON</em><br>
169325bd8deadSopenharmony_ci<em>type_qualifier</em> <em>SEMICOLON</em><br>
169335bd8deadSopenharmony_ci<em>type_qualifier</em> <em>IDENTIFIER</em> <em>SEMICOLON</em><br>
169345bd8deadSopenharmony_ci<em>type_qualifier</em> <em>IDENTIFIER</em> <em>identifier_list</em> <em>SEMICOLON</em></p>
169355bd8deadSopenharmony_ci</dd>
169365bd8deadSopenharmony_ci<dt class="hdlist1"><em>identifier_list</em> : </dt>
169375bd8deadSopenharmony_ci<dd>
169385bd8deadSopenharmony_ci<p><em>COMMA</em> <em>IDENTIFIER</em><br>
169395bd8deadSopenharmony_ci<em>identifier_list</em> <em>COMMA</em> <em>IDENTIFIER</em></p>
169405bd8deadSopenharmony_ci</dd>
169415bd8deadSopenharmony_ci<dt class="hdlist1"><em>function_prototype</em> : </dt>
169425bd8deadSopenharmony_ci<dd>
169435bd8deadSopenharmony_ci<p><em>function_declarator</em> <em>RIGHT_PAREN</em></p>
169445bd8deadSopenharmony_ci</dd>
169455bd8deadSopenharmony_ci<dt class="hdlist1"><em>function_declarator</em> : </dt>
169465bd8deadSopenharmony_ci<dd>
169475bd8deadSopenharmony_ci<p><em>function_header</em><br>
169485bd8deadSopenharmony_ci<em>function_header_with_parameters</em></p>
169495bd8deadSopenharmony_ci</dd>
169505bd8deadSopenharmony_ci<dt class="hdlist1"><em>function_header_with_parameters</em> : </dt>
169515bd8deadSopenharmony_ci<dd>
169525bd8deadSopenharmony_ci<p><em>function_header</em> <em>parameter_declaration</em><br>
169535bd8deadSopenharmony_ci<em>function_header_with_parameters</em> <em>COMMA</em> <em>parameter_declaration</em></p>
169545bd8deadSopenharmony_ci</dd>
169555bd8deadSopenharmony_ci<dt class="hdlist1"><em>function_header</em> : </dt>
169565bd8deadSopenharmony_ci<dd>
169575bd8deadSopenharmony_ci<p><em>fully_specified_type</em> <em>IDENTIFIER</em> <em>LEFT_PAREN</em></p>
169585bd8deadSopenharmony_ci</dd>
169595bd8deadSopenharmony_ci<dt class="hdlist1"><em>parameter_declarator</em> : </dt>
169605bd8deadSopenharmony_ci<dd>
169615bd8deadSopenharmony_ci<p><em>type_specifier</em> <em>IDENTIFIER</em><br>
169625bd8deadSopenharmony_ci<em>type_specifier</em> <em>IDENTIFIER</em> <em>array_specifier</em></p>
169635bd8deadSopenharmony_ci</dd>
169645bd8deadSopenharmony_ci<dt class="hdlist1"><em>parameter_declaration</em> : </dt>
169655bd8deadSopenharmony_ci<dd>
169665bd8deadSopenharmony_ci<p><em>type_qualifier</em> <em>parameter_declarator</em><br>
169675bd8deadSopenharmony_ci<em>parameter_declarator</em><br>
169685bd8deadSopenharmony_ci<em>type_qualifier</em> <em>parameter_type_specifier</em><br>
169695bd8deadSopenharmony_ci<em>parameter_type_specifier</em></p>
169705bd8deadSopenharmony_ci</dd>
169715bd8deadSopenharmony_ci<dt class="hdlist1"><em>parameter_type_specifier</em> : </dt>
169725bd8deadSopenharmony_ci<dd>
169735bd8deadSopenharmony_ci<p><em>type_specifier</em></p>
169745bd8deadSopenharmony_ci</dd>
169755bd8deadSopenharmony_ci<dt class="hdlist1"><em>init_declarator_list</em> : </dt>
169765bd8deadSopenharmony_ci<dd>
169775bd8deadSopenharmony_ci<p><em>single_declaration</em><br>
169785bd8deadSopenharmony_ci<em>init_declarator_list</em> <em>COMMA</em> <em>IDENTIFIER</em><br>
169795bd8deadSopenharmony_ci<em>init_declarator_list</em> <em>COMMA</em> <em>IDENTIFIER</em> <em>array_specifier</em><br>
169805bd8deadSopenharmony_ci<em>init_declarator_list</em> <em>COMMA</em> <em>IDENTIFIER</em> <em>array_specifier</em> <em>EQUAL</em>
169815bd8deadSopenharmony_ci<em>initializer</em><br>
169825bd8deadSopenharmony_ci<em>init_declarator_list</em> <em>COMMA</em> <em>IDENTIFIER</em> <em>EQUAL</em> <em>initializer</em></p>
169835bd8deadSopenharmony_ci</dd>
169845bd8deadSopenharmony_ci<dt class="hdlist1"><em>single_declaration</em> : </dt>
169855bd8deadSopenharmony_ci<dd>
169865bd8deadSopenharmony_ci<p><em>fully_specified_type</em><br>
169875bd8deadSopenharmony_ci<em>fully_specified_type</em> <em>IDENTIFIER</em><br>
169885bd8deadSopenharmony_ci<em>fully_specified_type</em> <em>IDENTIFIER</em> <em>array_specifier</em><br>
169895bd8deadSopenharmony_ci<em>fully_specified_type</em> <em>IDENTIFIER</em> <em>array_specifier</em> <em>EQUAL</em>
169905bd8deadSopenharmony_ci<em>initializer</em><br>
169915bd8deadSopenharmony_ci<em>fully_specified_type</em> <em>IDENTIFIER</em> <em>EQUAL</em> <em>initializer</em></p>
169925bd8deadSopenharmony_ci</dd>
169935bd8deadSopenharmony_ci</dl>
169945bd8deadSopenharmony_ci</div>
169955bd8deadSopenharmony_ci<div class="admonitionblock note">
169965bd8deadSopenharmony_ci<table>
169975bd8deadSopenharmony_ci<tr>
169985bd8deadSopenharmony_ci<td class="icon">
169995bd8deadSopenharmony_ci<i class="fa icon-note" title="Note"></i>
170005bd8deadSopenharmony_ci</td>
170015bd8deadSopenharmony_ci<td class="content">
170025bd8deadSopenharmony_ci<div class="paragraph">
170035bd8deadSopenharmony_ci<p>Grammar Note: No 'enum', or 'typedef'.</p>
170045bd8deadSopenharmony_ci</div>
170055bd8deadSopenharmony_ci</td>
170065bd8deadSopenharmony_ci</tr>
170075bd8deadSopenharmony_ci</table>
170085bd8deadSopenharmony_ci</div>
170095bd8deadSopenharmony_ci<div class="dlist">
170105bd8deadSopenharmony_ci<dl>
170115bd8deadSopenharmony_ci<dt class="hdlist1"><em>fully_specified_type</em> : </dt>
170125bd8deadSopenharmony_ci<dd>
170135bd8deadSopenharmony_ci<p><em>type_specifier</em><br>
170145bd8deadSopenharmony_ci<em>type_qualifier</em> <em>type_specifier</em></p>
170155bd8deadSopenharmony_ci</dd>
170165bd8deadSopenharmony_ci<dt class="hdlist1"><em>invariant_qualifier</em> : </dt>
170175bd8deadSopenharmony_ci<dd>
170185bd8deadSopenharmony_ci<p><em>INVARIANT</em></p>
170195bd8deadSopenharmony_ci</dd>
170205bd8deadSopenharmony_ci<dt class="hdlist1"><em>interpolation_qualifier</em> : </dt>
170215bd8deadSopenharmony_ci<dd>
170225bd8deadSopenharmony_ci<p><em>SMOOTH</em><br>
170235bd8deadSopenharmony_ci<em>FLAT</em><br>
170245bd8deadSopenharmony_ci<em>NOPERSPECTIVE</em></p>
170255bd8deadSopenharmony_ci</dd>
170265bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout_qualifier</em> : </dt>
170275bd8deadSopenharmony_ci<dd>
170285bd8deadSopenharmony_ci<p><em>LAYOUT</em> <em>LEFT_PAREN</em> <em>layout_qualifier_id_list</em> <em>RIGHT_PAREN</em></p>
170295bd8deadSopenharmony_ci</dd>
170305bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout_qualifier_id_list</em> : </dt>
170315bd8deadSopenharmony_ci<dd>
170325bd8deadSopenharmony_ci<p><em>layout_qualifier_id</em><br>
170335bd8deadSopenharmony_ci<em>layout_qualifier_id_list</em> <em>COMMA</em> <em>layout_qualifier_id</em></p>
170345bd8deadSopenharmony_ci</dd>
170355bd8deadSopenharmony_ci<dt class="hdlist1"><em>layout_qualifier_id</em> : </dt>
170365bd8deadSopenharmony_ci<dd>
170375bd8deadSopenharmony_ci<p><em>IDENTIFIER</em><br>
170385bd8deadSopenharmony_ci<em>IDENTIFIER</em> <em>EQUAL</em> <em>constant_expression</em><br>
170395bd8deadSopenharmony_ci<em>SHARED</em></p>
170405bd8deadSopenharmony_ci</dd>
170415bd8deadSopenharmony_ci<dt class="hdlist1"><em>precise_qualifier</em> : </dt>
170425bd8deadSopenharmony_ci<dd>
170435bd8deadSopenharmony_ci<p><em>PRECISE</em></p>
170445bd8deadSopenharmony_ci</dd>
170455bd8deadSopenharmony_ci<dt class="hdlist1"><em>type_qualifier</em> : </dt>
170465bd8deadSopenharmony_ci<dd>
170475bd8deadSopenharmony_ci<p><em>single_type_qualifier</em><br>
170485bd8deadSopenharmony_ci<em>type_qualifier</em> <em>single_type_qualifier</em></p>
170495bd8deadSopenharmony_ci</dd>
170505bd8deadSopenharmony_ci<dt class="hdlist1"><em>single_type_qualifier</em> : </dt>
170515bd8deadSopenharmony_ci<dd>
170525bd8deadSopenharmony_ci<p><em>storage_qualifier</em><br>
170535bd8deadSopenharmony_ci<em>layout_qualifier</em><br>
170545bd8deadSopenharmony_ci<em>precision_qualifier</em><br>
170555bd8deadSopenharmony_ci<em>interpolation_qualifier</em><br>
170565bd8deadSopenharmony_ci<em>invariant_qualifier</em><br>
170575bd8deadSopenharmony_ci<em>precise_qualifier</em></p>
170585bd8deadSopenharmony_ci</dd>
170595bd8deadSopenharmony_ci<dt class="hdlist1"><em>storage_qualifier</em> : </dt>
170605bd8deadSopenharmony_ci<dd>
170615bd8deadSopenharmony_ci<p><em>CONST</em><br>
170625bd8deadSopenharmony_ci<em>IN</em><br>
170635bd8deadSopenharmony_ci<em>OUT</em><br>
170645bd8deadSopenharmony_ci<em>INOUT</em><br>
170655bd8deadSopenharmony_ci<em>CENTROID</em><br>
170665bd8deadSopenharmony_ci<em>PATCH</em><br>
170675bd8deadSopenharmony_ci<em>SAMPLE</em><br>
170685bd8deadSopenharmony_ci<em>UNIFORM</em><br>
170695bd8deadSopenharmony_ci<em>BUFFER</em><br>
170705bd8deadSopenharmony_ci<em>SHARED</em><br>
170715bd8deadSopenharmony_ci<em>COHERENT</em><br>
170725bd8deadSopenharmony_ci<em>VOLATILE</em><br>
170735bd8deadSopenharmony_ci<em>RESTRICT</em><br>
170745bd8deadSopenharmony_ci<em>READONLY</em><br>
170755bd8deadSopenharmony_ci<em>WRITEONLY</em><br>
170765bd8deadSopenharmony_ci<em>SUBROUTINE</em><br>
170775bd8deadSopenharmony_ci<em>SUBROUTINE</em> <em>LEFT_PAREN</em> <em>type_name_list</em> <em>RIGHT_PAREN</em></p>
170785bd8deadSopenharmony_ci</dd>
170795bd8deadSopenharmony_ci<dt class="hdlist1"><em>type_name_list</em> : </dt>
170805bd8deadSopenharmony_ci<dd>
170815bd8deadSopenharmony_ci<p><em>TYPE_NAME</em><br>
170825bd8deadSopenharmony_ci<em>type_name_list</em> <em>COMMA</em> <em>TYPE_NAME</em></p>
170835bd8deadSopenharmony_ci</dd>
170845bd8deadSopenharmony_ci<dt class="hdlist1"><em>type_specifier</em> : </dt>
170855bd8deadSopenharmony_ci<dd>
170865bd8deadSopenharmony_ci<p><em>type_specifier_nonarray</em><br>
170875bd8deadSopenharmony_ci<em>type_specifier_nonarray</em> <em>array_specifier</em></p>
170885bd8deadSopenharmony_ci</dd>
170895bd8deadSopenharmony_ci<dt class="hdlist1"><em>array_specifier</em> : </dt>
170905bd8deadSopenharmony_ci<dd>
170915bd8deadSopenharmony_ci<p><em>LEFT_BRACKET</em> <em>RIGHT_BRACKET</em><br>
170925bd8deadSopenharmony_ci<em>LEFT_BRACKET</em> <em>conditional_expression</em> <em>RIGHT_BRACKET</em><br>
170935bd8deadSopenharmony_ci<em>array_specifier</em> <em>LEFT_BRACKET</em> <em>RIGHT_BRACKET</em><br>
170945bd8deadSopenharmony_ci<em>array_specifier</em> <em>LEFT_BRACKET</em> <em>conditional_expression</em> <em>RIGHT_BRACKET</em></p>
170955bd8deadSopenharmony_ci</dd>
170965bd8deadSopenharmony_ci<dt class="hdlist1"><em>type_specifier_nonarray</em> : </dt>
170975bd8deadSopenharmony_ci<dd>
170985bd8deadSopenharmony_ci<p><em>VOID</em><br>
170995bd8deadSopenharmony_ci<em>FLOAT</em><br>
171005bd8deadSopenharmony_ci<em>DOUBLE</em><br>
171015bd8deadSopenharmony_ci<em>INT</em><br>
171025bd8deadSopenharmony_ci<em>UINT</em><br>
171035bd8deadSopenharmony_ci<em>BOOL</em><br>
171045bd8deadSopenharmony_ci<em>VEC2</em><br>
171055bd8deadSopenharmony_ci<em>VEC3</em><br>
171065bd8deadSopenharmony_ci<em>VEC4</em><br>
171075bd8deadSopenharmony_ci<em>DVEC2</em><br>
171085bd8deadSopenharmony_ci<em>DVEC3</em><br>
171095bd8deadSopenharmony_ci<em>DVEC4</em><br>
171105bd8deadSopenharmony_ci<em>BVEC2</em><br>
171115bd8deadSopenharmony_ci<em>BVEC3</em><br>
171125bd8deadSopenharmony_ci<em>BVEC4</em><br>
171135bd8deadSopenharmony_ci<em>IVEC2</em><br>
171145bd8deadSopenharmony_ci<em>IVEC3</em><br>
171155bd8deadSopenharmony_ci<em>IVEC4</em><br>
171165bd8deadSopenharmony_ci<em>UVEC2</em><br>
171175bd8deadSopenharmony_ci<em>UVEC3</em><br>
171185bd8deadSopenharmony_ci<em>UVEC4</em><br>
171195bd8deadSopenharmony_ci<em>MAT2</em><br>
171205bd8deadSopenharmony_ci<em>MAT3</em><br>
171215bd8deadSopenharmony_ci<em>MAT4</em><br>
171225bd8deadSopenharmony_ci<em>MAT2X2</em><br>
171235bd8deadSopenharmony_ci<em>MAT2X3</em><br>
171245bd8deadSopenharmony_ci<em>MAT2X4</em><br>
171255bd8deadSopenharmony_ci<em>MAT3X2</em><br>
171265bd8deadSopenharmony_ci<em>MAT3X3</em><br>
171275bd8deadSopenharmony_ci<em>MAT3X4</em><br>
171285bd8deadSopenharmony_ci<em>MAT4X2</em><br>
171295bd8deadSopenharmony_ci<em>MAT4X3</em><br>
171305bd8deadSopenharmony_ci<em>MAT4X4</em><br>
171315bd8deadSopenharmony_ci<em>DMAT2</em><br>
171325bd8deadSopenharmony_ci<em>DMAT3</em><br>
171335bd8deadSopenharmony_ci<em>DMAT4</em><br>
171345bd8deadSopenharmony_ci<em>DMAT2X2</em><br>
171355bd8deadSopenharmony_ci<em>DMAT2X3</em><br>
171365bd8deadSopenharmony_ci<em>DMAT2X4</em><br>
171375bd8deadSopenharmony_ci<em>DMAT3X2</em><br>
171385bd8deadSopenharmony_ci<em>DMAT3X3</em><br>
171395bd8deadSopenharmony_ci<em>DMAT3X4</em><br>
171405bd8deadSopenharmony_ci<em>DMAT4X2</em><br>
171415bd8deadSopenharmony_ci<em>DMAT4X3</em><br>
171425bd8deadSopenharmony_ci<em>DMAT4X4</em><br>
171435bd8deadSopenharmony_ci<em>ATOMIC_UINT</em><br>
171445bd8deadSopenharmony_ci<em>SAMPLER2D</em><br>
171455bd8deadSopenharmony_ci<em>SAMPLER3D</em><br>
171465bd8deadSopenharmony_ci<em>SAMPLERCUBE</em><br>
171475bd8deadSopenharmony_ci<em>SAMPLER2DSHADOW</em><br>
171485bd8deadSopenharmony_ci<em>SAMPLERCUBESHADOW</em><br>
171495bd8deadSopenharmony_ci<em>SAMPLER2DARRAY</em><br>
171505bd8deadSopenharmony_ci<em>SAMPLER2DARRAYSHADOW</em><br>
171515bd8deadSopenharmony_ci<em>SAMPLERCUBEARRAY</em><br>
171525bd8deadSopenharmony_ci<em>SAMPLERCUBEARRAYSHADOW</em><br>
171535bd8deadSopenharmony_ci<em>ISAMPLER2D</em><br>
171545bd8deadSopenharmony_ci<em>ISAMPLER3D</em><br>
171555bd8deadSopenharmony_ci<em>ISAMPLERCUBE</em><br>
171565bd8deadSopenharmony_ci<em>ISAMPLER2DARRAY</em><br>
171575bd8deadSopenharmony_ci<em>ISAMPLERCUBEARRAY</em><br>
171585bd8deadSopenharmony_ci<em>USAMPLER2D</em><br>
171595bd8deadSopenharmony_ci<em>USAMPLER3D</em><br>
171605bd8deadSopenharmony_ci<em>USAMPLERCUBE</em><br>
171615bd8deadSopenharmony_ci<em>USAMPLER2DARRAY</em><br>
171625bd8deadSopenharmony_ci<em>USAMPLERCUBEARRAY</em><br>
171635bd8deadSopenharmony_ci<em>SAMPLER1D</em><br>
171645bd8deadSopenharmony_ci<em>SAMPLER1DSHADOW</em><br>
171655bd8deadSopenharmony_ci<em>SAMPLER1DARRAY</em><br>
171665bd8deadSopenharmony_ci<em>SAMPLER1DARRAYSHADOW</em><br>
171675bd8deadSopenharmony_ci<em>ISAMPLER1D</em><br>
171685bd8deadSopenharmony_ci<em>ISAMPLER1DARRAY</em><br>
171695bd8deadSopenharmony_ci<em>USAMPLER1D</em><br>
171705bd8deadSopenharmony_ci<em>USAMPLER1DARRAY</em><br>
171715bd8deadSopenharmony_ci<em>SAMPLER2DRECT</em><br>
171725bd8deadSopenharmony_ci<em>SAMPLER2DRECTSHADOW</em><br>
171735bd8deadSopenharmony_ci<em>ISAMPLER2DRECT</em><br>
171745bd8deadSopenharmony_ci<em>USAMPLER2DRECT</em><br>
171755bd8deadSopenharmony_ci<em>SAMPLERBUFFER</em><br>
171765bd8deadSopenharmony_ci<em>ISAMPLERBUFFER</em><br>
171775bd8deadSopenharmony_ci<em>USAMPLERBUFFER</em><br>
171785bd8deadSopenharmony_ci<em>SAMPLER2DMS</em><br>
171795bd8deadSopenharmony_ci<em>ISAMPLER2DMS</em><br>
171805bd8deadSopenharmony_ci<em>USAMPLER2DMS</em><br>
171815bd8deadSopenharmony_ci<em>SAMPLER2DMSARRAY</em><br>
171825bd8deadSopenharmony_ci<em>ISAMPLER2DMSARRAY</em><br>
171835bd8deadSopenharmony_ci<em>USAMPLER2DMSARRAY</em><br>
171845bd8deadSopenharmony_ci<em>IMAGE2D</em><br>
171855bd8deadSopenharmony_ci<em>IIMAGE2D</em><br>
171865bd8deadSopenharmony_ci<em>UIMAGE2D</em><br>
171875bd8deadSopenharmony_ci<em>IMAGE3D</em><br>
171885bd8deadSopenharmony_ci<em>IIMAGE3D</em><br>
171895bd8deadSopenharmony_ci<em>UIMAGE3D</em><br>
171905bd8deadSopenharmony_ci<em>IMAGECUBE</em><br>
171915bd8deadSopenharmony_ci<em>IIMAGECUBE</em><br>
171925bd8deadSopenharmony_ci<em>UIMAGECUBE</em><br>
171935bd8deadSopenharmony_ci<em>IMAGEBUFFER</em><br>
171945bd8deadSopenharmony_ci<em>IIMAGEBUFFER</em><br>
171955bd8deadSopenharmony_ci<em>UIMAGEBUFFER</em><br>
171965bd8deadSopenharmony_ci<em>IMAGE1D</em><br>
171975bd8deadSopenharmony_ci<em>IIMAGE1D</em><br>
171985bd8deadSopenharmony_ci<em>UIMAGE1D</em><br>
171995bd8deadSopenharmony_ci<em>IMAGE1DARRAY</em><br>
172005bd8deadSopenharmony_ci<em>IIMAGE1DARRAY</em><br>
172015bd8deadSopenharmony_ci<em>UIMAGE1DARRAY</em><br>
172025bd8deadSopenharmony_ci<em>IMAGE2DRECT</em><br>
172035bd8deadSopenharmony_ci<em>IIMAGE2DRECT</em><br>
172045bd8deadSopenharmony_ci<em>UIMAGE2DRECT</em><br>
172055bd8deadSopenharmony_ci<em>IMAGE2DARRAY</em><br>
172065bd8deadSopenharmony_ci<em>IIMAGE2DARRAY</em><br>
172075bd8deadSopenharmony_ci<em>UIMAGE2DARRAY</em><br>
172085bd8deadSopenharmony_ci<em>IMAGECUBEARRAY</em><br>
172095bd8deadSopenharmony_ci<em>IIMAGECUBEARRAY</em><br>
172105bd8deadSopenharmony_ci<em>UIMAGECUBEARRAY</em><br>
172115bd8deadSopenharmony_ci<em>IMAGE2DMS</em><br>
172125bd8deadSopenharmony_ci<em>IIMAGE2DMS</em><br>
172135bd8deadSopenharmony_ci<em>UIMAGE2DMS</em><br>
172145bd8deadSopenharmony_ci<em>IMAGE2DMSARRAY</em><br>
172155bd8deadSopenharmony_ci<em>IIMAGE2DMSARRAY</em><br>
172165bd8deadSopenharmony_ci<em>UIMAGE2DMSARRAY</em><br>
172175bd8deadSopenharmony_ci<em>struct_specifier</em><br>
172185bd8deadSopenharmony_ci<em>TYPE_NAME</em></p>
172195bd8deadSopenharmony_ci</dd>
172205bd8deadSopenharmony_ci<dt class="hdlist1"><em>precision_qualifier</em> : </dt>
172215bd8deadSopenharmony_ci<dd>
172225bd8deadSopenharmony_ci<p><em>HIGH_PRECISION</em><br>
172235bd8deadSopenharmony_ci<em>MEDIUM_PRECISION</em><br>
172245bd8deadSopenharmony_ci<em>LOW_PRECISION</em></p>
172255bd8deadSopenharmony_ci</dd>
172265bd8deadSopenharmony_ci<dt class="hdlist1"><em>struct_specifier</em> : </dt>
172275bd8deadSopenharmony_ci<dd>
172285bd8deadSopenharmony_ci<p><em>STRUCT</em> <em>IDENTIFIER</em> <em>LEFT_BRACE</em> <em>struct_declaration_list</em>
172295bd8deadSopenharmony_ci<em>RIGHT_BRACE</em><br>
172305bd8deadSopenharmony_ci<em>STRUCT</em> <em>LEFT_BRACE</em> <em>struct_declaration_list</em> <em>RIGHT_BRACE</em></p>
172315bd8deadSopenharmony_ci</dd>
172325bd8deadSopenharmony_ci<dt class="hdlist1"><em>struct_declaration_list</em> : </dt>
172335bd8deadSopenharmony_ci<dd>
172345bd8deadSopenharmony_ci<p><em>struct_declaration</em><br>
172355bd8deadSopenharmony_ci<em>struct_declaration_list</em> <em>struct_declaration</em></p>
172365bd8deadSopenharmony_ci</dd>
172375bd8deadSopenharmony_ci<dt class="hdlist1"><em>struct_declaration</em> : </dt>
172385bd8deadSopenharmony_ci<dd>
172395bd8deadSopenharmony_ci<p><em>type_specifier</em> <em>struct_declarator_list</em> <em>SEMICOLON</em><br>
172405bd8deadSopenharmony_ci<em>type_qualifier</em> <em>type_specifier</em> <em>struct_declarator_list</em> <em>SEMICOLON</em></p>
172415bd8deadSopenharmony_ci</dd>
172425bd8deadSopenharmony_ci<dt class="hdlist1"><em>struct_declarator_list</em> : </dt>
172435bd8deadSopenharmony_ci<dd>
172445bd8deadSopenharmony_ci<p><em>struct_declarator</em><br>
172455bd8deadSopenharmony_ci<em>struct_declarator_list</em> <em>COMMA</em> <em>struct_declarator</em></p>
172465bd8deadSopenharmony_ci</dd>
172475bd8deadSopenharmony_ci<dt class="hdlist1"><em>struct_declarator</em> : </dt>
172485bd8deadSopenharmony_ci<dd>
172495bd8deadSopenharmony_ci<p><em>IDENTIFIER</em><br>
172505bd8deadSopenharmony_ci<em>IDENTIFIER</em> <em>array_specifier</em></p>
172515bd8deadSopenharmony_ci</dd>
172525bd8deadSopenharmony_ci<dt class="hdlist1"><em>initializer</em> : </dt>
172535bd8deadSopenharmony_ci<dd>
172545bd8deadSopenharmony_ci<p><em>assignment_expression</em><br>
172555bd8deadSopenharmony_ci<em>LEFT_BRACE</em> <em>initializer_list</em> <em>RIGHT_BRACE</em><br>
172565bd8deadSopenharmony_ci<em>LEFT_BRACE</em> <em>initializer_list</em> <em>COMMA</em> <em>RIGHT_BRACE</em></p>
172575bd8deadSopenharmony_ci</dd>
172585bd8deadSopenharmony_ci<dt class="hdlist1"><em>initializer_list</em> : </dt>
172595bd8deadSopenharmony_ci<dd>
172605bd8deadSopenharmony_ci<p><em>initializer</em><br>
172615bd8deadSopenharmony_ci<em>initializer_list</em> <em>COMMA</em> <em>initializer</em></p>
172625bd8deadSopenharmony_ci</dd>
172635bd8deadSopenharmony_ci<dt class="hdlist1"><em>declaration_statement</em> : </dt>
172645bd8deadSopenharmony_ci<dd>
172655bd8deadSopenharmony_ci<p><em>declaration</em></p>
172665bd8deadSopenharmony_ci</dd>
172675bd8deadSopenharmony_ci<dt class="hdlist1"><em>statement</em> : </dt>
172685bd8deadSopenharmony_ci<dd>
172695bd8deadSopenharmony_ci<p><em>compound_statement</em><br>
172705bd8deadSopenharmony_ci<em>simple_statement</em></p>
172715bd8deadSopenharmony_ci</dd>
172725bd8deadSopenharmony_ci</dl>
172735bd8deadSopenharmony_ci</div>
172745bd8deadSopenharmony_ci<div class="admonitionblock note">
172755bd8deadSopenharmony_ci<table>
172765bd8deadSopenharmony_ci<tr>
172775bd8deadSopenharmony_ci<td class="icon">
172785bd8deadSopenharmony_ci<i class="fa icon-note" title="Note"></i>
172795bd8deadSopenharmony_ci</td>
172805bd8deadSopenharmony_ci<td class="content">
172815bd8deadSopenharmony_ci<div class="paragraph">
172825bd8deadSopenharmony_ci<p>Grammar Note: labeled statements for SWITCH only; 'goto' is not supported.</p>
172835bd8deadSopenharmony_ci</div>
172845bd8deadSopenharmony_ci</td>
172855bd8deadSopenharmony_ci</tr>
172865bd8deadSopenharmony_ci</table>
172875bd8deadSopenharmony_ci</div>
172885bd8deadSopenharmony_ci<div class="dlist">
172895bd8deadSopenharmony_ci<dl>
172905bd8deadSopenharmony_ci<dt class="hdlist1"><em>simple_statement</em> : </dt>
172915bd8deadSopenharmony_ci<dd>
172925bd8deadSopenharmony_ci<p><em>declaration_statement</em><br>
172935bd8deadSopenharmony_ci<em>expression_statement</em><br>
172945bd8deadSopenharmony_ci<em>selection_statement</em><br>
172955bd8deadSopenharmony_ci<em>switch_statement</em><br>
172965bd8deadSopenharmony_ci<em>case_label</em><br>
172975bd8deadSopenharmony_ci<em>iteration_statement</em><br>
172985bd8deadSopenharmony_ci<em>jump_statement</em></p>
172995bd8deadSopenharmony_ci</dd>
173005bd8deadSopenharmony_ci<dt class="hdlist1"><em>compound_statement</em> : </dt>
173015bd8deadSopenharmony_ci<dd>
173025bd8deadSopenharmony_ci<p><em>LEFT_BRACE</em> <em>RIGHT_BRACE</em><br>
173035bd8deadSopenharmony_ci<em>LEFT_BRACE</em> <em>statement_list</em> <em>RIGHT_BRACE</em></p>
173045bd8deadSopenharmony_ci</dd>
173055bd8deadSopenharmony_ci<dt class="hdlist1"><em>statement_no_new_scope</em> : </dt>
173065bd8deadSopenharmony_ci<dd>
173075bd8deadSopenharmony_ci<p><em>compound_statement_no_new_scope</em><br>
173085bd8deadSopenharmony_ci<em>simple_statement</em></p>
173095bd8deadSopenharmony_ci</dd>
173105bd8deadSopenharmony_ci<dt class="hdlist1"><em>compound_statement_no_new_scope</em> : </dt>
173115bd8deadSopenharmony_ci<dd>
173125bd8deadSopenharmony_ci<p><em>LEFT_BRACE</em> <em>RIGHT_BRACE</em><br>
173135bd8deadSopenharmony_ci<em>LEFT_BRACE</em> <em>statement_list</em> <em>RIGHT_BRACE</em></p>
173145bd8deadSopenharmony_ci</dd>
173155bd8deadSopenharmony_ci<dt class="hdlist1"><em>statement_list</em> : </dt>
173165bd8deadSopenharmony_ci<dd>
173175bd8deadSopenharmony_ci<p><em>statement</em><br>
173185bd8deadSopenharmony_ci<em>statement_list</em> <em>statement</em></p>
173195bd8deadSopenharmony_ci</dd>
173205bd8deadSopenharmony_ci<dt class="hdlist1"><em>expression_statement</em> : </dt>
173215bd8deadSopenharmony_ci<dd>
173225bd8deadSopenharmony_ci<p><em>SEMICOLON</em><br>
173235bd8deadSopenharmony_ci<em>expression</em> <em>SEMICOLON</em></p>
173245bd8deadSopenharmony_ci</dd>
173255bd8deadSopenharmony_ci<dt class="hdlist1"><em>selection_statement</em> : </dt>
173265bd8deadSopenharmony_ci<dd>
173275bd8deadSopenharmony_ci<p><em>IF</em> <em>LEFT_PAREN</em> <em>expression</em> <em>RIGHT_PAREN</em> <em>selection_rest_statement</em></p>
173285bd8deadSopenharmony_ci</dd>
173295bd8deadSopenharmony_ci<dt class="hdlist1"><em>selection_rest_statement</em> : </dt>
173305bd8deadSopenharmony_ci<dd>
173315bd8deadSopenharmony_ci<p><em>statement</em> <em>ELSE</em> <em>statement</em><br>
173325bd8deadSopenharmony_ci<em>statement</em></p>
173335bd8deadSopenharmony_ci</dd>
173345bd8deadSopenharmony_ci<dt class="hdlist1"><em>condition</em> : </dt>
173355bd8deadSopenharmony_ci<dd>
173365bd8deadSopenharmony_ci<p><em>expression</em><br>
173375bd8deadSopenharmony_ci<em>fully_specified_type</em> <em>IDENTIFIER</em> <em>EQUAL</em> <em>initializer</em></p>
173385bd8deadSopenharmony_ci</dd>
173395bd8deadSopenharmony_ci<dt class="hdlist1"><em>switch_statement</em> : </dt>
173405bd8deadSopenharmony_ci<dd>
173415bd8deadSopenharmony_ci<p><em>SWITCH</em> <em>LEFT_PAREN</em> <em>expression</em> <em>RIGHT_PAREN</em> <em>LEFT_BRACE</em>
173425bd8deadSopenharmony_ci<em>switch_statement_list</em><br>
173435bd8deadSopenharmony_ci<em>RIGHT_BRACE</em></p>
173445bd8deadSopenharmony_ci</dd>
173455bd8deadSopenharmony_ci<dt class="hdlist1"><em>switch_statement_list</em> : </dt>
173465bd8deadSopenharmony_ci<dd>
173475bd8deadSopenharmony_ci<p>/* <em>nothing</em> */<br>
173485bd8deadSopenharmony_ci<em>statement_list</em></p>
173495bd8deadSopenharmony_ci</dd>
173505bd8deadSopenharmony_ci<dt class="hdlist1"><em>case_label</em> : </dt>
173515bd8deadSopenharmony_ci<dd>
173525bd8deadSopenharmony_ci<p><em>CASE</em> <em>expression</em> <em>COLON</em><br>
173535bd8deadSopenharmony_ci<em>DEFAULT</em> <em>COLON</em></p>
173545bd8deadSopenharmony_ci</dd>
173555bd8deadSopenharmony_ci<dt class="hdlist1"><em>iteration_statement</em> : </dt>
173565bd8deadSopenharmony_ci<dd>
173575bd8deadSopenharmony_ci<p><em>WHILE</em> <em>LEFT_PAREN</em> <em>condition</em> <em>RIGHT_PAREN</em> <em>statement_no_new_scope</em><br>
173585bd8deadSopenharmony_ci<em>DO</em> <em>statement</em> <em>WHILE</em> <em>LEFT_PAREN</em> <em>expression</em> <em>RIGHT_PAREN</em>
173595bd8deadSopenharmony_ci<em>SEMICOLON</em><br>
173605bd8deadSopenharmony_ci<em>FOR</em> <em>LEFT_PAREN</em> <em>for_init_statement</em> <em>for_rest_statement</em>
173615bd8deadSopenharmony_ci<em>RIGHT_PAREN</em> <em>statement_no_new_scope</em></p>
173625bd8deadSopenharmony_ci</dd>
173635bd8deadSopenharmony_ci<dt class="hdlist1"><em>for_init_statement</em> : </dt>
173645bd8deadSopenharmony_ci<dd>
173655bd8deadSopenharmony_ci<p><em>expression_statement</em><br>
173665bd8deadSopenharmony_ci<em>declaration_statement</em></p>
173675bd8deadSopenharmony_ci</dd>
173685bd8deadSopenharmony_ci<dt class="hdlist1"><em>conditionopt</em> : </dt>
173695bd8deadSopenharmony_ci<dd>
173705bd8deadSopenharmony_ci<p><em>condition</em><br>
173715bd8deadSopenharmony_ci/* <em>empty</em> */</p>
173725bd8deadSopenharmony_ci</dd>
173735bd8deadSopenharmony_ci<dt class="hdlist1"><em>for_rest_statement</em> : </dt>
173745bd8deadSopenharmony_ci<dd>
173755bd8deadSopenharmony_ci<p><em>conditionopt</em> <em>SEMICOLON</em><br>
173765bd8deadSopenharmony_ci<em>conditionopt</em> <em>SEMICOLON</em> <em>expression</em></p>
173775bd8deadSopenharmony_ci</dd>
173785bd8deadSopenharmony_ci<dt class="hdlist1"><em>jump_statement</em> : </dt>
173795bd8deadSopenharmony_ci<dd>
173805bd8deadSopenharmony_ci<p><em>CONTINUE</em> <em>SEMICOLON</em><br>
173815bd8deadSopenharmony_ci<em>BREAK</em> <em>SEMICOLON</em><br>
173825bd8deadSopenharmony_ci<em>RETURN</em> <em>SEMICOLON</em><br>
173835bd8deadSopenharmony_ci<em>RETURN</em> <em>expression</em> <em>SEMICOLON</em><br>
173845bd8deadSopenharmony_ci<em>DISCARD</em> <em>SEMICOLON</em> // Fragment shader only.</p>
173855bd8deadSopenharmony_ci</dd>
173865bd8deadSopenharmony_ci</dl>
173875bd8deadSopenharmony_ci</div>
173885bd8deadSopenharmony_ci<div class="admonitionblock note">
173895bd8deadSopenharmony_ci<table>
173905bd8deadSopenharmony_ci<tr>
173915bd8deadSopenharmony_ci<td class="icon">
173925bd8deadSopenharmony_ci<i class="fa icon-note" title="Note"></i>
173935bd8deadSopenharmony_ci</td>
173945bd8deadSopenharmony_ci<td class="content">
173955bd8deadSopenharmony_ci<div class="paragraph">
173965bd8deadSopenharmony_ci<p>Grammar Note: No 'goto'.
173975bd8deadSopenharmony_ciGotos are not supported.</p>
173985bd8deadSopenharmony_ci</div>
173995bd8deadSopenharmony_ci</td>
174005bd8deadSopenharmony_ci</tr>
174015bd8deadSopenharmony_ci</table>
174025bd8deadSopenharmony_ci</div>
174035bd8deadSopenharmony_ci<div class="dlist">
174045bd8deadSopenharmony_ci<dl>
174055bd8deadSopenharmony_ci<dt class="hdlist1"><em>translation_unit</em> : </dt>
174065bd8deadSopenharmony_ci<dd>
174075bd8deadSopenharmony_ci<p><em>external_declaration</em><br>
174085bd8deadSopenharmony_ci<em>translation_unit</em> <em>external_declaration</em></p>
174095bd8deadSopenharmony_ci</dd>
174105bd8deadSopenharmony_ci<dt class="hdlist1"><em>external_declaration</em> : </dt>
174115bd8deadSopenharmony_ci<dd>
174125bd8deadSopenharmony_ci<p><em>function_definition</em><br>
174135bd8deadSopenharmony_ci<em>declaration</em><br>
174145bd8deadSopenharmony_ci<em>SEMICOLON</em></p>
174155bd8deadSopenharmony_ci</dd>
174165bd8deadSopenharmony_ci<dt class="hdlist1"><em>function_definition</em> : </dt>
174175bd8deadSopenharmony_ci<dd>
174185bd8deadSopenharmony_ci<p><em>function_prototype</em> <em>compound_statement_no_new_scope</em></p>
174195bd8deadSopenharmony_ci</dd>
174205bd8deadSopenharmony_ci</dl>
174215bd8deadSopenharmony_ci</div>
174225bd8deadSopenharmony_ci</div>
174235bd8deadSopenharmony_ci</div>
174245bd8deadSopenharmony_ci<div class="paragraph">
174255bd8deadSopenharmony_ci<p>In general the above grammar describes a super set of the OpenGL Shading Language.
174265bd8deadSopenharmony_ciCertain constructs that are valid purely in terms of the grammar are
174275bd8deadSopenharmony_cidisallowed by statements elsewhere in this specification.</p>
174285bd8deadSopenharmony_ci</div>
174295bd8deadSopenharmony_ci</div>
174305bd8deadSopenharmony_ci</div>
174315bd8deadSopenharmony_ci<div class="sect1">
174325bd8deadSopenharmony_ci<h2 id="acknowledgments">10. Acknowledgments</h2>
174335bd8deadSopenharmony_ci<div class="sectionbody">
174345bd8deadSopenharmony_ci<div class="paragraph">
174355bd8deadSopenharmony_ci<p>This specification is based on the work of those who contributed to past
174365bd8deadSopenharmony_civersions of the Open GL and Open GL ES Language Specifications and the
174375bd8deadSopenharmony_cifollowing contributors to this version:</p>
174385bd8deadSopenharmony_ci</div>
174395bd8deadSopenharmony_ci<div class="paragraph">
174405bd8deadSopenharmony_ci<p>Pat Brown, NVIDIA<br>
174415bd8deadSopenharmony_ciJeff Bolz, NVIDIA<br>
174425bd8deadSopenharmony_ciFrank Chen<br>
174435bd8deadSopenharmony_ciPierre Boudier, AMD<br>
174445bd8deadSopenharmony_ciPiers Daniell, NVIDIA<br>
174455bd8deadSopenharmony_ciChris Dodd, NVIDIA<br>
174465bd8deadSopenharmony_ciNick Haemel, NVIDIA<br>
174475bd8deadSopenharmony_ciJason Green, Transgaming<br>
174485bd8deadSopenharmony_ciBrent Insko, Intel<br>
174495bd8deadSopenharmony_ciJon Leech<br>
174505bd8deadSopenharmony_ciBill Licea-Kane, Qualcomm<br>
174515bd8deadSopenharmony_ciDaniel Koch, NVIDIA<br>
174525bd8deadSopenharmony_ciGraeme Leese, Broadcom<br>
174535bd8deadSopenharmony_ciBarthold Lichtenbelt, NVIDIA<br>
174545bd8deadSopenharmony_ciBruce Merry, ARM<br>
174555bd8deadSopenharmony_ciRobert Ohannessian<br>
174565bd8deadSopenharmony_ciTom Olson, ARM<br>
174575bd8deadSopenharmony_ciBrian Paul, VMware<br>
174585bd8deadSopenharmony_ciAcorn Pooley, NVIDIA<br>
174595bd8deadSopenharmony_ciDaniel Rakos, AMD<br>
174605bd8deadSopenharmony_ciChristophe Riccio, AMD<br>
174615bd8deadSopenharmony_ciKevin Rogovin<br>
174625bd8deadSopenharmony_ciIan Romanick, Intel<br>
174635bd8deadSopenharmony_ciGreg Roth, NVIDIA<br>
174645bd8deadSopenharmony_ciGraham Sellers, AMD<br>
174655bd8deadSopenharmony_ciDave Shreiner, ARM<br>
174665bd8deadSopenharmony_ciJeremy Sandmel, Apple<br>
174675bd8deadSopenharmony_ciRobert Simpson, Qualcomm<br>
174685bd8deadSopenharmony_ciEric Werness, NVIDIA<br>
174695bd8deadSopenharmony_ciMark Young, AMD</p>
174705bd8deadSopenharmony_ci</div>
174715bd8deadSopenharmony_ci</div>
174725bd8deadSopenharmony_ci</div>
174735bd8deadSopenharmony_ci<div class="sect1">
174745bd8deadSopenharmony_ci<h2 id="references">11. Normative References</h2>
174755bd8deadSopenharmony_ci<div class="sectionbody">
174765bd8deadSopenharmony_ci<div class="olist arabic">
174775bd8deadSopenharmony_ci<ol class="arabic">
174785bd8deadSopenharmony_ci<li>
174795bd8deadSopenharmony_ci<p>International Standard ISO/IEC 14882:1998(E).
174805bd8deadSopenharmony_ciProgramming Languages - C++. Referenced for preprocessor only</p>
174815bd8deadSopenharmony_ci</li>
174825bd8deadSopenharmony_ci<li>
174835bd8deadSopenharmony_ci<p>&#8220;OpenGL<sup>R</sup> ES, Version 3.2&#8221;,
174845bd8deadSopenharmony_ci<a href="https://www.khronos.org/registry/OpenGL/index_es.php" class="bare">https://www.khronos.org/registry/OpenGL/index_es.php</a>, November 3, 2016.</p>
174855bd8deadSopenharmony_ci</li>
174865bd8deadSopenharmony_ci<li>
174875bd8deadSopenharmony_ci<p>&#8220;The OpenGL<sup>R</sup> Graphics System: A Specification, Version 4.6 (Core
174885bd8deadSopenharmony_ciProfile)&#8221;, <a href="https://www.khronos.org/registry/OpenGL/index_gl.php" class="bare">https://www.khronos.org/registry/OpenGL/index_gl.php</a>, June
174895bd8deadSopenharmony_ci1, 2016.</p>
174905bd8deadSopenharmony_ci</li>
174915bd8deadSopenharmony_ci<li>
174925bd8deadSopenharmony_ci<p>IEEE 754-2008.
174935bd8deadSopenharmony_ci<em>IEEE Standard for Floating-Point Arithmetic</em></p>
174945bd8deadSopenharmony_ci</li>
174955bd8deadSopenharmony_ci<li>
174965bd8deadSopenharmony_ci<p>&#8220;SPIR-V Specification, Version 1.3, Revision 7&#8221; ,
174975bd8deadSopenharmony_ci<a href="https://www.khronos.org/registry/spir-v/" class="bare">https://www.khronos.org/registry/spir-v/</a>.</p>
174985bd8deadSopenharmony_ci</li>
174995bd8deadSopenharmony_ci<li>
175005bd8deadSopenharmony_ci<p>&#8220;Vulkan<sup>R</sup> 1.1.105 - A Specification&#8221;,
175015bd8deadSopenharmony_ci<a href="https://www.khronos.org/registry/vulkan/" class="bare">https://www.khronos.org/registry/vulkan/</a>,
175025bd8deadSopenharmony_ciMarch 19, 2019.</p>
175035bd8deadSopenharmony_ci</li>
175045bd8deadSopenharmony_ci</ol>
175055bd8deadSopenharmony_ci</div>
175065bd8deadSopenharmony_ci</div>
175075bd8deadSopenharmony_ci</div>
175085bd8deadSopenharmony_ci<div class="sect1">
175095bd8deadSopenharmony_ci<h2 id="_non_normative_spir_v_mappings">12. Non-Normative SPIR-V Mappings</h2>
175105bd8deadSopenharmony_ci<div class="sectionbody">
175115bd8deadSopenharmony_ci<div class="paragraph">
175125bd8deadSopenharmony_ci<p>This appendix includes:</p>
175135bd8deadSopenharmony_ci</div>
175145bd8deadSopenharmony_ci<div class="ulist">
175155bd8deadSopenharmony_ci<ul>
175165bd8deadSopenharmony_ci<li>
175175bd8deadSopenharmony_ci<p>a comparision of feature differences with SPIR-V versus without, for both Vulkan and OpenGL</p>
175185bd8deadSopenharmony_ci</li>
175195bd8deadSopenharmony_ci<li>
175205bd8deadSopenharmony_ci<p>a discussion of how GLSL features logically map to SPIR-V features.</p>
175215bd8deadSopenharmony_ci</li>
175225bd8deadSopenharmony_ci</ul>
175235bd8deadSopenharmony_ci</div>
175245bd8deadSopenharmony_ci<div class="sect2">
175255bd8deadSopenharmony_ci<h3 id="_feature_comparisons">12.1. Feature Comparisons</h3>
175265bd8deadSopenharmony_ci<div class="paragraph">
175275bd8deadSopenharmony_ci<p>The following features are removed for both OpenGL and Vulkan:</p>
175285bd8deadSopenharmony_ci</div>
175295bd8deadSopenharmony_ci<div class="ulist">
175305bd8deadSopenharmony_ci<ul>
175315bd8deadSopenharmony_ci<li>
175325bd8deadSopenharmony_ci<p>subroutines</p>
175335bd8deadSopenharmony_ci</li>
175345bd8deadSopenharmony_ci<li>
175355bd8deadSopenharmony_ci<p>shared and packed block layouts</p>
175365bd8deadSopenharmony_ci</li>
175375bd8deadSopenharmony_ci<li>
175385bd8deadSopenharmony_ci<p>the already deprecated texturing functions (e.g., <code>texture2D()</code>)</p>
175395bd8deadSopenharmony_ci</li>
175405bd8deadSopenharmony_ci<li>
175415bd8deadSopenharmony_ci<p>the already deprecated noise functions (e.g., <code>noise1()</code>)</p>
175425bd8deadSopenharmony_ci</li>
175435bd8deadSopenharmony_ci<li>
175445bd8deadSopenharmony_ci<p>compatibility-profile features</p>
175455bd8deadSopenharmony_ci</li>
175465bd8deadSopenharmony_ci<li>
175475bd8deadSopenharmony_ci<p><em>gl_DepthRangeParameters</em> and <em>gl_NumSamples</em></p>
175485bd8deadSopenharmony_ci</li>
175495bd8deadSopenharmony_ci</ul>
175505bd8deadSopenharmony_ci</div>
175515bd8deadSopenharmony_ci<div class="paragraph">
175525bd8deadSopenharmony_ci<p>Vulkan removed the following features, which are still present for OpenGL:</p>
175535bd8deadSopenharmony_ci</div>
175545bd8deadSopenharmony_ci<div class="ulist">
175555bd8deadSopenharmony_ci<ul>
175565bd8deadSopenharmony_ci<li>
175575bd8deadSopenharmony_ci<p>Default uniforms, for non-opaque types:
175585bd8deadSopenharmony_ciThe <strong>UniformConstant</strong> storage class can be used on individual
175595bd8deadSopenharmony_civariables at global scope. (That is, uniforms don&#8217;t have to be in a
175605bd8deadSopenharmony_ciblock, unless they are built-in members that are in block in GLSL
175615bd8deadSopenharmony_civersion 4.5 or above.)</p>
175625bd8deadSopenharmony_ci</li>
175635bd8deadSopenharmony_ci<li>
175645bd8deadSopenharmony_ci<p>GLSL atomic-counter bindings have the <em>offset</em> layout qualifier &#8594;
175655bd8deadSopenharmony_ciSPIR-V <strong>AtomicCounter</strong> storage class using the <strong>Offset</strong> decoration</p>
175665bd8deadSopenharmony_ci</li>
175675bd8deadSopenharmony_ci<li>
175685bd8deadSopenharmony_ci<p>GLSL <em>origin_lower_left</em> &#8594; SPIR-V <strong>OriginLowerLeft</strong></p>
175695bd8deadSopenharmony_ci</li>
175705bd8deadSopenharmony_ci<li>
175715bd8deadSopenharmony_ci<p>special rules for locations for input doubles in the vertex shader</p>
175725bd8deadSopenharmony_ci</li>
175735bd8deadSopenharmony_ci<li>
175745bd8deadSopenharmony_ci<p><em>gl_VertexID</em> and <em>gl_InstanceID</em> (more detail follows)</p>
175755bd8deadSopenharmony_ci</li>
175765bd8deadSopenharmony_ci</ul>
175775bd8deadSopenharmony_ci</div>
175785bd8deadSopenharmony_ci<div class="paragraph">
175795bd8deadSopenharmony_ci<p>The following features are added for both OpenGL and Vulkan:</p>
175805bd8deadSopenharmony_ci</div>
175815bd8deadSopenharmony_ci<div class="ulist">
175825bd8deadSopenharmony_ci<ul>
175835bd8deadSopenharmony_ci<li>
175845bd8deadSopenharmony_ci<p>specialization constants</p>
175855bd8deadSopenharmony_ci</li>
175865bd8deadSopenharmony_ci<li>
175875bd8deadSopenharmony_ci<p><em>offset</em> can organize members in a different order than declaration order</p>
175885bd8deadSopenharmony_ci</li>
175895bd8deadSopenharmony_ci<li>
175905bd8deadSopenharmony_ci<p><em>offset</em> and <em>align</em> layout qualifiers for uniform/buffer blocks for
175915bd8deadSopenharmony_civersions that did not support them</p>
175925bd8deadSopenharmony_ci</li>
175935bd8deadSopenharmony_ci</ul>
175945bd8deadSopenharmony_ci</div>
175955bd8deadSopenharmony_ci<div class="paragraph">
175965bd8deadSopenharmony_ci<p>Vulkan Only: The following features are added:</p>
175975bd8deadSopenharmony_ci</div>
175985bd8deadSopenharmony_ci<div class="ulist">
175995bd8deadSopenharmony_ci<ul>
176005bd8deadSopenharmony_ci<li>
176015bd8deadSopenharmony_ci<p>push-constant buffers</p>
176025bd8deadSopenharmony_ci</li>
176035bd8deadSopenharmony_ci<li>
176045bd8deadSopenharmony_ci<p>shader combining of separate textures and samplers (SPIR-V <strong>OpTypeSampler</strong>)</p>
176055bd8deadSopenharmony_ci</li>
176065bd8deadSopenharmony_ci<li>
176075bd8deadSopenharmony_ci<p>descriptor sets (<strong>DescriptorSet</strong> must be 0, if present)</p>
176085bd8deadSopenharmony_ci</li>
176095bd8deadSopenharmony_ci<li>
176105bd8deadSopenharmony_ci<p><em>gl_VertexIndex</em> and <em>gl_InstanceIndex</em></p>
176115bd8deadSopenharmony_ci</li>
176125bd8deadSopenharmony_ci<li>
176135bd8deadSopenharmony_ci<p>subpass-input targets and input attachments (<em>input_attachment_index</em>)</p>
176145bd8deadSopenharmony_ci</li>
176155bd8deadSopenharmony_ci</ul>
176165bd8deadSopenharmony_ci</div>
176175bd8deadSopenharmony_ci<div class="paragraph">
176185bd8deadSopenharmony_ci<p>The following features are changed in both OpenGL and Vulkan:</p>
176195bd8deadSopenharmony_ci</div>
176205bd8deadSopenharmony_ci<div class="ulist">
176215bd8deadSopenharmony_ci<ul>
176225bd8deadSopenharmony_ci<li>
176235bd8deadSopenharmony_ci<p><em>gl_FragColor</em> will no longer indicate an implicit broadcast</p>
176245bd8deadSopenharmony_ci</li>
176255bd8deadSopenharmony_ci</ul>
176265bd8deadSopenharmony_ci</div>
176275bd8deadSopenharmony_ci<div class="paragraph">
176285bd8deadSopenharmony_ci<p>Vulkan Only: The following features are changed:</p>
176295bd8deadSopenharmony_ci</div>
176305bd8deadSopenharmony_ci<div class="ulist">
176315bd8deadSopenharmony_ci<ul>
176325bd8deadSopenharmony_ci<li>
176335bd8deadSopenharmony_ci<p>precision qualifiers (<strong>mediump</strong> and <strong>lowp</strong>) will be respected for all
176345bd8deadSopenharmony_civersions, not dropped for desktop versions (default precision for
176355bd8deadSopenharmony_cidesktop versions is <strong>highp</strong> for all types)</p>
176365bd8deadSopenharmony_ci</li>
176375bd8deadSopenharmony_ci<li>
176385bd8deadSopenharmony_ci<p>arrays of uniforms and buffer blocks take only one binding number for
176395bd8deadSopenharmony_cithe entire object, not one per array element</p>
176405bd8deadSopenharmony_ci</li>
176415bd8deadSopenharmony_ci<li>
176425bd8deadSopenharmony_ci<p>the default origin is <em>origin_upper_left</em> instead of <em>origin_lower_left</em></p>
176435bd8deadSopenharmony_ci</li>
176445bd8deadSopenharmony_ci</ul>
176455bd8deadSopenharmony_ci</div>
176465bd8deadSopenharmony_ci<div class="paragraph">
176475bd8deadSopenharmony_ci<p>Vulkan does not allow multi-dimensional arrays of resources like
176485bd8deadSopenharmony_ciUBOs and SSBOs in its SPIR-V environment spec. SPIR-V supports
176495bd8deadSopenharmony_ciit and OpenGL already allows this for GLSL shaders. SPIR-V
176505bd8deadSopenharmony_cifor OpenGL also allows it.</p>
176515bd8deadSopenharmony_ci</div>
176525bd8deadSopenharmony_ci</div>
176535bd8deadSopenharmony_ci<div class="sect2">
176545bd8deadSopenharmony_ci<h3 id="_mapping_from_glsl_to_spir_v">12.2. Mapping from GLSL to SPIR-V</h3>
176555bd8deadSopenharmony_ci<div class="sect3">
176565bd8deadSopenharmony_ci<h4 id="_specialization_constants">12.2.1. Specialization Constants</h4>
176575bd8deadSopenharmony_ci<div class="paragraph">
176585bd8deadSopenharmony_ci<p>SPIR-V specialization constants, which can be set later by the client API,
176595bd8deadSopenharmony_cican be declared using <code>layout(constant_id=&#8230;&#8203;)</code>. For example, to make a
176605bd8deadSopenharmony_cispecialization constant with a default value of 12:</p>
176615bd8deadSopenharmony_ci</div>
176625bd8deadSopenharmony_ci<div class="literalblock">
176635bd8deadSopenharmony_ci<div class="content">
176645bd8deadSopenharmony_ci<pre>layout(constant_id = 17) const int arraySize = 12;</pre>
176655bd8deadSopenharmony_ci</div>
176665bd8deadSopenharmony_ci</div>
176675bd8deadSopenharmony_ci<div class="paragraph">
176685bd8deadSopenharmony_ci<p>Above, <code>17</code> is the ID by which the API or other tools can later refer to
176695bd8deadSopenharmony_cithis specific specialization constant.  The API or an intermediate tool can
176705bd8deadSopenharmony_cithen change its value to another constant integer before it is fully
176715bd8deadSopenharmony_cilowered to executable code.  If it is never changed before final lowering,
176725bd8deadSopenharmony_ciit will retain the value of 12.</p>
176735bd8deadSopenharmony_ci</div>
176745bd8deadSopenharmony_ci<div class="paragraph">
176755bd8deadSopenharmony_ci<p>Specialization constants have const semantics, except they don&#8217;t fold.
176765bd8deadSopenharmony_ciHence, an array can be declared with <code>arraySize</code> from above:</p>
176775bd8deadSopenharmony_ci</div>
176785bd8deadSopenharmony_ci<div class="literalblock">
176795bd8deadSopenharmony_ci<div class="content">
176805bd8deadSopenharmony_ci<pre>vec4 data[arraySize];  // legal, even though arraySize might change</pre>
176815bd8deadSopenharmony_ci</div>
176825bd8deadSopenharmony_ci</div>
176835bd8deadSopenharmony_ci<div class="paragraph">
176845bd8deadSopenharmony_ci<p>Specialization constants can be in expressions:</p>
176855bd8deadSopenharmony_ci</div>
176865bd8deadSopenharmony_ci<div class="literalblock">
176875bd8deadSopenharmony_ci<div class="content">
176885bd8deadSopenharmony_ci<pre>vec4 data2[arraySize + 2];</pre>
176895bd8deadSopenharmony_ci</div>
176905bd8deadSopenharmony_ci</div>
176915bd8deadSopenharmony_ci<div class="paragraph">
176925bd8deadSopenharmony_ci<p>This will make <code>data2</code> be sized by 2 more than whatever constant value
176935bd8deadSopenharmony_ci<code>arraySize</code> has when it is time to lower the shader to executable code.</p>
176945bd8deadSopenharmony_ci</div>
176955bd8deadSopenharmony_ci<div class="paragraph">
176965bd8deadSopenharmony_ci<p>An expression formed with specialization constants also behaves in the
176975bd8deadSopenharmony_cishader like a specialization constant, not a like a constant.</p>
176985bd8deadSopenharmony_ci</div>
176995bd8deadSopenharmony_ci<div class="literalblock">
177005bd8deadSopenharmony_ci<div class="content">
177015bd8deadSopenharmony_ci<pre>arraySize + 2       // a specialization constant (with no constant_id)</pre>
177025bd8deadSopenharmony_ci</div>
177035bd8deadSopenharmony_ci</div>
177045bd8deadSopenharmony_ci<div class="paragraph">
177055bd8deadSopenharmony_ci<p>Such expressions can be used in the same places as a constant.</p>
177065bd8deadSopenharmony_ci</div>
177075bd8deadSopenharmony_ci<div class="paragraph">
177085bd8deadSopenharmony_ci<p>The <em>constant_id</em> can only be applied to a scalar integer, a scalar floating-point
177095bd8deadSopenharmony_cior a scalar Boolean.</p>
177105bd8deadSopenharmony_ci</div>
177115bd8deadSopenharmony_ci<div class="paragraph">
177125bd8deadSopenharmony_ci<p>Only basic operators and constructors can be applied to a specialization
177135bd8deadSopenharmony_ciconstant and still result in a specialization constant:</p>
177145bd8deadSopenharmony_ci</div>
177155bd8deadSopenharmony_ci<div class="literalblock">
177165bd8deadSopenharmony_ci<div class="content">
177175bd8deadSopenharmony_ci<pre>layout(constant_id = 17) const int arraySize = 12;
177185bd8deadSopenharmony_cisin(float(arraySize));    // result is not a specialization constant</pre>
177195bd8deadSopenharmony_ci</div>
177205bd8deadSopenharmony_ci</div>
177215bd8deadSopenharmony_ci<div class="paragraph">
177225bd8deadSopenharmony_ci<p>While SPIR-V specialization constants are only for scalars, a vector
177235bd8deadSopenharmony_cican be made by operations on scalars:</p>
177245bd8deadSopenharmony_ci</div>
177255bd8deadSopenharmony_ci<div class="literalblock">
177265bd8deadSopenharmony_ci<div class="content">
177275bd8deadSopenharmony_ci<pre>layout(constant_id = 18) const int scX = 1;
177285bd8deadSopenharmony_cilayout(constant_id = 19) const int scZ = 1;
177295bd8deadSopenharmony_ciconst vec3 scVec = vec3(scX, 1, scZ);  // partially specialized vector</pre>
177305bd8deadSopenharmony_ci</div>
177315bd8deadSopenharmony_ci</div>
177325bd8deadSopenharmony_ci<div class="paragraph">
177335bd8deadSopenharmony_ci<p>A built-in variable can have a <em>constant_id</em> attached to it:</p>
177345bd8deadSopenharmony_ci</div>
177355bd8deadSopenharmony_ci<div class="literalblock">
177365bd8deadSopenharmony_ci<div class="content">
177375bd8deadSopenharmony_ci<pre>layout(constant_id = 18) gl_MaxImageUnits;</pre>
177385bd8deadSopenharmony_ci</div>
177395bd8deadSopenharmony_ci</div>
177405bd8deadSopenharmony_ci<div class="paragraph">
177415bd8deadSopenharmony_ci<p>This makes it behave as a specialization constant.  It is not a full
177425bd8deadSopenharmony_ciredeclaration; all other characteristics are left intact from the
177435bd8deadSopenharmony_cioriginal built-in declaration.</p>
177445bd8deadSopenharmony_ci</div>
177455bd8deadSopenharmony_ci<div class="paragraph">
177465bd8deadSopenharmony_ci<p>The built-in vector <em>gl_WorkGroupSize</em> can be specialized using special
177475bd8deadSopenharmony_cilayout <code>local_size_{xyz}_id</code> applied to the <strong>in</strong> qualifier.  For example:</p>
177485bd8deadSopenharmony_ci</div>
177495bd8deadSopenharmony_ci<div class="literalblock">
177505bd8deadSopenharmony_ci<div class="content">
177515bd8deadSopenharmony_ci<pre>layout(local_size_x_id = 18, local_size_z_id = 19) in;</pre>
177525bd8deadSopenharmony_ci</div>
177535bd8deadSopenharmony_ci</div>
177545bd8deadSopenharmony_ci<div class="paragraph">
177555bd8deadSopenharmony_ci<p>This leaves <em>gl_WorkGroupSize.y</em> as a non-specialization constant, with
177565bd8deadSopenharmony_ci<em>gl_WorkGroupSize</em> being a partially specialized vector.  Its <em>x</em> and <em>z</em>
177575bd8deadSopenharmony_cicomponents can be later specialized using the ID&#8217;s 18 and 19.</p>
177585bd8deadSopenharmony_ci</div>
177595bd8deadSopenharmony_ci</div>
177605bd8deadSopenharmony_ci<div class="sect3">
177615bd8deadSopenharmony_ci<h4 id="_vulkan_only_push_constants">12.2.2. Vulkan Only: Push Constants</h4>
177625bd8deadSopenharmony_ci<div class="paragraph">
177635bd8deadSopenharmony_ci<p>Push constants reside in a uniform block declared using the new
177645bd8deadSopenharmony_cilayout-qualifier-id <em>push_constant</em> applied to a uniform-block declaration.
177655bd8deadSopenharmony_ciThe API writes a set of constants to a push-constant buffer, and the shader
177665bd8deadSopenharmony_cireads them from a <em>push_constant</em> block:</p>
177675bd8deadSopenharmony_ci</div>
177685bd8deadSopenharmony_ci<div class="literalblock">
177695bd8deadSopenharmony_ci<div class="content">
177705bd8deadSopenharmony_ci<pre>layout(push_constant) uniform BlockName {
177715bd8deadSopenharmony_ci    int member1;
177725bd8deadSopenharmony_ci    float member2;
177735bd8deadSopenharmony_ci    ...
177745bd8deadSopenharmony_ci} InstanceName; // optional instance name
177755bd8deadSopenharmony_ci... = InstanceName.member2; // read a push constant</pre>
177765bd8deadSopenharmony_ci</div>
177775bd8deadSopenharmony_ci</div>
177785bd8deadSopenharmony_ci<div class="paragraph">
177795bd8deadSopenharmony_ci<p>The memory accounting used for the <em>push_constant</em> uniform block is different
177805bd8deadSopenharmony_cithan for other uniform blocks:  There is a separate small pool of memory
177815bd8deadSopenharmony_ciit must fit within.  By default, a <em>push_constant</em> buffer follows the std430
177825bd8deadSopenharmony_cipacking rules.</p>
177835bd8deadSopenharmony_ci</div>
177845bd8deadSopenharmony_ci</div>
177855bd8deadSopenharmony_ci<div class="sect3">
177865bd8deadSopenharmony_ci<h4 id="_vulkan_only_descriptor_sets">12.2.3. Vulkan Only: Descriptor Sets</h4>
177875bd8deadSopenharmony_ci<div class="paragraph">
177885bd8deadSopenharmony_ci<p>Each shader resource in a descriptor set is assigned a tuple of (set
177895bd8deadSopenharmony_cinumber, binding number, array element) that defines its location within
177905bd8deadSopenharmony_cia descriptor set layout.
177915bd8deadSopenharmony_ciIn GLSL, the set number and binding number are assigned via the <em>set</em>
177925bd8deadSopenharmony_ciand <em>binding</em> layout qualifiers respectively, and the array element is
177935bd8deadSopenharmony_ciimplicitly assigned consecutively starting with index equal to zero for
177945bd8deadSopenharmony_cithe first element of an array (and array element is zero for non-array
177955bd8deadSopenharmony_civariables):</p>
177965bd8deadSopenharmony_ci</div>
177975bd8deadSopenharmony_ci<div class="literalblock">
177985bd8deadSopenharmony_ci<div class="content">
177995bd8deadSopenharmony_ci<pre>// Assign set number = M, binding number = N, array element = 0
178005bd8deadSopenharmony_cilayout (set=M, binding=N) uniform sampler2D variableName;</pre>
178015bd8deadSopenharmony_ci</div>
178025bd8deadSopenharmony_ci</div>
178035bd8deadSopenharmony_ci<div class="literalblock">
178045bd8deadSopenharmony_ci<div class="content">
178055bd8deadSopenharmony_ci<pre>// Assign set number = M, binding number = N for all array elements,
178065bd8deadSopenharmony_ci// and array element = i for the ith member of an array of size I.
178075bd8deadSopenharmony_cilayout (set=M, binding=N) uniform sampler2D variableNameArray[I];</pre>
178085bd8deadSopenharmony_ci</div>
178095bd8deadSopenharmony_ci</div>
178105bd8deadSopenharmony_ci<div class="paragraph">
178115bd8deadSopenharmony_ci<p>For example, two combined texture/sampler objects can be declared in two
178125bd8deadSopenharmony_cidifferent descriptor sets as follows</p>
178135bd8deadSopenharmony_ci</div>
178145bd8deadSopenharmony_ci<div class="literalblock">
178155bd8deadSopenharmony_ci<div class="content">
178165bd8deadSopenharmony_ci<pre>layout(set = 0, binding = 0) uniform sampler2D ts3;
178175bd8deadSopenharmony_cilayout(set = 1, binding = 0) uniform sampler2D ts4;</pre>
178185bd8deadSopenharmony_ci</div>
178195bd8deadSopenharmony_ci</div>
178205bd8deadSopenharmony_ci<div class="paragraph">
178215bd8deadSopenharmony_ci<p>See the API documentation for more detail on the operation model of
178225bd8deadSopenharmony_cidescriptor sets.</p>
178235bd8deadSopenharmony_ci</div>
178245bd8deadSopenharmony_ci</div>
178255bd8deadSopenharmony_ci<div class="sect3">
178265bd8deadSopenharmony_ci<h4 id="_vulkan_only_samplers_images_textures_and_buffers">12.2.4. Vulkan Only: Samplers, Images, Textures, and Buffers</h4>
178275bd8deadSopenharmony_ci<div class="sect4">
178285bd8deadSopenharmony_ci<h5 id="_storage_images">Storage Images</h5>
178295bd8deadSopenharmony_ci<div class="paragraph">
178305bd8deadSopenharmony_ci<p>Storage images are declared in GLSL shader source using uniform image
178315bd8deadSopenharmony_civariables of the appropriate dimensionality as well as a format layout
178325bd8deadSopenharmony_ciqualifier (if necessary):</p>
178335bd8deadSopenharmony_ci</div>
178345bd8deadSopenharmony_ci<div class="literalblock">
178355bd8deadSopenharmony_ci<div class="content">
178365bd8deadSopenharmony_ci<pre>layout (set=m, binding=n, r32f) uniform image2D myStorageImage;</pre>
178375bd8deadSopenharmony_ci</div>
178385bd8deadSopenharmony_ci</div>
178395bd8deadSopenharmony_ci<div class="paragraph">
178405bd8deadSopenharmony_ci<p>Which maps to the following SPIR-V:</p>
178415bd8deadSopenharmony_ci</div>
178425bd8deadSopenharmony_ci<div class="literalblock">
178435bd8deadSopenharmony_ci<div class="content">
178445bd8deadSopenharmony_ci<pre>        ...
178455bd8deadSopenharmony_ci%1 = OpExtInstImport "GLSL.std.450"
178465bd8deadSopenharmony_ci        ...
178475bd8deadSopenharmony_ci        OpName %9 "myStorageImage"
178485bd8deadSopenharmony_ci        OpDecorate %9 DescriptorSet m
178495bd8deadSopenharmony_ci        OpDecorate %9 Binding n
178505bd8deadSopenharmony_ci%2 = OpTypeVoid
178515bd8deadSopenharmony_ci%3 = OpTypeFunction %2
178525bd8deadSopenharmony_ci%6 = OpTypeFloat 32
178535bd8deadSopenharmony_ci%7 = OpTypeImage %6 2D 0 0 0 2 R32f
178545bd8deadSopenharmony_ci%8 = OpTypePointer UniformConstant %7
178555bd8deadSopenharmony_ci%9 = OpVariable %8 UniformConstant
178565bd8deadSopenharmony_ci        ...</pre>
178575bd8deadSopenharmony_ci</div>
178585bd8deadSopenharmony_ci</div>
178595bd8deadSopenharmony_ci</div>
178605bd8deadSopenharmony_ci<div class="sect4">
178615bd8deadSopenharmony_ci<h5 id="_samplers">Samplers</h5>
178625bd8deadSopenharmony_ci<div class="paragraph">
178635bd8deadSopenharmony_ci<p>SPIR-V samplers are declared in GLSL shader source using uniform <strong>sampler</strong> and
178645bd8deadSopenharmony_ci<strong>samplerShadow</strong> types:</p>
178655bd8deadSopenharmony_ci</div>
178665bd8deadSopenharmony_ci<div class="literalblock">
178675bd8deadSopenharmony_ci<div class="content">
178685bd8deadSopenharmony_ci<pre>layout (set=m, binding=n) uniform sampler mySampler;</pre>
178695bd8deadSopenharmony_ci</div>
178705bd8deadSopenharmony_ci</div>
178715bd8deadSopenharmony_ci<div class="paragraph">
178725bd8deadSopenharmony_ci<p>Which maps to the following SPIR-V:</p>
178735bd8deadSopenharmony_ci</div>
178745bd8deadSopenharmony_ci<div class="literalblock">
178755bd8deadSopenharmony_ci<div class="content">
178765bd8deadSopenharmony_ci<pre>        ...
178775bd8deadSopenharmony_ci%1 = OpExtInstImport "GLSL.std.450"
178785bd8deadSopenharmony_ci        ...
178795bd8deadSopenharmony_ci        OpName %8 "mySampler"
178805bd8deadSopenharmony_ci        OpDecorate %8 DescriptorSet m
178815bd8deadSopenharmony_ci        OpDecorate %8 Binding n
178825bd8deadSopenharmony_ci%2 = OpTypeVoid
178835bd8deadSopenharmony_ci%3 = OpTypeFunction %2
178845bd8deadSopenharmony_ci%6 = OpTypeSampler
178855bd8deadSopenharmony_ci%7 = OpTypePointer UniformConstant %6
178865bd8deadSopenharmony_ci%8 = OpVariable %7 UniformConstant
178875bd8deadSopenharmony_ci        ...</pre>
178885bd8deadSopenharmony_ci</div>
178895bd8deadSopenharmony_ci</div>
178905bd8deadSopenharmony_ci</div>
178915bd8deadSopenharmony_ci<div class="sect4">
178925bd8deadSopenharmony_ci<h5 id="_textures_sampled_images">Textures (Sampled Images)</h5>
178935bd8deadSopenharmony_ci<div class="paragraph">
178945bd8deadSopenharmony_ci<p>Textures are declared in GLSL shader source using uniform texture
178955bd8deadSopenharmony_civariables of the appropriate dimensionality:</p>
178965bd8deadSopenharmony_ci</div>
178975bd8deadSopenharmony_ci<div class="literalblock">
178985bd8deadSopenharmony_ci<div class="content">
178995bd8deadSopenharmony_ci<pre>layout (set=m, binding=n) uniform texture2D mySampledImage;</pre>
179005bd8deadSopenharmony_ci</div>
179015bd8deadSopenharmony_ci</div>
179025bd8deadSopenharmony_ci<div class="paragraph">
179035bd8deadSopenharmony_ci<p>Which maps to the following SPIR-V:</p>
179045bd8deadSopenharmony_ci</div>
179055bd8deadSopenharmony_ci<div class="literalblock">
179065bd8deadSopenharmony_ci<div class="content">
179075bd8deadSopenharmony_ci<pre>        ...
179085bd8deadSopenharmony_ci%1 = OpExtInstImport "GLSL.std.450"
179095bd8deadSopenharmony_ci        ...
179105bd8deadSopenharmony_ci        OpName %9 "mySampledImage"
179115bd8deadSopenharmony_ci        OpDecorate %9 DescriptorSet m
179125bd8deadSopenharmony_ci        OpDecorate %9 Binding n
179135bd8deadSopenharmony_ci%2 = OpTypeVoid
179145bd8deadSopenharmony_ci%3 = OpTypeFunction %2
179155bd8deadSopenharmony_ci%6 = OpTypeFloat 32
179165bd8deadSopenharmony_ci%7 = OpTypeImage %6 2D 0 0 0 1 Unknown
179175bd8deadSopenharmony_ci%8 = OpTypePointer UniformConstant %7
179185bd8deadSopenharmony_ci%9 = OpVariable %8 UniformConstant
179195bd8deadSopenharmony_ci        ...</pre>
179205bd8deadSopenharmony_ci</div>
179215bd8deadSopenharmony_ci</div>
179225bd8deadSopenharmony_ci</div>
179235bd8deadSopenharmony_ci<div class="sect4">
179245bd8deadSopenharmony_ci<h5 id="_combined_texture_and_samplers">Combined Texture and Samplers</h5>
179255bd8deadSopenharmony_ci<div class="paragraph">
179265bd8deadSopenharmony_ci<p>Combined textures and samplers are declared in GLSL shader source using
179275bd8deadSopenharmony_ciuniform texture-combined sampler variables of the appropriate dimensionality:</p>
179285bd8deadSopenharmony_ci</div>
179295bd8deadSopenharmony_ci<div class="literalblock">
179305bd8deadSopenharmony_ci<div class="content">
179315bd8deadSopenharmony_ci<pre>layout (set=m, binding=n) uniform sampler2D myCombinedImageSampler;</pre>
179325bd8deadSopenharmony_ci</div>
179335bd8deadSopenharmony_ci</div>
179345bd8deadSopenharmony_ci<div class="paragraph">
179355bd8deadSopenharmony_ci<p>Which maps to the following SPIR-V:</p>
179365bd8deadSopenharmony_ci</div>
179375bd8deadSopenharmony_ci<div class="literalblock">
179385bd8deadSopenharmony_ci<div class="content">
179395bd8deadSopenharmony_ci<pre>        ...
179405bd8deadSopenharmony_ci%1 = OpExtInstImport "GLSL.std.450"
179415bd8deadSopenharmony_ci        ...
179425bd8deadSopenharmony_ci        OpName %10 "myCombinedImageSampler"
179435bd8deadSopenharmony_ci        OpDecorate %10 DescriptorSet m
179445bd8deadSopenharmony_ci        OpDecorate %10 Binding n
179455bd8deadSopenharmony_ci%2 = OpTypeVoid
179465bd8deadSopenharmony_ci%3 = OpTypeFunction %2
179475bd8deadSopenharmony_ci%6 = OpTypeFloat 32
179485bd8deadSopenharmony_ci%7 = OpTypeImage %6 2D 0 0 0 1 Unknown
179495bd8deadSopenharmony_ci%8 = OpTypeSampledImage %7
179505bd8deadSopenharmony_ci%9 = OpTypePointer UniformConstant %8
179515bd8deadSopenharmony_ci%10 = OpVariable %9 UniformConstant
179525bd8deadSopenharmony_ci        ...</pre>
179535bd8deadSopenharmony_ci</div>
179545bd8deadSopenharmony_ci</div>
179555bd8deadSopenharmony_ci<div class="paragraph">
179565bd8deadSopenharmony_ci<p>Note that a combined image sampler descriptor can be referred to as just
179575bd8deadSopenharmony_cian image or sampler in the shader as per the above sections.</p>
179585bd8deadSopenharmony_ci</div>
179595bd8deadSopenharmony_ci</div>
179605bd8deadSopenharmony_ci<div class="sect4">
179615bd8deadSopenharmony_ci<h5 id="_combining_separate_samplers_and_textures">Combining Separate Samplers and Textures</h5>
179625bd8deadSopenharmony_ci<div class="paragraph">
179635bd8deadSopenharmony_ci<p>A sampler, declared with the keyword <strong>sampler</strong>, contains just filtering
179645bd8deadSopenharmony_ciinformation, containing neither a texture nor an image:</p>
179655bd8deadSopenharmony_ci</div>
179665bd8deadSopenharmony_ci<div class="literalblock">
179675bd8deadSopenharmony_ci<div class="content">
179685bd8deadSopenharmony_ci<pre>uniform sampler s;    // a handle to filtering information</pre>
179695bd8deadSopenharmony_ci</div>
179705bd8deadSopenharmony_ci</div>
179715bd8deadSopenharmony_ci<div class="paragraph">
179725bd8deadSopenharmony_ci<p>A texture, declared with keywords like <strong>texture2D</strong>, contains just image
179735bd8deadSopenharmony_ciinformation, not filtering information:</p>
179745bd8deadSopenharmony_ci</div>
179755bd8deadSopenharmony_ci<div class="literalblock">
179765bd8deadSopenharmony_ci<div class="content">
179775bd8deadSopenharmony_ci<pre>uniform texture2D t;  // a handle to a texture (an image in SPIR-V)</pre>
179785bd8deadSopenharmony_ci</div>
179795bd8deadSopenharmony_ci</div>
179805bd8deadSopenharmony_ci<div class="paragraph">
179815bd8deadSopenharmony_ci<p>Constructors can then be used to combine a sampler and a texture at the
179825bd8deadSopenharmony_cipoint of making a texture lookup call:</p>
179835bd8deadSopenharmony_ci</div>
179845bd8deadSopenharmony_ci<div class="literalblock">
179855bd8deadSopenharmony_ci<div class="content">
179865bd8deadSopenharmony_ci<pre>texture(sampler2D(t, s), ...);</pre>
179875bd8deadSopenharmony_ci</div>
179885bd8deadSopenharmony_ci</div>
179895bd8deadSopenharmony_ci<div class="paragraph">
179905bd8deadSopenharmony_ci<p>Note, <code>layout()</code> information is omitted above for clarity of this feature.</p>
179915bd8deadSopenharmony_ci</div>
179925bd8deadSopenharmony_ci</div>
179935bd8deadSopenharmony_ci<div class="sect4">
179945bd8deadSopenharmony_ci<h5 id="_texture_buffers_uniform_texel_buffers">Texture Buffers (Uniform Texel Buffers)</h5>
179955bd8deadSopenharmony_ci<div class="paragraph">
179965bd8deadSopenharmony_ci<p>Texture buffers are declared in GLSL shader source using uniform
179975bd8deadSopenharmony_citextureBuffer variables:</p>
179985bd8deadSopenharmony_ci</div>
179995bd8deadSopenharmony_ci<div class="literalblock">
180005bd8deadSopenharmony_ci<div class="content">
180015bd8deadSopenharmony_ci<pre>layout (set=m, binding=n) uniform textureBuffer myUniformTexelBuffer;</pre>
180025bd8deadSopenharmony_ci</div>
180035bd8deadSopenharmony_ci</div>
180045bd8deadSopenharmony_ci<div class="paragraph">
180055bd8deadSopenharmony_ci<p>Which maps to the following SPIR-V:</p>
180065bd8deadSopenharmony_ci</div>
180075bd8deadSopenharmony_ci<div class="literalblock">
180085bd8deadSopenharmony_ci<div class="content">
180095bd8deadSopenharmony_ci<pre>        ...
180105bd8deadSopenharmony_ci%1 = OpExtInstImport "GLSL.std.450"
180115bd8deadSopenharmony_ci        ...
180125bd8deadSopenharmony_ci        OpName %9 "myUniformTexelBuffer"
180135bd8deadSopenharmony_ci        OpDecorate %9 DescriptorSet m
180145bd8deadSopenharmony_ci        OpDecorate %9 Binding n
180155bd8deadSopenharmony_ci%2 = OpTypeVoid
180165bd8deadSopenharmony_ci%3 = OpTypeFunction %2
180175bd8deadSopenharmony_ci%6 = OpTypeFloat 32
180185bd8deadSopenharmony_ci%7 = OpTypeImage %6 Buffer 0 0 0 1 Unknown
180195bd8deadSopenharmony_ci%8 = OpTypePointer UniformConstant %7
180205bd8deadSopenharmony_ci%9 = OpVariable %8 UniformConstant
180215bd8deadSopenharmony_ci        ...</pre>
180225bd8deadSopenharmony_ci</div>
180235bd8deadSopenharmony_ci</div>
180245bd8deadSopenharmony_ci</div>
180255bd8deadSopenharmony_ci<div class="sect4">
180265bd8deadSopenharmony_ci<h5 id="_image_buffers_storage_texel_buffers">Image Buffers (Storage Texel Buffers)</h5>
180275bd8deadSopenharmony_ci<div class="paragraph">
180285bd8deadSopenharmony_ci<p>Image buffers are declared in GLSL shader source using uniform
180295bd8deadSopenharmony_ciimageBuffer variables:</p>
180305bd8deadSopenharmony_ci</div>
180315bd8deadSopenharmony_ci<div class="literalblock">
180325bd8deadSopenharmony_ci<div class="content">
180335bd8deadSopenharmony_ci<pre>layout (set=m, binding=n, r32f) uniform imageBuffer myStorageTexelBuffer;</pre>
180345bd8deadSopenharmony_ci</div>
180355bd8deadSopenharmony_ci</div>
180365bd8deadSopenharmony_ci<div class="paragraph">
180375bd8deadSopenharmony_ci<p>Which maps to the following SPIR-V:</p>
180385bd8deadSopenharmony_ci</div>
180395bd8deadSopenharmony_ci<div class="literalblock">
180405bd8deadSopenharmony_ci<div class="content">
180415bd8deadSopenharmony_ci<pre>        ...
180425bd8deadSopenharmony_ci%1 = OpExtInstImport "GLSL.std.450"
180435bd8deadSopenharmony_ci        ...
180445bd8deadSopenharmony_ci        OpName %9 "myStorageTexelBuffer"
180455bd8deadSopenharmony_ci        OpDecorate %9 DescriptorSet m
180465bd8deadSopenharmony_ci        OpDecorate %9 Binding n
180475bd8deadSopenharmony_ci%2 = OpTypeVoid
180485bd8deadSopenharmony_ci%3 = OpTypeFunction %2
180495bd8deadSopenharmony_ci%6 = OpTypeFloat 32
180505bd8deadSopenharmony_ci%7 = OpTypeImage %6 Buffer 0 0 0 2 R32f
180515bd8deadSopenharmony_ci%8 = OpTypePointer UniformConstant %7
180525bd8deadSopenharmony_ci%9 = OpVariable %8 UniformConstant
180535bd8deadSopenharmony_ci        ...</pre>
180545bd8deadSopenharmony_ci</div>
180555bd8deadSopenharmony_ci</div>
180565bd8deadSopenharmony_ci</div>
180575bd8deadSopenharmony_ci<div class="sect4">
180585bd8deadSopenharmony_ci<h5 id="_storage_buffers">Storage Buffers</h5>
180595bd8deadSopenharmony_ci<div class="paragraph">
180605bd8deadSopenharmony_ci<p>Storage buffers are declared in GLSL shader source using buffer storage
180615bd8deadSopenharmony_ciqualifier and block syntax:</p>
180625bd8deadSopenharmony_ci</div>
180635bd8deadSopenharmony_ci<div class="literalblock">
180645bd8deadSopenharmony_ci<div class="content">
180655bd8deadSopenharmony_ci<pre>layout (set=m, binding=n) buffer myStorageBuffer
180665bd8deadSopenharmony_ci{
180675bd8deadSopenharmony_ci    vec4 myElement[];
180685bd8deadSopenharmony_ci};</pre>
180695bd8deadSopenharmony_ci</div>
180705bd8deadSopenharmony_ci</div>
180715bd8deadSopenharmony_ci<div class="paragraph">
180725bd8deadSopenharmony_ci<p>Which maps to the following SPIR-V:</p>
180735bd8deadSopenharmony_ci</div>
180745bd8deadSopenharmony_ci<div class="literalblock">
180755bd8deadSopenharmony_ci<div class="content">
180765bd8deadSopenharmony_ci<pre>        ...
180775bd8deadSopenharmony_ci%1 = OpExtInstImport "GLSL.std.450"
180785bd8deadSopenharmony_ci        ...
180795bd8deadSopenharmony_ci        OpName %9 "myStorageBuffer"
180805bd8deadSopenharmony_ci        OpMemberName %9 0 "myElement"
180815bd8deadSopenharmony_ci        OpName %11 ""
180825bd8deadSopenharmony_ci        OpDecorate %8 ArrayStride 16
180835bd8deadSopenharmony_ci        OpMemberDecorate %9 0 Offset 0
180845bd8deadSopenharmony_ci        OpDecorate %9 BufferBlock
180855bd8deadSopenharmony_ci        OpDecorate %11 DescriptorSet m
180865bd8deadSopenharmony_ci        OpDecorate %11 Binding n
180875bd8deadSopenharmony_ci%2 = OpTypeVoid
180885bd8deadSopenharmony_ci%3 = OpTypeFunction %2
180895bd8deadSopenharmony_ci%6 = OpTypeFloat 32
180905bd8deadSopenharmony_ci%7 = OpTypeVector %6 4
180915bd8deadSopenharmony_ci%8 = OpTypeRuntimeArray %7
180925bd8deadSopenharmony_ci%9 = OpTypeStruct %8
180935bd8deadSopenharmony_ci%10 = OpTypePointer Uniform %9
180945bd8deadSopenharmony_ci%11 = OpVariable %10 Uniform
180955bd8deadSopenharmony_ci        ...</pre>
180965bd8deadSopenharmony_ci</div>
180975bd8deadSopenharmony_ci</div>
180985bd8deadSopenharmony_ci</div>
180995bd8deadSopenharmony_ci<div class="sect4">
181005bd8deadSopenharmony_ci<h5 id="_uniform_buffers">Uniform Buffers</h5>
181015bd8deadSopenharmony_ci<div class="paragraph">
181025bd8deadSopenharmony_ci<p>Uniform buffers are declared in GLSL shader source using the uniform storage
181035bd8deadSopenharmony_ciqualifier and block syntax:</p>
181045bd8deadSopenharmony_ci</div>
181055bd8deadSopenharmony_ci<div class="literalblock">
181065bd8deadSopenharmony_ci<div class="content">
181075bd8deadSopenharmony_ci<pre>layout (set=m, binding=n) uniform myUniformBuffer
181085bd8deadSopenharmony_ci{
181095bd8deadSopenharmony_ci    vec4 myElement[32];
181105bd8deadSopenharmony_ci};</pre>
181115bd8deadSopenharmony_ci</div>
181125bd8deadSopenharmony_ci</div>
181135bd8deadSopenharmony_ci<div class="paragraph">
181145bd8deadSopenharmony_ci<p>Which maps to the following SPIR-V:</p>
181155bd8deadSopenharmony_ci</div>
181165bd8deadSopenharmony_ci<div class="literalblock">
181175bd8deadSopenharmony_ci<div class="content">
181185bd8deadSopenharmony_ci<pre>        ...
181195bd8deadSopenharmony_ci%1 = OpExtInstImport "GLSL.std.450"
181205bd8deadSopenharmony_ci        ...
181215bd8deadSopenharmony_ci        OpName %11 "myUniformBuffer"
181225bd8deadSopenharmony_ci        OpMemberName %11 0 "myElement"
181235bd8deadSopenharmony_ci        OpName %13 ""
181245bd8deadSopenharmony_ci        OpDecorate %10 ArrayStride 16
181255bd8deadSopenharmony_ci        OpMemberDecorate %11 0 Offset 0
181265bd8deadSopenharmony_ci        OpDecorate %11 Block
181275bd8deadSopenharmony_ci        OpDecorate %13 DescriptorSet m
181285bd8deadSopenharmony_ci        OpDecorate %13 Binding n
181295bd8deadSopenharmony_ci%2 = OpTypeVoid
181305bd8deadSopenharmony_ci%3 = OpTypeFunction %2
181315bd8deadSopenharmony_ci%6 = OpTypeFloat 32
181325bd8deadSopenharmony_ci%7 = OpTypeVector %6 4
181335bd8deadSopenharmony_ci%8 = OpTypeInt 32 0
181345bd8deadSopenharmony_ci%9 = OpConstant %8 32
181355bd8deadSopenharmony_ci%10 = OpTypeArray %7 %9
181365bd8deadSopenharmony_ci%11 = OpTypeStruct %10
181375bd8deadSopenharmony_ci%12 = OpTypePointer Uniform %11
181385bd8deadSopenharmony_ci%13 = OpVariable %12 Uniform
181395bd8deadSopenharmony_ci        ...</pre>
181405bd8deadSopenharmony_ci</div>
181415bd8deadSopenharmony_ci</div>
181425bd8deadSopenharmony_ci</div>
181435bd8deadSopenharmony_ci<div class="sect4">
181445bd8deadSopenharmony_ci<h5 id="_subpass_inputs_2">Subpass Inputs</h5>
181455bd8deadSopenharmony_ci<div class="paragraph">
181465bd8deadSopenharmony_ci<p>Within a rendering pass, a subpass can write results to an output target
181475bd8deadSopenharmony_cithat can then be read by the next subpass as an input subpass.  The
181485bd8deadSopenharmony_ci"Subpass Input" feature regards the ability to read an output target.</p>
181495bd8deadSopenharmony_ci</div>
181505bd8deadSopenharmony_ci<div class="paragraph">
181515bd8deadSopenharmony_ci<p>Subpass inputs are read through a new set of types, available only
181525bd8deadSopenharmony_cito fragment shaders:</p>
181535bd8deadSopenharmony_ci</div>
181545bd8deadSopenharmony_ci<div class="literalblock">
181555bd8deadSopenharmony_ci<div class="content">
181565bd8deadSopenharmony_ci<pre>subpassInput
181575bd8deadSopenharmony_cisubpassInputMS
181585bd8deadSopenharmony_ciisubpassInput
181595bd8deadSopenharmony_ciisubpassInputMS
181605bd8deadSopenharmony_ciusubpassInput
181615bd8deadSopenharmony_ciusubpassInputMS</pre>
181625bd8deadSopenharmony_ci</div>
181635bd8deadSopenharmony_ci</div>
181645bd8deadSopenharmony_ci<div class="paragraph">
181655bd8deadSopenharmony_ci<p>Unlike sampler and image objects, subpass inputs are implicitly addressed
181665bd8deadSopenharmony_ciby the fragment&#8217;s (<em>x</em>, <em>y</em>, <em>layer</em>) coordinate.</p>
181675bd8deadSopenharmony_ci</div>
181685bd8deadSopenharmony_ci<div class="paragraph">
181695bd8deadSopenharmony_ci<p>Input attachments are decorated with their input attachment index in
181705bd8deadSopenharmony_ciaddition to descriptor set and binding numbers.</p>
181715bd8deadSopenharmony_ci</div>
181725bd8deadSopenharmony_ci<div class="literalblock">
181735bd8deadSopenharmony_ci<div class="content">
181745bd8deadSopenharmony_ci<pre>layout (input_attachment_index=i, set=m, binding=n) uniform subpassInput myInputAttachment;</pre>
181755bd8deadSopenharmony_ci</div>
181765bd8deadSopenharmony_ci</div>
181775bd8deadSopenharmony_ci<div class="paragraph">
181785bd8deadSopenharmony_ci<p>Which maps to the following SPIR-V:</p>
181795bd8deadSopenharmony_ci</div>
181805bd8deadSopenharmony_ci<div class="literalblock">
181815bd8deadSopenharmony_ci<div class="content">
181825bd8deadSopenharmony_ci<pre>        ...
181835bd8deadSopenharmony_ci%1 = OpExtInstImport "GLSL.std.450"
181845bd8deadSopenharmony_ci        ...
181855bd8deadSopenharmony_ci        OpName %9 "myInputAttachment"
181865bd8deadSopenharmony_ci        OpDecorate %9 DescriptorSet m
181875bd8deadSopenharmony_ci        OpDecorate %9 Binding n
181885bd8deadSopenharmony_ci        OpDecorate %9 InputAttachmentIndex i
181895bd8deadSopenharmony_ci%2 = OpTypeVoid
181905bd8deadSopenharmony_ci%3 = OpTypeFunction %2
181915bd8deadSopenharmony_ci%6 = OpTypeFloat 32
181925bd8deadSopenharmony_ci%7 = OpTypeImage %6 SubpassData 0 0 0 2 Unknown
181935bd8deadSopenharmony_ci%8 = OpTypePointer UniformConstant %7
181945bd8deadSopenharmony_ci%9 = OpVariable %8 UniformConstant
181955bd8deadSopenharmony_ci        ...</pre>
181965bd8deadSopenharmony_ci</div>
181975bd8deadSopenharmony_ci</div>
181985bd8deadSopenharmony_ci<div class="paragraph">
181995bd8deadSopenharmony_ci<p>An <em>input_attachment_index</em> of i selects the ith entry in the input pass
182005bd8deadSopenharmony_cilist. (See API specification for more information.)</p>
182015bd8deadSopenharmony_ci</div>
182025bd8deadSopenharmony_ci<div class="paragraph">
182035bd8deadSopenharmony_ci<p>These objects support reading the subpass input through the following
182045bd8deadSopenharmony_cifunctions:</p>
182055bd8deadSopenharmony_ci</div>
182065bd8deadSopenharmony_ci<div class="literalblock">
182075bd8deadSopenharmony_ci<div class="content">
182085bd8deadSopenharmony_ci<pre>gvec4 subpassLoad(gsubpassInput   subpass);
182095bd8deadSopenharmony_cigvec4 subpassLoad(gsubpassInputMS subpass, int sample);</pre>
182105bd8deadSopenharmony_ci</div>
182115bd8deadSopenharmony_ci</div>
182125bd8deadSopenharmony_ci</div>
182135bd8deadSopenharmony_ci</div>
182145bd8deadSopenharmony_ci<div class="sect3">
182155bd8deadSopenharmony_ci<h4 id="_mapping_variables">12.2.5. Mapping Variables</h4>
182165bd8deadSopenharmony_ci<div class="sect4">
182175bd8deadSopenharmony_ci<h5 id="_gl_fragcolor"><em>gl_FragColor</em></h5>
182185bd8deadSopenharmony_ci<div class="paragraph">
182195bd8deadSopenharmony_ci<p>The fragment-stage built-in <em>gl_FragColor</em>, which implies a broadcast to all
182205bd8deadSopenharmony_cioutputs, is not present in SPIR-V. Shaders where writing to <em>gl_FragColor</em>
182215bd8deadSopenharmony_ciis allowed can still write to it, but it only means to write to an output:</p>
182225bd8deadSopenharmony_ci</div>
182235bd8deadSopenharmony_ci<div class="ulist">
182245bd8deadSopenharmony_ci<ul>
182255bd8deadSopenharmony_ci<li>
182265bd8deadSopenharmony_ci<p>of the same type as <em>gl_FragColor</em></p>
182275bd8deadSopenharmony_ci</li>
182285bd8deadSopenharmony_ci<li>
182295bd8deadSopenharmony_ci<p>decorated with location 0</p>
182305bd8deadSopenharmony_ci</li>
182315bd8deadSopenharmony_ci<li>
182325bd8deadSopenharmony_ci<p>not decorated as a built-in variable.</p>
182335bd8deadSopenharmony_ci</li>
182345bd8deadSopenharmony_ci</ul>
182355bd8deadSopenharmony_ci</div>
182365bd8deadSopenharmony_ci<div class="paragraph">
182375bd8deadSopenharmony_ci<p>There is no implicit broadcast.</p>
182385bd8deadSopenharmony_ci</div>
182395bd8deadSopenharmony_ci</div>
182405bd8deadSopenharmony_ci<div class="sect4">
182415bd8deadSopenharmony_ci<h5 id="_vulkan_gl_vertexindex_and_gl_instanceindex">Vulkan <em>gl_VertexIndex</em> and <em>gl_InstanceIndex</em></h5>
182425bd8deadSopenharmony_ci<div class="paragraph">
182435bd8deadSopenharmony_ci<p>Adds two new built-in variables, <em>gl_VertexIndex</em> and <em>gl_InstanceIndex</em> to
182445bd8deadSopenharmony_cireplace the existing built-in variables <em>gl_VertexID</em> and <em>gl_InstanceID</em>.</p>
182455bd8deadSopenharmony_ci</div>
182465bd8deadSopenharmony_ci<div class="paragraph">
182475bd8deadSopenharmony_ci<p>In the situations where the indexing is relative to some base offset,
182485bd8deadSopenharmony_cithese built-in variables are defined, for Vulkan, to take on values as
182495bd8deadSopenharmony_cifollows:</p>
182505bd8deadSopenharmony_ci</div>
182515bd8deadSopenharmony_ci<div class="literalblock">
182525bd8deadSopenharmony_ci<div class="content">
182535bd8deadSopenharmony_ci<pre>gl_VertexIndex             base, base+1, base+2, ...
182545bd8deadSopenharmony_cigl_InstanceIndex           base, base+1, base+2, ...</pre>
182555bd8deadSopenharmony_ci</div>
182565bd8deadSopenharmony_ci</div>
182575bd8deadSopenharmony_ci<div class="paragraph">
182585bd8deadSopenharmony_ci<p>Where it depends on the situation what the base actually is.</p>
182595bd8deadSopenharmony_ci</div>
182605bd8deadSopenharmony_ci</div>
182615bd8deadSopenharmony_ci<div class="sect4">
182625bd8deadSopenharmony_ci<h5 id="_storage_classes">Storage Classes:</h5>
182635bd8deadSopenharmony_ci<div class="literalblock">
182645bd8deadSopenharmony_ci<div class="content">
182655bd8deadSopenharmony_ci<pre>uniform sampler2D...;        -&gt; UniformConstant
182665bd8deadSopenharmony_ciuniform blockN { ... } ...;  -&gt; Uniform, with Block decoration
182675bd8deadSopenharmony_ciin / out variable            -&gt; Input/Output, possibly with block (below)
182685bd8deadSopenharmony_ciin / out block...            -&gt; Input/Output, with Block decoration
182695bd8deadSopenharmony_cibuffer  blockN { ... } ...;  -&gt; Uniform, with BufferBlock decoration
182705bd8deadSopenharmony_cishared                       -&gt; Workgroup
182715bd8deadSopenharmony_ci&lt;normal global&gt;              -&gt; Private</pre>
182725bd8deadSopenharmony_ci</div>
182735bd8deadSopenharmony_ci</div>
182745bd8deadSopenharmony_ci<div class="literalblock">
182755bd8deadSopenharmony_ci<div class="content">
182765bd8deadSopenharmony_ci<pre>Vulkan Only: buffer  blockN { ... } ...;  -&gt; StorageBuffer, when requested
182775bd8deadSopenharmony_ciOpenGL Only: uniform variable (non-block) -&gt; UniformConstant
182785bd8deadSopenharmony_ciOpenGL Only: ... uniform atomic_uint ...  -&gt; AtomicCounter</pre>
182795bd8deadSopenharmony_ci</div>
182805bd8deadSopenharmony_ci</div>
182815bd8deadSopenharmony_ci</div>
182825bd8deadSopenharmony_ci<div class="sect4">
182835bd8deadSopenharmony_ci<h5 id="_inputoutput">Input/Output</h5>
182845bd8deadSopenharmony_ci<div class="paragraph">
182855bd8deadSopenharmony_ci<p>Mapping of input/output blocks or variables is the same for all versions
182865bd8deadSopenharmony_ciof GLSL or ESSL. To the extent variables or members are available in a
182875bd8deadSopenharmony_civersion, its location is as follows:</p>
182885bd8deadSopenharmony_ci</div>
182895bd8deadSopenharmony_ci<div class="paragraph">
182905bd8deadSopenharmony_ci<p>These are mapped to SPIR-V individual variables, with similarly spelled
182915bd8deadSopenharmony_cibuilt-in decorations (except as noted):</p>
182925bd8deadSopenharmony_ci</div>
182935bd8deadSopenharmony_ci<div class="paragraph">
182945bd8deadSopenharmony_ci<p>Any stage:</p>
182955bd8deadSopenharmony_ci</div>
182965bd8deadSopenharmony_ci<div class="literalblock">
182975bd8deadSopenharmony_ci<div class="content">
182985bd8deadSopenharmony_ci<pre>in gl_VertexIndex          (Vulkan only)
182995bd8deadSopenharmony_ciin gl_VertexID             (OpenGL only)
183005bd8deadSopenharmony_ciin gl_InstanceIndex        (Vulkan only)
183015bd8deadSopenharmony_ciin gl_InstanceID           (OpenGL only)
183025bd8deadSopenharmony_ciin gl_InvocationID
183035bd8deadSopenharmony_ciin gl_PatchVerticesIn      (PatchVertices)
183045bd8deadSopenharmony_ciin gl_PrimitiveIDIn        (PrimitiveID)
183055bd8deadSopenharmony_ciin/out gl_PrimitiveID      (in/out based only on storage qualifier)
183065bd8deadSopenharmony_ciin gl_TessCoord</pre>
183075bd8deadSopenharmony_ci</div>
183085bd8deadSopenharmony_ci</div>
183095bd8deadSopenharmony_ci<div class="literalblock">
183105bd8deadSopenharmony_ci<div class="content">
183115bd8deadSopenharmony_ci<pre>in/out gl_Layer
183125bd8deadSopenharmony_ciin/out gl_ViewportIndex</pre>
183135bd8deadSopenharmony_ci</div>
183145bd8deadSopenharmony_ci</div>
183155bd8deadSopenharmony_ci<div class="literalblock">
183165bd8deadSopenharmony_ci<div class="content">
183175bd8deadSopenharmony_ci<pre>patch in/out gl_TessLevelOuter  (uses Patch decoration)
183185bd8deadSopenharmony_cipatch in/out gl_TessLevelInner  (uses Patch decoration)</pre>
183195bd8deadSopenharmony_ci</div>
183205bd8deadSopenharmony_ci</div>
183215bd8deadSopenharmony_ci<div class="paragraph">
183225bd8deadSopenharmony_ci<p>Compute stage only:</p>
183235bd8deadSopenharmony_ci</div>
183245bd8deadSopenharmony_ci<div class="literalblock">
183255bd8deadSopenharmony_ci<div class="content">
183265bd8deadSopenharmony_ci<pre>in gl_NumWorkGroups
183275bd8deadSopenharmony_ciin gl_WorkGroupSize
183285bd8deadSopenharmony_ciin gl_WorkGroupID
183295bd8deadSopenharmony_ciin gl_LocalInvocationID
183305bd8deadSopenharmony_ciin gl_GlobalInvocationID
183315bd8deadSopenharmony_ciin gl_LocalInvocationIndex</pre>
183325bd8deadSopenharmony_ci</div>
183335bd8deadSopenharmony_ci</div>
183345bd8deadSopenharmony_ci<div class="paragraph">
183355bd8deadSopenharmony_ci<p>Fragment stage only:</p>
183365bd8deadSopenharmony_ci</div>
183375bd8deadSopenharmony_ci<div class="literalblock">
183385bd8deadSopenharmony_ci<div class="content">
183395bd8deadSopenharmony_ci<pre>in gl_FragCoord
183405bd8deadSopenharmony_ciin gl_FrontFacing
183415bd8deadSopenharmony_ciin gl_ClipDistance
183425bd8deadSopenharmony_ciin gl_CullDistance
183435bd8deadSopenharmony_ciin gl_PointCoord
183445bd8deadSopenharmony_ciin gl_SampleID
183455bd8deadSopenharmony_ciin gl_SamplePosition
183465bd8deadSopenharmony_ciin gl_HelperInvocation
183475bd8deadSopenharmony_ciout gl_FragDepth
183485bd8deadSopenharmony_ciin gl_SampleMaskIn        (SampleMask)
183495bd8deadSopenharmony_ciout gl_SampleMask         (in/out based only on storage qualifier)</pre>
183505bd8deadSopenharmony_ci</div>
183515bd8deadSopenharmony_ci</div>
183525bd8deadSopenharmony_ci<div class="paragraph">
183535bd8deadSopenharmony_ci<p>These are mapped to SPIR-V blocks, as implied by the pseudo code, with
183545bd8deadSopenharmony_cithe members decorated with similarly spelled built-in decorations:</p>
183555bd8deadSopenharmony_ci</div>
183565bd8deadSopenharmony_ci<div class="paragraph">
183575bd8deadSopenharmony_ci<p>Non-fragment stage:</p>
183585bd8deadSopenharmony_ci</div>
183595bd8deadSopenharmony_ci<div class="literalblock">
183605bd8deadSopenharmony_ci<div class="content">
183615bd8deadSopenharmony_ci<pre>in/out gl_PerVertex {   // some subset of these members will be used
183625bd8deadSopenharmony_ci    gl_Position
183635bd8deadSopenharmony_ci    gl_PointSize
183645bd8deadSopenharmony_ci    gl_ClipDistance
183655bd8deadSopenharmony_ci    gl_CullDistance
183665bd8deadSopenharmony_ci}                       // name of block is for debug only</pre>
183675bd8deadSopenharmony_ci</div>
183685bd8deadSopenharmony_ci</div>
183695bd8deadSopenharmony_ci<div class="paragraph">
183705bd8deadSopenharmony_ci<p>There is at most one input and one output block per stage in SPIR-V.
183715bd8deadSopenharmony_ciThe subset and order of members will match between stages sharing an
183725bd8deadSopenharmony_ciinterface.</p>
183735bd8deadSopenharmony_ci</div>
183745bd8deadSopenharmony_ci</div>
183755bd8deadSopenharmony_ci</div>
183765bd8deadSopenharmony_ci<div class="sect3">
183775bd8deadSopenharmony_ci<h4 id="_vulkan_only_mapping_of_precision_qualifiers">12.2.6. Vulkan Only: Mapping of Precision Qualifiers</h4>
183785bd8deadSopenharmony_ci<div class="literalblock">
183795bd8deadSopenharmony_ci<div class="content">
183805bd8deadSopenharmony_ci<pre>lowp     -&gt; RelaxedPrecision, on storage variable and operation
183815bd8deadSopenharmony_cimediump  -&gt; RelaxedPrecision, on storage variable and operation
183825bd8deadSopenharmony_cihighp    -&gt; 32-bit, same as int or float</pre>
183835bd8deadSopenharmony_ci</div>
183845bd8deadSopenharmony_ci</div>
183855bd8deadSopenharmony_ci<div class="literalblock">
183865bd8deadSopenharmony_ci<div class="content">
183875bd8deadSopenharmony_ci<pre>portability tool/mode  -&gt; OpQuantizeToF16</pre>
183885bd8deadSopenharmony_ci</div>
183895bd8deadSopenharmony_ci</div>
183905bd8deadSopenharmony_ci</div>
183915bd8deadSopenharmony_ci<div class="sect3">
183925bd8deadSopenharmony_ci<h4 id="_mapping_of_precise">12.2.7. Mapping of <strong>precise</strong>:</h4>
183935bd8deadSopenharmony_ci<div class="literalblock">
183945bd8deadSopenharmony_ci<div class="content">
183955bd8deadSopenharmony_ci<pre>precise -&gt; NoContraction</pre>
183965bd8deadSopenharmony_ci</div>
183975bd8deadSopenharmony_ci</div>
183985bd8deadSopenharmony_ci</div>
183995bd8deadSopenharmony_ci<div class="sect3">
184005bd8deadSopenharmony_ci<h4 id="_opengl_mapping_of_atomic_uint_offset_layout_qualifier">12.2.8. OpenGL Mapping of <strong>atomic_uint</strong> <em>offset</em> layout qualifier</h4>
184015bd8deadSopenharmony_ci<div class="literalblock">
184025bd8deadSopenharmony_ci<div class="content">
184035bd8deadSopenharmony_ci<pre>offset         -&gt;  Offset (decoration)</pre>
184045bd8deadSopenharmony_ci</div>
184055bd8deadSopenharmony_ci</div>
184065bd8deadSopenharmony_ci</div>
184075bd8deadSopenharmony_ci<div class="sect3">
184085bd8deadSopenharmony_ci<h4 id="_mapping_of_images">12.2.9. Mapping of Images</h4>
184095bd8deadSopenharmony_ci<div class="literalblock">
184105bd8deadSopenharmony_ci<div class="content">
184115bd8deadSopenharmony_ci<pre>imageLoad()   -&gt; OpImageRead
184125bd8deadSopenharmony_ciimageStore()  -&gt; OpImageWrite
184135bd8deadSopenharmony_citexelFetch()  -&gt; OpImageFetch
184145bd8deadSopenharmony_cisubpassInput  -&gt; OpTypeImage with Dim of SubpassData (Vulkan only)
184155bd8deadSopenharmony_cisubpassLoad() -&gt; OpImageRead                         (Vulkan only)</pre>
184165bd8deadSopenharmony_ci</div>
184175bd8deadSopenharmony_ci</div>
184185bd8deadSopenharmony_ci<div class="literalblock">
184195bd8deadSopenharmony_ci<div class="content">
184205bd8deadSopenharmony_ci<pre>imageAtomicXXX(params, data)  -&gt; %ptr = OpImageTexelPointer params
184215bd8deadSopenharmony_ci                                        OpAtomicXXX %ptr, data</pre>
184225bd8deadSopenharmony_ci</div>
184235bd8deadSopenharmony_ci</div>
184245bd8deadSopenharmony_ci<div class="literalblock">
184255bd8deadSopenharmony_ci<div class="content">
184265bd8deadSopenharmony_ci<pre>XXXQueryXXX(combined) -&gt; %image = OpImage combined
184275bd8deadSopenharmony_ci                                OpXXXQueryXXX %image</pre>
184285bd8deadSopenharmony_ci</div>
184295bd8deadSopenharmony_ci</div>
184305bd8deadSopenharmony_ci</div>
184315bd8deadSopenharmony_ci<div class="sect3">
184325bd8deadSopenharmony_ci<h4 id="_mapping_of_layouts">12.2.10. Mapping of Layouts</h4>
184335bd8deadSopenharmony_ci<div class="literalblock">
184345bd8deadSopenharmony_ci<div class="content">
184355bd8deadSopenharmony_ci<pre>std140/std430  -&gt;  explicit Offset, ArrayStride, and MatrixStride
184365bd8deadSopenharmony_ci                    Decoration on struct members
184375bd8deadSopenharmony_cishared/packed  -&gt;  not allowed
184385bd8deadSopenharmony_ci&lt;default&gt;      -&gt;  not shared, but std140 or std430
184395bd8deadSopenharmony_cixfb_offset     -&gt;  Offset Decoration on the object or struct member
184405bd8deadSopenharmony_cixfb_buffer     -&gt;  XfbBuffer Decoration on the object
184415bd8deadSopenharmony_cixfb_stride     -&gt;  XfbStride Decoration on the object
184425bd8deadSopenharmony_ciany xfb_*      -&gt;  the Xfb Execution Mode is set
184435bd8deadSopenharmony_cicaptured XFB   -&gt;  has both XfbBuffer and Offset
184445bd8deadSopenharmony_cinon-captured   -&gt;  lacking XfbBuffer or Offset</pre>
184455bd8deadSopenharmony_ci</div>
184465bd8deadSopenharmony_ci</div>
184475bd8deadSopenharmony_ci<div class="literalblock">
184485bd8deadSopenharmony_ci<div class="content">
184495bd8deadSopenharmony_ci<pre>max_vertices   -&gt;  OutputVertices</pre>
184505bd8deadSopenharmony_ci</div>
184515bd8deadSopenharmony_ci</div>
184525bd8deadSopenharmony_ci</div>
184535bd8deadSopenharmony_ci<div class="sect3">
184545bd8deadSopenharmony_ci<h4 id="_mapping_of_barriers">12.2.11. Mapping of barriers</h4>
184555bd8deadSopenharmony_ci<div class="literalblock">
184565bd8deadSopenharmony_ci<div class="content">
184575bd8deadSopenharmony_ci<pre>barrier() (compute) -&gt; OpControlBarrier(/*Execution*/Workgroup,
184585bd8deadSopenharmony_ci                                        /*Memory*/Workgroup,
184595bd8deadSopenharmony_ci                                        /*Semantics*/AcquireRelease |
184605bd8deadSopenharmony_ci                                                    WorkgroupMemory)</pre>
184615bd8deadSopenharmony_ci</div>
184625bd8deadSopenharmony_ci</div>
184635bd8deadSopenharmony_ci<div class="literalblock">
184645bd8deadSopenharmony_ci<div class="content">
184655bd8deadSopenharmony_ci<pre>barrier() (tess control) -&gt; OpControlBarrier(/*Execution*/Workgroup,
184665bd8deadSopenharmony_ci                                            /*Memory*/Invocation,
184675bd8deadSopenharmony_ci                                            /*Semantics*/None)</pre>
184685bd8deadSopenharmony_ci</div>
184695bd8deadSopenharmony_ci</div>
184705bd8deadSopenharmony_ci<div class="literalblock">
184715bd8deadSopenharmony_ci<div class="content">
184725bd8deadSopenharmony_ci<pre>memoryBarrier() -&gt; OpMemoryBarrier(/*Memory*/Device,
184735bd8deadSopenharmony_ci                                    /*Semantics*/AcquireRelease |
184745bd8deadSopenharmony_ci                                                UniformMemory |
184755bd8deadSopenharmony_ci                                                WorkgroupMemory |
184765bd8deadSopenharmony_ci                                                ImageMemory)</pre>
184775bd8deadSopenharmony_ci</div>
184785bd8deadSopenharmony_ci</div>
184795bd8deadSopenharmony_ci<div class="literalblock">
184805bd8deadSopenharmony_ci<div class="content">
184815bd8deadSopenharmony_ci<pre>memoryBarrierBuffer() -&gt; OpMemoryBarrier(/*Memory*/Device,
184825bd8deadSopenharmony_ci                                        /*Semantics*/AcquireRelease |
184835bd8deadSopenharmony_ci                                                    UniformMemory)</pre>
184845bd8deadSopenharmony_ci</div>
184855bd8deadSopenharmony_ci</div>
184865bd8deadSopenharmony_ci<div class="literalblock">
184875bd8deadSopenharmony_ci<div class="content">
184885bd8deadSopenharmony_ci<pre>memoryBarrierShared() -&gt; OpMemoryBarrier(/*Memory*/Device,
184895bd8deadSopenharmony_ci                                        /*Semantics*/AcquireRelease |
184905bd8deadSopenharmony_ci                                                    WorkgroupMemory)</pre>
184915bd8deadSopenharmony_ci</div>
184925bd8deadSopenharmony_ci</div>
184935bd8deadSopenharmony_ci<div class="literalblock">
184945bd8deadSopenharmony_ci<div class="content">
184955bd8deadSopenharmony_ci<pre>memoryBarrierImage() -&gt; OpMemoryBarrier(/*Memory*/Device,
184965bd8deadSopenharmony_ci                                        /*Semantics*/AcquireRelease |
184975bd8deadSopenharmony_ci                                                    ImageMemory)</pre>
184985bd8deadSopenharmony_ci</div>
184995bd8deadSopenharmony_ci</div>
185005bd8deadSopenharmony_ci<div class="literalblock">
185015bd8deadSopenharmony_ci<div class="content">
185025bd8deadSopenharmony_ci<pre>groupMemoryBarrier() -&gt; OpMemoryBarrier(/*Memory*/Workgroup,
185035bd8deadSopenharmony_ci                                        /*Semantics*/AcquireRelease |
185045bd8deadSopenharmony_ci                                                    UniformMemory |
185055bd8deadSopenharmony_ci                                                    WorkgroupMemory |
185065bd8deadSopenharmony_ci                                                    ImageMemory)</pre>
185075bd8deadSopenharmony_ci</div>
185085bd8deadSopenharmony_ci</div>
185095bd8deadSopenharmony_ci</div>
185105bd8deadSopenharmony_ci<div class="sect3">
185115bd8deadSopenharmony_ci<h4 id="_mapping_of_atomics">12.2.12. Mapping of atomics</h4>
185125bd8deadSopenharmony_ci<div class="literalblock">
185135bd8deadSopenharmony_ci<div class="content">
185145bd8deadSopenharmony_ci<pre>all atomic builtin functions -&gt; Semantics = None(Relaxed)</pre>
185155bd8deadSopenharmony_ci</div>
185165bd8deadSopenharmony_ci</div>
185175bd8deadSopenharmony_ci<div class="literalblock">
185185bd8deadSopenharmony_ci<div class="content">
185195bd8deadSopenharmony_ci<pre>atomicExchange()             -&gt; OpAtomicExchange
185205bd8deadSopenharmony_ciimageAtomicExchange()        -&gt; OpAtomicExchange
185215bd8deadSopenharmony_ciatomicCompSwap()             -&gt; OpAtomicCompareExchange
185225bd8deadSopenharmony_ciimageAtomicCompSwap()        -&gt; OpAtomicCompareExchange
185235bd8deadSopenharmony_ciN/A                          -&gt; OpAtomicCompareExchangeWeak</pre>
185245bd8deadSopenharmony_ci</div>
185255bd8deadSopenharmony_ci</div>
185265bd8deadSopenharmony_ci</div>
185275bd8deadSopenharmony_ci<div class="sect3">
185285bd8deadSopenharmony_ci<h4 id="_opengl_only_mapping_of_atomics">12.2.13. OpenGL Only: Mapping of Atomics</h4>
185295bd8deadSopenharmony_ci<div class="literalblock">
185305bd8deadSopenharmony_ci<div class="content">
185315bd8deadSopenharmony_ci<pre>atomicCounterIncrement -&gt; OpAtomicIIncrement
185325bd8deadSopenharmony_ciatomicCounterDecrement -&gt; OpAtomicIDecrement
185335bd8deadSopenharmony_ciatomicCounter          -&gt; OpAtomicLoad</pre>
185345bd8deadSopenharmony_ci</div>
185355bd8deadSopenharmony_ci</div>
185365bd8deadSopenharmony_ci</div>
185375bd8deadSopenharmony_ci<div class="sect3">
185385bd8deadSopenharmony_ci<h4 id="_mapping_of_other_instructions">12.2.14. Mapping of other instructions</h4>
185395bd8deadSopenharmony_ci<div class="literalblock">
185405bd8deadSopenharmony_ci<div class="content">
185415bd8deadSopenharmony_ci<pre>%     -&gt; OpUMod/OpSMod
185425bd8deadSopenharmony_cimod() -&gt; OpFMod
185435bd8deadSopenharmony_ciN/A   -&gt; OpSRem/OpFRem</pre>
185445bd8deadSopenharmony_ci</div>
185455bd8deadSopenharmony_ci</div>
185465bd8deadSopenharmony_ci<div class="literalblock">
185475bd8deadSopenharmony_ci<div class="content">
185485bd8deadSopenharmony_ci<pre>pack/unpack (conversion)    -&gt; pack/unpack in GLSL extended instructions
185495bd8deadSopenharmony_cipack/unpack (no conversion) -&gt; OpBitcast</pre>
185505bd8deadSopenharmony_ci</div>
185515bd8deadSopenharmony_ci</div>
185525bd8deadSopenharmony_ci</div>
185535bd8deadSopenharmony_ci</div>
185545bd8deadSopenharmony_ci</div>
185555bd8deadSopenharmony_ci</div>
185565bd8deadSopenharmony_ci</div>
185575bd8deadSopenharmony_ci<div id="footer">
185585bd8deadSopenharmony_ci<div id="footer-text">
185595bd8deadSopenharmony_ciVersion 4.60.7<br>
185605bd8deadSopenharmony_ciLast updated 2019-07-10 14:42:53 MDT
185615bd8deadSopenharmony_ci</div>
185625bd8deadSopenharmony_ci</div>
185635bd8deadSopenharmony_ci
185645bd8deadSopenharmony_ci<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-MML-AM_HTMLorMML"></script>
185655bd8deadSopenharmony_ci</body>
185665bd8deadSopenharmony_ci</html>