vc4: Tell state_tracker that we would prefer NIR.

Before this series, the code generation path was:

GLSL IR -> TGSI -> NIR -> NIR clone -> QIR -> QPU

Now it's (generally)

GLSL IR -> NIR -> NIR clone -> QIR -> QPU
This commit is contained in:
Eric Anholt 2016-05-17 13:04:20 -07:00
parent d08f09c24e
commit 47e3cc7557
3 changed files with 31 additions and 8 deletions

View File

@ -1971,8 +1971,16 @@ static const nir_shader_compiler_options nir_options = {
.lower_fsat = true,
.lower_fsqrt = true,
.lower_negate = true,
.native_integers = true,
};
const void *
vc4_screen_get_compiler_options(struct pipe_screen *pscreen,
enum pipe_shader_ir ir, unsigned shader)
{
return &nir_options;
}
static int
count_nir_instrs(nir_shader *nir)
{
@ -2181,14 +2189,24 @@ vc4_shader_state_create(struct pipe_context *pctx,
so->program_id = vc4->next_uncompiled_program_id++;
if (vc4_debug & VC4_DEBUG_TGSI) {
fprintf(stderr, "prog %d TGSI:\n",
so->program_id);
tgsi_dump(cso->tokens, 0);
fprintf(stderr, "\n");
}
nir_shader *s;
nir_shader *s = tgsi_to_nir(cso->tokens, &nir_options);
if (cso->type == PIPE_SHADER_IR_NIR) {
/* The backend takes ownership of the NIR shader on state
* creation.
*/
s = cso->ir.nir;
} else {
assert(cso->type == PIPE_SHADER_IR_TGSI);
if (vc4_debug & VC4_DEBUG_TGSI) {
fprintf(stderr, "prog %d TGSI:\n",
so->program_id);
tgsi_dump(cso->tokens, 0);
fprintf(stderr, "\n");
}
s = tgsi_to_nir(cso->tokens, &nir_options);
}
NIR_PASS_V(s, nir_opt_global_to_local);
NIR_PASS_V(s, nir_convert_to_ssa);

View File

@ -386,7 +386,7 @@ vc4_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader,
case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS:
return VC4_MAX_TEXTURE_SAMPLERS;
case PIPE_SHADER_CAP_PREFERRED_IR:
return PIPE_SHADER_IR_TGSI;
return PIPE_SHADER_IR_NIR;
case PIPE_SHADER_CAP_SUPPORTED_IRS:
return 0;
case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT:
@ -633,6 +633,7 @@ vc4_screen_create(int fd)
pscreen->get_name = vc4_screen_get_name;
pscreen->get_vendor = vc4_screen_get_vendor;
pscreen->get_device_vendor = vc4_screen_get_vendor;
pscreen->get_compiler_options = vc4_screen_get_compiler_options;
return pscreen;

View File

@ -100,6 +100,10 @@ struct vc4_bo *
vc4_screen_bo_from_handle(struct pipe_screen *pscreen,
struct winsys_handle *whandle);
const void *
vc4_screen_get_compiler_options(struct pipe_screen *pscreen,
enum pipe_shader_ir ir, unsigned shader);
extern uint32_t vc4_debug;
void