diff options
| author | lbavoil <[email protected]> | 2018-03-15 11:19:29 +0100 |
|---|---|---|
| committer | lbavoil <[email protected]> | 2018-03-15 11:19:29 +0100 |
| commit | f01ecebfa72d6c470056b47e997dc7183fea1016 (patch) | |
| tree | 6d1503a28e93c227046addb4d5d4fabaa33fc1aa /build/tools/HLSLcc/May_2014/offline | |
| parent | HBAO+ 4.0.0.23740451 (diff) | |
| download | hbaoplus-f01ecebfa72d6c470056b47e997dc7183fea1016.tar.xz hbaoplus-f01ecebfa72d6c470056b47e997dc7183fea1016.zip | |
HBAO+ 4.0.0.23740451
Diffstat (limited to 'build/tools/HLSLcc/May_2014/offline')
| -rw-r--r-- | build/tools/HLSLcc/May_2014/offline/cjson/cJSON.c | 567 | ||||
| -rw-r--r-- | build/tools/HLSLcc/May_2014/offline/cjson/cJSON.h | 141 | ||||
| -rw-r--r-- | build/tools/HLSLcc/May_2014/offline/hash.h | 125 | ||||
| -rw-r--r-- | build/tools/HLSLcc/May_2014/offline/serializeReflection.cpp | 204 | ||||
| -rw-r--r-- | build/tools/HLSLcc/May_2014/offline/serializeReflection.h | 8 | ||||
| -rw-r--r-- | build/tools/HLSLcc/May_2014/offline/timer.cpp | 37 | ||||
| -rw-r--r-- | build/tools/HLSLcc/May_2014/offline/timer.h | 26 | ||||
| -rw-r--r-- | build/tools/HLSLcc/May_2014/offline/toGLSLStandalone.cpp | 677 |
8 files changed, 0 insertions, 1785 deletions
diff --git a/build/tools/HLSLcc/May_2014/offline/cjson/cJSON.c b/build/tools/HLSLcc/May_2014/offline/cjson/cJSON.c deleted file mode 100644 index ac1c7c9..0000000 --- a/build/tools/HLSLcc/May_2014/offline/cjson/cJSON.c +++ /dev/null @@ -1,567 +0,0 @@ -/* - Copyright (c) 2009 Dave Gamble - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -/* cJSON */ -/* JSON parser in C. */ - -#include <string.h> -#include <stdio.h> -#include <math.h> -#include <stdlib.h> -#include <float.h> -#include <limits.h> -#include <ctype.h> -#include "cJSON.h" - -static const char *ep; - -const char *cJSON_GetErrorPtr(void) {return ep;} - -static int cJSON_strcasecmp(const char *s1,const char *s2) -{ - if (!s1) return (s1==s2)?0:1;if (!s2) return 1; - for(; tolower(*s1) == tolower(*s2); ++s1, ++s2) if(*s1 == 0) return 0; - return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2); -} - -static void *(*cJSON_malloc)(size_t sz) = malloc; -static void (*cJSON_free)(void *ptr) = free; - -static char* cJSON_strdup(const char* str) -{ - size_t len; - char* copy; - - len = strlen(str) + 1; - if (!(copy = (char*)cJSON_malloc(len))) return 0; - memcpy(copy,str,len); - return copy; -} - -void cJSON_InitHooks(cJSON_Hooks* hooks) -{ - if (!hooks) { /* Reset hooks */ - cJSON_malloc = malloc; - cJSON_free = free; - return; - } - - cJSON_malloc = (hooks->malloc_fn)?hooks->malloc_fn:malloc; - cJSON_free = (hooks->free_fn)?hooks->free_fn:free; -} - -/* Internal constructor. */ -static cJSON *cJSON_New_Item(void) -{ - cJSON* node = (cJSON*)cJSON_malloc(sizeof(cJSON)); - if (node) memset(node,0,sizeof(cJSON)); - return node; -} - -/* Delete a cJSON structure. */ -void cJSON_Delete(cJSON *c) -{ - cJSON *next; - while (c) - { - next=c->next; - if (!(c->type&cJSON_IsReference) && c->child) cJSON_Delete(c->child); - if (!(c->type&cJSON_IsReference) && c->valuestring) cJSON_free(c->valuestring); - if (c->string) cJSON_free(c->string); - cJSON_free(c); - c=next; - } -} - -/* Parse the input text to generate a number, and populate the result into item. */ -static const char *parse_number(cJSON *item,const char *num) -{ - double n=0,sign=1,scale=0;int subscale=0,signsubscale=1; - - /* Could use sscanf for this? */ - if (*num=='-') sign=-1,num++; /* Has sign? */ - if (*num=='0') num++; /* is zero */ - if (*num>='1' && *num<='9') do n=(n*10.0)+(*num++ -'0'); while (*num>='0' && *num<='9'); /* Number? */ - if (*num=='.' && num[1]>='0' && num[1]<='9') {num++; do n=(n*10.0)+(*num++ -'0'),scale--; while (*num>='0' && *num<='9');} /* Fractional part? */ - if (*num=='e' || *num=='E') /* Exponent? */ - { num++;if (*num=='+') num++; else if (*num=='-') signsubscale=-1,num++; /* With sign? */ - while (*num>='0' && *num<='9') subscale=(subscale*10)+(*num++ - '0'); /* Number? */ - } - - n=sign*n*pow(10.0,(scale+subscale*signsubscale)); /* number = +/- number.fraction * 10^+/- exponent */ - - item->valuedouble=n; - item->valueint=(int)n; - item->type=cJSON_Number; - return num; -} - -/* Render the number nicely from the given item into a string. */ -static char *print_number(cJSON *item) -{ - char *str; - double d=item->valuedouble; - if (fabs(((double)item->valueint)-d)<=DBL_EPSILON && d<=INT_MAX && d>=INT_MIN) - { - str=(char*)cJSON_malloc(21); /* 2^64+1 can be represented in 21 chars. */ - if (str) sprintf(str,"%d",item->valueint); - } - else - { - str=(char*)cJSON_malloc(64); /* This is a nice tradeoff. */ - if (str) - { - if (fabs(floor(d)-d)<=DBL_EPSILON && fabs(d)<1.0e60)sprintf(str,"%.0f",d); - else if (fabs(d)<1.0e-6 || fabs(d)>1.0e9) sprintf(str,"%e",d); - else sprintf(str,"%f",d); - } - } - return str; -} - -/* Parse the input text into an unescaped cstring, and populate item. */ -static const unsigned char firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; -static const char *parse_string(cJSON *item,const char *str) -{ - const char *ptr=str+1;char *ptr2;char *out;int len=0;unsigned uc,uc2; - if (*str!='\"') {ep=str;return 0;} /* not a string! */ - - while (*ptr!='\"' && *ptr && ++len) if (*ptr++ == '\\') ptr++; /* Skip escaped quotes. */ - - out=(char*)cJSON_malloc(len+1); /* This is how long we need for the string, roughly. */ - if (!out) return 0; - - ptr=str+1;ptr2=out; - while (*ptr!='\"' && *ptr) - { - if (*ptr!='\\') *ptr2++=*ptr++; - else - { - ptr++; - switch (*ptr) - { - case 'b': *ptr2++='\b'; break; - case 'f': *ptr2++='\f'; break; - case 'n': *ptr2++='\n'; break; - case 'r': *ptr2++='\r'; break; - case 't': *ptr2++='\t'; break; - case 'u': /* transcode utf16 to utf8. */ - sscanf(ptr+1,"%4x",&uc);ptr+=4; /* get the unicode char. */ - - if ((uc>=0xDC00 && uc<=0xDFFF) || uc==0) break; /* check for invalid. */ - - if (uc>=0xD800 && uc<=0xDBFF) /* UTF16 surrogate pairs. */ - { - if (ptr[1]!='\\' || ptr[2]!='u') break; /* missing second-half of surrogate. */ - sscanf(ptr+3,"%4x",&uc2);ptr+=6; - if (uc2<0xDC00 || uc2>0xDFFF) break; /* invalid second-half of surrogate. */ - uc=0x10000 + (((uc&0x3FF)<<10) | (uc2&0x3FF)); - } - - len=4;if (uc<0x80) len=1;else if (uc<0x800) len=2;else if (uc<0x10000) len=3; ptr2+=len; - - switch (len) { - case 4: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6; - case 3: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6; - case 2: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6; - case 1: *--ptr2 =(uc | firstByteMark[len]); - } - ptr2+=len; - break; - default: *ptr2++=*ptr; break; - } - ptr++; - } - } - *ptr2=0; - if (*ptr=='\"') ptr++; - item->valuestring=out; - item->type=cJSON_String; - return ptr; -} - -/* Render the cstring provided to an escaped version that can be printed. */ -static char *print_string_ptr(const char *str) -{ - const char *ptr;char *ptr2,*out;int len=0;unsigned char token; - - if (!str) return cJSON_strdup(""); - ptr=str;while ((token=*ptr) && ++len) {if (strchr("\"\\\b\f\n\r\t",token)) len++; else if (token<32) len+=5;ptr++;} - - out=(char*)cJSON_malloc(len+3); - if (!out) return 0; - - ptr2=out;ptr=str; - *ptr2++='\"'; - while (*ptr) - { - if ((unsigned char)*ptr>31 && *ptr!='\"' && *ptr!='\\') *ptr2++=*ptr++; - else - { - *ptr2++='\\'; - switch (token=*ptr++) - { - case '\\': *ptr2++='\\'; break; - case '\"': *ptr2++='\"'; break; - case '\b': *ptr2++='b'; break; - case '\f': *ptr2++='f'; break; - case '\n': *ptr2++='n'; break; - case '\r': *ptr2++='r'; break; - case '\t': *ptr2++='t'; break; - default: sprintf(ptr2,"u%04x",token);ptr2+=5; break; /* escape and print */ - } - } - } - *ptr2++='\"';*ptr2++=0; - return out; -} -/* Invote print_string_ptr (which is useful) on an item. */ -static char *print_string(cJSON *item) {return print_string_ptr(item->valuestring);} - -/* Predeclare these prototypes. */ -static const char *parse_value(cJSON *item,const char *value); -static char *print_value(cJSON *item,int depth,int fmt); -static const char *parse_array(cJSON *item,const char *value); -static char *print_array(cJSON *item,int depth,int fmt); -static const char *parse_object(cJSON *item,const char *value); -static char *print_object(cJSON *item,int depth,int fmt); - -/* Utility to jump whitespace and cr/lf */ -static const char *skip(const char *in) {while (in && *in && (unsigned char)*in<=32) in++; return in;} - -/* Parse an object - create a new root, and populate. */ -cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated) -{ - const char *end=0; - cJSON *c=cJSON_New_Item(); - ep=0; - if (!c) return 0; /* memory fail */ - - end=parse_value(c,skip(value)); - if (!end) {cJSON_Delete(c);return 0;} /* parse failure. ep is set. */ - - /* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */ - if (require_null_terminated) {end=skip(end);if (*end) {cJSON_Delete(c);ep=end;return 0;}} - if (return_parse_end) *return_parse_end=end; - return c; -} -/* Default options for cJSON_Parse */ -cJSON *cJSON_Parse(const char *value) {return cJSON_ParseWithOpts(value,0,0);} - -/* Render a cJSON item/entity/structure to text. */ -char *cJSON_Print(cJSON *item) {return print_value(item,0,1);} -char *cJSON_PrintUnformatted(cJSON *item) {return print_value(item,0,0);} - -/* Parser core - when encountering text, process appropriately. */ -static const char *parse_value(cJSON *item,const char *value) -{ - if (!value) return 0; /* Fail on null. */ - if (!strncmp(value,"null",4)) { item->type=cJSON_NULL; return value+4; } - if (!strncmp(value,"false",5)) { item->type=cJSON_False; return value+5; } - if (!strncmp(value,"true",4)) { item->type=cJSON_True; item->valueint=1; return value+4; } - if (*value=='\"') { return parse_string(item,value); } - if (*value=='-' || (*value>='0' && *value<='9')) { return parse_number(item,value); } - if (*value=='[') { return parse_array(item,value); } - if (*value=='{') { return parse_object(item,value); } - - ep=value;return 0; /* failure. */ -} - -/* Render a value to text. */ -static char *print_value(cJSON *item,int depth,int fmt) -{ - char *out=0; - if (!item) return 0; - switch ((item->type)&255) - { - case cJSON_NULL: out=cJSON_strdup("null"); break; - case cJSON_False: out=cJSON_strdup("false");break; - case cJSON_True: out=cJSON_strdup("true"); break; - case cJSON_Number: out=print_number(item);break; - case cJSON_String: out=print_string(item);break; - case cJSON_Array: out=print_array(item,depth,fmt);break; - case cJSON_Object: out=print_object(item,depth,fmt);break; - } - return out; -} - -/* Build an array from input text. */ -static const char *parse_array(cJSON *item,const char *value) -{ - cJSON *child; - if (*value!='[') {ep=value;return 0;} /* not an array! */ - - item->type=cJSON_Array; - value=skip(value+1); - if (*value==']') return value+1; /* empty array. */ - - item->child=child=cJSON_New_Item(); - if (!item->child) return 0; /* memory fail */ - value=skip(parse_value(child,skip(value))); /* skip any spacing, get the value. */ - if (!value) return 0; - - while (*value==',') - { - cJSON *new_item; - if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */ - child->next=new_item;new_item->prev=child;child=new_item; - value=skip(parse_value(child,skip(value+1))); - if (!value) return 0; /* memory fail */ - } - - if (*value==']') return value+1; /* end of array */ - ep=value;return 0; /* malformed. */ -} - -/* Render an array to text */ -static char *print_array(cJSON *item,int depth,int fmt) -{ - char **entries; - char *out=0,*ptr,*ret;int len=5; - cJSON *child=item->child; - int numentries=0,i=0,fail=0; - - /* How many entries in the array? */ - while (child) numentries++,child=child->next; - /* Explicitly handle numentries==0 */ - if (!numentries) - { - out=(char*)cJSON_malloc(3); - if (out) strcpy(out,"[]"); - return out; - } - /* Allocate an array to hold the values for each */ - entries=(char**)cJSON_malloc(numentries*sizeof(char*)); - if (!entries) return 0; - memset(entries,0,numentries*sizeof(char*)); - /* Retrieve all the results: */ - child=item->child; - while (child && !fail) - { - ret=print_value(child,depth+1,fmt); - entries[i++]=ret; - if (ret) len+=(int)strlen(ret)+2+(fmt?1:0); else fail=1; - child=child->next; - } - - /* If we didn't fail, try to malloc the output string */ - if (!fail) out=(char*)cJSON_malloc(len); - /* If that fails, we fail. */ - if (!out) fail=1; - - /* Handle failure. */ - if (fail) - { - for (i=0;i<numentries;i++) if (entries[i]) cJSON_free(entries[i]); - cJSON_free(entries); - return 0; - } - - /* Compose the output array. */ - *out='['; - ptr=out+1;*ptr=0; - for (i=0;i<numentries;i++) - { - strcpy(ptr,entries[i]);ptr+=strlen(entries[i]); - if (i!=numentries-1) {*ptr++=',';if(fmt)*ptr++=' ';*ptr=0;} - cJSON_free(entries[i]); - } - cJSON_free(entries); - *ptr++=']';*ptr++=0; - return out; -} - -/* Build an object from the text. */ -static const char *parse_object(cJSON *item,const char *value) -{ - cJSON *child; - if (*value!='{') {ep=value;return 0;} /* not an object! */ - - item->type=cJSON_Object; - value=skip(value+1); - if (*value=='}') return value+1; /* empty array. */ - - item->child=child=cJSON_New_Item(); - if (!item->child) return 0; - value=skip(parse_string(child,skip(value))); - if (!value) return 0; - child->string=child->valuestring;child->valuestring=0; - if (*value!=':') {ep=value;return 0;} /* fail! */ - value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */ - if (!value) return 0; - - while (*value==',') - { - cJSON *new_item; - if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */ - child->next=new_item;new_item->prev=child;child=new_item; - value=skip(parse_string(child,skip(value+1))); - if (!value) return 0; - child->string=child->valuestring;child->valuestring=0; - if (*value!=':') {ep=value;return 0;} /* fail! */ - value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */ - if (!value) return 0; - } - - if (*value=='}') return value+1; /* end of array */ - ep=value;return 0; /* malformed. */ -} - -/* Render an object to text. */ -static char *print_object(cJSON *item,int depth,int fmt) -{ - char **entries=0,**names=0; - char *out=0,*ptr,*ret,*str;int len=7,i=0,j; - cJSON *child=item->child; - int numentries=0,fail=0; - /* Count the number of entries. */ - while (child) numentries++,child=child->next; - /* Explicitly handle empty object case */ - if (!numentries) - { - out=(char*)cJSON_malloc(fmt?depth+3:3); - if (!out) return 0; - ptr=out;*ptr++='{'; - if (fmt) {*ptr++='\n';for (i=0;i<depth-1;i++) *ptr++='\t';} - *ptr++='}';*ptr++=0; - return out; - } - /* Allocate space for the names and the objects */ - entries=(char**)cJSON_malloc(numentries*sizeof(char*)); - if (!entries) return 0; - names=(char**)cJSON_malloc(numentries*sizeof(char*)); - if (!names) {cJSON_free(entries);return 0;} - memset(entries,0,sizeof(char*)*numentries); - memset(names,0,sizeof(char*)*numentries); - - /* Collect all the results into our arrays: */ - child=item->child;depth++;if (fmt) len+=depth; - while (child) - { - names[i]=str=print_string_ptr(child->string); - entries[i++]=ret=print_value(child,depth,fmt); - if (str && ret) len+=(int)(strlen(ret)+strlen(str))+2+(fmt?2+depth:0); else fail=1; - child=child->next; - } - - /* Try to allocate the output string */ - if (!fail) out=(char*)cJSON_malloc(len); - if (!out) fail=1; - - /* Handle failure */ - if (fail) - { - for (i=0;i<numentries;i++) {if (names[i]) cJSON_free(names[i]);if (entries[i]) cJSON_free(entries[i]);} - cJSON_free(names);cJSON_free(entries); - return 0; - } - - /* Compose the output: */ - *out='{';ptr=out+1;if (fmt)*ptr++='\n';*ptr=0; - for (i=0;i<numentries;i++) - { - if (fmt) for (j=0;j<depth;j++) *ptr++='\t'; - strcpy(ptr,names[i]);ptr+=strlen(names[i]); - *ptr++=':';if (fmt) *ptr++='\t'; - strcpy(ptr,entries[i]);ptr+=strlen(entries[i]); - if (i!=numentries-1) *ptr++=','; - if (fmt) *ptr++='\n';*ptr=0; - cJSON_free(names[i]);cJSON_free(entries[i]); - } - - cJSON_free(names);cJSON_free(entries); - if (fmt) for (i=0;i<depth-1;i++) *ptr++='\t'; - *ptr++='}';*ptr++=0; - return out; -} - -/* Get Array size/item / object item. */ -int cJSON_GetArraySize(cJSON *array) {cJSON *c=array->child;int i=0;while(c)i++,c=c->next;return i;} -cJSON *cJSON_GetArrayItem(cJSON *array,int item) {cJSON *c=array->child; while (c && item>0) item--,c=c->next; return c;} -cJSON *cJSON_GetObjectItem(cJSON *object,const char *string) {cJSON *c=object->child; while (c && cJSON_strcasecmp(c->string,string)) c=c->next; return c;} - -/* Utility for array list handling. */ -static void suffix_object(cJSON *prev,cJSON *item) {prev->next=item;item->prev=prev;} -/* Utility for handling references. */ -static cJSON *create_reference(cJSON *item) {cJSON *ref=cJSON_New_Item();if (!ref) return 0;memcpy(ref,item,sizeof(cJSON));ref->string=0;ref->type|=cJSON_IsReference;ref->next=ref->prev=0;return ref;} - -/* Add item to array/object. */ -void cJSON_AddItemToArray(cJSON *array, cJSON *item) {cJSON *c=array->child;if (!item) return; if (!c) {array->child=item;} else {while (c && c->next) c=c->next; suffix_object(c,item);}} -void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item) {if (!item) return; if (item->string) cJSON_free(item->string);item->string=cJSON_strdup(string);cJSON_AddItemToArray(object,item);} -void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) {cJSON_AddItemToArray(array,create_reference(item));} -void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item) {cJSON_AddItemToObject(object,string,create_reference(item));} - -cJSON *cJSON_DetachItemFromArray(cJSON *array,int which) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return 0; - if (c->prev) c->prev->next=c->next;if (c->next) c->next->prev=c->prev;if (c==array->child) array->child=c->next;c->prev=c->next=0;return c;} -void cJSON_DeleteItemFromArray(cJSON *array,int which) {cJSON_Delete(cJSON_DetachItemFromArray(array,which));} -cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string) {int i=0;cJSON *c=object->child;while (c && cJSON_strcasecmp(c->string,string)) i++,c=c->next;if (c) return cJSON_DetachItemFromArray(object,i);return 0;} -void cJSON_DeleteItemFromObject(cJSON *object,const char *string) {cJSON_Delete(cJSON_DetachItemFromObject(object,string));} - -/* Replace array/object items with new ones. */ -void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return; - newitem->next=c->next;newitem->prev=c->prev;if (newitem->next) newitem->next->prev=newitem; - if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;c->next=c->prev=0;cJSON_Delete(c);} -void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem){int i=0;cJSON *c=object->child;while(c && cJSON_strcasecmp(c->string,string))i++,c=c->next;if(c){newitem->string=cJSON_strdup(string);cJSON_ReplaceItemInArray(object,i,newitem);}} - -/* Create basic types: */ -cJSON *cJSON_CreateNull(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_NULL;return item;} -cJSON *cJSON_CreateTrue(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_True;return item;} -cJSON *cJSON_CreateFalse(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_False;return item;} -cJSON *cJSON_CreateBool(int b) {cJSON *item=cJSON_New_Item();if(item)item->type=b?cJSON_True:cJSON_False;return item;} -cJSON *cJSON_CreateNumber(double num) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_Number;item->valuedouble=num;item->valueint=(int)num;}return item;} -cJSON *cJSON_CreateString(const char *string) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_String;item->valuestring=cJSON_strdup(string);}return item;} -cJSON *cJSON_CreateArray(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Array;return item;} -cJSON *cJSON_CreateObject(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Object;return item;} - -/* Create Arrays: */ -cJSON *cJSON_CreateIntArray(int *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;} -cJSON *cJSON_CreateFloatArray(float *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;} -cJSON *cJSON_CreateDoubleArray(double *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;} -cJSON *cJSON_CreateStringArray(const char **strings,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateString(strings[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;} - -/* Duplication */ -cJSON *cJSON_Duplicate(cJSON *item,int recurse) -{ - cJSON *newitem,*cptr,*nptr=0,*newchild; - /* Bail on bad ptr */ - if (!item) return 0; - /* Create new item */ - newitem=cJSON_New_Item(); - if (!newitem) return 0; - /* Copy over all vars */ - newitem->type=item->type&(~cJSON_IsReference),newitem->valueint=item->valueint,newitem->valuedouble=item->valuedouble; - if (item->valuestring) {newitem->valuestring=cJSON_strdup(item->valuestring); if (!newitem->valuestring) {cJSON_Delete(newitem);return 0;}} - if (item->string) {newitem->string=cJSON_strdup(item->string); if (!newitem->string) {cJSON_Delete(newitem);return 0;}} - /* If non-recursive, then we're done! */ - if (!recurse) return newitem; - /* Walk the ->next chain for the child. */ - cptr=item->child; - while (cptr) - { - newchild=cJSON_Duplicate(cptr,1); /* Duplicate (with recurse) each item in the ->next chain */ - if (!newchild) {cJSON_Delete(newitem);return 0;} - if (nptr) {nptr->next=newchild,newchild->prev=nptr;nptr=newchild;} /* If newitem->child already set, then crosswire ->prev and ->next and move on */ - else {newitem->child=newchild;nptr=newchild;} /* Set newitem->child and move to it */ - cptr=cptr->next; - } - return newitem; -} diff --git a/build/tools/HLSLcc/May_2014/offline/cjson/cJSON.h b/build/tools/HLSLcc/May_2014/offline/cjson/cJSON.h deleted file mode 100644 index 1aefe09..0000000 --- a/build/tools/HLSLcc/May_2014/offline/cjson/cJSON.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - Copyright (c) 2009 Dave Gamble - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -#ifndef cJSON__h -#define cJSON__h - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* cJSON Types: */ -#define cJSON_False 0 -#define cJSON_True 1 -#define cJSON_NULL 2 -#define cJSON_Number 3 -#define cJSON_String 4 -#define cJSON_Array 5 -#define cJSON_Object 6 - -#define cJSON_IsReference 256 - -/* The cJSON structure: */ -typedef struct cJSON { - struct cJSON *next,*prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */ - struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */ - - int type; /* The type of the item, as above. */ - - char *valuestring; /* The item's string, if type==cJSON_String */ - int valueint; /* The item's number, if type==cJSON_Number */ - double valuedouble; /* The item's number, if type==cJSON_Number */ - - char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */ -} cJSON; - -typedef struct cJSON_Hooks { - void *(*malloc_fn)(size_t sz); - void (*free_fn)(void *ptr); -} cJSON_Hooks; - -/* Supply malloc, realloc and free functions to cJSON */ -extern void cJSON_InitHooks(cJSON_Hooks* hooks); - - -/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */ -extern cJSON *cJSON_Parse(const char *value); -/* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */ -extern char *cJSON_Print(cJSON *item); -/* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */ -extern char *cJSON_PrintUnformatted(cJSON *item); -/* Delete a cJSON entity and all subentities. */ -extern void cJSON_Delete(cJSON *c); - -/* Returns the number of items in an array (or object). */ -extern int cJSON_GetArraySize(cJSON *array); -/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */ -extern cJSON *cJSON_GetArrayItem(cJSON *array,int item); -/* Get item "string" from object. Case insensitive. */ -extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string); - -/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */ -extern const char *cJSON_GetErrorPtr(void); - -/* These calls create a cJSON item of the appropriate type. */ -extern cJSON *cJSON_CreateNull(void); -extern cJSON *cJSON_CreateTrue(void); -extern cJSON *cJSON_CreateFalse(void); -extern cJSON *cJSON_CreateBool(int b); -extern cJSON *cJSON_CreateNumber(double num); -extern cJSON *cJSON_CreateString(const char *string); -extern cJSON *cJSON_CreateArray(void); -extern cJSON *cJSON_CreateObject(void); - -/* These utilities create an Array of count items. */ -extern cJSON *cJSON_CreateIntArray(int *numbers,int count); -extern cJSON *cJSON_CreateFloatArray(float *numbers,int count); -extern cJSON *cJSON_CreateDoubleArray(double *numbers,int count); -extern cJSON *cJSON_CreateStringArray(const char **strings,int count); - -/* Append item to the specified array/object. */ -extern void cJSON_AddItemToArray(cJSON *array, cJSON *item); -extern void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item); -/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */ -extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item); -extern void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item); - -/* Remove/Detatch items from Arrays/Objects. */ -extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which); -extern void cJSON_DeleteItemFromArray(cJSON *array,int which); -extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string); -extern void cJSON_DeleteItemFromObject(cJSON *object,const char *string); - -/* Update array items. */ -extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem); -extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem); - -/* Duplicate a cJSON item */ -extern cJSON *cJSON_Duplicate(cJSON *item,int recurse); -/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will -need to be released. With recurse!=0, it will duplicate any children connected to the item. -The item->next and ->prev pointers are always zero on return from Duplicate. */ - -/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */ -extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated); - -/* Macros for creating things quickly. */ -#define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull()) -#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue()) -#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse()) -#define cJSON_AddBoolToObject(object,name,b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b)) -#define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n)) -#define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s)) - -/* When assigning an integer value, it needs to be propagated to valuedouble too. */ -#define cJSON_SetIntValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val)) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/build/tools/HLSLcc/May_2014/offline/hash.h b/build/tools/HLSLcc/May_2014/offline/hash.h deleted file mode 100644 index eeb439e..0000000 --- a/build/tools/HLSLcc/May_2014/offline/hash.h +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef HASH_H_ -#define HASH_H_ - -/* --------------------------------------------------------------------- -mix -- mix 3 64-bit values reversibly. -mix() takes 48 machine instructions, but only 24 cycles on a superscalar - machine (like Intel's new MMX architecture). It requires 4 64-bit - registers for 4::2 parallelism. -All 1-bit deltas, all 2-bit deltas, all deltas composed of top bits of - (a,b,c), and all deltas of bottom bits were tested. All deltas were - tested both on random keys and on keys that were nearly all zero. - These deltas all cause every bit of c to change between 1/3 and 2/3 - of the time (well, only 113/400 to 287/400 of the time for some - 2-bit delta). These deltas all cause at least 80 bits to change - among (a,b,c) when the mix is run either forward or backward (yes it - is reversible). -This implies that a hash using mix64 has no funnels. There may be - characteristics with 3-bit deltas or bigger, I didn't test for - those. --------------------------------------------------------------------- -*/ -#define mix64(a,b,c) \ -{ \ - a -= b; a -= c; a ^= (c>>43); \ - b -= c; b -= a; b ^= (a<<9); \ - c -= a; c -= b; c ^= (b>>8); \ - a -= b; a -= c; a ^= (c>>38); \ - b -= c; b -= a; b ^= (a<<23); \ - c -= a; c -= b; c ^= (b>>5); \ - a -= b; a -= c; a ^= (c>>35); \ - b -= c; b -= a; b ^= (a<<49); \ - c -= a; c -= b; c ^= (b>>11); \ - a -= b; a -= c; a ^= (c>>12); \ - b -= c; b -= a; b ^= (a<<18); \ - c -= a; c -= b; c ^= (b>>22); \ -} - -/* --------------------------------------------------------------------- -hash64() -- hash a variable-length key into a 64-bit value - k : the key (the unaligned variable-length array of bytes) - len : the length of the key, counting by bytes - level : can be any 8-byte value -Returns a 64-bit value. Every bit of the key affects every bit of -the return value. No funnels. Every 1-bit and 2-bit delta achieves -avalanche. About 41+5len instructions. - -The best hash table sizes are powers of 2. There is no need to do -mod a prime (mod is sooo slow!). If you need less than 64 bits, -use a bitmask. For example, if you need only 10 bits, do - h = (h & hashmask(10)); -In which case, the hash table should have hashsize(10) elements. - -If you are hashing n strings (ub1 **)k, do it like this: - for (i=0, h=0; i<n; ++i) h = hash( k[i], len[i], h); - -By Bob Jenkins, Jan 4 1997. [email protected]. You may -use this code any way you wish, private, educational, or commercial, -but I would appreciate if you give me credit. - -See http://burtleburtle.net/bob/hash/evahash.html -Use for hash table lookup, or anything where one collision in 2^^64 -is acceptable. Do NOT use for cryptographic purposes. --------------------------------------------------------------------- -*/ - -static uint64_t hash64( register const uint8_t *k, register uint32_t length, register uint64_t initval ) -{ - register uint64_t a,b,c,len; - - /* Set up the internal state */ - len = length; - a = b = initval; /* the previous hash value */ - c = 0x9e3779b97f4a7c13LL; /* the golden ratio; an arbitrary value */ - - /*---------------------------------------- handle most of the key */ - while (len >= 24) - { - a += (k[0] +((uint64_t)k[ 1]<< 8)+((uint64_t)k[ 2]<<16)+((uint64_t)k[ 3]<<24) - +((uint64_t)k[4 ]<<32)+((uint64_t)k[ 5]<<40)+((uint64_t)k[ 6]<<48)+((uint64_t)k[ 7]<<56)); - b += (k[8] +((uint64_t)k[ 9]<< 8)+((uint64_t)k[10]<<16)+((uint64_t)k[11]<<24) - +((uint64_t)k[12]<<32)+((uint64_t)k[13]<<40)+((uint64_t)k[14]<<48)+((uint64_t)k[15]<<56)); - c += (k[16] +((uint64_t)k[17]<< 8)+((uint64_t)k[18]<<16)+((uint64_t)k[19]<<24) - +((uint64_t)k[20]<<32)+((uint64_t)k[21]<<40)+((uint64_t)k[22]<<48)+((uint64_t)k[23]<<56)); - mix64(a,b,c); - k += 24; len -= 24; - } - - /*------------------------------------- handle the last 23 bytes */ - c += length; - switch(len) /* all the case statements fall through */ - { - case 23: c+=((uint64_t)k[22]<<56); - case 22: c+=((uint64_t)k[21]<<48); - case 21: c+=((uint64_t)k[20]<<40); - case 20: c+=((uint64_t)k[19]<<32); - case 19: c+=((uint64_t)k[18]<<24); - case 18: c+=((uint64_t)k[17]<<16); - case 17: c+=((uint64_t)k[16]<<8); - /* the first byte of c is reserved for the length */ - case 16: b+=((uint64_t)k[15]<<56); - case 15: b+=((uint64_t)k[14]<<48); - case 14: b+=((uint64_t)k[13]<<40); - case 13: b+=((uint64_t)k[12]<<32); - case 12: b+=((uint64_t)k[11]<<24); - case 11: b+=((uint64_t)k[10]<<16); - case 10: b+=((uint64_t)k[ 9]<<8); - case 9: b+=((uint64_t)k[ 8]); - case 8: a+=((uint64_t)k[ 7]<<56); - case 7: a+=((uint64_t)k[ 6]<<48); - case 6: a+=((uint64_t)k[ 5]<<40); - case 5: a+=((uint64_t)k[ 4]<<32); - case 4: a+=((uint64_t)k[ 3]<<24); - case 3: a+=((uint64_t)k[ 2]<<16); - case 2: a+=((uint64_t)k[ 1]<<8); - case 1: a+=((uint64_t)k[ 0]); - /* case 0: nothing left to add */ - } - mix64(a,b,c); - /*-------------------------------------------- report the result */ - return c; -} - -#endif diff --git a/build/tools/HLSLcc/May_2014/offline/serializeReflection.cpp b/build/tools/HLSLcc/May_2014/offline/serializeReflection.cpp deleted file mode 100644 index 4f43337..0000000 --- a/build/tools/HLSLcc/May_2014/offline/serializeReflection.cpp +++ /dev/null @@ -1,204 +0,0 @@ -#include "serializeReflection.h" -#include "cJSON.h" -#include <string> -#include <sstream> - -void* jsonMalloc(size_t sz) -{ - return new char[sz]; -} -void jsonFree(void* ptr) -{ - char* charPtr = static_cast<char*>(ptr); - delete [] charPtr; -} - -static void AppendIntToString(std::string& str, uint32_t num) -{ - std::stringstream ss; - ss << num; - str += ss.str(); -} - -static void WriteInOutSignature(InOutSignature* psSignature, cJSON* obj) -{ - cJSON_AddItemToObject(obj, "SemanticName", cJSON_CreateString(psSignature->SemanticName)); - cJSON_AddItemToObject(obj, "ui32SemanticIndex", cJSON_CreateNumber(psSignature->ui32SemanticIndex)); - cJSON_AddItemToObject(obj, "eSystemValueType", cJSON_CreateNumber(psSignature->eSystemValueType)); - cJSON_AddItemToObject(obj, "eComponentType", cJSON_CreateNumber(psSignature->eComponentType)); - cJSON_AddItemToObject(obj, "ui32Register", cJSON_CreateNumber(psSignature->ui32Register)); - cJSON_AddItemToObject(obj, "ui32Mask", cJSON_CreateNumber(psSignature->ui32Mask)); - cJSON_AddItemToObject(obj, "ui32ReadWriteMask", cJSON_CreateNumber(psSignature->ui32ReadWriteMask)); -} - -static void WriteResourceBinding(ResourceBinding* psBinding, cJSON* obj) -{ - cJSON_AddItemToObject(obj, "Name", cJSON_CreateString(psBinding->Name)); - cJSON_AddItemToObject(obj, "eType", cJSON_CreateNumber(psBinding->eType)); - cJSON_AddItemToObject(obj, "ui32BindPoint", cJSON_CreateNumber(psBinding->ui32BindPoint)); - cJSON_AddItemToObject(obj, "ui32BindCount", cJSON_CreateNumber(psBinding->ui32BindCount)); - cJSON_AddItemToObject(obj, "ui32Flags", cJSON_CreateNumber(psBinding->ui32Flags)); - cJSON_AddItemToObject(obj, "eDimension", cJSON_CreateNumber(psBinding->eDimension)); - cJSON_AddItemToObject(obj, "ui32ReturnType", cJSON_CreateNumber(psBinding->ui32ReturnType)); - cJSON_AddItemToObject(obj, "ui32NumSamples", cJSON_CreateNumber(psBinding->ui32NumSamples)); -} - -static void WriteShaderVar(ShaderVar* psVar, cJSON* obj) -{ - cJSON_AddItemToObject(obj, "Name", cJSON_CreateString(psVar->Name)); - if(psVar->haveDefaultValue) - { - cJSON_AddItemToObject(obj, "aui32DefaultValues", cJSON_CreateIntArray((int*)psVar->pui32DefaultValues, psVar->ui32Size/4)); - } - cJSON_AddItemToObject(obj, "ui32StartOffset", cJSON_CreateNumber(psVar->ui32StartOffset)); - cJSON_AddItemToObject(obj, "ui32Size", cJSON_CreateNumber(psVar->ui32Size)); -} - -static void WriteConstantBuffer(ConstantBuffer* psCBuf, cJSON* obj) -{ - cJSON_AddItemToObject(obj, "Name", cJSON_CreateString(psCBuf->Name)); - cJSON_AddItemToObject(obj, "ui32NumVars", cJSON_CreateNumber(psCBuf->ui32NumVars)); - - for(uint32_t i = 0; i < psCBuf->ui32NumVars; ++i) - { - std::string name; - name += "var"; - AppendIntToString(name, i); - - cJSON* varObj = cJSON_CreateObject(); - cJSON_AddItemToObject(obj, name.c_str(), varObj); - - WriteShaderVar(&psCBuf->asVars[i], varObj); - } - - cJSON_AddItemToObject(obj, "ui32TotalSizeInBytes", cJSON_CreateNumber(psCBuf->ui32TotalSizeInBytes)); -} - -static void WriteClassType(ClassType* psClassType, cJSON* obj) -{ - cJSON_AddItemToObject(obj, "Name", cJSON_CreateString(psClassType->Name)); - cJSON_AddItemToObject(obj, "ui16ID", cJSON_CreateNumber(psClassType->ui16ID)); - cJSON_AddItemToObject(obj, "ui16ConstBufStride", cJSON_CreateNumber(psClassType->ui16ConstBufStride)); - cJSON_AddItemToObject(obj, "ui16Texture", cJSON_CreateNumber(psClassType->ui16Texture)); - cJSON_AddItemToObject(obj, "ui16Sampler", cJSON_CreateNumber(psClassType->ui16Sampler)); -} - -static void WriteClassInstance(ClassInstance* psClassInst, cJSON* obj) -{ - cJSON_AddItemToObject(obj, "Name", cJSON_CreateString(psClassInst->Name)); - cJSON_AddItemToObject(obj, "ui16ID", cJSON_CreateNumber(psClassInst->ui16ID)); - cJSON_AddItemToObject(obj, "ui16ConstBuf", cJSON_CreateNumber(psClassInst->ui16ConstBuf)); - cJSON_AddItemToObject(obj, "ui16ConstBufOffset", cJSON_CreateNumber(psClassInst->ui16ConstBufOffset)); - cJSON_AddItemToObject(obj, "ui16Texture", cJSON_CreateNumber(psClassInst->ui16Texture)); - cJSON_AddItemToObject(obj, "ui16Sampler", cJSON_CreateNumber(psClassInst->ui16Sampler)); -} - -const char* SerializeReflection(ShaderInfo* psReflection) -{ - cJSON* root; - - cJSON_Hooks hooks; - hooks.malloc_fn = jsonMalloc; - hooks.free_fn = jsonFree; - cJSON_InitHooks(&hooks); - - root=cJSON_CreateObject(); - cJSON_AddItemToObject(root, "ui32MajorVersion", cJSON_CreateNumber(psReflection->ui32MajorVersion)); - cJSON_AddItemToObject(root, "ui32MinorVersion", cJSON_CreateNumber(psReflection->ui32MinorVersion)); - - cJSON_AddItemToObject(root, "ui32NumInputSignatures", cJSON_CreateNumber(psReflection->ui32NumInputSignatures)); - - for(uint32_t i = 0; i < psReflection->ui32NumInputSignatures; ++i) - { - std::string name; - name += "input"; - AppendIntToString(name, i); - - cJSON* obj = cJSON_CreateObject(); - cJSON_AddItemToObject(root, name.c_str(), obj); - - WriteInOutSignature(psReflection->psInputSignatures+i, obj); - } - - cJSON_AddItemToObject(root, "ui32NumOutputSignatures", cJSON_CreateNumber(psReflection->ui32NumOutputSignatures)); - - for(uint32_t i = 0; i < psReflection->ui32NumOutputSignatures; ++i) - { - std::string name; - name += "output"; - AppendIntToString(name, i); - - cJSON* obj = cJSON_CreateObject(); - cJSON_AddItemToObject(root, name.c_str(), obj); - - WriteInOutSignature(psReflection->psOutputSignatures+i, obj); - } - - cJSON_AddItemToObject(root, "ui32NumResourceBindings", cJSON_CreateNumber(psReflection->ui32NumResourceBindings)); - - for(uint32_t i = 0; i < psReflection->ui32NumResourceBindings; ++i) - { - std::string name; - name += "resource"; - AppendIntToString(name, i); - - cJSON* obj = cJSON_CreateObject(); - cJSON_AddItemToObject(root, name.c_str(), obj); - - WriteResourceBinding(psReflection->psResourceBindings+i, obj); - } - - cJSON_AddItemToObject(root, "ui32NumConstantBuffers", cJSON_CreateNumber(psReflection->ui32NumConstantBuffers)); - - for(uint32_t i = 0; i < psReflection->ui32NumConstantBuffers; ++i) - { - std::string name; - name += "cbuf"; - AppendIntToString(name, i); - - cJSON* obj = cJSON_CreateObject(); - cJSON_AddItemToObject(root, name.c_str(), obj); - - WriteConstantBuffer(psReflection->psConstantBuffers+i, obj); - } - - //psThisPointerConstBuffer is a cache. Don't need to write this out. - //It just points to the $ThisPointer cbuffer within the psConstantBuffers array. - - for(uint32_t i = 0; i < psReflection->ui32NumClassTypes; ++i) - { - std::string name; - name += "classType"; - AppendIntToString(name, i); - - cJSON* obj = cJSON_CreateObject(); - cJSON_AddItemToObject(root, name.c_str(), obj); - - WriteClassType(psReflection->psClassTypes+i, obj); - } - - for(uint32_t i = 0; i < psReflection->ui32NumClassInstances; ++i) - { - std::string name; - name += "classInst"; - AppendIntToString(name, i); - - cJSON* obj = cJSON_CreateObject(); - cJSON_AddItemToObject(root, name.c_str(), obj); - - WriteClassInstance(psReflection->psClassInstances+i, obj); - } - - //psReflection->aui32TableIDToTypeID - //psReflection->aui32ConstBufferBindpointRemap - - cJSON_AddItemToObject(root, "eTessPartitioning", cJSON_CreateNumber(psReflection->eTessPartitioning)); - cJSON_AddItemToObject(root, "eTessOutPrim", cJSON_CreateNumber(psReflection->eTessOutPrim)); - - - const char* jsonString = cJSON_Print(root); - - cJSON_Delete(root); - - return jsonString; -} diff --git a/build/tools/HLSLcc/May_2014/offline/serializeReflection.h b/build/tools/HLSLcc/May_2014/offline/serializeReflection.h deleted file mode 100644 index 495e5b8..0000000 --- a/build/tools/HLSLcc/May_2014/offline/serializeReflection.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef SERIALIZE_REFLECTION_H_ -#define SERIALIZE_REFLECTION_H_ - -#include "hlslcc.h" - -const char* SerializeReflection(ShaderInfo* psReflection); - -#endif diff --git a/build/tools/HLSLcc/May_2014/offline/timer.cpp b/build/tools/HLSLcc/May_2014/offline/timer.cpp deleted file mode 100644 index ac7858b..0000000 --- a/build/tools/HLSLcc/May_2014/offline/timer.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "timer.h" - -void InitTimer(Timer_t* psTimer) -{ -#if defined(_WIN32) - QueryPerformanceFrequency(&psTimer->frequency); -#endif -} - -void ResetTimer(Timer_t* psTimer) -{ -#if defined(_WIN32) - QueryPerformanceCounter(&psTimer->startCount); -#else - gettimeofday(&psTimer->startCount, 0); -#endif -} - -/* Returns time in micro seconds */ -double ReadTimer(Timer_t* psTimer) -{ - double startTimeInMicroSec, endTimeInMicroSec; - -#if defined(_WIN32) - const double freq = (1000000.0 / psTimer->frequency.QuadPart); - QueryPerformanceCounter(&psTimer->endCount); - startTimeInMicroSec = psTimer->startCount.QuadPart * freq; - endTimeInMicroSec = psTimer->endCount.QuadPart * freq; -#else - gettimeofday(&psTimer->endCount, 0); - startTimeInMicroSec = (psTimer->startCount.tv_sec * 1000000.0) + psTimer->startCount.tv_usec; - endTimeInMicroSec = (psTimer->endCount.tv_sec * 1000000.0) + psTimer->endCount.tv_usec; -#endif - - return endTimeInMicroSec - startTimeInMicroSec; -} - diff --git a/build/tools/HLSLcc/May_2014/offline/timer.h b/build/tools/HLSLcc/May_2014/offline/timer.h deleted file mode 100644 index 05d6b0f..0000000 --- a/build/tools/HLSLcc/May_2014/offline/timer.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef TIMER_H -#define TIMER_H - -#ifdef _WIN32 -#include <Windows.h> -#else -#include <sys/time.h> -#endif - -typedef struct -{ -#ifdef _WIN32 - LARGE_INTEGER frequency; - LARGE_INTEGER startCount; - LARGE_INTEGER endCount; -#else - struct timeval startCount; - struct timeval endCount; -#endif -} Timer_t; - -void InitTimer(Timer_t* psTimer); -void ResetTimer(Timer_t* psTimer); -double ReadTimer(Timer_t* psTimer); - -#endif diff --git a/build/tools/HLSLcc/May_2014/offline/toGLSLStandalone.cpp b/build/tools/HLSLcc/May_2014/offline/toGLSLStandalone.cpp deleted file mode 100644 index 4cdb2a6..0000000 --- a/build/tools/HLSLcc/May_2014/offline/toGLSLStandalone.cpp +++ /dev/null @@ -1,677 +0,0 @@ - -#include "hlslcc.hpp" -#include "stdlib.h" -#include "stdio.h" -#include <string> -#include <string.h> -#include "hash.h" -#include "serializeReflection.h" - -#ifdef _WIN32 -#include <direct.h> -#else -#include <sys/stat.h> -#endif - -#include "timer.h" - -#if defined(_WIN32) -#define VALIDATE_OUTPUT -#endif - -#if defined(VALIDATE_OUTPUT) -#if defined(_WIN32) -#include <windows.h> -#include <gl/GL.h> - - #pragma comment(lib, "opengl32.lib") - - typedef char GLcharARB; /* native character */ - typedef unsigned int GLhandleARB; /* shader object handle */ -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 - typedef void (WINAPI * PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); - typedef GLhandleARB (WINAPI * PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); - typedef void (WINAPI * PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); - typedef void (WINAPI * PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); - typedef void (WINAPI * PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); - typedef void (WINAPI * PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); - typedef GLhandleARB (WINAPI * PFNGLCREATEPROGRAMOBJECTARBPROC) (void); - typedef void (WINAPI * PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); - typedef void (WINAPI * PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); - typedef void (WINAPI * PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); - typedef void (WINAPI * PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei* length, GLcharARB* infoLog); - - static PFNGLDELETEOBJECTARBPROC glDeleteObjectARB; - static PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB; - static PFNGLSHADERSOURCEARBPROC glShaderSourceARB; - static PFNGLCOMPILESHADERARBPROC glCompileShaderARB; - static PFNGLGETINFOLOGARBPROC glGetInfoLogARB; - static PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB; - static PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB; - static PFNGLATTACHOBJECTARBPROC glAttachObjectARB; - static PFNGLLINKPROGRAMARBPROC glLinkProgramARB; - static PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB; - static PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; - -#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 -#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 -#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 -#define WGL_CONTEXT_FLAGS_ARB 0x2094 -#define ERROR_INVALID_VERSION_ARB 0x2095 -#define ERROR_INVALID_PROFILE_ARB 0x2096 - -#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 -#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 -#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 - -typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int* attribList); -static PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB; - -void InitOpenGL() -{ - HGLRC rc; - - // setup minimal required GL - HWND wnd = CreateWindowA( - "STATIC", - "GL", - WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, - 0, 0, 16, 16, - NULL, NULL, - GetModuleHandle(NULL), NULL ); - HDC dc = GetDC( wnd ); - - PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL, - PFD_TYPE_RGBA, 32, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 16, 0, - 0, PFD_MAIN_PLANE, 0, 0, 0, 0 - }; - - int fmt = ChoosePixelFormat( dc, &pfd ); - SetPixelFormat( dc, fmt, &pfd ); - - rc = wglCreateContext( dc ); - wglMakeCurrent( dc, rc ); - - wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"); - - if(wglCreateContextAttribsARB) - { - const int OpenGLContextAttribs [] = { - WGL_CONTEXT_MAJOR_VERSION_ARB, 3, - WGL_CONTEXT_MINOR_VERSION_ARB, 3, - #if defined(_DEBUG) - //WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB | WGL_CONTEXT_DEBUG_BIT_ARB, - #else - //WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, - #endif - //WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, - 0, 0 - }; - - const HGLRC OpenGLContext = wglCreateContextAttribsARB( dc, 0, OpenGLContextAttribs ); - - wglMakeCurrent(dc, OpenGLContext); - - wglDeleteContext(rc); - - rc = OpenGLContext; - } - - glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)wglGetProcAddress("glDeleteObjectARB"); - glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)wglGetProcAddress("glCreateShaderObjectARB"); - glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)wglGetProcAddress("glShaderSourceARB"); - glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)wglGetProcAddress("glCompileShaderARB"); - glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)wglGetProcAddress("glGetInfoLogARB"); - glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)wglGetProcAddress("glGetObjectParameterivARB"); - glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)wglGetProcAddress("glCreateProgramObjectARB"); - glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)wglGetProcAddress("glAttachObjectARB"); - glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC)wglGetProcAddress("glLinkProgramARB"); - glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)wglGetProcAddress("glUseProgramObjectARB"); - glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog"); -} -#endif - -int TryCompileShader(GLenum eGLSLShaderType, const char* inFilename, char* shader, double* pCompileTime) -{ - GLint iCompileStatus; - GLuint hShader; - Timer_t timer; - - InitTimer(&timer); - - InitOpenGL(); - - hShader = glCreateShaderObjectARB(eGLSLShaderType); - glShaderSourceARB(hShader, 1, (const char **)&shader, NULL); - - ResetTimer(&timer); - glCompileShaderARB(hShader); - *pCompileTime = ReadTimer(&timer); - - /* Check it compiled OK */ - glGetObjectParameterivARB (hShader, GL_OBJECT_COMPILE_STATUS_ARB, &iCompileStatus); - - if (iCompileStatus != GL_TRUE) - { - FILE* errorFile; - GLint iInfoLogLength = 0; - char* pszInfoLog; - std::string filename; - - filename += inFilename; - - glGetObjectParameterivARB (hShader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &iInfoLogLength); - - pszInfoLog = new char[iInfoLogLength]; - - printf("Error: Failed to compile GLSL shader\n"); - - glGetInfoLogARB (hShader, iInfoLogLength, NULL, pszInfoLog); - - printf(pszInfoLog); - - filename += "_compileErrors.txt"; - - //Dump to file - errorFile = fopen(filename.c_str(), "w"); - fprintf(errorFile, shader); - fprintf(errorFile, pszInfoLog); - fclose(errorFile); - - delete [] pszInfoLog; - - return 0; - } - - return 1; -} -#endif - -int fileExists(const char* path) -{ - FILE* shaderFile; - shaderFile = fopen(path, "rb"); - - if(shaderFile) - { - fclose(shaderFile); - return 1; - } - return 0; -} - -GLLang LanguageFromString(const char* str) -{ - if(strcmp(str, "es100")==0) - { - return LANG_ES_100; - } - if(strcmp(str, "es300")==0) - { - return LANG_ES_300; - } - if(strcmp(str, "es310")==0) - { - return LANG_ES_310; - } - if(strcmp(str, "120")==0) - { - return LANG_120; - } - if(strcmp(str, "130")==0) - { - return LANG_130; - } - if(strcmp(str, "140")==0) - { - return LANG_140; - } - if(strcmp(str, "150")==0) - { - return LANG_150; - } - if(strcmp(str, "330")==0) - { - return LANG_330; - } - if(strcmp(str, "400")==0) - { - return LANG_400; - } - if(strcmp(str, "410")==0) - { - return LANG_410; - } - if(strcmp(str, "420")==0) - { - return LANG_420; - } - if(strcmp(str, "430")==0) - { - return LANG_430; - } - if(strcmp(str, "440")==0) - { - return LANG_440; - } - return LANG_DEFAULT; -} - -#define MAX_PATH_CHARS 256 - -typedef struct -{ - GLLang language; - - int flags; - - const char* shaderFile; - char* outputShaderFile; - - int numLinkShaders; - char linkIn[5][MAX_PATH_CHARS]; - char linkOut[5][MAX_PATH_CHARS]; - - char* reflectPath; - - char cacheKey[MAX_PATH_CHARS]; -} Options; - -void InitOptions(Options* psOptions) -{ - psOptions->language = LANG_DEFAULT; - psOptions->flags = 0; - psOptions->numLinkShaders = 0; - psOptions->reflectPath = NULL; - - psOptions->shaderFile = NULL; - - psOptions->linkIn[0][0] = 0; - psOptions->linkIn[1][0] = 0; - psOptions->linkIn[2][0] = 0; - psOptions->linkIn[3][0] = 0; - psOptions->linkIn[4][0] = 0; - - psOptions->linkOut[0][0] = 0; - psOptions->linkOut[1][0] = 0; - psOptions->linkOut[2][0] = 0; - psOptions->linkOut[3][0] = 0; - psOptions->linkOut[4][0] = 0; -} - -void PrintHelp() -{ - printf("Command line options:\n"); - - printf("\t-lang=X \t GLSL language to use. e.g. es100 or 140.\n"); - printf("\t-flags=X \t The integer value of the HLSLCC_FLAGS to used.\n"); - printf("\t-reflect=X \t File to write reflection JSON to.\n"); - printf("\t-in=X \t Shader file to compile.\n"); - printf("\t-out=X \t File to write the compiled shader from -in to.\n"); - - printf("\t-linkin=X Semicolon-separated shader list. Max one per stage. Pixel shader should be given first. Hull (if present) should come before domain.\n"); - printf("\t-linkout=X Semicolon-separated list of output files to write the compilition result of -linkin shaders to.\n"); - - printf("\t-hashout=[dir/]out-file-name \t Output file name is a hash of 'out-file-name', put in the directory 'dir'.\n"); - printf("\t-hashlinkout=X Semicolon-separated list of output files to write the compilition result of -linkin shaders to. The basepath is a hash of all the file names given.\n"); - printf("\n"); -} - -int GetOptions(int argc, char** argv, Options* psOptions) -{ - int i; - int fullShaderChain = -1; - int hashOut = 0; - - InitOptions(psOptions); - - for(i=1; i<argc; i++) - { - char *option; - - option = strstr(argv[i],"-help"); - if(option != NULL) - { - PrintHelp(); - return 0; - } - - option = strstr(argv[i],"-reflect="); - if(option != NULL) - { - psOptions->reflectPath = option + strlen("-reflect="); - } - - option = strstr(argv[i],"-lang="); - if(option != NULL) - { - psOptions->language = LanguageFromString((&option[strlen("-lang=")])); - } - - option = strstr(argv[i],"-flags="); - if(option != NULL) - { - psOptions->flags = atol(&option[strlen("-flags=")]); - } - - option = strstr(argv[i],"-in="); - if(option != NULL) - { - fullShaderChain = 0; - psOptions->shaderFile = option + strlen("-in="); - if(!fileExists(psOptions->shaderFile)) - { - printf("Invalid path: %s\n", psOptions->shaderFile); - return 0; - } - } - - option = strstr(argv[i],"-out="); - if(option != NULL) - { - fullShaderChain = 0; - psOptions->outputShaderFile = option + strlen("-out="); - } - - option = strstr(argv[i],"-hashout"); - if(option != NULL) - { - fullShaderChain = 0; - psOptions->outputShaderFile = option + strlen("-hashout="); - - char* dir; - int64_t length; - - uint64_t hash = hash64((const uint8_t*)psOptions->outputShaderFile, (uint32_t)strlen(psOptions->outputShaderFile), 0); - - uint32_t high = (uint32_t)( hash >> 32 ); - uint32_t low = (uint32_t)( hash & 0x00000000FFFFFFFF ); - - dir = strrchr(psOptions->outputShaderFile, '\\'); - - if(!dir) - { - dir = strrchr(psOptions->outputShaderFile, '//'); - } - - if(!dir) - { - length = 0; - } - else - { - length = (dir-psOptions->outputShaderFile) + 1; - } - - for(i=0; i< length;++i) - { - psOptions->cacheKey[i] = psOptions->outputShaderFile[i]; - } - - //sprintf(psOptions->cacheKey, "%x%x", high, low); - sprintf(&psOptions->cacheKey[i], "%010llX", hash); - - psOptions->outputShaderFile = psOptions->cacheKey; - } - - //Semicolon-separated list of shader files to compile - //Any dependencies between these shaders will be handled - //so that they can be linked together into a monolithic program. - //If using separate_shader_objects with GLSL 430 or later then -linkin - //is only needed for hull and domain tessellation shaders - not doing - //so risks incorrect layout qualifiers in domain shaders. - option = strstr(argv[i],"-linkin="); - if(option != NULL) - { - const char* cter; - int shaderIndex = 0; - int writeIndex = 0; - - cter = option + strlen("-linkin="); - - while(cter[0] != '\0') - { - if(cter[0] == ';') - { - psOptions->linkIn[shaderIndex][writeIndex] = '\0'; - shaderIndex++; - writeIndex = 0; - cter++; - } - - if(shaderIndex < 5 && writeIndex < MAX_PATH_CHARS) - { - psOptions->linkIn[shaderIndex][writeIndex++] = cter[0]; - } - - cter++; - } - - psOptions->linkIn[shaderIndex][writeIndex] = '\0'; - - psOptions->numLinkShaders = shaderIndex+1; - - fullShaderChain = 1; - } - - option = strstr(argv[i],"-linkout="); - if(option != NULL) - { - const char* cter; - int shaderIndex = 0; - int writeIndex = 0; - - cter = option + strlen("-linkout="); - - while(cter[0] != '\0') - { - if(cter[0] == ';') - { - psOptions->linkOut[shaderIndex][writeIndex] = '\0'; - shaderIndex++; - writeIndex = 0; - cter++; - } - - if(shaderIndex < 5 && writeIndex < MAX_PATH_CHARS) - { - psOptions->linkOut[shaderIndex][writeIndex++] = cter[0]; - } - - cter++; - } - - psOptions->linkOut[shaderIndex][writeIndex] = '\0'; - } - - option = strstr(argv[i],"-hashlinkout="); - if(option != NULL) - { - const char* cter; - const char* fullList; - int shaderIndex = 0; - int writeIndex = 0; - - char files[5][MAX_PATH_CHARS]; - - fullList = option + strlen("-hashlinkout="); - cter = fullList; - - while(cter[0] != '\0') - { - if(cter[0] == ';') - { - files[shaderIndex][writeIndex] = '\0'; - shaderIndex++; - writeIndex = 0; - cter++; - } - - if(shaderIndex < 5 && writeIndex < MAX_PATH_CHARS) - { - files[shaderIndex][writeIndex++] = cter[0]; - } - - cter++; - } - - files[shaderIndex][writeIndex] = '\0'; - - - uint64_t hash = hash64((const uint8_t*)fullList, (uint32_t)strlen(fullList), 0); - - uint32_t high = (uint32_t)( hash >> 32 ); - uint32_t low = (uint32_t)( hash & 0x00000000FFFFFFFF ); - - for(int i=0; i < shaderIndex+1; ++i) - { - char dir[MAX_PATH_CHARS]; - char fullDir[MAX_PATH_CHARS]; //includes hash - - char* separatorPtr = strrchr(&files[i][0], '\\'); - - if(!separatorPtr) - { - separatorPtr = strrchr(&files[i][0], '//'); - } - - char* file = separatorPtr + 1; - - size_t k = 0; - const size_t dirChars = (size_t)(separatorPtr-&files[i][0]); - for(; k < dirChars; ++k) - { - dir[k] = files[i][k]; - } - - dir[k] = '\0'; - - sprintf(&fullDir[0], "%s//%010llX", dir, hash); - -#if defined(_WIN32) - _mkdir(fullDir); -#else - mkdir(fullDir, 0777); -#endif - - //outdir/hash/fileA...fileB - sprintf(&psOptions->linkOut[i][0], "%s//%s", fullDir, file); - } - } - } - - return 1; -} - -void *malloc_hook(size_t size) -{ - return malloc(size); -} -void *calloc_hook(size_t num,size_t size) -{ - return calloc(num,size); -} -void *realloc_hook(void *p,size_t size) -{ - return realloc(p,size); -} -void free_hook(void *p) -{ - free(p); -} - -int Run(const char* srcPath, const char* destPath, GLLang language, int flags, const char* reflectPath, GLSLCrossDependencyData* dependencies) -{ - FILE* outputFile; - GLSLShader result; - Timer_t timer; - int compiledOK = 0; - double crossCompileTime = 0; - double glslCompileTime = 0; - - HLSLcc_SetMemoryFunctions(malloc_hook,calloc_hook,free_hook,realloc_hook); - - InitTimer(&timer); - - ResetTimer(&timer); - GlExtensions ext; - ext.ARB_explicit_attrib_location = 0; - ext.ARB_explicit_uniform_location = 0; - ext.ARB_shading_language_420pack = 0; - compiledOK = TranslateHLSLFromFile(srcPath, flags, language, &ext , dependencies, &result); - crossCompileTime = ReadTimer(&timer); - - if(compiledOK) - { - //printf("cc time: %.2f us\n", crossCompileTime); - - if(destPath) - { - //Dump to file - outputFile = fopen(destPath, "w"); - fprintf(outputFile, result.sourceCode); - fclose(outputFile); - } - - if(reflectPath) - { - const char* jsonString = SerializeReflection(&result.reflection); - outputFile = fopen(reflectPath, "w"); - fprintf(outputFile, jsonString); - fclose(outputFile); - } - -#if defined(VALIDATE_OUTPUT) - compiledOK = TryCompileShader(result.shaderType, destPath ? destPath : "", result.sourceCode, &glslCompileTime); - - if(compiledOK) - { - //printf("glsl time: %.2f us\n", glslCompileTime); - } -#endif - - FreeGLSLShader(&result); - } - - return compiledOK; -} - -int main(int argc, char** argv) -{ - Options options; - int i; - - if(!GetOptions(argc, argv, &options)) - { - return 1; - } - - if(options.shaderFile) - { - if(!Run(options.shaderFile, options.outputShaderFile, options.language, options.flags, options.reflectPath, NULL)) - { - return 1; - } - } - - GLSLCrossDependencyData depends; - for(i=0; i<options.numLinkShaders; ++i) - { - if(!Run(options.linkIn[i], options.linkOut[i][0] ? options.linkOut[i] : NULL, options.language, options.flags, NULL, &depends)) - { - return 1; - } - } - - - return 0; -} |