[Mesa-dev] [PATCH 1/2] gallivm: allow negation of all integer types

Roland Scheidegger sroland at vmware.com
Thu May 2 20:05:11 PDT 2013


Am 03.05.2013 03:07, schrieb Dave Airlie:
>> Sorry to hear the hw doesn't support it, but this is supported by d3d10
>> so it's quite likely some hw indeed supports it. There's always some
>> things some hw can't do natively.
> 
> Well I was hoping before adding new things for sw driver to gallium we
> should confirm if it
> makes sense for hw.
Most things in d3d10 make sense for (at least some) hw. I think intel
graphics could do this for instance.
And btw this doesn't really help sw driver all that much. We just emit a
negate anyway (which will actually get turned into a sub IIRC), and let
llvm deal with the rest (it will recognize things like src1 +
negate(src2) and magically turn it into a sub). (Though I guess using
indexable temps there might be some disadvantage for issuing the negate
in a separate instruction but this is something we should probably fix
one day in any case.). So this is really more because it seems to make
sense to allow it for more straightforward translation of some APIs,
we've got the negate bit for floats so why not for ints?


> 
>> I'd be fine to just restrict it to some opcodes, e.g. exclude logic ops
>> if that helps you. Note that tgsi (and d3d10 for that matter) also for
>> instance don't have a integer SUB opcode, so the natural way for
>> encoding that would of course just be with a ADD with negate modifier on
>> second arg, and I bet your hw could do that one.
> 
> Nope, all r600 hw has SUB_INT. The negate bit is always specified to
> only operate
> on float instructions.
That's what I'm saying. In hlsl someone would do a "-" which gets
converted to add with negate modifier. You'd then just convert it back
to a sub (looks like with glsl we always get a separate negate
instruction followed by iadd but I haven't looked why). Ok granted this
does not work for add if both sources are negated (unless you could
negate destination).
Someone might prefer separate sub and adds with no modifiers. Others
might prefer just adds but with modifiers.
And if you can't do it it should be easy enough to emulate by emitting a
negation (which you'd otherwise get as a separate instruction anyway).

But well if noone else thinks this makes sense we could disallow it and
just emit INEG's separately.

Roland


More information about the mesa-dev mailing list