boolean
draw_install_aapoint_stage(struct draw_context *draw, struct pipe_context *pipe);
-void
+boolean
draw_install_pstipple_stage(struct draw_context *draw, struct pipe_context *pipe);
{
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
struct aaline_fragment_shader *aafs = CALLOC_STRUCT(aaline_fragment_shader);
+ if (aafs == NULL)
+ return NULL;
- if (aafs) {
- aafs->state = *fs;
+ aafs->state = *fs;
- /* pass-through */
- aafs->driver_fs = aaline->driver_create_fs_state(aaline->pipe, fs);
- }
+ /* pass-through */
+ aafs->driver_fs = aaline->driver_create_fs_state(aaline->pipe, fs);
return aafs;
}
{
struct aapoint_stage *aapoint = aapoint_stage_from_pipe(pipe);
struct aapoint_fragment_shader *aafs = CALLOC_STRUCT(aapoint_fragment_shader);
+ if (aafs == NULL)
+ return NULL;
- if (aafs) {
- aafs->state = *fs;
+ aafs->state = *fs;
- /* pass-through */
- aafs->driver_fs = aapoint->driver_create_fs_state(aapoint->pipe, fs);
- }
+ /* pass-through */
+ aafs->driver_fs = aapoint->driver_create_fs_state(aapoint->pipe, fs);
return aafs;
}
{
struct aapoint_stage *aapoint;
+ pipe->draw = (void *) draw;
/*
* Create / install AA point drawing / prim stage
pipe->bind_fs_state = aapoint_bind_fs_state;
pipe->delete_fs_state = aapoint_delete_fs_state;
- pipe->draw = (void *) draw;
draw->pipeline.aapoint = &aapoint->stage;
+ return TRUE;
+
fail:
if (aapoint)
aapoint->stage.destroy( &aapoint->stage );
struct draw_stage *draw_clip_stage( struct draw_context *draw )
{
struct clipper *clipper = CALLOC_STRUCT(clipper);
+ if (clipper == NULL)
+ goto fail;
- draw_alloc_temp_verts( &clipper->stage, MAX_CLIPPED_VERTICES+1 );
+ if (!draw_alloc_temp_verts( &clipper->stage, MAX_CLIPPED_VERTICES+1 ))
+ goto fail;
clipper->stage.draw = draw;
clipper->stage.point = clip_point;
clipper->plane = draw->plane;
return &clipper->stage;
+
+ fail:
+ if (clipper)
+ clipper->stage.destroy( &clipper->stage );
+
+ return NULL;
}
struct draw_stage *draw_cull_stage( struct draw_context *draw )
{
struct cull_stage *cull = CALLOC_STRUCT(cull_stage);
+ if (cull == NULL)
+ goto fail;
- draw_alloc_temp_verts( &cull->stage, 0 );
+ if (!draw_alloc_temp_verts( &cull->stage, 0 ))
+ goto fail;
cull->stage.draw = draw;
cull->stage.next = NULL;
cull->stage.destroy = cull_destroy;
return &cull->stage;
+
+ fail:
+ if (cull)
+ cull->stage.destroy( &cull->stage );
+
+ return NULL;
}
struct draw_stage *draw_flatshade_stage( struct draw_context *draw )
{
struct flat_stage *flatshade = CALLOC_STRUCT(flat_stage);
+ if (flatshade == NULL)
+ goto fail;
- draw_alloc_temp_verts( &flatshade->stage, 2 );
+ if (!draw_alloc_temp_verts( &flatshade->stage, 2 ))
+ goto fail;
flatshade->stage.draw = draw;
flatshade->stage.next = NULL;
flatshade->stage.destroy = flatshade_destroy;
return &flatshade->stage;
+
+ fail:
+ if (flatshade)
+ flatshade->stage.destroy( &flatshade->stage );
+
+ return NULL;
}
struct draw_stage *draw_offset_stage( struct draw_context *draw )
{
struct offset_stage *offset = CALLOC_STRUCT(offset_stage);
+ if (offset == NULL)
+ goto fail;
draw_alloc_temp_verts( &offset->stage, 3 );
offset->stage.destroy = offset_destroy;
return &offset->stage;
+
+ fail:
+ if (offset)
+ offset->stage.destroy( &offset->stage );
+
+ return NULL;
}
* into the draw module's pipeline. This will not be used if the
* hardware has native support for AA lines.
*/
-void
+boolean
draw_install_pstipple_stage(struct draw_context *draw,
struct pipe_context *pipe)
{
* Create / install AA line drawing / prim stage
*/
pstip = draw_pstip_stage( draw );
- assert(pstip);
+ if (pstip == NULL)
+ goto fail;
+
draw->pipeline.pstipple = &pstip->stage;
pstip->pipe = pipe;
pipe->bind_sampler_states = pstip_bind_sampler_states;
pipe->set_sampler_textures = pstip_set_sampler_textures;
pipe->set_polygon_stipple = pstip_set_polygon_stipple;
+
+ return TRUE;
+
+ fail:
+ if (pstip)
+ pstip->stage.destroy( &pstip->stage );
+
+ return FALSE;
}
struct draw_stage *draw_twoside_stage( struct draw_context *draw )
{
struct twoside_stage *twoside = CALLOC_STRUCT(twoside_stage);
+ if (twoside == NULL)
+ goto fail;
- draw_alloc_temp_verts( &twoside->stage, 3 );
+ if (!draw_alloc_temp_verts( &twoside->stage, 3 ))
+ goto fail;
twoside->stage.draw = draw;
twoside->stage.next = NULL;
twoside->stage.destroy = twoside_destroy;
return &twoside->stage;
+
+ fail:
+ if (twoside)
+ twoside->stage.destroy( &twoside->stage );
+
+ return NULL;
}
struct draw_stage *draw_unfilled_stage( struct draw_context *draw )
{
struct unfilled_stage *unfilled = CALLOC_STRUCT(unfilled_stage);
+ if (unfilled == NULL)
+ goto fail;
- draw_alloc_temp_verts( &unfilled->stage, 0 );
+ if (!draw_alloc_temp_verts( &unfilled->stage, 0 ))
+ goto fail;
unfilled->stage.draw = draw;
unfilled->stage.next = NULL;
unfilled->stage.destroy = unfilled_destroy;
return &unfilled->stage;
+
+ fail:
+ if (unfilled)
+ unfilled->stage.destroy( &unfilled->stage );
+
+ return NULL;
}
*/
boolean draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr )
{
- unsigned i;
- ubyte *store;
-
assert(!stage->tmp);
stage->tmp = NULL;
stage->nr_tmps = nr;
- if (nr == 0)
- return FALSE;
- store = (ubyte *) MALLOC( MAX_VERTEX_SIZE * nr );
- if (store == NULL)
- return FALSE;
+ if (nr != 0)
+ {
+ unsigned i;
+ ubyte *store = (ubyte *) MALLOC( MAX_VERTEX_SIZE * nr );
+
+ if (store == NULL)
+ return FALSE;
- stage->tmp = (struct vertex_header **) MALLOC( sizeof(struct vertex_header *) * nr );
-
- for (i = 0; i < nr; i++)
- stage->tmp[i] = (struct vertex_header *)(store + i * MAX_VERTEX_SIZE);
+ stage->tmp = (struct vertex_header **) MALLOC( sizeof(struct vertex_header *) * nr );
+ if (stage->tmp == NULL) {
+ FREE(store);
+ return FALSE;
+ }
+
+ for (i = 0; i < nr; i++)
+ stage->tmp[i] = (struct vertex_header *)(store + i * MAX_VERTEX_SIZE);
+ }
return TRUE;
}
struct draw_stage *draw_validate_stage( struct draw_context *draw )
{
struct draw_stage *stage = CALLOC_STRUCT(draw_stage);
+ if (stage == NULL)
+ return NULL;
stage->draw = draw;
stage->next = NULL;
struct vbuf_render *render )
{
struct vbuf_stage *vbuf = CALLOC_STRUCT(vbuf_stage);
-
- if(!vbuf)
+ if (vbuf == NULL)
goto fail;
vbuf->stage.draw = draw;
vbuf->indices = (ushort *) align_malloc( vbuf->max_indices *
sizeof(vbuf->indices[0]),
16 );
- if(!vbuf->indices)
+ if (!vbuf->indices)
goto fail;
vbuf->vertices = NULL;
struct draw_stage *draw_wide_point_stage( struct draw_context *draw )
{
struct widepoint_stage *wide = CALLOC_STRUCT(widepoint_stage);
+ if (wide == NULL)
+ goto fail;
- draw_alloc_temp_verts( &wide->stage, 4 );
+ if (!draw_alloc_temp_verts( &wide->stage, 4 ))
+ goto fail;
wide->stage.draw = draw;
wide->stage.next = NULL;
wide->stage.destroy = widepoint_destroy;
return &wide->stage;
+
+ fail:
+ if (wide)
+ wide->stage.destroy( &wide->stage );
+
+ return NULL;
}
struct draw_pt_middle_end *draw_pt_fetch_emit( struct draw_context *draw )
{
struct fetch_emit_middle_end *fetch_emit = CALLOC_STRUCT( fetch_emit_middle_end );
+ if (fetch_emit == NULL)
+ return NULL;
fetch_emit->base.prepare = fetch_emit_prepare;
fetch_emit->base.run = fetch_emit_run;
(struct vertex_header *)MALLOC(fpme->vertex_size * fetch_count);
if (!pipeline_verts) {
+ /* Not much we can do here - just skip the rendering.
+ */
assert(0);
return;
}
struct draw_pt_front_end *draw_pt_vcache( struct draw_context *draw )
{
struct vcache_frontend *vcache = CALLOC_STRUCT( vcache_frontend );
+ if (vcache == NULL)
+ return NULL;
vcache->base.prepare = vcache_prepare;
vcache->base.run = NULL;