SDL_shader_tools icon indicating copy to clipboard operation
SDL_shader_tools copied to clipboard

Bytecode Format Megathread

Open icculus opened this issue 3 years ago • 1 comments

Work has started on defining the bytecode format, and is ongoing:

https://github.com/icculus/SDL_shader_tools/blob/main/docs/README-bytecode-format.md

You can see a lot of these things aren't filled in yet, but that's mostly laziness on my part, and they will come with time. But there's enough there to let people sound alarms on crucial design choices.

icculus avatar Sep 07 '22 14:09 icculus

struct String {
    Uint32 num_words;  // number of 32-bit words this struct uses.
    Uint32 data[]; // num_words*4 of UTF-8 string data, NULL-terminated. Padded with zeroes to end on 32-bit boundary.
};

Why number of words instead of number of actually meaningful bytes?

struct Instruction {
    Uint32 opcode;   // each instruction type has a unique value.
    Uint32 num_words;  // number of 32-bit words this struct uses.
    Uint32 operands[];  // instructions are variable size
};

I'm not sure variable-sized instructions are a good idea. I can imagine cases where one would like to quickly parse all the instructions into an array before interpreting them. How much overhead do you expect from rounding everything up to the same size?

Also, are there any instructions where num_words is variable? If not, you could remove that field and provide an opcode -> size translation table as part of the spec instead.

Akaricchi avatar Jan 21 '23 11:01 Akaricchi