From ebb960c6d31ffd8fe73d849abf6a917d112cb843 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 17 Jul 2018 14:21:42 -0700 Subject: [PATCH] iris: compile a TCS...don't bother with passthrough yet --- src/gallium/drivers/iris/iris_program.c | 62 ++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/iris/iris_program.c b/src/gallium/drivers/iris/iris_program.c index 7a11840590e..1a425eb5333 100644 --- a/src/gallium/drivers/iris/iris_program.c +++ b/src/gallium/drivers/iris/iris_program.c @@ -386,10 +386,70 @@ get_unified_tess_slots(const struct iris_context *ice, } } +static bool +iris_compile_tcs(struct iris_context *ice, + struct iris_uncompiled_shader *ish, + const struct brw_tcs_prog_key *key) +{ + struct iris_screen *screen = (struct iris_screen *)ice->ctx.screen; + const struct brw_compiler *compiler = screen->compiler; + const struct gen_device_info *devinfo = &screen->devinfo; + void *mem_ctx = ralloc_context(NULL); + struct brw_tcs_prog_data *tcs_prog_data = + rzalloc(mem_ctx, struct brw_tcs_prog_data); + struct brw_vue_prog_data *vue_prog_data = &tcs_prog_data->base; + struct brw_stage_prog_data *prog_data = &vue_prog_data->base; + + assert(ish->base.type == PIPE_SHADER_IR_NIR); + + nir_shader *nir = ish->base.ir.nir; + + assign_common_binding_table_offsets(devinfo, nir, prog_data, 0); + + iris_setup_uniforms(compiler, mem_ctx, nir, prog_data); + + char *error_str = NULL; + const unsigned *program = + brw_compile_tcs(compiler, &ice->dbg, mem_ctx, key, tcs_prog_data, nir, + -1, &error_str); + if (program == NULL) { + dbg_printf("Failed to compile evaluation shader: %s\n", error_str); + ralloc_free(mem_ctx); + return false; + } + + iris_setup_push_uniform_range(compiler, prog_data); + + iris_upload_and_bind_shader(ice, IRIS_CACHE_TCS, key, program, prog_data, + NULL); + + ralloc_free(mem_ctx); + return true; +} + static void iris_update_compiled_tcs(struct iris_context *ice) { - // XXX: TCS + struct iris_uncompiled_shader *tcs = + ice->shaders.uncompiled[MESA_SHADER_TESS_CTRL]; + + if (!tcs) + return; + + const struct shader_info *tes_info = + get_shader_info(ice, MESA_SHADER_TESS_EVAL); + struct brw_tcs_prog_key key = { + .program_string_id = tcs->program_id, + .tes_primitive_mode = tes_info->tess.primitive_mode, + }; + get_unified_tess_slots(ice, &key.outputs_written, + &key.patch_outputs_written); + ice->vtbl.populate_tcs_key(ice, &key); + + if (iris_bind_cached_shader(ice, IRIS_CACHE_TCS, &key)) + return; + + UNUSED bool success = iris_compile_tcs(ice, tcs, &key); } static bool -- 2.30.2