mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-11-01 04:47:53 +00:00
copy_params: Use constructor instead of C-like initialization
This commit is contained in:
parent
1af4414861
commit
03d10ea3b4
3 changed files with 39 additions and 47 deletions
|
@ -9,6 +9,16 @@
|
|||
namespace VideoCommon {
|
||||
|
||||
struct CopyParams {
|
||||
CopyParams(u32 source_x, u32 source_y, u32 source_z, u32 dest_x, u32 dest_y, u32 dest_z,
|
||||
u32 source_level, u32 dest_level, u32 width, u32 height, u32 depth)
|
||||
: source_x{source_x}, source_y{source_y}, source_z{source_z}, dest_x{dest_x},
|
||||
dest_y{dest_y}, dest_z{dest_z}, source_level{source_level},
|
||||
dest_level{dest_level}, width{width}, height{height}, depth{depth} {}
|
||||
|
||||
CopyParams(u32 width, u32 height, u32 depth, u32 level)
|
||||
: source_x{}, source_y{}, source_z{}, dest_x{}, dest_y{}, dest_z{}, source_level{level},
|
||||
dest_level{level}, width{width}, height{height}, depth{depth} {}
|
||||
|
||||
u32 source_x;
|
||||
u32 source_y;
|
||||
u32 source_z;
|
||||
|
|
|
@ -149,45 +149,32 @@ public:
|
|||
}
|
||||
|
||||
std::vector<CopyParams> BreakDown(const SurfaceParams& in_params) const {
|
||||
auto set_up_copy = [](CopyParams& cp, const u32 width, const u32 height, const u32 depth,
|
||||
const u32 level) {
|
||||
cp.source_x = 0;
|
||||
cp.source_y = 0;
|
||||
cp.source_z = 0;
|
||||
cp.dest_x = 0;
|
||||
cp.dest_y = 0;
|
||||
cp.dest_z = 0;
|
||||
cp.source_level = level;
|
||||
cp.dest_level = level;
|
||||
cp.width = width;
|
||||
cp.height = height;
|
||||
cp.depth = depth;
|
||||
};
|
||||
const u32 layers = params.depth;
|
||||
const u32 mipmaps = params.num_levels;
|
||||
std::vector<CopyParams> result;
|
||||
const u32 layers{params.depth};
|
||||
const u32 mipmaps{params.num_levels};
|
||||
|
||||
if (params.is_layered) {
|
||||
std::vector<CopyParams> result{layers * mipmaps};
|
||||
for (std::size_t layer = 0; layer < layers; layer++) {
|
||||
const u32 layer_offset = layer * mipmaps;
|
||||
for (std::size_t level = 0; level < mipmaps; level++) {
|
||||
CopyParams& cp = result[layer_offset + level];
|
||||
const u32 width =
|
||||
std::min(params.GetMipWidth(level), in_params.GetMipWidth(level));
|
||||
const u32 height =
|
||||
std::min(params.GetMipHeight(level), in_params.GetMipHeight(level));
|
||||
set_up_copy(cp, width, height, layer, level);
|
||||
result.reserve(static_cast<std::size_t>(layers) * static_cast<std::size_t>(mipmaps));
|
||||
for (u32 layer = 0; layer < layers; layer++) {
|
||||
const u32 layer_offset{layer * mipmaps};
|
||||
for (u32 level = 0; level < mipmaps; level++) {
|
||||
const u32 width{
|
||||
std::min(params.GetMipWidth(level), in_params.GetMipWidth(level))};
|
||||
const u32 height{
|
||||
std::min(params.GetMipHeight(level), in_params.GetMipHeight(level))};
|
||||
result.emplace_back(width, height, layer, level);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
} else {
|
||||
std::vector<CopyParams> result{mipmaps};
|
||||
result.reserve(mipmaps);
|
||||
for (std::size_t level = 0; level < mipmaps; level++) {
|
||||
CopyParams& cp = result[level];
|
||||
const u32 width = std::min(params.GetMipWidth(level), in_params.GetMipWidth(level));
|
||||
const u32 height =
|
||||
std::min(params.GetMipHeight(level), in_params.GetMipHeight(level));
|
||||
const u32 depth = std::min(params.GetMipDepth(level), in_params.GetMipDepth(level));
|
||||
set_up_copy(cp, width, height, depth, level);
|
||||
const u32 width{std::min(params.GetMipWidth(level), in_params.GetMipWidth(level))};
|
||||
const u32 height{
|
||||
std::min(params.GetMipHeight(level), in_params.GetMipHeight(level))};
|
||||
const u32 depth{std::min(params.GetMipDepth(level), in_params.GetMipDepth(level))};
|
||||
result.emplace_back(width, height, depth, level);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -283,7 +283,7 @@ private:
|
|||
}
|
||||
|
||||
std::pair<TSurface, TView> RebuildSurface(TSurface current_surface,
|
||||
const SurfaceParams& params) {
|
||||
const SurfaceParams& params) {
|
||||
const auto gpu_addr = current_surface->GetGpuAddr();
|
||||
TSurface new_surface = GetUncachedSurface(gpu_addr, params);
|
||||
std::vector<CopyParams> bricks = current_surface->BreakDown(params);
|
||||
|
@ -323,26 +323,21 @@ private:
|
|||
return {};
|
||||
}
|
||||
const std::size_t candidate_size = src_params.GetGuestSizeInBytes();
|
||||
auto mipmap_layer = new_surface->GetLayerMipmap(surface->GetGpuAddr());
|
||||
auto mipmap_layer{new_surface->GetLayerMipmap(surface->GetGpuAddr())};
|
||||
if (!mipmap_layer) {
|
||||
return {};
|
||||
}
|
||||
const u32 layer = (*mipmap_layer).first;
|
||||
const u32 mipmap = (*mipmap_layer).second;
|
||||
const u32 layer{mipmap_layer->first};
|
||||
const u32 mipmap{mipmap_layer->second};
|
||||
if (new_surface->GetMipmapSize(mipmap) != candidate_size) {
|
||||
return {};
|
||||
}
|
||||
// Now we got all the data set up
|
||||
CopyParams copy_params{};
|
||||
const u32 dst_width = params.GetMipWidth(mipmap);
|
||||
const u32 dst_height = params.GetMipHeight(mipmap);
|
||||
copy_params.width = std::min(src_params.width, dst_width);
|
||||
copy_params.height = std::min(src_params.height, dst_height);
|
||||
copy_params.depth = 1;
|
||||
copy_params.source_level = 0;
|
||||
copy_params.dest_level = mipmap;
|
||||
copy_params.source_z = 0;
|
||||
copy_params.dest_z = layer;
|
||||
const u32 dst_width{params.GetMipWidth(mipmap)};
|
||||
const u32 dst_height{params.GetMipHeight(mipmap)};
|
||||
const CopyParams copy_params(0, 0, 0, 0, 0, layer, 0, mipmap,
|
||||
std::min(src_params.width, dst_width),
|
||||
std::min(src_params.height, dst_height), 1);
|
||||
ImageCopy(surface, new_surface, copy_params);
|
||||
}
|
||||
for (auto surface : overlaps) {
|
||||
|
|
Loading…
Reference in a new issue