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

[pull] main from microsoft:main #19

Merged
merged 4 commits into from
Feb 15, 2024
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
40 changes: 33 additions & 7 deletions ShaderConverter/ShaderConv/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1506,23 +1506,49 @@ void
CContext::Translate_RCP( const CInstr& instr )
{
// div dest, vec4( 1.0f ), src0
// movc dest, src0, dest, src0

const COperandBase dest = instr.CreateDstOperand();
const COperandBase src0 = this->EmitSrcOperand( instr, 0 );
const DWORD dwToken = instr.GetSrcToken( 0 );
const DWORD dwModifier = ( dwToken & D3DSP_SRCMOD_MASK );

this->EmitDstInstruction( instr.GetModifiers(),
D3D10_SB_OPCODE_DIV,
dest,
COperand( 1.0f ),
src0 );

this->EmitDstInstruction(instr.GetModifiers(),
D3D10_SB_OPCODE_MOVC,
dest,
src0,
dest,
src0 );
// movc doesn't allow modifiers on the comparison param, so if src0 has modifiers we need to apply those and mov into a temp register
// note that according to spec, rcp can only act on scalar values, so we just mov into r0.z
if ( dwModifier != D3DSPSM_NONE )
{
// mov r0.z, src0
// movc dest, r0.z, dest, src0


m_pShaderAsm->EmitInstruction(
CInstruction( D3D10_SB_OPCODE_MOV,
CTempOperandDst( SREG_TMP0, D3D10_SB_OPERAND_4_COMPONENT_MASK_Z ),
src0 ) );

this->EmitDstInstruction( instr.GetModifiers(),
D3D10_SB_OPCODE_MOVC,
dest,
CTempOperand4( SREG_TMP0, __SWIZZLE_Z ),
dest,
src0 );
}
else
{
// movc dest, src0, dest, src0

this->EmitDstInstruction( instr.GetModifiers(),
D3D10_SB_OPCODE_MOVC,
dest,
src0,
dest,
src0 );
}
}

///---------------------------------------------------------------------------
Expand Down
Loading