Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Implement mipmap slope/const using a shader constant. #10376

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hrydgard
Copy link
Owner

@hrydgard hrydgard commented Dec 8, 2017

Fixes the mipmap test completely in GLES3, D3D11, Vulkan without having to resort to bias hacks and range clamping.

However, we're obviously missing something because Tony Hawk is blurry, and some other games seem to choose too high a mipmap level (GTA). Really not sure it's a good idea to merge this, or what to do with it really... Might take part of it (resolution-dependent mip bias) and merge separately...

so for now, DO NOT MERGE

…modes. Fixes the mipmap test for D3D11, Vulkan and modern GL properly, while keeping Tony Hawk games working.

Also implements increasing the lod level with the render resolution
properly.
@@ -477,6 +477,8 @@ enum {
GPU_SUPPORTS_VERTEX_TEXTURE_FETCH = FLAG_BIT(11),
GPU_SUPPORTS_TEXTURE_FLOAT = FLAG_BIT(12),
GPU_SUPPORTS_16BIT_FORMATS = FLAG_BIT(13),
GPU_SUPPORTS_EXPLICIT_LOD = FLAG_BIT(14),
// 2 free bits!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one now right?

-[Unknown]

Copy link
Collaborator

@unknownbrackets unknownbrackets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you skip slope, does it still affect GTA (in other words, is GTA even using slope?)

I'm a little confused on the resolution bias. I'll add to the other issue, though.

-[Unknown]

@@ -1315,14 +1315,20 @@ void GPUCommon::Execute_End(u32 op, u32 diff) {
}

void GPUCommon::Execute_TexLevel(u32 op, u32 diff) {
if (diff == 0xFFFFFFFF) return;

if (diff == 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that already what FLAG_EXECUTEONCHANGE does?

-[Unknown]

@@ -586,6 +587,31 @@ void LinkedShader::UpdateUniforms(u32 vertType, const VShaderID &vsid) {
if (dirty & DIRTY_STENCILREPLACEVALUE) {
glUniform1f(u_stencilReplaceValue, (float)gstate.getStencilTestRef() * (1.0f / 255.0f));
}

if ((dirty & DIRTY_TEXLOD) && gstate_c.Supports(GPU_SUPPORTS_EXPLICIT_LOD) && u_texlod) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't uniformMask handle the u_texlod (and ideally GPU_SUPPORTS_EXPLICIT_LOD)? Also, isn't -1 the invalid value?

-[Unknown]

// We can't support more than 8 bits of frac, so truncate.
int useful = (f.u >> 15) & 0xFFFF;
// Now offset so the exponent aligns with log2f (exp=127 is 0.)
return (float)(useful - 127 * 256) * (1.0f / 256.0f);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just define this in terms of TexLog2 to avoid repeating code?

-[Unknown]

@@ -61,7 +61,7 @@
#include "Windows/GPU/WindowsVulkanContext.h"

#ifdef _DEBUG
static const bool g_validate_ = true;
static const bool g_validate_ = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debugging.

-[Unknown]

@@ -27,7 +27,7 @@
PPSSPP_EXE = None
TEST_ROOT = "pspautotests/tests/"
teamcity_mode = False
TIMEOUT = 5
TIMEOUT = 500
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debugging, I assume?

-[Unknown]

float lod = 0.0;
switch (gstate.getTexLevelMode()) {
case GE_TEXLEVEL_MODE_CONST: {
float scaleLog = TexLog2F((float)gstate_c.curRTScale);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this assumes that all mip levels contain the same image, just scaled, right? I guess we haven't heard it manually detected by anyone, so maybe it's true. Unless some game accidentally specifies black or something dumb for some level that never happened so was never noticed.

-[Unknown]

@@ -86,6 +86,7 @@ enum {
FS_BIT_BLENDFUNC_B = 42, // 4 bits
FS_BIT_FLATSHADE = 46,
FS_BIT_BGRA_TEXTURE = 47,
FS_BIT_TEXLOD = 48,
// 48+ are free.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*49.

-[Unknown]

@ghost
Copy link

ghost commented Sep 9, 2021

This PR and #14789 is not related?

@hrydgard
Copy link
Owner Author

hrydgard commented Sep 9, 2021

This PR kinda failed by not solving the problems it was supposed to. Auto Max Quality just sidesteps the problem entirely instead by doing what makes sense on modern hardware and achieves better quality, so will probably not bother with working more on this anytime soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants