mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-08 16:01:42 +12:00
rsx: Refactor shader codegen and fix shadow sampling on depth-float
This commit is contained in:
parent
d9cb1a6319
commit
bee76fc8d1
6 changed files with 1059 additions and 986 deletions
|
@ -4,6 +4,7 @@
|
|||
#include "Emu/Cell/PPUCallback.h"
|
||||
|
||||
#include "Common/BufferUtils.h"
|
||||
#include "Common/GLSLCommon.h"
|
||||
#include "Common/texture_cache.h"
|
||||
#include "Common/surface_store.h"
|
||||
#include "Capture/rsx_capture.h"
|
||||
|
@ -1853,7 +1854,7 @@ namespace rsx
|
|||
if (tex.alpha_kill_enabled())
|
||||
{
|
||||
//alphakill can be ignored unless a valid comparison function is set
|
||||
texture_control |= (1 << 4);
|
||||
texture_control |= (1 << texture_control_bits::ALPHAKILL);
|
||||
}
|
||||
|
||||
const u32 texaddr = rsx::get_address(tex.offset(), tex.location());
|
||||
|
@ -1865,37 +1866,34 @@ namespace rsx
|
|||
|
||||
if (sampler_descriptors[i]->format_class != RSX_FORMAT_CLASS_COLOR)
|
||||
{
|
||||
switch (format)
|
||||
switch (sampler_descriptors[i]->format_class)
|
||||
{
|
||||
case CELL_GCM_TEXTURE_X16:
|
||||
{
|
||||
// A simple way to quickly read DEPTH16 data without shadow comparison
|
||||
case RSX_FORMAT_CLASS_DEPTH16_FLOAT:
|
||||
case RSX_FORMAT_CLASS_DEPTH24_FLOAT_X8_PACK32:
|
||||
texture_control |= (1 << texture_control_bits::DEPTH_FLOAT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case CELL_GCM_TEXTURE_A8R8G8B8:
|
||||
case CELL_GCM_TEXTURE_D8R8G8B8:
|
||||
{
|
||||
// Reading depth data as XRGB8 is supported with in-shader conversion
|
||||
// TODO: Optionally add support for 16-bit formats (not necessary since type casts are easy with that)
|
||||
u32 control_bits = sampler_descriptors[i]->format_class == RSX_FORMAT_CLASS_DEPTH24_FLOAT_X8_PACK32? (1u << 16) : 0u;
|
||||
control_bits |= tex.remap() & 0xFFFF;
|
||||
// Emulate bitcast in shader
|
||||
current_fragment_program.redirected_textures |= (1 << i);
|
||||
current_fragment_program.texture_scale[i][2] = std::bit_cast<f32>(control_bits);
|
||||
const auto float_en = (sampler_descriptors[i]->format_class == RSX_FORMAT_CLASS_DEPTH24_FLOAT_X8_PACK32)? 1 : 0;
|
||||
texture_control |= (float_en << texture_control_bits::DEPTH_FLOAT);
|
||||
break;
|
||||
}
|
||||
case CELL_GCM_TEXTURE_X16: // A simple way to quickly read DEPTH16 data without shadow comparison
|
||||
case CELL_GCM_TEXTURE_DEPTH16:
|
||||
case CELL_GCM_TEXTURE_DEPTH16_FLOAT:
|
||||
case CELL_GCM_TEXTURE_DEPTH24_D8:
|
||||
case CELL_GCM_TEXTURE_DEPTH16_FLOAT:
|
||||
case CELL_GCM_TEXTURE_DEPTH24_D8_FLOAT:
|
||||
{
|
||||
const auto compare_mode = tex.zfunc();
|
||||
if (!tex.alpha_kill_enabled() &&
|
||||
compare_mode < rsx::comparison_function::always &&
|
||||
compare_mode > rsx::comparison_function::never)
|
||||
{
|
||||
current_fragment_program.shadow_textures |= (1 << i);
|
||||
texture_control |= u32(tex.zfunc()) << 8;
|
||||
}
|
||||
// Supported formats, nothing to do
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -1912,7 +1910,7 @@ namespace rsx
|
|||
case CELL_GCM_TEXTURE_R5G5B5A1:
|
||||
case CELL_GCM_TEXTURE_R5G6B5:
|
||||
case CELL_GCM_TEXTURE_R6G5B5:
|
||||
texture_control |= (1 << 5);
|
||||
texture_control |= (1 << texture_control_bits::RENORMALIZE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -1932,14 +1930,14 @@ namespace rsx
|
|||
const auto remap_ctrl = (tex.remap() >> 8) & 0xAA;
|
||||
if (remap_ctrl == 0xAA)
|
||||
{
|
||||
argb8_convert |= (sign_convert & 0xFu) << 6;
|
||||
argb8_convert |= (sign_convert & 0xFu) << texture_control_bits::EXPAND_OFFSET;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (remap_ctrl & 0x03) argb8_convert |= (sign_convert & 0x1u) << 6;
|
||||
if (remap_ctrl & 0x0C) argb8_convert |= (sign_convert & 0x2u) << 6;
|
||||
if (remap_ctrl & 0x30) argb8_convert |= (sign_convert & 0x4u) << 6;
|
||||
if (remap_ctrl & 0xC0) argb8_convert |= (sign_convert & 0x8u) << 6;
|
||||
if (remap_ctrl & 0x03) argb8_convert |= (sign_convert & 0x1u) << texture_control_bits::EXPAND_OFFSET;
|
||||
if (remap_ctrl & 0x0C) argb8_convert |= (sign_convert & 0x2u) << texture_control_bits::EXPAND_OFFSET;
|
||||
if (remap_ctrl & 0x30) argb8_convert |= (sign_convert & 0x4u) << texture_control_bits::EXPAND_OFFSET;
|
||||
if (remap_ctrl & 0xC0) argb8_convert |= (sign_convert & 0x8u) << texture_control_bits::EXPAND_OFFSET;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue