Skip to content

Commit

Permalink
Don't throw an exception if stereo isn't supported
Browse files Browse the repository at this point in the history
  • Loading branch information
bejado committed Nov 10, 2023
1 parent 7fc416a commit f160c95
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions filament/include/filament/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,11 +670,12 @@ class UTILS_PUBLIC View : public FilamentAPI {
* - punctual lights
*
* Stereo rendering depends on device and platform support. To check if stereo rendering is
* supported, use Engine::isStereoSupported().
* supported, use Engine::isStereoSupported(). If stereo rendering is not supported, then the
* stereoscopic options have no effect.
*
* @param options The stereoscopic options to use on this view
*/
void setStereoscopicOptions(StereoscopicOptions const& options);
void setStereoscopicOptions(StereoscopicOptions const& options) noexcept;

/**
* Returns the stereoscopic options associated with this View.
Expand Down
2 changes: 1 addition & 1 deletion filament/src/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ bool View::isStencilBufferEnabled() const noexcept {
return downcast(this)->isStencilBufferEnabled();
}

void View::setStereoscopicOptions(const StereoscopicOptions& options) {
void View::setStereoscopicOptions(const StereoscopicOptions& options) noexcept {
return downcast(this)->setStereoscopicOptions(options);
}

Expand Down
4 changes: 1 addition & 3 deletions filament/src/details/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,9 +1126,7 @@ View::PickingQuery& FView::pick(uint32_t x, uint32_t y, backend::CallbackHandler
return *pQuery;
}

void FView::setStereoscopicOptions(const StereoscopicOptions& options) {
ASSERT_PRECONDITION(!options.enabled || mIsStereoSupported,
"Stereo rendering is not supported.");
void FView::setStereoscopicOptions(const StereoscopicOptions& options) noexcept {
mStereoscopicOptions = options;
}

Expand Down
6 changes: 4 additions & 2 deletions filament/src/details/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ class FView : public View {
bool hasDPCF() const noexcept { return mShadowType == ShadowType::DPCF; }
bool hasPCSS() const noexcept { return mShadowType == ShadowType::PCSS; }
bool hasPicking() const noexcept { return mActivePickingQueriesList != nullptr; }
bool hasInstancedStereo() const noexcept { return mStereoscopicOptions.enabled; }
bool hasInstancedStereo() const noexcept {
return mIsStereoSupported && mStereoscopicOptions.enabled;
}

FrameGraphId<FrameGraphTexture> renderShadowMaps(FEngine& engine, FrameGraph& fg,
CameraInfo const& cameraInfo, math::float4 const& userTime,
Expand All @@ -188,7 +190,7 @@ class FView : public View {

bool isStencilBufferEnabled() const noexcept { return mStencilBufferEnabled; }

void setStereoscopicOptions(StereoscopicOptions const& options);
void setStereoscopicOptions(StereoscopicOptions const& options) noexcept;

FCamera const* getDirectionalLightCamera() const noexcept {
return mShadowMapManager.getDirectionalLightCamera();
Expand Down

0 comments on commit f160c95

Please sign in to comment.