vk/cmd_buffer: Add a helper for allocating dynamic state
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 15 Jul 2015 23:33:47 +0000 (16:33 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 15 Jul 2015 23:56:29 +0000 (16:56 -0700)
This matches what we do for surface state and makes the dynamic state pool
more opaque to things that need to get dynamic state.

src/vulkan/anv_cmd_buffer.c
src/vulkan/anv_cmd_emit.c
src/vulkan/private.h

index 86d8f08971ed12fe33a0657499e241468715d4c2..e6e60e141891323668ecca29b5dbec3580f8731e 100644 (file)
@@ -318,6 +318,14 @@ anv_cmd_buffer_alloc_surface_state(struct anv_cmd_buffer *cmd_buffer,
    return state;
 }
 
+struct anv_state
+anv_cmd_buffer_alloc_dynamic_state(struct anv_cmd_buffer *cmd_buffer,
+                                   uint32_t size, uint32_t alignment)
+{
+   return anv_state_stream_alloc(&cmd_buffer->dynamic_state_stream,
+                                 size, alignment);
+}
+
 VkResult
 anv_cmd_buffer_new_surface_state_bo(struct anv_cmd_buffer *cmd_buffer)
 {
index b4cb0c048d0f1352383c92c0afccabe84bc64e01..4c9f29ffaabb5d43e5612ddaf32ee3db4cb81154 100644 (file)
@@ -409,7 +409,7 @@ cmd_buffer_emit_samplers(struct anv_cmd_buffer *cmd_buffer,
       return VK_SUCCESS;
 
    uint32_t size = sampler_count * 16;
-   *state = anv_state_stream_alloc(&cmd_buffer->dynamic_state_stream, size, 32);
+   *state = anv_cmd_buffer_alloc_dynamic_state(cmd_buffer, size, 32);
 
    if (state->map == NULL)
       return VK_ERROR_OUT_OF_DEVICE_MEMORY;
@@ -522,8 +522,8 @@ anv_cmd_buffer_emit_dynamic(struct anv_cmd_buffer *cmd_buffer,
 {
    struct anv_state state;
 
-   state = anv_state_stream_alloc(&cmd_buffer->dynamic_state_stream,
-                                  dwords * 4, alignment);
+   state = anv_cmd_buffer_alloc_dynamic_state(cmd_buffer,
+                                              dwords * 4, alignment);
    memcpy(state.map, a, dwords * 4);
 
    VG(VALGRIND_CHECK_MEM_IS_DEFINED(state.map, dwords * 4));
@@ -539,8 +539,8 @@ anv_cmd_buffer_merge_dynamic(struct anv_cmd_buffer *cmd_buffer,
    struct anv_state state;
    uint32_t *p;
 
-   state = anv_state_stream_alloc(&cmd_buffer->dynamic_state_stream,
-                                  dwords * 4, alignment);
+   state = anv_cmd_buffer_alloc_dynamic_state(cmd_buffer,
+                                              dwords * 4, alignment);
    p = state.map;
    for (uint32_t i = 0; i < dwords; i++)
       p[i] = a[i] | b[i];
index cd80c896f35cd8e22c25b2854c2cbc0afb417b4b..cfc46ee8f60d8c2a241fde6c5dd2a0ac45ce022d 100644 (file)
@@ -717,6 +717,9 @@ struct anv_cmd_buffer {
 struct anv_state
 anv_cmd_buffer_alloc_surface_state(struct anv_cmd_buffer *cmd_buffer,
                                    uint32_t size, uint32_t alignment);
+struct anv_state
+anv_cmd_buffer_alloc_dynamic_state(struct anv_cmd_buffer *cmd_buffer,
+                                   uint32_t size, uint32_t alignment);
 
 VkResult anv_cmd_buffer_new_surface_state_bo(struct anv_cmd_buffer *cmd_buffer);