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

[dxso] Respect all PS input elements for registers #3471

Merged
merged 1 commit into from
Jun 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/dxso/dxso_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3229,6 +3229,21 @@ void DxsoCompiler::emitControlFlowGenericLoop(
if (mask.popCount() == 0)
mask = DxsoRegMask(true, true, true, true);

// Pixel shaders seem to load every element (or every element exported by VS)
// regardless of the mask in the DCL used.
//
// I imagine this is because at one point D3D9 ASM was very literal to GPUs,
// and the input's mask from the PS didn't correspond to anything and the
// physical output register was filled with the extra data from the VS not
// included in the mask on the PS, so it just worked(tm).
//
// Fixes a bug in Test Drive Unlimited's shadow code where it outputs o8.xyz, but the PS
// has a decl for v8.xy and it tries to do 2D Shadow sampling (needs 3 elements .xyz) in the PS.
// This likely occured because the compiler was not aware of shadow sampling when generating
// the writemask for the PS.
if (m_programInfo.type() == DxsoProgramType::PixelShader)
mask = DxsoRegMask(true, true, true, true);

std::array<uint32_t, 4> indices = { 0, 1, 2, 3 };
uint32_t count = 0;
for (uint32_t i = 0; i < 4; i++) {
Expand Down