mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-09 16:35:13 +00:00
rsx/vk: Support ingesting pre-processed GPU data as texture input
This commit is contained in:
parent
bef7d793d3
commit
ca054644ef
5 changed files with 104 additions and 26 deletions
|
|
@ -1009,13 +1009,19 @@ namespace vk
|
|||
{
|
||||
caps.supports_byteswap = (image_linear_size >= 1024);
|
||||
caps.supports_hw_deswizzle = caps.supports_byteswap;
|
||||
caps.supports_zero_copy = false;// caps.supports_byteswap;
|
||||
caps.supports_zero_copy = caps.supports_byteswap;
|
||||
caps.supports_vtc_decoding = false;
|
||||
check_caps = false;
|
||||
}
|
||||
|
||||
auto buf_allocator = [&]() -> std::tuple<void*, usz>
|
||||
{
|
||||
if (image_setup_flags & source_is_gpu_resident)
|
||||
{
|
||||
// We should never reach here, unless something is very wrong...
|
||||
fmt::throw_exception("Cannot allocate CPU memory for GPU-only data");
|
||||
}
|
||||
|
||||
// Map with extra padding bytes in case of realignment
|
||||
offset_in_upload_buffer = upload_heap.alloc<512>(image_linear_size + 8);
|
||||
void* mapped_buffer = upload_heap.map(offset_in_upload_buffer, image_linear_size + 8);
|
||||
|
|
@ -1026,6 +1032,21 @@ namespace vk
|
|||
opt = upload_texture_subresource(io_buf, layout, format, is_swizzled, caps);
|
||||
upload_heap.unmap();
|
||||
|
||||
if (image_setup_flags & source_is_gpu_resident)
|
||||
{
|
||||
// Read from GPU buf if the input is already uploaded.
|
||||
auto [iobuf, io_offset] = layout.data.raw();
|
||||
upload_buffer = static_cast<buffer*>(iobuf);
|
||||
offset_in_upload_buffer = io_offset;
|
||||
// Never upload. Data is already resident.
|
||||
opt.require_upload = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Read from upload buffer
|
||||
upload_buffer = upload_heap.heap.get();
|
||||
}
|
||||
|
||||
copy_regions.push_back({});
|
||||
auto& copy_info = copy_regions.back();
|
||||
copy_info.bufferOffset = offset_in_upload_buffer;
|
||||
|
|
@ -1038,8 +1059,6 @@ namespace vk
|
|||
copy_info.imageSubresource.mipLevel = layout.level;
|
||||
copy_info.bufferRowLength = upload_pitch_in_texel;
|
||||
|
||||
upload_buffer = upload_heap.heap.get();
|
||||
|
||||
if (opt.require_upload)
|
||||
{
|
||||
ensure(!opt.deferred_cmds.empty());
|
||||
|
|
@ -1117,7 +1136,7 @@ namespace vk
|
|||
copy.size = copy_cmd.length;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (upload_buffer != scratch_buf || offset_in_upload_buffer != scratch_offset)
|
||||
{
|
||||
buffer_copies.push_back({});
|
||||
auto& copy = buffer_copies.back();
|
||||
|
|
@ -1163,7 +1182,7 @@ namespace vk
|
|||
range_ptr += op.second;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (!buffer_copies.empty())
|
||||
{
|
||||
vkCmdCopyBuffer(cmd2, upload_buffer->value, scratch_buf->value, static_cast<u32>(buffer_copies.size()), buffer_copies.data());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue