Skip to content

Commit b30a44c

Browse files
committed
rsx: Make BX2 flag respect constant overrides
1 parent 8a1b323 commit b30a44c

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

rpcs3/Emu/RSX/Program/GLSLSnippets/RSXProg/RSXFragmentTextureOps.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ R"(
3434
#define _enable_texture_expand(index) \
3535
do { \
3636
if (_test_bit(TEX_PARAM(index).flags, FORMAT_FEATURE_BIASED_RENORMALIZATION_BIT)) { \
37-
_texture_flag_override = SIGN_EXPAND_MASK; \
37+
_texture_flag_override = SIGN_EXPAND_MASK & (_get_bits(TEX_PARAM(index).remap, 16, 4) << EXPAND_A_BIT); \
3838
_texture_flag_erase = GAMMA_CTRL_MASK; \
3939
_texture_bx2_active = true; \
4040
} \

rpcs3/Emu/RSX/RSXThread.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,15 +2366,19 @@ namespace rsx
23662366

23672367
if (format_features & RSX_FORMAT_FEATURE_GAMMA_CORRECTION)
23682368
{
2369-
// Tests show this is applied post-readout. It's a property of the final value stored in the register and is not remapped. It overwrites even constant channels (REMAP_ZERO | REMAP_ONE)
2369+
// Tests show this is applied post-readout. It's a property of the final value stored in the register and is not remapped.
2370+
// NOTE: GAMMA correction has no algorithmic effect on constants (0 and 1) so we need not mask it out for correctness.
23702371
gamma = tex.gamma() & ~(argb8_signed);
23712372
}
23722373

23732374
if (format_features & RSX_FORMAT_FEATURE_BIASED_NORMALIZATION)
23742375
{
23752376
// The renormalization flag applies to all channels. It is weaker than the other flags.
2376-
unsigned_remap = (tex.unsigned_remap() == CELL_GCM_TEXTURE_UNSIGNED_REMAP_NORMAL) ? 0u : 0xF;
2377-
unsigned_remap &= ~(argb8_signed | gamma);
2377+
// This applies on input and is subject to remap overrides
2378+
if (tex.unsigned_remap() == CELL_GCM_TEXTURE_UNSIGNED_REMAP_BIASED)
2379+
{
2380+
unsigned_remap = remap_channel_bits(texture_remap, 0xF) & ~(argb8_signed | gamma);
2381+
}
23782382
}
23792383

23802384
u32 argb8_convert = gamma;
@@ -2390,6 +2394,13 @@ namespace rsx
23902394
texture_control |= argb8_convert;
23912395

23922396
texture_control |= format_features << texture_control_bits::FORMAT_FEATURES_OFFSET;
2397+
2398+
if (current_fp_metadata.has_tex_bx2_conv)
2399+
{
2400+
const u32 remap_hi = remap_channel_bits(texture_remap, 0xFu);
2401+
current_fragment_program.texture_params[i].remap &= ~(0xFu << 16u);
2402+
current_fragment_program.texture_params[i].remap |= (remap_hi << 16u);
2403+
}
23932404
}
23942405

23952406
current_fragment_program.texture_params[i].control = texture_control;

0 commit comments

Comments
 (0)