* 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;
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;
assert(pstip->fs->sampler_unit < PIPE_MAX_SAMPLERS);
pstip->fs->pstip_fs = pstip->driver_create_fs_state(pstip->pipe, &pstip_fs);
+
+ return TRUE;
}
/**
* 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;
texTemp.cpp = 1;
pstip->texture = screen->texture_create(screen, &texTemp);
- assert(pstip->texture->refcount == 1);
+ if (pstip->texture == NULL)
+ return FALSE;
+
+ return TRUE;
}
* 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;
sampler.max_lod = 0.0f;
pstip->sampler_cso = pipe->create_sampler_state(pipe, &sampler);
+ if (pstip->sampler_cso == NULL)
+ return FALSE;
+
+ return TRUE;
}
* 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;
}
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 */
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;