MBS File Format

chunk {
    char     ident[4];
    uint32_t size;
}

string {
    chunk header;   // ="STRI"
    char  string[]; // Null terminated, Zero-padded to 4-byte boundary.
}

frag_sta {
    chunk    header;    // ="FSTA"
    uint32_t stacksize; // fragment stack size
    uint32_t stackofs;  // starting offset
}

frag_dis {
    chunk    header;    // ="FDIS"
    uint32_t discard;   // 1 if shader has discard instruction
}

frag_buu {
    chunk    header;    // ="FBUU"
    uint8_t reads_color; // gl_FBColor
    uint8_t writes_color; // gl_FragColor
    uint8_t reads_depth; // gl_FBDepth
    uint8_t writes_depth; // ? gl_FragDepth (not supported in GLES2)
    uint8_t reads_stencil; // gl_FBStencil
    uint8_t writes_stencil; // ? gl_FragStencil (not supported in GLES2)
    uint8_t unknown_0;
    uint8_t unknown_1;
}

symbol {
    chunk    header; // ="VUNI"/"VVAR"/"VATT"
    string   symbol;
    uint8_t  unknown_0; // =0x00
    // type: 
    //   0x01 float
    //   0x02 int
    //   0x03 bool 
    //   0x04 matrix
    //   0x05 sampler2D
    //   0x06 samplerCube
    //   0x08 struct
    //   0x09 samplerExternalOES 
    uint8_t  type;      
    uint16_t component_count;
    uint16_t component_size;
    uint16_t entry_count;
    uint16_t src_stride;
    uint8_t  dst_stride;
    uint8_t  precision;
    uint32_t invariant; // 1 if "invariant" keyword specified, otherwise 0
    uint16_t offset;
    uint16_t index; // Usually -1 (0xFFFF) otherwise index of parent struct
}

table {
    chunk    header; // ="SUNI"/"SVAR"/"SATT"
    uint32_t count;
    symbol   symbols[count];
}

dbin {
    chunk    header; // ="DBIN"
    uint32_t code[];
}

frag {
    chunk    header;  // ="CFRA"
    // version (seems _mali_core_type from mali_ioctl.h)
    //   0x05 MALI_200
    //   0x07 MALI_400_PP
    uint32_t version; // =5
    frag_sta sta;
    frag_dis dis;
    frag_buu buu;
    table    uniforms; // ="SUNI"
    table    varyings; // ="SVAR"
    dbin     code;
}

vert_fins {
    chunk header; // ="FINS"
    uint32_t unknown_0;
    uint32_t instructions;
    uint32_t attrib_prefetch;
}

vertex {
    chunk header; // ="CVER"
    // version (seems _mali_core_type from mali_ioctl.h)
    //   0x02 MALI_GP2
    //   0x06 MALI_400_GP
    uint32_t version;
    vert_fins fins;
    table uniforms; // ="SUNI"
    table attributes; // ="SATT"
    table variants; // ="SVAR"
    dbin code;
}

file {
    chunk header; // ="MBS1"
    frag  fragment;
    vert  vertex;
}