turnip: implement VK_KHR_shader_terminate_invocation

OpTerminateInvocation provides the behavior required by the GLSL
discard statement, which we already implement.

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9460>
This commit is contained in:
Danylo Piliaiev 2021-03-05 20:28:54 +02:00 committed by Marge Bot
parent 9dd9424a85
commit 64367f2359
4 changed files with 14 additions and 3 deletions

View File

@ -494,7 +494,7 @@ Khronos extensions that are not part of any Vulkan version:
VK_EXT_sample_locations DONE (anv, radv, tu/a650)
VK_KHR_shader_clock DONE (anv, radv)
VK_KHR_shader_non_semantic_info DONE (anv, radv)
VK_KHR_shader_terminate_invocation DONE (anv, radv)
VK_KHR_shader_terminate_invocation DONE (anv, radv, tu)
VK_KHR_shared_presentable_image not started
VK_KHR_surface DONE (anv, lvp, radv, tu, v3dv)
VK_KHR_surface_protected_capabilities DONE (anv, lvp, radv)

View File

@ -1952,11 +1952,15 @@ emit_intrinsic(struct ir3_context *ctx, nir_intrinsic_instr *intr)
case nir_intrinsic_discard_if:
case nir_intrinsic_discard:
case nir_intrinsic_demote:
case nir_intrinsic_demote_if: {
case nir_intrinsic_demote_if:
case nir_intrinsic_terminate:
case nir_intrinsic_terminate_if:
{
struct ir3_instruction *cond, *kill;
if (intr->intrinsic == nir_intrinsic_discard_if ||
intr->intrinsic == nir_intrinsic_demote_if) {
intr->intrinsic == nir_intrinsic_demote_if ||
intr->intrinsic == nir_intrinsic_terminate_if) {
/* conditional discard: */
src = ir3_get_src(ctx, &intr->src[0]);
cond = src[0];

View File

@ -628,6 +628,12 @@ tu_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice,
features->shaderDemoteToHelperInvocation = true;
break;
}
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES_KHR: {
VkPhysicalDeviceShaderTerminateInvocationFeaturesKHR *features =
(VkPhysicalDeviceShaderTerminateInvocationFeaturesKHR *)ext;
features->shaderTerminateInvocation = true;
break;
}
default:
break;

View File

@ -118,6 +118,7 @@ EXTENSIONS = [
Extension('VK_KHR_relaxed_block_layout', 1, True),
Extension('VK_EXT_robustness2', 1, True),
Extension('VK_EXT_shader_demote_to_helper_invocation', 1, True),
Extension('VK_KHR_shader_terminate_invocation', 1, True),
]
MAX_API_VERSION = VkVersion(MAX_API_VERSION)