Bug 91292

Summary: [BDW+] glVertexAttribDivisor not working in combination with glPolygonMode
Product: Mesa Reporter: Hugh Fisher <laranzu>
Component: Drivers/DRI/i965Assignee: Neil Roberts <nroberts>
Status: RESOLVED FIXED QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: major    
Priority: medium CC: nroberts
Version: 10.5   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Complete small program to demonstrate problem. Compile instructions in source
Expected output from running program
Complete small program to demonstrate problem with gl_InstanceID

Description Hugh Fisher 2015-07-10 13:39:00 UTC
Created attachment 117029 [details]
Complete small program to demonstrate problem. Compile instructions in source

glVertexAttribDivisor does not work on a Fedora 21 system with Intel HD Graphics 5500, Mesa 10.5.8, core profile version 3.3. Attribute with divisor set to 1 (per instance) appears to be still incrementing per vertex.

Mesa 10.5.8 built from source with floating point textures enabled. Problem is not mentioned in release notes for 10.5.9, 10.6, or 10.6.1; does not appear in bug database.

Attached is program that demonstrates problem.
Comment 1 Hugh Fisher 2015-07-10 13:39:56 UTC
Created attachment 117030 [details]
Expected output from running program
Comment 2 Neil Roberts 2015-07-10 14:52:57 UTC
I tested this on git master (f12302b89836a2) on SKL and it's also failing. However I think it is due to the combination of glPolygonMode and glVertexAttribDivisor rather than a general failure with glVertexAttribDivisor. If I comment out the call to glPolygonMode then it works (albeit with filled triangles).

There is a piglit test called arb_instanced_arrays-instanced_arrays which tests glVertexAttribDivisor and this does work on SKL.

This problem doesn't exist on HSW.
Comment 3 Neil Roberts 2015-07-10 15:24:54 UTC
I have an idea what's going wrong. I'm working on a patch.
Comment 4 Neil Roberts 2015-07-10 17:05:54 UTC
http://patchwork.freedesktop.org/patch/54228/
Comment 5 Hugh Fisher 2015-07-11 07:07:21 UTC
Here's another presumably related bug. Polygon mode GL_LINE also clobbers gl_InstanceID in a vertex shader. Value appears to be undefined.

Still on Mesa 10.5.8, but with patch 54228 applied which does fix the attribute divisor
Comment 6 Hugh Fisher 2015-07-11 07:08:20 UTC
Created attachment 117049 [details]
Complete small program to demonstrate problem with gl_InstanceID
Comment 7 Neil Roberts 2015-07-13 12:50:46 UTC
I think the problem with gl_InstanceID is probably bug 84677.

Yes, I guess a fix for either of these will interact with each other. I think the patch I posted here won't work if we fix the other bug because it would put the element for the vertex/instance ID before the edge flag.
Comment 8 Neil Roberts 2015-07-13 17:15:05 UTC
I've posted a v2 of the patch which works in conjunction with a fix for the other bug here:

http://patchwork.freedesktop.org/patch/54325/

I've also posted a patch for Piglit to make sure we test glPolygonMode with gl_InstanceID here:

http://patchwork.freedesktop.org/patch/54320/
Comment 9 Neil Roberts 2015-07-14 13:36:45 UTC
I've also extended the test to test glPolygonMode with an instanced array here:

http://patchwork.freedesktop.org/patch/54451/
Comment 10 Hugh Fisher 2015-07-17 00:17:00 UTC
Reversed the original patch, applied the version 2 of this patch and the version 2 patch for bug 84677 to my Mesa 10.5.8 source tree.

Both programs now work as expected on my Intel HD 5500.
Comment 11 Neil Roberts 2015-11-30 18:17:14 UTC
The patch was landed in master and later released in 10.6.6.

http://cgit.freedesktop.org/mesa/mesa/commit/?id=3a1ab2348050fd32f4155

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.