Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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