Esempio n. 1
0
static void *
svga_create_gs_state(struct pipe_context *pipe,
                     const struct pipe_shader_state *templ)
{
   struct svga_context *svga = svga_context(pipe);
   struct svga_geometry_shader *gs = CALLOC_STRUCT(svga_geometry_shader);

   if (!gs)
      return NULL;

   SVGA_STATS_TIME_PUSH(svga_sws(svga), SVGA_STATS_TIME_CREATEGS);

   gs->base.tokens = tgsi_dup_tokens(templ->tokens);

   /* Collect basic info that we'll need later:
    */
   tgsi_scan_shader(gs->base.tokens, &gs->base.info);

   gs->draw_shader = draw_create_geometry_shader(svga->swtnl.draw, templ);

   gs->base.id = svga->debug.shader_id++;

   gs->generic_outputs = svga_get_generic_outputs_mask(&gs->base.info);

   /* check for any stream output declarations */
   if (templ->stream_output.num_outputs) {
      gs->base.stream_output = svga_create_stream_output(svga, &gs->base,
                                                         &templ->stream_output);
   }

   SVGA_STATS_TIME_POP(svga_sws(svga));
   return gs;
}
Esempio n. 2
0
static void *
llvmpipe_create_gs_state(struct pipe_context *pipe,
                         const struct pipe_shader_state *templ)
{
   struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
   struct lp_geometry_shader *state;

   state = CALLOC_STRUCT(lp_geometry_shader);
   if (!state)
      goto no_state;

   /* debug */
   if (LP_DEBUG & DEBUG_TGSI) {
      debug_printf("llvmpipe: Create geometry shader %p:\n", (void *)state);
      tgsi_dump(templ->tokens, 0);
   }

   /* copy stream output info */
   state->no_tokens = !templ->tokens;
   memcpy(&state->stream_output, &templ->stream_output, sizeof state->stream_output);

   if (templ->tokens) {
      state->dgs = draw_create_geometry_shader(llvmpipe->draw, templ);
      if (state->dgs == NULL) {
         goto no_dgs;
      }
   }

   return state;

no_dgs:
   FREE( state );
no_state:
   return NULL;
}
Esempio n. 3
0
static void *
llvmpipe_create_gs_state(struct pipe_context *pipe,
                         const struct pipe_shader_state *templ)
{
    struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
    struct lp_geometry_shader *state;

    state = CALLOC_STRUCT(lp_geometry_shader);
    if (state == NULL )
        goto fail;

    /* debug */
    if (0)
        tgsi_dump(templ->tokens, 0);

    /* copy stream output info */
    state->shader = *templ;
    if (templ->tokens) {
        /* 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;

        state->draw_data = draw_create_geometry_shader(llvmpipe->draw, templ);
        if (state->draw_data == NULL)
            goto fail;
    }

    return state;

fail:
    if (state) {
        FREE( (void *)state->shader.tokens );
        FREE( state->draw_data );
        FREE( state );
    }
    return NULL;
}