mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-02 20:36:50 -05:00
Fixed 'unexpected EOL' when building shaders. Added error message for missing shader entry point.
This commit is contained in:
parent
8511cefe54
commit
cc69b20e14
7 changed files with 201 additions and 190 deletions
|
@ -41,16 +41,6 @@ vec4 powRgba(vec4 _rgba, float _pow)
|
||||||
return result;
|
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 calcLight(int _idx, mat3 _tbn, vec3 _wpos, vec3 _normal, vec3 _view)
|
||||||
{
|
{
|
||||||
vec3 lp = u_lightPosRadius[_idx].xyz - _wpos;
|
vec3 lp = u_lightPosRadius[_idx].xyz - _wpos;
|
||||||
|
|
Binary file not shown.
Binary file not shown.
10
makefile
10
makefile
|
@ -78,6 +78,16 @@ osx-release64:
|
||||||
make -C .build/projects/gmake-osx config=release64
|
make -C .build/projects/gmake-osx config=release64
|
||||||
osx: osx-debug32 osx-release32 osx-debug64 osx-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:
|
docs:
|
||||||
markdown README.md > .build/docs/readme.html
|
markdown README.md > .build/docs/readme.html
|
||||||
|
|
||||||
|
|
20
src/dds.cpp
20
src/dds.cpp
|
@ -21,7 +21,9 @@ namespace bgfx
|
||||||
#define DDS_DXT4 BX_MAKEFOURCC('D', 'X', 'T', '4')
|
#define DDS_DXT4 BX_MAKEFOURCC('D', 'X', 'T', '4')
|
||||||
#define DDS_DXT5 BX_MAKEFOURCC('D', 'X', 'T', '5')
|
#define DDS_DXT5 BX_MAKEFOURCC('D', 'X', 'T', '5')
|
||||||
#define DDS_ATI1 BX_MAKEFOURCC('A', 'T', 'I', '1')
|
#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_ATI2 BX_MAKEFOURCC('A', 'T', 'I', '2')
|
||||||
|
#define DDS_BC5U BX_MAKEFOURCC('B', 'C', '5', 'U')
|
||||||
|
|
||||||
#define D3DFMT_A16B16G16R16 36
|
#define D3DFMT_A16B16G16R16 36
|
||||||
#define D3DFMT_A16B16G16R16F 113
|
#define D3DFMT_A16B16G16R16F 113
|
||||||
|
@ -466,34 +468,36 @@ bool parseDds(Dds& _dds, const Memory* _mem)
|
||||||
{
|
{
|
||||||
case DDS_DXT1:
|
case DDS_DXT1:
|
||||||
type = TextureFormat::BC1;
|
type = TextureFormat::BC1;
|
||||||
blockSize = 8;
|
|
||||||
bpp = 4;
|
bpp = 4;
|
||||||
|
blockSize = 4*4*bpp/8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DDS_DXT2:
|
case DDS_DXT2:
|
||||||
case DDS_DXT3:
|
case DDS_DXT3:
|
||||||
type = TextureFormat::BC2;
|
type = TextureFormat::BC2;
|
||||||
blockSize = 16;
|
bpp = 8;
|
||||||
bpp = 4;
|
blockSize = 4*4*bpp/8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DDS_DXT4:
|
case DDS_DXT4:
|
||||||
case DDS_DXT5:
|
case DDS_DXT5:
|
||||||
type = TextureFormat::BC3;
|
type = TextureFormat::BC3;
|
||||||
blockSize = 16;
|
bpp = 8;
|
||||||
bpp = 4;
|
blockSize = 4*4*bpp/8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DDS_ATI1:
|
case DDS_ATI1:
|
||||||
|
case DDS_BC4U:
|
||||||
type = TextureFormat::BC4;
|
type = TextureFormat::BC4;
|
||||||
blockSize = 16;
|
|
||||||
bpp = 4;
|
bpp = 4;
|
||||||
|
blockSize = 4*4*bpp/8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DDS_ATI2:
|
case DDS_ATI2:
|
||||||
|
case DDS_BC5U:
|
||||||
type = TextureFormat::BC5;
|
type = TextureFormat::BC5;
|
||||||
blockSize = 16;
|
bpp = 8;
|
||||||
bpp = 4;
|
blockSize = 4*4*bpp/8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case D3DFMT_A16B16G16R16:
|
case D3DFMT_A16B16G16R16:
|
||||||
|
|
Binary file not shown.
|
@ -1480,11 +1480,21 @@ int main(int _argc, const char* _argv[])
|
||||||
|
|
||||||
const size_t padding = 16;
|
const size_t padding = 16;
|
||||||
uint32_t size = (uint32_t)fsize(file);
|
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);
|
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);
|
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 shaderInputs;
|
||||||
InOut shaderOutputs;
|
InOut shaderOutputs;
|
||||||
uint32_t inputHash = 0;
|
uint32_t inputHash = 0;
|
||||||
|
@ -1565,9 +1575,6 @@ int main(int _argc, const char* _argv[])
|
||||||
"#define mat4 float4x4\n"
|
"#define mat4 float4x4\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
char* entry = strstr(data, "void main()");
|
|
||||||
if (NULL != entry)
|
|
||||||
{
|
|
||||||
entry[4] = '_';
|
entry[4] = '_';
|
||||||
|
|
||||||
if (fragment)
|
if (fragment)
|
||||||
|
@ -1667,7 +1674,6 @@ int main(int _argc, const char* _argv[])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (preprocessor.run(input) )
|
if (preprocessor.run(input) )
|
||||||
{
|
{
|
||||||
|
@ -1772,6 +1778,7 @@ int main(int _argc, const char* _argv[])
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
delete [] data;
|
delete [] data;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue