summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/softpipe/sp_quad_fs.c
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2009-07-15 23:44:53 +0100
committerKeith Whitwell <keithw@vmware.com>2009-07-16 09:53:07 +0100
commit6175653d0bceedba1f599d27111bab14f312f134 (patch)
treeadf7ba396a1621549b4842d047709129dc87646a /src/gallium/drivers/softpipe/sp_quad_fs.c
parent3a3b83e5112b725e22f05b32a273a2351b820944 (diff)
gallium: proper constructor and destructor for tgsi_exec_machine
Centralize the creation, initialization and destruction of this struct. Use align_malloc instead of home-brew alternatives.
Diffstat (limited to 'src/gallium/drivers/softpipe/sp_quad_fs.c')
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_fs.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c
index ca637a1d6a4..28f8d1a60ea 100644
--- a/src/gallium/drivers/softpipe/sp_quad_fs.c
+++ b/src/gallium/drivers/softpipe/sp_quad_fs.c
@@ -52,7 +52,7 @@
struct quad_shade_stage
{
struct quad_stage stage; /**< base class */
- struct tgsi_exec_machine machine;
+ struct tgsi_exec_machine *machine;
struct tgsi_exec_vector *inputs, *outputs;
};
@@ -73,7 +73,7 @@ shade_quad(struct quad_stage *qs, struct quad_header *quad)
{
struct quad_shade_stage *qss = quad_shade_stage( qs );
struct softpipe_context *softpipe = qs->softpipe;
- struct tgsi_exec_machine *machine = &qss->machine;
+ struct tgsi_exec_machine *machine = qss->machine;
boolean z_written;
/* Consts do not require 16 byte alignment. */
@@ -146,7 +146,7 @@ shade_begin(struct quad_stage *qs)
struct softpipe_context *softpipe = qs->softpipe;
softpipe->fs->prepare( softpipe->fs,
- &qss->machine,
+ qss->machine,
(struct tgsi_sampler **)
softpipe->tgsi.frag_samplers_list );
@@ -159,9 +159,8 @@ shade_destroy(struct quad_stage *qs)
{
struct quad_shade_stage *qss = (struct quad_shade_stage *) qs;
- tgsi_exec_machine_free_data(&qss->machine);
- FREE( qss->inputs );
- FREE( qss->outputs );
+ tgsi_exec_machine_destroy(qss->machine);
+
FREE( qs );
}
@@ -170,19 +169,24 @@ struct quad_stage *
sp_quad_shade_stage( struct softpipe_context *softpipe )
{
struct quad_shade_stage *qss = CALLOC_STRUCT(quad_shade_stage);
-
- /* allocate storage for program inputs/outputs, aligned to 16 bytes */
- qss->inputs = MALLOC(PIPE_MAX_ATTRIBS * sizeof(*qss->inputs) + 16);
- qss->outputs = MALLOC(PIPE_MAX_ATTRIBS * sizeof(*qss->outputs) + 16);
- qss->machine.Inputs = align16(qss->inputs);
- qss->machine.Outputs = align16(qss->outputs);
+ if (!qss)
+ goto fail;
qss->stage.softpipe = softpipe;
qss->stage.begin = shade_begin;
qss->stage.run = shade_quad;
qss->stage.destroy = shade_destroy;
- tgsi_exec_machine_init( &qss->machine );
+ qss->machine = tgsi_exec_machine_create();
+ if (!qss->machine)
+ goto fail;
return &qss->stage;
+
+fail:
+ if (qss && qss->machine)
+ tgsi_exec_machine_destroy(qss->machine);
+
+ FREE(qss);
+ return NULL;
}