| 448 | // support the in-place declarations (like res = t + vec3(...) for example). |
| 449 | |
| 450 | std::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 | |
| 482 | std::string GpuShaderText::vectorCompareExpression(const std::string& lhs, const std::string& op, const std::string& rhs) |
| 483 | { |
nothing calls this directly
no test coverage detected