diff --git a/.gitignore b/.gitignore index 5945717c..755e87e9 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ app/release.jks /agc-photon-lut /third_party __pycache__ -/scripts/research +/scripts/research/* +!/scripts/research/generate_mgc_spatial_rgb_merge_static_asm.py .codex-tmp -.tmp \ No newline at end of file +.tmp diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index 579ef3ab..a52922df 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -147,6 +147,45 @@ set_source_files_properties( OBJECT_DEPENDS "${MGC_SHARPEN_CAPSULE}" ) +set( + MGC_SPATIAL_RGB_CAPSULE + "${CMAKE_CURRENT_SOURCE_DIR}/mgc_denoise_static/mgc_spatial_rgb_merge_capsule.bin" +) +set( + MGC_SPATIAL_RGB_CAPSULE_SHA256 + "196c4fb671a4c1e0667518d334474afd6f81a35a01acfd9d385089630a58eddd" +) +if(NOT EXISTS "${MGC_SPATIAL_RGB_CAPSULE}") + message( + FATAL_ERROR + "MGC Spatial RGB Merge capsule is missing; regenerate it with " + "scripts/research/generate_mgc_spatial_rgb_merge_static_asm.py" + ) +endif() +file( + SHA256 + "${MGC_SPATIAL_RGB_CAPSULE}" + MGC_SPATIAL_RGB_CAPSULE_ACTUAL_SHA256 +) +if(NOT MGC_SPATIAL_RGB_CAPSULE_ACTUAL_SHA256 STREQUAL MGC_SPATIAL_RGB_CAPSULE_SHA256) + message(FATAL_ERROR "MGC Spatial RGB Merge capsule hash mismatch") +endif() +set( + MGC_SPATIAL_RGB_ASM + "${CMAKE_CURRENT_BINARY_DIR}/mgc_spatial_rgb_merge_static.S" +) +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/mgc_denoise_static/mgc_spatial_rgb_merge_static.S.in" + "${MGC_SPATIAL_RGB_ASM}" + @ONLY +) +set_source_files_properties( + "${MGC_SPATIAL_RGB_ASM}" + PROPERTIES + GENERATED TRUE + OBJECT_DEPENDS "${MGC_SPATIAL_RGB_CAPSULE}" +) + # 4. 添加头文件路径 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/LibRaw) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libjpeg-turbo/src) @@ -234,12 +273,14 @@ add_library(my-native-lib SHARED mgc_denoise_static/mgc_denoise_static.cpp mgc_denoise_static/mgc_full_resolution_denoise_jni.cpp mgc_denoise_static/mgc_sabre_resolve_jni.cpp + mgc_denoise_static/mgc_spatial_rgb_merge_jni.cpp mgc_denoise_static/mgc_sharpen_jni.cpp mgc_denoise_static/mgc_spatial_strength_jni.cpp "${MGC_DENOISE_ASM}" "${MGC_DEMOIRE_ASM}" "${MGC_SABRE_ASM}" "${MGC_SHARPEN_ASM}" + "${MGC_SPATIAL_RGB_ASM}" ${LIBRAW_SOURCES} ${ADOBE_DNG_SOURCES} ) diff --git a/app/src/main/cpp/mgc_denoise_static/mgc_denoise_static.cpp b/app/src/main/cpp/mgc_denoise_static/mgc_denoise_static.cpp index 1f2083fd..7c8d5a55 100644 --- a/app/src/main/cpp/mgc_denoise_static/mgc_denoise_static.cpp +++ b/app/src/main/cpp/mgc_denoise_static/mgc_denoise_static.cpp @@ -674,6 +674,26 @@ PHOTON_MGC_DEFINE_HALIDE_ERROR(5dae6b8) PHOTON_MGC_DEFINE_HALIDE_ERROR(5f57538) PHOTON_MGC_DEFINE_HALIDE_ERROR(5f59544) PHOTON_MGC_DEFINE_HALIDE_ERROR(5f595a0) +PHOTON_MGC_DEFINE_HALIDE_ERROR(2055170) +PHOTON_MGC_DEFINE_HALIDE_ERROR(38a3740) +PHOTON_MGC_DEFINE_HALIDE_ERROR(38a92e8) +PHOTON_MGC_DEFINE_HALIDE_ERROR(5f94b18) +PHOTON_MGC_DEFINE_HALIDE_ERROR(5f94c0c) +PHOTON_MGC_DEFINE_HALIDE_ERROR(5f94c78) +PHOTON_MGC_DEFINE_HALIDE_ERROR(5f94d60) +PHOTON_MGC_DEFINE_HALIDE_ERROR(5f94e38) +PHOTON_MGC_DEFINE_HALIDE_ERROR(5f94ec4) +PHOTON_MGC_DEFINE_HALIDE_ERROR(5f94fa8) +PHOTON_MGC_DEFINE_HALIDE_ERROR(5f95034) +PHOTON_MGC_DEFINE_HALIDE_ERROR(5f950cc) +PHOTON_MGC_DEFINE_HALIDE_ERROR(5f95260) +PHOTON_MGC_DEFINE_HALIDE_ERROR(5f95540) +PHOTON_MGC_DEFINE_HALIDE_ERROR(5f95560) +PHOTON_MGC_DEFINE_HALIDE_ERROR(5f95638) +PHOTON_MGC_DEFINE_HALIDE_ERROR(5f956a4) +PHOTON_MGC_DEFINE_HALIDE_ERROR(5ff6938) +PHOTON_MGC_DEFINE_HALIDE_ERROR(5ff8944) +PHOTON_MGC_DEFINE_HALIDE_ERROR(5ff89a0) #undef PHOTON_MGC_DEFINE_HALIDE_ERROR diff --git a/app/src/main/cpp/mgc_denoise_static/mgc_spatial_rgb_merge_capsule.bin b/app/src/main/cpp/mgc_denoise_static/mgc_spatial_rgb_merge_capsule.bin new file mode 100644 index 00000000..a66886a8 Binary files /dev/null and b/app/src/main/cpp/mgc_denoise_static/mgc_spatial_rgb_merge_capsule.bin differ diff --git a/app/src/main/cpp/mgc_denoise_static/mgc_spatial_rgb_merge_jni.cpp b/app/src/main/cpp/mgc_denoise_static/mgc_spatial_rgb_merge_jni.cpp new file mode 100644 index 00000000..c899f083 --- /dev/null +++ b/app/src/main/cpp/mgc_denoise_static/mgc_spatial_rgb_merge_jni.cpp @@ -0,0 +1,404 @@ +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + +constexpr char kTag[] = "PLog_MgcSpatialRgbAot"; + +struct HalideType { + uint8_t code; + uint8_t bits; + uint16_t lanes; +}; + +struct HalideDimension { + int32_t min; + int32_t extent; + int32_t stride; + uint32_t flags; +}; + +struct HalideBuffer { + uint64_t device; + const void* device_interface; + uint8_t* host; + uint64_t flags; + HalideType type; + int32_t dimensions; + const HalideDimension* dim; + void* padding; +}; + +static_assert(sizeof(HalideBuffer) == 56); +static_assert(sizeof(HalideDimension) == 16); +static_assert(offsetof(HalideBuffer, type) == 32); +static_assert(offsetof(HalideBuffer, dimensions) == 36); +static_assert(offsetof(HalideBuffer, dim) == 40); + +constexpr HalideType kUInt8 = {1, 8, 1}; +constexpr HalideType kUInt16 = {1, 16, 1}; +constexpr HalideType kUInt64 = {1, 64, 1}; +constexpr HalideType kFloat16 = {2, 16, 1}; +constexpr HalideType kFloat32 = {2, 32, 1}; + +constexpr int32_t Camera2CfaToMgcBayerPattern(int cfa_pattern) { + switch (cfa_pattern) { + case 0: + return 1; // RGGB + case 1: + return 3; // GRBG + case 2: + return 4; // GBRG + case 3: + return 2; // BGGR + default: + return 0; + } +} + +HalideBuffer MakeBuffer( + void* host, + HalideType type, + const HalideDimension* dimensions, + int dimension_count) { + HalideBuffer buffer = {}; + buffer.host = static_cast(host); + buffer.type = type; + buffer.dimensions = dimension_count; + buffer.dim = dimensions; + return buffer; +} + +bool CopyFloatArray( + JNIEnv* env, + jfloatArray source, + int expected_size, + std::vector* output, + bool require_positive) { + if (source == nullptr || env->GetArrayLength(source) != expected_size) return false; + output->resize(expected_size); + env->GetFloatArrayRegion(source, 0, expected_size, output->data()); + if (env->ExceptionCheck()) return false; + return std::all_of(output->begin(), output->end(), [require_positive](float value) { + return std::isfinite(value) && (!require_positive || value > 0.0f); + }); +} + +bool CheckedProduct(std::initializer_list factors, int64_t* result) { + int64_t value = 1; + for (const int64_t factor : factors) { + if (factor <= 0 || value > std::numeric_limits::max() / factor) return false; + value *= factor; + } + *result = value; + return true; +} + +float HalfToFloat(uint16_t value) { + const uint32_t sign = static_cast(value & 0x8000u) << 16u; + uint32_t exponent = (value >> 10u) & 0x1fu; + uint32_t mantissa = value & 0x03ffu; + uint32_t encoded = 0; + if (exponent == 0) { + if (mantissa == 0) { + encoded = sign; + } else { + int shift = 0; + while ((mantissa & 0x0400u) == 0) { + mantissa <<= 1u; + ++shift; + } + mantissa &= 0x03ffu; + encoded = sign | + (static_cast(127 - 14 - shift) << 23u) | + (mantissa << 13u); + } + } else if (exponent == 0x1fu) { + encoded = sign | 0x7f800000u | (mantissa << 13u); + } else { + encoded = sign | ((exponent + 127u - 15u) << 23u) | (mantissa << 13u); + } + float result = 0.0f; + std::memcpy(&result, &encoded, sizeof(result)); + return result; +} + +} // namespace + +// Exact generated ABI at MGC 9.7.047 V25 libgcastartup.so+0x371990c. +extern "C" int photon_mgc_merge_rgb_raw16_f16_tile16_halide( + void* user_context, + int32_t bayer_pattern, + HalideBuffer* base_frame, + HalideBuffer* burst_ptrs, + HalideBuffer* alignment, + HalideBuffer* rejection_masks, + HalideBuffer* frame_weights, + HalideBuffer* wb_gains, + HalideBuffer* input_black_levels_rgb, + HalideBuffer* input_black_levels_rggb, + HalideBuffer* input_gains, + float overall_gain, + float merge_sharpness, + HalideBuffer* kernel_sigmas, + int32_t output_width, + int32_t output_height, + HalideBuffer* output); + +extern "C" JNIEXPORT jint JNICALL +Java_com_hinnka_mycamera_processor_MgcSpatialRgbMerger_nativeMerge( + JNIEnv* env, + jobject, + jobjectArray raw_buffers, + jintArray raw_offsets_array, + jintArray raw_row_strides_array, + jobject alignment_buffer, + jint alignment_width, + jint alignment_height, + jobject rejection_buffer, + jint rejection_width, + jint rejection_height, + jfloatArray frame_weights_array, + jfloatArray wb_gains_array, + jfloatArray input_black_levels_rgb_array, + jfloatArray input_black_levels_rggb_array, + jfloatArray input_gains_array, + jfloat overall_gain, + jfloat merge_sharpness, + jfloatArray kernel_sigmas_array, + jint raw_width, + jint raw_height, + jint output_width, + jint output_height, + jint cfa_pattern, + jobject output_buffer) { + const int32_t mgc_pattern = Camera2CfaToMgcBayerPattern(cfa_pattern); + const int frame_count = raw_buffers != nullptr + ? env->GetArrayLength(raw_buffers) + : 0; + if (frame_count <= 0 || raw_offsets_array == nullptr || + raw_row_strides_array == nullptr || alignment_buffer == nullptr || + rejection_buffer == nullptr || output_buffer == nullptr || + env->GetArrayLength(raw_offsets_array) != frame_count || + env->GetArrayLength(raw_row_strides_array) != frame_count || + raw_width <= 0 || raw_height <= 0 || output_width <= 0 || + output_height <= 0 || (output_width & 15) != 0 || + (output_height & 15) != 0 || alignment_width != output_width / 16 || + alignment_height != output_height / 16 || rejection_width <= 0 || + rejection_height <= 0 || mgc_pattern == 0 || + !std::isfinite(overall_gain) || overall_gain <= 0.0f || + !std::isfinite(merge_sharpness) || merge_sharpness < 0.0f) { + return -1; + } + + int64_t raw_pixel_count = 0; + int64_t output_sample_count = 0; + int64_t alignment_sample_count = 0; + int64_t rejection_sample_count = 0; + if (!CheckedProduct({raw_width, raw_height}, &raw_pixel_count) || + !CheckedProduct({output_width, output_height, 3}, &output_sample_count) || + !CheckedProduct( + {alignment_width, alignment_height, frame_count, 2}, + &alignment_sample_count) || + !CheckedProduct( + {rejection_width, rejection_height, frame_count}, + &rejection_sample_count) || + raw_pixel_count > static_cast( + std::numeric_limits::max() / sizeof(uint16_t))) { + return -1; + } + + auto* alignment = static_cast(env->GetDirectBufferAddress(alignment_buffer)); + auto* rejection = static_cast(env->GetDirectBufferAddress(rejection_buffer)); + auto* output = static_cast(env->GetDirectBufferAddress(output_buffer)); + if (alignment == nullptr || rejection == nullptr || output == nullptr || + env->GetDirectBufferCapacity(alignment_buffer) < + alignment_sample_count * static_cast(sizeof(float)) || + env->GetDirectBufferCapacity(rejection_buffer) < rejection_sample_count || + env->GetDirectBufferCapacity(output_buffer) < + output_sample_count * static_cast(sizeof(uint16_t))) { + return -1; + } + + std::vector raw_offsets(frame_count); + std::vector raw_row_strides(frame_count); + env->GetIntArrayRegion(raw_offsets_array, 0, frame_count, raw_offsets.data()); + env->GetIntArrayRegion( + raw_row_strides_array, + 0, + frame_count, + raw_row_strides.data()); + if (env->ExceptionCheck()) return -1; + + // Camera2 RAW planes are normally tight. Point the AOT directly at those direct buffers and + // allocate a packed copy only for the uncommon padded-row plane; copying the whole burst would + // otherwise duplicate hundreds of megabytes before Halide starts. + std::vector> packed_raw(frame_count); + std::vector burst_ptrs(frame_count); + for (int frame = 0; frame < frame_count; ++frame) { + jobject raw_buffer = env->GetObjectArrayElement(raw_buffers, frame); + if (raw_buffer == nullptr) return -1; + auto* raw_base = static_cast(env->GetDirectBufferAddress(raw_buffer)); + const int64_t raw_capacity = env->GetDirectBufferCapacity(raw_buffer); + const int64_t offset = raw_offsets[frame]; + const int64_t row_stride = raw_row_strides[frame]; + const int64_t required = offset + + static_cast(raw_height - 1) * row_stride + + static_cast(raw_width) * sizeof(uint16_t); + if (raw_base == nullptr || offset < 0 || (offset & 1LL) != 0 || + row_stride < raw_width * 2LL || + required > raw_capacity) { + env->DeleteLocalRef(raw_buffer); + return -1; + } + uint16_t* destination = nullptr; + if (row_stride == raw_width * static_cast(sizeof(uint16_t))) { + destination = reinterpret_cast(raw_base + offset); + } else { + packed_raw[frame].resize(static_cast(raw_pixel_count)); + destination = packed_raw[frame].data(); + for (int y = 0; y < raw_height; ++y) { + std::memcpy( + destination + static_cast(y) * raw_width, + raw_base + offset + static_cast(y) * row_stride, + static_cast(raw_width) * sizeof(uint16_t)); + } + } + burst_ptrs[frame] = reinterpret_cast(destination); + env->DeleteLocalRef(raw_buffer); + } + + std::vector frame_weights; + std::vector wb_gains; + std::vector black_rgb; + std::vector black_rggb; + std::vector input_gains; + std::vector kernel_sigmas; + if (!CopyFloatArray(env, frame_weights_array, frame_count, &frame_weights, true) || + !CopyFloatArray(env, wb_gains_array, 4, &wb_gains, true) || + !CopyFloatArray(env, input_black_levels_rgb_array, 3, &black_rgb, false) || + !CopyFloatArray(env, input_black_levels_rggb_array, 4, &black_rggb, false) || + !CopyFloatArray(env, input_gains_array, frame_count, &input_gains, true) || + !CopyFloatArray(env, kernel_sigmas_array, frame_count, &kernel_sigmas, true)) { + return -1; + } + + const int32_t alignment_plane_stride = alignment_width * alignment_height; + const int32_t rejection_plane_stride = rejection_width * rejection_height; + const int32_t output_plane_stride = output_width * output_height; + const HalideDimension raw_dimensions[2] = { + {0, raw_width, 1, 0}, + {0, raw_height, raw_width, 0}, + }; + const HalideDimension burst_dimensions[1] = {{0, frame_count, 1, 0}}; + const HalideDimension alignment_dimensions[4] = { + {0, alignment_width, 1, 0}, + {0, alignment_height, alignment_width, 0}, + {0, frame_count, alignment_plane_stride, 0}, + {0, 2, alignment_plane_stride * frame_count, 0}, + }; + const HalideDimension rejection_dimensions[3] = { + {0, rejection_width, 1, 0}, + {0, rejection_height, rejection_width, 0}, + {0, frame_count, rejection_plane_stride, 0}, + }; + const HalideDimension frame_dimensions[1] = {{0, frame_count, 1, 0}}; + const HalideDimension wb_dimensions[1] = {{0, 4, 1, 0}}; + const HalideDimension rgb_dimensions[1] = {{0, 3, 1, 0}}; + const HalideDimension rggb_dimensions[1] = {{0, 4, 1, 0}}; + const HalideDimension output_dimensions[3] = { + {0, output_width, 1, 0}, + {0, output_height, output_width, 0}, + {0, 3, output_plane_stride, 0}, + }; + + HalideBuffer base = MakeBuffer( + reinterpret_cast(static_cast(burst_ptrs[0])), + kUInt16, + raw_dimensions, + 2); + HalideBuffer burst = MakeBuffer( + burst_ptrs.data(), kUInt64, burst_dimensions, 1); + HalideBuffer alignment_halide = MakeBuffer( + alignment, kFloat32, alignment_dimensions, 4); + HalideBuffer rejection_halide = MakeBuffer( + rejection, kUInt8, rejection_dimensions, 3); + HalideBuffer weights_halide = MakeBuffer( + frame_weights.data(), kFloat32, frame_dimensions, 1); + HalideBuffer wb_halide = MakeBuffer( + wb_gains.data(), kFloat32, wb_dimensions, 1); + HalideBuffer black_rgb_halide = MakeBuffer( + black_rgb.data(), kFloat32, rgb_dimensions, 1); + HalideBuffer black_rggb_halide = MakeBuffer( + black_rggb.data(), kFloat32, rggb_dimensions, 1); + HalideBuffer gains_halide = MakeBuffer( + input_gains.data(), kFloat32, frame_dimensions, 1); + HalideBuffer sigmas_halide = MakeBuffer( + kernel_sigmas.data(), kFloat32, frame_dimensions, 1); + HalideBuffer output_halide = MakeBuffer( + output, kFloat16, output_dimensions, 3); + + const int result = photon_mgc_merge_rgb_raw16_f16_tile16_halide( + nullptr, + mgc_pattern, + &base, + &burst, + &alignment_halide, + &rejection_halide, + &weights_halide, + &wb_halide, + &black_rgb_halide, + &black_rggb_halide, + &gains_halide, + overall_gain, + merge_sharpness, + &sigmas_halide, + output_width, + output_height, + &output_halide); + if (result != 0) { + __android_log_print( + ANDROID_LOG_ERROR, + kTag, + "MergeRgbRaw16F16 failed result=%d raw=%dx%d output=%dx%d frames=%d cfa=%d", + result, + raw_width, + raw_height, + output_width, + output_height, + frame_count, + cfa_pattern); + return result; + } + return 0; +} + +extern "C" JNIEXPORT jint JNICALL +Java_com_hinnka_mycamera_processor_MgcSpatialRgbMerger_nativeConvertPlanarF16ToFixed16( + JNIEnv* env, + jobject, + jobject buffer, + jint sample_count) { + if (buffer == nullptr || sample_count <= 0) return -1; + auto* samples = static_cast(env->GetDirectBufferAddress(buffer)); + const int64_t required_bytes = + static_cast(sample_count) * static_cast(sizeof(uint16_t)); + if (samples == nullptr || env->GetDirectBufferCapacity(buffer) < required_bytes) return -1; + auto* fixed16 = reinterpret_cast(samples); + for (int index = 0; index < sample_count; ++index) { + const float sample = HalfToFloat(samples[index]); + const float finite_sample = std::isfinite(sample) ? sample : 0.0f; + fixed16[index] = static_cast(std::lrintf( + std::clamp(finite_sample, 0.0f, 32767.0f))); + } + return 0; +} diff --git a/app/src/main/cpp/mgc_denoise_static/mgc_spatial_rgb_merge_static.S.in b/app/src/main/cpp/mgc_denoise_static/mgc_spatial_rgb_merge_static.S.in new file mode 100644 index 00000000..218b12c6 --- /dev/null +++ b/app/src/main/cpp/mgc_denoise_static/mgc_spatial_rgb_merge_static.S.in @@ -0,0 +1,1118 @@ +/* Generated mechanically from pinned MGC 9.7.047 V25 Spatial RGB Merge AOT. + * Do not edit; regenerate with + * scripts/research/generate_mgc_spatial_rgb_merge_static_asm.py. + */ + +#if !defined(__aarch64__) +#error "MGC Spatial RGB Merge static lift is arm64-only" +#endif + + .hidden photon_mgc_halide_error_2055170 + .hidden photon_mgc_halide_error_38a3740 + .hidden photon_mgc_halide_error_38a92e8 + .hidden photon_mgc_halide_error_5f94b18 + .hidden photon_mgc_halide_error_5f94c0c + .hidden photon_mgc_halide_error_5f94c78 + .hidden photon_mgc_halide_error_5f94d60 + .hidden photon_mgc_halide_error_5f94e38 + .hidden photon_mgc_halide_error_5f94ec4 + .hidden photon_mgc_halide_error_5f94fa8 + .hidden photon_mgc_halide_error_5f95034 + .hidden photon_mgc_halide_error_5f950cc + .hidden photon_mgc_halide_error_5f95260 + .hidden photon_mgc_halide_error_5f95540 + .hidden photon_mgc_halide_error_5f95560 + .hidden photon_mgc_halide_error_5f95638 + .hidden photon_mgc_halide_error_5f956a4 + .hidden photon_mgc_halide_error_5ff6938 + .hidden photon_mgc_halide_error_5ff8944 + .hidden photon_mgc_halide_error_5ff89a0 + .hidden photon_mgc_halide_do_par_for + .hidden photon_mgc_halide_free + .hidden photon_mgc_halide_malloc + .hidden photon_mgc_halide_trace + .hidden photon_mgc_u16_copy_dispatch + +.section .text.photon_mgc.SpatialRgb.u16_copy_dispatch,"ax",@progbits + .p2align 4 + .type photon_mgc_u16_copy_dispatch, %function +photon_mgc_u16_copy_dispatch: + cmp w0, #2 + b.ne .Lphoton_mgc_u16_copy_unsupported + mov x0, x1 + mov x1, x2 + ldr w8, [x1, #0x24] + cmp w8, #3 + b.eq photon_mgc_spatial_rgb_address_5e4dca8 + b photon_mgc_spatial_rgb_address_5e4cb58 +.Lphoton_mgc_u16_copy_unsupported: + mov w0, #-1 + ret + .size photon_mgc_u16_copy_dispatch, .-photon_mgc_u16_copy_dispatch + +.section .text.photon_mgc.SpatialRgb.merge,"ax",@progbits + .p2align 12 + .global photon_mgc_merge_rgb_raw16_f16_tile16_halide + .hidden photon_mgc_merge_rgb_raw16_f16_tile16_halide + .type photon_mgc_merge_rgb_raw16_f16_tile16_halide, %function +photon_mgc_spatial_rgb_page_370f000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x0, 0x514 +photon_mgc_spatial_rgb_address_370f514: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x514, 0x38 + adrp x10, photon_mgc_spatial_rgb_page_6b6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x54c, 0x38 + adrp x10, photon_mgc_spatial_rgb_page_6bc000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x584, 0x70 + adrp x8, photon_mgc_spatial_rgb_page_6b4000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x5f4, 0x2ec + bl photon_mgc_spatial_rgb_address_389b420 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x8e0, 0x274 + bl photon_mgc_spatial_rgb_address_389b420 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xb54, 0x214 + adrp x20, photon_mgc_spatial_rgb_page_6ba000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd68, 0xf0 + adrp x15, photon_mgc_spatial_rgb_page_6bc000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xe58, 0x18c +photon_mgc_spatial_rgb_page_3710000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xfe4, 0x80 + adrp x9, photon_mgc_spatial_rgb_page_6c2000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1064, 0x8 + adrp x9, photon_mgc_spatial_rgb_page_6b9000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x106c, 0x4 + adrp x9, photon_mgc_spatial_rgb_page_6b5000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1070, 0xf68 +photon_mgc_spatial_rgb_page_3711000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1fd8, 0xb8 + bl photon_mgc_spatial_rgb_address_389b420 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x2090, 0x278 + bl photon_mgc_spatial_rgb_address_389b420 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x2308, 0x1c4 + bl photon_mgc_spatial_rgb_address_389b420 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x24cc, 0x2a0 + bl photon_mgc_spatial_rgb_address_389b420 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x276c, 0x1f8 + bl photon_mgc_spatial_rgb_address_389b420 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x2964, 0x3c + adrp x4, photon_mgc_spatial_rgb_page_6bc000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x29a0, 0x620 +photon_mgc_spatial_rgb_page_3712000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x2fc0, 0xd74 + adrp x8, photon_mgc_spatial_rgb_page_6c4000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x3d34, 0x288 +photon_mgc_spatial_rgb_page_3713000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x3fbc, 0x470 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x442c, 0x2c + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x4458, 0x58 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x44b0, 0x44 + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x44f4, 0x40 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x4534, 0x20 + adrp x4, photon_mgc_spatial_rgb_page_6bc000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x4554, 0x20 + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x4574, 0x20 + adrp x4, photon_mgc_spatial_rgb_page_6bc000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x4594, 0x69c + bl photon_mgc_spatial_rgb_address_389b420 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x4c30, 0x288 + bl photon_mgc_spatial_rgb_address_389b420 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x4eb8, 0xdc +photon_mgc_spatial_rgb_page_3714000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x4f94, 0x104 + bl photon_mgc_spatial_rgb_address_389b420 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x5098, 0x298 + bl photon_mgc_spatial_rgb_address_389b420 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x5330, 0x1f4 + bl photon_mgc_spatial_rgb_address_389b420 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x5524, 0x3c + adrp x30, photon_mgc_spatial_rgb_page_6bc000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x5560, 0x50c + adrp x30, photon_mgc_spatial_rgb_page_6bc000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x5a6c, 0x2dc + adrp x30, photon_mgc_spatial_rgb_page_6bc000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x5d48, 0x234 +photon_mgc_spatial_rgb_page_3715000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x5f7c, 0x1000 +photon_mgc_spatial_rgb_page_3716000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x6f7c, 0x74 + adrp x8, photon_mgc_spatial_rgb_page_6c4000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x6ff0, 0x6dc + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x76cc, 0x2c + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x76f8, 0x4c + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x7744, 0x34 + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x7778, 0x34 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x77ac, 0x18 + adrp x30, photon_mgc_spatial_rgb_page_6bc000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x77c4, 0x20 + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x77e4, 0x18 + adrp x30, photon_mgc_spatial_rgb_page_6bc000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x77fc, 0x618 + bl photon_mgc_spatial_rgb_address_389b420 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x7e14, 0x140 +photon_mgc_spatial_rgb_page_3717000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x7f54, 0x154 + bl photon_mgc_spatial_rgb_address_389b420 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x80a8, 0x1e4 + bl photon_mgc_spatial_rgb_address_389b420 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x828c, 0x2a0 + bl photon_mgc_spatial_rgb_address_389b420 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x852c, 0x1f4 + bl photon_mgc_spatial_rgb_address_389b420 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x8720, 0x3c + adrp x4, photon_mgc_spatial_rgb_page_6bc000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x875c, 0x7e4 +photon_mgc_spatial_rgb_page_3718000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x8f40, 0xbcc + adrp x8, photon_mgc_spatial_rgb_page_6c4000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x9b0c, 0x430 +photon_mgc_spatial_rgb_page_3719000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x9f3c, 0x3a8 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa2e4, 0x2c + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa310, 0x54 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa364, 0x34 + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa398, 0x3c + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa3d4, 0x20 + adrp x4, photon_mgc_spatial_rgb_page_6bc000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa3f4, 0x20 + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa414, 0x20 + adrp x4, photon_mgc_spatial_rgb_page_6bc000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa434, 0x10c + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa540, 0x28 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa568, 0x28 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa590, 0x14 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa5a4, 0x48 + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa5ec, 0x24 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa610, 0x4 + bl photon_mgc_halide_error_5f94b18 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa614, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa620, 0x8 + bl photon_mgc_halide_error_5f94b18 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa628, 0x10 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa638, 0x4 + bl photon_mgc_halide_error_5f94c0c + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa63c, 0x3c + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa678, 0x4 + bl photon_mgc_halide_error_5f94b18 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa67c, 0x1c + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa698, 0xc + bl photon_mgc_halide_error_5f94fa8 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa6a4, 0x30 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa6d4, 0xc + bl photon_mgc_halide_error_5f94fa8 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa6e0, 0x18 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa6f8, 0x8 + bl photon_mgc_halide_error_5f94fa8 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa700, 0x20 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa720, 0x8 + bl photon_mgc_halide_error_5f94fa8 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa728, 0x1c + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa744, 0x4 + bl photon_mgc_halide_error_5f94b18 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa748, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa754, 0x18 + bl photon_mgc_halide_error_5f94fa8 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa76c, 0x58 +photon_mgc_spatial_rgb_address_371990c: +photon_mgc_merge_rgb_raw16_f16_tile16_halide: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa7c4, 0x168 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa92c, 0x20 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa94c, 0x20 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xa96c, 0x518 + bl photon_mgc_spatial_rgb_address_389ec70 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xae84, 0x24 +photon_mgc_spatial_rgb_page_371a000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xaea8, 0x218 + bl photon_mgc_spatial_rgb_address_389ec70 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xb0c0, 0x8 + adrp x9, photon_mgc_spatial_rgb_page_6b6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xb0c8, 0x1c + adrp x10, photon_mgc_spatial_rgb_page_6bc000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xb0e4, 0x198 + bl photon_mgc_spatial_rgb_address_389b420 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xb27c, 0x1a0 + bl photon_mgc_spatial_rgb_address_389b420 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xb41c, 0x2e0 + adrp x13, photon_mgc_spatial_rgb_page_6b4000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xb6fc, 0x48 + adrp x9, photon_mgc_spatial_rgb_page_6b4000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xb744, 0xf8 + adrp x13, photon_mgc_spatial_rgb_page_6b4000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xb83c, 0x38 + adrp x13, photon_mgc_spatial_rgb_page_6b4000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xb874, 0x5c + adrp x15, photon_mgc_spatial_rgb_page_6b4000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xb8d0, 0x38 + adrp x14, photon_mgc_spatial_rgb_page_6b4000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xb908, 0x88 + adrp x29, photon_mgc_spatial_rgb_page_6b4000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xb990, 0x88 + adrp x17, photon_mgc_spatial_rgb_page_6b4000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xba18, 0x80 + adrp x29, photon_mgc_spatial_rgb_page_6b4000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xba98, 0x10c + adrp x11, photon_mgc_spatial_rgb_page_6b4000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xbba4, 0x2c8 +photon_mgc_spatial_rgb_page_371b000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xbe6c, 0x5ac + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc418, 0x8 + bl photon_mgc_halide_error_5f94d60 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc420, 0x3c + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc45c, 0x50 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc4ac, 0x8 + bl photon_mgc_halide_error_5f94d60 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc4b4, 0x40 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc4f4, 0x34 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc528, 0x30 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc558, 0x44 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc59c, 0x44 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc5e0, 0x2c + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc60c, 0x8 + bl photon_mgc_halide_error_5f94d60 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc614, 0x24 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc638, 0x3c + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc674, 0x48 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc6bc, 0x30 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc6ec, 0x30 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc71c, 0x30 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc74c, 0x34 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc780, 0x4 + adrp x3, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc784, 0x24 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc7a8, 0x34 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc7dc, 0x20 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc7fc, 0x2c + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc828, 0x24 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc84c, 0x30 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc87c, 0x30 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc8ac, 0x4 + adrp x3, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc8b0, 0x24 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc8d4, 0x20 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc8f4, 0x34 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc928, 0x44 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc96c, 0x2c + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc998, 0x8 + bl photon_mgc_halide_error_5f94d60 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc9a0, 0x1c + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc9bc, 0x34 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xc9f0, 0x18 + bl photon_mgc_halide_error_5f94ec4 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xca08, 0xb0 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xcab8, 0x4 + adrp x3, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xcabc, 0x8 + bl photon_mgc_halide_error_5f95260 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xcac4, 0x308 +photon_mgc_spatial_rgb_page_371c000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xcdcc, 0x210 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xcfdc, 0x34 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd010, 0x2c + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd03c, 0x30 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd06c, 0x24 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd090, 0x20 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd0b0, 0x28 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd0d8, 0x30 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd108, 0x24 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd12c, 0x20 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd14c, 0x20 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd16c, 0x28 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd194, 0x24 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd1b8, 0x20 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd1d8, 0x20 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd1f8, 0x44 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd23c, 0x1c + adrp x8, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd258, 0x2c + bl photon_mgc_halide_trace + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd284, 0xf8 + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd37c, 0x20 + adrp x9, photon_mgc_spatial_rgb_page_6b4000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd39c, 0x94 + bl photon_mgc_spatial_rgb_address_389ec70 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd430, 0x274 + adrp x1, photon_mgc_spatial_rgb_page_61e7000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd6a4, 0x4c + bl photon_mgc_halide_do_par_for + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd6f0, 0x8 + adrp x20, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd6f8, 0x10 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd708, 0x10 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd718, 0x20 + bl photon_mgc_halide_trace + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd738, 0x38 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd770, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd77c, 0x8 + bl photon_mgc_halide_error_5f94b18 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd784, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd790, 0x4 + adrp x2, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd794, 0x10 + bl photon_mgc_halide_error_5f94c78 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd7a4, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd7ac, 0xc + bl photon_mgc_halide_error_5f94fa8 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd7b8, 0x8 + bl photon_mgc_halide_error_5f95540 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd7c0, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd7c8, 0x8 + bl photon_mgc_halide_error_5f94c0c + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd7d0, 0x20 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd7f0, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd7f8, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd800, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd808, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd810, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd818, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd820, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd828, 0x34 + b photon_mgc_halide_error_5f95560 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd85c, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd864, 0x10 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd874, 0x4 + adrp x3, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd878, 0x8 + bl photon_mgc_halide_error_5f95260 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd880, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd88c, 0x10 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd89c, 0x4 + adrp x3, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd8a0, 0x8 + bl photon_mgc_halide_error_5f95260 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd8a8, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd8b4, 0xc + bl photon_mgc_halide_error_5f94d60 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd8c0, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd8cc, 0x8 + bl photon_mgc_halide_error_5f94e38 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd8d4, 0x4 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd8d8, 0x10 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd8e8, 0x10 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd8f8, 0x10 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd908, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd914, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd91c, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd924, 0x14 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd938, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd940, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd948, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd954, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd960, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd968, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd974, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd980, 0x10 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd990, 0x10 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd9a0, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd9a8, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd9b4, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd9c0, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd9c8, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd9d0, 0x8 + bl photon_mgc_halide_error_5f95638 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd9d8, 0x4 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd9dc, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd9e8, 0x10 + bl photon_mgc_halide_error_5f950cc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd9f8, 0x4 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xd9fc, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xda04, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xda0c, 0x8 + bl photon_mgc_halide_error_5f956a4 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xda14, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xda1c, 0xc + bl photon_mgc_halide_error_5f95034 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xda28, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xda34, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xda40, 0xc + bl photon_mgc_halide_error_5f95034 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xda4c, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xda58, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xda64, 0xc + bl photon_mgc_halide_error_5f95034 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xda70, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xda78, 0xc + bl photon_mgc_halide_error_5f95034 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xda84, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xda8c, 0xc + bl photon_mgc_halide_error_5f95034 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xda98, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdaa4, 0x8 + bl photon_mgc_halide_error_5f94e38 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdaac, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdab4, 0xc + bl photon_mgc_halide_error_5f95034 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdac0, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdacc, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdad8, 0xc + bl photon_mgc_halide_error_5f95034 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdae4, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdaf0, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdafc, 0xc + bl photon_mgc_halide_error_5f95034 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdb08, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdb10, 0xc + bl photon_mgc_halide_error_5f95034 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdb1c, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdb24, 0x4 + adrp x3, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdb28, 0x10 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdb38, 0xc + bl photon_mgc_halide_error_5f95034 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdb44, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdb50, 0x8 + bl photon_mgc_halide_error_5f94e38 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdb58, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdb60, 0xc + bl photon_mgc_halide_error_5f95034 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdb6c, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdb78, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdb84, 0xc + bl photon_mgc_halide_error_5f95034 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdb90, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdb98, 0xc + bl photon_mgc_halide_error_5f95034 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdba4, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdbac, 0x4 + adrp x3, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdbb0, 0x14 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdbc4, 0x4 +photon_mgc_spatial_rgb_page_371d000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdbc8, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdbd0, 0xc + bl photon_mgc_halide_error_5f95034 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdbdc, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdbe4, 0xc + bl photon_mgc_halide_error_5f95034 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdbf0, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdbf8, 0xc + bl photon_mgc_halide_error_5f95034 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdc04, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdc10, 0x8 + bl photon_mgc_halide_error_5f94e38 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdc18, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdc24, 0x8 + bl photon_mgc_halide_error_5f95034 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdc2c, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdc34, 0xc + bl photon_mgc_halide_error_5f95034 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdc40, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdc48, 0x4 + adrp x3, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdc4c, 0x10 + adrp x1, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdc5c, 0x4 + adrp x3, photon_mgc_spatial_rgb_page_bc6000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xdc60, 0xf28 + + +.section .text.photon_mgc.SpatialRgb.green_dispatch,"ax",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_389e000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xeb88, 0xc70 +photon_mgc_spatial_rgb_address_389ec70: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xf7f8, 0x84 + adrp x10, photon_mgc_spatial_rgb_page_6b2000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xf87c, 0x19c + bl photon_mgc_halide_error_38a92e8 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xfa18, 0x14 + bl photon_mgc_halide_error_38a3740 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xfa2c, 0x1c + bl photon_mgc_spatial_rgb_address_38aee1c + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xfa48, 0x14 + adrp x2, photon_mgc_spatial_rgb_page_4e9000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xfa5c, 0x8 + bl photon_mgc_halide_error_5ff6938 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xfa64, 0x8 + bl photon_mgc_halide_error_2055170 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xfa6c, 0x4 + adrp x1, photon_mgc_spatial_rgb_page_51d000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xfa70, 0x10 + adrp x1, photon_mgc_spatial_rgb_page_51d000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xfa80, 0x4 + adrp x3, photon_mgc_spatial_rgb_page_53d000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xfa84, 0x10 + bl photon_mgc_halide_error_5ff8944 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xfa94, 0x4 + bl photon_mgc_halide_error_5ff89a0 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xfa98, 0xc0 + + +.section .text.photon_mgc.SpatialRgb.green_raw16,"ax",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_38aa000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0xfb58, 0x69c +photon_mgc_spatial_rgb_address_38aa69c: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x101f4, 0x1cc + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x103c0, 0x44 + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x10404, 0x1c + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x10420, 0x68c + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x10aac, 0x9c +photon_mgc_spatial_rgb_page_38ab000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x10b48, 0xd70 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x118b8, 0x28c +photon_mgc_spatial_rgb_page_38ac000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x11b44, 0x8 + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x11b4c, 0x420 + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x11f6c, 0x474 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x123e0, 0x18 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x123f8, 0x150 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x12548, 0x78 + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x125c0, 0xc8 + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x12688, 0x68 + bl photon_mgc_halide_error_5f95540 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x126f0, 0x58 + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x12748, 0x4c + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x12794, 0x1c + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x127b0, 0x368 +photon_mgc_spatial_rgb_page_38ad000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x12b18, 0x20c + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x12d24, 0x6e4 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x13408, 0x288 + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x13690, 0x424 + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x13ab4, 0x54 +photon_mgc_spatial_rgb_page_38ae000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x13b08, 0x420 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x13f28, 0x18 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x13f40, 0x118 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14058, 0x68 + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x140c0, 0xa0 + bl photon_mgc_halide_malloc + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14160, 0x48 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x141a8, 0x14 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x141bc, 0x14 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x141d0, 0x30 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14200, 0xc + bl photon_mgc_halide_error_5f94fa8 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1420c, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14218, 0xc + bl photon_mgc_halide_error_5f94fa8 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14224, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1422c, 0x20 + bl photon_mgc_halide_error_5f94fa8 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1424c, 0x2c + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14278, 0x28 + bl photon_mgc_halide_error_5f94fa8 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x142a0, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x142a8, 0x20 + bl photon_mgc_halide_error_5f94fa8 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x142c8, 0x2c + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x142f4, 0x28 + bl photon_mgc_halide_error_5f94fa8 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1431c, 0xc + bl photon_mgc_halide_error_5f95540 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14328, 0x38 + bl photon_mgc_halide_error_5f95540 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14360, 0x3c + bl photon_mgc_halide_error_5f95540 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1439c, 0x40 + bl photon_mgc_halide_error_5f95540 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x143dc, 0x3c + bl photon_mgc_halide_error_5f95540 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14418, 0x30 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14448, 0x68 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x144b0, 0x18 + bl photon_mgc_halide_error_5f94fa8 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x144c8, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x144d0, 0x10 + bl photon_mgc_halide_error_5f94fa8 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x144e0, 0xc + bl photon_mgc_halide_error_5f95540 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x144ec, 0x2c + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14518, 0x10 + bl photon_mgc_halide_error_5f94fa8 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14528, 0x30 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14558, 0x18 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14570, 0x14 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14584, 0x50 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x145d4, 0x80 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14654, 0x48 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1469c, 0x30 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x146cc, 0x2c + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x146f8, 0x2c + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14724, 0x30 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14754, 0x20 + bl photon_mgc_halide_free + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14774, 0x20 + bl photon_mgc_halide_error_5f95540 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14794, 0x34 + bl photon_mgc_halide_error_5f95540 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x147c8, 0x38 + bl photon_mgc_halide_error_5f95540 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14800, 0x34 + bl photon_mgc_halide_error_5f95540 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14834, 0x30 +photon_mgc_spatial_rgb_address_38aee1c: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14864, 0xb8 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1491c, 0x128 +photon_mgc_spatial_rgb_page_38af000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14a44, 0x290 + adrp x7, photon_mgc_spatial_rgb_page_6b4000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14cd4, 0x64 + adrp x14, photon_mgc_spatial_rgb_page_6ba000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14d38, 0x40 + adrp x14, photon_mgc_spatial_rgb_page_6ba000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14d78, 0xa0 + adrp x5, photon_mgc_spatial_rgb_page_6b4000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x14e18, 0x3fc + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15214, 0x40 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15254, 0x3c + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15290, 0x44 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x152d4, 0x4 + adrp x3, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x152d8, 0x2c + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15304, 0x2c + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15330, 0x3c + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1536c, 0x30 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1539c, 0x4 + adrp x3, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x153a0, 0x2c + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x153cc, 0x1d8 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x155a4, 0x34 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x155d8, 0x20 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x155f8, 0x24 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1561c, 0x18 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15634, 0x1c + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15650, 0x18 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15668, 0x48 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x156b0, 0x10 + adrp x8, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x156c0, 0x24 + bl photon_mgc_halide_trace + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x156e4, 0x4 + adrp x1, photon_mgc_spatial_rgb_page_61e7000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x156e8, 0x114 + adrp x8, photon_mgc_spatial_rgb_page_6c3000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x157fc, 0x4 + adrp x8, photon_mgc_spatial_rgb_page_6bd000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15800, 0x34 + bl photon_mgc_halide_do_par_for + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15834, 0x4 + adrp x8, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15838, 0x1c + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15854, 0x1c + bl photon_mgc_halide_trace + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15870, 0x2c + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1589c, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x158a4, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x158b0, 0x28 + b photon_mgc_halide_error_5f95560 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x158d8, 0x4 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x158dc, 0x10 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x158ec, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x158f8, 0x20 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15918, 0x18 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15930, 0x14 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15944, 0x10 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15954, 0x18 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1596c, 0x10 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1597c, 0x14 +photon_mgc_spatial_rgb_page_38b0000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15990, 0x18 + b photon_mgc_halide_error_5f94e38 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x159a8, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x159b4, 0x2c + b photon_mgc_halide_error_5f94d60 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x159e0, 0x10 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x159f0, 0x30 + b photon_mgc_halide_error_5f94ec4 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15a20, 0x4 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15a24, 0x10 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15a34, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15a40, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15a48, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15a54, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15a5c, 0x30 + b photon_mgc_halide_error_5f94fa8 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15a8c, 0x28 + b photon_mgc_halide_error_5f95638 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15ab4, 0x30 + b photon_mgc_halide_error_5f950cc + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15ae4, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15aec, 0x28 + b photon_mgc_halide_error_5f956a4 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15b14, 0x4 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15b18, 0x18 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15b30, 0xc + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15b3c, 0x2c + b photon_mgc_halide_error_5f95034 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15b68, 0x8 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15b70, 0x4 + adrp x3, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15b74, 0x14 + adrp x1, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15b88, 0x4 + adrp x3, photon_mgc_spatial_rgb_page_bd1000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15b8c, 0x2c + b photon_mgc_halide_error_5f95260 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x15bb8, 0xd68 + + +.section .text.photon_mgc.SpatialRgb.u16_buffer_view_copy,"ax",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_389b000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x16920, 0x20c + adrp x11, photon_mgc_spatial_rgb_page_6b5000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x16b2c, 0x1c0 + bl photon_mgc_u16_copy_dispatch + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x16cec, 0x4c +photon_mgc_spatial_rgb_address_389b420: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x16d38, 0xbe0 + + +.section .text.photon_mgc.SpatialRgb.u16_copy,"ax",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_5e4c000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x17918, 0xb58 +photon_mgc_spatial_rgb_address_5e4cb58: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x18470, 0x4a8 +photon_mgc_spatial_rgb_page_5e4d000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x18918, 0x68 + adrp x6, photon_mgc_spatial_rgb_page_6ba000 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x18980, 0xc3c +photon_mgc_spatial_rgb_address_5e4dca8: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x195bc, 0x358 +photon_mgc_spatial_rgb_page_5e4e000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x19914, 0x1000 + +.section .rodata.photon_mgc.spatial_rgb_page_4e9000,"a",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_4e9000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1a914, 0x1000 + +.section .rodata.photon_mgc.spatial_rgb_page_51d000,"a",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_51d000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1b914, 0x1000 + +.section .rodata.photon_mgc.spatial_rgb_page_53d000,"a",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_53d000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1c914, 0x1000 + +.section .rodata.photon_mgc.spatial_rgb_page_6b2000,"a",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_6b2000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1d914, 0x1000 + +.section .rodata.photon_mgc.spatial_rgb_page_6b4000,"a",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_6b4000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1e914, 0x1000 + +.section .rodata.photon_mgc.spatial_rgb_page_6b5000,"a",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_6b5000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x1f914, 0x1000 + +.section .rodata.photon_mgc.spatial_rgb_page_6b6000,"a",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_6b6000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x20914, 0x1000 + +.section .rodata.photon_mgc.spatial_rgb_page_6b9000,"a",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_6b9000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x21914, 0x1000 + +.section .rodata.photon_mgc.spatial_rgb_page_6ba000,"a",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_6ba000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x22914, 0x1000 + +.section .rodata.photon_mgc.spatial_rgb_page_6bc000,"a",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_6bc000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x23914, 0x1000 + +.section .rodata.photon_mgc.spatial_rgb_page_6bd000,"a",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_6bd000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x24914, 0x1000 + +.section .rodata.photon_mgc.spatial_rgb_page_6c2000,"a",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_6c2000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x25914, 0x1000 + +.section .rodata.photon_mgc.spatial_rgb_page_6c3000,"a",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_6c3000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x26914, 0x1000 + +.section .rodata.photon_mgc.spatial_rgb_page_6c4000,"a",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_6c4000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x27914, 0x1000 + +.section .rodata.photon_mgc.spatial_rgb_page_bc6000,"a",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_bc6000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x28914, 0x1000 + +.section .rodata.photon_mgc.spatial_rgb_page_bd1000,"a",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_bd1000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x29914, 0x1000 + +.section .data.rel.ro.photon_mgc.spatial_rgb_page_61e7000,"aw",@progbits + .p2align 12 +photon_mgc_spatial_rgb_page_61e7000: + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x2a914, 0x938 + .xword photon_mgc_spatial_rgb_address_370f514 + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x2b24c, 0xe8 + .xword photon_mgc_spatial_rgb_address_38aa69c + .incbin "@MGC_SPATIAL_RGB_CAPSULE@", 0x2b334, 0x5d0 + +.section .note.GNU-stack,"",@progbits diff --git a/app/src/main/java/com/hinnka/mycamera/processor/GlesMgcRawSpatialShaders.kt b/app/src/main/java/com/hinnka/mycamera/processor/GlesMgcRawSpatialShaders.kt index 4eb71fd9..9ac5cd87 100644 --- a/app/src/main/java/com/hinnka/mycamera/processor/GlesMgcRawSpatialShaders.kt +++ b/app/src/main/java/com/hinnka/mycamera/processor/GlesMgcRawSpatialShaders.kt @@ -1534,6 +1534,41 @@ internal object GlesMgcRawSpatialShaders { } """.trimIndent() + /** + * Converts the original MGC MergeRgbRaw16F16 planar Q14 output to the stacker's RGB16 + * boundary. The AOT output is already un-white-balanced camera RGB; WB is used only by the + * AOT's internal green guide and must not be divided out again here. + */ + val normalizeAotRgb16 = """ + #version 300 es + precision highp float; + precision highp int; + uniform sampler2D uChannelPlane; + uniform sampler2D uLensShading; + uniform ivec2 uOutputSize; + uniform float uOutputExposureScale; + uniform int uUseLensShading; + uniform int uChannel; + layout(location = 0) out highp uvec4 oRgb16; + + void main() { + ivec2 p = ivec2(gl_FragCoord.xy); + float value = texelFetch(uChannelPlane, p, 0).r * (1.0 / 16384.0); + if (uUseLensShading != 0) { + vec2 uv = (vec2(p) + vec2(0.5)) / vec2(uOutputSize); + vec4 shading = texture(uLensShading, clamp(uv, vec2(0.0), vec2(1.0))); + float channelShading = uChannel == 0 ? shading.r : + (uChannel == 1 ? 0.5 * (shading.g + shading.b) : shading.a); + value *= channelShading; + } + uint encodedValue = uint(round( + clamp(value * uOutputExposureScale, 0.0, 1.0) * 65535.0 + )); + oRgb16 = uvec4(0u); + oRgb16[uChannel] = encodedValue; + } + """.trimIndent() + /** * First integer-to-float conversion stays in compute image load/store. Some Mali drivers * incorrectly lower the equivalent fragment-sampler uint16 conversion to FP16. diff --git a/app/src/main/java/com/hinnka/mycamera/processor/GlesMgcRawSpatialStacker.kt b/app/src/main/java/com/hinnka/mycamera/processor/GlesMgcRawSpatialStacker.kt index 9d82d4f7..77f5678b 100644 --- a/app/src/main/java/com/hinnka/mycamera/processor/GlesMgcRawSpatialStacker.kt +++ b/app/src/main/java/com/hinnka/mycamera/processor/GlesMgcRawSpatialStacker.kt @@ -41,8 +41,9 @@ internal fun resolveFusionReferenceSignal( * The stage order, constants and shader equations come from this APK's libgcastartup.so. The * recovered MGC parameter-generation equations are cross-checked against Google's published * kernel units and SNR tuning range. The Bayer output preserves the CFA lattice. The RGB output - * performs joint RAW-domain G/R-G/B-G reconstruction at the requested output scale while keeping - * MGC alignment, rejection, Bento admission and propagated-noise postprocessing authoritative. + * executes MGC 9.7.047 V25's complete MergeRgbRaw16F16 AOT, including its internal full-resolution + * green reconstruction, while keeping MGC alignment, rejection, Bento admission and propagated- + * noise postprocessing authoritative. */ internal class GlesMgcRawSpatialStacker( private val width: Int, @@ -224,6 +225,7 @@ internal class GlesMgcRawSpatialStacker( private data class FrameCalibration( val blackLevels: FloatArray, + val inputGain: Float, val gains: FloatArray, val blackTerms: FloatArray, val bayerPhaseGains: FloatArray, @@ -368,6 +370,10 @@ internal class GlesMgcRawSpatialStacker( } else { height } + // MergeRgbRaw16F16TileSize16Halide writes complete 16x16 output tiles. Keep the app-visible + // dimensions unchanged and let only the private planar AOT allocation cover the final tile. + private val rgbAotOutputWidth = ceilDiv(outputWidth, RGB_AOT_TILE_SIZE) * RGB_AOT_TILE_SIZE + private val rgbAotOutputHeight = ceilDiv(outputHeight, RGB_AOT_TILE_SIZE) * RGB_AOT_TILE_SIZE private val sensorWhiteLevelCode = max(1, whiteLevel) private val sensorWhiteLevel = sensorWhiteLevelCode.toFloat() // RawMetadata has already converted positional Camera2 black levels to R, Gr, Gb, B. @@ -472,6 +478,7 @@ internal class GlesMgcRawSpatialStacker( private var mergeRgbProgram = 0 private var normalizeBayerProgram = 0 private var normalizeRgbProgram = 0 + private var normalizeAotRgbProgram = 0 private var copyRgb16ToFloatProgram = 0 private var rgbChromaPostprocessor: GlesMgcSpatialRgbChromaPostprocessor? = null private var packBayerFixed16Program = 0 @@ -587,7 +594,6 @@ internal class GlesMgcRawSpatialStacker( var strengthRejectionHostBuffer: ByteBuffer? = null var rgbDiagnosticHostBuffer: ByteBuffer? = null var strengthCapture: StrengthCapture? = null - var onlineRgbAccumulator: OnlineRgbAccumulator? = null val processStartNs = System.nanoTime() val originalThreadPriority = GlesGpuScheduler.lowerCurrentThreadPriority(TAG) return try { @@ -653,7 +659,7 @@ internal class GlesMgcRawSpatialStacker( GLES30.GL_LINEAR, ) val needsSabreCovariance = mergeMethod == MgcMergeMethod.SABRE - val referenceCovariance = if (outputMode == MgcSpatialOutputMode.RGB || needsSabreCovariance) { + val referenceCovariance = if (needsSabreCovariance) { createTexture( guideWidth, guideHeight, @@ -663,7 +669,7 @@ internal class GlesMgcRawSpatialStacker( } else { 0 } - val currentCovariance = if (outputMode == MgcSpatialOutputMode.RGB || needsSabreCovariance) { + val currentCovariance = if (needsSabreCovariance) { createTexture( guideWidth, guideHeight, @@ -782,7 +788,7 @@ internal class GlesMgcRawSpatialStacker( guideTexture = referenceGuide, forceReferenceColorRgb = 0f, ) - if (outputMode == MgcSpatialOutputMode.RGB || needsSabreCovariance) { + if (needsSabreCovariance) { renderCovariance( rawTexture = referenceRaw, noiseTexture = referenceNoiseLut, @@ -983,7 +989,7 @@ internal class GlesMgcRawSpatialStacker( guideTexture = bentoGuide, forceReferenceColorRgb = 0f, ) - if (outputMode == MgcSpatialOutputMode.RGB || needsSabreCovariance) { + if (needsSabreCovariance) { renderCovariance( rawTexture = bentoRaw, noiseTexture = normalizedNoiseLut, @@ -1269,45 +1275,19 @@ internal class GlesMgcRawSpatialStacker( } val spatialNoiseFrameCount = 1 + (if (bentoAccepted) 1 else 0) + temporalMergeCount - if (MultiFrameConfig.ENABLE_MGC_SPATIAL_DEFAULT_DENOISE && - !referenceOnly && - spatialNoiseFrameCount > 1 + if (outputMode == MgcSpatialOutputMode.RGB || + (MultiFrameConfig.ENABLE_MGC_SPATIAL_DEFAULT_DENOISE && + !referenceOnly && spatialNoiseFrameCount > 1) ) { strengthCapture = createStrengthCapture( frameCount = spatialNoiseFrameCount, referenceCalibration = referenceCalibration, ) } - if ( - outputMode == MgcSpatialOutputMode.RGB - ) { - onlineRgbAccumulator = createOnlineRgbAccumulator( - reusableRawTexture = currentRaw, - diagnosticCapture = strengthCapture, - ).also { online -> - online.rawUploadCount = 1 + if (evaluateBentoCandidate) 1 else 0 - online.rawUploadBytes = online.rawUploadCount.toLong() * - width * height * RAW_BYTES_PER_PIXEL - } - } var capturedFrameIndex = 0 - fun submitOrRetainRgbFrame( - frame: RgbMergeFrame, - rawTexture: Int, - label: String, - ) { - val online = onlineRgbAccumulator - if (online != null) { - contributeOnlineRgbFrame( - accumulator = online, - frame = frame, - rawTexture = rawTexture, - label = label, - ) - } else { - rgbMergeFrames += frame - } + fun admitRgbFrame(frame: RgbMergeFrame) { + rgbMergeFrames += frame } if (outputMode == MgcSpatialOutputMode.BAYER) { @@ -1327,7 +1307,7 @@ internal class GlesMgcRawSpatialStacker( ) } if (outputMode == MgcSpatialOutputMode.RGB) { - submitOrRetainRgbFrame( + admitRgbFrame( frame = RgbMergeFrame( imageIndex = 0, calibration = referenceCalibration, @@ -1337,8 +1317,6 @@ internal class GlesMgcRawSpatialStacker( flowBounds = MgcSpatialRgbFlowBounds.Zero, useFrameWeight = true, ), - rawTexture = referenceRaw, - label = "reference", ) } strengthCapture?.let { capture -> @@ -1365,10 +1343,7 @@ internal class GlesMgcRawSpatialStacker( ) } if (outputMode == MgcSpatialOutputMode.RGB) { - check(bentoRgbCovarianceTexture != 0) { - "Accepted MGC Bento RGB frame has no covariance texture" - } - submitOrRetainRgbFrame( + admitRgbFrame( frame = RgbMergeFrame( imageIndex = ultrashortIndex, calibration = checkNotNull(bentoCalibration), @@ -1378,8 +1353,6 @@ internal class GlesMgcRawSpatialStacker( flowBounds = conservativeRgbFlowBounds, useFrameWeight = true, ), - rawTexture = bentoRaw, - label = "bento", ) } strengthCapture?.let { capture -> @@ -1407,7 +1380,7 @@ internal class GlesMgcRawSpatialStacker( ) } if (outputMode == MgcSpatialOutputMode.RGB) { - submitOrRetainRgbFrame( + admitRgbFrame( frame = RgbMergeFrame( imageIndex = 0, calibration = referenceCalibration, @@ -1417,8 +1390,6 @@ internal class GlesMgcRawSpatialStacker( flowBounds = MgcSpatialRgbFlowBounds.Zero, useFrameWeight = false, ), - rawTexture = referenceRaw, - label = "reference", ) } strengthCapture?.let { capture -> @@ -1433,10 +1404,6 @@ internal class GlesMgcRawSpatialStacker( } } - if (onlineRgbAccumulator != null) { - images[0].close() - if (bentoAccepted) images[ultrashortIndex].close() - } GlesGpuScheduler.yieldToUiRenderer() for (index in temporalFrameRange) { @@ -1448,31 +1415,10 @@ internal class GlesMgcRawSpatialStacker( var postPrepareSubmitNs = 0L beginTemporalScratchFrame() try { - val online = onlineRgbAccumulator - val temporalRaw = if (online != null) { - val slot = online.nextRawSlot - val texture = online.rawSlots[slot] - online.nextRawSlot = (slot + 1) % online.rawSlots.size - online.passWindow.awaitResources( - label = "MGC RGB RAW slot $slot upload frame $index", - resources = longArrayOf( - GlesGpuScheduler.textureResource(texture), - ), - ) + val temporalRaw = currentRaw.also { texture -> val uploadStartNs = System.nanoTime() uploadRaw(images[index], texture, "frame $index") uploadCallNs = System.nanoTime() - uploadStartNs - online.rawUploadNs += uploadCallNs - online.rawUploadCount += 1 - online.rawUploadBytes += - width.toLong() * height * RAW_BYTES_PER_PIXEL - texture - } else { - currentRaw.also { texture -> - val uploadStartNs = System.nanoTime() - uploadRaw(images[index], texture, "frame $index") - uploadCallNs = System.nanoTime() - uploadStartNs - } } val prepareStartNs = System.nanoTime() val prepared = prepareTemporalFrame( @@ -1548,59 +1494,17 @@ internal class GlesMgcRawSpatialStacker( ) } if (outputMode == MgcSpatialOutputMode.RGB) { - if (online != null) { - submitOrRetainRgbFrame( - frame = RgbMergeFrame( - imageIndex = index, - calibration = prepared.calibration, - alignmentTexture = prepared.bayerAlignmentTexture, - weightTexture = mergeWeight, - covarianceTexture = currentCovariance, - flowBounds = conservativeRgbFlowBounds, - useFrameWeight = true, - ), - rawTexture = temporalRaw, - label = "frame $index", - ) - } else { - val retainedAlignment = copyPersistentTexture( - source = prepared.bayerAlignmentTexture, - textureWidth = bayerAlignmentWidth, - textureHeight = bayerAlignmentHeight, - internalFormat = GLES30.GL_RGBA32F, - filter = GLES30.GL_NEAREST, - label = "MGC RGB alignment frame $index", - ) - val retainedWeight = if (mergeWeight == identityWeight) { - identityWeight - } else { - copyPersistentTexture( - source = mergeWeight, - textureWidth = mergeWeightWidth, - textureHeight = mergeWeightHeight, - internalFormat = GLES30.GL_R8, - filter = GLES30.GL_LINEAR, - label = "MGC RGB final weight frame $index", - ) - } - val retainedCovariance = copyPersistentTexture( - source = currentCovariance, - textureWidth = guideWidth, - textureHeight = guideHeight, - internalFormat = GLES30.GL_RGB10_A2, - filter = GLES30.GL_LINEAR, - label = "MGC RGB covariance frame $index", - ) - rgbMergeFrames += RgbMergeFrame( + admitRgbFrame( + RgbMergeFrame( imageIndex = index, calibration = prepared.calibration, - alignmentTexture = retainedAlignment, - weightTexture = retainedWeight, - covarianceTexture = retainedCovariance, + alignmentTexture = prepared.bayerAlignmentTexture, + weightTexture = mergeWeight, + covarianceTexture = currentCovariance, flowBounds = conservativeRgbFlowBounds, useFrameWeight = true, - ) - } + ), + ) } strengthCapture?.let { capture -> captureStrengthFrame( @@ -1613,7 +1517,6 @@ internal class GlesMgcRawSpatialStacker( ) } mergedFrames += 1 - if (online != null) images[index].close() postPrepareSubmitNs = System.nanoTime() - postPrepareStartNs } finally { endTemporalScratchFrame() @@ -1648,28 +1551,12 @@ internal class GlesMgcRawSpatialStacker( } val lensShadingCorrectionApplied: Boolean if (outputMode == MgcSpatialOutputMode.RGB) { - val online = onlineRgbAccumulator - val retainedTemporalTextures = if (online != null) { - check(online.contributedFrames == mergedFrames) { - "MGC Spatial online RGB admitted ${online.contributedFrames} frames, " + - "but Bayer/noise merge admitted $mergedFrames" - } - intArrayOf( - online.semanticAccumulator, - online.opponentWeightAccumulator, - ) - } else { - check(rgbMergeFrames.size == mergedFrames) { - "MGC Spatial RGB admitted ${rgbMergeFrames.size} frames, " + - "but Bayer/noise merge admitted $mergedFrames" - } - rgbMergeFrames.flatMap { frame -> - listOf( - frame.alignmentTexture, - frame.weightTexture, - frame.covarianceTexture, - ) - }.toIntArray() + check(rgbMergeFrames.size == mergedFrames) { + "MGC Spatial RGB admitted ${rgbMergeFrames.size} frames, " + + "but Bayer/noise merge admitted $mergedFrames" + } + val aotCapture = checkNotNull(readyStrengthCapture) { + "MGC Spatial RGB AOT inputs were not captured" } val temporalGpuBytes = estimatedOwnedTextureBytes() PLog.i( @@ -1680,59 +1567,43 @@ internal class GlesMgcRawSpatialStacker( "${temporalGpuBytes > RGB_TEXTURE_ADVISORY_BYTES}", ) releaseRgbTemporalPhaseResources( - persistentTextures = retainedTemporalTextures, - strengthCapture = readyStrengthCapture, + persistentTextures = IntArray(0), + strengthCapture = aotCapture, ) - online?.passWindow?.clearAfterCheckpoint() - val preparedStrengthAtlases = readyStrengthCapture?.let { capture -> - materializeRgbStrengthAtlases(capture).also { prepared -> - strengthAlignmentHostBuffer = prepared.first.cpuBuffer - strengthRejectionHostBuffer = prepared.second.cpuBuffer - } + val preparedStrengthAtlases = materializeRgbStrengthAtlases(aotCapture).also { + strengthAlignmentHostBuffer = it.first.cpuBuffer + strengthRejectionHostBuffer = it.second.cpuBuffer } val rgbMergeStartNs = System.nanoTime() - val rgbOutput = if (online != null) { - finishOnlineRgbMerge( - accumulator = online, - outputExposureScale = outputExposure.normalizationScale, - diagnosticCapture = readyStrengthCapture, - ) - } else { - renderRgbMerge( - frames = resolveRgbFlowBounds(rgbMergeFrames), - images = images, - outputExposureScale = outputExposure.normalizationScale, - diagnosticCapture = readyStrengthCapture, - ) - } + val rgbOutput = renderOriginalAotRgbMerge( + frames = rgbMergeFrames, + images = images, + outputExposureScale = outputExposure.normalizationScale, + mergeSharpness = RGB_AOT_MERGE_SHARPNESS_SCALE * + finishRawSharpenAttenuationScale, + capture = aotCapture, + preparedAlignment = preparedStrengthAtlases.first, + preparedRejection = preparedStrengthAtlases.second, + ) cpuOutput = rgbOutput.cpuBuffer exportedRgbTexture = rgbOutput.gpuTexture exportedRgbCompletionTimeline = rgbOutput.completionTimeline rgbDiagnosticHostBuffer = rgbOutput.diagnosticFixed16?.cpuBuffer - readyStrengthCapture?.let { capture -> - val startNs = System.nanoTime() - queuedStrengthReadback = queueStrengthReadback( - capture = capture, - preparedAlignment = checkNotNull(preparedStrengthAtlases).first, - preparedRejection = preparedStrengthAtlases.second, - preparedFusedFixed16 = checkNotNull(rgbOutput.diagnosticFixed16), - ) - strengthQueueElapsedMs = (System.nanoTime() - startNs) / 1_000_000L - } + val startNs = System.nanoTime() + queuedStrengthReadback = queueStrengthReadback( + capture = aotCapture, + preparedAlignment = preparedStrengthAtlases.first, + preparedRejection = preparedStrengthAtlases.second, + preparedFusedFixed16 = checkNotNull(rgbOutput.diagnosticFixed16), + ) + strengthQueueElapsedMs = (System.nanoTime() - startNs) / 1_000_000L lensShadingCorrectionApplied = hasLensShading() PLog.i( TAG, "MGC Spatial RGB dispatch complete frames=$mergedFrames " + "took=${(System.nanoTime() - rgbMergeStartNs) / 1_000_000L}ms " + - "mode=${when { - online != null -> "online-full-accumulator" - else -> "streamed-band" - }} " + - "rawWindowSlots=${when { - online != null -> online.rawSlots.size - else -> RGB_RAW_WINDOW_SLOTS - }} " + - "maxInFlight=$RGB_MAX_IN_FLIGHT_PASSES", + "mode=mgc-v25-merge-rgb-raw16-f16-aot " + + "aotOutput=${rgbAotOutputWidth}x$rgbAotOutputHeight", ) } else { val bayer16 = renderBayer16( @@ -1891,11 +1762,7 @@ internal class GlesMgcRawSpatialStacker( "lscApplied=$lensShadingCorrectionApplied result=$resultLabel " + "programInit=${programInitMs}ms " + "queueMode=${if (outputMode == MgcSpatialOutputMode.RGB) { - if (onlineRgbAccumulator != null) { - "online-raw-sequential-full-accumulator" - } else { - "streamed-raw-two-slot-two-in-flight-band" - } + "mgc-v25-native-aot" } else { "ordered-continuous" }} " + @@ -1950,7 +1817,6 @@ internal class GlesMgcRawSpatialStacker( mgcSpatialReferenceOnlyDiagnostic = referenceOnly, ) } catch (error: Exception) { - onlineRgbAccumulator?.passWindow?.drain("MGC Spatial merge failure") PLog.e(TAG, "MGC Spatial ${outputMode.name} merge failed", error) null } finally { @@ -3059,15 +2925,11 @@ internal class GlesMgcRawSpatialStacker( includeReferenceHighlightMask: Boolean = includeBentoAssessment, ) { guideProgram = linkProgram(GlesMgcRawSpatialShaders.guide, "mgc_spatial_guide") - if (outputMode == MgcSpatialOutputMode.RGB || mergeMethod == MgcMergeMethod.SABRE) { + if (mergeMethod == MgcMergeMethod.SABRE) { covarianceProgram = linkProgram( GlesMgcRawSpatialShaders.covariance, "mgc_spatial_rgb_covariance", ) - rgbChromaGuideProgram = linkProgram( - GlesMgcRawSpatialShaders.rgbChromaGuide, - "mgc_spatial_rgb_chroma_guide", - ) } rawToGrayProgram = linkProgram(GlesMgcRawSpatialShaders.rawToGray, "mgc_raw_to_gray") downsampleProgram = linkProgram( @@ -3193,15 +3055,11 @@ internal class GlesMgcRawSpatialStacker( check(supportsComputePrograms) { "MGC Spatial RGB color noise/IIR requires the GLES 3.1 compute baseline" } - mergeRgbProgram = linkProgram( - GlesMgcRawSpatialShaders.mergeRgb, - "mgc_spatial_rgb_merge", - ) // Color noise/IIR owns a fixed RGBA16UI boundary, matching the VGN/Radiance - // contract. A direct-float consumer is converted only after the complete chain. - normalizeRgbProgram = linkProgram( - GlesMgcRawSpatialShaders.normalizeRgb16, - "mgc_spatial_rgb16ui", + // contract. The original planar F16 AOT output enters that boundary exactly once. + normalizeAotRgbProgram = linkProgram( + GlesMgcRawSpatialShaders.normalizeAotRgb16, + "mgc_spatial_v25_aot_rgb16ui", ) if (exportGpuLinearRgbSource && gpuLinearRgbStorage == GpuLinearRgbStorage.RGBA16F @@ -3214,10 +3072,6 @@ internal class GlesMgcRawSpatialStacker( rgbChromaPostprocessor = createRgbChromaPostprocessor().also { it.initPrograms() } - packRgbFixed16FallbackProgram = linkProgram( - MgcStrengthReadbackShaders.RGB_FIXED16_FRAGMENT, - "mgc_spatial_rgb_fixed16_fallback", - ) } normalizeBayerProgram = linkProgram( GlesMgcRawSpatialShaders.normalizeBayer, @@ -3395,6 +3249,7 @@ internal class GlesMgcRawSpatialStacker( } return FrameCalibration( blackLevels = frameBlackLevel, + inputGain = exposureScale, gains = gains, blackTerms = blackTerms, bayerPhaseGains = bayerPhaseGains, @@ -4650,7 +4505,7 @@ internal class GlesMgcRawSpatialStacker( guideTexture = currentGuide, forceReferenceColorRgb = 0f, ) - if (outputMode == MgcSpatialOutputMode.RGB || mergeMethod == MgcMergeMethod.SABRE) { + if (mergeMethod == MgcMergeMethod.SABRE) { renderCovariance( rawTexture = currentRaw, noiseTexture = currentNoiseLut, @@ -5233,12 +5088,7 @@ internal class GlesMgcRawSpatialStacker( imageWidth = if (outputMode == MgcSpatialOutputMode.RGB) outputWidth else width, imageHeight = if (outputMode == MgcSpatialOutputMode.RGB) outputHeight else height, ) - if (outputMode == MgcSpatialOutputMode.RGB) { - check(packRgbFixed16FallbackProgram != 0) { - "MGC Spatial RGB diagnostic pack program is unavailable" - } - } - require(frameCount > 1) + require(frameCount >= 1) val maximumTextureSize = IntArray(1) GLES30.glGetIntegerv(GLES30.GL_MAX_TEXTURE_SIZE, maximumTextureSize, 0) val alignmentLayout = createMgcSpatialStrengthAtlasLayout( @@ -6441,6 +6291,244 @@ internal class GlesMgcRawSpatialStacker( accumulator.contributedFrames += 1 } + /** + * Executes MGC 9.7.047 V25's complete Spatial RGB Halide AOT. In particular, this call keeps + * DemosaicGreenRaw16 inside the original pipeline; the three output planes therefore share + * MGC's edge-directed green guide and adaptive kernel geometry instead of reconstructing edge + * direction independently per color channel. + */ + private fun renderOriginalAotRgbMerge( + frames: List, + images: List, + outputExposureScale: Float, + mergeSharpness: Float, + capture: StrengthCapture, + preparedAlignment: PreparedTextureReadback, + preparedRejection: PreparedTextureReadback, + ): RgbMergeOutput { + check(outputMode == MgcSpatialOutputMode.RGB) + check(normalizeAotRgbProgram != 0) { + "MGC Spatial V25 AOT output program is not initialized" + } + require(frames.isNotEmpty() && frames.size == capture.frameCount) + require(frames.all { it.imageIndex in images.indices }) + require(outputExposureScale.isFinite() && outputExposureScale > 0f) + require(mergeSharpness.isFinite() && mergeSharpness >= 0f) + check(capture.geometry.fixed16Width == rgbAotOutputWidth && + capture.geometry.fixed16Height == rgbAotOutputHeight) { + "MGC Spatial RGB AOT geometry ${capture.geometry.fixed16Width}x" + + "${capture.geometry.fixed16Height} does not match " + + "${rgbAotOutputWidth}x$rgbAotOutputHeight" + } + val alignment = checkNotNull(preparedAlignment.cpuBuffer) { + "MGC Spatial RGB AOT alignment is not host-resident" + }.duplicate().order(ByteOrder.nativeOrder()).apply { + position(0) + limit(preparedAlignment.byteCount) + } + val rejection = checkNotNull(preparedRejection.cpuBuffer) { + "MGC Spatial RGB AOT rejection is not host-resident" + }.duplicate().order(ByteOrder.nativeOrder()).apply { + position(0) + limit(preparedRejection.byteCount) + } + val rawPlanes = frames.map { frame -> + images[frame.imageIndex].planes.firstOrNull() + ?: error("MGC Spatial RGB frame ${frame.imageIndex} has no RAW plane") + } + rawPlanes.forEachIndexed { index, plane -> + require(plane.pixelStride == RAW_BYTES_PER_PIXEL) { + "MGC Spatial RGB AOT frame $index pixel stride=${plane.pixelStride}, expected 2" + } + require(plane.rowStride >= width * RAW_BYTES_PER_PIXEL) { + "MGC Spatial RGB AOT frame $index row stride=${plane.rowStride}, width=$width" + } + } + val rawBuffers = Array(rawPlanes.size) { index -> + rawPlanes[index].buffer.duplicate().order(ByteOrder.nativeOrder()).also { buffer -> + require(buffer.isDirect) { "MGC Spatial RGB AOT RAW frame $index is not direct" } + } + } + val rawOffsets = IntArray(rawBuffers.size) { index -> rawBuffers[index].position() } + val rawRowStrides = IntArray(rawPlanes.size) { index -> rawPlanes[index].rowStride } + val referenceBlack = frames.first().calibration.blackLevels + val inputBlackRgb = floatArrayOf( + referenceBlack[0], + 0.5f * (referenceBlack[1] + referenceBlack[2]), + referenceBlack[3], + ) + val inputGains = FloatArray(frames.size) { index -> + frames[index].calibration.inputGain + } + val aotSampleCount = capture.geometry.fixed16SampleCount + .also { require(it in 1..Int.MAX_VALUE.toLong()) } + .toInt() + val aotByteCount = strengthFixed16ReadbackByteCount(capture) + val outputBytes = outputWidth.toLong() * outputHeight * 3L * Short.SIZE_BYTES + require(outputBytes in 1..Int.MAX_VALUE.toLong()) + val fullOutput = MgcSpatialRgbRect(0, 0, outputWidth, outputHeight) + val fullOutputTile = MgcSpatialRgbTile(index = 0, outputCore = fullOutput) + var aotPlanar: ByteBuffer? = null + var cpuOutput: ByteBuffer? = null + var diagnosticFixed16: PreparedTextureReadback? = null + var gpuOutput = 0 + var postprocessedUi = 0 + val completionRecorder = GlesGpuCompletion.StackTimelineRecorder() + var completionTimeline: GpuStackCompletionTimeline? = null + try { + aotPlanar = LargeDirectBuffer.allocate( + aotByteCount.toLong(), + "MGC V25 Spatial RGB planar F16/Q14", + )?.order(ByteOrder.nativeOrder()) ?: error( + "Unable to allocate MGC V25 Spatial RGB planar output", + ) + if (!exportGpuLinearRgbSource) { + cpuOutput = LargeDirectBuffer.allocate( + outputBytes, + "MGC V25 Spatial RGB16 output", + )?.order(ByteOrder.nativeOrder()) ?: error( + "Unable to allocate MGC V25 Spatial RGB16 output", + ) + } + val aotStartNs = System.nanoTime() + MgcSpatialRgbMerger.merge( + rawBuffers = rawBuffers, + rawOffsets = rawOffsets, + rawRowStrides = rawRowStrides, + alignment = alignment, + alignmentWidth = capture.alignmentWidth, + alignmentHeight = capture.alignmentHeight, + rejection = rejection, + rejectionWidth = capture.rejectionWidth, + rejectionHeight = capture.rejectionHeight, + frameWeights = capture.frameWeights, + whiteBalanceGains = calculationWhiteBalance, + inputBlackLevelsRgb = inputBlackRgb, + inputBlackLevelsRggb = referenceBlack, + inputGains = inputGains, + overallGain = sabreResolveRawScale, + mergeSharpness = mergeSharpness, + kernelSigmas = capture.kernelSigmas, + rawWidth = width, + rawHeight = height, + outputWidth = rgbAotOutputWidth, + outputHeight = rgbAotOutputHeight, + cfaPattern = cfaPattern, + outputPlanarF16 = checkNotNull(aotPlanar), + ) + val aotMs = elapsedMs(aotStartNs) + + val chromaPostprocessor = checkNotNull(rgbChromaPostprocessor) { + "MGC Spatial RGB chroma postprocessor is not initialized" + } + chromaPostprocessor.initStorage(listOf(fullOutputTile)) + val lensShadingTexture = createLensShadingTexture() + uploadAndNormalizeOriginalAotRgb( + planarF16 = checkNotNull(aotPlanar), + lensShadingTexture = lensShadingTexture, + target = chromaPostprocessor.normalizationTargetTexture(), + outputExposureScale = outputExposureScale, + ) + chromaPostprocessor.markTileWritten(fullOutputTile) + + // The GL upload no longer reads client memory after glTexSubImage2D returns. Reuse the + // same native allocation for the planar signed-Q14 diagnostic expected by the lifted + // Spatial-noise AOT instead of holding a second full-resolution planar allocation. + MgcSpatialRgbMerger.convertPlanarF16ToFixed16( + buffer = checkNotNull(aotPlanar), + sampleCount = aotSampleCount, + ) + diagnosticFixed16 = PreparedTextureReadback( + byteCount = aotByteCount, + queuedGpuReadback = null, + cpuBuffer = checkNotNull(aotPlanar), + mode = "mgc-v25-aot-planar-q14-host", + targetBindMs = 0L, + readSubmitMs = 0L, + totalSubmitMs = aotMs, + ) + aotPlanar = null + + releaseRgbFusionPhaseTextures( + retainedTexture = chromaPostprocessor.normalizationTargetTexture(), + label = "V25 AOT", + ) + GlesGpuScheduler.memoryBarrier() + val chromaResult = chromaPostprocessor.process( + obtainOutputBuffer = { checkNotNull(cpuOutput) }, + deferFullSizeReadback = exportGpuLinearRgbSource, + onFinalSubmitted = if (exportGpuLinearRgbSource) { + { completionRecorder.mark(GpuStackCompletionStage.CHROMA_POSTPROCESS) } + } else { + null + }, + ) + postprocessedUi = chromaResult.exportedTextureId + if (exportGpuLinearRgbSource) { + check(postprocessedUi != 0) { + "MGC Spatial RGB chroma did not export its filtered texture" + } + gpuOutput = if (gpuLinearRgbStorage == GpuLinearRgbStorage.RGBA16UI) { + postprocessedUi.also { postprocessedUi = 0 } + } else { + GlesGpuCompletion.awaitSubmittedWork( + label = "MGC Spatial V25 AOT IIR-to-float handoff", + checkGlError = ::checkGlError, + ) + createTexture( + outputWidth, + outputHeight, + GLES30.GL_RGBA16F, + GLES30.GL_NEAREST, + ).also { target -> + renderRgb16ToFloat(postprocessedUi, target) + GLES30.glDeleteTextures(1, intArrayOf(postprocessedUi), 0) + postprocessedUi = 0 + } + } + } + if (gpuOutput != 0) { + completionRecorder.mark(GpuStackCompletionStage.FINAL_EXPORT) + completionTimeline = completionRecorder.finish() + if (completionTimeline == null) { + GlesGpuCompletion.awaitSubmittedWork( + label = "MGC Spatial V25 AOT RGB export", + checkGlError = ::checkGlError, + ) + } + if (textures.remove(gpuOutput)) textureSpecs.remove(gpuOutput) + } + PLog.i( + TAG, + "MGC Spatial V25 RGB AOT frames=${frames.size} " + + "raw=${width}x$height aot=${rgbAotOutputWidth}x$rgbAotOutputHeight " + + "visible=${outputWidth}x$outputHeight rawScale=$sabreResolveRawScale " + + "mergeSharpness=$mergeSharpness aot=${aotMs}ms " + + "colorNoiseIir=${chromaResult.chromaSubmissionMs}ms " + + "chromaFinal=${chromaResult.finalSubmissionMs}ms", + ) + return RgbMergeOutput( + cpuBuffer = cpuOutput, + gpuTexture = gpuOutput, + diagnosticFixed16 = diagnosticFixed16, + completionTimeline = completionTimeline, + ) + } catch (throwable: Throwable) { + completionTimeline?.releasePending() + completionRecorder.releasePending() + if (postprocessedUi != 0) { + GLES30.glDeleteTextures(1, intArrayOf(postprocessedUi), 0) + } + if (gpuOutput != 0 && !textures.contains(gpuOutput)) { + GLES30.glDeleteTextures(1, intArrayOf(gpuOutput), 0) + } + LargeDirectBuffer.free(aotPlanar) + LargeDirectBuffer.free(diagnosticFixed16?.cpuBuffer) + LargeDirectBuffer.free(cpuOutput) + throw throwable + } + } + private fun finishOnlineRgbMerge( accumulator: OnlineRgbAccumulator, outputExposureScale: Float, @@ -7599,6 +7687,93 @@ internal class GlesMgcRawSpatialStacker( checkGlError("MGC Spatial RGB normalize tile $outputCore") } + /** + * Streams one planar F16 channel at a time into the RGBA16UI chroma boundary. This keeps the + * peak GPU allocation to one R16F plane plus the final surface, even for 2x Spatial output. + */ + private fun uploadAndNormalizeOriginalAotRgb( + planarF16: ByteBuffer, + lensShadingTexture: Int, + target: Int, + outputExposureScale: Float, + ) { + check(normalizeAotRgbProgram != 0) + require(planarF16.isDirect) + require(outputExposureScale.isFinite() && outputExposureScale > 0f) + val planeByteCountLong = rgbAotOutputWidth.toLong() * rgbAotOutputHeight * Short.SIZE_BYTES + require(planeByteCountLong in 1..Int.MAX_VALUE.toLong()) + val planeByteCount = planeByteCountLong.toInt() + require(planarF16.capacity().toLong() >= planeByteCountLong * 3L) + val planeTexture = createTexture( + rgbAotOutputWidth, + rgbAotOutputHeight, + GLES30.GL_R16F, + GLES30.GL_NEAREST, + ) + try { + GLES30.glBindBuffer(GLES30.GL_PIXEL_UNPACK_BUFFER, 0) + GLES30.glPixelStorei(GLES30.GL_UNPACK_ALIGNMENT, 1) + GLES30.glPixelStorei(GLES30.GL_UNPACK_ROW_LENGTH, 0) + for (channel in 0 until 3) { + val source = planarF16.duplicate().order(ByteOrder.nativeOrder()).apply { + position(channel * planeByteCount) + limit((channel + 1) * planeByteCount) + } + GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, planeTexture) + GLES30.glTexSubImage2D( + GLES30.GL_TEXTURE_2D, + 0, + 0, + 0, + rgbAotOutputWidth, + rgbAotOutputHeight, + GLES30.GL_RED, + GLES30.GL_HALF_FLOAT, + source, + ) + GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0) + GLES30.glUseProgram(normalizeAotRgbProgram) + bindTexture(normalizeAotRgbProgram, "uChannelPlane", 0, planeTexture) + bindTexture(normalizeAotRgbProgram, "uLensShading", 1, lensShadingTexture) + uniform2i(normalizeAotRgbProgram, "uOutputSize", outputWidth, outputHeight) + uniform1f( + normalizeAotRgbProgram, + "uOutputExposureScale", + outputExposureScale, + ) + uniform1i( + normalizeAotRgbProgram, + "uUseLensShading", + if (hasLensShading()) 1 else 0, + ) + uniform1i(normalizeAotRgbProgram, "uChannel", channel) + GLES30.glColorMask( + channel == 0, + channel == 1, + channel == 2, + channel == 0, + ) + drawRegion( + program = normalizeAotRgbProgram, + target = target, + viewportLeft = 0, + viewportTop = 0, + viewportWidth = outputWidth, + viewportHeight = outputHeight, + ) + } + GLES31.glMemoryBarrier( + GLES31.GL_FRAMEBUFFER_BARRIER_BIT or + GLES31.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT, + ) + checkGlError("upload and normalize MGC V25 Spatial RGB AOT planes") + } finally { + GLES30.glColorMask(true, true, true, true) + GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0) + releaseOwnedTexture(planeTexture, "MGC V25 Spatial RGB AOT upload plane") + } + } + private fun renderRgb16ToFloat( source: Int, target: Int, @@ -9000,6 +9175,8 @@ internal class GlesMgcRawSpatialStacker( const val SABRE_DENOISE_REDUCTION_HIGH = 0.7f const val EGL_OPENGL_ES3_BIT_KHR = 0x00000040 const val RAW_BYTES_PER_PIXEL = 2 + const val RGB_AOT_TILE_SIZE = 16 + const val RGB_AOT_MERGE_SHARPNESS_SCALE = 0.8f const val RGB_RAW_WINDOW_SLOTS = 2 const val RGB_MAX_IN_FLIGHT_PASSES = 2 const val RGB_DIAGNOSTIC_PBO_SLOTS = 2 diff --git a/app/src/main/java/com/hinnka/mycamera/processor/GlesMgcSpatialRgbChromaPostprocessor.kt b/app/src/main/java/com/hinnka/mycamera/processor/GlesMgcSpatialRgbChromaPostprocessor.kt index 5f29df54..b8b38e47 100644 --- a/app/src/main/java/com/hinnka/mycamera/processor/GlesMgcSpatialRgbChromaPostprocessor.kt +++ b/app/src/main/java/com/hinnka/mycamera/processor/GlesMgcSpatialRgbChromaPostprocessor.kt @@ -823,20 +823,6 @@ internal object GlesMgcSpatialRgbChromaShaders { return dot(rgb, vec3(0.25, 0.5, 0.25)); } - float decodeSnorm8(uint encoded) { - int signedValue = int(encoded & 255u); - if (signedValue > 127) signedValue -= 256; - return clamp(float(signedValue) / 127.0, -1.0, 1.0); - } - - vec2 directionMomentAt(ivec2 p) { - uint encoded = imageLoad(uCameraRgb, imagePosition(p)).a; - return vec2( - decodeSnorm8(encoded), - decodeSnorm8(encoded >> 8u) - ); - } - uint directionMaskAt(ivec2 p) { const ivec2 directions[8] = ivec2[8]( ivec2(0, -1), @@ -848,18 +834,7 @@ internal object GlesMgcSpatialRgbChromaShaders { ivec2(-1, 1), ivec2(-1, -1) ); - const vec2 doubledDirectionAxes[8] = vec2[8]( - vec2(-1.0, 0.0), - vec2(1.0, 0.0), - vec2(-1.0, 0.0), - vec2(1.0, 0.0), - vec2(0.0, -1.0), - vec2(0.0, 1.0), - vec2(0.0, -1.0), - vec2(0.0, 1.0) - ); float center = yAt(p); - vec2 directionMoment = directionMomentAt(p); float gradients[8]; float minGradient = 65504.0; float maxGradient = 0.0; @@ -867,14 +842,7 @@ internal object GlesMgcSpatialRgbChromaShaders { float first = yAt(p + directions[i]); float second = yAt(p + directions[i] * 2); float rgbGradient = abs(center - first) + 0.5 * abs(first - second); - // The fused RAW-green moment identifies the edge axis. RGB still supplies the - // signed N/E/S/W decision and all local gradient magnitudes. - float structureScale = clamp( - 1.0 + 0.5 * dot(directionMoment, doubledDirectionAxes[i]), - 0.5, - 1.5 - ); - gradients[i] = rgbGradient * structureScale; + gradients[i] = rgbGradient; minGradient = min(minGradient, gradients[i]); maxGradient = max(maxGradient, gradients[i]); } diff --git a/app/src/main/java/com/hinnka/mycamera/processor/MgcSpatialRgbMerger.kt b/app/src/main/java/com/hinnka/mycamera/processor/MgcSpatialRgbMerger.kt new file mode 100644 index 00000000..a13a34cd --- /dev/null +++ b/app/src/main/java/com/hinnka/mycamera/processor/MgcSpatialRgbMerger.kt @@ -0,0 +1,104 @@ +package com.hinnka.mycamera.processor + +import java.nio.ByteBuffer + +/** JNI boundary for MGC 9.7.047 V25's original Spatial RGB merge AOT. */ +internal object MgcSpatialRgbMerger { + init { + System.loadLibrary("my-native-lib") + } + + fun merge( + rawBuffers: Array, + rawOffsets: IntArray, + rawRowStrides: IntArray, + alignment: ByteBuffer, + alignmentWidth: Int, + alignmentHeight: Int, + rejection: ByteBuffer, + rejectionWidth: Int, + rejectionHeight: Int, + frameWeights: FloatArray, + whiteBalanceGains: FloatArray, + inputBlackLevelsRgb: FloatArray, + inputBlackLevelsRggb: FloatArray, + inputGains: FloatArray, + overallGain: Float, + mergeSharpness: Float, + kernelSigmas: FloatArray, + rawWidth: Int, + rawHeight: Int, + outputWidth: Int, + outputHeight: Int, + cfaPattern: Int, + outputPlanarF16: ByteBuffer, + ) { + val result = nativeMerge( + rawBuffers, + rawOffsets, + rawRowStrides, + alignment, + alignmentWidth, + alignmentHeight, + rejection, + rejectionWidth, + rejectionHeight, + frameWeights, + whiteBalanceGains, + inputBlackLevelsRgb, + inputBlackLevelsRggb, + inputGains, + overallGain, + mergeSharpness, + kernelSigmas, + rawWidth, + rawHeight, + outputWidth, + outputHeight, + cfaPattern, + outputPlanarF16, + ) + check(result == 0) { "MGC MergeRgbRaw16F16 failed with status=$result" } + outputPlanarF16.position(0) + outputPlanarF16.limit(outputPlanarF16.capacity()) + } + + /** Reuses the uploaded planar F16 allocation as the Spatial-noise AOT's planar Q14 input. */ + fun convertPlanarF16ToFixed16(buffer: ByteBuffer, sampleCount: Int) { + val result = nativeConvertPlanarF16ToFixed16(buffer, sampleCount) + check(result == 0) { "MGC planar F16-to-Q14 conversion failed with status=$result" } + buffer.position(0) + buffer.limit(buffer.capacity()) + } + + private external fun nativeMerge( + rawBuffers: Array, + rawOffsets: IntArray, + rawRowStrides: IntArray, + alignment: ByteBuffer, + alignmentWidth: Int, + alignmentHeight: Int, + rejection: ByteBuffer, + rejectionWidth: Int, + rejectionHeight: Int, + frameWeights: FloatArray, + whiteBalanceGains: FloatArray, + inputBlackLevelsRgb: FloatArray, + inputBlackLevelsRggb: FloatArray, + inputGains: FloatArray, + overallGain: Float, + mergeSharpness: Float, + kernelSigmas: FloatArray, + rawWidth: Int, + rawHeight: Int, + outputWidth: Int, + outputHeight: Int, + cfaPattern: Int, + outputPlanarF16: ByteBuffer, + ): Int + + private external fun nativeConvertPlanarF16ToFixed16( + buffer: ByteBuffer, + sampleCount: Int, + ): Int +} diff --git a/app/src/main/java/com/hinnka/mycamera/raw/DngProfileGainTableMap.kt b/app/src/main/java/com/hinnka/mycamera/raw/DngProfileGainTableMap.kt index 91de0d52..6dce4821 100644 --- a/app/src/main/java/com/hinnka/mycamera/raw/DngProfileGainTableMap.kt +++ b/app/src/main/java/com/hinnka/mycamera/raw/DngProfileGainTableMap.kt @@ -136,7 +136,7 @@ data class DngProfileGainTableMap( */ fun hasClassicTiffHeader(file: File): Boolean { if (!file.exists() || file.length() < 8L) return false - if (BuildConfig.DEBUG) return false +// if (BuildConfig.DEBUG) return false return runCatching { RandomAccessFile(file, "r").use { raf -> val byteOrder = readTiffByteOrder(raf) ?: return@use false diff --git a/app/src/main/java/com/hinnka/mycamera/raw/RawSceneExposureEstimator.kt b/app/src/main/java/com/hinnka/mycamera/raw/RawSceneExposureEstimator.kt index 0798e1f4..8d99e956 100644 --- a/app/src/main/java/com/hinnka/mycamera/raw/RawSceneExposureEstimator.kt +++ b/app/src/main/java/com/hinnka/mycamera/raw/RawSceneExposureEstimator.kt @@ -94,7 +94,7 @@ internal object RawSceneExposureMath { // Ordinary MGC/Google ZSL exposure tuning. These are finalizer constraints, not sensor limits. const val MAX_POST_CAPTURE_GAIN = 26.5f const val MAX_OVERALL_GAIN = 102f - const val DEFAULT_EXPOSURE_COMPENSATION_EV = -0.3f + const val DEFAULT_EXPOSURE_COMPENSATION_EV = 0f // MGC's low-resolution RGB scene measurement uses ten U15 code values as its floor. private const val SIGNAL_FLOOR = 10f / 32767f diff --git a/app/src/test/java/com/hinnka/mycamera/processor/GlesMgcRawSpatialShadersTest.kt b/app/src/test/java/com/hinnka/mycamera/processor/GlesMgcRawSpatialShadersTest.kt index c651dd1e..c92ff16f 100644 --- a/app/src/test/java/com/hinnka/mycamera/processor/GlesMgcRawSpatialShadersTest.kt +++ b/app/src/test/java/com/hinnka/mycamera/processor/GlesMgcRawSpatialShadersTest.kt @@ -106,6 +106,7 @@ class GlesMgcRawSpatialShadersTest { listOf( GlesMgcRawSpatialShaders.mergeRgb, GlesMgcRawSpatialShaders.normalizeRgb16, + GlesMgcRawSpatialShaders.normalizeAotRgb16, ).forEachIndexed { index, shader -> val sourceFile = File.createTempFile("mgc-spatial-rgb-$index-", ".frag") val outputFile = File.createTempFile("mgc-spatial-rgb-$index-", ".spv") @@ -201,6 +202,22 @@ class GlesMgcRawSpatialShadersTest { assertFalse(shader.contains("ivec2(gl_FragCoord.xy) * 2")) } + @Test + fun originalAotOutputUsesPlanarQ14CameraRgbWithoutWbUndo() { + val shader = GlesMgcRawSpatialShaders.normalizeAotRgb16 + + assertTrue(shader.contains("#version 300 es")) + assertTrue(shader.contains("* (1.0 / 16384.0)")) + assertTrue(shader.contains("float channelShading")) + assertTrue(shader.contains("out highp uvec4 oRgb16")) + assertTrue(shader.contains("oRgb16[uChannel] = encodedValue")) + assertFalse(shader.contains("uimage2D")) + assertFalse(shader.contains("imageLoad")) + assertFalse(shader.contains("imageStore")) + assertFalse(shader.contains("uCalculationGains")) + assertFalse(shader.contains("uCameraDomainScale")) + } + @Test fun spatialRejectionPipelineKeepsMergeAcceptanceWeightSemantics() { val pixelDifferenceDownsample = diff --git a/app/src/test/java/com/hinnka/mycamera/processor/GlesMgcSpatialRgbChromaPostprocessorTest.kt b/app/src/test/java/com/hinnka/mycamera/processor/GlesMgcSpatialRgbChromaPostprocessorTest.kt index c7363150..e4e880b5 100644 --- a/app/src/test/java/com/hinnka/mycamera/processor/GlesMgcSpatialRgbChromaPostprocessorTest.kt +++ b/app/src/test/java/com/hinnka/mycamera/processor/GlesMgcSpatialRgbChromaPostprocessorTest.kt @@ -3,21 +3,24 @@ package com.hinnka.mycamera.processor import java.io.File import org.junit.Assert.assertArrayEquals import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Assume.assumeTrue import org.junit.Test class GlesMgcSpatialRgbChromaPostprocessorTest { @Test - fun postprocessorKeepsWbPairedAndDoesNotReapplyLensShading() { + fun postprocessorKeepsWbPairedUsesRgbDirectionAndDoesNotReapplyLensShading() { val seed = GlesMgcSpatialRgbChromaShaders.seed val finish = GlesMgcSpatialRgbChromaShaders.finalCameraRgb assertTrue(seed.contains("cameraRgb * uCalculationGains")) assertTrue(finish.contains("/\n max(uCalculationGains")) assertTrue(seed.contains("directionMaskAt(p)")) - assertTrue(seed.contains("directionMomentAt(p)")) - assertTrue(seed.contains("dot(directionMoment, doubledDirectionAxes[i])")) + assertTrue(seed.contains("float rgbGradient")) + assertTrue(seed.contains("gradients[i] = rgbGradient")) + assertFalse(seed.contains("directionMomentAt")) + assertFalse(seed.contains("doubledDirectionAxes")) assertTrue(seed.contains("count << 8")) assertTrue(seed.contains("const float finiteScale = 65504.0 / 65535.0")) assertTrue(!seed.contains("vec3(imageLoad(uCameraRgb")) diff --git a/docs/gles-driver-compatibility.md b/docs/gles-driver-compatibility.md index d238f138..7f1751f4 100644 --- a/docs/gles-driver-compatibility.md +++ b/docs/gles-driver-compatibility.md @@ -13,7 +13,7 @@ | SSBO binding | 跨驱动约束 | 查询上限;不同 program 复用低编号槽位 | | PBO 热路径回读 | 已确认存在驱动差异 | 优先 compute 打包到 SSBO,超限或编译失败时回退 framebuffer readback | | `readonly` SSBO 实参 | 已确认,Mali | SSBO 元素先复制到局部变量,再传给用户函数 | -| `RGBA16F` image 原位读写 | 已确认 | 改用 `R32UI` half 打包、ping-pong 或 additive blending | +| `RGBA16F` / `RGBA16UI` image 原位读写 | 已确认 | 改用 framebuffer、`R32UI` half 打包、ping-pong 或 additive blending | | `RGBA16UI` attachment 回读 | 跨驱动约束 | 以 RGBA16 回读,在 native 层批量移除 Alpha | | MRT attachment 残留 | 已确认,Adreno | render-target 数减少时显式 detach 尾部 attachment | | `uint16 -> float` | 已确认,Mali | 首次转换走 compute image load/store,不走 fragment sampler 直接转换 | @@ -162,6 +162,24 @@ unsupported format on read/write image Blending 路径保留逐帧 FP16 写回舍入语义,但仅适用于加法;不得用于非加法更新、次序相关替换或任意读改写。每个 compute pass 还必须校验并发 image 数不超过 image unit 上限。 +### `RGBA16UI` image 原位读写 + +**证据**:OPPO PMA110,Adreno 840,驱动 +`OpenGL ES 3.2 V@0842.41 (GIT@8cfe428358, I8188c84bfe, 1777522173)`。该驱动 +拒绝同时包含 `imageLoad` / `imageStore` 的 `layout(rgba16ui) uimage2D`: + +```text +unsupported format on read/write image +``` + +- 不由 `RGBA16UI` readonly/writeonly image 或整数 framebuffer 可用推断同格式 read/write + image 可用。 +- 逐通道组装 RGBA16UI 时,使用整数 framebuffer fragment 输出配合 + `glColorMask`;每个通道恰好写一次,结束后恢复完整 color mask,并在 image consumer + 前包含 `GL_FRAMEBUFFER_BARRIER_BIT | GL_SHADER_IMAGE_ACCESS_BARRIER_BIT`。 +- 算法确实需要读取旧值时,使用 readonly source 与 writeonly destination ping-pong;不要把 + read/modify/write 改写成依赖未定义 attachment 内容的局部通道覆盖。 + ### `RGBA16UI` attachment 回读 不要依赖驱动从 `RGBA16UI` attachment 直接完成三通道格式转换: