mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 04:38:03 +02:00
anv: Add a back-door for passing NIR shaders directly into the pipeline
This will allow us to use NIR directly for meta operations rather than having to go through SPIR-V.
This commit is contained in:
parent
b68805f83c
commit
add99c4beb
3 changed files with 19 additions and 7 deletions
|
|
@ -895,7 +895,6 @@ anv_compile_shader_spirv(struct anv_compiler *compiler,
|
||||||
struct anv_shader *shader = pipeline->shaders[stage];
|
struct anv_shader *shader = pipeline->shaders[stage];
|
||||||
struct gl_shader *mesa_shader;
|
struct gl_shader *mesa_shader;
|
||||||
int name = 0;
|
int name = 0;
|
||||||
uint32_t *spirv;
|
|
||||||
|
|
||||||
mesa_shader = brw_new_shader(&brw->ctx, name, stage_info[stage].token);
|
mesa_shader = brw_new_shader(&brw->ctx, name, stage_info[stage].token);
|
||||||
fail_if(mesa_shader == NULL,
|
fail_if(mesa_shader == NULL,
|
||||||
|
|
@ -937,13 +936,21 @@ anv_compile_shader_spirv(struct anv_compiler *compiler,
|
||||||
struct gl_shader_compiler_options *glsl_options =
|
struct gl_shader_compiler_options *glsl_options =
|
||||||
&compiler->screen->compiler->glsl_compiler_options[stage_info[stage].stage];
|
&compiler->screen->compiler->glsl_compiler_options[stage_info[stage].stage];
|
||||||
|
|
||||||
spirv = (uint32_t *) shader->module->data;
|
if (shader->module->nir) {
|
||||||
assert(spirv[0] == SPIR_V_MAGIC_NUMBER);
|
/* Some things such as our meta clear/blit code will give us a NIR
|
||||||
assert(shader->module->size % 4 == 0);
|
* shader directly. In that case, we just ignore the SPIR-V entirely
|
||||||
|
* and just use the NIR shader */
|
||||||
|
mesa_shader->Program->nir = shader->module->nir;
|
||||||
|
mesa_shader->Program->nir->options = glsl_options->NirOptions;
|
||||||
|
} else {
|
||||||
|
uint32_t *spirv = (uint32_t *) shader->module->data;
|
||||||
|
assert(spirv[0] == SPIR_V_MAGIC_NUMBER);
|
||||||
|
assert(shader->module->size % 4 == 0);
|
||||||
|
|
||||||
mesa_shader->Program->nir =
|
mesa_shader->Program->nir =
|
||||||
spirv_to_nir(spirv, shader->module->size / 4,
|
spirv_to_nir(spirv, shader->module->size / 4,
|
||||||
stage_info[stage].stage, glsl_options->NirOptions);
|
stage_info[stage].stage, glsl_options->NirOptions);
|
||||||
|
}
|
||||||
nir_validate_shader(mesa_shader->Program->nir);
|
nir_validate_shader(mesa_shader->Program->nir);
|
||||||
|
|
||||||
brw_process_nir(mesa_shader->Program->nir,
|
brw_process_nir(mesa_shader->Program->nir,
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ VkResult anv_CreateShaderModule(
|
||||||
if (module == NULL)
|
if (module == NULL)
|
||||||
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
|
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||||
|
|
||||||
|
module->nir = NULL;
|
||||||
module->size = pCreateInfo->codeSize;
|
module->size = pCreateInfo->codeSize;
|
||||||
memcpy(module->data, pCreateInfo->pCode, module->size);
|
memcpy(module->data, pCreateInfo->pCode, module->size);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -994,7 +994,11 @@ struct anv_fence {
|
||||||
bool ready;
|
bool ready;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct nir_shader;
|
||||||
|
|
||||||
struct anv_shader_module {
|
struct anv_shader_module {
|
||||||
|
struct nir_shader * nir;
|
||||||
|
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
char data[0];
|
char data[0];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue