mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 18:53:28 +01:00
rsx: Minor refactoring (#10358)
- Fix some misnomers. - Allow finer grained control over texture section creation routines.
This commit is contained in:
parent
763828837b
commit
9e62e98f79
@ -353,11 +353,11 @@ namespace rsx
|
||||
virtual image_view_type create_temporary_subresource_view(commandbuffer_type&, image_storage_type* src, u32 gcm_format, u16 x, u16 y, u16 w, u16 h, const texture_channel_remap_t& remap_vector) = 0;
|
||||
virtual void release_temporary_subresource(image_view_type rsc) = 0;
|
||||
virtual section_storage_type* create_new_texture(commandbuffer_type&, const address_range &rsx_range, u16 width, u16 height, u16 depth, u16 mipmaps, u16 pitch, u32 gcm_format,
|
||||
rsx::texture_upload_context context, rsx::texture_dimension_extended type, bool swizzled, texture_create_flags flags) = 0;
|
||||
rsx::texture_upload_context context, rsx::texture_dimension_extended type, bool swizzled, component_order swizzle_flags, rsx::flags32_t flags) = 0;
|
||||
virtual section_storage_type* upload_image_from_cpu(commandbuffer_type&, const address_range &rsx_range, u16 width, u16 height, u16 depth, u16 mipmaps, u16 pitch, u32 gcm_format, texture_upload_context context,
|
||||
const std::vector<rsx::subresource_layout>& subresource_layout, rsx::texture_dimension_extended type, bool swizzled) = 0;
|
||||
virtual section_storage_type* create_nul_section(commandbuffer_type&, const address_range &rsx_range, bool memory_load) = 0;
|
||||
virtual void enforce_surface_creation_type(section_storage_type& section, u32 gcm_format, texture_create_flags expected) = 0;
|
||||
virtual void set_component_order(section_storage_type& section, u32 gcm_format, component_order expected) = 0;
|
||||
virtual void insert_texture_barrier(commandbuffer_type&, image_storage_type* tex, bool strong_ordering = true) = 0;
|
||||
virtual image_view_type generate_cubemap_from_images(commandbuffer_type&, u32 gcm_format, u16 size, const std::vector<copy_region_descriptor>& sources, const texture_channel_remap_t& remap_vector) = 0;
|
||||
virtual image_view_type generate_3d_from_2d_images(commandbuffer_type&, u32 gcm_format, u16 width, u16 height, u16 depth, const std::vector<copy_region_descriptor>& sources, const texture_channel_remap_t& remap_vector) = 0;
|
||||
@ -2705,11 +2705,11 @@ namespace rsx
|
||||
if (cached_dest && !use_null_region)
|
||||
{
|
||||
// Prep surface
|
||||
auto channel_order = src_is_render_target ? rsx::texture_create_flags::native_component_order :
|
||||
dst_is_argb8 ? rsx::texture_create_flags::default_component_order :
|
||||
rsx::texture_create_flags::swapped_native_component_order;
|
||||
auto channel_order = src_is_render_target ? rsx::component_order::native :
|
||||
dst_is_argb8 ? rsx::component_order::default_ :
|
||||
rsx::component_order::swapped_native;
|
||||
|
||||
enforce_surface_creation_type(*cached_dest, preferred_dst_format, channel_order);
|
||||
set_component_order(*cached_dest, preferred_dst_format, channel_order);
|
||||
}
|
||||
|
||||
// Validate clipping region
|
||||
@ -2771,9 +2771,9 @@ namespace rsx
|
||||
else
|
||||
{
|
||||
// render target data is already in correct swizzle layout
|
||||
auto channel_order = src_is_render_target ? rsx::texture_create_flags::native_component_order :
|
||||
dst_is_argb8 ? rsx::texture_create_flags::default_component_order :
|
||||
rsx::texture_create_flags::swapped_native_component_order;
|
||||
auto channel_order = src_is_render_target ? rsx::component_order::native :
|
||||
dst_is_argb8 ? rsx::component_order::default_ :
|
||||
rsx::component_order::swapped_native;
|
||||
|
||||
// Translate dst_area into the 'full' dst block based on dst.rsx_address as (0, 0)
|
||||
dst_area.x1 += dst_offset.x;
|
||||
@ -2785,7 +2785,7 @@ namespace rsx
|
||||
{
|
||||
cached_dest = create_new_texture(cmd, rsx_range, dst_dimensions.width, dst_dimensions.height, 1, 1, dst.pitch,
|
||||
preferred_dst_format, rsx::texture_upload_context::blit_engine_dst, rsx::texture_dimension_extended::texture_dimension_2d,
|
||||
false, channel_order);
|
||||
false, channel_order, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2808,7 +2808,7 @@ namespace rsx
|
||||
preferred_dst_format, rsx::texture_upload_context::blit_engine_dst, subresource_layout,
|
||||
rsx::texture_dimension_extended::texture_dimension_2d, false);
|
||||
|
||||
enforce_surface_creation_type(*cached_dest, preferred_dst_format, channel_order);
|
||||
set_component_order(*cached_dest, preferred_dst_format, channel_order);
|
||||
}
|
||||
|
||||
dest_texture = cached_dest->get_raw_texture();
|
||||
|
@ -21,11 +21,11 @@ namespace rsx
|
||||
chain_direction_backward, // Only lower-base-address pages chain (unless they overlap the fault)
|
||||
};
|
||||
|
||||
enum texture_create_flags
|
||||
enum class component_order
|
||||
{
|
||||
default_component_order = 0,
|
||||
native_component_order = 1,
|
||||
swapped_native_component_order = 2,
|
||||
default_ = 0,
|
||||
native = 1,
|
||||
swapped_native = 2,
|
||||
};
|
||||
|
||||
enum memory_read_flags
|
||||
|
@ -1104,7 +1104,7 @@ namespace rsx
|
||||
bool speculatively_flushed = false;
|
||||
|
||||
rsx::memory_read_flags readback_behaviour = rsx::memory_read_flags::flush_once;
|
||||
rsx::texture_create_flags view_flags = rsx::texture_create_flags::default_component_order;
|
||||
rsx::component_order view_flags = rsx::component_order::default_;
|
||||
rsx::texture_upload_context context = rsx::texture_upload_context::shader_read;
|
||||
rsx::texture_dimension_extended image_type = rsx::texture_dimension_extended::texture_dimension_2d;
|
||||
|
||||
@ -1179,7 +1179,7 @@ namespace rsx
|
||||
m_predictor_entry = nullptr;
|
||||
|
||||
readback_behaviour = rsx::memory_read_flags::flush_once;
|
||||
view_flags = rsx::texture_create_flags::default_component_order;
|
||||
view_flags = rsx::component_order::default_;
|
||||
context = rsx::texture_upload_context::shader_read;
|
||||
image_type = rsx::texture_dimension_extended::texture_dimension_2d;
|
||||
|
||||
@ -1654,7 +1654,7 @@ namespace rsx
|
||||
return *m_predictor_entry;
|
||||
}
|
||||
|
||||
void set_view_flags(rsx::texture_create_flags flags)
|
||||
void set_view_flags(rsx::component_order flags)
|
||||
{
|
||||
view_flags = flags;
|
||||
}
|
||||
@ -1716,7 +1716,7 @@ namespace rsx
|
||||
return rsx_pitch;
|
||||
}
|
||||
|
||||
rsx::texture_create_flags get_view_flags() const
|
||||
rsx::component_order get_view_flags() const
|
||||
{
|
||||
return view_flags;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ namespace gl
|
||||
if (!src || static_cast<GLenum>(src->get_internal_format()) != sized_internal_fmt)
|
||||
{
|
||||
// Apply base component map onto the new texture if a data cast has been done
|
||||
swizzle = get_component_mapping(gcm_format, rsx::texture_create_flags::default_component_order);
|
||||
swizzle = get_component_mapping(gcm_format, rsx::component_order::default_);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -470,7 +470,7 @@ namespace gl
|
||||
gl::texture_view* create_temporary_subresource_impl(gl::command_context& cmd, gl::texture* src, GLenum sized_internal_fmt, GLenum dst_type, u32 gcm_format,
|
||||
u16 x, u16 y, u16 width, u16 height, u16 depth, u8 mipmaps, const rsx::texture_channel_remap_t& remap, bool copy);
|
||||
|
||||
std::array<GLenum, 4> get_component_mapping(u32 gcm_format, rsx::texture_create_flags flags) const
|
||||
std::array<GLenum, 4> get_component_mapping(u32 gcm_format, rsx::component_order flags) const
|
||||
{
|
||||
switch (gcm_format)
|
||||
{
|
||||
@ -486,15 +486,15 @@ namespace gl
|
||||
|
||||
switch (flags)
|
||||
{
|
||||
case rsx::texture_create_flags::default_component_order:
|
||||
case rsx::component_order::default_:
|
||||
{
|
||||
return gl::get_swizzle_remap(gcm_format);
|
||||
}
|
||||
case rsx::texture_create_flags::native_component_order:
|
||||
case rsx::component_order::native:
|
||||
{
|
||||
return{ GL_ALPHA, GL_RED, GL_GREEN, GL_BLUE };
|
||||
}
|
||||
case rsx::texture_create_flags::swapped_native_component_order:
|
||||
case rsx::component_order::swapped_native:
|
||||
{
|
||||
return{ GL_BLUE, GL_ALPHA, GL_RED, GL_GREEN };
|
||||
}
|
||||
@ -624,7 +624,7 @@ namespace gl
|
||||
}
|
||||
|
||||
cached_texture_section* create_new_texture(gl::command_context &cmd, const utils::address_range &rsx_range, u16 width, u16 height, u16 depth, u16 mipmaps, u16 pitch,
|
||||
u32 gcm_format, rsx::texture_upload_context context, rsx::texture_dimension_extended type, bool swizzled, rsx::texture_create_flags flags) override
|
||||
u32 gcm_format, rsx::texture_upload_context context, rsx::texture_dimension_extended type, bool swizzled, rsx::component_order swizzle_flags, rsx::flags32_t /*flags*/) override
|
||||
{
|
||||
const rsx::image_section_attributes_t search_desc = { .gcm_format = gcm_format, .width = width, .height = height, .depth = depth, .mipmaps = mipmaps };
|
||||
const bool allow_dirty = (context != rsx::texture_upload_context::framebuffer_storage);
|
||||
@ -676,12 +676,12 @@ namespace gl
|
||||
cached.create(width, height, depth, mipmaps, image, pitch, true);
|
||||
}
|
||||
|
||||
cached.set_view_flags(flags);
|
||||
cached.set_view_flags(swizzle_flags);
|
||||
cached.set_context(context);
|
||||
cached.set_swizzled(swizzled);
|
||||
cached.set_dirty(false);
|
||||
|
||||
const auto swizzle = get_component_mapping(gcm_format, flags);
|
||||
const auto swizzle = get_component_mapping(gcm_format, swizzle_flags);
|
||||
image->set_native_component_layout(swizzle);
|
||||
|
||||
if (context != rsx::texture_upload_context::blit_engine_dst)
|
||||
@ -748,7 +748,7 @@ namespace gl
|
||||
rsx::texture_upload_context context, const std::vector<rsx::subresource_layout>& subresource_layout, rsx::texture_dimension_extended type, bool input_swizzled) override
|
||||
{
|
||||
auto section = create_new_texture(cmd, rsx_range, width, height, depth, mipmaps, pitch, gcm_format, context, type, input_swizzled,
|
||||
rsx::texture_create_flags::default_component_order);
|
||||
rsx::component_order::default_, 0);
|
||||
|
||||
gl::upload_texture(section->get_raw_texture(), gcm_format, input_swizzled, subresource_layout);
|
||||
|
||||
@ -756,7 +756,7 @@ namespace gl
|
||||
return section;
|
||||
}
|
||||
|
||||
void enforce_surface_creation_type(cached_texture_section& section, u32 gcm_format, rsx::texture_create_flags flags) override
|
||||
void set_component_order(cached_texture_section& section, u32 gcm_format, rsx::component_order flags) override
|
||||
{
|
||||
if (flags == section.get_view_flags())
|
||||
return;
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "VKDMA.h"
|
||||
#include "VKRenderTargets.h"
|
||||
#include "VKResourceManager.h"
|
||||
#include "VKRenderPass.h"
|
||||
#include "vkutils/image_helpers.h"
|
||||
|
||||
#include "../Common/texture_cache.h"
|
||||
@ -396,6 +397,11 @@ namespace vk
|
||||
friend baseclass;
|
||||
|
||||
public:
|
||||
enum texture_create_flags : u32
|
||||
{
|
||||
initialize_image_contents = 1,
|
||||
};
|
||||
|
||||
void on_section_destroyed(cached_texture_section& tex) override
|
||||
{
|
||||
if (tex.is_managed())
|
||||
@ -425,7 +431,7 @@ namespace vk
|
||||
m_temporary_memory_size = 0;
|
||||
}
|
||||
|
||||
VkComponentMapping apply_component_mapping_flags(u32 gcm_format, rsx::texture_create_flags flags, const rsx::texture_channel_remap_t& remap_vector) const
|
||||
VkComponentMapping apply_component_mapping_flags(u32 gcm_format, rsx::component_order flags, const rsx::texture_channel_remap_t& remap_vector) const
|
||||
{
|
||||
switch (gcm_format)
|
||||
{
|
||||
@ -442,17 +448,17 @@ namespace vk
|
||||
VkComponentMapping mapping = {};
|
||||
switch (flags)
|
||||
{
|
||||
case rsx::texture_create_flags::default_component_order:
|
||||
case rsx::component_order::default_:
|
||||
{
|
||||
mapping = vk::apply_swizzle_remap(vk::get_component_mapping(gcm_format), remap_vector);
|
||||
break;
|
||||
}
|
||||
case rsx::texture_create_flags::native_component_order:
|
||||
case rsx::component_order::native:
|
||||
{
|
||||
mapping = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A };
|
||||
break;
|
||||
}
|
||||
case rsx::texture_create_flags::swapped_native_component_order:
|
||||
case rsx::component_order::swapped_native:
|
||||
{
|
||||
mapping = { VK_COMPONENT_SWIZZLE_A, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B };
|
||||
break;
|
||||
@ -766,7 +772,7 @@ namespace vk
|
||||
}
|
||||
|
||||
cached_texture_section* create_new_texture(vk::command_buffer& cmd, const utils::address_range &rsx_range, u16 width, u16 height, u16 depth, u16 mipmaps, u16 pitch,
|
||||
u32 gcm_format, rsx::texture_upload_context context, rsx::texture_dimension_extended type, bool swizzled, rsx::texture_create_flags flags) override
|
||||
u32 gcm_format, rsx::texture_upload_context context, rsx::texture_dimension_extended type, bool swizzled, rsx::component_order swizzle_flags, rsx::flags32_t flags) override
|
||||
{
|
||||
const auto section_depth = depth;
|
||||
|
||||
@ -824,7 +830,7 @@ namespace vk
|
||||
// Reuse
|
||||
region.set_rsx_pitch(pitch);
|
||||
|
||||
if (context != rsx::texture_upload_context::shader_read)
|
||||
if (flags & texture_create_flags::initialize_image_contents)
|
||||
{
|
||||
// Wipe memory
|
||||
image->change_layout(cmd, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
@ -863,12 +869,12 @@ namespace vk
|
||||
region.create(width, height, section_depth, mipmaps, image, pitch, true, gcm_format);
|
||||
}
|
||||
|
||||
region.set_view_flags(flags);
|
||||
region.set_view_flags(swizzle_flags);
|
||||
region.set_context(context);
|
||||
region.set_swizzled(swizzled);
|
||||
region.set_dirty(false);
|
||||
|
||||
image->native_component_map = apply_component_mapping_flags(gcm_format, flags, rsx::default_remap_vector);
|
||||
image->native_component_map = apply_component_mapping_flags(gcm_format, swizzle_flags, rsx::default_remap_vector);
|
||||
|
||||
// Its not necessary to lock blit dst textures as they are just reused as necessary
|
||||
switch (context)
|
||||
@ -918,8 +924,15 @@ namespace vk
|
||||
cached_texture_section* upload_image_from_cpu(vk::command_buffer& cmd, const utils::address_range& rsx_range, u16 width, u16 height, u16 depth, u16 mipmaps, u16 pitch, u32 gcm_format,
|
||||
rsx::texture_upload_context context, const std::vector<rsx::subresource_layout>& subresource_layout, rsx::texture_dimension_extended type, bool swizzled) override
|
||||
{
|
||||
if (context != rsx::texture_upload_context::shader_read)
|
||||
{
|
||||
if (vk::is_renderpass_open(cmd))
|
||||
{
|
||||
vk::end_renderpass(cmd);
|
||||
}
|
||||
}
|
||||
auto section = create_new_texture(cmd, rsx_range, width, height, depth, mipmaps, pitch, gcm_format, context, type, swizzled,
|
||||
rsx::texture_create_flags::default_component_order);
|
||||
rsx::component_order::default_, 0);
|
||||
|
||||
auto image = section->get_raw_texture();
|
||||
image->set_debug_name(fmt::format("Raw Texture @0x%x", rsx_range.start));
|
||||
@ -979,7 +992,7 @@ namespace vk
|
||||
return section;
|
||||
}
|
||||
|
||||
void enforce_surface_creation_type(cached_texture_section& section, u32 gcm_format, rsx::texture_create_flags expected_flags) override
|
||||
void set_component_order(cached_texture_section& section, u32 gcm_format, rsx::component_order expected_flags) override
|
||||
{
|
||||
if (expected_flags == section.get_view_flags())
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user