1331
1308
TGSI_SEMANTIC_POSITION
1332
1309
""""""""""""""""""""""
1334
Position, sometimes known as HPOS or WPOS for historical reasons, is the
1335
location of the vertex in space, in ``(x, y, z, w)`` format. ``x``, ``y``, and ``z``
1336
are the Cartesian coordinates, and ``w`` is the homogenous coordinate and used
1337
for the perspective divide, if enabled.
1339
As a vertex shader output, position should be scaled to the viewport. When
1340
used in fragment shaders, position will be in window coordinates. The convention
1341
used depends on the FS_COORD_ORIGIN and FS_COORD_PIXEL_CENTER properties.
1343
XXX additionally, is there a way to configure the perspective divide? it's
1344
accelerated on most chipsets AFAIK...
1346
Position, if not specified, usually defaults to ``(0, 0, 0, 1)``, and can
1347
be partially specified as ``(x, y, 0, 1)`` or ``(x, y, z, 1)``.
1349
XXX usually? can we solidify that?
1311
For vertex shaders, TGSI_SEMANTIC_POSITION indicates the vertex shader
1312
output register which contains the homogeneous vertex position in the clip
1313
space coordinate system. After clipping, the X, Y and Z components of the
1314
vertex will be divided by the W value to get normalized device coordinates.
1316
For fragment shaders, TGSI_SEMANTIC_POSITION is used to indicate that
1317
fragment shader input contains the fragment's window position. The X
1318
component starts at zero and always increases from left to right.
1319
The Y component starts at zero and always increases but Y=0 may either
1320
indicate the top of the window or the bottom depending on the fragment
1321
coordinate origin convention (see TGSI_PROPERTY_FS_COORD_ORIGIN).
1322
The Z coordinate ranges from 0 to 1 to represent depth from the front
1323
to the back of the Z buffer. The W component contains the reciprocol
1324
of the interpolated vertex position W component.
1326
Fragment shaders may also declare an output register with
1327
TGSI_SEMANTIC_POSITION. Only the Z component is writable. This allows
1328
the fragment shader to change the fragment's Z position.
1351
1332
TGSI_SEMANTIC_COLOR
1352
1333
"""""""""""""""""""
1354
Colors are used to, well, color the primitives. Colors are always in
1355
``(r, g, b, a)`` format.
1357
If alpha is not specified, it defaults to 1.
1335
For vertex shader outputs or fragment shader inputs/outputs, this
1336
label indicates that the resister contains an R,G,B,A color.
1338
Several shader inputs/outputs may contain colors so the semantic index
1339
is used to distinguish them. For example, color[0] may be the diffuse
1340
color while color[1] may be the specular color.
1342
This label is needed so that the flat/smooth shading can be applied
1343
to the right interpolants during rasterization.
1359
1347
TGSI_SEMANTIC_BCOLOR
1360
1348
""""""""""""""""""""
1362
1350
Back-facing colors are only used for back-facing polygons, and are only valid
1363
1351
in vertex shader outputs. After rasterization, all polygons are front-facing
1364
and COLOR and BCOLOR end up occupying the same slots in the fragment, so
1365
all BCOLORs effectively become regular COLORs in the fragment shader.
1352
and COLOR and BCOLOR end up occupying the same slots in the fragment shader,
1353
so all BCOLORs effectively become regular COLORs in the fragment shader.
1367
1356
TGSI_SEMANTIC_FOG
1368
1357
"""""""""""""""""
1370
The fog coordinate historically has been used to replace the depth coordinate
1371
for generation of fog in dedicated fog blocks. Gallium, however, does not use
1372
dedicated fog acceleration, placing it entirely in the fragment shader
1375
The fog coordinate should be written in ``(f, 0, 0, 1)`` format. Only the first
1376
component matters when writing from the vertex shader; the driver will ensure
1377
that the coordinate is in this format when used as a fragment shader input.
1359
Vertex shader inputs and outputs and fragment shader inputs may be
1360
labeled with TGSI_SEMANTIC_FOG to indicate that the register contains
1361
a fog coordinate in the form (F, 0, 0, 1). Typically, the fragment
1362
shader will use the fog coordinate to compute a fog blend factor which
1363
is used to blend the normal fragment color with a constant fog color.
1365
Only the first component matters when writing from the vertex shader;
1366
the driver will ensure that the coordinate is in this format when used
1367
as a fragment shader input.
1379
1370
TGSI_SEMANTIC_PSIZE
1380
1371
"""""""""""""""""""
1382
PSIZE, or point size, is used to specify point sizes per-vertex. It should
1383
be in ``(s, 0, 0, 1)`` format, where ``s`` is the (possibly clamped) point size.
1384
Only the first component matters when writing from the vertex shader.
1373
Vertex shader input and output registers may be labeled with
1374
TGIS_SEMANTIC_PSIZE to indicate that the register contains a point size
1375
in the form (S, 0, 0, 1). The point size controls the width or diameter
1376
of points for rasterization. This label cannot be used in fragment
1386
1379
When using this semantic, be sure to set the appropriate state in the
1387
1380
:ref:`rasterizer` first.
1389
1383
TGSI_SEMANTIC_GENERIC
1390
1384
"""""""""""""""""""""
1392
Generic semantics are nearly always used for texture coordinate attributes,
1393
in ``(s, t, r, q)`` format. ``t`` and ``r`` may be unused for certain kinds
1394
of lookups, and ``q`` is the level-of-detail bias for biased sampling.
1386
All vertex/fragment shader inputs/outputs not labeled with any other
1387
semantic label can be considered to be generic attributes. Typical
1388
uses of generic inputs/outputs are texcoords and user-defined values.
1396
These attributes are called "generic" because they may be used for anything
1397
else, including parameters, texture generation information, or anything that
1398
can be stored inside a four-component vector.
1400
1391
TGSI_SEMANTIC_NORMAL
1401
1392
""""""""""""""""""""
1403
Vertex normal; could be used to implement per-pixel lighting for legacy APIs
1404
that allow mixing fixed-function and programmable stages.
1394
Indicates that a vertex shader input is a normal vector. This is
1395
typically only used for legacy graphics APIs.
1406
1398
TGSI_SEMANTIC_FACE
1407
1399
""""""""""""""""""
1409
FACE is the facing bit, to store the facing information for the fragment
1410
shader. ``(f, 0, 0, 1)`` is the format. The first component will be positive
1411
when the fragment is front-facing, and negative when the component is
1401
This label applies to fragment shader inputs only and indicates that
1402
the register contains front/back-face information of the form (F, 0,
1403
0, 1). The first component will be positive when the fragment belongs
1404
to a front-facing polygon, and negative when the fragment belongs to a
1405
back-facing polygon.
1414
1408
TGSI_SEMANTIC_EDGEFLAG
1415
1409
""""""""""""""""""""""
1411
For vertex shaders, this sematic label indicates that an input or
1412
output is a boolean edge flag. The register layout is [F, x, x, x]
1413
where F is 0.0 or 1.0 and x = don't care. Normally, the vertex shader
1414
simply copies the edge flag input to the edgeflag output.
1416
Edge flags are used to control which lines or points are actually
1417
drawn when the polygon mode converts triangles/quads/polygons into
1471
1473
+--------------------+--------------+--------------------+--------------+
1472
1474
| Texture Components | Gallium | OpenGL | Direct3D 9 |
1473
1475
+====================+==============+====================+==============+
1474
| R | XXX TBD | (r, 0, 0, 1) | (r, 1, 1, 1) |
1476
| R | (r, 0, 0, 1) | (r, 0, 0, 1) | (r, 1, 1, 1) |
1475
1477
+--------------------+--------------+--------------------+--------------+
1476
| RG | XXX TBD | (r, g, 0, 1) | (r, g, 1, 1) |
1478
| RG | (r, g, 0, 1) | (r, g, 0, 1) | (r, g, 1, 1) |
1477
1479
+--------------------+--------------+--------------------+--------------+
1478
1480
| RGB | (r, g, b, 1) | (r, g, b, 1) | (r, g, b, 1) |
1479
1481
+--------------------+--------------+--------------------+--------------+