From f78089b962537364d52ba05aa14dacbe20de995c Mon Sep 17 00:00:00 2001 From: Axel Davy Date: Tue, 4 Oct 2016 19:14:42 +0200 Subject: [PATCH] st/nine: Drop unused constant upload path This path has been disabled for some time because of some bugs with it. It hasn't been updated to the new features, and is not faster. Signed-off-by: Axel Davy Reviewed-by: Patrick Rudolph --- src/gallium/state_trackers/nine/device9.c | 27 --- src/gallium/state_trackers/nine/device9.h | 4 - src/gallium/state_trackers/nine/nine_state.c | 183 +------------------ 3 files changed, 4 insertions(+), 210 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 2ec8cb6f201..cc13399ec5e 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -302,9 +302,7 @@ NineDevice9_ctor( struct NineDevice9 *This, /* Create constant buffers. */ { - struct pipe_resource tmpl; unsigned max_const_vs, max_const_ps; - memset(&tmpl, 0, sizeof(tmpl)); /* vs 3.0: >= 256 float constants, but for cards with exactly 256 slots, * we have to take in some more slots for int and bool*/ @@ -336,29 +334,6 @@ NineDevice9_ctor( struct NineDevice9 *This, strstr(pScreen->get_name(pScreen), "ATI")) { This->driver_bugs.buggy_barycentrics = TRUE; } - - /* Disable NV path for now, needs some fixes */ - This->prefer_user_constbuf = TRUE; - - tmpl.target = PIPE_BUFFER; - tmpl.format = PIPE_FORMAT_R8_UNORM; - tmpl.height0 = 1; - tmpl.depth0 = 1; - tmpl.array_size = 1; - tmpl.last_level = 0; - tmpl.nr_samples = 0; - tmpl.usage = PIPE_USAGE_DYNAMIC; - tmpl.bind = PIPE_BIND_CONSTANT_BUFFER; - tmpl.flags = 0; - - tmpl.width0 = This->vs_const_size; - This->constbuf_vs = pScreen->resource_create(pScreen, &tmpl); - - tmpl.width0 = This->ps_const_size; - This->constbuf_ps = pScreen->resource_create(pScreen, &tmpl); - - if (!This->constbuf_vs || !This->constbuf_ps) - return E_OUTOFMEMORY; } /* allocate dummy texture/sampler for when there are missing ones bound */ @@ -479,8 +454,6 @@ NineDevice9_dtor( struct NineDevice9 *This ) pipe_sampler_view_reference(&This->dummy_sampler_view, NULL); pipe_resource_reference(&This->dummy_texture, NULL); - pipe_resource_reference(&This->constbuf_vs, NULL); - pipe_resource_reference(&This->constbuf_ps, NULL); pipe_resource_reference(&This->dummy_vbo, NULL); FREE(This->state.vs_const_f); FREE(This->state.ps_const_f); diff --git a/src/gallium/state_trackers/nine/device9.h b/src/gallium/state_trackers/nine/device9.h index 8eedfe132fe..f2fd164cc12 100644 --- a/src/gallium/state_trackers/nine/device9.h +++ b/src/gallium/state_trackers/nine/device9.h @@ -76,10 +76,6 @@ struct NineDevice9 boolean is_recording; boolean in_scene; - boolean prefer_user_constbuf; - - struct pipe_resource *constbuf_vs; - struct pipe_resource *constbuf_ps; uint16_t vs_const_size; uint16_t ps_const_size; uint16_t max_vs_const_f; diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c index fd098ca68ea..a18dd73f4f3 100644 --- a/src/gallium/state_trackers/nine/nine_state.c +++ b/src/gallium/state_trackers/nine/nine_state.c @@ -78,157 +78,6 @@ prepare_rasterizer(struct NineDevice9 *device) device->state.commit |= NINE_STATE_COMMIT_RASTERIZER; } -static void -prepare_ps_constants_userbuf(struct NineDevice9 *device); - -#define DO_UPLOAD_CONST_F(buf,p,c,d) \ - do { \ - DBG("upload ConstantF [%u .. %u]\n", x, (x) + (c) - 1); \ - box.x = (p) * 4 * sizeof(float); \ - box.width = (c) * 4 * sizeof(float); \ - pipe->buffer_subdata(pipe, buf, usage, box.x, box.width, &((d)[p * 4])); \ - } while(0) - -/* OK, this is a bit ugly ... */ -static void -upload_constants(struct NineDevice9 *device, unsigned shader_type) -{ - struct pipe_context *pipe = device->pipe; - struct pipe_resource *buf; - struct pipe_box box; - const void *data; - const float *const_f; - const int *const_i; - const BOOL *const_b; - uint32_t data_b[NINE_MAX_CONST_B]; - uint16_t dirty_i; - uint16_t dirty_b; - const unsigned usage = PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE; - unsigned x = 0; /* silence warning */ - unsigned i, c; - struct nine_range *r, *p, *lconstf_ranges; - float *lconstf_data; - - box.y = 0; - box.z = 0; - box.height = 1; - box.depth = 1; - - if (shader_type == PIPE_SHADER_VERTEX) { - DBG("VS\n"); - buf = device->constbuf_vs; - - const_f = device->state.vs_const_f; - for (p = r = device->state.changed.vs_const_f; r; p = r, r = r->next) - DO_UPLOAD_CONST_F(buf, r->bgn, r->end - r->bgn, const_f); - if (p) { - nine_range_pool_put_chain(&device->range_pool, - device->state.changed.vs_const_f, p); - device->state.changed.vs_const_f = NULL; - } - - dirty_i = device->state.changed.vs_const_i; - device->state.changed.vs_const_i = 0; - const_i = &device->state.vs_const_i[0][0]; - - dirty_b = device->state.changed.vs_const_b; - device->state.changed.vs_const_b = 0; - const_b = device->state.vs_const_b; - - lconstf_ranges = device->state.vs->lconstf.ranges; - lconstf_data = device->state.vs->lconstf.data; - - device->state.changed.group &= ~NINE_STATE_VS_CONST; - } else { - DBG("PS\n"); - /* features only implemented on the userbuf path */ - if (device->state.ps->bumpenvmat_needed || ( - device->state.ps->byte_code.version < 0x30 && - device->state.rs[D3DRS_FOGENABLE])) { - device->prefer_user_constbuf = TRUE; - prepare_ps_constants_userbuf(device); - return; - } - buf = device->constbuf_ps; - - const_f = device->state.ps_const_f; - for (p = r = device->state.changed.ps_const_f; r; p = r, r = r->next) - DO_UPLOAD_CONST_F(buf, r->bgn, r->end - r->bgn, const_f); - if (p) { - nine_range_pool_put_chain(&device->range_pool, - device->state.changed.ps_const_f, p); - device->state.changed.ps_const_f = NULL; - } - - dirty_i = device->state.changed.ps_const_i; - device->state.changed.ps_const_i = 0; - const_i = &device->state.ps_const_i[0][0]; - - dirty_b = device->state.changed.ps_const_b; - device->state.changed.ps_const_b = 0; - const_b = device->state.ps_const_b; - - lconstf_ranges = NULL; - lconstf_data = NULL; - - device->state.changed.group &= ~NINE_STATE_PS_CONST; - } - - /* write range from min to max changed, it's not much data */ - /* bool1 */ - if (dirty_b) { - c = util_last_bit(dirty_b); - i = ffs(dirty_b) - 1; - x = buf->width0 - (NINE_MAX_CONST_B - i) * 4; - c -= i; - memcpy(data_b, &(const_b[i]), c * sizeof(uint32_t)); - box.x = x; - box.width = c * 4; - DBG("upload ConstantB [%u .. %u]\n", x, x + c - 1); - pipe->buffer_subdata(pipe, buf, usage, box.x, box.width, data_b); - } - - /* int4 */ - for (c = 0, i = 0; dirty_i; i++, dirty_i >>= 1) { - if (dirty_i & 1) { - if (!c) - x = i; - ++c; - } else - if (c) { - DBG("upload ConstantI [%u .. %u]\n", x, x + c - 1); - data = &const_i[x * 4]; - box.x = buf->width0 - (NINE_MAX_CONST_I * 4 + NINE_MAX_CONST_B) * 4; - box.x += x * 4 * sizeof(int); - box.width = c * 4 * sizeof(int); - c = 0; - pipe->buffer_subdata(pipe, buf, usage, box.x, box.width, data); - } - } - if (c) { - DBG("upload ConstantI [%u .. %u]\n", x, x + c - 1); - data = &const_i[x * 4]; - box.x = buf->width0 - (NINE_MAX_CONST_I * 4 + NINE_MAX_CONST_B) * 4; - box.x += x * 4 * sizeof(int); - box.width = c * 4 * sizeof(int); - pipe->buffer_subdata(pipe, buf, usage, box.x, box.width, data); - } - - /* TODO: only upload these when shader itself changes */ - if (lconstf_ranges) { - unsigned n = 0; - struct nine_range *r = lconstf_ranges; - while (r) { - box.x = r->bgn * 4 * sizeof(float); - n += r->end - r->bgn; - box.width = (r->end - r->bgn) * 4 * sizeof(float); - data = &lconstf_data[4 * n]; - pipe->buffer_subdata(pipe, buf, usage, box.x, box.width, data); - r = r->next; - } - } -} - static void prepare_vs_constants_userbuf(struct NineDevice9 *device) { @@ -1026,17 +875,10 @@ nine_update_state(struct NineDevice9 *device) prepare_rasterizer(device); if (group & (NINE_STATE_TEXTURE | NINE_STATE_SAMPLER)) update_textures_and_samplers(device); - if (device->prefer_user_constbuf) { - if ((group & (NINE_STATE_VS_CONST | NINE_STATE_VS)) && state->programmable_vs) - prepare_vs_constants_userbuf(device); - if ((group & (NINE_STATE_PS_CONST | NINE_STATE_PS)) && state->ps) - prepare_ps_constants_userbuf(device); - } else { - if ((group & NINE_STATE_VS_CONST) && state->programmable_vs) - upload_constants(device, PIPE_SHADER_VERTEX); - if ((group & NINE_STATE_PS_CONST) && state->ps) - upload_constants(device, PIPE_SHADER_FRAGMENT); - } + if ((group & (NINE_STATE_VS_CONST | NINE_STATE_VS)) && state->programmable_vs) + prepare_vs_constants_userbuf(device); + if ((group & (NINE_STATE_PS_CONST | NINE_STATE_PS)) && state->ps) + prepare_ps_constants_userbuf(device); } if (state->changed.vtxbuf) @@ -1317,23 +1159,6 @@ nine_state_set_defaults(struct NineDevice9 *device, const D3DCAPS9 *caps, state->dummy_vbo_bound_at = -1; state->vbo_bound_done = FALSE; } - - if (!device->prefer_user_constbuf) { - /* fill cb_vs and cb_ps for the non user constbuf path */ - struct pipe_constant_buffer cb; - - cb.buffer_offset = 0; - cb.buffer_size = device->vs_const_size; - cb.buffer = device->constbuf_vs; - cb.user_buffer = NULL; - state->pipe.cb_vs = cb; - - cb.buffer_size = device->ps_const_size; - cb.buffer = device->constbuf_ps; - state->pipe.cb_ps = cb; - - state->commit |= NINE_STATE_COMMIT_CONST_VS | NINE_STATE_COMMIT_CONST_PS; - } } void -- 2.30.2