mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Software renderer: Use hardware color conversion on Vulkan in 5551 16-bit mode
This commit is contained in:
parent
3a0804a7dd
commit
58568632e8
3 changed files with 31 additions and 6 deletions
|
@ -163,6 +163,9 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) {
|
|||
// For accuracy, try to handle 0 stride - sometimes used.
|
||||
if (displayStride_ == 0) {
|
||||
srcheight = 1;
|
||||
u1 = 1.0f;
|
||||
} else {
|
||||
u1 = (float)srcwidth / displayStride_;
|
||||
}
|
||||
|
||||
Draw::TextureDesc desc{};
|
||||
|
@ -181,11 +184,13 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) {
|
|||
desc.height = srcheight;
|
||||
desc.initData.push_back(data);
|
||||
desc.format = Draw::DataFormat::R8G8B8A8_UNORM;
|
||||
if (displayStride_ != 0) {
|
||||
u1 = (float)srcwidth / displayStride_;
|
||||
} else {
|
||||
u1 = 1.0f;
|
||||
}
|
||||
} else if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN && displayFormat_ == GE_FORMAT_5551) {
|
||||
u8 *data = Memory::GetPointer(displayFramebuf_);
|
||||
desc.swizzle = Draw::TextureSwizzle::BGRA;
|
||||
desc.format = Draw::DataFormat::A1R5G5B5_UNORM_PACK16;
|
||||
desc.width = displayStride_ == 0 ? srcwidth : displayStride_;
|
||||
desc.height = srcheight;
|
||||
desc.initData.push_back(data);
|
||||
} else {
|
||||
// TODO: This should probably be converted in a shader instead..
|
||||
fbTexBuffer.resize(srcwidth * srcheight);
|
||||
|
|
|
@ -515,9 +515,16 @@ struct DeviceCaps {
|
|||
std::string deviceName; // The device name to use when creating the thin3d context, to get the same one.
|
||||
};
|
||||
|
||||
// Some predefined swizzle
|
||||
enum class TextureSwizzle {
|
||||
NO_SWIZZLE = 0,
|
||||
BGRA = 1,
|
||||
};
|
||||
|
||||
struct TextureDesc {
|
||||
TextureType type;
|
||||
DataFormat format;
|
||||
TextureSwizzle swizzle;
|
||||
int width;
|
||||
int height;
|
||||
int depth;
|
||||
|
|
|
@ -699,7 +699,20 @@ bool VKTexture::Create(VkCommandBuffer cmd, VulkanPushBuffer *push, const Textur
|
|||
// Gonna have to generate some, which requires TRANSFER_SRC
|
||||
usageBits |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
||||
}
|
||||
if (!vkTex_->CreateDirect(cmd, alloc, width_, height_, mipLevels_, vulkanFormat, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, usageBits)) {
|
||||
|
||||
VkComponentMapping mapping{}; // Defaults to no swizzle
|
||||
switch (desc.swizzle) {
|
||||
case TextureSwizzle::NO_SWIZZLE:
|
||||
break;
|
||||
case TextureSwizzle::BGRA:
|
||||
mapping.r = VK_COMPONENT_SWIZZLE_B;
|
||||
mapping.g = VK_COMPONENT_SWIZZLE_G;
|
||||
mapping.b = VK_COMPONENT_SWIZZLE_R;
|
||||
mapping.a = VK_COMPONENT_SWIZZLE_A;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!vkTex_->CreateDirect(cmd, alloc, width_, height_, mipLevels_, vulkanFormat, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, usageBits, &mapping)) {
|
||||
ELOG("Failed to create VulkanTexture: %dx%dx%d fmt %d, %d levels", width_, height_, depth_, (int)vulkanFormat, mipLevels_);
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue