summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Oliveira <igor.oliveira@openbossa.org>2010-08-20 03:55:18 -0400
committerIgor Oliveira <igor.oliveira@openbossa.org>2010-08-20 04:08:15 -0400
commitcab8bd19263723a1350e6445ec3c5b4bd3911f0f (patch)
treecbcb1d0dff82947c6a572c448815112327060293
parentaae9df6b44a93b707f1720489e8c73cd2810815a (diff)
DRM/Gallium3D: code cleanup.
* move z surface creation for a function; * clear the stencil when creating the surface; * fix the wrong depth initialization in gallium_fill
-rw-r--r--src/drm/cairo-drm-gallium-surface.c87
1 files changed, 47 insertions, 40 deletions
diff --git a/src/drm/cairo-drm-gallium-surface.c b/src/drm/cairo-drm-gallium-surface.c
index b060ea6e..4d1879af 100644
--- a/src/drm/cairo-drm-gallium-surface.c
+++ b/src/drm/cairo-drm-gallium-surface.c
@@ -560,16 +560,47 @@ gallium_surface_release_source_image (void *abstract_surface,
}
static void
+_gallium_set_zbuffer(void *abstract_surface)
+{
+ gallium_surface_t *surface = abstract_surface;
+ gallium_device_t *device = gallium_device (surface);
+ struct pipe_surface *zsurface;
+ struct pipe_resource *resource;
+ struct pipe_resource template;
+
+ memset(&template, 0, sizeof(template));
+ template.target = PIPE_TEXTURE_2D;
+ template.format = PIPE_FORMAT_Z24_UNORM_S8_USCALED;
+ template.width0 = surface->drm.width;
+ template.height0 = surface->drm.height;
+ template.depth0 = 1;
+ template.last_level = 0;
+ template.bind = PIPE_BIND_DEPTH_STENCIL;
+ resource = device->screen->resource_create (device->screen,
+ &template);
+
+ zsurface = device->screen->get_tex_surface(device->pipe->screen,
+ resource,
+ 0, 0, 0,
+ PIPE_BIND_DEPTH_STENCIL);
+
+ device->framebuffer.zsbuf = zsurface;
+
+}
+
+static void
_gallium_set_states(void *abstract_surface)
{
gallium_surface_t *surface = abstract_surface;
gallium_device_t *device = gallium_device (surface);
- cso_set_framebuffer (device->cso, &device->framebuffer);
cso_set_blend (device->cso, &surface->blend);
cso_set_depth_stencil_alpha (device->cso, &surface->depthstencil);
cso_set_rasterizer (device->cso, &surface->rasterizer);
cso_set_viewport (device->cso, &device->viewport);
+
+ _gallium_set_zbuffer(abstract_surface);
+ cso_set_framebuffer (device->cso, &device->framebuffer);
}
static void
@@ -1083,32 +1114,6 @@ _gallium_fill (void *abstract_surface,
struct pipe_depth_stencil_alpha_state st;
struct pipe_stencil_ref sr;
-
- struct pipe_surface *zsurface;
- struct pipe_resource *resource;
- {
- struct pipe_resource template;
- memset(&template, 0, sizeof(template));
- template.target = PIPE_TEXTURE_2D;
- template.format = PIPE_FORMAT_Z24_UNORM_S8_USCALED;
- template.width0 = surface->drm.width;
- template.height0 = surface->drm.height;
- template.depth0 = 1;
- template.last_level = 0;
- template.bind = PIPE_BIND_DEPTH_STENCIL;
- resource = device->screen->resource_create (device->screen,
- &template);
-
- zsurface = device->screen->get_tex_surface(device->pipe->screen,
- resource,
- 0, 0, 0,
- PIPE_BIND_DEPTH_STENCIL);
-
- }
-
- device->framebuffer.zsbuf = zsurface;
- _gallium_set_states(abstract_surface);
-
{
struct pipe_blend_state blend;
@@ -1126,10 +1131,7 @@ _gallium_fill (void *abstract_surface,
memset(&sr, 0, sizeof(struct pipe_stencil_ref));
cso_set_stencil_ref(device->cso, &sr);
- device->pipe->clear(device->pipe, PIPE_CLEAR_DEPTHSTENCIL, NULL, 1.0, 0);
-
st.stencil[0].enabled = 1;
- st.depth.enabled = 1;
if (fill_rule == CAIRO_FILL_RULE_EVEN_ODD) {
// initialize stencil
st.stencil[0].func = PIPE_FUNC_ALWAYS;
@@ -1205,7 +1207,6 @@ _gallium_fill (void *abstract_surface,
cso_set_rasterizer(device->cso, &rasterizer);
// initialize stencil
- st.depth.enabled = 1;
st.stencil[0].enabled = 1;
st.stencil[0].func = PIPE_FUNC_ALWAYS;
st.stencil[0].fail_op = PIPE_STENCIL_OP_KEEP;
@@ -1258,7 +1259,6 @@ _gallium_fill (void *abstract_surface,
}
}
- st.depth.enabled = 0;
st.stencil[1].enabled = 0;
st.stencil[0].func = PIPE_FUNC_NOTEQUAL;
st.stencil[0].fail_op = PIPE_STENCIL_OP_REPLACE;
@@ -1266,7 +1266,6 @@ _gallium_fill (void *abstract_surface,
st.stencil[0].zpass_op = PIPE_STENCIL_OP_REPLACE;
st.stencil[0].valuemask = ~0;
st.stencil[0].writemask = ~0;
- st.stencil[1] = st.stencil[0];
cso_set_depth_stencil_alpha(device->cso, &st);
cso_restore_blend(device->cso);
@@ -1337,8 +1336,6 @@ gallium_surface_paint (void *abstract_surface,
status = _cairo_surface_paint (surface->fallback, op, source, clip);
}
- _gallium_set_states(surface);
-
cso_set_vertex_elements (device->cso, 2, surface->velem);
util_draw_vertex_buffer (device->pipe,
@@ -1402,8 +1399,6 @@ gallium_surface_stroke (void *abstract_surface,
_gallium_surface_paint_solid(abstract_surface, source, shader);
}
- _gallium_set_states(abstract_surface);
-
gallium_stroke = _gallium_init_stroke();
gallium_stroke->gallium_ctm = &surface->gallium_ctm;
_cairo_path_fixed_stroke_to_shaper(path,
@@ -1459,7 +1454,6 @@ gallium_surface_fill (void *abstract_surface,
_gallium_surface_paint_solid(abstract_surface, source, shader);
}
- _gallium_set_states(abstract_surface);
gallium_stroke = _gallium_init_stroke();
gallium_stroke->gallium_ctm = &surface->gallium_ctm;
_gallium_path_from_cairo(gallium_stroke, path);
@@ -1481,6 +1475,8 @@ gallium_surface_glyphs (void *abstract_surface,
int *num_remaining)
{
gallium_surface_t *surface = abstract_surface;
+ gallium_device_t *device = gallium_device(surface);
+ gallium_shader_t *shader = device->shader;
cairo_status_t status = CAIRO_INT_STATUS_UNSUPPORTED;
*num_remaining = 0;
@@ -1498,12 +1494,12 @@ gallium_surface_glyphs (void *abstract_surface,
return status;
}
- printf("\n\n\n\n");
status = gallium_surface_fill (abstract_surface, op, source,
&path, CAIRO_FILL_RULE_WINDING,
- 0.25, CAIRO_ANTIALIAS_SUBPIXEL,
+ 0.1, CAIRO_ANTIALIAS_SUBPIXEL,
clip);
+ _cairo_path_fixed_fini (&path);
}
return status;
@@ -1703,6 +1699,17 @@ gallium_surface_create_internal (gallium_device_t *device,
cairo_matrix_init_scale (&surface->gallium_ctm, 1.0/width, 1.0/height);
+ {
+ //an initial state to blend
+ surface->blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+ surface->blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+ surface->blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
+ surface->blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+ }
+
+ _gallium_set_states(surface);
+ device->pipe->clear(device->pipe, PIPE_CLEAR_DEPTHSTENCIL, NULL, 0.0, 0);
+
return &surface->drm.base;
}