OpenGL fix

This commit is contained in:
Henrik Rydgård committed 2022-08-01 11:57:22 +02:00
1 parent 655cadc281
commit 73fc9fb520
3 files changed
+12 -3

No files matched your search

+3 -1
View File
@@ -1051,8 +1051,10 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
}
if (colorToDepth) {
DepthScaleFactors factors = GetDepthScaleFactors();
WRITE(p, " highp float depthValue = float(uint(%s.x * 32.0) | (uint(%s.y * 64.0) << 5) | (uint(%s.z * 32.0) << 11)) / 65535.0;\n", "v", "v", "v"); // compat.fragColor0, compat.fragColor0, compat.fragColor0);
WRITE(p, " gl_FragDepth = depthValue;\n"); // TODO: Don't forget to apply accurate-depth kind of stuff
WRITE(p, " gl_FragDepth = (depthValue / %f) - %f;\n", factors.scale / 65535.0f, factors.offset);
}
if (gstate_c.Supports(GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT)) {
+4 -1
View File
@@ -81,7 +81,6 @@ struct ViewportAndScissor {
void ConvertViewportAndScissor(bool useBufferedRendering, float renderWidth, float renderHeight, int bufferWidth, int bufferHeight, ViewportAndScissor &out);
float ToScaledDepthFromIntegerScale(float z);
// Use like this: (z - offset) * scale
struct DepthScaleFactors {
float offset;
float scale;
@@ -89,6 +88,10 @@ struct DepthScaleFactors {
float Apply(float z) const {
return (z - offset) * scale;
}
float ApplyInverse(float z) const {
return (z / scale) + offset;
}
};
DepthScaleFactors GetDepthScaleFactors();
+5 -1
View File
@@ -250,7 +250,11 @@ void DrawEngineGLES::ApplyDrawState(int prim) {
GenericStencilFuncState stencilState;
ConvertStencilFuncState(stencilState);
if (gstate.isModeClear()) {
if (gstate_c.renderMode == FB_MODE_COLOR_TO_DEPTH) {
// Enforce plain depth writing.
renderManager->SetStencilDisabled();
renderManager->SetDepth(true, true, GL_ALWAYS);
} else if (gstate.isModeClear()) {
// Depth Test
if (gstate.isClearModeDepthMask()) {
framebufferManager_->SetDepthUpdated();