gallium: adapt state trackers etc. to pipe_constant_buffer removal
This commit is contained in:
@@ -353,7 +353,7 @@ init_buffers(struct vl_compositor *c)
|
|||||||
* Create our vertex shader's constant buffer
|
* Create our vertex shader's constant buffer
|
||||||
* Const buffer contains scaling and translation vectors
|
* Const buffer contains scaling and translation vectors
|
||||||
*/
|
*/
|
||||||
c->vs_const_buf.buffer = pipe_buffer_create
|
c->vs_const_buf = pipe_buffer_create
|
||||||
(
|
(
|
||||||
c->pipe->screen,
|
c->pipe->screen,
|
||||||
1,
|
1,
|
||||||
@@ -365,7 +365,7 @@ init_buffers(struct vl_compositor *c)
|
|||||||
* Create our fragment shader's constant buffer
|
* Create our fragment shader's constant buffer
|
||||||
* Const buffer contains the color conversion matrix and bias vectors
|
* Const buffer contains the color conversion matrix and bias vectors
|
||||||
*/
|
*/
|
||||||
c->fs_const_buf.buffer = pipe_buffer_create
|
c->fs_const_buf = pipe_buffer_create
|
||||||
(
|
(
|
||||||
c->pipe->screen,
|
c->pipe->screen,
|
||||||
1,
|
1,
|
||||||
@@ -390,8 +390,8 @@ cleanup_buffers(struct vl_compositor *c)
|
|||||||
for (i = 0; i < 2; ++i)
|
for (i = 0; i < 2; ++i)
|
||||||
pipe_buffer_reference(&c->vertex_bufs[i].buffer, NULL);
|
pipe_buffer_reference(&c->vertex_bufs[i].buffer, NULL);
|
||||||
|
|
||||||
pipe_buffer_reference(&c->vs_const_buf.buffer, NULL);
|
pipe_buffer_reference(&c->vs_const_buf, NULL);
|
||||||
pipe_buffer_reference(&c->fs_const_buf.buffer, NULL);
|
pipe_buffer_reference(&c->fs_const_buf, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool vl_compositor_init(struct vl_compositor *compositor, struct pipe_context *pipe)
|
bool vl_compositor_init(struct vl_compositor *compositor, struct pipe_context *pipe)
|
||||||
@@ -483,13 +483,13 @@ void vl_compositor_render(struct vl_compositor *compositor,
|
|||||||
compositor->pipe->bind_fs_state(compositor->pipe, compositor->fragment_shader);
|
compositor->pipe->bind_fs_state(compositor->pipe, compositor->fragment_shader);
|
||||||
compositor->pipe->set_vertex_buffers(compositor->pipe, 2, compositor->vertex_bufs);
|
compositor->pipe->set_vertex_buffers(compositor->pipe, 2, compositor->vertex_bufs);
|
||||||
compositor->pipe->set_vertex_elements(compositor->pipe, 2, compositor->vertex_elems);
|
compositor->pipe->set_vertex_elements(compositor->pipe, 2, compositor->vertex_elems);
|
||||||
compositor->pipe->set_constant_buffer(compositor->pipe, PIPE_SHADER_VERTEX, 0, &compositor->vs_const_buf);
|
compositor->pipe->set_constant_buffer(compositor->pipe, PIPE_SHADER_VERTEX, 0, compositor->vs_const_buf);
|
||||||
compositor->pipe->set_constant_buffer(compositor->pipe, PIPE_SHADER_FRAGMENT, 0, &compositor->fs_const_buf);
|
compositor->pipe->set_constant_buffer(compositor->pipe, PIPE_SHADER_FRAGMENT, 0, compositor->fs_const_buf);
|
||||||
|
|
||||||
vs_consts = pipe_buffer_map
|
vs_consts = pipe_buffer_map
|
||||||
(
|
(
|
||||||
compositor->pipe->screen,
|
compositor->pipe->screen,
|
||||||
compositor->vs_const_buf.buffer,
|
compositor->vs_const_buf,
|
||||||
PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD
|
PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -511,7 +511,7 @@ void vl_compositor_render(struct vl_compositor *compositor,
|
|||||||
vs_consts->src_trans.z = 0;
|
vs_consts->src_trans.z = 0;
|
||||||
vs_consts->src_trans.w = 0;
|
vs_consts->src_trans.w = 0;
|
||||||
|
|
||||||
pipe_buffer_unmap(compositor->pipe->screen, compositor->vs_const_buf.buffer);
|
pipe_buffer_unmap(compositor->pipe->screen, compositor->vs_const_buf);
|
||||||
|
|
||||||
compositor->pipe->draw_arrays(compositor->pipe, PIPE_PRIM_TRIANGLE_STRIP, 0, 4);
|
compositor->pipe->draw_arrays(compositor->pipe, PIPE_PRIM_TRIANGLE_STRIP, 0, 4);
|
||||||
compositor->pipe->flush(compositor->pipe, PIPE_FLUSH_RENDER_CACHE, fence);
|
compositor->pipe->flush(compositor->pipe, PIPE_FLUSH_RENDER_CACHE, fence);
|
||||||
@@ -525,10 +525,10 @@ void vl_compositor_set_csc_matrix(struct vl_compositor *compositor, const float
|
|||||||
|
|
||||||
memcpy
|
memcpy
|
||||||
(
|
(
|
||||||
pipe_buffer_map(compositor->pipe->screen, compositor->fs_const_buf.buffer, PIPE_BUFFER_USAGE_CPU_WRITE),
|
pipe_buffer_map(compositor->pipe->screen, compositor->fs_const_buf, PIPE_BUFFER_USAGE_CPU_WRITE),
|
||||||
mat,
|
mat,
|
||||||
sizeof(struct fragment_shader_consts)
|
sizeof(struct fragment_shader_consts)
|
||||||
);
|
);
|
||||||
|
|
||||||
pipe_buffer_unmap(compositor->pipe->screen, compositor->fs_const_buf.buffer);
|
pipe_buffer_unmap(compositor->pipe->screen, compositor->fs_const_buf);
|
||||||
}
|
}
|
||||||
|
@@ -47,7 +47,7 @@ struct vl_compositor
|
|||||||
struct pipe_scissor_state scissor;
|
struct pipe_scissor_state scissor;
|
||||||
struct pipe_vertex_buffer vertex_bufs[2];
|
struct pipe_vertex_buffer vertex_bufs[2];
|
||||||
struct pipe_vertex_element vertex_elems[2];
|
struct pipe_vertex_element vertex_elems[2];
|
||||||
struct pipe_constant_buffer vs_const_buf, fs_const_buf;
|
struct pipe_buffer *vs_const_buf, *fs_const_buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool vl_compositor_init(struct vl_compositor *compositor, struct pipe_context *pipe);
|
bool vl_compositor_init(struct vl_compositor *compositor, struct pipe_context *pipe);
|
||||||
|
@@ -929,7 +929,7 @@ init_buffers(struct vl_mpeg12_mc_renderer *r)
|
|||||||
r->vertex_elems[7].nr_components = 2;
|
r->vertex_elems[7].nr_components = 2;
|
||||||
r->vertex_elems[7].src_format = PIPE_FORMAT_R32G32_FLOAT;
|
r->vertex_elems[7].src_format = PIPE_FORMAT_R32G32_FLOAT;
|
||||||
|
|
||||||
r->vs_const_buf.buffer = pipe_buffer_create
|
r->vs_const_buf = pipe_buffer_create
|
||||||
(
|
(
|
||||||
r->pipe->screen,
|
r->pipe->screen,
|
||||||
DEFAULT_BUF_ALIGNMENT,
|
DEFAULT_BUF_ALIGNMENT,
|
||||||
@@ -937,7 +937,7 @@ init_buffers(struct vl_mpeg12_mc_renderer *r)
|
|||||||
sizeof(struct vertex_shader_consts)
|
sizeof(struct vertex_shader_consts)
|
||||||
);
|
);
|
||||||
|
|
||||||
r->fs_const_buf.buffer = pipe_buffer_create
|
r->fs_const_buf = pipe_buffer_create
|
||||||
(
|
(
|
||||||
r->pipe->screen,
|
r->pipe->screen,
|
||||||
DEFAULT_BUF_ALIGNMENT,
|
DEFAULT_BUF_ALIGNMENT,
|
||||||
@@ -946,11 +946,11 @@ init_buffers(struct vl_mpeg12_mc_renderer *r)
|
|||||||
|
|
||||||
memcpy
|
memcpy
|
||||||
(
|
(
|
||||||
pipe_buffer_map(r->pipe->screen, r->fs_const_buf.buffer, PIPE_BUFFER_USAGE_CPU_WRITE),
|
pipe_buffer_map(r->pipe->screen, r->fs_const_buf, PIPE_BUFFER_USAGE_CPU_WRITE),
|
||||||
&fs_consts, sizeof(struct fragment_shader_consts)
|
&fs_consts, sizeof(struct fragment_shader_consts)
|
||||||
);
|
);
|
||||||
|
|
||||||
pipe_buffer_unmap(r->pipe->screen, r->fs_const_buf.buffer);
|
pipe_buffer_unmap(r->pipe->screen, r->fs_const_buf);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -962,8 +962,8 @@ cleanup_buffers(struct vl_mpeg12_mc_renderer *r)
|
|||||||
|
|
||||||
assert(r);
|
assert(r);
|
||||||
|
|
||||||
pipe_buffer_reference(&r->vs_const_buf.buffer, NULL);
|
pipe_buffer_reference(&r->vs_const_buf, NULL);
|
||||||
pipe_buffer_reference(&r->fs_const_buf.buffer, NULL);
|
pipe_buffer_reference(&r->fs_const_buf, NULL);
|
||||||
|
|
||||||
for (i = 0; i < 3; ++i)
|
for (i = 0; i < 3; ++i)
|
||||||
pipe_buffer_reference(&r->vertex_bufs.all[i].buffer, NULL);
|
pipe_buffer_reference(&r->vertex_bufs.all[i].buffer, NULL);
|
||||||
@@ -1273,19 +1273,19 @@ flush(struct vl_mpeg12_mc_renderer *r)
|
|||||||
|
|
||||||
vs_consts = pipe_buffer_map
|
vs_consts = pipe_buffer_map
|
||||||
(
|
(
|
||||||
r->pipe->screen, r->vs_const_buf.buffer,
|
r->pipe->screen, r->vs_const_buf,
|
||||||
PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD
|
PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD
|
||||||
);
|
);
|
||||||
|
|
||||||
vs_consts->denorm.x = r->surface->width0;
|
vs_consts->denorm.x = r->surface->width0;
|
||||||
vs_consts->denorm.y = r->surface->height0;
|
vs_consts->denorm.y = r->surface->height0;
|
||||||
|
|
||||||
pipe_buffer_unmap(r->pipe->screen, r->vs_const_buf.buffer);
|
pipe_buffer_unmap(r->pipe->screen, r->vs_const_buf);
|
||||||
|
|
||||||
r->pipe->set_constant_buffer(r->pipe, PIPE_SHADER_VERTEX, 0,
|
r->pipe->set_constant_buffer(r->pipe, PIPE_SHADER_VERTEX, 0,
|
||||||
&r->vs_const_buf);
|
r->vs_const_buf);
|
||||||
r->pipe->set_constant_buffer(r->pipe, PIPE_SHADER_FRAGMENT, 0,
|
r->pipe->set_constant_buffer(r->pipe, PIPE_SHADER_FRAGMENT, 0,
|
||||||
&r->fs_const_buf);
|
r->fs_const_buf);
|
||||||
|
|
||||||
if (num_macroblocks[MACROBLOCK_TYPE_INTRA] > 0) {
|
if (num_macroblocks[MACROBLOCK_TYPE_INTRA] > 0) {
|
||||||
r->pipe->set_vertex_buffers(r->pipe, 1, r->vertex_bufs.all);
|
r->pipe->set_vertex_buffers(r->pipe, 1, r->vertex_bufs.all);
|
||||||
|
@@ -63,8 +63,8 @@ struct vl_mpeg12_mc_renderer
|
|||||||
|
|
||||||
struct pipe_viewport_state viewport;
|
struct pipe_viewport_state viewport;
|
||||||
struct pipe_scissor_state scissor;
|
struct pipe_scissor_state scissor;
|
||||||
struct pipe_constant_buffer vs_const_buf;
|
struct pipe_buffer *vs_const_buf;
|
||||||
struct pipe_constant_buffer fs_const_buf;
|
struct pipe_buffer *fs_const_buf;
|
||||||
struct pipe_framebuffer_state fb_state;
|
struct pipe_framebuffer_state fb_state;
|
||||||
struct pipe_vertex_element vertex_elems[8];
|
struct pipe_vertex_element vertex_elems[8];
|
||||||
|
|
||||||
|
@@ -75,7 +75,6 @@
|
|||||||
%rename(BlendColor) pipe_blend_color;
|
%rename(BlendColor) pipe_blend_color;
|
||||||
%rename(Blend) pipe_blend_state;
|
%rename(Blend) pipe_blend_state;
|
||||||
%rename(Clip) pipe_clip_state;
|
%rename(Clip) pipe_clip_state;
|
||||||
%rename(ConstantBuffer) pipe_constant_buffer;
|
|
||||||
%rename(Depth) pipe_depth_state;
|
%rename(Depth) pipe_depth_state;
|
||||||
%rename(Stencil) pipe_stencil_state;
|
%rename(Stencil) pipe_stencil_state;
|
||||||
%rename(Alpha) pipe_alpha_state;
|
%rename(Alpha) pipe_alpha_state;
|
||||||
|
@@ -118,10 +118,7 @@ struct st_context {
|
|||||||
void set_constant_buffer(unsigned shader, unsigned index,
|
void set_constant_buffer(unsigned shader, unsigned index,
|
||||||
struct pipe_buffer *buffer )
|
struct pipe_buffer *buffer )
|
||||||
{
|
{
|
||||||
struct pipe_constant_buffer state;
|
$self->pipe->set_constant_buffer($self->pipe, shader, index, buffer);
|
||||||
memset(&state, 0, sizeof(state));
|
|
||||||
state.buffer = buffer;
|
|
||||||
$self->pipe->set_constant_buffer($self->pipe, shader, index, &state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_framebuffer(const struct pipe_framebuffer_state *state )
|
void set_framebuffer(const struct pipe_framebuffer_state *state )
|
||||||
|
@@ -94,7 +94,7 @@ struct_factories = {
|
|||||||
"pipe_blend_color": gallium.BlendColor,
|
"pipe_blend_color": gallium.BlendColor,
|
||||||
"pipe_blend_state": gallium.Blend,
|
"pipe_blend_state": gallium.Blend,
|
||||||
#"pipe_clip_state": gallium.Clip,
|
#"pipe_clip_state": gallium.Clip,
|
||||||
#"pipe_constant_buffer": gallium.ConstantBuffer,
|
#"pipe_buffer": gallium.Buffer,
|
||||||
"pipe_depth_state": gallium.Depth,
|
"pipe_depth_state": gallium.Depth,
|
||||||
"pipe_stencil_state": gallium.Stencil,
|
"pipe_stencil_state": gallium.Stencil,
|
||||||
"pipe_alpha_state": gallium.Alpha,
|
"pipe_alpha_state": gallium.Alpha,
|
||||||
@@ -458,10 +458,10 @@ class Context(Object):
|
|||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
def set_constant_buffer(self, shader, index, buffer):
|
def set_constant_buffer(self, shader, index, buffer):
|
||||||
if buffer is not None and buffer.buffer is not None:
|
if buffer is not None:
|
||||||
self.real.set_constant_buffer(shader, index, buffer.buffer)
|
self.real.set_constant_buffer(shader, index, buffer)
|
||||||
|
|
||||||
self.dump_constant_buffer(buffer.buffer)
|
self.dump_constant_buffer(buffer)
|
||||||
|
|
||||||
def set_framebuffer_state(self, state):
|
def set_framebuffer_state(self, state):
|
||||||
_state = gallium.Framebuffer()
|
_state = gallium.Framebuffer()
|
||||||
|
@@ -147,22 +147,22 @@ static void setup_constant_buffer(struct vg_context *ctx, const void *buffer,
|
|||||||
VGint param_bytes)
|
VGint param_bytes)
|
||||||
{
|
{
|
||||||
struct pipe_context *pipe = ctx->pipe;
|
struct pipe_context *pipe = ctx->pipe;
|
||||||
struct pipe_constant_buffer *cbuf = &ctx->filter.buffer;
|
struct pipe_buffer **cbuf = &ctx->filter.buffer;
|
||||||
|
|
||||||
/* We always need to get a new buffer, to keep the drivers simple and
|
/* We always need to get a new buffer, to keep the drivers simple and
|
||||||
* avoid gratuitous rendering synchronization. */
|
* avoid gratuitous rendering synchronization. */
|
||||||
pipe_buffer_reference(&cbuf->buffer, NULL);
|
pipe_buffer_reference(cbuf, NULL);
|
||||||
|
|
||||||
cbuf->buffer = pipe_buffer_create(pipe->screen, 16,
|
*cbuf = pipe_buffer_create(pipe->screen, 16,
|
||||||
PIPE_BUFFER_USAGE_CONSTANT,
|
PIPE_BUFFER_USAGE_CONSTANT,
|
||||||
param_bytes);
|
param_bytes);
|
||||||
|
|
||||||
if (cbuf->buffer) {
|
if (*cbuf) {
|
||||||
st_no_flush_pipe_buffer_write(ctx, cbuf->buffer,
|
st_no_flush_pipe_buffer_write(ctx, *cbuf,
|
||||||
0, param_bytes, buffer);
|
0, param_bytes, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, cbuf);
|
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, *cbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setup_samplers(struct vg_context *ctx, struct filter_info *info)
|
static void setup_samplers(struct vg_context *ctx, struct filter_info *info)
|
||||||
|
@@ -217,7 +217,7 @@ static void setup_mask_framebuffer(struct pipe_surface *surf,
|
|||||||
static void setup_mask_operation(VGMaskOperation operation)
|
static void setup_mask_operation(VGMaskOperation operation)
|
||||||
{
|
{
|
||||||
struct vg_context *ctx = vg_current_context();
|
struct vg_context *ctx = vg_current_context();
|
||||||
struct pipe_constant_buffer *cbuf = &ctx->mask.cbuf;
|
struct pipe_buffer **cbuf = &ctx->mask.cbuf;
|
||||||
const VGint param_bytes = 4 * sizeof(VGfloat);
|
const VGint param_bytes = 4 * sizeof(VGfloat);
|
||||||
const VGfloat ones[4] = {1.f, 1.f, 1.f, 1.f};
|
const VGfloat ones[4] = {1.f, 1.f, 1.f, 1.f};
|
||||||
void *shader = 0;
|
void *shader = 0;
|
||||||
@@ -225,17 +225,17 @@ static void setup_mask_operation(VGMaskOperation operation)
|
|||||||
/* We always need to get a new buffer, to keep the drivers simple and
|
/* We always need to get a new buffer, to keep the drivers simple and
|
||||||
* avoid gratuitous rendering synchronization.
|
* avoid gratuitous rendering synchronization.
|
||||||
*/
|
*/
|
||||||
pipe_buffer_reference(&cbuf->buffer, NULL);
|
pipe_buffer_reference(cbuf, NULL);
|
||||||
|
|
||||||
cbuf->buffer = pipe_buffer_create(ctx->pipe->screen, 1,
|
*cbuf = pipe_buffer_create(ctx->pipe->screen, 1,
|
||||||
PIPE_BUFFER_USAGE_CONSTANT,
|
PIPE_BUFFER_USAGE_CONSTANT,
|
||||||
param_bytes);
|
param_bytes);
|
||||||
if (cbuf->buffer) {
|
if (*cbuf) {
|
||||||
st_no_flush_pipe_buffer_write(ctx, cbuf->buffer,
|
st_no_flush_pipe_buffer_write(ctx, *cbuf,
|
||||||
0, param_bytes, ones);
|
0, param_bytes, ones);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, cbuf);
|
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, *cbuf);
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
case VG_UNION_MASK: {
|
case VG_UNION_MASK: {
|
||||||
if (!ctx->mask.union_fs) {
|
if (!ctx->mask.union_fs) {
|
||||||
@@ -320,22 +320,22 @@ static void setup_mask_samplers(struct pipe_texture *umask)
|
|||||||
static void setup_mask_fill(const VGfloat color[4])
|
static void setup_mask_fill(const VGfloat color[4])
|
||||||
{
|
{
|
||||||
struct vg_context *ctx = vg_current_context();
|
struct vg_context *ctx = vg_current_context();
|
||||||
struct pipe_constant_buffer *cbuf = &ctx->mask.cbuf;
|
struct pipe_buffer **cbuf = &ctx->mask.cbuf;
|
||||||
const VGint param_bytes = 4 * sizeof(VGfloat);
|
const VGint param_bytes = 4 * sizeof(VGfloat);
|
||||||
|
|
||||||
/* We always need to get a new buffer, to keep the drivers simple and
|
/* We always need to get a new buffer, to keep the drivers simple and
|
||||||
* avoid gratuitous rendering synchronization.
|
* avoid gratuitous rendering synchronization.
|
||||||
*/
|
*/
|
||||||
pipe_buffer_reference(&cbuf->buffer, NULL);
|
pipe_buffer_reference(cbuf, NULL);
|
||||||
|
|
||||||
cbuf->buffer = pipe_buffer_create(ctx->pipe->screen, 1,
|
*cbuf = pipe_buffer_create(ctx->pipe->screen, 1,
|
||||||
PIPE_BUFFER_USAGE_CONSTANT,
|
PIPE_BUFFER_USAGE_CONSTANT,
|
||||||
param_bytes);
|
param_bytes);
|
||||||
if (cbuf->buffer) {
|
if (*cbuf) {
|
||||||
st_no_flush_pipe_buffer_write(ctx, cbuf->buffer, 0, param_bytes, color);
|
st_no_flush_pipe_buffer_write(ctx, *cbuf, 0, param_bytes, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, cbuf);
|
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, *cbuf);
|
||||||
cso_set_fragment_shader_handle(ctx->cso_context,
|
cso_set_fragment_shader_handle(ctx->cso_context,
|
||||||
shaders_cache_fill(ctx->sc,
|
shaders_cache_fill(ctx->sc,
|
||||||
VEGA_SOLID_FILL_SHADER));
|
VEGA_SOLID_FILL_SHADER));
|
||||||
|
@@ -77,7 +77,8 @@ struct vg_paint {
|
|||||||
struct pipe_sampler_state sampler;
|
struct pipe_sampler_state sampler;
|
||||||
} pattern;
|
} pattern;
|
||||||
|
|
||||||
struct pipe_constant_buffer cbuf;
|
/* XXX next 3 all unneded? */
|
||||||
|
struct pipe_buffer *cbuf;
|
||||||
struct pipe_shader_state fs_state;
|
struct pipe_shader_state fs_state;
|
||||||
void *fs;
|
void *fs;
|
||||||
};
|
};
|
||||||
|
@@ -51,7 +51,7 @@ struct shader {
|
|||||||
VGImageMode image_mode;
|
VGImageMode image_mode;
|
||||||
|
|
||||||
float constants[MAX_CONSTANTS];
|
float constants[MAX_CONSTANTS];
|
||||||
struct pipe_constant_buffer cbuf;
|
struct pipe_buffer *cbuf;
|
||||||
struct pipe_shader_state fs_state;
|
struct pipe_shader_state fs_state;
|
||||||
void *fs;
|
void *fs;
|
||||||
};
|
};
|
||||||
@@ -96,25 +96,25 @@ static void setup_constant_buffer(struct shader *shader)
|
|||||||
{
|
{
|
||||||
struct vg_context *ctx = shader->context;
|
struct vg_context *ctx = shader->context;
|
||||||
struct pipe_context *pipe = shader->context->pipe;
|
struct pipe_context *pipe = shader->context->pipe;
|
||||||
struct pipe_constant_buffer *cbuf = &shader->cbuf;
|
struct pipe_buffer **cbuf = &shader->cbuf;
|
||||||
VGint param_bytes = paint_constant_buffer_size(shader->paint);
|
VGint param_bytes = paint_constant_buffer_size(shader->paint);
|
||||||
float temp_buf[MAX_CONSTANTS];
|
float temp_buf[MAX_CONSTANTS];
|
||||||
|
|
||||||
assert(param_bytes <= sizeof(temp_buf));
|
assert(param_bytes <= sizeof(temp_buf));
|
||||||
paint_fill_constant_buffer(shader->paint, temp_buf);
|
paint_fill_constant_buffer(shader->paint, temp_buf);
|
||||||
|
|
||||||
if (cbuf->buffer == NULL ||
|
if (*cbuf == NULL ||
|
||||||
memcmp(temp_buf, shader->constants, param_bytes) != 0)
|
memcmp(temp_buf, shader->constants, param_bytes) != 0)
|
||||||
{
|
{
|
||||||
pipe_buffer_reference(&cbuf->buffer, NULL);
|
pipe_buffer_reference(cbuf, NULL);
|
||||||
|
|
||||||
memcpy(shader->constants, temp_buf, param_bytes);
|
memcpy(shader->constants, temp_buf, param_bytes);
|
||||||
cbuf->buffer = pipe_user_buffer_create(pipe->screen,
|
*cbuf = pipe_user_buffer_create(pipe->screen,
|
||||||
&shader->constants,
|
&shader->constants,
|
||||||
sizeof(shader->constants));
|
sizeof(shader->constants));
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, cbuf);
|
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, *cbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VGint blend_bind_samplers(struct vg_context *ctx,
|
static VGint blend_bind_samplers(struct vg_context *ctx,
|
||||||
|
@@ -122,8 +122,8 @@ struct vg_context * vg_create_context(struct pipe_context *pipe,
|
|||||||
|
|
||||||
void vg_destroy_context(struct vg_context *ctx)
|
void vg_destroy_context(struct vg_context *ctx)
|
||||||
{
|
{
|
||||||
struct pipe_constant_buffer *cbuf = &ctx->mask.cbuf;
|
struct pipe_buffer **cbuf = &ctx->mask.cbuf;
|
||||||
struct pipe_constant_buffer *vsbuf = &ctx->vs_const_buffer;
|
struct pipe_buffer **vsbuf = &ctx->vs_const_buffer;
|
||||||
|
|
||||||
util_destroy_blit(ctx->blit);
|
util_destroy_blit(ctx->blit);
|
||||||
renderer_destroy(ctx->renderer);
|
renderer_destroy(ctx->renderer);
|
||||||
@@ -131,11 +131,11 @@ void vg_destroy_context(struct vg_context *ctx)
|
|||||||
shader_destroy(ctx->shader);
|
shader_destroy(ctx->shader);
|
||||||
paint_destroy(ctx->default_paint);
|
paint_destroy(ctx->default_paint);
|
||||||
|
|
||||||
if (cbuf && cbuf->buffer)
|
if (*cbuf)
|
||||||
pipe_buffer_reference(&cbuf->buffer, NULL);
|
pipe_buffer_reference(cbuf, NULL);
|
||||||
|
|
||||||
if (vsbuf && vsbuf->buffer)
|
if (*vsbuf)
|
||||||
pipe_buffer_reference(&vsbuf->buffer, NULL);
|
pipe_buffer_reference(vsbuf, NULL);
|
||||||
|
|
||||||
if (ctx->clear.fs) {
|
if (ctx->clear.fs) {
|
||||||
cso_delete_fragment_shader(ctx->cso_context, ctx->clear.fs);
|
cso_delete_fragment_shader(ctx->cso_context, ctx->clear.fs);
|
||||||
@@ -371,20 +371,20 @@ void vg_validate_state(struct vg_context *ctx)
|
|||||||
2.f/fb->width, 2.f/fb->height, 1, 1,
|
2.f/fb->width, 2.f/fb->height, 1, 1,
|
||||||
-1, -1, 0, 0
|
-1, -1, 0, 0
|
||||||
};
|
};
|
||||||
struct pipe_constant_buffer *cbuf = &ctx->vs_const_buffer;
|
struct pipe_buffer **cbuf = &ctx->vs_const_buffer;
|
||||||
|
|
||||||
vg_set_viewport(ctx, VEGA_Y0_BOTTOM);
|
vg_set_viewport(ctx, VEGA_Y0_BOTTOM);
|
||||||
|
|
||||||
pipe_buffer_reference(&cbuf->buffer, NULL);
|
pipe_buffer_reference(cbuf, NULL);
|
||||||
cbuf->buffer = pipe_buffer_create(ctx->pipe->screen, 16,
|
*cbuf = pipe_buffer_create(ctx->pipe->screen, 16,
|
||||||
PIPE_BUFFER_USAGE_CONSTANT,
|
PIPE_BUFFER_USAGE_CONSTANT,
|
||||||
param_bytes);
|
param_bytes);
|
||||||
|
|
||||||
if (cbuf->buffer) {
|
if (*cbuf) {
|
||||||
st_no_flush_pipe_buffer_write(ctx, cbuf->buffer,
|
st_no_flush_pipe_buffer_write(ctx, *cbuf,
|
||||||
0, param_bytes, vs_consts);
|
0, param_bytes, vs_consts);
|
||||||
}
|
}
|
||||||
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_VERTEX, 0, cbuf);
|
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_VERTEX, 0, *cbuf);
|
||||||
}
|
}
|
||||||
if ((ctx->state.dirty & VS_DIRTY)) {
|
if ((ctx->state.dirty & VS_DIRTY)) {
|
||||||
cso_set_vertex_shader_handle(ctx->cso_context,
|
cso_set_vertex_shader_handle(ctx->cso_context,
|
||||||
|
@@ -113,7 +113,7 @@ struct vg_context
|
|||||||
} clear;
|
} clear;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct pipe_constant_buffer cbuf;
|
struct pipe_buffer *cbuf;
|
||||||
struct pipe_sampler_state sampler;
|
struct pipe_sampler_state sampler;
|
||||||
|
|
||||||
struct vg_shader *union_fs;
|
struct vg_shader *union_fs;
|
||||||
@@ -135,7 +135,7 @@ struct vg_context
|
|||||||
|
|
||||||
struct pipe_sampler_state blend_sampler;
|
struct pipe_sampler_state blend_sampler;
|
||||||
struct {
|
struct {
|
||||||
struct pipe_constant_buffer buffer;
|
struct pipe_buffer *buffer;
|
||||||
void *color_matrix_fs;
|
void *color_matrix_fs;
|
||||||
} filter;
|
} filter;
|
||||||
struct vg_paint *default_paint;
|
struct vg_paint *default_paint;
|
||||||
@@ -145,7 +145,7 @@ struct vg_context
|
|||||||
struct vg_shader *plain_vs;
|
struct vg_shader *plain_vs;
|
||||||
struct vg_shader *clear_vs;
|
struct vg_shader *clear_vs;
|
||||||
struct vg_shader *texture_vs;
|
struct vg_shader *texture_vs;
|
||||||
struct pipe_constant_buffer vs_const_buffer;
|
struct pipe_buffer *vs_const_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vg_object {
|
struct vg_object {
|
||||||
|
@@ -379,14 +379,14 @@ struct xorg_renderer * renderer_create(struct pipe_context *pipe)
|
|||||||
|
|
||||||
void renderer_destroy(struct xorg_renderer *r)
|
void renderer_destroy(struct xorg_renderer *r)
|
||||||
{
|
{
|
||||||
struct pipe_constant_buffer *vsbuf = &r->vs_const_buffer;
|
struct pipe_buffer **vsbuf = &r->vs_const_buffer;
|
||||||
struct pipe_constant_buffer *fsbuf = &r->fs_const_buffer;
|
struct pipe_buffer **fsbuf = &r->fs_const_buffer;
|
||||||
|
|
||||||
if (vsbuf && vsbuf->buffer)
|
if (*vsbuf)
|
||||||
pipe_buffer_reference(&vsbuf->buffer, NULL);
|
pipe_buffer_reference(vsbuf, NULL);
|
||||||
|
|
||||||
if (fsbuf && fsbuf->buffer)
|
if (*fsbuf)
|
||||||
pipe_buffer_reference(&fsbuf->buffer, NULL);
|
pipe_buffer_reference(fsbuf, NULL);
|
||||||
|
|
||||||
if (r->shaders) {
|
if (r->shaders) {
|
||||||
xorg_shaders_destroy(r->shaders);
|
xorg_shaders_destroy(r->shaders);
|
||||||
@@ -409,20 +409,20 @@ void renderer_set_constants(struct xorg_renderer *r,
|
|||||||
const float *params,
|
const float *params,
|
||||||
int param_bytes)
|
int param_bytes)
|
||||||
{
|
{
|
||||||
struct pipe_constant_buffer *cbuf =
|
struct pipe_buffer **cbuf =
|
||||||
(shader_type == PIPE_SHADER_VERTEX) ? &r->vs_const_buffer :
|
(shader_type == PIPE_SHADER_VERTEX) ? &r->vs_const_buffer :
|
||||||
&r->fs_const_buffer;
|
&r->fs_const_buffer;
|
||||||
|
|
||||||
pipe_buffer_reference(&cbuf->buffer, NULL);
|
pipe_buffer_reference(cbuf, NULL);
|
||||||
cbuf->buffer = pipe_buffer_create(r->pipe->screen, 16,
|
*cbuf = pipe_buffer_create(r->pipe->screen, 16,
|
||||||
PIPE_BUFFER_USAGE_CONSTANT,
|
PIPE_BUFFER_USAGE_CONSTANT,
|
||||||
param_bytes);
|
param_bytes);
|
||||||
|
|
||||||
if (cbuf->buffer) {
|
if (*cbuf) {
|
||||||
pipe_buffer_write(r->pipe->screen, cbuf->buffer,
|
pipe_buffer_write(r->pipe->screen, *cbuf,
|
||||||
0, param_bytes, params);
|
0, param_bytes, params);
|
||||||
}
|
}
|
||||||
r->pipe->set_constant_buffer(r->pipe, shader_type, 0, cbuf);
|
r->pipe->set_constant_buffer(r->pipe, shader_type, 0, *cbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -23,8 +23,8 @@ struct xorg_renderer {
|
|||||||
|
|
||||||
int fb_width;
|
int fb_width;
|
||||||
int fb_height;
|
int fb_height;
|
||||||
struct pipe_constant_buffer vs_const_buffer;
|
struct pipe_buffer *vs_const_buffer;
|
||||||
struct pipe_constant_buffer fs_const_buffer;
|
struct pipe_buffer *fs_const_buffer;
|
||||||
|
|
||||||
float buffer[BUF_SIZE];
|
float buffer[BUF_SIZE];
|
||||||
int buffer_size;
|
int buffer_size;
|
||||||
|
@@ -57,7 +57,7 @@ void st_upload_constants( struct st_context *st,
|
|||||||
unsigned shader_type)
|
unsigned shader_type)
|
||||||
{
|
{
|
||||||
struct pipe_context *pipe = st->pipe;
|
struct pipe_context *pipe = st->pipe;
|
||||||
struct pipe_constant_buffer *cbuf = &st->state.constants[shader_type];
|
struct pipe_buffer **cbuf = &st->state.constants[shader_type];
|
||||||
|
|
||||||
assert(shader_type == PIPE_SHADER_VERTEX ||
|
assert(shader_type == PIPE_SHADER_VERTEX ||
|
||||||
shader_type == PIPE_SHADER_FRAGMENT);
|
shader_type == PIPE_SHADER_FRAGMENT);
|
||||||
@@ -71,8 +71,8 @@ void st_upload_constants( struct st_context *st,
|
|||||||
/* We always need to get a new buffer, to keep the drivers simple and
|
/* We always need to get a new buffer, to keep the drivers simple and
|
||||||
* avoid gratuitous rendering synchronization.
|
* avoid gratuitous rendering synchronization.
|
||||||
*/
|
*/
|
||||||
pipe_buffer_reference(&cbuf->buffer, NULL );
|
pipe_buffer_reference(cbuf, NULL );
|
||||||
cbuf->buffer = pipe_buffer_create(pipe->screen, 16,
|
*cbuf = pipe_buffer_create(pipe->screen, 16,
|
||||||
PIPE_BUFFER_USAGE_CONSTANT,
|
PIPE_BUFFER_USAGE_CONSTANT,
|
||||||
paramBytes );
|
paramBytes );
|
||||||
|
|
||||||
@@ -84,12 +84,12 @@ void st_upload_constants( struct st_context *st,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* load Mesa constants into the constant buffer */
|
/* load Mesa constants into the constant buffer */
|
||||||
if (cbuf->buffer)
|
if (cbuf)
|
||||||
st_no_flush_pipe_buffer_write(st, cbuf->buffer,
|
st_no_flush_pipe_buffer_write(st, *cbuf,
|
||||||
0, paramBytes,
|
0, paramBytes,
|
||||||
params->ParameterValues);
|
params->ParameterValues);
|
||||||
|
|
||||||
st->pipe->set_constant_buffer(st->pipe, shader_type, 0, cbuf);
|
st->pipe->set_constant_buffer(st->pipe, shader_type, 0, *cbuf);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
st->constants.tracked_state[shader_type].dirty.mesa = 0x0;
|
st->constants.tracked_state[shader_type].dirty.mesa = 0x0;
|
||||||
|
@@ -217,8 +217,8 @@ static void st_destroy_context_priv( struct st_context *st )
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < Elements(st->state.constants); i++) {
|
for (i = 0; i < Elements(st->state.constants); i++) {
|
||||||
if (st->state.constants[i].buffer) {
|
if (st->state.constants[i]) {
|
||||||
pipe_buffer_reference(&st->state.constants[i].buffer, NULL);
|
pipe_buffer_reference(&st->state.constants[i], NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -92,7 +92,7 @@ struct st_context
|
|||||||
struct pipe_sampler_state samplers[PIPE_MAX_SAMPLERS];
|
struct pipe_sampler_state samplers[PIPE_MAX_SAMPLERS];
|
||||||
struct pipe_sampler_state *sampler_list[PIPE_MAX_SAMPLERS];
|
struct pipe_sampler_state *sampler_list[PIPE_MAX_SAMPLERS];
|
||||||
struct pipe_clip_state clip;
|
struct pipe_clip_state clip;
|
||||||
struct pipe_constant_buffer constants[2];
|
struct pipe_buffer *constants[2];
|
||||||
struct pipe_framebuffer_state framebuffer;
|
struct pipe_framebuffer_state framebuffer;
|
||||||
struct pipe_texture *sampler_texture[PIPE_MAX_SAMPLERS];
|
struct pipe_texture *sampler_texture[PIPE_MAX_SAMPLERS];
|
||||||
struct pipe_scissor_state scissor;
|
struct pipe_scissor_state scissor;
|
||||||
|
@@ -239,10 +239,10 @@ st_feedback_draw_vbo(GLcontext *ctx,
|
|||||||
|
|
||||||
/* map constant buffers */
|
/* map constant buffers */
|
||||||
mapped_constants = pipe_buffer_map(pipe->screen,
|
mapped_constants = pipe_buffer_map(pipe->screen,
|
||||||
st->state.constants[PIPE_SHADER_VERTEX].buffer,
|
st->state.constants[PIPE_SHADER_VERTEX],
|
||||||
PIPE_BUFFER_USAGE_CPU_READ);
|
PIPE_BUFFER_USAGE_CPU_READ);
|
||||||
draw_set_mapped_constant_buffer(st->draw, mapped_constants,
|
draw_set_mapped_constant_buffer(st->draw, mapped_constants,
|
||||||
st->state.constants[PIPE_SHADER_VERTEX].buffer->size);
|
st->state.constants[PIPE_SHADER_VERTEX]->size);
|
||||||
|
|
||||||
|
|
||||||
/* draw here */
|
/* draw here */
|
||||||
@@ -252,7 +252,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
|
|||||||
|
|
||||||
|
|
||||||
/* unmap constant buffers */
|
/* unmap constant buffers */
|
||||||
pipe_buffer_unmap(pipe->screen, st->state.constants[PIPE_SHADER_VERTEX].buffer);
|
pipe_buffer_unmap(pipe->screen, st->state.constants[PIPE_SHADER_VERTEX]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* unmap vertex/index buffers
|
* unmap vertex/index buffers
|
||||||
|
Reference in New Issue
Block a user