8000 Fix AMD/Windows GUI visualization bug by drkoller · Pull Request #1079 · colmap/colmap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Dismiss alert

Fix AMD/Windows GUI visualization bug #1079

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

Merged
merged 1 commit into from
Dec 18, 2020
Merged

Fix AMD/Windows GUI visualization bug #1079

merged 1 commit into from
Dec 18, 2020

Conversation

drkoller
Copy link
Contributor
@drkoller drkoller commented Dec 18, 2020

Throughout the lifetime of the COLMAP software, users on the Windows platform with AMD display drivers have reported problems visualizing 3D geometry in the main display window of the COLMAP GUI. See for example:

The source of these problems is an OpenGL programming bug resulting in mismatched vertex attribute indices (locations) between the shader code and the calling code. For example, this current COLMAP code:

// in_position
shader_program_.enableAttributeArray(0);
shader_program_.setAttributeBuffer(0, GL_FLOAT, 0, 3,
sizeof(PointPainter::Data));
// in_color
shader_program_.enableAttributeArray(1);
shader_program_.setAttributeBuffer(1, GL_FLOAT, 3 * sizeof(GLfloat), 4,
sizeof(PointPainter::Data));

sets the vertex position attribute to correspond to location 0, and the vertex color attribute to location 1. However, these attribute locations are not specified in the GLSL shaders, and so different OpenGL implementations are free to assign different mappings for these vertex attributes. While Nvidia drivers seem to use choose locations 0 and 1 for the vertex position and color attributes, respectively, AMD drivers on Windows seem to be using the opposite configuration (location 0 for color, location 1 for position) when the COLMAP shaders are compiled. So, the vertex data is misinterpreted by the shaders on AMD cards.

There are several different ways in OpenGL to harmonize the vertex attribute locations with the shaders (glGetAttribLocation() queries, glBindAttribLocation() binding, GL_ARB_explicit_attrib_location in the shader code, etc.). In this PR, I've fixed the bug by using similar QOpenGLShaderProgram methods to those already in use by COLMAP, but calling them with the corresponding attribute names from the shader programs, rather than the hard-coded indices of 0 and 1. With this change, the vertex attributes are properly matched, and 3D geometry is rendered as expected on both NVidia and AMD systems.

@ahojnnes
Copy link
Contributor

Fantastic, thanks very much for tracking down this issue!

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

Successfully merging this pull request may close these issues.

2 participants
0