This commit is contained in:
Branimir Karadžić 2017-09-30 16:25:11 -07:00
parent 3708ed0d16
commit ed572fc5a6
10 changed files with 56 additions and 53 deletions

View File

@ -592,7 +592,7 @@ restart:
for (AppI* app = getFirstApp(); NULL != app; app = app->getNext() )
{
if (NULL == selected
&& bx::strFindI(app->getName(), find) )
&& bx::strFindI(app->getName(), INT32_MAX, find) )
{
selected = app;
}
@ -749,7 +749,7 @@ restart:
}
_debug = s_debug;
s_width = _width;
s_height = _height;

View File

@ -492,7 +492,7 @@ namespace bgfx
static uint8_t parseAttrTo(char*& _ptr, char _to, uint8_t _default)
{
const char* str = bx::strFind(_ptr, _to);
const char* str = bx::strFind(_ptr, INT32_MAX, _to);
if (NULL != str
&& 3 > str-_ptr)
{

View File

@ -1082,7 +1082,7 @@ namespace bgfx { namespace d3d11
}
if (BX_ENABLED(BGFX_CONFIG_DEBUG_PERFHUD)
&& 0 != bx::strFind(description, "PerfHUD") )
&& 0 != bx::strFind(description, INT32_MAX, "PerfHUD") )
{
m_adapter = adapter;
m_driverType = D3D_DRIVER_TYPE_REFERENCE;

View File

@ -711,7 +711,7 @@ namespace bgfx { namespace d3d12
}
if (BX_ENABLED(BGFX_CONFIG_DEBUG_PERFHUD)
&& 0 != bx::strFind(description, "PerfHUD") )
&& 0 != bx::strFind(description, INT32_MAX, "PerfHUD") )
{
m_adapter = adapter;
m_driverType = D3D_DRIVER_TYPE_REFERENCE;

View File

@ -549,7 +549,7 @@ namespace bgfx { namespace d3d9
}
if (BX_ENABLED(BGFX_CONFIG_DEBUG_PERFHUD)
&& 0 != bx::strFind(desc.Description, "PerfHUD") )
&& 0 != bx::strFind(desc.Description, INT32_MAX, "PerfHUD") )
{
m_adapter = ii;
m_deviceType = D3DDEVTYPE_REF;

View File

@ -1059,7 +1059,7 @@ namespace bgfx { namespace gl
while (pos < end)
{
uint32_t len;
const char* space = bx::strFind(pos, ' ');
const char* space = bx::strFind(pos, INT32_MAX, ' ');
if (NULL != space)
{
len = bx::uint32_min(sizeof(name), (uint32_t)(space - pos) );
@ -1861,8 +1861,8 @@ namespace bgfx { namespace gl
;
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES >= 31)
&& 0 == bx::strCmp(m_vendor, "Imagination Technologies")
&& NULL != bx::strFind(m_version, "(SDK 3.5@3510720)") )
&& 0 == bx::strCmp(m_vendor, "Imagination Technologies")
&& NULL != bx::strFind(m_version, INT32_MAX, "(SDK 3.5@3510720)") )
{
// Skip initializing extensions that are broken in emulator.
s_extension[Extension::ARB_program_interface_query ].m_initialize =
@ -1870,8 +1870,8 @@ namespace bgfx { namespace gl
}
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES)
&& 0 == bx::strCmp(m_vendor, "Imagination Technologies")
&& NULL != bx::strFind(m_version, "1.8@905891") )
&& 0 == bx::strCmp(m_vendor, "Imagination Technologies")
&& NULL != bx::strFind(m_version, INT32_MAX, "1.8@905891") )
{
m_workaround.m_detachShader = false;
}
@ -1889,7 +1889,7 @@ namespace bgfx { namespace gl
while (pos < end)
{
uint32_t len;
const char* space = bx::strFind(pos, ' ');
const char* space = bx::strFind(pos, INT32_MAX, ' ');
if (NULL != space)
{
len = bx::uint32_min(sizeof(name), (uint32_t)(space - pos) );
@ -4587,13 +4587,13 @@ namespace bgfx { namespace gl
num = bx::uint32_max(num, 1);
int offset = 0;
char* array = const_cast<char*>(bx::strFind(name, '[') );
char* array = const_cast<char*>(bx::strFind(name, INT32_MAX, '[') );
if (NULL != array)
{
BX_TRACE("--- %s", name);
*array = '\0';
array++;
char* end = const_cast<char*>(bx::strFind(array, ']') );
char* end = const_cast<char*>(bx::strFind(array, INT32_MAX, ']') );
if (NULL != end)
{ // Some devices (Amazon Fire) might not return terminating brace.
*end = '\0';
@ -5754,10 +5754,10 @@ namespace bgfx { namespace gl
if (insertFragDepth)
{
const char* entry = bx::strFind(temp, "void main ()");
const char* entry = bx::strFind(temp, INT32_MAX, "void main ()");
if (NULL != entry)
{
char* brace = const_cast<char*>(bx::strFind(entry, "{") );
char* brace = const_cast<char*>(bx::strFind(entry, INT32_MAX, "{") );
if (NULL != brace)
{
const char* end = bx::strmb(brace, '{', '}');
@ -5885,7 +5885,7 @@ namespace bgfx { namespace gl
{
char tmpFragData[16];
bx::snprintf(tmpFragData, BX_COUNTOF(tmpFragData), "gl_FragData[%d]", ii);
fragData = bx::uint32_max(fragData, NULL == bx::strFind(code, tmpFragData) ? 0 : ii+1);
fragData = bx::uint32_max(fragData, NULL == bx::strFind(code, INT32_MAX, tmpFragData) ? 0 : ii+1);
}
BGFX_FATAL(0 != fragData, Fatal::InvalidShader, "Unable to find and patch gl_FragData!");
@ -5978,7 +5978,7 @@ namespace bgfx { namespace gl
{
char tmpFragData[16];
bx::snprintf(tmpFragData, BX_COUNTOF(tmpFragData), "gl_FragData[%d]", ii);
fragData = bx::uint32_max(fragData, NULL == bx::strFind(code, tmpFragData) ? 0 : ii+1);
fragData = bx::uint32_max(fragData, NULL == bx::strFind(code, INT32_MAX, tmpFragData) ? 0 : ii+1);
}
BGFX_FATAL(0 != fragData, Fatal::InvalidShader, "Unable to find and patch gl_FragData!");

View File

@ -393,7 +393,10 @@ namespace bgfx
replace[len] = '\0';
BX_CHECK(len >= bx::strLen(_replace), "");
for (const char* ptr = bx::strFind(_str, _find); NULL != ptr; ptr = bx::strFind(ptr + len, _find) )
for (const char* ptr = bx::strFind(_str, INT32_MAX, _find)
; NULL != ptr
; ptr = bx::strFind(ptr + len, INT32_MAX, _find)
)
{
bx::memCopy(const_cast<char*>(ptr), replace, len);
}
@ -531,9 +534,9 @@ namespace bgfx
{
char* start = scratch(_includeDir);
for (char* split = const_cast<char*>(bx::strFind(start, ';') )
for (char* split = const_cast<char*>(bx::strFind(start, INT32_MAX, ';') )
; NULL != split
; split = const_cast<char*>(bx::strFind(start, ';') )
; split = const_cast<char*>(bx::strFind(start, INT32_MAX, ';') )
)
{
*split = '\0';
@ -710,7 +713,7 @@ namespace bgfx
bx::FilePath fp(_filePath);
char tmp[bx::kMaxFilePath];
bx::strCopy(tmp, BX_COUNTOF(tmp), fp.getFileName() );
const char* base = bx::strFind(_filePath, tmp);
const char* base = bx::strFind(_filePath, INT32_MAX, tmp);
return base;
}
@ -951,7 +954,7 @@ namespace bgfx
&& '\0' != *defines)
{
defines = bx::strws(defines);
const char* eol = bx::strFind(defines, ';');
const char* eol = bx::strFind(defines, INT32_MAX, ';');
if (NULL == eol)
{
eol = defines + bx::strLen(defines);
@ -1087,7 +1090,7 @@ namespace bgfx
&& *parse != '\0')
{
parse = bx::strws(parse);
const char* eol = bx::strFind(parse, ';');
const char* eol = bx::strFind(parse, INT32_MAX, ';');
if (NULL == eol)
{
eol = bx::streol(parse);
@ -1217,14 +1220,14 @@ namespace bgfx
if (0 == bx::strCmp(str, "input", 5) )
{
str += 5;
const char* comment = bx::strFind(str, "//");
const char* comment = bx::strFind(str, INT32_MAX, "//");
eol = NULL != comment && comment < eol ? comment : eol;
inputHash = parseInOut(shaderInputs, str, eol);
}
else if (0 == bx::strCmp(str, "output", 6) )
{
str += 6;
const char* comment = bx::strFind(str, "//");
const char* comment = bx::strFind(str, INT32_MAX, "//");
eol = NULL != comment && comment < eol ? comment : eol;
outputHash = parseInOut(shaderOutputs, str, eol);
}
@ -1298,7 +1301,7 @@ namespace bgfx
}
else if ('c' == shaderType) // Compute
{
char* entry = const_cast<char*>(bx::strFind(input, "void main()") );
char* entry = const_cast<char*>(bx::strFind(input, INT32_MAX, "void main()") );
if (NULL == entry)
{
fprintf(stderr, "Shader entry point 'void main()' is not found.\n");
@ -1337,10 +1340,10 @@ namespace bgfx
uint32_t arg = 0;
const bool hasLocalInvocationID = NULL != bx::strFind(input, "gl_LocalInvocationID");
const bool hasLocalInvocationIndex = NULL != bx::strFind(input, "gl_LocalInvocationIndex");
const bool hasGlobalInvocationID = NULL != bx::strFind(input, "gl_GlobalInvocationID");
const bool hasWorkGroupID = NULL != bx::strFind(input, "gl_WorkGroupID");
const bool hasLocalInvocationID = NULL != bx::strFind(input, INT32_MAX, "gl_LocalInvocationID");
const bool hasLocalInvocationIndex = NULL != bx::strFind(input, INT32_MAX, "gl_LocalInvocationIndex");
const bool hasGlobalInvocationID = NULL != bx::strFind(input, INT32_MAX, "gl_GlobalInvocationID");
const bool hasWorkGroupID = NULL != bx::strFind(input, INT32_MAX, "gl_WorkGroupID");
if (hasLocalInvocationID)
{
@ -1485,7 +1488,7 @@ namespace bgfx
}
else // Vertex/Fragment
{
char* entry = const_cast<char*>(bx::strFind(input, "void main()") );
char* entry = const_cast<char*>(bx::strFind(input, INT32_MAX, "void main()") );
if (NULL == entry)
{
fprintf(stderr, "Shader entry point 'void main()' is not found.\n");
@ -1585,17 +1588,17 @@ namespace bgfx
if ('f' == shaderType)
{
const char* insert = bx::strFind(entry, "{");
const char* insert = bx::strFind(entry, INT32_MAX, "{");
if (NULL != insert)
{
insert = strInsert(const_cast<char*>(insert+1), "\nvec4 bgfx_VoidFrag = vec4_splat(0.0);\n");
}
const bool hasFragColor = NULL != bx::strFind(input, "gl_FragColor");
const bool hasFragCoord = NULL != bx::strFind(input, "gl_FragCoord") || hlsl > 3 || hlsl == 2;
const bool hasFragDepth = NULL != bx::strFind(input, "gl_FragDepth");
const bool hasFrontFacing = NULL != bx::strFind(input, "gl_FrontFacing");
const bool hasPrimitiveId = NULL != bx::strFind(input, "gl_PrimitiveID");
const bool hasFragColor = NULL != bx::strFind(input, INT32_MAX, "gl_FragColor");
const bool hasFragCoord = NULL != bx::strFind(input, INT32_MAX, "gl_FragCoord") || hlsl > 3 || hlsl == 2;
const bool hasFragDepth = NULL != bx::strFind(input, INT32_MAX, "gl_FragDepth");
const bool hasFrontFacing = NULL != bx::strFind(input, INT32_MAX, "gl_FrontFacing");
const bool hasPrimitiveId = NULL != bx::strFind(input, INT32_MAX, "gl_PrimitiveID");
bool hasFragData[8] = {};
uint32_t numFragData = 0;
@ -1603,7 +1606,7 @@ namespace bgfx
{
char temp[32];
bx::snprintf(temp, BX_COUNTOF(temp), "gl_FragData[%d]", ii);
hasFragData[ii] = NULL != bx::strFind(input, temp);
hasFragData[ii] = NULL != bx::strFind(input, INT32_MAX, temp);
numFragData += hasFragData[ii];
}
@ -1725,10 +1728,10 @@ namespace bgfx
}
else if ('v' == shaderType)
{
const bool hasVertexId = NULL != bx::strFind(input, "gl_VertexID");
const bool hasInstanceId = NULL != bx::strFind(input, "gl_InstanceID");
const bool hasVertexId = NULL != bx::strFind(input, INT32_MAX, "gl_VertexID");
const bool hasInstanceId = NULL != bx::strFind(input, INT32_MAX, "gl_InstanceID");
const char* brace = bx::strFind(entry, "{");
const char* brace = bx::strFind(entry, INT32_MAX, "{");
if (NULL != brace)
{
const char* end = bx::strmb(brace, '{', '}');
@ -1927,7 +1930,7 @@ namespace bgfx
|| !!bx::findIdentifierMatch(input, s_ARB_shader_texture_lod)
|| !!bx::findIdentifierMatch(input, s_EXT_shader_texture_lod)
;
const bool usesInstanceID = !!bx::strFind(input, "gl_InstanceID");
const bool usesInstanceID = !!bx::strFind(input, INT32_MAX, "gl_InstanceID");
const bool usesGpuShader4 = !!bx::findIdentifierMatch(input, s_EXT_gpu_shader4);
const bool usesGpuShader5 = !!bx::findIdentifierMatch(input, s_ARB_gpu_shader5);
const bool usesTexelFetch = !!bx::findIdentifierMatch(input, s_texelFetch);

View File

@ -109,7 +109,7 @@ namespace bgfx { namespace glsl
&& *parse != '\0')
{
parse = bx::strws(parse);
const char* eol = bx::strFind(parse, ';');
const char* eol = bx::strFind(parse, INT32_MAX, ';');
if (NULL != eol)
{
const char* qualifier = parse;
@ -169,13 +169,13 @@ namespace bgfx { namespace glsl
char uniformName[256];
uint8_t num = 1;
const char* array = bx::strFind(name, "[", int32_t(eol-parse) );
const char* array = bx::strFind(name, int32_t(eol-parse), "[");
if (NULL != array)
{
bx::strCopy(uniformName, int32_t(array-name+1), name);
char arraySize[32];
const char* end = bx::strFind(array, "]", int32_t(eol-array) );
const char* end = bx::strFind(array, int32_t(eol-array), "]");
bx::strCopy(arraySize, int32_t(end-array), array+1);
num = uint8_t(atoi(arraySize) );
}
@ -204,19 +204,19 @@ namespace bgfx { namespace glsl
}
else
{
const char* parse = bx::strFind(optimizedShader, "struct xlatMtlShaderUniform {");
const char* parse = bx::strFind(optimizedShader, INT32_MAX, "struct xlatMtlShaderUniform {");
const char* end = parse;
if (NULL != parse)
{
parse += bx::strLen("struct xlatMtlShaderUniform {");
end = bx::strFind(parse, "};");
end = bx::strFind(parse, INT32_MAX, "};");
}
while ( parse < end
&& *parse != '\0')
{
parse = bx::strws(parse);
const char* eol = bx::strFind(parse, ';');
const char* eol = bx::strFind(parse, INT32_MAX, ';');
if (NULL != eol)
{
const char* typen = parse;
@ -228,13 +228,13 @@ namespace bgfx { namespace glsl
char uniformName[256];
uint8_t num = 1;
const char* array = bx::strFind(name, "[", int32_t(eol-parse) );
const char* array = bx::strFind(name, int32_t(eol-parse), "[");
if (NULL != array)
{
bx::strCopy(uniformName, int32_t(array-name+1), name);
char arraySize[32];
const char* arrayEnd = bx::strFind(array, "]", int32_t(eol-array) );
const char* arrayEnd = bx::strFind(array, int32_t(eol-array), "]");
bx::strCopy(arraySize, int32_t(arrayEnd-array), array+1);
num = uint8_t(atoi(arraySize) );
}

View File

@ -522,7 +522,7 @@ namespace bgfx { namespace hlsl
, bindDesc.BindCount
);
const char * end = bx::strFind(bindDesc.Name, "Sampler");
const char * end = bx::strFind(bindDesc.Name, INT32_MAX, "Sampler");
if (NULL != end)
{
Uniform un;

View File

@ -602,7 +602,7 @@ namespace bgfx { namespace spirv
int32_t start = 0;
int32_t end = INT32_MAX;
const char* err = bx::strFind(log, "ERROR:");
const char* err = bx::strFind(log, INT32_MAX, "ERROR:");
bool found = false;