tests: allow passing shader strings directly.

This makes writing tests using text shaders possible
macos/master
Dave Airlie 10 years ago
parent fcaeadc4ad
commit 91ec75a503
  1. 12
      tests/testvirgl_encode.c
  2. 3
      tests/testvirgl_encode.h

@ -178,16 +178,19 @@ int virgl_encode_rasterizer_state(struct virgl_context *ctx,
int virgl_encode_shader_state(struct virgl_context *ctx,
uint32_t handle,
uint32_t type,
const struct pipe_shader_state *shader)
const struct pipe_shader_state *shader,
const char *shad_str)
{
char *str;
uint32_t shader_len, len;
int i;
int ret;
uint32_t tmp;
int num_tokens = tgsi_num_tokens(shader->tokens);
int num_tokens;
int str_total_size = 65536;
if (!shad_str) {
num_tokens = tgsi_num_tokens(shader->tokens);
str = CALLOC(1, str_total_size);
if (!str)
return -1;
@ -198,6 +201,10 @@ int virgl_encode_shader_state(struct virgl_context *ctx,
FREE(str);
return -1;
}
} else {
num_tokens = 0;
str = (char *)shad_str;
}
shader_len = strlen(str) + 1;
len = ((shader_len + 3) / 4) + VIRGL_OBJ_SHADER_HDR_SIZE(shader->stream_output.num_outputs);
@ -222,6 +229,7 @@ int virgl_encode_shader_state(struct virgl_context *ctx,
}
virgl_encoder_write_block(ctx->cbuf, (uint8_t *)str, shader_len);
if (str != shad_str)
FREE(str);
return 0;
}

@ -49,7 +49,8 @@ extern int virgl_encode_rasterizer_state(struct virgl_context *ctx,
extern int virgl_encode_shader_state(struct virgl_context *ctx,
uint32_t handle,
uint32_t type,
const struct pipe_shader_state *shader);
const struct pipe_shader_state *shader,
const char *shad_str);
int virgl_encode_stream_output_info(struct virgl_context *ctx,
uint32_t handle,

Loading…
Cancel
Save