mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 19:40:10 +01:00
ir3: Add ir3_shader_create_variant()
This is similar to ir3_shader_get_variant(), but always compiles the variant from scratch and returns a variant that's owned by the user rather than the shader. We'll need this because when variants are stored in the Vulkan pipeline cache they will outlive their shader. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16147>
This commit is contained in:
parent
ea646ac9af
commit
3e3f8b1639
2 changed files with 18 additions and 6 deletions
|
|
@ -314,9 +314,8 @@ compile_variant(struct ir3_shader *shader, struct ir3_shader_variant *v)
|
|||
*/
|
||||
static struct ir3_shader_variant *
|
||||
alloc_variant(struct ir3_shader *shader, const struct ir3_shader_key *key,
|
||||
struct ir3_shader_variant *nonbinning)
|
||||
struct ir3_shader_variant *nonbinning, void *mem_ctx)
|
||||
{
|
||||
void *mem_ctx = shader;
|
||||
/* hang the binning variant off it's non-binning counterpart instead
|
||||
* of the shader, to simplify the error cleanup paths
|
||||
*/
|
||||
|
|
@ -393,9 +392,9 @@ needs_binning_variant(struct ir3_shader_variant *v)
|
|||
|
||||
static struct ir3_shader_variant *
|
||||
create_variant(struct ir3_shader *shader, const struct ir3_shader_key *key,
|
||||
bool write_disasm)
|
||||
bool write_disasm, void *mem_ctx)
|
||||
{
|
||||
struct ir3_shader_variant *v = alloc_variant(shader, key, NULL);
|
||||
struct ir3_shader_variant *v = alloc_variant(shader, key, NULL, mem_ctx);
|
||||
|
||||
if (!v)
|
||||
goto fail;
|
||||
|
|
@ -403,7 +402,7 @@ create_variant(struct ir3_shader *shader, const struct ir3_shader_key *key,
|
|||
v->disasm_info.write_disasm = write_disasm;
|
||||
|
||||
if (needs_binning_variant(v)) {
|
||||
v->binning = alloc_variant(shader, key, v);
|
||||
v->binning = alloc_variant(shader, key, v, mem_ctx);
|
||||
if (!v->binning)
|
||||
goto fail;
|
||||
v->binning->disasm_info.write_disasm = write_disasm;
|
||||
|
|
@ -442,6 +441,14 @@ fail:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct ir3_shader_variant *
|
||||
ir3_shader_create_variant(struct ir3_shader *shader,
|
||||
const struct ir3_shader_key *key,
|
||||
bool keep_ir)
|
||||
{
|
||||
return create_variant(shader, key, keep_ir, NULL);
|
||||
}
|
||||
|
||||
static inline struct ir3_shader_variant *
|
||||
shader_variant(struct ir3_shader *shader, const struct ir3_shader_key *key)
|
||||
{
|
||||
|
|
@ -464,7 +471,7 @@ ir3_shader_get_variant(struct ir3_shader *shader,
|
|||
|
||||
if (!v) {
|
||||
/* compile new variant if it doesn't exist already: */
|
||||
v = create_variant(shader, key, write_disasm);
|
||||
v = create_variant(shader, key, write_disasm, shader);
|
||||
if (v) {
|
||||
v->next = shader->variants;
|
||||
shader->variants = v;
|
||||
|
|
|
|||
|
|
@ -912,10 +912,15 @@ ir3_max_const(const struct ir3_shader_variant *v)
|
|||
|
||||
void *ir3_shader_assemble(struct ir3_shader_variant *v);
|
||||
struct ir3_shader_variant *
|
||||
ir3_shader_create_variant(struct ir3_shader *shader,
|
||||
const struct ir3_shader_key *key,
|
||||
bool keep_ir);
|
||||
struct ir3_shader_variant *
|
||||
ir3_shader_get_variant(struct ir3_shader *shader,
|
||||
const struct ir3_shader_key *key, bool binning_pass,
|
||||
bool keep_ir, bool *created);
|
||||
|
||||
|
||||
struct ir3_shader_options {
|
||||
unsigned reserved_user_consts;
|
||||
enum ir3_wavesize_option api_wavesize, real_wavesize;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue