glslang tests: Get same form of IEEE INF across platforms. Submitted by Lei Zhang (antiagainst@google.com) and David Neto (dneto@google.com).
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31210 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
b38c969e34
commit
e7cbfa5cab
3 changed files with 34 additions and 8 deletions
|
|
@ -37,6 +37,24 @@
|
|||
#include "localintermediate.h"
|
||||
#include "../Include/InfoSink.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <float.h>
|
||||
#else
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
bool is_positive_infinity(double x) {
|
||||
#ifdef _MSC_VER
|
||||
return _fpclass(x) == _FPCLASS_PINF;
|
||||
#else
|
||||
return isinf(x) && (x >= 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace glslang {
|
||||
|
||||
//
|
||||
|
|
@ -441,11 +459,19 @@ void OutputConstantUnion(TInfoSink& out, const TIntermTyped* node, const TConstU
|
|||
case EbtFloat:
|
||||
case EbtDouble:
|
||||
{
|
||||
const int maxSize = 300;
|
||||
char buf[maxSize];
|
||||
snprintf(buf, maxSize, "%f", constUnion[i].getDConst());
|
||||
const double value = constUnion[i].getDConst();
|
||||
// Print infinity in a portable way, for test stability.
|
||||
// Other cases may be needed in the future: negative infinity,
|
||||
// and NaNs.
|
||||
if (is_positive_infinity(value))
|
||||
out.debug << "inf\n";
|
||||
else {
|
||||
const int maxSize = 300;
|
||||
char buf[maxSize];
|
||||
snprintf(buf, maxSize, "%f", value);
|
||||
|
||||
out.debug << buf << "\n";
|
||||
out.debug << buf << "\n";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EbtInt:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue