From 094ea1bbd08a68741aecee3290992b8e18c90c1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 16 Mar 2019 13:28:26 +0100 Subject: [PATCH] GL: new "intel-windows-broken-dsa-integer-vertex-attributes" workaround. --- doc/changelog.dox | 3 +++ src/Magnum/GL/Implementation/MeshState.cpp | 13 ++++++++++++- src/Magnum/GL/Implementation/driverSpecific.cpp | 7 +++++++ src/Magnum/GL/Mesh.cpp | 11 +++++++++++ src/Magnum/GL/Mesh.h | 3 +++ 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index 408ca3295..ede7dbf6f 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -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 diff --git a/src/Magnum/GL/Implementation/MeshState.cpp b/src/Magnum/GL/Implementation/MeshState.cpp index eba7ba5b2..422b0c820 100644 --- a/src/Magnum/GL/Implementation/MeshState.cpp +++ b/src/Magnum/GL/Implementation/MeshState.cpp @@ -57,8 +57,19 @@ MeshState::MeshState(Context& context, ContextState& contextState, std::vector()) { 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 diff --git a/src/Magnum/GL/Implementation/driverSpecific.cpp b/src/Magnum/GL/Implementation/driverSpecific.cpp index 65e4d1dd2..d71baf08f 100644 --- a/src/Magnum/GL/Implementation/driverSpecific.cpp +++ b/src/Magnum/GL/Implementation/driverSpecific.cpp @@ -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 diff --git a/src/Magnum/GL/Mesh.cpp b/src/Magnum/GL/Mesh.cpp index 52dd2bdc3..873685813 100644 --- a/src/Magnum/GL/Mesh.cpp +++ b/src/Magnum/GL/Mesh.cpp @@ -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) { diff --git a/src/Magnum/GL/Mesh.h b/src/Magnum/GL/Mesh.h index b304bbcf8..cf26cc2ea 100644 --- a/src/Magnum/GL/Mesh.h +++ b/src/Magnum/GL/Mesh.h @@ -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);