Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional color format checks #1396

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions app/src/openxr/cpp/DeviceDelegateOpenXR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,30 @@ DeviceDelegateOpenXR::CreateLayerCylinder(const VRLayerSurfacePtr& aMoveLayer) {
return layer;
}

void DeviceDelegateOpenXR::checkSupportedColorFormats(GLint aInternalFormat) {
ASSERT(m.session);
std::string format;
switch (aInternalFormat) {
case GL_COMPRESSED_SRGB8_ETC2:
format = "GL_COMPRESSED_SRGB8_ETC2";
break;
case GL_COMPRESSED_RGB8_ETC2:
format = "GL_COMPRESSED_RGB8_ETC2";
break;
case GL_RGBA8:
format = "GL_RGBA8";
break;
case GL_SRGB8_ALPHA8:
format = "GL_SRGB8_ALPHA8";
break;
default:
format = "UNKNOWN";
}

VRB_LOG("Checking the %s color format", format.c_str());
CHECK_MSG(m.SupportsColorFormat(aInternalFormat), "Runtime doesn't support the selected swapChain color format");
}


VRLayerCubePtr
DeviceDelegateOpenXR::CreateLayerCube(int32_t aWidth, int32_t aHeight, GLint aInternalFormat) {
Expand All @@ -1383,6 +1407,7 @@ DeviceDelegateOpenXR::CreateLayerCube(int32_t aWidth, int32_t aHeight, GLint aIn
VRLayerCubePtr layer = VRLayerCube::Create(aWidth, aHeight, aInternalFormat);
m.cubeLayer = OpenXRLayerCube::Create(layer, aInternalFormat);
if (m.session != XR_NULL_HANDLE) {
checkSupportedColorFormats(aInternalFormat);
vrb::RenderContextPtr context = m.context.lock();
m.cubeLayer->Init(m.javaContext->env, m.session, context);
}
Expand Down Expand Up @@ -1602,6 +1627,7 @@ DeviceDelegateOpenXR::EnterVR(const crow::BrowserEGLContext& aEGLContext) {
layer->Init(m.javaContext->env, m.session, context);
}
if (m.cubeLayer) {
checkSupportedColorFormats(m.cubeLayer->GetColorFormat());
m.cubeLayer->Init(m.javaContext->env, m.session, context);
}
if (m.equirectLayer) {
Expand Down
4 changes: 4 additions & 0 deletions app/src/openxr/cpp/DeviceDelegateOpenXR.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ class DeviceDelegateOpenXR : public DeviceDelegate {
bool IsInVRMode() const;
bool ExitApp();
bool ShouldExitRenderLoop() const;

private:
void checkSupportedColorFormats(GLint aInternalFormat);

protected:
struct State;
DeviceDelegateOpenXR(State& aState);
Expand Down
2 changes: 1 addition & 1 deletion app/src/openxr/cpp/OpenXRLayers.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ class OpenXRLayerCube : public OpenXRLayerBase<VRLayerCubePtr, XrCompositionLaye
void Update(XrSpace aSpace, const XrPosef &aReorientPose, XrSwapchain aClearSwapChain) override;
void Destroy() override;
bool IsLoaded() const;

GLint GetColorFormat() { return glFormat; }
protected:
GLint glFormat;
};
Expand Down