headers from v1.31.5
This commit is contained in:
39
ios/include/backend/AcquiredImage.h
Normal file
39
ios/include/backend/AcquiredImage.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TNT_FILAMENT_BACKEND_PRIVATE_ACQUIREDIMAGE_H
|
||||
#define TNT_FILAMENT_BACKEND_PRIVATE_ACQUIREDIMAGE_H
|
||||
|
||||
#include <backend/DriverEnums.h>
|
||||
|
||||
namespace filament::backend {
|
||||
|
||||
class CallbackHandler;
|
||||
|
||||
// This lightweight POD allows us to bundle the state required to process an ACQUIRED stream.
|
||||
// Since these types of external images need to be moved around and queued up, an encapsulation is
|
||||
// very useful.
|
||||
|
||||
struct AcquiredImage {
|
||||
void* image = nullptr;
|
||||
backend::StreamCallback callback = nullptr;
|
||||
void* userData = nullptr;
|
||||
CallbackHandler* handler = nullptr;
|
||||
};
|
||||
|
||||
} // namespace filament::backend
|
||||
|
||||
#endif // TNT_FILAMENT_BACKEND_PRIVATE_ACQUIREDIMAGE_H
|
||||
@@ -42,11 +42,42 @@
|
||||
*/
|
||||
namespace filament::backend {
|
||||
|
||||
/**
|
||||
* Requests a SwapChain with an alpha channel.
|
||||
*/
|
||||
static constexpr uint64_t SWAP_CHAIN_CONFIG_TRANSPARENT = 0x1;
|
||||
|
||||
/**
|
||||
* This flag indicates that the swap chain may be used as a source surface
|
||||
* for reading back render results. This config flag must be set when creating
|
||||
* any SwapChain that will be used as the source for a blit operation.
|
||||
*/
|
||||
static constexpr uint64_t SWAP_CHAIN_CONFIG_READABLE = 0x2;
|
||||
|
||||
/**
|
||||
* Indicates that the native X11 window is an XCB window rather than an XLIB window.
|
||||
* This is ignored on non-Linux platforms and in builds that support only one X11 API.
|
||||
*/
|
||||
static constexpr uint64_t SWAP_CHAIN_CONFIG_ENABLE_XCB = 0x4;
|
||||
|
||||
/**
|
||||
* Indicates that the native window is a CVPixelBufferRef.
|
||||
*
|
||||
* This is only supported by the Metal backend. The CVPixelBuffer must be in the
|
||||
* kCVPixelFormatType_32BGRA format.
|
||||
*
|
||||
* It is not necessary to add an additional retain call before passing the pixel buffer to
|
||||
* Filament. Filament will call CVPixelBufferRetain during Engine::createSwapChain, and
|
||||
* CVPixelBufferRelease when the swap chain is destroyed.
|
||||
*/
|
||||
static constexpr uint64_t SWAP_CHAIN_CONFIG_APPLE_CVPIXELBUFFER = 0x8;
|
||||
|
||||
/**
|
||||
* Indicates that the SwapChain must automatically perform linear to srgb encoding.
|
||||
*/
|
||||
static constexpr uint64_t SWAP_CHAIN_CONFIG_SRGB_COLORSPACE = 0x10;
|
||||
|
||||
|
||||
static constexpr size_t MAX_VERTEX_ATTRIBUTE_COUNT = 16; // This is guaranteed by OpenGL ES.
|
||||
static constexpr size_t MAX_SAMPLER_COUNT = 62; // Maximum needed at feature level 3.
|
||||
static constexpr size_t MAX_VERTEX_BUFFER_COUNT = 16; // Max number of bound buffer objects.
|
||||
|
||||
@@ -23,22 +23,28 @@
|
||||
|
||||
#include <utils/compiler.h>
|
||||
|
||||
namespace filament {
|
||||
namespace backend {
|
||||
namespace filament::backend {
|
||||
|
||||
class Driver;
|
||||
|
||||
/**
|
||||
* Platform is an interface that abstracts how the backend (also referred to as Driver) is
|
||||
* created. The backend provides several common Platform concrete implementations, which are
|
||||
* selected automatically. It is possible however to provide a custom Platform when creating
|
||||
* the filament Engine.
|
||||
*/
|
||||
class UTILS_PUBLIC Platform {
|
||||
public:
|
||||
struct SwapChain {};
|
||||
struct Fence {};
|
||||
struct Stream {};
|
||||
struct ExternalTexture {
|
||||
uintptr_t image = 0;
|
||||
};
|
||||
|
||||
struct DriverConfig {
|
||||
size_t handleArenaSize = 0; // size of handle arena in bytes. Setting to 0 indicates default value is to be used. Driver clamps to valid values.
|
||||
/*
|
||||
* size of handle arena in bytes. Setting to 0 indicates default value is to be used.
|
||||
* Driver clamps to valid values.
|
||||
*/
|
||||
size_t handleArenaSize = 0;
|
||||
};
|
||||
|
||||
virtual ~Platform() noexcept;
|
||||
@@ -62,7 +68,8 @@ public:
|
||||
*
|
||||
* @return nullptr on failure, or a pointer to the newly created driver.
|
||||
*/
|
||||
virtual backend::Driver* createDriver(void* sharedContext, const DriverConfig& driverConfig) noexcept = 0;
|
||||
virtual backend::Driver* createDriver(void* sharedContext,
|
||||
const DriverConfig& driverConfig) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Processes the platform's event queue when called from its primary event-handling thread.
|
||||
@@ -71,39 +78,9 @@ public:
|
||||
* on platforms that need it, such as macOS + OpenGL. Returns false if this is not the main
|
||||
* thread, or if the platform does not need to perform any special processing.
|
||||
*/
|
||||
virtual bool pumpEvents() noexcept { return false; }
|
||||
virtual bool pumpEvents() noexcept;
|
||||
};
|
||||
|
||||
|
||||
class UTILS_PUBLIC DefaultPlatform : public Platform {
|
||||
public:
|
||||
~DefaultPlatform() noexcept override;
|
||||
|
||||
/**
|
||||
* Creates a Platform configured for the requested backend if available
|
||||
*
|
||||
* @param backendHint Preferred backend, if not available the backend most suitable for the
|
||||
* underlying platform is returned and \p backendHint is updated
|
||||
* accordingly. Can't be nullptr.
|
||||
*
|
||||
* @return A pointer to the Platform object.
|
||||
*
|
||||
* @see destroy
|
||||
*/
|
||||
static DefaultPlatform* create(backend::Backend* backendHint) noexcept;
|
||||
|
||||
/**
|
||||
* Destroys a Platform object returned by create()
|
||||
*
|
||||
* @param platform a reference (as a pointer) to the DefaultPlatform pointer to destroy.
|
||||
* \p platform is cleared upon return.
|
||||
*
|
||||
* @see create
|
||||
*/
|
||||
static void destroy(DefaultPlatform** platform) noexcept;
|
||||
};
|
||||
|
||||
} // namespace backend
|
||||
} // namespace filament
|
||||
|
||||
#endif // TNT_FILAMENT_BACKEND_PLATFORM_H
|
||||
|
||||
4
ios/include/backend/README.md
Normal file
4
ios/include/backend/README.md
Normal file
@@ -0,0 +1,4 @@
|
||||
# include/backend Headers
|
||||
|
||||
Headers in `include/backend/` are fully public, in particular they can be included in filament's
|
||||
public headers.
|
||||
261
ios/include/backend/platforms/OpenGLPlatform.h
Normal file
261
ios/include/backend/platforms/OpenGLPlatform.h
Normal file
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TNT_FILAMENT_BACKEND_PRIVATE_OPENGLPLATFORM_H
|
||||
#define TNT_FILAMENT_BACKEND_PRIVATE_OPENGLPLATFORM_H
|
||||
|
||||
#include <backend/AcquiredImage.h>
|
||||
#include <backend/Platform.h>
|
||||
|
||||
namespace filament::backend {
|
||||
|
||||
class Driver;
|
||||
|
||||
/**
|
||||
* A Platform interface that creates an OpenGL backend.
|
||||
*
|
||||
* WARNING: None of the methods below are allowed to change the GL state and must restore it
|
||||
* upon return.
|
||||
*
|
||||
*/
|
||||
class OpenGLPlatform : public Platform {
|
||||
protected:
|
||||
|
||||
/*
|
||||
* Derived classes can use this to instantiate the default OpenGLDriver backend.
|
||||
* This is typically called from your implementation of createDriver()
|
||||
*/
|
||||
static Driver* createDefaultDriver(OpenGLPlatform* platform,
|
||||
void* sharedContext, const DriverConfig& driverConfig);
|
||||
|
||||
~OpenGLPlatform() noexcept override;
|
||||
|
||||
public:
|
||||
|
||||
struct ExternalTexture {
|
||||
unsigned int target; // GLenum target
|
||||
unsigned int id; // GLuint id
|
||||
};
|
||||
|
||||
/**
|
||||
* Called by the driver to destroy the OpenGL context. This should clean up any windows
|
||||
* or buffers from initialization. This is for instance where `eglDestroyContext` would be
|
||||
* called.
|
||||
*/
|
||||
virtual void terminate() noexcept = 0;
|
||||
|
||||
/**
|
||||
* Called by the driver to create a SwapChain for this driver.
|
||||
*
|
||||
* @param nativeWindow a token representing the native window. See concrete implementation
|
||||
* for details.
|
||||
* @param flags extra flags used by the implementation, see filament::SwapChain
|
||||
* @return The driver's SwapChain object.
|
||||
*
|
||||
*/
|
||||
virtual SwapChain* createSwapChain(void* nativeWindow, uint64_t flags) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Return whether createSwapChain supports the SWAP_CHAIN_CONFIG_SRGB_COLORSPACE flag.
|
||||
* The default implementation returns false.
|
||||
*
|
||||
* @return true if SWAP_CHAIN_CONFIG_SRGB_COLORSPACE is supported, false otherwise.
|
||||
*/
|
||||
virtual bool isSRGBSwapChainSupported() const noexcept;
|
||||
|
||||
/**
|
||||
* Called by the driver create a headless SwapChain.
|
||||
*
|
||||
* @param width width of the buffer
|
||||
* @param height height of the buffer
|
||||
* @param flags extra flags used by the implementation, see filament::SwapChain
|
||||
* @return The driver's SwapChain object.
|
||||
*
|
||||
* TODO: we need a more generic way of passing construction parameters
|
||||
* A void* might be enough.
|
||||
*/
|
||||
virtual SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t flags) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Called by the driver to destroys the SwapChain
|
||||
* @param swapChain SwapChain to be destroyed.
|
||||
*/
|
||||
virtual void destroySwapChain(SwapChain* swapChain) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Called by the driver to establish the default FBO. The default implementation returns 0.
|
||||
* @return a GLuint casted to a uint32_t that is an OpenGL framebuffer object.
|
||||
*/
|
||||
virtual uint32_t createDefaultRenderTarget() noexcept;
|
||||
|
||||
/**
|
||||
* Called by the driver to make the OpenGL context active on the calling thread and bind
|
||||
* the drawSwapChain to the default render target (FBO) created with createDefaultRenderTarget.
|
||||
* @param drawSwapChain SwapChain to draw to. It must be bound to the default FBO.
|
||||
* @param readSwapChain SwapChain to read from (for operation like `glBlitFramebuffer`)
|
||||
*/
|
||||
virtual void makeCurrent(SwapChain* drawSwapChain, SwapChain* readSwapChain) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Called by the driver once the current frame finishes drawing. Typically, this should present
|
||||
* the drawSwapChain. This is for example where `eglMakeCurrent()` would be called.
|
||||
* @param swapChain the SwapChain to present.
|
||||
*/
|
||||
virtual void commit(SwapChain* swapChain) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Set the time the next committed buffer should be presented to the user at.
|
||||
*
|
||||
* @param presentationTimeInNanosecond time in the future in nanosecond. The clock used depends
|
||||
* on the concrete platform implementation.
|
||||
*/
|
||||
virtual void setPresentationTime(int64_t presentationTimeInNanosecond) noexcept;
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// Fence support
|
||||
|
||||
/**
|
||||
* Can this implementation create a Fence.
|
||||
* @return true if supported, false otherwise. The default implementation returns false.
|
||||
*/
|
||||
virtual bool canCreateFence() noexcept;
|
||||
|
||||
/**
|
||||
* Creates a Fence (e.g. eglCreateSyncKHR). This must be implemented if `canCreateFence`
|
||||
* returns true. Fences are used for frame pacing.
|
||||
*
|
||||
* @return A Fence object. The default implementation returns nullptr.
|
||||
*/
|
||||
virtual Fence* createFence() noexcept;
|
||||
|
||||
/**
|
||||
* Destroys a Fence object. The default implementation does nothing.
|
||||
*
|
||||
* @param fence Fence to destroy.
|
||||
*/
|
||||
virtual void destroyFence(Fence* fence) noexcept;
|
||||
|
||||
/**
|
||||
* Waits on a Fence.
|
||||
*
|
||||
* @param fence Fence to wait on.
|
||||
* @param timeout Timeout.
|
||||
* @return Whether the fence signaled or timed out. See backend::FenceStatus.
|
||||
* The default implementation always return backend::FenceStatus::ERROR.
|
||||
*/
|
||||
virtual backend::FenceStatus waitFence(Fence* fence, uint64_t timeout) noexcept;
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// Streaming support
|
||||
|
||||
/**
|
||||
* Creates a Stream from a native Stream.
|
||||
*
|
||||
* WARNING: This is called synchronously from the application thread (NOT the Driver thread)
|
||||
*
|
||||
* @param nativeStream The native stream, this parameter depends on the concrete implementation.
|
||||
* @return A new Stream object.
|
||||
*/
|
||||
virtual Stream* createStream(void* nativeStream) noexcept;
|
||||
|
||||
/**
|
||||
* Destroys a Stream.
|
||||
* @param stream Stream to destroy.
|
||||
*/
|
||||
virtual void destroyStream(Stream* stream) noexcept;
|
||||
|
||||
/**
|
||||
* The specified stream takes ownership of the texture (tname) object
|
||||
* Once attached, the texture is automatically updated with the Stream's content, which
|
||||
* could be a video stream for instance.
|
||||
*
|
||||
* @param stream Stream to take ownership of the texture
|
||||
* @param tname GL texture id to "bind" to the Stream.
|
||||
*/
|
||||
virtual void attach(Stream* stream, intptr_t tname) noexcept;
|
||||
|
||||
/**
|
||||
* Destroys the texture associated to the stream
|
||||
* @param stream Stream to detach from its texture
|
||||
*/
|
||||
virtual void detach(Stream* stream) noexcept;
|
||||
|
||||
/**
|
||||
* Updates the content of the texture attached to the stream.
|
||||
* @param stream Stream to update
|
||||
* @param timestamp Output parameter: Timestamp of the image bound to the texture.
|
||||
*/
|
||||
virtual void updateTexImage(Stream* stream, int64_t* timestamp) noexcept;
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// External Image support
|
||||
|
||||
/**
|
||||
* Creates an external texture handle. External textures don't have any parameters because
|
||||
* these are undefined until setExternalImage() is called.
|
||||
* @return a pointer to an ExternalTexture structure filled with valid token. However, the
|
||||
* implementation could just return { 0, GL_TEXTURE_2D } at this point. The actual
|
||||
* values can be delayed until setExternalImage.
|
||||
*/
|
||||
virtual ExternalTexture *createExternalImageTexture() noexcept;
|
||||
|
||||
/**
|
||||
* Destroys an external texture handle and associated data.
|
||||
* @param texture a pointer to the handle to destroy.
|
||||
*/
|
||||
virtual void destroyExternalImage(ExternalTexture* texture) noexcept;
|
||||
|
||||
// called on the application thread to allow Filament to take ownership of the image
|
||||
|
||||
/**
|
||||
* Takes ownership of the externalImage. The externalImage parameter depends on the Platform's
|
||||
* concrete implementation. Ownership is released when destroyExternalImage() is called.
|
||||
*
|
||||
* WARNING: This is called synchronously from the application thread (NOT the Driver thread)
|
||||
*
|
||||
* @param externalImage A token representing the platform's external image.
|
||||
* @see destroyExternalImage
|
||||
*/
|
||||
virtual void retainExternalImage(void* externalImage) noexcept;
|
||||
|
||||
/**
|
||||
* Called to bind the platform-specific externalImage to an ExternalTexture.
|
||||
* ExternalTexture::id is guaranteed to be bound when this method is called and ExternalTexture
|
||||
* is updated with new values for id/target if necessary.
|
||||
*
|
||||
* WARNING: this method is not allowed to change the bound texture, or must restore the previous
|
||||
* binding upon return. This is to avoid problem with a backend doing state caching.
|
||||
*
|
||||
* @param externalImage The platform-specific external image.
|
||||
* @param texture an in/out pointer to ExternalTexture, id and target can be updated if necessary.
|
||||
* @return true on success, false on error.
|
||||
*/
|
||||
virtual bool setExternalImage(void* externalImage, ExternalTexture* texture) noexcept;
|
||||
|
||||
/**
|
||||
* The method allows platforms to convert a user-supplied external image object into a new type
|
||||
* (e.g. HardwareBuffer => EGLImage). The default implementation returns source.
|
||||
* @param source Image to transform.
|
||||
* @return Transformed image.
|
||||
*/
|
||||
virtual AcquiredImage transformAcquiredImage(AcquiredImage source) noexcept;
|
||||
};
|
||||
|
||||
} // namespace filament
|
||||
|
||||
#endif // TNT_FILAMENT_BACKEND_PRIVATE_OPENGLPLATFORM_H
|
||||
67
ios/include/backend/platforms/PlatformCocoaGL.h
Normal file
67
ios/include/backend/platforms/PlatformCocoaGL.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_COCOA_GL_H
|
||||
#define TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_COCOA_GL_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <backend/platforms/OpenGLPlatform.h>
|
||||
|
||||
#include <backend/DriverEnums.h>
|
||||
|
||||
namespace filament::backend {
|
||||
|
||||
struct PlatformCocoaGLImpl;
|
||||
|
||||
/**
|
||||
* A concrete implementation of OpenGLPlatform that supports macOS's Cocoa.
|
||||
*/
|
||||
class PlatformCocoaGL : public OpenGLPlatform {
|
||||
public:
|
||||
PlatformCocoaGL();
|
||||
~PlatformCocoaGL() noexcept override;
|
||||
|
||||
protected:
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// Platform Interface
|
||||
|
||||
Driver* createDriver(void* sharedContext,
|
||||
const Platform::DriverConfig& driverConfig) noexcept override;
|
||||
|
||||
// Currently returns 0
|
||||
int getOSVersion() const noexcept override;
|
||||
|
||||
bool pumpEvents() noexcept override;
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// OpenGLPlatform Interface
|
||||
|
||||
void terminate() noexcept override;
|
||||
|
||||
SwapChain* createSwapChain(void* nativewindow, uint64_t flags) noexcept override;
|
||||
SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t flags) noexcept override;
|
||||
void destroySwapChain(SwapChain* swapChain) noexcept override;
|
||||
void makeCurrent(SwapChain* drawSwapChain, SwapChain* readSwapChain) noexcept override;
|
||||
void commit(SwapChain* swapChain) noexcept override;
|
||||
|
||||
private:
|
||||
PlatformCocoaGLImpl* pImpl = nullptr;
|
||||
};
|
||||
|
||||
} // namespace filament::backend
|
||||
|
||||
#endif // TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_COCOA_GL_H
|
||||
69
ios/include/backend/platforms/PlatformCocoaTouchGL.h
Normal file
69
ios/include/backend/platforms/PlatformCocoaTouchGL.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_COCOA_TOUCH_GL_H
|
||||
#define TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_COCOA_TOUCH_GL_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <backend/platforms/OpenGLPlatform.h>
|
||||
|
||||
#include <backend/DriverEnums.h>
|
||||
|
||||
namespace filament::backend {
|
||||
|
||||
struct PlatformCocoaTouchGLImpl;
|
||||
|
||||
class PlatformCocoaTouchGL : public OpenGLPlatform {
|
||||
public:
|
||||
PlatformCocoaTouchGL();
|
||||
~PlatformCocoaTouchGL() noexcept;
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// Platform Interface
|
||||
|
||||
Driver* createDriver(void* sharedGLContext,
|
||||
const Platform::DriverConfig& driverConfig) noexcept override;
|
||||
|
||||
int getOSVersion() const noexcept final { return 0; }
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// OpenGLPlatform Interface
|
||||
|
||||
void terminate() noexcept override;
|
||||
|
||||
uint32_t createDefaultRenderTarget() noexcept override;
|
||||
|
||||
SwapChain* createSwapChain(void* nativewindow, uint64_t flags) noexcept override;
|
||||
SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t flags) noexcept override;
|
||||
void destroySwapChain(SwapChain* swapChain) noexcept override;
|
||||
void makeCurrent(SwapChain* drawSwapChain, SwapChain* readSwapChain) noexcept override;
|
||||
void commit(SwapChain* swapChain) noexcept override;
|
||||
|
||||
OpenGLPlatform::ExternalTexture* createExternalImageTexture() noexcept override;
|
||||
void destroyExternalImage(ExternalTexture* texture) noexcept override;
|
||||
void retainExternalImage(void* externalImage) noexcept override;
|
||||
bool setExternalImage(void* externalImage, ExternalTexture* texture) noexcept override;
|
||||
|
||||
private:
|
||||
PlatformCocoaTouchGLImpl* pImpl = nullptr;
|
||||
};
|
||||
|
||||
using ContextManager = PlatformCocoaTouchGL;
|
||||
|
||||
} // namespace filament::backend
|
||||
|
||||
#endif // TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_COCOA_TOUCH_GL_H
|
||||
120
ios/include/backend/platforms/PlatformEGL.h
Normal file
120
ios/include/backend/platforms/PlatformEGL.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_EGL_H
|
||||
#define TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_EGL_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
|
||||
#include <backend/platforms/OpenGLPlatform.h>
|
||||
|
||||
#include <backend/DriverEnums.h>
|
||||
|
||||
namespace filament::backend {
|
||||
|
||||
/**
|
||||
* A concrete implementation of OpenGLPlatform that supports EGL.
|
||||
*/
|
||||
class PlatformEGL : public OpenGLPlatform {
|
||||
public:
|
||||
|
||||
PlatformEGL() noexcept;
|
||||
|
||||
protected:
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// Platform Interface
|
||||
|
||||
/**
|
||||
* Initializes EGL, creates the OpenGL context and returns a concrete Driver implementation
|
||||
* that supports OpenGL/OpenGL ES.
|
||||
*/
|
||||
Driver* createDriver(void* sharedContext,
|
||||
const Platform::DriverConfig& driverConfig) noexcept override;
|
||||
|
||||
/**
|
||||
* This returns zero. This method can be overridden to return something more useful.
|
||||
* @return zero
|
||||
*/
|
||||
int getOSVersion() const noexcept override;
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// OpenGLPlatform Interface
|
||||
|
||||
void terminate() noexcept override;
|
||||
|
||||
bool isSRGBSwapChainSupported() const noexcept override;
|
||||
SwapChain* createSwapChain(void* nativewindow, uint64_t flags) noexcept override;
|
||||
SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t flags) noexcept override;
|
||||
void destroySwapChain(SwapChain* swapChain) noexcept override;
|
||||
void makeCurrent(SwapChain* drawSwapChain, SwapChain* readSwapChain) noexcept override;
|
||||
void commit(SwapChain* swapChain) noexcept override;
|
||||
|
||||
bool canCreateFence() noexcept override;
|
||||
Fence* createFence() noexcept override;
|
||||
void destroyFence(Fence* fence) noexcept override;
|
||||
FenceStatus waitFence(Fence* fence, uint64_t timeout) noexcept override;
|
||||
|
||||
OpenGLPlatform::ExternalTexture* createExternalImageTexture() noexcept override;
|
||||
void destroyExternalImage(ExternalTexture* texture) noexcept override;
|
||||
bool setExternalImage(void* externalImage, ExternalTexture* texture) noexcept override;
|
||||
|
||||
/**
|
||||
* Logs glGetError() to slog.e
|
||||
* @param name a string giving some context on the error. Typically __func__.
|
||||
*/
|
||||
static void logEglError(const char* name) noexcept;
|
||||
|
||||
/**
|
||||
* Calls glGetError() to clear the current error flags. logs a warning to log.w if
|
||||
* an error was pending.
|
||||
*/
|
||||
static void clearGlError() noexcept;
|
||||
|
||||
/**
|
||||
* Always use this instead of eglMakeCurrent().
|
||||
*/
|
||||
EGLBoolean makeCurrent(EGLSurface drawSurface, EGLSurface readSurface) noexcept;
|
||||
|
||||
// TODO: this should probably use getters instead.
|
||||
EGLDisplay mEGLDisplay = EGL_NO_DISPLAY;
|
||||
EGLContext mEGLContext = EGL_NO_CONTEXT;
|
||||
EGLSurface mCurrentDrawSurface = EGL_NO_SURFACE;
|
||||
EGLSurface mCurrentReadSurface = EGL_NO_SURFACE;
|
||||
EGLSurface mEGLDummySurface = EGL_NO_SURFACE;
|
||||
EGLConfig mEGLConfig = EGL_NO_CONFIG_KHR;
|
||||
|
||||
// supported extensions detected at runtime
|
||||
struct {
|
||||
struct {
|
||||
bool OES_EGL_image_external_essl3 = false;
|
||||
} gl;
|
||||
struct {
|
||||
bool KHR_no_config_context = false;
|
||||
bool KHR_gl_colorspace = false;
|
||||
} egl;
|
||||
} ext;
|
||||
|
||||
private:
|
||||
void initializeGlExtensions() noexcept;
|
||||
EGLConfig findSwapChainConfig(uint64_t flags) const;
|
||||
};
|
||||
|
||||
} // namespace filament::backend
|
||||
|
||||
#endif // TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_EGL_H
|
||||
82
ios/include/backend/platforms/PlatformEGLAndroid.h
Normal file
82
ios/include/backend/platforms/PlatformEGLAndroid.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_EGL_ANDROID_H
|
||||
#define TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_EGL_ANDROID_H
|
||||
|
||||
#include <backend/platforms/PlatformEGL.h>
|
||||
|
||||
namespace filament::backend {
|
||||
|
||||
class ExternalStreamManagerAndroid;
|
||||
|
||||
/**
|
||||
* A concrete implementation of OpenGLPlatform and subclass of PlatformEGL that supports
|
||||
* EGL on Android. It adds Android streaming functionality to PlatformEGL.
|
||||
*/
|
||||
class PlatformEGLAndroid : public PlatformEGL {
|
||||
public:
|
||||
|
||||
PlatformEGLAndroid() noexcept;
|
||||
~PlatformEGLAndroid() noexcept override;
|
||||
|
||||
protected:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// Platform Interface
|
||||
|
||||
/**
|
||||
* Returns the Android SDK version.
|
||||
* @return Android SDK version.
|
||||
*/
|
||||
int getOSVersion() const noexcept override;
|
||||
|
||||
Driver* createDriver(void* sharedContext,
|
||||
const Platform::DriverConfig& driverConfig) noexcept override;
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// OpenGLPlatform Interface
|
||||
|
||||
void terminate() noexcept override;
|
||||
|
||||
/**
|
||||
* Set the presentation time using `eglPresentationTimeANDROID`
|
||||
* @param presentationTimeInNanosecond
|
||||
*/
|
||||
void setPresentationTime(int64_t presentationTimeInNanosecond) noexcept override;
|
||||
|
||||
|
||||
Stream* createStream(void* nativeStream) noexcept override;
|
||||
void destroyStream(Stream* stream) noexcept override;
|
||||
void attach(Stream* stream, intptr_t tname) noexcept override;
|
||||
void detach(Stream* stream) noexcept override;
|
||||
void updateTexImage(Stream* stream, int64_t* timestamp) noexcept override;
|
||||
|
||||
/**
|
||||
* Converts a AHardwareBuffer to EGLImage
|
||||
* @param source source.image is a AHardwareBuffer
|
||||
* @return source.image contains an EGLImage
|
||||
*/
|
||||
AcquiredImage transformAcquiredImage(AcquiredImage source) noexcept override;
|
||||
|
||||
private:
|
||||
int mOSVersion;
|
||||
ExternalStreamManagerAndroid& mExternalStreamManager;
|
||||
};
|
||||
|
||||
} // namespace filament::backend
|
||||
|
||||
#endif // TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_EGL_ANDROID_H
|
||||
37
ios/include/backend/platforms/PlatformEGLHeadless.h
Normal file
37
ios/include/backend/platforms/PlatformEGLHeadless.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TNT_FILAMENT_DRIVER_OPENGL_PLATFORM_EGL_HEADLESS_H
|
||||
#define TNT_FILAMENT_DRIVER_OPENGL_PLATFORM_EGL_HEADLESS_H
|
||||
|
||||
#include "PlatformEGL.h"
|
||||
|
||||
namespace filament::backend {
|
||||
|
||||
/**
|
||||
* A concrete implementation of OpenGLPlatform that supports EGL with only headless swapchains.
|
||||
*/
|
||||
class PlatformEGLHeadless : public PlatformEGL {
|
||||
public:
|
||||
PlatformEGLHeadless() noexcept;
|
||||
|
||||
Driver* createDriver(void* sharedContext,
|
||||
const Platform::DriverConfig& driverConfig) noexcept override;
|
||||
};
|
||||
|
||||
} // namespace filament
|
||||
|
||||
#endif // TNT_FILAMENT_DRIVER_OPENGL_PLATFORM_EGL_HEADLESS_H
|
||||
67
ios/include/backend/platforms/PlatformGLX.h
Normal file
67
ios/include/backend/platforms/PlatformGLX.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_GLX_H
|
||||
#define TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_GLX_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bluegl/BlueGL.h"
|
||||
#include <GL/glx.h>
|
||||
|
||||
#include <backend/platforms/OpenGLPlatform.h>
|
||||
|
||||
#include <backend/DriverEnums.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace filament::backend {
|
||||
|
||||
/**
|
||||
* A concrete implementation of OpenGLPlatform that supports GLX.
|
||||
*/
|
||||
class PlatformGLX : public OpenGLPlatform {
|
||||
protected:
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// Platform Interface
|
||||
|
||||
Driver* createDriver(void* sharedGLContext,
|
||||
const DriverConfig& driverConfig) noexcept override;
|
||||
|
||||
int getOSVersion() const noexcept final override { return 0; }
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// OpenGLPlatform Interface
|
||||
|
||||
void terminate() noexcept override;
|
||||
|
||||
SwapChain* createSwapChain(void* nativewindow, uint64_t flags) noexcept override;
|
||||
SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t flags) noexcept override;
|
||||
void destroySwapChain(SwapChain* swapChain) noexcept override;
|
||||
void makeCurrent(SwapChain* drawSwapChain, SwapChain* readSwapChain) noexcept override;
|
||||
void commit(SwapChain* swapChain) noexcept override;
|
||||
|
||||
private:
|
||||
Display *mGLXDisplay;
|
||||
GLXContext mGLXContext;
|
||||
GLXFBConfig* mGLXConfig;
|
||||
GLXPbuffer mDummySurface;
|
||||
std::vector<GLXPbuffer> mPBuffers;
|
||||
};
|
||||
|
||||
} // namespace filament::backend
|
||||
|
||||
#endif // TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_GLX_H
|
||||
64
ios/include/backend/platforms/PlatformWGL.h
Normal file
64
ios/include/backend/platforms/PlatformWGL.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_WGL_H
|
||||
#define TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_WGL_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <windows.h>
|
||||
#include "utils/unwindows.h"
|
||||
|
||||
#include <backend/platforms/OpenGLPlatform.h>
|
||||
|
||||
#include <backend/DriverEnums.h>
|
||||
|
||||
namespace filament::backend {
|
||||
|
||||
/**
|
||||
* A concrete implementation of OpenGLPlatform that supports WGL.
|
||||
*/
|
||||
class PlatformWGL : public OpenGLPlatform {
|
||||
protected:
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// Platform Interface
|
||||
|
||||
Driver* createDriver(void* sharedGLContext,
|
||||
const Platform::DriverConfig& driverConfig) noexcept override;
|
||||
|
||||
int getOSVersion() const noexcept final override { return 0; }
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// OpenGLPlatform Interface
|
||||
|
||||
void terminate() noexcept override;
|
||||
|
||||
SwapChain* createSwapChain(void* nativewindow, uint64_t flags) noexcept override;
|
||||
SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t flags) noexcept override;
|
||||
void destroySwapChain(SwapChain* swapChain) noexcept override;
|
||||
void makeCurrent(SwapChain* drawSwapChain, SwapChain* readSwapChain) noexcept override;
|
||||
void commit(SwapChain* swapChain) noexcept override;
|
||||
|
||||
protected:
|
||||
HGLRC mContext = NULL;
|
||||
HWND mHWnd = NULL;
|
||||
HDC mWhdc = NULL;
|
||||
PIXELFORMATDESCRIPTOR mPfd = {};
|
||||
};
|
||||
|
||||
} // namespace filament::backend
|
||||
|
||||
#endif // TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_GLX_H
|
||||
55
ios/include/backend/platforms/PlatformWebGL.h
Normal file
55
ios/include/backend/platforms/PlatformWebGL.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_WEBGL_H
|
||||
#define TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_WEBGL_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <backend/platforms/OpenGLPlatform.h>
|
||||
|
||||
#include <backend/DriverEnums.h>
|
||||
|
||||
namespace filament::backend {
|
||||
|
||||
/**
|
||||
* A concrete implementation of OpenGLPlatform that supports WebGL.
|
||||
*/
|
||||
class PlatformWebGL : public OpenGLPlatform {
|
||||
protected:
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// Platform Interface
|
||||
|
||||
Driver* createDriver(void* sharedGLContext,
|
||||
const Platform::DriverConfig& driverConfig) noexcept override;
|
||||
|
||||
int getOSVersion() const noexcept override;
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// OpenGLPlatform Interface
|
||||
|
||||
void terminate() noexcept override;
|
||||
|
||||
SwapChain* createSwapChain(void* nativewindow, uint64_t flags) noexcept override;
|
||||
SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t flags) noexcept override;
|
||||
void destroySwapChain(SwapChain* swapChain) noexcept override;
|
||||
void makeCurrent(SwapChain* drawSwapChain, SwapChain* readSwapChain) noexcept override;
|
||||
void commit(SwapChain* swapChain) noexcept override;
|
||||
};
|
||||
|
||||
} // namespace filament::backend
|
||||
|
||||
#endif // TNT_FILAMENT_BACKEND_OPENGL_OPENGL_PLATFORM_WEBGL_H
|
||||
49
ios/include/backend/platforms/VulkanPlatform.h
Normal file
49
ios/include/backend/platforms/VulkanPlatform.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TNT_FILAMENT_BACKEND_PLATFORMS_VULKANPLATFORM_H
|
||||
#define TNT_FILAMENT_BACKEND_PLATFORMS_VULKANPLATFORM_H
|
||||
|
||||
#include <backend/Platform.h>
|
||||
|
||||
namespace filament::backend {
|
||||
|
||||
/**
|
||||
* A Platform interface that creates a Vulkan backend.
|
||||
*/
|
||||
|
||||
class VulkanPlatform : public Platform {
|
||||
public:
|
||||
struct SurfaceBundle {
|
||||
void* surface;
|
||||
// On certain platforms, the extent of the surface cannot be queried from Vulkan. In those
|
||||
// situations, we allow the frontend to pass in the extent to use in creating the swap
|
||||
// chains. Platform implementation should set extent to 0 if they do not expect to set the
|
||||
// swap chain extent.
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
};
|
||||
|
||||
// Given a Vulkan instance and native window handle, creates the platform-specific surface.
|
||||
virtual SurfaceBundle createVkSurfaceKHR(void* nativeWindow, void* instance,
|
||||
uint64_t flags) noexcept = 0;
|
||||
|
||||
~VulkanPlatform() override;
|
||||
};
|
||||
|
||||
} // namespace filament::backend
|
||||
|
||||
#endif //TNT_FILAMENT_BACKEND_PLATFORMS_VULKANPLATFORM_H
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <math/vec3.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -20,8 +20,7 @@
|
||||
#include <math/vec2.h>
|
||||
#include <math/vec3.h>
|
||||
|
||||
namespace filament {
|
||||
namespace color {
|
||||
namespace filament::color {
|
||||
|
||||
using namespace math;
|
||||
|
||||
@@ -35,7 +34,7 @@ struct Primaries {
|
||||
float2 b;
|
||||
|
||||
bool operator==(const Primaries& rhs) const noexcept {
|
||||
return r == rhs.r && b == rhs.b && g == rhs.b;
|
||||
return r == rhs.r && b == rhs.b && g == rhs.g;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -197,8 +196,8 @@ private:
|
||||
*/
|
||||
class PartialColorSpace {
|
||||
public:
|
||||
constexpr ColorSpace operator-(const WhitePoint whitePoint) const {
|
||||
return ColorSpace(mPrimaries, mTransferFunction, whitePoint);
|
||||
constexpr ColorSpace operator-(const WhitePoint& whitePoint) const {
|
||||
return { mPrimaries, mTransferFunction, whitePoint };
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -222,14 +221,14 @@ private:
|
||||
*/
|
||||
class Gamut {
|
||||
public:
|
||||
constexpr Gamut(const Primaries primaries) : mPrimaries(primaries) {
|
||||
constexpr explicit Gamut(const Primaries primaries) : mPrimaries(primaries) {
|
||||
}
|
||||
|
||||
constexpr Gamut(float2 r, float2 g, float2 b) : Gamut(Primaries{r, g, b}) {
|
||||
constexpr Gamut(float2 r, float2 g, float2 b) : Gamut(Primaries{ r, g, b }) {
|
||||
}
|
||||
|
||||
constexpr PartialColorSpace operator-(const TransferFunction transferFunction) const {
|
||||
return PartialColorSpace(mPrimaries, transferFunction);
|
||||
constexpr PartialColorSpace operator-(const TransferFunction& transferFunction) const {
|
||||
return { mPrimaries, transferFunction };
|
||||
}
|
||||
|
||||
constexpr const Primaries& getPrimaries() const { return mPrimaries; }
|
||||
@@ -239,18 +238,19 @@ private:
|
||||
};
|
||||
|
||||
//! Rec.709 color gamut, used in the sRGB and DisplayP3 color spaces.
|
||||
constexpr Gamut Rec709 = Gamut({0.640f, 0.330f}, {0.300f, 0.600f}, {0.150f, 0.060f});
|
||||
constexpr Gamut Rec709 = {{ 0.640f, 0.330f },
|
||||
{ 0.300f, 0.600f },
|
||||
{ 0.150f, 0.060f }};
|
||||
|
||||
//! Linear transfer function.
|
||||
constexpr TransferFunction Linear = TransferFunction(1.0, 0.0, 0.0, 0.0, 1.0);
|
||||
constexpr TransferFunction Linear = { 1.0, 0.0, 0.0, 0.0, 1.0 };
|
||||
|
||||
//! sRGB transfer function.
|
||||
constexpr TransferFunction sRGB =
|
||||
TransferFunction(1.0 / 1.055, 0.055 / 1.055, 1.0 / 12.92, 0.04045, 2.4);
|
||||
constexpr TransferFunction sRGB = { 1.0 / 1.055, 0.055 / 1.055, 1.0 / 12.92, 0.04045, 2.4 };
|
||||
|
||||
//! Standard CIE 1931 2° illuminant D65. This illuminant has a color temperature of 6504K.
|
||||
constexpr WhitePoint D65 = WhitePoint({0.31271f, 0.32902f});
|
||||
constexpr WhitePoint D65 = { 0.31271f, 0.32902f };
|
||||
|
||||
} // namespace color
|
||||
} // namespace filament
|
||||
} // namespace filament::color
|
||||
|
||||
#endif // TNT_FILAMENT_COLOR_SPACE_H
|
||||
|
||||
@@ -206,20 +206,44 @@ public:
|
||||
*
|
||||
* In general Filament reserves the right to re-order renderables to allow for efficient
|
||||
* rendering. However clients can control ordering at a coarse level using \em priority.
|
||||
* The priority is applied separately for opaque and translucent objects, that is, opaque
|
||||
* objects are always drawn before translucent objects regardless of the priority.
|
||||
*
|
||||
* For example, this could be used to draw a semitransparent HUD, if a client wishes to
|
||||
* avoid using a separate View for the HUD. Note that priority is completely orthogonal to
|
||||
* For example, this could be used to draw a semitransparent HUD on top of everything,
|
||||
* without using a separate View. Note that priority is completely orthogonal to
|
||||
* Builder::layerMask, which merely controls visibility.
|
||||
*
|
||||
* The Skybox always using the lowest priority, so it's drawn last, which may improve
|
||||
* performance.
|
||||
*
|
||||
* @param priority clamped to the range [0..7], defaults to 4; 7 is lowest priority
|
||||
* (rendered last).
|
||||
*
|
||||
* @return Builder reference for chaining calls.
|
||||
*
|
||||
* @see Builder::blendOrder(), RenderableManager::setBlendOrderAt()
|
||||
* @see Builder::blendOrder()
|
||||
* @see Builder::channel()
|
||||
* @see RenderableManager::setPriority()
|
||||
* @see RenderableManager::setBlendOrderAt()
|
||||
*/
|
||||
Builder& priority(uint8_t priority) noexcept;
|
||||
|
||||
/**
|
||||
* Set the channel this renderable is associated to. There can be 4 channels.
|
||||
* All renderables in a given channel are rendered together, regardless of anything else.
|
||||
* They are sorted as usual withing a channel.
|
||||
* Channels work similarly to priorities, except that they enforce the strongest ordering.
|
||||
*
|
||||
* @param channel clamped to the range [0..3], defaults to 0.
|
||||
*
|
||||
* @return Builder reference for chaining calls.
|
||||
*
|
||||
* @see Builder::blendOrder()
|
||||
* @see Builder::priority()
|
||||
* @see RenderableManager::setBlendOrderAt()
|
||||
*/
|
||||
Builder& channel(uint8_t channel) noexcept;
|
||||
|
||||
/**
|
||||
* Controls frustum culling, true by default.
|
||||
*
|
||||
@@ -461,6 +485,13 @@ public:
|
||||
*/
|
||||
void setPriority(Instance instance, uint8_t priority) noexcept;
|
||||
|
||||
/**
|
||||
* Changes the channel a renderable is associated to.
|
||||
*
|
||||
* \see Builder::channel().
|
||||
*/
|
||||
void setChannel(Instance instance, uint8_t channel) noexcept;
|
||||
|
||||
/**
|
||||
* Changes whether or not frustum culling is on.
|
||||
*
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
namespace filament {
|
||||
|
||||
class Engine;
|
||||
|
||||
/**
|
||||
* A swap chain represents an Operating System's *native* renderable surface.
|
||||
*
|
||||
@@ -148,7 +150,11 @@ public:
|
||||
using FrameScheduledCallback = backend::FrameScheduledCallback;
|
||||
using FrameCompletedCallback = backend::FrameCompletedCallback;
|
||||
|
||||
/**
|
||||
* Requests a SwapChain with an alpha channel.
|
||||
*/
|
||||
static const uint64_t CONFIG_TRANSPARENT = backend::SWAP_CHAIN_CONFIG_TRANSPARENT;
|
||||
|
||||
/**
|
||||
* This flag indicates that the swap chain may be used as a source surface
|
||||
* for reading back render results. This config must be set when creating
|
||||
@@ -178,6 +184,29 @@ public:
|
||||
static const uint64_t CONFIG_APPLE_CVPIXELBUFFER =
|
||||
backend::SWAP_CHAIN_CONFIG_APPLE_CVPIXELBUFFER;
|
||||
|
||||
/**
|
||||
* Indicates that the SwapChain must automatically perform linear to sRGB encoding.
|
||||
*
|
||||
* This flag is ignored if isSRGBSwapChainSupported() is false.
|
||||
*
|
||||
* When using this flag, the output colorspace in ColorGrading should be set to
|
||||
* Rec709-Linear-D65, or post-processing should be disabled.
|
||||
*
|
||||
* @see isSRGBSwapChainSupported()
|
||||
* @see ColorGrading.outputColorSpace()
|
||||
* @see View.setPostProcessingEnabled()
|
||||
*/
|
||||
static constexpr uint64_t CONFIG_SRGB_COLORSPACE = backend::SWAP_CHAIN_CONFIG_SRGB_COLORSPACE;
|
||||
|
||||
/**
|
||||
* Return whether createSwapChain supports the SWAP_CHAIN_CONFIG_SRGB_COLORSPACE flag.
|
||||
* The default implementation returns false.
|
||||
*
|
||||
* @param engine A pointer to the filament Engine
|
||||
* @return true if SWAP_CHAIN_CONFIG_SRGB_COLORSPACE is supported, false otherwise.
|
||||
*/
|
||||
static bool isSRGBSwapChainSupported(Engine& engine) noexcept;
|
||||
|
||||
void* getNativeWindow() const noexcept;
|
||||
|
||||
/**
|
||||
|
||||
336
ios/include/geometry/TangentSpaceMesh.h
Normal file
336
ios/include/geometry/TangentSpaceMesh.h
Normal file
@@ -0,0 +1,336 @@
|
||||
/*
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TNT_GEOMETRY_TANGENTSPACEMESH_H
|
||||
#define TNT_GEOMETRY_TANGENTSPACEMESH_H
|
||||
|
||||
#include <math/quat.h>
|
||||
#include <math/vec3.h>
|
||||
#include <math/vec4.h>
|
||||
#include <utils/compiler.h>
|
||||
|
||||
namespace filament {
|
||||
namespace geometry {
|
||||
|
||||
struct TangentSpaceMeshInput;
|
||||
struct TangentSpaceMeshOutput;
|
||||
|
||||
/* WARNING: WORK-IN-PROGRESS, PLEASE DO NOT USE */
|
||||
/**
|
||||
* This class builds Filament-style TANGENTS buffers given an input mesh.
|
||||
*
|
||||
* This class enables the client to chose between several algorithms. The client can retrieve the
|
||||
* result through the `get` methods on the class. If the chosen algorithm did not remesh the input,
|
||||
* the client is advised to just use the data they provided instead of querying. For example, if
|
||||
* the chosen method is Algorithm::FRISVAD, then the client should not need to call getPositions().
|
||||
* We will simply copy from the input `positions` in that case.
|
||||
*
|
||||
* If the client calls getPositions() and positions were not provided as input, we will throw
|
||||
* and exception. Similar behavior will apply to UVs.
|
||||
*
|
||||
* This class supersedes the implementation in SurfaceOrientation.h
|
||||
*/
|
||||
class TangentSpaceMesh {
|
||||
public:
|
||||
enum class Algorithm : uint8_t {
|
||||
/**
|
||||
* default
|
||||
*
|
||||
* Tries to select the best possible algorithm given the input. The corresponding algorithms
|
||||
* are detailed in the corresponding enums.
|
||||
* <pre>
|
||||
* INPUT ALGORITHM
|
||||
* -----------------------------------------------------------
|
||||
* normals FRISVAD
|
||||
* positions + indices FLAT_SHADING
|
||||
* normals + uvs + positions + indices MIKKTSPACE
|
||||
* </pre>
|
||||
*/
|
||||
DEFAULT = 0,
|
||||
|
||||
/**
|
||||
* mikktspace
|
||||
*
|
||||
* **Requires**: `normals + uvs + positions + indices` <br/>
|
||||
* **Reference**:
|
||||
* - Mikkelsen, M., 2008. Simulation of wrinkled surfaces revisited.
|
||||
* - https://github.com/mmikk/MikkTSpace
|
||||
* - https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#meshes-overview
|
||||
*
|
||||
* **Note**: Will remesh
|
||||
*/
|
||||
MIKKTSPACE = 1,
|
||||
|
||||
/**
|
||||
* Lengyel's method
|
||||
*
|
||||
* **Requires**: `normals + uvs + positions + indices` <br/>
|
||||
* **Reference**: Lengyel, E., 2019. Foundations of Game Engine Development: Rendering. Terathon
|
||||
* Software LLC.. (Chapter 7)
|
||||
*/
|
||||
LENGYEL = 2,
|
||||
|
||||
/**
|
||||
* Hughes-Moller method
|
||||
*
|
||||
* **Requires**: `normals` <br/>
|
||||
* **Reference**:
|
||||
* - Hughes, J.F. and Moller, T., 1999. Building an orthonormal basis from a unit
|
||||
* vector. journal of graphics tools, 4(4), pp.33-35.
|
||||
* - Parker, S.G., Bigler, J., Dietrich, A., Friedrich, H., Hoberock, J., Luebke, D.,
|
||||
* McAllister, D., McGuire, M., Morley, K., Robison, A. and Stich, M., 2010.
|
||||
* Optix: a general purpose ray tracing engine. Acm transactions on graphics (tog),
|
||||
* 29(4), pp.1-13.
|
||||
* **Note**: We implement the Optix variant, which is documented in the second reference above.
|
||||
*/
|
||||
HUGHES_MOLLER = 3,
|
||||
|
||||
/**
|
||||
* Frisvad's method
|
||||
*
|
||||
* **Requires**: `normals` <br/>
|
||||
* **Reference**:
|
||||
* - Frisvad, J.R., 2012. Building an orthonormal basis from a 3D unit vector without
|
||||
* normalization. Journal of Graphics Tools, 16(3), pp.151-159.
|
||||
* - http://people.compute.dtu.dk/jerf/code/hairy/
|
||||
*/
|
||||
FRISVAD = 4,
|
||||
|
||||
/**
|
||||
* Flat Shading
|
||||
*
|
||||
* **Requires**: `positions + indices` <br/>
|
||||
* **Note**: Will remesh
|
||||
*/
|
||||
FLAT_SHADING = 5
|
||||
};
|
||||
|
||||
/**
|
||||
* Use this class to provide input to the TangentSpaceMesh computation. **Important**:
|
||||
* Computation of the tangent space is intended to be synchronous (working on the same thread).
|
||||
* Client is expected to keep the input immutable and in a good state for the duration of both
|
||||
* computation *and* query. That is, when querying the result of the tangent spaces, part of the
|
||||
* result might depend on the input data.
|
||||
*/
|
||||
class Builder {
|
||||
public:
|
||||
Builder() noexcept;
|
||||
~Builder() noexcept;
|
||||
|
||||
/**
|
||||
* Move constructor
|
||||
*/
|
||||
Builder(Builder&& that) noexcept;
|
||||
|
||||
/**
|
||||
* Move constructor
|
||||
*/
|
||||
Builder& operator=(Builder&& that) noexcept;
|
||||
|
||||
Builder(const Builder&) = delete;
|
||||
Builder& operator=(const Builder&) = delete;
|
||||
|
||||
/**
|
||||
* Client must provide this parameter
|
||||
*
|
||||
* @param vertexCount The input number of vertcies
|
||||
*/
|
||||
Builder& vertexCount(size_t vertexCount) noexcept;
|
||||
|
||||
/**
|
||||
* @param normals The input normals
|
||||
* @param stride The stride for iterating through `normals`
|
||||
* @return Builder
|
||||
*/
|
||||
Builder& normals(const filament::math::float3* normals, size_t stride = 0) noexcept;
|
||||
|
||||
/**
|
||||
* @param tangents The input tangents. The `w` component is for use with
|
||||
* Algorithm::SIGN_OF_W.
|
||||
* @param stride The stride for iterating through `tangents`
|
||||
* @return Builder
|
||||
*/
|
||||
Builder& tangents(const filament::math::float4* tangents, size_t stride = 0) noexcept;
|
||||
|
||||
/**
|
||||
* @param uvs The input uvs
|
||||
* @param stride The stride for iterating through `uvs`
|
||||
* @return Builder
|
||||
*/
|
||||
Builder& uvs(const filament::math::float2* uvs, size_t stride = 0) noexcept;
|
||||
|
||||
/**
|
||||
* @param positions The input positions
|
||||
* @param stride The stride for iterating through `positions`
|
||||
* @return Builder
|
||||
*/
|
||||
Builder& positions(const filament::math::float3* positions, size_t stride = 0) noexcept;
|
||||
|
||||
Builder& triangleCount(size_t triangleCount) noexcept;
|
||||
Builder& triangles(const filament::math::uint3* triangles) noexcept;
|
||||
Builder& triangles(const filament::math::ushort3* triangles) noexcept;
|
||||
|
||||
Builder& algorithm(Algorithm algorithm) noexcept;
|
||||
|
||||
/**
|
||||
* Computes the tangent space mesh. The resulting mesh object is owned by the callee. The
|
||||
* callee must call TangentSpaceMesh::destroy on the object once they are finished with it.
|
||||
*
|
||||
* The state of the Builder will be reset after each call to build(). The client needs to
|
||||
* populate the builder with parameters again if they choose to re-use it.
|
||||
*
|
||||
* @return A TangentSpaceMesh
|
||||
*/
|
||||
TangentSpaceMesh* build();
|
||||
|
||||
private:
|
||||
TangentSpaceMesh* mMesh = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
* Destory the mesh object
|
||||
* @param mesh A pointer to a TangentSpaceMesh ready to be destroyed
|
||||
*/
|
||||
static void destroy(TangentSpaceMesh* mesh) noexcept;
|
||||
|
||||
/**
|
||||
* Move constructor
|
||||
*/
|
||||
TangentSpaceMesh(TangentSpaceMesh&& that) noexcept;
|
||||
|
||||
/**
|
||||
* Move constructor
|
||||
*/
|
||||
TangentSpaceMesh& operator=(TangentSpaceMesh&& that) noexcept;
|
||||
|
||||
TangentSpaceMesh(const TangentSpaceMesh&) = delete;
|
||||
TangentSpaceMesh& operator=(const TangentSpaceMesh&) = delete;
|
||||
|
||||
/**
|
||||
* Number of output vertices
|
||||
*
|
||||
* The number of output vertices can be the same as the input if the selected algorithm did not
|
||||
* "remesh" the input.
|
||||
*
|
||||
* @return The number of vertices
|
||||
*/
|
||||
size_t getVertexCount() const noexcept;
|
||||
|
||||
/**
|
||||
* Get output vertex positions.
|
||||
* Assumes the `out` param is at least of getVertexCount() length (while accounting for
|
||||
* `stride`). The output vertices can be the same as the input if the selected algorithm did
|
||||
* not "remesh" the input. The remeshed vertices are not guarranteed to have correlation in
|
||||
* order with the input mesh.
|
||||
*
|
||||
* @param out Client-allocated array that will be used for copying out positions.
|
||||
* @param stride Stride for iterating through `out`
|
||||
*/
|
||||
void getPositions(filament::math::float3* out, size_t stride = 0) const;
|
||||
|
||||
/**
|
||||
* Get output UVs.
|
||||
* Assumes the `out` param is at least of getVertexCount() length (while accounting for
|
||||
* `stride`). The output uvs can be the same as the input if the selected algorithm did
|
||||
* not "remesh" the input. The remeshed UVs are not guarranteed to have correlation in order
|
||||
* with the input mesh.
|
||||
*
|
||||
* @param out Client-allocated array that will be used for copying out UVs.
|
||||
* @param stride Stride for iterating through `out`
|
||||
*/
|
||||
void getUVs(filament::math::float2* out, size_t stride = 0) const;
|
||||
|
||||
/**
|
||||
* Get output tangent space.
|
||||
* Assumes the `out` param is at least of getVertexCount() length (while accounting for
|
||||
* `stride`).
|
||||
*
|
||||
* @param out Client-allocated array that will be used for copying out tangent space in
|
||||
* 32-bit floating points.
|
||||
* @param stride Stride for iterating through `out`
|
||||
*/
|
||||
void getQuats(filament::math::quatf* out, size_t stride = 0) const noexcept;
|
||||
|
||||
/**
|
||||
* Get output tangent space.
|
||||
* Assumes the `out` param is at least of getVertexCount() length (while accounting for
|
||||
* `stride`).
|
||||
*
|
||||
* @param out Client-allocated array that will be used for copying out tangent space in
|
||||
* 16-bit signed integers.
|
||||
* @param stride Stride for iterating through `out`
|
||||
*/
|
||||
void getQuats(filament::math::short4* out, size_t stride = 0) const noexcept;
|
||||
|
||||
/**
|
||||
* Get output tangent space.
|
||||
* Assumes the `out` param is at least of getVertexCount() length (while accounting for
|
||||
* `stride`).
|
||||
*
|
||||
* @param out Client-allocated array that will be used for copying out tangent space in
|
||||
* 16-bit floating points.
|
||||
* @param stride Stride for iterating through `out`
|
||||
*/
|
||||
void getQuats(filament::math::quath* out, size_t stride = 0) const noexcept;
|
||||
|
||||
/**
|
||||
* Get number of output triangles.
|
||||
* The number of output triangles is the same as the number of input triangles. However, when a
|
||||
* "remesh" is carried out the output triangles are not guarranteed to have any correlation with
|
||||
* the input.
|
||||
*
|
||||
* @return The number of vertices
|
||||
*/
|
||||
size_t getTriangleCount() const noexcept;
|
||||
|
||||
/**
|
||||
* Get output triangles.
|
||||
* This method assumes that the `out` param provided by the client is at least of
|
||||
* getTriangleCount() length. If the client calls getTriangles() and triangles were not
|
||||
* provided as input, we will throw and exception.
|
||||
*
|
||||
* @param out Client's array for the output triangles in unsigned 32-bit indices.
|
||||
*/
|
||||
void getTriangles(filament::math::uint3* out) const;
|
||||
|
||||
/**
|
||||
* Get output triangles.
|
||||
* This method assumes that the `out` param provided by the client is at least of
|
||||
* getTriangleCount() length. If the client calls getTriangles() and triangles were not
|
||||
* provided as input, we will throw and exception.
|
||||
*
|
||||
* @param out Client's array for the output triangles in unsigned 16-bit indices.
|
||||
*/
|
||||
void getTriangles(filament::math::ushort3* out) const;
|
||||
|
||||
/**
|
||||
* @return The algorithm used to compute the output mesh.
|
||||
*/
|
||||
Algorithm getAlgorithm() const noexcept;
|
||||
|
||||
private:
|
||||
~TangentSpaceMesh() noexcept;
|
||||
TangentSpaceMesh() noexcept;
|
||||
TangentSpaceMeshInput* mInput;
|
||||
TangentSpaceMeshOutput* mOutput;
|
||||
|
||||
friend class Builder;
|
||||
};
|
||||
|
||||
} // namespace geometry
|
||||
} // namespace filament
|
||||
|
||||
#endif //TNT_GEOMETRY_TANGENTSPACEMESH_H
|
||||
12
ios/include/material/unlit_opaque.S
Normal file
12
ios/include/material/unlit_opaque.S
Normal file
@@ -0,0 +1,12 @@
|
||||
.global UNLIT_OPAQUE_UNLIT_OFFSET;
|
||||
.global UNLIT_OPAQUE_UNLIT_SIZE;
|
||||
|
||||
.global UNLIT_OPAQUE_PACKAGE
|
||||
.section .rodata
|
||||
UNLIT_OPAQUE_PACKAGE:
|
||||
.incbin "unlit_opaque.bin"
|
||||
UNLIT_OPAQUE_UNLIT_OFFSET:
|
||||
.int 0
|
||||
UNLIT_OPAQUE_UNLIT_SIZE:
|
||||
.int 34077
|
||||
|
||||
12
ios/include/material/unlit_opaque.apple.S
Normal file
12
ios/include/material/unlit_opaque.apple.S
Normal file
@@ -0,0 +1,12 @@
|
||||
.global _UNLIT_OPAQUE_UNLIT_OFFSET;
|
||||
.global _UNLIT_OPAQUE_UNLIT_SIZE;
|
||||
|
||||
.global _UNLIT_OPAQUE_PACKAGE
|
||||
.section __TEXT,__const
|
||||
_UNLIT_OPAQUE_PACKAGE:
|
||||
.incbin "unlit_opaque.bin"
|
||||
_UNLIT_OPAQUE_UNLIT_OFFSET:
|
||||
.int 0
|
||||
_UNLIT_OPAQUE_UNLIT_SIZE:
|
||||
.int 34077
|
||||
|
||||
BIN
ios/include/material/unlit_opaque.bin
Normal file
BIN
ios/include/material/unlit_opaque.bin
Normal file
Binary file not shown.
1713
ios/include/material/unlit_opaque.c
Normal file
1713
ios/include/material/unlit_opaque.c
Normal file
File diff suppressed because it is too large
Load Diff
BIN
ios/include/material/unlit_opaque.filamat
Normal file
BIN
ios/include/material/unlit_opaque.filamat
Normal file
Binary file not shown.
13
ios/include/material/unlit_opaque.h
Normal file
13
ios/include/material/unlit_opaque.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef UNLIT_OPAQUE_H_
|
||||
#define UNLIT_OPAQUE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern "C" {
|
||||
extern const uint8_t UNLIT_OPAQUE_PACKAGE[];
|
||||
extern int UNLIT_OPAQUE_UNLIT_OFFSET;
|
||||
extern int UNLIT_OPAQUE_UNLIT_SIZE;
|
||||
}
|
||||
#define UNLIT_OPAQUE_UNLIT_DATA (UNLIT_OPAQUE_PACKAGE + UNLIT_OPAQUE_UNLIT_OFFSET)
|
||||
|
||||
#endif
|
||||
@@ -1,12 +0,0 @@
|
||||
.global UNLITOPAQUE_UNLIT_OPAQUE_OFFSET;
|
||||
.global UNLITOPAQUE_UNLIT_OPAQUE_SIZE;
|
||||
|
||||
.global UNLITOPAQUE_PACKAGE
|
||||
.section .rodata
|
||||
UNLITOPAQUE_PACKAGE:
|
||||
.incbin "unlitopaque.bin"
|
||||
UNLITOPAQUE_UNLIT_OPAQUE_OFFSET:
|
||||
.int 0
|
||||
UNLITOPAQUE_UNLIT_OPAQUE_SIZE:
|
||||
.int 35615
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
.global _UNLITOPAQUE_UNLIT_OPAQUE_OFFSET;
|
||||
.global _UNLITOPAQUE_UNLIT_OPAQUE_SIZE;
|
||||
|
||||
.global _UNLITOPAQUE_PACKAGE
|
||||
.section __TEXT,__const
|
||||
_UNLITOPAQUE_PACKAGE:
|
||||
.incbin "unlitopaque.bin"
|
||||
_UNLITOPAQUE_UNLIT_OPAQUE_OFFSET:
|
||||
.int 0
|
||||
_UNLITOPAQUE_UNLIT_OPAQUE_SIZE:
|
||||
.int 35615
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -1,13 +0,0 @@
|
||||
#ifndef UNLITOPAQUE_H_
|
||||
#define UNLITOPAQUE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern "C" {
|
||||
extern const uint8_t UNLITOPAQUE_PACKAGE[];
|
||||
extern int UNLITOPAQUE_UNLIT_OPAQUE_OFFSET;
|
||||
extern int UNLITOPAQUE_UNLIT_OPAQUE_SIZE;
|
||||
}
|
||||
#define UNLITOPAQUE_UNLIT_OPAQUE_DATA (UNLITOPAQUE_PACKAGE + UNLITOPAQUE_UNLIT_OPAQUE_OFFSET)
|
||||
|
||||
#endif
|
||||
@@ -23,38 +23,36 @@
|
||||
# define MATHIO_PUBLIC
|
||||
#endif
|
||||
|
||||
namespace filament {
|
||||
namespace math {
|
||||
namespace filament::math::details {
|
||||
|
||||
namespace details { template<typename T> class TQuaternion; }
|
||||
template<typename T> class TQuaternion;
|
||||
|
||||
template<typename T>
|
||||
MATHIO_PUBLIC
|
||||
std::ostream& operator<<(std::ostream& out, const details::TVec2<T>& v) noexcept;
|
||||
std::ostream& operator<<(std::ostream& out, const TVec2<T>& v) noexcept;
|
||||
|
||||
template<typename T>
|
||||
MATHIO_PUBLIC
|
||||
std::ostream& operator<<(std::ostream& out, const details::TVec3<T>& v) noexcept;
|
||||
std::ostream& operator<<(std::ostream& out, const TVec3<T>& v) noexcept;
|
||||
|
||||
template<typename T>
|
||||
MATHIO_PUBLIC
|
||||
std::ostream& operator<<(std::ostream& out, const details::TVec4<T>& v) noexcept;
|
||||
std::ostream& operator<<(std::ostream& out, const TVec4<T>& v) noexcept;
|
||||
|
||||
template<typename T>
|
||||
MATHIO_PUBLIC
|
||||
std::ostream& operator<<(std::ostream& out, const details::TMat22<T>& v) noexcept;
|
||||
std::ostream& operator<<(std::ostream& out, const TMat22<T>& v) noexcept;
|
||||
|
||||
template<typename T>
|
||||
MATHIO_PUBLIC
|
||||
std::ostream& operator<<(std::ostream& out, const details::TMat33<T>& v) noexcept;
|
||||
std::ostream& operator<<(std::ostream& out, const TMat33<T>& v) noexcept;
|
||||
|
||||
template<typename T>
|
||||
MATHIO_PUBLIC
|
||||
std::ostream& operator<<(std::ostream& out, const details::TMat44<T>& v) noexcept;
|
||||
std::ostream& operator<<(std::ostream& out, const TMat44<T>& v) noexcept;
|
||||
|
||||
template<typename T>
|
||||
MATHIO_PUBLIC
|
||||
std::ostream& operator<<(std::ostream& out, const details::TQuaternion<T>& v) noexcept;
|
||||
std::ostream& operator<<(std::ostream& out, const TQuaternion<T>& v) noexcept;
|
||||
|
||||
} // namespace math
|
||||
} // namespace filament
|
||||
} // namespace filament::math::details
|
||||
|
||||
@@ -43,6 +43,13 @@ public:
|
||||
*/
|
||||
Path(const char* pathname);
|
||||
|
||||
/**
|
||||
* Creates a new path with the specified pathname.
|
||||
*
|
||||
* @param pathname a pathname string view
|
||||
*/
|
||||
Path(std::string_view pathname);
|
||||
|
||||
/**
|
||||
* Creates a new path with the specified pathname.
|
||||
*
|
||||
|
||||
@@ -26,8 +26,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array> // note: this is safe, see how std::array is used below (inline / private)
|
||||
#include <cstddef>
|
||||
#include <iterator> // for std::random_access_iterator_tag
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
namespace utils {
|
||||
@@ -42,7 +45,7 @@ public:
|
||||
|
||||
// Type of the Nth array
|
||||
template<size_t N>
|
||||
using TypeAt = typename std::tuple_element<N, std::tuple<Elements...>>::type;
|
||||
using TypeAt = typename std::tuple_element_t<N, std::tuple<Elements...>>;
|
||||
|
||||
// Number of arrays
|
||||
static constexpr size_t getArrayCount() noexcept { return kArrayCount; }
|
||||
@@ -228,7 +231,7 @@ public:
|
||||
using std::swap;
|
||||
swap(mCapacity, rhs.mCapacity);
|
||||
swap(mSize, rhs.mSize);
|
||||
swap(mArrayOffset, rhs.mArrayOffset);
|
||||
swap(mArrays, rhs.mArrays);
|
||||
swap(mAllocator, rhs.mAllocator);
|
||||
}
|
||||
|
||||
@@ -237,7 +240,7 @@ public:
|
||||
using std::swap;
|
||||
swap(mCapacity, rhs.mCapacity);
|
||||
swap(mSize, rhs.mSize);
|
||||
swap(mArrayOffset, rhs.mArrayOffset);
|
||||
swap(mArrays, rhs.mArrays);
|
||||
swap(mAllocator, rhs.mAllocator);
|
||||
}
|
||||
return *this;
|
||||
@@ -245,7 +248,7 @@ public:
|
||||
|
||||
~StructureOfArraysBase() {
|
||||
destroy_each(0, mSize);
|
||||
mAllocator.free(mArrayOffset[0]);
|
||||
mAllocator.free(std::get<0>(mArrays));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
@@ -271,14 +274,14 @@ public:
|
||||
constexpr size_t align = std::max({ std::max(alignof(std::max_align_t), alignof(Elements))... });
|
||||
const size_t sizeNeeded = getNeededSize(capacity);
|
||||
void* buffer = mAllocator.alloc(sizeNeeded, align);
|
||||
auto const oldBuffer = std::get<0>(mArrays);
|
||||
|
||||
// move all the items (one array at a time) from the old allocation to the new
|
||||
// this also update the array pointers
|
||||
move_each(buffer, capacity);
|
||||
|
||||
// free the old buffer
|
||||
std::swap(buffer, mArrayOffset[0]);
|
||||
mAllocator.free(buffer);
|
||||
mAllocator.free(oldBuffer);
|
||||
|
||||
// and make sure to update the capacity
|
||||
mCapacity = capacity;
|
||||
@@ -342,58 +345,66 @@ public:
|
||||
return push_back_unsafe(std::forward<Elements>(args)...);
|
||||
}
|
||||
|
||||
// in C++20 we could use a lambda with explicit template parameter instead
|
||||
struct PushBackUnsafeClosure {
|
||||
size_t last;
|
||||
std::tuple<Elements...> args;
|
||||
inline explicit PushBackUnsafeClosure(size_t last, Elements&& ... args)
|
||||
: last(last), args(std::forward<Elements>(args)...) {}
|
||||
inline explicit PushBackUnsafeClosure(size_t last, Elements const& ... args)
|
||||
: last(last), args(args...) {}
|
||||
template<size_t I>
|
||||
inline void operator()(TypeAt<I>* p) {
|
||||
new(p + last) TypeAt<I>{ std::get<I>(args) };
|
||||
}
|
||||
};
|
||||
|
||||
StructureOfArraysBase& push_back_unsafe(Elements const& ... args) noexcept {
|
||||
const size_t last = mSize++;
|
||||
size_t i = 0;
|
||||
int UTILS_UNUSED dummy[] = {
|
||||
(new(getArray<Elements>(i) + last)Elements(args), i++, 0)... };
|
||||
for_each_index(mArrays, PushBackUnsafeClosure{ mSize++, args... });
|
||||
return *this;
|
||||
}
|
||||
|
||||
StructureOfArraysBase& push_back_unsafe(Elements&& ... args) noexcept {
|
||||
const size_t last = mSize++;
|
||||
size_t i = 0;
|
||||
int UTILS_UNUSED dummy[] = {
|
||||
(new(getArray<Elements>(i) + last)Elements(std::forward<Elements>(args)), i++, 0)... };
|
||||
for_each_index(mArrays, PushBackUnsafeClosure{ mSize++, std::forward<Elements>(args)... });
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename F, typename ... ARGS>
|
||||
void forEach(F&& f, ARGS&& ... args) {
|
||||
size_t i = 0;
|
||||
int UTILS_UNUSED dummy[] = {
|
||||
(f(getArray<Elements>(i), std::forward<ARGS>(args)...), i++, 0)... };
|
||||
for_each(mArrays, [&](size_t, auto* p) {
|
||||
f(p, std::forward<ARGS>(args)...);
|
||||
});
|
||||
}
|
||||
|
||||
// return a pointer to the first element of the ElementIndex]th array
|
||||
template<size_t ElementIndex>
|
||||
TypeAt<ElementIndex>* data() noexcept {
|
||||
return getArray<TypeAt<ElementIndex>>(ElementIndex);
|
||||
return std::get<ElementIndex>(mArrays);
|
||||
}
|
||||
|
||||
template<size_t ElementIndex>
|
||||
TypeAt<ElementIndex> const* data() const noexcept {
|
||||
return getArray<TypeAt<ElementIndex>>(ElementIndex);
|
||||
return std::get<ElementIndex>(mArrays);
|
||||
}
|
||||
|
||||
template<size_t ElementIndex>
|
||||
TypeAt<ElementIndex>* begin() noexcept {
|
||||
return getArray<TypeAt<ElementIndex>>(ElementIndex);
|
||||
return std::get<ElementIndex>(mArrays);
|
||||
}
|
||||
|
||||
template<size_t ElementIndex>
|
||||
TypeAt<ElementIndex> const* begin() const noexcept {
|
||||
return getArray<TypeAt<ElementIndex>>(ElementIndex);
|
||||
return std::get<ElementIndex>(mArrays);
|
||||
}
|
||||
|
||||
template<size_t ElementIndex>
|
||||
TypeAt<ElementIndex>* end() noexcept {
|
||||
return getArray<TypeAt<ElementIndex>>(ElementIndex) + size();
|
||||
return std::get<ElementIndex>(mArrays) + size();
|
||||
}
|
||||
|
||||
template<size_t ElementIndex>
|
||||
TypeAt<ElementIndex> const* end() const noexcept {
|
||||
return getArray<TypeAt<ElementIndex>>(ElementIndex) + size();
|
||||
return std::get<ElementIndex>(mArrays) + size();
|
||||
}
|
||||
|
||||
template<size_t ElementIndex>
|
||||
@@ -486,14 +497,26 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
template<typename T>
|
||||
T const* getArray(size_t arrayIndex) const {
|
||||
return static_cast<T const*>(mArrayOffset[arrayIndex]);
|
||||
template<std::size_t I = 0, typename FuncT, typename... Tp>
|
||||
inline typename std::enable_if<I == sizeof...(Tp), void>::type
|
||||
for_each(std::tuple<Tp...>&, FuncT) {}
|
||||
|
||||
template<std::size_t I = 0, typename FuncT, typename... Tp>
|
||||
inline typename std::enable_if<I < sizeof...(Tp), void>::type
|
||||
for_each(std::tuple<Tp...>& t, FuncT f) {
|
||||
f(I, std::get<I>(t));
|
||||
for_each<I + 1, FuncT, Tp...>(t, f);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T* getArray(size_t arrayIndex) {
|
||||
return static_cast<T*>(mArrayOffset[arrayIndex]);
|
||||
template<std::size_t I = 0, typename FuncT, typename... Tp>
|
||||
inline typename std::enable_if<I == sizeof...(Tp), void>::type
|
||||
for_each_index(std::tuple<Tp...>&, FuncT) {}
|
||||
|
||||
template<std::size_t I = 0, typename FuncT, typename... Tp>
|
||||
inline typename std::enable_if<I < sizeof...(Tp), void>::type
|
||||
for_each_index(std::tuple<Tp...>& t, FuncT f) {
|
||||
f.template operator()<I>(std::get<I>(t));
|
||||
for_each_index<I + 1, FuncT, Tp...>(t, f);
|
||||
}
|
||||
|
||||
inline void resizeNoCheck(size_t needed) noexcept {
|
||||
@@ -584,10 +607,11 @@ private:
|
||||
});
|
||||
}
|
||||
|
||||
// update the pointers (the first offset will be filled later
|
||||
for (size_t i = 1; i < kArrayCount; i++) {
|
||||
mArrayOffset[i] = (char*)buffer + offsets[i];
|
||||
}
|
||||
// update the pointers
|
||||
for_each(mArrays, [buffer, &offsets](size_t i, auto&& p) {
|
||||
using Type = std::remove_reference_t<decltype(p)>;
|
||||
p = Type((char*)buffer + offsets[i]);
|
||||
});
|
||||
}
|
||||
|
||||
// capacity in array elements
|
||||
@@ -595,10 +619,11 @@ private:
|
||||
// size in array elements
|
||||
size_t mSize = 0;
|
||||
// N pointers to each arrays
|
||||
void *mArrayOffset[kArrayCount] = { nullptr };
|
||||
std::tuple<std::add_pointer_t<Elements>...> mArrays{};
|
||||
Allocator mAllocator;
|
||||
};
|
||||
|
||||
|
||||
template<typename Allocator, typename... Elements>
|
||||
inline
|
||||
typename StructureOfArraysBase<Allocator, Elements...>::StructureRef&
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <algorithm> // for std::fill
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
|
||||
#if defined(__ARM_NEON)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#define VIEWER_SETTINGS_H
|
||||
|
||||
#include <filament/ColorGrading.h>
|
||||
#include <filament/ColorSpace.h>
|
||||
#include <filament/IndirectLight.h>
|
||||
#include <filament/LightManager.h>
|
||||
#include <filament/MaterialInstance.h>
|
||||
@@ -36,6 +37,8 @@
|
||||
|
||||
namespace filament {
|
||||
|
||||
using namespace color;
|
||||
|
||||
class Skybox;
|
||||
class Renderer;
|
||||
|
||||
@@ -116,33 +119,38 @@ struct GenericToneMapperSettings {
|
||||
};
|
||||
|
||||
struct ColorGradingSettings {
|
||||
// fields are ordered to avoid padding
|
||||
bool enabled = true;
|
||||
filament::ColorGrading::QualityLevel quality = filament::ColorGrading::QualityLevel::MEDIUM;
|
||||
ToneMapping toneMapping = ToneMapping::ACES_LEGACY;
|
||||
GenericToneMapperSettings genericToneMapper;
|
||||
bool linkedCurves = false;
|
||||
bool luminanceScaling = false;
|
||||
bool gamutMapping = false;
|
||||
float exposure = 0.0f;
|
||||
float nightAdaptation = 0.0f;
|
||||
float temperature = 0.0f;
|
||||
float tint = 0.0f;
|
||||
math::float3 outRed{1.0f, 0.0f, 0.0f};
|
||||
math::float3 outGreen{0.0f, 1.0f, 0.0f};
|
||||
math::float3 outBlue{0.0f, 0.0f, 1.0f};
|
||||
filament::ColorGrading::QualityLevel quality = filament::ColorGrading::QualityLevel::MEDIUM;
|
||||
ToneMapping toneMapping = ToneMapping::ACES_LEGACY;
|
||||
bool padding0{};
|
||||
bool padding1{};
|
||||
color::ColorSpace colorspace = Rec709-sRGB-D65;
|
||||
GenericToneMapperSettings genericToneMapper;
|
||||
math::float4 shadows{1.0f, 1.0f, 1.0f, 0.0f};
|
||||
math::float4 midtones{1.0f, 1.0f, 1.0f, 0.0f};
|
||||
math::float4 highlights{1.0f, 1.0f, 1.0f, 0.0f};
|
||||
math::float4 ranges{0.0f, 0.333f, 0.550f, 1.0f};
|
||||
float contrast = 1.0f;
|
||||
float vibrance = 1.0f;
|
||||
float saturation = 1.0f;
|
||||
math::float3 outRed{1.0f, 0.0f, 0.0f};
|
||||
math::float3 outGreen{0.0f, 1.0f, 0.0f};
|
||||
math::float3 outBlue{0.0f, 0.0f, 1.0f};
|
||||
math::float3 slope{1.0f};
|
||||
math::float3 offset{0.0f};
|
||||
math::float3 power{1.0f};
|
||||
math::float3 gamma{1.0f};
|
||||
math::float3 midPoint{1.0f};
|
||||
math::float3 scale{1.0f};
|
||||
bool linkedCurves = false;
|
||||
float exposure = 0.0f;
|
||||
float nightAdaptation = 0.0f;
|
||||
float temperature = 0.0f;
|
||||
float tint = 0.0f;
|
||||
float contrast = 1.0f;
|
||||
float vibrance = 1.0f;
|
||||
float saturation = 1.0f;
|
||||
|
||||
bool operator!=(const ColorGradingSettings &rhs) const { return !(rhs == *this); }
|
||||
bool operator==(const ColorGradingSettings &rhs) const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user