vk: Use a separate block pool and state stream for binding tables
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 19 May 2015 02:56:32 +0000 (19:56 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 19 May 2015 03:57:43 +0000 (20:57 -0700)
The binding table pointers packet only allows for a 16-bit binding table
address so all binding tables have to be in the first 64 KB of the surface
state BO.  We solve this by adding a slave block pool that pulls off the
first 64 KB worth of blocks and reserves them for binding tables.

src/vulkan/device.c
src/vulkan/private.h

index 09dddb766c216e0673ecb1215c7b69b61fc9f56a..a26986b658ae3fb22e24b056f0acda735620734d 100644 (file)
@@ -321,6 +321,15 @@ VkResult anv_CreateDevice(
    anv_block_pool_init(&device->instruction_block_pool, device, 2048);
    anv_block_pool_init(&device->surface_state_block_pool, device, 2048);
 
+
+   /* Binding table pointers are only 16 bits so we have to make sure that
+    * they get allocated at the beginning of the surface state BO.  To
+    * handle this, we create a separate block pool that works out of the
+    * first 64 KB of the surface state BO.
+    */
+   anv_block_pool_init_slave(&device->binding_table_block_pool,
+                             &device->surface_state_block_pool, 32);
+
    anv_state_pool_init(&device->surface_state_pool,
                        &device->surface_state_block_pool);
 
@@ -2077,6 +2086,8 @@ VkResult anv_CreateCommandBuffer(
       goto fail_exec2_objects;
    }
 
+   anv_state_stream_init(&cmd_buffer->binding_table_state_stream,
+                         &device->binding_table_block_pool);
    anv_state_stream_init(&cmd_buffer->surface_state_stream,
                          &device->surface_state_block_pool);
    anv_state_stream_init(&cmd_buffer->dynamic_state_stream,
@@ -2469,7 +2480,8 @@ flush_descriptor_sets(struct anv_cmd_buffer *cmd_buffer)
          uint32_t size;
 
          size = (bias + surface_count) * sizeof(uint32_t);
-         state = anv_state_stream_alloc(&cmd_buffer->surface_state_stream, size, 32);
+         state = anv_state_stream_alloc(&cmd_buffer->binding_table_state_stream,
+                                        size, 32);
          memcpy(state.map, bindings->descriptors[s].surfaces, size);
 
          for (uint32_t i = 0; i < layers; i++)
index fb28b61aff184264b2d23fa1250a41e50b9f921f..13be1b9479105d50b96774cb037becaf749787d9 100644 (file)
@@ -293,6 +293,7 @@ struct anv_device {
 
     struct anv_block_pool                       instruction_block_pool;
     struct anv_block_pool                       surface_state_block_pool;
+    struct anv_block_pool                       binding_table_block_pool;
     struct anv_state_pool                       surface_state_pool;
 
     struct anv_clear_state                      clear_state;
@@ -548,6 +549,7 @@ struct anv_cmd_buffer {
 
    uint32_t                                     bo_count;
    struct anv_batch                             batch;
+   struct anv_state_stream                      binding_table_state_stream;
    struct anv_state_stream                      surface_state_stream;
    struct anv_state_stream                      dynamic_state_stream;