iris: rework num textures to util_lastbit
authorKenneth Graunke <kenneth@whitecape.org>
Sun, 13 Jan 2019 19:36:10 +0000 (11:36 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:12 +0000 (10:26 -0800)
src/gallium/drivers/iris/iris_program.c
src/gallium/drivers/iris/iris_state.c

index d2ada71146db6f2932de606df7932f56fe1d511f..4eb2b676a7d9ec60336489060be078f622f17e5d 100644 (file)
@@ -543,10 +543,12 @@ assign_common_binding_table_offsets(const struct gen_device_info *devinfo,
 {
    const struct shader_info *info = &nir->info;
 
-   if (info->num_textures) {
+   unsigned num_textures = util_last_bit(info->textures_used);
+
+   if (num_textures) {
       prog_data->binding_table.texture_start = next_binding_table_offset;
       prog_data->binding_table.gather_texture_start = next_binding_table_offset;
-      next_binding_table_offset += info->num_textures;
+      next_binding_table_offset += num_textures;
    } else {
       prog_data->binding_table.texture_start = 0xd0d0d0d0;
       prog_data->binding_table.gather_texture_start = 0xd0d0d0d0;
@@ -581,10 +583,10 @@ assign_common_binding_table_offsets(const struct gen_device_info *devinfo,
    prog_data->binding_table.plane_start[0] = prog_data->binding_table.texture_start;
 
    prog_data->binding_table.plane_start[1] = next_binding_table_offset;
-   next_binding_table_offset += info->num_textures;
+   next_binding_table_offset += num_textures;
 
    prog_data->binding_table.plane_start[2] = next_binding_table_offset;
-   next_binding_table_offset += info->num_textures;
+   next_binding_table_offset += num_textures;
 
    /* Set the binding table size */
    prog_data->binding_table.size_bytes = next_binding_table_offset * 4;
index e7801a698dc74713f990feedebfb30f8c9b0a7f5..2cf9c62587e2a72025810f723c6183684f779c94 100644 (file)
@@ -3719,9 +3719,11 @@ iris_populate_binding_table(struct iris_context *ice,
       }
    }
 
-   bt_assert(texture_start, info->num_textures > 0);
+   unsigned num_textures = util_last_bit(info->textures_used);
 
-   for (int i = 0; i < info->num_textures; i++) {
+   bt_assert(texture_start, num_textures > 0);
+
+   for (int i = 0; i < num_textures; i++) {
       struct iris_sampler_view *view = shs->textures[i];
       uint32_t addr = view ? use_sampler_view(batch, view)
                            : use_null_surface(batch, ice);