added new layer input pass
This commit is contained in:
@@ -188,6 +188,7 @@ std::vector<RenderPassDescriptor> OpenGLRenderPass::BuildLayerPassDescriptors(
|
||||
pass.passId = passProgram.passId;
|
||||
pass.layerId = state.layerId;
|
||||
pass.shaderId = state.shaderId;
|
||||
pass.layerInputTexture = layerInputTexture;
|
||||
pass.sourceTexture = passSourceTexture;
|
||||
pass.sourceFramebuffer = passIndex == 0 ? layerInputFramebuffer : passSourceFramebuffer;
|
||||
pass.destinationTexture = passDestinationTexture;
|
||||
@@ -226,6 +227,7 @@ void OpenGLRenderPass::RenderLayerPass(
|
||||
return;
|
||||
|
||||
RenderShaderProgram(
|
||||
pass.layerInputTexture,
|
||||
pass.sourceTexture,
|
||||
pass.destinationFramebuffer,
|
||||
*pass.passProgram,
|
||||
@@ -243,6 +245,7 @@ void OpenGLRenderPass::RenderLayerPass(
|
||||
}
|
||||
|
||||
void OpenGLRenderPass::RenderShaderProgram(
|
||||
GLuint layerInputTexture,
|
||||
GLuint sourceTexture,
|
||||
GLuint destinationFrameBuffer,
|
||||
PassProgram& passProgram,
|
||||
@@ -267,7 +270,7 @@ void OpenGLRenderPass::RenderShaderProgram(
|
||||
const std::vector<GLuint> temporalHistoryTextures = mRenderer.TemporalHistory().ResolveTemporalHistoryTextures(state, sourceTexture, state.isTemporal ? historyCap : 0);
|
||||
const GLuint feedbackTexture = mRenderer.FeedbackBuffers().ResolveReadTexture(state);
|
||||
const ShaderTextureBindings::RuntimeTextureBindingPlan texturePlan =
|
||||
mTextureBindings.BuildLayerRuntimeBindingPlan(passProgram, sourceTexture, state, feedbackTexture, sourceHistoryTextures, temporalHistoryTextures);
|
||||
mTextureBindings.BuildLayerRuntimeBindingPlan(passProgram, sourceTexture, layerInputTexture, state, feedbackTexture, sourceHistoryTextures, temporalHistoryTextures);
|
||||
mTextureBindings.BindRuntimeTexturePlan(texturePlan);
|
||||
glBindVertexArray(mRenderer.FullscreenVertexArray());
|
||||
glUseProgram(passProgram.program);
|
||||
|
||||
@@ -44,6 +44,7 @@ private:
|
||||
const TextBindingUpdater& updateTextBinding,
|
||||
const GlobalParamsUpdater& updateGlobalParams);
|
||||
void RenderShaderProgram(
|
||||
GLuint layerInputTexture,
|
||||
GLuint sourceTexture,
|
||||
GLuint destinationFrameBuffer,
|
||||
PassProgram& passProgram,
|
||||
|
||||
@@ -28,6 +28,7 @@ struct RenderPassDescriptor
|
||||
std::string passId;
|
||||
std::string layerId;
|
||||
std::string shaderId;
|
||||
GLuint layerInputTexture = 0;
|
||||
GLuint sourceTexture = 0;
|
||||
GLuint sourceFramebuffer = 0;
|
||||
GLuint destinationTexture = 0;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <gl/gl.h>
|
||||
|
||||
constexpr GLuint kLayerInputTextureUnit = 0;
|
||||
constexpr GLuint kDecodedVideoTextureUnit = 1;
|
||||
constexpr GLuint kSourceHistoryTextureUnitBase = 2;
|
||||
constexpr GLuint kPackedVideoTextureUnit = 2;
|
||||
|
||||
@@ -117,7 +117,11 @@ void ShaderTextureBindings::AssignLayerSamplerUniforms(GLuint program, const Run
|
||||
{
|
||||
const GLuint shaderTextureBase = ResolveShaderTextureBase(state, historyCap);
|
||||
|
||||
const GLint videoInputLocation = glGetUniformLocation(program, "gVideoInput");
|
||||
const GLint layerInputLocation = FindSamplerUniformLocation(program, "gLayerInput");
|
||||
if (layerInputLocation >= 0)
|
||||
glUniform1i(layerInputLocation, static_cast<GLint>(kLayerInputTextureUnit));
|
||||
|
||||
const GLint videoInputLocation = FindSamplerUniformLocation(program, "gVideoInput");
|
||||
if (videoInputLocation >= 0)
|
||||
glUniform1i(videoInputLocation, static_cast<GLint>(kDecodedVideoTextureUnit));
|
||||
|
||||
@@ -136,7 +140,7 @@ void ShaderTextureBindings::AssignLayerSamplerUniforms(GLuint program, const Run
|
||||
|
||||
if (state.feedback.enabled)
|
||||
{
|
||||
const GLint feedbackSamplerLocation = glGetUniformLocation(program, "gFeedbackState");
|
||||
const GLint feedbackSamplerLocation = FindSamplerUniformLocation(program, "gFeedbackState");
|
||||
if (feedbackSamplerLocation >= 0)
|
||||
glUniform1i(feedbackSamplerLocation, static_cast<GLint>(ResolveFeedbackTextureUnit(state, historyCap)));
|
||||
}
|
||||
@@ -160,12 +164,14 @@ void ShaderTextureBindings::AssignLayerSamplerUniforms(GLuint program, const Run
|
||||
ShaderTextureBindings::RuntimeTextureBindingPlan ShaderTextureBindings::BuildLayerRuntimeBindingPlan(
|
||||
const PassProgram& passProgram,
|
||||
GLuint layerInputTexture,
|
||||
GLuint originalLayerInputTexture,
|
||||
const RuntimeRenderState& state,
|
||||
GLuint feedbackTexture,
|
||||
const std::vector<GLuint>& sourceHistoryTextures,
|
||||
const std::vector<GLuint>& temporalHistoryTextures) const
|
||||
{
|
||||
RuntimeTextureBindingPlan plan;
|
||||
plan.bindings.push_back({ "originalLayerInput", "gLayerInput", originalLayerInputTexture, kLayerInputTextureUnit });
|
||||
plan.bindings.push_back({ "layerInput", "gVideoInput", layerInputTexture, kDecodedVideoTextureUnit });
|
||||
|
||||
for (std::size_t index = 0; index < sourceHistoryTextures.size(); ++index)
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
RuntimeTextureBindingPlan BuildLayerRuntimeBindingPlan(
|
||||
const PassProgram& passProgram,
|
||||
GLuint layerInputTexture,
|
||||
GLuint originalLayerInputTexture,
|
||||
const RuntimeRenderState& state,
|
||||
GLuint feedbackTexture,
|
||||
const std::vector<GLuint>& sourceHistoryTextures,
|
||||
|
||||
Reference in New Issue
Block a user