Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Commit

Permalink
Updated DXUT and Effects11 for May 2022 release
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn committed May 24, 2022
1 parent f2623ef commit e73c129
Show file tree
Hide file tree
Showing 38 changed files with 299 additions and 326 deletions.
12 changes: 7 additions & 5 deletions DXUT/Core/DDSTextureLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------

#include "dxut.h"
#include "DXUT.h"
#include "DDSTextureLoader.h"

#include <algorithm>
Expand Down Expand Up @@ -125,16 +125,18 @@ namespace

inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; }

#if defined(_DEBUG) || defined(PROFILE)
template<UINT TNameLength>
inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_ const char (&name)[TNameLength]) noexcept
{
#if defined(_DEBUG) || defined(PROFILE)
resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name);
}
#else
UNREFERENCED_PARAMETER(resource);
UNREFERENCED_PARAMETER(name);
#endif
template<UINT TNameLength>
inline void SetDebugObjectName(_In_ ID3D11DeviceChild*, _In_ const char(&)[TNameLength]) noexcept
{
}
#endif

//--------------------------------------------------------------------------------------
HRESULT LoadTextureDataFromMemory(
Expand Down
27 changes: 20 additions & 7 deletions DXUT/Core/DXUT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,23 @@ bool g_bThreadSafe = true;
class DXUTLock
{
public:

#ifdef _PREFAST_
#pragma prefast(push)
#pragma prefast( suppress:26166, "g_bThreadSafe controls behavior" )
#endif

inline _Acquires_lock_(g_cs) DXUTLock() noexcept { if( g_bThreadSafe ) EnterCriticalSection( &g_cs ); }

#ifdef _PREFAST_
#pragma prefast( suppress:26165, "g_bThreadSafe controls behavior" )
#endif

inline _Releases_lock_(g_cs) ~DXUTLock() { if( g_bThreadSafe ) LeaveCriticalSection( &g_cs ); }

#ifdef _PREFAST_
#pragma prefast(pop)
#endif
};

//--------------------------------------------------------------------------------------
Expand Down Expand Up @@ -707,7 +720,7 @@ HRESULT WINAPI DXUTInit( bool bParseCommandLine,
memset( &tk, 0, sizeof(tk) );
GetDXUTState().SetStartupToggleKeys( tk );

FILTERKEYS fk = {sizeof(FILTERKEYS), 0};
FILTERKEYS fk = { sizeof(FILTERKEYS), 0, 0, 0, 0, 0 };
if ( !SystemParametersInfo(SPI_GETFILTERKEYS, sizeof(FILTERKEYS), &fk, 0) )
memset( &fk, 0, sizeof(fk) );
GetDXUTState().SetStartupFilterKeys( fk );
Expand Down Expand Up @@ -1570,11 +1583,11 @@ LRESULT CALLBACK DXUTStaticWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
// Don't allow the F10 key to act as a shortcut to the menu bar
// by not passing these messages to the DefWindowProc only when
// there's no menu present
if( !GetDXUTState().GetCallDefWindowProc() || !GetDXUTState().GetMenu() &&
( uMsg == WM_SYSKEYDOWN || uMsg == WM_SYSKEYUP ) && wParam == VK_F10 )
if (!GetDXUTState().GetCallDefWindowProc() || (!GetDXUTState().GetMenu() &&
(uMsg == WM_SYSKEYDOWN || uMsg == WM_SYSKEYUP) && wParam == VK_F10))
return 0;
else
return DefWindowProc( hWnd, uMsg, wParam, lParam );
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}


Expand Down Expand Up @@ -1722,7 +1735,7 @@ HRESULT WINAPI DXUTCreateDevice(D3D_FEATURE_LEVEL reqFL, bool bWindowed, int nS
memset( &osv, 0, sizeof(osv) );
osv.dwOSVersionInfoSize = sizeof(osv);
#pragma warning( suppress : 4996 28159 )
GetVersionEx( (LPOSVERSIONINFO)&osv );
std::ignore = GetVersionEx( (LPOSVERSIONINFO)&osv );

if ( ( osv.dwMajorVersion > 6 )
|| ( osv.dwMajorVersion == 6 && osv.dwMinorVersion >= 1 )
Expand Down Expand Up @@ -3107,7 +3120,7 @@ void DXUTCleanup3DEnvironment( _In_ bool bReleaseSettings )
ID3D11Debug * d3dDebug = nullptr;
if( SUCCEEDED( pd3dDevice->QueryInterface( IID_PPV_ARGS(&d3dDebug) ) ) )
{
d3dDebug->ReportLiveDeviceObjects( D3D11_RLDO_SUMMARY | D3D11_RLDO_DETAIL );
d3dDebug->ReportLiveDeviceObjects( static_cast<D3D11_RLDO_FLAGS>(D3D11_RLDO_SUMMARY | D3D11_RLDO_DETAIL) );
d3dDebug->Release();
}
#endif
Expand Down Expand Up @@ -3527,7 +3540,7 @@ HRESULT WINAPI DXUTToggleFullScreen()
{
static const DXGI_MODE_DESC s_adapterDesktopDisplayMode =
{
800, 600, { 0, 0 }, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
800, 600, { 0, 0 }, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED, DXGI_MODE_SCALING_UNSPECIFIED,
};
memcpy(&adapterDesktopDisplayMode, &s_adapterDesktopDisplayMode, sizeof(DXGI_MODE_DESC));
}
Expand Down
16 changes: 9 additions & 7 deletions DXUT/Core/DXUT.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,18 @@
#define NOMINMAX
#endif

#include <windows.h>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <new>
#include <tuple>

#include <Windows.h>
#include <initguid.h>
#include <assert.h>
#include <commctrl.h> // for InitCommonControls()
#include <shellapi.h> // for ExtractIcon()
#include <new.h> // for placement new
#include <shlobj.h>
#include <math.h>
#include <limits.h>
#include <stdio.h>

// CRT's memory leak detection
#if defined(DEBUG) || defined(_DEBUG)
Expand Down Expand Up @@ -131,7 +133,7 @@
((DWORD)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
#endif

#define DXUT_VERSION 1126
#define DXUT_VERSION 1127

//--------------------------------------------------------------------------------------
// Structs
Expand Down
2 changes: 0 additions & 2 deletions DXUT/Core/DXUTDevice11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
//--------------------------------------------------------------------------------------
extern void DXUTGetCallbackD3D11DeviceAcceptable( LPDXUTCALLBACKISD3D11DEVICEACCEPTABLE* ppCallbackIsDeviceAcceptable, void** ppUserContext );

static int __cdecl SortModesCallback( const void* arg1, const void* arg2 );

CD3D11Enumeration* g_pDXUTD3D11Enumeration = nullptr;

HRESULT WINAPI DXUTCreateD3D11Enumeration()
Expand Down
14 changes: 9 additions & 5 deletions DXUT/Core/DXUTmisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
//
// http://go.microsoft.com/fwlink/?LinkId=320437
//--------------------------------------------------------------------------------------
#include "dxut.h"
#include "DXUT.h"
#include <xinput.h>

#ifndef XINPUT_DLL_W
#define XINPUT_DLL_W L"xinput9_1_0.dll"
#endif

#include "ScreenGrab.h"


Expand Down Expand Up @@ -938,7 +942,7 @@ HRESULT DXUTGetGamepadState( DWORD dwPort, DXUT_GAMEPAD* pGamePad, bool bThumbst
static LPXINPUTGETCAPABILITIES s_pXInputGetCapabilities = nullptr;
if( !s_pXInputGetState || !s_pXInputGetCapabilities )
{
HINSTANCE hInst = LoadLibraryEx( XINPUT_DLL, nullptr, 0x00000800 /* LOAD_LIBRARY_SEARCH_SYSTEM32 */ );
HINSTANCE hInst = LoadLibraryExW( XINPUT_DLL_W, nullptr, 0x00000800 /* LOAD_LIBRARY_SEARCH_SYSTEM32 */ );
if( hInst )
{
s_pXInputGetState = reinterpret_cast<LPXINPUTGETSTATE>( reinterpret_cast<void*>( GetProcAddress( hInst, "XInputGetState" ) ) );
Expand Down Expand Up @@ -1045,7 +1049,7 @@ void DXUTEnableXInput( _In_ bool bEnable )
static LPXINPUTENABLE s_pXInputEnable = nullptr;
if( !s_pXInputEnable )
{
HINSTANCE hInst = LoadLibraryEx( XINPUT_DLL, nullptr, 0x00000800 /* LOAD_LIBRARY_SEARCH_SYSTEM32 */ );
HINSTANCE hInst = LoadLibraryExW( XINPUT_DLL_W, nullptr, 0x00000800 /* LOAD_LIBRARY_SEARCH_SYSTEM32 */ );
if( hInst )
s_pXInputEnable = reinterpret_cast<LPXINPUTENABLE>( reinterpret_cast<void*>( GetProcAddress( hInst, "XInputEnable" ) ) );
}
Expand All @@ -1064,7 +1068,7 @@ HRESULT DXUTStopRumbleOnAllControllers()
static LPXINPUTSETSTATE s_pXInputSetState = nullptr;
if( !s_pXInputSetState )
{
HINSTANCE hInst = LoadLibraryEx( XINPUT_DLL, nullptr, 0x00000800 /* LOAD_LIBRARY_SEARCH_SYSTEM32 */ );
HINSTANCE hInst = LoadLibraryExW( XINPUT_DLL_W, nullptr, 0x00000800 /* LOAD_LIBRARY_SEARCH_SYSTEM32 */ );
if( hInst )
s_pXInputSetState = reinterpret_cast<LPXINPUTSETSTATE>( reinterpret_cast<void*>( GetProcAddress( hInst, "XInputSetState" ) ) );
}
Expand Down Expand Up @@ -1246,7 +1250,7 @@ HRESULT DXUTSnapD3D11Screenshot( _In_z_ LPCWSTR szFileName, _In_ bool usedds )
if (!pSwap)
return E_FAIL;

ID3D11Texture2D* pBackBuffer;
ID3D11Texture2D* pBackBuffer = nullptr;
HRESULT hr = pSwap->GetBuffer( 0, __uuidof( *pBackBuffer ), ( LPVOID* )&pBackBuffer );
if (hr != S_OK)
return hr;
Expand Down
8 changes: 4 additions & 4 deletions DXUT/Core/DXUTmisc.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const WCHAR* WINAPI DXUTTraceWindowsMessage( _In_ UINT uMsg );
#else
#define DXUT_ERR(str,hr) (hr)
#define DXUT_ERR_MSGBOX(str,hr) (hr)
#define DXUTTRACE (__noop)
#define DXUTTRACE
#endif


Expand Down Expand Up @@ -224,9 +224,9 @@ const DWORD DXUT_PERFEVENTCOLOR3 = 0xFF6464C8;
#define DXUT_SetPerfMarker( color, pstrMessage ) DXUT_Dynamic_D3DPERF_SetMarker( color, pstrMessage )
#else
// PROFILE is not defined, so these macros do nothing
#define DXUT_BeginPerfEvent( color, pstrMessage ) (__noop)
#define DXUT_EndPerfEvent() (__noop)
#define DXUT_SetPerfMarker( color, pstrMessage ) (__noop)
#define DXUT_BeginPerfEvent( color, pstrMessage )
#define DXUT_EndPerfEvent()
#define DXUT_SetPerfMarker( color, pstrMessage )
#endif

//--------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion DXUT/Core/ScreenGrab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------

#include "dxut.h"
#include "DXUT.h"

// Does not capture 1D textures or 3D textures (volume maps)

Expand Down
16 changes: 11 additions & 5 deletions DXUT/Core/WICTextureLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------

#include "dxut.h"
#include "DXUT.h"

// We could load multi-frame images (TIFF/GIF) into a texture array.
// For now, we just load the first frame (note: DirectXTex supports multi-frame images)
Expand All @@ -36,6 +36,8 @@

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstring>
#include <iterator>
#include <memory>
Expand All @@ -53,16 +55,18 @@ using Microsoft::WRL::ComPtr;
namespace
{
//--------------------------------------------------------------------------------------
#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
template<UINT TNameLength>
inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_ const char(&name)[TNameLength]) noexcept
{
#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name);
}
#else
UNREFERENCED_PARAMETER(resource);
UNREFERENCED_PARAMETER(name);
#endif
template<UINT TNameLength>
inline void SetDebugObjectName(_In_ ID3D11DeviceChild*, _In_ const char(&)[TNameLength]) noexcept
{
}
#endif

//-------------------------------------------------------------------------------------
// WIC Pixel Format Translation Data
Expand Down Expand Up @@ -167,7 +171,9 @@ namespace
// We don't support n-channel formats
};

#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
bool g_WIC2 = false;
#endif

BOOL WINAPI InitializeWICFactory(PINIT_ONCE, PVOID, PVOID *ifactory) noexcept
{
Expand Down
Loading

0 comments on commit e73c129

Please sign in to comment.