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

Reinterpret framebuffer formats as needed. Outrun reflections partial fix #13636

Merged
merged 9 commits into from
Nov 8, 2020

Conversation

hrydgard
Copy link
Owner

@hrydgard hrydgard commented Nov 7, 2020

PSP games sometimes render to a framebuffer in one format, then keeps rendering using another format. For example, like Outrun, you can render to the alpha channel of an RGBA4444 texture by switching it to RGB565, rendering to the B channel with a 11110 mask, and then switching back. We don't internally store textures in these low bit depths, we always use 8888 for a variety of reasons, so when switching formats, this shader converts the color to the corresponding old 16-bit format, and converts back to 8888 from that using the new 16-bit format. This can be a minor speed it but should indeed be minor.

First step towards fixing car reflections in Outrun: Coast to Coast. See #11358 .

This also deletes the recent mistakenly added early version of this, ColorReinterpret.cpp/h.

This makes use of a lot of the infrastructure I've added or refactored recently... the new ShaderWriter etc.

I'm a little afraid of performance regressions so I'll enable this for all games later, so far restricting it to Outrun.

NOTE! Doesn't fully fix it, there's still some blue/yellow color distortion in the reflections. That will be fixed separately later - the color bitmasking part has still not been implemented so the write to alpha also stomps the top bit of the blue channel. See my comment in #11358 about that. Here's how it looks now (from a good angle):

ULES00262_00010

It's at least better than before:

ULES00262_00011

@hrydgard hrydgard added the GE emulation Backend-independent GPU issues label Nov 7, 2020
@hrydgard hrydgard added this to the v1.11.0 milestone Nov 7, 2020
@hrydgard hrydgard changed the title Reinterpret framebuffer formats on switch. Reinterpret framebuffer formats as needed Nov 7, 2020
@hrydgard hrydgard changed the title Reinterpret framebuffer formats as needed Reinterpret framebuffer formats as needed. Outrun reflections partial fix Nov 7, 2020
@hrydgard hrydgard force-pushed the reinterpret-framebuffer-formats branch from 5dd67fd to 18d4bfa Compare November 7, 2020 23:12
};

// TODO: We could have an option to preserve any extra color precision. But gonna start without it.
// Requires full size integer math.
Copy link
Contributor

@aliaspider aliaspider Nov 8, 2020

Choose a reason for hiding this comment

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

you could double the widths of the channels (10-12-10 instead of 5-6-5 etc.), although not sure if it is worth it ...
Edit: nvm, it wouldn't work out xD

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yeah let's think more about this. I feel that it should be possible somehow but...

More work on reinterpret

Buildsystem fixes
@hrydgard hrydgard force-pushed the reinterpret-framebuffer-formats branch from 18d4bfa to 2cb78e5 Compare November 8, 2020 09:52
@@ -983,6 +989,8 @@ Pipeline *D3D11DrawContext::CreateGraphicsPipeline(const PipelineDesc &desc) {
std::vector<D3D11ShaderModule *> shaders;
D3D11ShaderModule *vshader = nullptr;
for (auto iter : desc.shaders) {
iter->AddRef();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, seems like we'd need a Release() for this in the destructor of the pipeline?

-[Unknown]

Copy link
Owner Author

Choose a reason for hiding this comment

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

That is right! Thanks for the catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GE emulation Backend-independent GPU issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants