#version 450
// Elementwise multiplication compute shader
// Computes: result[i] = a[i] * b[i]
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
layout(set = 0, binding = 0) buffer InputBufferA {
float a[];
};
layout(set = 0, binding = 1) buffer InputBufferB {
float b[];
};
layout(set = 0, binding = 2) buffer OutputBuffer {
float result[];
};
void main() {
uint index = gl_GlobalInvocationID.x;
// Bounds checking
if (index >= a.length() || index >= b.length() || index >= result.length()) {
return;
}
// Perform elementwise multiplication entirely on GPU
result[index] = a[index] * b[index];
}