vk: Move vertex buffers into struct anv_bindings
authorKristian Høgsberg <kristian.h.kristensen@intel.com>
Fri, 15 May 2015 23:34:31 +0000 (16:34 -0700)
committerKristian Høgsberg <kristian.h.kristensen@intel.com>
Fri, 15 May 2015 23:34:31 +0000 (16:34 -0700)
src/vulkan/device.c
src/vulkan/meta.c
src/vulkan/private.h

index 8b0c2279f92e33d39ccc2ea86b5de5973399f33d..303f2854760fb6082c12cc66fbf7725463c1352a 100644 (file)
@@ -2239,8 +2239,8 @@ void VKAPI vkCmdBindVertexBuffers(
     * stride from the pipeline. */
 
    for (uint32_t i = 0; i < bindingCount; i++) {
-      cmd_buffer->vb[startBinding + i].buffer = (struct anv_buffer *) pBuffers[i];
-      cmd_buffer->vb[startBinding + i].offset = pOffsets[i];
+      cmd_buffer->bindings.vb[startBinding + i].buffer = (struct anv_buffer *) pBuffers[i];
+      cmd_buffer->bindings.vb[startBinding + i].offset = pOffsets[i];
       cmd_buffer->vb_dirty |= 1 << (startBinding + i);
    }
 }
@@ -2335,8 +2335,8 @@ anv_cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer)
                           GEN8_3DSTATE_VERTEX_BUFFERS);
       uint32_t vb, i = 0;
       for_each_bit(vb, cmd_buffer->vb_dirty) {
-         struct anv_buffer *buffer = cmd_buffer->vb[vb].buffer;
-         uint32_t offset = cmd_buffer->vb[vb].offset;
+         struct anv_buffer *buffer = cmd_buffer->bindings.vb[vb].buffer;
+         uint32_t offset = cmd_buffer->bindings.vb[vb].offset;
       
          struct GEN8_VERTEX_BUFFER_STATE state = {
             .VertexBufferIndex = vb,
index 5091977d2ba8966c0badd54547417a13afd3771e..6d44e3336ecd00943827c06e09e4fc80eea673a9 100644 (file)
@@ -146,11 +146,8 @@ anv_device_init_meta_clear_state(struct anv_device *device)
                               &device->clear_state.rs_state);
 }
 
+#define NUM_VB_USED 2
 struct anv_saved_state {
-   struct {
-      struct anv_buffer *buffer;
-      VkDeviceSize offset;
-   } vb[2];
    struct anv_bindings bindings;
    struct anv_pipeline *pipeline;
 };
@@ -159,7 +156,6 @@ static void
 anv_cmd_buffer_save(struct anv_cmd_buffer *cmd_buffer,
                     struct anv_saved_state *state)
 {
-   memcpy(state->vb, cmd_buffer->vb, sizeof(state->vb));
    memcpy(&state->bindings, &cmd_buffer->bindings, sizeof(state->bindings));
    state->pipeline = cmd_buffer->pipeline;
 }
@@ -168,11 +164,10 @@ static void
 anv_cmd_buffer_restore(struct anv_cmd_buffer *cmd_buffer,
                        const struct anv_saved_state *state)
 {
-   memcpy(cmd_buffer->vb, state->vb, sizeof(state->vb));
    memcpy(&cmd_buffer->bindings, &state->bindings, sizeof(state->bindings));
    cmd_buffer->pipeline = state->pipeline;
 
-   cmd_buffer->vb_dirty |= (1 << ARRAY_SIZE(state->vb)) - 1;
+   cmd_buffer->vb_dirty |= (1 << NUM_VB_USED) - 1;
    cmd_buffer->dirty |= ANV_CMD_BUFFER_PIPELINE_DIRTY |
                         ANV_CMD_BUFFER_DESCRIPTOR_SET_DIRTY;
 }
index 2e8ae9fb6bdb54a7030f87c9d7e1fb3a0caac05f..48900dc8022405f3e82929921733553365cefcfa 100644 (file)
@@ -507,6 +507,11 @@ struct anv_buffer {
 #define ANV_CMD_BUFFER_RS_DIRTY                 (1 << 2)
    
 struct anv_bindings {
+   struct {
+      struct anv_buffer *buffer;
+      VkDeviceSize offset;
+   }                                            vb[MAX_VBS];
+
    struct {
       uint32_t                                  surfaces[256];
       struct {
@@ -532,10 +537,6 @@ struct anv_cmd_buffer {
    struct anv_state_stream                      dynamic_state_stream;
 
    /* State required while building cmd buffer */
-   struct {
-      struct anv_buffer *buffer;
-      VkDeviceSize offset;
-   }                                            vb[MAX_VBS];
    uint32_t                                     vb_dirty;
    uint32_t                                     dirty;
    struct anv_pipeline *                        pipeline;