spirv: Implement SPV_KHR_shader_clock
We only have the subgroup variant in NIR (equivalent to clockARB), so only support that for now. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
This commit is contained in:
@@ -60,6 +60,7 @@ struct spirv_supported_capabilities {
|
|||||||
bool post_depth_coverage;
|
bool post_depth_coverage;
|
||||||
bool runtime_descriptor_array;
|
bool runtime_descriptor_array;
|
||||||
bool float_controls;
|
bool float_controls;
|
||||||
|
bool shader_clock;
|
||||||
bool shader_viewport_index_layer;
|
bool shader_viewport_index_layer;
|
||||||
bool stencil_export;
|
bool stencil_export;
|
||||||
bool storage_8bit;
|
bool storage_8bit;
|
||||||
|
@@ -3652,6 +3652,10 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
|
|||||||
spv_check_supported(demote_to_helper_invocation, cap);
|
spv_check_supported(demote_to_helper_invocation, cap);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SpvCapabilityShaderClockKHR:
|
||||||
|
spv_check_supported(shader_clock, cap);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
vtn_fail("Unhandled capability: %s (%u)",
|
vtn_fail("Unhandled capability: %s (%u)",
|
||||||
spirv_capability_to_string(cap), cap);
|
spirv_capability_to_string(cap), cap);
|
||||||
@@ -4554,6 +4558,37 @@ vtn_handle_body_instruction(struct vtn_builder *b, SpvOp opcode,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case SpvOpReadClockKHR: {
|
||||||
|
assert(vtn_constant_uint(b, w[3]) == SpvScopeSubgroup);
|
||||||
|
|
||||||
|
/* Operation supports two result types: uvec2 and uint64_t. The NIR
|
||||||
|
* intrinsic gives uvec2, so pack the result for the other case.
|
||||||
|
*/
|
||||||
|
nir_intrinsic_instr *intrin =
|
||||||
|
nir_intrinsic_instr_create(b->nb.shader, nir_intrinsic_shader_clock);
|
||||||
|
nir_ssa_dest_init(&intrin->instr, &intrin->dest, 2, 32, NULL);
|
||||||
|
nir_builder_instr_insert(&b->nb, &intrin->instr);
|
||||||
|
|
||||||
|
struct vtn_type *type = vtn_value(b, w[1], vtn_value_type_type)->type;
|
||||||
|
const struct glsl_type *dest_type = type->type;
|
||||||
|
nir_ssa_def *result;
|
||||||
|
|
||||||
|
if (glsl_type_is_vector(dest_type)) {
|
||||||
|
assert(dest_type == glsl_vector_type(GLSL_TYPE_UINT, 2));
|
||||||
|
result = &intrin->dest.ssa;
|
||||||
|
} else {
|
||||||
|
assert(glsl_type_is_scalar(dest_type));
|
||||||
|
assert(glsl_get_base_type(dest_type) == GLSL_TYPE_UINT64);
|
||||||
|
result = nir_pack_64_2x32(&b->nb, &intrin->dest.ssa);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct vtn_value *val = vtn_push_value(b, w[2], vtn_value_type_ssa);
|
||||||
|
val->type = type;
|
||||||
|
val->ssa = vtn_create_ssa_value(b, dest_type);
|
||||||
|
val->ssa->def = result;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
vtn_fail_with_opcode("Unhandled opcode", opcode);
|
vtn_fail_with_opcode("Unhandled opcode", opcode);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user