From 610dca88a340d906fc84e0fc26be56407f3bf3b9 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Wed, 29 Jan 2020 11:05:54 -0800 Subject: [PATCH] Remove everything related to the depth-prepass depth-preass is no longer supported. --- RELEASE_NOTES.md | 1 + .../filament-android/src/main/cpp/View.cpp | 7 --- .../com/google/android/filament/View.java | 58 ------------------- filament/include/filament/View.h | 35 ----------- filament/src/RenderPass.cpp | 26 ++++----- filament/src/RenderPass.h | 17 +----- filament/src/Renderer.cpp | 9 +-- filament/src/View.cpp | 8 --- filament/src/details/Renderer.h | 2 - filament/src/details/View.h | 17 ------ libs/gltfio/include/gltfio/SimpleViewer.h | 10 ---- samples/app/FilamentApp.cpp | 1 - samples/vk_hellotriangle.cpp | 1 - web/filament-js/filament.d.ts | 6 -- web/filament-js/jsbindings.cpp | 1 - web/filament-js/jsenums.cpp | 5 -- 16 files changed, 15 insertions(+), 189 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index c65bf71144..fd76718f38 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -7,6 +7,7 @@ A new header is inserted each time a *tag* is created. - The Android support libraries (gltfio and filament-utils) now use dynamic linking. - Screen-space refraction is now supported. +- Removed depth-prepass related APIs. ## v1.4.5 diff --git a/android/filament-android/src/main/cpp/View.cpp b/android/filament-android/src/main/cpp/View.cpp index 2343181102..9ce4cc89d7 100644 --- a/android/filament-android/src/main/cpp/View.cpp +++ b/android/filament-android/src/main/cpp/View.cpp @@ -193,13 +193,6 @@ Java_com_google_android_filament_View_nSetDynamicLightingOptions(JNIEnv*, view->setDynamicLightingOptions(zLightNear, zLightFar); } -extern "C" JNIEXPORT void JNICALL -Java_com_google_android_filament_View_nSetDepthPrepass(JNIEnv*, - jclass, jlong nativeView, jint value) { - View* view = (View*) nativeView; - view->setDepthPrepass(View::DepthPrepass(value)); -} - extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_View_nSetPostProcessingEnabled(JNIEnv*, jclass, jlong nativeView, jboolean enabled) { diff --git a/android/filament-android/src/main/java/com/google/android/filament/View.java b/android/filament-android/src/main/java/com/google/android/filament/View.java index 0227362282..496a235817 100644 --- a/android/filament-android/src/main/java/com/google/android/filament/View.java +++ b/android/filament-android/src/main/java/com/google/android/filament/View.java @@ -62,7 +62,6 @@ public class View { private Viewport mViewport = new Viewport(0, 0, 0, 0); private DynamicResolutionOptions mDynamicResolution; private RenderQuality mRenderQuality; - private DepthPrepass mDepthPrepass = DepthPrepass.DEFAULT; private AmbientOcclusionOptions mAmbientOcclusionOptions; private RenderTarget mRenderTarget; @@ -240,19 +239,6 @@ public class View { TEMPORAL } - /** @see #setDepthPrepass */ - public enum DepthPrepass { - DEFAULT(-1), - DISABLED(0), - ENABLED(1); - - final int value; - - DepthPrepass(int value) { - this.value = value; - } - }; - View(long nativeView) { mNativeObject = nativeView; } @@ -612,49 +598,6 @@ public class View { return mRenderQuality; } - /** - * Checks if this view is rendered with a depth-only prepass. - * - * @return the value set by {@link #setDepthPrepass}. - */ - @NonNull - public DepthPrepass getDepthPrepass() { - return mDepthPrepass; - } - - /** - * Sets whether this view is rendered with or without a depth pre-pass. - * - *

This setting is ignored and will be removed in future versions of Filament.

- * - *

- * By default, the system picks the most appropriate strategy for your platform; this method - * lets you override that strategy. - *

- * - *

- * When the depth pre-pass is enabled, the renderer will first draw all objects in the - * depth buffer from front to back, and then draw the objects again but sorted to minimize - * state changes. With the depth pre-pass disabled, objects are drawn only once, but it may - * result in more state changes or more overdraw. - *

- * - *

- * The best strategy may depend on the scene and/or GPU. - *

- * - * - */ - @Deprecated - public void setDepthPrepass(@NonNull DepthPrepass depthPrepass) { - mDepthPrepass = depthPrepass; - nSetDepthPrepass(getNativeObject(), depthPrepass.value); - } - /** * Returns true if post-processing is enabled. * @@ -821,7 +764,6 @@ public class View { float minScale, float maxScale, int history); private static native void nSetRenderQuality(long nativeView, int hdrColorBufferQuality); private static native void nSetDynamicLightingOptions(long nativeView, float zLightNear, float zLightFar); - private static native void nSetDepthPrepass(long nativeView, int value); private static native void nSetPostProcessingEnabled(long nativeView, boolean enabled); private static native boolean nIsPostProcessingEnabled(long nativeView); private static native void nSetFrontFaceWindingInverted(long nativeView, boolean inverted); diff --git a/filament/include/filament/View.h b/filament/include/filament/View.h index fb962b0fbd..de6638dad8 100644 --- a/filament/include/filament/View.h +++ b/filament/include/filament/View.h @@ -169,13 +169,6 @@ public: FXAA = 1 //!< FXAA is a low-quality but very efficient type of anti-aliasing. (default). }; - /** @see setDepthPrepass */ - enum class DepthPrepass : int8_t { - DEFAULT = -1, - DISABLED, - ENABLED, - }; - /** * List of available post-processing dithering techniques. */ @@ -220,34 +213,6 @@ public: */ AmbientOcclusionOptions const& getAmbientOcclusionOptions() const noexcept; - /** - * Sets whether this view is rendered with or without a depth pre-pass. - * - * NOTE: this setting is ignored and will be removed in future versions of Filament. - * - * By default, the system picks the most appropriate strategy, this method lets the - * application override that strategy. - * - * When the depth pre-pass is enabled, the renderer will first draw all objects in the - * depth buffer from front to back, and then draw the objects again but sorted to minimize - * state changes. With the depth pre-pass disabled, objects are drawn only once, but it may - * result in more state changes or more overdraw. - * - * The best strategy may depend on the scene and/or GPU. - * - * @param prepass DepthPrepass::DEFAULT uses the most appropriate strategy, - * DepthPrepass::DISABLED disables the depth pre-pass, - * DepthPrepass::ENABLE enables the depth pre-pass. - */ - void setDepthPrepass(DepthPrepass prepass) noexcept; - - /** - * Checks if this view is rendered with a depth-only prepass. - * - * @return the value set by setDepthPass(). - */ - DepthPrepass getDepthPrepass() const noexcept; - /** * Sets the View's name. Only useful for debugging. * @param name Pointer to the View's name. The string is copied. diff --git a/filament/src/RenderPass.cpp b/filament/src/RenderPass.cpp index 5526d3c0aa..37c4cd1f4d 100644 --- a/filament/src/RenderPass.cpp +++ b/filament/src/RenderPass.cpp @@ -338,7 +338,7 @@ void RenderPass::generateCommands(uint32_t commandTypeFlags, Command* const comm * easier to debug and doesn't impact performance (it's just a predicted jump). */ - switch (commandTypeFlags & CommandTypeFlags::COLOR_AND_DEPTH) { + switch (commandTypeFlags & (CommandTypeFlags::COLOR | CommandTypeFlags::DEPTH)) { case CommandTypeFlags::COLOR: generateCommandsImpl(commandTypeFlags, curr, soa, range, renderFlags, cameraPosition, cameraForward); @@ -347,9 +347,8 @@ void RenderPass::generateCommands(uint32_t commandTypeFlags, Command* const comm generateCommandsImpl(commandTypeFlags, curr, soa, range, renderFlags, cameraPosition, cameraForward); break; - case CommandTypeFlags::COLOR_AND_DEPTH: - generateCommandsImpl(commandTypeFlags, curr, - soa, range, renderFlags, cameraPosition, cameraForward); + default: + // we should never end-up here break; } } @@ -522,17 +521,14 @@ void RenderPass::generateCommandsImpl(uint32_t extraFlags, (mode == TransparencyMode::TWO_PASSES_ONE_SIDE) ? SamplerCompareFunc::LE : cmdColor.primitive.rasterState.depthFunc; } else { - // color pass, opaque objects... - if (!depthPass) { - // ...without depth pre-pass: - // this will bucket objects by Z, front-to-back and then sort by material - // in each buckets. We use the top 10 bits of the distance, which - // bucketizes the depth by its log2 and in 4 linear chunks in each bucket. - cmdColor.key &= ~Z_BUCKET_MASK; - cmdColor.key |= makeField(distanceBits >> 22u, Z_BUCKET_MASK, - Z_BUCKET_SHIFT); - } - // ...with depth pre-pass, we just sort by materials + // color pass: + // This will bucket objects by Z, front-to-back and then sort by material + // in each buckets. We use the top 10 bits of the distance, which + // bucketizes the depth by its log2 and in 4 linear chunks in each bucket. + cmdColor.key &= ~Z_BUCKET_MASK; + cmdColor.key |= makeField(distanceBits >> 22u, Z_BUCKET_MASK, + Z_BUCKET_SHIFT); + curr->key = uint64_t(Pass::SENTINEL); ++curr; } diff --git a/filament/src/RenderPass.h b/filament/src/RenderPass.h index 30ad22d495..e65464bb13 100644 --- a/filament/src/RenderPass.h +++ b/filament/src/RenderPass.h @@ -100,9 +100,8 @@ public: }; enum CommandTypeFlags : uint8_t { - COLOR = 0x1, // generate the color pass only (e.g. no depth-prepass) + COLOR = 0x1, // generate the color pass only DEPTH = 0x2, // generate the depth pass only ( e.g. shadowmap) - COLOR_AND_DEPTH = COLOR | DEPTH, // shadow-casters are rendered in the depth buffer, regardless of blending (or alpha masking) DEPTH_CONTAINS_SHADOW_CASTERS = 0x4, @@ -111,9 +110,6 @@ public: // alpha-tested objects are not rendered in the depth buffer DEPTH_FILTER_ALPHA_MASKED_OBJECTS = 0x10, - // generate commands for color with depth pre-pass -- in this case, we want to put - // objects that use alpha-testing or blending in the depth prepass. - COLOR_WITH_DEPTH_PREPASS = DEPTH | COLOR | DEPTH_FILTER_TRANSLUCENT_OBJECTS | DEPTH_FILTER_ALPHA_MASKED_OBJECTS, // generate commands for shadow map SHADOW = DEPTH | DEPTH_CONTAINS_SHADOW_CASTERS, // generate commands for SSAO @@ -138,16 +134,7 @@ public: // | correctness | optimizations (truncation allowed) | // // - // COLOR command (with depth prepass) - // | 6 | 2| 2|1| 3 | 2| 16 | 32 | - // +------+--+--+-+---+--+----------------+--------------------------------+ - // |000001|01|00|a|ppp|00|0000000000000000| material-id | - // |000010|01|00|a|ppp|00|0000000000000000| material-id | refraction - // +------+--+--+-+---+--+----------------+--------------------------------+ - // | correctness | optimizations (truncation allowed) | - // - // - // COLOR command (without depth prepass) + // COLOR command // | 6 | 2| 2|1| 3 | 2| 6 | 10 | 32 | // +------+--+--+-+---+--+------+----------+--------------------------------+ // |000001|01|00|a|ppp|00|000000| Z-bucket | material-id | diff --git a/filament/src/Renderer.cpp b/filament/src/Renderer.cpp index f82c17dde1..eae527bf4b 100644 --- a/filament/src/Renderer.cpp +++ b/filament/src/Renderer.cpp @@ -320,9 +320,8 @@ void FRenderer::renderJob(ArenaScope& arena, FView& view) { // Color passes // TODO: ideally this should be a FrameGraph pass to participate to automatic culling - RenderPass::CommandTypeFlags commandType = getCommandType(view.getDepthPrepass()); pass.newCommandBuffer(); - pass.appendCommands(commandType); + pass.appendCommands(RenderPass::COLOR); pass.sortCommands(); const ColorPassConfig config { @@ -801,12 +800,6 @@ Handle FRenderer::getRenderTarget(FView& view) const noexcept { return viewRenderTarget ? viewRenderTarget : mRenderTarget; } -RenderPass::CommandTypeFlags FRenderer::getCommandType(View::DepthPrepass prepass) noexcept { - // We are universally disabling the depth prepass for multiple reasons: invariance artifacts - // on many platforms, insufficient / negative performance gains, and the complexity it incurs. - return RenderPass::COLOR; -} - } // namespace details // ------------------------------------------------------------------------------------------------ diff --git a/filament/src/View.cpp b/filament/src/View.cpp index 3b2bc9262a..63f1a184a6 100644 --- a/filament/src/View.cpp +++ b/filament/src/View.cpp @@ -951,14 +951,6 @@ bool View::isFrontFaceWindingInverted() const noexcept { return upcast(this)->isFrontFaceWindingInverted(); } -void View::setDepthPrepass(View::DepthPrepass prepass) noexcept { - upcast(this)->setDepthPrepass(prepass); -} - -View::DepthPrepass View::getDepthPrepass() const noexcept { - return upcast(this)->getDepthPrepass(); -} - void View::setDynamicLightingOptions(float zLightNear, float zLightFar) noexcept { upcast(this)->setDynamicLightingOptions(zLightNear, zLightFar); } diff --git a/filament/src/details/Renderer.h b/filament/src/details/Renderer.h index 0a53761a45..5898d86d02 100644 --- a/filament/src/details/Renderer.h +++ b/filament/src/details/Renderer.h @@ -100,8 +100,6 @@ private: uint32_t xoffset, uint32_t yoffset, uint32_t width, uint32_t height, backend::PixelBufferDescriptor&& buffer); - static RenderPass::CommandTypeFlags getCommandType(View::DepthPrepass prepass) noexcept; - struct ColorPassConfig { Viewport svp; backend::TextureFormat hdrFormat; diff --git a/filament/src/details/View.h b/filament/src/details/View.h index 6c37739308..9668dfd8b0 100644 --- a/filament/src/details/View.h +++ b/filament/src/details/View.h @@ -224,22 +224,6 @@ public: mHasPostProcessPass = enabled; } - void setDepthPrepass(DepthPrepass prepass) noexcept { -#ifdef __EMSCRIPTEN__ - if (prepass == View::DepthPrepass::ENABLED) { - utils::slog.w << "WARNING: " << - "Depth prepass cannot be enabled on web due to invariance requirements." << - utils::io::endl; - return; - } -#endif - mDepthPrepass = prepass; - } - - DepthPrepass getDepthPrepass() const noexcept { - return mDepthPrepass; - } - void setAmbientOcclusion(AmbientOcclusion ambientOcclusion) noexcept { mAmbientOcclusion = ambientOcclusion; } @@ -353,7 +337,6 @@ private: Dithering mDithering = Dithering::TEMPORAL; bool mShadowingEnabled = true; bool mHasPostProcessPass = true; - DepthPrepass mDepthPrepass = DepthPrepass::DEFAULT; AmbientOcclusion mAmbientOcclusion = AmbientOcclusion::NONE; AmbientOcclusionOptions mAmbientOcclusionOptions{}; diff --git a/libs/gltfio/include/gltfio/SimpleViewer.h b/libs/gltfio/include/gltfio/SimpleViewer.h index 42102a7c5a..28c8ae6699 100644 --- a/libs/gltfio/include/gltfio/SimpleViewer.h +++ b/libs/gltfio/include/gltfio/SimpleViewer.h @@ -137,12 +137,6 @@ public: */ void enableDithering(bool b) { mEnableDithering = b; } - /** - * Enables depth prepass on the view. - * Defaults to true. - */ - void enablePrepass(bool b) { mEnablePrepass = b; } - /** * Enables FXAA antialiasing in the post-process pipeline. * Defaults to true. @@ -195,7 +189,6 @@ private: bool mEnableSunlight = true; bool mEnableShadows = true; bool mEnableDithering = true; - bool mEnablePrepass = true; bool mEnableFxaa = true; bool mEnableMsaa = true; bool mEnableSsao = true; @@ -417,14 +410,11 @@ void SimpleViewer::updateUserInterface() { if (ImGui::CollapsingHeader("View")) { ImGui::Checkbox("Dithering", &mEnableDithering); - ImGui::Checkbox("Depth prepass", &mEnablePrepass); ImGui::Checkbox("FXAA", &mEnableFxaa); ImGui::Checkbox("MSAA 4x", &mEnableMsaa); ImGui::Checkbox("SSAO", &mEnableSsao); } - mView->setDepthPrepass( - mEnablePrepass ? View::DepthPrepass::ENABLED : View::DepthPrepass::DISABLED); mView->setDithering(mEnableDithering ? View::Dithering::TEMPORAL : View::Dithering::NONE); mView->setAntiAliasing(mEnableFxaa ? View::AntiAliasing::FXAA : View::AntiAliasing::NONE); mView->setSampleCount(mEnableMsaa ? 4 : 1); diff --git a/samples/app/FilamentApp.cpp b/samples/app/FilamentApp.cpp index e61a5c8858..1cb5193d60 100644 --- a/samples/app/FilamentApp.cpp +++ b/samples/app/FilamentApp.cpp @@ -516,7 +516,6 @@ FilamentApp::Window::Window(FilamentApp* filamentApp, mViews.emplace_back(mDepthView = new CView(*mRenderer, "Depth View")); mViews.emplace_back(mGodView = new GodView(*mRenderer, "God View")); mViews.emplace_back(mOrthoView = new CView(*mRenderer, "Ortho View")); - mDepthView->getView()->setDepthPrepass(View::DepthPrepass::DISABLED); } mViews.emplace_back(mUiView = new CView(*mRenderer, "UI View")); diff --git a/samples/vk_hellotriangle.cpp b/samples/vk_hellotriangle.cpp index cdb252cadc..f57f0d8833 100644 --- a/samples/vk_hellotriangle.cpp +++ b/samples/vk_hellotriangle.cpp @@ -68,7 +68,6 @@ int main(int argc, char** argv) { auto setup = [&app](Engine* engine, View* view, Scene* scene) { view->setClearColor({0.1, 0.125, 0.25, 1.0}); view->setPostProcessingEnabled(false); - view->setDepthPrepass(filament::View::DepthPrepass::DISABLED); static_assert(sizeof(Vertex) == 12, "Strange vertex size."); app.vb = VertexBuffer::Builder() .vertexCount(3) diff --git a/web/filament-js/filament.d.ts b/web/filament-js/filament.d.ts index 2e5c9b71e1..e484bad052 100644 --- a/web/filament-js/filament.d.ts +++ b/web/filament-js/filament.d.ts @@ -704,12 +704,6 @@ export enum View$AntiAliasing { FXAA, } -export enum View$DepthPrepass { - DEFAULT, - DISABLED, - ENABLED, -} - export enum WrapMode { CLAMP_TO_EDGE, REPEAT, diff --git a/web/filament-js/jsbindings.cpp b/web/filament-js/jsbindings.cpp index 32dc244696..cb44a7635e 100644 --- a/web/filament-js/jsbindings.cpp +++ b/web/filament-js/jsbindings.cpp @@ -464,7 +464,6 @@ class_("View") .function("getViewport", &View::getViewport) .function("setViewport", &View::setViewport) .function("setClearColor", &View::setClearColor) - .function("setDepthPrepass", &View::setDepthPrepass) .function("setPostProcessingEnabled", &View::setPostProcessingEnabled) .function("setAntiAliasing", &View::setAntiAliasing) .function("getAntiAliasing", &View::getAntiAliasing) diff --git a/web/filament-js/jsenums.cpp b/web/filament-js/jsenums.cpp index 567eb26185..f683c1de16 100644 --- a/web/filament-js/jsenums.cpp +++ b/web/filament-js/jsenums.cpp @@ -117,11 +117,6 @@ enum_("View$AntiAliasing") .value("NONE", View::AntiAliasing::NONE) .value("FXAA", View::AntiAliasing::FXAA); -enum_("View$DepthPrepass") - .value("DEFAULT", View::DepthPrepass::DEFAULT) - .value("DISABLED", View::DepthPrepass::DISABLED) - .value("ENABLED", View::DepthPrepass::ENABLED); - enum_("Camera$Projection") .value("PERSPECTIVE", Camera::Projection::PERSPECTIVE) .value("ORTHO", Camera::Projection::ORTHO);