Merge pull request #271 from KhronosGroup/frexp-struct
Support FrexpStruct/ModfStruct.
This commit is contained in:
Коммит
9b04443808
|
@ -0,0 +1,43 @@
|
|||
#version 310 es
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
struct ResType
|
||||
{
|
||||
highp float _m0;
|
||||
int _m1;
|
||||
};
|
||||
|
||||
struct ResType_1
|
||||
{
|
||||
highp vec2 _m0;
|
||||
ivec2 _m1;
|
||||
};
|
||||
|
||||
layout(location = 0) in float v0;
|
||||
layout(location = 1) in vec2 v1;
|
||||
layout(location = 0) out float FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
ResType _16;
|
||||
_16._m0 = frexp(v0, _16._m1);
|
||||
mediump int e0 = _16._m1;
|
||||
float f0 = _16._m0;
|
||||
ResType _22;
|
||||
_22._m0 = frexp(v0 + 1.0, _22._m1);
|
||||
e0 = _22._m1;
|
||||
f0 = _22._m0;
|
||||
ResType_1 _35;
|
||||
_35._m0 = frexp(v1, _35._m1);
|
||||
mediump ivec2 e1 = _35._m1;
|
||||
vec2 f1 = _35._m0;
|
||||
float r0;
|
||||
float _41 = modf(v0, r0);
|
||||
float m0 = _41;
|
||||
vec2 r1;
|
||||
vec2 _45 = modf(v1, r1);
|
||||
vec2 m1 = _45;
|
||||
FragColor = ((((f0 + f1.x) + f1.y) + m0) + m1.x) + m1.y;
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
#version 310 es
|
||||
precision mediump float;
|
||||
|
||||
layout(location = 0) out float FragColor;
|
||||
layout(location = 0) in float v0;
|
||||
layout(location = 1) in vec2 v1;
|
||||
|
||||
void main()
|
||||
{
|
||||
int e0;
|
||||
float f0 = frexp(v0, e0);
|
||||
f0 = frexp(v0 + 1.0, e0);
|
||||
|
||||
ivec2 e1;
|
||||
vec2 f1 = frexp(v1, e1);
|
||||
|
||||
float r0;
|
||||
float m0 = modf(v0, r0);
|
||||
vec2 r1;
|
||||
vec2 m1 = modf(v1, r1);
|
||||
|
||||
FragColor = f0 + f1.x + f1.y + m0 + m1.x + m1.y;
|
||||
}
|
||||
|
|
@ -3291,6 +3291,19 @@ void CompilerGLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop,
|
|||
emit_binary_func_op(result_type, id, args[0], args[1], "modf");
|
||||
break;
|
||||
|
||||
case GLSLstd450ModfStruct:
|
||||
{
|
||||
forced_temporaries.insert(id);
|
||||
auto &type = get<SPIRType>(result_type);
|
||||
auto flags = meta[id].decoration.decoration_flags;
|
||||
statement(flags_to_precision_qualifiers_glsl(type, flags), variable_decl(type, to_name(id)), ";");
|
||||
set<SPIRExpression>(id, to_name(id), result_type, true);
|
||||
|
||||
statement(to_expression(id), ".", to_member_name(type, 0), " = ", "modf(", to_expression(args[0]), ", ",
|
||||
to_expression(id), ".", to_member_name(type, 1), ");");
|
||||
break;
|
||||
}
|
||||
|
||||
// Minmax
|
||||
case GLSLstd450FMin:
|
||||
case GLSLstd450UMin:
|
||||
|
@ -3400,6 +3413,20 @@ void CompilerGLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop,
|
|||
forced_temporaries.insert(id);
|
||||
emit_binary_func_op(result_type, id, args[0], args[1], "frexp");
|
||||
break;
|
||||
|
||||
case GLSLstd450FrexpStruct:
|
||||
{
|
||||
forced_temporaries.insert(id);
|
||||
auto &type = get<SPIRType>(result_type);
|
||||
auto flags = meta[id].decoration.decoration_flags;
|
||||
statement(flags_to_precision_qualifiers_glsl(type, flags), variable_decl(type, to_name(id)), ";");
|
||||
set<SPIRExpression>(id, to_name(id), result_type, true);
|
||||
|
||||
statement(to_expression(id), ".", to_member_name(type, 0), " = ", "frexp(", to_expression(args[0]), ", ",
|
||||
to_expression(id), ".", to_member_name(type, 1), ");");
|
||||
break;
|
||||
}
|
||||
|
||||
case GLSLstd450Ldexp:
|
||||
emit_binary_func_op(result_type, id, args[0], args[1], "ldexp");
|
||||
break;
|
||||
|
|
Загрузка…
Ссылка в новой задаче