From e9d751fd23f85b980aa47faf702b89292c01e20d Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Wed, 10 Jan 2018 17:01:01 -0800 Subject: [PATCH] try to avoid reusing uniform buffer locations --- .../src/RenderableParticleEffectEntityItem.cpp | 7 ++++++- .../src/RenderablePolyLineEntityItem.cpp | 5 +++-- libraries/render-utils/src/LightClusters.cpp | 13 ++++++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp index bc96e45881..a3e6cd4341 100644 --- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp @@ -23,6 +23,8 @@ using namespace render::entities; static uint8_t CUSTOM_PIPELINE_NUMBER = 0; static gpu::Stream::FormatPointer _vertexFormat; static std::weak_ptr _texturedPipeline; +// FIXME: This is interfering with the uniform buffers in DeferredLightingEffect.cpp, so use 11 to avoid collisions +static int32_t PARTICLE_UNIFORM_SLOT { 11 }; static ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key) { auto texturedPipeline = _texturedPipeline.lock(); @@ -38,6 +40,9 @@ static ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, co auto fragShader = gpu::Shader::createPixel(std::string(textured_particle_frag)); auto program = gpu::Shader::createProgram(vertShader, fragShader); + gpu::Shader::BindingSet slotBindings; + slotBindings.insert(gpu::Shader::Binding(std::string("particleBuffer"), PARTICLE_UNIFORM_SLOT)); + gpu::Shader::makeProgram(*program, slotBindings); _texturedPipeline = texturedPipeline = gpu::Pipeline::create(program, state); } @@ -320,7 +325,7 @@ void ParticleEffectEntityRenderer::doRender(RenderArgs* args) { transform.setScale(vec3(1)); } batch.setModelTransform(transform); - batch.setUniformBuffer(0, _uniformBuffer); + batch.setUniformBuffer(PARTICLE_UNIFORM_SLOT, _uniformBuffer); batch.setInputFormat(_vertexFormat); batch.setInputBuffer(0, _particleBuffer, 0, sizeof(GpuParticle)); diff --git a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp index 21764dff7f..b362721cde 100644 --- a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp @@ -33,8 +33,9 @@ using namespace render; using namespace render::entities; static uint8_t CUSTOM_PIPELINE_NUMBER { 0 }; -static const int32_t PAINTSTROKE_TEXTURE_SLOT{ 0 }; -static const int32_t PAINTSTROKE_UNIFORM_SLOT{ 0 }; +static const int32_t PAINTSTROKE_TEXTURE_SLOT { 0 }; +// FIXME: This is interfering with the uniform buffers in DeferredLightingEffect.cpp, so use 11 to avoid collisions +static const int32_t PAINTSTROKE_UNIFORM_SLOT { 11 }; static gpu::Stream::FormatPointer polylineFormat; static gpu::PipelinePointer polylinePipeline; #ifdef POLYLINE_ENTITY_USE_FADE_EFFECT diff --git a/libraries/render-utils/src/LightClusters.cpp b/libraries/render-utils/src/LightClusters.cpp index eedb9053c7..d6ac7fd2e2 100644 --- a/libraries/render-utils/src/LightClusters.cpp +++ b/libraries/render-utils/src/LightClusters.cpp @@ -37,14 +37,13 @@ enum LightClusterGridShader_MapSlot { }; enum LightClusterGridShader_BufferSlot { - LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT = 0, - DEFERRED_FRAME_TRANSFORM_BUFFER_SLOT =1, - CAMERA_CORRECTION_BUFFER_SLOT = 2, + DEFERRED_FRAME_TRANSFORM_BUFFER_SLOT = 0, + CAMERA_CORRECTION_BUFFER_SLOT = 1, LIGHT_GPU_SLOT = render::ShapePipeline::Slot::LIGHT, - LIGHT_INDEX_GPU_SLOT = 5, - - LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT = 6, - LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT = 7, + LIGHT_INDEX_GPU_SLOT = 7, + LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT = 8, + LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT = 9, + LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT = 10, }; FrustumGrid::FrustumGrid(const FrustumGrid& source) :