Skip to content

Commit 6cff080

Browse files
author
leadedge
committed
corrected test for fbo blit extension
1 parent 88f2fa7 commit 6cff080

File tree

4 files changed

+66
-57
lines changed

4 files changed

+66
-57
lines changed

SpoutSDK/Source/SpoutGLDXinterop.cpp

Lines changed: 60 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/**
22
33
spoutGLDXinterop.cpp
44
@@ -190,6 +190,7 @@
190190
- CleanupInterop after sender creation fail
191191
- CleanupDX9 change to prevent crash with Milkdrop
192192
- add pQuery->Release() to FlushWait
193+
04.02.17 - corrected test for fbo blit extension
193194
194195
*/
195196

@@ -486,7 +487,7 @@ bool spoutGLDXinterop::DX11available()
486487
//
487488
// https://code.google.com/p/chromium/issues/detail?id=106438
488489
//
489-
// NOTES : On a “normal” system EnumDisplayDevices and IDXGIAdapter::GetDesc always concur
490+
// NOTES : On a normal system EnumDisplayDevices and IDXGIAdapter::GetDesc always concur
490491
// i.e. the device that owns the head will be the device that performs the rendering.
491492
// On an Optimus system IDXGIAdapter::GetDesc will return whichever device has been selected for rendering.
492493
// So on an Optimus system it is possible that IDXGIAdapter::GetDesc will return the dGPU whereas
@@ -1642,31 +1643,32 @@ bool spoutGLDXinterop::WriteGLDXtexture(GLuint TextureID, GLuint TextureTarget,
16421643
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
16431644
if(status == GL_FRAMEBUFFER_COMPLETE_EXT) {
16441645

1645-
// Default invert flag is false so do the flip to get it the right way up if the user wants that
1646-
if(bInvert) {
1647-
// Blit method with checks - 0.75 - 0.85 msec
1648-
// copy one texture buffer to the other while flipping upside down (OpenGL and DirectX have different texture origins)
1649-
glBlitFramebufferEXT(0, 0, // srcX0, srcY0,
1650-
width, height, // srcX1, srcY1
1651-
0, height, // dstX0, dstY0,
1652-
width, 0, // dstX1, dstY1,
1653-
GL_COLOR_BUFFER_BIT, GL_NEAREST); // GLbitfield mask, GLenum filter
1654-
}
1655-
else {
1656-
if(m_bBLITavailable) {
1646+
if(m_bBLITavailable) {
1647+
// Default invert flag is false so do the flip to get it the right way up if the user wants that
1648+
if(bInvert) {
1649+
// Blit method with checks - 0.75 - 0.85 msec
1650+
// copy one texture buffer to the other while flipping upside down (OpenGL and DirectX have different texture origins)
1651+
glBlitFramebufferEXT(0, 0, // srcX0, srcY0,
1652+
width, height, // srcX1, srcY1
1653+
0, height, // dstX0, dstY0,
1654+
width, 0, // dstX1, dstY1,
1655+
GL_COLOR_BUFFER_BIT, GL_NEAREST); // GLbitfield mask, GLenum filter
1656+
}
1657+
else {
16571658
// Do not flip during blit
16581659
glBlitFramebufferEXT(0, 0, // srcX0, srcY0,
16591660
width, height, // srcX1, srcY1
16601661
0, 0, // dstX0, dstY0,
16611662
width, height, // dstX1, dstY1,
16621663
GL_COLOR_BUFFER_BIT, GL_NEAREST); // GLbitfield mask, GLenum filter
16631664
}
1664-
else {
1665-
// Copy from the fbo (input texture attached) to the shared texture
1666-
glBindTexture(GL_TEXTURE_2D, m_glTexture);
1667-
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, width, height);
1668-
glBindTexture(GL_TEXTURE_2D, 0);
1669-
}
1665+
}
1666+
else {
1667+
// No fbo blit extension
1668+
// Copy from the fbo (input texture attached) to the shared texture
1669+
glBindTexture(GL_TEXTURE_2D, m_glTexture);
1670+
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, width, height);
1671+
glBindTexture(GL_TEXTURE_2D, 0);
16701672
}
16711673
}
16721674
else {
@@ -1720,30 +1722,31 @@ bool spoutGLDXinterop::ReadGLDXtexture(GLuint TextureID, GLuint TextureTarget, u
17201722

17211723
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
17221724
if(status == GL_FRAMEBUFFER_COMPLETE_EXT) {
1723-
// Flip if the user wants that
1724-
if(bInvert) {
1725-
// copy one texture buffer to the other while flipping upside down
1726-
glBlitFramebufferEXT(0, 0, // srcX0, srcY0,
1727-
width, height, // srcX1, srcY1
1728-
0, height, // dstX0, dstY0,
1729-
width, 0, // dstX1, dstY1,
1730-
GL_COLOR_BUFFER_BIT, GL_LINEAR);
1731-
}
1732-
else {
1733-
if(m_bBLITavailable) {
1725+
if(m_bBLITavailable) {
1726+
// Flip if the user wants that
1727+
if(bInvert) {
1728+
// copy one texture buffer to the other while flipping upside down
1729+
glBlitFramebufferEXT(0, 0, // srcX0, srcY0,
1730+
width, height, // srcX1, srcY1
1731+
0, height, // dstX0, dstY0,
1732+
width, 0, // dstX1, dstY1,
1733+
GL_COLOR_BUFFER_BIT, GL_LINEAR);
1734+
}
1735+
else {
17341736
// Do not flip during blit
17351737
glBlitFramebufferEXT(0, 0, // srcX0, srcY0,
17361738
width, height, // srcX1, srcY1
17371739
0, 0, // dstX0, dstY0,
17381740
width, height, // dstX1, dstY1,
17391741
GL_COLOR_BUFFER_BIT, GL_NEAREST); // GLbitfield mask, GLenum filter
17401742
}
1741-
else {
1742-
// Copy from the fbo (shared texture attached) to the dest texture
1743-
glBindTexture(TextureTarget, TextureID);
1744-
glCopyTexSubImage2D(TextureTarget, 0, 0, 0, 0, 0, width, height);
1745-
glBindTexture(TextureTarget, 0);
1746-
}
1743+
}
1744+
else {
1745+
// No fbo blit extension available
1746+
// Copy from the fbo (shared texture attached) to the dest texture
1747+
glBindTexture(TextureTarget, TextureID);
1748+
glCopyTexSubImage2D(TextureTarget, 0, 0, 0, 0, 0, width, height);
1749+
glBindTexture(TextureTarget, 0);
17471750
}
17481751
}
17491752
else {
@@ -2109,7 +2112,7 @@ void spoutGLDXinterop::FlushWait()
21092112

21102113
// For a receiver, make sure that the GPU is finished processing commands before accessing the
21112114
// staging texture and before the sender fills the shared texture again on the next frame.
2112-
// For a sender, make sure the SopyResource fnction has completed before the receiver application
2115+
// For a sender, make sure the CopyResource fnction has completed before the receiver application
21132116
// accesses the shared texture.
21142117
// https://msdn.microsoft.com/en-us/library/windows/desktop/ff476578%28v=vs.85%29.aspx
21152118
ZeroMemory(&queryDesc, sizeof(queryDesc));
@@ -3969,31 +3972,32 @@ bool spoutGLDXinterop::CopyTexture( GLuint SourceID,
39693972

39703973
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
39713974
if(status == GL_FRAMEBUFFER_COMPLETE_EXT) {
3972-
// Default invert flag is false so do the flip to get it the right way up if the user wants that
3973-
if(bInvert) {
3974-
// Blit method with checks - 0.75 - 0.85 msec
3975-
// copy one texture buffer to the other while flipping upside down
3976-
// (OpenGL and DirectX have different texture origins)
3977-
glBlitFramebufferEXT(0, 0, // srcX0, srcY0,
3978-
width, height, // srcX1, srcY1
3979-
0, height, // dstX0, dstY0,
3980-
width, 0, // dstX1, dstY1,
3981-
GL_COLOR_BUFFER_BIT, GL_NEAREST); // GLbitfield mask, GLenum filter
3982-
}
3983-
else {
3984-
if(m_bBLITavailable) {
3975+
if(m_bBLITavailable) {
3976+
if(bInvert) {
3977+
// Blit method with checks - 0.75 - 0.85 msec
3978+
// copy one texture buffer to the other while flipping upside down
3979+
// (OpenGL and DirectX have different texture origins)
3980+
glBlitFramebufferEXT(0, 0, // srcX0, srcY0,
3981+
width, height, // srcX1, srcY1
3982+
0, height, // dstX0, dstY0,
3983+
width, 0, // dstX1, dstY1,
3984+
GL_COLOR_BUFFER_BIT, GL_NEAREST); // GLbitfield mask, GLenum filter
3985+
}
3986+
else {
39853987
// Do not flip during blit
39863988
glBlitFramebufferEXT(0, 0, // srcX0, srcY0,
39873989
width, height, // srcX1, srcY1
39883990
0, 0, // dstX0, dstY0,
39893991
width, height, // dstX1, dstY1,
39903992
GL_COLOR_BUFFER_BIT, GL_NEAREST); // GLbitfield mask, GLenum filter
39913993
}
3992-
else {
3993-
glBindTexture(DestTarget, DestID);
3994-
glCopyTexSubImage2D(DestTarget, 0, 0, 0, 0, 0, width, height);
3995-
glBindTexture(DestTarget, 0);
3996-
}
3994+
}
3995+
else {
3996+
// No fbo blit extension
3997+
// Copy from the fbo (source texture attached) to the dest texture
3998+
glBindTexture(DestTarget, DestID);
3999+
glCopyTexSubImage2D(DestTarget, 0, 0, 0, 0, 0, width, height);
4000+
glBindTexture(DestTarget, 0);
39974001
}
39984002
}
39994003
else {

SpoutSDK/Source/SpoutGLDXinterop.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class SPOUT_DLLEXP spoutGLDXinterop {
115115
bool SetShareMode(int mode);
116116

117117
bool IsBGRAavailable(); // are the bgra extensions available
118-
bool IsPBOavailable(); // Are pbo extensions supported
118+
bool IsPBOavailable(); // Are pbo extensions supported
119119
void SetBufferMode(bool bActive); // Set the pbo availability on or off
120120
bool GetBufferMode();
121121

SpoutSDK/Source/SpoutGLextensions.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ bool loadPBOextensions()
260260
#endif
261261
}
262262

263+
264+
263265
bool InitializeGlew()
264266
{
265267
#ifdef USE_GLEW
@@ -302,6 +304,8 @@ unsigned int loadGLextensions() {
302304

303305
unsigned int caps = 0; // as per elio glextensions
304306

307+
// printf("loadGLextensions\n");
308+
305309
#ifdef USE_GLEW
306310
InitializeGlew(); // probably needs failure check
307311
#endif

SpoutSDK/Source/SpoutGLextensions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ extern glRenderbufferStorageEXTPROC glRenderbufferStorageEXT;
257257
typedef void (APIENTRY *glBlitFramebufferEXTPROC) (GLint srcX0,GLint srcY0,GLint srcX1,GLint srcY1,GLint dstX0,GLint dstY0,GLint dstX1,GLint dstY1,GLbitfield mask,GLenum filter);
258258
extern glBlitFramebufferEXTPROC glBlitFramebufferEXT;
259259

260+
260261
// ------------------------------
261262
// OpenGL sync control extensions
262263
// ------------------------------

0 commit comments

Comments
 (0)