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)
{
mRenderer->mFastTransferExtensionAvailable = false;
mRenderer->SetFastTransferAvailable(false);
OutputDebugStringA("Input/output dimensions differ; using regular OpenGL transfer fallback instead of fast transfer.\n");
}
@@ -151,10 +151,10 @@ bool OpenGLComposite::InitDeckLink()
else
resizeWindow(mDeckLink->outputFrameWidth / 2, mDeckLink->outputFrameHeight / 2);
if (mRenderer->mFastTransferExtensionAvailable)
if (mRenderer->FastTransferAvailable())
{
// 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);
goto error;
@@ -307,10 +307,10 @@ void OpenGLComposite::VideoFrameArrived(IDeckLinkVideoInputFrame* inputFrame, bo
wglMakeCurrent( hGLDC, hGLRC ); // make OpenGL context current in this thread
if (mRenderer->mFastTransferExtensionAvailable)
if (mRenderer->FastTransferAvailable())
{
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");
allocator->waitForTransferComplete(videoPixels);
@@ -318,9 +318,9 @@ void OpenGLComposite::VideoFrameArrived(IDeckLinkVideoInputFrame* inputFrame, bo
else
{
// 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);
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
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.
const auto renderStartTime = std::chrono::steady_clock::now();
if (mRenderer->mFastTransferExtensionAvailable)
if (mRenderer->FastTransferAvailable())
VideoFrameTransfer::beginTextureInUse(VideoFrameTransfer::GPUtoCPU);
glBindFramebuffer(GL_FRAMEBUFFER, mRenderer->mIdFrameBuf);
glBindFramebuffer(GL_FRAMEBUFFER, mRenderer->CompositeFramebuffer());
renderEffect();
glBindFramebuffer(GL_READ_FRAMEBUFFER, mRenderer->mIdFrameBuf);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mRenderer->mOutputFrameBuf);
glBindFramebuffer(GL_READ_FRAMEBUFFER, mRenderer->CompositeFramebuffer());
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);
glBindFramebuffer(GL_FRAMEBUFFER, mRenderer->mOutputFrameBuf);
glBindFramebuffer(GL_FRAMEBUFFER, mRenderer->OutputFramebuffer());
glFlush();
if (mRenderer->mFastTransferExtensionAvailable)
if (mRenderer->FastTransferAvailable())
VideoFrameTransfer::endTextureInUse(VideoFrameTransfer::GPUtoCPU);
const auto renderEndTime = std::chrono::steady_clock::now();
if (mRuntimeHost)
@@ -393,13 +393,13 @@ void OpenGLComposite::PlayoutFrameCompleted(IDeckLinkVideoFrame* completedFrame,
void* 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)
VideoFrameTransfer::endTextureInUse(VideoFrameTransfer::CPUtoGPU);
if (! mDeckLink->playoutAllocator->transferFrame(pFrame, mRenderer->mOutputTexture))
if (! mDeckLink->playoutAllocator->transferFrame(pFrame, mRenderer->OutputTexture()))
OutputDebugStringA("Playback: transferFrame() failed\n");
paintGL();
@@ -409,7 +409,7 @@ void OpenGLComposite::PlayoutFrameCompleted(IDeckLinkVideoFrame* completedFrame,
}
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);
paintGL();
}
@@ -551,9 +551,9 @@ void OpenGLComposite::resetTemporalHistoryState()
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");
return true;