mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 09:10:11 +01:00
vbo: Remove pedantic warning about 'end' beind out of bounds.
The application supplied [start, end] range is merely a conservative hint of the ranges of index values inside the index buffer. There is no requirement that all vertices in the range [start, end] be referenced. Passing an 'end' value larger than the maximum legal index is perfectly acceptible; applications can legally pass 0xffffffff when they don't have a tighter bound readily available. Thus, the warning doesn't indicate a correctness issue; it could only indicate a performance issue. However, it does not even do that. glDrawRangeElements is designed to optimize non-VBO vertex data uploads by providing an upper bound on the size of buffers a driver would need to allocate. With VBOs, the data is already in an uploaded buffer, so the range doesn't help. The clincher is: we only know _MaxElement for VBOs. For user-space arrays, we just set it to 2,000,000,000 (see mesa/main/varray.h:63.) So we can only check this in the case where it is not useful. Many applications, including the Unigine demos, currently trigger this warning, which suggests the applications are buggy when they're actually fine. Eliminating the warning should confuse users less while not actually losing any benefit to application developers. NOTE: This is a candidate for release branches. Suggested-by: Jose Fonseca <jfonseca@vmware.com> Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Roland Scheidegger <sroland@vmware.com>
This commit is contained in:
parent
e2dce7f7ee
commit
f9be8543aa
1 changed files with 2 additions and 47 deletions
|
|
@ -708,6 +708,7 @@ vbo_exec_DrawArraysInstanced(GLenum mode, GLint start, GLsizei count,
|
||||||
* Map GL_ELEMENT_ARRAY_BUFFER and print contents.
|
* Map GL_ELEMENT_ARRAY_BUFFER and print contents.
|
||||||
* For debugging.
|
* For debugging.
|
||||||
*/
|
*/
|
||||||
|
#if 0
|
||||||
static void
|
static void
|
||||||
dump_element_buffer(struct gl_context *ctx, GLenum type)
|
dump_element_buffer(struct gl_context *ctx, GLenum type)
|
||||||
{
|
{
|
||||||
|
|
@ -759,6 +760,7 @@ dump_element_buffer(struct gl_context *ctx, GLenum type)
|
||||||
|
|
||||||
ctx->Driver.UnmapBuffer(ctx, ctx->Array.ArrayObj->ElementArrayBufferObj);
|
ctx->Driver.UnmapBuffer(ctx, ctx->Array.ArrayObj->ElementArrayBufferObj);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -856,7 +858,6 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
|
||||||
const GLvoid *indices,
|
const GLvoid *indices,
|
||||||
GLint basevertex)
|
GLint basevertex)
|
||||||
{
|
{
|
||||||
static GLuint warnCount = 0;
|
|
||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
|
|
||||||
if (MESA_VERBOSE & VERBOSE_DRAW)
|
if (MESA_VERBOSE & VERBOSE_DRAW)
|
||||||
|
|
@ -886,52 +887,6 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end >= ctx->Array.ArrayObj->_MaxElement) {
|
if (end >= ctx->Array.ArrayObj->_MaxElement) {
|
||||||
/* the max element is out of bounds of one or more enabled arrays */
|
|
||||||
warnCount++;
|
|
||||||
|
|
||||||
if (warnCount < 10) {
|
|
||||||
_mesa_warning(ctx, "glDraw[Range]Elements(start %u, end %u, count %d, "
|
|
||||||
"type 0x%x, indices=%p)\n"
|
|
||||||
"\tend is out of bounds (max=%u) "
|
|
||||||
"Element Buffer %u (size %d)\n"
|
|
||||||
"\tThis should probably be fixed in the application.",
|
|
||||||
start, end, count, type, indices,
|
|
||||||
ctx->Array.ArrayObj->_MaxElement - 1,
|
|
||||||
ctx->Array.ArrayObj->ElementArrayBufferObj->Name,
|
|
||||||
(int) ctx->Array.ArrayObj->ElementArrayBufferObj->Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0)
|
|
||||||
dump_element_buffer(ctx, type);
|
|
||||||
|
|
||||||
if (0)
|
|
||||||
_mesa_print_arrays(ctx);
|
|
||||||
|
|
||||||
/* 'end' was out of bounds, but now let's check the actual array
|
|
||||||
* indexes to see if any of them are out of bounds.
|
|
||||||
*/
|
|
||||||
if (0) {
|
|
||||||
GLuint max = _mesa_max_buffer_index(ctx, count, type, indices,
|
|
||||||
ctx->Array.ArrayObj->ElementArrayBufferObj);
|
|
||||||
if (max >= ctx->Array.ArrayObj->_MaxElement) {
|
|
||||||
if (warnCount < 10) {
|
|
||||||
_mesa_warning(ctx, "glDraw[Range]Elements(start %u, end %u, "
|
|
||||||
"count %d, type 0x%x, indices=%p)\n"
|
|
||||||
"\tindex=%u is out of bounds (max=%u) "
|
|
||||||
"Element Buffer %u (size %d)\n"
|
|
||||||
"\tSkipping the glDrawRangeElements() call",
|
|
||||||
start, end, count, type, indices, max,
|
|
||||||
ctx->Array.ArrayObj->_MaxElement - 1,
|
|
||||||
ctx->Array.ArrayObj->ElementArrayBufferObj->Name,
|
|
||||||
(int) ctx->Array.ArrayObj->ElementArrayBufferObj->Size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* XXX we could also find the min index and compare to 'start'
|
|
||||||
* to see if start is correct. But it's more likely to get the
|
|
||||||
* upper bound wrong.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set 'end' to the max possible legal value */
|
/* Set 'end' to the max possible legal value */
|
||||||
assert(ctx->Array.ArrayObj->_MaxElement >= 1);
|
assert(ctx->Array.ArrayObj->_MaxElement >= 1);
|
||||||
end = ctx->Array.ArrayObj->_MaxElement - 1;
|
end = ctx->Array.ArrayObj->_MaxElement - 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue