Add ClangCl support for CMake (#14)

This commit is contained in:
Chuck Walbourn 2022-05-23 00:45:06 -07:00 коммит произвёл GitHub
Родитель 846926ea7e
Коммит 939b138842
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
19 изменённых файлов: 79 добавлений и 48 удалений

Просмотреть файл

@ -5,7 +5,7 @@
// This is the binary file interface shared between the Effects
// compiler and runtime.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/p/?LinkId=271568
@ -148,6 +148,7 @@ enum EVarType
EVT_Object,
EVT_Struct,
EVT_Interface,
EVT_Count,
};
enum EScalarType

Просмотреть файл

@ -3,7 +3,7 @@
//
// Direct3D 11 Effects States Header
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/p/?LinkId=271568

Просмотреть файл

@ -5,7 +5,7 @@
// This file defines properties of states which can appear in
// state blocks and pass blocks.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/p/?LinkId=271568

Просмотреть файл

@ -3,7 +3,7 @@
//
// Direct3D 11 Effects Stream Out Decl Parser
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/p/?LinkId=271568

Просмотреть файл

@ -13,7 +13,7 @@ project (Effects11
option(ENABLE_CODE_ANALYSIS "Use Static Code Analysis on build" OFF)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
@ -114,11 +114,18 @@ install(FILES
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /fp:fast)
if((${CMAKE_SIZEOF_VOID_P} EQUAL 4) AND (NOT ${DIRECTX_ARCH} MATCHES "arm"))
if((${CMAKE_SIZEOF_VOID_P} EQUAL 4) AND (NOT ${DIRECTX_ARCH} MATCHES "^arm"))
target_compile_options(${PROJECT_NAME} PRIVATE /arch:SSE2)
endif()
endif()
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set(WarningsLib "-Wno-microsoft-exception-spec" "-Wno-microsoft-goto" "-Wno-switch"
"-Wno-unused-value" "-Wno-unused-function" "-Wno-dynamic-class-memaccess"
"-Wno-tautological-constant-out-of-range-compare" "-Wno-invalid-offsetof")
target_compile_options(${PROJECT_NAME} PRIVATE ${WarningsLib})
endif()
if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
target_compile_options(${PROJECT_NAME} PRIVATE /wd5205 /JMC- /Zc:__cplusplus)

Просмотреть файл

@ -70,6 +70,17 @@
"strategy": "external"
}
},
{
"name": "Clang",
"hidden": true,
"cacheVariables": {
"CMAKE_CXX_COMPILER": "clang-cl.exe"
},
"toolset": {
"value": "host=x64",
"strategy": "external"
}
},
{
"name": "UWP",
@ -80,12 +91,12 @@
"hidden": true
},
{ "name": "x64-Debug" , "description": "MSVC for x64 (Debug) for Windows 10", "inherits": [ "base", "x64", "Debug", "MSVC" ] },
{ "name": "x64-Release" , "description": "MSVC for x64 (Release) for Windows 10", "inherits": [ "base", "x64", "Release", "MSVC" ] },
{ "name": "x86-Debug" , "description": "MSVC for x86 (Debug) for Windows 10", "inherits": [ "base", "x86", "Debug", "MSVC" ] },
{ "name": "x86-Release" , "description": "MSVC for x86 (Release) for Windows 10", "inherits": [ "base", "x86", "Release", "MSVC" ] },
{ "name": "arm64-Debug" , "description": "MSVC for ARM64 (Debug) for Windows 10", "inherits": [ "base", "ARM64", "Debug", "MSVC" ] },
{ "name": "arm64-Release" , "description": "MSVC for ARM64 (Release) for Windows 10", "inherits": [ "base", "ARM64", "Release", "MSVC" ] },
{ "name": "x64-Debug" , "description": "MSVC for x64 (Debug)", "inherits": [ "base", "x64", "Debug", "MSVC" ] },
{ "name": "x64-Release" , "description": "MSVC for x64 (Release)", "inherits": [ "base", "x64", "Release", "MSVC" ] },
{ "name": "x86-Debug" , "description": "MSVC for x86 (Debug)", "inherits": [ "base", "x86", "Debug", "MSVC" ] },
{ "name": "x86-Release" , "description": "MSVC for x86 (Release)", "inherits": [ "base", "x86", "Release", "MSVC" ] },
{ "name": "arm64-Debug" , "description": "MSVC for ARM64 (Debug)", "inherits": [ "base", "ARM64", "Debug", "MSVC" ] },
{ "name": "arm64-Release" , "description": "MSVC for ARM64 (Release)", "inherits": [ "base", "ARM64", "Release", "MSVC" ] },
{ "name": "x64-Debug-UWP" , "description": "MSVC for x64 (Debug) for UWP", "inherits": [ "base", "x64", "Debug", "MSVC", "UWP" ] },
{ "name": "x64-Release-UWP" , "description": "MSVC for x64 (Release) for UWP", "inherits": [ "base", "x64", "Release", "MSVC", "UWP" ] },
@ -94,6 +105,11 @@
{ "name": "arm-Debug-UWP" , "description": "MSVC for ARM (Debug) for UWP", "inherits": [ "base", "ARM", "Debug", "MSVC", "UWP" ] },
{ "name": "arm-Release-UWP" , "description": "MSVC for ARM (Release) for UWP", "inherits": [ "base", "ARM", "Release", "MSVC", "UWP" ] },
{ "name": "arm64-Debug-UWP" , "description": "MSVC for ARM64 (Debug) for UWP", "inherits": [ "base", "ARM64", "Debug", "MSVC", "UWP" ] },
{ "name": "arm64-Release-UWP", "description": "MSVC for ARM64 (Release) for UWP", "inherits": [ "base", "ARM64", "Release", "MSVC", "UWP" ] }
{ "name": "arm64-Release-UWP", "description": "MSVC for ARM64 (Release) for UWP", "inherits": [ "base", "ARM64", "Release", "MSVC", "UWP" ] },
{ "name": "x64-Debug-Clang" , "description": "Clang/LLVM for x64 (Debug)", "inherits": [ "base", "x64", "Debug", "Clang" ] },
{ "name": "x64-Release-Clang" , "description": "Clang/LLVM for x64 (Release)", "inherits": [ "base", "x64", "Release", "Clang" ] },
{ "name": "x86-Debug-Clang" , "description": "Clang/LLVM for x86 (Debug)", "inherits": [ "base", "x86", "Debug", "Clang" ], "environment": { "CXXFLAGS": "-m32" } },
{ "name": "x86-Release-Clang" , "description": "Clang/LLVM for x86 (Release)", "inherits": [ "base", "x86", "Release", "Clang" ], "environment": { "CXXFLAGS": "-m32" } }
]
}

Просмотреть файл

@ -3,7 +3,7 @@
//
// Direct3D 11 Effects Header for ID3DX11Effect Implementation
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/p/?LinkId=271568
@ -721,10 +721,14 @@ struct SVariable
char *pSemantic;
uint32_t ExplicitBindPoint;
SVariable() noexcept
SVariable() noexcept :
Data{},
pMemberData(nullptr),
pType(nullptr),
pName(nullptr),
pSemantic(nullptr),
ExplicitBindPoint(uint32_t(-1))
{
ZeroMemory(this, sizeof(*this));
ExplicitBindPoint = uint32_t(-1);
}
};

Просмотреть файл

@ -3,7 +3,7 @@
//
// Effect API entry point
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/p/?LinkId=271568

Просмотреть файл

@ -3,7 +3,7 @@
//
// Direct3D Effects file loading code
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/p/?LinkId=271568
@ -184,8 +184,8 @@ inline HRESULT VerifyPointer(uint32_t oBase, uint32_t dwSize, uint32_t dwMaxSize
CEffectHeap::CEffectHeap() noexcept :
m_pData(nullptr),
m_dwSize(0),
m_dwBufferSize(0)
m_dwBufferSize(0),
m_dwSize(0)
{
}
@ -1016,7 +1016,7 @@ HRESULT CEffectLoader::LoadTypeAndAddToPool(SType **ppType, uint32_t dwOffset)
case EVT_Object:
VHD( m_msUnstructured.Read((void**) &pObjectType, sizeof(uint32_t)), "Invalid pEffectBuffer: cannot read object type." );
temporaryType.ObjectType = *pObjectType;
VBD( temporaryType.VarType > EOT_Invalid && temporaryType.VarType < EOT_Count, "Invalid pEffectBuffer: invalid object type." );
VBD( temporaryType.VarType > EVT_Invalid && temporaryType.VarType < EVT_Count, "Invalid pEffectBuffer: invalid object type." );
VN( pHashBuffer = m_HashBuffer.AddRange(sizeof(temporaryType.VarType) + sizeof(temporaryType.Elements) +
sizeof(temporaryType.pTypeName) + sizeof(temporaryType.ObjectType)) );

Просмотреть файл

@ -4,7 +4,7 @@
// Direct3D 11 Effects header for the FX file loader
// A CEffectLoader is created at load time to facilitate loading
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/p/?LinkId=271568

Просмотреть файл

@ -6,7 +6,7 @@
// are typically called when creating, cloning, or optimizing an
// Effect, or reflecting a variable.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/p/?LinkId=271568
@ -376,7 +376,7 @@ HRESULT SShaderBlock::GetShaderDesc(_Out_ D3DX11_EFFECT_SHADER_DESC *pDesc, _In_
pDesc->NumPatchConstantSignatureEntries = ShaderDesc.PatchConstantParameters;
}
}
lExit:
return hr;
}

Просмотреть файл

@ -3,7 +3,7 @@
//
// Direct3D 11 Effects public reflection APIs
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/p/?LinkId=271568
@ -934,7 +934,7 @@ HRESULT SConstantBuffer::GetDesc(_Out_ D3DX11_EFFECT_VARIABLE_DESC *pDesc)
pDesc->Semantic = nullptr;
pDesc->BufferOffset = 0;
if (ExplicitBindPoint != -1)
if (ExplicitBindPoint != static_cast<uint32_t>(- 1))
{
pDesc->ExplicitBindPoint = ExplicitBindPoint;
pDesc->Flags |= D3DX11_EFFECT_VARIABLE_EXPLICIT_BIND_POINT;
@ -1438,6 +1438,10 @@ HRESULT SPassBlock::GetShaderDescHelper(D3DX11_PASS_SHADER_DESC *pDesc)
ApplyPassAssignments();
#ifdef _PREFAST_
#pragma prefast(push)
#pragma prefast(disable:__WARNING_UNUSED_POINTER_ASSIGNMENT, "pFuncName used in DPF")
#endif
switch (EShaderType)
{
case EOT_VertexShader:
@ -1456,20 +1460,20 @@ HRESULT SPassBlock::GetShaderDescHelper(D3DX11_PASS_SHADER_DESC *pDesc)
pShaderBlock = BackingStore.pGeometryShaderBlock;
break;
case EOT_HullShader5:
#pragma prefast(suppress:__WARNING_UNUSED_POINTER_ASSIGNMENT, "pFuncName used in DPF")
pFuncName = "ID3DX11EffectPass::GetHullShaderDesc";
pShaderBlock = BackingStore.pHullShaderBlock;
break;
case EOT_DomainShader5:
#pragma prefast(suppress:__WARNING_UNUSED_POINTER_ASSIGNMENT, "pFuncName used in DPF")
pFuncName = "ID3DX11EffectPass::GetDomainShaderDesc";
pShaderBlock = BackingStore.pDomainShaderBlock;
break;
case EOT_ComputeShader5:
#pragma prefast(suppress:__WARNING_UNUSED_POINTER_ASSIGNMENT, "pFuncName used in DPF")
pFuncName = "ID3DX11EffectPass::GetComputeShaderDesc";
pShaderBlock = BackingStore.pComputeShaderBlock;
break;
#ifdef _PREFAST_
#pragma prefast(pop)
#endif
default:
assert(0);
}
@ -1627,7 +1631,6 @@ HRESULT SPassBlock::Apply(_In_ uint32_t Flags, _In_ ID3D11DeviceContext* pContex
pEffect->ApplyPassBlock(this);
pEffect->m_pContext = nullptr;
lExit:
return hr;
}

Просмотреть файл

@ -5,7 +5,7 @@
// These functions are expected to be called at high frequency
// (when applying a pass).
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/p/?LinkId=271568
@ -640,7 +640,7 @@ void CEffect::IncrementTimer()
m_LocalTimer++;
#if !defined(_M_X64) && !defined(_M_ARM64)
#if _DEBUG
#ifdef _DEBUG
if (m_LocalTimer > g_TimerRolloverCount)
{
DPF(0, "Rolling over timer (current time: %zu, rollover cap: %u).", m_LocalTimer, g_TimerRolloverCount);

Просмотреть файл

@ -4,7 +4,7 @@
// Direct3D 11 Effects Variable reflection template
// These templates define the many Effect variable types.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/p/?LinkId=271568

Просмотреть файл

@ -6,7 +6,7 @@
// Lifetime for most Effects objects is based on the the lifetime of the master
// effect, so the reference count is not used.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/p/?LinkId=271568

Просмотреть файл

@ -3,7 +3,7 @@
//
// Direct3D 11 Effects implementation for helper data structures
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/p/?LinkId=271568
@ -261,7 +261,7 @@ CDataBlockStore::CDataBlockStore() noexcept :
m_Offset(0),
m_IsAligned(false)
{
#if _DEBUG
#ifdef _DEBUG
m_cAllocations = 0;
#endif
}
@ -332,7 +332,7 @@ void* CDataBlockStore::Allocate(_In_ uint32_t bufferSize)
{
void *pRetValue = nullptr;
#if _DEBUG
#ifdef _DEBUG
m_cAllocations++;
#endif

Просмотреть файл

@ -3,7 +3,7 @@
//
// Direct3D 11 Effect Types & APIs Header
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/p/?LinkId=271568

Просмотреть файл

@ -3,7 +3,7 @@
//
// Direct3D 11 Effects helper defines and data structures
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/p/?LinkId=271568
@ -197,14 +197,14 @@ public:
HRESULT m_hLastError;
CEffectVector<T>() noexcept :
m_hLastError(S_OK),
#if _DEBUG
m_pCastData(nullptr),
#endif
m_pData(nullptr),
m_CurSize(0),
m_MaxSize(0)
m_MaxSize(0),
m_hLastError(S_OK)
{
#if _DEBUG
m_pCastData = nullptr;
#endif // _DEBUG
}
~CEffectVector<T>()

Просмотреть файл

@ -3,7 +3,7 @@
//
// Direct3D 11 shader effects precompiled header
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/p/?LinkId=271568
@ -46,8 +46,8 @@
#include "d3dxGlobal.h"
#include <stddef.h>
#include <stdlib.h>
#include <cstddef>
#include <cstdlib>
#include "Effect.h"
#include "EffectStateBase11.h"