mirror of https://github.com/bkaradzic/bgfx
Added interpolator qualifier support.
This commit is contained in:
parent
c7a257c27d
commit
0ebb4923fc
|
@ -1961,7 +1961,7 @@ DEPRECATED_ES_KEYWORD(VARYING);
|
|||
case 66:
|
||||
YY_RULE_SETUP
|
||||
#line 294 "src/glsl/glsl_lexer.ll"
|
||||
KEYWORD(120, 300, 120, 300, CENTROID);
|
||||
KEYWORD(120, 100, 120, 100, CENTROID);
|
||||
YY_BREAK
|
||||
case 67:
|
||||
YY_RULE_SETUP
|
||||
|
@ -1971,17 +1971,17 @@ KEYWORD(120, 100, 120, 100, INVARIANT);
|
|||
case 68:
|
||||
YY_RULE_SETUP
|
||||
#line 296 "src/glsl/glsl_lexer.ll"
|
||||
KEYWORD(130, 100, 130, 300, FLAT);
|
||||
KEYWORD(120, 100, 120, 100, FLAT);
|
||||
YY_BREAK
|
||||
case 69:
|
||||
YY_RULE_SETUP
|
||||
#line 297 "src/glsl/glsl_lexer.ll"
|
||||
KEYWORD(130, 300, 130, 300, SMOOTH);
|
||||
KEYWORD(120, 100, 120, 100, SMOOTH);
|
||||
YY_BREAK
|
||||
case 70:
|
||||
YY_RULE_SETUP
|
||||
#line 298 "src/glsl/glsl_lexer.ll"
|
||||
KEYWORD(130, 300, 130, 0, NOPERSPECTIVE);
|
||||
KEYWORD(120, 100, 120, 100, NOPERSPECTIVE);
|
||||
YY_BREAK
|
||||
case 71:
|
||||
YY_RULE_SETUP
|
||||
|
|
|
@ -291,11 +291,11 @@ out return OUT_TOK;
|
|||
inout return INOUT_TOK;
|
||||
uniform return UNIFORM;
|
||||
varying DEPRECATED_ES_KEYWORD(VARYING);
|
||||
centroid KEYWORD(120, 300, 120, 300, CENTROID);
|
||||
centroid KEYWORD(120, 100, 120, 100, CENTROID);
|
||||
invariant KEYWORD(120, 100, 120, 100, INVARIANT);
|
||||
flat KEYWORD(130, 100, 130, 300, FLAT);
|
||||
smooth KEYWORD(130, 300, 130, 300, SMOOTH);
|
||||
noperspective KEYWORD(130, 300, 130, 0, NOPERSPECTIVE);
|
||||
flat KEYWORD(120, 100, 120, 100, FLAT);
|
||||
smooth KEYWORD(120, 100, 120, 100, SMOOTH);
|
||||
noperspective KEYWORD(120, 100, 120, 100, NOPERSPECTIVE);
|
||||
|
||||
sampler1D DEPRECATED_ES_KEYWORD(SAMPLER1D);
|
||||
sampler2D return SAMPLER2D;
|
||||
|
|
|
@ -303,7 +303,7 @@ void ir_print_glsl_visitor::newline_deindent()
|
|||
|
||||
void ir_print_glsl_visitor::print_var_name (ir_variable* v)
|
||||
{
|
||||
long id = (long)hash_table_find (globals->var_hash, v);
|
||||
uintptr_t id = (uintptr_t)hash_table_find (globals->var_hash, v);
|
||||
if (!id && v->data.mode == ir_var_temporary)
|
||||
{
|
||||
id = ++globals->var_counter;
|
||||
|
@ -418,7 +418,7 @@ void ir_print_glsl_visitor::visit(ir_variable *ir)
|
|||
// give an id to any variable defined in a function that is not an uniform
|
||||
if ((this->mode == kPrintGlslNone && ir->data.mode != ir_var_uniform))
|
||||
{
|
||||
long id = (long)hash_table_find (globals->var_hash, ir);
|
||||
uintptr_t id = (uintptr_t)hash_table_find (globals->var_hash, ir);
|
||||
if (id == 0)
|
||||
{
|
||||
id = ++globals->var_counter;
|
||||
|
|
|
@ -3117,6 +3117,12 @@ namespace bgfx
|
|||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES)
|
||||
&& BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES < 30) )
|
||||
{
|
||||
writeString(&writer
|
||||
, "#define flat\n"
|
||||
"#define smooth\n"
|
||||
"#define noperspective\n"
|
||||
);
|
||||
|
||||
bool usesDerivatives = s_extension[Extension::OES_standard_derivatives].m_supported
|
||||
&& bx::findIdentifierMatch(code, s_OES_standard_derivatives)
|
||||
;
|
||||
|
@ -3257,6 +3263,9 @@ namespace bgfx
|
|||
, "#define lowp\n"
|
||||
"#define mediump\n"
|
||||
"#define highp\n"
|
||||
"#define flat\n"
|
||||
"#define smooth\n"
|
||||
"#define noperspective\n"
|
||||
);
|
||||
|
||||
bx::write(&writer, code, codeLen);
|
||||
|
|
|
@ -4,29 +4,29 @@
|
|||
*/
|
||||
|
||||
#define _BX_TRACE(_format, ...) \
|
||||
do { \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
if (g_verbose) \
|
||||
{ \
|
||||
fprintf(stderr, BX_FILE_LINE_LITERAL "" _format "\n", ##__VA_ARGS__); \
|
||||
} \
|
||||
} while(0)
|
||||
BX_MACRO_BLOCK_END
|
||||
|
||||
#define _BX_WARN(_condition, _format, ...) \
|
||||
do { \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
if (!(_condition) ) \
|
||||
{ \
|
||||
BX_TRACE("WARN " _format, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while(0)
|
||||
BX_MACRO_BLOCK_END
|
||||
|
||||
#define _BX_CHECK(_condition, _format, ...) \
|
||||
do { \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
if (!(_condition) ) \
|
||||
{ \
|
||||
BX_TRACE("CHECK " _format, ##__VA_ARGS__); \
|
||||
bx::debugBreak(); \
|
||||
} \
|
||||
} while(0)
|
||||
BX_MACRO_BLOCK_END
|
||||
|
||||
#define BX_TRACE _BX_TRACE
|
||||
#define BX_WARN _BX_WARN
|
||||
|
@ -250,6 +250,20 @@ struct Uniform
|
|||
};
|
||||
typedef std::vector<Uniform> UniformArray;
|
||||
|
||||
const char* interpolationDx11(const char* _glsl)
|
||||
{
|
||||
if (0 == strcmp(_glsl, "smooth") )
|
||||
{
|
||||
return "linear";
|
||||
}
|
||||
else if (0 == strcmp(_glsl, "flat") )
|
||||
{
|
||||
return "nointerpolation";
|
||||
}
|
||||
|
||||
return _glsl; // noperspective
|
||||
}
|
||||
|
||||
#if BX_PLATFORM_WINDOWS
|
||||
struct UniformRemapDx9
|
||||
{
|
||||
|
@ -485,6 +499,7 @@ private:
|
|||
struct Varying
|
||||
{
|
||||
std::string m_precision;
|
||||
std::string m_interpolation;
|
||||
std::string m_name;
|
||||
std::string m_type;
|
||||
std::string m_init;
|
||||
|
@ -1668,6 +1683,7 @@ void help(const char* _error = NULL)
|
|||
" nacl\n"
|
||||
" osx\n"
|
||||
" windows\n"
|
||||
" --preprocess Preprocess only.\n"
|
||||
" --raw Do not process shader. No preprocessor, and no glsl-optimizer (GLSL only).\n"
|
||||
" --type <type> Shader type (vertex, fragment)\n"
|
||||
" --varyingdef <file path> Path to varying.def.sc file.\n"
|
||||
|
@ -1915,6 +1931,7 @@ int main(int _argc, const char* _argv[])
|
|||
if (NULL != eol)
|
||||
{
|
||||
const char* precision = NULL;
|
||||
const char* interpolation = NULL;
|
||||
const char* type = parse;
|
||||
|
||||
if (0 == strncmp(type, "lowp", 4)
|
||||
|
@ -1924,6 +1941,15 @@ int main(int _argc, const char* _argv[])
|
|||
precision = type;
|
||||
type = parse = bx::strws(bx::strword(parse) );
|
||||
}
|
||||
|
||||
if (0 == strncmp(type, "flat", 4)
|
||||
|| 0 == strncmp(type, "smooth", 6)
|
||||
|| 0 == strncmp(type, "noperspective", 13) )
|
||||
{
|
||||
interpolation = type;
|
||||
type = parse = bx::strws(bx::strword(parse) );
|
||||
}
|
||||
|
||||
const char* name = parse = bx::strws(bx::strword(parse) );
|
||||
const char* column = parse = bx::strws(bx::strword(parse) );
|
||||
const char* semantics = parse = bx::strws(bx::strnws (parse) );
|
||||
|
@ -1941,6 +1967,12 @@ int main(int _argc, const char* _argv[])
|
|||
{
|
||||
var.m_precision.assign(precision, bx::strword(precision)-precision);
|
||||
}
|
||||
|
||||
if (NULL != interpolation)
|
||||
{
|
||||
var.m_interpolation.assign(interpolation, bx::strword(interpolation)-interpolation);
|
||||
}
|
||||
|
||||
var.m_type.assign(type, bx::strword(type)-type);
|
||||
var.m_name.assign(name, bx::strword(name)-name);
|
||||
var.m_semantics.assign(semantics, bx::strword(semantics)-semantics);
|
||||
|
@ -1959,6 +1991,8 @@ int main(int _argc, const char* _argv[])
|
|||
}
|
||||
}
|
||||
|
||||
BX_TRACE("1");
|
||||
|
||||
InOut shaderInputs;
|
||||
InOut shaderOutputs;
|
||||
uint32_t inputHash = 0;
|
||||
|
@ -2022,6 +2056,8 @@ int main(int _argc, const char* _argv[])
|
|||
}
|
||||
}
|
||||
|
||||
BX_TRACE("2");
|
||||
|
||||
if (raw)
|
||||
{
|
||||
{
|
||||
|
@ -2122,18 +2158,21 @@ int main(int _argc, const char* _argv[])
|
|||
{
|
||||
const Varying& var = varyingIt->second;
|
||||
const char* name = var.m_name.c_str();
|
||||
|
||||
if (0 == strncmp(name, "a_", 2)
|
||||
|| 0 == strncmp(name, "i_", 2) )
|
||||
{
|
||||
preprocessor.writef("attribute %s %s %s;\n"
|
||||
preprocessor.writef("attribute %s %s %s %s;\n"
|
||||
, var.m_precision.c_str()
|
||||
, var.m_interpolation.c_str()
|
||||
, var.m_type.c_str()
|
||||
, name
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
preprocessor.writef("varying %s %s %s;\n"
|
||||
preprocessor.writef("%s varying %s %s %s;\n"
|
||||
, var.m_interpolation.c_str()
|
||||
, var.m_precision.c_str()
|
||||
, var.m_type.c_str()
|
||||
, name
|
||||
|
@ -2148,7 +2187,11 @@ int main(int _argc, const char* _argv[])
|
|||
if (varyingIt != varyingMap.end() )
|
||||
{
|
||||
const Varying& var = varyingIt->second;
|
||||
preprocessor.writef("varying %s %s;\n", var.m_type.c_str(), var.m_name.c_str() );
|
||||
preprocessor.writef("%s varying %s %s;\n"
|
||||
, var.m_interpolation.c_str()
|
||||
, var.m_type.c_str()
|
||||
, var.m_name.c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2169,6 +2212,15 @@ int main(int _argc, const char* _argv[])
|
|||
"#define mat4 float4x4\n"
|
||||
);
|
||||
|
||||
if (hlsl < 4)
|
||||
{
|
||||
preprocessor.writef(
|
||||
"#define flat\n"
|
||||
"#define smooth\n"
|
||||
"#define noperspective\n"
|
||||
);
|
||||
}
|
||||
|
||||
entry[4] = '_';
|
||||
|
||||
if ('f' == shaderType)
|
||||
|
@ -2208,7 +2260,13 @@ int main(int _argc, const char* _argv[])
|
|||
if (varyingIt != varyingMap.end() )
|
||||
{
|
||||
const Varying& var = varyingIt->second;
|
||||
preprocessor.writef(" \\\n\t%s%s %s : %s", arg++ > 0 ? ", " : " ", var.m_type.c_str(), var.m_name.c_str(), var.m_semantics.c_str() );
|
||||
preprocessor.writef(" \\\n\t%s%s %s %s : %s"
|
||||
, arg++ > 0 ? ", " : " "
|
||||
, interpolationDx11(var.m_interpolation.c_str() )
|
||||
, var.m_type.c_str()
|
||||
, var.m_name.c_str()
|
||||
, var.m_semantics.c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue