Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/metal/kernels/compute_texture_update.msl
| Show All 32 Lines | |||||
| #if DIMS == 1 | #if DIMS == 1 | ||||
| # define POSITION_TYPE uint | # define POSITION_TYPE uint | ||||
| #elif DIMS == 2 | #elif DIMS == 2 | ||||
| # define POSITION_TYPE uint2 | # define POSITION_TYPE uint2 | ||||
| #elif DIMS == 3 | #elif DIMS == 3 | ||||
| # define POSITION_TYPE uint3 | # define POSITION_TYPE uint3 | ||||
| #endif | #endif | ||||
| float3 mtl_linear_to_srgb_attr(float3 c) | |||||
| { | |||||
| c = max(c, float3(0.0)); | |||||
| float3 c1 = c * 12.92; | |||||
| float3 c2 = 1.055 * pow(c, float3(1.0 / 2.4)) - 0.055; | |||||
| return mix(c1, c2, step(float3(0.0031308), c)); | |||||
| } | |||||
| float3 mtl_srgb_to_linear_attr(float3 c) | |||||
| { | |||||
| c = max(c, float3(0.0)); | |||||
| float3 c1 = c * (1.0 / 12.92); | |||||
| float3 c2 = pow((c + 0.055) * (1.0 / 1.055), float3(2.4)); | |||||
| return mix(c1, c2, step(float3(0.04045), c)); | |||||
| } | |||||
| struct TextureUpdateParams { | struct TextureUpdateParams { | ||||
| int mip_index; | int mip_index; | ||||
| int extent[3]; | int extent[3]; | ||||
| int offset[3]; | int offset[3]; | ||||
| uint unpack_row_length; | uint unpack_row_length; | ||||
| }; | }; | ||||
| kernel void compute_texture_update(constant TextureUpdateParams ¶ms [[buffer(0)]], | kernel void compute_texture_update(constant TextureUpdateParams ¶ms [[buffer(0)]], | ||||
| ▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | #elif TEX_TYPE == GPU_TEXTURE_2D_ARRAY | ||||
| for (int i = COMPONENT_COUNT_INPUT; i < COMPONENT_COUNT_OUTPUT; i++) { | for (int i = COMPONENT_COUNT_INPUT; i < COMPONENT_COUNT_OUTPUT; i++) { | ||||
| output[i] = OUTPUT_DATA_TYPE(0); | output[i] = OUTPUT_DATA_TYPE(0); | ||||
| } | } | ||||
| update_tex.write( | update_tex.write( | ||||
| output, uint2(params.offset[0], params.offset[1]) + uint2(xx, yy), params.offset[2] + layer); | output, uint2(params.offset[0], params.offset[1]) + uint2(xx, yy), params.offset[2] + layer); | ||||
| #endif | #endif | ||||
| } | } | ||||
| No newline at end of file | No newline at end of file | ||||