MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / declareVarStr

Method declareVarStr

src/OpenColorIO/GpuShaderUtils.cpp:450–480  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

448// support the in-place declarations (like res = t + vec3(...) for example).
449
450std::string GpuShaderText::declareVarStr(const std::string & name, float v)
451{
452 if (name.empty())
453 {
454 throw Exception("GPU variable name is empty.");
455 }
456
457 // Note that OSL does not support inf and -inf so the code below adjusts the value to float max.
458
459 if (std::isinf(v))
460 {
461 float newVal = v;
462
463 if (std::signbit(v))
464 {
465 newVal = -1 * std::numeric_limits<float>::max();
466 }
467 else
468 {
469 newVal = std::numeric_limits<float>::max();
470 }
471
472 std::ostringstream oss;
473 oss.precision(std::numeric_limits<float>::max_digits10);
474 oss << newVal;
475
476 return floatDecl(name) + " = " + oss.str();
477 }
478
479 return floatDecl(name) + " = " + getFloatString(v, m_lang);
480}
481
482std::string GpuShaderText::vectorCompareExpression(const std::string& lhs, const std::string& op, const std::string& rhs)
483{

Callers

nothing calls this directly

Calls 2

getFloatStringFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected