Skip to content

Commit f228522

Browse files
committed
Merge remote-tracking branch 'origin/main' into metahorizon-support
2 parents 1d4c93b + c4b7a22 commit f228522

3 files changed

Lines changed: 27 additions & 9 deletions

File tree

android/sharedCode/src/main/cpp/VROAVRecorderAndroid.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,16 @@ bool VROAVRecorderAndroid::onRenderedFrameTexture(std::shared_ptr<VRORenderTarge
8686
_recorderDisplay->setViewport({0, 0, input->getWidth(), input->getHeight()});
8787

8888
driver->bindRenderTarget(_recorderDisplay, VRORenderTargetUnbindOp::Invalidate);
89-
_recordingPostProcess->blit({ input->getTexture(0) }, driver);
89+
90+
// In linear color mode (HDR enabled) the scene framebuffer holds linear RGB values;
91+
// gamma-encode them before the encoder reads the surface, otherwise recorded video
92+
// is noticeably darker than the live view. In non-linear mode the framebuffer is
93+
// already sRGB-encoded and can be blit straight through.
94+
if (driver->getColorRenderingMode() == VROColorRenderingMode::Linear) {
95+
getGammaPostProcess(driver)->blit({ input->getTexture(0) }, driver);
96+
} else {
97+
_recordingPostProcess->blit({ input->getTexture(0) }, driver);
98+
}
9099
}
91100

92101
if (_scheduledScreenShot) {
@@ -156,11 +165,16 @@ std::shared_ptr<VRORenderTarget> VROAVRecorderAndroid::bindScreenshotLDRTarget(i
156165

157166
std::shared_ptr<VROImagePostProcess> VROAVRecorderAndroid::getGammaPostProcess(std::shared_ptr<VRODriver> driver) {
158167
if (!_gammaPostProcess) {
159-
std::vector<std::string> samplers = { "hdr_texture", "tone_mapping_mask" };
168+
// The sampler name in `samplers` must match the uniform name in the shader
169+
// code below — VROImagePostProcess uses `samplers` to locate and bind the
170+
// input texture(s) to the corresponding shader uniform(s). A name mismatch
171+
// leaves the sampler unbound and the shader reads from texture unit 0 with
172+
// no texture attached, producing a black frame.
173+
std::vector<std::string> samplers = { "hdr_texture" };
160174
std::vector<std::string> code = {
161175
"const highp float gamma = 2.2;",
162-
"uniform sampler2D srgb_texture;",
163-
"highp vec4 srgb_color = texture(srgb_texture, v_texcoord);",
176+
"uniform sampler2D hdr_texture;",
177+
"highp vec4 srgb_color = texture(hdr_texture, v_texcoord);",
164178
"highp vec3 gamma_color = pow(srgb_color.xyz, vec3(1.0 / gamma));",
165179
"frag_color = vec4(gamma_color, srgb_color.a);",
166180
};

android/sharedCode/src/main/cpp/arcore/VROARSessionARCore.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,6 +1637,7 @@ void VROARSessionARCore::checkVPSAvailability(double latitude, double longitude,
16371637
// acquireNewAnchor. No VPS required — placed by GPS + compass + VIO.
16381638
// AR placement math is delegated to RVCCAGeospatialProvider::computeArPosition()
16391639
// (proprietary algorithm inside libreactvisioncca — not exposed in open-source virocore).
1640+
#if RVCCA_AVAILABLE
16401641
static std::shared_ptr<VROGeospatialAnchor> createLocalGPSAnchor(
16411642
arcore::Session *session,
16421643
const VROGeospatialPose &devicePose,
@@ -1682,6 +1683,7 @@ static std::shared_ptr<VROGeospatialAnchor> createLocalGPSAnchor(
16821683
arSession->addAnchor(vAnchor);
16831684
return geoAnchor;
16841685
}
1686+
#endif // RVCCA_AVAILABLE
16851687

16861688
void VROARSessionARCore::createGeospatialAnchor(double latitude, double longitude, double altitude,
16871689
VROQuaternion quaternion,

android/sharedCode/src/main/java/com/viro/core/internal/MediaRecorderSurface.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,14 @@ public boolean eglSetup() {
105105
return false;
106106
}
107107

108-
// Finally, create a window egl surface with the shared eglContext and mRecorderSurface.
109-
final int EGL_GL_COLORSPACE_KHR = 0x309D;
110-
final int EGL_GL_COLORSPACE_SRGB_KHR = 0x3089;
108+
// Create a window egl surface with the shared eglContext and mRecorderSurface.
109+
// Only EGL_NONE is passed — no EGL_GL_COLORSPACE_* attribute. On Tensor/Mali drivers,
110+
// tagging the encoder-input surface as sRGB causes the driver to gamma-linearize
111+
// every framebuffer write and the encoder to emit color_transfer=iec61966-2-1,
112+
// producing mis-tagged pixels that no post-hoc remux can repair and throttling GPU
113+
// throughput. With no colorspace attribute the encoder emits plain BT.709 SDR
114+
// consistently across SoCs.
111115
final int[] surfaceAttribs = {
112-
EGL_GL_COLORSPACE_KHR,
113-
EGL_GL_COLORSPACE_SRGB_KHR,
114116
EGL14.EGL_NONE
115117
};
116118
mEGLSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], mRecorderSurface,

0 commit comments

Comments
 (0)