summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/drivers/r300/r300_render.c
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2018-10-23 06:36:00 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2018-10-23 06:36:00 +0000
commitb65fcab046d3a1b6b6ac315720df220925c5322e (patch)
treeff73dcc383ac0799c655ff6194cda9dacb75dde9 /lib/mesa/src/gallium/drivers/r300/r300_render.c
parent18d6381c51e253e4c41c62619f80d9ce745b95c8 (diff)
Merge Mesa 17.3.9
Mesa 18.x needs an ld with build-id for at least the intel code Mesa 18.2 assumes linux only memfd syscalls in intel code Tested by matthieu@, kettenis@ and myself on a variety of hardware and architectures. ok kettenis@
Diffstat (limited to 'lib/mesa/src/gallium/drivers/r300/r300_render.c')
-rw-r--r--lib/mesa/src/gallium/drivers/r300/r300_render.c77
1 files changed, 48 insertions, 29 deletions
diff --git a/lib/mesa/src/gallium/drivers/r300/r300_render.c b/lib/mesa/src/gallium/drivers/r300/r300_render.c
index ad0f48961..4cae76603 100644
--- a/lib/mesa/src/gallium/drivers/r300/r300_render.c
+++ b/lib/mesa/src/gallium/drivers/r300/r300_render.c
@@ -373,7 +373,7 @@ static void r300_draw_arrays_immediate(struct r300_context *r300,
/* Map the buffer. */
if (!map[vbi]) {
map[vbi] = (uint32_t*)r300->rws->buffer_map(
- r300_resource(vbuf->buffer)->buf,
+ r300_resource(vbuf->buffer.resource)->buf,
r300->cs, PIPE_TRANSFER_READ | PIPE_TRANSFER_UNSYNCHRONIZED);
map[vbi] += (vbuf->buffer_offset / 4) + stride[i] * info->start;
}
@@ -501,7 +501,7 @@ static void r300_draw_elements_immediate(struct r300_context *r300,
const uint8_t *ptr1;
const uint16_t *ptr2;
const uint32_t *ptr4;
- unsigned index_size = r300->index_buffer.index_size;
+ unsigned index_size = info->index_size;
unsigned i, count_dwords = index_size == 4 ? info->count :
(info->count + 1) / 2;
CS_LOCALS(r300);
@@ -519,7 +519,7 @@ static void r300_draw_elements_immediate(struct r300_context *r300,
switch (index_size) {
case 1:
- ptr1 = (uint8_t*)r300->index_buffer.user_buffer;
+ ptr1 = (uint8_t*)info->index.user;
ptr1 += info->start;
OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (info->count << 16) |
@@ -543,7 +543,7 @@ static void r300_draw_elements_immediate(struct r300_context *r300,
break;
case 2:
- ptr2 = (uint16_t*)r300->index_buffer.user_buffer;
+ ptr2 = (uint16_t*)info->index.user;
ptr2 += info->start;
OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (info->count << 16) |
@@ -562,7 +562,7 @@ static void r300_draw_elements_immediate(struct r300_context *r300,
break;
case 4:
- ptr4 = (uint32_t*)r300->index_buffer.user_buffer;
+ ptr4 = (uint32_t*)info->index.user;
ptr4 += info->start;
OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (info->count << 16) |
@@ -584,8 +584,9 @@ static void r300_draw_elements(struct r300_context *r300,
const struct pipe_draw_info *info,
int instance_id)
{
- struct pipe_resource *indexBuffer = r300->index_buffer.buffer;
- unsigned indexSize = r300->index_buffer.index_size;
+ struct pipe_resource *indexBuffer =
+ info->has_user_indices ? NULL : info->index.resource;
+ unsigned indexSize = info->index_size;
struct pipe_resource* orgIndexBuffer = indexBuffer;
unsigned start = info->start;
unsigned count = info->count;
@@ -600,7 +601,7 @@ static void r300_draw_elements(struct r300_context *r300,
&index_offset);
}
- r300_translate_index_buffer(r300, &r300->index_buffer, &indexBuffer,
+ r300_translate_index_buffer(r300, info, &indexBuffer,
&indexSize, index_offset, &start, count);
/* Fallback for misaligned ushort indices. */
@@ -621,10 +622,10 @@ static void r300_draw_elements(struct r300_context *r300,
count, (uint8_t*)ptr);
}
} else {
- if (r300->index_buffer.user_buffer)
+ if (info->has_user_indices)
r300_upload_index_buffer(r300, &indexBuffer, indexSize,
&start, count,
- r300->index_buffer.user_buffer);
+ info->index.user);
}
/* 19 dwords for emit_draw_elements. Give up if the function fails. */
@@ -741,13 +742,13 @@ static unsigned r300_max_vertex_count(struct r300_context *r300)
unsigned size, max_count, value;
/* We're not interested in constant and per-instance attribs. */
- if (!vb->buffer ||
+ if (!vb->buffer.resource ||
!vb->stride ||
velems[i].instance_divisor) {
continue;
}
- size = vb->buffer->width0;
+ size = vb->buffer.resource->width0;
/* Subtract buffer_offset. */
value = vb->buffer_offset;
@@ -792,7 +793,7 @@ static void r300_draw_vbo(struct pipe_context* pipe,
r300_update_derived_state(r300);
/* Draw. */
- if (info.indexed) {
+ if (info.index_size) {
unsigned max_count = r300_max_vertex_count(r300);
if (!max_count) {
@@ -807,11 +808,9 @@ static void r300_draw_vbo(struct pipe_context* pipe,
}
info.max_index = max_count - 1;
- info.start += r300->index_buffer.offset / r300->index_buffer.index_size;
if (info.instance_count <= 1) {
- if (info.count <= 8 &&
- r300->index_buffer.user_buffer) {
+ if (info.count <= 8 && info.has_user_indices) {
r300_draw_elements_immediate(r300, &info);
} else {
r300_draw_elements(r300, &info, -1);
@@ -847,6 +846,17 @@ static void r300_swtcl_draw_vbo(struct pipe_context* pipe,
return;
}
+ if (!u_trim_pipe_prim(info->mode, (unsigned*)&info->count))
+ return;
+
+ if (info->index_size) {
+ draw_set_indexes(r300->draw,
+ info->has_user_indices ?
+ info->index.user :
+ r300_resource(info->index.resource)->malloced_buffer,
+ info->index_size, ~0);
+ }
+
r300_update_derived_state(r300);
draw_vbo(r300->draw, info);
@@ -1103,10 +1113,12 @@ struct draw_stage* r300_draw_stage(struct r300_context* r300)
* would be computed and stored twice, which makes the clear/copy codepaths
* somewhat inefficient. Instead we use a rectangular point sprite. */
void r300_blitter_draw_rectangle(struct blitter_context *blitter,
+ void *vertex_elements_cso,
+ blitter_get_vs_func get_vs,
int x1, int y1, int x2, int y2,
- float depth,
+ float depth, unsigned num_instances,
enum blitter_attrib_type type,
- const union pipe_color_union *attrib)
+ const union blitter_attrib *attrib)
{
struct r300_context *r300 = r300_context(util_blitter_get_pipe(blitter));
unsigned last_sprite_coord_enable = r300->sprite_coord_enable;
@@ -1115,21 +1127,28 @@ void r300_blitter_draw_rectangle(struct blitter_context *blitter,
unsigned vertex_size =
type == UTIL_BLITTER_ATTRIB_COLOR || !r300->draw ? 8 : 4;
unsigned dwords = 13 + vertex_size +
- (type == UTIL_BLITTER_ATTRIB_TEXCOORD ? 7 : 0);
- static const union pipe_color_union zeros;
+ (type == UTIL_BLITTER_ATTRIB_TEXCOORD_XY ? 7 : 0);
+ static const union blitter_attrib zeros;
CS_LOCALS(r300);
/* XXX workaround for a lockup in MSAA resolve on SWTCL chipsets, this
* function most probably doesn't handle type=NONE correctly */
- if (!r300->screen->caps.has_tcl && type == UTIL_BLITTER_ATTRIB_NONE) {
- util_blitter_draw_rectangle(blitter, x1, y1, x2, y2, depth, type, attrib);
+ if ((!r300->screen->caps.has_tcl && type == UTIL_BLITTER_ATTRIB_NONE) ||
+ type == UTIL_BLITTER_ATTRIB_TEXCOORD_XYZW ||
+ num_instances > 1) {
+ util_blitter_draw_rectangle(blitter, vertex_elements_cso, get_vs,
+ x1, y1, x2, y2,
+ depth, num_instances, type, attrib);
return;
}
if (r300->skip_rendering)
return;
- if (type == UTIL_BLITTER_ATTRIB_TEXCOORD)
+ r300->context.bind_vertex_elements_state(&r300->context, vertex_elements_cso);
+ r300->context.bind_vs_state(&r300->context, get_vs(blitter));
+
+ if (type == UTIL_BLITTER_ATTRIB_TEXCOORD_XY)
r300->sprite_coord_enable = 1;
r300_update_derived_state(r300);
@@ -1146,15 +1165,15 @@ void r300_blitter_draw_rectangle(struct blitter_context *blitter,
/* Set up GA. */
OUT_CS_REG(R300_GA_POINT_SIZE, (height * 6) | ((width * 6) << 16));
- if (type == UTIL_BLITTER_ATTRIB_TEXCOORD) {
+ if (type == UTIL_BLITTER_ATTRIB_TEXCOORD_XY) {
/* Set up the GA to generate texcoords. */
OUT_CS_REG(R300_GB_ENABLE, R300_GB_POINT_STUFF_ENABLE |
(R300_GB_TEX_STR << R300_GB_TEX0_SOURCE_SHIFT));
OUT_CS_REG_SEQ(R300_GA_POINT_S0, 4);
- OUT_CS_32F(attrib->f[0]);
- OUT_CS_32F(attrib->f[3]);
- OUT_CS_32F(attrib->f[2]);
- OUT_CS_32F(attrib->f[1]);
+ OUT_CS_32F(attrib->texcoord.x1);
+ OUT_CS_32F(attrib->texcoord.y2);
+ OUT_CS_32F(attrib->texcoord.x2);
+ OUT_CS_32F(attrib->texcoord.y1);
}
/* Set up VAP controls. */
@@ -1178,7 +1197,7 @@ void r300_blitter_draw_rectangle(struct blitter_context *blitter,
if (vertex_size == 8) {
if (!attrib)
attrib = &zeros;
- OUT_CS_TABLE(attrib->f, 4);
+ OUT_CS_TABLE(attrib->color, 4);
}
END_CS;