Change Slots->Slot to be congruous with gpu

This commit is contained in:
Zach Pomerantz 2016-01-05 16:27:02 -08:00
parent 258a414404
commit 4eff377258
4 changed files with 28 additions and 26 deletions

View file

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

View file

@ -136,7 +136,7 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat
auto textureCache = DependencyManager::get<TextureCache>(); auto textureCache = DependencyManager::get<TextureCache>();
batch.setUniformBuffer(ShapePipeline::Slots::MATERIAL_GPU, _drawMaterial->getSchemaBuffer()); batch.setUniformBuffer(ShapePipeline::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::Slots::DIFFUSE_MAP, diffuseMap->getTextureView()); batch.setResourceTexture(ShapePipeline::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::Slots::DIFFUSE_MAP, textureCache->getGrayTexture()); batch.setResourceTexture(ShapePipeline::Slot::DIFFUSE_MAP, textureCache->getGrayTexture());
} }
} else { } else {
batch.setResourceTexture(ShapePipeline::Slots::DIFFUSE_MAP, textureCache->getWhiteTexture()); batch.setResourceTexture(ShapePipeline::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::Slots::NORMAL_MAP, normalMap->getTextureView()); batch.setResourceTexture(ShapePipeline::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::Slots::NORMAL_MAP, textureCache->getBlueTexture()); batch.setResourceTexture(ShapePipeline::Slot::NORMAL_MAP, textureCache->getBlueTexture());
} }
} else { } else {
batch.setResourceTexture(ShapePipeline::Slots::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 // 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::Slots::SPECULAR_MAP, specularMap->getTextureView()); batch.setResourceTexture(ShapePipeline::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::Slots::SPECULAR_MAP, textureCache->getBlackTexture()); batch.setResourceTexture(ShapePipeline::Slot::SPECULAR_MAP, textureCache->getBlackTexture());
} }
} else { } else {
batch.setResourceTexture(ShapePipeline::Slots::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 // 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::Slots::LIGHTMAP_MAP, lightmapMap->getTextureView()); batch.setResourceTexture(ShapePipeline::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::Slots::LIGHTMAP_MAP, textureCache->getGrayTexture()); batch.setResourceTexture(ShapePipeline::Slot::LIGHTMAP_MAP, textureCache->getGrayTexture());
} }
} else { } else {
batch.setResourceTexture(ShapePipeline::Slots::LIGHTMAP_MAP, nullptr); batch.setResourceTexture(ShapePipeline::Slot::LIGHTMAP_MAP, nullptr);
} }
// Texcoord transforms ? // Texcoord transforms ?
@ -438,9 +438,9 @@ void ModelMeshPartPayload::bindTransform(gpu::Batch& batch, const ShapePipeline:
Transform transform; Transform transform;
if (state.clusterBuffer) { if (state.clusterBuffer) {
if (_model->_cauterizeBones) { if (_model->_cauterizeBones) {
batch.setUniformBuffer(ShapePipeline::Slots::SKINNING_GPU, state.cauterizedClusterBuffer); batch.setUniformBuffer(ShapePipeline::Slot::SKINNING_GPU, state.cauterizedClusterBuffer);
} else { } else {
batch.setUniformBuffer(ShapePipeline::Slots::SKINNING_GPU, state.clusterBuffer); batch.setUniformBuffer(ShapePipeline::Slot::SKINNING_GPU, state.clusterBuffer);
} }
} else { } else {
if (_model->_cauterizeBones) { if (_model->_cauterizeBones) {

View file

@ -41,14 +41,14 @@ const Shape::PipelinePointer Shape::_pickPipeline(RenderArgs* args, const Key& k
void Shape::PipelineLib::addPipeline(Key key, gpu::ShaderPointer& vertexShader, gpu::ShaderPointer& pixelShader) { void Shape::PipelineLib::addPipeline(Key key, gpu::ShaderPointer& vertexShader, gpu::ShaderPointer& pixelShader) {
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
slotBindings.insert(gpu::Shader::Binding(std::string("skinClusterBuffer"), Slots::SKINNING_GPU)); slotBindings.insert(gpu::Shader::Binding(std::string("skinClusterBuffer"), Slot::SKINNING_GPU));
slotBindings.insert(gpu::Shader::Binding(std::string("materialBuffer"), Slots::MATERIAL_GPU)); slotBindings.insert(gpu::Shader::Binding(std::string("materialBuffer"), Slot::MATERIAL_GPU));
slotBindings.insert(gpu::Shader::Binding(std::string("diffuseMap"), Slots::DIFFUSE_MAP)); slotBindings.insert(gpu::Shader::Binding(std::string("diffuseMap"), Slot::DIFFUSE_MAP));
slotBindings.insert(gpu::Shader::Binding(std::string("normalMap"), Slots::NORMAL_MAP)); slotBindings.insert(gpu::Shader::Binding(std::string("normalMap"), Slot::NORMAL_MAP));
slotBindings.insert(gpu::Shader::Binding(std::string("specularMap"), Slots::SPECULAR_MAP)); slotBindings.insert(gpu::Shader::Binding(std::string("specularMap"), Slot::SPECULAR_MAP));
slotBindings.insert(gpu::Shader::Binding(std::string("emissiveMap"), Slots::LIGHTMAP_MAP)); slotBindings.insert(gpu::Shader::Binding(std::string("emissiveMap"), Slot::LIGHTMAP_MAP));
slotBindings.insert(gpu::Shader::Binding(std::string("lightBuffer"), Slots::LIGHT_BUFFER)); slotBindings.insert(gpu::Shader::Binding(std::string("lightBuffer"), Slot::LIGHT_BUFFER));
slotBindings.insert(gpu::Shader::Binding(std::string("normalFittingMap"), Slots::NORMAL_FITTING_MAP)); slotBindings.insert(gpu::Shader::Binding(std::string("normalFittingMap"), Slot::NORMAL_FITTING_MAP));
gpu::ShaderPointer program = gpu::Shader::createProgram(vertexShader, pixelShader); gpu::ShaderPointer program = gpu::Shader::createProgram(vertexShader, pixelShader);
gpu::Shader::makeProgram(*program, slotBindings); gpu::Shader::makeProgram(*program, slotBindings);

View file

@ -122,7 +122,7 @@ inline QDebug operator<<(QDebug debug, const ShapeKey& renderKey) {
// Rendering abstraction over gpu::Pipeline and map locations // Rendering abstraction over gpu::Pipeline and map locations
class ShapePipeline { class ShapePipeline {
public: public:
class Slots { class Slot {
public: public:
static const int SKINNING_GPU = 2; static const int SKINNING_GPU = 2;
static const int MATERIAL_GPU = 3; static const int MATERIAL_GPU = 3;
@ -163,7 +163,7 @@ public:
using Key = ShapeKey; using Key = ShapeKey;
using Pipeline = ShapePipeline; using Pipeline = ShapePipeline;
using PipelinePointer = std::shared_ptr<Pipeline>; using PipelinePointer = std::shared_ptr<Pipeline>;
using Slots = ShapePipeline::Slots; using Slot = ShapePipeline::Slot;
using Locations = ShapePipeline::Locations; using Locations = ShapePipeline::Locations;
using PipelineMap = std::unordered_map<ShapeKey, PipelinePointer, ShapeKey::Hash, ShapeKey::KeyEqual>; using PipelineMap = std::unordered_map<ShapeKey, PipelinePointer, ShapeKey::Hash, ShapeKey::KeyEqual>;