gallium: Add a nir-to-TGSI pass.

The goal is to replace glsl_to_tgsi.cpp and its supporting code (~10k
LOC).  This code ends up being smaller because NIR has many lowering
passes that help it map better to TGSI than GLSL IR does.

As a benefit, this brings NIR optimizations to TGSI-only drivers.
Many of the softpipe shaders I've looked at end up being significantly
shorter.  Some potentially relevant changes to TGSI consumers:

- All immediates are now UINT typed.  This means they're less legible
  in printouts, but means that they get deduplicated better (no more
  multiple copies of 0x0!)
- Sampler views are not currently declared.
- nir_registers don't have their live ranges tracked, so TGSI temp usage
  may go up with a lot of control flow.
- nir_lower_vec_to_mov naively inserts movs instead of trying to coalesce
  the movs with the generators of the ssa values, sometimes increasing
  instruction count.

Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3395>
This commit is contained in:
Eric Anholt 2014-11-05 12:41:08 -08:00
parent d867e7c974
commit 34cc6a804e
4 changed files with 2683 additions and 0 deletions

View File

@ -315,6 +315,7 @@ C_SOURCES := \
NIR_SOURCES := \
nir/tgsi_to_nir.c \
nir/tgsi_to_nir.h \
nir/nir_to_tgsi.c \
nir/nir_draw_helpers.c \
nir/nir_draw_helpers.h

View File

@ -329,6 +329,8 @@ files_libgallium = files(
'util/u_viewport.h',
'nir/tgsi_to_nir.c',
'nir/tgsi_to_nir.h',
'nir/nir_to_tgsi.c',
'nir/nir_to_tgsi.h',
'nir/nir_draw_helpers.c',
'nir/nir_draw_helpers.h',
)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,33 @@
/*
* Copyright © 2014 Broadcom
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifndef NIR_TO_TGSI_H
#define NIR_TO_TGSI_H
struct nir_shader;
struct pipe_screen;
const void *nir_to_tgsi(struct nir_shader *s,
struct pipe_screen *screen);
#endif /* NIR_TO_TGSI_H */