diff options
author | Chia-I Wu <[email protected]> | 2013-06-20 16:34:25 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2013-06-25 12:42:04 +0800 |
commit | d209da5e338ee1f437cbce21e9cba667d60ee557 (patch) | |
tree | 23fc047677dde5b9d592cdab65897d6032d1cdf9 /src/gallium/drivers/ilo/ilo_shader.c | |
parent | 5c8db569abf3f1e508d57cccb95856936bce29e4 (diff) |
ilo: introduce ilo_shader_cso for VS
When a new VS kernel is generated, a newly added function,
ilo_gpe_init_vs_cso(), is called to construct 3DSTATE_VS command in
ilo_shader_cso. When the command needs to be emitted later, we copy the
command from the CSO instead of constructing it dynamically.
Diffstat (limited to 'src/gallium/drivers/ilo/ilo_shader.c')
-rw-r--r-- | src/gallium/drivers/ilo/ilo_shader.c | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/src/gallium/drivers/ilo/ilo_shader.c b/src/gallium/drivers/ilo/ilo_shader.c index 21faf773e59..983cfffc851 100644 --- a/src/gallium/drivers/ilo/ilo_shader.c +++ b/src/gallium/drivers/ilo/ilo_shader.c @@ -613,18 +613,12 @@ ilo_shader_state_search_variant(struct ilo_shader_state *state, /** * Add a shader variant to the shader state. */ -struct ilo_shader * +static struct ilo_shader * ilo_shader_state_add_variant(struct ilo_shader_state *state, const struct ilo_shader_variant *variant) { struct ilo_shader *sh; - sh = ilo_shader_state_search_variant(state, variant); - if (sh) - return sh; - - ilo_shader_state_gc(state); - switch (state->info.type) { case PIPE_SHADER_VERTEX: sh = ilo_shader_compile_vs(state, variant); @@ -663,10 +657,18 @@ ilo_shader_state_use_variant(struct ilo_shader_state *state, const struct ilo_shader_variant *variant) { struct ilo_shader *sh; + bool construct_cso = false; - sh = ilo_shader_state_add_variant(state, variant); - if (!sh) - return false; + sh = ilo_shader_state_search_variant(state, variant); + if (!sh) { + ilo_shader_state_gc(state); + + sh = ilo_shader_state_add_variant(state, variant); + if (!sh) + return false; + + construct_cso = true; + } /* move to head */ if (state->variants.next != &sh->list) { @@ -676,6 +678,16 @@ ilo_shader_state_use_variant(struct ilo_shader_state *state, state->shader = sh; + if (construct_cso) { + switch (state->info.type) { + case PIPE_SHADER_VERTEX: + ilo_gpe_init_vs_cso(state->info.dev, state, &sh->cso); + break; + default: + break; + } + } + return true; } @@ -896,3 +908,16 @@ ilo_shader_get_kernel_param(const struct ilo_shader_state *shader, return val; } + +/** + * Return the CSO of the selected kernel. + */ +const struct ilo_shader_cso * +ilo_shader_get_kernel_cso(const struct ilo_shader_state *shader) +{ + const struct ilo_shader *kernel = shader->shader; + + assert(kernel); + + return &kernel->cso; +} |