spirv: Add support for SPV_EXT_shader_image_atomic_int64

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7509>
This commit is contained in:
Jason Ekstrand
2020-03-17 17:57:42 -05:00
committed by Marge Bot
parent 5a3e22018d
commit 2bbe01b186
2 changed files with 20 additions and 4 deletions

View File

@@ -54,6 +54,7 @@ struct spirv_supported_capabilities {
bool image_ms_array; bool image_ms_array;
bool image_read_without_format; bool image_read_without_format;
bool image_write_without_format; bool image_write_without_format;
bool image_atomic_int64;
bool int8; bool int8;
bool int16; bool int16;
bool int64; bool int64;

View File

@@ -1333,6 +1333,8 @@ translate_image_format(struct vtn_builder *b, SpvImageFormat format)
case SpvImageFormatRg8ui: return PIPE_FORMAT_R8G8_UINT; case SpvImageFormatRg8ui: return PIPE_FORMAT_R8G8_UINT;
case SpvImageFormatR16ui: return PIPE_FORMAT_R16_UINT; case SpvImageFormatR16ui: return PIPE_FORMAT_R16_UINT;
case SpvImageFormatR8ui: return PIPE_FORMAT_R8_UINT; case SpvImageFormatR8ui: return PIPE_FORMAT_R8_UINT;
case SpvImageFormatR64ui: return PIPE_FORMAT_R64_UINT;
case SpvImageFormatR64i: return PIPE_FORMAT_R64_SINT;
default: default:
vtn_fail("Invalid image format: %s (%u)", vtn_fail("Invalid image format: %s (%u)",
spirv_imageformat_to_string(format), format); spirv_imageformat_to_string(format), format);
@@ -1607,9 +1609,17 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
vtn_fail_if(sampled_type->base_type != vtn_base_type_void, vtn_fail_if(sampled_type->base_type != vtn_base_type_void,
"Sampled type of OpTypeImage must be void for kernels"); "Sampled type of OpTypeImage must be void for kernels");
} else { } else {
vtn_fail_if(sampled_type->base_type != vtn_base_type_scalar || vtn_fail_if(sampled_type->base_type != vtn_base_type_scalar,
glsl_get_bit_size(sampled_type->type) != 32, "Sampled type of OpTypeImage must be a scalar");
"Sampled type of OpTypeImage must be a 32-bit scalar"); if (b->options->caps.image_atomic_int64) {
vtn_fail_if(glsl_get_bit_size(sampled_type->type) != 32 &&
glsl_get_bit_size(sampled_type->type) != 64,
"Sampled type of OpTypeImage must be a 32 or 64-bit "
"scalar");
} else {
vtn_fail_if(glsl_get_bit_size(sampled_type->type) != 32,
"Sampled type of OpTypeImage must be a 32-bit scalar");
}
} }
enum glsl_sampler_dim dim; enum glsl_sampler_dim dim;
@@ -3315,7 +3325,8 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
intrin->num_components = dest_components; intrin->num_components = dest_components;
nir_ssa_dest_init(&intrin->instr, &intrin->dest, nir_ssa_dest_init(&intrin->instr, &intrin->dest,
nir_intrinsic_dest_components(intrin), 32, NULL); nir_intrinsic_dest_components(intrin),
glsl_get_bit_size(type->type), NULL);
nir_builder_instr_insert(&b->nb, &intrin->instr); nir_builder_instr_insert(&b->nb, &intrin->instr);
@@ -4460,6 +4471,10 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
spv_check_supported(ray_traversal_primitive_culling, cap); spv_check_supported(ray_traversal_primitive_culling, cap);
break; break;
case SpvCapabilityInt64ImageEXT:
spv_check_supported(image_atomic_int64, 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);