Skip to content

Commit

Permalink
Workaround clang/LLVM bug with /fp:fast+SSE+float_control
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn committed Feb 4, 2024
1 parent 95796ba commit d18af15
Show file tree
Hide file tree
Showing 11 changed files with 234 additions and 31 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ endif()

if(MSVC)
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE /Wall /GR- /fp:fast "$<$<NOT:$<CONFIG:DEBUG>>:/guard:cf>")
target_compile_options(${t} PRIVATE /Wall /GR- "$<$<NOT:$<CONFIG:DEBUG>>:/guard:cf>")
target_link_options(${t} PRIVATE /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO)
endforeach()

Expand Down Expand Up @@ -649,7 +649,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()
target_compile_options(${PROJECT_NAME} PRIVATE ${WarningsLib})

set(WarningsEXE ${WarningsLib} "-Wno-c++98-compat" "-Wno-c++98-compat-pedantic" "-Wno-switch" "-Wno-switch-enum" "-Wno-covered-switch-default" "-Wno-language-extension-token" "-Wno-missing-prototypes" "-Wno-global-constructors" "-Wno-double-promotion")
set(WarningsEXE ${WarningsLib} "-Wno-c++98-compat" "-Wno-c++98-compat-pedantic" "-Wno-switch" "-Wno-switch-enum" "-Wno-switch-default" "-Wno-covered-switch-default" "-Wno-language-extension-token" "-Wno-missing-prototypes" "-Wno-global-constructors" "-Wno-double-promotion")
foreach(t IN LISTS TOOL_EXES)
target_compile_options(${t} PRIVATE ${WarningsEXE})
endforeach()
Expand All @@ -659,7 +659,7 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
endforeach()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE /sdl /permissive- /JMC- /Zc:__cplusplus /Zc:inline)
target_compile_options(${t} PRIVATE /sdl /permissive- /JMC- /Zc:__cplusplus /Zc:inline /fp:fast)
endforeach()

if(ENABLE_CODE_ANALYSIS)
Expand Down
15 changes: 15 additions & 0 deletions DDSTextureLoader/DDSTextureLoader11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,9 @@ namespace

// No 3:3:2 or paletted DXGI formats aka D3DFMT_R3G3B2, D3DFMT_P8
break;

default:
return DXGI_FORMAT_UNKNOWN;
}
}
else if (ddpf.flags & DDS_LUMINANCE)
Expand Down Expand Up @@ -776,6 +779,9 @@ namespace
return DXGI_FORMAT_R8G8_UNORM; // Some DDS writers assume the bitcount should be 8 instead of 16
}
break;

default:
return DXGI_FORMAT_UNKNOWN;
}
}
else if (ddpf.flags & DDS_ALPHA)
Expand Down Expand Up @@ -808,6 +814,9 @@ namespace
return DXGI_FORMAT_R8G8_SNORM; // D3DX10/11 writes this out as DX10 extension
}
break;

default:
return DXGI_FORMAT_UNKNOWN;
}

// No DXGI format maps to DDPF_BUMPLUMINANCE aka D3DFMT_L6V5U5, D3DFMT_X8L8V8U8
Expand Down Expand Up @@ -908,6 +917,9 @@ namespace
return DXGI_FORMAT_R32G32B32A32_FLOAT;

// No DXGI format maps to D3DFMT_CxV8U8

default:
return DXGI_FORMAT_UNKNOWN;
}
}

Expand Down Expand Up @@ -1312,6 +1324,9 @@ namespace
}
}
break;

default:
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
}

return hr;
Expand Down
15 changes: 15 additions & 0 deletions DDSTextureLoader/DDSTextureLoader12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,9 @@ namespace

// No 3:3:2 or paletted DXGI formats aka D3DFMT_R3G3B2, D3DFMT_P8
break;

default:
return DXGI_FORMAT_UNKNOWN;
}
}
else if (ddpf.flags & DDS_LUMINANCE)
Expand Down Expand Up @@ -860,6 +863,9 @@ namespace
return DXGI_FORMAT_R8G8_UNORM; // Some DDS writers assume the bitcount should be 8 instead of 16
}
break;

default:
return DXGI_FORMAT_UNKNOWN;
}
}
else if (ddpf.flags & DDS_ALPHA)
Expand Down Expand Up @@ -892,6 +898,9 @@ namespace
return DXGI_FORMAT_R8G8_SNORM; // D3DX10/11 writes this out as DX10 extension
}
break;

default:
return DXGI_FORMAT_UNKNOWN;
}

// No DXGI format maps to DDPF_BUMPLUMINANCE aka D3DFMT_L6V5U5, D3DFMT_X8L8V8U8
Expand Down Expand Up @@ -992,6 +1001,9 @@ namespace
return DXGI_FORMAT_R32G32B32A32_FLOAT;

// No DXGI format maps to D3DFMT_CxV8U8

default:
return DXGI_FORMAT_UNKNOWN;
}
}

Expand Down Expand Up @@ -1127,6 +1139,9 @@ namespace
res.SlicePitch = res.RowPitch * static_cast<LONG>(height);
}
break;

default:
break;
}
}

Expand Down
15 changes: 15 additions & 0 deletions DDSTextureLoader/DDSTextureLoader9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,9 @@ namespace

// Paletted texture formats are typically not supported on modern video cards aka D3DFMT_P8, D3DFMT_A8P8
break;

default:
return D3DFMT_UNKNOWN;
}
}
else if (ddpf.flags & DDS_LUMINANCE)
Expand Down Expand Up @@ -651,6 +654,9 @@ namespace
return D3DFMT_A8L8; // Some DDS writers assume the bitcount should be 8 instead of 16
}
break;

default:
return D3DFMT_UNKNOWN;
}
}
else if (ddpf.flags & DDS_ALPHA)
Expand Down Expand Up @@ -685,6 +691,9 @@ namespace
return D3DFMT_V8U8;
}
break;

default:
return D3DFMT_UNKNOWN;
}
}
else if (ddpf.flags & DDS_BUMPLUMINANCE)
Expand All @@ -704,6 +713,9 @@ namespace
return D3DFMT_L6V5U5;
}
break;

default:
return D3DFMT_UNKNOWN;
}
}
else if (ddpf.flags & DDS_FOURCC)
Expand Down Expand Up @@ -760,6 +772,9 @@ namespace
case D3DFMT_A32B32G32R32F:
case D3DFMT_CxV8U8:
return static_cast<D3DFORMAT>(ddpf.fourCC);

default:
return D3DFMT_UNKNOWN;
}
}

Expand Down
4 changes: 4 additions & 0 deletions DirectXTex/BC6HBC7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1800,6 +1800,7 @@ void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const noexcept
case 0x17: warnstr = "BC6H: Reserved mode 10111 encountered during decoding\n"; break;
case 0x1B: warnstr = "BC6H: Reserved mode 11011 encountered during decoding\n"; break;
case 0x1F: warnstr = "BC6H: Reserved mode 11111 encountered during decoding\n"; break;
default: break;
}
OutputDebugStringA(warnstr);
#endif
Expand Down Expand Up @@ -2762,6 +2763,7 @@ void D3DX_BC7::Decode(HDRColorA* pOut) const noexcept
case 1: std::swap(outPixel.r, outPixel.a); break;
case 2: std::swap(outPixel.g, outPixel.a); break;
case 3: std::swap(outPixel.b, outPixel.a); break;
default: break;
}

pOut[i] = HDRColorA(outPixel);
Expand Down Expand Up @@ -2837,6 +2839,7 @@ void D3DX_BC7::Encode(uint32_t flags, const HDRColorA* const pIn) noexcept
case 1: for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].r, EP.aLDRPixels[i].a); break;
case 2: for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].g, EP.aLDRPixels[i].a); break;
case 3: for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].b, EP.aLDRPixels[i].a); break;
default: break;
}

for (size_t im = 0; im < uNumIdxMode && fMSEBest > 0; ++im)
Expand Down Expand Up @@ -2877,6 +2880,7 @@ void D3DX_BC7::Encode(uint32_t flags, const HDRColorA* const pIn) noexcept
case 1: for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].r, EP.aLDRPixels[i].a); break;
case 2: for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].g, EP.aLDRPixels[i].a); break;
case 3: for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].b, EP.aLDRPixels[i].a); break;
default: break;
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions DirectXTex/DirectXTexConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ void DirectX::Internal::CopyScanline(
case DXGI_FORMAT_A8_UNORM:
memset(pDestination, 0xff, outSize);
return;

default:
break;
}
}

Expand Down Expand Up @@ -586,6 +589,9 @@ void DirectX::Internal::SwizzleScanline(
}
}
break;

default:
break;
}

// Fall-through case is to just use memcpy (assuming this is not an in-place operation)
Expand Down
3 changes: 3 additions & 0 deletions DirectXTex/DirectXTexD3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,9 @@ HRESULT DirectX::CreateTextureEx(
hr = pDevice->CreateTexture3D(&desc, initData.get(), reinterpret_cast<ID3D11Texture3D**>(ppResource));
}
break;

default:
return HRESULT_E_NOT_SUPPORTED;
}

return hr;
Expand Down
3 changes: 3 additions & 0 deletions DirectXTex/DirectXTexD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ namespace
res.SlicePitch = res.RowPitch * static_cast<PT>(height);
}
break;

default:
break;
}
}

Expand Down
2 changes: 2 additions & 0 deletions DirectXTex/DirectXTexTGA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,7 @@ namespace

switch (metadata.GetAlphaMode())
{
default:
case TEX_ALPHA_MODE_UNKNOWN:
ext->bAttributesType = HasAlpha(metadata.format) ? TGA_ATTRIBUTE_UNDEFINED : TGA_ATTRIBUTE_NONE;
break;
Expand Down Expand Up @@ -1399,6 +1400,7 @@ namespace
case TGA_ATTRIBUTE_UNDEFINED: return TEX_ALPHA_MODE_CUSTOM;
case TGA_ATTRIBUTE_ALPHA: return TEX_ALPHA_MODE_STRAIGHT;
case TGA_ATTRIBUTE_PREMULTIPLIED: return TEX_ALPHA_MODE_PREMULTIPLIED;
default: return TEX_ALPHA_MODE_UNKNOWN;
}
}

Expand Down
Loading

0 comments on commit d18af15

Please sign in to comment.