i965: Upload separate VS and FS sampler state tables.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 26 Jun 2013 05:14:04 +0000 (22:14 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 19 Aug 2013 20:16:59 +0000 (13:16 -0700)
Now, each shader stage has a sampler state table that only refers to the
samplers actually used by that problem.  This should make the VS table
non-existant or very small.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
src/mesa/drivers/dri/i965/gen7_sampler_state.c

index 5280b8831fe7d365f7b860b86f1773883d8d250f..fbe00b12fb809b052620e641215eabe391ef7bac 100644 (file)
@@ -817,6 +817,7 @@ struct brw_context
 
       /** Upload a SAMPLER_STATE table. */
       void (*upload_sampler_state_table)(struct brw_context *brw,
+                                         struct gl_program *prog,
                                          uint32_t *sampler_count,
                                          uint32_t *sst_offset,
                                          uint32_t *sdc_offset);
index 78366ca19f423f77366c0dd1bdfc7c79b3ca7c69..e8d47d06e9c1affaf37336c4273dfa77e0bf87c8 100644 (file)
@@ -368,6 +368,7 @@ static void brw_update_sampler_state(struct brw_context *brw,
 
 static void
 brw_upload_sampler_state_table(struct brw_context *brw,
+                               struct gl_program *prog,
                                uint32_t *sampler_count,
                                uint32_t *sst_offset,
                                uint32_t *sdc_offset)
@@ -375,11 +376,7 @@ brw_upload_sampler_state_table(struct brw_context *brw,
    struct gl_context *ctx = &brw->ctx;
    struct brw_sampler_state *samplers;
 
-   /* BRW_NEW_VERTEX_PROGRAM and BRW_NEW_FRAGMENT_PROGRAM */
-   struct gl_program *vs = (struct gl_program *) brw->vertex_program;
-   struct gl_program *fs = (struct gl_program *) brw->fragment_program;
-
-   GLbitfield SamplersUsed = vs->SamplersUsed | fs->SamplersUsed;
+   GLbitfield SamplersUsed = prog->SamplersUsed;
 
    /* ARB programs use the texture unit number as the sampler index, so we
     * need to find the highest unit used.  A bit-count will not work.
@@ -394,10 +391,9 @@ brw_upload_sampler_state_table(struct brw_context *brw,
                              32, sst_offset);
    memset(samplers, 0, *sampler_count * sizeof(*samplers));
 
-   for (unsigned s = 0; s < brw->wm.sampler_count; s++) {
+   for (unsigned s = 0; s < *sampler_count; s++) {
       if (SamplersUsed & (1 << s)) {
-         const unsigned unit = (fs->SamplersUsed & (1 << s)) ?
-            fs->SamplerUnits[s] : vs->SamplerUnits[s];
+         const unsigned unit = prog->SamplerUnits[s];
          if (ctx->Texture.Unit[unit]._ReallyEnabled)
             brw_update_sampler_state(brw, unit, s, &samplers[s],
                                      *sst_offset, &sdc_offset[s]);
@@ -410,12 +406,16 @@ brw_upload_sampler_state_table(struct brw_context *brw,
 static void
 brw_upload_samplers(struct brw_context *brw)
 {
-   brw->vtbl.upload_sampler_state_table(brw,
+   /* BRW_NEW_FRAGMENT_PROGRAM */
+   struct gl_program *fs = (struct gl_program *) brw->fragment_program;
+   brw->vtbl.upload_sampler_state_table(brw, fs,
                                         &brw->wm.sampler_count,
                                         &brw->wm.sampler_offset,
                                         brw->wm.sdc_offset);
 
-   brw->vtbl.upload_sampler_state_table(brw,
+   /* BRW_NEW_VERTEX_PROGRAM */
+   struct gl_program *vs = (struct gl_program *) brw->vertex_program;
+   brw->vtbl.upload_sampler_state_table(brw, vs,
                                         &brw->vs.sampler_count,
                                         &brw->vs.sampler_offset,
                                         brw->vs.sdc_offset);
index c7b69d5d6c6cbe74433bad3259d4028474a54f65..5701f4d8f04508392c2df4dd5382ad0abc716e43 100644 (file)
@@ -186,6 +186,7 @@ gen7_update_sampler_state(struct brw_context *brw, int unit, int ss_index,
 
 static void
 gen7_upload_sampler_state_table(struct brw_context *brw,
+                                struct gl_program *prog,
                                 uint32_t *sampler_count,
                                 uint32_t *sst_offset,
                                 uint32_t *sdc_offset)
@@ -193,11 +194,7 @@ gen7_upload_sampler_state_table(struct brw_context *brw,
    struct gl_context *ctx = &brw->ctx;
    struct gen7_sampler_state *samplers;
 
-   /* BRW_NEW_VERTEX_PROGRAM and BRW_NEW_FRAGMENT_PROGRAM */
-   struct gl_program *vs = (struct gl_program *) brw->vertex_program;
-   struct gl_program *fs = (struct gl_program *) brw->fragment_program;
-
-   GLbitfield SamplersUsed = vs->SamplersUsed | fs->SamplersUsed;
+   GLbitfield SamplersUsed = prog->SamplersUsed;
 
    *sampler_count = _mesa_fls(SamplersUsed);
 
@@ -209,10 +206,9 @@ gen7_upload_sampler_state_table(struct brw_context *brw,
                              32, sst_offset);
    memset(samplers, 0, *sampler_count * sizeof(*samplers));
 
-   for (unsigned s = 0; s < brw->wm.sampler_count; s++) {
+   for (unsigned s = 0; s < *sampler_count; s++) {
       if (SamplersUsed & (1 << s)) {
-         const unsigned unit = (fs->SamplersUsed & (1 << s)) ?
-            fs->SamplerUnits[s] : vs->SamplerUnits[s];
+         const unsigned unit = prog->SamplerUnits[s];
          if (ctx->Texture.Unit[unit]._ReallyEnabled)
             gen7_update_sampler_state(brw, unit, s, &samplers[s],
                                       &sdc_offset[s]);