summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-07-04 23:48:36 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-07-04 23:48:36 +0000
commit636f2b9d2b579c767c5ae7c8c5ddf1fd02de0b0a (patch)
treeb415eda2652e545284b0404966d61ea30d042304 /Graphics/GraphicsEngine
parentCorrected depth-related GLSL definitions for Vulkan case (diff)
downloadDiligentCore-636f2b9d2b579c767c5ae7c8c5ddf1fd02de0b0a.tar.gz
DiligentCore-636f2b9d2b579c767c5ae7c8c5ddf1fd02de0b0a.zip
Added NDC attribs data to DeviceCaps structure
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/interface/DeviceCaps.h39
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;
+ }
+ }
};
}