On 30/01/18 09:30, Connor Abbott wrote:
When I was talking about handling I/O for radeonsi NIR with Nicolai, I
think the conclusion was that the best way forward is to make the
driver call nir_lower_io and friends, at least for inputs and outputs.
This is a perfect example of the kind of hacks that we have to do --
precisely how to handle inputs is a driver-specific thing, and piling
up special cases like this in the state tracker is just unsustainable.
As an aside, we probably should be using the load_barycentric_*
intrinsics, which would make the code for interpolateAt* much cleaner
for radeonsi, since we don't have to deal with variable derefs. The
goal should be to eliminatem manual deref walking and offset
calculation from radeonsi nir entirely, it shouldn't be necessary at
all.
That is probably a nice goal longer term but currently the shared nir to
llvm code expects nir_lower_io not to be used. For now I'm planning on
adding a CAP here rather than using glsl version, as suggested by others.
I'd first like to get nir for radeonsi passing piglit before tackling
any large refactors to the shared nir to llvm code, besides the forced
lowering and array splitting is the real hack here and this patch is
avoiding that.
Connor
On Sun, Jan 14, 2018 at 10:46 PM, Timothy Arceri <[email protected]> wrote:
We need this to be able to support the interpolateAt builtins in a
sane way. It also leads to the generation of more optimal code.
The lowering and splitting is made conditional on glsl 400 because
vc4 and freedreno both expect these passes to be enabled and niether
support glsl 400 so don't need to deal with the interpolateAt builtins.
We leave the other stages for now as to avoid regressions.
---
src/mesa/state_tracker/st_glsl_to_nir.cpp | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp
b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 6e3a1548f4..bc55c5b7db 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -461,7 +461,9 @@ st_nir_get_mesa_program(struct gl_context *ctx,
struct gl_linked_shader *shader)
{
struct st_context *st = st_context(ctx);
+ struct pipe_screen *screen = st->pipe->screen;
struct gl_program *prog;
+ unsigned glsl_version = screen->get_param(screen,
PIPE_CAP_GLSL_FEATURE_LEVEL);
validate_ir_tree(shader->ir);
@@ -491,11 +493,14 @@ st_nir_get_mesa_program(struct gl_context *ctx,
prog->nir = nir;
if (nir->info.stage != MESA_SHADER_TESS_CTRL &&
- nir->info.stage != MESA_SHADER_TESS_EVAL) {
+ nir->info.stage != MESA_SHADER_TESS_EVAL &&
+ (nir->info.stage != MESA_SHADER_FRAGMENT ||
+ (glsl_version < 400 && nir->info.stage == MESA_SHADER_FRAGMENT))) {
NIR_PASS_V(nir, nir_lower_io_to_temporaries,
nir_shader_get_entrypoint(nir),
true, true);
}
+
NIR_PASS_V(nir, nir_lower_global_vars_to_local);
NIR_PASS_V(nir, nir_split_var_copies);
NIR_PASS_V(nir, nir_lower_var_copies);
@@ -665,12 +670,16 @@ st_finalize_nir(struct st_context *st, struct gl_program
*prog,
struct gl_shader_program *shader_program, nir_shader *nir)
{
struct pipe_screen *screen = st->pipe->screen;
+ unsigned glsl_version = screen->get_param(screen,
PIPE_CAP_GLSL_FEATURE_LEVEL);
NIR_PASS_V(nir, nir_split_var_copies);
NIR_PASS_V(nir, nir_lower_var_copies);
if (nir->info.stage != MESA_SHADER_TESS_CTRL &&
- nir->info.stage != MESA_SHADER_TESS_EVAL)
+ nir->info.stage != MESA_SHADER_TESS_EVAL &&
+ (nir->info.stage != MESA_SHADER_FRAGMENT ||
+ (glsl_version < 400 && nir->info.stage == MESA_SHADER_FRAGMENT))) {
NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects);
+ }
if (nir->info.stage == MESA_SHADER_VERTEX) {
/* Needs special handling so drvloc matches the vbo state: */
--
2.14.3
_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev
_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev