From 89fe9372b2915212a43a70822ef12f46309289c9 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Mon, 29 Oct 2018 19:37:01 -0700 Subject: Redefined frexp in HLSL2GLSL converter to match HLSL signature (float frexp(float, float)) --- .../include/GLSLDefinitions.h | 32 ++++++++++++++++++++++ .../include/GLSLDefinitions_inc.h | 32 ++++++++++++++++++++++ .../src/HLSL2GLSLConverterImpl.cpp | 2 +- 3 files changed, 65 insertions(+), 1 deletion(-) (limited to 'Graphics') diff --git a/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions.h b/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions.h index dc94bcac..5197d84c 100644 --- a/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions.h +++ b/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions.h @@ -644,6 +644,38 @@ uvec3 _ToUvec( vec3 f3 ){ return _ToUvec3( f3.x, f3.y, f3.z ); } uvec4 _ToUvec( vec4 f4 ){ return _ToUvec4( f4.x, f4.y, f4.z, f4.w ); } +// We have to redefine 'float frexp(float, int)' as 'float frexp(float, float)' +float _frexp(float f1, out float fexp1) +{ + int iexp1; + float sig1 = frexp(f1, iexp1); + fexp1 = float(iexp1); + return sig1; +} +vec2 _frexp(vec2 f2, out vec2 fexp2) +{ + ivec2 iexp2; + vec2 sig2 = frexp(f2, iexp2); + fexp2 = vec2(iexp2); + return sig2; +} +vec3 _frexp(vec3 f3, out vec3 fexp3) +{ + ivec3 iexp3; + vec3 sig3 = frexp(f3, iexp3); + fexp3 = vec3(iexp3); + return sig3; +} +vec4 _frexp(vec4 f4, out vec4 fexp4) +{ + ivec4 iexp4; + vec4 sig4 = frexp(f4, iexp4); + fexp4 = vec4(iexp4); + return sig4; +} +#define frexp _frexp + + // TEXTURE FUNCTION STUB MACROS // https://www.opengl.org/wiki/Sampler_(GLSL) diff --git a/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions_inc.h b/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions_inc.h index 1ad09c50..a94355c4 100644 --- a/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions_inc.h +++ b/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions_inc.h @@ -644,6 +644,38 @@ "uvec4 _ToUvec( vec4 f4 ){ return _ToUvec4( f4.x, f4.y, f4.z, f4.w ); }\n" "\n" "\n" +"// We have to redefine \'float frexp(float, int)\' as \'float frexp(float, float)\'\n" +"float _frexp(float f1, out float fexp1)\n" +"{\n" +" int iexp1;\n" +" float sig1 = frexp(f1, iexp1);\n" +" fexp1 = float(iexp1);\n" +" return sig1;\n" +"}\n" +"vec2 _frexp(vec2 f2, out vec2 fexp2)\n" +"{\n" +" ivec2 iexp2;\n" +" vec2 sig2 = frexp(f2, iexp2);\n" +" fexp2 = vec2(iexp2);\n" +" return sig2;\n" +"}\n" +"vec3 _frexp(vec3 f3, out vec3 fexp3)\n" +"{\n" +" ivec3 iexp3;\n" +" vec3 sig3 = frexp(f3, iexp3);\n" +" fexp3 = vec3(iexp3);\n" +" return sig3;\n" +"}\n" +"vec4 _frexp(vec4 f4, out vec4 fexp4)\n" +"{\n" +" ivec4 iexp4;\n" +" vec4 sig4 = frexp(f4, iexp4);\n" +" fexp4 = vec4(iexp4);\n" +" return sig4;\n" +"}\n" +"#define frexp _frexp\n" +"\n" +"\n" "// TEXTURE FUNCTION STUB MACROS\n" "// https://www.opengl.org/wiki/Sampler_(GLSL)\n" "\n" diff --git a/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp b/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp index 5e53bd4e..04c88348 100644 --- a/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp +++ b/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp @@ -213,7 +213,7 @@ // (-) fmod( {matrix types} ) // [V] frac( {float, float2, float3, float4} ) // (-) frac( {matrix types} ) -// [V] frexp( {float, float2, float3, float4}, {int, int2, int3, int4} ) +// [V] frexp( {float, float2, float3, float4}, {float, float2, float3, float4} ) // [V] fwidth( {float, float2, float3, float4} ) // (-) fwidth( {matrix types} ) // [V] isfinite( {float, float2, float3, float4} ) - implemented as (!isinf(x) && !isnan(x)) -- cgit v1.2.3