Merge pull request #8333 from SamGondelman/miscFixes

Miscellaneous cmake and render engine improvements
This commit is contained in:
Brad Hefta-Gaub 2016-08-10 11:06:50 -07:00 committed by GitHub
commit a714f325fe
13 changed files with 31 additions and 43 deletions

View file

@ -23,13 +23,13 @@ function(AUTOSCRIBE_SHADER SHADER_FILE)
#Extract the unique include shader paths #Extract the unique include shader paths
set(INCLUDES ${HIFI_LIBRARIES_SHADER_INCLUDE_FILES}) set(INCLUDES ${HIFI_LIBRARIES_SHADER_INCLUDE_FILES})
#message(Hifi for includes ${INCLUDES}) #message(${TARGET_NAME} Hifi for includes ${INCLUDES})
foreach(EXTRA_SHADER_INCLUDE ${INCLUDES}) foreach(EXTRA_SHADER_INCLUDE ${INCLUDES})
list(APPEND SHADER_INCLUDES_PATHS ${EXTRA_SHADER_INCLUDE}) list(APPEND SHADER_INCLUDES_PATHS ${EXTRA_SHADER_INCLUDE})
endforeach() endforeach()
list(REMOVE_DUPLICATES SHADER_INCLUDES_PATHS) list(REMOVE_DUPLICATES SHADER_INCLUDES_PATHS)
#message(ready for includes ${SHADER_INCLUDES_PATHS}) #message(ready for includes ${SHADER_INCLUDES_PATHS})
# make the scribe include arguments # make the scribe include arguments
set(SCRIBE_INCLUDES) set(SCRIBE_INCLUDES)
@ -77,6 +77,7 @@ endfunction()
macro(AUTOSCRIBE_SHADER_LIB) macro(AUTOSCRIBE_SHADER_LIB)
set(HIFI_LIBRARIES_SHADER_INCLUDE_FILES "")
file(RELATIVE_PATH RELATIVE_LIBRARY_DIR_PATH ${CMAKE_CURRENT_SOURCE_DIR} "${HIFI_LIBRARY_DIR}") file(RELATIVE_PATH RELATIVE_LIBRARY_DIR_PATH ${CMAKE_CURRENT_SOURCE_DIR} "${HIFI_LIBRARY_DIR}")
foreach(HIFI_LIBRARY ${ARGN}) foreach(HIFI_LIBRARY ${ARGN})
#if (NOT TARGET ${HIFI_LIBRARY}) #if (NOT TARGET ${HIFI_LIBRARY})
@ -86,7 +87,7 @@ macro(AUTOSCRIBE_SHADER_LIB)
#file(GLOB_RECURSE HIFI_LIBRARIES_SHADER_INCLUDE_FILES ${HIFI_LIBRARY_DIR}/${HIFI_LIBRARY}/src/*.slh) #file(GLOB_RECURSE HIFI_LIBRARIES_SHADER_INCLUDE_FILES ${HIFI_LIBRARY_DIR}/${HIFI_LIBRARY}/src/*.slh)
list(APPEND HIFI_LIBRARIES_SHADER_INCLUDE_FILES ${HIFI_LIBRARY_DIR}/${HIFI_LIBRARY}/src) list(APPEND HIFI_LIBRARIES_SHADER_INCLUDE_FILES ${HIFI_LIBRARY_DIR}/${HIFI_LIBRARY}/src)
endforeach() endforeach()
#message(${HIFI_LIBRARIES_SHADER_INCLUDE_FILES}) #message("${TARGET_NAME} ${HIFI_LIBRARIES_SHADER_INCLUDE_FILES}")
file(GLOB_RECURSE SHADER_INCLUDE_FILES src/*.slh) file(GLOB_RECURSE SHADER_INCLUDE_FILES src/*.slh)
file(GLOB_RECURSE SHADER_SOURCE_FILES src/*.slv src/*.slf src/*.slg) file(GLOB_RECURSE SHADER_SOURCE_FILES src/*.slv src/*.slf src/*.slg)
@ -95,13 +96,14 @@ macro(AUTOSCRIBE_SHADER_LIB)
set(SHADERS_DIR "${CMAKE_CURRENT_BINARY_DIR}/shaders/${TARGET_NAME}") set(SHADERS_DIR "${CMAKE_CURRENT_BINARY_DIR}/shaders/${TARGET_NAME}")
file(MAKE_DIRECTORY ${SHADERS_DIR}) file(MAKE_DIRECTORY ${SHADERS_DIR})
#message(${SHADER_INCLUDE_FILES}) #message("${TARGET_NAME} ${SHADER_INCLUDE_FILES}")
set(AUTOSCRIBE_SHADER_SRC "")
foreach(SHADER_FILE ${SHADER_SOURCE_FILES}) foreach(SHADER_FILE ${SHADER_SOURCE_FILES})
AUTOSCRIBE_SHADER(${SHADER_FILE} ${SHADER_INCLUDE_FILES}) AUTOSCRIBE_SHADER(${SHADER_FILE} ${SHADER_INCLUDE_FILES})
file(TO_CMAKE_PATH "${AUTOSCRIBE_SHADER_RETURN}" AUTOSCRIBE_GENERATED_FILE) file(TO_CMAKE_PATH "${AUTOSCRIBE_SHADER_RETURN}" AUTOSCRIBE_GENERATED_FILE)
list(APPEND AUTOSCRIBE_SHADER_SRC ${AUTOSCRIBE_GENERATED_FILE}) list(APPEND AUTOSCRIBE_SHADER_SRC ${AUTOSCRIBE_GENERATED_FILE})
endforeach() endforeach()
#message(${AUTOSCRIBE_SHADER_SRC}) #message(${TARGET_NAME} ${AUTOSCRIBE_SHADER_SRC})
if (WIN32) if (WIN32)
source_group("Shaders" FILES ${SHADER_INCLUDE_FILES}) source_group("Shaders" FILES ${SHADER_INCLUDE_FILES})
@ -116,4 +118,4 @@ macro(AUTOSCRIBE_SHADER_LIB)
# Link library shaders, if they exist # Link library shaders, if they exist
include_directories("${SHADERS_DIR}") include_directories("${SHADERS_DIR}")
endmacro() endmacro()

View file

@ -54,8 +54,9 @@ macro(SETUP_HIFI_LIBRARY)
target_link_libraries(${TARGET_NAME} Qt5::${QT_MODULE}) target_link_libraries(${TARGET_NAME} Qt5::${QT_MODULE})
endforeach() endforeach()
# Don't make scribed shaders cumulative # Don't make scribed shaders or QT resource files cumulative
set(AUTOSCRIBE_SHADER_LIB_SRC "") set(AUTOSCRIBE_SHADER_LIB_SRC "")
set(QT_RESOURCES_FILE "")
target_glm() target_glm()

View file

@ -93,7 +93,7 @@ public slots:
/// successful edit, if the input id is for an unknown overlay this function will have no effect /// successful edit, if the input id is for an unknown overlay this function will have no effect
bool editOverlays(const QVariant& propertiesById); bool editOverlays(const QVariant& propertiesById);
/// deletes a particle /// deletes an overlay
void deleteOverlay(unsigned int id); void deleteOverlay(unsigned int id);
/// get the string type of the overlay used in addOverlay /// get the string type of the overlay used in addOverlay

View file

@ -176,25 +176,6 @@ void RenderableModelEntityItem::doInitialModelSimulation() {
_needsInitialSimulation = false; _needsInitialSimulation = false;
} }
// TODO: we need a solution for changes to the postion/rotation/etc of a model...
// this current code path only addresses that in this setup case... not the changing/moving case
bool RenderableModelEntityItem::readyToAddToScene(RenderArgs* renderArgs) {
if (!_model && renderArgs) {
// TODO: this getModel() appears to be about 3% of model render time. We should optimize
PerformanceTimer perfTimer("getModel");
EntityTreeRenderer* renderer = static_cast<EntityTreeRenderer*>(renderArgs->_renderer);
getModel(renderer);
}
if (renderArgs && _model && _needsInitialSimulation && _model->isActive() && _model->isLoaded()) {
// make sure to simulate so everything gets set up correctly for rendering
doInitialModelSimulation();
_model->renderSetup(renderArgs);
}
bool ready = !_needsInitialSimulation && _model && _model->readyToAddToScene(renderArgs);
return ready;
}
class RenderableModelEntityItemMeta { class RenderableModelEntityItemMeta {
public: public:
RenderableModelEntityItemMeta(EntityItemPointer entity) : entity(entity){ } RenderableModelEntityItemMeta(EntityItemPointer entity) : entity(entity){ }

View file

@ -40,7 +40,6 @@ public:
void doInitialModelSimulation(); void doInitialModelSimulation();
virtual bool readyToAddToScene(RenderArgs* renderArgs = nullptr);
virtual bool addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges) override; virtual bool addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges) override;
virtual void removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges) override; virtual void removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges) override;

View file

@ -44,7 +44,7 @@ out vec4 varColor;
out vec2 varTexcoord; out vec2 varTexcoord;
const int NUM_VERTICES_PER_PARTICLE = 4; const int NUM_VERTICES_PER_PARTICLE = 4;
// This ordering ensures that un-rotated particles render upright in the wiewer. // This ordering ensures that un-rotated particles render upright in the viewer.
const vec4 UNIT_QUAD[NUM_VERTICES_PER_PARTICLE] = vec4[NUM_VERTICES_PER_PARTICLE]( const vec4 UNIT_QUAD[NUM_VERTICES_PER_PARTICLE] = vec4[NUM_VERTICES_PER_PARTICLE](
vec4(-1.0, 1.0, 0.0, 0.0), vec4(-1.0, 1.0, 0.0, 0.0),
vec4(-1.0, -1.0, 0.0, 0.0), vec4(-1.0, -1.0, 0.0, 0.0),

View file

@ -634,8 +634,8 @@ bool EntityTreeElement::findDetailedRayIntersection(const glm::vec3& origin, con
} }
} else { } else {
// if the entity type doesn't support a detailed intersection, then just return the non-AABox results // if the entity type doesn't support a detailed intersection, then just return the non-AABox results
// Never intersect with particle effect entities // Never intersect with particle entities
if (localDistance < distance && EntityTypes::getEntityTypeName(entity->getType()) != "ParticleEffect") { if (localDistance < distance && entity->getType() != EntityTypes::ParticleEffect) {
distance = localDistance; distance = localDistance;
face = localFace; face = localFace;
surfaceNormal = localSurfaceNormal; surfaceNormal = localSurfaceNormal;

View file

@ -596,7 +596,7 @@ int makeUniformBlockSlots(GLuint glprogram, const Shader::BindingSet& slotBindin
} }
Element element(SCALAR, gpu::UINT32, gpu::UNIFORM_BUFFER); Element element(SCALAR, gpu::UINT32, gpu::UNIFORM_BUFFER);
buffers.insert(Shader::Slot(name, binding, element, Resource::BUFFER)); buffers.insert(Shader::Slot(name, binding, element, Resource::BUFFER, size));
} }
return buffersCount; return buffersCount;
} }

View file

@ -53,19 +53,22 @@ public:
int32 _location{INVALID_LOCATION}; int32 _location{INVALID_LOCATION};
Element _element; Element _element;
uint16 _resourceType{Resource::BUFFER}; uint16 _resourceType{Resource::BUFFER};
uint32 _size { 0 };
Slot(const Slot& s) : _name(s._name), _location(s._location), _element(s._element), _resourceType(s._resourceType) {} Slot(const Slot& s) : _name(s._name), _location(s._location), _element(s._element), _resourceType(s._resourceType), _size(s._size) {}
Slot(Slot&& s) : _name(s._name), _location(s._location), _element(s._element), _resourceType(s._resourceType) {} Slot(Slot&& s) : _name(s._name), _location(s._location), _element(s._element), _resourceType(s._resourceType), _size(s._size) {}
Slot(const std::string& name, int32 location, const Element& element, uint16 resourceType = Resource::BUFFER) : Slot(const std::string& name, int32 location, const Element& element, uint16 resourceType = Resource::BUFFER, uint32 size = 0) :
_name(name), _location(location), _element(element), _resourceType(resourceType) {} _name(name), _location(location), _element(element), _resourceType(resourceType), _size(size) {}
Slot(const std::string& name) : _name(name) {} Slot(const std::string& name) : _name(name) {}
Slot& operator= (const Slot& s) { Slot& operator= (const Slot& s) {
_name = s._name; _name = s._name;
_location = s._location; _location = s._location;
_element = s._element; _element = s._element;
_resourceType = s._resourceType; _resourceType = s._resourceType;
return (*this); } _size = s._size;
return (*this);
}
}; };
class Binding { class Binding {

View file

@ -1,9 +1,9 @@
set(TARGET_NAME render-utils) set(TARGET_NAME render-utils)
AUTOSCRIBE_SHADER_LIB(gpu model render procedural) AUTOSCRIBE_SHADER_LIB(gpu model render)
# pull in the resources.qrc file # pull in the resources.qrc file
qt5_add_resources(QT_RESOURCES_FILE "${CMAKE_CURRENT_SOURCE_DIR}/res/fonts/fonts.qrc") qt5_add_resources(QT_RESOURCES_FILE "${CMAKE_CURRENT_SOURCE_DIR}/res/fonts/fonts.qrc")
setup_hifi_library(Widgets OpenGL Network Qml Quick Script) setup_hifi_library(Widgets OpenGL Network Qml Quick Script)
link_hifi_libraries(shared gpu procedural model model-networking render animation fbx) link_hifi_libraries(shared gpu model model-networking render animation fbx)
target_nsight() target_nsight()
target_oglplus() target_oglplus()

View file

@ -7,6 +7,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include <qmath.h>
#include "animdebugdraw_vert.h" #include "animdebugdraw_vert.h"
#include "animdebugdraw_frag.h" #include "animdebugdraw_frag.h"
#include <gpu/Batch.h> #include <gpu/Batch.h>

View file

@ -11,7 +11,7 @@
#include "GeometryCache.h" #include "GeometryCache.h"
#include <qmath.h>
#include <cmath> #include <cmath>
#include <QtCore/QThreadPool> #include <QtCore/QThreadPool>

View file

@ -1,5 +1,5 @@
set(TARGET_NAME render) set(TARGET_NAME render)
AUTOSCRIBE_SHADER_LIB(gpu model procedural) AUTOSCRIBE_SHADER_LIB(gpu model)
setup_hifi_library() setup_hifi_library()
link_hifi_libraries(shared gpu model) link_hifi_libraries(shared gpu model)