[Mesa-dev] [PATCH 16/17] nir: Pass through fb_fetch_output and OutputsRead from GLSL IR.

Francisco Jerez currojerez at riseup.net
Thu Jul 21 04:49:46 UTC 2016


The NIR representation of framebuffer fetch is the same as the GLSL
IR's until interface variables are lowered away, at which point it
will be translated to load output intrinsics.  The GLSL-to-NIR pass
just needs to copy the bits over to the NIR program.
---
 src/compiler/glsl/glsl_to_nir.cpp | 2 ++
 src/compiler/nir/nir.h            | 9 +++++++++
 2 files changed, 11 insertions(+)

diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
index 20302e3..36b05e7 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -154,6 +154,7 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
    shader->info.inputs_read = sh->Program->InputsRead;
    shader->info.double_inputs_read = sh->Program->DoubleInputsRead;
    shader->info.outputs_written = sh->Program->OutputsWritten;
+   shader->info.outputs_read = sh->Program->OutputsRead;
    shader->info.patch_inputs_read = sh->Program->PatchInputsRead;
    shader->info.patch_outputs_written = sh->Program->PatchOutputsWritten;
    shader->info.system_values_read = sh->Program->SystemValuesRead;
@@ -406,6 +407,7 @@ nir_visitor::visit(ir_variable *ir)
    var->data.image.restrict_flag = ir->data.image_restrict;
    var->data.image.format = ir->data.image_format;
    var->data.max_array_access = ir->data.max_array_access;
+   var->data.fb_fetch_output = ir->data.fb_fetch_output;
 
    var->num_state_slots = ir->get_num_state_slots();
    if (var->num_state_slots > 0) {
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index c5d3b6b..586e68c 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -227,6 +227,13 @@ typedef struct nir_variable {
       unsigned location_frac:2;
 
       /**
+       * Whether this is a fragment shader output implicitly initialized with
+       * the previous contents of the specified render target at the
+       * framebuffer location corresponding to this shader invocation.
+       */
+      unsigned fb_fetch_output:1;
+
+      /**
        * \brief Layout qualifier for gl_FragDepth.
        *
        * This is not equal to \c ir_depth_layout_none if and only if this
@@ -1718,6 +1725,8 @@ typedef struct nir_shader_info {
    uint64_t double_inputs_read;
    /* Which outputs are actually written */
    uint64_t outputs_written;
+   /* Which outputs are actually read */
+   uint64_t outputs_read;
    /* Which system values are actually read */
    uint64_t system_values_read;
 
-- 
2.9.0



More information about the mesa-dev mailing list