Skip to content

Commit

Permalink
IGL: Add new shouldPresent flag to shellParams
Browse files Browse the repository at this point in the history
Summary:
This diff adds a new shouldPresent flag to shellParams. This indicates whether shell apps should ask the command buffer to present on completion.

The Android shell is updated to set this to false as it forces a present via eglSwapBuffers.

Reviewed By: tgoulart, corporateshark

Differential Revision: D49402232

fbshipit-source-id: 74ac817099bc1b2451b0ee281a37df221dbf195a
  • Loading branch information
Eric Griffith authored and facebook-github-bot committed Sep 22, 2023
1 parent c4a4b41 commit 6e16544
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions shell/android/jni/TinyRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <shell/shared/fileLoader/android/FileLoaderAndroid.h>
#include <shell/shared/imageLoader/android/ImageLoaderAndroid.h>
#include <shell/shared/renderSession/DefaultSession.h>
#include <shell/shared/renderSession/ShellParams.h>
#if IGL_BACKEND_VULKAN
#include <igl/vulkan/Device.h>
#include <igl/vulkan/HWDevice.h>
Expand Down Expand Up @@ -51,6 +52,7 @@ void TinyRenderer::init(AAssetManager* mgr,
auto backendType = (backendTypeID_ == BackendTypeID::GLES3) ? igl::opengl::RenderingAPI::GLES3
: igl::opengl::RenderingAPI::GLES2;
d = hwDevice.create(hwDevices[0], backendType, nullptr, &result);
shellParams_.shouldPresent = false;
break;
}
#endif
Expand Down Expand Up @@ -94,6 +96,7 @@ void TinyRenderer::init(AAssetManager* mgr,
static_cast<igl::shell::ImageLoaderAndroid&>(platform_->getImageLoader()).setAssetManager(mgr);
static_cast<igl::shell::FileLoaderAndroid&>(platform_->getFileLoader()).setAssetManager(mgr);
session_ = igl::shell::createDefaultRenderSession(platform_);
session_->setShellParams(shellParams_);
IGL_ASSERT(session_ != nullptr);
session_->initialize();
}
Expand Down
2 changes: 2 additions & 0 deletions shell/android/jni/TinyRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <memory>
#include <shell/shared/platform/android/PlatformAndroid.h>
#include <shell/shared/renderSession/RenderSession.h>
#include <shell/shared/renderSession/ShellParams.h>

namespace igl::samples {

Expand All @@ -33,6 +34,7 @@ class TinyRenderer final {
std::shared_ptr<igl::shell::PlatformAndroid> platform_;
std::unique_ptr<igl::shell::RenderSession> session_;

shell::ShellParams shellParams_;
uint32_t width_ = 0;
uint32_t height_ = 0;
};
Expand Down
2 changes: 0 additions & 2 deletions shell/shared/renderSession/RenderSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ RenderSession::RenderSession(std::shared_ptr<Platform> platform) :

RenderSession::~RenderSession() noexcept = default;

void RenderSession::update(igl::SurfaceTextures surfaceTextures) noexcept {}

void RenderSession::updateDisplayScale(float scale) noexcept {
platform_->getDisplayContext().scale = scale;
}
Expand Down
2 changes: 1 addition & 1 deletion shell/shared/renderSession/RenderSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RenderSession {

virtual void initialize() noexcept {}
// NOLINTNEXTLINE(performance-unnecessary-value-param)
virtual void update(igl::SurfaceTextures surfaceTextures) noexcept;
virtual void update(igl::SurfaceTextures surfaceTextures) noexcept {}
virtual void dispose() noexcept {}

void updateDisplayScale(float scale) noexcept;
Expand Down
1 change: 1 addition & 0 deletions shell/shared/renderSession/ShellParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ struct ShellParams {
glm::ivec2 nativeSurfaceDimensions = glm::ivec2(2048, 1536);
igl::TextureFormat defaultColorFramebufferFormat = igl::TextureFormat::BGRA_SRGB;
float viewportScale = 1.f;
bool shouldPresent = true;
};
} // namespace igl::shell

0 comments on commit 6e16544

Please sign in to comment.