Fix floating point OpMod.

Floating point mod uses separate builtin in GLSL.
This commit is contained in:
Hans-Kristian Arntzen 2016-04-16 09:25:14 +02:00
parent 7c738c5068
commit b424851706
3 changed files with 54 additions and 1 deletions

View File

@ -0,0 +1,24 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer SSBO
{
vec4 in_data[];
} _23;
layout(binding = 1, std430) buffer SSBO2
{
vec4 out_data[];
} _33;
void main()
{
uint ident = gl_GlobalInvocationID.x;
vec4 v = mod(_23.in_data[ident], _33.out_data[ident]);
_33.out_data[ident] = v;
uvec4 vu = (floatBitsToUint(_23.in_data[ident]) % floatBitsToUint(_33.out_data[ident]));
_33.out_data[ident] = uintBitsToFloat(vu);
ivec4 vi = (floatBitsToInt(_23.in_data[ident]) % floatBitsToInt(_33.out_data[ident]));
_33.out_data[ident] = intBitsToFloat(vi);
}

26
shaders/comp/mod.comp Normal file
View File

@ -0,0 +1,26 @@
#version 310 es
layout(local_size_x = 1) in;
layout(std430, binding = 0) readonly buffer SSBO
{
vec4 in_data[];
};
layout(std430, binding = 1) writeonly buffer SSBO2
{
vec4 out_data[];
};
void main()
{
uint ident = gl_GlobalInvocationID.x;
vec4 v = mod(in_data[ident], out_data[ident]);
out_data[ident] = v;
uvec4 vu = floatBitsToUint(in_data[ident]) % floatBitsToUint(out_data[ident]);
out_data[ident] = uintBitsToFloat(vu);
ivec4 vi = floatBitsToInt(in_data[ident]) % floatBitsToInt(out_data[ident]);
out_data[ident] = intBitsToFloat(vi);
}

View File

@ -2718,10 +2718,13 @@ void CompilerGLSL::emit_instruction(const Instruction &i)
case OpUMod:
case OpSMod:
case OpFMod:
BOP(%);
break;
case OpFMod:
BFOP(mod);
break;
// Relational
case OpAny:
UFOP(any);