// @generated by tool/gen/fn/generate.py; DO NOT EDIT.
// schema=cryptography_hash.json schema_version=1 generator_version=64
// schema_sha256=982731ed954c1dddbb0b1430f6561e03cbaf7cb6e7880fae9ba317ad9a1fa87b
// No OA C++ fixed SHA-2/SHA-3 batch donor exists (cryptoFnHash.toml).
// Adaptation: schema-owned ABI adapter over existing checked Slang formulas.
// Each invocation owns one whole digest row; all rows contain complete words.
// Input row starts may be unaligned; the imported helpers own packed reads.
import attributes;
import sha3;
struct PushConstants {
uint input_index;
uint output_index;
uint count;
uint message_len;
};
[[vk::push_constant]] PushConstants push;
[[vk::binding(0, 0)]] RWByteAddressBuffer storage_buffers[];
[kernel_name("sha3_256")]
[domain("cryptography")]
[variant("generic")]
[dtype("u8")]
[status("experimental")]
[shader("compute")]
[numthreads(32, 1, 1)]
void main(uint3 dispatch_thread_id : SV_DispatchThreadID) {
uint index = dispatch_thread_id.x;
if (index >= push.count) return;
uint input_extent, output_extent;
storage_buffers[push.input_index].GetDimensions(input_extent);
storage_buffers[push.output_index].GetDimensions(output_extent);
// Divide before multiplying, including zero-length messages. Host admission
// also checks logical byte extents; descriptor extents include word padding.
if ((input_extent & 3u) != 0u || (output_extent & 3u) != 0u
|| (push.message_len != 0u && push.count > input_extent / push.message_len)
|| push.count > output_extent / 32u) return;
uint2 digest[4];
if (!sha3_256(storage_buffers[push.input_index],
index * push.message_len, push.message_len, digest)) return;
uint base = index * 32u;
[loop]
for (uint word = 0u; word < 4u; ++word) {
storage_buffers[push.output_index].Store<uint>(base + word * 8u, digest[word].x);
storage_buffers[push.output_index].Store<uint>(base + word * 8u + 4u, digest[word].y);
}
}