Hide renderer internals
Some checks failed
CI / Native Windows Build And Tests (push) Has been cancelled
CI / React UI Build (push) Has been cancelled
CI / Windows Release Package (push) Has been cancelled

This commit is contained in:
2026-05-06 10:48:50 +10:00
parent 35f5a024fd
commit 5fd24b3f06
5 changed files with 94 additions and 64 deletions

View File

@@ -131,7 +131,7 @@ bool OpenGLComposite::InitDeckLink()
} }
if (mDeckLink->inputFrameWidth != mDeckLink->outputFrameWidth || mDeckLink->inputFrameHeight != mDeckLink->outputFrameHeight) if (mDeckLink->inputFrameWidth != mDeckLink->outputFrameWidth || mDeckLink->inputFrameHeight != mDeckLink->outputFrameHeight)
{ {
mRenderer->mFastTransferExtensionAvailable = false; mRenderer->SetFastTransferAvailable(false);
OutputDebugStringA("Input/output dimensions differ; using regular OpenGL transfer fallback instead of fast transfer.\n"); OutputDebugStringA("Input/output dimensions differ; using regular OpenGL transfer fallback instead of fast transfer.\n");
} }
@@ -151,10 +151,10 @@ bool OpenGLComposite::InitDeckLink()
else else
resizeWindow(mDeckLink->outputFrameWidth / 2, mDeckLink->outputFrameHeight / 2); resizeWindow(mDeckLink->outputFrameWidth / 2, mDeckLink->outputFrameHeight / 2);
if (mRenderer->mFastTransferExtensionAvailable) if (mRenderer->FastTransferAvailable())
{ {
// Initialize fast video frame transfers // Initialize fast video frame transfers
if (! VideoFrameTransfer::initialize(mDeckLink->inputFrameWidth, mDeckLink->inputFrameHeight, mRenderer->mCaptureTexture, mRenderer->mOutputTexture)) if (! VideoFrameTransfer::initialize(mDeckLink->inputFrameWidth, mDeckLink->inputFrameHeight, mRenderer->CaptureTexture(), mRenderer->OutputTexture()))
{ {
MessageBox(NULL, _T("Cannot initialize video transfers."), _T("VideoFrameTransfer error."), MB_OK); MessageBox(NULL, _T("Cannot initialize video transfers."), _T("VideoFrameTransfer error."), MB_OK);
goto error; goto error;
@@ -307,10 +307,10 @@ void OpenGLComposite::VideoFrameArrived(IDeckLinkVideoInputFrame* inputFrame, bo
wglMakeCurrent( hGLDC, hGLRC ); // make OpenGL context current in this thread wglMakeCurrent( hGLDC, hGLRC ); // make OpenGL context current in this thread
if (mRenderer->mFastTransferExtensionAvailable) if (mRenderer->FastTransferAvailable())
{ {
CComQIPtr<PinnedMemoryAllocator, &IID_PinnedMemoryAllocator> allocator(inputFrameBuffer); CComQIPtr<PinnedMemoryAllocator, &IID_PinnedMemoryAllocator> allocator(inputFrameBuffer);
if (!allocator || !allocator->transferFrame(videoPixels, mRenderer->mCaptureTexture)) if (!allocator || !allocator->transferFrame(videoPixels, mRenderer->CaptureTexture()))
OutputDebugStringA("Capture: transferFrame() failed\n"); OutputDebugStringA("Capture: transferFrame() failed\n");
allocator->waitForTransferComplete(videoPixels); allocator->waitForTransferComplete(videoPixels);
@@ -318,9 +318,9 @@ void OpenGLComposite::VideoFrameArrived(IDeckLinkVideoInputFrame* inputFrame, bo
else else
{ {
// Use a straightforward texture buffer // Use a straightforward texture buffer
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, mRenderer->mUnpinnedTextureBuffer); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, mRenderer->UnpinnedTextureBuffer());
glBufferData(GL_PIXEL_UNPACK_BUFFER, textureSize, videoPixels, GL_DYNAMIC_DRAW); glBufferData(GL_PIXEL_UNPACK_BUFFER, textureSize, videoPixels, GL_DYNAMIC_DRAW);
glBindTexture(GL_TEXTURE_2D, mRenderer->mCaptureTexture); glBindTexture(GL_TEXTURE_2D, mRenderer->CaptureTexture());
// NULL for last arg indicates use current GL_PIXEL_UNPACK_BUFFER target as texture data // NULL for last arg indicates use current GL_PIXEL_UNPACK_BUFFER target as texture data
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, mDeckLink->inputFrameWidth / 2, mDeckLink->inputFrameHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, mDeckLink->inputFrameWidth / 2, mDeckLink->inputFrameHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
@@ -353,16 +353,16 @@ void OpenGLComposite::PlayoutFrameCompleted(IDeckLinkVideoFrame* completedFrame,
// Draw the effect output to the off-screen framebuffer. // Draw the effect output to the off-screen framebuffer.
const auto renderStartTime = std::chrono::steady_clock::now(); const auto renderStartTime = std::chrono::steady_clock::now();
if (mRenderer->mFastTransferExtensionAvailable) if (mRenderer->FastTransferAvailable())
VideoFrameTransfer::beginTextureInUse(VideoFrameTransfer::GPUtoCPU); VideoFrameTransfer::beginTextureInUse(VideoFrameTransfer::GPUtoCPU);
glBindFramebuffer(GL_FRAMEBUFFER, mRenderer->mIdFrameBuf); glBindFramebuffer(GL_FRAMEBUFFER, mRenderer->CompositeFramebuffer());
renderEffect(); renderEffect();
glBindFramebuffer(GL_READ_FRAMEBUFFER, mRenderer->mIdFrameBuf); glBindFramebuffer(GL_READ_FRAMEBUFFER, mRenderer->CompositeFramebuffer());
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mRenderer->mOutputFrameBuf); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mRenderer->OutputFramebuffer());
glBlitFramebuffer(0, 0, mDeckLink->inputFrameWidth, mDeckLink->inputFrameHeight, 0, 0, mDeckLink->outputFrameWidth, mDeckLink->outputFrameHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR); glBlitFramebuffer(0, 0, mDeckLink->inputFrameWidth, mDeckLink->inputFrameHeight, 0, 0, mDeckLink->outputFrameWidth, mDeckLink->outputFrameHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
glBindFramebuffer(GL_FRAMEBUFFER, mRenderer->mOutputFrameBuf); glBindFramebuffer(GL_FRAMEBUFFER, mRenderer->OutputFramebuffer());
glFlush(); glFlush();
if (mRenderer->mFastTransferExtensionAvailable) if (mRenderer->FastTransferAvailable())
VideoFrameTransfer::endTextureInUse(VideoFrameTransfer::GPUtoCPU); VideoFrameTransfer::endTextureInUse(VideoFrameTransfer::GPUtoCPU);
const auto renderEndTime = std::chrono::steady_clock::now(); const auto renderEndTime = std::chrono::steady_clock::now();
if (mRuntimeHost) if (mRuntimeHost)
@@ -393,13 +393,13 @@ void OpenGLComposite::PlayoutFrameCompleted(IDeckLinkVideoFrame* completedFrame,
void* pFrame; void* pFrame;
outputVideoFrameBuffer->GetBytes(&pFrame); outputVideoFrameBuffer->GetBytes(&pFrame);
if (mRenderer->mFastTransferExtensionAvailable) if (mRenderer->FastTransferAvailable())
{ {
// Finished with mRenderer->mCaptureTexture // Finished sampling the capture texture for this frame.
if (!mDeckLink->hasNoInputSource) if (!mDeckLink->hasNoInputSource)
VideoFrameTransfer::endTextureInUse(VideoFrameTransfer::CPUtoGPU); VideoFrameTransfer::endTextureInUse(VideoFrameTransfer::CPUtoGPU);
if (! mDeckLink->playoutAllocator->transferFrame(pFrame, mRenderer->mOutputTexture)) if (! mDeckLink->playoutAllocator->transferFrame(pFrame, mRenderer->OutputTexture()))
OutputDebugStringA("Playback: transferFrame() failed\n"); OutputDebugStringA("Playback: transferFrame() failed\n");
paintGL(); paintGL();
@@ -409,7 +409,7 @@ void OpenGLComposite::PlayoutFrameCompleted(IDeckLinkVideoFrame* completedFrame,
} }
else else
{ {
glBindFramebuffer(GL_READ_FRAMEBUFFER, mRenderer->mOutputFrameBuf); glBindFramebuffer(GL_READ_FRAMEBUFFER, mRenderer->OutputFramebuffer());
glReadPixels(0, 0, mDeckLink->outputFrameWidth, mDeckLink->outputFrameHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pFrame); glReadPixels(0, 0, mDeckLink->outputFrameWidth, mDeckLink->outputFrameHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pFrame);
paintGL(); paintGL();
} }
@@ -551,9 +551,9 @@ void OpenGLComposite::resetTemporalHistoryState()
bool OpenGLComposite::CheckOpenGLExtensions() bool OpenGLComposite::CheckOpenGLExtensions()
{ {
mRenderer->mFastTransferExtensionAvailable = VideoFrameTransfer::checkFastMemoryTransferAvailable(); mRenderer->SetFastTransferAvailable(VideoFrameTransfer::checkFastMemoryTransferAvailable());
if (!mRenderer->mFastTransferExtensionAvailable) if (!mRenderer->FastTransferAvailable())
OutputDebugStringA("Fast memory transfer extension not available, using regular OpenGL transfer fallback instead\n"); OutputDebugStringA("Fast memory transfer extension not available, using regular OpenGL transfer fallback instead\n");
return true; return true;

View File

@@ -17,9 +17,9 @@ void OpenGLRenderPass::Render(
const TextBindingUpdater& updateTextBinding, const TextBindingUpdater& updateTextBinding,
const GlobalParamsUpdater& updateGlobalParams) const GlobalParamsUpdater& updateGlobalParams)
{ {
if (hasInputSource && mRenderer.mFastTransferExtensionAvailable) if (hasInputSource && mRenderer.FastTransferAvailable())
{ {
// Signal that we're about to draw using mCaptureTexture onto mFBOTexture. // Signal that the capture texture is about to be sampled into the composite framebuffer.
VideoFrameTransfer::beginTextureInUse(VideoFrameTransfer::CPUtoGPU); VideoFrameTransfer::beginTextureInUse(VideoFrameTransfer::CPUtoGPU);
} }
@@ -31,31 +31,32 @@ void OpenGLRenderPass::Render(
} }
else else
{ {
glBindFramebuffer(GL_FRAMEBUFFER, mRenderer.mDecodeFrameBuf); glBindFramebuffer(GL_FRAMEBUFFER, mRenderer.DecodeFramebuffer());
glViewport(0, 0, inputFrameWidth, inputFrameHeight); glViewport(0, 0, inputFrameWidth, inputFrameHeight);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
} }
if (layerStates.empty() || mRenderer.mLayerPrograms.empty()) std::vector<LayerProgram>& layerPrograms = mRenderer.LayerPrograms();
if (layerStates.empty() || layerPrograms.empty())
{ {
glBindFramebuffer(GL_READ_FRAMEBUFFER, mRenderer.mDecodeFrameBuf); glBindFramebuffer(GL_READ_FRAMEBUFFER, mRenderer.DecodeFramebuffer());
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mRenderer.mIdFrameBuf); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mRenderer.CompositeFramebuffer());
glBlitFramebuffer(0, 0, inputFrameWidth, inputFrameHeight, 0, 0, inputFrameWidth, inputFrameHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR); glBlitFramebuffer(0, 0, inputFrameWidth, inputFrameHeight, 0, 0, inputFrameWidth, inputFrameHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
glBindFramebuffer(GL_FRAMEBUFFER, mRenderer.mIdFrameBuf); glBindFramebuffer(GL_FRAMEBUFFER, mRenderer.CompositeFramebuffer());
} }
else else
{ {
GLuint sourceTexture = mRenderer.mDecodedTexture; GLuint sourceTexture = mRenderer.DecodedTexture();
GLuint sourceFrameBuffer = mRenderer.mDecodeFrameBuf; GLuint sourceFrameBuffer = mRenderer.DecodeFramebuffer();
for (std::size_t index = 0; index < layerStates.size() && index < mRenderer.mLayerPrograms.size(); ++index) for (std::size_t index = 0; index < layerStates.size() && index < layerPrograms.size(); ++index)
{ {
const std::size_t remaining = layerStates.size() - index; const std::size_t remaining = layerStates.size() - index;
const bool writeToMain = (remaining % 2) == 1; const bool writeToMain = (remaining % 2) == 1;
RenderShaderProgram( RenderShaderProgram(
sourceTexture, sourceTexture,
writeToMain ? mRenderer.mIdFrameBuf : mRenderer.mLayerTempFrameBuf, writeToMain ? mRenderer.CompositeFramebuffer() : mRenderer.LayerTempFramebuffer(),
mRenderer.mLayerPrograms[index], layerPrograms[index],
layerStates[index], layerStates[index],
inputFrameWidth, inputFrameWidth,
inputFrameHeight, inputFrameHeight,
@@ -63,30 +64,30 @@ void OpenGLRenderPass::Render(
updateTextBinding, updateTextBinding,
updateGlobalParams); updateGlobalParams);
if (layerStates[index].temporalHistorySource == TemporalHistorySource::PreLayerInput) if (layerStates[index].temporalHistorySource == TemporalHistorySource::PreLayerInput)
mRenderer.mTemporalHistory.PushPreLayerFramebuffer(layerStates[index].layerId, sourceFrameBuffer, inputFrameWidth, inputFrameHeight); mRenderer.TemporalHistory().PushPreLayerFramebuffer(layerStates[index].layerId, sourceFrameBuffer, inputFrameWidth, inputFrameHeight);
sourceTexture = writeToMain ? mRenderer.mFBOTexture : mRenderer.mLayerTempTexture; sourceTexture = writeToMain ? mRenderer.CompositeTexture() : mRenderer.LayerTempTexture();
sourceFrameBuffer = writeToMain ? mRenderer.mIdFrameBuf : mRenderer.mLayerTempFrameBuf; sourceFrameBuffer = writeToMain ? mRenderer.CompositeFramebuffer() : mRenderer.LayerTempFramebuffer();
} }
} }
mRenderer.mTemporalHistory.PushSourceFramebuffer(mRenderer.mDecodeFrameBuf, inputFrameWidth, inputFrameHeight); mRenderer.TemporalHistory().PushSourceFramebuffer(mRenderer.DecodeFramebuffer(), inputFrameWidth, inputFrameHeight);
if (hasInputSource && mRenderer.mFastTransferExtensionAvailable) if (hasInputSource && mRenderer.FastTransferAvailable())
VideoFrameTransfer::endTextureInUse(VideoFrameTransfer::CPUtoGPU); VideoFrameTransfer::endTextureInUse(VideoFrameTransfer::CPUtoGPU);
} }
void OpenGLRenderPass::RenderDecodePass(unsigned inputFrameWidth, unsigned inputFrameHeight) void OpenGLRenderPass::RenderDecodePass(unsigned inputFrameWidth, unsigned inputFrameHeight)
{ {
glBindFramebuffer(GL_FRAMEBUFFER, mRenderer.mDecodeFrameBuf); glBindFramebuffer(GL_FRAMEBUFFER, mRenderer.DecodeFramebuffer());
glViewport(0, 0, inputFrameWidth, inputFrameHeight); glViewport(0, 0, inputFrameWidth, inputFrameHeight);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glActiveTexture(GL_TEXTURE0 + kPackedVideoTextureUnit); glActiveTexture(GL_TEXTURE0 + kPackedVideoTextureUnit);
glBindTexture(GL_TEXTURE_2D, mRenderer.mCaptureTexture); glBindTexture(GL_TEXTURE_2D, mRenderer.CaptureTexture());
glBindVertexArray(mRenderer.mFullscreenVAO); glBindVertexArray(mRenderer.FullscreenVertexArray());
glUseProgram(mRenderer.mDecodeProgram); glUseProgram(mRenderer.DecodeProgram());
const GLint packedResolutionLocation = glGetUniformLocation(mRenderer.mDecodeProgram, "uPackedVideoResolution"); const GLint packedResolutionLocation = glGetUniformLocation(mRenderer.DecodeProgram(), "uPackedVideoResolution");
const GLint decodedResolutionLocation = glGetUniformLocation(mRenderer.mDecodeProgram, "uDecodedVideoResolution"); const GLint decodedResolutionLocation = glGetUniformLocation(mRenderer.DecodeProgram(), "uDecodedVideoResolution");
if (packedResolutionLocation >= 0) if (packedResolutionLocation >= 0)
glUniform2f(packedResolutionLocation, static_cast<float>(inputFrameWidth / 2), static_cast<float>(inputFrameHeight)); glUniform2f(packedResolutionLocation, static_cast<float>(inputFrameWidth / 2), static_cast<float>(inputFrameHeight));
if (decodedResolutionLocation >= 0) if (decodedResolutionLocation >= 0)
@@ -123,11 +124,11 @@ void OpenGLRenderPass::RenderShaderProgram(
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glActiveTexture(GL_TEXTURE0 + kDecodedVideoTextureUnit); glActiveTexture(GL_TEXTURE0 + kDecodedVideoTextureUnit);
glBindTexture(GL_TEXTURE_2D, sourceTexture); glBindTexture(GL_TEXTURE_2D, sourceTexture);
mRenderer.mTemporalHistory.BindSamplers(state, sourceTexture, historyCap); mRenderer.TemporalHistory().BindSamplers(state, sourceTexture, historyCap);
BindLayerTextureAssets(layerProgram); BindLayerTextureAssets(layerProgram);
glBindVertexArray(mRenderer.mFullscreenVAO); glBindVertexArray(mRenderer.FullscreenVertexArray());
glUseProgram(layerProgram.program); glUseProgram(layerProgram.program);
updateGlobalParams(state, mRenderer.mTemporalHistory.SourceAvailableCount(), mRenderer.mTemporalHistory.AvailableCountForLayer(state.layerId)); updateGlobalParams(state, mRenderer.TemporalHistory().SourceAvailableCount(), mRenderer.TemporalHistory().AvailableCountForLayer(state.layerId));
glDrawArrays(GL_TRIANGLES, 0, 3); glDrawArrays(GL_TRIANGLES, 0, 3);
glUseProgram(0); glUseProgram(0);
glBindVertexArray(0); glBindVertexArray(0);

View File

@@ -102,6 +102,13 @@ bool OpenGLRenderer::InitializeResources(unsigned inputFrameWidth, unsigned inpu
return true; return true;
} }
void OpenGLRenderer::SetDecodeShaderProgram(GLuint program, GLuint vertexShader, GLuint fragmentShader)
{
mDecodeProgram = program;
mDecodeVertexShader = vertexShader;
mDecodeFragmentShader = fragmentShader;
}
void OpenGLRenderer::ResizeView(int width, int height) void OpenGLRenderer::ResizeView(int width, int height)
{ {
mViewWidth = width; mViewWidth = width;

View File

@@ -44,6 +44,38 @@ public:
std::vector<TextBinding> textBindings; std::vector<TextBinding> textBindings;
}; };
bool FastTransferAvailable() const { return mFastTransferExtensionAvailable; }
void SetFastTransferAvailable(bool available) { mFastTransferExtensionAvailable = available; }
GLuint CaptureTexture() const { return mCaptureTexture; }
GLuint DecodedTexture() const { return mDecodedTexture; }
GLuint LayerTempTexture() const { return mLayerTempTexture; }
GLuint CompositeTexture() const { return mFBOTexture; }
GLuint OutputTexture() const { return mOutputTexture; }
GLuint UnpinnedTextureBuffer() const { return mUnpinnedTextureBuffer; }
GLuint DecodeFramebuffer() const { return mDecodeFrameBuf; }
GLuint LayerTempFramebuffer() const { return mLayerTempFrameBuf; }
GLuint CompositeFramebuffer() const { return mIdFrameBuf; }
GLuint OutputFramebuffer() const { return mOutputFrameBuf; }
GLuint FullscreenVertexArray() const { return mFullscreenVAO; }
GLuint GlobalParamsUBO() const { return mGlobalParamsUBO; }
GLuint DecodeProgram() const { return mDecodeProgram; }
GLsizeiptr GlobalParamsUBOSize() const { return mGlobalParamsUBOSize; }
void SetGlobalParamsUBOSize(GLsizeiptr size) { mGlobalParamsUBOSize = size; }
void ReplaceLayerPrograms(std::vector<LayerProgram>& newPrograms) { mLayerPrograms.swap(newPrograms); }
std::vector<LayerProgram>& LayerPrograms() { return mLayerPrograms; }
const std::vector<LayerProgram>& LayerPrograms() const { return mLayerPrograms; }
TemporalHistoryBuffers& TemporalHistory() { return mTemporalHistory; }
const TemporalHistoryBuffers& TemporalHistory() const { return mTemporalHistory; }
void SetDecodeShaderProgram(GLuint program, GLuint vertexShader, GLuint fragmentShader);
bool InitializeResources(unsigned inputFrameWidth, unsigned inputFrameHeight, unsigned outputFrameWidth, unsigned outputFrameHeight, std::string& error);
void ResizeView(int width, int height);
void PresentToWindow(HDC hdc, unsigned outputFrameWidth, unsigned outputFrameHeight);
void DestroyResources();
void DestroySingleLayerProgram(LayerProgram& layerProgram);
void DestroyLayerPrograms();
void DestroyDecodeShaderProgram();
private:
bool mFastTransferExtensionAvailable = false; bool mFastTransferExtensionAvailable = false;
GLuint mCaptureTexture = 0; GLuint mCaptureTexture = 0;
GLuint mDecodedTexture = 0; GLuint mDecodedTexture = 0;
@@ -67,12 +99,4 @@ public:
int mViewHeight = 0; int mViewHeight = 0;
std::vector<LayerProgram> mLayerPrograms; std::vector<LayerProgram> mLayerPrograms;
TemporalHistoryBuffers mTemporalHistory; TemporalHistoryBuffers mTemporalHistory;
bool InitializeResources(unsigned inputFrameWidth, unsigned inputFrameHeight, unsigned outputFrameWidth, unsigned outputFrameHeight, std::string& error);
void ResizeView(int width, int height);
void PresentToWindow(HDC hdc, unsigned outputFrameWidth, unsigned outputFrameHeight);
void DestroyResources();
void DestroySingleLayerProgram(LayerProgram& layerProgram);
void DestroyLayerPrograms();
void DestroyDecodeShaderProgram();
}; };

View File

@@ -62,12 +62,12 @@ bool OpenGLShaderPrograms::CompileLayerPrograms(unsigned inputFrameWidth, unsign
const std::vector<RuntimeRenderState> layerStates = mRuntimeHost.GetLayerRenderStates(inputFrameWidth, inputFrameHeight); const std::vector<RuntimeRenderState> layerStates = mRuntimeHost.GetLayerRenderStates(inputFrameWidth, inputFrameHeight);
std::string temporalError; std::string temporalError;
const unsigned historyCap = mRuntimeHost.GetMaxTemporalHistoryFrames(); const unsigned historyCap = mRuntimeHost.GetMaxTemporalHistoryFrames();
if (!mRenderer.mTemporalHistory.ValidateTextureUnitBudget(layerStates, historyCap, temporalError)) if (!mRenderer.TemporalHistory().ValidateTextureUnitBudget(layerStates, historyCap, temporalError))
{ {
CopyErrorMessage(temporalError, errorMessageSize, errorMessage); CopyErrorMessage(temporalError, errorMessageSize, errorMessage);
return false; return false;
} }
if (!mRenderer.mTemporalHistory.EnsureResources(layerStates, historyCap, inputFrameWidth, inputFrameHeight, temporalError)) if (!mRenderer.TemporalHistory().EnsureResources(layerStates, historyCap, inputFrameWidth, inputFrameHeight, temporalError))
{ {
CopyErrorMessage(temporalError, errorMessageSize, errorMessage); CopyErrorMessage(temporalError, errorMessageSize, errorMessage);
return false; return false;
@@ -89,7 +89,7 @@ bool OpenGLShaderPrograms::CompileLayerPrograms(unsigned inputFrameWidth, unsign
} }
DestroyLayerPrograms(); DestroyLayerPrograms();
mRenderer.mLayerPrograms.swap(newPrograms); mRenderer.ReplaceLayerPrograms(newPrograms);
mRuntimeHost.SetCompileStatus(true, "Shader layers compiled successfully."); mRuntimeHost.SetCompileStatus(true, "Shader layers compiled successfully.");
mRuntimeHost.ClearReloadRequest(); mRuntimeHost.ClearReloadRequest();
@@ -273,9 +273,7 @@ bool OpenGLShaderPrograms::CompileDecodeShader(int errorMessageSize, char* error
} }
DestroyDecodeShaderProgram(); DestroyDecodeShaderProgram();
mRenderer.mDecodeProgram = newProgram.release(); mRenderer.SetDecodeShaderProgram(newProgram.release(), newVertexShader.release(), newFragmentShader.release());
mRenderer.mDecodeVertexShader = newVertexShader.release();
mRenderer.mDecodeFragmentShader = newFragmentShader.release();
return true; return true;
} }
@@ -296,7 +294,7 @@ void OpenGLShaderPrograms::DestroyDecodeShaderProgram()
void OpenGLShaderPrograms::ResetTemporalHistoryState() void OpenGLShaderPrograms::ResetTemporalHistoryState()
{ {
mRenderer.mTemporalHistory.ResetState(); mRenderer.TemporalHistory().ResetState();
} }
bool OpenGLShaderPrograms::LoadTextureAsset(const ShaderTextureAsset& textureAsset, GLuint& textureId, std::string& error) bool OpenGLShaderPrograms::LoadTextureAsset(const ShaderTextureAsset& textureAsset, GLuint& textureId, std::string& error)
@@ -410,17 +408,17 @@ bool OpenGLShaderPrograms::UpdateGlobalParamsBuffer(const RuntimeRenderState& st
buffer.resize(AlignStd140(buffer.size(), 16), 0); buffer.resize(AlignStd140(buffer.size(), 16), 0);
glBindBuffer(GL_UNIFORM_BUFFER, mRenderer.mGlobalParamsUBO); glBindBuffer(GL_UNIFORM_BUFFER, mRenderer.GlobalParamsUBO());
if (mRenderer.mGlobalParamsUBOSize != static_cast<GLsizeiptr>(buffer.size())) if (mRenderer.GlobalParamsUBOSize() != static_cast<GLsizeiptr>(buffer.size()))
{ {
glBufferData(GL_UNIFORM_BUFFER, static_cast<GLsizeiptr>(buffer.size()), buffer.data(), GL_DYNAMIC_DRAW); glBufferData(GL_UNIFORM_BUFFER, static_cast<GLsizeiptr>(buffer.size()), buffer.data(), GL_DYNAMIC_DRAW);
mRenderer.mGlobalParamsUBOSize = static_cast<GLsizeiptr>(buffer.size()); mRenderer.SetGlobalParamsUBOSize(static_cast<GLsizeiptr>(buffer.size()));
} }
else else
{ {
glBufferSubData(GL_UNIFORM_BUFFER, 0, static_cast<GLsizeiptr>(buffer.size()), buffer.data()); glBufferSubData(GL_UNIFORM_BUFFER, 0, static_cast<GLsizeiptr>(buffer.size()), buffer.data());
} }
glBindBufferBase(GL_UNIFORM_BUFFER, kGlobalParamsBindingPoint, mRenderer.mGlobalParamsUBO); glBindBufferBase(GL_UNIFORM_BUFFER, kGlobalParamsBindingPoint, mRenderer.GlobalParamsUBO());
glBindBuffer(GL_UNIFORM_BUFFER, 0); glBindBuffer(GL_UNIFORM_BUFFER, 0);
return true; return true;