[Mesa-dev] gallium scaled types

Marek Olšák maraeo at gmail.com
Mon Sep 12 12:45:23 PDT 2011

On Mon, Sep 12, 2011 at 8:51 PM, Jose Fonseca <jfonseca at vmware.com> wrote:
> This is what the OpenGL spec says about VertexAttribIPointer:
>  Data for an array specified by VertexAttribPointer will
>  be converted to floating-point by normalizing if normalized is TRUE, and converted
>  directly to floating-point otherwise. Data for an array specified by VertexAttribI-
>  Pointer will always be left as integer values; such data are referred to as pure
>  integers.
> Formats describe how to interpret the data in memory, and normalization is an important part of that interpretation. But this "integer" vs "pure integer" distinction merely describes the recipient of that interpretation , and not the source interpretation itself.  In this is merely to ensure no precision loss, although a recipient that can hold the data without loss could be determined without any assistance.
> AFAICS, saying that the integers should be kept as integers only makes sense in the context of shaders, and nothing else. A blit from a integer texture to a pure integer texture is nothing but a memcpy.

First and foremost, SCALED has never been used as a pure integer type
in Gallium in the same manner NORM is not a pure integer type. It is
what it is: SCALED, that is non-normalized. Maybe it was meant to be
an integer, but it's not and it's not equivalent to any of the D3D10
integer types *now*. The D3D10 integer types don't exist in Gallium.
Please see also below.

> Gallium has formats named as PIPE_xxx_xSCALED for historical reasons, but PIPE_xxx_xINT would be better.  They describe integers in memory.

NORM are also integers in memory, yet they are not perceived as
integers by shaders. Yes, the INT is the basic type. But, ints can be
read either as:
1) converted to float normalized (NORM)
2) converted to float non-normalized (SCALED)
3) no conversion (just INT)

> Note that D3D10 has no concept of PIPE_xxx_xSCALED vs PIPE_xxx_xINT formats either [1].

That's because D3D10 doesn't have scaled types at all, so they are not
listed there. There is no concept or convention involved. But the
scaled types *do* exist in OpenGL and they *do* exist in hardware. As
I said earlier, scaled and int are completely different types in R600,
despite the fact they are all ints in memory, so are the normalized

Adding an is-scaled flag to pipe_vertex_element_state would do the job though.

>> Likewise for textures. We have something similar for
>> rectangle
>> textures. There is the texture type PIPE_TEXTURE_RECT in the
>> interface
>> and the TGSI_TEXTURE_RECT fetch instruction type. I think the integer
>> textures should follow suit to make hardware driver implementations
>> sane.
> I really don't follow the analogy between texture rectangles and pixel formats...

The idea was to have the info about types and their interpretations in
both pipe_resource and shader declarations, at least a flag in a
shader resource that it's an integer, like in OpenGL, but maybe that's
not useful to anyone. The analogy with RECT was that you have the same
info in both places.


More information about the mesa-dev mailing list