Skip to content

Commit

Permalink
Version 2.031
Browse files Browse the repository at this point in the history
01.12.23
Rebuild x86/x64 with Spout version 2.007.013 files
  • Loading branch information
leadedge committed Dec 1, 2023
1 parent c2822d2 commit dc6eec6
Show file tree
Hide file tree
Showing 18 changed files with 369 additions and 133 deletions.
15 changes: 14 additions & 1 deletion SpoutDX/source/SpoutCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Thanks and credit to Malcolm Bechard, the author of this file
https://github.com/mbechard
Copyright (c) 2014-2023, Lynn Jarvis. All rights reserved.
Copyright (c) 2014-2024, Lynn Jarvis. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -82,5 +82,18 @@
#pragma warning(disable:26812) // unscoped enums
#endif

//
// For ARM build
// __movsd intrinsic not defined
//
#if defined _M_ARM64
#include <memory.h>
inline void __movsd(unsigned long* Destination,
const unsigned long* Source, size_t Count)
{
memcpy(Destination, Source, Count);
}
#endif


#endif
25 changes: 16 additions & 9 deletions SpoutDX/source/SpoutCopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Copyright (c) 2016-2023, Lynn Jarvis. All rights reserved.
Copyright (c) 2016-2024, Lynn Jarvis. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -69,6 +69,8 @@
Remove rgba_to_bgr_sse3
Add experimental rgb_to_bgra_sse3
Version 2.007.012
07.10.23 - Conditional compile options for _M_ARM64 in CheckSSE and header
20.10.23 - FlipBuffer / CopyPixels - default pitch width*4
*/

Expand Down Expand Up @@ -101,10 +103,9 @@ void spoutCopy::CopyPixels(const unsigned char *source, unsigned char *dest,
unsigned int width, unsigned int height,
GLenum glFormat, bool bInvert) const
{
unsigned int Size = width*height; // GL_LUMINANCE default

if (glFormat == GL_RGBA || glFormat == GL_BGRA_EXT)
Size = width * height * 4;
unsigned int Size = width*height*4; // RGBA default
if (glFormat == GL_LUMINANCE)
Size = width*height;
else if (glFormat == GL_RGB || glFormat == GL_BGR_EXT)
Size = width*height * 3;

Expand Down Expand Up @@ -141,11 +142,11 @@ void spoutCopy::FlipBuffer(const unsigned char *src,
unsigned int height,
GLenum glFormat) const
{
unsigned int pitch = width; // GL_LUMINANCE default
if (glFormat == GL_RGBA || glFormat == GL_BGRA_EXT)
pitch = width * 4; // RGBA format specified
unsigned int pitch = width*4; // RGBA default
if (glFormat == GL_LUMINANCE)
pitch = width; // Luminance data
else if (glFormat == GL_RGB || glFormat == GL_BGR_EXT)
pitch = width * 3; // RGB format specified
pitch = width * 3; // RGB format specified (RGB float not supported)

unsigned int line_s = 0;
unsigned int line_t = (height - 1)*pitch;
Expand Down Expand Up @@ -1459,6 +1460,11 @@ void spoutCopy::bgra2bgr(const void *bgra_source, void *bgr_dest, unsigned int w
//
void spoutCopy::CheckSSE()
{
#ifdef _M_ARM64 // All SSE will be routed to NEON
m_bSSE2 = true;
m_bSSE3 = true;
m_bSSSE3 = true;
#else
// An array of four integers that contains the information returned
// in EAX (0), EBX (1), ECX (2), and EDX (3) about supported features of the CPU.
int CPUInfo[4] ={-1, -1, -1, -1};
Expand All @@ -1480,6 +1486,7 @@ void spoutCopy::CheckSSE()
// SSSE3 = (cpuid02 & (0x1 << 9)
m_bSSSE3 = ((CPUInfo[2] & (0x1 << 9)) || false);
}
#endif

}

Expand Down
6 changes: 5 additions & 1 deletion SpoutDX/source/SpoutCopy.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Copyright (c) 2016-2023, Lynn Jarvis. All rights reserved.
Copyright (c) 2016-2024, Lynn Jarvis. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -38,8 +38,12 @@
#include <stdio.h> // for debug printf
#include <gl/gl.h> // For OpenGL definitions
#include <intrin.h> // for cpuid to test for SSE2
#ifdef _M_ARM64
#include <sse2neon.h> // for NEON
#else
#include <emmintrin.h> // for SSE2
#include <tmmintrin.h> // for SSSE3
#endif
#include <cmath> // For compatibility with Clang. PR#81
#include <stdint.h> // for _uint32 etc

Expand Down
55 changes: 29 additions & 26 deletions SpoutDX/source/SpoutDirectX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,12 @@
// ReleaseDX11Device - release ID3D11Device1 and ID3D11DeviceContext1 if created
// Version 2.007.012
// 07.08.23 - Comment out code for debug layers
// 19.10.23 - GetNumAdapters - remove unused adapter description and output list
//
// ====================================================================================
/*
Copyright (c) 2014-2023. Lynn Jarvis. All rights reserved.
Copyright (c) 2014-2024. Lynn Jarvis. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -555,7 +556,7 @@ bool spoutDirectX::CreateSharedDX11Texture(ID3D11Device* pd3dDevice,
}

SpoutLogNotice("spoutDirectX::CreateSharedDX11Texture");
SpoutLogNotice(" pDevice = 0x%.7X, width = %d, height = %d, format = %d", PtrToUint(pd3dDevice), width, height, format);
SpoutLogNotice(" pDevice = 0x%.7X, width = %d, height = %d, format = 0x%X (%d)", PtrToUint(pd3dDevice), width, height, format, format);

// Use the format passed in
// If that is zero or DX9 format, use the default format
Expand Down Expand Up @@ -606,7 +607,6 @@ bool spoutDirectX::CreateSharedDX11Texture(ID3D11Device* pd3dDevice,
desc.MipLevels = 1;
desc.ArraySize = 1;


const HRESULT res = pd3dDevice->CreateTexture2D(&desc, NULL, ppSharedTexture);
if (FAILED(res)) {
const long long lres = static_cast<long long>((LOWORD(res)));
Expand Down Expand Up @@ -671,7 +671,8 @@ bool spoutDirectX::CreateSharedDX11Texture(ID3D11Device* pd3dDevice,
pOtherResource = nullptr;
pTexture = nullptr;

SpoutLogNotice(" pTexture = [0x%8.8X] : dxShareHandle = [0x%8.8X]", PtrToUint(*ppSharedTexture), LOWORD(dxShareHandle) );
SpoutLogNotice(" pTexture [0x%8.8X] (%dx%d format 0x%X) : dxShareHandle = [0x%8.8X]",
PtrToUint(*ppSharedTexture), width, height, texformat, LOWORD(dxShareHandle) );

return true;

Expand Down Expand Up @@ -1077,6 +1078,9 @@ int spoutDirectX::GetNumAdapters()

for (i = 0; _dxgi_factory1->EnumAdapters( i, &adapter1_ptr ) != DXGI_ERROR_NOT_FOUND; i++ ) {
if (!adapter1_ptr) break;
/*
// Adapter description
// Currently not used
DXGI_ADAPTER_DESC desc;
adapter1_ptr->GetDesc( &desc );
// printf(" Adapter(%d) : %S\n", i, desc.Description );
Expand All @@ -1089,31 +1093,30 @@ int spoutDirectX::GetNumAdapters()
// Look for outputs
IDXGIOutput* p_output = nullptr;
// Is there a first output on this adapter ?
if (adapter1_ptr->EnumOutputs(0, &p_output) == DXGI_ERROR_NOT_FOUND) {
if (!p_output) break;
if (p_output == 0) {
// Warning ?
// SpoutLogWarning("spoutDirectX::GetNumAdapters - No outputs for Adapter %d : %S", i, desc.Description);
}
else {
// Here we can list all the outputs of the adapter
DXGI_OUTPUT_DESC desc_out={};
for (UINT32 j = 0; adapter1_ptr->EnumOutputs(j, &p_output) != DXGI_ERROR_NOT_FOUND; j++) {
p_output->GetDesc(&desc_out);
// printf(" Output : %d\n", j );
// printf(" Name %S\n", desc_out.DeviceName );
// HMONITOR hMon = desc_out.Monitor;
// printf(" Attached to desktop : (%d) %s\n", desc_out.AttachedToDesktop, desc_out.AttachedToDesktop ? "yes" : "no" );
// printf(" Rotation : %d\n", desc_out.Rotation );
// printf(" Left : %d\n", desc_out.DesktopCoordinates.left );
// printf(" Top : %d\n", desc_out.DesktopCoordinates.top );
// printf(" Right : %d\n", desc_out.DesktopCoordinates.right );
// printf(" Bottom : %d\n", desc_out.DesktopCoordinates.bottom );
p_output->Release();
}
if (adapter1_ptr->EnumOutputs(0, &p_output) != DXGI_ERROR_NOT_FOUND) {
p_output->Release();
// Here we can list all the outputs of the adapter
DXGI_OUTPUT_DESC desc_out={};
for (UINT32 j = 0; adapter1_ptr->EnumOutputs(j, &p_output) != DXGI_ERROR_NOT_FOUND; j++) {
p_output->GetDesc(&desc_out);
// printf(" Output : %d\n", j );
// printf(" Name %S\n", desc_out.DeviceName );
// HMONITOR hMon = desc_out.Monitor;
// printf(" Attached to desktop : (%d) %s\n", desc_out.AttachedToDesktop, desc_out.AttachedToDesktop ? "yes" : "no" );
// printf(" Rotation : %d\n", desc_out.Rotation );
// printf(" Left : %d\n", desc_out.DesktopCoordinates.left );
// printf(" Top : %d\n", desc_out.DesktopCoordinates.top );
// printf(" Right : %d\n", desc_out.DesktopCoordinates.right );
// printf(" Bottom : %d\n", desc_out.DesktopCoordinates.bottom );
p_output->Release();
}
}
else {
SpoutLogWarning("spoutDirectX::GetNumAdapters - No outputs for Adapter %d : %S", i, desc.Description);
}
*/
adapter1_ptr->Release();
}

Expand Down
2 changes: 1 addition & 1 deletion SpoutDX/source/SpoutDirectX.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Functions to manage DirectX 11 texture sharing
Copyright (c) 2014 - 2023, Lynn Jarvis. All rights reserved.
Copyright (c) 2014 - 2024, Lynn Jarvis. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Expand Down
2 changes: 1 addition & 1 deletion SpoutDX/source/SpoutFrameCount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
// ====================================================================================
//
/*
Copyright (c) 2019-2023. Lynn Jarvis. All rights reserved.
Copyright (c) 2019-2024. Lynn Jarvis. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Expand Down
2 changes: 1 addition & 1 deletion SpoutDX/source/SpoutFrameCount.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Frame counting management
Copyright (c) 2019-2023. Lynn Jarvis. All rights reserved.
Copyright (c) 2019-2024. Lynn Jarvis. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Expand Down
45 changes: 31 additions & 14 deletions SpoutDX/source/SpoutSenderNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@
Version 2.007.11
13.07.23 - setActiveSenderName - close any existing active sender map
Version 2.007.012
07.10.23 - Conditional compile options for _M_ARM64
Moved additonal includes from cpp to header
28.10.23 - SetSenderInfo - use QueryFullProcessImageNameA
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Copyright (c) 2014-2023, Lynn Jarvis. All rights reserved.
Copyright (c) 2014-2024, Lynn Jarvis. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -530,7 +533,7 @@ bool spoutSenderNames::GetSenderInfo(const char* sendername, unsigned int &width
if(getSharedInfo(sendername, &info)) {
width = (unsigned int)info.width;
height = (unsigned int)info.height;
#ifdef _M_X64
#if defined _M_X64 || defined _M_ARM64
dxShareHandle = (HANDLE)(LongToHandle((long)info.shareHandle));
#else
dxShareHandle = (HANDLE)info.shareHandle;
Expand Down Expand Up @@ -577,21 +580,35 @@ bool spoutSenderNames::SetSenderInfo(const char* sendername, unsigned int width,
#endif
info.format = (uint32_t)dwFormat;

//
// Initialize unused variables
//

// Texture usage
// Texture usage - unused
info.usage = 0;

// Description : Host path
char exepath[256]={};
GetModuleFileNameA(NULL, &exepath[0], sizeof(exepath));

// Partner ID : Sender CPU sharing mode
// Set by SetSenderID
// TODO : combine here

// Description : Host path
// Description field is 256 uint8_t, initialize with zeros
char exepath[256]={0};

// Get the full path of the current process
// GetModuleFileNameA(NULL, &exepath[0], sizeof(exepath));

// GetModuleFileNameA could fail for Windows on Arm systems
// Use QueryFullProcessImageNameA instead
DWORD dwProcId = GetCurrentProcessId();
HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, dwProcId);
if (hProc) {
DWORD bufferSize = 256;
if (!QueryFullProcessImageNameA(hProc, 0, exepath, &bufferSize)) {
SpoutLogWarning("spoutSenderNames::SetSenderInfo - QueryFullProcessImageName failed");
}
CloseHandle(hProc);
}
else {
SpoutLogWarning("spoutSenderNames::SetSenderInfo - could not get process handle");
}

// Description is defined as wide chars, but the path is stored as byte chars
memcpy(&info.description[0], &exepath[0], 256); // wchar 128

Expand Down Expand Up @@ -759,7 +776,7 @@ bool spoutSenderNames::FindActiveSender(char * sendername, unsigned int& theWidt
strcpy_s(sendername, maxlength, &sname[0]); // pass back sender name
theWidth = (unsigned int)TextureInfo.width;
theHeight = (unsigned int)TextureInfo.height;
#ifdef _M_X64
#if defined _M_X64 || defined _M_ARM64
hSharehandle = (HANDLE)(LongToHandle((long)TextureInfo.shareHandle));
#else
hSharehandle = (HANDLE)TextureInfo.shareHandle;
Expand Down Expand Up @@ -868,7 +885,7 @@ bool spoutSenderNames::CheckSender(const char *sendername, unsigned int &theWidt
// Return the texture info
theWidth = (unsigned int)info.width;
theHeight = (unsigned int)info.height;
#ifdef _M_X64
#if defined _M_X64 || defined _M_ARM64
hSharehandle = (HANDLE)(LongToHandle((long)info.shareHandle));
#else
hSharehandle = (HANDLE)info.shareHandle;
Expand Down Expand Up @@ -923,7 +940,7 @@ bool spoutSenderNames::FindSender(char *sendername, unsigned int &width, unsigne
if (getSharedInfo(sendername, &info)) {
width = (unsigned int)info.width; // pass back sender size
height = (unsigned int)info.height;
#ifdef _M_X64
#if defined _M_X64 || defined _M_ARM64
hSharehandle = (HANDLE)(LongToHandle((long)info.shareHandle));
#else
hSharehandle = (HANDLE)info.shareHandle;
Expand Down
6 changes: 5 additions & 1 deletion SpoutDX/source/SpoutSenderNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
https://github.com/mbechard
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Copyright (c) 2014-2023, Lynn Jarvis. All rights reserved.
Copyright (c) 2014-2024, Lynn Jarvis. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -47,6 +47,10 @@
#include <unordered_map>
#include <intrin.h> // for __movsd
#include <stdint.h> // for _uint32
#include <assert.h>
#ifdef _M_ARM64
#include <sse2neon.h> // For ARM
#endif

#include "SpoutCommon.h"
#include "SpoutSharedMemory.h"
Expand Down
4 changes: 1 addition & 3 deletions SpoutDX/source/SpoutSharedMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Copyright (c) 2014-2023, Lynn Jarvis. All rights reserved.
Copyright (c) 2014-2024, Lynn Jarvis. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -47,9 +47,7 @@
// 28.10.22 - Code documentation
// 18.12.22 - Catch any exception from using Close in destructor
// 07.01.23 - Change m_pName from const char* to char* for strdup
// Version 2.007.11
// 12.05.23 - Create and Open - Clear ERROR_ALREADY_EXISTS to avoid detection elsewhere.
// Version 2.007.012
// ====================================================================================


Expand Down
2 changes: 1 addition & 1 deletion SpoutDX/source/SpoutSharedMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
https://github.com/mbechard
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Copyright (c) 2014-2023, Lynn Jarvis. All rights reserved.
Copyright (c) 2014-2024, Lynn Jarvis. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Expand Down
Loading

0 comments on commit dc6eec6

Please sign in to comment.