mojoshader.h
changeset 1164 006194daea99
parent 1156 6e760a19f456
child 1171 9f27482a2f58
equal deleted inserted replaced
1163:c73c39a59dd4 1164:006194daea99
   465     MOJOSHADER_symbol *symbols;
   465     MOJOSHADER_symbol *symbols;
   466     unsigned int instruction_count;
   466     unsigned int instruction_count;
   467     MOJOSHADER_preshaderInstruction *instructions;
   467     MOJOSHADER_preshaderInstruction *instructions;
   468     unsigned int register_count;
   468     unsigned int register_count;
   469     float *registers;
   469     float *registers;
       
   470     MOJOSHADER_malloc malloc;
       
   471     MOJOSHADER_free free;
       
   472     void *malloc_data;
   470 } MOJOSHADER_preshader;
   473 } MOJOSHADER_preshader;
   471 
   474 
   472 /*
   475 /*
   473  * Structure used to return data from parsing of a shader...
   476  * Structure used to return data from parsing of a shader...
   474  */
   477  */
   799  *  MOJOSHADER_parse() is, too.
   802  *  MOJOSHADER_parse() is, too.
   800  */
   803  */
   801 DECLSPEC void MOJOSHADER_freeParseData(const MOJOSHADER_parseData *data);
   804 DECLSPEC void MOJOSHADER_freeParseData(const MOJOSHADER_parseData *data);
   802 
   805 
   803 
   806 
   804 /* !!! FIXME: document me. */
   807 /*
       
   808  * You almost certainly don't need this function, unless you absolutely know
       
   809  *  why you need it without hesitation. This is useful if you're doing
       
   810  *  extremely low-level shader work or building specialized tools.
       
   811  *
       
   812  * Parse a preshader structure. This expects a buffer of bytes that represents
       
   813  *  the preshader data starting with its magic number token and ending at
       
   814  *  the end of the comment tokens that contain this preshader. Note that it
       
   815  *  does _not_ start at the beginning of the comment tokens.
       
   816  *
       
   817  * On success, this will return a MOJOSHADER_preshader. This can be
       
   818  *  deallocated later by calling MOJOSHADER_freePreshader(). On failure,
       
   819  *  this will return NULL. Unlike other MojoShader APIs, this assumes you
       
   820  *  either have a complete and valid buffer of preshader tokens or you have
       
   821  *  incomplete/corrupted data, so there is no explicit error reporting. Please
       
   822  *  note that if the system runs out of memory, this function will also return
       
   823  *  NULL without distinction.
       
   824  *
       
   825  * This function is thread safe, so long as any allocator you passed into
       
   826  *  MOJOSHADER_parsePreshader() is, too.
       
   827  */
   805 DECLSPEC const MOJOSHADER_preshader *MOJOSHADER_parsePreshader(const unsigned char *buf,
   828 DECLSPEC const MOJOSHADER_preshader *MOJOSHADER_parsePreshader(const unsigned char *buf,
   806                                                                const unsigned int len,
   829                                                                const unsigned int len,
   807                                                                MOJOSHADER_malloc m,
   830                                                                MOJOSHADER_malloc m,
   808                                                                MOJOSHADER_free f,
   831                                                                MOJOSHADER_free f,
   809                                                                void *d);
   832                                                                void *d);
   810 
   833 
   811 
   834 
   812 /* !!! FIXME: document me. */
   835 /*
   813 DECLSPEC void MOJOSHADER_freePreshader(const MOJOSHADER_preshader *preshader,
   836  * You almost certainly don't need this function, unless you absolutely know
   814                                        MOJOSHADER_free f,
   837  *  why you need it without hesitation. This is useful if you're doing
   815                                        void *d);
   838  *  extremely low-level shader work or building specialized tools.
       
   839  *
       
   840  * Call this to dispose of preshader parsing results when you are done with
       
   841  *  them. This will call the MOJOSHADER_free function you provided to
       
   842  *  MOJOSHADER_parsePreshader() multiple times, if you provided one.
       
   843  *  Passing a NULL here is a safe no-op.
       
   844  *
       
   845  * You only need to call this function for results from a call to
       
   846  *  MOJOSHADER_parsePreshader(). Other MojoShader structures with a preshader
       
   847  *  field, such as MOJOSHADER_parseData(), should not use this function, as
       
   848  *  the preshader will be deallocated with everything else in
       
   849  *  MOJOSHADER_freeParseData(), etc.
       
   850  *
       
   851  * This function is thread safe, so long as any allocator you passed into
       
   852  *  MOJOSHADER_parsePreshader() is, too.
       
   853  */
       
   854 DECLSPEC void MOJOSHADER_freePreshader(const MOJOSHADER_preshader *preshader);
   816 
   855 
   817 
   856 
   818 /* Effects interface... */
   857 /* Effects interface... */
   819 #include "mojoshader_effects.h"
   858 #include "mojoshader_effects.h"
   820 
   859