Commit e0f93284 authored by Marek Olšák's avatar Marek Olšák

u_upload_mgr: pass alignment to u_upload_data manually

Reviewed-by: default avatarNicolai Hähnle <nicolai.haehnle@amd.com>
parent 020009f7
......@@ -1191,7 +1191,7 @@ static void blitter_draw(struct blitter_context_priv *ctx,
vb.stride = 8 * sizeof(float);
u_upload_data(ctx->upload, 0, sizeof(ctx->vertices), ctx->vertices,
u_upload_data(ctx->upload, 0, sizeof(ctx->vertices), 4, ctx->vertices,
&vb.buffer_offset, &vb.buffer);
if (!vb.buffer)
return;
......@@ -2111,7 +2111,7 @@ void util_blitter_clear_buffer(struct blitter_context *blitter,
return;
}
u_upload_data(ctx->upload, 0, num_channels*4, clear_value,
u_upload_data(ctx->upload, 0, num_channels*4, 4, clear_value,
&vb.buffer_offset, &vb.buffer);
if (!vb.buffer)
goto out;
......
......@@ -243,13 +243,14 @@ u_upload_alloc(struct u_upload_mgr *upload,
void u_upload_data(struct u_upload_mgr *upload,
unsigned min_out_offset,
unsigned size,
unsigned alignment,
const void *data,
unsigned *out_offset,
struct pipe_resource **outbuf)
{
uint8_t *ptr;
u_upload_alloc(upload, min_out_offset, size, upload->alignment,
u_upload_alloc(upload, min_out_offset, size, alignment,
out_offset, outbuf,
(void**)&ptr);
if (ptr)
......@@ -282,6 +283,7 @@ void u_upload_buffer(struct u_upload_mgr *upload,
if (0)
debug_printf("upload ptr %p ofs %d sz %d\n", map, offset, size);
u_upload_data(upload, min_out_offset, size, map, out_offset, outbuf);
u_upload_data(upload, min_out_offset, size, upload->alignment,
map, out_offset, outbuf);
pipe_buffer_unmap( upload->pipe, transfer );
}
......@@ -97,6 +97,7 @@ void u_upload_alloc(struct u_upload_mgr *upload,
void u_upload_data(struct u_upload_mgr *upload,
unsigned min_out_offset,
unsigned size,
unsigned alignment,
const void *data,
unsigned *out_offset,
struct pipe_resource **outbuf);
......
......@@ -987,7 +987,7 @@ u_vbuf_upload_buffers(struct u_vbuf *mgr,
real_vb = &mgr->real_vertex_buffer[i];
ptr = mgr->vertex_buffer[i].user_buffer;
u_upload_data(mgr->uploader, start, end - start, ptr + start,
u_upload_data(mgr->uploader, start, end - start, 4, ptr + start,
&real_vb->buffer_offset, &real_vb->buffer);
if (!real_vb->buffer)
return PIPE_ERROR_OUT_OF_MEMORY;
......
......@@ -92,7 +92,7 @@ ilo_launch_grid(struct pipe_context *pipe,
input_buf.buffer_size =
ilo_shader_get_kernel_param(cs, ILO_KERNEL_CS_INPUT_SIZE);
if (input_buf.buffer_size) {
u_upload_data(ilo->uploader, 0, input_buf.buffer_size, input,
u_upload_data(ilo->uploader, 0, input_buf.buffer_size, 16, input,
&input_buf.buffer_offset, &input_buf.buffer);
}
......
......@@ -376,7 +376,7 @@ finalize_cbuf_state(struct ilo_context *ilo,
if (cbuf->cso[i].resource)
continue;
u_upload_data(ilo->uploader, 0, cbuf->cso[i].info.size,
u_upload_data(ilo->uploader, 0, cbuf->cso[i].info.size, 16,
cbuf->cso[i].user_buffer, &offset, &cbuf->cso[i].resource);
cbuf->cso[i].info.vma = ilo_resource_get_vma(cbuf->cso[i].resource);
......@@ -426,7 +426,7 @@ finalize_index_buffer(struct ilo_context *ilo)
unsigned hw_offset;
if (vec->ib.state.user_buffer) {
u_upload_data(ilo->uploader, 0, size,
u_upload_data(ilo->uploader, 0, size, 16,
vec->ib.state.user_buffer + offset,
&hw_offset, &vec->ib.hw_resource);
} else {
......
......@@ -1010,7 +1010,7 @@ static void r300_render_draw_elements(struct vbuf_render* render,
CS_LOCALS(r300);
DBG(r300, DBG_DRAW, "r300: render_draw_elements (count: %d)\n", count);
u_upload_data(r300->uploader, 0, count * 2, indices,
u_upload_data(r300->uploader, 0, count * 2, 4, indices,
&index_buffer_offset, &index_buffer);
if (!index_buffer) {
return;
......
......@@ -42,7 +42,7 @@ void r300_upload_index_buffer(struct r300_context *r300,
*index_buffer = NULL;
u_upload_data(r300->uploader,
0, count * index_size,
0, count * index_size, 4,
ptr + (*start * index_size),
&index_offset,
index_buffer);
......
......@@ -1106,10 +1106,10 @@ static void r600_set_constant_buffer(struct pipe_context *ctx, uint shader, uint
tmpPtr[i] = util_cpu_to_le32(((uint32_t *)ptr)[i]);
}
u_upload_data(rctx->b.uploader, 0, size, tmpPtr, &cb->buffer_offset, &cb->buffer);
u_upload_data(rctx->b.uploader, 0, size, 256, tmpPtr, &cb->buffer_offset, &cb->buffer);
free(tmpPtr);
} else {
u_upload_data(rctx->b.uploader, 0, input->buffer_size, ptr, &cb->buffer_offset, &cb->buffer);
u_upload_data(rctx->b.uploader, 0, input->buffer_size, 256, ptr, &cb->buffer_offset, &cb->buffer);
}
/* account it in gtt */
rctx->b.gtt += input->buffer_size;
......@@ -1753,7 +1753,7 @@ static void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info
if (ib.user_buffer && (R600_BIG_ENDIAN || info.indirect ||
info.instance_count > 1 ||
info.count*ib.index_size > 20)) {
u_upload_data(rctx->b.uploader, 0, info.count * ib.index_size,
u_upload_data(rctx->b.uploader, 0, info.count * ib.index_size, 256,
ib.user_buffer, &ib.offset, &ib.buffer);
ib.user_buffer = NULL;
}
......
......@@ -842,7 +842,7 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
start_offset = start * ib.index_size;
u_upload_data(sctx->b.uploader, start_offset, count * ib.index_size,
(char*)ib.user_buffer + start_offset,
256, (char*)ib.user_buffer + start_offset,
&ib.offset, &ib.buffer);
if (!ib.buffer)
return;
......
......@@ -319,7 +319,7 @@ vc4_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
if (vc4->indexbuf.user_buffer) {
prsc = NULL;
u_upload_data(vc4->uploader, 0,
info->count * index_size,
info->count * index_size, 4,
vc4->indexbuf.user_buffer,
&offset, &prsc);
} else {
......
......@@ -605,7 +605,7 @@ static void virgl_draw_vbo(struct pipe_context *ctx,
ib.offset = vctx->index_buffer.offset + info.start * ib.index_size;
if (ib.user_buffer) {
u_upload_data(vctx->uploader, 0, info.count * ib.index_size,
u_upload_data(vctx->uploader, 0, info.count * ib.index_size, 256,
ib.user_buffer, &ib.offset, &ib.buffer);
ib.user_buffer = NULL;
}
......
......@@ -397,10 +397,9 @@ NineDevice9_ctor( struct NineDevice9 *This,
if (!This->driver_caps.user_ibufs)
This->index_uploader = u_upload_create(This->pipe, 128 * 1024, 4, PIPE_BIND_INDEX_BUFFER);
if (!This->driver_caps.user_cbufs) {
unsigned alignment = GET_PCAP(CONSTANT_BUFFER_OFFSET_ALIGNMENT);
This->constbuf_alignment = GET_PCAP(CONSTANT_BUFFER_OFFSET_ALIGNMENT);
This->constbuf_uploader = u_upload_create(This->pipe, This->vs_const_size,
alignment, PIPE_BIND_CONSTANT_BUFFER);
This->constbuf_alignment, PIPE_BIND_CONSTANT_BUFFER);
}
This->driver_caps.window_space_position_support = GET_PCAP(TGSI_VS_WINDOW_SPACE_POSITION);
......@@ -2955,6 +2954,7 @@ NineDevice9_DrawPrimitiveUP( struct NineDevice9 *This,
u_upload_data(This->vertex_uploader,
0,
(info.max_index + 1) * VertexStreamZeroStride, /* XXX */
4,
vtxbuf.user_buffer,
&vtxbuf.buffer_offset,
&vtxbuf.buffer);
......@@ -3027,6 +3027,7 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This,
base,
(info.max_index -
info.min_index + 1) * VertexStreamZeroStride, /* XXX */
4,
(const uint8_t *)vbuf.user_buffer + base,
&vbuf.buffer_offset,
&vbuf.buffer);
......@@ -3039,6 +3040,7 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This,
u_upload_data(This->index_uploader,
0,
info.count * ibuf.index_size,
4,
ibuf.user_buffer,
&ibuf.offset,
&ibuf.buffer);
......
......@@ -128,6 +128,7 @@ struct NineDevice9
struct u_upload_mgr *vertex_uploader;
struct u_upload_mgr *index_uploader;
struct u_upload_mgr *constbuf_uploader;
unsigned constbuf_alignment;
struct nine_range_pool range_pool;
......
......@@ -1866,6 +1866,7 @@ nine_ff_update(struct NineDevice9 *device)
u_upload_data(device->constbuf_uploader,
0,
cb.buffer_size,
device->constbuf_alignment,
cb.user_buffer,
&cb.buffer_offset,
&cb.buffer);
......@@ -1888,6 +1889,7 @@ nine_ff_update(struct NineDevice9 *device)
u_upload_data(device->constbuf_uploader,
0,
cb.buffer_size,
device->constbuf_alignment,
cb.user_buffer,
&cb.buffer_offset,
&cb.buffer);
......
......@@ -260,6 +260,7 @@ prepare_vs_constants_userbuf(struct NineDevice9 *device)
u_upload_data(device->constbuf_uploader,
0,
cb.buffer_size,
device->constbuf_alignment,
cb.user_buffer,
&cb.buffer_offset,
&cb.buffer);
......@@ -336,6 +337,7 @@ prepare_ps_constants_userbuf(struct NineDevice9 *device)
u_upload_data(device->constbuf_uploader,
0,
cb.buffer_size,
device->constbuf_alignment,
cb.user_buffer,
&cb.buffer_offset,
&cb.buffer);
......
......@@ -84,6 +84,7 @@ void st_upload_constants( struct st_context *st,
cb.buffer = NULL;
cb.user_buffer = NULL;
u_upload_data(st->constbuf_uploader, 0, paramBytes,
st->ctx->Const.UniformBufferOffsetAlignment,
params->ParameterValues, &cb.buffer_offset, &cb.buffer);
u_upload_unmap(st->constbuf_uploader);
} else {
......
......@@ -107,7 +107,7 @@ setup_index_buffer(struct st_context *st,
else if (st->indexbuf_uploader) {
/* upload indexes from user memory into a real buffer */
u_upload_data(st->indexbuf_uploader, 0,
ib->count * ibuffer->index_size, ib->ptr,
ib->count * ibuffer->index_size, 4, ib->ptr,
&ibuffer->offset, &ibuffer->buffer);
if (!ibuffer->buffer) {
/* out of memory */
......
......@@ -314,10 +314,11 @@ void st_init_limits(struct pipe_screen *screen,
c->GLSLSkipStrictMaxUniformLimitCheck =
screen->get_param(screen, PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS);
c->UniformBufferOffsetAlignment =
screen->get_param(screen, PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT);
if (can_ubo) {
extensions->ARB_uniform_buffer_object = GL_TRUE;
c->UniformBufferOffsetAlignment =
screen->get_param(screen, PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT);
c->MaxCombinedUniformBlocks = c->MaxUniformBufferBindings =
c->Program[MESA_SHADER_VERTEX].MaxUniformBlocks +
c->Program[MESA_SHADER_TESS_CTRL].MaxUniformBlocks +
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment