Skip to content

Commit

Permalink
fix some missing includes and trivial warnings (#8414)
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelflinger authored Feb 7, 2025
1 parent c16cab2 commit 559bc4e
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 103 deletions.
84 changes: 43 additions & 41 deletions filament/backend/src/opengl/OpenGLDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,19 @@
#include <backend/Program.h>
#include <backend/TargetBufferInfo.h>

#include "private/backend/CommandStream.h"
#include "private/backend/Dispatcher.h"
#include "private/backend/DriverApi.h"

#include <type_traits>
#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>
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) };
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -2381,7 +2383,7 @@ bool OpenGLDriver::isDepthStencilResolveSupported() {
return true;
}

bool OpenGLDriver::isDepthStencilBlitSupported(TextureFormat format) {
bool OpenGLDriver::isDepthStencilBlitSupported(TextureFormat) {
return true;
}

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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));
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -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()
}

Expand Down Expand Up @@ -3595,19 +3597,19 @@ 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;
ds->update(mContext, binding, bo, offset, size);
}

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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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();

Expand Down
6 changes: 3 additions & 3 deletions filament/backend/src/opengl/OpenGLDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,13 @@ class OpenGLDriver final : public OpenGLDriverBase {

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,
Expand Down Expand Up @@ -347,7 +347,7 @@ class OpenGLDriver final : public OpenGLDriverBase {
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;
Expand Down
Loading

0 comments on commit 559bc4e

Please sign in to comment.