}
-static INLINE boolean
+static inline boolean
reserve(struct svga_shader_emitter *emit, unsigned nr_dwords)
{
if (emit->ptr - emit->buf + nr_dwords * sizeof(unsigned) >= emit->size) {
* can be dynamically grown. Once we've finished and know how large
* it is, it will be copied to a hardware buffer for upload.
*/
-static struct svga_shader_result *
+static struct svga_shader_variant *
svga_tgsi_translate(const struct svga_shader *shader,
- struct svga_compile_key key, unsigned unit)
+ const struct svga_compile_key *key, unsigned unit)
{
- struct svga_shader_result *result = NULL;
+ struct svga_shader_variant *variant = NULL;
struct svga_shader_emitter emit;
memset(&emit, 0, sizeof(emit));
emit.ptr = emit.buf;
emit.unit = unit;
- emit.key = key;
+ emit.key = *key;
tgsi_scan_shader(shader->tokens, &emit.info);
emit.imm_start = emit.info.file_max[TGSI_FILE_CONSTANT] + 1;
if (unit == PIPE_SHADER_FRAGMENT)
- emit.imm_start += key.fkey.num_unnormalized_coords;
+ emit.imm_start += key->fkey.num_unnormalized_coords;
if (unit == PIPE_SHADER_VERTEX) {
- emit.imm_start += key.vkey.need_prescale ? 2 : 0;
+ emit.imm_start += key->vkey.need_prescale ? 2 : 0;
}
emit.nr_hw_float_const =
goto fail;
}
- result = CALLOC_STRUCT(svga_shader_result);
- if (result == NULL)
+ variant = CALLOC_STRUCT(svga_shader_variant);
+ if (variant == NULL)
goto fail;
- result->shader = shader;
- result->tokens = (const unsigned *) emit.buf;
- result->nr_tokens = (emit.ptr - emit.buf) / sizeof(unsigned);
- memcpy(&result->key, &key, sizeof key);
- result->id = UTIL_BITMASK_INVALID_INDEX;
+ variant->shader = shader;
+ variant->tokens = (const unsigned *) emit.buf;
+ variant->nr_tokens = (emit.ptr - emit.buf) / sizeof(unsigned);
+ memcpy(&variant->key, key, sizeof(*key));
+ variant->id = UTIL_BITMASK_INVALID_INDEX;
if (SVGA_DEBUG & DEBUG_TGSI) {
debug_printf("#####################################\n");
tgsi_dump(shader->tokens, 0);
if (SVGA_DEBUG & DEBUG_TGSI) {
debug_printf("Shader %u compiled below\n", shader->id);
- svga_shader_dump(result->tokens, result->nr_tokens, FALSE);
+ svga_shader_dump(variant->tokens, variant->nr_tokens, FALSE);
}
debug_printf("#####################################\n");
}
- return result;
+ return variant;
fail:
- FREE(result);
+ FREE(variant);
FREE(emit.buf);
return NULL;
}
-struct svga_shader_result *
+struct svga_shader_variant *
svga_translate_fragment_program(const struct svga_fragment_shader *fs,
const struct svga_fs_compile_key *fkey)
{
memcpy(key.generic_remap_table, fs->generic_remap_table,
sizeof(fs->generic_remap_table));
- return svga_tgsi_translate(&fs->base, key, PIPE_SHADER_FRAGMENT);
+ return svga_tgsi_translate(&fs->base, &key, PIPE_SHADER_FRAGMENT);
}
-struct svga_shader_result *
+struct svga_shader_variant *
svga_translate_vertex_program(const struct svga_vertex_shader *vs,
const struct svga_vs_compile_key *vkey)
{
*/
svga_remap_generics(vkey->fs_generic_inputs, key.generic_remap_table);
- return svga_tgsi_translate(&vs->base, key, PIPE_SHADER_VERTEX);
-}
-
-
-void
-svga_destroy_shader_result(struct svga_shader_result *result)
-{
- FREE((unsigned *) result->tokens);
- FREE(result);
+ return svga_tgsi_translate(&vs->base, &key, PIPE_SHADER_VERTEX);
}