mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 04:50:11 +01:00
mesa: move primitive restart enablement determination from st/mesa to main
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7441>
This commit is contained in:
parent
6dd8b6518e
commit
52c20a6eea
9 changed files with 43 additions and 45 deletions
|
|
@ -149,7 +149,7 @@ brw_handle_primitive_restart(struct gl_context *ctx,
|
||||||
/* If PrimitiveRestart is not enabled, then we aren't concerned about
|
/* If PrimitiveRestart is not enabled, then we aren't concerned about
|
||||||
* handling this draw.
|
* handling this draw.
|
||||||
*/
|
*/
|
||||||
if (!(ctx->Array._PrimitiveRestart)) {
|
if (!ctx->Array._PrimitiveRestart[ib->index_size_shift]) {
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -903,7 +903,7 @@ genX(upload_cut_index)(struct brw_context *brw)
|
||||||
const struct gl_context *ctx = &brw->ctx;
|
const struct gl_context *ctx = &brw->ctx;
|
||||||
|
|
||||||
brw_batch_emit(brw, GENX(3DSTATE_VF), vf) {
|
brw_batch_emit(brw, GENX(3DSTATE_VF), vf) {
|
||||||
if (ctx->Array._PrimitiveRestart && brw->ib.ib) {
|
if (ctx->Array._PrimitiveRestart[brw->ib.ib->index_size_shift] && brw->ib.ib) {
|
||||||
vf.IndexedDrawCutIndexEnable = true;
|
vf.IndexedDrawCutIndexEnable = true;
|
||||||
vf.CutIndex = ctx->Array._RestartIndex[brw->ib.index_size - 1];
|
vf.CutIndex = ctx->Array._RestartIndex[brw->ib.index_size - 1];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1610,8 +1610,9 @@ copy_array_attrib(struct gl_context *ctx,
|
||||||
dest->LockCount = src->LockCount;
|
dest->LockCount = src->LockCount;
|
||||||
dest->PrimitiveRestart = src->PrimitiveRestart;
|
dest->PrimitiveRestart = src->PrimitiveRestart;
|
||||||
dest->PrimitiveRestartFixedIndex = src->PrimitiveRestartFixedIndex;
|
dest->PrimitiveRestartFixedIndex = src->PrimitiveRestartFixedIndex;
|
||||||
dest->_PrimitiveRestart = src->_PrimitiveRestart;
|
|
||||||
dest->RestartIndex = src->RestartIndex;
|
dest->RestartIndex = src->RestartIndex;
|
||||||
|
memcpy(dest->_PrimitiveRestart, src->_PrimitiveRestart,
|
||||||
|
sizeof(src->_PrimitiveRestart));
|
||||||
memcpy(dest->_RestartIndex, src->_RestartIndex, sizeof(src->_RestartIndex));
|
memcpy(dest->_RestartIndex, src->_RestartIndex, sizeof(src->_RestartIndex));
|
||||||
/* skip NewState */
|
/* skip NewState */
|
||||||
/* skip RebindArrays */
|
/* skip RebindArrays */
|
||||||
|
|
|
||||||
|
|
@ -47,11 +47,31 @@
|
||||||
void
|
void
|
||||||
_mesa_update_derived_primitive_restart_state(struct gl_context *ctx)
|
_mesa_update_derived_primitive_restart_state(struct gl_context *ctx)
|
||||||
{
|
{
|
||||||
ctx->Array._PrimitiveRestart = ctx->Array.PrimitiveRestart ||
|
if (ctx->Array.PrimitiveRestart ||
|
||||||
ctx->Array.PrimitiveRestartFixedIndex;
|
ctx->Array.PrimitiveRestartFixedIndex) {
|
||||||
ctx->Array._RestartIndex[0] = _mesa_primitive_restart_index(ctx, 1);
|
unsigned restart_index[3] = {
|
||||||
ctx->Array._RestartIndex[1] = _mesa_primitive_restart_index(ctx, 2);
|
_mesa_primitive_restart_index(ctx, 1),
|
||||||
ctx->Array._RestartIndex[3] = _mesa_primitive_restart_index(ctx, 4);
|
_mesa_primitive_restart_index(ctx, 2),
|
||||||
|
_mesa_primitive_restart_index(ctx, 4),
|
||||||
|
};
|
||||||
|
|
||||||
|
ctx->Array._RestartIndex[0] = restart_index[0];
|
||||||
|
ctx->Array._RestartIndex[1] = restart_index[1];
|
||||||
|
ctx->Array._RestartIndex[3] = restart_index[2];
|
||||||
|
|
||||||
|
/* Enable primitive restart only when the restart index can have an
|
||||||
|
* effect. This is required for correctness in AMD GFX8 support.
|
||||||
|
* Other hardware may also benefit from taking a faster, non-restart path
|
||||||
|
* when possible.
|
||||||
|
*/
|
||||||
|
ctx->Array._PrimitiveRestart[0] = true && restart_index[0] <= UINT8_MAX;
|
||||||
|
ctx->Array._PrimitiveRestart[1] = true && restart_index[1] <= UINT16_MAX;
|
||||||
|
ctx->Array._PrimitiveRestart[2] = true;
|
||||||
|
} else {
|
||||||
|
ctx->Array._PrimitiveRestart[0] = false;
|
||||||
|
ctx->Array._PrimitiveRestart[1] = false;
|
||||||
|
ctx->Array._PrimitiveRestart[2] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1631,7 +1631,7 @@ struct gl_array_attrib
|
||||||
/*@{*/
|
/*@{*/
|
||||||
GLboolean PrimitiveRestart;
|
GLboolean PrimitiveRestart;
|
||||||
GLboolean PrimitiveRestartFixedIndex;
|
GLboolean PrimitiveRestartFixedIndex;
|
||||||
GLboolean _PrimitiveRestart;
|
GLboolean _PrimitiveRestart[3]; /**< Enable indexed by index_size_shift. */
|
||||||
GLuint RestartIndex;
|
GLuint RestartIndex;
|
||||||
GLuint _RestartIndex[4]; /**< Restart indices for index_size - 1. */
|
GLuint _RestartIndex[4]; /**< Restart indices for index_size - 1. */
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
|
||||||
|
|
@ -69,28 +69,6 @@
|
||||||
#include "cso_cache/cso_context.h"
|
#include "cso_cache/cso_context.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the restart index.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
setup_primitive_restart(struct gl_context *ctx, struct pipe_draw_info *info)
|
|
||||||
{
|
|
||||||
if (ctx->Array._PrimitiveRestart) {
|
|
||||||
unsigned index_size = info->index_size;
|
|
||||||
|
|
||||||
info->restart_index = ctx->Array._RestartIndex[index_size - 1];
|
|
||||||
|
|
||||||
/* Enable primitive restart only when the restart index can have an
|
|
||||||
* effect. This is required for correctness in radeonsi GFX8 support.
|
|
||||||
* Other hardware may also benefit from taking a faster, non-restart path
|
|
||||||
* when possible.
|
|
||||||
*/
|
|
||||||
if (index_size == 4 || info->restart_index < (1 << (index_size * 8)))
|
|
||||||
info->primitive_restart = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translate OpenGL primtive type (GL_POINTS, GL_TRIANGLE_STRIP, etc) to
|
* Translate OpenGL primtive type (GL_POINTS, GL_TRIANGLE_STRIP, etc) to
|
||||||
* the corresponding Gallium type.
|
* the corresponding Gallium type.
|
||||||
|
|
@ -214,7 +192,8 @@ st_draw_vbo(struct gl_context *ctx,
|
||||||
info.index.user = ib->ptr;
|
info.index.user = ib->ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_primitive_restart(ctx, &info);
|
info.restart_index = ctx->Array._RestartIndex[info.index_size - 1];
|
||||||
|
info.primitive_restart = ctx->Array._PrimitiveRestart[ib->index_size_shift];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
info.index_size = 0;
|
info.index_size = 0;
|
||||||
|
|
@ -287,8 +266,8 @@ st_indirect_draw_vbo(struct gl_context *ctx,
|
||||||
info.index.resource = st_buffer_object(bufobj)->buffer;
|
info.index.resource = st_buffer_object(bufobj)->buffer;
|
||||||
draw.start = pointer_to_offset(ib->ptr) >> ib->index_size_shift;
|
draw.start = pointer_to_offset(ib->ptr) >> ib->index_size_shift;
|
||||||
|
|
||||||
/* Primitive restart is not handled by the VBO module in this case. */
|
info.restart_index = ctx->Array._RestartIndex[info.index_size - 1];
|
||||||
setup_primitive_restart(ctx, &info);
|
info.primitive_restart = ctx->Array._PrimitiveRestart[ib->index_size_shift];
|
||||||
}
|
}
|
||||||
|
|
||||||
info.mode = translate_prim(ctx, mode);
|
info.mode = translate_prim(ctx, mode);
|
||||||
|
|
|
||||||
|
|
@ -213,10 +213,8 @@ st_feedback_draw_vbo(struct gl_context *ctx,
|
||||||
(ubyte *) mapped_indices,
|
(ubyte *) mapped_indices,
|
||||||
index_size, ~0);
|
index_size, ~0);
|
||||||
|
|
||||||
if (ctx->Array._PrimitiveRestart) {
|
info.primitive_restart = ctx->Array._PrimitiveRestart[ib->index_size_shift];
|
||||||
info.primitive_restart = true;
|
info.restart_index = ctx->Array._RestartIndex[index_size - 1];
|
||||||
info.restart_index = ctx->Array._RestartIndex[index_size - 1];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
info.index_size = 0;
|
info.index_size = 0;
|
||||||
info.has_user_indices = false;
|
info.has_user_indices = false;
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,7 @@ vbo_get_minmax_index(struct gl_context *ctx,
|
||||||
GLuint *min_index, GLuint *max_index,
|
GLuint *min_index, GLuint *max_index,
|
||||||
const GLuint count)
|
const GLuint count)
|
||||||
{
|
{
|
||||||
const GLboolean restart = ctx->Array._PrimitiveRestart;
|
const GLboolean restart = ctx->Array._PrimitiveRestart[ib->index_size_shift];
|
||||||
const GLuint restartIndex =
|
const GLuint restartIndex =
|
||||||
ctx->Array._RestartIndex[(1 << ib->index_size_shift) - 1];
|
ctx->Array._RestartIndex[(1 << ib->index_size_shift) - 1];
|
||||||
const char *indices;
|
const char *indices;
|
||||||
|
|
|
||||||
|
|
@ -1376,7 +1376,7 @@ _save_OBE_MultiDrawArrays(GLenum mode, const GLint *first,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
array_element(struct gl_context *ctx,
|
array_element(struct gl_context *ctx,
|
||||||
GLint basevertex, GLuint elt, unsigned index_size)
|
GLint basevertex, GLuint elt, unsigned index_size_shift)
|
||||||
{
|
{
|
||||||
/* Section 10.3.5 Primitive Restart:
|
/* Section 10.3.5 Primitive Restart:
|
||||||
* [...]
|
* [...]
|
||||||
|
|
@ -1387,8 +1387,8 @@ array_element(struct gl_context *ctx,
|
||||||
/* If PrimitiveRestart is enabled and the index is the RestartIndex
|
/* If PrimitiveRestart is enabled and the index is the RestartIndex
|
||||||
* then we call PrimitiveRestartNV and return.
|
* then we call PrimitiveRestartNV and return.
|
||||||
*/
|
*/
|
||||||
if (ctx->Array._PrimitiveRestart &&
|
if (ctx->Array._PrimitiveRestart[index_size_shift] &&
|
||||||
elt == ctx->Array._RestartIndex[index_size - 1]) {
|
elt == ctx->Array._RestartIndex[(1 << index_size_shift) - 1]) {
|
||||||
CALL_PrimitiveRestartNV(ctx->CurrentServerDispatch, ());
|
CALL_PrimitiveRestartNV(ctx->CurrentServerDispatch, ());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1442,15 +1442,15 @@ _save_OBE_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case GL_UNSIGNED_BYTE:
|
case GL_UNSIGNED_BYTE:
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
array_element(ctx, basevertex, ((GLubyte *) indices)[i], 1);
|
array_element(ctx, basevertex, ((GLubyte *) indices)[i], 0);
|
||||||
break;
|
break;
|
||||||
case GL_UNSIGNED_SHORT:
|
case GL_UNSIGNED_SHORT:
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
array_element(ctx, basevertex, ((GLushort *) indices)[i], 2);
|
array_element(ctx, basevertex, ((GLushort *) indices)[i], 1);
|
||||||
break;
|
break;
|
||||||
case GL_UNSIGNED_INT:
|
case GL_UNSIGNED_INT:
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
array_element(ctx, basevertex, ((GLuint *) indices)[i], 4);
|
array_element(ctx, basevertex, ((GLuint *) indices)[i], 2);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
_mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(type)");
|
_mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(type)");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue