[Mesa-dev] [PATCH 1/3] u_format: implement fetch_rgba_uint and fetch_rgba_sint for integer formats

Ian Romanick idr at freedesktop.org
Mon Jan 2 19:58:00 PST 2012


On 01/02/2012 09:18 AM, Marek Olšák wrote:
> On Mon, Jan 2, 2012 at 5:56 PM, Dave Airlie<airlied at gmail.com>  wrote:
>> On Mon, Jan 2, 2012 at 4:40 PM, Marek Olšák<maraeo at gmail.com>  wrote:
>>> On Mon, Jan 2, 2012 at 3:31 PM, Dave Airlie<airlied at gmail.com>  wrote:
>>>> On Mon, Jan 2, 2012 at 1:07 PM, Marek Olšák<maraeo at gmail.com>  wrote:
>>>>> Fetching int as float and vice versa is not allowed.
>>>>> Fetching unsigned int as signed int and vice versa is not allowed either.
>>>>
>>>> The first is true, the second isn't, otherwise I'd have implemented
>>>> this that way.
>>>>
>>>>> Doing conversions like that isn't allowed in OpenGL.
>>>>
>>>> I don't have chapter/verse but EXT_texture_integer doesn't seem to
>>>> disallow this.
>>>
>>> EXT_texture_integer doesn't, but that extension doesn't define the new
>>> GLSL samplers, it only requires EXT_gpu_shader4.
>>>
>>> See this part from EXT_gpu_shader4 (modifications to section 8.7 of
>>> the GLSL spec):
>>>
>>> Table 8.xxx lists the supported combinations of sampler types and
>>> texture internal formats.
>>>
>>>       texture
>>>       internal      default (float) integer     unsigned integer
>>>       format        sampler         sampler     sampler
>>>       float         vec4            n/a          n/a
>>>       normalized    vec4            n/a          n/a
>>>       signed int    n/a             ivec4        n/a
>>>       unsigned int  n/a             n/a          uvec4
>>>
>>> That is, no conversions are allowed. The pack/unpack stuff is
>>> different, because it doesn't involve shaders. I have no opinion on
>>> whether we should be that strict in u_format or not. Being strict may
>>> later prevent making programming mistakes though.
>>
>> Did you mean samplers instead of shaders in that sentence? if so I
>> probably agree that its fine then.
>
> I am not sure right now what the restrictions on vertex attribs are,
> so yes, I meant samplers.

Signed and unsigned integer data can be supplied to float attributes via 
glVertexAttribPointer.  Whether the data is interpreted as normalized or 
not depends on a parameter to that function.

Signed and unsigned integer data can be supplied to int and uint 
attributes via glVertexAttribIPointer.  If the signedness of the data 
doesn't match that of the attribute, the result is undefined.  There's a 
bit about that in the description of glVertexAttribI in the GL3 spec.

So, I think it should work the same as for textures.

> Marek
>
>>
>> Also I'd agree with starting simple and only enabling the conversions
>> if something comes up later, so with that,
>>
>> Reviewed-by: Dave Airlie<airlied at redhat.com>
>>
>> Dave.
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list