Skip to content

Commit

Permalink
some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
er2off committed May 3, 2024
1 parent 2998568 commit 3cdab55
Show file tree
Hide file tree
Showing 30 changed files with 206 additions and 147 deletions.
6 changes: 6 additions & 0 deletions appframework/sdlmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,13 +709,15 @@ void CSDLMgr::Shutdown()
{
SDLAPP_FUNC;

#ifdef DX_TO_GL_ABSTRACTION
if (gGL && m_readFBO)
#ifdef TOGLES
gGL->glDeleteFramebuffers(1, &m_readFBO);
#else
gGL->glDeleteFramebuffersEXT(1, &m_readFBO);
#endif
m_readFBO = 0;
#endif

if ( m_Window )
{
Expand Down Expand Up @@ -819,6 +821,10 @@ bool CSDLMgr::CreateHiddenGameWindow( const char *pTitle, int width, int height
int flags = SDL_WINDOW_HIDDEN;
#if defined( DX_TO_GL_ABSTRACTION )
flags |= SDL_WINDOW_OPENGL;
#elif defined(DXVK)
flags |= SDL_WINDOW_VULKAN;
#else
#error "Invalid SDL window backend"
#endif
m_Window = SDL_CreateWindow( pTitle, x, y, width, height, flags );

Expand Down
2 changes: 2 additions & 0 deletions engine/audio/posix_stubs.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ typedef wchar_t BCHAR;

typedef uint MMRESULT;
typedef uint32 *DWORD_PTR;
#ifndef DXVK
typedef char *LPCSTR;
#endif
typedef uint POINTL;

#define IDLE_PRIORITY_CLASS 1
Expand Down
3 changes: 2 additions & 1 deletion engine/masterserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,8 @@ void CMaster::Shutdown(void)
void CMaster::RequestInternetServerList(const char *gamedir, IServerListResponse *response)
{
if( m_bNoMasters ) return;
strncpy( m_szGameDir, gamedir, sizeof(m_szGameDir) );
if( gamedir != m_szGameDir)
strncpy( m_szGameDir, gamedir, sizeof(m_szGameDir) );

if( response )
{
Expand Down
9 changes: 6 additions & 3 deletions engine/sys_getmodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
#endif

#if defined( _WIN32 ) && !defined( _X360 )
#include "winlite.h"
# include "winlite.h"
#elif defined(POSIX)
# ifdef DXVK
# include <windows.h>
# endif
typedef void *HDC;
#endif

Expand Down Expand Up @@ -1117,7 +1120,7 @@ void CVideoMode_Common::DrawNullBackground( void *hHDC, int w, int h )

}

#ifndef _WIN32
#ifdef DX_TO_GL_ABSTRACTION

typedef unsigned char BYTE;
typedef signed long LONG;
Expand Down Expand Up @@ -1172,7 +1175,7 @@ typedef struct _GUID
#endif
typedef GUID UUID;

#endif //WIN32
#endif //DX_TO_GL_ABSTRACTION
//-----------------------------------------------------------------------------
// Purpose: Blits an image to the loading window hdc
//-----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion engine/sys_mainwind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ void *CGame::GetMainWindow( void )

void *CGame::GetMainDeviceWindow( void )
{
#if defined( DX_TO_GL_ABSTRACTION ) && defined( USE_SDL )
#ifdef USE_SDL
return (void*)m_pSDLWindow;
#else
return (void*)m_hWindow;
Expand Down
5 changes: 4 additions & 1 deletion engine/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,10 @@ def build(bld):
libs += ['USER32', 'WINMM', 'WININET', 'DSOUND', 'DXGUID', 'GDI32', 'bzip2']
elif bld.env.DEST_OS == 'darwin' and not bld.env.DEDICATED:
libs += ['APPKIT', 'COREAUDIO', 'AUDIOTOOLBOX', 'SYSTEMCONFIGURATION']


if bld.env.DXVK:
libs += ['dxvk']

install_path = bld.env.LIBDIR

bld.shlib(
Expand Down
4 changes: 2 additions & 2 deletions materialsystem/cmaterialsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,7 @@ void CMaterialSystem::GenerateConfigFromConfigKeyValues( MaterialSystem_Config_t

pConfig->m_Flags = 0;

#ifdef LINUX
#ifdef POSIX

uint width = 0;
uint height = 0;
Expand Down Expand Up @@ -1714,7 +1714,7 @@ void CMaterialSystem::GenerateConfigFromConfigKeyValues( MaterialSystem_Config_t

pKeyValues->deleteThis();

#endif // LINUX
#endif // POSIX

WriteConfigurationInfoToConVars( bOverwriteCommandLineValues );
m_bGeneratedConfig = true;
Expand Down
43 changes: 23 additions & 20 deletions materialsystem/shaderapidx9/shaderapidx8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ static ConVar mat_use_smp( "mat_use_smp", "0" );
static ConVar r_pix_start( "r_pix_start", "0" );
static ConVar r_pix_recordframes( "r_pix_recordframes", "0" );

#ifdef USE_SDL
void posixGetClientRect( void *hWnd, RECT *destRect );
#endif

#define D3DDeviceWrapper IDirect3DDevice9

Expand Down Expand Up @@ -2115,7 +2118,7 @@ void CShaderAPIDx8::ReleaseInternalRenderTargets( )
// Those should be released separately via the texure manager
if ( m_pBackBufferSurface )
{
#if POSIX
#ifdef DX_TO_GL_ABSTRACTION
// dxabstract's AddRef/Release have optional args to help track usage
int nRetVal = m_pBackBufferSurface->Release( 0, "-B CShaderAPIDx8::ReleaseInternalRenderTargets public release color buffer");
#else
Expand All @@ -2127,7 +2130,7 @@ void CShaderAPIDx8::ReleaseInternalRenderTargets( )

if ( m_pZBufferSurface )
{
#if POSIX
#ifdef DX_TO_GL_ABSTRACTION
// dxabstract's AddRef/Release have optional args to help track usage
int nRetVal = m_pZBufferSurface->Release( 0, "-B CShaderAPIDx8::ReleaseInternalRenderTargets public release zbuffer");
#else
Expand Down Expand Up @@ -3698,10 +3701,10 @@ void CShaderAPIDx8::ResetRenderState( bool bFullReset )

// Viewport defaults to the window size
RECT windowRect;
#if !defined( DX_TO_GL_ABSTRACTION )
GetClientRect( (HWND)m_hWnd, &windowRect );
#if defined( DX_TO_GL_ABSTRACTION ) || defined( POSIX )
posixGetClientRect( (VD3DHWND)m_hWnd, &windowRect );
#else
toglGetClientRect( (VD3DHWND)m_hWnd, &windowRect );
GetClientRect( (HWND)m_hWnd, &windowRect );
#endif

ShaderViewport_t viewport;
Expand Down Expand Up @@ -7711,7 +7714,7 @@ IDirect3DSurface* CShaderAPIDx8::GetTextureSurface( ShaderAPITextureHandle_t tex
{
pSurface = tex.GetRenderTargetSurface( false );

#if POSIX
#ifdef DX_TO_GL_ABSTRACTION
// dxabstract's AddRef/Release have optional args to help track usage
pSurface->AddRef( 0, "CShaderAPIDx8::GetTextureSurface public addref");
#else
Expand Down Expand Up @@ -7831,7 +7834,7 @@ void CShaderAPIDx8::SetRenderTargetEx( int nRenderTargetID, ShaderAPITextureHand
{
// This is just to make the code a little simpler...
// (simplifies the release logic)
#if POSIX
#ifdef DX_TO_GL_ABSTRACTION
// dxabstract's AddRef/Release have optional args to help track usage
pColorSurface->AddRef( 0, "+C CShaderAPIDx8::SetRenderTargetEx public addref 1");
#else
Expand Down Expand Up @@ -7862,7 +7865,7 @@ void CShaderAPIDx8::SetRenderTargetEx( int nRenderTargetID, ShaderAPITextureHand
#endif
{
// simplify the prologue logic
#if POSIX
#ifdef DX_TO_GL_ABSTRACTION
// dxabstract's AddRef/Release have optional args to help track usage
pZSurface->AddRef( 0, "+D CShaderAPIDx8::SetRenderTargetEx public addref 1");
#else
Expand Down Expand Up @@ -7890,7 +7893,7 @@ void CShaderAPIDx8::SetRenderTargetEx( int nRenderTargetID, ShaderAPITextureHand
pZSurface = GetDepthTextureSurface( depthTextureHandle );
if ( pZSurface )
{
#if POSIX
#ifdef DX_TO_GL_ABSTRACTION
// dxabstract's AddRef/Release have optional args to help track usage
pZSurface->AddRef( 0, "+D CShaderAPIDx8::SetRenderTargetEx public addref 2");
#else
Expand All @@ -7906,7 +7909,7 @@ void CShaderAPIDx8::SetRenderTargetEx( int nRenderTargetID, ShaderAPITextureHand
if ( !pZSurface )
{
// Refcount of color surface was increased above
#if POSIX
#ifdef DX_TO_GL_ABSTRACTION
// dxabstract's AddRef/Release have optional args to help track usage
pColorSurface->Release( 0, "-C CShaderAPIDx8::SetRenderTargetEx public release 1" );
#else
Expand Down Expand Up @@ -7992,7 +7995,7 @@ void CShaderAPIDx8::SetRenderTargetEx( int nRenderTargetID, ShaderAPITextureHand
int ref;
if ( pZSurface )
{
#if POSIX
#ifdef DX_TO_GL_ABSTRACTION
ref = pZSurface->Release( 0, "-D CShaderAPIDx8::SetRenderTargetEx public release (z surface)");
#else
ref = pZSurface->Release();
Expand All @@ -8008,7 +8011,7 @@ void CShaderAPIDx8::SetRenderTargetEx( int nRenderTargetID, ShaderAPITextureHand
if( pColorSurface )
#endif
{
#if POSIX
#ifdef DX_TO_GL_ABSTRACTION
ref = pColorSurface->Release( 0, "-C CShaderAPIDx8::SetRenderTargetEx public release (color surface)");
#else
ref = pColorSurface->Release();
Expand Down Expand Up @@ -10409,7 +10412,7 @@ void CShaderAPIDx8::Ortho( double left, double top, double right, double bottom,
// introduces a -1 scale in the y coordinates
// D3DXMatrixOrthoOffCenterLH( &matrix, left, right, bottom, top, zNear, zFar );

D3DXMatrixOrthoOffCenterRH( &matrix, left, right, top, bottom, zNear, zFar );
//D3DXMatrixOrthoOffCenterRH( &matrix, left, right, top, bottom, zNear, zFar );
m_pMatrixStack[m_CurrStack]->MultMatrixLocal(&matrix);
Assert( m_CurrStack == MATERIAL_PROJECTION );
UpdateMatrixTransform();
Expand All @@ -10424,7 +10427,7 @@ void CShaderAPIDx8::PerspectiveX( double fovx, double aspect, double zNear, doub
float height = width / aspect;
Assert( m_CurrStack == MATERIAL_PROJECTION );
D3DXMATRIX rh;
D3DXMatrixPerspectiveRH( &rh, width, height, zNear, zFar );
//D3DXMatrixPerspectiveRH( &rh, width, height, zNear, zFar );
m_pMatrixStack[m_CurrStack]->MultMatrixLocal(&rh);
UpdateMatrixTransform();
}
Expand All @@ -10445,7 +10448,7 @@ void CShaderAPIDx8::PerspectiveOffCenterX( double fovx, double aspect, double zN

Assert( m_CurrStack == MATERIAL_PROJECTION );
D3DXMATRIX rh;
D3DXMatrixPerspectiveOffCenterRH( &rh, flFrontPlaneLeft, flFrontPlaneRight, flFrontPlaneBottom, flFrontPlaneTop, zNear, zFar );
//D3DXMatrixPerspectiveOffCenterRH( &rh, flFrontPlaneLeft, flFrontPlaneRight, flFrontPlaneBottom, flFrontPlaneTop, zNear, zFar );
m_pMatrixStack[m_CurrStack]->MultMatrixLocal(&rh);
UpdateMatrixTransform();
}
Expand Down Expand Up @@ -11512,10 +11515,10 @@ void CShaderAPIDx8::SetViewports( int nCount, const ShaderViewport_t* pViewports
if ( IsPC() && m_IsResizing )
{
RECT viewRect;
#if !defined( DX_TO_GL_ABSTRACTION )
GetClientRect( ( HWND )m_ViewHWnd, &viewRect );
#if defined( DX_TO_GL_ABSTRACTION ) || defined( POSIX )
posixGetClientRect( (VD3DHWND)m_ViewHWnd, &viewRect );
#else
toglGetClientRect( (VD3DHWND)m_ViewHWnd, &viewRect );
GetClientRect( ( HWND )m_ViewHWnd, &viewRect );
#endif
m_nWindowWidth = viewRect.right - viewRect.left;
m_nWindowHeight = viewRect.bottom - viewRect.top;
Expand Down Expand Up @@ -12047,7 +12050,7 @@ IDirect3DSurface* CShaderAPIDx8::GetBackBufferImageHDR( Rect_t *pSrcRect, Rect_t
NULL );
}
pTmpSurface = m_pSmallBackBufferFP16TempSurface;
#if POSIX
#ifdef DX_TO_GL_ABSTRACTION
pTmpSurface->AddRef( 0, "CShaderAPIDx8::GetBackBufferImageHDR public addref");
#else
pTmpSurface->AddRef();
Expand Down Expand Up @@ -12151,7 +12154,7 @@ IDirect3DSurface* CShaderAPIDx8::GetBackBufferImage( Rect_t *pSrcRect, Rect_t *p
// Don't bother to blit through the full-screen texture if we don't
// have to stretch, we're not coming from the backbuffer, and we don't have to do AA resolve
pTmpSurface = pRenderTarget;
#if POSIX
#ifdef DX_TO_GL_ABSTRACTION
pTmpSurface->AddRef( 0, "CShaderAPIDx8::GetBackBufferImage public addref");
#else
pTmpSurface->AddRef();
Expand Down
44 changes: 31 additions & 13 deletions materialsystem/shaderapidx9/shaderdevicebase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,28 @@ CShaderDeviceMgrBase *g_pShaderDeviceMgr;
CShaderAPIBase *g_pShaderAPI;
IShaderShadow *g_pShaderShadow;

#ifdef USE_SDL
#include "appframework/ilaunchermgr.h"
ILauncherMgr *g_pLauncherMgr = NULL; // set in CMaterialSystem::Connect

void posixGetClientRect( void *hWnd, RECT *destRect )
{
// the only useful answer this call can offer, is the size of the canvas.
// actually getting the window bounds is not useful.
// so, see if a D3D device is up and running, and if so,
// dig in and find out its backbuffer size and use that.

uint width, height;
g_pLauncherMgr->RenderedSize( width, height, false ); // false = get them, don't set them
Assert( width!=0 && height!=0 );

destRect->left = 0;
destRect->top = 0;
destRect->right = width;
destRect->bottom = height;
}
#endif

bool g_bUseShaderMutex = false; // Shader mutex globals
bool g_bShaderAccessDisallowed;
CShaderMutex g_ShaderMutex;
Expand Down Expand Up @@ -149,6 +171,10 @@ bool CShaderDeviceMgrBase::Connect( CreateInterfaceFn factory )
g_pShaderUtil = (IShaderUtil*)ShaderDeviceFactory( SHADER_UTIL_INTERFACE_VERSION, NULL );
g_pShaderDeviceMgr = this;

#ifdef USE_SDL
g_pLauncherMgr = (ILauncherMgr*)factory( SDLMGR_INTERFACE_VERSION, NULL );
#endif

s_TempFactory = NULL;

if ( !g_pShaderUtil || !g_pFullFileSystem || !g_pShaderDeviceMgr )
Expand Down Expand Up @@ -962,7 +988,7 @@ bool CShaderDeviceBase::IsAAEnabled() const
//-----------------------------------------------------------------------------
#define MATERIAL_SYSTEM_WINDOW_ID 0xFEEDDEAD

#ifdef USE_ACTUAL_DX
#if defined(_WIN32) && defined(USE_ACTUAL_DX)
static VD3DHWND GetTopmostParentWindow( VD3DHWND hWnd )
{
// Find the parent window...
Expand Down Expand Up @@ -1005,19 +1031,11 @@ static BOOL CALLBACK EnumWindowsProcNotThis( VD3DHWND hWnd, LPARAM lParam )
EnumChildWindows( hWnd, EnumChildWindowsProc, lParam );
return TRUE;
}
#endif

//-----------------------------------------------------------------------------
// Adds a hook to let us know when other instances are setting the mode
//-----------------------------------------------------------------------------

#ifdef STRICT
#define WINDOW_PROC WNDPROC
#else
#define WINDOW_PROC FARPROC
#endif

#ifdef USE_ACTUAL_DX
static LRESULT CALLBACK ShaderDX8WndProc(VD3DHWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
#if !defined( _X360 )
Expand Down Expand Up @@ -1065,7 +1083,7 @@ static LRESULT CALLBACK ShaderDX8WndProc(VD3DHWND hWnd, UINT msg, WPARAM wParam,
void CShaderDeviceBase::InstallWindowHook( void* hWnd )
{
Assert( m_hWndCookie == NULL );
#ifdef USE_ACTUAL_DX
#if defined(_WIN32) && defined(USE_ACTUAL_DX)
#if !defined( _X360 )
VD3DHWND hParent = GetTopmostParentWindow( (VD3DHWND)hWnd );

Expand Down Expand Up @@ -1096,7 +1114,7 @@ void CShaderDeviceBase::InstallWindowHook( void* hWnd )

void CShaderDeviceBase::RemoveWindowHook( void* hWnd )
{
#ifdef USE_ACTUAL_DX
#if defined(_WIN32) && defined(USE_ACTUAL_DX)
#if !defined( _X360 )
if ( m_hWndCookie )
{
Expand All @@ -1117,7 +1135,7 @@ void CShaderDeviceBase::RemoveWindowHook( void* hWnd )
//-----------------------------------------------------------------------------
void CShaderDeviceBase::SendIPCMessage( IPCMessage_t msg )
{
#ifdef USE_ACTUAL_DX
#if defined(_WIN32) && defined(USE_ACTUAL_DX)
#if !defined( _X360 )
// Gotta send this to all windows, since we don't know which ones
// are material system apps...
Expand Down Expand Up @@ -1240,7 +1258,7 @@ void CShaderDeviceBase::GetWindowSize( int& nWidth, int& nHeight ) const
#ifdef _WIN32
GetClientRect( ( HWND )m_ViewHWnd, &rect );
#else
toglGetClientRect( (VD3DHWND)m_ViewHWnd, &rect );
posixGetClientRect( (VD3DHWND)m_ViewHWnd, &rect );
#endif
nWidth = rect.right - rect.left;
nHeight = rect.bottom - rect.top;
Expand Down
Loading

0 comments on commit 3cdab55

Please sign in to comment.