mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
zink: put those shader keys to work fixing up fragment shaders
eliminate gl_SampleMask writes when necessary to mimic GL behavior Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7193>
This commit is contained in:
parent
9aa08221fa
commit
eeff625ab3
1 changed files with 21 additions and 1 deletions
|
|
@ -222,9 +222,26 @@ zink_shader_compile(struct zink_screen *screen, struct zink_shader *zs, struct z
|
||||||
{
|
{
|
||||||
VkShaderModule mod = VK_NULL_HANDLE;
|
VkShaderModule mod = VK_NULL_HANDLE;
|
||||||
void *streamout = NULL;
|
void *streamout = NULL;
|
||||||
|
nir_shader *nir = zs->nir;
|
||||||
|
/* TODO: use a separate mem ctx here for ralloc */
|
||||||
if (zs->streamout.so_info_slots && (zs->nir->info.stage != MESA_SHADER_VERTEX || !zs->has_geometry_shader))
|
if (zs->streamout.so_info_slots && (zs->nir->info.stage != MESA_SHADER_VERTEX || !zs->has_geometry_shader))
|
||||||
streamout = &zs->streamout;
|
streamout = &zs->streamout;
|
||||||
struct spirv_shader *spirv = nir_to_spirv(zs->nir, streamout, shader_slot_map, shader_slots_reserved);
|
if (zs->nir->info.stage == MESA_SHADER_FRAGMENT) {
|
||||||
|
nir = nir_shader_clone(NULL, nir);
|
||||||
|
if (!zink_fs_key(key)->samples && nir->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_SAMPLE_MASK)) {
|
||||||
|
/* VK will always use gl_SampleMask[] values even if sample count is 0,
|
||||||
|
* so we need to skip this write here to mimic GL's behavior of ignoring it
|
||||||
|
*/
|
||||||
|
nir_foreach_shader_out_variable(var, nir) {
|
||||||
|
if (var->data.location == FRAG_RESULT_SAMPLE_MASK)
|
||||||
|
var->data.mode = nir_var_shader_temp;
|
||||||
|
}
|
||||||
|
nir_fixup_deref_modes(nir);
|
||||||
|
NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_shader_temp, NULL);
|
||||||
|
optimize_nir(nir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
struct spirv_shader *spirv = nir_to_spirv(nir, streamout, shader_slot_map, shader_slots_reserved);
|
||||||
assert(spirv);
|
assert(spirv);
|
||||||
|
|
||||||
if (zink_debug & ZINK_DEBUG_SPIRV) {
|
if (zink_debug & ZINK_DEBUG_SPIRV) {
|
||||||
|
|
@ -247,6 +264,9 @@ zink_shader_compile(struct zink_screen *screen, struct zink_shader *zs, struct z
|
||||||
if (vkCreateShaderModule(screen->dev, &smci, NULL, &mod) != VK_SUCCESS)
|
if (vkCreateShaderModule(screen->dev, &smci, NULL, &mod) != VK_SUCCESS)
|
||||||
mod = VK_NULL_HANDLE;
|
mod = VK_NULL_HANDLE;
|
||||||
|
|
||||||
|
if (zs->nir->info.stage == MESA_SHADER_FRAGMENT)
|
||||||
|
ralloc_free(nir);
|
||||||
|
|
||||||
/* TODO: determine if there's any reason to cache spirv output? */
|
/* TODO: determine if there's any reason to cache spirv output? */
|
||||||
free(spirv->words);
|
free(spirv->words);
|
||||||
free(spirv);
|
free(spirv);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue