dan sinclair | 196326c | 2024-12-06 12:40:09 +0000 | [diff] [blame] | 1 | // |
| 2 | // fragment_main |
| 3 | // |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 4 | #version 310 es |
| 5 | precision highp float; |
| 6 | precision highp int; |
dan sinclair | 6e93ca5 | 2024-08-28 23:58:04 +0000 | [diff] [blame] | 7 | |
dan sinclair | 6e93ca5 | 2024-08-28 23:58:04 +0000 | [diff] [blame] | 8 | |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 9 | struct tint_GammaTransferParams { |
| 10 | float G; |
| 11 | float A; |
| 12 | float B; |
| 13 | float C; |
| 14 | float D; |
| 15 | float E; |
| 16 | float F; |
| 17 | uint padding; |
| 18 | }; |
| 19 | |
| 20 | struct tint_ExternalTextureParams_std140 { |
| 21 | uint numPlanes; |
| 22 | uint doYuvToRgbConversionOnly; |
James Price | 925f03f | 2024-10-10 23:01:30 +0000 | [diff] [blame] | 23 | uint tint_pad_0; |
dan sinclair | 2574827 | 2024-10-08 20:05:30 +0000 | [diff] [blame] | 24 | uint tint_pad_1; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 25 | mat3x4 yuvToRgbConversionMatrix; |
| 26 | tint_GammaTransferParams gammaDecodeParams; |
| 27 | tint_GammaTransferParams gammaEncodeParams; |
| 28 | vec3 gamutConversionMatrix_col0; |
dan sinclair | 2574827 | 2024-10-08 20:05:30 +0000 | [diff] [blame] | 29 | uint tint_pad_2; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 30 | vec3 gamutConversionMatrix_col1; |
dan sinclair | 2574827 | 2024-10-08 20:05:30 +0000 | [diff] [blame] | 31 | uint tint_pad_3; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 32 | vec3 gamutConversionMatrix_col2; |
dan sinclair | 2574827 | 2024-10-08 20:05:30 +0000 | [diff] [blame] | 33 | uint tint_pad_4; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 34 | vec2 sampleTransform_col0; |
| 35 | vec2 sampleTransform_col1; |
| 36 | vec2 sampleTransform_col2; |
| 37 | vec2 loadTransform_col0; |
| 38 | vec2 loadTransform_col1; |
| 39 | vec2 loadTransform_col2; |
| 40 | vec2 samplePlane0RectMin; |
| 41 | vec2 samplePlane0RectMax; |
| 42 | vec2 samplePlane1RectMin; |
| 43 | vec2 samplePlane1RectMax; |
Corentin Wallez | 9e9ed67 | 2024-11-21 11:56:04 +0000 | [diff] [blame] | 44 | uvec2 apparentSize; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 45 | vec2 plane1CoordFactor; |
| 46 | }; |
| 47 | |
| 48 | struct tint_ExternalTextureParams { |
| 49 | uint numPlanes; |
| 50 | uint doYuvToRgbConversionOnly; |
| 51 | mat3x4 yuvToRgbConversionMatrix; |
| 52 | tint_GammaTransferParams gammaDecodeParams; |
| 53 | tint_GammaTransferParams gammaEncodeParams; |
| 54 | mat3 gamutConversionMatrix; |
| 55 | mat3x2 sampleTransform; |
| 56 | mat3x2 loadTransform; |
| 57 | vec2 samplePlane0RectMin; |
| 58 | vec2 samplePlane0RectMax; |
| 59 | vec2 samplePlane1RectMin; |
| 60 | vec2 samplePlane1RectMax; |
Corentin Wallez | 9e9ed67 | 2024-11-21 11:56:04 +0000 | [diff] [blame] | 61 | uvec2 apparentSize; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 62 | vec2 plane1CoordFactor; |
| 63 | }; |
| 64 | |
| 65 | layout(binding = 0, std430) |
James Price | 2312bfa | 2024-12-13 09:53:34 -0800 | [diff] [blame] | 66 | buffer f_prevent_dce_block_ssbo { |
James Price | 71c1d54 | 2024-10-10 23:01:19 +0000 | [diff] [blame] | 67 | vec4 inner; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 68 | } v_1; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 69 | layout(binding = 2, std140) |
James Price | 2312bfa | 2024-12-13 09:53:34 -0800 | [diff] [blame] | 70 | uniform f_arg_0_params_block_std140_ubo { |
James Price | 71c1d54 | 2024-10-10 23:01:19 +0000 | [diff] [blame] | 71 | tint_ExternalTextureParams_std140 inner; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 72 | } v_2; |
dan sinclair | 680183f | 2024-10-07 19:57:38 +0000 | [diff] [blame] | 73 | uniform highp sampler2D arg_0_plane0; |
| 74 | uniform highp sampler2D arg_0_plane1; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 75 | vec3 tint_GammaCorrection(vec3 v, tint_GammaTransferParams params) { |
| 76 | vec3 v_3 = vec3(params.G); |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 77 | return mix((sign(v) * (pow(((params.A * abs(v)) + params.B), v_3) + params.E)), (sign(v) * ((params.C * abs(v)) + params.F)), lessThan(abs(v), vec3(params.D))); |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 78 | } |
dan sinclair | 680183f | 2024-10-07 19:57:38 +0000 | [diff] [blame] | 79 | vec4 tint_TextureLoadExternal(tint_ExternalTextureParams params, uvec2 coords) { |
Corentin Wallez | 9e9ed67 | 2024-11-21 11:56:04 +0000 | [diff] [blame] | 80 | vec2 v_4 = round((params.loadTransform * vec3(vec2(min(coords, params.apparentSize)), 1.0f))); |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 81 | uvec2 v_5 = uvec2(v_4); |
| 82 | vec3 v_6 = vec3(0.0f); |
| 83 | float v_7 = 0.0f; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 84 | if ((params.numPlanes == 1u)) { |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 85 | ivec2 v_8 = ivec2(v_5); |
| 86 | vec4 v_9 = texelFetch(arg_0_plane0, v_8, int(0u)); |
| 87 | v_6 = v_9.xyz; |
James Price | 25379d3 | 2024-11-28 21:23:47 +0000 | [diff] [blame] | 88 | v_7 = v_9.w; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 89 | } else { |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 90 | ivec2 v_10 = ivec2(v_5); |
James Price | 25379d3 | 2024-11-28 21:23:47 +0000 | [diff] [blame] | 91 | float v_11 = texelFetch(arg_0_plane0, v_10, int(0u)).x; |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 92 | ivec2 v_12 = ivec2(uvec2((v_4 * params.plane1CoordFactor))); |
| 93 | v_6 = (vec4(v_11, texelFetch(arg_0_plane1, v_12, int(0u)).xy, 1.0f) * params.yuvToRgbConversionMatrix); |
| 94 | v_7 = 1.0f; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 95 | } |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 96 | vec3 v_13 = v_6; |
| 97 | vec3 v_14 = vec3(0.0f); |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 98 | if ((params.doYuvToRgbConversionOnly == 0u)) { |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 99 | v_14 = tint_GammaCorrection((params.gamutConversionMatrix * tint_GammaCorrection(v_13, params.gammaDecodeParams)), params.gammaEncodeParams); |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 100 | } else { |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 101 | v_14 = v_13; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 102 | } |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 103 | return vec4(v_14, v_7); |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 104 | } |
| 105 | tint_ExternalTextureParams tint_convert_tint_ExternalTextureParams(tint_ExternalTextureParams_std140 tint_input) { |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 106 | mat3 v_15 = mat3(tint_input.gamutConversionMatrix_col0, tint_input.gamutConversionMatrix_col1, tint_input.gamutConversionMatrix_col2); |
| 107 | mat3x2 v_16 = mat3x2(tint_input.sampleTransform_col0, tint_input.sampleTransform_col1, tint_input.sampleTransform_col2); |
Corentin Wallez | 9e9ed67 | 2024-11-21 11:56:04 +0000 | [diff] [blame] | 108 | return tint_ExternalTextureParams(tint_input.numPlanes, tint_input.doYuvToRgbConversionOnly, tint_input.yuvToRgbConversionMatrix, tint_input.gammaDecodeParams, tint_input.gammaEncodeParams, v_15, v_16, mat3x2(tint_input.loadTransform_col0, tint_input.loadTransform_col1, tint_input.loadTransform_col2), tint_input.samplePlane0RectMin, tint_input.samplePlane0RectMax, tint_input.samplePlane1RectMin, tint_input.samplePlane1RectMax, tint_input.apparentSize, tint_input.plane1CoordFactor); |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 109 | } |
| 110 | vec4 textureLoad_1bfdfb() { |
| 111 | uvec2 arg_1 = uvec2(1u); |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 112 | tint_ExternalTextureParams v_17 = tint_convert_tint_ExternalTextureParams(v_2.inner); |
dan sinclair | ec3114d | 2024-11-28 16:23:49 +0000 | [diff] [blame] | 113 | vec4 res = tint_TextureLoadExternal(v_17, min(arg_1, ((v_17.apparentSize + uvec2(1u)) - uvec2(1u)))); |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 114 | return res; |
| 115 | } |
| 116 | void main() { |
James Price | 71c1d54 | 2024-10-10 23:01:19 +0000 | [diff] [blame] | 117 | v_1.inner = textureLoad_1bfdfb(); |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 118 | } |
dan sinclair | 196326c | 2024-12-06 12:40:09 +0000 | [diff] [blame] | 119 | // |
| 120 | // compute_main |
| 121 | // |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 122 | #version 310 es |
| 123 | |
| 124 | |
| 125 | struct tint_GammaTransferParams { |
| 126 | float G; |
| 127 | float A; |
| 128 | float B; |
| 129 | float C; |
| 130 | float D; |
| 131 | float E; |
| 132 | float F; |
| 133 | uint padding; |
| 134 | }; |
| 135 | |
| 136 | struct tint_ExternalTextureParams_std140 { |
| 137 | uint numPlanes; |
| 138 | uint doYuvToRgbConversionOnly; |
James Price | 925f03f | 2024-10-10 23:01:30 +0000 | [diff] [blame] | 139 | uint tint_pad_0; |
dan sinclair | 2574827 | 2024-10-08 20:05:30 +0000 | [diff] [blame] | 140 | uint tint_pad_1; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 141 | mat3x4 yuvToRgbConversionMatrix; |
| 142 | tint_GammaTransferParams gammaDecodeParams; |
| 143 | tint_GammaTransferParams gammaEncodeParams; |
| 144 | vec3 gamutConversionMatrix_col0; |
dan sinclair | 2574827 | 2024-10-08 20:05:30 +0000 | [diff] [blame] | 145 | uint tint_pad_2; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 146 | vec3 gamutConversionMatrix_col1; |
dan sinclair | 2574827 | 2024-10-08 20:05:30 +0000 | [diff] [blame] | 147 | uint tint_pad_3; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 148 | vec3 gamutConversionMatrix_col2; |
dan sinclair | 2574827 | 2024-10-08 20:05:30 +0000 | [diff] [blame] | 149 | uint tint_pad_4; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 150 | vec2 sampleTransform_col0; |
| 151 | vec2 sampleTransform_col1; |
| 152 | vec2 sampleTransform_col2; |
| 153 | vec2 loadTransform_col0; |
| 154 | vec2 loadTransform_col1; |
| 155 | vec2 loadTransform_col2; |
| 156 | vec2 samplePlane0RectMin; |
| 157 | vec2 samplePlane0RectMax; |
| 158 | vec2 samplePlane1RectMin; |
| 159 | vec2 samplePlane1RectMax; |
Corentin Wallez | 9e9ed67 | 2024-11-21 11:56:04 +0000 | [diff] [blame] | 160 | uvec2 apparentSize; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 161 | vec2 plane1CoordFactor; |
| 162 | }; |
| 163 | |
| 164 | struct tint_ExternalTextureParams { |
| 165 | uint numPlanes; |
| 166 | uint doYuvToRgbConversionOnly; |
| 167 | mat3x4 yuvToRgbConversionMatrix; |
| 168 | tint_GammaTransferParams gammaDecodeParams; |
| 169 | tint_GammaTransferParams gammaEncodeParams; |
| 170 | mat3 gamutConversionMatrix; |
| 171 | mat3x2 sampleTransform; |
| 172 | mat3x2 loadTransform; |
| 173 | vec2 samplePlane0RectMin; |
| 174 | vec2 samplePlane0RectMax; |
| 175 | vec2 samplePlane1RectMin; |
| 176 | vec2 samplePlane1RectMax; |
Corentin Wallez | 9e9ed67 | 2024-11-21 11:56:04 +0000 | [diff] [blame] | 177 | uvec2 apparentSize; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 178 | vec2 plane1CoordFactor; |
| 179 | }; |
| 180 | |
| 181 | layout(binding = 0, std430) |
James Price | 71c1d54 | 2024-10-10 23:01:19 +0000 | [diff] [blame] | 182 | buffer prevent_dce_block_1_ssbo { |
| 183 | vec4 inner; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 184 | } v_1; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 185 | layout(binding = 2, std140) |
James Price | 71c1d54 | 2024-10-10 23:01:19 +0000 | [diff] [blame] | 186 | uniform arg_0_params_block_std140_1_ubo { |
| 187 | tint_ExternalTextureParams_std140 inner; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 188 | } v_2; |
dan sinclair | 680183f | 2024-10-07 19:57:38 +0000 | [diff] [blame] | 189 | uniform highp sampler2D arg_0_plane0; |
| 190 | uniform highp sampler2D arg_0_plane1; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 191 | vec3 tint_GammaCorrection(vec3 v, tint_GammaTransferParams params) { |
| 192 | vec3 v_3 = vec3(params.G); |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 193 | return mix((sign(v) * (pow(((params.A * abs(v)) + params.B), v_3) + params.E)), (sign(v) * ((params.C * abs(v)) + params.F)), lessThan(abs(v), vec3(params.D))); |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 194 | } |
dan sinclair | 680183f | 2024-10-07 19:57:38 +0000 | [diff] [blame] | 195 | vec4 tint_TextureLoadExternal(tint_ExternalTextureParams params, uvec2 coords) { |
Corentin Wallez | 9e9ed67 | 2024-11-21 11:56:04 +0000 | [diff] [blame] | 196 | vec2 v_4 = round((params.loadTransform * vec3(vec2(min(coords, params.apparentSize)), 1.0f))); |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 197 | uvec2 v_5 = uvec2(v_4); |
| 198 | vec3 v_6 = vec3(0.0f); |
| 199 | float v_7 = 0.0f; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 200 | if ((params.numPlanes == 1u)) { |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 201 | ivec2 v_8 = ivec2(v_5); |
| 202 | vec4 v_9 = texelFetch(arg_0_plane0, v_8, int(0u)); |
| 203 | v_6 = v_9.xyz; |
James Price | 25379d3 | 2024-11-28 21:23:47 +0000 | [diff] [blame] | 204 | v_7 = v_9.w; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 205 | } else { |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 206 | ivec2 v_10 = ivec2(v_5); |
James Price | 25379d3 | 2024-11-28 21:23:47 +0000 | [diff] [blame] | 207 | float v_11 = texelFetch(arg_0_plane0, v_10, int(0u)).x; |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 208 | ivec2 v_12 = ivec2(uvec2((v_4 * params.plane1CoordFactor))); |
| 209 | v_6 = (vec4(v_11, texelFetch(arg_0_plane1, v_12, int(0u)).xy, 1.0f) * params.yuvToRgbConversionMatrix); |
| 210 | v_7 = 1.0f; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 211 | } |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 212 | vec3 v_13 = v_6; |
| 213 | vec3 v_14 = vec3(0.0f); |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 214 | if ((params.doYuvToRgbConversionOnly == 0u)) { |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 215 | v_14 = tint_GammaCorrection((params.gamutConversionMatrix * tint_GammaCorrection(v_13, params.gammaDecodeParams)), params.gammaEncodeParams); |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 216 | } else { |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 217 | v_14 = v_13; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 218 | } |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 219 | return vec4(v_14, v_7); |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 220 | } |
| 221 | tint_ExternalTextureParams tint_convert_tint_ExternalTextureParams(tint_ExternalTextureParams_std140 tint_input) { |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 222 | mat3 v_15 = mat3(tint_input.gamutConversionMatrix_col0, tint_input.gamutConversionMatrix_col1, tint_input.gamutConversionMatrix_col2); |
| 223 | mat3x2 v_16 = mat3x2(tint_input.sampleTransform_col0, tint_input.sampleTransform_col1, tint_input.sampleTransform_col2); |
Corentin Wallez | 9e9ed67 | 2024-11-21 11:56:04 +0000 | [diff] [blame] | 224 | return tint_ExternalTextureParams(tint_input.numPlanes, tint_input.doYuvToRgbConversionOnly, tint_input.yuvToRgbConversionMatrix, tint_input.gammaDecodeParams, tint_input.gammaEncodeParams, v_15, v_16, mat3x2(tint_input.loadTransform_col0, tint_input.loadTransform_col1, tint_input.loadTransform_col2), tint_input.samplePlane0RectMin, tint_input.samplePlane0RectMax, tint_input.samplePlane1RectMin, tint_input.samplePlane1RectMax, tint_input.apparentSize, tint_input.plane1CoordFactor); |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 225 | } |
| 226 | vec4 textureLoad_1bfdfb() { |
| 227 | uvec2 arg_1 = uvec2(1u); |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 228 | tint_ExternalTextureParams v_17 = tint_convert_tint_ExternalTextureParams(v_2.inner); |
dan sinclair | ec3114d | 2024-11-28 16:23:49 +0000 | [diff] [blame] | 229 | vec4 res = tint_TextureLoadExternal(v_17, min(arg_1, ((v_17.apparentSize + uvec2(1u)) - uvec2(1u)))); |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 230 | return res; |
| 231 | } |
| 232 | layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; |
| 233 | void main() { |
James Price | 71c1d54 | 2024-10-10 23:01:19 +0000 | [diff] [blame] | 234 | v_1.inner = textureLoad_1bfdfb(); |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 235 | } |
dan sinclair | 196326c | 2024-12-06 12:40:09 +0000 | [diff] [blame] | 236 | // |
| 237 | // vertex_main |
| 238 | // |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 239 | #version 310 es |
| 240 | |
| 241 | |
| 242 | struct tint_GammaTransferParams { |
| 243 | float G; |
| 244 | float A; |
| 245 | float B; |
| 246 | float C; |
| 247 | float D; |
| 248 | float E; |
| 249 | float F; |
| 250 | uint padding; |
| 251 | }; |
| 252 | |
| 253 | struct tint_ExternalTextureParams_std140 { |
| 254 | uint numPlanes; |
| 255 | uint doYuvToRgbConversionOnly; |
James Price | 925f03f | 2024-10-10 23:01:30 +0000 | [diff] [blame] | 256 | uint tint_pad_0; |
dan sinclair | 2574827 | 2024-10-08 20:05:30 +0000 | [diff] [blame] | 257 | uint tint_pad_1; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 258 | mat3x4 yuvToRgbConversionMatrix; |
| 259 | tint_GammaTransferParams gammaDecodeParams; |
| 260 | tint_GammaTransferParams gammaEncodeParams; |
| 261 | vec3 gamutConversionMatrix_col0; |
dan sinclair | 2574827 | 2024-10-08 20:05:30 +0000 | [diff] [blame] | 262 | uint tint_pad_2; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 263 | vec3 gamutConversionMatrix_col1; |
dan sinclair | 2574827 | 2024-10-08 20:05:30 +0000 | [diff] [blame] | 264 | uint tint_pad_3; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 265 | vec3 gamutConversionMatrix_col2; |
dan sinclair | 2574827 | 2024-10-08 20:05:30 +0000 | [diff] [blame] | 266 | uint tint_pad_4; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 267 | vec2 sampleTransform_col0; |
| 268 | vec2 sampleTransform_col1; |
| 269 | vec2 sampleTransform_col2; |
| 270 | vec2 loadTransform_col0; |
| 271 | vec2 loadTransform_col1; |
| 272 | vec2 loadTransform_col2; |
| 273 | vec2 samplePlane0RectMin; |
| 274 | vec2 samplePlane0RectMax; |
| 275 | vec2 samplePlane1RectMin; |
| 276 | vec2 samplePlane1RectMax; |
Corentin Wallez | 9e9ed67 | 2024-11-21 11:56:04 +0000 | [diff] [blame] | 277 | uvec2 apparentSize; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 278 | vec2 plane1CoordFactor; |
| 279 | }; |
| 280 | |
| 281 | struct tint_ExternalTextureParams { |
| 282 | uint numPlanes; |
| 283 | uint doYuvToRgbConversionOnly; |
| 284 | mat3x4 yuvToRgbConversionMatrix; |
| 285 | tint_GammaTransferParams gammaDecodeParams; |
| 286 | tint_GammaTransferParams gammaEncodeParams; |
| 287 | mat3 gamutConversionMatrix; |
| 288 | mat3x2 sampleTransform; |
| 289 | mat3x2 loadTransform; |
| 290 | vec2 samplePlane0RectMin; |
| 291 | vec2 samplePlane0RectMax; |
| 292 | vec2 samplePlane1RectMin; |
| 293 | vec2 samplePlane1RectMax; |
Corentin Wallez | 9e9ed67 | 2024-11-21 11:56:04 +0000 | [diff] [blame] | 294 | uvec2 apparentSize; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 295 | vec2 plane1CoordFactor; |
| 296 | }; |
| 297 | |
| 298 | struct VertexOutput { |
| 299 | vec4 pos; |
| 300 | vec4 prevent_dce; |
| 301 | }; |
| 302 | |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 303 | layout(binding = 2, std140) |
James Price | 2312bfa | 2024-12-13 09:53:34 -0800 | [diff] [blame] | 304 | uniform v_arg_0_params_block_std140_ubo { |
James Price | 71c1d54 | 2024-10-10 23:01:19 +0000 | [diff] [blame] | 305 | tint_ExternalTextureParams_std140 inner; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 306 | } v_1; |
dan sinclair | 680183f | 2024-10-07 19:57:38 +0000 | [diff] [blame] | 307 | uniform highp sampler2D arg_0_plane0; |
| 308 | uniform highp sampler2D arg_0_plane1; |
James Price | ced6366 | 2024-12-13 10:48:26 -0800 | [diff] [blame] | 309 | layout(location = 0) flat out vec4 tint_interstage_location0; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 310 | vec3 tint_GammaCorrection(vec3 v, tint_GammaTransferParams params) { |
| 311 | vec3 v_2 = vec3(params.G); |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 312 | return mix((sign(v) * (pow(((params.A * abs(v)) + params.B), v_2) + params.E)), (sign(v) * ((params.C * abs(v)) + params.F)), lessThan(abs(v), vec3(params.D))); |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 313 | } |
dan sinclair | 680183f | 2024-10-07 19:57:38 +0000 | [diff] [blame] | 314 | vec4 tint_TextureLoadExternal(tint_ExternalTextureParams params, uvec2 coords) { |
Corentin Wallez | 9e9ed67 | 2024-11-21 11:56:04 +0000 | [diff] [blame] | 315 | vec2 v_3 = round((params.loadTransform * vec3(vec2(min(coords, params.apparentSize)), 1.0f))); |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 316 | uvec2 v_4 = uvec2(v_3); |
| 317 | vec3 v_5 = vec3(0.0f); |
| 318 | float v_6 = 0.0f; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 319 | if ((params.numPlanes == 1u)) { |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 320 | ivec2 v_7 = ivec2(v_4); |
| 321 | vec4 v_8 = texelFetch(arg_0_plane0, v_7, int(0u)); |
| 322 | v_5 = v_8.xyz; |
James Price | 25379d3 | 2024-11-28 21:23:47 +0000 | [diff] [blame] | 323 | v_6 = v_8.w; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 324 | } else { |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 325 | ivec2 v_9 = ivec2(v_4); |
James Price | 25379d3 | 2024-11-28 21:23:47 +0000 | [diff] [blame] | 326 | float v_10 = texelFetch(arg_0_plane0, v_9, int(0u)).x; |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 327 | ivec2 v_11 = ivec2(uvec2((v_3 * params.plane1CoordFactor))); |
| 328 | v_5 = (vec4(v_10, texelFetch(arg_0_plane1, v_11, int(0u)).xy, 1.0f) * params.yuvToRgbConversionMatrix); |
| 329 | v_6 = 1.0f; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 330 | } |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 331 | vec3 v_12 = v_5; |
| 332 | vec3 v_13 = vec3(0.0f); |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 333 | if ((params.doYuvToRgbConversionOnly == 0u)) { |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 334 | v_13 = tint_GammaCorrection((params.gamutConversionMatrix * tint_GammaCorrection(v_12, params.gammaDecodeParams)), params.gammaEncodeParams); |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 335 | } else { |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 336 | v_13 = v_12; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 337 | } |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 338 | return vec4(v_13, v_6); |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 339 | } |
| 340 | tint_ExternalTextureParams tint_convert_tint_ExternalTextureParams(tint_ExternalTextureParams_std140 tint_input) { |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 341 | mat3 v_14 = mat3(tint_input.gamutConversionMatrix_col0, tint_input.gamutConversionMatrix_col1, tint_input.gamutConversionMatrix_col2); |
| 342 | mat3x2 v_15 = mat3x2(tint_input.sampleTransform_col0, tint_input.sampleTransform_col1, tint_input.sampleTransform_col2); |
Corentin Wallez | 9e9ed67 | 2024-11-21 11:56:04 +0000 | [diff] [blame] | 343 | return tint_ExternalTextureParams(tint_input.numPlanes, tint_input.doYuvToRgbConversionOnly, tint_input.yuvToRgbConversionMatrix, tint_input.gammaDecodeParams, tint_input.gammaEncodeParams, v_14, v_15, mat3x2(tint_input.loadTransform_col0, tint_input.loadTransform_col1, tint_input.loadTransform_col2), tint_input.samplePlane0RectMin, tint_input.samplePlane0RectMax, tint_input.samplePlane1RectMin, tint_input.samplePlane1RectMax, tint_input.apparentSize, tint_input.plane1CoordFactor); |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 344 | } |
| 345 | vec4 textureLoad_1bfdfb() { |
| 346 | uvec2 arg_1 = uvec2(1u); |
dan sinclair | 3d64565 | 2024-11-19 15:29:05 +0000 | [diff] [blame] | 347 | tint_ExternalTextureParams v_16 = tint_convert_tint_ExternalTextureParams(v_1.inner); |
dan sinclair | ec3114d | 2024-11-28 16:23:49 +0000 | [diff] [blame] | 348 | vec4 res = tint_TextureLoadExternal(v_16, min(arg_1, ((v_16.apparentSize + uvec2(1u)) - uvec2(1u)))); |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 349 | return res; |
| 350 | } |
| 351 | VertexOutput vertex_main_inner() { |
James Price | 49631b5 | 2024-12-13 13:34:39 -0800 | [diff] [blame^] | 352 | VertexOutput v_17 = VertexOutput(vec4(0.0f), vec4(0.0f)); |
| 353 | v_17.pos = vec4(0.0f); |
| 354 | v_17.prevent_dce = textureLoad_1bfdfb(); |
| 355 | return v_17; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 356 | } |
| 357 | void main() { |
James Price | 49631b5 | 2024-12-13 13:34:39 -0800 | [diff] [blame^] | 358 | VertexOutput v_18 = vertex_main_inner(); |
| 359 | gl_Position = v_18.pos; |
James Price | 25379d3 | 2024-11-28 21:23:47 +0000 | [diff] [blame] | 360 | gl_Position.y = -(gl_Position.y); |
| 361 | gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); |
James Price | 49631b5 | 2024-12-13 13:34:39 -0800 | [diff] [blame^] | 362 | tint_interstage_location0 = v_18.prevent_dce; |
dan sinclair | 803ff2b | 2024-09-23 18:37:22 +0000 | [diff] [blame] | 363 | gl_PointSize = 1.0f; |
| 364 | } |