Fixed 'unexpected EOL' when building shaders. Added error message for missing shader entry point.

This commit is contained in:
bkaradzic 2013-02-14 17:27:10 -08:00
parent 8511cefe54
commit cc69b20e14
7 changed files with 201 additions and 190 deletions

View file

@ -41,16 +41,6 @@ vec4 powRgba(vec4 _rgba, float _pow)
return result;
}
vec4 toLinear(vec4 _rgba)
{
return powRgba(_rgba, 2.2);
}
vec4 toGamma(vec4 _rgba)
{
return powRgba(_rgba, 1.0/2.2);
}
vec3 calcLight(int _idx, mat3 _tbn, vec3 _wpos, vec3 _normal, vec3 _view)
{
vec3 lp = u_lightPosRadius[_idx].xyz - _wpos;

View file

@ -78,6 +78,16 @@ osx-release64:
make -C .build/projects/gmake-osx config=release64
osx: osx-debug32 osx-release32 osx-debug64 osx-release64
rebuild-shaders:
make -C examples/01-cubes rebuild
make -C examples/02-metaballs rebuild
make -C examples/03-raymarch rebuild
make -C examples/04-mesh rebuild
make -C examples/05-instancing rebuild
make -C examples/06-bump rebuild
make -C examples/07-callback rebuild
make -C examples/08-update rebuild
docs:
markdown README.md > .build/docs/readme.html

View file

@ -21,7 +21,9 @@ namespace bgfx
#define DDS_DXT4 BX_MAKEFOURCC('D', 'X', 'T', '4')
#define DDS_DXT5 BX_MAKEFOURCC('D', 'X', 'T', '5')
#define DDS_ATI1 BX_MAKEFOURCC('A', 'T', 'I', '1')
#define DDS_BC4U BX_MAKEFOURCC('B', 'C', '4', 'U')
#define DDS_ATI2 BX_MAKEFOURCC('A', 'T', 'I', '2')
#define DDS_BC5U BX_MAKEFOURCC('B', 'C', '5', 'U')
#define D3DFMT_A16B16G16R16 36
#define D3DFMT_A16B16G16R16F 113
@ -466,34 +468,36 @@ bool parseDds(Dds& _dds, const Memory* _mem)
{
case DDS_DXT1:
type = TextureFormat::BC1;
blockSize = 8;
bpp = 4;
blockSize = 4*4*bpp/8;
break;
case DDS_DXT2:
case DDS_DXT3:
type = TextureFormat::BC2;
blockSize = 16;
bpp = 4;
bpp = 8;
blockSize = 4*4*bpp/8;
break;
case DDS_DXT4:
case DDS_DXT5:
type = TextureFormat::BC3;
blockSize = 16;
bpp = 4;
bpp = 8;
blockSize = 4*4*bpp/8;
break;
case DDS_ATI1:
case DDS_BC4U:
type = TextureFormat::BC4;
blockSize = 16;
bpp = 4;
blockSize = 4*4*bpp/8;
break;
case DDS_ATI2:
case DDS_BC5U:
type = TextureFormat::BC5;
blockSize = 16;
bpp = 4;
bpp = 8;
blockSize = 4*4*bpp/8;
break;
case D3DFMT_A16B16G16R16:

Binary file not shown.

View file

@ -1480,11 +1480,21 @@ int main(int _argc, const char* _argv[])
const size_t padding = 16;
uint32_t size = (uint32_t)fsize(file);
char* data = new char[size+padding];
char* data = new char[size+padding+1];
size = (uint32_t)fread(data, 1, size, file);
memset(&data[size], 0, padding);
// Compiler generates "error X3000: syntax error: unexpected end of file"
// if input doesn't have empty line at EOF.
data[size] = '\n';
memset(&data[size+1], 0, padding);
fclose(file);
char* entry = strstr(data, "void main()");
if (NULL == entry)
{
fprintf(stderr, "Shader entry point 'void main()' is not found.\n");
}
else
{
InOut shaderInputs;
InOut shaderOutputs;
uint32_t inputHash = 0;
@ -1565,9 +1575,6 @@ int main(int _argc, const char* _argv[])
"#define mat4 float4x4\n"
);
char* entry = strstr(data, "void main()");
if (NULL != entry)
{
entry[4] = '_';
if (fragment)
@ -1667,7 +1674,6 @@ int main(int _argc, const char* _argv[])
);
}
}
}
if (preprocessor.run(input) )
{
@ -1772,6 +1778,7 @@ int main(int _argc, const char* _argv[])
return EXIT_SUCCESS;
}
}
}
delete [] data;
}