From f936d4c05e28f4798c10c67f7f4ca98c2274bec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Tue, 22 Sep 2015 15:19:39 -0700 Subject: [PATCH] Fixed clang warnings. --- 3rdparty/dxsdk/include/d3d10.h | 8 +++---- 3rdparty/dxsdk/include/d3dx12.h | 40 ++++++++++++++++----------------- scripts/bgfx.lua | 8 ++++++- src/renderer_d3d12.cpp | 32 +++++++++++++------------- src/shader_dxbc.cpp | 2 +- 5 files changed, 48 insertions(+), 42 deletions(-) diff --git a/3rdparty/dxsdk/include/d3d10.h b/3rdparty/dxsdk/include/d3d10.h index 4d89fc47..980838b3 100644 --- a/3rdparty/dxsdk/include/d3d10.h +++ b/3rdparty/dxsdk/include/d3d10.h @@ -1667,7 +1667,7 @@ struct CD3D10_BUFFER_DESC : public D3D10_BUFFER_DESC MiscFlags = miscFlags; } ~CD3D10_BUFFER_DESC() {} - operator const D3D10_BUFFER_DESC&() const { return *this; } +// operator const D3D10_BUFFER_DESC&() const { return *this; } }; #endif @@ -1894,7 +1894,7 @@ struct CD3D10_TEXTURE1D_DESC : public D3D10_TEXTURE1D_DESC MiscFlags = miscFlags; } ~CD3D10_TEXTURE1D_DESC() {} - operator const D3D10_TEXTURE1D_DESC&() const { return *this; } +// operator const D3D10_TEXTURE1D_DESC&() const { return *this; } }; #endif @@ -2137,7 +2137,7 @@ struct CD3D10_TEXTURE2D_DESC : public D3D10_TEXTURE2D_DESC MiscFlags = miscFlags; } ~CD3D10_TEXTURE2D_DESC() {} - operator const D3D10_TEXTURE2D_DESC&() const { return *this; } +// operator const D3D10_TEXTURE2D_DESC&() const { return *this; } }; #endif typedef struct D3D10_MAPPED_TEXTURE2D @@ -2381,7 +2381,7 @@ struct CD3D10_TEXTURE3D_DESC : public D3D10_TEXTURE3D_DESC MiscFlags = miscFlags; } ~CD3D10_TEXTURE3D_DESC() {} - operator const D3D10_TEXTURE3D_DESC&() const { return *this; } +// operator const D3D10_TEXTURE3D_DESC&() const { return *this; } }; #endif typedef struct D3D10_MAPPED_TEXTURE3D diff --git a/3rdparty/dxsdk/include/d3dx12.h b/3rdparty/dxsdk/include/d3dx12.h index ba59dfc7..6b5e97d8 100644 --- a/3rdparty/dxsdk/include/d3dx12.h +++ b/3rdparty/dxsdk/include/d3dx12.h @@ -48,7 +48,7 @@ struct CD3DX12_RECT : public D3D12_RECT bottom = Bottom; } ~CD3DX12_RECT() {} - operator const D3D12_RECT&() const { return *this; } +// operator const D3D12_RECT&() const { return *this; } }; //------------------------------------------------------------------------------------------------ @@ -99,7 +99,7 @@ struct CD3DX12_BOX : public D3D12_BOX back = Back; } ~CD3DX12_BOX() {} - operator const D3D12_BOX&() const { return *this; } +// operator const D3D12_BOX&() const { return *this; } }; inline bool operator==( const D3D12_BOX& l, const D3D12_BOX& r ) { @@ -162,7 +162,7 @@ struct CD3DX12_DEPTH_STENCIL_DESC : public D3D12_DEPTH_STENCIL_DESC BackFace.StencilFunc = backStencilFunc; } ~CD3DX12_DEPTH_STENCIL_DESC() {} - operator const D3D12_DEPTH_STENCIL_DESC&() const { return *this; } +// operator const D3D12_DEPTH_STENCIL_DESC&() const { return *this; } }; //------------------------------------------------------------------------------------------------ @@ -189,7 +189,7 @@ struct CD3DX12_BLEND_DESC : public D3D12_BLEND_DESC RenderTarget[ i ] = defaultRenderTargetBlendDesc; } ~CD3DX12_BLEND_DESC() {} - operator const D3D12_BLEND_DESC&() const { return *this; } +// operator const D3D12_BLEND_DESC&() const { return *this; } }; //------------------------------------------------------------------------------------------------ @@ -240,7 +240,7 @@ struct CD3DX12_RASTERIZER_DESC : public D3D12_RASTERIZER_DESC ConservativeRaster = conservativeRaster; } ~CD3DX12_RASTERIZER_DESC() {} - operator const D3D12_RASTERIZER_DESC&() const { return *this; } +// operator const D3D12_RASTERIZER_DESC&() const { return *this; } }; //------------------------------------------------------------------------------------------------ @@ -258,7 +258,7 @@ struct CD3DX12_RESOURCE_ALLOCATION_INFO : public D3D12_RESOURCE_ALLOCATION_INFO SizeInBytes = size; Alignment = alignment; } - operator const D3D12_RESOURCE_ALLOCATION_INFO&() const { return *this; } +// operator const D3D12_RESOURCE_ALLOCATION_INFO&() const { return *this; } }; //------------------------------------------------------------------------------------------------ @@ -292,7 +292,7 @@ struct CD3DX12_HEAP_PROPERTIES : public D3D12_HEAP_PROPERTIES CreationNodeMask = creationNodeMask; VisibleNodeMask = nodeMask; } - operator const D3D12_HEAP_PROPERTIES&() const { return *this; } +// operator const D3D12_HEAP_PROPERTIES&() const { return *this; } bool IsCPUAccessible() const { return Type == D3D12_HEAP_TYPE_UPLOAD || Type == D3D12_HEAP_TYPE_READBACK || (Type == D3D12_HEAP_TYPE_CUSTOM && @@ -382,7 +382,7 @@ struct CD3DX12_HEAP_DESC : public D3D12_HEAP_DESC Alignment = resAllocInfo.Alignment; Flags = flags; } - operator const D3D12_HEAP_DESC&() const { return *this; } +// operator const D3D12_HEAP_DESC&() const { return *this; } bool IsCPUAccessible() const { return static_cast< const CD3DX12_HEAP_PROPERTIES* >( &Properties )->IsCPUAccessible(); } }; @@ -421,7 +421,7 @@ struct CD3DX12_CLEAR_VALUE : public D3D12_CLEAR_VALUE memcpy( &DepthStencil.Depth, &depth, sizeof( depth ) ); DepthStencil.Stencil = stencil; } - operator const D3D12_CLEAR_VALUE&() const { return *this; } +// operator const D3D12_CLEAR_VALUE&() const { return *this; } }; //------------------------------------------------------------------------------------------------ @@ -439,7 +439,7 @@ struct CD3DX12_RANGE : public D3D12_RANGE Begin = begin; End = end; } - operator const D3D12_RANGE&() const { return *this; } +// operator const D3D12_RANGE&() const { return *this; } }; //------------------------------------------------------------------------------------------------ @@ -461,7 +461,7 @@ struct CD3DX12_TILED_RESOURCE_COORDINATE : public D3D12_TILED_RESOURCE_COORDINAT Z = z; Subresource = subresource; } - operator const D3D12_TILED_RESOURCE_COORDINATE&() const { return *this; } +// operator const D3D12_TILED_RESOURCE_COORDINATE&() const { return *this; } }; //------------------------------------------------------------------------------------------------ @@ -485,7 +485,7 @@ struct CD3DX12_TILE_REGION_SIZE : public D3D12_TILE_REGION_SIZE Height = height; Depth = depth; } - operator const D3D12_TILE_REGION_SIZE&() const { return *this; } +// operator const D3D12_TILE_REGION_SIZE&() const { return *this; } }; //------------------------------------------------------------------------------------------------ @@ -507,7 +507,7 @@ struct CD3DX12_SUBRESOURCE_TILING : public D3D12_SUBRESOURCE_TILING DepthInTiles = depthInTiles; StartTileIndexInOverallResource = startTileIndexInOverallResource; } - operator const D3D12_SUBRESOURCE_TILING&() const { return *this; } +// operator const D3D12_SUBRESOURCE_TILING&() const { return *this; } }; //------------------------------------------------------------------------------------------------ @@ -527,7 +527,7 @@ struct CD3DX12_TILE_SHAPE : public D3D12_TILE_SHAPE HeightInTexels = heightInTexels; DepthInTexels = depthInTexels; } - operator const D3D12_TILE_SHAPE&() const { return *this; } +// operator const D3D12_TILE_SHAPE&() const { return *this; } }; //------------------------------------------------------------------------------------------------ @@ -578,7 +578,7 @@ struct CD3DX12_RESOURCE_BARRIER : public D3D12_RESOURCE_BARRIER barrier.UAV.pResource = pResource; return result; } - operator const D3D12_RESOURCE_BARRIER&() const { return *this; } +// operator const D3D12_RESOURCE_BARRIER&() const { return *this; } }; //------------------------------------------------------------------------------------------------ @@ -600,7 +600,7 @@ struct CD3DX12_PACKED_MIP_INFO : public D3D12_PACKED_MIP_INFO NumTilesForPackedMips = numTilesForPackedMips; StartTileIndexInOverallResource = startTileIndexInOverallResource; } - operator const D3D12_PACKED_MIP_INFO&() const { return *this; } +// operator const D3D12_PACKED_MIP_INFO&() const { return *this; } }; //------------------------------------------------------------------------------------------------ @@ -634,7 +634,7 @@ struct CD3DX12_SUBRESOURCE_FOOTPRINT : public D3D12_SUBRESOURCE_FOOTPRINT Depth = (resDesc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? resDesc.DepthOrArraySize : 1); RowPitch = rowPitch; } - operator const D3D12_SUBRESOURCE_FOOTPRINT&() const { return *this; } +// operator const D3D12_SUBRESOURCE_FOOTPRINT&() const { return *this; } }; //------------------------------------------------------------------------------------------------ @@ -1304,7 +1304,7 @@ struct CD3DX12_RESOURCE_DESC : public D3D12_RESOURCE_DESC { return MipLevels * ArraySize() * PlaneCount(pDevice); } inline UINT CalcSubresource(UINT MipSlice, UINT ArraySlice, UINT PlaneSlice) { return D3D12CalcSubresource(MipSlice, ArraySlice, PlaneSlice, MipLevels, ArraySize()); } - operator const D3D12_RESOURCE_DESC&() const { return *this; } +// operator const D3D12_RESOURCE_DESC&() const { return *this; } }; inline bool operator==( const D3D12_RESOURCE_DESC& l, const D3D12_RESOURCE_DESC& r ) { @@ -1356,7 +1356,7 @@ inline UINT64 GetRequiredIntermediateSize( UINT64 RequiredSize = 0; ID3D12Device* pDevice; - pDestinationResource->GetDevice(__uuidof(*pDevice), reinterpret_cast(&pDevice)); + pDestinationResource->GetDevice(__uuidof(ID3D12Device), reinterpret_cast(&pDevice)); pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, 0, nullptr, nullptr, nullptr, &RequiredSize); pDevice->Release(); @@ -1450,7 +1450,7 @@ inline UINT64 UpdateSubresources( D3D12_RESOURCE_DESC Desc = pDestinationResource->GetDesc(); ID3D12Device* pDevice; - pDestinationResource->GetDevice(__uuidof(*pDevice), reinterpret_cast(&pDevice)); + pDestinationResource->GetDevice(__uuidof(ID3D12Device), reinterpret_cast(&pDevice)); pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, pLayouts, pNumRows, pRowSizesInBytes, &RequiredSize); pDevice->Release(); diff --git a/scripts/bgfx.lua b/scripts/bgfx.lua index 8c196d5b..c9658d35 100644 --- a/scripts/bgfx.lua +++ b/scripts/bgfx.lua @@ -69,11 +69,17 @@ function bgfxProject(_name, _kind, _defines) "GLESv2", } - configuration { "winphone8* or winstore8*"} + configuration { "winphone8* or winstore8*" } linkoptions { "/ignore:4264" -- LNK4264: archiving object file compiled with /ZW into a static library; note that when authoring Windows Runtime types it is not recommended to link with a static library that contains Windows Runtime metadata } + configuration { "*clang*" } + buildoptions { + "-Wno-microsoft-enum-value", -- enumerator value is not representable in the underlying type 'int' + "-Wno-microsoft-const-init", -- default initialization of an object of const type '' without a user-provided default constructor is a Microsoft extension + } + configuration { "osx" } links { "Cocoa.framework", diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index d20b1793..bdcc05e4 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -836,10 +836,10 @@ namespace bgfx { namespace d3d12 D3D12_ROOT_PARAMETER rootParameter[] = { - { D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, { 1, &descRange[Rdt::Sampler] }, D3D12_SHADER_VISIBILITY_ALL }, - { D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, { 1, &descRange[Rdt::SRV] }, D3D12_SHADER_VISIBILITY_ALL }, - { D3D12_ROOT_PARAMETER_TYPE_CBV, { 0, 0 }, D3D12_SHADER_VISIBILITY_ALL }, - { D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, { 1, &descRange[Rdt::UAV] }, D3D12_SHADER_VISIBILITY_ALL }, + { D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, { { 1, &descRange[Rdt::Sampler] } }, D3D12_SHADER_VISIBILITY_ALL }, + { D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, { { 1, &descRange[Rdt::SRV] } }, D3D12_SHADER_VISIBILITY_ALL }, + { D3D12_ROOT_PARAMETER_TYPE_CBV, { { 0, 0 } }, D3D12_SHADER_VISIBILITY_ALL }, + { D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, { { 1, &descRange[Rdt::UAV] } }, D3D12_SHADER_VISIBILITY_ALL }, }; rootParameter[Rdt::CBV].Descriptor.RegisterSpace = 0; rootParameter[Rdt::CBV].Descriptor.ShaderRegister = 0; @@ -1365,7 +1365,7 @@ namespace bgfx { namespace d3d12 box.back = 1; setResourceBarrier(m_commandList, backBuffer, D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_COPY_SOURCE); - D3D12_TEXTURE_COPY_LOCATION dst = { readback, D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, layout }; + D3D12_TEXTURE_COPY_LOCATION dst = { readback, D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, { layout } }; D3D12_TEXTURE_COPY_LOCATION src = { backBuffer, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, {} }; m_commandList->CopyTextureRegion(&dst, 0, 0, 0, &src, &box); setResourceBarrier(m_commandList, backBuffer, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_PRESENT); @@ -3027,10 +3027,10 @@ data.NumQualityLevels = 0; D3D12_INDIRECT_ARGUMENT_DESC drawArgDesc[] = { - { D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW, { Rdt::CBV } }, - { D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW, 0 }, - { D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW, 1 }, - { D3D12_INDIRECT_ARGUMENT_TYPE_DRAW, 0 }, + { D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW, { { Rdt::CBV } } }, + { D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW, { { 0 } } }, + { D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW, { { 1 } } }, + { D3D12_INDIRECT_ARGUMENT_TYPE_DRAW, { { 0 } } }, }; D3D12_COMMAND_SIGNATURE_DESC drawCommandSignature = @@ -3049,11 +3049,11 @@ data.NumQualityLevels = 0; D3D12_INDIRECT_ARGUMENT_DESC drawIndexedArgDesc[] = { - { D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW, { Rdt::CBV } }, - { D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW, 0 }, - { D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW, 1 }, - { D3D12_INDIRECT_ARGUMENT_TYPE_INDEX_BUFFER_VIEW, 0 }, - { D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED, 0 }, + { D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW, { { Rdt::CBV } } }, + { D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW, { { 0 } } }, + { D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW, { { 1 } } }, + { D3D12_INDIRECT_ARGUMENT_TYPE_INDEX_BUFFER_VIEW, { { 0 } } }, + { D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED, { { 0 } } }, }; D3D12_COMMAND_SIGNATURE_DESC drawIndexedCommandSignature = @@ -4025,9 +4025,9 @@ data.NumQualityLevels = 0; box.front = _z; box.back = _z+_depth; - D3D12_TEXTURE_COPY_LOCATION dst = { m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, {} }; + D3D12_TEXTURE_COPY_LOCATION dst = { m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, { } }; dst.SubresourceIndex = subres; - D3D12_TEXTURE_COPY_LOCATION src = { staging, D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, layout }; + D3D12_TEXTURE_COPY_LOCATION src = { staging, D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, { layout } }; _commandList->CopyTextureRegion(&dst, _rect.m_x, _rect.m_y, 0, &src, &box); setState(_commandList, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); diff --git a/src/shader_dxbc.cpp b/src/shader_dxbc.cpp index 5d8d9609..34e50c14 100644 --- a/src/shader_dxbc.cpp +++ b/src/shader_dxbc.cpp @@ -490,7 +490,7 @@ namespace bgfx }; BX_STATIC_ASSERT(BX_COUNTOF(s_dxbcSrvType) == DxbcResourceDim::Count); - static const char* s_dxbcInterpolationName[] = + const char* s_dxbcInterpolationName[] = { "", "constant",