Experimental optimizations, not yet ready for stable branch

--HG--
branch : async_streaming
This commit is contained in:
2013-10-08 20:44:31 -07:00
parent 4dddec7f85
commit e849f55b34
6 changed files with 52 additions and 3 deletions

View File

@@ -1720,6 +1720,7 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_UNROLL_LOOPS = YES;
GCC_VERSION = com.apple.compilers.llvmgcc42;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
@@ -1728,6 +1729,7 @@
"$(SRCROOT)/3rdparty/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
LLVM_VECTORIZE_LOOPS = YES;
MACOSX_DEPLOYMENT_TARGET = 10.6;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
@@ -1741,6 +1743,8 @@
CLANG_CXX_LIBRARY = "libc++";
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_OPTIMIZATION_LEVEL = fast;
GCC_UNROLL_LOOPS = YES;
GCC_VERSION = com.apple.compilers.llvmgcc42;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
@@ -1749,6 +1753,7 @@
"$(SRCROOT)/3rdparty/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
LLVM_VECTORIZE_LOOPS = YES;
MACOSX_DEPLOYMENT_TARGET = 10.6;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;

View File

@@ -87,7 +87,7 @@ float KRMat4::operator[](unsigned i) const {
}
// Overload comparison operator
bool KRMat4::operator==(const KRMat4 &m) {
bool KRMat4::operator==(const KRMat4 &m) const {
return memcmp(c, m.c, sizeof(float) * 16) == 0;
}

View File

@@ -83,7 +83,7 @@ class KRMat4 {
KRMat4& operator=(const KRMat4 &m);
// Overload comparison operator
bool operator==(const KRMat4 &m);
bool operator==(const KRMat4 &m) const;
// Overload compound multiply operator
KRMat4& operator*=(const KRMat4 &m);

View File

@@ -214,7 +214,15 @@ void KRMeshManager::bindVBO(GLvoid *data, GLsizeiptr size, GLvoid *index_data, G
#endif
GLDEBUG(glBindBuffer(GL_ARRAY_BUFFER, m_currentVBO.vbo_handle));
#if GL_OES_mapbuffer
GLDEBUG(glBufferData(GL_ARRAY_BUFFER, size, NULL, static_vbo ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW));
GLDEBUG(void *map_ptr = glMapBufferOES(GL_ARRAY_BUFFER, GL_WRITE_ONLY_OES));
memcpy(map_ptr, data, size);
GLDEBUG(glUnmapBufferOES(GL_ARRAY_BUFFER));
#else
GLDEBUG(glBufferData(GL_ARRAY_BUFFER, size, data, static_vbo ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW));
#endif
m_memoryTransferredThisFrame += size;
m_vboMemUsed += size;
configureAttribs(vertex_attrib_flags);
@@ -226,7 +234,17 @@ void KRMeshManager::bindVBO(GLvoid *data, GLsizeiptr size, GLvoid *index_data, G
GLDEBUG(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
} else {
GLDEBUG(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_currentVBO.vbo_handle_indexes));
#if GL_OES_mapbuffer
GLDEBUG(glBufferData(GL_ELEMENT_ARRAY_BUFFER, index_data_size, NULL, static_vbo ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW));
GLDEBUG(void *map_ptr = glMapBufferOES(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY_OES));
memcpy(map_ptr, index_data, index_data_size);
GLDEBUG(glUnmapBufferOES(GL_ELEMENT_ARRAY_BUFFER));
#else
GLDEBUG(glBufferData(GL_ELEMENT_ARRAY_BUFFER, index_data_size, index_data, static_vbo ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW));
#endif
m_memoryTransferredThisFrame += index_data_size;
m_vboMemUsed += index_data_size;
m_currentVBO.size += index_data_size;

View File

@@ -43,6 +43,23 @@ KRModel::KRModel(KRScene &scene, std::string instance_name, std::string model_na
m_min_lod_coverage = lod_min_coverage;
m_receivesShadow = receives_shadow;
m_faces_camera = faces_camera;
m_boundsCachedMat.c[0] = -1.0f;
m_boundsCachedMat.c[1] = -1.0f;
m_boundsCachedMat.c[2] = -1.0f;
m_boundsCachedMat.c[3] = -1.0f;
m_boundsCachedMat.c[4] = -1.0f;
m_boundsCachedMat.c[5] = -1.0f;
m_boundsCachedMat.c[6] = -1.0f;
m_boundsCachedMat.c[7] = -1.0f;
m_boundsCachedMat.c[8] = -1.0f;
m_boundsCachedMat.c[9] = -1.0f;
m_boundsCachedMat.c[10] = -1.0f;
m_boundsCachedMat.c[11] = -1.0f;
m_boundsCachedMat.c[12] = -1.0f;
m_boundsCachedMat.c[13] = -1.0f;
m_boundsCachedMat.c[14] = -1.0f;
m_boundsCachedMat.c[15] = -1.0f;
}
KRModel::~KRModel() {
@@ -155,7 +172,12 @@ KRAABB KRModel::getBounds() {
float max_dimension = normal_bounds.longest_radius();
return KRAABB(normal_bounds.center()-KRVector3(max_dimension), normal_bounds.center() + KRVector3(max_dimension));
} else {
return KRAABB(m_models[0]->getMinPoint(), m_models[0]->getMaxPoint(), getModelMatrix());
if(!(m_boundsCachedMat == getModelMatrix())) {
m_boundsCachedMat = getModelMatrix();
m_boundsCached = KRAABB(m_models[0]->getMinPoint(), m_models[0]->getMaxPoint(), getModelMatrix());
}
return m_boundsCached;
}
} else {
return KRAABB::Infinite();

View File

@@ -74,6 +74,10 @@ private:
bool m_receivesShadow;
bool m_faces_camera;
KRMat4 m_boundsCachedMat;
KRAABB m_boundsCached;
};