summaryrefslogtreecommitdiff
path: root/src/gallium
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2008-04-21 17:17:27 +0100
committerKeith Whitwell <keith@tungstengraphics.com>2008-04-21 17:17:27 +0100
commit30b4dc29091347252bc61d3be9370db0a45c16c3 (patch)
tree719238bf9a9aacf235feb9c6452cffb3d1a56336 /src/gallium
parent0d4ece4c5a243dc4b684331bad49f220311e5520 (diff)
draw: more propogation -- pstipple stage.
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aaline.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_pstipple.c43
2 files changed, 33 insertions, 11 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index fbb5b45b40..7e5f8bd281 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -641,6 +641,7 @@ aaline_first_line(struct draw_stage *stage, struct prim_header *header)
*/
if (!bind_aaline_fragment_shader(aaline)) {
stage->line = draw_pipe_passthrough_line;
+ stage->line(stage, header);
return;
}
diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
index ac08aa10ce..61bdd29aa0 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
@@ -320,7 +320,7 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
* Generate the frag shader we'll use for doing polygon stipple.
* This will be the user's shader prefixed with a TEX and KIL instruction.
*/
-static void
+static boolean
generate_pstip_fs(struct pstip_stage *pstip)
{
const struct pipe_shader_state *orig_fs = &pstip->fs->state;
@@ -332,6 +332,8 @@ generate_pstip_fs(struct pstip_stage *pstip)
pstip_fs = *orig_fs; /* copy to init */
pstip_fs.tokens = MALLOC(sizeof(struct tgsi_token) * MAX);
+ if (pstip_fs.tokens == NULL)
+ return FALSE;
memset(&transform, 0, sizeof(transform));
transform.wincoordInput = -1;
@@ -355,6 +357,8 @@ generate_pstip_fs(struct pstip_stage *pstip)
assert(pstip->fs->sampler_unit < PIPE_MAX_SAMPLERS);
pstip->fs->pstip_fs = pstip->driver_create_fs_state(pstip->pipe, &pstip_fs);
+
+ return TRUE;
}
@@ -404,7 +408,7 @@ pstip_update_texture(struct pstip_stage *pstip)
/**
* Create the texture map we'll use for stippling.
*/
-static void
+static boolean
pstip_create_texture(struct pstip_stage *pstip)
{
struct pipe_context *pipe = pstip->pipe;
@@ -421,7 +425,10 @@ pstip_create_texture(struct pstip_stage *pstip)
texTemp.cpp = 1;
pstip->texture = screen->texture_create(screen, &texTemp);
- assert(pstip->texture->refcount == 1);
+ if (pstip->texture == NULL)
+ return FALSE;
+
+ return TRUE;
}
@@ -430,7 +437,7 @@ pstip_create_texture(struct pstip_stage *pstip)
* By using a mipmapped texture, we don't have to generate a different
* texture image for each line size.
*/
-static void
+static boolean
pstip_create_sampler(struct pstip_stage *pstip)
{
struct pipe_sampler_state sampler;
@@ -448,6 +455,10 @@ pstip_create_sampler(struct pstip_stage *pstip)
sampler.max_lod = 0.0f;
pstip->sampler_cso = pipe->create_sampler_state(pipe, &sampler);
+ if (pstip->sampler_cso == NULL)
+ return FALSE;
+
+ return TRUE;
}
@@ -455,13 +466,15 @@ pstip_create_sampler(struct pstip_stage *pstip)
* When we're about to draw our first AA line in a batch, this function is
* called to tell the driver to bind our modified fragment shader.
*/
-static void
+static boolean
bind_pstip_fragment_shader(struct pstip_stage *pstip)
{
- if (!pstip->fs->pstip_fs) {
- generate_pstip_fs(pstip);
- }
+ if (!pstip->fs->pstip_fs ||
+ !generate_pstip_fs(pstip))
+ return FALSE;
+
pstip->driver_bind_fs_state(pstip->pipe, pstip->fs->pstip_fs);
+ return TRUE;
}
@@ -486,7 +499,12 @@ pstip_first_tri(struct draw_stage *stage, struct prim_header *header)
assert(stage->draw->rasterizer->poly_stipple_enable);
/* bind our fragprog */
- bind_pstip_fragment_shader(pstip);
+ if (!bind_pstip_fragment_shader(pstip)) {
+ stage->tri = draw_pipe_passthrough_tri;
+ stage->tri(stage, header);
+ return;
+ }
+
/* how many samplers? */
/* we'll use sampler/texture[pstip->sampler_unit] for the stipple */
@@ -706,8 +724,11 @@ draw_install_pstipple_stage(struct draw_context *draw,
pstip->pipe = pipe;
/* create special texture, sampler state */
- pstip_create_texture(pstip);
- pstip_create_sampler(pstip);
+ if (!pstip_create_texture(pstip))
+ goto fail;
+
+ if (!pstip_create_sampler(pstip))
+ goto fail;
/* save original driver functions */
pstip->driver_create_fs_state = pipe->create_fs_state;