i965: Move curb_read_length/total_scratch to brw_stage_prog_data.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 2 Sep 2014 18:38:29 +0000 (11:38 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 4 Sep 2014 00:11:33 +0000 (17:11 -0700)
All shader stages have these fields, so it makes sense to store them in
the common base structure, rather than duplicating them in each.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
16 files changed:
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_vec4.cpp
src/mesa/drivers/dri/i965/brw_vec4_gs.c
src/mesa/drivers/dri/i965/brw_vs.c
src/mesa/drivers/dri/i965/brw_vs_state.c
src/mesa/drivers/dri/i965/brw_wm.c
src/mesa/drivers/dri/i965/brw_wm_state.c
src/mesa/drivers/dri/i965/gen6_vs_state.c
src/mesa/drivers/dri/i965/gen6_wm_state.c
src/mesa/drivers/dri/i965/gen7_gs_state.c
src/mesa/drivers/dri/i965/gen7_vs_state.c
src/mesa/drivers/dri/i965/gen7_wm_state.c
src/mesa/drivers/dri/i965/gen8_gs_state.c
src/mesa/drivers/dri/i965/gen8_ps_state.c
src/mesa/drivers/dri/i965/gen8_vs_state.c

index ef68c53fd34c037d4901b03457b2a43498087d17..d1ec2ea447ea189df93a3fe610b51b95fcd0f75c 100644 (file)
@@ -359,6 +359,9 @@ struct brw_stage_prog_data {
    GLuint nr_params;       /**< number of float params/constants */
    GLuint nr_pull_params;
 
+   unsigned curb_read_length;
+   unsigned total_scratch;
+
    /**
     * Register where the thread expects to find input data from the URB
     * (typically uniforms, followed by vertex or fragment attributes).
@@ -386,13 +389,11 @@ struct brw_stage_prog_data {
 struct brw_wm_prog_data {
    struct brw_stage_prog_data base;
 
-   GLuint curb_read_length;
    GLuint num_varying_inputs;
 
    GLuint dispatch_grf_start_reg_16;
    GLuint reg_blocks;
    GLuint reg_blocks_16;
-   GLuint total_scratch;
 
    struct {
       /** @{
@@ -592,10 +593,8 @@ struct brw_vec4_prog_data {
    struct brw_stage_prog_data base;
    struct brw_vue_map vue_map;
 
-   GLuint curb_read_length;
    GLuint urb_read_length;
    GLuint total_grf;
-   GLuint total_scratch;
 
    /* Used for calculating urb partitions.  In the VS, this is the size of the
     * URB entry used for both input and output to the thread.  In the GS, this
index ac6b1060ecf918d375b360f2aba692f4373cf840..5f98287e965019ef20edb7e5311b8e3d18046ab8 100644 (file)
@@ -1463,7 +1463,7 @@ fs_visitor::assign_curb_setup()
       prog_data->dispatch_grf_start_reg_16 = payload.num_regs;
    }
 
-   prog_data->curb_read_length = ALIGN(stage_prog_data->nr_params, 8) / 8;
+   prog_data->base.curb_read_length = ALIGN(stage_prog_data->nr_params, 8) / 8;
 
    /* Map the offsets in the UNIFORM file to fixed HW regs. */
    foreach_in_list(fs_inst, inst, &instructions) {
@@ -1583,7 +1583,7 @@ fs_visitor::calculate_urb_setup()
 void
 fs_visitor::assign_urb_setup()
 {
-   int urb_start = payload.num_regs + prog_data->curb_read_length;
+   int urb_start = payload.num_regs + prog_data->base.curb_read_length;
 
    /* Offset all the urb_setup[] index by the actual position of the
     * setup regs, now that the location of the constants has been chosen.
@@ -3345,7 +3345,7 @@ fs_visitor::run()
       schedule_instructions(SCHEDULE_POST);
 
    if (last_scratch > 0) {
-      prog_data->total_scratch = brw_get_scratch_size(last_scratch);
+      prog_data->base.total_scratch = brw_get_scratch_size(last_scratch);
    }
 
    if (brw->use_rep_send)
index b247bf7532b7a81f9285464a7b1ae1803aee3a85..5d8f711a100347bde9b48166565bfef8623cdc5c 100644 (file)
@@ -1606,7 +1606,8 @@ vec4_visitor::setup_uniforms(int reg)
 
    stage_prog_data->nr_params = this->uniforms * 4;
 
-   prog_data->curb_read_length = reg - prog_data->base.dispatch_grf_start_reg;
+   prog_data->base.curb_read_length =
+      reg - prog_data->base.dispatch_grf_start_reg;
 
    return reg;
 }
index d99502de61326e861be8159eef0772615e2b88b3..210e20ea2ec9d1e73d1f9349d81d304df8baddae 100644 (file)
@@ -242,11 +242,12 @@ do_gs_prog(struct brw_context *brw,
                  "Try reducing the number of live vec4 values to "
                  "improve performance.\n");
 
-      c.prog_data.base.total_scratch
+      c.prog_data.base.base.total_scratch
          = brw_get_scratch_size(c.base.last_scratch*REG_SIZE);
 
       brw_get_scratch_bo(brw, &stage_state->scratch_bo,
-                        c.prog_data.base.total_scratch * brw->max_gs_threads);
+                        c.prog_data.base.base.total_scratch *
+                         brw->max_gs_threads);
    }
 
    brw_upload_cache(&brw->cache, BRW_GS_PROG,
index 8e8b04493b98854bd36f9190e6f64751cd8ff6e1..4730635fe477489685a52a12d2ce2857c3fc9b90 100644 (file)
@@ -304,11 +304,12 @@ do_vs_prog(struct brw_context *brw,
                  "Try reducing the number of live vec4 values to "
                  "improve performance.\n");
 
-      prog_data.base.total_scratch
+      prog_data.base.base.total_scratch
          = brw_get_scratch_size(c.base.last_scratch*REG_SIZE);
 
       brw_get_scratch_bo(brw, &brw->vs.base.scratch_bo,
-                        prog_data.base.total_scratch * brw->max_vs_threads);
+                        prog_data.base.base.total_scratch *
+                         brw->max_vs_threads);
    }
 
    brw_upload_cache(&brw->cache, BRW_VS_PROG,
index e05d3f9af36ac7b80e004b9628c1c351b4e9cf29..53ac335752bbfdd00efaa5646ed4fa43884d1ce0 100644 (file)
@@ -82,11 +82,11 @@ brw_upload_vs_unit(struct brw_context *brw)
    vs->thread1.binding_table_entry_count =
       brw->vs.prog_data->base.base.binding_table.size_bytes / 4;
 
-   if (brw->vs.prog_data->base.total_scratch != 0) {
+   if (brw->vs.prog_data->base.base.total_scratch != 0) {
       vs->thread2.scratch_space_base_pointer =
         stage_state->scratch_bo->offset64 >> 10; /* reloc */
       vs->thread2.per_thread_scratch_space =
-        ffs(brw->vs.prog_data->base.total_scratch) - 11;
+        ffs(brw->vs.prog_data->base.base.total_scratch) - 11;
    } else {
       vs->thread2.scratch_space_base_pointer = 0;
       vs->thread2.per_thread_scratch_space = 0;
@@ -94,7 +94,7 @@ brw_upload_vs_unit(struct brw_context *brw)
 
    vs->thread3.urb_entry_read_length = brw->vs.prog_data->base.urb_read_length;
    vs->thread3.const_urb_entry_read_length
-      = brw->vs.prog_data->base.curb_read_length;
+      = brw->vs.prog_data->base.base.curb_read_length;
    vs->thread3.dispatch_grf_start_reg =
       brw->vs.prog_data->base.base.dispatch_grf_start_reg;
    vs->thread3.urb_entry_read_offset = 0;
@@ -172,7 +172,7 @@ brw_upload_vs_unit(struct brw_context *brw)
    }
 
    /* Emit scratch space relocation */
-   if (brw->vs.prog_data->base.total_scratch != 0) {
+   if (brw->vs.prog_data->base.base.total_scratch != 0) {
       drm_intel_bo_emit_reloc(brw->batch.bo,
                              stage_state->state_offset +
                              offsetof(struct brw_vs_unit_state, thread2),
index 2e3cd4bb2cc20ab2784bb902b9d797c746038d58..6834534c54af0daf2011c2608326614835adceed 100644 (file)
@@ -187,9 +187,9 @@ bool do_wm_prog(struct brw_context *brw,
       return false;
    }
 
-   if (prog_data.total_scratch) {
+   if (prog_data.base.total_scratch) {
       brw_get_scratch_bo(brw, &brw->wm.base.scratch_bo,
-                        prog_data.total_scratch * brw->max_wm_threads);
+                        prog_data.base.total_scratch * brw->max_wm_threads);
    }
 
    if (unlikely(INTEL_DEBUG & DEBUG_WM))
index 3fd8821832452c5fda1e7b0d3dd4a8d6f4d4f4a5..58f2cf86062a3616c08c23e9656db009fafefbe7 100644 (file)
@@ -124,11 +124,11 @@ brw_upload_wm_unit(struct brw_context *brw)
    wm->thread1.binding_table_entry_count =
       brw->wm.prog_data->base.binding_table.size_bytes / 4;
 
-   if (brw->wm.prog_data->total_scratch != 0) {
+   if (brw->wm.prog_data->base.total_scratch != 0) {
       wm->thread2.scratch_space_base_pointer =
         brw->wm.base.scratch_bo->offset64 >> 10; /* reloc */
       wm->thread2.per_thread_scratch_space =
-        ffs(brw->wm.prog_data->total_scratch) - 11;
+        ffs(brw->wm.prog_data->base.total_scratch) - 11;
    } else {
       wm->thread2.scratch_space_base_pointer = 0;
       wm->thread2.per_thread_scratch_space = 0;
@@ -140,7 +140,7 @@ brw_upload_wm_unit(struct brw_context *brw)
       brw->wm.prog_data->num_varying_inputs * 2;
    wm->thread3.urb_entry_read_offset = 0;
    wm->thread3.const_urb_entry_read_length =
-      brw->wm.prog_data->curb_read_length;
+      brw->wm.prog_data->base.curb_read_length;
    /* BRW_NEW_CURBE_OFFSETS */
    wm->thread3.const_urb_entry_read_offset = brw->curbe.wm_start * 2;
 
@@ -219,7 +219,7 @@ brw_upload_wm_unit(struct brw_context *brw)
       wm->wm4.stats_enable = 1;
 
    /* Emit scratch space relocation */
-   if (brw->wm.prog_data->total_scratch != 0) {
+   if (brw->wm.prog_data->base.total_scratch != 0) {
       drm_intel_bo_emit_reloc(brw->batch.bo,
                              brw->wm.base.state_offset +
                              offsetof(struct brw_wm_unit_state, thread2),
index 77f566cd3566b08abc31b1aa80958da3666c722e..2427407c18ef59a1734ffaaca03944db41afc200 100644 (file)
@@ -215,10 +215,10 @@ upload_vs_state(struct brw_context *brw)
              ((brw->vs.prog_data->base.base.binding_table.size_bytes / 4) <<
               GEN6_VS_BINDING_TABLE_ENTRY_COUNT_SHIFT));
 
-   if (brw->vs.prog_data->base.total_scratch) {
+   if (brw->vs.prog_data->base.base.total_scratch) {
       OUT_RELOC(stage_state->scratch_bo,
                I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
-               ffs(brw->vs.prog_data->base.total_scratch) - 11);
+               ffs(brw->vs.prog_data->base.base.total_scratch) - 11);
    } else {
       OUT_BATCH(0);
    }
index de95db8b8ab46c16c52cf61eb21b01abf9506672..930f9ae4670e28a57640bfe2505ed6e8662b22cb 100644 (file)
@@ -284,10 +284,10 @@ upload_wm_state(struct brw_context *brw)
    OUT_BATCH(_3DSTATE_WM << 16 | (9 - 2));
    OUT_BATCH(ksp0);
    OUT_BATCH(dw2);
-   if (brw->wm.prog_data->total_scratch) {
+   if (brw->wm.prog_data->base.total_scratch) {
       OUT_RELOC(brw->wm.base.scratch_bo,
                 I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
-               ffs(brw->wm.prog_data->total_scratch) - 11);
+               ffs(brw->wm.prog_data->base.total_scratch) - 11);
    } else {
       OUT_BATCH(0);
    }
index 93f48f6557b7fb67679bd78314f36bd6e298965c..6b0fb97b64c660de1f15449502bf4d943c9f0518 100644 (file)
@@ -94,10 +94,10 @@ upload_gs_state(struct brw_context *brw)
                 ((brw->gs.prog_data->base.base.binding_table.size_bytes / 4) <<
                  GEN6_GS_BINDING_TABLE_ENTRY_COUNT_SHIFT));
 
-      if (brw->gs.prog_data->base.total_scratch) {
+      if (brw->gs.prog_data->base.base.total_scratch) {
          OUT_RELOC(stage_state->scratch_bo,
                    I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
-                   ffs(brw->gs.prog_data->base.total_scratch) - 11);
+                   ffs(brw->gs.prog_data->base.base.total_scratch) - 11);
       } else {
          OUT_BATCH(0);
       }
index fd8a78f1872815a1d74d63a1e0bbfb2baced2553..7534de28c2e95b60dfeaeddeda8d4fa56a5c19c8 100644 (file)
@@ -90,10 +90,10 @@ upload_vs_state(struct brw_context *brw)
              ((brw->vs.prog_data->base.base.binding_table.size_bytes / 4) <<
               GEN6_VS_BINDING_TABLE_ENTRY_COUNT_SHIFT));
 
-   if (brw->vs.prog_data->base.total_scratch) {
+   if (brw->vs.prog_data->base.base.total_scratch) {
       OUT_RELOC(stage_state->scratch_bo,
                I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
-               ffs(brw->vs.prog_data->base.total_scratch) - 11);
+               ffs(brw->vs.prog_data->base.base.total_scratch) - 11);
    } else {
       OUT_BATCH(0);
    }
index 278cf17964c7bdedabf2482bb435e29a8f351b8f..809a2499b601e1ce1dbc6b9b4c4f267dbfb7a153 100644 (file)
@@ -252,10 +252,10 @@ upload_ps_state(struct brw_context *brw)
    OUT_BATCH(_3DSTATE_PS << 16 | (8 - 2));
    OUT_BATCH(ksp0);
    OUT_BATCH(dw2);
-   if (brw->wm.prog_data->total_scratch) {
+   if (brw->wm.prog_data->base.total_scratch) {
       OUT_RELOC(brw->wm.base.scratch_bo,
                I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
-               ffs(brw->wm.prog_data->total_scratch) - 11);
+               ffs(brw->wm.prog_data->base.total_scratch) - 11);
    } else {
       OUT_BATCH(0);
    }
index 446edec21798e5e431756ab26245e2446f4f4618..5cb5be970bdce2f3a4bbb248189ff4b2511c8277 100644 (file)
@@ -55,10 +55,10 @@ gen8_upload_gs_state(struct brw_context *brw)
                 ((prog_data->base.binding_table.size_bytes / 4) <<
                  GEN6_GS_BINDING_TABLE_ENTRY_COUNT_SHIFT));
 
-      if (brw->gs.prog_data->base.total_scratch) {
+      if (brw->gs.prog_data->base.base.total_scratch) {
          OUT_RELOC64(stage_state->scratch_bo,
                      I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
-                     ffs(brw->gs.prog_data->base.total_scratch) - 11);
+                     ffs(brw->gs.prog_data->base.base.total_scratch) - 11);
          WARN_ONCE(true,
                    "May need to implement a temporary workaround: GS Number of "
                    "URB Entries must be less than or equal to the GS Maximum "
index 5e313bfd22672226202cba9216d328fa686cce7b..3d3df19916a3bc60cc8e4cfdae920625cf257e5f 100644 (file)
@@ -225,10 +225,10 @@ upload_ps_state(struct brw_context *brw)
    OUT_BATCH(ksp0);
    OUT_BATCH(0);
    OUT_BATCH(dw3);
-   if (brw->wm.prog_data->total_scratch) {
+   if (brw->wm.prog_data->base.total_scratch) {
       OUT_RELOC64(brw->wm.base.scratch_bo,
                   I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
-                  ffs(brw->wm.prog_data->total_scratch) - 11);
+                  ffs(brw->wm.prog_data->base.total_scratch) - 11);
    } else {
       OUT_BATCH(0);
       OUT_BATCH(0);
index f5e8dd3e4e81540f5cc546b7aac045296f668b19..0cc4f0cdc5fc6c2493d0f70bd9bb498ac75132dc 100644 (file)
@@ -55,10 +55,10 @@ upload_vs_state(struct brw_context *brw)
              ((prog_data->base.binding_table.size_bytes / 4) <<
                GEN6_VS_BINDING_TABLE_ENTRY_COUNT_SHIFT));
 
-   if (prog_data->total_scratch) {
+   if (prog_data->base.total_scratch) {
       OUT_RELOC64(stage_state->scratch_bo,
                   I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
-                  ffs(prog_data->total_scratch) - 11);
+                  ffs(prog_data->base.total_scratch) - 11);
    } else {
       OUT_BATCH(0);
       OUT_BATCH(0);