gallium: change set_constant_buffer to be UBO-friendly
This commit is contained in:
@@ -99,8 +99,8 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
|
||||
dimensions[1] = p->framebuffer.height;
|
||||
}
|
||||
|
||||
p->pipe->set_constant_buffer(p->pipe, PIPE_SHADER_VERTEX, 0, constbuf);
|
||||
p->pipe->set_constant_buffer(p->pipe, PIPE_SHADER_FRAGMENT, 0, constbuf);
|
||||
pipe_set_constant_buffer(p->pipe, PIPE_SHADER_VERTEX, 0, constbuf);
|
||||
pipe_set_constant_buffer(p->pipe, PIPE_SHADER_FRAGMENT, 0, constbuf);
|
||||
|
||||
mstencil.stencil[0].enabled = 1;
|
||||
mstencil.stencil[0].valuemask = mstencil.stencil[0].writemask = ~0;
|
||||
|
@@ -437,6 +437,21 @@ pipe_transfer_destroy( struct pipe_context *context,
|
||||
context->transfer_destroy(context, transfer);
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
pipe_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
|
||||
struct pipe_resource *buf)
|
||||
{
|
||||
if (buf) {
|
||||
struct pipe_constant_buffer cb;
|
||||
cb.buffer = buf;
|
||||
cb.buffer_offset = 0;
|
||||
cb.buffer_size = buf->width0;
|
||||
pipe->set_constant_buffer(pipe, shader, index, &cb);
|
||||
} else {
|
||||
pipe->set_constant_buffer(pipe, shader, index, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static INLINE boolean util_get_offset(
|
||||
const struct pipe_rasterizer_state *templ,
|
||||
|
@@ -1015,7 +1015,7 @@ vl_compositor_render(struct vl_compositor_state *s,
|
||||
c->pipe->bind_vs_state(c->pipe, c->vs);
|
||||
c->pipe->set_vertex_buffers(c->pipe, 1, &c->vertex_buf);
|
||||
c->pipe->bind_vertex_elements_state(c->pipe, c->vertex_elems_state);
|
||||
c->pipe->set_constant_buffer(c->pipe, PIPE_SHADER_FRAGMENT, 0, s->csc_matrix);
|
||||
pipe_set_constant_buffer(c->pipe, PIPE_SHADER_FRAGMENT, 0, s->csc_matrix);
|
||||
c->pipe->bind_rasterizer_state(c->pipe, c->rast);
|
||||
|
||||
draw_layers(c, s, dirty_area);
|
||||
|
@@ -458,12 +458,11 @@ static void
|
||||
galahad_set_constant_buffer(struct pipe_context *_pipe,
|
||||
uint shader,
|
||||
uint index,
|
||||
struct pipe_resource *_resource)
|
||||
struct pipe_constant_buffer *_cb)
|
||||
{
|
||||
struct galahad_context *glhd_pipe = galahad_context(_pipe);
|
||||
struct pipe_context *pipe = glhd_pipe->pipe;
|
||||
struct pipe_resource *unwrapped_resource;
|
||||
struct pipe_resource *resource = NULL;
|
||||
struct pipe_constant_buffer cb;
|
||||
|
||||
if (shader >= PIPE_SHADER_TYPES) {
|
||||
glhd_error("Unknown shader type %u", shader);
|
||||
@@ -479,15 +478,15 @@ galahad_set_constant_buffer(struct pipe_context *_pipe,
|
||||
}
|
||||
|
||||
/* XXX hmm? unwrap the input state */
|
||||
if (_resource) {
|
||||
unwrapped_resource = galahad_resource_unwrap(_resource);
|
||||
resource = unwrapped_resource;
|
||||
if (_cb) {
|
||||
cb = *_cb;
|
||||
cb.buffer = galahad_resource_unwrap(_cb->buffer);
|
||||
}
|
||||
|
||||
pipe->set_constant_buffer(pipe,
|
||||
shader,
|
||||
index,
|
||||
resource);
|
||||
_cb ? &cb : NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -665,9 +665,10 @@ static void i915_delete_vs_state(struct pipe_context *pipe, void *shader)
|
||||
|
||||
static void i915_set_constant_buffer(struct pipe_context *pipe,
|
||||
uint shader, uint index,
|
||||
struct pipe_resource *buf)
|
||||
struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct i915_context *i915 = i915_context(pipe);
|
||||
struct pipe_resource *buf = cb ? cb->buffer : NULL;
|
||||
unsigned new_num = 0;
|
||||
boolean diff = TRUE;
|
||||
|
||||
|
@@ -411,23 +411,22 @@ static void
|
||||
identity_set_constant_buffer(struct pipe_context *_pipe,
|
||||
uint shader,
|
||||
uint index,
|
||||
struct pipe_resource *_resource)
|
||||
struct pipe_constant_buffer *_cb)
|
||||
{
|
||||
struct identity_context *id_pipe = identity_context(_pipe);
|
||||
struct pipe_context *pipe = id_pipe->pipe;
|
||||
struct pipe_resource *unwrapped_resource;
|
||||
struct pipe_resource *resource = NULL;
|
||||
struct pipe_constant_buffer cb;
|
||||
|
||||
/* XXX hmm? unwrap the input state */
|
||||
if (_resource) {
|
||||
unwrapped_resource = identity_resource_unwrap(_resource);
|
||||
resource = unwrapped_resource;
|
||||
if (_cb) {
|
||||
cb = *_cb;
|
||||
cb.buffer = identity_resource_unwrap(_cb->buffer);
|
||||
}
|
||||
|
||||
pipe->set_constant_buffer(pipe,
|
||||
shader,
|
||||
index,
|
||||
resource);
|
||||
_cb ? &cb : NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -1169,9 +1169,10 @@ llvmpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
|
||||
static void
|
||||
llvmpipe_set_constant_buffer(struct pipe_context *pipe,
|
||||
uint shader, uint index,
|
||||
struct pipe_resource *constants)
|
||||
struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
|
||||
struct pipe_resource *constants = cb ? cb->buffer : NULL;
|
||||
unsigned size = constants ? constants->width0 : 0;
|
||||
const void *data = constants ? llvmpipe_resource_data(constants) : NULL;
|
||||
|
||||
|
@@ -175,7 +175,7 @@ static void noop_set_framebuffer_state(struct pipe_context *ctx,
|
||||
|
||||
static void noop_set_constant_buffer(struct pipe_context *ctx,
|
||||
uint shader, uint index,
|
||||
struct pipe_resource *buffer)
|
||||
struct pipe_constant_buffer *cb)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -317,9 +317,10 @@ nv30_set_sample_mask(struct pipe_context *pipe, unsigned sample_mask)
|
||||
|
||||
static void
|
||||
nv30_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
|
||||
struct pipe_resource *buf)
|
||||
struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct nv30_context *nv30 = nv30_context(pipe);
|
||||
struct pipe_resource *buf = cb ? cb->buffer : NULL;
|
||||
unsigned size;
|
||||
|
||||
size = 0;
|
||||
|
@@ -744,9 +744,10 @@ nv50_gp_state_bind(struct pipe_context *pipe, void *hwcso)
|
||||
|
||||
static void
|
||||
nv50_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
|
||||
struct pipe_resource *res)
|
||||
struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct nv50_context *nv50 = nv50_context(pipe);
|
||||
struct pipe_resource *res = cb ? cb->buffer : NULL;
|
||||
|
||||
pipe_resource_reference(&nv50->constbuf[shader][index], res);
|
||||
|
||||
|
@@ -616,9 +616,10 @@ nvc0_gp_state_bind(struct pipe_context *pipe, void *hwcso)
|
||||
|
||||
static void
|
||||
nvc0_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
|
||||
struct pipe_resource *res)
|
||||
struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct nvc0_context *nvc0 = nvc0_context(pipe);
|
||||
struct pipe_resource *res = cb ? cb->buffer : NULL;
|
||||
|
||||
switch (shader) {
|
||||
case PIPE_SHADER_VERTEX: shader = 0; break;
|
||||
|
@@ -1819,9 +1819,10 @@ static void r300_delete_vs_state(struct pipe_context* pipe, void* shader)
|
||||
|
||||
static void r300_set_constant_buffer(struct pipe_context *pipe,
|
||||
uint shader, uint index,
|
||||
struct pipe_resource *buf)
|
||||
struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct r300_context* r300 = r300_context(pipe);
|
||||
struct pipe_resource *buf = cb ? cb->buffer : NULL;
|
||||
struct r300_constant_buffer *cbuf;
|
||||
struct r300_resource *rbuf = r300_resource(buf);
|
||||
uint32_t *mapped;
|
||||
|
@@ -1177,7 +1177,7 @@ static void evergreen_set_clip_state(struct pipe_context *ctx,
|
||||
{
|
||||
struct r600_context *rctx = (struct r600_context *)ctx;
|
||||
struct r600_pipe_state *rstate = CALLOC_STRUCT(r600_pipe_state);
|
||||
struct pipe_resource *cbuf;
|
||||
struct pipe_constant_buffer cb;
|
||||
|
||||
if (rstate == NULL)
|
||||
return;
|
||||
@@ -1203,12 +1203,14 @@ static void evergreen_set_clip_state(struct pipe_context *ctx,
|
||||
rctx->states[R600_PIPE_STATE_CLIP] = rstate;
|
||||
r600_context_pipe_state_set(rctx, rstate);
|
||||
|
||||
cbuf = pipe_user_buffer_create(ctx->screen,
|
||||
cb.buffer = pipe_user_buffer_create(ctx->screen,
|
||||
state->ucp,
|
||||
4*4*8, /* 8*4 floats */
|
||||
PIPE_BIND_CONSTANT_BUFFER);
|
||||
r600_set_constant_buffer(ctx, PIPE_SHADER_VERTEX, 1, cbuf);
|
||||
pipe_resource_reference(&cbuf, NULL);
|
||||
cb.buffer_offset = 0;
|
||||
cb.buffer_size = 4*4*8;
|
||||
r600_set_constant_buffer(ctx, PIPE_SHADER_VERTEX, 1, &cb);
|
||||
pipe_resource_reference(&cb.buffer, NULL);
|
||||
}
|
||||
|
||||
static void evergreen_set_polygon_stipple(struct pipe_context *ctx,
|
||||
@@ -1762,7 +1764,7 @@ static void evergreen_emit_constant_buffer(struct r600_context *rctx,
|
||||
uint32_t dirty_mask = state->dirty_mask;
|
||||
|
||||
while (dirty_mask) {
|
||||
struct r600_constant_buffer *cb;
|
||||
struct pipe_constant_buffer *cb;
|
||||
struct r600_resource *rbuffer;
|
||||
uint64_t va;
|
||||
unsigned buffer_index = ffs(dirty_mask) - 1;
|
||||
|
@@ -227,17 +227,10 @@ struct r600_stencil_ref
|
||||
ubyte writemask[2];
|
||||
};
|
||||
|
||||
struct r600_constant_buffer
|
||||
{
|
||||
struct pipe_resource *buffer;
|
||||
unsigned buffer_offset;
|
||||
unsigned buffer_size;
|
||||
};
|
||||
|
||||
struct r600_constbuf_state
|
||||
{
|
||||
struct r600_atom atom;
|
||||
struct r600_constant_buffer cb[PIPE_MAX_CONSTANT_BUFFERS];
|
||||
struct pipe_constant_buffer cb[PIPE_MAX_CONSTANT_BUFFERS];
|
||||
uint32_t enabled_mask;
|
||||
uint32_t dirty_mask;
|
||||
};
|
||||
@@ -496,7 +489,7 @@ void r600_delete_ps_shader(struct pipe_context *ctx, void *state);
|
||||
void r600_delete_vs_shader(struct pipe_context *ctx, void *state);
|
||||
void r600_constant_buffers_dirty(struct r600_context *rctx, struct r600_constbuf_state *state);
|
||||
void r600_set_constant_buffer(struct pipe_context *ctx, uint shader, uint index,
|
||||
struct pipe_resource *buffer);
|
||||
struct pipe_constant_buffer *cb);
|
||||
struct pipe_stream_output_target *
|
||||
r600_create_so_target(struct pipe_context *ctx,
|
||||
struct pipe_resource *buffer,
|
||||
|
@@ -1260,7 +1260,7 @@ static void r600_set_clip_state(struct pipe_context *ctx,
|
||||
{
|
||||
struct r600_context *rctx = (struct r600_context *)ctx;
|
||||
struct r600_pipe_state *rstate = CALLOC_STRUCT(r600_pipe_state);
|
||||
struct pipe_resource * cbuf;
|
||||
struct pipe_constant_buffer cb;
|
||||
|
||||
if (rstate == NULL)
|
||||
return;
|
||||
@@ -1286,12 +1286,14 @@ static void r600_set_clip_state(struct pipe_context *ctx,
|
||||
rctx->states[R600_PIPE_STATE_CLIP] = rstate;
|
||||
r600_context_pipe_state_set(rctx, rstate);
|
||||
|
||||
cbuf = pipe_user_buffer_create(ctx->screen,
|
||||
cb.buffer = pipe_user_buffer_create(ctx->screen,
|
||||
state->ucp,
|
||||
4*4*8, /* 8*4 floats */
|
||||
PIPE_BIND_CONSTANT_BUFFER);
|
||||
r600_set_constant_buffer(ctx, PIPE_SHADER_VERTEX, 1, cbuf);
|
||||
pipe_resource_reference(&cbuf, NULL);
|
||||
cb.buffer_offset = 0;
|
||||
cb.buffer_size = 4*4*8;
|
||||
r600_set_constant_buffer(ctx, PIPE_SHADER_VERTEX, 1, &cb);
|
||||
pipe_resource_reference(&cb.buffer, NULL);
|
||||
}
|
||||
|
||||
static void r600_set_polygon_stipple(struct pipe_context *ctx,
|
||||
@@ -1733,7 +1735,7 @@ static void r600_emit_constant_buffers(struct r600_context *rctx,
|
||||
uint32_t dirty_mask = state->dirty_mask;
|
||||
|
||||
while (dirty_mask) {
|
||||
struct r600_constant_buffer *cb;
|
||||
struct pipe_constant_buffer *cb;
|
||||
struct r600_resource *rbuffer;
|
||||
unsigned offset;
|
||||
unsigned buffer_index = ffs(dirty_mask) - 1;
|
||||
|
@@ -530,11 +530,11 @@ void r600_constant_buffers_dirty(struct r600_context *rctx, struct r600_constbuf
|
||||
}
|
||||
|
||||
void r600_set_constant_buffer(struct pipe_context *ctx, uint shader, uint index,
|
||||
struct pipe_resource *buffer)
|
||||
struct pipe_constant_buffer *input)
|
||||
{
|
||||
struct r600_context *rctx = (struct r600_context *)ctx;
|
||||
struct r600_constbuf_state *state;
|
||||
struct r600_constant_buffer *cb;
|
||||
struct pipe_constant_buffer *cb;
|
||||
uint8_t *ptr;
|
||||
|
||||
switch (shader) {
|
||||
@@ -551,7 +551,7 @@ void r600_set_constant_buffer(struct pipe_context *ctx, uint shader, uint index,
|
||||
/* Note that the state tracker can unbind constant buffers by
|
||||
* passing NULL here.
|
||||
*/
|
||||
if (unlikely(!buffer)) {
|
||||
if (unlikely(!input)) {
|
||||
state->enabled_mask &= ~(1 << index);
|
||||
state->dirty_mask &= ~(1 << index);
|
||||
pipe_resource_reference(&state->cb[index].buffer, NULL);
|
||||
@@ -559,15 +559,15 @@ void r600_set_constant_buffer(struct pipe_context *ctx, uint shader, uint index,
|
||||
}
|
||||
|
||||
cb = &state->cb[index];
|
||||
cb->buffer_size = buffer->width0;
|
||||
cb->buffer_size = input->buffer_size;
|
||||
|
||||
ptr = buffer->user_ptr;
|
||||
ptr = input->buffer->user_ptr;
|
||||
|
||||
if (ptr) {
|
||||
/* Upload the user buffer. */
|
||||
if (R600_BIG_ENDIAN) {
|
||||
uint32_t *tmpPtr;
|
||||
unsigned i, size = buffer->width0;
|
||||
unsigned i, size = input->buffer_size;
|
||||
|
||||
if (!(tmpPtr = malloc(size))) {
|
||||
R600_ERR("Failed to allocate BE swap buffer.\n");
|
||||
@@ -581,12 +581,12 @@ void r600_set_constant_buffer(struct pipe_context *ctx, uint shader, uint index,
|
||||
u_upload_data(rctx->uploader, 0, size, tmpPtr, &cb->buffer_offset, &cb->buffer);
|
||||
free(tmpPtr);
|
||||
} else {
|
||||
u_upload_data(rctx->uploader, 0, buffer->width0, ptr, &cb->buffer_offset, &cb->buffer);
|
||||
u_upload_data(rctx->uploader, 0, input->buffer_size, ptr, &cb->buffer_offset, &cb->buffer);
|
||||
}
|
||||
} else {
|
||||
/* Setup the hw buffer. */
|
||||
cb->buffer_offset = 0;
|
||||
pipe_resource_reference(&cb->buffer, buffer);
|
||||
cb->buffer_offset = input->buffer_offset;
|
||||
pipe_resource_reference(&cb->buffer, input->buffer);
|
||||
}
|
||||
|
||||
state->enabled_mask |= 1 << index;
|
||||
|
@@ -424,10 +424,10 @@ static void r600_update_alpha_ref(struct r600_context *rctx)
|
||||
}
|
||||
|
||||
void r600_set_constant_buffer(struct pipe_context *ctx, uint shader, uint index,
|
||||
struct pipe_resource *buffer)
|
||||
struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct r600_context *rctx = (struct r600_context *)ctx;
|
||||
struct r600_resource *rbuffer = r600_resource(buffer);
|
||||
struct r600_resource *rbuffer = cb ? r600_resource(cb->buffer) : NULL;
|
||||
struct r600_pipe_state *rstate;
|
||||
uint64_t va_offset;
|
||||
uint32_t offset;
|
||||
@@ -435,7 +435,7 @@ void r600_set_constant_buffer(struct pipe_context *ctx, uint shader, uint index,
|
||||
/* Note that the state tracker can unbind constant buffers by
|
||||
* passing NULL here.
|
||||
*/
|
||||
if (buffer == NULL) {
|
||||
if (cb == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -474,7 +474,7 @@ void r600_set_constant_buffer(struct pipe_context *ctx, uint shader, uint index,
|
||||
|
||||
r600_context_pipe_state_set(rctx, rstate);
|
||||
|
||||
if (buffer != &rbuffer->b.b)
|
||||
if (cb->buffer != &rbuffer->b.b)
|
||||
pipe_resource_reference((struct pipe_resource**)&rbuffer, NULL);
|
||||
}
|
||||
|
||||
|
@@ -442,7 +442,7 @@ void r600_bind_vs_shader(struct pipe_context *ctx, void *state);
|
||||
void r600_delete_ps_shader(struct pipe_context *ctx, void *state);
|
||||
void r600_delete_vs_shader(struct pipe_context *ctx, void *state);
|
||||
void r600_set_constant_buffer(struct pipe_context *ctx, uint shader, uint index,
|
||||
struct pipe_resource *buffer);
|
||||
struct pipe_constant_buffer *cb);
|
||||
struct pipe_stream_output_target *
|
||||
r600_create_so_target(struct pipe_context *ctx,
|
||||
struct pipe_resource *buffer,
|
||||
|
@@ -614,24 +614,23 @@ static void
|
||||
rbug_set_constant_buffer(struct pipe_context *_pipe,
|
||||
uint shader,
|
||||
uint index,
|
||||
struct pipe_resource *_resource)
|
||||
struct pipe_constant_buffer *_cb)
|
||||
{
|
||||
struct rbug_context *rb_pipe = rbug_context(_pipe);
|
||||
struct pipe_context *pipe = rb_pipe->pipe;
|
||||
struct pipe_resource *unwrapped_resource;
|
||||
struct pipe_resource *resource = NULL;
|
||||
struct pipe_constant_buffer cb;
|
||||
|
||||
/* XXX hmm? unwrap the input state */
|
||||
if (_resource) {
|
||||
unwrapped_resource = rbug_resource_unwrap(_resource);
|
||||
resource = unwrapped_resource;
|
||||
if (_cb) {
|
||||
cb = *_cb;
|
||||
cb.buffer = rbug_resource_unwrap(_cb->buffer);
|
||||
}
|
||||
|
||||
pipe_mutex_lock(rb_pipe->call_mutex);
|
||||
pipe->set_constant_buffer(pipe,
|
||||
shader,
|
||||
index,
|
||||
resource);
|
||||
_cb ? &cb : NULL);
|
||||
pipe_mutex_unlock(rb_pipe->call_mutex);
|
||||
}
|
||||
|
||||
|
@@ -342,9 +342,10 @@ softpipe_delete_gs_state(struct pipe_context *pipe, void *gs)
|
||||
static void
|
||||
softpipe_set_constant_buffer(struct pipe_context *pipe,
|
||||
uint shader, uint index,
|
||||
struct pipe_resource *constants)
|
||||
struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct softpipe_context *softpipe = softpipe_context(pipe);
|
||||
struct pipe_resource *constants = cb ? cb->buffer : NULL;
|
||||
unsigned size = constants ? constants->width0 : 0;
|
||||
const void *data = constants ? softpipe_resource(constants)->data : NULL;
|
||||
|
||||
|
@@ -45,9 +45,10 @@ struct svga_constbuf
|
||||
|
||||
static void svga_set_constant_buffer(struct pipe_context *pipe,
|
||||
uint shader, uint index,
|
||||
struct pipe_resource *buf)
|
||||
struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct svga_context *svga = svga_context(pipe);
|
||||
struct pipe_resource *buf = cb ? cb->buffer : NULL;
|
||||
|
||||
assert(shader < PIPE_SHADER_TYPES);
|
||||
assert(index == 0);
|
||||
|
@@ -721,13 +721,15 @@ trace_context_set_sample_mask(struct pipe_context *_pipe,
|
||||
static INLINE void
|
||||
trace_context_set_constant_buffer(struct pipe_context *_pipe,
|
||||
uint shader, uint index,
|
||||
struct pipe_resource *buffer)
|
||||
struct pipe_constant_buffer *constant_buffer)
|
||||
{
|
||||
struct trace_context *tr_ctx = trace_context(_pipe);
|
||||
struct pipe_context *pipe = tr_ctx->pipe;
|
||||
struct pipe_constant_buffer cb;
|
||||
|
||||
if (buffer) {
|
||||
buffer = trace_resource_unwrap(tr_ctx, buffer);
|
||||
if (constant_buffer) {
|
||||
cb = *constant_buffer;
|
||||
cb.buffer = trace_resource_unwrap(tr_ctx, constant_buffer->buffer);
|
||||
}
|
||||
|
||||
trace_dump_call_begin("pipe_context", "set_constant_buffer");
|
||||
@@ -735,9 +737,18 @@ trace_context_set_constant_buffer(struct pipe_context *_pipe,
|
||||
trace_dump_arg(ptr, pipe);
|
||||
trace_dump_arg(uint, shader);
|
||||
trace_dump_arg(uint, index);
|
||||
trace_dump_arg(ptr, buffer);
|
||||
if (constant_buffer) {
|
||||
trace_dump_struct_begin("pipe_constant_buffer");
|
||||
trace_dump_member(ptr, constant_buffer, buffer);
|
||||
trace_dump_member(uint, constant_buffer, buffer_offset);
|
||||
trace_dump_member(uint, constant_buffer, buffer_size);
|
||||
trace_dump_struct_end();
|
||||
} else {
|
||||
trace_dump_arg(ptr, constant_buffer);
|
||||
}
|
||||
|
||||
pipe->set_constant_buffer(pipe, shader, index, buffer);
|
||||
pipe->set_constant_buffer(pipe, shader, index,
|
||||
constant_buffer ? &cb : NULL);
|
||||
|
||||
trace_dump_call_end();
|
||||
}
|
||||
|
@@ -41,6 +41,7 @@ struct pipe_blend_color;
|
||||
struct pipe_blend_state;
|
||||
struct pipe_box;
|
||||
struct pipe_clip_state;
|
||||
struct pipe_constant_buffer;
|
||||
struct pipe_depth_stencil_alpha_state;
|
||||
struct pipe_draw_info;
|
||||
struct pipe_fence_handle;
|
||||
@@ -194,7 +195,7 @@ struct pipe_context {
|
||||
|
||||
void (*set_constant_buffer)( struct pipe_context *,
|
||||
uint shader, uint index,
|
||||
struct pipe_resource *buf );
|
||||
struct pipe_constant_buffer *buf );
|
||||
|
||||
void (*set_framebuffer_state)( struct pipe_context *,
|
||||
const struct pipe_framebuffer_state * );
|
||||
|
@@ -450,6 +450,17 @@ struct pipe_vertex_buffer
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A constant buffer. A subrange of an existing buffer can be set
|
||||
* as a constant buffer.
|
||||
*/
|
||||
struct pipe_constant_buffer {
|
||||
struct pipe_resource *buffer; /**< the actual buffer */
|
||||
unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */
|
||||
unsigned buffer_size; /**< how much data can be read in shader */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A stream output target. The structure specifies the range vertices can
|
||||
* be written to.
|
||||
|
@@ -344,7 +344,7 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe>
|
||||
{
|
||||
constant_buffers[s][start + i] = constbufs[i];
|
||||
if(s < caps.stages && start + i < caps.constant_buffers[s])
|
||||
pipe->set_constant_buffer(pipe, s, start + i, constbufs[i] ? constbufs[i]->resource : NULL);
|
||||
pipe_set_constant_buffer(pipe, s, start + i, constbufs[i] ? constbufs[i]->resource : NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1715,7 +1715,7 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe>
|
||||
{
|
||||
unsigned num = std::min(caps.constant_buffers[s], (unsigned)D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT);
|
||||
for(unsigned i = 0; i < num; ++i)
|
||||
pipe->set_constant_buffer(pipe, s, i, constant_buffers[s][i].p ? constant_buffers[s][i].p->resource : 0);
|
||||
pipe_set_constant_buffer(pipe, s, i, constant_buffers[s][i].p ? constant_buffers[s][i].p->resource : 0);
|
||||
}
|
||||
|
||||
update_flags |= (1 << (UPDATE_SAMPLERS_SHIFT + D3D11_STAGE_VS)) | (1 << (UPDATE_VIEWS_SHIFT + D3D11_STAGE_VS));
|
||||
@@ -1961,7 +1961,7 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe>
|
||||
if(constant_buffers[s][i] == buffer)
|
||||
{
|
||||
constant_buffers[s][i] = (ID3D10Buffer*)NULL;
|
||||
pipe->set_constant_buffer(pipe, s, i, NULL);
|
||||
pipe_set_constant_buffer(pipe, s, i, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -179,7 +179,7 @@ static void renderer_set_mvp(struct renderer *renderer,
|
||||
pipe_buffer_write(renderer->pipe, cbuf,
|
||||
0, sizeof(consts), consts);
|
||||
}
|
||||
renderer->pipe->set_constant_buffer(renderer->pipe,
|
||||
pipe_set_constant_buffer(renderer->pipe,
|
||||
PIPE_SHADER_VERTEX, 0, cbuf);
|
||||
|
||||
memcpy(cur, mvp, sizeof(*mvp));
|
||||
@@ -478,7 +478,7 @@ static void renderer_set_custom_fs(struct renderer *renderer,
|
||||
const_buffer_len);
|
||||
pipe_buffer_write(renderer->pipe, cbuf, 0,
|
||||
const_buffer_len, const_buffer);
|
||||
renderer->pipe->set_constant_buffer(renderer->pipe,
|
||||
pipe_set_constant_buffer(renderer->pipe,
|
||||
PIPE_SHADER_FRAGMENT, 0, cbuf);
|
||||
|
||||
renderer->fs_cbuf = cbuf;
|
||||
|
@@ -408,7 +408,7 @@ renderer_set_constants(struct xa_context *r,
|
||||
if (*cbuf) {
|
||||
pipe_buffer_write(r->pipe, *cbuf, 0, param_bytes, params);
|
||||
}
|
||||
r->pipe->set_constant_buffer(r->pipe, shader_type, 0, *cbuf);
|
||||
pipe_set_constant_buffer(r->pipe, shader_type, 0, *cbuf);
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -437,7 +437,7 @@ void renderer_set_constants(struct xorg_renderer *r,
|
||||
pipe_buffer_write(r->pipe, *cbuf,
|
||||
0, param_bytes, params);
|
||||
}
|
||||
r->pipe->set_constant_buffer(r->pipe, shader_type, 0, *cbuf);
|
||||
pipe_set_constant_buffer(r->pipe, shader_type, 0, *cbuf);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -148,7 +148,7 @@ static void init_fs_constbuf( void )
|
||||
sizeof constants1);
|
||||
|
||||
|
||||
ctx->set_constant_buffer(ctx,
|
||||
pipe_set_constant_buffer(ctx,
|
||||
PIPE_SHADER_FRAGMENT, 0,
|
||||
constbuf1);
|
||||
}
|
||||
@@ -165,7 +165,7 @@ static void init_fs_constbuf( void )
|
||||
sizeof constants2);
|
||||
|
||||
|
||||
ctx->set_constant_buffer(ctx,
|
||||
pipe_set_constant_buffer(ctx,
|
||||
PIPE_SHADER_FRAGMENT, 1,
|
||||
constbuf2);
|
||||
}
|
||||
|
@@ -181,7 +181,7 @@ static void init_fs_constbuf( void )
|
||||
sizeof constants1);
|
||||
|
||||
|
||||
ctx->set_constant_buffer(ctx,
|
||||
pipe_set_constant_buffer(ctx,
|
||||
PIPE_SHADER_GEOMETRY, 0,
|
||||
constbuf1);
|
||||
}
|
||||
@@ -198,7 +198,7 @@ static void init_fs_constbuf( void )
|
||||
sizeof constants2);
|
||||
|
||||
|
||||
ctx->set_constant_buffer(ctx,
|
||||
pipe_set_constant_buffer(ctx,
|
||||
PIPE_SHADER_GEOMETRY, 1,
|
||||
constbuf2);
|
||||
}
|
||||
|
@@ -110,7 +110,7 @@ static void init_fs_constbuf( void )
|
||||
sizeof constants);
|
||||
|
||||
|
||||
ctx->set_constant_buffer(ctx,
|
||||
pipe_set_constant_buffer(ctx,
|
||||
PIPE_SHADER_FRAGMENT, 0,
|
||||
constbuf);
|
||||
}
|
||||
|
@@ -63,7 +63,7 @@ void st_upload_constants( struct st_context *st,
|
||||
|
||||
/* update constants */
|
||||
if (params && params->NumParameters) {
|
||||
struct pipe_resource *cbuf;
|
||||
struct pipe_constant_buffer cb;
|
||||
const uint paramBytes = params->NumParameters * sizeof(GLfloat) * 4;
|
||||
|
||||
/* Update the constants which come from fixed-function state, such as
|
||||
@@ -77,10 +77,12 @@ void st_upload_constants( struct st_context *st,
|
||||
* avoid gratuitous rendering synchronization.
|
||||
* Let's use a user buffer to avoid an unnecessary copy.
|
||||
*/
|
||||
cbuf = pipe_user_buffer_create(pipe->screen,
|
||||
cb.buffer = pipe_user_buffer_create(pipe->screen,
|
||||
params->ParameterValues,
|
||||
paramBytes,
|
||||
PIPE_BIND_CONSTANT_BUFFER);
|
||||
cb.buffer_offset = 0;
|
||||
cb.buffer_size = paramBytes;
|
||||
|
||||
if (ST_DEBUG & DEBUG_CONSTANTS) {
|
||||
debug_printf("%s(shader=%d, numParams=%d, stateFlags=0x%x)\n",
|
||||
@@ -89,8 +91,8 @@ void st_upload_constants( struct st_context *st,
|
||||
_mesa_print_parameter_list(params);
|
||||
}
|
||||
|
||||
st->pipe->set_constant_buffer(st->pipe, shader_type, 0, cbuf);
|
||||
pipe_resource_reference(&cbuf, NULL);
|
||||
st->pipe->set_constant_buffer(st->pipe, shader_type, 0, &cb);
|
||||
pipe_resource_reference(&cb.buffer, NULL);
|
||||
|
||||
st->state.constants[shader_type].ptr = params->ParameterValues;
|
||||
st->state.constants[shader_type].size = paramBytes;
|
||||
|
Reference in New Issue
Block a user