Cross-API shader dev is fun you guys!!!!11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DECLARE_SAMPLER_IBUF(0, int1, zigzag8); | |
| DECLARE_SAMPLER_IBUF(1, int1, coeff_data); | |
| DECLARE_SAMPLER_IBUF(2, int1, dc_data); | |
| #ifdef MOTION | |
| #ifdef SUB_PLANE | |
| DECLARE_SAMPLER_U2D(3, i_img); // reference frame | |
| #else | |
| DECLARE_SAMPLER_U2D_GATHER(3, i_img); // reference frame | |
| #endif | |
| DECLARE_SAMPLER_IBUF(4, ivec2, motion_buf); | |
| DECLARE_IMAGE_R16I_BUF(1, dc_out_buf); | |
| #endif | |
| #define METAL_ARGD \ | |
| METAL_ARG(constant frame_consts& u0) \ | |
| METAL_ARG(device int1 *zigzag8) METAL_ARG(device int1 *coeff_data) METAL_ARG(device short1 *dc_data) \ | |
| METAL_ARG(texture2d<ushort> i_img) METAL_ARG(rwtexture2d_ushort o_img) \ | |
| METAL_ARG(device short2 *motion_buf) METAL_ARG(device short1 *dc_out_buf) \ | |
| METAL_ARG(threadgroup uvec2 *ac_nonzero) METAL_ARG(threadgroup int *coeffs) METAL_ARG(threadgroup uint *dcf_linear) | |
| #define METAL_ARGS \ | |
| METAL_ARG(u0) \ | |
| METAL_ARG(zigzag8) METAL_ARG(coeff_data) METAL_ARG(dc_data) \ | |
| METAL_ARG(i_img) METAL_ARG(o_img) \ | |
| METAL_ARG(motion_buf) METAL_ARG(dc_out_buf) \ | |
| METAL_ARG(ac_nonzero) METAL_ARG(coeffs) METAL_ARG(dcf_linear) | |
| #ifdef SUB_PLANE | |
| DECLARE_IMAGE_RG8UI_2D(0, o_img); | |
| #else | |
| DECLARE_IMAGE_R8UI_2D(0, o_img); | |
| #endif | |
| // ---- Shared utils | |
| int get_dc(uint offs METAL_ARGD) | |
| { | |
| return bufferFetch(dc_data, offs).x; | |
| } | |
| int coeff_data_v(uint offs METAL_ARGD) | |
| { | |
| return bufferFetch(coeff_data, offs).x; | |
| } | |
| // throughout this shader, "ptr" is always an array index in | |
| // units of 16-bit ints. | |
| #ifndef METAL_LANG | |
| int get_int16(uint ptr) | |
| { | |
| int val_pair = coeff_data_v(ptr >> 1); | |
| return bitfieldExtract(val_pair, int(ptr & 1) << 4, 16); | |
| } | |
| #else | |
| int get_int16(uint ptr METAL_ARGD) | |
| { | |
| return ((device short *) coeff_data)[ptr]; | |
| } | |
| #endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment