<html>
<head>
<base href="https://bugs.freedesktop.org/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Offset/alignment issue with layout std140 and vec3"
href="https://bugs.freedesktop.org/show_bug.cgi?id=92909">92909</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Offset/alignment issue with layout std140 and vec3
</td>
</tr>
<tr>
<th>Product</th>
<td>Mesa
</td>
</tr>
<tr>
<th>Version</th>
<td>11.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>x86-64 (AMD64)
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux (All)
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Component</th>
<td>Drivers/DRI/i965
</td>
</tr>
<tr>
<th>Assignee</th>
<td>idr@freedesktop.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>dimitri.sabadie@gmail.com
</td>
</tr>
<tr>
<th>QA Contact</th>
<td>intel-3d-bugs@lists.freedesktop.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=119574" name="attach_119574" title="source code with compilation line (first line)">attachment 119574</a> <a href="attachment.cgi?id=119574&action=edit" title="source code with compilation line (first line)">[details]</a></span>
source code with compilation line (first line)
When trying to compile an OpenGL 3.2 program to demonstrate the use of UBO
(Uniform Buffer Objects), I got astonished my program worked on nvidia but not
on i915. I spent days trying to fix my code, but I was eventually advised to
submit a driver bug here.
The problem is there when trying to send three colors to fulfill a triangle
(red, green and blue). I attached the code so that you can run it and test it;
it’s rather small.
So, the shader defines a uniform block as:
struct Color {
vec3 rgb;
float k;
};
The rule 3 and rule 9 of the gl32 specs state that the scalar (float) should be
aligned on a 4 bytes and that the vec3 should be aligned on 16 bytes. The vec3
rgb field is already aligned on 16 bytes (because its offset is 0) and the
float k is already aligned as well (because its offset is 12, which is a
multiple of 4). So no padding is needed and the structure’s size is 16 bytes.
Though, I guess the driver tries to do different things on the GLSL side and I
get wrong values for k (though the vec3 works, like, if I don’t use k in the
fragment shader output, I get a correct behavior).</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the QA Contact for the bug.</li>
</ul>
</body>
</html>