[Mesa-dev] [PATCH 11/21] mesa: use common outputs written field

Timothy Arceri timothy.arceri at collabora.com
Thu Oct 20 08:47:01 UTC 2016


---
 src/mesa/main/context.c              | 2 +-
 src/mesa/main/ff_fragment_shader.cpp | 2 +-
 src/mesa/main/ffvertex_prog.c        | 4 ++--
 src/mesa/program/arbprogparse.c      | 4 ++--
 src/mesa/program/prog_print.c        | 3 ++-
 src/mesa/program/prog_to_nir.c       | 5 ++---
 src/mesa/program/program_parse.y     | 2 +-
 src/mesa/program/programopt.c        | 8 ++++----
 src/mesa/swrast/s_context.c          | 3 ++-
 src/mesa/swrast/s_fragprog.c         | 6 +++---
 src/mesa/swrast/s_span.c             | 2 +-
 src/mesa/tnl/t_context.c             | 3 ++-
 src/mesa/tnl/t_vb_program.c          | 7 ++++---
 13 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 65c1b6d..5aaf150 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -741,7 +741,7 @@ check_context_limits(struct gl_context *ctx)
 
    /* check that we don't exceed the size of various bitfields */
    assert(VARYING_SLOT_MAX <=
-	  (8 * sizeof(ctx->VertexProgram._Current->OutputsWritten)));
+	  (8 * sizeof(ctx->VertexProgram._Current->info.outputs_written)));
    assert(VARYING_SLOT_MAX <=
 	  (8 * sizeof(ctx->FragmentProgram._Current->info.inputs_read)));
 
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index 5300335..9aa1dc1 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -370,7 +370,7 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx )
       else
          vprog = ctx->VertexProgram.Current;
 
-      vp_outputs = vprog->OutputsWritten;
+      vp_outputs = vprog->info.outputs_written;
 
       /* These get generated in the setup routine regardless of the
        * vertex program:
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index 00409cc..8cec1cb 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -461,7 +461,7 @@ static struct ureg register_input( struct tnl_program *p, GLuint input )
  */
 static struct ureg register_output( struct tnl_program *p, GLuint output )
 {
-   p->program->OutputsWritten |= BITFIELD64_BIT(output);
+   p->program->info.outputs_written |= BITFIELD64_BIT(output);
    return make_ureg(PROGRAM_OUTPUT, output);
 }
 
@@ -1640,7 +1640,7 @@ create_new_program( const struct state_key *key,
    p.program->NumAttributes = p.program->NumAddressRegs = 0;
    p.program->Parameters = _mesa_new_parameter_list();
    p.program->info.inputs_read = 0;
-   p.program->OutputsWritten = 0;
+   p.program->info.outputs_written = 0;
 
    build_tnl_program( &p );
 }
diff --git a/src/mesa/program/arbprogparse.c b/src/mesa/program/arbprogparse.c
index 53f661f..e545d71 100644
--- a/src/mesa/program/arbprogparse.c
+++ b/src/mesa/program/arbprogparse.c
@@ -108,7 +108,7 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target,
    program->NumNativeTexInstructions = prog.NumTexInstructions;
    program->NumNativeTexIndirections = prog.NumTexIndirections;
    program->info.inputs_read      = prog.info.inputs_read;
-   program->OutputsWritten  = prog.OutputsWritten;
+   program->info.outputs_written = prog.info.outputs_written;
    program->IndirectRegisterFiles = prog.IndirectRegisterFiles;
    for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++) {
       program->TexturesUsed[i] = prog.TexturesUsed[i];
@@ -197,7 +197,7 @@ _mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target,
    program->NumNativeAttributes = prog.NumNativeAttributes;
    program->NumNativeAddressRegs = prog.NumNativeAddressRegs;
    program->info.inputs_read     = prog.info.inputs_read;
-   program->OutputsWritten = prog.OutputsWritten;
+   program->info.outputs_written = prog.info.outputs_written;
    program->IndirectRegisterFiles = prog.IndirectRegisterFiles;
    program->IsPositionInvariant = (state.option.PositionInvariant)
       ? GL_TRUE : GL_FALSE;
diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c
index 19d5785..182da6d 100644
--- a/src/mesa/program/prog_print.c
+++ b/src/mesa/program/prog_print.c
@@ -874,7 +874,8 @@ _mesa_fprint_program_parameters(FILE *f,
    fprintf(f, "InputsRead: %" PRIx64 " (0b%s)\n",
            (uint64_t) prog->info.inputs_read, binary(prog->info.inputs_read));
    fprintf(f, "OutputsWritten: %" PRIx64 " (0b%s)\n",
-           (uint64_t) prog->OutputsWritten, binary(prog->OutputsWritten));
+           (uint64_t) prog->info.outputs_written,
+           binary(prog->info.outputs_written));
    fprintf(f, "NumInstructions=%d\n", prog->NumInstructions);
    fprintf(f, "NumTemporaries=%d\n", prog->NumTemporaries);
    fprintf(f, "NumParameters=%d\n", prog->NumParameters);
diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c
index 9c3ebc0..3c62456 100644
--- a/src/mesa/program/prog_to_nir.c
+++ b/src/mesa/program/prog_to_nir.c
@@ -945,11 +945,11 @@ setup_registers_and_variables(struct ptn_compile *c)
    }
 
    /* Create output registers and variables. */
-   int max_outputs = util_last_bit(c->prog->OutputsWritten);
+   int max_outputs = util_last_bit(c->prog->info.outputs_written);
    c->output_regs = rzalloc_array(c, nir_register *, max_outputs);
 
    for (int i = 0; i < max_outputs; i++) {
-      if (!(c->prog->OutputsWritten & BITFIELD64_BIT(i)))
+      if (!(c->prog->info.outputs_written & BITFIELD64_BIT(i)))
          continue;
 
       /* Since we can't load from outputs in the IR, we make temporaries
@@ -1051,7 +1051,6 @@ prog_to_nir(const struct gl_program *prog,
    s->info->num_abos = 0;
    s->info->num_ssbos = 0;
    s->info->num_images = 0;
-   s->info->outputs_written = prog->OutputsWritten;
    s->info->system_values_read = prog->SystemValuesRead;
    s->info->uses_texture_gather = false;
    s->info->uses_clip_distance_out = false;
diff --git a/src/mesa/program/program_parse.y b/src/mesa/program/program_parse.y
index 294ada1..6dbb045 100644
--- a/src/mesa/program/program_parse.y
+++ b/src/mesa/program/program_parse.y
@@ -594,7 +594,7 @@ maskedDstReg: dstReg optionalMask
 		 YYERROR;
 	      }
 
-	      state->prog->OutputsWritten |= BITFIELD64_BIT($$.Index);
+              state->prog->info.outputs_written |= BITFIELD64_BIT($$.Index);
 	   }
 	}
 	;
diff --git a/src/mesa/program/programopt.c b/src/mesa/program/programopt.c
index 3c9839b..b4bbbda 100644
--- a/src/mesa/program/programopt.c
+++ b/src/mesa/program/programopt.c
@@ -108,7 +108,7 @@ _mesa_insert_mvp_dp4_code(struct gl_context *ctx, struct gl_program *vprog)
    vprog->Instructions = newInst;
    vprog->NumInstructions = newLen;
    vprog->info.inputs_read |= VERT_BIT_POS;
-   vprog->OutputsWritten |= BITFIELD64_BIT(VARYING_SLOT_POS);
+   vprog->info.outputs_written |= BITFIELD64_BIT(VARYING_SLOT_POS);
 }
 
 
@@ -209,7 +209,7 @@ _mesa_insert_mvp_mad_code(struct gl_context *ctx, struct gl_program *vprog)
    vprog->Instructions = newInst;
    vprog->NumInstructions = newLen;
    vprog->info.inputs_read |= VERT_BIT_POS;
-   vprog->OutputsWritten |= BITFIELD64_BIT(VARYING_SLOT_POS);
+   vprog->info.outputs_written |= BITFIELD64_BIT(VARYING_SLOT_POS);
 }
 
 
@@ -264,7 +264,7 @@ _mesa_append_fog_code(struct gl_context *ctx, struct gl_program *fprog,
       return;
    }
 
-   if (!(fprog->OutputsWritten & (1 << FRAG_RESULT_COLOR))) {
+   if (!(fprog->info.outputs_written & (1 << FRAG_RESULT_COLOR))) {
       /* program doesn't output color, so nothing to do */
       return;
    }
@@ -409,7 +409,7 @@ _mesa_append_fog_code(struct gl_context *ctx, struct gl_program *fprog,
    fprog->Instructions = newInst;
    fprog->NumInstructions = inst - newInst;
    fprog->info.inputs_read |= VARYING_BIT_FOGC;
-   assert(fprog->OutputsWritten & (1 << FRAG_RESULT_COLOR));
+   assert(fprog->info.outputs_written & (1 << FRAG_RESULT_COLOR));
 }
 
 
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index a8c2ea3..9cb03b3 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -221,7 +221,8 @@ _swrast_update_deferred_texture(struct gl_context *ctx)
    else {
       GLboolean use_fprog = _swrast_use_fragment_program(ctx);
       const struct gl_program *fprog = ctx->FragmentProgram._Current;
-      if (use_fprog && (fprog->OutputsWritten & (1 << FRAG_RESULT_DEPTH))) {
+      if (use_fprog &&
+          (fprog->info.outputs_written & (1 << FRAG_RESULT_DEPTH))) {
          /* Z comes from fragment program/shader */
          swrast->_DeferredTexture = GL_FALSE;
       }
diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c
index bb601db..9bd357d 100644
--- a/src/mesa/swrast/s_fragprog.c
+++ b/src/mesa/swrast/s_fragprog.c
@@ -204,7 +204,7 @@ run_program(struct gl_context *ctx, SWspan *span, GLuint start, GLuint end)
 {
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
    const struct gl_program *program = ctx->FragmentProgram._Current;
-   const GLbitfield64 outputsWritten = program->OutputsWritten;
+   const GLbitfield64 outputsWritten = program->info.outputs_written;
    struct gl_program_machine *machine = &swrast->FragProgMachine;
    GLuint i;
 
@@ -271,12 +271,12 @@ _swrast_exec_fragment_program( struct gl_context *ctx, SWspan *span )
 
    run_program(ctx, span, 0, span->end);
 
-   if (program->OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_COLOR)) {
+   if (program->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_COLOR)) {
       span->interpMask &= ~SPAN_RGBA;
       span->arrayMask |= SPAN_RGBA;
    }
 
-   if (program->OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_DEPTH)) {
+   if (program->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_DEPTH)) {
       span->interpMask &= ~SPAN_Z;
       span->arrayMask |= SPAN_Z;
    }
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 949c230..49fc580 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1313,7 +1313,7 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span)
       const struct gl_program *fp = ctx->FragmentProgram._Current;
       const GLboolean multiFragOutputs = 
          _swrast_use_fragment_program(ctx)
-         && fp->OutputsWritten >= (1 << FRAG_RESULT_DATA0);
+         && fp->info.outputs_written >= (1 << FRAG_RESULT_DATA0);
       /* Save srcColorType because convert_color_type() can change it */
       const GLenum srcColorType = span->array->ChanType;
       GLuint buf;
diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c
index 0319e85..ec18fa0 100644
--- a/src/mesa/tnl/t_context.c
+++ b/src/mesa/tnl/t_context.c
@@ -183,7 +183,8 @@ _tnl_InvalidateState( struct gl_context *ctx, GLuint new_state )
    if (vp) {
       GLuint i;
       for (i = 0; i < MAX_VARYING; i++) {
-	 if (vp->OutputsWritten & BITFIELD64_BIT(VARYING_SLOT_VAR0 + i)) {
+	 if (vp->info.outputs_written &
+             BITFIELD64_BIT(VARYING_SLOT_VAR0 + i)) {
             tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_GENERIC(i));
          }
       }
diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c
index 1ed087c..695821a 100644
--- a/src/mesa/tnl/t_vb_program.c
+++ b/src/mesa/tnl/t_vb_program.c
@@ -304,7 +304,7 @@ run_vp( struct gl_context *ctx, struct tnl_pipeline_stage *stage )
    /* make list of outputs to save some time below */
    numOutputs = 0;
    for (i = 0; i < VARYING_SLOT_MAX; i++) {
-      if (program->OutputsWritten & BITFIELD64_BIT(i)) {
+      if (program->info.outputs_written & BITFIELD64_BIT(i)) {
          outputs[numOutputs++] = i;
       }
    }
@@ -378,7 +378,7 @@ run_vp( struct gl_context *ctx, struct tnl_pipeline_stage *stage )
       }
 
       /* FOGC is a special case.  Fragment shader expects (f,0,0,1) */
-      if (program->OutputsWritten & BITFIELD64_BIT(VARYING_SLOT_FOGC)) {
+      if (program->info.outputs_written & BITFIELD64_BIT(VARYING_SLOT_FOGC)) {
          store->results[VARYING_SLOT_FOGC].data[i][1] = 0.0;
          store->results[VARYING_SLOT_FOGC].data[i][2] = 0.0;
          store->results[VARYING_SLOT_FOGC].data[i][3] = 1.0;
@@ -443,7 +443,8 @@ run_vp( struct gl_context *ctx, struct tnl_pipeline_stage *stage )
    }
 
    for (i = 0; i < ctx->Const.MaxVarying; i++) {
-      if (program->OutputsWritten & BITFIELD64_BIT(VARYING_SLOT_VAR0 + i)) {
+      if (program->info.outputs_written &
+          BITFIELD64_BIT(VARYING_SLOT_VAR0 + i)) {
          /* Note: varying results get put into the generic attributes */
 	 VB->AttribPtr[VERT_ATTRIB_GENERIC0+i]
             = &store->results[VARYING_SLOT_VAR0 + i];
-- 
2.7.4



More information about the mesa-dev mailing list