Skip to content

Commit

Permalink
rsx/fp: Improvements
Browse files Browse the repository at this point in the history
- Export some debug information in the free texture register space components zw
  Very useful when analysing renderdoc captures
- Enable shadow comparison on depth as long as compare function is active and texture is uploaded for depth read
  Some engines (UE3) read all the components in the shader and use mul/mad with the result
  • Loading branch information
kd-11 committed Mar 25, 2018
1 parent 5817f9f commit 2755289
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
8 changes: 4 additions & 4 deletions rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,10 +644,10 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode)
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE1D));
return true;
case rsx::texture_dimension_extended::texture_dimension_2d:
if (DstExpectsSca() && (m_prog.shadow_textures & (1 << dst.tex_num)))
if (m_prog.shadow_textures & (1 << dst.tex_num))
{
m_shadow_sampled_textures |= (1 << dst.tex_num);
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SHADOW2D) + ".r", false); //No swizzle mask on shadow lookup
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SHADOW2D) + ".xxxx");
return true;
}
if (m_prog.redirected_textures & (1 << dst.tex_num))
Expand Down Expand Up @@ -676,10 +676,10 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode)
return true;
case rsx::texture_dimension_extended::texture_dimension_2d:
//Note shadow comparison only returns a true/false result!
if (DstExpectsSca() && (m_prog.shadow_textures & (1 << dst.tex_num)))
if (m_prog.shadow_textures & (1 << dst.tex_num))
{
m_shadow_sampled_textures |= (1 << dst.tex_num);
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SHADOW2D_PROJ) + ".r", false); //No swizzle mask on shadow lookup
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SHADOW2D_PROJ) + ".xxxx");
}
else
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_PROJ));
Expand Down
7 changes: 4 additions & 3 deletions rpcs3/Emu/RSX/Common/ProgramStateCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,10 @@ class program_state_cache
}
else if (sanitize)
{
//Lower NaNs to 0
const auto mask = _mm_cmpunord_ps((__m128&)shuffled_vector, _mm_set1_ps(1.f));
const auto result = _mm_andnot_ps(mask, (__m128&)shuffled_vector);
//Convert NaNs and Infs to 0
const auto masked = _mm_and_si128((__m128i&)shuffled_vector, _mm_set1_epi32(0x7fffffff));
const auto valid = _mm_cmplt_epi32(masked, _mm_set1_epi32(0x7f800000));
const auto result = _mm_and_si128((__m128i&)shuffled_vector, valid);
_mm_stream_si128((__m128i*)dst, (__m128i&)result);
}
else
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/Emu/RSX/RSXThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,8 @@ namespace rsx
auto &tex = rsx::method_registers.fragment_textures[i];
result.texture_scale[i][0] = sampler_descriptors[i]->scale_x;
result.texture_scale[i][1] = sampler_descriptors[i]->scale_y;
result.texture_scale[i][2] = (f32)tex.remap(); //Debug value
result.texture_scale[i][3] = (f32)tex.format(); //Debug value
result.textures_alpha_kill[i] = 0;
result.textures_zfunc[i] = 0;

Expand Down

0 comments on commit 2755289

Please sign in to comment.