summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/tgsi
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2010-05-06 14:38:55 -0600
committerBrian Paul <[email protected]>2010-05-06 15:19:02 -0600
commitc8f0e805a9e4c26eadc45bb1fd172b6702f581ab (patch)
tree625ab76385db95c21c8828000173ec7812544af6 /src/gallium/auxiliary/tgsi
parentfbb1ad33a42f91797327a099d6565d1c201099b4 (diff)
tgsi: fix tgsi_exec_machine_bind_shader() to handle NULL tokens, samplers
This lets us unbind a shader from the tgsi_exec_machine. Since shaders aren't ref counted we need this to properly clean up when deleting shaders elsewhere.
Diffstat (limited to 'src/gallium/auxiliary/tgsi')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index 63f2b8578bb..1218242653f 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -635,6 +635,23 @@ tgsi_exec_machine_bind_shader(
mach->Tokens = tokens;
mach->Samplers = samplers;
+ if (!tokens) {
+ /* unbind and free all */
+ if (mach->Declarations) {
+ FREE( mach->Declarations );
+ }
+ mach->Declarations = NULL;
+ mach->NumDeclarations = 0;
+
+ if (mach->Instructions) {
+ FREE( mach->Instructions );
+ }
+ mach->Instructions = NULL;
+ mach->NumInstructions = 0;
+
+ return;
+ }
+
k = tgsi_parse_init (&parse, mach->Tokens);
if (k != TGSI_PARSE_OK) {
debug_printf( "Problem parsing!\n" );
@@ -792,7 +809,9 @@ void
tgsi_exec_machine_destroy(struct tgsi_exec_machine *mach)
{
if (mach) {
- FREE(mach->Instructions);
+ if (mach->Instructions)
+ FREE(mach->Instructions);
+ if (mach->Declarations)
FREE(mach->Declarations);
}