[Mesa-dev] [PATCH 6/7] i965: Add a brw_wm_prog_data::has_render_target_reads field.

Kenneth Graunke kenneth at whitecape.org
Tue Aug 22 20:58:00 UTC 2017


State upload code should use prog_data rather than poking at shader_info
directly.
---
 src/intel/compiler/brw_compiler.h                | 1 +
 src/intel/compiler/brw_fs.cpp                    | 2 ++
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 6 ++----
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/intel/compiler/brw_compiler.h b/src/intel/compiler/brw_compiler.h
index 66d6a6f5ee8..6753a8daf08 100644
--- a/src/intel/compiler/brw_compiler.h
+++ b/src/intel/compiler/brw_compiler.h
@@ -614,6 +614,7 @@ struct brw_wm_prog_data {
    bool uses_src_depth;
    bool uses_src_w;
    bool uses_sample_mask;
+   bool has_render_target_reads;
    bool has_side_effects;
    bool pulls_bary;
 
diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp
index b48dc4167e7..f2596e38861 100644
--- a/src/intel/compiler/brw_fs.cpp
+++ b/src/intel/compiler/brw_fs.cpp
@@ -6544,6 +6544,8 @@ brw_compile_fs(const struct brw_compiler *compiler, void *log_data,
        shader->info.fs.uses_sample_qualifier ||
        shader->info.outputs_read);
 
+   prog_data->has_render_target_reads = shader->info.outputs_read != 0ull;
+
    prog_data->early_fragment_tests = shader->info.fs.early_fragment_tests;
    prog_data->post_depth_coverage = shader->info.fs.post_depth_coverage;
    prog_data->inner_coverage = shader->info.fs.inner_coverage;
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index dc1a770a5d3..5cfdbe58102 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -1049,9 +1049,8 @@ update_renderbuffer_read_surfaces(struct brw_context *brw)
    const struct brw_wm_prog_data *wm_prog_data =
       brw_wm_prog_data(brw->wm.base.prog_data);
 
-   /* BRW_NEW_FRAGMENT_PROGRAM */
-   if (!ctx->Extensions.MESA_shader_framebuffer_fetch &&
-       brw->fragment_program && brw->fragment_program->info.outputs_read) {
+   if (wm_prog_data->has_render_target_reads &&
+       !ctx->Extensions.MESA_shader_framebuffer_fetch) {
       /* _NEW_BUFFERS */
       const struct gl_framebuffer *fb = ctx->DrawBuffer;
 
@@ -1117,7 +1116,6 @@ const struct brw_tracked_state brw_renderbuffer_read_surfaces = {
       .mesa = _NEW_BUFFERS,
       .brw = BRW_NEW_BATCH |
              BRW_NEW_FAST_CLEAR_COLOR |
-             BRW_NEW_FRAGMENT_PROGRAM |
              BRW_NEW_FS_PROG_DATA,
    },
    .emit = update_renderbuffer_read_surfaces,
-- 
2.14.1



More information about the mesa-dev mailing list