<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>> This shouldn't be an issue, since buffers are required to have a 1-byte<br>
format </p>
<p><br>
</p>
<p>Ah OK. I was no longer sure. In that case, I can leave the single code path and put an assert as you suggested.</p>
<div><br>
</div>
Jose<br>
<br>
<div style="color: rgb(0, 0, 0);">
<div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Roland Scheidegger<br>
<b>Sent:</b> Monday, July 24, 2017 16:22<br>
<b>To:</b> Jose Fonseca; mesa-dev@lists.freedesktop.org; Brian Paul; bruce.cherniak@intel.com<br>
<b>Subject:</b> Re: [PATCH] trace: Correct transfer box size calculation.</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">Am 24.07.2017 um 15:26 schrieb Jose Fonseca:<br>
> In particular:<br>
> <br>
> 1) For buffers the box expresses bytes, not pixels.<br>
This shouldn't be an issue, since buffers are required to have a 1-byte<br>
format (usually R8_UINT, but R8_UNORM works too).<br>
(llvmpipe_transfer_map, for instance, will still do all the format dance<br>
for calculating offsets, makes no difference either way.)<br>
<br>
<br>
> <br>
> 2) For textures we must not approximate the calculation with `stride *<br>
> height`, or `slice_stride * depth`, as that can easily lead to buffer<br>
> overflows, particularly for partial transfers.<br>
> <br>
> But this code path is not currently very relevant since the trace<br>
> driver is only dumping data for buffers.<br>
> <br>
> This should address the issue that Bruce Cherniak found and diagnosed.<br>
<br>
<br>
> ---<br>
> src/gallium/drivers/trace/tr_dump.c | 30 +++++++++++++++++-------------<br>
> 1 file changed, 17 insertions(+), 13 deletions(-)<br>
> <br>
> diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c<br>
> index 78c72492dc..aab55644f3 100644<br>
> --- a/src/gallium/drivers/trace/tr_dump.c<br>
> +++ b/src/gallium/drivers/trace/tr_dump.c<br>
> @@ -450,21 +450,25 @@ void trace_dump_box_bytes(const void *data,<br>
> {<br>
> size_t size;<br>
> <br>
> - /*<br>
> - * Only dump buffer transfers to avoid huge files.<br>
> - * TODO: Make this run-time configurable<br>
> - */<br>
> - if (resource->target != PIPE_BUFFER) {<br>
> - size = 0;<br>
> + if (resource->target == PIPE_BUFFER) {<br>
> + /* For buffers the box should be in bytes, regardless of the format.<br>
> + */<br>
So, maybe an assert that format is actually a 1-byte format would make<br>
more sense instead.<br>
<br>
But otherwise, looks great.<br>
Reviewed-by: Roland Scheidegger <sroland@vmware.com><br>
<br>
> + assert(box->height == 1);<br>
> + assert(box->depth == 1);<br>
> + size = box->width;<br>
> } else {<br>
> enum pipe_format format = resource->format;<br>
> - if (slice_stride)<br>
> - size = box->depth * slice_stride;<br>
> - else if (stride)<br>
> - size = util_format_get_nblocksy(format, box->height) * stride;<br>
> - else {<br>
> - size = util_format_get_nblocksx(format, box->width) * util_format_get_blocksize(format);<br>
> - }<br>
> + assert(box->height > 0);<br>
> + assert(box->depth > 0);<br>
> + size = util_format_get_nblocksx(format, box->width ) * util_format_get_blocksize(format)<br>
> + + (util_format_get_nblocksy(format, box->height) - 1) * stride<br>
> + + (box->depth - 1) * slice_stride;<br>
> +<br>
> + /*<br>
> + * Only dump buffer transfers to avoid huge files.<br>
> + * TODO: Make this run-time configurable<br>
> + */<br>
> + size = 0;<br>
> }<br>
> <br>
> trace_dump_bytes(data, size);<br>
> <br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>