diff options
author | Samuel Rødal <sroedal@trolltech.com> | 2009-09-01 09:55:13 +0200 |
---|---|---|
committer | Samuel Rødal <sroedal@trolltech.com> | 2009-09-01 10:56:23 +0200 |
commit | efe61b3b44c0c391d4c11bd061e531f03bf8fb4a (patch) | |
tree | cf03410fd0031a617b23f645a27d953520b1cbf1 /src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h | |
parent | a985aaccfcaf2e24b7094875f2e6f51d80c45997 (diff) |
Fixed poor utilization of depth buffer range in GL 2 paint engine.
Before this patch we were only able to do 20 or so IntersectClips before
failing, this patch instead adapts to the fixed point nature of typical
depth buffer implementations and lets us do ~2^15 IntersectClip
operations before failing, which should be a reasonable limit for any
real-world application.
Using the following mapping of old floating point depths to integer
depths:
-1.0 -> 0, -0.5 -> 1,
0.0 -> 2, 0.25 -> 3,
0.5 -> 4, 0.625 -> 5,
etc..
Reviewed-by: Tom
Diffstat (limited to 'src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h')
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 58fcde1df8..552e390626 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -82,8 +82,8 @@ public: bool depthTestEnabled; bool scissorTestEnabled; - qreal currentDepth; - qreal maxDepth; + uint maxDepth; + uint currentDepth; bool canRestoreClip; QRect rectangleClip; @@ -230,13 +230,26 @@ public: QGLEngineShaderManager* shaderManager; - void writeClip(const QVectorPath &path, float depth); + void writeClip(const QVectorPath &path, uint depth); void updateDepthScissorTest(); void setScissor(const QRect &rect); void regenerateDepthClip(); void systemStateChanged(); uint use_system_clip : 1; + static inline GLfloat rawDepth(uint depth) + { + // assume at least 16 bits in the depth buffer, and + // use 2^15 depth levels to be safe with regard to + // rounding issues etc + return depth * (1.0f / GLfloat((1 << 15) - 1)); + } + + static inline GLfloat normalizedDeviceDepth(uint depth) + { + return 2.0f * rawDepth(depth) - 1.0f; + } + uint location(QGLEngineShaderManager::Uniform uniform) { return shaderManager->getUniformLocation(uniform); |