Difference between revisions of "SHBIN"
(→DVLE) |
(boolean, integer and vec4 constants !) |
||
Line 160: | Line 160: | ||
|} | |} | ||
− | Constant table entry : | + | Constant table entry header : |
+ | |||
{| class="wikitable" border="1" | {| class="wikitable" border="1" | ||
|- | |- | ||
Line 166: | Line 167: | ||
! Size | ! Size | ||
! Description | ! Description | ||
+ | |- | ||
+ | | 0x0 | ||
+ | | 0x1 | ||
+ | | Constant type | ||
|- | |- | ||
| 0x2 | | 0x2 | ||
| 0x1 | | 0x1 | ||
| Uniform ID | | Uniform ID | ||
+ | |} | ||
+ | |||
+ | There are (at least) 3 types of constants : 0 is boolean, 1 is integer and 2 is float24 vec4. | ||
+ | |||
+ | Corresponding constant entry formats : | ||
+ | |||
+ | {| class="wikitable" border="1" | ||
+ | |- | ||
+ | ! Offset | ||
+ | ! Size | ||
+ | ! Description | ||
+ | |- | ||
+ | | 0x0 | ||
+ | | 0x1 | ||
+ | | 0x0 | ||
+ | |- | ||
+ | | 0x2 | ||
+ | | 0x1 | ||
+ | | Uniform bool ID | ||
+ | |- | ||
+ | | 0x4 | ||
+ | | 0x1 | ||
+ | | Value (boolean) | ||
+ | |} | ||
+ | |||
+ | {| class="wikitable" border="1" | ||
+ | |- | ||
+ | ! Offset | ||
+ | ! Size | ||
+ | ! Description | ||
+ | |- | ||
+ | | 0x0 | ||
+ | | 0x1 | ||
+ | | 0x2 | ||
+ | |- | ||
+ | | 0x2 | ||
+ | | 0x1 | ||
+ | | Uniform vector ID | ||
|- | |- | ||
| 0x4 | | 0x4 |
Revision as of 09:06, 2 December 2014
Overview
The SHBIN (SHader BINary) file is used to contain compiled and linked shader programs. These can include vertex shaders (typically compiled from .vsh files) and geometry shaders (typically compiled from .gsh files, though .asm have been observed). In commercial games/apps, SHBIN files can be found as standalone files with the extension .shbin, or contained within .bcsdr files. BCSDR files use CGFX as a container, but the underlying DVLB/DVLP/DVLE structure remains unchanged.
A SHBIN's structure starts with a header, then a DVLP, then DVLE(s).
DVLB Header
Offset | Size | Description |
---|---|---|
0x0 | 0x4 | Magic "DVLB" |
0x4 | 0x4 | N = number of DVLEs in SHBIN |
0x8 | 0x4*N | DVLE offset table; each offset is a u32 relative to the start of the DVLB section |
The DVLP file comes directly after the header.
DVLP
Offset | Size | Description |
---|---|---|
0x0 | 0x4 | Magic "DVLP" |
0x4 | 0x4 | ? (Maybe a version number?) |
0x8 | 0x4 | Offset (relative to DVLP start) to the compiled shader binary blob |
0xC | 0x4 | Size of compiled shader binary blob, in words |
0x10 | 0x4 | Offset (relative to DVLP start) to shader instruction extension table |
0x14 | 0x4 | Number of shader instruction extension table entries (each entry is 8-byte long) |
0x18 | 0x4 | Offset (relative to DVLP start) to filename symbol table |
DVLE
Offset | Size | Description |
---|---|---|
0x0 | 0x4 | Magic "DVLE" |
0x6 | 0x1 | Shader type (0x0 = vertex shader, 0x1 = geometry shader; might contain other flags) |
0x8 | 0x4 | Program's main offset in binary blob (in words) |
0xC | 0x4 | Program's endmain offset in binary blob (in words) |
0x18 | 0x4 | Offset (relative to DVLE start) to constant table |
0x1C | 0x4 | Number of entries in constant table (each entry is 0x14-byte long) |
0x20 | 0x4 | Offset (relative to DVLE start) to label table |
0x24 | 0x4 | Number of entries in label table (each entry is 0x10-byte long) |
0x28 | 0x4 | Offset (relative to DVLE start) to output register table |
0x2C | 0x4 | Number of entries in output register table (each entry is 0x8-byte long) |
0x30 | 0x4 | Offset (relative to DVLE start) to uniform table |
0x34 | 0x4 | Number of entries in uniform table (each entry is 0x8-byte long) |
0x38 | 0x4 | Offset (relative to DVLE start) to symbol table |
0x3C | 0x4 | Size of symbol table (in bytes) |
Label table entry :
Offset | Size | Description |
---|---|---|
0x0 | 0x1 | Label ID |
0x4 | 0x4 | Offset (relative to shader program blob start) to label's location, in words |
0x8 | 0x4 | ? |
0xC | 0x4 | Offset (relative to DVLE symbol table start) to label's symbol |
Constant table entry header :
Offset | Size | Description |
---|---|---|
0x0 | 0x1 | Constant type |
0x2 | 0x1 | Uniform ID |
There are (at least) 3 types of constants : 0 is boolean, 1 is integer and 2 is float24 vec4.
Corresponding constant entry formats :
Offset | Size | Description |
---|---|---|
0x0 | 0x1 | 0x0 |
0x2 | 0x1 | Uniform bool ID |
0x4 | 0x1 | Value (boolean) |
Offset | Size | Description |
---|---|---|
0x0 | 0x1 | 0x2 |
0x2 | 0x1 | Uniform vector ID |
0x4 | 0x4 | x (float24) |
0x8 | 0x4 | y (float24) |
0xC | 0x4 | z (float24) |
0x10 | 0x4 | w (float24) |
Output register table entry:
Bit | Description |
---|---|
0-3 | Output type (see table below) |
16-19 | Register ID |
32-35 | Output attribute component mask (e.g. 5=xz) |
Output types (vertex shader) :
ID | Description |
---|---|
0x0 | result.position |
0x1 | result.normalquat |
0x2 | result.color |
0x3 | result.texcoord0 |
0x4 | ? |
0x5 | result.texcoord1 |
0x6 | result.texcoord2 |
0x7 | ? |
0x8 | result.view |
0x9 | result.normal |
Uniform table entry :
Offset | Size | Description |
---|---|---|
0x0 | 0x4 | Offset (relative to DVLE symbol table start) to variable's symbol |
0x4 | 0x2 | Variable start register |
0x6 | 0x2 | Variable end register |
Each DVLE is associated to an individual shader shader program contained in the binary blob. A single shader binary blob may contain multiple shader programs of the same kind.
Each program's constants are stored as vec4 in a uniform table. These are sent over to the GPU when changing to a give program.
Instruction Set
For a description of the instruction set, see the following page : Shader Instruction Set