diff --git a/libraries/render-utils/src/SubsurfaceScattering.cpp b/libraries/render-utils/src/SubsurfaceScattering.cpp index 50067d003f..60f47cc0db 100644 --- a/libraries/render-utils/src/SubsurfaceScattering.cpp +++ b/libraries/render-utils/src/SubsurfaceScattering.cpp @@ -311,8 +311,8 @@ void diffuseProfileGPU(gpu::TexturePointer& profileMap, RenderArgs* args) { auto ps = subsurfaceScattering_makeProfile_frag::getShader(); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); - gpu::Shader::BindingSet slotBindings; - gpu::Shader::makeProgram(*program, slotBindings); + //gpu::Shader::BindingSet slotBindings; + // gpu::Shader::makeProgram(*program, slotBindings); gpu::StatePointer state = gpu::StatePointer(new gpu::State()); @@ -342,26 +342,31 @@ void diffuseScatterGPU(const gpu::TexturePointer& profileMap, gpu::TexturePointe int height = lut->getHeight(); gpu::PipelinePointer makePipeline; - { - auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS(); - auto ps = subsurfaceScattering_makeLUT_frag::getShader(); - gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); + + auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS(); + auto ps = subsurfaceScattering_makeLUT_frag::getShader(); + gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); + //gpu::Shader::BindingSet slotBindings; + //slotBindings.insert(gpu::Shader::Binding(std::string("scatteringProfile"), 0)); + //gpu::Shader::makeProgram(*program, slotBindings); - gpu::Shader::BindingSet slotBindings; - slotBindings.insert(gpu::Shader::Binding(std::string("scatteringProfile"), 0)); - gpu::Shader::makeProgram(*program, slotBindings); - gpu::StatePointer state = gpu::StatePointer(new gpu::State()); - - makePipeline = gpu::Pipeline::create(program, state); - } + gpu::StatePointer state = gpu::StatePointer(new gpu::State()); + makePipeline = gpu::Pipeline::create(program, state); + auto makeFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("diffuseScatter")); makeFramebuffer->setRenderBuffer(0, lut); gpu::doInBatch("SubsurfaceScattering::diffuseScatterGPU", args->_context, [=](gpu::Batch& batch) { batch.enableStereo(false); + batch.runLambda([program] (){ + gpu::Shader::BindingSet slotBindings; + slotBindings.insert(gpu::Shader::Binding(std::string("scatteringProfile"), 0)); + gpu::Shader::makeProgram(*program, slotBindings); + }); + batch.setViewportTransform(glm::ivec4(0, 0, width, height)); batch.setFramebuffer(makeFramebuffer); @@ -385,8 +390,8 @@ void computeSpecularBeckmannGPU(gpu::TexturePointer& beckmannMap, RenderArgs* ar auto ps = subsurfaceScattering_makeSpecularBeckmann_frag::getShader(); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); - gpu::Shader::BindingSet slotBindings; - gpu::Shader::makeProgram(*program, slotBindings); + //gpu::Shader::BindingSet slotBindings; + //gpu::Shader::makeProgram(*program, slotBindings); gpu::StatePointer state = gpu::StatePointer(new gpu::State()); @@ -495,7 +500,7 @@ gpu::PipelinePointer DebugSubsurfaceScattering::getShowLUTPipeline() { gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::Shader::BindingSet slotBindings; - gpu::Shader::makeProgram(*program, slotBindings); + //gpu::Shader::makeProgram(*program, slotBindings); gpu::StatePointer state = gpu::StatePointer(new gpu::State()); diff --git a/libraries/render-utils/src/SurfaceGeometryPass.cpp b/libraries/render-utils/src/SurfaceGeometryPass.cpp index cfdb67ecb6..943cf14719 100644 --- a/libraries/render-utils/src/SurfaceGeometryPass.cpp +++ b/libraries/render-utils/src/SurfaceGeometryPass.cpp @@ -167,7 +167,7 @@ void LinearDepthPass::run(const render::RenderContextPointer& renderContext, con outputs.edit3() = halfLinearDepthTexture; outputs.edit4() = halfNormalTexture; - auto linearDepthPipeline = getLinearDepthPipeline(); + auto linearDepthPipeline = getLinearDepthPipeline(renderContext); auto downsamplePipeline = getDownsamplePipeline(); auto depthViewport = args->_viewport; @@ -209,16 +209,17 @@ void LinearDepthPass::run(const render::RenderContextPointer& renderContext, con } -const gpu::PipelinePointer& LinearDepthPass::getLinearDepthPipeline() { +const gpu::PipelinePointer& LinearDepthPass::getLinearDepthPipeline(const render::RenderContextPointer& renderContext) { + gpu::ShaderPointer program; if (!_linearDepthPipeline) { auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS(); auto ps = surfaceGeometry_makeLinearDepth_frag::getShader(); - gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); + program = gpu::Shader::createProgram(vs, ps); - gpu::Shader::BindingSet slotBindings; + /*gpu::Shader::BindingSet slotBindings; slotBindings.insert(gpu::Shader::Binding(std::string("deferredFrameTransformBuffer"), DepthLinearPass_FrameTransformSlot)); slotBindings.insert(gpu::Shader::Binding(std::string("depthMap"), DepthLinearPass_DepthMapSlot)); - gpu::Shader::makeProgram(*program, slotBindings); + gpu::Shader::makeProgram(*program, slotBindings);*/ gpu::StatePointer state = gpu::StatePointer(new gpu::State()); @@ -230,8 +231,16 @@ const gpu::PipelinePointer& LinearDepthPass::getLinearDepthPipeline() { // Good to go add the brand new pipeline _linearDepthPipeline = gpu::Pipeline::create(program, state); + + gpu::doInBatch("LinearDepthPass::run", renderContext->args->_context, [=](gpu::Batch& batch) { + gpu::Shader::BindingSet slotBindings; + slotBindings.insert(gpu::Shader::Binding(std::string("deferredFrameTransformBuffer"), DepthLinearPass_FrameTransformSlot)); + slotBindings.insert(gpu::Shader::Binding(std::string("depthMap"), DepthLinearPass_DepthMapSlot)); + gpu::Shader::makeProgram(*program, slotBindings); + }); } + return _linearDepthPipeline; } diff --git a/libraries/render-utils/src/SurfaceGeometryPass.h b/libraries/render-utils/src/SurfaceGeometryPass.h index 859bcaa07a..2e517731c3 100644 --- a/libraries/render-utils/src/SurfaceGeometryPass.h +++ b/libraries/render-utils/src/SurfaceGeometryPass.h @@ -81,7 +81,7 @@ private: LinearDepthFramebufferPointer _linearDepthFramebuffer; - const gpu::PipelinePointer& getLinearDepthPipeline(); + const gpu::PipelinePointer& getLinearDepthPipeline(const render::RenderContextPointer& renderContext); gpu::PipelinePointer _linearDepthPipeline; const gpu::PipelinePointer& getDownsamplePipeline();