8f6df770ce
Add bool members is_read and is_written to SPIRType::Image. Output correct texture read/write access by marking whether textures are read from and written to by the shader. Override bitcast_glsl_op() to use Metal as_type<type> functions. Add implementations of SPIR-V functions inverse(), degrees() & radians(). Map inverseSqrt() to rsqrt(). Map roundEven() to rint(). GLSL functions imageSize() and textureSize() map to equivalent expression using MSL get_width() & get_height() functions. Map several SPIR-V integer bitfield functions to MSL equivalents. Map SPIR-V atomic functions to MSL equivalents. Map texture packing and unpacking functions to MSL equivalents. Refactor existing, and add new, image query functions. Reorganize header lines into includes and pragmas. Simplify type_to_glsl() logic. Add MSL test case vert/functions.vert for added function implementations. Add MSL test case comp/atomic.comp for added function implementations. test_shaders.py use macOS compilation for MSL shader compilation validations.
27 lines
649 B
Plaintext
27 lines
649 B
Plaintext
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
|
|
|
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
|
|
using namespace metal;
|
|
|
|
struct myBlock
|
|
{
|
|
int a;
|
|
float b[1];
|
|
};
|
|
|
|
// Implementation of the GLSL mod() function, which is slightly different than Metal fmod()
|
|
template<typename Tx, typename Ty>
|
|
Tx mod(Tx x, Ty y)
|
|
{
|
|
return x - y * floor(x / y);
|
|
}
|
|
|
|
kernel void main0(device myBlock& myStorage [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
|
|
{
|
|
myStorage.a = (myStorage.a + 1) % 256;
|
|
myStorage.b[gl_GlobalInvocationID.x] = mod(myStorage.b[gl_GlobalInvocationID.x] + 0.0199999995529651641845703125, 1.0);
|
|
}
|
|
|