code size optimizations
- prevent unrolling of some loops. e.g. one loop generated more than 1 KB of code!
This commit is contained in:
committed by
Mathias Agopian
parent
5bcc4cfff1
commit
815fb36b98
@@ -134,6 +134,7 @@ FVertexBuffer::FVertexBuffer(FEngine& engine, const VertexBuffer::Builder& build
|
||||
|
||||
auto const& declaredAttributes = mDeclaredAttributes;
|
||||
auto const& attributes = mAttributes;
|
||||
#pragma nounroll
|
||||
for (size_t i = 0, n = attributeArray.size(); i < n; ++i) {
|
||||
if (declaredAttributes[i]) {
|
||||
attributeArray[i].offset = attributes[i].offset;
|
||||
|
||||
@@ -401,6 +401,7 @@ void OpenGLDriver::unbindTexture(GLenum target, GLuint texture_id) noexcept {
|
||||
|
||||
void OpenGLDriver::unbindSampler(GLuint sampler) noexcept {
|
||||
// unbind this sampler from all the units it might be bound to
|
||||
#pragma nounroll // clang generates >800B of code!!!
|
||||
for (GLuint unit = 0; unit < MAX_TEXTURE_UNITS; unit++) {
|
||||
if (state.textures.units[unit].sampler == sampler) {
|
||||
bindSampler(unit, 0);
|
||||
@@ -1260,6 +1261,7 @@ void OpenGLDriver::destroyVertexBuffer(Driver::VertexBufferHandle vbh) {
|
||||
// bindings of bound buffers are reset to 0
|
||||
const size_t targetIndex = getIndexForBufferTarget(GL_ARRAY_BUFFER);
|
||||
auto& target = state.buffers.genericBinding[targetIndex];
|
||||
#pragma nounroll
|
||||
for (GLuint b : eb->gl.buffers) {
|
||||
if (target == b) {
|
||||
target = 0;
|
||||
@@ -1326,6 +1328,8 @@ void OpenGLDriver::destroyUniformBuffer(Driver::UniformBufferHandle ubh) {
|
||||
// bindings of bound buffers are reset to 0
|
||||
const size_t targetIndex = getIndexForBufferTarget(GL_UNIFORM_BUFFER);
|
||||
auto& target = state.buffers.targets[targetIndex];
|
||||
|
||||
#pragma nounroll // clang generates >1 KiB of code!!
|
||||
for (auto& buffer : target.buffers) {
|
||||
if (buffer.name == ub->gl.ubo.id) {
|
||||
buffer.name = 0;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
#include <filament/EngineEnums.h>
|
||||
|
||||
#include <tsl/robin_map.h>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace filament {
|
||||
|
||||
@@ -89,7 +89,7 @@ private:
|
||||
return ((uint32_t) blockIndex << 8) + localOffset;
|
||||
}
|
||||
std::vector<SamplerBindingInfo> mBindingList;
|
||||
std::unordered_map<BindingKey, SamplerBindingInfo> mBindingMap;
|
||||
tsl::robin_map<BindingKey, SamplerBindingInfo> mBindingMap;
|
||||
uint8_t mSamplerBlockOffsets[filament::BindingPoints::COUNT] = { UNKNOWN_OFFSET };
|
||||
};
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ Profiler::Profiler() noexcept {
|
||||
}
|
||||
|
||||
Profiler::~Profiler() noexcept {
|
||||
#pragma nounroll
|
||||
for (int fd : mCountersFd) {
|
||||
if (fd >= 0) {
|
||||
close(fd);
|
||||
@@ -72,6 +73,7 @@ Profiler::~Profiler() noexcept {
|
||||
|
||||
uint32_t Profiler::resetEvents(uint32_t eventMask) noexcept {
|
||||
// close all counters
|
||||
#pragma nounroll
|
||||
for (int& fd : mCountersFd) {
|
||||
if (fd >= 0) {
|
||||
close(fd);
|
||||
@@ -133,7 +135,7 @@ uint32_t Profiler::resetEvents(uint32_t eventMask) noexcept {
|
||||
mEnabledEvents |= EV_L1D_MISSES;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (eventMask & EV_BPU_REFS) {
|
||||
pe.type = PERF_TYPE_HARDWARE;
|
||||
pe.config = PERF_COUNT_HW_BRANCH_INSTRUCTIONS;
|
||||
@@ -143,7 +145,7 @@ uint32_t Profiler::resetEvents(uint32_t eventMask) noexcept {
|
||||
mEnabledEvents |= EV_BPU_REFS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (eventMask & EV_BPU_MISSES) {
|
||||
pe.type = PERF_TYPE_HARDWARE;
|
||||
pe.config = PERF_COUNT_HW_BRANCH_MISSES;
|
||||
@@ -153,7 +155,7 @@ uint32_t Profiler::resetEvents(uint32_t eventMask) noexcept {
|
||||
mEnabledEvents |= EV_BPU_MISSES;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef __ARM_ARCH
|
||||
if (eventMask & EV_L1I_REFS) {
|
||||
pe.type = PERF_TYPE_RAW;
|
||||
|
||||
Reference in New Issue
Block a user