From 9540130c412ec668ff1b9e50a420041a59ea1f15 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Fri, 15 May 2015 16:34:31 -0700 Subject: [PATCH] vk: Move vertex buffers into struct anv_bindings --- src/vulkan/device.c | 8 ++++---- src/vulkan/meta.c | 9 ++------- src/vulkan/private.h | 9 +++++---- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/vulkan/device.c b/src/vulkan/device.c index 8b0c2279f92..303f2854760 100644 --- a/src/vulkan/device.c +++ b/src/vulkan/device.c @@ -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, diff --git a/src/vulkan/meta.c b/src/vulkan/meta.c index 5091977d2ba..6d44e3336ec 100644 --- a/src/vulkan/meta.c +++ b/src/vulkan/meta.c @@ -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; } diff --git a/src/vulkan/private.h b/src/vulkan/private.h index 2e8ae9fb6bd..48900dc8022 100644 --- a/src/vulkan/private.h +++ b/src/vulkan/private.h @@ -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; -- 2.30.2