LukasBanana / LLGL

Low Level Graphics Library (LLGL) is a thin abstraction layer for the modern graphics APIs OpenGL, Direct3D, Vulkan, and Metal
BSD 3-Clause "New" or "Revised" License
2.05k stars 139 forks source link

Dx11 bug with caps.features.hasLogicOp. #40

Closed raxvan closed 5 years ago

raxvan commented 5 years ago

There is an inconsistency between this lines: DXCode.cpp: caps.features.hasLogicOp = (featureLevel >= D3D_FEATURE_LEVEL_11_1); DX11Types.cpp (function Convert): if (src.logicOp != LogicOp::Disabled) without define LLGL_D3D11_ENABLE_FEATURELEVEL added to compile.

Value of hasLogicOp can be set to true by D3D_FEATURE_LEVEL_11_1 but the code assumes it's disabled without LLGL_D3D11_ENABLE_FEATURELEVEL

LukasBanana commented 5 years ago

What do you mean by that:

hasLogicOp can be set to true

The feature level that is passed to DXGetRenderingCaps is the one that was selected during device creation. It's not necessarily the one you selected manually.

The LLGL_D3D11_ENABLE_FEATURELEVEL macro is used to prevent compile errors when the respective header is not available.

raxvan commented 5 years ago

The value of hasLogicOp is true. But then trying to create a graphics pipeline the function Convert throws because it's assumes that hasLogicOp is false.

LukasBanana commented 5 years ago

I see, the error message is indeed somehow confusing. However, when the graphics pipeline wants to create a blend state with logic-op enabled, the D3D device must have been created with version 11.1, or in other words D3D11_BLEND_DESC1 is required not D3D11_BLEND_DESC.

So maybe the feature level should be limited to the highest version of the LLGL_D3D11_ENABLE_FEATURELEVEL macro.

raxvan commented 5 years ago

Yes, directx feature level should be caped to value of LLGL_D3D11_ENABLE_FEATURELEVEL.

LukasBanana commented 5 years ago

Fixed with 5c917ea.