renderer_vulkan: Rework format handling
* This is a pretty large commit that aims to solve some issues with the current format system * The instance now builds at application initialization an array of format traits for each pixel format that includes information such as blit/attachment/storage support and fallback formats * The runtime doesn't ask the instance for formats but receives these traits and can dedice on its own what to build For now we do the same as before, we require both blit and attachment support * Morton swizzling also sees many bug fixes. The previous code was very hacky and didn't work for partial texture updates. It was also inconsistent, as it would take a tiled_buffer and write to the middle of linear * Now the functions have been greatly simplified and adjusted to work better with std::span. This fixes out of bounds errors and texture glitches (like the display in Mario Kart 7)
This commit is contained in:
@ -11,18 +11,22 @@
|
||||
|
||||
namespace VideoCore {
|
||||
|
||||
void SwizzleTexture(const SurfaceParams& params, u32 start_offset, u32 end_offset,
|
||||
void SwizzleTexture(const SurfaceParams& swizzle_info, PAddr start_addr, PAddr end_addr,
|
||||
std::span<std::byte> source_linear, std::span<std::byte> dest_tiled) {
|
||||
const u32 func_index = static_cast<u32>(params.pixel_format);
|
||||
const u32 func_index = static_cast<u32>(swizzle_info.pixel_format);
|
||||
const MortonFunc SwizzleImpl = SWIZZLE_TABLE[func_index];
|
||||
SwizzleImpl(params.stride, params.height, start_offset, end_offset, source_linear, dest_tiled);
|
||||
SwizzleImpl(swizzle_info.width, swizzle_info.height,
|
||||
start_addr - swizzle_info.addr, end_addr - swizzle_info.addr,
|
||||
source_linear, dest_tiled);
|
||||
}
|
||||
|
||||
void UnswizzleTexture(const SurfaceParams& params, u32 start_offset, u32 end_offset,
|
||||
void UnswizzleTexture(const SurfaceParams& unswizzle_info, PAddr start_addr, PAddr end_addr,
|
||||
std::span<std::byte> source_tiled, std::span<std::byte> dest_linear) {
|
||||
const u32 func_index = static_cast<u32>(params.pixel_format);
|
||||
const u32 func_index = static_cast<u32>(unswizzle_info.pixel_format);
|
||||
const MortonFunc UnswizzleImpl = UNSWIZZLE_TABLE[func_index];
|
||||
UnswizzleImpl(params.stride, params.height, start_offset, end_offset, dest_linear, source_tiled);
|
||||
UnswizzleImpl(unswizzle_info.width, unswizzle_info.height,
|
||||
start_addr - unswizzle_info.addr, end_addr - unswizzle_info.addr,
|
||||
dest_linear, source_tiled);
|
||||
}
|
||||
|
||||
ClearValue MakeClearValue(SurfaceType type, PixelFormat format, const u8* fill_data) {
|
||||
|
Reference in New Issue
Block a user