Cleanup for style/dead code

This commit is contained in:
Zach Pomerantz 2016-01-06 11:42:58 -08:00
parent d8ff133cc6
commit 9bc661adc8
9 changed files with 67 additions and 56 deletions

View file

@ -129,14 +129,14 @@ void MeshPartPayload::bindMesh(gpu::Batch& batch) const {
} }
} }
void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::LocationsPointer locations) const { void MeshPartPayload::bindMaterial(gpu::Batch& batch, const Shape::Pipeline::LocationsPointer locations) const {
if (!_drawMaterial) { if (!_drawMaterial) {
return; return;
} }
auto textureCache = DependencyManager::get<TextureCache>(); auto textureCache = DependencyManager::get<TextureCache>();
batch.setUniformBuffer(ShapePipeline::Slot::MATERIAL_GPU, _drawMaterial->getSchemaBuffer()); batch.setUniformBuffer(Shape::Pipeline::Slot::MATERIAL_GPU, _drawMaterial->getSchemaBuffer());
auto materialKey = _drawMaterial->getKey(); auto materialKey = _drawMaterial->getKey();
auto textureMaps = _drawMaterial->getTextureMaps(); auto textureMaps = _drawMaterial->getTextureMaps();
@ -146,44 +146,44 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat
if (materialKey.isDiffuseMap()) { if (materialKey.isDiffuseMap()) {
auto diffuseMap = textureMaps[model::MaterialKey::DIFFUSE_MAP]; auto diffuseMap = textureMaps[model::MaterialKey::DIFFUSE_MAP];
if (diffuseMap && diffuseMap->isDefined()) { if (diffuseMap && diffuseMap->isDefined()) {
batch.setResourceTexture(ShapePipeline::Slot::DIFFUSE_MAP, diffuseMap->getTextureView()); batch.setResourceTexture(Shape::Pipeline::Slot::DIFFUSE_MAP, diffuseMap->getTextureView());
if (!diffuseMap->getTextureTransform().isIdentity()) { if (!diffuseMap->getTextureTransform().isIdentity()) {
diffuseMap->getTextureTransform().getMatrix(texcoordTransform[0]); diffuseMap->getTextureTransform().getMatrix(texcoordTransform[0]);
} }
} else { } else {
batch.setResourceTexture(ShapePipeline::Slot::DIFFUSE_MAP, textureCache->getGrayTexture()); batch.setResourceTexture(Shape::Pipeline::Slot::DIFFUSE_MAP, textureCache->getGrayTexture());
} }
} else { } else {
batch.setResourceTexture(ShapePipeline::Slot::DIFFUSE_MAP, textureCache->getWhiteTexture()); batch.setResourceTexture(Shape::Pipeline::Slot::DIFFUSE_MAP, textureCache->getWhiteTexture());
} }
// Normal map // Normal map
if (materialKey.isNormalMap()) { if (materialKey.isNormalMap()) {
auto normalMap = textureMaps[model::MaterialKey::NORMAL_MAP]; auto normalMap = textureMaps[model::MaterialKey::NORMAL_MAP];
if (normalMap && normalMap->isDefined()) { if (normalMap && normalMap->isDefined()) {
batch.setResourceTexture(ShapePipeline::Slot::NORMAL_MAP, normalMap->getTextureView()); batch.setResourceTexture(Shape::Pipeline::Slot::NORMAL_MAP, normalMap->getTextureView());
// texcoord are assumed to be the same has diffuse // texcoord are assumed to be the same has diffuse
} else { } else {
batch.setResourceTexture(ShapePipeline::Slot::NORMAL_MAP, textureCache->getBlueTexture()); batch.setResourceTexture(Shape::Pipeline::Slot::NORMAL_MAP, textureCache->getBlueTexture());
} }
} else { } else {
batch.setResourceTexture(ShapePipeline::Slot::NORMAL_MAP, nullptr); batch.setResourceTexture(Shape::Pipeline::Slot::NORMAL_MAP, nullptr);
} }
// TODO: For now gloss map is used as the "specular map in the shading, we ll need to fix that // TODO: For now gloss map is used as the "specular map in the shading, we ll need to fix that
if (materialKey.isGlossMap()) { if (materialKey.isGlossMap()) {
auto specularMap = textureMaps[model::MaterialKey::GLOSS_MAP]; auto specularMap = textureMaps[model::MaterialKey::GLOSS_MAP];
if (specularMap && specularMap->isDefined()) { if (specularMap && specularMap->isDefined()) {
batch.setResourceTexture(ShapePipeline::Slot::SPECULAR_MAP, specularMap->getTextureView()); batch.setResourceTexture(Shape::Pipeline::Slot::SPECULAR_MAP, specularMap->getTextureView());
// texcoord are assumed to be the same has diffuse // texcoord are assumed to be the same has diffuse
} else { } else {
batch.setResourceTexture(ShapePipeline::Slot::SPECULAR_MAP, textureCache->getBlackTexture()); batch.setResourceTexture(Shape::Pipeline::Slot::SPECULAR_MAP, textureCache->getBlackTexture());
} }
} else { } else {
batch.setResourceTexture(ShapePipeline::Slot::SPECULAR_MAP, nullptr); batch.setResourceTexture(Shape::Pipeline::Slot::SPECULAR_MAP, nullptr);
} }
// TODO: For now lightmaop is piped into the emissive map unit, we need to fix that and support for real emissive too // TODO: For now lightmaop is piped into the emissive map unit, we need to fix that and support for real emissive too
@ -191,7 +191,7 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat
auto lightmapMap = textureMaps[model::MaterialKey::LIGHTMAP_MAP]; auto lightmapMap = textureMaps[model::MaterialKey::LIGHTMAP_MAP];
if (lightmapMap && lightmapMap->isDefined()) { if (lightmapMap && lightmapMap->isDefined()) {
batch.setResourceTexture(ShapePipeline::Slot::LIGHTMAP_MAP, lightmapMap->getTextureView()); batch.setResourceTexture(Shape::Pipeline::Slot::LIGHTMAP_MAP, lightmapMap->getTextureView());
auto lightmapOffsetScale = lightmapMap->getLightmapOffsetScale(); auto lightmapOffsetScale = lightmapMap->getLightmapOffsetScale();
batch._glUniform2f(locations->emissiveParams, lightmapOffsetScale.x, lightmapOffsetScale.y); batch._glUniform2f(locations->emissiveParams, lightmapOffsetScale.x, lightmapOffsetScale.y);
@ -200,10 +200,10 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat
lightmapMap->getTextureTransform().getMatrix(texcoordTransform[1]); lightmapMap->getTextureTransform().getMatrix(texcoordTransform[1]);
} }
} else { } else {
batch.setResourceTexture(ShapePipeline::Slot::LIGHTMAP_MAP, textureCache->getGrayTexture()); batch.setResourceTexture(Shape::Pipeline::Slot::LIGHTMAP_MAP, textureCache->getGrayTexture());
} }
} else { } else {
batch.setResourceTexture(ShapePipeline::Slot::LIGHTMAP_MAP, nullptr); batch.setResourceTexture(Shape::Pipeline::Slot::LIGHTMAP_MAP, nullptr);
} }
// Texcoord transforms ? // Texcoord transforms ?
@ -212,7 +212,7 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat
} }
} }
void MeshPartPayload::bindTransform(gpu::Batch& batch, const ShapePipeline::LocationsPointer locations) const { void MeshPartPayload::bindTransform(gpu::Batch& batch, const Shape::Pipeline::LocationsPointer locations) const {
batch.setModelTransform(_drawTransform); batch.setModelTransform(_drawTransform);
} }
@ -377,7 +377,7 @@ ShapeKey ModelMeshPartPayload::getShapeKey() const {
int vertexCount = mesh.vertices.size(); int vertexCount = mesh.vertices.size();
if (vertexCount == 0) { if (vertexCount == 0) {
// sanity check // sanity check
return ShapeKey::Builder::invalid(); return ShapeKey::Builder::invalid(); // FIXME
} }
@ -431,16 +431,16 @@ void ModelMeshPartPayload::bindMesh(gpu::Batch& batch) const {
} }
} }
void ModelMeshPartPayload::bindTransform(gpu::Batch& batch, const ShapePipeline::LocationsPointer locations) const { void ModelMeshPartPayload::bindTransform(gpu::Batch& batch, const Shape::Pipeline::LocationsPointer locations) const {
// Still relying on the raw data from the model // Still relying on the raw data from the model
const Model::MeshState& state = _model->_meshStates.at(_meshIndex); const Model::MeshState& state = _model->_meshStates.at(_meshIndex);
Transform transform; Transform transform;
if (state.clusterBuffer) { if (state.clusterBuffer) {
if (_model->_cauterizeBones) { if (_model->_cauterizeBones) {
batch.setUniformBuffer(ShapePipeline::Slot::SKINNING_GPU, state.cauterizedClusterBuffer); batch.setUniformBuffer(Shape::Pipeline::Slot::SKINNING_GPU, state.cauterizedClusterBuffer);
} else { } else {
batch.setUniformBuffer(ShapePipeline::Slot::SKINNING_GPU, state.clusterBuffer); batch.setUniformBuffer(Shape::Pipeline::Slot::SKINNING_GPU, state.clusterBuffer);
} }
} else { } else {
if (_model->_cauterizeBones) { if (_model->_cauterizeBones) {

View file

@ -46,8 +46,8 @@ public:
// ModelMeshPartPayload functions to perform render // ModelMeshPartPayload functions to perform render
void drawCall(gpu::Batch& batch) const; void drawCall(gpu::Batch& batch) const;
virtual void bindMesh(gpu::Batch& batch) const; virtual void bindMesh(gpu::Batch& batch) const;
virtual void bindMaterial(gpu::Batch& batch, const render::ShapePipeline::LocationsPointer locations) const; virtual void bindMaterial(gpu::Batch& batch, const render::Shape::Pipeline::LocationsPointer locations) const;
virtual void bindTransform(gpu::Batch& batch, const render::ShapePipeline::LocationsPointer locations) const; virtual void bindTransform(gpu::Batch& batch, const render::Shape::Pipeline::LocationsPointer locations) const;
// Payload resource cached values // Payload resource cached values
model::MeshPointer _drawMesh; model::MeshPointer _drawMesh;
@ -89,7 +89,7 @@ public:
// ModelMeshPartPayload functions to perform render // ModelMeshPartPayload functions to perform render
void bindMesh(gpu::Batch& batch) const override; void bindMesh(gpu::Batch& batch) const override;
void bindTransform(gpu::Batch& batch, const render::ShapePipeline::LocationsPointer locations) const override; void bindTransform(gpu::Batch& batch, const render::Shape::Pipeline::LocationsPointer locations) const override;
void initCache(); void initCache();

View file

@ -51,29 +51,35 @@ public:
}; };
class DrawOpaqueDeferred { class DrawOpaqueDeferred {
ShapeRender _renderer;
public: public:
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, const render::ItemIDsBounds& inItems); void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, const render::ItemIDsBounds& inItems);
typedef render::Job::ModelI<DrawOpaqueDeferred, render::ItemIDsBounds> JobModel; typedef render::Job::ModelI<DrawOpaqueDeferred, render::ItemIDsBounds> JobModel;
protected:
ShapeRender _renderer;
}; };
class DrawTransparentDeferred { class DrawTransparentDeferred {
ShapeRender _renderer;
public: public:
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, const render::ItemIDsBounds& inItems); void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, const render::ItemIDsBounds& inItems);
typedef render::Job::ModelI<DrawTransparentDeferred, render::ItemIDsBounds> JobModel; typedef render::Job::ModelI<DrawTransparentDeferred, render::ItemIDsBounds> JobModel;
protected:
ShapeRender _renderer;
}; };
class DrawStencilDeferred { class DrawStencilDeferred {
static gpu::PipelinePointer _opaquePipeline; //lazy evaluation hence mutable
public: public:
static const gpu::PipelinePointer& getOpaquePipeline(); static const gpu::PipelinePointer& getOpaquePipeline();
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext); void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
typedef render::Job::Model<DrawStencilDeferred> JobModel; typedef render::Job::Model<DrawStencilDeferred> JobModel;
protected:
static gpu::PipelinePointer _opaquePipeline; //lazy evaluation hence mutable
}; };
class DrawBackgroundDeferred { class DrawBackgroundDeferred {
@ -84,14 +90,16 @@ public:
}; };
class DrawOverlay3D { class DrawOverlay3D {
static gpu::PipelinePointer _opaquePipeline; //lazy evaluation hence mutable
ShapeRender _renderer;
public: public:
static const gpu::PipelinePointer& getOpaquePipeline(); static const gpu::PipelinePointer& getOpaquePipeline();
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext); void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
typedef render::Job::Model<DrawOverlay3D> JobModel; typedef render::Job::Model<DrawOverlay3D> JobModel;
protected:
static gpu::PipelinePointer _opaquePipeline; //lazy evaluation hence mutable
ShapeRender _renderer;
}; };
class Blit { class Blit {

View file

@ -38,7 +38,8 @@
#include "model_translucent_frag.h" #include "model_translucent_frag.h"
ShapeRender::ShapeRender() { ShapeRender::ShapeRender() {
// TODO: There is probably a cleaner way to init the pipeline that in a derived class // TODO: Move pipeline initialization to those Jobs using ShapeRender
// such that they own their own pipelines and it is done only once
if (_pipelineLib.empty()) { if (_pipelineLib.empty()) {
initPipeline(); initPipeline();
} }

View file

@ -16,14 +16,15 @@
#include <model/Material.h> #include <model/Material.h>
class ShapeRender : public render::Shape { class ShapeRender : public render::Shape {
static model::MaterialPointer _collisionHullMaterial;
public: public:
ShapeRender(); ShapeRender();
static void initPipeline(); static void initPipeline();
const PipelinePointer pickPipeline(RenderArgs* args, const Key& key) const override; const PipelinePointer pickPipeline(RenderArgs* args, const Key& key) const override;
static model::MaterialPointer getCollisionHullMaterial(); static model::MaterialPointer getCollisionHullMaterial();
protected:
static model::MaterialPointer _collisionHullMaterial;
}; };
#endif // hifi_render_utils_Shape_h #endif // hifi_render_utils_Shape_h

View file

@ -223,12 +223,12 @@ void render::renderLights(const SceneContextPointer& sceneContext, const RenderC
void renderShape(RenderArgs* args, const Shape& shapeContext, Item& item) { void renderShape(RenderArgs* args, const Shape& shapeContext, Item& item) {
assert(item.getKey().isShape()); assert(item.getKey().isShape());
const auto& key = item.getShapeKey(); const auto& key = item.getShapeKey();
if (key.isValid() && key.hasPipeline()) { if (key.isValid() && !key.hasOwnPipeline()) {
args->_pipeline = shapeContext.pickPipeline(args, key); args->_pipeline = shapeContext.pickPipeline(args, key);
if (args->_pipeline) { if (args->_pipeline) {
item.render(args); item.render(args);
} }
} else if (!key.hasPipeline()) { } else if (key.hasOwnPipeline()) {
item.render(args); item.render(args);
} else { } else {
qDebug() << "Item could not be rendered: invalid key ?" << key; qDebug() << "Item could not be rendered: invalid key ?" << key;

View file

@ -103,12 +103,6 @@ public:
} }
public: public:
class Context {
public:
virtual const ShapePipeline pickPipeline(RenderArgs* args, const ShapeKey& key) = 0;
};
using ContextPointer = std::shared_ptr<Context>;
class Concept { class Concept {
std::string _name; std::string _name;
bool _isEnabled = true; bool _isEnabled = true;
@ -274,7 +268,7 @@ public:
typedef Job::ModelIO<DepthSortItems, ItemIDsBounds, ItemIDsBounds> JobModel; typedef Job::ModelIO<DepthSortItems, ItemIDsBounds, ItemIDsBounds> JobModel;
}; };
class DrawLight : public Shape { class DrawLight {
public: public:
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext); void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext);

View file

@ -350,7 +350,10 @@ template <class T> int payloadGetLayer(const std::shared_ptr<T>& payloadData) {
template <class T> void payloadRender(const std::shared_ptr<T>& payloadData, RenderArgs* args) { } template <class T> void payloadRender(const std::shared_ptr<T>& payloadData, RenderArgs* args) { }
// Shape type interface // Shape type interface
template <class T> const ShapeKey shapeGetShapeKey(const std::shared_ptr<T>& payloadData) { return ShapeKey::Builder::noPipeline(); } // This allows shapes to characterize their pipeline via a ShapeKey, to be picked with a subclass of Shape.
// When creating a new shape payload you need to create a specialized version, or the ShapeKey will be ownPipeline,
// implying that the shape will setup its own pipeline without the use of the ShapeKey.
template <class T> const ShapeKey shapeGetShapeKey(const std::shared_ptr<T>& payloadData) { return ShapeKey::Builder::ownPipeline(); }
template <class T> class Payload : public Item::PayloadInterface { template <class T> class Payload : public Item::PayloadInterface {
public: public:

View file

@ -31,7 +31,7 @@ public:
SHADOW, SHADOW,
WIREFRAME, WIREFRAME,
NO_PIPELINE, OWN_PIPELINE,
INVALID, INVALID,
NUM_FLAGS, // Not a valid flag NUM_FLAGS, // Not a valid flag
@ -62,10 +62,10 @@ public:
Builder& withDepthOnly() { _flags.set(DEPTH_ONLY); return (*this); } Builder& withDepthOnly() { _flags.set(DEPTH_ONLY); return (*this); }
Builder& withShadow() { _flags.set(SHADOW); return (*this); } Builder& withShadow() { _flags.set(SHADOW); return (*this); }
Builder& withWireframe() { _flags.set(WIREFRAME); return (*this); } Builder& withWireframe() { _flags.set(WIREFRAME); return (*this); }
Builder& withoutPipeline() { _flags.set(NO_PIPELINE); return (*this); } Builder& withOwnPipeline() { _flags.set(OWN_PIPELINE); return (*this); }
Builder& invalidate() { _flags.set(INVALID); return (*this); } Builder& invalidate() { _flags.set(INVALID); return (*this); }
static const ShapeKey noPipeline() { return Builder().withoutPipeline(); } static const ShapeKey ownPipeline() { return Builder().withOwnPipeline(); }
static const ShapeKey invalid() { return Builder().invalidate(); } static const ShapeKey invalid() { return Builder().invalidate(); }
}; };
ShapeKey(const Builder& builder) : ShapeKey(builder._flags) {} ShapeKey(const Builder& builder) : ShapeKey(builder._flags) {}
@ -81,7 +81,7 @@ public:
bool isShadow() const { return _flags[SHADOW]; } bool isShadow() const { return _flags[SHADOW]; }
bool isWireFrame() const { return _flags[WIREFRAME]; } bool isWireFrame() const { return _flags[WIREFRAME]; }
bool hasPipeline() const { return !_flags[NO_PIPELINE]; } bool hasOwnPipeline() const { return _flags[OWN_PIPELINE]; }
bool isValid() const { return !_flags[INVALID]; } bool isValid() const { return !_flags[INVALID]; }
// Hasher for use in unordered_maps // Hasher for use in unordered_maps
@ -101,18 +101,22 @@ public:
inline QDebug operator<<(QDebug debug, const ShapeKey& renderKey) { inline QDebug operator<<(QDebug debug, const ShapeKey& renderKey) {
if (renderKey.isValid()) { if (renderKey.isValid()) {
debug << "[ShapeKey:" if (renderKey.hasOwnPipeline()) {
<< "hasLightmap:" << renderKey.hasLightmap() debug << "[ShapeKey: OWN_PIPELINE]";
<< "hasTangents:" << renderKey.hasTangents() } else {
<< "hasSpecular:" << renderKey.hasSpecular() debug << "[ShapeKey:"
<< "hasEmissive:" << renderKey.hasEmissive() << "hasLightmap:" << renderKey.hasLightmap()
<< "isTranslucent:" << renderKey.isTranslucent() << "hasTangents:" << renderKey.hasTangents()
<< "isSkinned:" << renderKey.isSkinned() << "hasSpecular:" << renderKey.hasSpecular()
<< "isStereo:" << renderKey.isStereo() << "hasEmissive:" << renderKey.hasEmissive()
<< "isDepthOnly:" << renderKey.isDepthOnly() << "isTranslucent:" << renderKey.isTranslucent()
<< "isShadow:" << renderKey.isShadow() << "isSkinned:" << renderKey.isSkinned()
<< "isWireFrame:" << renderKey.isWireFrame() << "isStereo:" << renderKey.isStereo()
<< "]"; << "isDepthOnly:" << renderKey.isDepthOnly()
<< "isShadow:" << renderKey.isShadow()
<< "isWireFrame:" << renderKey.isWireFrame()
<< "]";
}
} else { } else {
debug << "[ShapeKey: INVALID]"; debug << "[ShapeKey: INVALID]";
} }