/**************************************************************************
*
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2007 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "lp_context.h"
#include "lp_state.h"
#include "lp_texture.h"
+#include "lp_debug.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
state = CALLOC_STRUCT(lp_geometry_shader);
if (state == NULL )
- goto fail;
+ goto no_state;
/* debug */
- if (0)
+ if (LP_DEBUG & DEBUG_TGSI) {
+ debug_printf("llvmpipe: Create geometry shader %p:\n", (void *)state);
tgsi_dump(templ->tokens, 0);
+ }
- /* copy shader tokens, the ones passed in will go away.
- */
- state->shader.tokens = tgsi_dup_tokens(templ->tokens);
- if (state->shader.tokens == NULL)
- goto fail;
+ /* copy stream output info */
+ state->no_tokens = !templ->tokens;
+ memcpy(&state->stream_output, &templ->stream_output, sizeof state->stream_output);
- state->draw_data = draw_create_geometry_shader(llvmpipe->draw, templ);
- if (state->draw_data == NULL)
- goto fail;
+ if (templ->tokens) {
+ state->dgs = draw_create_geometry_shader(llvmpipe->draw, templ);
+ if (state->dgs == NULL) {
+ goto no_dgs;
+ }
+ }
return state;
-fail:
- if (state) {
- FREE( (void *)state->shader.tokens );
- FREE( state->draw_data );
- FREE( state );
- }
+no_dgs:
+ FREE( state );
+no_state:
return NULL;
}
llvmpipe->gs = (struct lp_geometry_shader *)gs;
draw_bind_geometry_shader(llvmpipe->draw,
- (llvmpipe->gs ? llvmpipe->gs->draw_data : NULL));
+ (llvmpipe->gs ? llvmpipe->gs->dgs : NULL));
llvmpipe->dirty |= LP_NEW_GS;
}
struct lp_geometry_shader *state =
(struct lp_geometry_shader *)gs;
- draw_delete_geometry_shader(llvmpipe->draw,
- (state) ? state->draw_data : 0);
- FREE( (void *)state->shader.tokens );
+ if (!state) {
+ return;
+ }
+
+ draw_delete_geometry_shader(llvmpipe->draw, state->dgs);
FREE(state);
}