Bug 82668 - Can't set int attributes to certain values on 32-bit
Summary: Can't set int attributes to certain values on 32-bit
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Mesa core (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: marius predut
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-15 15:07 UTC by Neil Roberts
Modified: 2015-02-25 23:42 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Piglit test case to demonstrate the problem (5.58 KB, text/plain)
2014-08-15 15:10 UTC, Neil Roberts
Details

Description Neil Roberts 2014-08-15 15:07:52 UTC
On 32-bit builds you can't set int attributes using glUniformI* to certain values if they happen to look like a signalling NaN number when interpreted as a float. This is similar to bug 81150 except that it is not limited to the i965 driver.

The problem is that the attribute values are always stored in float variables even if they are actually integers. The values are converted to float using INT_AS_FLT and UINT_AS_FLT. I think the best thing to do would be to get rid of these functions and have FLT_AS_UINT instead. Then we can change all of the variables to store the values in GLuints instead of floats.
Comment 1 Neil Roberts 2014-08-15 15:10:59 UTC
Created attachment 104683 [details]
Piglit test case to demonstrate the problem
Comment 2 Neil Roberts 2014-08-15 15:12:20 UTC
(In reply to comment #0)
> On 32-bit builds you can't set int attributes using glUniformI*

Err, I meant glVertexAttribI*
Comment 3 Jason Ekstrand 2014-08-19 16:36:14 UTC
I took a brief look at this.  It doesn't look too hard to chane.  We just need to update the code in mesa/vbo to do integer copies instead of float copies.  Maybe we should change the pointer type while we're at it?
Comment 4 marius predut 2015-01-12 21:44:54 UTC
After some investigation and testing ,the best solution I found is to use union gl_constant_value to store the values(vtx.attrptr) instead of storing them in a float. That involve to update all the dependency and use a new defined macros like this:

#define ATTR( A, N, T, V0, V1, V2, V3 )	  ATTR_##T(A, N, T, V0, V1, V2, V3) 

#define ATTR_GLuint( A, N, T, V0, V1, V2, V3 ) \
	ATTR_UNION(A, N, T, UINT_AS_UNION(V0), UINT_AS_UNION(V1), UINT_AS_UNION(V2), UINT_AS_UNION(V3))
#define ATTR_GLint( A, N, T, V0, V1, V2, V3 ) \
	ATTR_UNION(A, N, T, INT_AS_UNION(V0), INT_AS_UNION(V1), INT_AS_UNION(V2), INT_AS_UNION(V3))

The old ATTR became ATTR_UNION and treat the input values(V1,...,V4) as gl_constant_value union.
Comment 5 marius predut 2015-01-20 16:20:28 UTC
A patch that fix this defect was sent to mesa-dev@lists.freedesktop.org
Comment 6 Brian Paul 2015-02-25 23:42:27 UTC
Patch committed to master.
1a93e7690dc90211164082d6a2d26d93da8127ef


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.