mirror of
https://github.com/InoriRus/Kyty.git
synced 2026-08-28 05:06:40 +00:00
render to mips
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "Emulator/Common.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#ifdef KYTY_EMU_ENABLED
|
||||
|
||||
namespace Kyty {
|
||||
@@ -18,25 +20,42 @@ class CommandBuffer;
|
||||
struct GraphicContext;
|
||||
struct VulkanBuffer;
|
||||
struct VulkanImage;
|
||||
struct TextureVulkanImage;
|
||||
struct DepthStencilVulkanImage;
|
||||
struct VulkanSwapchain;
|
||||
|
||||
struct BufferImageCopy
|
||||
{
|
||||
uint32_t offset;
|
||||
uint32_t pitch;
|
||||
uint32_t dst_level;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t pitch;
|
||||
int dst_x;
|
||||
int dst_y;
|
||||
};
|
||||
|
||||
struct ImageImageCopy
|
||||
{
|
||||
VulkanImage* src_image;
|
||||
uint32_t src_level;
|
||||
uint32_t dst_level;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
int src_x;
|
||||
int src_y;
|
||||
int dst_x;
|
||||
int dst_y;
|
||||
};
|
||||
|
||||
void UtilBufferToImage(CommandBuffer* buffer, VulkanBuffer* src_buffer, uint32_t src_pitch, VulkanImage* dst_image);
|
||||
void UtilBufferToImage(CommandBuffer* buffer, VulkanBuffer* src_buffer, TextureVulkanImage* dst_image,
|
||||
const Vector<BufferImageCopy>& regions, uint64_t dst_layout);
|
||||
void UtilBufferToImage(CommandBuffer* buffer, VulkanBuffer* src_buffer, VulkanImage* dst_image, const Vector<BufferImageCopy>& regions,
|
||||
uint64_t dst_layout);
|
||||
void UtilImageToImage(CommandBuffer* buffer, const Vector<ImageImageCopy>& regions, VulkanImage* dst_image, uint64_t dst_layout);
|
||||
void UtilBlitImage(CommandBuffer* buffer, VulkanImage* src_image, VulkanSwapchain* dst_swapchain);
|
||||
void UtilFillImage(GraphicContext* ctx, VulkanImage* dst_image, const void* src_data, uint64_t size, uint32_t src_pitch);
|
||||
void UtilFillImage(GraphicContext* ctx, TextureVulkanImage* dst_image, const void* src_data, uint64_t size,
|
||||
const Vector<BufferImageCopy>& regions, uint64_t dst_layout);
|
||||
void UtilFillImage(GraphicContext* ctx, VulkanImage* dst_image, const void* src_data, uint64_t size, const Vector<BufferImageCopy>& regions,
|
||||
uint64_t dst_layout);
|
||||
void UtilFillImage(GraphicContext* ctx, const Vector<ImageImageCopy>& regions, VulkanImage* dst_image, uint64_t dst_layout);
|
||||
void UtilCopyBuffer(VulkanBuffer* src_buffer, VulkanBuffer* dst_buffer, uint64_t size);
|
||||
void UtilSetDepthLayoutOptimal(DepthStencilVulkanImage* image);
|
||||
void UtilSetImageLayoutOptimal(VulkanImage* image);
|
||||
@@ -44,6 +63,31 @@ void UtilSetImageLayoutOptimal(VulkanImage* image);
|
||||
void VulkanCreateBuffer(GraphicContext* gctx, uint64_t size, VulkanBuffer* buffer);
|
||||
void VulkanDeleteBuffer(GraphicContext* gctx, VulkanBuffer* buffer);
|
||||
|
||||
inline std::pair<int, int> UtilCalcMipmapOffset(uint32_t lod, uint32_t width, uint32_t height)
|
||||
{
|
||||
uint32_t mip_width = width;
|
||||
uint32_t mip_height = height;
|
||||
int mip_x = 0;
|
||||
int mip_y = 0;
|
||||
|
||||
for (uint32_t i = 0; i < 16; i++)
|
||||
{
|
||||
if (i == lod)
|
||||
{
|
||||
return {mip_x, mip_y};
|
||||
}
|
||||
|
||||
bool odd = ((i & 1u) != 0);
|
||||
mip_x += static_cast<int>(odd ? mip_width : 0);
|
||||
mip_y += static_cast<int>(odd ? 0 : mip_height);
|
||||
|
||||
mip_width >>= (mip_width > 1 ? 1u : 0u);
|
||||
mip_height >>= (mip_height > 1 ? 1u : 0u);
|
||||
}
|
||||
|
||||
return {mip_x, mip_y};
|
||||
}
|
||||
|
||||
} // namespace Kyty::Libs::Graphics
|
||||
|
||||
#endif // KYTY_EMU_ENABLED
|
||||
|
||||
Reference in New Issue
Block a user