diff options
Diffstat (limited to 'Graphics/GraphicsEngine')
| -rw-r--r-- | Graphics/GraphicsEngine/interface/DeviceCaps.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Graphics/GraphicsEngine/interface/DeviceCaps.h b/Graphics/GraphicsEngine/interface/DeviceCaps.h index b4e00081..496f3599 100644 --- a/Graphics/GraphicsEngine/interface/DeviceCaps.h +++ b/Graphics/GraphicsEngine/interface/DeviceCaps.h @@ -129,5 +129,44 @@ namespace Diligent { return DevType == DeviceType::Vulkan; } + + struct NDCAttribs + { + const float MinZ; // Minimum z value of normalized device coordinate space + const float ZtoDepthScale; // NDC z to depth scale + const float YtoVScale; // Scale to transform NDC y coordinate to texture V coordinate + + float GetZtoDepthBias() const + { + // Returns ZtoDepthBias such that given NDC z coordinate, depth value can be + // computed as follows: + // d = z * ZtoDepthScale + ZtoDepthBias + return -MinZ * ZtoDepthScale; + } + }; + + const NDCAttribs& GetNDCAttribs()const + { + if (IsVulkanDevice()) + { + static constexpr const NDCAttribs NDCAttribsVk {0.0f, 1.0f, 0.5f}; + return NDCAttribsVk; + } + else if (IsD3DDevice()) + { + static constexpr const NDCAttribs NDCAttribsD3D {0.0f, 1.0f, -0.5f}; + return NDCAttribsD3D; + } + else if (IsGLDevice()) + { + static constexpr const NDCAttribs NDCAttribsGL {-1.0f, 0.5f, 0.5f}; + return NDCAttribsGL; + } + else + { + static constexpr const NDCAttribs NDCAttribsDefault {0.0f, 1.0f, 0.5f}; + return NDCAttribsDefault; + } + } }; } |
