RSX texture refactor (#2144)

This commit is contained in:
raven02 2016-09-19 09:25:49 +08:00 committed by GitHub
parent 530ea688e4
commit 77f8ce503d
12 changed files with 62 additions and 62 deletions

View file

@ -6,7 +6,7 @@
namespace rsx
{
void texture::init()
void fragment_texture::init()
{
// Offset
registers[NV4097_SET_TEXTURE_OFFSET + (m_index * 8)] = 0;
@ -38,32 +38,32 @@ namespace rsx
registers[NV4097_SET_TEXTURE_BORDER_COLOR + (m_index * 8)] = 0;
}
u32 texture::offset() const
u32 fragment_texture::offset() const
{
return registers[NV4097_SET_TEXTURE_OFFSET + (m_index * 8)];
}
u8 texture::location() const
u8 fragment_texture::location() const
{
return (registers[NV4097_SET_TEXTURE_FORMAT + (m_index * 8)] & 0x3) - 1;
}
bool texture::cubemap() const
bool fragment_texture::cubemap() const
{
return ((registers[NV4097_SET_TEXTURE_FORMAT + (m_index * 8)] >> 2) & 0x1);
}
u8 texture::border_type() const
u8 fragment_texture::border_type() const
{
return ((registers[NV4097_SET_TEXTURE_FORMAT + (m_index * 8)] >> 3) & 0x1);
}
rsx::texture_dimension texture::dimension() const
rsx::texture_dimension fragment_texture::dimension() const
{
return rsx::to_texture_dimension((registers[NV4097_SET_TEXTURE_FORMAT + (m_index * 8)] >> 4) & 0xf);
}
rsx::texture_dimension_extended texture::get_extended_texture_dimension() const
rsx::texture_dimension_extended fragment_texture::get_extended_texture_dimension() const
{
switch (dimension())
{
@ -75,12 +75,12 @@ namespace rsx
}
}
u8 texture::format() const
u8 fragment_texture::format() const
{
return ((registers[NV4097_SET_TEXTURE_FORMAT + (m_index * 8)] >> 8) & 0xff);
}
bool texture::is_compressed_format() const
bool fragment_texture::is_compressed_format() const
{
int texture_format = format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN);
if (texture_format == CELL_GCM_TEXTURE_COMPRESSED_DXT1 ||
@ -90,12 +90,12 @@ namespace rsx
return false;
}
u16 texture::mipmap() const
u16 fragment_texture::mipmap() const
{
return ((registers[NV4097_SET_TEXTURE_FORMAT + (m_index * 8)] >> 16) & 0xffff);
}
u16 texture::get_exact_mipmap_count() const
u16 fragment_texture::get_exact_mipmap_count() const
{
if (is_compressed_format())
{
@ -108,137 +108,137 @@ namespace rsx
return std::min(mipmap(), max_mipmap_count);
}
rsx::texture_wrap_mode texture::wrap_s() const
rsx::texture_wrap_mode fragment_texture::wrap_s() const
{
return rsx::to_texture_wrap_mode((registers[NV4097_SET_TEXTURE_ADDRESS + (m_index * 8)]) & 0xf);
}
rsx::texture_wrap_mode texture::wrap_t() const
rsx::texture_wrap_mode fragment_texture::wrap_t() const
{
return rsx::to_texture_wrap_mode((registers[NV4097_SET_TEXTURE_ADDRESS + (m_index * 8)] >> 8) & 0xf);
}
rsx::texture_wrap_mode texture::wrap_r() const
rsx::texture_wrap_mode fragment_texture::wrap_r() const
{
return rsx::to_texture_wrap_mode((registers[NV4097_SET_TEXTURE_ADDRESS + (m_index * 8)] >> 16) & 0xf);
}
u8 texture::unsigned_remap() const
u8 fragment_texture::unsigned_remap() const
{
return ((registers[NV4097_SET_TEXTURE_ADDRESS + (m_index * 8)] >> 12) & 0xf);
}
u8 texture::zfunc() const
u8 fragment_texture::zfunc() const
{
return ((registers[NV4097_SET_TEXTURE_ADDRESS + (m_index * 8)] >> 28) & 0xf);
}
u8 texture::gamma() const
u8 fragment_texture::gamma() const
{
return ((registers[NV4097_SET_TEXTURE_ADDRESS + (m_index * 8)] >> 20) & 0xf);
}
u8 texture::aniso_bias() const
u8 fragment_texture::aniso_bias() const
{
return ((registers[NV4097_SET_TEXTURE_ADDRESS + (m_index * 8)] >> 4) & 0xf);
}
u8 texture::signed_remap() const
u8 fragment_texture::signed_remap() const
{
return ((registers[NV4097_SET_TEXTURE_ADDRESS + (m_index * 8)] >> 24) & 0xf);
}
bool texture::enabled() const
bool fragment_texture::enabled() const
{
return location() <= 1 && ((registers[NV4097_SET_TEXTURE_CONTROL0 + (m_index * 8)] >> 31) & 0x1);
}
u16 texture::min_lod() const
u16 fragment_texture::min_lod() const
{
return ((registers[NV4097_SET_TEXTURE_CONTROL0 + (m_index * 8)] >> 19) & 0xfff);
}
u16 texture::max_lod() const
u16 fragment_texture::max_lod() const
{
return ((registers[NV4097_SET_TEXTURE_CONTROL0 + (m_index * 8)] >> 7) & 0xfff);
}
rsx::texture_max_anisotropy texture::max_aniso() const
rsx::texture_max_anisotropy fragment_texture::max_aniso() const
{
return rsx::to_texture_max_anisotropy((registers[NV4097_SET_TEXTURE_CONTROL0 + (m_index * 8)] >> 4) & 0x7);
}
bool texture::alpha_kill_enabled() const
bool fragment_texture::alpha_kill_enabled() const
{
return ((registers[NV4097_SET_TEXTURE_CONTROL0 + (m_index * 8)] >> 2) & 0x1);
}
u32 texture::remap() const
u32 fragment_texture::remap() const
{
return (registers[NV4097_SET_TEXTURE_CONTROL1 + (m_index * 8)]);
}
float texture::bias() const
float fragment_texture::bias() const
{
return float(f16((registers[NV4097_SET_TEXTURE_FILTER + (m_index * 8)]) & 0x1fff));
}
rsx::texture_minify_filter texture::min_filter() const
rsx::texture_minify_filter fragment_texture::min_filter() const
{
return rsx::to_texture_minify_filter((registers[NV4097_SET_TEXTURE_FILTER + (m_index * 8)] >> 16) & 0x7);
}
rsx::texture_magnify_filter texture::mag_filter() const
rsx::texture_magnify_filter fragment_texture::mag_filter() const
{
return rsx::to_texture_magnify_filter((registers[NV4097_SET_TEXTURE_FILTER + (m_index * 8)] >> 24) & 0x7);
}
u8 texture::convolution_filter() const
u8 fragment_texture::convolution_filter() const
{
return ((registers[NV4097_SET_TEXTURE_FILTER + (m_index * 8)] >> 13) & 0xf);
}
bool texture::a_signed() const
bool fragment_texture::a_signed() const
{
return ((registers[NV4097_SET_TEXTURE_FILTER + (m_index * 8)] >> 28) & 0x1);
}
bool texture::r_signed() const
bool fragment_texture::r_signed() const
{
return ((registers[NV4097_SET_TEXTURE_FILTER + (m_index * 8)] >> 29) & 0x1);
}
bool texture::g_signed() const
bool fragment_texture::g_signed() const
{
return ((registers[NV4097_SET_TEXTURE_FILTER + (m_index * 8)] >> 30) & 0x1);
}
bool texture::b_signed() const
bool fragment_texture::b_signed() const
{
return ((registers[NV4097_SET_TEXTURE_FILTER + (m_index * 8)] >> 31) & 0x1);
}
u16 texture::width() const
u16 fragment_texture::width() const
{
return ((registers[NV4097_SET_TEXTURE_IMAGE_RECT + (m_index * 8)] >> 16) & 0xffff);
}
u16 texture::height() const
u16 fragment_texture::height() const
{
return ((registers[NV4097_SET_TEXTURE_IMAGE_RECT + (m_index * 8)]) & 0xffff);
}
u32 texture::border_color() const
u32 fragment_texture::border_color() const
{
return registers[NV4097_SET_TEXTURE_BORDER_COLOR + (m_index * 8)];
}
u16 texture::depth() const
u16 fragment_texture::depth() const
{
return registers[NV4097_SET_TEXTURE_CONTROL3 + m_index] >> 20;
}
u32 texture::pitch() const
u32 fragment_texture::pitch() const
{
return registers[NV4097_SET_TEXTURE_CONTROL3 + m_index] & 0xfffff;
}