diff options
author | Kenneth Graunke <[email protected]> | 2019-09-18 20:12:33 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2019-09-18 22:50:52 -0700 |
commit | 6841f11d1417c15f96276aaf53b92d0f5c998865 (patch) | |
tree | 396d901cdc2818b2e83f565d9871bc48b7bdc952 /src/gallium/drivers | |
parent | ddd314f0cecb89004980618ac40171a079f324fe (diff) |
iris: Use state_refs for draw parameters.
iris_state_ref is a <resource, offset> tuple, which is exactly what we
need here.
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/iris/iris_context.h | 6 | ||||
-rw-r--r-- | src/gallium/drivers/iris/iris_draw.c | 8 | ||||
-rw-r--r-- | src/gallium/drivers/iris/iris_state.c | 30 |
3 files changed, 21 insertions, 23 deletions
diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h index f711398f33b..ed814ee6824 100644 --- a/src/gallium/drivers/iris/iris_context.h +++ b/src/gallium/drivers/iris/iris_context.h @@ -555,8 +555,7 @@ struct iris_context { * buffer or to the buffer that stures the previous values for non * indirect draws. */ - struct pipe_resource *draw_params_res; - uint32_t draw_params_offset; + struct iris_state_ref draw_params; struct { /** @@ -577,8 +576,7 @@ struct iris_context { * contains parameters that are not present in the indirect buffer as * drawid and is_indexed_draw. They will go in their own vertex element. */ - struct pipe_resource *derived_draw_params_res; - uint32_t derived_draw_params_offset; + struct iris_state_ref derived_draw_params; bool is_indirect; } draw; diff --git a/src/gallium/drivers/iris/iris_draw.c b/src/gallium/drivers/iris/iris_draw.c index fc2c14eab7f..005da3f7a6d 100644 --- a/src/gallium/drivers/iris/iris_draw.c +++ b/src/gallium/drivers/iris/iris_draw.c @@ -114,9 +114,9 @@ iris_update_draw_parameters(struct iris_context *ice, const struct pipe_draw_info *info) { if (info->indirect) { - pipe_resource_reference(&ice->draw.draw_params_res, + pipe_resource_reference(&ice->draw.draw_params.res, info->indirect->buffer); - ice->draw.draw_params_offset = info->indirect->offset + + ice->draw.draw_params.offset = info->indirect->offset + (info->index_size ? 12 : 8); ice->draw.params.firstvertex = 0; ice->draw.params.baseinstance = 0; @@ -127,8 +127,8 @@ iris_update_draw_parameters(struct iris_context *ice, ice->draw.params.firstvertex != (info->index_size ? info->index_bias : info->start) || (ice->draw.params.baseinstance != info->start_instance)) { - pipe_resource_reference(&ice->draw.draw_params_res, NULL); - ice->draw.draw_params_offset = 0; + pipe_resource_reference(&ice->draw.draw_params.res, NULL); + ice->draw.draw_params.offset = 0; ice->draw.params.firstvertex = info->index_size ? info->index_bias : info->start; ice->draw.params.baseinstance = info->start_instance; diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index ce68e998c13..609115bce60 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -5293,26 +5293,26 @@ iris_upload_dirty_render_state(struct iris_context *ice, int dynamic_bound = ice->state.bound_vertex_buffers; if (ice->state.vs_uses_draw_params) { - if (ice->draw.draw_params_offset == 0) { + if (ice->draw.draw_params.offset == 0) { u_upload_data(ice->ctx.stream_uploader, 0, sizeof(ice->draw.params), - 4, &ice->draw.params, &ice->draw.draw_params_offset, - &ice->draw.draw_params_res); + 4, &ice->draw.params, &ice->draw.draw_params.offset, + &ice->draw.draw_params.res); } - assert(ice->draw.draw_params_res); + assert(ice->draw.draw_params.res); struct iris_vertex_buffer_state *state = &(ice->state.genx->vertex_buffers[count]); - pipe_resource_reference(&state->resource, ice->draw.draw_params_res); + pipe_resource_reference(&state->resource, ice->draw.draw_params.res); struct iris_resource *res = (void *) state->resource; iris_pack_state(GENX(VERTEX_BUFFER_STATE), state->state, vb) { vb.VertexBufferIndex = count; vb.AddressModifyEnable = true; vb.BufferPitch = 0; - vb.BufferSize = res->bo->size - ice->draw.draw_params_offset; + vb.BufferSize = res->bo->size - ice->draw.draw_params.offset; vb.BufferStartingAddress = ro_bo(NULL, res->bo->gtt_offset + - (int) ice->draw.draw_params_offset); + (int) ice->draw.draw_params.offset); vb.MOCS = mocs(res->bo); } dynamic_bound |= 1ull << count; @@ -5323,24 +5323,24 @@ iris_upload_dirty_render_state(struct iris_context *ice, u_upload_data(ice->ctx.stream_uploader, 0, sizeof(ice->draw.derived_params), 4, &ice->draw.derived_params, - &ice->draw.derived_draw_params_offset, - &ice->draw.derived_draw_params_res); + &ice->draw.derived_draw_params.offset, + &ice->draw.derived_draw_params.res); struct iris_vertex_buffer_state *state = &(ice->state.genx->vertex_buffers[count]); pipe_resource_reference(&state->resource, - ice->draw.derived_draw_params_res); - struct iris_resource *res = (void *) ice->draw.derived_draw_params_res; + ice->draw.derived_draw_params.res); + struct iris_resource *res = (void *) ice->draw.derived_draw_params.res; iris_pack_state(GENX(VERTEX_BUFFER_STATE), state->state, vb) { vb.VertexBufferIndex = count; vb.AddressModifyEnable = true; vb.BufferPitch = 0; vb.BufferSize = - res->bo->size - ice->draw.derived_draw_params_offset; + res->bo->size - ice->draw.derived_draw_params.offset; vb.BufferStartingAddress = ro_bo(NULL, res->bo->gtt_offset + - (int) ice->draw.derived_draw_params_offset); + (int) ice->draw.derived_draw_params.offset); vb.MOCS = mocs(res->bo); } dynamic_bound |= 1ull << count; @@ -5930,8 +5930,8 @@ iris_destroy_state(struct iris_context *ice) { struct iris_genx_state *genx = ice->state.genx; - pipe_resource_reference(&ice->draw.draw_params_res, NULL); - pipe_resource_reference(&ice->draw.derived_draw_params_res, NULL); + pipe_resource_reference(&ice->draw.draw_params.res, NULL); + pipe_resource_reference(&ice->draw.derived_draw_params.res, NULL); uint64_t bound_vbs = ice->state.bound_vertex_buffers; while (bound_vbs) { |