Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Glf fails to read half-float EXR images #581

Closed
sourimantg opened this issue Aug 6, 2018 · 1 comment
Closed

Glf fails to read half-float EXR images #581

sourimantg opened this issue Aug 6, 2018 · 1 comment

Comments

@sourimantg
Copy link

Description of Issue

While using Glf to read input EXR files, in which each channel is encoded as a half float (tpypical use-case: environment lights), a segmentation fault occurs.

Steps to Reproduce

  1. Properly setup Glf for image reading
pxr::GlfImageSharedPtr image = pxr::GlfImage::OpenForReading(texName);
pxr::GlfImage::StorageSpec storage;
[...]
image->Read(storage); // <- segfault happens here

texName refers to a valid, resolved path to an EXR image with half float channels.
storage is initialized properly.

Solution proposal

The problem seems to come from the method _GetOIIOBaseType(GLenum type), in the file oiioImage.cpp. The conversion between a GLenum and a TypeDesc is missing the half float case. The implementation should look something like this:

/// Converts a GL type into its OpenImageIO component type equivalent.
static TypeDesc
_GetOIIOBaseType(GLenum type)
{
    switch (type) {
    case GL_UNSIGNED_BYTE:
    case GL_BYTE:
        return TypeDesc::UINT8;
    case GL_UNSIGNED_INT:
    case GL_INT:
        return TypeDesc::UINT;
    case GL_HALF_FLOAT:        // new line
        return TypeDesc::HALF; // new line
    case GL_FLOAT:
        return TypeDesc::FLOAT;
    default:
        TF_CODING_ERROR("Unsupported type");
        return TypeDesc::FLOAT;
    }
}

It's worth noting that the reverse conversion implemented in _GLTypeFromImageData(TypeDesc typedesc) properly addresses the half float case.

Applying this modification solves the problem on my tests.

System Information (OS, Hardware)

Windows 7, but should be similar on other platforms

Package Versions

0.8.5a, not tested on dev branch but according to a git blame, the problem should be in this branch too.

Build Flags

(stripped the directory-related directives)

cmake -G "Visual Studio 14 2015 Win64"
-DBoost_NO_SYSTEM_PATHS=ON 
-DPXR_ENABLE_PYTHON_SUPPORT=ON 
-DBUILD_SHARED_LIBS=ON 
-DPXR_BUILD_DOCUMENTATION=OFF 
-DPXR_BUILD_TESTS=OFF
-DPXR_BUILD_IMAGING=ON 
-DPXR_ENABLE_PTEX_SUPPORT=OFF 
-DPXR_BUILD_EMBREE_PLUGIN=OFF 
-DPXR_BUILD_USD_IMAGING=ON 
-DPXR_BUILD_ALEMBIC_PLUGIN=OFF 
-DPXR_BUILD_MAYA_PLUGIN=ON 
-DPXR_BUILD_KATANA_PLUGIN=OFF 
-DPXR_BUILD_HOUDINI_PLUGIN=OFF 
-DCMAKE_CXX_FLAGS="/Zm150"
@jtran56
Copy link

jtran56 commented Aug 23, 2018

Filed as internal issue #164138.

AdamFelt pushed a commit to autodesk-forks/USD that referenced this issue Apr 16, 2024
…lve/adsk/internal-only/feature/ios

Merge branch Resolve/adsk/internal only/feature/ios into adsk/dev.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants