summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2012-05-11 16:38:13 +0200
committerMarek Olšák <[email protected]>2012-05-11 16:38:13 +0200
commitbb4c5d72d7c7cb1d9e7016e2c07c36875f30011a (patch)
tree153444ff535900f82ae63b5af8ccd09fb2f063af /src/gallium/state_trackers
parent96956dc5076fc03b9290368ca90e3f3b870ee613 (diff)
parent8dd3e341b337ca2d22bcc0e7548a78a6c36ca77d (diff)
Merge branch 'gallium-userbuf'
Conflicts: src/gallium/docs/source/screen.rst src/gallium/drivers/nv50/nv50_state.c src/gallium/include/pipe/p_defines.h src/mesa/state_tracker/st_draw.c
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h6
-rw-r--r--src/gallium/state_trackers/vega/polygon.c29
-rw-r--r--src/gallium/state_trackers/vega/renderer.c27
-rw-r--r--src/gallium/state_trackers/xa/xa_renderer.c61
-rw-r--r--src/gallium/state_trackers/xorg/xorg_crtc.c2
-rw-r--r--src/gallium/state_trackers/xorg/xorg_driver.c2
-rw-r--r--src/gallium/state_trackers/xorg/xorg_renderer.c69
7 files changed, 53 insertions, 143 deletions
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/polygon.c b/src/gallium/state_trackers/vega/polygon.c
index bcc5cb272ca..3faec749e12 100644
--- a/src/gallium/state_trackers/vega/polygon.c
+++ b/src/gallium/state_trackers/vega/polygon.c
@@ -57,7 +57,7 @@ struct polygon
VGint num_verts;
VGboolean dirty;
- struct pipe_resource *vbuf;
+ void *user_vbuf;
struct pipe_screen *screen;
};
@@ -89,7 +89,7 @@ struct polygon * polygon_create(int size)
poly->size = size;
poly->num_verts = 0;
poly->dirty = VG_TRUE;
- poly->vbuf = NULL;
+ poly->user_vbuf = NULL;
return poly;
}
@@ -101,16 +101,13 @@ struct polygon * polygon_create_from_data(float *data, int size)
memcpy(poly->data, data, sizeof(float) * COMPONENTS * size);
poly->num_verts = size;
poly->dirty = VG_TRUE;
- poly->vbuf = NULL;
+ poly->user_vbuf = NULL;
return poly;
}
void polygon_destroy(struct polygon *poly)
{
- if (poly->vbuf)
- pipe_resource_reference(&poly->vbuf, NULL);
-
free(poly->data);
free(poly);
}
@@ -247,25 +244,15 @@ VGboolean polygon_is_closed(struct polygon *p)
static void polygon_prepare_buffer(struct vg_context *ctx,
struct polygon *poly)
{
- int vert_size;
struct pipe_context *pipe;
- vert_size = poly->num_verts * COMPONENTS * sizeof(float);
-
/*polygon_print(poly);*/
pipe = ctx->pipe;
- if (poly->vbuf == NULL || poly->dirty) {
- if (poly->vbuf) {
- pipe_resource_reference(&poly->vbuf,
- NULL);
- }
+ if (poly->user_vbuf == NULL || poly->dirty) {
poly->screen = pipe->screen;
- poly->vbuf= pipe_user_buffer_create(poly->screen,
- poly->data,
- vert_size,
- PIPE_BIND_VERTEX_BUFFER);
+ poly->user_vbuf = poly->data;
poly->dirty = VG_FALSE;
}
}
@@ -300,9 +287,8 @@ void polygon_fill(struct polygon *poly, struct vg_context *ctx)
/* tell renderer about the vertex buffer */
memset(&vbuffer, 0, sizeof(vbuffer));
- vbuffer.buffer = poly->vbuf;
+ vbuffer.user_buffer = poly->user_vbuf;
vbuffer.stride = COMPONENTS * sizeof(float); /* vertex size */
- vbuffer.buffer_offset = 0;
renderer_polygon_stencil_begin(ctx->renderer,
&velement, ctx->state.vg.fill_rule, VG_FALSE);
@@ -343,7 +329,6 @@ void polygon_array_fill(struct polygon_array *polyarray, struct vg_context *ctx)
/* tell renderer about the vertex buffer */
memset(&vbuffer, 0, sizeof(vbuffer));
vbuffer.stride = COMPONENTS * sizeof(float); /* vertex size */
- vbuffer.buffer_offset = 0;
/* prepare the stencil buffer */
renderer_polygon_stencil_begin(ctx->renderer,
@@ -352,7 +337,7 @@ void polygon_array_fill(struct polygon_array *polyarray, struct vg_context *ctx)
struct polygon *poly = (((struct polygon**)polys->data)[i]);
polygon_prepare_buffer(ctx, poly);
- vbuffer.buffer = poly->vbuf;
+ vbuffer.user_buffer = poly->user_vbuf;
renderer_polygon_stencil(ctx->renderer, &vbuffer,
PIPE_PRIM_TRIANGLE_FAN, 0, (VGuint) poly->num_verts);
diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c
index add1eec0038..23ec14ab84c 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;
@@ -566,20 +566,9 @@ static void renderer_quad_texcoord(struct renderer *r,
*/
static void renderer_quad_draw(struct renderer *r)
{
- struct pipe_resource *buf;
-
- buf = pipe_user_buffer_create(r->pipe->screen,
- r->vertices,
- sizeof(r->vertices),
- PIPE_BIND_VERTEX_BUFFER);
- if (buf) {
- util_draw_vertex_buffer(r->pipe, r->cso, buf, 0,
- PIPE_PRIM_TRIANGLE_FAN,
- Elements(r->vertices), /* verts */
- Elements(r->vertices[0])); /* attribs/vert */
-
- pipe_resource_reference(&buf, NULL);
- }
+ util_draw_user_vertex_buffer(r->cso, r->vertices, PIPE_PRIM_TRIANGLE_FAN,
+ Elements(r->vertices), /* verts */
+ Elements(r->vertices[0])); /* attribs/vert */
}
/**
@@ -1054,7 +1043,7 @@ void renderer_polygon_stencil(struct renderer *renderer,
cso_set_vertex_buffers(renderer->cso, 1, vbuf);
if (!renderer->u.polygon_stencil.manual_two_sides) {
- util_draw_arrays(renderer->pipe, mode, start, count);
+ cso_draw_arrays(renderer->cso, mode, start, count);
}
else {
struct pipe_rasterizer_state raster;
@@ -1069,7 +1058,7 @@ void renderer_polygon_stencil(struct renderer *renderer,
cso_set_rasterizer(renderer->cso, &raster);
cso_set_depth_stencil_alpha(renderer->cso, &dsa);
- util_draw_arrays(renderer->pipe, mode, start, count);
+ cso_draw_arrays(renderer->cso, mode, start, count);
/* back */
raster.cull_face = PIPE_FACE_FRONT;
@@ -1077,7 +1066,7 @@ void renderer_polygon_stencil(struct renderer *renderer,
cso_set_rasterizer(renderer->cso, &raster);
cso_set_depth_stencil_alpha(renderer->cso, &dsa);
- util_draw_arrays(renderer->pipe, mode, start, count);
+ cso_draw_arrays(renderer->cso, mode, start, count);
}
}
diff --git a/src/gallium/state_trackers/xa/xa_renderer.c b/src/gallium/state_trackers/xa/xa_renderer.c
index 7052f396c3a..217887ec1ae 100644
--- a/src/gallium/state_trackers/xa/xa_renderer.c
+++ b/src/gallium/state_trackers/xa/xa_renderer.c
@@ -71,40 +71,19 @@ map_point(float *mat, float x, float y, float *out_x, float *out_y)
}
}
-static INLINE struct pipe_resource *
-renderer_buffer_create(struct xa_context *r)
-{
- struct pipe_resource *buf = pipe_user_buffer_create(r->pipe->screen,
- r->buffer,
- sizeof(float) *
- r->buffer_size,
- PIPE_BIND_VERTEX_BUFFER);
-
- r->buffer_size = 0;
-
- return buf;
-}
-
static INLINE void
renderer_draw(struct xa_context *r)
{
- struct pipe_context *pipe = r->pipe;
- struct pipe_resource *buf = 0;
int num_verts = r->buffer_size / (r->attrs_per_vertex * NUM_COMPONENTS);
if (!r->buffer_size)
return;
- buf = renderer_buffer_create(r);
-
- if (buf) {
- cso_set_vertex_elements(r->cso, r->attrs_per_vertex, r->velems);
-
- util_draw_vertex_buffer(pipe, r->cso, buf, 0, PIPE_PRIM_QUADS, num_verts, /* verts */
- r->attrs_per_vertex); /* attribs/vert */
-
- pipe_resource_reference(&buf, NULL);
- }
+ cso_set_vertex_elements(r->cso, r->attrs_per_vertex, r->velems);
+ util_draw_user_vertex_buffer(r->cso, r->buffer, PIPE_PRIM_QUADS,
+ num_verts, /* verts */
+ r->attrs_per_vertex); /* attribs/vert */
+ r->buffer_size = 0;
}
static INLINE void
@@ -304,7 +283,7 @@ add_vertex_data2(struct xa_context *r,
src_s0, src_t1, mask_s0, mask_t1);
}
-static struct pipe_resource *
+static void
setup_vertex_data_yuv(struct xa_context *r,
float srcX,
float srcY,
@@ -337,8 +316,6 @@ setup_vertex_data_yuv(struct xa_context *r,
add_vertex_1tex(r, dstX + dstW, dstY + dstH, s1, t1);
/* 4th vertex */
add_vertex_1tex(r, dstX, dstY + dstH, s0, t1);
-
- return renderer_buffer_create(r);
}
/* Set up framebuffer, viewport and vertex shader constant buffer
@@ -408,7 +385,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
@@ -530,23 +507,17 @@ renderer_draw_yuv(struct xa_context *r,
int dst_x,
int dst_y, int dst_w, int dst_h, struct xa_surface *srf[])
{
- struct pipe_context *pipe = r->pipe;
- struct pipe_resource *buf = 0;
+ const int num_attribs = 2; /*pos + tex coord */
- buf = setup_vertex_data_yuv(r,
- src_x, src_y, src_w, src_h, dst_x, dst_y, dst_w,
- dst_h, srf);
+ setup_vertex_data_yuv(r,
+ src_x, src_y, src_w, src_h,
+ dst_x, dst_y, dst_w, dst_h, srf);
- if (buf) {
- const int num_attribs = 2; /*pos + tex coord */
-
- cso_set_vertex_elements(r->cso, num_attribs, r->velems);
-
- util_draw_vertex_buffer(pipe, r->cso, buf, 0, PIPE_PRIM_QUADS, 4, /* verts */
- num_attribs); /* attribs/vert */
-
- pipe_resource_reference(&buf, NULL);
- }
+ cso_set_vertex_elements(r->cso, num_attribs, r->velems);
+ util_draw_user_vertex_buffer(r->cso, r->buffer, PIPE_PRIM_QUADS,
+ 4, /* verts */
+ num_attribs); /* attribs/vert */
+ r->buffer_size = 0;
}
void
diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c
index 22e61cf7081..6a78abebcb1 100644
--- a/src/gallium/state_trackers/xorg/xorg_crtc.c
+++ b/src/gallium/state_trackers/xorg/xorg_crtc.c
@@ -55,7 +55,7 @@
#include "util/u_rect.h"
#ifdef HAVE_LIBKMS
-#include "libkms.h"
+#include "libkms/libkms.h"
#endif
struct crtc_private
diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c
index 0ade319cdc3..eb9d7f075ef 100644
--- a/src/gallium/state_trackers/xorg/xorg_driver.c
+++ b/src/gallium/state_trackers/xorg/xorg_driver.c
@@ -59,7 +59,7 @@
#include "xorg_winsys.h"
#ifdef HAVE_LIBKMS
-#include "libkms.h"
+#include "libkms/libkms.h"
#endif
/*
diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c
index eba72d81908..ca25b0912f1 100644
--- a/src/gallium/state_trackers/xorg/xorg_renderer.c
+++ b/src/gallium/state_trackers/xorg/xorg_renderer.c
@@ -42,44 +42,19 @@ static INLINE void map_point(float *mat, float x, float y,
}
}
-static INLINE struct pipe_resource *
-renderer_buffer_create(struct xorg_renderer *r)
-{
- struct pipe_resource *buf =
- pipe_user_buffer_create(r->pipe->screen,
- r->buffer,
- sizeof(float)*
- r->buffer_size,
-/* XXX was: PIPE_BUFFER_USAGE_PIXEL/PIPE_BUFFER_USAGE_GPU_WRITE even though this is a vertex buffer??? */
- PIPE_BIND_VERTEX_BUFFER);
- r->buffer_size = 0;
-
- return buf;
-}
-
static INLINE void
renderer_draw(struct xorg_renderer *r)
{
- struct pipe_context *pipe = r->pipe;
- struct pipe_resource *buf = 0;
int num_verts = r->buffer_size/(r->attrs_per_vertex * NUM_COMPONENTS);
if (!r->buffer_size)
return;
- buf = renderer_buffer_create(r);
-
-
- if (buf) {
- cso_set_vertex_elements(r->cso, r->attrs_per_vertex, r->velems);
+ cso_set_vertex_elements(r->cso, r->attrs_per_vertex, r->velems);
+ util_draw_user_vertex_buffer(r->cso, r->buffer, PIPE_PRIM_QUADS,
+ num_verts, r->attrs_per_vertex);
- util_draw_vertex_buffer(pipe, r->cso, buf, 0,
- PIPE_PRIM_QUADS,
- num_verts, /* verts */
- r->attrs_per_vertex); /* attribs/vert */
-
- pipe_resource_reference(&buf, NULL);
- }
+ r->buffer_size = 0;
}
static INLINE void
@@ -287,7 +262,7 @@ add_vertex_data2(struct xorg_renderer *r,
src_s0, src_t1, mask_s0, mask_t1);
}
-static struct pipe_resource *
+static void
setup_vertex_data_yuv(struct xorg_renderer *r,
float srcX, float srcY, float srcW, float srcH,
float dstX, float dstY, float dstW, float dstH,
@@ -317,8 +292,6 @@ setup_vertex_data_yuv(struct xorg_renderer *r,
/* 4th vertex */
add_vertex_1tex(r, dstX, dstY + dstH,
s0, t1);
-
- return renderer_buffer_create(r);
}
@@ -437,7 +410,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);
}
@@ -592,34 +565,26 @@ void renderer_copy_pixmap(struct xorg_renderer *r,
add_vertex_1tex(r, x0, y1, s0, t1);
}
-
-
-
void renderer_draw_yuv(struct xorg_renderer *r,
float src_x, float src_y, float src_w, float src_h,
int dst_x, int dst_y, int dst_w, int dst_h,
struct pipe_resource **textures)
{
- struct pipe_context *pipe = r->pipe;
- struct pipe_resource *buf = 0;
-
- buf = setup_vertex_data_yuv(r,
- src_x, src_y, src_w, src_h,
- dst_x, dst_y, dst_w, dst_h,
- textures);
+ const int num_attribs = 2; /*pos + tex coord*/
- if (buf) {
- const int num_attribs = 2; /*pos + tex coord*/
+ setup_vertex_data_yuv(r,
+ src_x, src_y, src_w, src_h,
+ dst_x, dst_y, dst_w, dst_h,
+ textures);
- cso_set_vertex_elements(r->cso, num_attribs, r->velems);
+ cso_set_vertex_elements(r->cso, num_attribs, r->velems);
- util_draw_vertex_buffer(pipe, r->cso, buf, 0,
- PIPE_PRIM_QUADS,
- 4, /* verts */
- num_attribs); /* attribs/vert */
+ util_draw_user_vertex_buffer(r->cso, r->buffer,
+ PIPE_PRIM_QUADS,
+ 4, /* verts */
+ num_attribs); /* attribs/vert */
- pipe_resource_reference(&buf, NULL);
- }
+ r->buffer_size = 0;
}
void renderer_begin_solid(struct xorg_renderer *r)