code maintenance/cleanups
- try to help DataReshaper a bit - fix some typos in comments - address a few "todos" - protect mActivePrograms with a lock, as it should
This commit is contained in:
committed by
Mathias Agopian
parent
6a1cc3abe9
commit
5906d144dd
@@ -40,12 +40,13 @@ public:
|
||||
// trailing channels. This is useful for platforms that only accept 4-component data, since
|
||||
// users often wish to submit (or receive) 3-component data.
|
||||
template<typename componentType, size_t srcChannelCount, size_t dstChannelCount>
|
||||
static void reshape(void* dest, const void* src, size_t numSrcBytes) {
|
||||
static void reshape(void* UTILS_RESTRICT dest, const void* UTILS_RESTRICT src,
|
||||
size_t numSrcBytes) {
|
||||
const componentType maxValue = getMaxValue<componentType>();
|
||||
const componentType* in = (const componentType*) src;
|
||||
componentType* out = (componentType*) dest;
|
||||
const size_t width = (numSrcBytes / sizeof(componentType)) / srcChannelCount;
|
||||
const int minChannelCount = filament::math::min(srcChannelCount, dstChannelCount);
|
||||
constexpr size_t minChannelCount = math::min(srcChannelCount, dstChannelCount);
|
||||
for (size_t column = 0; column < width; ++column) {
|
||||
for (size_t channel = 0; channel < minChannelCount; ++channel) {
|
||||
out[channel] = in[channel];
|
||||
@@ -60,24 +61,26 @@ public:
|
||||
|
||||
// Converts a n-channel image of UBYTE, INT, UINT, or FLOAT to a different type.
|
||||
template<typename dstComponentType, typename srcComponentType>
|
||||
static void reshapeImage(uint8_t* dest, const uint8_t* src, size_t srcBytesPerRow,
|
||||
static void reshapeImage(uint8_t* UTILS_RESTRICT dest, const uint8_t* UTILS_RESTRICT src,
|
||||
size_t srcBytesPerRow,
|
||||
size_t srcChannelCount, size_t dstBytesPerRow, size_t dstChannelCount,
|
||||
size_t width, size_t height, bool swizzle) {
|
||||
const dstComponentType dstMaxValue = getMaxValue<dstComponentType>();
|
||||
const srcComponentType srcMaxValue = getMaxValue<srcComponentType>();
|
||||
const size_t minChannelCount = filament::math::min(srcChannelCount, dstChannelCount);
|
||||
const size_t minChannelCount = math::min(srcChannelCount, dstChannelCount);
|
||||
assert_invariant(minChannelCount <= 4);
|
||||
const int inds[4] = {swizzle ? 2 : 0, 1, swizzle ? 0 : 2, 3};
|
||||
UTILS_ASSUME(minChannelCount <= 4);
|
||||
const int inds[4] = { swizzle ? 2 : 0, 1, swizzle ? 0 : 2, 3 };
|
||||
for (size_t row = 0; row < height; ++row) {
|
||||
const srcComponentType* in = (const srcComponentType*) src;
|
||||
dstComponentType* out = (dstComponentType*) dest;
|
||||
const srcComponentType* in = (const srcComponentType*)src;
|
||||
dstComponentType* out = (dstComponentType*)dest;
|
||||
for (size_t column = 0; column < width; ++column) {
|
||||
for (size_t channel = 0; channel < minChannelCount; ++channel) {
|
||||
if constexpr (std::is_same_v<dstComponentType, srcComponentType>) {
|
||||
out[channel] = in[inds[channel]];
|
||||
} else {
|
||||
// TODO: beware of overflows in the multiply
|
||||
// TODO: probably not correct for _INTEGER src/dst
|
||||
// FIXME: beware of overflows in the multiply
|
||||
// FIXME: probably not correct for _INTEGER src/dst
|
||||
out[channel] = in[inds[channel]] * dstMaxValue / srcMaxValue;
|
||||
}
|
||||
}
|
||||
@@ -93,9 +96,9 @@ public:
|
||||
}
|
||||
|
||||
// Converts a n-channel image of UBYTE, INT, UINT, or FLOAT to a different type.
|
||||
static bool reshapeImage(PixelBufferDescriptor* dst, PixelDataType srcType,
|
||||
uint32_t srcChannelCount, const uint8_t* srcBytes, int srcBytesPerRow, int width,
|
||||
int height, bool swizzle) {
|
||||
static bool reshapeImage(PixelBufferDescriptor* UTILS_RESTRICT dst, PixelDataType srcType,
|
||||
uint32_t srcChannelCount, const uint8_t* UTILS_RESTRICT srcBytes, int srcBytesPerRow,
|
||||
int width, int height, bool swizzle) {
|
||||
size_t dstChannelCount;
|
||||
switch (dst->format) {
|
||||
case PixelDataFormat::R_INTEGER: dstChannelCount = 1; break;
|
||||
|
||||
@@ -1946,7 +1946,7 @@ void OpenGLDriver::setCompressedTextureData(GLTexture* t, uint32_t level,
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: maybe assert that the CompressedPixelDataType is the same than the internalFormat
|
||||
// TODO: maybe assert that the CompressedPixelDataType is the same as the internalFormat
|
||||
|
||||
GLsizei imageSize = GLsizei(p.imageSize);
|
||||
|
||||
|
||||
@@ -86,11 +86,6 @@ FrameGraphId<FrameGraphTexture> RendererUtils::colorPass(
|
||||
}
|
||||
|
||||
if (!data.color) {
|
||||
// FIXME: this works only when the viewport is full
|
||||
// if (view.isSkyboxVisible()) {
|
||||
// // if the skybox is visible, then we don't need to clear at all
|
||||
// clearColorFlags &= ~TargetBufferFlags::COLOR;
|
||||
// }
|
||||
data.color = builder.createTexture("Color Buffer", colorBufferDesc);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ size_t ResourceAllocator::TextureKey::getSize() const noexcept {
|
||||
size += size / 3;
|
||||
}
|
||||
// TODO: this is not taking into account the potential sidecar MS buffer
|
||||
// but we have not way to know about its existence at this point.
|
||||
// but we have no way to know about its existence at this point.
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
@@ -539,6 +539,7 @@ void FMaterial::onEditCallback(void* userdata, const utils::CString& name, const
|
||||
|
||||
void FMaterial::onQueryCallback(void* userdata, VariantList* pVariants) {
|
||||
FMaterial* material = upcast((Material*) userdata);
|
||||
std::lock_guard<utils::Mutex> lock(material->mActiveProgramsLock);
|
||||
*pVariants = material->mActivePrograms;
|
||||
material->mActivePrograms.reset();
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <private/filament/Variant.h>
|
||||
|
||||
#include <utils/compiler.h>
|
||||
#include <utils/Mutex.h>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
@@ -90,7 +91,9 @@ public:
|
||||
[[nodiscard]] backend::Handle<backend::HwProgram> getProgram(Variant variant) const noexcept {
|
||||
#if FILAMENT_ENABLE_MATDBG
|
||||
assert_invariant(variant.key < VARIANT_COUNT);
|
||||
std::unique_lock<utils::Mutex> lock(mActiveProgramsLock);
|
||||
mActivePrograms.set(variant.key);
|
||||
lock.unlock();
|
||||
#endif
|
||||
assert_invariant(mCachedPrograms[variant.key]);
|
||||
return mCachedPrograms[variant.key];
|
||||
@@ -225,7 +228,7 @@ private:
|
||||
|
||||
#if FILAMENT_ENABLE_MATDBG
|
||||
matdbg::MaterialKey mDebuggerId;
|
||||
// TODO: this should be protected with a mutex
|
||||
mutable utils::Mutex mActiveProgramsLock;
|
||||
mutable VariantList mActivePrograms;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -554,8 +554,6 @@ void FRenderer::renderJob(ArenaScope& arena, FView& view) {
|
||||
// But, this a no-op in common resolutions, in particular in 720p.
|
||||
// The origin of rendering is not modified, the padding is added to the right/top.
|
||||
//
|
||||
// TODO: use this feature to implement guard-bands
|
||||
//
|
||||
// TODO: Should we enable when we don't have post-processing?
|
||||
// Without post-processing, we usually draw directly into
|
||||
// the SwapChain, and we might want to keep it this way.
|
||||
|
||||
@@ -455,7 +455,7 @@ bool FScene::hasContactShadows() const noexcept {
|
||||
}
|
||||
|
||||
// find out if at least one light has contact-shadow enabled
|
||||
// TODO: we could cache the the result of this Loop in the LightManager
|
||||
// TODO: we could cache the result of this Loop in the LightManager
|
||||
auto& lcm = mEngine.getLightManager();
|
||||
const auto *pFirst = mLightData.begin<LIGHT_INSTANCE>();
|
||||
const auto *pLast = mLightData.end<LIGHT_INSTANCE>();
|
||||
|
||||
@@ -658,7 +658,7 @@ void FView::prepareCamera(const CameraInfo& cameraInfo) const noexcept {
|
||||
void FView::prepareViewport(const filament::Viewport& viewport,
|
||||
uint32_t xoffset, uint32_t yoffset) const noexcept {
|
||||
SYSTRACE_CALL();
|
||||
// TODO: we should pass viewport.{left|bottom} to the backend so it can offset the
|
||||
// TODO: we should pass viewport.{left|bottom} to the backend, so it can offset the
|
||||
// scissor properly.
|
||||
mPerViewUniforms.prepareViewport(viewport, xoffset, yoffset);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user