<div dir="ltr"><div>I don't plan to do anything else if this patch is enough to fix certain 32-bit games.</div><div><br></div><div>Marek<br></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Dec 14, 2018 at 6:10 PM Axel Davy <<a href="mailto:davyaxel0@gmail.com">davyaxel0@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Marek,<br>
<br>
That seems a good idea.<br>
Several 32bits games have virtual address space issues as well with both <br>
Nine and Wine (but Nine seems a bit more affected because more libs are <br>
loaded).<br>
<br>
Maybe the patch could go a little bit further by doing the same for <br>
buffers the first time they si_buffer_transfer_unmap is called for them ?<br>
<br>
I've seen several nine games use a few big buffers (in DEFAULT pool) to <br>
store quite a lot of vertices,<br>
in addition to the buffers frequently written to for rendering.<br>
<br>
Unmapping those big buffers, that we are never going to write to again, <br>
could save a bit of that precious virtual space.<br>
<br>
The safest test I believe, is to look only at buffers that are written <br>
to only once, thus always unmapping on first unmap.<br>
For the buffers often written to, the cost of the first unmap will be <br>
negligible.<br>
<br>
What do you think ?<br>
<br>
Axel<br>
<br>
On 14/12/2018 22:24, Marek Olšák wrote:<br>
> From: Marek Olšák <<a href="mailto:marek.olsak@amd.com" target="_blank">marek.olsak@amd.com</a>><br>
><br>
> Team Fortress 2 32-bit version runs out of the CPU address space.<br>
> ---<br>
> src/gallium/drivers/radeonsi/si_texture.c | 16 ++++++++++++++++<br>
> 1 file changed, 16 insertions(+)<br>
><br>
> diff --git a/src/gallium/drivers/radeonsi/si_texture.c b/src/gallium/drivers/radeonsi/si_texture.c<br>
> index 95f1e8c9693..39869445b0f 100644<br>
> --- a/src/gallium/drivers/radeonsi/si_texture.c<br>
> +++ b/src/gallium/drivers/radeonsi/si_texture.c<br>
> @@ -1791,20 +1791,26 @@ static void *si_texture_transfer_map(struct pipe_context *ctx,<br>
> <br>
> buf = trans->staging;<br>
> } else {<br>
> /* the resource is mapped directly */<br>
> offset = si_texture_get_offset(sctx->screen, tex, level, box,<br>
> &trans->b.b.stride,<br>
> &trans->b.b.layer_stride);<br>
> buf = &tex->buffer;<br>
> }<br>
> <br>
> + /* Always unmap texture CPU mappings on 32-bit architectures, so that<br>
> + * we don't run out of the CPU address space.<br>
> + */<br>
> + if (sizeof(void*) == 4)<br>
> + usage |= RADEON_TRANSFER_TEMPORARY;<br>
> +<br>
> if (!(map = si_buffer_map_sync_with_rings(sctx, buf, usage)))<br>
> goto fail_trans;<br>
> <br>
> *ptransfer = &trans->b.b;<br>
> return map + offset;<br>
> <br>
> fail_trans:<br>
> r600_resource_reference(&trans->staging, NULL);<br>
> pipe_resource_reference(&trans->b.b.resource, NULL);<br>
> FREE(trans);<br>
> @@ -1812,20 +1818,30 @@ fail_trans:<br>
> }<br>
> <br>
> static void si_texture_transfer_unmap(struct pipe_context *ctx,<br>
> struct pipe_transfer* transfer)<br>
> {<br>
> struct si_context *sctx = (struct si_context*)ctx;<br>
> struct si_transfer *stransfer = (struct si_transfer*)transfer;<br>
> struct pipe_resource *texture = transfer->resource;<br>
> struct si_texture *tex = (struct si_texture*)texture;<br>
> <br>
> + /* Always unmap texture CPU mappings on 32-bit architectures, so that<br>
> + * we don't run out of the CPU address space.<br>
> + */<br>
> + if (sizeof(void*) == 4) {<br>
> + struct r600_resource *buf =<br>
> + stransfer->staging ? stransfer->staging : &tex->buffer;<br>
> +<br>
> + sctx->ws->buffer_unmap(buf->buf);<br>
> + }<br>
> +<br>
> if ((transfer->usage & PIPE_TRANSFER_WRITE) && stransfer->staging) {<br>
> if (tex->is_depth && tex->buffer.b.b.nr_samples <= 1) {<br>
> ctx->resource_copy_region(ctx, texture, transfer->level,<br>
> transfer->box.x, transfer->box.y, transfer->box.z,<br>
> &stransfer->staging->b.b, transfer->level,<br>
> &transfer->box);<br>
> } else {<br>
> si_copy_from_staging_texture(ctx, stransfer);<br>
> }<br>
> }<br>
<br>
<br>
</blockquote></div></div>