aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/postprocess/pp_mlaa.c4
-rw-r--r--src/gallium/auxiliary/util/u_inlines.h15
-rw-r--r--src/gallium/auxiliary/vl/vl_compositor.c2
-rw-r--r--src/gallium/drivers/galahad/glhd_context.c13
-rw-r--r--src/gallium/drivers/i915/i915_state.c3
-rw-r--r--src/gallium/drivers/identity/id_context.c13
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_fs.c3
-rw-r--r--src/gallium/drivers/noop/noop_state.c2
-rw-r--r--src/gallium/drivers/nv30/nv30_state.c3
-rw-r--r--src/gallium/drivers/nv50/nv50_state.c3
-rw-r--r--src/gallium/drivers/nvc0/nvc0_state.c3
-rw-r--r--src/gallium/drivers/r300/r300_state.c3
-rw-r--r--src/gallium/drivers/r600/evergreen_state.c18
-rw-r--r--src/gallium/drivers/r600/r600_pipe.h11
-rw-r--r--src/gallium/drivers/r600/r600_state.c18
-rw-r--r--src/gallium/drivers/r600/r600_state_common.c18
-rw-r--r--src/gallium/drivers/radeonsi/r600_state_common.c8
-rw-r--r--src/gallium/drivers/radeonsi/radeonsi_pipe.h2
-rw-r--r--src/gallium/drivers/rbug/rbug_context.c13
-rw-r--r--src/gallium/drivers/softpipe/sp_state_shader.c3
-rw-r--r--src/gallium/drivers/svga/svga_pipe_constants.c3
-rw-r--r--src/gallium/drivers/trace/tr_context.c21
-rw-r--r--src/gallium/include/pipe/p_context.h3
-rw-r--r--src/gallium/include/pipe/p_state.h11
-rw-r--r--src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h6
-rw-r--r--src/gallium/state_trackers/vega/renderer.c4
-rw-r--r--src/gallium/state_trackers/xa/xa_renderer.c2
-rw-r--r--src/gallium/state_trackers/xorg/xorg_renderer.c2
-rw-r--r--src/gallium/tests/graw/fs-test.c4
-rw-r--r--src/gallium/tests/graw/gs-test.c4
-rw-r--r--src/gallium/tests/graw/vs-test.c2
31 files changed, 130 insertions, 90 deletions
diff --git a/src/gallium/auxiliary/postprocess/pp_mlaa.c b/src/gallium/auxiliary/postprocess/pp_mlaa.c
index 51bc02edacc..b61cbaafb5e 100644
--- a/src/gallium/auxiliary/postprocess/pp_mlaa.c
+++ b/src/gallium/auxiliary/postprocess/pp_mlaa.c
@@ -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;
diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h
index 49b4531dbac..651f7c2d727 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -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,
diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c
index cc213b748a5..0cb1a9f38ad 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ b/src/gallium/auxiliary/vl/vl_compositor.c
@@ -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);
diff --git a/src/gallium/drivers/galahad/glhd_context.c b/src/gallium/drivers/galahad/glhd_context.c
index 0bb18884c8d..f0bbf4e8a95 100644
--- a/src/gallium/drivers/galahad/glhd_context.c
+++ b/src/gallium/drivers/galahad/glhd_context.c
@@ -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
diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c
index 4c284d9fcbb..40cef5a9d86 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -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;
diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c
index af3f8239ccd..29421849079 100644
--- a/src/gallium/drivers/identity/id_context.c
+++ b/src/gallium/drivers/identity/id_context.c
@@ -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
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 482f4e38632..7a6c1ab5bc7 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -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;
diff --git a/src/gallium/drivers/noop/noop_state.c b/src/gallium/drivers/noop/noop_state.c
index 9d8dbfc4e25..f1387af3a39 100644
--- a/src/gallium/drivers/noop/noop_state.c
+++ b/src/gallium/drivers/noop/noop_state.c
@@ -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)
{
}
diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c
index 64a8f33d466..534d1f0794b 100644
--- a/src/gallium/drivers/nv30/nv30_state.c
+++ b/src/gallium/drivers/nv30/nv30_state.c
@@ -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;
diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c
index 5b783da7ad7..34d2b6daead 100644
--- a/src/gallium/drivers/nv50/nv50_state.c
+++ b/src/gallium/drivers/nv50/nv50_state.c
@@ -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);
diff --git a/src/gallium/drivers/nvc0/nvc0_state.c b/src/gallium/drivers/nvc0/nvc0_state.c
index a2be53a433d..0a23ecd27b1 100644
--- a/src/gallium/drivers/nvc0/nvc0_state.c
+++ b/src/gallium/drivers/nvc0/nvc0_state.c
@@ -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;
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index 337008be47e..058e6f881f0 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -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;
diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
index 97a27d242c0..07771c17768 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -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,
- 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 = pipe_user_buffer_create(ctx->screen,
+ state->ucp,
+ 4*4*8, /* 8*4 floats */
+ PIPE_BIND_CONSTANT_BUFFER);
+ 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;
diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
index e17011bfb68..63fc27564d7 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -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,
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index 116ec5fca0e..1e7c5a43c02 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -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,
- 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 = pipe_user_buffer_create(ctx->screen,
+ state->ucp,
+ 4*4*8, /* 8*4 floats */
+ PIPE_BIND_CONSTANT_BUFFER);
+ 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;
diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
index 02577ef61a2..6f888df6a30 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -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;
diff --git a/src/gallium/drivers/radeonsi/r600_state_common.c b/src/gallium/drivers/radeonsi/r600_state_common.c
index d283e41e681..1970b52312d 100644
--- a/src/gallium/drivers/radeonsi/r600_state_common.c
+++ b/src/gallium/drivers/radeonsi/r600_state_common.c
@@ -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);
}
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.h b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
index 64ddd5de253..ab30892d51a 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
@@ -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,
diff --git a/src/gallium/drivers/rbug/rbug_context.c b/src/gallium/drivers/rbug/rbug_context.c
index 46518cd6977..799b3a30c63 100644
--- a/src/gallium/drivers/rbug/rbug_context.c
+++ b/src/gallium/drivers/rbug/rbug_context.c
@@ -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);
}
diff --git a/src/gallium/drivers/softpipe/sp_state_shader.c b/src/gallium/drivers/softpipe/sp_state_shader.c
index 6acb57b3fe6..af05d0d5d68 100644
--- a/src/gallium/drivers/softpipe/sp_state_shader.c
+++ b/src/gallium/drivers/softpipe/sp_state_shader.c
@@ -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;
diff --git a/src/gallium/drivers/svga/svga_pipe_constants.c b/src/gallium/drivers/svga/svga_pipe_constants.c
index 2fa2142d07d..5de547bc08a 100644
--- a/src/gallium/drivers/svga/svga_pipe_constants.c
+++ b/src/gallium/drivers/svga/svga_pipe_constants.c
@@ -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);
diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c
index 51a8b259a04..23f854ae9b8 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -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();
}
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index 8b4a1588b86..1871b214610 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -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 * );
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index a459a56a760..42510a685bf 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -451,6 +451,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.
*
diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
index d5c366ffd4f..a7b761c707f 100644
--- a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
+++ b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
@@ -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);
}
}
}
diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c
index add1eec0038..bafe55257f6 100644
--- a/src/gallium/state_trackers/vega/renderer.c
+++ b/src/gallium/state_trackers/vega/renderer.c
@@ -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;
diff --git a/src/gallium/state_trackers/xa/xa_renderer.c b/src/gallium/state_trackers/xa/xa_renderer.c
index 7052f396c3a..8ba6e1ead69 100644
--- a/src/gallium/state_trackers/xa/xa_renderer.c
+++ b/src/gallium/state_trackers/xa/xa_renderer.c
@@ -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
diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c
index eba72d81908..e28e06a9261 100644
--- a/src/gallium/state_trackers/xorg/xorg_renderer.c
+++ b/src/gallium/state_trackers/xorg/xorg_renderer.c
@@ -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);
}
diff --git a/src/gallium/tests/graw/fs-test.c b/src/gallium/tests/graw/fs-test.c
index f8b2a0a77a0..b42a86cfc8e 100644
--- a/src/gallium/tests/graw/fs-test.c
+++ b/src/gallium/tests/graw/fs-test.c
@@ -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);
}
diff --git a/src/gallium/tests/graw/gs-test.c b/src/gallium/tests/graw/gs-test.c
index ef2440291fc..a471abd9a3d 100644
--- a/src/gallium/tests/graw/gs-test.c
+++ b/src/gallium/tests/graw/gs-test.c
@@ -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);
}
diff --git a/src/gallium/tests/graw/vs-test.c b/src/gallium/tests/graw/vs-test.c
index 83d86fbf5b2..23b7ada98ad 100644
--- a/src/gallium/tests/graw/vs-test.c
+++ b/src/gallium/tests/graw/vs-test.c
@@ -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);
}