On 4 March 2016 at 11:49, Dave Airlie <airl...@gmail.com> wrote:
> So this came up with virgl, after I fixed some other stupidity (there
> may still be some), but it provoked some questions.
>
> In brw_vec4_gs_visitor.cpp the dual object code builds a visitor and
> runs it. If the run fails then it goes and compiles in single object
> mode.
>
> Now we pass prog_data into the first pass, and it seems to modify
> nr_params, then when the second pass goes to run it gets the wrong
> number of uniforms and asserts in the middle. Should something be
> saving some values and restoring them here, or undoing something from
> the visitor code?

Here's a horrible demonstration patch that seems to work.

Dave.
From 43f3fd297e2334a3154698d09cf90ec8e81a86c1 Mon Sep 17 00:00:00 2001
From: Dave Airlie <airl...@redhat.com>
Date: Fri, 4 Mar 2016 11:59:39 +1000
Subject: [PATCH] i965/gs: backup prog data around first attempt at compiling
 GS.

If we fail to compile GS in dual object mode, then we'll probably
mangle the contents of prog_data on the way (particularly nr_params).

This backs up the data structure contents and restores it before
proceeding to the next attempt.

Signed-off-by: Dave Airlie <airl...@redhat.com>
---
 src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
index 7df6c72..f36ddc2 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
@@ -843,6 +843,7 @@ brw_compile_gs(const struct brw_compiler *compiler, void *log_data,
           likely(!(INTEL_DEBUG & DEBUG_NO_DUAL_OBJECT_GS))) {
          prog_data->base.dispatch_mode = DISPATCH_MODE_4X2_DUAL_OBJECT;
 
+         brw_gs_prog_data backup = *prog_data;
          vec4_gs_visitor v(compiler, log_data, &c, prog_data, shader,
                            mem_ctx, true /* no_spills */, shader_time_index);
          if (v.run()) {
@@ -850,6 +851,7 @@ brw_compile_gs(const struct brw_compiler *compiler, void *log_data,
                                               shader, &prog_data->base, v.cfg,
                                               final_assembly_size);
          }
+         *prog_data = backup;
       }
    }
 
-- 
2.5.0

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to