mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
Patching GL shaders to avoid compiler warnings.
This commit is contained in:
parent
b854588861
commit
5d22798482
1 changed files with 43 additions and 1 deletions
|
@ -4337,7 +4337,10 @@ namespace bgfx { namespace gl
|
|||
|
||||
bool usesIUsamplers = !!bx::findIdentifierMatch(code, s_uisamplers);
|
||||
|
||||
uint32_t version = usesIUsamplers ? 130 : (usesTextureLod ? 120 : 0);
|
||||
uint32_t version = usesIUsamplers
|
||||
? 130
|
||||
: (usesTextureLod ? 120 : 0)
|
||||
;
|
||||
|
||||
if (0 != version)
|
||||
{
|
||||
|
@ -4352,6 +4355,44 @@ namespace bgfx { namespace gl
|
|||
}
|
||||
}
|
||||
|
||||
if (130 <= version)
|
||||
{
|
||||
if (m_type == GL_FRAGMENT_SHADER)
|
||||
{
|
||||
writeString(&writer, "#define varying in\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
writeString(&writer, "#define attribute in\n");
|
||||
writeString(&writer, "#define varying out\n");
|
||||
}
|
||||
|
||||
uint32_t fragData = 0;
|
||||
|
||||
if (!!bx::findIdentifierMatch(code, "gl_FragData") )
|
||||
{
|
||||
for (uint32_t ii = 0, num = g_caps.maxFBAttachments; ii < num; ++ii)
|
||||
{
|
||||
char tmpFragData[16];
|
||||
bx::snprintf(tmpFragData, BX_COUNTOF(tmpFragData), "gl_FragData[%d]", ii);
|
||||
fragData = bx::uint32_max(fragData, NULL == strstr(code, tmpFragData) ? 0 : ii+1);
|
||||
}
|
||||
|
||||
BGFX_FATAL(0 != fragData, Fatal::InvalidShader, "Unable to find and patch gl_FragData!");
|
||||
}
|
||||
|
||||
if (0 != fragData)
|
||||
{
|
||||
writeStringf(&writer, "out vec4 bgfx_FragData[%d];\n", fragData);
|
||||
writeString(&writer, "#define gl_FragData bgfx_FragData\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
writeString(&writer, "out vec4 bgfx_FragColor;\n");
|
||||
writeString(&writer, "#define gl_FragColor bgfx_FragColor\n");
|
||||
}
|
||||
}
|
||||
|
||||
writeString(&writer
|
||||
, "#define lowp\n"
|
||||
"#define mediump\n"
|
||||
|
@ -4462,6 +4503,7 @@ namespace bgfx { namespace gl
|
|||
code = temp;
|
||||
}
|
||||
|
||||
BX_TRACE("%s", code);
|
||||
GL_CHECK(glShaderSource(m_id, 1, (const GLchar**)&code, NULL) );
|
||||
GL_CHECK(glCompileShader(m_id) );
|
||||
|
||||
|
|
Loading…
Reference in a new issue