Implement glClearDepth

This commit is contained in:
Luke Benstead 2020-03-24 13:58:44 +00:00
parent 5c980d2183
commit 4292304df1
2 changed files with 12 additions and 7 deletions

View File

@ -1171,10 +1171,15 @@ GL_FORCE_INLINE void divide(SubmissionTarget* target) {
float f = MATH_fsrra(vertex->w * vertex->w);
vertex->xyz[0] *= f;
vertex->xyz[1] *= f;
vertex->xyz[2] = f;
/* Scale depending on glDepthRange */
vertex->xyz[2] = 1.0f - ((DEPTH_RANGE_MULTIPLIER_L * vertex->xyz[2] * f) + DEPTH_RANGE_MULTIPLIER_H);
/* FIXME: Consider taking glDepthRange into account. PVR is designed to use invW rather
* than Z which is unlike most GPUs - this apparently provides advantages.
*
* This can be done (if Z is between -1 and 1) with:
*
* //((DEPTH_RANGE_MULTIPLIER_L * vertex->xyz[2] * f) + DEPTH_RANGE_MULTIPLIER_H);
*/
++vertex;
}
}

View File

@ -274,6 +274,7 @@ void _glInitContext() {
GL_CONTEXT.fmt.uv = PVR_UVFMT_32BIT;
GL_CONTEXT.gen.color_clamp = PVR_CLRCLAMP_DISABLE;
glClearDepth(1.0f);
glDepthFunc(GL_LESS);
glDepthMask(GL_TRUE);
glFrontFace(GL_CCW);
@ -439,13 +440,12 @@ GLAPI void APIENTRY glClearColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
/* Depth Testing */
GLAPI void APIENTRY glClearDepthf(GLfloat depth) {
_GL_UNUSED(depth);
glClearDepth(depth);
}
GLAPI void APIENTRY glClearDepth(GLfloat depth) {
_GL_UNUSED(depth);
/* We reverse because using invW means that farther Z == lower number */
pvr_set_zclip(1.0f - depth);
}
GLAPI void APIENTRY glDrawBuffer(GLenum mode) {