Fix some y-flip issues in D3D11. It got broken by recent refactorings.

Fixes #21726
This commit is contained in:
Henrik Rydgård committed 2026-05-26 15:51:24 +02:00
1 parent b8a71e8712
commit 06a7793f57
5 files changed
+6 -24

No files matched your search

+1
View File
@@ -275,6 +275,7 @@ bool TranslateShader(std::string *dest, ShaderLanguage destLang, const ShaderLan
spirv_cross::CompilerHLSL::Options options{};
options.shader_model = 50;
spirv_cross::CompilerGLSL::Options options_common{};
options_common.vertex.flip_vert_y = true;
options_common.vertex.fixup_clipspace = true;
hlsl.set_hlsl_options(options);
hlsl.set_common_options(options_common);
-8
View File
@@ -1551,10 +1551,6 @@ bool FramebufferManagerCommon::DrawFramebufferToOutput(const DisplayLayoutConfig
if (needBackBufferYSwap_) {
flags |= OutputFlags::BACKBUFFER_FLIPPED;
}
// CopyToOutput reverses these, probably to match "up".
if (GetGPUBackend() == GPUBackend::DIRECT3D11) {
flags |= OutputFlags::POSITION_FLIPPED;
}
constexpr float u0 = 0.0f, u1 = 480.0f / 512.0f;
constexpr float v0 = 0.0f, v1 = 1.0f;
@@ -1725,10 +1721,6 @@ void FramebufferManagerCommon::PrepareCopyDisplayToOutput(const DisplayLayoutCon
if (needBackBufferYSwap_) {
flags |= OutputFlags::BACKBUFFER_FLIPPED;
}
// DrawActiveTexture reverses these, probably to match "up".
if (GetGPUBackend() == GPUBackend::DIRECT3D11) {
flags |= OutputFlags::POSITION_FLIPPED;
}
int actualWidth = (vfb->bufferWidth * vfb->renderWidth) / vfb->width;
int actualHeight = (vfb->bufferHeight * vfb->renderHeight) / vfb->height;
+4 -7
View File
@@ -745,7 +745,7 @@ void PresentationCommon::RunPostshaderPasses(const DisplayLayoutConfig &config,
}
// If we flipped, we rotate the other way.
if ((flags & OutputFlags::BACKBUFFER_FLIPPED) || (flags & OutputFlags::POSITION_FLIPPED)) {
if ((flags & OutputFlags::BACKBUFFER_FLIPPED)) {
if ((rotation & 1) != 0)
rotation ^= 2;
}
@@ -784,7 +784,7 @@ void PresentationCommon::RunPostshaderPasses(const DisplayLayoutConfig &config,
}
// Finally, we compensate the y vertex positions for the backbuffer for any flipping.
if ((flags & OutputFlags::POSITION_FLIPPED) || (flags & OutputFlags::BACKBUFFER_FLIPPED)) {
if (flags & OutputFlags::BACKBUFFER_FLIPPED) {
for (int i = 0; i < 4; i++) {
verts[i].y = -verts[i].y;
}
@@ -831,11 +831,8 @@ void PresentationCommon::RunPostshaderPasses(const DisplayLayoutConfig &config,
if (usePostShader) {
// When we render to temp framebuffers during post, we switch position, not UV.
// The flipping here is only because D3D has a clip coordinate system that doesn't match their screen coordinate system.
// The flipping here is only because D3D has a clip coordinate system that doesn't match their screen coordinate system.
bool flipped = flags & OutputFlags::POSITION_FLIPPED;
float y0 = flipped ? 1.0f : -1.0f;
float y1 = flipped ? -1.0f : 1.0f;
float y0 = -1.0f;
float y1 = 1.0f;
verts[4] = {-1.0f, y0, 0.0f, 0.0f, 0.0f, 0xFFFFFFFF}; // TL
verts[5] = {1.0f, y0, 0.0f, 1.0f, 0.0f, 0xFFFFFFFF}; // TR
verts[6] = {-1.0f, y1, 0.0f, 0.0f, 1.0f, 0xFFFFFFFF}; // BL
-1
View File
@@ -74,7 +74,6 @@ enum class OutputFlags {
NEAREST = 0x0001,
RB_SWIZZLE = 0x0002,
BACKBUFFER_FLIPPED = 0x0004, // Viewport/scissor coordinates are y-flipped.
POSITION_FLIPPED = 0x0008, // Vertex position in the shader is y-flipped relative to the screen.
PILLARBOX = 0x0010, // Squeeze the image horizontally. Used for the DarkStalkers hack.
};
ENUM_CLASS_BITOPS(OutputFlags);
+1 -8
View File
@@ -630,15 +630,8 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(const DisplayLayoutConfig &config,
fbTex = draw_->CreateTexture(desc);
switch (GetGPUBackend()) {
case GPUBackend::OPENGL:
if (GetGPUBackend() == GPUBackend::OPENGL) {
outputFlags |= OutputFlags::BACKBUFFER_FLIPPED;
break;
case GPUBackend::DIRECT3D11:
outputFlags |= OutputFlags::POSITION_FLIPPED;
break;
case GPUBackend::VULKAN:
break;
}
presentation_->SourceTexture(fbTex, desc.width, desc.height);