<div dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 26, 2016 at 12:31 AM, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">commit 7c8dfa78b98a12c1c5 (i965/draw: Use the real size for vertex<br>
buffers) changed how we programmed the VERTEX_BUFFER_STATE size field.<br>
<br>
Previously, we programmed it to the size of the actual underlying BO,<br>
which is page-aligned, and potentially much larger than the GL buffer<br>
object. This violated the ARB_robust_buffer_access spec.<br>
<br>
With that change, we started programming it based on the range of data<br>
we expect the draw call to actually access - which is based on the<br>
min_index and max_index information provided to glDrawRangeElements().<br>
<br>
Unfortunately, applications often provide inaccurate range information<br>
to glDrawRangeElements(). For example, all the Unreal demos appear to<br>
draw using a range of [0, 3] when the index buffer's actual index range<br>
is [0, 5]. Such results are undefined, and we are absolutely allowed<br>
to restrict access to the range they specified. However, the failure<br>
mode is usually that nothing draws, or misrendering with wild geometry,<br>
which is kind of bad for a common mistake. And people tend to assume<br>
the range information isn't that important when data is in VBOs.<br>
<br>
There's no real advantage, either. ARB_robust_buffer_access only<br>
requires us to restrict access to the GL buffer object size, not<br>
the range of data we think they should access. Doing that allows<br>
buggy applications to still function. (Note that we still use this<br>
information for busy-tracking, so if they try to overwrite the data<br>
with glBufferSubData, they'll still hit a bug.) This seems to be<br>
safer.<br>
<br>
We may want to provide the more strict range as a debug option,<br>
or scan the VBO and warn against bogus glDrawRangeElements in<br>
debug contexts. That can be done as a later patch, though.<br>
<br>
Makes Unreal demos draw again.<br>
<br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
---<br>
src/mesa/drivers/dri/i965/brw_draw_upload.c | 3 +--<br>
1 file changed, 1 insertion(+), 2 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c<br>
index f4d1b2c..bfe20c5 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c<br>
@@ -543,6 +543,7 @@ brw_prepare_vertices(struct brw_context *brw)<br>
buffer->offset = offset;<br>
buffer->stride = glarray->StrideB;<br>
buffer->step_rate = glarray->InstanceDivisor;<br>
+ buffer->size = glarray->BufferObj->Size - offset;<br>
<br>
enabled_buffer[j] = intel_buffer;<br>
buffer_range_start[j] = start;<br>
@@ -610,8 +611,6 @@ brw_prepare_vertices(struct brw_context *brw)<br>
<br>
buffer->bo = intel_bufferobj_buffer(brw, enabled_buffer[i], start, range);<br>
drm_intel_bo_reference(buffer->bo);<br>
-<br>
- buffer->size = start + range;<br>
}<br>
<br>
/* If we need to upload all the arrays, then we can trim those arrays to<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.8.2<br>
<br>
</font></span></blockquote></div><br></div>