This commit is contained in:
Бранимир Караџић
2023-12-27 20:57:13 -08:00
parent bd71a63e26
commit 03a2c26457

View File

@@ -1508,7 +1508,7 @@ namespace bgfx
{
bx::write(_shaderWriter, uint16_t(0), &err);
uint32_t shaderSize = (uint32_t)bx::strLen(input);
const uint32_t shaderSize = (uint32_t)bx::strLen(input);
bx::write(_shaderWriter, shaderSize, &err);
bx::write(_shaderWriter, input, shaderSize, &err);
bx::write(_shaderWriter, uint8_t(0), &err);
@@ -2416,7 +2416,8 @@ namespace bgfx
bx::stringPrintf(code, "#extension GL_OES_texture_3D : enable\n");
}
if ((glsl_profile < 300) && (!bx::findIdentifierMatch(input, s_EXT_shadow_samplers).isEmpty()))
if (glsl_profile < 300
&& !bx::findIdentifierMatch(input, s_EXT_shadow_samplers).isEmpty() )
{
bx::stringPrintf(code
, "#extension GL_EXT_shadow_samplers : enable\n"
@@ -2446,7 +2447,8 @@ namespace bgfx
);
}
if ((glsl_profile < 300) && (!bx::findIdentifierMatch(input, "gl_FragDepth").isEmpty() ))
if (glsl_profile < 300
&& !bx::findIdentifierMatch(input, "gl_FragDepth").isEmpty() )
{
bx::stringPrintf(code
, "#extension GL_EXT_frag_depth : enable\n"
@@ -2649,7 +2651,8 @@ namespace bgfx
bool consoleOut = cmdLine.hasArg("stdout");
const char* outFilePath = cmdLine.findOption('o');
if (NULL == outFilePath && !consoleOut)
if (NULL == outFilePath
&& !consoleOut)
{
help("Output file name must be specified or use \"--stdout\" to output to stdout.");
return bx::kExitFailure;
@@ -2798,6 +2801,7 @@ namespace bgfx
const char* varyingdef = cmdLine.findOption("varyingdef", defaultVarying.c_str() );
attribdef.load(varyingdef);
varying = attribdef.getData();
if (NULL != varying
&& *varying != '\0')
{
@@ -2809,11 +2813,12 @@ namespace bgfx
}
}
const size_t padding = 16384;
uint32_t size = (uint32_t)bx::getSize(&reader);
char* data = new char[size+padding+1];
size = (uint32_t)bx::read(&reader, data, size, bx::ErrorAssert{});
int32_t size = bx::getSize(&reader);
const int32_t total = size + 16384;
char* data = new char[total];
size = bx::read(&reader, data, size, bx::ErrorAssert{});
// Trim UTF-8 BOM
if (data[0] == '\xef'
&& data[1] == '\xbb'
&& data[2] == '\xbf')
@@ -2822,12 +2827,30 @@ namespace bgfx
size -= 3;
}
const char ch = data[0];
if (false // https://en.wikipedia.org/wiki/Byte_order_mark#Byte_order_marks_by_encoding
|| '\x00' == ch
|| '\x0e' == ch
|| '\x2b' == ch
|| '\x84' == ch
|| '\xdd' == ch
|| '\xf7' == ch
|| '\xfb' == ch
|| '\xfe' == ch
|| '\xff' == ch
)
{
bx::printf("Shader input file has unsupported BOM.\n");
return bx::kExitFailure;
}
// Compiler generates "error X3000: syntax error: unexpected end of file"
// if input doesn't have empty line at EOF.
data[size] = '\n';
bx::memSet(&data[size+1], 0, padding);
bx::memSet(&data[size+1], 0, total-size-1);
bx::close(&reader);
{
bx::FileWriter* writer = NULL;
if (!consoleOut)
@@ -2848,7 +2871,15 @@ namespace bgfx
}
}
compiled = compileShader(varying, commandLineComment.c_str(), data, size, options, consoleOut ? bx::getStdOut() : writer, bx::getStdOut());
compiled = compileShader(
varying
, commandLineComment.c_str()
, data
, size
, options
, consoleOut ? bx::getStdOut() : writer
, bx::getStdOut()
);
if (!consoleOut)
{
@@ -2856,6 +2887,7 @@ namespace bgfx
delete writer;
}
}
}
if (compiled)
{