Skip to content

Commit

Permalink
Vers 2.030
Browse files Browse the repository at this point in the history
25.07.23   Elevate privilges of SpoutCamSettings to require Administrator privileges
05.08.23   Revise comment to make ReceiveImage rgb flag more clear
Revise SpoutDX ReceiveImage/ReadPixelData to handle RGBA textures
06.09.23   Rebuild x86/x64 with Spout version 2.007.012 files
VS2022 /MT Version 2.030
  • Loading branch information
leadedge committed Sep 6, 2023
1 parent e0d47fc commit c2822d2
Show file tree
Hide file tree
Showing 16 changed files with 401 additions and 128 deletions.
52 changes: 50 additions & 2 deletions SpoutDX/source/SpoutDX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@
// All object releases - flush context to avoid deferred destruction
// 08.07.23 - Remove global keyed texture option and SetKeyed/GetKeyed.
// Retain option in SpoutDirectX CreateSharedDX11Texture.
// 04.08.23 - Correct unused m_bKeyed argument for CreateSharedDX11Texture
// 28.08.23 - Add ReadTexurePixels utility function
//
// ====================================================================================
/*
Expand Down Expand Up @@ -886,6 +888,7 @@ bool spoutDX::ReceiveImage(unsigned char * pixels,
return true;
}


// The receiving pixel buffer is created after the first update
// So check here instead of at the beginning
if (!pixels)
Expand All @@ -895,6 +898,7 @@ bool spoutDX::ReceiveImage(unsigned char * pixels,
if (!m_pStaging[0] || !m_pStaging[1])
return false;


//
// Found a sender
//
Expand Down Expand Up @@ -929,6 +933,45 @@ bool spoutDX::ReceiveImage(unsigned char * pixels,

}

//---------------------------------------------------------
// Function: ReadTexurePixels
// Read pixels from texture
bool spoutDX::ReadTexurePixels(ID3D11Texture2D* pTexture, unsigned char* pixels)
{
if (!pTexture || !pixels)
return false;

// Get texture size
D3D11_TEXTURE2D_DESC desc={};
pTexture->GetDesc(&desc);
unsigned int width = desc.Width;
unsigned int height = desc.Height;

// Set global width and height for ReadPixelData
if (!m_pStaging[0]) {
m_Width = width;
m_Height = height;
}

// Update staging textures if necessary
CheckStagingTextures(width, height, m_dwFormat);
if (!m_pStaging[0] || !m_pStaging[1])
return false;

m_Index = (m_Index + 1) % 2;
m_NextIndex = (m_Index + 1) % 2;

// Copy from the texture to the first staging texture
m_pImmediateContext->CopyResource(m_pStaging[m_Index], pTexture);

// Map and read from the second while the first is occupied
ReadPixelData(m_pStaging[m_NextIndex], pixels, width, height, false, false, false);

return true;

}


//---------------------------------------------------------
// Function: SelectSender
// Open sender selection dialog
Expand Down Expand Up @@ -1919,6 +1962,7 @@ void spoutDX::DisableSpoutLog()
}



//
// PRIVATE
//
Expand Down Expand Up @@ -2285,10 +2329,12 @@ bool spoutDX::ReadPixelData(ID3D11Texture2D* pStagingSource, unsigned char* dest
else {
// Copy rgba to bgra line by line allowing for source pitch using the fastest method
// Uses SSE3 copy function if line data is 16bit aligned (see SpoutCopy.cpp)
if(bSwap)
if (bSwap) {
spoutcopy.rgba2bgra(mappedSubResource.pData, destpixels, width, height, mappedSubResource.RowPitch, bInvert);
else
}
else {
spoutcopy.rgba2rgba(mappedSubResource.pData, destpixels, width, height, mappedSubResource.RowPitch, bInvert);
}
}
}
else if (m_dwFormat == 28) { // DXGI_FORMAT_R8G8B8A8_UNORM
Expand All @@ -2314,8 +2360,10 @@ bool spoutDX::ReadPixelData(ID3D11Texture2D* pStagingSource, unsigned char* dest
spoutcopy.rgba2rgbResample(mappedSubResource.pData, destpixels, m_Width, m_Height, mappedSubResource.RowPitch, width, height, bInvert, m_bMirror, m_bSwapRB);
}
else {
// Approx 5 msec at 1920x1080
spoutcopy.rgba2rgb(mappedSubResource.pData, destpixels, m_Width, m_Height, mappedSubResource.RowPitch, bInvert, m_bMirror, m_bSwapRB);
}

}

m_pImmediateContext->Unmap(pStagingSource, 0);
Expand Down
4 changes: 4 additions & 0 deletions SpoutDX/source/SpoutDX.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ class SPOUT_DLLEXP spoutDX {
bool ReceiveTexture(ID3D11Texture2D** ppTexture);
// Receive an image
bool ReceiveImage(unsigned char * pixels, unsigned int width, unsigned int height, bool bRGB = false, bool bInvert = false);
// Read pixels from texture
bool ReadTexurePixels(ID3D11Texture2D* ppTexture, unsigned char* pixels);


// Open sender selection dialog
void SelectSender();
// Sender has changed
Expand Down
14 changes: 9 additions & 5 deletions SpoutDX/source/SpoutDirectX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
// Create ID3D11Device1 and ID3D11DeviceContext1 for D3D_FEATURE_LEVEL_11_1
// ReleaseDX11Device - release ID3D11Device1 and ID3D11DeviceContext1 if created
// Version 2.007.012
// 07.08.23 - Comment out code for debug layers
//
// ====================================================================================
/*
Expand Down Expand Up @@ -402,10 +403,9 @@ ID3D11Device* spoutDirectX::CreateDX11device()
// See also : void spoutDirectX::DebugLog
//

#if defined(_DEBUG)
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

// #if defined(_DEBUG)
// createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
// #endif

// GL/DX interop Spec
// ID3D11Device can only be used on WDDM operating systems : Must be multithreaded
Expand Down Expand Up @@ -858,7 +858,9 @@ bool spoutDirectX::OpenDX11shareHandle(ID3D11Device* pDevice, ID3D11Texture2D**
// ID3D11Texture2D * texturePointer = *ppSharedTexture;
// D3D11_TEXTURE2D_DESC td ={};
// texturePointer->GetDesc(&td);
// printf("td.Format = %d\n", td.Format); // 87
// printf("td.Format = %d\n", td.Format);
// 87 - DXGI_FORMAT_B8G8R8A8_UNORM
// 28 - DXGI_FORMAT_R8G8B8A8_UNORM
// printf("td.Width = %d\n", td.Width);
// printf("td.Height = %d\n", td.Height);
// printf("td.MipLevels = %d\n", td.MipLevels);
Expand Down Expand Up @@ -1850,6 +1852,7 @@ void spoutDirectX::DebugLog(ID3D11Device* pd3dDevice, const char* format, ...)
#pragma warning(default:26485)


/*
// REMOVE THIS COMMENT LINE TO ENABLE SDK LAYERS
#ifdef _DEBUG
Expand Down Expand Up @@ -1886,6 +1889,7 @@ void spoutDirectX::DebugLog(ID3D11Device* pd3dDevice, const char* format, ...)
#endif
*/
// REMOVE THIS COMMENT LINE TO ENABLE SDK LAYERS


Expand Down
Loading

0 comments on commit c2822d2

Please sign in to comment.