Skip to content

Commit

Permalink
Rename IOS define to FILAMENT_IOS (#8340)
Browse files Browse the repository at this point in the history
  • Loading branch information
bejado authored Jan 8, 2025
1 parent f0b9a30 commit 863b134
Show file tree
Hide file tree
Showing 24 changed files with 50 additions and 50 deletions.
6 changes: 3 additions & 3 deletions filament/backend/src/PlatformFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#if defined(FILAMENT_SUPPORTS_OPENGL) && !defined(FILAMENT_USE_EXTERNAL_GLES3)
#include "backend/platforms/PlatformEGLAndroid.h"
#endif
#elif defined(IOS)
#elif defined(FILAMENT_IOS)
#if defined(FILAMENT_SUPPORTS_OPENGL) && !defined(FILAMENT_USE_EXTERNAL_GLES3)
#include "backend/platforms/PlatformCocoaTouchGL.h"
#endif
Expand Down Expand Up @@ -88,7 +88,7 @@ Platform* PlatformFactory::create(Backend* backend) noexcept {
*backend = Backend::OPENGL;
#elif defined(__ANDROID__)
*backend = Backend::OPENGL;
#elif defined(IOS) || defined(__APPLE__)
#elif defined(FILAMENT_IOS) || defined(__APPLE__)
*backend = Backend::METAL;
#elif defined(FILAMENT_DRIVER_SUPPORTS_VULKAN)
*backend = Backend::VULKAN;
Expand Down Expand Up @@ -119,7 +119,7 @@ Platform* PlatformFactory::create(Backend* backend) noexcept {
return nullptr;
#elif defined(__ANDROID__)
return new PlatformEGLAndroid();
#elif defined(IOS)
#elif defined(FILAMENT_IOS)
return new PlatformCocoaTouchGL();
#elif defined(__APPLE__)
return new PlatformCocoaGL();
Expand Down
2 changes: 1 addition & 1 deletion filament/backend/src/metal/MetalBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class MetalRingBuffer {
// In practice, MetalRingBuffer is used for argument buffers, which are kept in the constant
// address space. Constant buffers have specific alignment requirements when specifying an
// offset.
#if defined(IOS)
#if defined(FILAMENT_IOS)
#if TARGET_OS_SIMULATOR
// The iOS simulator has differing alignment requirements.
static constexpr auto METAL_CONSTANT_BUFFER_OFFSET_ALIGNMENT = 256;
Expand Down
12 changes: 6 additions & 6 deletions filament/backend/src/metal/MetalDriver.mm
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@
}

ShaderModel MetalDriver::getShaderModel() const noexcept {
#if defined(IOS)
#if defined(FILAMENT_IOS)
return ShaderModel::MOBILE;
#else
return ShaderModel::DESKTOP;
Expand Down Expand Up @@ -983,15 +983,15 @@
case MTLPixelFormatRGBA16Float:
return true;

#if !defined(IOS)
#if !defined(FILAMENT_IOS)
// Mipmappable only on desktop:
case MTLPixelFormatR32Float:
case MTLPixelFormatRG32Float:
case MTLPixelFormatRGBA32Float:
return true;
#endif

#if defined(IOS)
#if defined(FILAMENT_IOS)
// Mipmappable only on iOS:
case MTLPixelFormatRGB9E5Float:
return true;
Expand Down Expand Up @@ -1364,7 +1364,7 @@
if (@available(iOS 13, *)) {
MTLCaptureDescriptor* descriptor = [MTLCaptureDescriptor new];
descriptor.captureObject = mContext->device;
#if defined(IOS)
#if defined(FILAMENT_IOS)
descriptor.destination = MTLCaptureDestinationDeveloperTools;
#else
descriptor.destination = MTLCaptureDestinationGPUTraceDocument;
Expand Down Expand Up @@ -1428,7 +1428,7 @@
width:srcTextureSize.width
height:srcTextureSize.height
mipmapped:NO];
#if defined(IOS)
#if defined(FILAMENT_IOS)
textureDescriptor.storageMode = MTLStorageModeShared;
#else
textureDescriptor.storageMode = MTLStorageModeManaged;
Expand All @@ -1447,7 +1447,7 @@

mContext->blitter->blit(getPendingCommandBuffer(mContext), args, "readPixels blit");

#if !defined(IOS)
#if !defined(FILAMENT_IOS)
// Managed textures on macOS require explicit synchronization between GPU / CPU.
id <MTLBlitCommandEncoder> blitEncoder = [getPendingCommandBuffer(mContext) blitCommandEncoder];
[blitEncoder synchronizeResource:readPixelsTexture];
Expand Down
4 changes: 2 additions & 2 deletions filament/backend/src/metal/MetalEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ inline MTLPixelFormat getMetalFormatLinear(MTLPixelFormat format) {
case MTLPixelFormatRG8Unorm_sRGB: return MTLPixelFormatRG8Unorm;
case MTLPixelFormatRGBA8Unorm_sRGB: return MTLPixelFormatRGBA8Unorm;
case MTLPixelFormatBGRA8Unorm_sRGB: return MTLPixelFormatBGRA8Unorm;
#if !defined(IOS)
#if !defined(FILAMENT_IOS)
case MTLPixelFormatBC1_RGBA_sRGB: return MTLPixelFormatBC1_RGBA;
case MTLPixelFormatBC2_RGBA_sRGB: return MTLPixelFormatBC2_RGBA;
case MTLPixelFormatBC3_RGBA_sRGB: return MTLPixelFormatBC3_RGBA;
Expand Down Expand Up @@ -268,7 +268,7 @@ constexpr inline bool isMetalFormatStencil(MTLPixelFormat format) {
case MTLPixelFormatStencil8:
case MTLPixelFormatDepth32Float_Stencil8:
case MTLPixelFormatX32_Stencil8:
#if !defined(IOS)
#if !defined(FILAMENT_IOS)
case MTLPixelFormatDepth24Unorm_Stencil8:
case MTLPixelFormatX24_Stencil8:
#endif
Expand Down
8 changes: 4 additions & 4 deletions filament/backend/src/metal/MetalHandles.mm
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static inline MTLTextureUsage getMetalTextureUsage(TextureUsage usage) {
textureDescriptor.height = headlessHeight;
// Specify MTLTextureUsageShaderRead so the headless surface can be blitted from.
textureDescriptor.usage = MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead;
#if defined(IOS)
#if defined(FILAMENT_IOS)
textureDescriptor.storageMode = MTLStorageModeShared;
#else
textureDescriptor.storageMode = MTLStorageModeManaged;
Expand Down Expand Up @@ -520,7 +520,7 @@ static void func(void* user) {
const BOOL mipmapped = levels > 1;
const BOOL multisampled = samples > 1;

#if defined(IOS)
#if defined(FILAMENT_IOS)
const BOOL textureArray = target == SamplerType::SAMPLER_2D_ARRAY;
FILAMENT_CHECK_PRECONDITION(!textureArray || !multisampled)
<< "iOS does not support multisampled texture arrays.";
Expand All @@ -533,7 +533,7 @@ static void func(void* user) {
switch (target) {
case SamplerType::SAMPLER_2D:
return MTLTextureType2DMultisample;
#if !defined(IOS)
#if !defined(FILAMENT_IOS)
case SamplerType::SAMPLER_2D_ARRAY:
return MTLTextureType2DMultisampleArray;
#endif
Expand Down Expand Up @@ -856,7 +856,7 @@ static void func(void* user) {
descriptor.height = region.size.height;
descriptor.depth = region.size.depth;

#if defined(IOS)
#if defined(FILAMENT_IOS)
descriptor.storageMode = MTLStorageModeShared;
#else
descriptor.storageMode = MTLStorageModeManaged;
Expand Down
2 changes: 1 addition & 1 deletion filament/backend/src/metal/MetalPlatform.mm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
id<MTLDevice> MetalPlatform::createDevice() noexcept {
id<MTLDevice> result;

#if !defined(IOS)
#if !defined(FILAMENT_IOS)
const bool forceIntegrated =
NSProcessInfo.processInfo.environment[@"FILAMENT_FORCE_INTEGRATED_GPU"] != nil;
if (forceIntegrated) {
Expand Down
2 changes: 1 addition & 1 deletion filament/backend/src/metal/MetalState.mm
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
MTLCompareFunctionNever : getCompareFunction(params.compareFunc);
samplerDescriptor.supportArgumentBuffers = YES;

#if defined(IOS)
#if defined(FILAMENT_IOS)
// Older Apple devices (and the simulator) don't support setting a comparison function in
// MTLSamplerDescriptor.
// In practice, this means shadows are not supported when running in the simulator.
Expand Down
2 changes: 1 addition & 1 deletion filament/backend/src/noop/NoopDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Dispatcher NoopDriver::getDispatcher() const noexcept {
}

ShaderModel NoopDriver::getShaderModel() const noexcept {
#if defined(__ANDROID__) || defined(IOS) || defined(__EMSCRIPTEN__)
#if defined(__ANDROID__) || defined(FILAMENT_IOS) || defined(__EMSCRIPTEN__)
return ShaderModel::MOBILE;
#else
return ShaderModel::DESKTOP;
Expand Down
12 changes: 6 additions & 6 deletions filament/backend/src/opengl/OpenGLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ void OpenGLContext::initProcs(Procs* procs,
procs->maxShaderCompilerThreadsKHR = +[](GLuint) {};

#ifdef BACKEND_OPENGL_VERSION_GLES
# ifndef IOS // IOS is guaranteed to have ES3.x
# ifndef FILAMENT_IOS // FILAMENT_IOS is guaranteed to have ES3.x
# ifndef __EMSCRIPTEN__
if (UTILS_UNLIKELY(major == 2)) {
// Runtime OpenGL version is ES 2.x
Expand Down Expand Up @@ -438,7 +438,7 @@ void OpenGLContext::initProcs(Procs* procs,
procs->maxShaderCompilerThreadsKHR = glMaxShaderCompilerThreadsKHR;
}
# endif // __EMSCRIPTEN__
# endif // IOS
# endif // FILAMENT_IOS
#else
procs->maxShaderCompilerThreadsKHR = glMaxShaderCompilerThreadsARB;
#endif
Expand Down Expand Up @@ -576,14 +576,14 @@ void OpenGLContext::initBugs(Bugs* bugs, Extensions const& exts,
}

#ifdef BACKEND_OPENGL_VERSION_GLES
# ifndef IOS // IOS is guaranteed to have ES3.x
# ifndef FILAMENT_IOS // FILAMENT_IOS is guaranteed to have ES3.x
if (UTILS_UNLIKELY(major == 2)) {
if (UTILS_UNLIKELY(!exts.OES_vertex_array_object)) {
// we activate this workaround path, which does the reset of array buffer
bugs->vao_doesnt_store_element_array_buffer_binding = true;
}
}
# endif // IOS
# endif // FILAMENT_IOS
#else
// feedback loops are allowed on GL desktop as long as writes are disabled
bugs->allow_read_only_ancillary_feedback_loop = true;
Expand Down Expand Up @@ -622,7 +622,7 @@ FeatureLevel OpenGLContext::resolveFeatureLevel(GLint major, GLint minor,
}
}
}
# ifndef IOS // IOS is guaranteed to have ES3.x
# ifndef FILAMENT_IOS // FILAMENT_IOS is guaranteed to have ES3.x
else if (UTILS_UNLIKELY(major == 2)) {
// Runtime OpenGL version is ES 2.x
// note: mandatory extensions (all supported by Mali-400 and Adreno 304)
Expand All @@ -634,7 +634,7 @@ FeatureLevel OpenGLContext::resolveFeatureLevel(GLint major, GLint minor,
// OES_texture_npot
featureLevel = FeatureLevel::FEATURE_LEVEL_0;
}
# endif // IOS
# endif // FILAMENT_IOS
#else
assert_invariant(gets.max_texture_image_units >= 16);
assert_invariant(gets.max_combined_texture_image_units >= 32);
Expand Down
2 changes: 1 addition & 1 deletion filament/backend/src/opengl/OpenGLContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class OpenGLContext final : public TimerQueryFactoryInterface {
}

inline bool isES2() const noexcept {
#if defined(BACKEND_OPENGL_VERSION_GLES) && !defined(IOS)
#if defined(BACKEND_OPENGL_VERSION_GLES) && !defined(FILAMENT_IOS)
# ifndef BACKEND_OPENGL_LEVEL_GLES30
return true;
# else
Expand Down
4 changes: 2 additions & 2 deletions filament/backend/src/opengl/OpenGLDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1381,13 +1381,13 @@ void OpenGLDriver::framebufferTexture(TargetBufferInfo const& binfo,
#ifndef FILAMENT_SILENCE_NOT_SUPPORTED_BY_ES2

// TODO: support multiview for iOS and WebGL
#if !defined(__EMSCRIPTEN__) && !defined(IOS)
#if !defined(__EMSCRIPTEN__) && !defined(FILAMENT_IOS)
if (layerCount > 1) {
// if layerCount > 1, it means we use the multiview extension.
glFramebufferTextureMultiviewOVR(GL_FRAMEBUFFER, attachment,
t->gl.id, 0, binfo.layer, layerCount);
} else
#endif // !defined(__EMSCRIPTEN__) && !defined(IOS)
#endif // !defined(__EMSCRIPTEN__) && !defined(FILAMENT_IOS)
{
// GL_TEXTURE_2D_MULTISAMPLE_ARRAY is not supported in GLES
glFramebufferTextureLayer(GL_FRAMEBUFFER, attachment,
Expand Down
8 changes: 4 additions & 4 deletions filament/backend/src/opengl/gl_headers.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
# define FILAMENT_SILENCE_NOT_SUPPORTED_BY_ES2
#endif

#elif defined(IOS)
#elif defined(FILAMENT_IOS)

#define GLES_SILENCE_DEPRECATION

Expand All @@ -81,7 +81,7 @@
#if defined(GL_VERSION_4_5)
#elif defined(GL_ES_VERSION_3_1)
#elif defined(GL_ES_VERSION_3_0)
# if !defined(IOS) && !defined(__EMSCRIPTEN__)
# if !defined(FILAMENT_IOS) && !defined(__EMSCRIPTEN__)
# error "GLES 3.0 headers only supported on iOS and WebGL2"
# endif
#elif defined(GL_ES_VERSION_2_0)
Expand All @@ -98,7 +98,7 @@

#if defined(GL_ES_VERSION_2_0) // this basically means all versions of GLES

#if defined(IOS)
#if defined(FILAMENT_IOS)

// iOS headers only provide prototypes, nothing to do.

Expand Down Expand Up @@ -271,7 +271,7 @@ void glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, void *d
#endif

#ifdef GL_ES_VERSION_2_0
# ifndef IOS
# ifndef FILAMENT_IOS
# ifndef GL_OES_vertex_array_object
# error "Headers with GL_OES_vertex_array_object are mandatory unless on iOS"
# endif
Expand Down
2 changes: 1 addition & 1 deletion filament/backend/src/vulkan/VulkanDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ Driver* VulkanDriver::create(VulkanPlatform* platform, VulkanContext const& cont
}

ShaderModel VulkanDriver::getShaderModel() const noexcept {
#if defined(__ANDROID__) || defined(IOS)
#if defined(__ANDROID__) || defined(FILAMENT_IOS)
return ShaderModel::MOBILE;
#else
return ShaderModel::DESKTOP;
Expand Down
6 changes: 3 additions & 3 deletions filament/backend/src/vulkan/platform/VulkanPlatformApple.mm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#ifndef VK_MVK_macos_surface
#error VK_MVK_macos_surface is not defined
#endif
#elif defined(IOS)
#elif defined(FILAMENT_IOS)
// Metal is not available when building for the iOS simulator on Desktop.
#define METAL_AVAILABLE __has_include(<QuartzCore/CAMetalLayer.h>)
#if METAL_AVAILABLE
Expand All @@ -56,7 +56,7 @@
ExtensionSet const ret = {
#if defined(__APPLE__)
VK_MVK_MACOS_SURFACE_EXTENSION_NAME, // TODO: replace with VK_EXT_metal_surface
#elif defined(IOS) && defined(METAL_AVAILABLE)
#elif defined(FILAMENT_IOS) && defined(METAL_AVAILABLE)
VK_MVK_IOS_SURFACE_EXTENSION_NAME,
#endif
};
Expand Down Expand Up @@ -90,7 +90,7 @@
VkResult result = vkCreateMacOSSurfaceMVK((VkInstance) instance, &createInfo, VKALLOC,
(VkSurfaceKHR*) &surface);
FILAMENT_CHECK_POSTCONDITION(result == VK_SUCCESS) << "vkCreateMacOSSurfaceMVK error.";
#elif defined(IOS) && defined(METAL_AVAILABLE)
#elif defined(FILAMENT_IOS) && defined(METAL_AVAILABLE)
CAMetalLayer* metalLayer = (CAMetalLayer*) nativeWindow;
// Create the VkSurface.
FILAMENT_CHECK_POSTCONDITION(vkCreateIOSSurfaceMVK)
Expand Down
4 changes: 2 additions & 2 deletions filament/backend/test/BackendTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static constexpr size_t CONFIG_COMMAND_BUFFERS_SIZE = 3 * CONFIG_MIN_COMMAND
using namespace filament;
using namespace filament::backend;

#ifndef IOS
#ifndef FILAMENT_IOS
#include <imageio/ImageEncoder.h>
#include <image/ColorTransform.h>

Expand Down Expand Up @@ -177,7 +177,7 @@ void BackendTest::readPixelsAndAssertHash(const char* testName, size_t width, si

// Export a screenshot, if requested.
if (c->exportScreenshot) {
#ifndef IOS
#ifndef FILAMENT_IOS
LinearImage image(c->width, c->height, 4);
image = toLinearWithAlpha<uint8_t>(c->width, c->height, c->width * 4,
(uint8_t*) buffer);
Expand Down
4 changes: 2 additions & 2 deletions filament/backend/test/test_Blit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include <fstream>

#ifndef IOS
#ifndef FILAMENT_IOS
#include <imageio/ImageEncoder.h>
#include <image/ColorTransform.h>
#endif
Expand Down Expand Up @@ -67,7 +67,7 @@ struct ScreenshotParams {
uint32_t pixelHashResult;
};

#ifdef IOS
#ifdef FILAMENT_IOS
static void dumpScreenshot(DriverApi& dapi, Handle<HwRenderTarget> rt, ScreenshotParams* params) {}
#else
static void dumpScreenshot(DriverApi& dapi, Handle<HwRenderTarget> rt, ScreenshotParams* params) {
Expand Down
4 changes: 2 additions & 2 deletions filament/backend/test/test_FeedbackLoops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <stddef.h>
#include <stdint.h>

#ifndef IOS
#ifndef FILAMENT_IOS
#include <imageio/ImageEncoder.h>
#include <image/ColorTransform.h>

Expand Down Expand Up @@ -112,7 +112,7 @@ static void dumpScreenshot(DriverApi& dapi, Handle<HwRenderTarget> rt) {
int w = kTexWidth, h = kTexHeight;
const uint32_t* texels = (uint32_t*) buffer;
sPixelHashResult = utils::hash::murmur3(texels, size / 4, 0);
#ifndef IOS
#ifndef FILAMENT_IOS
LinearImage image(w, h, 4);
image = toLinearWithAlpha<uint8_t>(w, h, w * 4, (uint8_t*) buffer);
std::ofstream pngstrm("feedback.png", std::ios::binary | std::ios::trunc);
Expand Down
4 changes: 2 additions & 2 deletions filament/backend/test/test_ReadPixels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
using namespace filament;
using namespace filament::backend;

#ifndef IOS
#ifndef FILAMENT_IOS
#include <imageio/ImageEncoder.h>
#include <image/ColorTransform.h>

Expand Down Expand Up @@ -137,7 +137,7 @@ TEST_F(ReadPixelsTest, ReadPixels) {
}

void exportScreenshot(void* pixelData) const {
#ifndef IOS
#ifndef FILAMENT_IOS
const size_t width = readRect.width, height = readRect.height;
LinearImage image(width, height, 4);
if (format == PixelDataFormat::RGBA && type == PixelDataType::UBYTE) {
Expand Down
Loading

0 comments on commit 863b134

Please sign in to comment.