1// Copyright 2015-2021 The Khronos Group Inc. 2// 3// SPDX-License-Identifier: Apache-2.0 4 5= Math Test 6 7This file (vkmath.txt) contains all the latexmath blocks and inlines in the 8Vulkan spec and style guide, so we can see how they are rendered with 9different methods and output formats. 10 11== File chapters/fundamentals.txt 12 13=== latexmath block 1 14 15[latexmath] 16++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 17f = { c \over { 2^b - 1 } } 18++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 19 20=== latexmath block 2 21 22[latexmath] 23++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 24f = \max\left( {c \over {2^{b-1} - 1}}, -1.0 \right) 25++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 26 27== File chapters/interfaces.txt 28 29=== latexmath inline 1 30 31latexmath:[(x,y,z,\frac{1}{w})] 32 33=== latexmath inline 2 34 35latexmath:[\frac{1}{w}] 36 37== File chapters/primsrast.txt 38 39=== latexmath block 3 40 41[latexmath] 42++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 43s = {1 \over 2} + { \left( x_p - x_f \right) \over \text{size} } 44++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 45 46[latexmath] 47++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 48t = {1 \over 2} + { \left( y_p - y_f \right) \over \text{size} } 49++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 50 51=== latexmath block 4 52 53[latexmath] 54++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 55t = {{( \mathbf{p}_r - \mathbf{p}_a ) \cdot ( \mathbf{p}_b - \mathbf{p}_a )} 56 \over {\| \mathbf{p}_b - \mathbf{p}_a \|^2 }} 57++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 58 59=== latexmath block 5 60 61[latexmath] 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 63f = {{ (1-t) {f_a / w_a} + t { f_b / w_b} } \over 64 {(1-t) / w_a + t / w_b }} 65++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 66 67=== latexmath block 6 68 69[latexmath] 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 71a = -{1 \over 2}\sum_{i=0}^{n-1} 72 x_f^i y_f^{i \oplus 1} - 73 x_f^{i \oplus 1} y_f^i 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 75 76=== latexmath inline 3 77 78latexmath:[x_f^i] and latexmath:[y_f^i] 79 80=== latexmath block 7 81 82[latexmath] 83++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 84a = {{\mathrm{A}(p p_b p_c)} \over {\mathrm{A}(p_a p_b p_c)}}, \quad 85b = {{\mathrm{A}(p p_a p_c)} \over {\mathrm{A}(p_a p_b p_c)}}, \quad 86c = {{\mathrm{A}(p p_a p_b)} \over {\mathrm{A}(p_a p_b p_c)}}, 87++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 88 89=== latexmath block 8 90 91[latexmath] 92++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 93f = { a {f_a / w_a} + b {f_b / w_b} + c {f_c / w_c} } \over 94 { {a / w_a} + {b / w_b} + {c / w_c} } 95++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 96 97== File chapters/fundamentals.txt 98 99=== latexmath block 9 100 101[latexmath] 102++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 103f = { c \over { 2^b - 1 } } 104++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 105 106=== latexmath block 10 107 108[latexmath] 109++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 110f = \max\left( {c \over {2^{b-1} - 1}}, -1.0 \right) 111++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 112 113== File chapters/interfaces.txt 114 115=== latexmath inline 4 116 117latexmath:[(x,y,z,\frac{1}{w})] 118 119=== latexmath inline 5 120 121latexmath:[\frac{1}{w}]. 122 123== File chapters/primsrast.txt 124 125=== latexmath block 11 126 127[latexmath] 128++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 129s = {1 \over 2} + { \left( x_p - x_f \right) \over \text{size} } 130++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 131[latexmath] 132++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 133t = {1 \over 2} + { \left( y_p - y_f \right) \over \text{size} } 134++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 135 136=== latexmath block 12 137 138[latexmath] 139++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 140t = {{( \mathbf{p}_r - \mathbf{p}_a ) \cdot ( \mathbf{p}_b - \mathbf{p}_a )} 141 \over {\| \mathbf{p}_b - \mathbf{p}_a \|^2 }} 142++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 143 144=== latexmath block 13 145 146[latexmath] 147++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 148f = {{ (1-t) {f_a / w_a} + t { f_b / w_b} } \over 149 {(1-t) / w_a + t / w_b }} 150++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 151 152=== latexmath block 14 153 154[latexmath] 155++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 156a = -{1 \over 2}\sum_{i=0}^{n-1} 157 x_f^i y_f^{i \oplus 1} - 158 x_f^{i \oplus 1} y_f^i 159++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 160 161=== latexmath inline 6 162 163latexmath:[x_f^i] and latexmath:[y_f^i] 164 165=== latexmath block 15 166 167[latexmath] 168++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 169a = {{\mathrm{A}(p p_b p_c)} \over {\mathrm{A}(p_a p_b p_c)}}, \quad 170b = {{\mathrm{A}(p p_a p_c)} \over {\mathrm{A}(p_a p_b p_c)}}, \quad 171c = {{\mathrm{A}(p p_a p_b)} \over {\mathrm{A}(p_a p_b p_c)}}, 172++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 173 174=== latexmath block 16 175 176[latexmath] 177++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 178f = { a {f_a / w_a} + b {f_b / w_b} + c {f_c / w_c} } \over 179 { {a / w_a} + {b / w_b} + {c / w_c} } 180++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 181 182=== latexmath block 17 183 184[latexmath] 185++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 186f = \sum_{i=1}^{n} a_i f_i 187++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 188 189=== latexmath inline 7 190 191latexmath:[\sum_{i=1}^{n}a_i = 1]. 192 193=== latexmath block 18 194 195[latexmath] 196++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 197m = \sqrt{ \left({{\partial z_f} \over {\partial x_f}}\right)^2 198 + \left({{\partial z_f} \over {\partial y_f}}\right)^2} 199++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 200 201=== latexmath block 19 202 203[latexmath] 204++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 205m = \max\left( \left| {{\partial z_f} \over {\partial x_f}} \right|, 206 \left| {{\partial z_f} \over {\partial y_f}} \right| \right) 207++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 208 209=== latexmath block 20 210 211[latexmath] 212++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 213o = 214\begin{cases} 215 m \times depthBiasSlopeFactor + 216 r \times depthBiasConstantFactor & depthBiasClamp = 0\ or\ NaN \\ 217 \min(m \times depthBiasSlopeFactor + 218 r \times depthBiasConstantFactor, 219 depthBiasClamp) & depthBiasClamp > 0 \\ 220 \max(m \times depthBiasSlopeFactor + 221 r \times depthBiasConstantFactor, 222 depthBiasClamp) & depthBiasClamp < 0 \\ 223\end{cases} 224++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 225 226== File chapters/tessellation.txt 227 228=== latexmath inline 8 229 230latexmath:[\frac{1}{n}, \frac{2}{n}, \ldots, \frac{n-1}{n}] 231 232== File chapters/textures.txt 233 234=== latexmath block 21 235 236[latexmath] 237+++++++++++++++++++ 238\begin{aligned} 239N & = 9 & \text{number of mantissa bits per component} \\ 240B & = 15 & \text{exponent bias} \\ 241E_{max} & = 31 & \text{maximum possible biased exponent value} \\ 242sharedexp_{max} & = \frac{(2^N-1)}{2^N} \times 2^{(E_{max}-B)} 243\end{aligned} 244+++++++++++++++++++ 245 246=== latexmath block 22 247 248[latexmath] 249+++++++++++++++++++ 250\begin{aligned} 251exp' = 252 \begin{cases} 253 \left \lfloor \log_2(max_{clamped}) \right \rfloor + (B+1) 254 & \text{for}\ max_{clamped} > 2^{-(B+1)} \\ 255 0 256 & \text{for}\ max_{clamped} \leq 2^{-(B+1)} 257 \end{cases} 258\end{aligned} 259+++++++++++++++++++ 260 261=== latexmath block 23 262 263[latexmath] 264+++++++++++++++++++ 265\begin{aligned} 266max_{shared} = 267\left \lfloor 268\frac{max_{clamped}}{2^{(exp'-B-N)}}+\frac{1}{2} 269\right \rfloor 270\end{aligned} 271+++++++++++++++++++ 272 273=== latexmath block 24 274 275[latexmath] 276+++++++++++++++++++ 277\begin{aligned} 278exp_{shared} = 279 \begin{cases} 280 exp' & \text{for}\ 0 \leq max_{shared} < 2^N \\ 281 exp'+1 & \text{for}\ max_{shared} = 2^N 282 \end{cases} 283\end{aligned} 284+++++++++++++++++++ 285 286=== latexmath block 25 287 288[latexmath] 289+++++++++++++++++++ 290\begin{aligned} 291red_{shared} & = 292 \left \lfloor 293 \frac{red_{clamped}}{2^{(exp_{shared}-B-N)}}+ \frac{1}{2} 294 \right \rfloor \\ 295green_{shared} & = 296 \left \lfloor 297 \frac{green_{clamped}}{2^{(exp_{shared}-B-N)}}+ \frac{1}{2} 298 \right \rfloor \\ 299blue_{shared} & = 300 \left \lfloor 301 \frac{blue_{clamped}}{2^{(exp_{shared}-B-N)}}+ \frac{1}{2} 302 \right \rfloor 303\end{aligned} 304+++++++++++++++++++ 305 306=== latexmath block 26 307 308[latexmath] 309+++++++++++++++++++ 310\begin{aligned} 311D & = 1.0 & 312 \begin{cases} 313 D_{ref} \leq D & \text{for LEQUAL} \\ 314 D_{ref} \geq D & \text{for GEQUAL} \\ 315 D_{ref} < D & \text{for LESS} \\ 316 D_{ref} > D & \text{for GREATER} \\ 317 D_{ref} = D & \text{for EQUAL} \\ 318 D_{ref} \neq D & \text{for NOTEQUAL} \\ 319 true & \text{for ALWAYS} \\ 320 false & \text{for NEVER} 321 \end{cases} \\ 322D & = 0.0 & \text{otherwise} 323\end{aligned} 324+++++++++++++++++++ 325 326=== latexmath block 27 327 328[latexmath] 329+++++++++++++++++++ 330\begin{aligned} 331C'_{rgba}[R] & = 332 \begin{cases} 333 C_{rgba}[R] & \text{for RED swizzle} \\ 334 C_{rgba}[G] & \text{for GREEN swizzle} \\ 335 C_{rgba}[B] & \text{for BLUE swizzle} \\ 336 C_{rgba}[A] & \text{for ALPHA swizzle} \\ 337 0 & \text{for ZERO swizzle} \\ 338 one & \text{for ONE swizzle} \\ 339 C_{rgba}[R] & \text{for IDENTITY swizzle} 340 \end{cases} 341\end{aligned} 342+++++++++++++++++++ 343 344=== latexmath block 28 345 346[latexmath] 347+++++++++++++++++++ 348\begin{aligned} 349C_{rgba}[R] & \text{is the RED component} \\ 350C_{rgba}[G] & \text{is the GREEN component} \\ 351C_{rgba}[B] & \text{is the BLUE component} \\ 352C_{rgba}[A] & \text{is the ALPHA component} \\ 353one & = 1.0\text{f} & \text{for floating point components} \\ 354one & = 1 & \text{for integer components} 355\end{aligned} 356+++++++++++++++++++ 357 358=== latexmath block 29 359 360[latexmath] 361+++++++++++++++++++ 362\begin{aligned} 363dPdx_{i_1,j_0} & = dPdx_{i_0,j_0} & = P_{i_1,j_0} - P_{i_0,j_0} \\ 364dPdx_{i_1,j_1} & = dPdx_{i_0,j_1} & = P_{i_1,j_1} - P_{i_0,j_1} \\ 365\\ 366dPdy_{i_0,j_1} & = dPdy_{i_0,j_0} & = P_{i_0,j_1} - P_{i_0,j_0} \\ 367dPdy_{i_1,j_1} & = dPdy_{i_1,j_0} & = P_{i_1,j_1} - P_{i_1,j_0} 368\end{aligned} 369+++++++++++++++++++ 370 371=== latexmath block 30 372 373[latexmath] 374+++++++++++++++++++ 375\begin{aligned} 376dPdx & = 377 \begin{cases} 378 dPdx_{i_0,j_0} & \text{preferred}\\ 379 dPdx_{i_0,j_1} 380 \end{cases} \\ 381dPdy & = 382 \begin{cases} 383 dPdy_{i_0,j_0} & \text{preferred}\\ 384 dPdy_{i_1,j_0} 385 \end{cases} 386\end{aligned} 387+++++++++++++++++++ 388 389=== latexmath block 31 390 391[latexmath] 392+++++++++++++++++++ 393\begin{aligned} 394s & = \frac{s}{q}, & \text{for 1D, 2D, or 3D image} \\ 395\\ 396t & = \frac{t}{q}, & \text{for 2D or 3D image} \\ 397\\ 398r & = \frac{r}{q}, & \text{for 3D image} \\ 399\\ 400D_{ref} & = \frac{D_{ref}}{q}, & \text{if provided} 401\end{aligned} 402+++++++++++++++++++ 403 404 405=== latexmath block 32 406 407[latexmath] 408+++++++++++++++++++ 409\begin{aligned} 410\partial{s}/\partial{x} & = dPdx(s), & \partial{s}/\partial{y} & = dPdy(s), & \text{for 1D, 2D, Cube, or 3D image} \\ 411\partial{t}/\partial{x} & = dPdx(t), & \partial{t}/\partial{y} & = dPdy(t), & \text{for 2D, Cube, or 3D image} \\ 412\partial{u}/\partial{x} & = dPdx(u), & \partial{u}/\partial{y} & = dPdy(u), & \text{for Cube or 3D image} 413\end{aligned} 414+++++++++++++++++++ 415 416=== latexmath block 33 417 418[latexmath] 419++++++++++++++++++++++++ 420\begin{aligned} 421s_{face} & = 422 \frac{1}{2} \times \frac{s_c}{|r_c|} + \frac{1}{2} \\ 423t_{face} & = 424 \frac{1}{2} \times \frac{t_c}{|r_c|} + \frac{1}{2} \\ 425\end{aligned} 426++++++++++++++++++++++++ 427 428=== latexmath block 34 429 430[latexmath] 431++++++++++++++++++++++++ 432\begin{aligned} 433\frac{\partial{s_{face}}}{\partial{x}} &= 434 \frac{\partial}{\partial{x}} \left ( \frac{1}{2} \times \frac{s_{c}}{|r_{c}|} 435 + \frac{1}{2}\right ) \\ 436\frac{\partial{s_{face}}}{\partial{x}} &= 437 \frac{1}{2} \times \frac{\partial}{\partial{x}} 438 \left ( \frac{s_{c}}{|r_{c}|} \right ) \\ 439\frac{\partial{s_{face}}}{\partial{x}} &= 440 \frac{1}{2} \times 441 \left ( 442 \frac{ 443 |r_{c}| \times \partial{s_c}/\partial{x} 444 -s_c \times {\partial{r_{c}}}/{\partial{x}}} 445 {\left ( r_{c} \right )^2} 446 \right ) 447\end{aligned} 448++++++++++++++++++++++++ 449 450=== latexmath block 35 451 452[latexmath] 453++++++++++++++++++++++++ 454\begin{aligned} 455\frac{\partial{s_{face}}}{\partial{y}} &= 456 \frac{1}{2} \times 457 \left ( 458 \frac{ 459 |r_{c}| \times \partial{s_c}/\partial{y} 460 -s_c \times {\partial{r_{c}}}/{\partial{y}}} 461 {\left ( r_{c} \right )^2} 462 \right )\\ 463\frac{\partial{t_{face}}}{\partial{x}} &= 464 \frac{1}{2} \times 465 \left ( 466 \frac{ 467 |r_{c}| \times \partial{t_c}/\partial{x} 468 -t_c \times {\partial{r_{c}}}/{\partial{x}}} 469 {\left ( r_{c} \right )^2} 470 \right ) \\ 471\frac{\partial{t_{face}}}{\partial{y}} &= 472 \frac{1}{2} \times 473 \left ( 474 \frac{ 475 |r_{c}| \times \partial{t_c}/\partial{y} 476 -t_c \times {\partial{r_{c}}}/{\partial{y}}} 477 {\left ( r_{c} \right )^2} 478 \right ) 479\end{aligned} 480++++++++++++++++++++++++ 481 482=== latexmath block 36 483 484[latexmath] 485++++++++++++++++++++++++ 486\begin{aligned} 487\rho_{x} & = \sqrt{ m_{ux} ^{2} + m_{vx} ^{2} + m_{wx} ^{2} } \\ 488\rho_{y} & = \sqrt{ m_{uy} ^{2} + m_{vy} ^{2} + m_{wy} ^{2} } 489\end{aligned} 490++++++++++++++++++++++++ 491 492=== latexmath block 37 493 494 {empty}:: [eq]#f~x~# is continuous and monotonically increasing in each of 495 [eq]#m~ux~#, [eq]#m~vx~#, and [eq]#m~wx~# 496 {empty}:: [eq]#f~y~# is continuous and monotonically increasing in each of 497 [eq]#m~uy~#, [eq]#m~vy~#, and [eq]#m~wy~# 498 {empty}:: [eq]#max({vert}m~ux~{vert}, {vert}m~vx~{vert}, 499 {vert}m~wx~{vert}) {leq} f~x~ {leq} {vert}m~ux~{vert} {plus} 500 {vert}m~vx~{vert} {plus} {vert}m~wx~{vert}# 501 {empty}:: [eq]#max({vert}m~uy~{vert}, {vert}m~vy~{vert}, 502 {vert}m~wy~{vert}) {leq} f~y~ {leq} {vert}m~uy~{vert} {plus} 503 {vert}m~vy~{vert} {plus} {vert}m~wy~{vert}# 504 505=== latexmath block 38 506 507[latexmath] 508++++++++++++++++++++++++ 509\begin{aligned} 510N & = \min \left (\left \lceil \frac{\rho_{max}}{\rho_{min}} \right \rceil ,max_{Aniso} \right ) 511\end{aligned} 512++++++++++++++++++++++++ 513 514=== latexmath block 39 515 516[latexmath] 517++++++++++++++++++++++++ 518\begin{aligned} 519\lambda_{base}(x,y) & = 520 \begin{cases} 521 shaderOp.Lod & \text{(from optional SPIR-V operand)} \\ 522 \log_2 \left ( \frac{\rho_{max}}{N} \right ) & \text{otherwise} 523 \end{cases} \\ 524\lambda'(x,y) & = \lambda_{base} + \mathbin{clamp}(sampler.bias + shaderOp.bias,-maxSamplerLodBias,maxSamplerLodBias) \\ 525\lambda & = 526 \begin{cases} 527 lod_{max}, & \lambda' > lod_{max} \\ 528 \lambda', & lod_{min} \leq \lambda' \leq lod_{max} \\ 529 lod_{min}, & \lambda' < lod_{min} \\ 530 undefined, & lod_{min} > lod_{max} \\ 531 \end{cases} 532\end{aligned} 533++++++++++++++++++++++++ 534 535=== latexmath block 40 536 537[latexmath] 538++++++++++++++++++++++++ 539\begin{aligned} 540sampler.bias & = mipLodBias & \text{(from sampler descriptor)} \\ 541shaderOp.bias & = 542 \begin{cases} 543 Bias & \text{(from optional SPIR-V operand)} \\ 544 0 & \text{otherwise} 545 \end{cases} \\ 546sampler.lod_{min} & = minLod & \text{(from sampler descriptor)} \\ 547shaderOp.lod_{min} & = 548 \begin{cases} 549 MinLod & \text{(from optional SPIR-V operand)} \\ 550 0 & \text{otherwise} 551 \end{cases} \\ 552\\ 553lod_{min} & = \max(sampler.lod_{min}, shaderOp.lod_{min}) \\ 554lod_{max} & = maxLod & \text{(from sampler descriptor)} 555\end{aligned} 556++++++++++++++++++++++++ 557 558=== latexmath block 41 559 560[latexmath] 561++++++++++++++++++++++++ 562\begin{aligned} 563d = 564 \begin{cases} 565 level_{base}, & \lambda \leq \frac{1}{2} \\[.5em] 566 nearest(\lambda), & \lambda > \frac{1}{2}, 567 level_{base} + \lambda \leq 568 q + \frac{1}{2} \\[.5em] 569 q, & \lambda > \frac{1}{2}, 570 level_{base} + \lambda > q + \frac{1}{2} 571 \end{cases} 572\end{aligned} 573++++++++++++++++++++++++ 574 575=== latexmath block 42 576 577[latexmath] 578++++++++++++++++++++++++ 579\begin{aligned} 580nearest(\lambda) & = 581 \begin{cases} 582 \left \lceil level_{base}+\lambda + \frac{1}{2}\right \rceil - 1, & 583 \text{preferred} \\ 584 \left \lfloor level_{base}+\lambda + \frac{1}{2}\right \rfloor, & 585 \text{alternative} 586 \end{cases} 587\end{aligned} 588++++++++++++++++++++++++ 589 590=== latexmath block 43 591 592[latexmath] 593++++++++++++++++++++++++ 594\begin{aligned} 595d_{hi} & = 596 \begin{cases} 597 q, & level_{base} + \lambda \geq q \\ 598 \left \lfloor level_{base}+\lambda \right \rfloor, & \text{otherwise} 599 \end{cases} \\ 600d_{lo} & = 601 \begin{cases} 602 q, & level_{base} + \lambda \geq q \\ 603 d_{hi}+1, & \text{otherwise} 604 \end{cases} 605\end{aligned} 606++++++++++++++++++++++++ 607 608=== latexmath block 44 609 610[latexmath] 611++++++++++++++++++++++++ 612\begin{aligned} 613u(x,y) & = s(x,y) \times width_{level} \\ 614v(x,y) & = 615 \begin{cases} 616 0 & \text{for 1D images} \\ 617 t(x,y) \times height_{level} & \text{otherwise} 618 \end{cases} \\ 619w(x,y) & = 620 \begin{cases} 621 0 & \text{for 2D or Cube images} \\ 622 r(x,y) \times depth_{level} & \text{otherwise} 623 \end{cases} \\ 624\\ 625a(x,y) & = 626 \begin{cases} 627 a(x,y) & \text{for array images} \\ 628 0 & \text{otherwise} 629 \end{cases} 630\end{aligned} 631++++++++++++++++++++++++ 632 633=== latexmath block 45 634 635[latexmath] 636++++++++++++++++++++++++ 637\begin{aligned} 638\mathbin{RNE}(a) & = 639 \begin{cases} 640 \mathbin{roundTiesToEven}(a) & \text{preferred, from IEEE Std 754-2008 Floating-Point Arithmetic} \\ 641 \left \lfloor a + \frac{1}{2} \right \rfloor & \text{alternative} 642 \end{cases} 643\end{aligned} 644++++++++++++++++++++++++ 645 646=== latexmath block 46 647 648[latexmath] 649++++++++++++++++++++++++ 650\begin{aligned} 651i &= 652 \begin{cases} 653 i \bmod size & \text{for repeat} \\ 654 (size-1) - \mathbin{mirror} 655 ((i \bmod (2 \times size)) - size) & \text{for mirrored repeat} \\ 656 \mathbin{clamp}(i,0,size-1) & \text{for clamp to edge} \\ 657 \mathbin{clamp}(i,-1,size) & \text{for clamp to border} \\ 658 \mathbin{clamp}(\mathbin{mirror}(i),0,size-1) & \text{for mirror clamp to edge} 659 \end{cases} 660\end{aligned} 661++++++++++++++++++++++++ 662 663 664=== latexmath block 47 665 666[latexmath] 667++++++++++++++++++++++++ 668\begin{aligned} 669& \mathbin{mirror}(n) = 670 \begin{cases} 671 n & \text{for}\ n \geq 0 \\ 672 -(1+n) & \text{otherwise} 673 \end{cases} 674\end{aligned} 675++++++++++++++++++++++++ 676 677=== latexmath block 48 678 679[latexmath] 680++++++++++++++++++++++++ 681\begin{aligned} 682\tau[R] &= \tau_{i0j1}[level_{base}][comp] \\ 683\tau[G] &= \tau_{i1j1}[level_{base}][comp] \\ 684\tau[B] &= \tau_{i1j0}[level_{base}][comp] \\ 685\tau[A] &= \tau_{i0j0}[level_{base}][comp] 686\end{aligned} 687++++++++++++++++++++++++ 688 689=== latexmath block 49 690 691[latexmath] 692++++++++++++++++++++++++ 693\begin{aligned} 694\tau[level_{base}][comp] &= 695 \begin{cases} 696 \tau[level_{base}][R], & \text{for}\ comp = 0 \\ 697 \tau[level_{base}][G], & \text{for}\ comp = 1 \\ 698 \tau[level_{base}][B], & \text{for}\ comp = 2 \\ 699 \tau[level_{base}][A], & \text{for}\ comp = 3 700 \end{cases}\\ 701comp & \,\text{from SPIR-V operand Component} 702\end{aligned} 703++++++++++++++++++++++++ 704 705=== latexmath block 50 706 707[latexmath] 708++++++++++++++++++++++++ 709\begin{aligned} 710\tau[level] &= 711 \begin{cases} 712 \tau_{ijk}[level], & \text{for 3D image} \\ 713 \tau_{ij}[level], & \text{for 2D or Cube image} \\ 714 \tau_{i}[level], & \text{for 1D image} 715 \end{cases} 716\end{aligned} 717++++++++++++++++++++++++ 718 719=== latexmath block 51 720 721[latexmath] 722++++++++++++++++++++++++ 723\begin{aligned} 724\tau_{3D}[level] & = (1-\alpha)(1-\beta)(1-\gamma)\tau_{i0j0k0}[level] \\ 725 & \, + (\alpha)(1-\beta)(1-\gamma)\tau_{i1j0k0}[level] \\ 726 & \, + (1-\alpha)(\beta)(1-\gamma)\tau_{i0j1k0}[level] \\ 727 & \, + (\alpha)(\beta)(1-\gamma)\tau_{i1j1k0}[level] \\ 728 & \, + (1-\alpha)(1-\beta)(\gamma)\tau_{i0j0k1}[level] \\ 729 & \, + (\alpha)(1-\beta)(\gamma)\tau_{i1j0k1}[level] \\ 730 & \, + (1-\alpha)(\beta)(\gamma)\tau_{i0j1k1}[level] \\ 731 & \, + (\alpha)(\beta)(\gamma)\tau_{i1j1k1}[level] 732\end{aligned} 733++++++++++++++++++++++++ 734 735=== latexmath block 52 736 737[latexmath] 738++++++++++++++++++++++++ 739\begin{aligned} 740\tau_{2D}[level] & = (1-\alpha)(1-\beta)\tau_{i0j0}[level] \\ 741 & \, + (\alpha)(1-\beta)\tau_{i1j0}[level] \\ 742 & \, + (1-\alpha)(\beta)\tau_{i0j1}[level] \\ 743 & \, + (\alpha)(\beta)\tau_{i1j1}[level] 744\end{aligned} 745++++++++++++++++++++++++ 746 747=== latexmath block 53 748 749[latexmath] 750++++++++++++++++++++++++ 751\begin{aligned} 752\tau_{1D}[level] & = (1-\alpha)\tau_{i0}[level] \\ 753 & \, + (\alpha)\tau_{i1}[level] 754\end{aligned} 755++++++++++++++++++++++++ 756 757=== latexmath block 54 758 759[latexmath] 760++++++++++++++++++++++++ 761\begin{aligned} 762\tau[level] &= 763 \begin{cases} 764 \tau_{3D}[level], & \text{for 3D image} \\ 765 \tau_{2D}[level], & \text{for 2D or Cube image} \\ 766 \tau_{1D}[level], & \text{for 1D image} 767 \end{cases} 768\end{aligned} 769++++++++++++++++++++++++ 770 771=== latexmath block 55 772 773[latexmath] 774++++++++++++++++++++++++ 775\begin{aligned} 776\tau &= 777 \begin{cases} 778 \tau[d], & \text{for mip mode BASE or NEAREST} \\ 779 (1-\delta)\tau[d_{hi}]+\delta\tau[d_{lo}], & \text{for mip mode LINEAR} 780 \end{cases} 781\end{aligned} 782++++++++++++++++++++++++ 783 784=== latexmath block 56 785 786[latexmath] 787++++++++++++++++++++++++ 788\begin{aligned} 789\tau_{2Daniso} & = 790 \frac{1}{N}\sum_{i=1}^{N} 791 {\tau_{2D}\left ( 792 u \left ( x - \frac{1}{2} + \frac{i}{N+1} , y \right ), 793 \left ( v \left (x-\frac{1}{2}+\frac{i}{N+1} \right ), y 794\right ) 795 \right )}, 796 & \text{when}\ \rho_{x} > \rho_{y} \\ 797\tau_{2Daniso} &= 798 \frac{1}{N}\sum_{i=1}^{N} 799 {\tau_{2D}\left ( 800 u \left ( x, y - \frac{1}{2} + \frac{i}{N+1} \right ), 801 \left ( v \left (x,y-\frac{1}{2}+\frac{i}{N+1} \right ) 802\right ) 803 \right )}, 804 & \text{when}\ \rho_{y} \geq \rho_{x} 805\end{aligned} 806++++++++++++++++++++++++ 807 808== File chapters/vertexpostproc.txt 809 810=== latexmath block 57 811 812[latexmath] 813++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 814\begin{array}{c} 815-w_c \leq x_c \leq w_c \\ 816-w_c \leq y_c \leq w_c \\ 8170 \leq z_c \leq w_c 818\end{array} 819++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 820 821=== latexmath block 58 822 823[latexmath] 824++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 825\left(\begin{array}{c} 826x_c \\ 827y_c \\ 828z_c \\ 829w_c 830\end{array}\right) 831++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 832 833=== latexmath block 59 834 835[latexmath] 836++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 837\left( 838 \begin{array}{c} 839 x_d \\ 840 y_d \\ 841 z_d 842 \end{array} 843\right) = 844\left( 845 \begin{array}{c} 846 \frac{x_c}{w_c} \\ 847 \frac{y_c}{w_c} \\ 848 \frac{z_c}{w_c} 849 \end{array} 850\right) 851++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 852 853=== latexmath inline 12 854 855latexmath:[\frac{k}{2^m - 1}] 856 857== File chapters/VK_IMG_filter_cubic/filter_cubic_texel_filtering.txt 858 859=== latexmath block 60 860 861[latexmath] 862++++++++++++++++++++++++ 863\begin{aligned} 864cinterp(\tau_0, \tau_1, \tau_2, \tau_3, \omega) = 865\frac{1}{2} 866\begin{bmatrix}1 & \omega & \omega^2 & \omega^3 \end{bmatrix} 867\times 868\begin{bmatrix} 869 0 & 2 & 0 & 0 \\ 870-1 & 0 & 1 & 0 \\ 871 2 & -5 & 4 & 1 \\ 872-1 & 3 & -3 & 1 873\end{bmatrix} 874\times 875\begin{bmatrix} 876\tau_0 \\ 877\tau_1 \\ 878\tau_2 \\ 879\tau_3 880\end{bmatrix} 881\end{aligned} 882++++++++++++++++++++++++ 883 884=== latexmath block 61 885 886[latexmath] 887++++++++++++++++++++++++ 888\begin{aligned} 889\tau[level] &= 890 \begin{cases} 891 \tau_{2D}[level], & \text{for 2D image} \\ 892 \tau_{1D}[level], & \text{for 1D image} 893 \end{cases} 894\end{aligned} 895++++++++++++++++++++++++ 896 897== File chapters/VK_IMG_filter_cubic/filter_cubic_texel_selection.txt 898 899=== latexmath block 62 900 901[latexmath] 902++++++++++++++++++++++++ 903\begin{aligned} 904i_{0} & = \left \lfloor u - \frac{3}{2} \right \rfloor & i_{1} & = i_{0} + 1 & i_{2} & = i_{1} + 1 & i_{3} & = i_{2} + 1 \\[1em] 905j_{0} & = \left \lfloor u - \frac{3}{2} \right \rfloor & j_{1} & = j_{0} + 1 & j_{2} & = j_{1} + 1 & j_{3} & = j_{2} + 1 \\ 906\\ 907\alpha & = \mathbin{frac} \left ( u - \frac{1}{2} \right ) \\[1em] 908\beta & = \mathbin{frac} \left ( v - \frac{1}{2} \right ) 909\end{aligned} 910++++++++++++++++++++++++ 911 912== File style/writing.txt 913 914=== latexmath inline 13 915 916latexmath:[[0,1\]] 917 918=== latexmath inline 14 919 920latexmath:[\frac{1 - \frac{x}{2}}{x - 1}] 921 922=== latexmath inline 15 923 924latexmath:[\mathbf{c} = t \mathbf{c}_1 + (1-t) \mathbf{c}_2.] 925 926=== latexmath block 63 927 928[latexmath] 929+++++++++++++++++++ 930\begin{aligned} 931c_{RGB} & = 932 \begin{cases} 933 \frac{c_{sRGB}}{12.92} & \text{for}\ c_{sRGB} \leq 0.04045 \\ 934 \left ( \frac{c_{sRGB}+0.055}{1.055} \right )^{2.4} & \text{for}\ c_{sRGB} > 0.04045 935 \end{cases} 936\end{aligned} 937+++++++++++++++++++ 938 939=== latexmath block 64 940 941[latexmath] 942+++++++++++++++++++ 943V = 944 \begin{cases} 945 (-1)^S \times 0.0, & E = 0, M = 0 \\ 946 (-1)^S \times 2^{-14} \times { M \over 2^{10} }, 947 & E = 0, M \neq 0 \\ 948 (-1)^S \times 2^{E-15} \times { \left( 1 + { M \over 2^{10} } \right) }, 949 & 0 < E < 31 \\ 950 (-1)^S \times Inf, & E = 31, M = 0 \\ 951 NaN, & E = 31, M \neq 0 952 \end{cases} 953+++++++++++++++++++ 954