Commit Graph

100 Commits

Author SHA1 Message Date
Eric Engestrom e740e7a6f0 scons: rename PIPE_SUBSYSTEM_EMBEDDED to EMBEDDED_DEVICE
It has nothing to do with the PIPE_SUBSYSTEM_* stuff from gallium.

Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2019-08-02 18:38:52 +01:00
Brian Paul ed83e73c4e translate: whitespace fixes in translate_generic.c 2017-06-20 07:56:34 -06:00
Ilia Mirkin 5b0d64886d translate: fix start_instance parameter in sse version
The generic version gets this right already, but this was using an
incorrect formula in SSE.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "11.2 12.0" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
2016-06-21 21:50:16 -04:00
Marek Olšák fb523cb6ad gallium: merge PIPE_SWIZZLE_* and UTIL_FORMAT_SWIZZLE_*
Use PIPE_SWIZZLE_* everywhere.
Use X/Y/Z/W/0/1 instead of RED, GREEN, BLUE, ALPHA, ZERO, ONE.
The new enum is called pipe_swizzle.

Acked-by: Jose Fonseca <jfonseca@vmware.com>
2016-04-22 01:30:39 +02:00
Edward O'Callaghan 150c289f60 gallium/auxiliary: Sanitize NULL checks into canonical form
Use NULL tests of the form `if (ptr)' or `if (!ptr)'.
They do not depend on the definition of the symbol NULL.
Further, they provide the opportunity for the accidental
assignment, are clear and succinct.

Signed-off-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
2015-12-06 17:10:23 +01:00
Ilia Mirkin a2a1a5805f gallium: replace INLINE with inline
Generated by running:
git grep -l INLINE src/gallium/ | xargs sed -i 's/\bINLINE\b/inline/g'
git grep -l INLINE src/mesa/state_tracker/ | xargs sed -i 's/\bINLINE\b/inline/g'
git checkout src/gallium/state_trackers/clover/Doxyfile

and manual edits to
src/gallium/include/pipe/p_compiler.h
src/gallium/README.portability

to remove mentions of the inline define.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Acked-by: Marek Olšák <marek.olsak@amd.com>
2015-07-21 17:52:16 -04:00
Matt Turner 14ded5ee61 gallium: Use util_cpu_to_le{16,32} in many more places.
... and util_le{16,32}_to_cpu. I think I've used the right ones for
describing the actual operation performed (even though they're both just
"byte-swap this if I'm on big-endian").

The Linux Kernel has typedefs __le32/__be32 and friends that static
analysis tools can use to check that byte-orderings are correct. It
might be interesting to apply that here as well.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2015-02-23 10:41:22 -08:00
José Fonseca 56bf948e11 rtasm,translate: Re-enable SSE on Mingw64.
This reverts f4dd099171.

The src/gallium/tests/unit/translate_test.c gives the same results on
MinGW 64-bits as on Linux 64-bits.  And since MinGW is often used for
development/testing due to its convenience, it's better not to have this
sort of differences relative to MSVC.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
2014-11-20 14:11:36 +00:00
Andreas Hartmetz 1c6aa6599e translate_sse: Use the correct buffer index in this fast path.
It is possible that there are multiple input buffers but only one is
relevant for translation. Then there will be only a single translation
group, which might need to source data from a buffer index != 0.

Fixes wrong vertex shader inputs as observed while debugging with an
application and driver combination that requires translation of a
vertex attribute in a non-trivial set of attributes and input buffers.

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
2014-04-29 20:35:10 -04:00
Zack Rusin 1dd84357ec translate: fix buffer overflows
Because in draw we always inject position at slot 0 whenever
fragment shader would take the maximum number of inputs (32) it
meant that we had PIPE_MAX_ATTRIBS + 1 slots to translate, which
meant that we were crashing with fragment shaders that took
the maximum number of attributes as inputs. The actual max number
of attributes we need to translate thus is PIPE_MAX_ATTRIBS + 1.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: José Fonseca <jfonseca@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Matthew McClure <mcclurem@vmware.com>
2014-03-04 15:56:04 -05:00
Brian Paul c6d94648cf translate: reindent translate_sse.c
Trivial.
2014-02-02 06:52:36 -07:00
Ilia Mirkin 3de97ce920 translate: deal with size overflows by casting to ptrdiff_t
This was discovered as a result of the draw-elements-base-vertex-neg
piglit test, which passes very negative offsets in, followed up by large
indices. The nouveau code correctly adjusts the pointer, but the
translate code needs to do the proper inverse correction. Similarly fix
up the SSE code to do a 64-bit multiply to compute the proper offset.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Brian Paul <brianp@vmware.com>
2014-01-27 16:40:42 +01:00
José Fonseca 8771285054 s/Tungsten Graphics/VMware/
Tungsten Graphics Inc. was acquired by VMware Inc. in 2008.  Leaving the
old copyright name is creating unnecessary confusion, hence this change.

This was the sed script I used:

    $ cat tg2vmw.sed
    # Run as:
    #
    #   git reset --hard HEAD && find include scons src -type f -not -name 'sed*' -print0 | xargs -0 sed -i -f tg2vmw.sed
    #

    # Rename copyrights
    s/Tungsten Gra\(ph\|hp\)ics,\? [iI]nc\.\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./g
    /Copyright/s/Tungsten Graphics\(,\? [iI]nc\.\)\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./
    s/TUNGSTEN GRAPHICS/VMWARE/g

    # Rename emails
    s/alanh@tungstengraphics.com/alanh@vmware.com/
    s/jens@tungstengraphics.com/jowen@vmware.com/g
    s/jrfonseca-at-tungstengraphics-dot-com/jfonseca-at-vmware-dot-com/
    s/jrfonseca\?@tungstengraphics.com/jfonseca@vmware.com/g
    s/keithw\?@tungstengraphics.com/keithw@vmware.com/g
    s/michel@tungstengraphics.com/daenzer@vmware.com/g
    s/thomas-at-tungstengraphics-dot-com/thellstom-at-vmware-dot-com/
    s/zack@tungstengraphics.com/zackr@vmware.com/

    # Remove dead links
    s@Tungsten Graphics (http://www.tungstengraphics.com)@Tungsten Graphics@g

    # C string src/gallium/state_trackers/vega/api_misc.c
    s/"Tungsten Graphics, Inc"/"VMware, Inc"/

Reviewed-by: Brian Paul <brianp@vmware.com>
2014-01-17 20:00:32 +00:00
Jon TURNEY cedfd79be2 translate_sse: Fix generated code argument handling for msabi on x86_64
translate_sse.c contains code for msabi on x86_64, but it appears to be
untested.

Currently arguments 1 and 2 passed to the generated code are moved as 32-bit
quantities into the registers used by sysvabi, irrespective of the architecture.
Since these may be pointers, they must be moved as 64-bit quantities to avoid
truncation.

Commit f4dd099171 disabled tranlate_sse.c on MinGW
x86_64, I don't know if was due to this issue, or a different one...

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Brian Paul <brianp@vmware.com>
2013-10-18 14:17:15 +01:00
Zack Rusin 0e9ec86973 draw: cleanup and fix instance id computation
The instance id system value always starts at 0, even if the
specified start instance is larger than 0. Instead of implicitly
setting instance id to instance id plus start instance and then
having to subtract instance id when computing the buffer offsets
lets just set instance id to the proper instance id. This fixes
instance id computation and cleansup buffer offset computation.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2013-07-25 02:02:36 -04:00
Zack Rusin 1c2e5c223d draw/translate: fix instancing
We were incorrectly computing the buffer offset when using the
instances. The buffer offset is always equal to:
start_instance * stride + (instance_num / instance_divisor) *
stride
We were completely ignoring the start instance quite
often producing instances that completely wrong, e.g. if
start instance = 5, instance divisor = 2, then on the first
iteration it should be:
5 * stride, not (5/2) * stride as we'd have currently, and if
start instance = 1, instance divisor = 3, then on the first
iteration it should be:
1 * stride, not 0 as we'd have.
This fixes it and adjusts all the code to the changes.

Signed-off-by: Zack Rusin <zackr@vmware.com>
2013-06-28 05:21:20 -04:00
José Fonseca a416a4a91d translate: Fix the fetch function assertions.
fetch_rgba_float is NULL for integer formats, and vice-versa.

Reviewed-by: Brian Paul <brianp@vmware.com>
2012-12-04 19:35:19 +00:00
Vinson Lee 7528e2104f translate: Fix typo in is_legal_int_format_combo.
Fixes same on both sides defect reported by Coverity.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: José Fonseca <jfonseca@vmware.com>
2012-08-07 22:34:28 -07:00
José Fonseca fa8dcb848f translate: Free elt8_func/elt16_func too.
These were leaking.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
2012-06-29 12:21:08 +01:00
Marek Olšák d1f11ed3ef translate: implement translation of 10_10_10_2 types
This is for GL_ARB_vertex_type_2_10_10_10_rev.
I just took the code from u_format_table.c. It's based on pack_rgba_float.
I had no other choice. The u_format hooks are not exactly compatible
with translate. The cleanup of it is left for future work.

Reviewed-by: Dave Airlie <airlied@redhat.com>
2012-01-05 18:29:11 +01:00
Marek Olšák 0a8a7144a1 translate: implement translation of (pure) integer formats
The conversion is limited to only a few cases, because converting to any other
type shouldn't happen in any driver.

Reviewed-by: Dave Airlie <airlied@redhat.com>
2012-01-05 18:29:11 +01:00
Marek Olšák 1acef6a746 translate: implement translation of half floats in the generic codepath 2012-01-05 18:29:11 +01:00
Brian Paul 37ef7c22ab translate: check for PIPE_SUBSYSTEM_EMBEDDED 2011-09-22 08:26:36 -06:00
José Fonseca f4dd099171 rtasm,translate: Disable on Mingw-w64.
Causes crash and stack corruption.

Needs more investigation. Disable for now.
2011-09-06 20:40:44 +01:00
Brian Paul 8b7f760f83 translate: disable clamping of instanced array indexes
This fixes piglit's draw-instanced-divisor test for softpipe on both
the generic and SSE paths.  This is temporary until we have the
correct per-array max_index information.
2011-04-19 16:13:47 -06:00
Brian Paul 41b38bd21c translate: s/varient/variant/ 2011-04-15 10:16:53 -06:00
José Fonseca 17bbc1f042 translate: Respect translate_buffer::max_index. 2011-04-01 20:18:18 +01:00
Tim Wiederhake c48dd8049c secure malloc in translate_cache_create
Signed-off-by: Brian Paul <brianp@vmware.com>
2011-01-24 09:17:54 -07:00
Brian Paul af03c14d4c translate: remove unused prototypes 2010-10-25 10:34:44 -06:00
Brian Paul 81d5afbbec translate: use function typedefs, casts to silence warnings 2010-10-25 10:31:56 -06:00
Luca Barbieri 6b6b454037 translate_sse: clear state for each function emission
Fixes #29771.
2010-08-24 04:18:11 +02:00
Luca Barbieri d1e6b31cb8 translate_sse: fix x86-64 2010-08-23 23:23:27 +02:00
Jakob Bornecrantz 8e632666af translate_sse: add R32G32B32A32_FLOAT -> X8X8X8X8_UNORM for EMIT_4UB
Changed by me to use movd instead of movss to avoid penalties.
2010-08-22 20:30:16 +02:00
Luca Barbieri 4f3fedcef7 translate_sse: refactor constant management 2010-08-22 20:28:27 +02:00
Vinson Lee 2a7493ada4 translate_sse: Silence uninitialized variable warnings.
Initialize variables on error paths.
2010-08-21 23:24:28 -07:00
Luca Barbieri d3fe699b0b translate_sse: enable on Win64
According to Vinson, enabling it causes no regressions
2010-08-20 00:09:37 +02:00
Luca Barbieri 18f207310b translate_sse: fix emit_load_sse2 2010-08-19 10:04:07 +02:00
Luca Barbieri 547e88e70d translate_sse: don't overwrite source buffer pointer
We were putting the source pointer in a register used as a temporary,
breaking all paths that don't read the data in a single instruction.
2010-08-18 04:21:46 +02:00
Vinson Lee f437ee85f4 translate: Move loop variable declaration outside for loop.
Fixes MSVC build.
2010-08-16 13:52:57 -07:00
José Fonseca b421cb9546 translate: Remove unused temporary register.
Assuming the side-effect of x86_make_reg is also unnecessary.
2010-08-16 17:21:14 +01:00
José Fonseca ded92e5dd8 translate: Eliminate void pointer arithmetic.
Non-portable.
2010-08-16 17:21:14 +01:00
Luca Barbieri c2da8e7702 translate_sse: major rewrite (v5)
NOTE: Win64 is untested, and is thus currently disabled.
If you have such a system, please enable it and report whether it works.
To enable it, change src/gallium/auxiliary/translate/translate.c

Changes in v5:
- On Win64, preserve %xmm6 and %xmm7 as required by the ABI
- Use _WIN64 instead of WIN64

Changes in v4:
- Use x86_target() and x86_target_caps()
- Enable translate_sse in x86-64, but not in Win64

Changes in v3:
- Win64 support (untested)
- Use u_cpu_detect.h constants instead of #ifs

Changes in v2:
- Minimize #ifs
- Give a name to magic number CHANNELS_0001
- Add support for CPUs without SSE (only memcpy and swizzles, like non SSE2)
- Fixed comments

translate_sse is currently very limited to the point of
being useless in essentially all cases.

In particular, it only support some float32 and unorm8
formats and doesn't work on x86-64.

This commit rewrites it to support:
1. Dumb memory copy for any pair of identical formats
2. All formats that are swizzles of each other
3. Converting 32/64-bit floats and all 8/16/32-bit integers to 32-bit float
4. Converting unorm8/snorm8 to snorm16 and uscaled8/sscaled8 to sscaled16
5. Support for x86-64 (doesn't take advantage of it in any way though)

This new translate can even be useful to translate index buffers for
cards that lack 8-bit index support.

It passes the testsuite I wrote, but note that this is a major change, and more
testing would be great.
2010-08-16 17:09:24 +02:00
Luca Barbieri 4a4e29a9ab translate: add support for 8/16-bit indices
Currently, only 32-bit indices are supported, but some use cases
translate needs support for all types.
2010-08-16 16:57:05 +02:00
Luca Barbieri 68e74f1b01 translate_sse: remove useless generated function wrappers
Currently translate_sse puts two trivial wrappers in the translate vtable.

These slow it down and enlarge the source code for no gain, except perhaps
the ability to set a breakpoint there, so remove them.

Breakpoints can be set on the caller of the translate functions, with no
loss of functionality.
2010-08-16 16:57:05 +02:00
Luca Barbieri 1cb92fb92e translate_generic: factor out common code between linear and indexed
This moves the common code into a separate ALWAYS_INLINE function.
2010-08-16 16:57:05 +02:00
Luca Barbieri ddcf028aa0 translate_generic: use memcpy if possible (v3)
Changes in v3:
- If we can do a copy, don't try to get an emit func, as that can assert(0)

Changes in v2:
- Add comment regarding copy_size

When used in GPU drivers, translate can be used to simultaneously
perform a gather operation, and convert away from unsupported formats.

In this use case, input and output formats will often be identical: clearly
it would make sense to use a memcpy in this case.

Instead, translate will insist to convert to and from 32-bit floating point
numbers.

This is not only extremely expensive, but it also loses precision for
32/64-bit integers and 64-bit floating point numbers.

This patch changes translate_generic to just use memcpy if the formats are
identical, non-blocked, and with an integral number of bytes per pixel (note
that all sensible vertex formats are like this).
2010-08-16 16:57:05 +02:00
Luca Barbieri 10adb7840c translate: allow clients to ask for supported output formats
Currently translate asserts on unsupported output formats, making
it impossible to use for some purposes, such as testing whether it
actually works on all formats it supports.

Removing the assert was met with opposition, so this change allows
clients to ask whether an output format is supported, and they are thus
able to avoid attempting to use it.

Since this is just an addition to the API, no adverse effect is
possible, and it makes the testsuite work again.
2010-08-11 21:47:27 +02:00
Luca Barbieri 5266bc3c60 Revert "translate_generic: return NULL instead of assert(0) if format not supported"
This reverts commit 16b45ca7ce.

José Fonseca asked for a revert.

Note that the testsuite will now segfault since it attempts to test
all possible formats.
2010-08-11 17:01:27 +02:00
Luca Barbieri 684aeb366f translate_generic: fix broken A8R8G8B8_UNORM output
translate was attempting to output A8R8G8B8_UNORM as if it were
R8G8B8A8_UNORM.

Now the tests just added pass.
2010-08-11 16:27:58 +02:00
Luca Barbieri 16b45ca7ce translate_generic: return NULL instead of assert(0) if format not supported
This gives the caller a chance to recover (or crash anyway otherwise).
2010-08-11 16:27:57 +02:00