From: Jason Ekstrand Date: Thu, 5 Nov 2015 03:48:59 +0000 (-0800) Subject: anv/cmd_buffer: Don't use an anv_state pointer in emit_binding_table X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1b68120760460c3d23425dadf46df75274b6ddb0;p=mesa.git anv/cmd_buffer: Don't use an anv_state pointer in emit_binding_table The anv_state is supposed to be a flyweight so we're not really saving anything by using a pointer. Also, we were creating one, setting a pointer to it, and then having it go out-of-scope which is bad. --- diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c index 99f10981f69..57cc8a6456b 100644 --- a/src/vulkan/anv_cmd_buffer.c +++ b/src/vulkan/anv_cmd_buffer.c @@ -596,7 +596,7 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer, cmd_buffer->state.descriptors[binding->set]; struct anv_descriptor *desc = &set->descriptors[binding->offset]; - const struct anv_state *surface_state; + struct anv_state surface_state; struct anv_bo *bo; uint32_t bo_offset; @@ -606,31 +606,30 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer, /* Nothing for us to do here */ continue; case ANV_DESCRIPTOR_TYPE_BUFFER_VIEW: - surface_state = &desc->buffer_view->surface_state; + surface_state = desc->buffer_view->surface_state; bo = desc->buffer_view->bo; bo_offset = desc->buffer_view->offset; break; case ANV_DESCRIPTOR_TYPE_BUFFER_AND_OFFSET: { - struct anv_state state = + surface_state = anv_cmd_buffer_alloc_surface_state(cmd_buffer); - anv_fill_buffer_surface_state(cmd_buffer->device, state.map, + anv_fill_buffer_surface_state(cmd_buffer->device, surface_state.map, anv_format_for_vk_format(VK_FORMAT_R32G32B32A32_SFLOAT), desc->offset, desc->range); - surface_state = &state; bo = desc->buffer_view->bo; bo_offset = desc->buffer_view->offset; break; } case ANV_DESCRIPTOR_TYPE_IMAGE_VIEW: case ANV_DESCRIPTOR_TYPE_IMAGE_VIEW_AND_SAMPLER: - surface_state = &desc->image_view->nonrt_surface_state; + surface_state = desc->image_view->nonrt_surface_state; bo = desc->image_view->bo; bo_offset = desc->image_view->offset; break; } - bt_map[bias + s] = surface_state->offset + state_offset; - add_surface_state_reloc(cmd_buffer, *surface_state, bo, bo_offset); + bt_map[bias + s] = surface_state.offset + state_offset; + add_surface_state_reloc(cmd_buffer, surface_state, bo, bo_offset); } return VK_SUCCESS;