rsx: Use designated initializer for the dangerous copy_region_descriptor type

- We need to move more dangerous braced initializations to c++20
- Also adds a base address variable which will come in handy
This commit is contained in:
kd-11 2023-07-01 02:35:52 +03:00 committed by kd-11
commit 8f98e572e1
5 changed files with 116 additions and 85 deletions

View file

@ -143,6 +143,7 @@ namespace rsx
std::vector<copy_region_descriptor> sections_to_copy; std::vector<copy_region_descriptor> sections_to_copy;
texture_channel_remap_t remap; texture_channel_remap_t remap;
deferred_request_command op = deferred_request_command::nop; deferred_request_command op = deferred_request_command::nop;
u32 external_ref_addr = 0;
u16 x = 0; u16 x = 0;
u16 y = 0; u16 y = 0;
@ -274,6 +275,7 @@ namespace rsx
// Blit op is a semantic variant of the copy and atlas ops. // Blit op is a semantic variant of the copy and atlas ops.
// We can simply reuse the atlas handler for this for now, but this allows simplification. // We can simply reuse the atlas handler for this for now, but this allows simplification.
external_subresource_desc.op = deferred_request_command::blit_image_static; external_subresource_desc.op = deferred_request_command::blit_image_static;
external_subresource_desc.external_ref_addr = cpy.base_addr;
} }
} }
} }
@ -1666,13 +1668,18 @@ namespace rsx
{ {
sections[n] = sections[n] =
{ {
desc.external_handle, .src = desc.external_handle,
surface_transform::coordinate_transform, .xform = surface_transform::coordinate_transform,
0, .level = 0,
0, static_cast<u16>(desc.slice_h * n), .src_x = 0,
0, 0, n, .src_y = static_cast<u16>(desc.slice_h * n),
desc.width, desc.height, .dst_x = 0,
desc.width, desc.height .dst_y = 0,
.dst_z = n,
.src_w = desc.width,
.src_h = desc.height,
.dst_w = desc.width,
.dst_h = desc.height
}; };
} }
@ -1692,13 +1699,18 @@ namespace rsx
{ {
sections[n] = sections[n] =
{ {
desc.external_handle, .src = desc.external_handle,
surface_transform::coordinate_transform, .xform = surface_transform::coordinate_transform,
0, .level = 0,
0, static_cast<u16>(desc.slice_h * n), .src_x = 0,
0, 0, n, .src_y = static_cast<u16>(desc.slice_h * n),
desc.width, desc.height, .dst_x = 0,
desc.width, desc.height .dst_y = 0,
.dst_z = n,
.src_w = desc.width,
.src_h = desc.height,
.dst_w = desc.width,
.dst_h = desc.height
}; };
} }

View file

@ -20,6 +20,7 @@ namespace rsx
{ {
image_resource_type src; image_resource_type src;
flags32_t xform; flags32_t xform;
u32 base_addr;
u8 level; u8 level;
u16 src_x; u16 src_x;
u16 src_y; u16 src_y;
@ -315,16 +316,19 @@ namespace rsx
out.push_back out.push_back
({ ({
section.surface->get_surface(rsx::surface_access::transfer_read), .src = section.surface->get_surface(rsx::surface_access::transfer_read),
surface_transform::identity, .xform = surface_transform::identity,
0, .base_addr = section.base_addr,
static_cast<u16>(src_x), .level = 0,
static_cast<u16>(src_y), .src_x = static_cast<u16>(src_x),
static_cast<u16>(dst_x), .src_y = static_cast<u16>(src_y),
static_cast<u16>(dst_y), .dst_x = static_cast<u16>(dst_x),
slice, .dst_y = static_cast<u16>(dst_y),
src_width, src_height, .dst_z = slice,
dst_width, dst_height .src_w = src_width,
.src_h = src_height,
.dst_w = dst_width,
.dst_h = dst_height
}); });
}; };
@ -378,36 +382,37 @@ namespace rsx
out.push_back out.push_back
({ ({
section->get_raw_texture(), .src = section->get_raw_texture(),
surface_transform::identity, .xform = surface_transform::identity,
0, .base_addr = address,
static_cast<u16>(src_offset.x), // src.x .level = 0,
static_cast<u16>(src_offset.y), // src.y .src_x = static_cast<u16>(src_offset.x), // src.x
_dst_x, // dst.x .src_y = static_cast<u16>(src_offset.y), // src.y
_dst_y, // dst.y .dst_x = _dst_x, // dst.x
slice, .dst_y = _dst_y, // dst.y
src_w, .dst_z = slice,
height, .src_w = src_w,
_dst_w, .src_h = height,
_dst_h .dst_w = _dst_w,
.dst_h = _dst_h
}); });
} }
else else
{ {
out.push_back out.push_back
({ ({
section->get_raw_texture(), .src = section->get_raw_texture(),
surface_transform::identity, .xform = surface_transform::identity,
0, .level = 0,
static_cast<u16>(src_offset.x), // src.x .src_x = static_cast<u16>(src_offset.x), // src.x
static_cast<u16>(src_offset.y), // src.y .src_y = static_cast<u16>(src_offset.y), // src.y
static_cast<u16>(dst_offset.x), // dst.x .dst_x = static_cast<u16>(dst_offset.x), // dst.x
static_cast<u16>(dst_y - dst_slice_begin), // dst.y .dst_y = static_cast<u16>(dst_y - dst_slice_begin), // dst.y
0, .dst_z = 0,
src_w, .src_w = src_w,
height, .src_h = height,
dst_w, .dst_w = dst_w,
height .dst_h = height
}); });
} }
}; };
@ -561,6 +566,7 @@ namespace rsx
// First, we convert this descriptor to a copy descriptor // First, we convert this descriptor to a copy descriptor
desc.external_subresource_desc.external_handle = section.src; desc.external_subresource_desc.external_handle = section.src;
desc.external_subresource_desc.external_ref_addr = section.base_addr;
// Now apply conversion // Now apply conversion
convert_image_copy_to_clip_descriptor( convert_image_copy_to_clip_descriptor(
@ -828,12 +834,14 @@ namespace rsx
{ {
if (level.image_handle) if (level.image_handle)
{ {
copy_region_descriptor_type mip{}; copy_region_descriptor_type mip
mip.src = level.image_handle->image(); {
mip.xform = surface_transform::coordinate_transform; .src = level.image_handle->image(),
mip.level = mipmap_level; .xform = surface_transform::coordinate_transform,
mip.dst_w = attr.width; .level = mipmap_level,
mip.dst_h = attr.height; .dst_w = attr.width,
.dst_h = attr.height
};
// "Fast" framebuffer results are a perfect match for attr so we do not store transfer sizes // "Fast" framebuffer results are a perfect match for attr so we do not store transfer sizes
// Calculate transfer dimensions from attr // Calculate transfer dimensions from attr
@ -856,18 +864,21 @@ namespace rsx
case deferred_request_command::copy_image_dynamic: case deferred_request_command::copy_image_dynamic:
case deferred_request_command::copy_image_static: case deferred_request_command::copy_image_static:
{ {
copy_region_descriptor_type mip{}; copy_region_descriptor_type mip
mip.src = level.external_subresource_desc.external_handle; {
mip.xform = surface_transform::coordinate_transform; .src = level.external_subresource_desc.external_handle,
mip.level = mipmap_level; .xform = surface_transform::coordinate_transform,
mip.dst_w = attr.width; .level = mipmap_level,
mip.dst_h = attr.height;
// NOTE: gather_texture_slices pre-applies resolution scaling // NOTE: gather_texture_slices pre-applies resolution scaling
mip.src_x = level.external_subresource_desc.x; .src_x = level.external_subresource_desc.x,
mip.src_y = level.external_subresource_desc.y; .src_y = level.external_subresource_desc.y,
mip.src_w = level.external_subresource_desc.width; .src_w = level.external_subresource_desc.width,
mip.src_h = level.external_subresource_desc.height; .src_h = level.external_subresource_desc.height,
.dst_w = attr.width,
.dst_h = attr.height
};
sections.push_back(mip); sections.push_back(mip);
break; break;

View file

@ -161,11 +161,14 @@ namespace gl
{ {
std::vector<copy_region_descriptor> region = std::vector<copy_region_descriptor> region =
{{ {{
src, .src = src,
rsx::surface_transform::coordinate_transform, .xform = rsx::surface_transform::coordinate_transform,
0, .src_x = x,
x, y, 0, 0, 0, .src_y = y,
width, height, width, height .src_w = width,
.src_h = height,
.dst_w = width,
.dst_h = height
}}; }};
copy_transfer_regions_impl(cmd, dst, region); copy_transfer_regions_impl(cmd, dst, region);

View file

@ -591,11 +591,12 @@ namespace gl
{ {
std::vector<copy_region_descriptor> region = std::vector<copy_region_descriptor> region =
{{ {{
src, .src = src,
rsx::surface_transform::identity, .xform = rsx::surface_transform::identity,
0, .src_w = width,
0, 0, 0, 0, 0, .src_h = height,
width, height, width, height .dst_w = width,
.dst_h = height
}}; }};
copy_transfer_regions_impl(cmd, dst->image(), region); copy_transfer_regions_impl(cmd, dst->image(), region);

View file

@ -612,11 +612,14 @@ namespace vk
{ {
std::vector<copy_region_descriptor> region = std::vector<copy_region_descriptor> region =
{ { { {
source, .src = source,
rsx::surface_transform::coordinate_transform, .xform = rsx::surface_transform::coordinate_transform,
0, .src_x = x,
x, y, 0, 0, 0, .src_y = y,
w, h, w, h .src_w = w,
.src_h = h,
.dst_w = w,
.dst_h = h
} }; } };
vk::change_image_layout(cmd, image.get(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); vk::change_image_layout(cmd, image.get(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
@ -800,11 +803,12 @@ namespace vk
{ {
std::vector<copy_region_descriptor> region = std::vector<copy_region_descriptor> region =
{ { { {
src, .src = src,
rsx::surface_transform::identity, .xform = rsx::surface_transform::identity,
0, .src_w = width,
0, 0, 0, 0, 0, .src_h = height,
width, height, width, height .dst_w = width,
.dst_h = height
} }; } };
auto dst = dst_view->image(); auto dst = dst_view->image();