Rename Shape to ShapePipelineLib, Shape.h to ShapePipeline.h

This commit is contained in:
Zach Pomerantz 2016-01-07 13:27:22 -08:00
parent 7f0781f6e8
commit 1b3e144395
9 changed files with 56 additions and 53 deletions

View file

@ -21,7 +21,7 @@
#include "model/Stage.h"
#include "model/Geometry.h"
#include "render/Shape.h"
#include "render/ShapePipeline.h"
class RenderArgs;
class SimpleProgramKey;
@ -32,7 +32,7 @@ class DeferredLightingEffect : public Dependency {
SINGLETON_DEPENDENCY
public:
static const int NORMAL_FITTING_MAP_SLOT = render::Shape::Slot::NORMAL_FITTING_MAP;
static const int NORMAL_FITTING_MAP_SLOT = render::ShapePipeline::Slot::NORMAL_FITTING_MAP;
static const int DEFERRED_TRANSFORM_BUFFER_SLOT = 2;
void init();

View file

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

View file

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

View file

@ -12,10 +12,10 @@
#ifndef hifi_render_utils_Shape_h
#define hifi_render_utils_Shape_h
#include <render/Shape.h>
#include <render/ShapePipeline.h>
#include <model/Material.h>
class ShapeRender : public render::Shape {
class ShapeRender : public render::ShapePipelineLib {
public:
ShapeRender();
static void initPipeline();

View file

@ -220,7 +220,7 @@ void render::renderLights(const SceneContextPointer& sceneContext, const RenderC
}
}
void renderShape(RenderArgs* args, const Shape& shapeContext, Item& item) {
void renderShape(RenderArgs* args, const ShapePipelineLib& shapeContext, Item& item) {
assert(item.getKey().isShape());
const auto& key = item.getShapeKey();
if (key.isValid() && !key.hasOwnPipeline()) {
@ -236,7 +236,7 @@ void renderShape(RenderArgs* args, const Shape& shapeContext, Item& item) {
}
void render::renderShapes(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext,
const Shape& shapeContext, const ItemIDsBounds& inItems, int maxDrawnItems) {
const ShapePipelineLib& shapeContext, const ItemIDsBounds& inItems, int maxDrawnItems) {
auto& scene = sceneContext->_scene;
RenderArgs* args = renderContext->getArgs();

View file

@ -13,7 +13,7 @@
#define hifi_render_Task_h
#include "Engine.h"
#include "Shape.h"
#include "ShapePipeline.h"
#include "gpu/Batch.h"
#include <PerfStat.h>
@ -222,7 +222,7 @@ typedef std::vector<Job> Jobs;
void cullItems(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems, ItemIDsBounds& outITems);
void depthSortItems(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, bool frontToBack, const ItemIDsBounds& inItems, ItemIDsBounds& outITems);
void renderLights(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems);
void renderShapes(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const Shape& shapeContext, const ItemIDsBounds& inItems, int maxDrawnItems = -1);
void renderShapes(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ShapePipelineLib& shapeContext, const ItemIDsBounds& inItems, int maxDrawnItems = -1);
class FetchItems {

View file

@ -25,7 +25,7 @@
#include <RenderArgs.h>
#include "model/Material.h"
#include "Shape.h"
#include "ShapePipeline.h"
namespace render {

View file

@ -1,5 +1,5 @@
//
// Shape.cpp
// ShapePipeline.cpp
// render/src/render
//
// Created by Zach Pomerantz on 12/31/15.
@ -9,20 +9,24 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "Shape.h"
#include "ShapePipeline.h"
#include <PerfStat.h>
using namespace render;
Shape::PipelineLib Shape::_pipelineLib;
ShapePipelineLib::PipelineLib ShapePipelineLib::_pipelineLib;
const Shape::PipelinePointer Shape::_pickPipeline(RenderArgs* args, const Key& key) {
void ShapePipelineLib::addPipeline(Key key, gpu::ShaderPointer& vertexShader, gpu::ShaderPointer& pixelShader) {
_pipelineLib.addPipeline(key, vertexShader, pixelShader);
}
const ShapePipelineLib::PipelinePointer ShapePipelineLib::_pickPipeline(RenderArgs* args, const Key& key) {
assert(!_pipelineLib.empty());
assert(args);
assert(args->_batch);
PerformanceTimer perfTimer("Shape::getPipeline");
PerformanceTimer perfTimer("ShapePipelineLib::getPipeline");
const auto& pipelineIterator = _pipelineLib.find(key);
if (pipelineIterator == _pipelineLib.end()) {
@ -39,7 +43,7 @@ const Shape::PipelinePointer Shape::_pickPipeline(RenderArgs* args, const Key& k
return shapePipeline;
}
void Shape::PipelineLib::addPipeline(Key key, gpu::ShaderPointer& vertexShader, gpu::ShaderPointer& pixelShader) {
void ShapePipelineLib::PipelineLib::addPipeline(Key key, gpu::ShaderPointer& vertexShader, gpu::ShaderPointer& pixelShader) {
gpu::Shader::BindingSet slotBindings;
slotBindings.insert(gpu::Shader::Binding(std::string("skinClusterBuffer"), Slot::SKINNING_GPU));
slotBindings.insert(gpu::Shader::Binding(std::string("materialBuffer"), Slot::MATERIAL_GPU));

View file

@ -1,5 +1,5 @@
//
// Shape.h
// ShapePipeline.h
// render/src/render
//
// Created by Zach Pomerantz on 12/31/15.
@ -9,8 +9,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_render_Shape_h
#define hifi_render_Shape_h
#ifndef hifi_render_ShapePipeline_h
#define hifi_render_ShapePipeline_h
#include <gpu/Batch.h>
#include <RenderArgs.h>
@ -160,36 +160,35 @@ public:
ShapePipeline(gpu::PipelinePointer pipeline, std::shared_ptr<Locations> locations) :
pipeline(pipeline), locations(locations) {}
};
using ShapePipelinePointer = std::shared_ptr<ShapePipeline>;
// Meta-information (pipeline and locations) to render a shape
class Shape {
class ShapePipelineLib {
public:
using Key = ShapeKey;
using Pipeline = ShapePipeline;
using PipelinePointer = std::shared_ptr<Pipeline>;
using PipelinePointer = ShapePipelinePointer;
using Slot = ShapePipeline::Slot;
using Locations = ShapePipeline::Locations;
virtual ~ShapePipelineLib() = default;
static void addPipeline(Key key, gpu::ShaderPointer& vertexShader, gpu::ShaderPointer& pixelShader);
virtual const PipelinePointer pickPipeline(RenderArgs* args, const Key& key) const {
return ShapePipelineLib::_pickPipeline(args, key);
}
protected:
using PipelineMap = std::unordered_map<ShapeKey, PipelinePointer, ShapeKey::Hash, ShapeKey::KeyEqual>;
class PipelineLib : public PipelineMap {
public:
void addPipeline(Key key, gpu::ShaderPointer& vertexShader, gpu::ShaderPointer& pixelShader);
};
static void addPipeline(Key key, gpu::ShaderPointer& vertexShader, gpu::ShaderPointer& pixelShader) {
_pipelineLib.addPipeline(key, vertexShader, pixelShader);
}
virtual const PipelinePointer pickPipeline(RenderArgs* args, const Key& key) const {
return Shape::_pickPipeline(args, key);
}
virtual ~Shape() {};
protected:
static const PipelinePointer _pickPipeline(RenderArgs* args, const Key& key);
static PipelineLib _pipelineLib;
static const PipelinePointer _pickPipeline(RenderArgs* args, const Key& key);
};
}
#endif // hifi_render_Shape_h
#endif // hifi_render_ShapePipeline_h