[Mesa-dev] [PATCH] gallium: add INTERP_* opcodes to support interpolateAt*

Ilia Mirkin imirkin at alum.mit.edu
Sun Jul 6 15:46:55 PDT 2014


On Sun, Jul 6, 2014 at 6:23 PM, Roland Scheidegger <sroland at vmware.com> wrote:
> The only thing I'm wondering is about hw support for offset version
> taking a generic float. In particular, it looks like intel graphics
> actually uses 4bit immediates for the offset version (just like dictated
> by the d3d11 specification).
> At a quick glance I couldn't quite see how it's done with southern
> islands, but this one has a 4bit int to float instruction "to be used in
> shader interpolation" so my guess is it will indeed take any float
> natively. Didn't look at nvidia, but a float makes sense then if not all
> hw agrees.

NVIDIA Kepler (and I assume all Fermi+) hw takes a S0.11 fixed-point
point offset (12 bits total) for each axis (stuffed into a single
32-bit register), clamped to [-0.5, 0.4375]. No clue if all the bits
are actually used. GLSL also wants floats, so someone would have to do
the conversion somewhere... might as well make the interface more
generic, IMO.

>
> Reviewed-by: Roland Scheidegger <sroland at vmware.com>
>
> Am 06.07.2014 07:02, schrieb Ilia Mirkin:
>> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
>> ---
>>
>> There's an accompanying patch based on ChrisF's unpublished series to add
>> interpolateAt* to mesa core that makes use of them, and a further couple of
>> patches which inmplement this on nvc0.
>>
>> With all that, nvc0 passes all the piglits in ChrisF's repo except for the
>> interpolateAtCentroid-flat one, which fails on the blob driver in exactly the
>> same way (and for a reason totally unrelated to these new opcodes).
>>
>>  src/gallium/auxiliary/tgsi/tgsi_info.c     |  4 ++++
>>  src/gallium/docs/source/tgsi.rst           | 23 +++++++++++++++++++++++
>>  src/gallium/include/pipe/p_shader_tokens.h |  6 +++++-
>>  3 files changed, 32 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c
>> index e2c4e65..e24348f 100644
>> --- a/src/gallium/auxiliary/tgsi/tgsi_info.c
>> +++ b/src/gallium/auxiliary/tgsi/tgsi_info.c
>> @@ -231,6 +231,10 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] =
>>     { 1, 1, 0, 0, 0, 0, COMP, "LSB", TGSI_OPCODE_LSB },
>>     { 1, 1, 0, 0, 0, 0, COMP, "IMSB", TGSI_OPCODE_IMSB },
>>     { 1, 1, 0, 0, 0, 0, COMP, "UMSB", TGSI_OPCODE_UMSB },
>> +
>> +   { 1, 1, 0, 0, 0, 0, OTHR, "INTERP_CENTROID", TGSI_OPCODE_INTERP_CENTROID },
>> +   { 1, 2, 0, 0, 0, 0, OTHR, "INTERP_SAMPLE", TGSI_OPCODE_INTERP_SAMPLE },
>> +   { 1, 2, 0, 0, 0, 0, OTHR, "INTERP_OFFSET", TGSI_OPCODE_INTERP_OFFSET },
>>  };
>>
>>  const struct tgsi_opcode_info *
>> diff --git a/src/gallium/docs/source/tgsi.rst b/src/gallium/docs/source/tgsi.rst
>> index 4213b4a..3f4f0e6 100644
>> --- a/src/gallium/docs/source/tgsi.rst
>> +++ b/src/gallium/docs/source/tgsi.rst
>> @@ -1808,6 +1808,29 @@ This instruction replicates its result.
>>    dst = \frac{src.x}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
>>
>>
>> +Interpolation ISA
>> +^^^^^^^^^^^^^^^^^
>> +
>> +The interpolation instructions allow an input to be interpolated in a
>> +different way than its declaration. This corresponds to the GLSL 4.00
>> +interpolateAt* functions. The first argument of each of these must come from
>> +``TGSI_FILE_INPUT``.
>> +
>> +.. opcode:: INTERP_CENTROID - Interpolate at the centroid
>> +
>> +   Interpolates the varying specified by src0 at the centroid
>> +
>> +.. opcode:: INTERP_SAMPLE - Interpolate at the specified sample
>> +
>> +   Interpolates the varying specified by src0 at the sample id specified by
>> +   src1.x (interpreted as an integer)
>> +
>> +.. opcode:: INTERP_OFFSET - Interpolate at the specified offset
>> +
>> +   Interpolates the varying specified by src0 at the offset src1.xy from the
>> +   pixel center (interpreted as floats)
>> +
>> +
>>  .. _doubleopcodes:
>>
>>  Double ISA
>> diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
>> index e68258d..0d3ad6a 100644
>> --- a/src/gallium/include/pipe/p_shader_tokens.h
>> +++ b/src/gallium/include/pipe/p_shader_tokens.h
>> @@ -477,7 +477,11 @@ struct tgsi_property_data {
>>  #define TGSI_OPCODE_IMSB                190
>>  #define TGSI_OPCODE_UMSB                191
>>
>> -#define TGSI_OPCODE_LAST                192
>> +#define TGSI_OPCODE_INTERP_CENTROID     192
>> +#define TGSI_OPCODE_INTERP_SAMPLE       193
>> +#define TGSI_OPCODE_INTERP_OFFSET       194
>> +
>> +#define TGSI_OPCODE_LAST                195
>>
>>  #define TGSI_SAT_NONE            0  /* do not saturate */
>>  #define TGSI_SAT_ZERO_ONE        1  /* clamp to [0,1] */
>>


More information about the mesa-dev mailing list