Resurrect the NOOP driver.
This commit is contained in:
@@ -6,3 +6,4 @@ libs/utils/test_utils
|
||||
libs/filamat/test_filamat
|
||||
tools/matc/test_matc
|
||||
tools/cmgen/test_cmgen compare
|
||||
libs/filameshio/test_filameshio
|
||||
|
||||
@@ -156,6 +156,7 @@ set(MATERIAL_SRCS
|
||||
# Remove it from release builds, since it uses some space needlessly.
|
||||
if (CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
list(APPEND SRCS src/driver/noop/NoopDriver.cpp)
|
||||
list(APPEND SRCS src/driver/noop/PlatformNoop.cpp)
|
||||
endif()
|
||||
|
||||
if(IOS AND NOT FILAMENT_SUPPORTS_VULKAN)
|
||||
|
||||
@@ -59,6 +59,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
#include "driver/noop/PlatformNoop.h"
|
||||
#endif
|
||||
|
||||
namespace filament {
|
||||
namespace driver {
|
||||
|
||||
@@ -77,6 +81,11 @@ Platform* Platform::create(Backend* backend) noexcept {
|
||||
if (*backend == Backend::DEFAULT) {
|
||||
*backend = Backend::OPENGL;
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
if (*backend == Backend::NOOP) {
|
||||
return new PlatformNoop();
|
||||
}
|
||||
#endif
|
||||
if (*backend == Backend::VULKAN) {
|
||||
#if defined(FILAMENT_DRIVER_SUPPORTS_VULKAN)
|
||||
#if defined(ANDROID)
|
||||
|
||||
@@ -24,12 +24,19 @@ Driver* NoopDriver::create() {
|
||||
return new NoopDriver();
|
||||
}
|
||||
|
||||
NoopDriver::NoopDriver() noexcept
|
||||
: DriverBase(new ConcreteDispatcher<NoopDriver>(this)) {
|
||||
NoopDriver::NoopDriver() noexcept : DriverBase(new ConcreteDispatcher<NoopDriver>(this)) {
|
||||
}
|
||||
|
||||
NoopDriver::~NoopDriver() noexcept = default;
|
||||
|
||||
driver::ShaderModel NoopDriver::getShaderModel() const noexcept {
|
||||
#if defined(GLES31_HEADERS)
|
||||
return driver::ShaderModel::GL_CORE_30;
|
||||
#else
|
||||
return driver::ShaderModel::GL_CORE_41;
|
||||
#endif
|
||||
}
|
||||
|
||||
// explicit instantiation of the Dispatcher
|
||||
template class ConcreteDispatcher<NoopDriver>;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
static Driver* create();
|
||||
|
||||
private:
|
||||
ShaderModel getShaderModel() const noexcept final { return ShaderModel::UNKNOWN; }
|
||||
ShaderModel getShaderModel() const noexcept final;
|
||||
|
||||
/*
|
||||
* Driver interface
|
||||
@@ -44,8 +44,11 @@ private:
|
||||
#define DECL_DRIVER_API(methodName, paramsDecl, params) \
|
||||
UTILS_ALWAYS_INLINE void methodName(paramsDecl) { }
|
||||
|
||||
// The only reason we return a non-zero value is so that "isTextureFormatSupported"
|
||||
// returns true, which is necessary because Engine creates an internal 1x1 texture
|
||||
// during its initialization phase.
|
||||
#define DECL_DRIVER_API_SYNCHRONOUS(RetType, methodName, paramsDecl, params) \
|
||||
RetType methodName(paramsDecl) override { return RetType(); }
|
||||
RetType methodName(paramsDecl) override { return RetType(true); }
|
||||
|
||||
#define DECL_DRIVER_API_RETURN(RetType, methodName, paramsDecl, params) \
|
||||
RetType methodName##Synchronous() noexcept override { \
|
||||
|
||||
27
filament/src/driver/noop/PlatformNoop.cpp
Normal file
27
filament/src/driver/noop/PlatformNoop.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "driver/noop/PlatformNoop.h"
|
||||
|
||||
#include "driver/noop/NoopDriver.h"
|
||||
|
||||
namespace filament {
|
||||
|
||||
Driver* PlatformNoop::createDriver(void* const sharedGLContext) noexcept {
|
||||
return NoopDriver::create();
|
||||
}
|
||||
|
||||
} // namespace filament
|
||||
39
filament/src/driver/noop/PlatformNoop.h
Normal file
39
filament/src/driver/noop/PlatformNoop.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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_DRIVER_NOOP_PLATFORM_NOOP_H
|
||||
#define TNT_FILAMENT_DRIVER_NOOP_PLATFORM_NOOP_H
|
||||
|
||||
#include <filament/driver/DriverEnums.h>
|
||||
#include <filament/driver/Platform.h>
|
||||
|
||||
namespace filament {
|
||||
|
||||
class PlatformNoop final : public driver::Platform {
|
||||
public:
|
||||
|
||||
int getOSVersion() const noexcept final override { return 0; }
|
||||
|
||||
~PlatformNoop() noexcept override { }
|
||||
|
||||
protected:
|
||||
|
||||
Driver* createDriver(void* sharedContext) noexcept override;
|
||||
};
|
||||
|
||||
} // namespace filament
|
||||
|
||||
#endif // TNT_FILAMENT_DRIVER_NOOP_PLATFORM_NOOP_H
|
||||
@@ -42,6 +42,7 @@ enum class Backend : uint8_t {
|
||||
DEFAULT = 0, //!< Automatically selects an appropriate driver for the platform.
|
||||
OPENGL = 1, //!< Selects the OpenGL driver (which supports OpenGL ES as well).
|
||||
VULKAN = 2, //!< Selects the Vulkan driver if the platform supports it.
|
||||
NOOP = 3, //!< Selects the no-op driver for testing purposes.
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -107,7 +107,7 @@ static const InterleavedVertex interleavedVertices[] = { {
|
||||
class FilameshTest : public testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
engine = Engine::create(Engine::Backend::OPENGL);
|
||||
engine = Engine::create(Engine::Backend::NOOP);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
|
||||
Reference in New Issue
Block a user