Skip to content

Commit

Permalink
GL: new "intel-windows-broken-dsa-integer-vertex-attributes" workaround.
Browse files Browse the repository at this point in the history
  • Loading branch information
mosra committed Mar 16, 2019
1 parent 3c1a12c commit 094ea1b
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc/changelog.dox
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ See also:
fixing @ref GL::Framebuffer::clearColor()
- @cpp "intel-windows-broken-dsa-indexed-queries" @ce fixing
@ref GL::PrimitiveQuery::begin(UnsignedInt)
- @cpp "intel-windows-broken-dsa-integer-vertex-attributes" @ce fixing
@ref GL::Mesh::addVertexBuffer() with @ref Magnum::Short "Short"
attributes
- New `--magnum-gpu-validation` @ref GL-Context-command-line "command-line option"
and a corresponding environment variable to conveniently enable
@gl_extension{KHR,debug} debug output
Expand Down
13 changes: 12 additions & 1 deletion src/Magnum/GL/Implementation/MeshState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,19 @@ MeshState::MeshState(Context& context, ContextState& contextState, std::vector<s
if(context.isExtensionSupported<Extensions::ARB::direct_state_access>()) {
extensions.emplace_back(Extensions::ARB::direct_state_access::string());

/* Intel Windows drivers are ... special */
#ifdef CORRADE_TARGET_WINDOWS
if((context.detectedDriver() & Context::DetectedDriver::IntelWindows) &&
!context.isDriverWorkaroundDisabled("intel-windows-broken-dsa-integer-vertex-attributes"))
{
attributePointerImplementation = &Mesh::attributePointerImplementationVAODSAIntelWindows;
} else
#endif
{
attributePointerImplementation = &Mesh::attributePointerImplementationVAODSA;
}

createImplementation = &Mesh::createImplementationVAODSA;
attributePointerImplementation = &Mesh::attributePointerImplementationVAODSA;
bindIndexBufferImplementation = &Mesh::bindIndexBufferImplementationVAODSA;
} else
#endif
Expand Down
7 changes: 7 additions & 0 deletions src/Magnum/GL/Implementation/driverSpecific.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,13 @@ namespace {
glBeginQueryIndexed(). Using the non-DSA glGenQueries() instead
makes it work properly. See TransformFeedbackGLTest for a test. */
"intel-windows-broken-dsa-indexed-queries",

/* DSA-ified "vertex layout" glVertexArrayAttribIFormat() is broken
when passing shorts instead of full 32bit ints. Using the old-style
glVertexAttribIPointer() works correctly. No idea if the non-DSA
glVertexAttribIFormat() works or not. A test that triggers this
issue is in MeshGLTest::addVertexBufferIntWithShort(). */
"intel-windows-broken-dsa-integer-vertex-attributes",
#endif

#ifndef MAGNUM_TARGET_GLES
Expand Down
11 changes: 11 additions & 0 deletions src/Magnum/GL/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,17 @@ void Mesh::attributePointerImplementationVAODSA(AttributeLayout&& attribute) {
if(attribute.divisor)
(this->*Context::current().state().mesh->vertexAttribDivisorImplementation)(attribute.location, attribute.divisor);
}

#ifdef CORRADE_TARGET_WINDOWS
void Mesh::attributePointerImplementationVAODSAIntelWindows(AttributeLayout&& attribute) {
/* See the "intel-windows-broken-dsa-integer-vertex-attributes" workaround
for more information. */
if(attribute.kind == DynamicAttribute::Kind::Integral)
return attributePointerImplementationVAO(std::move(attribute));
else
return attributePointerImplementationVAODSA(std::move(attribute));
}
#endif
#endif

void Mesh::vertexAttribPointer(AttributeLayout& attribute) {
Expand Down
3 changes: 3 additions & 0 deletions src/Magnum/GL/Mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,9 @@ class MAGNUM_GL_EXPORT Mesh: public AbstractObject {
void MAGNUM_GL_LOCAL attributePointerImplementationVAO(AttributeLayout&& attribute);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_GL_LOCAL attributePointerImplementationVAODSA(AttributeLayout&& attribute);
#ifdef CORRADE_TARGET_WINDOWS
void MAGNUM_GL_LOCAL attributePointerImplementationVAODSAIntelWindows(AttributeLayout&& attribute);
#endif
#endif
void MAGNUM_GL_LOCAL vertexAttribPointer(AttributeLayout& attribute);

Expand Down

0 comments on commit 094ea1b

Please sign in to comment.