mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-09 00:11:24 +12:00
RSX texture refactor (#2144)
This commit is contained in:
parent
530ea688e4
commit
77f8ce503d
12 changed files with 62 additions and 62 deletions
|
@ -188,7 +188,7 @@ std::vector<rsx_subresource_layout> get_subresources_layout_impl(const RsxTextur
|
|||
fmt::throw_exception("Wrong format 0x%x" HERE, format);
|
||||
}
|
||||
|
||||
std::vector<rsx_subresource_layout> get_subresources_layout(const rsx::texture &texture)
|
||||
std::vector<rsx_subresource_layout> get_subresources_layout(const rsx::fragment_texture &texture)
|
||||
{
|
||||
return get_subresources_layout_impl(texture);
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ static size_t get_placed_texture_storage_size(u16 width, u16 height, u32 depth,
|
|||
return result * (cubemap ? 6 : 1);
|
||||
}
|
||||
|
||||
size_t get_placed_texture_storage_size(const rsx::texture &texture, size_t row_pitch_alignement, size_t mipmap_alignment)
|
||||
size_t get_placed_texture_storage_size(const rsx::fragment_texture &texture, size_t row_pitch_alignement, size_t mipmap_alignment)
|
||||
{
|
||||
return get_placed_texture_storage_size(texture.width(), texture.height(), texture.depth(), texture.format(), texture.mipmap(), texture.cubemap(),
|
||||
row_pitch_alignement, mipmap_alignment);
|
||||
|
@ -468,7 +468,7 @@ static size_t get_texture_size(u32 w, u32 h, u8 format)
|
|||
}
|
||||
}
|
||||
|
||||
size_t get_texture_size(const rsx::texture &texture)
|
||||
size_t get_texture_size(const rsx::fragment_texture &texture)
|
||||
{
|
||||
return get_texture_size(texture.width(), texture.height(), texture.format());
|
||||
}
|
||||
|
|
|
@ -18,14 +18,14 @@ struct rsx_subresource_layout
|
|||
* Get size to store texture in a linear fashion.
|
||||
* Storage is assumed to use a rowPitchAlignement boundary for every row of texture.
|
||||
*/
|
||||
size_t get_placed_texture_storage_size(const rsx::texture &texture, size_t row_pitch_alignement, size_t mipmap_alignment = 0x200);
|
||||
size_t get_placed_texture_storage_size(const rsx::fragment_texture &texture, size_t row_pitch_alignement, size_t mipmap_alignment = 0x200);
|
||||
size_t get_placed_texture_storage_size(const rsx::vertex_texture &texture, size_t row_pitch_alignement, size_t mipmap_alignment = 0x200);
|
||||
|
||||
/**
|
||||
* get all rsx_subresource_layout for texture.
|
||||
* The subresources are ordered per layer then per mipmap level (as in rsx memory).
|
||||
*/
|
||||
std::vector<rsx_subresource_layout> get_subresources_layout(const rsx::texture &texture);
|
||||
std::vector<rsx_subresource_layout> get_subresources_layout(const rsx::fragment_texture &texture);
|
||||
std::vector<rsx_subresource_layout> get_subresources_layout(const rsx::vertex_texture &texture);
|
||||
|
||||
void upload_texture_subresource(gsl::span<gsl::byte> dst_buffer, const rsx_subresource_layout &src_layout, int format, bool is_swizzled, size_t dst_row_pitch_multiple_of);
|
||||
|
@ -36,5 +36,5 @@ u8 get_format_block_size_in_texel(int format);
|
|||
/**
|
||||
* Get number of bytes occupied by texture in RSX mem
|
||||
*/
|
||||
size_t get_texture_size(const rsx::texture &texture);
|
||||
size_t get_texture_size(const rsx::fragment_texture &texture);
|
||||
size_t get_texture_size(const rsx::vertex_texture &texture);
|
||||
|
|
|
@ -35,7 +35,7 @@ D3D12_COMPARISON_FUNC get_sampler_compare_func[] =
|
|||
D3D12_COMPARISON_FUNC_ALWAYS
|
||||
};
|
||||
|
||||
D3D12_SAMPLER_DESC get_sampler_desc(const rsx::texture &texture)
|
||||
D3D12_SAMPLER_DESC get_sampler_desc(const rsx::fragment_texture &texture)
|
||||
{
|
||||
D3D12_SAMPLER_DESC samplerDesc = {};
|
||||
samplerDesc.Filter = get_texture_filter(texture.min_filter(), texture.mag_filter());
|
||||
|
@ -56,7 +56,7 @@ D3D12_SAMPLER_DESC get_sampler_desc(const rsx::texture &texture)
|
|||
|
||||
namespace
|
||||
{
|
||||
CD3DX12_RESOURCE_DESC get_texture_description(const rsx::texture &texture)
|
||||
CD3DX12_RESOURCE_DESC get_texture_description(const rsx::fragment_texture &texture)
|
||||
{
|
||||
const u8 format = texture.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN);
|
||||
DXGI_FORMAT dxgi_format = get_texture_format(format);
|
||||
|
@ -92,7 +92,7 @@ namespace {
|
|||
* Allocate buffer in texture_buffer_heap big enough and upload data into existing_texture which should be in COPY_DEST state
|
||||
*/
|
||||
void update_existing_texture(
|
||||
const rsx::texture &texture,
|
||||
const rsx::fragment_texture &texture,
|
||||
ID3D12GraphicsCommandList *command_list,
|
||||
d3d12_data_heap &texture_buffer_heap,
|
||||
ID3D12Resource *existing_texture)
|
||||
|
@ -145,7 +145,7 @@ namespace {
|
|||
* using a temporary texture buffer.
|
||||
*/
|
||||
ComPtr<ID3D12Resource> upload_single_texture(
|
||||
const rsx::texture &texture,
|
||||
const rsx::fragment_texture &texture,
|
||||
ID3D12Device *device,
|
||||
ID3D12GraphicsCommandList *command_list,
|
||||
d3d12_data_heap &texture_buffer_heap)
|
||||
|
@ -165,7 +165,7 @@ ComPtr<ID3D12Resource> upload_single_texture(
|
|||
}
|
||||
|
||||
|
||||
D3D12_SHADER_RESOURCE_VIEW_DESC get_srv_descriptor_with_dimensions(const rsx::texture &tex)
|
||||
D3D12_SHADER_RESOURCE_VIEW_DESC get_srv_descriptor_with_dimensions(const rsx::fragment_texture &tex)
|
||||
{
|
||||
D3D12_SHADER_RESOURCE_VIEW_DESC shared_resource_view_desc = {};
|
||||
switch (tex.get_extended_texture_dimension())
|
||||
|
|
|
@ -313,7 +313,7 @@ void GLGSRender::begin()
|
|||
|
||||
namespace
|
||||
{
|
||||
GLenum get_gl_target_for_texture(const rsx::texture& tex)
|
||||
GLenum get_gl_target_for_texture(const rsx::fragment_texture& tex)
|
||||
{
|
||||
switch (tex.get_extended_texture_dimension())
|
||||
{
|
||||
|
|
|
@ -433,7 +433,7 @@ namespace rsx
|
|||
return false;
|
||||
}
|
||||
|
||||
void texture::init(int index, rsx::texture& tex)
|
||||
void texture::init(int index, rsx::fragment_texture& tex)
|
||||
{
|
||||
switch (tex.dimension())
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
namespace rsx
|
||||
{
|
||||
class vertex_texture;
|
||||
class texture;
|
||||
class fragment_texture;
|
||||
|
||||
namespace gl
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ namespace rsx
|
|||
return (v << 2) | (v >> 4);
|
||||
}
|
||||
|
||||
void init(int index, rsx::texture& tex);
|
||||
void init(int index, rsx::fragment_texture& tex);
|
||||
void init(int index, rsx::vertex_texture& tex);
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -14,15 +14,15 @@ namespace rsx
|
|||
texture_dimension_3d = 3,
|
||||
};
|
||||
|
||||
class texture
|
||||
class fragment_texture
|
||||
{
|
||||
protected:
|
||||
const u8 m_index;
|
||||
std::array<u32, 0x10000 / 4> ®isters;
|
||||
|
||||
public:
|
||||
texture(u8 idx, std::array<u32, 0x10000 / 4> &r) : m_index(idx), registers(r) { }
|
||||
texture() = delete;
|
||||
fragment_texture(u8 idx, std::array<u32, 0x10000 / 4> &r) : m_index(idx), registers(r) { }
|
||||
fragment_texture() = delete;
|
||||
|
||||
//initialize texture registers with default values
|
||||
void init();
|
||||
|
|
|
@ -19,7 +19,7 @@ extern cfg::bool_entry g_cfg_rsx_debug_output;
|
|||
|
||||
namespace rsx
|
||||
{
|
||||
class texture;
|
||||
class fragment_texture;
|
||||
}
|
||||
|
||||
namespace vk
|
||||
|
@ -458,7 +458,7 @@ namespace vk
|
|||
void create(vk::render_device &device, VkFormat format, VkImageUsageFlags usage, u32 width, u32 height, u32 mipmaps = 1, bool gpu_only = false, VkComponentMapping swizzle = default_component_map());
|
||||
void destroy();
|
||||
|
||||
void init(rsx::texture &tex, vk::command_buffer &cmd, bool ignore_checks = false);
|
||||
void init(rsx::fragment_texture &tex, vk::command_buffer &cmd, bool ignore_checks = false);
|
||||
void flush(vk::command_buffer & cmd);
|
||||
|
||||
//Fill with debug color 0xFF
|
||||
|
|
|
@ -282,7 +282,7 @@ namespace vk
|
|||
create(device, format, usage, tiling, width, height, mipmaps, gpu_only, swizzle);
|
||||
}
|
||||
|
||||
void texture::init(rsx::texture& tex, vk::command_buffer &cmd, bool ignore_checks)
|
||||
void texture::init(rsx::fragment_texture& tex, vk::command_buffer &cmd, bool ignore_checks)
|
||||
{
|
||||
VkImageViewType best_type = VK_IMAGE_VIEW_TYPE_2D;
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ namespace vk
|
|||
purge_cache();
|
||||
}
|
||||
|
||||
vk::image_view* upload_texture(command_buffer cmd, rsx::texture &tex, rsx::vk_render_targets &m_rtts, const vk::memory_type_mapping &memory_type_mapping, vk_data_heap& upload_heap, vk::buffer* upload_buffer)
|
||||
vk::image_view* upload_texture(command_buffer cmd, rsx::fragment_texture &tex, rsx::vk_render_targets &m_rtts, const vk::memory_type_mapping &memory_type_mapping, vk_data_heap& upload_heap, vk::buffer* upload_buffer)
|
||||
{
|
||||
const u32 texaddr = rsx::get_address(tex.offset(), tex.location());
|
||||
const u32 range = (u32)get_texture_size(tex);
|
||||
|
|
|
@ -142,7 +142,7 @@ namespace rsx
|
|||
return *this;
|
||||
}
|
||||
|
||||
std::array<texture, 16> fragment_textures;
|
||||
std::array<fragment_texture, 16> fragment_textures;
|
||||
std::array<vertex_texture, 4> vertex_textures;
|
||||
|
||||
|
||||
|
@ -171,7 +171,7 @@ namespace rsx
|
|||
std::array<data_array_format_info, 16> vertex_arrays_info;
|
||||
|
||||
rsx_state() :
|
||||
fragment_textures(fill_array<texture>(registers, std::make_index_sequence<16>())),
|
||||
fragment_textures(fill_array<fragment_texture>(registers, std::make_index_sequence<16>())),
|
||||
vertex_textures(fill_array<vertex_texture>(registers, std::make_index_sequence<4>())),
|
||||
vertex_arrays_info(fill_array<data_array_format_info>(registers, std::make_index_sequence<16>()))
|
||||
{ }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue