}
}
+void
+cso_set_constant_user_buffer(struct cso_context *cso,
+ enum pipe_shader_type shader_stage,
+ unsigned index, void *ptr, unsigned size)
+{
+ if (ptr) {
+ struct pipe_constant_buffer cb;
+ cb.buffer = NULL;
+ cb.buffer_offset = 0;
+ cb.buffer_size = size;
+ cb.user_buffer = ptr;
+ cso_set_constant_buffer(cso, shader_stage, index, &cb);
+ } else {
+ cso_set_constant_buffer(cso, shader_stage, index, NULL);
+ }
+}
+
void
cso_save_constant_buffer_slot0(struct cso_context *cso,
enum pipe_shader_type shader_stage)
enum pipe_shader_type shader_stage,
unsigned index,
struct pipe_resource *buffer);
+void cso_set_constant_user_buffer(struct cso_context *cso,
+ enum pipe_shader_type shader_stage,
+ unsigned index, void *ptr, unsigned size);
void cso_save_constant_buffer_slot0(struct cso_context *cso,
enum pipe_shader_type shader_stage);
void cso_restore_constant_buffer_slot0(struct cso_context *cso,
static float constants[] = { 1, 1, 0, 0 };
static unsigned int dimensions[2] = { 0, 0 };
-/** Upload the constants. */
-static void
-up_consts(struct pp_queue_t *ppq)
-{
- struct pipe_context *pipe = ppq->p->pipe;
-
- pipe->buffer_subdata(pipe, ppq->constbuf, PIPE_TRANSFER_WRITE,
- 0, sizeof(constants), constants);
-}
-
/** Run function of the MLAA filter. */
static void
pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
/* Insufficient initialization checks. */
assert(p);
assert(ppq);
- assert(ppq->constbuf);
assert(ppq->areamaptex);
assert(ppq->inner_tmp);
assert(ppq->shaders[n]);
constants[0] = 1.0f / p->framebuffer.width;
constants[1] = 1.0f / p->framebuffer.height;
- up_consts(ppq);
dimensions[0] = p->framebuffer.width;
dimensions[1] = p->framebuffer.height;
}
- cso_set_constant_buffer_resource(p->cso, PIPE_SHADER_VERTEX,
- 0, ppq->constbuf);
- cso_set_constant_buffer_resource(p->cso, PIPE_SHADER_FRAGMENT,
- 0, ppq->constbuf);
+ cso_set_constant_user_buffer(p->cso, PIPE_SHADER_VERTEX,
+ 0, constants, sizeof(constants));
+ cso_set_constant_user_buffer(p->cso, PIPE_SHADER_FRAGMENT,
+ 0, constants, sizeof(constants));
mstencil.stencil[0].enabled = 1;
mstencil.stencil[0].valuemask = mstencil.stencil[0].writemask = ~0;
return FALSE;
}
- ppq->constbuf = pipe_buffer_create(ppq->p->screen,
- PIPE_BIND_CONSTANT_BUFFER,
- PIPE_USAGE_DEFAULT,
- sizeof(constants));
- if (ppq->constbuf == NULL) {
- pp_debug("Failed to allocate constant buffer\n");
- goto fail;
- }
-
pp_debug("mlaa: using %u max search steps\n", val);
util_sprintf(tmp_text, "%s"
void
pp_jimenezmlaa_free(struct pp_queue_t *ppq, unsigned int n)
{
- if (ppq->areamaptex) {
- pipe_resource_reference(&ppq->areamaptex, NULL);
- }
-
- if (ppq->constbuf) {
- pipe_resource_reference(&ppq->constbuf, NULL);
- }
+ pipe_resource_reference(&ppq->areamaptex, NULL);
}