nir, spirv: Add support for VK_EXT_fragment_density_map

This involves two new system values.

Reviewed-by: Faith Ekstrand <faith@gfxstrand.net>
Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20303>
This commit is contained in:
Connor Abbott 2022-11-25 12:41:46 +01:00 committed by Marge Bot
parent 6c0a8a7f06
commit 0977925c53
7 changed files with 32 additions and 0 deletions

View file

@ -2503,6 +2503,10 @@ nir_intrinsic_from_system_value(gl_system_value val)
return nir_intrinsic_load_frag_shading_rate;
case SYSTEM_VALUE_FULLY_COVERED:
return nir_intrinsic_load_fully_covered;
case SYSTEM_VALUE_FRAG_SIZE:
return nir_intrinsic_load_frag_size;
case SYSTEM_VALUE_FRAG_INVOCATION_COUNT:
return nir_intrinsic_load_frag_invocation_count;
default:
unreachable("system value does not directly correspond to intrinsic");
}
@ -2652,6 +2656,10 @@ nir_system_value_from_intrinsic(nir_intrinsic_op intrin)
return SYSTEM_VALUE_MESH_VIEW_COUNT;
case nir_intrinsic_load_fully_covered:
return SYSTEM_VALUE_FULLY_COVERED;
case nir_intrinsic_load_frag_size:
return SYSTEM_VALUE_FRAG_SIZE;
case nir_intrinsic_load_frag_invocation_count:
return SYSTEM_VALUE_FRAG_INVOCATION_COUNT;
default:
unreachable("intrinsic doesn't produce a system value");
}

View file

@ -866,6 +866,8 @@ system_value("shared_base_ptr", 0, bit_sizes=[32,64])
system_value("global_base_ptr", 0, bit_sizes=[32,64])
# Address of a transform feedback buffer, indexed by BASE
system_value("xfb_address", 1, bit_sizes=[32,64], indices=[BASE])
system_value("frag_size", 2)
system_value("frag_invocation_count", 1)
# System values for ray tracing.
system_value("ray_launch_id", 3)

View file

@ -339,6 +339,8 @@ gl_system_value_name(gl_system_value sysval)
ENUM(SYSTEM_VALUE_REL_PATCH_ID_IR3),
ENUM(SYSTEM_VALUE_FRAG_SHADING_RATE),
ENUM(SYSTEM_VALUE_FULLY_COVERED),
ENUM(SYSTEM_VALUE_FRAG_SIZE),
ENUM(SYSTEM_VALUE_FRAG_INVOCATION_COUNT),
};
STATIC_ASSERT(ARRAY_SIZE(names) == SYSTEM_VALUE_MAX);
return NAME(sysval);

View file

@ -875,6 +875,13 @@ typedef enum
*/
SYSTEM_VALUE_FULLY_COVERED,
/*
* Fragment size and invocation count used for
* EXT_fragment_invocation_density (Vulkan).
*/
SYSTEM_VALUE_FRAG_SIZE,
SYSTEM_VALUE_FRAG_INVOCATION_COUNT,
SYSTEM_VALUE_MAX /**< Number of values */
} gl_system_value;

View file

@ -63,6 +63,7 @@ struct spirv_supported_capabilities {
bool float64_atomic_add;
bool float64_atomic_min_max;
bool float64;
bool fragment_density;
bool fragment_fully_covered;
bool fragment_shader_pixel_interlock;
bool fragment_shader_sample_interlock;

View file

@ -4893,6 +4893,10 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
spv_check_supported(fragment_fully_covered, cap);
break;
case SpvCapabilityFragmentDensityEXT:
spv_check_supported(fragment_density, cap);
break;
default:
vtn_fail("Unhandled capability: %s (%u)",
spirv_capability_to_string(cap), cap);

View file

@ -1174,6 +1174,14 @@ vtn_get_builtin_location(struct vtn_builder *b,
*location = SYSTEM_VALUE_FULLY_COVERED;
set_mode_system_value(b, mode);
break;
case SpvBuiltInFragSizeEXT:
*location = SYSTEM_VALUE_FRAG_SIZE;
set_mode_system_value(b, mode);
break;
case SpvBuiltInFragInvocationCountEXT:
*location = SYSTEM_VALUE_FRAG_INVOCATION_COUNT;
set_mode_system_value(b, mode);
break;
default:
vtn_fail("Unsupported builtin: %s (%u)",