summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/auxiliary/util/u_prim_restart.c
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2018-01-08 05:41:34 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2018-01-08 05:41:34 +0000
commitc00801de923e125863aaf8180439d59d610b2517 (patch)
treee2896aa2785f3cf2151aeeb3c95fb5cc09a2fe02 /lib/mesa/src/gallium/auxiliary/util/u_prim_restart.c
parentbe30e6efb92db21299b936c0e068e7088941e9c9 (diff)
Revert to Mesa 13.0.6 again.
Corruption has again been reported on Intel hardware running Xorg with the modesetting driver (which uses OpenGL based acceleration instead of SNA acceleration the intel driver defaults to). Reported in various forms on Sandy Bridge (X220), Ivy Bridge (X230) and Haswell (X240). Confirmed to not occur with the intel driver but the xserver was changed to default to the modesetting driver on >= gen4 hardware (except Ironlake). One means of triggering this is to open a large pdf with xpdf on an idle machine and highlight a section of the document. There have been reports of gpu hangs on gen4 intel hardware (T500 with GM45, X61 with 965GM) when starting Xorg as well.
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary/util/u_prim_restart.c')
-rw-r--r--lib/mesa/src/gallium/auxiliary/util/u_prim_restart.c56
1 files changed, 30 insertions, 26 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/util/u_prim_restart.c b/lib/mesa/src/gallium/auxiliary/util/u_prim_restart.c
index 9ff93a7f6..a4d7c1433 100644
--- a/lib/mesa/src/gallium/auxiliary/util/u_prim_restart.c
+++ b/lib/mesa/src/gallium/auxiliary/util/u_prim_restart.c
@@ -39,26 +39,28 @@
*/
enum pipe_error
util_translate_prim_restart_ib(struct pipe_context *context,
- const struct pipe_draw_info *info,
- struct pipe_resource **dst_buffer)
+ struct pipe_index_buffer *src_buffer,
+ struct pipe_resource **dst_buffer,
+ unsigned num_indexes,
+ unsigned restart_index)
{
struct pipe_screen *screen = context->screen;
struct pipe_transfer *src_transfer = NULL, *dst_transfer = NULL;
void *src_map = NULL, *dst_map = NULL;
- const unsigned src_index_size = info->index_size;
+ const unsigned src_index_size = src_buffer->index_size;
unsigned dst_index_size;
/* 1-byte indexes are converted to 2-byte indexes, 4-byte stays 4-byte */
- dst_index_size = MAX2(2, info->index_size);
+ dst_index_size = MAX2(2, src_buffer->index_size);
assert(dst_index_size == 2 || dst_index_size == 4);
/* no user buffers for now */
- assert(!info->has_user_indices);
+ assert(src_buffer->user_buffer == NULL);
/* Create new index buffer */
*dst_buffer = pipe_buffer_create(screen, PIPE_BIND_INDEX_BUFFER,
PIPE_USAGE_STREAM,
- info->count * dst_index_size);
+ num_indexes * dst_index_size);
if (!*dst_buffer)
goto error;
@@ -69,9 +71,9 @@ util_translate_prim_restart_ib(struct pipe_context *context,
goto error;
/* Map original / src index buffer */
- src_map = pipe_buffer_map_range(context, info->index.resource,
- info->start * src_index_size,
- info->count * src_index_size,
+ src_map = pipe_buffer_map_range(context, src_buffer->buffer,
+ src_buffer->offset,
+ num_indexes * src_index_size,
PIPE_TRANSFER_READ,
&src_transfer);
if (!src_map)
@@ -81,16 +83,16 @@ util_translate_prim_restart_ib(struct pipe_context *context,
uint8_t *src = (uint8_t *) src_map;
uint16_t *dst = (uint16_t *) dst_map;
unsigned i;
- for (i = 0; i < info->count; i++) {
- dst[i] = (src[i] == info->restart_index) ? 0xffff : src[i];
+ for (i = 0; i < num_indexes; i++) {
+ dst[i] = (src[i] == restart_index) ? 0xffff : src[i];
}
}
else if (src_index_size == 2 && dst_index_size == 2) {
uint16_t *src = (uint16_t *) src_map;
uint16_t *dst = (uint16_t *) dst_map;
unsigned i;
- for (i = 0; i < info->count; i++) {
- dst[i] = (src[i] == info->restart_index) ? 0xffff : src[i];
+ for (i = 0; i < num_indexes; i++) {
+ dst[i] = (src[i] == restart_index) ? 0xffff : src[i];
}
}
else {
@@ -99,8 +101,8 @@ util_translate_prim_restart_ib(struct pipe_context *context,
unsigned i;
assert(src_index_size == 4);
assert(dst_index_size == 4);
- for (i = 0; i < info->count; i++) {
- dst[i] = (src[i] == info->restart_index) ? 0xffffffff : src[i];
+ for (i = 0; i < num_indexes; i++) {
+ dst[i] = (src[i] == restart_index) ? 0xffffffff : src[i];
}
}
@@ -115,7 +117,7 @@ error:
if (dst_transfer)
pipe_buffer_unmap(context, dst_transfer);
if (*dst_buffer)
- pipe_resource_reference(dst_buffer, NULL);
+ screen->resource_destroy(screen, *dst_buffer);
return PIPE_ERROR_OUT_OF_MEMORY;
}
@@ -175,6 +177,7 @@ add_range(struct range_info *info, unsigned start, unsigned count)
*/
enum pipe_error
util_draw_vbo_without_prim_restart(struct pipe_context *context,
+ const struct pipe_index_buffer *ib,
const struct pipe_draw_info *info)
{
const void *src_map;
@@ -183,15 +186,15 @@ util_draw_vbo_without_prim_restart(struct pipe_context *context,
struct pipe_transfer *src_transfer = NULL;
unsigned i, start, count;
- assert(info->index_size);
+ assert(info->indexed);
assert(info->primitive_restart);
/* Get pointer to the index data */
- if (!info->has_user_indices) {
+ if (ib->buffer) {
/* map the index buffer (only the range we need to scan) */
- src_map = pipe_buffer_map_range(context, info->index.resource,
- info->start * info->index_size,
- info->count * info->index_size,
+ src_map = pipe_buffer_map_range(context, ib->buffer,
+ ib->offset + info->start * ib->index_size,
+ info->count * ib->index_size,
PIPE_TRANSFER_READ,
&src_transfer);
if (!src_map) {
@@ -199,12 +202,13 @@ util_draw_vbo_without_prim_restart(struct pipe_context *context,
}
}
else {
- if (!info->index.user) {
+ if (!ib->user_buffer) {
debug_printf("User-space index buffer is null!");
return PIPE_ERROR_BAD_INPUT;
}
- src_map = (const uint8_t *) info->index.user
- + info->start * info->index_size;
+ src_map = (const uint8_t *) ib->user_buffer
+ + ib->offset
+ + info->start * ib->index_size;
}
#define SCAN_INDEXES(TYPE) \
@@ -227,9 +231,9 @@ util_draw_vbo_without_prim_restart(struct pipe_context *context,
} \
}
- start = 0;
+ start = info->start;
count = 0;
- switch (info->index_size) {
+ switch (ib->index_size) {
case 1:
SCAN_INDEXES(uint8_t);
break;