<p dir="ltr">Buffer range is a property of the binding, not the buffer. What if one buffer is bound twice with diff ranges to diff bindings?</p>
<p dir="ltr">Also please don't make core changes in commits with a driver prefix... I nearly missed this one because it said i965.</p>
<div class="gmail_quote">On Dec 15, 2015 6:52 AM, "Iago Toral Quiroga" <<a href="mailto:itoral@igalia.com">itoral@igalia.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Samuel Iglesias Gonsálvez <<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>><br>
<br>
Commit 5bb5eeea fix a bug indicating that the surfaces should have the<br>
API buffer size. Hovewer it picked the wrong value.<br>
<br>
This patch adds a new variable, which takes into account<br>
glBindBufferRange() values. Fixes the following regressions:<br>
<br>
ES31-CTS.shader_storage_buffer_object.advanced-unsizedArrayLength-cs-std430-vec-bindrangeOffset<br>
ES31-CTS.shader_storage_buffer_object.advanced-unsizedArrayLength-cs-std430-vec-bindrangeSize<br>
<br>
Signed-off-by: Samuel Iglesias Gonsálvez <<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>><br>
---<br>
src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 12 ++++++++----<br>
src/mesa/drivers/dri/i965/intel_buffer_objects.c | 1 +<br>
src/mesa/main/bufferobj.c | 4 +++-<br>
src/mesa/main/mtypes.h | 1 +<br>
4 files changed, 13 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c<br>
index c4ebbf3..9072860 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c<br>
@@ -949,12 +949,14 @@ brw_upload_ubo_surfaces(struct brw_context *brw,<br>
} else {<br>
struct intel_buffer_object *intel_bo =<br>
intel_buffer_object(binding->BufferObject);<br>
+ GLsizeiptrARB size = MIN2(binding->BufferObject->BufferRangeSize,<br>
+ binding->BufferObject->Size - binding->Offset);<br>
drm_intel_bo *bo =<br>
intel_bufferobj_buffer(brw, intel_bo,<br>
binding->Offset,<br>
- binding->BufferObject->Size - binding->Offset);<br>
+ size);<br>
brw_create_constant_surface(brw, bo, binding->Offset,<br>
- binding->BufferObject->Size - binding->Offset,<br>
+ size,<br>
&ubo_surf_offsets[i]);<br>
}<br>
}<br>
@@ -971,12 +973,14 @@ brw_upload_ubo_surfaces(struct brw_context *brw,<br>
} else {<br>
struct intel_buffer_object *intel_bo =<br>
intel_buffer_object(binding->BufferObject);<br>
+ GLsizeiptrARB size = MIN2(binding->BufferObject->BufferRangeSize,<br>
+ binding->BufferObject->Size - binding->Offset);<br>
drm_intel_bo *bo =<br>
intel_bufferobj_buffer(brw, intel_bo,<br>
binding->Offset,<br>
- binding->BufferObject->Size - binding->Offset);<br>
+ size);<br>
brw_create_buffer_surface(brw, bo, binding->Offset,<br>
- binding->BufferObject->Size - binding->Offset,<br>
+ size,<br>
&ssbo_surf_offsets[i]);<br>
}<br>
}<br>
diff --git a/src/mesa/drivers/dri/i965/intel_buffer_objects.c b/src/mesa/drivers/dri/i965/intel_buffer_objects.c<br>
index 7a5b3fc..b26c939 100644<br>
--- a/src/mesa/drivers/dri/i965/intel_buffer_objects.c<br>
+++ b/src/mesa/drivers/dri/i965/intel_buffer_objects.c<br>
@@ -198,6 +198,7 @@ brw_buffer_data(struct gl_context *ctx,<br>
(void) target;<br>
<br>
intel_obj->Base.Size = size;<br>
+ intel_obj->Base.BufferRangeSize = size;<br>
intel_obj->Base.Usage = usage;<br>
intel_obj->Base.StorageFlags = storageFlags;<br>
<br>
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c<br>
index e0639c8..7f42673 100644<br>
--- a/src/mesa/main/bufferobj.c<br>
+++ b/src/mesa/main/bufferobj.c<br>
@@ -43,7 +43,7 @@<br>
#include "glformats.h"<br>
#include "texstore.h"<br>
#include "transformfeedback.h"<br>
-<br>
+#include "macros.h"<br>
<br>
/* Debug flags */<br>
/*#define VBO_DEBUG*/<br>
@@ -2838,6 +2838,7 @@ bind_buffer_range_uniform_buffer(struct gl_context *ctx,<br>
<br>
_mesa_reference_buffer_object(ctx, &ctx->UniformBuffer, bufObj);<br>
bind_uniform_buffer(ctx, index, bufObj, offset, size, GL_FALSE);<br>
+ bufObj->BufferRangeSize = MIN2(size, bufObj->Size);<br>
}<br>
<br>
/**<br>
@@ -2873,6 +2874,7 @@ bind_buffer_range_shader_storage_buffer(struct gl_context *ctx,<br>
<br>
_mesa_reference_buffer_object(ctx, &ctx->ShaderStorageBuffer, bufObj);<br>
bind_shader_storage_buffer(ctx, index, bufObj, offset, size, GL_FALSE);<br>
+ bufObj->BufferRangeSize = MIN2(size, bufObj->Size);<br>
}<br>
<br>
/**<br>
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h<br>
index acacae0..91f9f5e 100644<br>
--- a/src/mesa/main/mtypes.h<br>
+++ b/src/mesa/main/mtypes.h<br>
@@ -1268,6 +1268,7 @@ struct gl_buffer_object<br>
GLenum Usage; /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */<br>
GLbitfield StorageFlags; /**< GL_MAP_PERSISTENT_BIT, etc. */<br>
GLsizeiptrARB Size; /**< Size of buffer storage in bytes */<br>
+ GLsizeiptrARB BufferRangeSize; /**< Amount of data that can be read from or written to, in bytes */<br>
GLubyte *Data; /**< Location of storage either in RAM or VRAM. */<br>
GLboolean DeletePending; /**< true if buffer object is removed from the hash */<br>
GLboolean Written; /**< Ever written to? (for debugging) */<br>
--<br>
1.9.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div>