AcademySoftwareFoundation / AcademySoftwareFoundation/OpenColorIO

greaterThan() error with GPU_LANGUAGE_CG

Open
#1,701 2 comments 0 reactions 0 assignees View on GitHub
Needs Discussion
Dominant language
C++
Stars
2.1k
Forks
505
PR merge metrics
No merged PRs in 30d

Description

When using the new ACES 1.3 ocio config, I'm getting the following error:
```
(283) : error C1101: ambiguous overloaded function reference "greaterThan(half4, half4)"
(0) : bool4 greaterThan(unsigned long4, unsigned long4)
(0) : bool4 greaterThan(long4, long4)
(0) : bool4 greaterThan(double4, double4)
(0) : bool4 greaterThan(unsigned int4, unsigned int4)
(0) : bool4 greaterThan(int4, int4)
(0) : bool4 greaterThan(float4, float4)
```
I'm using GPU_LANGUAGE_CG and the OpenColorIO generated shader uses `half` vectors as per the `getVecKeyword()` method in GpuShaderUtils.cpp. The GLSL method `greaterThan()` ([which does component-wise greater-than comparison of two vectors](https://registry.khronos.org/OpenGL-Refpages/gl4/html/greaterThan.xhtml)) doesn't support `half4` so I'm proposing the change below:

```
diff --git a/src/OpenColorIO/GpuShaderUtils.cpp b/src/OpenColorIO/GpuShaderUtils.cpp
index 711bde89..418f27df 100644
--- a/src/OpenColorIO/GpuShaderUtils.cpp
+++ b/src/OpenColorIO/GpuShaderUtils.cpp
@@ -985,11 +985,11 @@ std::string GpuShaderText::float3GreaterThan(const std::string & a,
case GPU_LANGUAGE_GLSL_4_0:
case GPU_LANGUAGE_GLSL_ES_1_0:
case GPU_LANGUAGE_GLSL_ES_3_0:
- case GPU_LANGUAGE_CG:
{
kw << float3Keyword() << "(greaterThan( " << a << ", " << b << "))";
break;
}
+ case GPU_LANGUAGE_CG:
case LANGUAGE_OSL_1:
case GPU_LANGUAGE_MSL_2_0:
case GPU_LANGUAGE_HLSL_DX11:
@@ -1020,13 +1020,13 @@ std::string GpuShaderText::float4GreaterThan(const std::string & a,
case GPU_LANGUAGE_GLSL_4_0:
case GPU_LANGUAGE_GLSL_ES_1_0:
case GPU_LANGUAGE_GLSL_ES_3_0:
- case GPU_LANGUAGE_CG:
{
kw << float4Keyword() << "(greaterThan( " << a << ", " << b << "))";
break;
}
case GPU_LANGUAGE_MSL_2_0:
case GPU_LANGUAGE_HLSL_DX11:
+ case GPU_LANGUAGE_CG:
{
kw << float4Keyword() << "("
<< "(" << a << "[0] > " << b << "[0]) ? 1.0 : 0.0, "
```

Contributor guide

Open the contributing guide

Research direction

Start in src/OpenColorIO/GpuShaderUtils.cpp, reading float3GreaterThan and float4GreaterThan and the GPU_LANGUAGE_CG branches. Generate or inspect the ACES 1.3 GPU shader for CG and compare its greater-than expressions with the reported compiler error. Done means CG output no longer produces an ambiguous greaterThan(half4, half4) reference.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.