#define TGSI_DEBUG 0
-/** XXX we should use the version of this from u_memory.h but including
- * that header causes symbol collisions.
- */
-static INLINE void *
-mem_dup(const void *src, uint size)
-{
- void *dup = _mesa_malloc(size);
- if (dup)
- _mesa_memcpy(dup, src, size);
- return dup;
-}
-
-
-
/**
* Translate a Mesa vertex shader into a TGSI shader.
* \param outputMapping to map vertex program output registers (VERT_RESULT_x)
const ubyte *outputSemanticIndex)
{
struct pipe_context *pipe = st->pipe;
- struct tgsi_token tokens[ST_MAX_SHADER_TOKENS];
+ struct tgsi_token *tokens;
GLuint defaultOutputMapping[VERT_RESULT_MAX];
struct pipe_shader_state vs;
GLuint attr, i;
GLbitfield input_flags[MAX_PROGRAM_INPUTS];
GLbitfield output_flags[MAX_PROGRAM_OUTPUTS];
+ tokens = (struct tgsi_token *)MALLOC(ST_MAX_SHADER_TOKENS * sizeof *tokens);
+ if(!tokens) {
+ /* FIXME: propagate error to the caller */
+ assert(0);
+ return;
+ }
+
memset(&vs, 0, sizeof(vs));
memset(input_flags, 0, sizeof(input_flags));
memset(output_flags, 0, sizeof(output_flags));
assert(num_tokens < ST_MAX_SHADER_TOKENS);
vs.tokens = (struct tgsi_token *)
- mem_dup(tokens, num_tokens * sizeof(tokens[0]));
+ _mesa_realloc(tokens,
+ ST_MAX_SHADER_TOKENS * sizeof *tokens,
+ num_tokens * sizeof *tokens);
stvp->num_inputs = vs_num_inputs;
stvp->state = vs; /* struct copy */
const GLuint inputMapping[])
{
struct pipe_context *pipe = st->pipe;
- struct tgsi_token tokens[ST_MAX_SHADER_TOKENS];
+ struct tgsi_token *tokens;
GLuint outputMapping[FRAG_RESULT_MAX];
GLuint defaultInputMapping[FRAG_ATTRIB_MAX];
struct pipe_shader_state fs;
GLbitfield input_flags[MAX_PROGRAM_INPUTS];
GLbitfield output_flags[MAX_PROGRAM_OUTPUTS];
+ tokens = (struct tgsi_token *)MALLOC(ST_MAX_SHADER_TOKENS * sizeof *tokens);
+ if(!tokens) {
+ /* FIXME: propagate error to the caller */
+ assert(0);
+ return;
+ }
+
memset(&fs, 0, sizeof(fs));
memset(input_flags, 0, sizeof(input_flags));
memset(output_flags, 0, sizeof(output_flags));
assert(num_tokens < ST_MAX_SHADER_TOKENS);
fs.tokens = (struct tgsi_token *)
- mem_dup(tokens, num_tokens * sizeof(tokens[0]));
+ _mesa_realloc(tokens,
+ ST_MAX_SHADER_TOKENS * sizeof *tokens,
+ num_tokens * sizeof *tokens);
stfp->state = fs; /* struct copy */
stfp->driver_shader = pipe->create_fs_state(pipe, &fs);