fix some missing includes and trivial warnings (#8414)
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include <backend/Program.h>
|
||||
#include <backend/TargetBufferInfo.h>
|
||||
|
||||
#include "private/backend/CommandStream.h"
|
||||
#include "private/backend/Dispatcher.h"
|
||||
#include "private/backend/DriverApi.h"
|
||||
|
||||
@@ -46,9 +47,11 @@
|
||||
#include <utils/BitmaskEnum.h>
|
||||
#include <utils/FixedCapacityVector.h>
|
||||
#include <utils/CString.h>
|
||||
#include <utils/Invocable.h>
|
||||
#include <utils/Log.h>
|
||||
#include <utils/Panic.h>
|
||||
#include <utils/Systrace.h>
|
||||
#include <utils/Slice.h>
|
||||
#include <utils/compiler.h>
|
||||
#include <utils/debug.h>
|
||||
#include <utils/ostream.h>
|
||||
@@ -155,7 +158,7 @@ using namespace GLUtils;
|
||||
|
||||
UTILS_NOINLINE
|
||||
OpenGLDriver* OpenGLDriver::create(OpenGLPlatform* const platform,
|
||||
void* const sharedGLContext, const Platform::DriverConfig& driverConfig) noexcept {
|
||||
void* const /*sharedGLContext*/, const Platform::DriverConfig& driverConfig) noexcept {
|
||||
assert_invariant(platform);
|
||||
OpenGLPlatform* const ec = platform;
|
||||
|
||||
@@ -222,7 +225,7 @@ OpenGLDriver* OpenGLDriver::create(OpenGLPlatform* const platform,
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t const defaultSize = FILAMENT_OPENGL_HANDLE_ARENA_SIZE_IN_MB * 1024U * 1024U;
|
||||
constexpr size_t defaultSize = FILAMENT_OPENGL_HANDLE_ARENA_SIZE_IN_MB * 1024U * 1024U;
|
||||
Platform::DriverConfig validConfig{ driverConfig };
|
||||
validConfig.handleArenaSize = std::max(driverConfig.handleArenaSize, defaultSize);
|
||||
OpenGLDriver* const driver = new(std::nothrow) OpenGLDriver(ec, validConfig);
|
||||
@@ -277,7 +280,6 @@ OpenGLDriver::OpenGLDriver(OpenGLPlatform* platform, const Platform::DriverConfi
|
||||
driverConfig.disableHandleUseAfterFreeCheck),
|
||||
mDriverConfig(driverConfig),
|
||||
mCurrentPushConstants(new(std::nothrow) PushConstantBundle{}) {
|
||||
|
||||
// set a reasonable default value for our stream array
|
||||
mTexturesWithStreamsAttached.reserve(8);
|
||||
mStreamsWithPendingAcquiredImage.reserve(8);
|
||||
@@ -366,8 +368,8 @@ void OpenGLDriver::bindSampler(GLuint unit, GLuint sampler) noexcept {
|
||||
mContext.bindSampler(unit, sampler);
|
||||
}
|
||||
|
||||
void OpenGLDriver::setPushConstant(backend::ShaderStage stage, uint8_t index,
|
||||
backend::PushConstantVariant value) {
|
||||
void OpenGLDriver::setPushConstant(ShaderStage stage, uint8_t index,
|
||||
PushConstantVariant value) {
|
||||
assert_invariant(stage == ShaderStage::VERTEX || stage == ShaderStage::FRAGMENT);
|
||||
|
||||
#if FILAMENT_ENABLE_MATDBG
|
||||
@@ -376,7 +378,7 @@ void OpenGLDriver::setPushConstant(backend::ShaderStage stage, uint8_t index,
|
||||
}
|
||||
#endif
|
||||
|
||||
utils::Slice<std::pair<GLint, ConstantType>> constants;
|
||||
Slice<std::pair<GLint, ConstantType>> constants;
|
||||
if (stage == ShaderStage::VERTEX) {
|
||||
constants = mCurrentPushConstants->vertexConstants;
|
||||
} else if (stage == ShaderStage::FRAGMENT) {
|
||||
@@ -681,7 +683,7 @@ void OpenGLDriver::createBufferObjectR(Handle<HwBufferObject> boh,
|
||||
bo->gl.buffer = malloc(byteCount);
|
||||
memset(bo->gl.buffer, 0, byteCount);
|
||||
} else {
|
||||
bo->gl.binding = GLUtils::getBufferBindingType(bindingType);
|
||||
bo->gl.binding = getBufferBindingType(bindingType);
|
||||
glGenBuffers(1, &bo->gl.id);
|
||||
gl.bindBuffer(bo->gl.binding, bo->gl.id);
|
||||
glBufferData(bo->gl.binding, byteCount, nullptr, getBufferUsage(usage));
|
||||
@@ -758,7 +760,7 @@ void OpenGLDriver::createProgramR(Handle<HwProgram> ph, Program&& program) {
|
||||
}
|
||||
|
||||
UTILS_NOINLINE
|
||||
void OpenGLDriver::textureStorage(OpenGLDriver::GLTexture* t,
|
||||
void OpenGLDriver::textureStorage(GLTexture* t,
|
||||
uint32_t width, uint32_t height, uint32_t depth, bool useProtectedMemory) noexcept {
|
||||
|
||||
auto& gl = mContext;
|
||||
@@ -1144,7 +1146,7 @@ void OpenGLDriver::createTextureExternalImageR(Handle<HwTexture> th, SamplerType
|
||||
}
|
||||
|
||||
void OpenGLDriver::createTextureExternalImagePlaneR(Handle<HwTexture> th,
|
||||
backend::TextureFormat format, uint32_t width, uint32_t height, backend::TextureUsage usage,
|
||||
TextureFormat format, uint32_t width, uint32_t height, TextureUsage usage,
|
||||
void* image, uint32_t plane) {
|
||||
// not relevant for the OpenGL backend
|
||||
}
|
||||
@@ -1460,7 +1462,7 @@ void OpenGLDriver::framebufferTexture(TargetBufferInfo const& binfo,
|
||||
&& ((gl.ext.EXT_multisampled_render_to_texture && attachment == GL_COLOR_ATTACHMENT0)
|
||||
|| gl.ext.EXT_multisampled_render_to_texture2)) {
|
||||
assert_invariant(rt->gl.samples > 1);
|
||||
// We have a multi-sample rendertarget and we have EXT_multisampled_render_to_texture,
|
||||
// We have a multi-sample rendertarget, and we have EXT_multisampled_render_to_texture,
|
||||
// so, we can directly use a 1-sample texture as attachment, multi-sample resolve,
|
||||
// will happen automagically and efficiently in the driver.
|
||||
// This extension only exists on OpenGL ES.
|
||||
@@ -1660,9 +1662,9 @@ void OpenGLDriver::createRenderTargetR(Handle<HwRenderTarget> rth,
|
||||
rt->gl.samples = samples;
|
||||
rt->targets = targets;
|
||||
|
||||
UTILS_UNUSED_IN_RELEASE math::vec2<uint32_t> tmin = { std::numeric_limits<uint32_t>::max() };
|
||||
UTILS_UNUSED_IN_RELEASE math::vec2<uint32_t> tmax = { 0 };
|
||||
auto checkDimensions = [&tmin, &tmax](GLTexture* t, uint8_t level) {
|
||||
UTILS_UNUSED_IN_RELEASE vec2<uint32_t> tmin = { std::numeric_limits<uint32_t>::max() };
|
||||
UTILS_UNUSED_IN_RELEASE vec2<uint32_t> tmax = { 0 };
|
||||
auto checkDimensions = [&tmin, &tmax](GLTexture const* t, uint8_t level) {
|
||||
const auto twidth = std::max(1u, t->width >> level);
|
||||
const auto theight = std::max(1u, t->height >> level);
|
||||
tmin = { std::min(tmin.x, twidth), std::min(tmin.y, theight) };
|
||||
@@ -2364,11 +2366,11 @@ bool OpenGLDriver::isStereoSupported() {
|
||||
return false;
|
||||
}
|
||||
switch (mDriverConfig.stereoscopicType) {
|
||||
case backend::StereoscopicType::INSTANCED:
|
||||
case StereoscopicType::INSTANCED:
|
||||
return mContext.ext.EXT_clip_cull_distance;
|
||||
case backend::StereoscopicType::MULTIVIEW:
|
||||
case StereoscopicType::MULTIVIEW:
|
||||
return mContext.ext.OVR_multiview2;
|
||||
case backend::StereoscopicType::NONE:
|
||||
case StereoscopicType::NONE:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2381,7 +2383,7 @@ bool OpenGLDriver::isDepthStencilResolveSupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpenGLDriver::isDepthStencilBlitSupported(TextureFormat format) {
|
||||
bool OpenGLDriver::isDepthStencilBlitSupported(TextureFormat) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2415,12 +2417,12 @@ FeatureLevel OpenGLDriver::getFeatureLevel() {
|
||||
return mContext.getFeatureLevel();
|
||||
}
|
||||
|
||||
math::float2 OpenGLDriver::getClipSpaceParams() {
|
||||
float2 OpenGLDriver::getClipSpaceParams() {
|
||||
return mContext.ext.EXT_clip_control ?
|
||||
// z-coordinate of virtual and physical clip-space is in [-w, 0]
|
||||
math::float2{ 1.0f, 0.0f } :
|
||||
float2{ 1.0f, 0.0f } :
|
||||
// z-coordinate of virtual clip-space is in [-w,0], physical is in [-w, w]
|
||||
math::float2{ 2.0f, -1.0f };
|
||||
float2{ 2.0f, -1.0f };
|
||||
}
|
||||
|
||||
uint8_t OpenGLDriver::getMaxDrawBuffers() {
|
||||
@@ -2484,7 +2486,7 @@ void OpenGLDriver::makeCurrent(Handle<HwSwapChain> schDraw, Handle<HwSwapChain>
|
||||
// Updating driver objects
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
void OpenGLDriver::setDebugTag(HandleBase::HandleId handleId, utils::CString tag) {
|
||||
void OpenGLDriver::setDebugTag(HandleBase::HandleId handleId, CString tag) {
|
||||
mHandleAllocator.associateTagToHandle(handleId, std::move(tag));
|
||||
}
|
||||
|
||||
@@ -2660,7 +2662,7 @@ void OpenGLDriver::generateMipmaps(Handle<HwTexture> th) {
|
||||
CHECK_GL_ERROR(utils::slog.e)
|
||||
}
|
||||
|
||||
void OpenGLDriver::setTextureData(GLTexture* t, uint32_t level,
|
||||
void OpenGLDriver::setTextureData(GLTexture const* t, uint32_t level,
|
||||
uint32_t xoffset, uint32_t yoffset, uint32_t zoffset,
|
||||
uint32_t width, uint32_t height, uint32_t depth,
|
||||
PixelBufferDescriptor&& p) {
|
||||
@@ -2769,7 +2771,7 @@ void OpenGLDriver::setTextureData(GLTexture* t, uint32_t level,
|
||||
CHECK_GL_ERROR(utils::slog.e)
|
||||
}
|
||||
|
||||
void OpenGLDriver::setCompressedTextureData(GLTexture* t, uint32_t level,
|
||||
void OpenGLDriver::setCompressedTextureData(GLTexture const* t, uint32_t level,
|
||||
uint32_t xoffset, uint32_t yoffset, uint32_t zoffset,
|
||||
uint32_t width, uint32_t height, uint32_t depth,
|
||||
PixelBufferDescriptor&& p) {
|
||||
@@ -3410,8 +3412,8 @@ void OpenGLDriver::readPixels(Handle<HwRenderTarget> src,
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenGLDriver::readBufferSubData(backend::BufferObjectHandle boh,
|
||||
uint32_t offset, uint32_t size, backend::BufferDescriptor&& p) {
|
||||
void OpenGLDriver::readBufferSubData(BufferObjectHandle boh,
|
||||
uint32_t offset, uint32_t size, BufferDescriptor&& p) {
|
||||
UTILS_UNUSED_IN_RELEASE auto& gl = mContext;
|
||||
assert_invariant(!gl.isES2());
|
||||
|
||||
@@ -3558,13 +3560,13 @@ void OpenGLDriver::beginFrame(
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLDriver::setFrameScheduledCallback(Handle<HwSwapChain> sch, CallbackHandler* handler,
|
||||
FrameScheduledCallback&& callback, uint64_t flags) {
|
||||
void OpenGLDriver::setFrameScheduledCallback(Handle<HwSwapChain>, CallbackHandler*,
|
||||
FrameScheduledCallback&& /*callback*/, uint64_t /*flags*/) {
|
||||
DEBUG_MARKER()
|
||||
}
|
||||
|
||||
void OpenGLDriver::setFrameCompletedCallback(Handle<HwSwapChain> sch,
|
||||
CallbackHandler* handler, utils::Invocable<void(void)>&& callback) {
|
||||
void OpenGLDriver::setFrameCompletedCallback(Handle<HwSwapChain>,
|
||||
CallbackHandler*, Invocable<void()>&& /*callback*/) {
|
||||
DEBUG_MARKER()
|
||||
}
|
||||
|
||||
@@ -3595,9 +3597,9 @@ void OpenGLDriver::endFrame(UTILS_UNUSED uint32_t frameId) {
|
||||
}
|
||||
|
||||
void OpenGLDriver::updateDescriptorSetBuffer(
|
||||
backend::DescriptorSetHandle dsh,
|
||||
backend::descriptor_binding_t binding,
|
||||
backend::BufferObjectHandle boh,
|
||||
DescriptorSetHandle dsh,
|
||||
descriptor_binding_t binding,
|
||||
BufferObjectHandle boh,
|
||||
uint32_t offset, uint32_t size) {
|
||||
GLDescriptorSet* ds = handle_cast<GLDescriptorSet*>(dsh);
|
||||
GLBufferObject* bo = boh ? handle_cast<GLBufferObject*>(boh) : nullptr;
|
||||
@@ -3605,9 +3607,9 @@ void OpenGLDriver::updateDescriptorSetBuffer(
|
||||
}
|
||||
|
||||
void OpenGLDriver::updateDescriptorSetTexture(
|
||||
backend::DescriptorSetHandle dsh,
|
||||
backend::descriptor_binding_t binding,
|
||||
backend::TextureHandle th,
|
||||
DescriptorSetHandle dsh,
|
||||
descriptor_binding_t binding,
|
||||
TextureHandle th,
|
||||
SamplerParams params) {
|
||||
GLDescriptorSet* ds = handle_cast<GLDescriptorSet*>(dsh);
|
||||
GLTexture* t = th ? handle_cast<GLTexture*>(th) : nullptr;
|
||||
@@ -3640,7 +3642,7 @@ void OpenGLDriver::finish(int) {
|
||||
|
||||
UTILS_NOINLINE
|
||||
void OpenGLDriver::clearWithRasterPipe(TargetBufferFlags clearFlags,
|
||||
math::float4 const& linearColor, GLfloat depth, GLint stencil) noexcept {
|
||||
float4 const& linearColor, GLfloat depth, GLint stencil) noexcept {
|
||||
|
||||
if (any(clearFlags & TargetBufferFlags::COLOR_ALL)) {
|
||||
mContext.colorMask(GL_TRUE);
|
||||
@@ -3963,9 +3965,9 @@ void OpenGLDriver::bindRenderPrimitive(Handle<HwRenderPrimitive> rph) {
|
||||
}
|
||||
|
||||
void OpenGLDriver::bindDescriptorSet(
|
||||
backend::DescriptorSetHandle dsh,
|
||||
backend::descriptor_set_t set,
|
||||
backend::DescriptorSetOffsetArray&& offsets) {
|
||||
DescriptorSetHandle dsh,
|
||||
descriptor_set_t set,
|
||||
DescriptorSetOffsetArray&& offsets) {
|
||||
|
||||
if (UTILS_UNLIKELY(!dsh)) {
|
||||
mBoundDescriptorSets[set].dsh = dsh;
|
||||
@@ -3997,7 +3999,7 @@ void OpenGLDriver::bindDescriptorSet(
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLDriver::updateDescriptors(utils::bitset8 invalidDescriptorSets) noexcept {
|
||||
void OpenGLDriver::updateDescriptors(bitset8 invalidDescriptorSets) noexcept {
|
||||
assert_invariant(mBoundProgram);
|
||||
auto const offsetOnly = mInvalidDescriptorSetBindingOffsets & ~mInvalidDescriptorSetBindings;
|
||||
invalidDescriptorSets.forEachSetBit([this, offsetOnly,
|
||||
@@ -4109,7 +4111,7 @@ void OpenGLDriver::draw(PipelineState state, Handle<HwRenderPrimitive> rph,
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLDriver::dispatchCompute(Handle<HwProgram> program, math::uint3 workGroupCount) {
|
||||
void OpenGLDriver::dispatchCompute(Handle<HwProgram> program, uint3 workGroupCount) {
|
||||
DEBUG_MARKER()
|
||||
getShaderCompilerService().tick();
|
||||
|
||||
|
||||
@@ -298,13 +298,13 @@ private:
|
||||
|
||||
void setStencilState(StencilState ss) noexcept;
|
||||
|
||||
void setTextureData(GLTexture* t,
|
||||
void setTextureData(GLTexture const* t,
|
||||
uint32_t level,
|
||||
uint32_t xoffset, uint32_t yoffset, uint32_t zoffset,
|
||||
uint32_t width, uint32_t height, uint32_t depth,
|
||||
PixelBufferDescriptor&& p);
|
||||
|
||||
void setCompressedTextureData(GLTexture* t,
|
||||
void setCompressedTextureData(GLTexture const* t,
|
||||
uint32_t level,
|
||||
uint32_t xoffset, uint32_t yoffset, uint32_t zoffset,
|
||||
uint32_t width, uint32_t height, uint32_t depth,
|
||||
@@ -347,7 +347,7 @@ private:
|
||||
struct {
|
||||
DescriptorSetHandle dsh;
|
||||
std::array<uint32_t, CONFIG_UNIFORM_BINDING_COUNT> offsets;
|
||||
} mBoundDescriptorSets[MAX_DESCRIPTOR_SET_COUNT];
|
||||
} mBoundDescriptorSets[MAX_DESCRIPTOR_SET_COUNT] = {};
|
||||
|
||||
void clearWithRasterPipe(TargetBufferFlags clearFlags,
|
||||
math::float4 const& linearColor, GLfloat depth, GLint stencil) noexcept;
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
#include "details/Fence.h"
|
||||
#include "details/IndexBuffer.h"
|
||||
#include "details/IndirectLight.h"
|
||||
#include "details/InstanceBuffer.h"
|
||||
#include "details/Material.h"
|
||||
#include "details/MorphTargetBuffer.h"
|
||||
#include "details/Renderer.h"
|
||||
#include "details/Scene.h"
|
||||
#include "details/SkinningBuffer.h"
|
||||
@@ -36,28 +38,39 @@
|
||||
#include "details/VertexBuffer.h"
|
||||
#include "details/View.h"
|
||||
|
||||
#include <filament/ColorGrading.h>
|
||||
#include <filament/Engine.h>
|
||||
#include <filament/MaterialEnums.h>
|
||||
|
||||
#include <private/filament/DescriptorSets.h>
|
||||
#include <private/filament/EngineEnums.h>
|
||||
#include <private/filament/Variant.h>
|
||||
|
||||
#include <private/backend/PlatformFactory.h>
|
||||
|
||||
#include <backend/DriverEnums.h>
|
||||
|
||||
#include <utils/Allocator.h>
|
||||
#include <utils/CallStack.h>
|
||||
#include <utils/compiler.h>
|
||||
#include <utils/debug.h>
|
||||
#include <utils/Invocable.h>
|
||||
#include <utils/Log.h>
|
||||
#include <utils/ostream.h>
|
||||
#include <utils/Panic.h>
|
||||
#include <utils/PrivateImplementation-impl.h>
|
||||
#include <utils/Systrace.h>
|
||||
#include <utils/ThreadUtils.h>
|
||||
|
||||
#include <math/vec3.h>
|
||||
#include <math/vec4.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <initializer_list>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <new>
|
||||
#include <optional>
|
||||
#include <thread>
|
||||
#include <string_view>
|
||||
@@ -66,6 +79,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "generated/resources/materials.h"
|
||||
@@ -101,7 +115,7 @@ Engine* FEngine::create(Builder const& builder) {
|
||||
|
||||
// Normally we launch a thread and create the context and Driver from there (see FEngine::loop).
|
||||
// In the single-threaded case, we do so in the here and now.
|
||||
if (!UTILS_HAS_THREADING) {
|
||||
if constexpr (!UTILS_HAS_THREADING) {
|
||||
Platform* platform = builder->mPlatform;
|
||||
void* const sharedContext = builder->mSharedContext;
|
||||
|
||||
@@ -144,7 +158,7 @@ Engine* FEngine::create(Builder const& builder) {
|
||||
// now we can initialize the largest part of the engine
|
||||
instance->init();
|
||||
|
||||
if (!UTILS_HAS_THREADING) {
|
||||
if constexpr (!UTILS_HAS_THREADING) {
|
||||
instance->execute();
|
||||
}
|
||||
|
||||
@@ -163,7 +177,7 @@ void FEngine::create(Builder const& builder, Invocable<void(void*)>&& callback)
|
||||
instance->mDriverThread = std::thread(&FEngine::loop, instance);
|
||||
|
||||
// launch a thread to call the callback -- so it can't do any damage.
|
||||
std::thread callbackThread = std::thread([instance, callback = std::move(callback)]() {
|
||||
std::thread callbackThread = std::thread([instance, callback = std::move(callback)] {
|
||||
instance->mDriverBarrier.await();
|
||||
callback(instance);
|
||||
});
|
||||
@@ -196,7 +210,7 @@ FEngine* FEngine::getEngine(void* token) {
|
||||
|
||||
#endif
|
||||
|
||||
// these must be static because only a pointer is copied to the render stream
|
||||
// These must be static because only a pointer is copied to the render stream
|
||||
// Note that these coordinates are specified in OpenGL clip space. Other backends can transform
|
||||
// these in the vertex shader as needed.
|
||||
static constexpr float4 sFullScreenTriangleVertices[3] = {
|
||||
@@ -206,7 +220,7 @@ static constexpr float4 sFullScreenTriangleVertices[3] = {
|
||||
};
|
||||
|
||||
// these must be static because only a pointer is copied to the render stream
|
||||
static const uint16_t sFullScreenTriangleIndices[3] = { 0, 1, 2 };
|
||||
static constexpr uint16_t sFullScreenTriangleIndices[3] = { 0, 1, 2 };
|
||||
|
||||
FEngine::FEngine(Builder const& builder) :
|
||||
mBackend(builder->mBackend),
|
||||
@@ -216,7 +230,6 @@ FEngine::FEngine(Builder const& builder) :
|
||||
mPostProcessManager(*this),
|
||||
mEntityManager(EntityManager::get()),
|
||||
mRenderableManager(*this),
|
||||
mTransformManager(),
|
||||
mLightManager(*this),
|
||||
mCameraManager(*this),
|
||||
mCommandBufferQueue(
|
||||
@@ -274,7 +287,7 @@ uint32_t FEngine::getJobSystemThreadPoolSize(Config const& config) noexcept {
|
||||
}
|
||||
|
||||
// 1 thread for the user, 1 thread for the backend
|
||||
int threadCount = (int)std::thread::hardware_concurrency() - 2;
|
||||
int threadCount = int(std::thread::hardware_concurrency()) - 2;
|
||||
// make sure we have at least 1 thread though
|
||||
threadCount = std::max(1, threadCount);
|
||||
return threadCount;
|
||||
@@ -347,8 +360,8 @@ void FEngine::init() {
|
||||
}
|
||||
|
||||
// initialize the dummy textures so that their contents are not undefined
|
||||
static const uint32_t zeroes[6] = {0};
|
||||
static const uint32_t ones = 0xffffffff;
|
||||
static constexpr uint32_t zeroes[6] = {};
|
||||
static constexpr uint32_t ones = 0xffffffff;
|
||||
|
||||
mDefaultIblTexture = downcast(Texture::Builder()
|
||||
.width(1).height(1).levels(1)
|
||||
@@ -360,7 +373,7 @@ void FEngine::init() {
|
||||
{ zeroes, sizeof(zeroes), Texture::Format::RGBA, Texture::Type::UBYTE });
|
||||
|
||||
// 3 bands = 9 float3
|
||||
const float sh[9 * 3] = { 0.0f };
|
||||
constexpr float sh[9 * 3] = { 0.0f };
|
||||
mDefaultIbl = downcast(IndirectLight::Builder()
|
||||
.irradiance(3, reinterpret_cast<const float3*>(sh))
|
||||
.build(*this));
|
||||
@@ -427,10 +440,10 @@ void FEngine::init() {
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
mDefaultMaterial = downcast(defaultMaterialBuilder.build(*const_cast<FEngine*>(this)));
|
||||
mDefaultMaterial = downcast(defaultMaterialBuilder.build(*this));
|
||||
|
||||
float3 dummyPositions[1] = {};
|
||||
short4 dummyTangents[1] = {};
|
||||
constexpr float3 dummyPositions[1] = {};
|
||||
constexpr short4 dummyTangents[1] = {};
|
||||
mDummyMorphTargetBuffer->setPositionsAt(*this, 0, dummyPositions, 1, 0);
|
||||
mDummyMorphTargetBuffer->setTangentsAt(*this, 0, dummyTangents, 1, 0);
|
||||
|
||||
@@ -453,7 +466,7 @@ void FEngine::init() {
|
||||
mPostProcessManager.init();
|
||||
|
||||
mDebugRegistry.registerProperty("d.shadowmap.debug_directional_shadowmap",
|
||||
&debug.shadowmap.debug_directional_shadowmap, [this]() {
|
||||
&debug.shadowmap.debug_directional_shadowmap, [this] {
|
||||
mMaterials.forEach([this](FMaterial* material) {
|
||||
if (material->getMaterialDomain() == MaterialDomain::SURFACE) {
|
||||
|
||||
@@ -469,7 +482,7 @@ void FEngine::init() {
|
||||
});
|
||||
|
||||
mDebugRegistry.registerProperty("d.lighting.debug_froxel_visualization",
|
||||
&debug.lighting.debug_froxel_visualization, [this]() {
|
||||
&debug.lighting.debug_froxel_visualization, [this] {
|
||||
mMaterials.forEach([this](FMaterial* material) {
|
||||
if (material->getMaterialDomain() == MaterialDomain::SURFACE) {
|
||||
|
||||
@@ -607,7 +620,7 @@ void FEngine::shutdown() {
|
||||
|
||||
// now wait for all pending commands to be executed and the thread to exit
|
||||
mCommandBufferQueue.requestExit();
|
||||
if (!UTILS_HAS_THREADING) {
|
||||
if constexpr (!UTILS_HAS_THREADING) {
|
||||
execute();
|
||||
getDriverApi().terminate();
|
||||
} else {
|
||||
@@ -638,13 +651,13 @@ void FEngine::prepare() {
|
||||
DriverApi& driver = getDriverApi();
|
||||
|
||||
for (auto& materialInstanceList: mMaterialInstances) {
|
||||
materialInstanceList.second.forEach([&driver](FMaterialInstance* item) {
|
||||
materialInstanceList.second.forEach([&driver](FMaterialInstance const* item) {
|
||||
item->commit(driver);
|
||||
});
|
||||
}
|
||||
|
||||
mMaterials.forEach([](FMaterial* material) {
|
||||
#if FILAMENT_ENABLE_MATDBG
|
||||
#if FILAMENT_ENABLE_MATDBG // NOLINT(*-include-cleaner)
|
||||
material->checkProgramEdits();
|
||||
#endif
|
||||
});
|
||||
@@ -668,7 +681,7 @@ void FEngine::flushAndWait() {
|
||||
flushAndWait(FENCE_WAIT_FOR_EVER);
|
||||
}
|
||||
|
||||
bool FEngine::flushAndWait(uint64_t timeout) {
|
||||
bool FEngine::flushAndWait(uint64_t const timeout) {
|
||||
FILAMENT_CHECK_PRECONDITION(!mCommandBufferQueue.isPaused())
|
||||
<< "Cannot call Engine::flushAndWait() when rendering thread is paused!";
|
||||
|
||||
@@ -749,7 +762,7 @@ int FEngine::loop() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if FILAMENT_ENABLE_FGVIEWER
|
||||
#if FILAMENT_ENABLE_FGVIEWER // NOLINT(*-include-cleaner)
|
||||
#ifdef __ANDROID__
|
||||
const char* fgviewerPortString = "8085";
|
||||
#else
|
||||
@@ -779,9 +792,9 @@ int FEngine::loop() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FEngine::flushCommandBuffer(CommandBufferQueue& commandQueue) {
|
||||
void FEngine::flushCommandBuffer(CommandBufferQueue& commandBufferQueue) const {
|
||||
getDriver().purge();
|
||||
commandQueue.flush();
|
||||
commandBufferQueue.flush();
|
||||
}
|
||||
|
||||
const FMaterial* FEngine::getSkyboxMaterial() const noexcept {
|
||||
@@ -802,7 +815,7 @@ const FMaterial* FEngine::getSkyboxMaterial() const noexcept {
|
||||
*/
|
||||
|
||||
template<typename T, typename ... ARGS>
|
||||
inline T* FEngine::create(ResourceList<T>& list,
|
||||
T* FEngine::create(ResourceList<T>& list,
|
||||
typename T::Builder const& builder, ARGS&& ... args) noexcept {
|
||||
T* p = mHeapAllocator.make<T>(*this, builder, std::forward<ARGS>(args)...);
|
||||
if (UTILS_LIKELY(p)) {
|
||||
@@ -880,7 +893,7 @@ FMaterialInstance* FEngine::createMaterialInstance(const FMaterial* material,
|
||||
const FMaterialInstance* other, const char* name) noexcept {
|
||||
FMaterialInstance* p = mHeapAllocator.make<FMaterialInstance>(*this, other, name);
|
||||
if (UTILS_LIKELY(p)) {
|
||||
auto pos = mMaterialInstances.emplace(material, "MaterialInstance");
|
||||
auto const pos = mMaterialInstances.emplace(material, "MaterialInstance");
|
||||
pos.first->second.insert(p);
|
||||
}
|
||||
return p;
|
||||
@@ -958,7 +971,7 @@ FCamera* FEngine::createCamera(Entity const entity) noexcept {
|
||||
}
|
||||
|
||||
FCamera* FEngine::getCameraComponent(Entity const entity) noexcept {
|
||||
auto ci = mCameraManager.getInstance(entity);
|
||||
auto const ci = mCameraManager.getInstance(entity);
|
||||
return ci ? mCameraManager.getCamera(ci) : nullptr;
|
||||
}
|
||||
|
||||
@@ -1011,16 +1024,16 @@ void FEngine::cleanupResourceListLocked(Lock& lock, ResourceList<T>&& list) {
|
||||
|
||||
template<typename T>
|
||||
UTILS_ALWAYS_INLINE
|
||||
inline bool FEngine::isValid(const T* ptr, ResourceList<T> const& list) const {
|
||||
bool FEngine::isValid(const T* ptr, ResourceList<T> const& list) const {
|
||||
auto& l = const_cast<ResourceList<T>&>(list);
|
||||
return l.find(ptr) != l.end();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
UTILS_ALWAYS_INLINE
|
||||
inline bool FEngine::terminateAndDestroy(const T* ptr, ResourceList<T>& list) {
|
||||
if (ptr == nullptr) return true;
|
||||
bool const success = list.remove(ptr);
|
||||
bool FEngine::terminateAndDestroy(const T* p, ResourceList<T>& list) {
|
||||
if (p == nullptr) return true;
|
||||
bool const success = list.remove(p);
|
||||
|
||||
#if UTILS_HAS_RTTI
|
||||
auto typeName = CallStack::typeName<T>();
|
||||
@@ -1030,19 +1043,19 @@ inline bool FEngine::terminateAndDestroy(const T* ptr, ResourceList<T>& list) {
|
||||
#endif
|
||||
|
||||
if (ASSERT_PRECONDITION_NON_FATAL(success,
|
||||
"Object %s at %p doesn't exist (double free?)", typeNameCStr, ptr)) {
|
||||
const_cast<T*>(ptr)->terminate(*this);
|
||||
mHeapAllocator.destroy(const_cast<T*>(ptr));
|
||||
"Object %s at %p doesn't exist (double free?)", typeNameCStr, p)) {
|
||||
const_cast<T*>(p)->terminate(*this);
|
||||
mHeapAllocator.destroy(const_cast<T*>(p));
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
template<typename T, typename Lock>
|
||||
UTILS_ALWAYS_INLINE
|
||||
inline bool FEngine::terminateAndDestroyLocked(Lock& lock, const T* ptr, ResourceList<T>& list) {
|
||||
if (ptr == nullptr) return true;
|
||||
bool FEngine::terminateAndDestroyLocked(Lock& lock, const T* p, ResourceList<T>& list) {
|
||||
if (p == nullptr) return true;
|
||||
lock.lock();
|
||||
bool const success = list.remove(ptr);
|
||||
bool const success = list.remove(p);
|
||||
lock.unlock();
|
||||
|
||||
#if UTILS_HAS_RTTI
|
||||
@@ -1053,9 +1066,9 @@ inline bool FEngine::terminateAndDestroyLocked(Lock& lock, const T* ptr, Resourc
|
||||
#endif
|
||||
|
||||
if (ASSERT_PRECONDITION_NON_FATAL(success,
|
||||
"Object %s at %p doesn't exist (double free?)", typeNameCStr, ptr)) {
|
||||
const_cast<T*>(ptr)->terminate(*this);
|
||||
mHeapAllocator.destroy(const_cast<T*>(ptr));
|
||||
"Object %s at %p doesn't exist (double free?)", typeNameCStr, p)) {
|
||||
const_cast<T*>(p)->terminate(*this);
|
||||
mHeapAllocator.destroy(const_cast<T*>(p));
|
||||
}
|
||||
return success;
|
||||
}
|
||||
@@ -1148,11 +1161,11 @@ bool FEngine::destroy(const FInstanceBuffer* p){
|
||||
}
|
||||
|
||||
UTILS_NOINLINE
|
||||
bool FEngine::destroy(const FMaterial* ptr) {
|
||||
if (ptr == nullptr) return true;
|
||||
bool const success = terminateAndDestroy(ptr, mMaterials);
|
||||
bool FEngine::destroy(const FMaterial* p) {
|
||||
if (p == nullptr) return true;
|
||||
bool const success = terminateAndDestroy(p, mMaterials);
|
||||
if (UTILS_LIKELY(success)) {
|
||||
auto pos = mMaterialInstances.find(ptr);
|
||||
auto const pos = mMaterialInstances.find(p);
|
||||
if (UTILS_LIKELY(pos != mMaterialInstances.cend())) {
|
||||
mMaterialInstances.erase(pos);
|
||||
}
|
||||
@@ -1161,8 +1174,8 @@ bool FEngine::destroy(const FMaterial* ptr) {
|
||||
}
|
||||
|
||||
UTILS_NOINLINE
|
||||
bool FEngine::destroy(const FMaterialInstance* ptr) {
|
||||
if (ptr == nullptr) return true;
|
||||
bool FEngine::destroy(const FMaterialInstance* p) {
|
||||
if (p == nullptr) return true;
|
||||
|
||||
// Check that the material instance we're destroying is not in use in the RenderableManager
|
||||
// To do this, we currently need to inspect all render primitives in the RenderableManager
|
||||
@@ -1178,13 +1191,13 @@ bool FEngine::destroy(const FMaterialInstance* ptr) {
|
||||
for (size_t j = 0; j < primitiveCount; j++) {
|
||||
auto const* const mi = rcm.getMaterialInstanceAt(ri, 0, j);
|
||||
if (features.engine.debug.assert_material_instance_in_use) {
|
||||
FILAMENT_CHECK_PRECONDITION(mi != ptr)
|
||||
FILAMENT_CHECK_PRECONDITION(mi != p)
|
||||
<< "destroying MaterialInstance \""
|
||||
<< mi->getName() << "\" which is still in use by Renderable (entity="
|
||||
<< entity.getId() << ", instance="
|
||||
<< ri.asValue() << ", index=" << j << ")";
|
||||
} else {
|
||||
if (UTILS_UNLIKELY(mi == ptr)) {
|
||||
if (UTILS_UNLIKELY(mi == p)) {
|
||||
slog.e << "destroying MaterialInstance \""
|
||||
<< mi->getName() << "\" which is still in use by Renderable (entity="
|
||||
<< entity.getId() << ", instance="
|
||||
@@ -1196,11 +1209,11 @@ bool FEngine::destroy(const FMaterialInstance* ptr) {
|
||||
}
|
||||
}
|
||||
|
||||
if (ptr->isDefaultInstance()) return false;
|
||||
auto pos = mMaterialInstances.find(ptr->getMaterial());
|
||||
if (p->isDefaultInstance()) return false;
|
||||
auto const pos = mMaterialInstances.find(p->getMaterial());
|
||||
assert_invariant(pos != mMaterialInstances.cend());
|
||||
if (pos != mMaterialInstances.cend()) {
|
||||
return terminateAndDestroy(ptr, pos->second);
|
||||
return terminateAndDestroy(p, pos->second);
|
||||
}
|
||||
// this shouldn't happen, this would be double-free
|
||||
return false;
|
||||
@@ -1253,7 +1266,7 @@ bool FEngine::isValid(const FMaterial* m, const FMaterialInstance* p) const {
|
||||
}
|
||||
|
||||
// then find the material instance list for that material
|
||||
auto it = mMaterialInstances.find(m);
|
||||
auto const it = mMaterialInstances.find(m);
|
||||
if (it == mMaterialInstances.end()) {
|
||||
// this could happen if this material has no material instances at all
|
||||
return false;
|
||||
@@ -1342,7 +1355,7 @@ void* FEngine::streamAlloc(size_t const size, size_t const alignment) noexcept {
|
||||
|
||||
bool FEngine::execute() {
|
||||
// wait until we get command buffers to be executed (or thread exit requested)
|
||||
auto buffers = mCommandBufferQueue.waitForCommands();
|
||||
auto const buffers = mCommandBufferQueue.waitForCommands();
|
||||
if (UTILS_UNLIKELY(buffers.empty())) {
|
||||
return false;
|
||||
}
|
||||
@@ -1381,7 +1394,7 @@ Engine::FeatureLevel FEngine::getSupportedFeatureLevel() const noexcept {
|
||||
|
||||
Engine::FeatureLevel FEngine::setActiveFeatureLevel(FeatureLevel featureLevel) {
|
||||
FILAMENT_CHECK_PRECONDITION(featureLevel <= getSupportedFeatureLevel())
|
||||
<< "Feature level " << (unsigned)featureLevel << " not supported";
|
||||
<< "Feature level " << unsigned(featureLevel) << " not supported";
|
||||
FILAMENT_CHECK_PRECONDITION(mActiveFeatureLevel >= FeatureLevel::FEATURE_LEVEL_1)
|
||||
<< "Cannot adjust feature level beyond 0 at runtime";
|
||||
return (mActiveFeatureLevel = std::max(mActiveFeatureLevel, featureLevel));
|
||||
@@ -1400,7 +1413,7 @@ void FEngine::unprotected() noexcept {
|
||||
mUnprotectedDummySwapchain->makeCurrent(getDriverApi());
|
||||
}
|
||||
|
||||
bool FEngine::setFeatureFlag(char const* name, bool const value) noexcept {
|
||||
bool FEngine::setFeatureFlag(char const* name, bool const value) const noexcept {
|
||||
auto* const p = getFeatureFlagPtr(name);
|
||||
if (p) {
|
||||
*p = value;
|
||||
@@ -1471,7 +1484,7 @@ Engine::Builder& Engine::Builder::feature(char const* name, bool const value) no
|
||||
}
|
||||
|
||||
Engine::Builder& Engine::Builder::features(std::initializer_list<char const *> const list) noexcept {
|
||||
for (auto name : list) {
|
||||
for (auto const name : list) {
|
||||
if (name) {
|
||||
feature(name, true);
|
||||
}
|
||||
@@ -1500,15 +1513,15 @@ Engine::Config Engine::BuilderDetails::validateConfig(Config config) noexcept {
|
||||
// Use at least the defaults set by the build system
|
||||
config.minCommandBufferSizeMB = std::max(
|
||||
config.minCommandBufferSizeMB,
|
||||
(uint32_t)FILAMENT_MIN_COMMAND_BUFFERS_SIZE_IN_MB);
|
||||
uint32_t(FILAMENT_MIN_COMMAND_BUFFERS_SIZE_IN_MB)); // NOLINT(*-include-cleaner)
|
||||
|
||||
config.perFrameCommandsSizeMB = std::max(
|
||||
config.perFrameCommandsSizeMB,
|
||||
(uint32_t)FILAMENT_PER_FRAME_COMMANDS_SIZE_IN_MB);
|
||||
uint32_t(FILAMENT_PER_FRAME_COMMANDS_SIZE_IN_MB)); // NOLINT(*-include-cleaner)
|
||||
|
||||
config.perRenderPassArenaSizeMB = std::max(
|
||||
config.perRenderPassArenaSizeMB,
|
||||
(uint32_t)FILAMENT_PER_RENDER_PASS_ARENA_SIZE_IN_MB);
|
||||
uint32_t(FILAMENT_PER_RENDER_PASS_ARENA_SIZE_IN_MB)); // NOLINT(*-include-cleaner)
|
||||
|
||||
config.commandBufferSizeMB = std::max(
|
||||
config.commandBufferSizeMB,
|
||||
|
||||
@@ -519,7 +519,7 @@ private:
|
||||
void shutdown();
|
||||
|
||||
int loop();
|
||||
void flushCommandBuffer(backend::CommandBufferQueue& commandBufferQueue);
|
||||
void flushCommandBuffer(backend::CommandBufferQueue& commandBufferQueue) const;
|
||||
|
||||
template<typename T>
|
||||
bool isValid(const T* ptr, ResourceList<T> const& list) const;
|
||||
@@ -730,7 +730,7 @@ public:
|
||||
return { mFeatures.data(), mFeatures.size() };
|
||||
}
|
||||
|
||||
bool setFeatureFlag(char const* name, bool value) noexcept;
|
||||
bool setFeatureFlag(char const* name, bool value) const noexcept;
|
||||
std::optional<bool> getFeatureFlag(char const* name) const noexcept;
|
||||
bool* getFeatureFlagPtr(std::string_view name, bool allowConstant = false) const noexcept;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user