mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-25 17:37:07 +02:00
[vk, spir-v] Adding emulation of Array 1D with 2D for Android
This commit is contained in:
parent
6c1fc4b4ed
commit
89926bce0b
1 changed files with 39 additions and 11 deletions
|
|
@ -66,10 +66,20 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] VkImageType ConvertImageType(const ImageType type) {
|
[[nodiscard]] VkImageType ConvertImageType(const ImageType type, const Device& device) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ImageType::e1D:
|
case ImageType::e1D:
|
||||||
return VK_IMAGE_TYPE_1D;
|
// Mobile Vulkan (Adreno, Mali, PowerVR, IMG) lacks Sampled1D SPIR-V capability
|
||||||
|
// Emulate as 2D texture with height=1 on mobile, use native 1D on desktop
|
||||||
|
{
|
||||||
|
const auto driver_id = device.GetDriverID();
|
||||||
|
const bool is_mobile = driver_id == VK_DRIVER_ID_QUALCOMM_PROPRIETARY ||
|
||||||
|
driver_id == VK_DRIVER_ID_MESA_TURNIP ||
|
||||||
|
driver_id == VK_DRIVER_ID_ARM_PROPRIETARY ||
|
||||||
|
driver_id == VK_DRIVER_ID_BROADCOM_PROPRIETARY ||
|
||||||
|
driver_id == VK_DRIVER_ID_IMAGINATION_PROPRIETARY;
|
||||||
|
return is_mobile ? VK_IMAGE_TYPE_2D : VK_IMAGE_TYPE_1D;
|
||||||
|
}
|
||||||
case ImageType::e2D:
|
case ImageType::e2D:
|
||||||
case ImageType::Linear:
|
case ImageType::Linear:
|
||||||
return VK_IMAGE_TYPE_2D;
|
return VK_IMAGE_TYPE_2D;
|
||||||
|
|
@ -141,7 +151,7 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
.flags = flags,
|
.flags = flags,
|
||||||
.imageType = ConvertImageType(info.type),
|
.imageType = ConvertImageType(info.type, device),
|
||||||
.format = format_info.format,
|
.format = format_info.format,
|
||||||
.extent{
|
.extent{
|
||||||
.width = info.size.width >> samples_x,
|
.width = info.size.width >> samples_x,
|
||||||
|
|
@ -306,10 +316,18 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
|
||||||
return VK_COMPONENT_SWIZZLE_ZERO;
|
return VK_COMPONENT_SWIZZLE_ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] VkImageViewType ImageViewType(Shader::TextureType type) {
|
[[nodiscard]] VkImageViewType ImageViewType(Shader::TextureType type, const Device& device) {
|
||||||
|
const auto driver_id = device.GetDriverID();
|
||||||
|
const bool is_mobile = driver_id == VK_DRIVER_ID_QUALCOMM_PROPRIETARY ||
|
||||||
|
driver_id == VK_DRIVER_ID_MESA_TURNIP ||
|
||||||
|
driver_id == VK_DRIVER_ID_ARM_PROPRIETARY ||
|
||||||
|
driver_id == VK_DRIVER_ID_BROADCOM_PROPRIETARY ||
|
||||||
|
driver_id == VK_DRIVER_ID_IMAGINATION_PROPRIETARY;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Shader::TextureType::Color1D:
|
case Shader::TextureType::Color1D:
|
||||||
return VK_IMAGE_VIEW_TYPE_1D;
|
// Emulate 1D as 2D with height=1 on mobile (no Sampled1D capability)
|
||||||
|
return is_mobile ? VK_IMAGE_VIEW_TYPE_2D : VK_IMAGE_VIEW_TYPE_1D;
|
||||||
case Shader::TextureType::Color2D:
|
case Shader::TextureType::Color2D:
|
||||||
case Shader::TextureType::Color2DRect:
|
case Shader::TextureType::Color2DRect:
|
||||||
return VK_IMAGE_VIEW_TYPE_2D;
|
return VK_IMAGE_VIEW_TYPE_2D;
|
||||||
|
|
@ -318,7 +336,8 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
|
||||||
case Shader::TextureType::Color3D:
|
case Shader::TextureType::Color3D:
|
||||||
return VK_IMAGE_VIEW_TYPE_3D;
|
return VK_IMAGE_VIEW_TYPE_3D;
|
||||||
case Shader::TextureType::ColorArray1D:
|
case Shader::TextureType::ColorArray1D:
|
||||||
return VK_IMAGE_VIEW_TYPE_1D_ARRAY;
|
// Emulate 1D array as 2D array with height=1 on mobile
|
||||||
|
return is_mobile ? VK_IMAGE_VIEW_TYPE_2D_ARRAY : VK_IMAGE_VIEW_TYPE_1D_ARRAY;
|
||||||
case Shader::TextureType::ColorArray2D:
|
case Shader::TextureType::ColorArray2D:
|
||||||
return VK_IMAGE_VIEW_TYPE_2D_ARRAY;
|
return VK_IMAGE_VIEW_TYPE_2D_ARRAY;
|
||||||
case Shader::TextureType::ColorArrayCube:
|
case Shader::TextureType::ColorArrayCube:
|
||||||
|
|
@ -331,10 +350,18 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
|
||||||
return VK_IMAGE_VIEW_TYPE_2D;
|
return VK_IMAGE_VIEW_TYPE_2D;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] VkImageViewType ImageViewType(VideoCommon::ImageViewType type) {
|
[[nodiscard]] VkImageViewType ImageViewType(VideoCommon::ImageViewType type, const Device& device) {
|
||||||
|
const auto driver_id = device.GetDriverID();
|
||||||
|
const bool is_mobile = driver_id == VK_DRIVER_ID_QUALCOMM_PROPRIETARY ||
|
||||||
|
driver_id == VK_DRIVER_ID_MESA_TURNIP ||
|
||||||
|
driver_id == VK_DRIVER_ID_ARM_PROPRIETARY ||
|
||||||
|
driver_id == VK_DRIVER_ID_BROADCOM_PROPRIETARY ||
|
||||||
|
driver_id == VK_DRIVER_ID_IMAGINATION_PROPRIETARY;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case VideoCommon::ImageViewType::e1D:
|
case VideoCommon::ImageViewType::e1D:
|
||||||
return VK_IMAGE_VIEW_TYPE_1D;
|
// Emulate 1D as 2D with height=1 on mobile (no Sampled1D capability)
|
||||||
|
return is_mobile ? VK_IMAGE_VIEW_TYPE_2D : VK_IMAGE_VIEW_TYPE_1D;
|
||||||
case VideoCommon::ImageViewType::e2D:
|
case VideoCommon::ImageViewType::e2D:
|
||||||
case VideoCommon::ImageViewType::Rect:
|
case VideoCommon::ImageViewType::Rect:
|
||||||
return VK_IMAGE_VIEW_TYPE_2D;
|
return VK_IMAGE_VIEW_TYPE_2D;
|
||||||
|
|
@ -343,7 +370,8 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
|
||||||
case VideoCommon::ImageViewType::e3D:
|
case VideoCommon::ImageViewType::e3D:
|
||||||
return VK_IMAGE_VIEW_TYPE_3D;
|
return VK_IMAGE_VIEW_TYPE_3D;
|
||||||
case VideoCommon::ImageViewType::e1DArray:
|
case VideoCommon::ImageViewType::e1DArray:
|
||||||
return VK_IMAGE_VIEW_TYPE_1D_ARRAY;
|
// Emulate 1D array as 2D array with height=1 on mobile
|
||||||
|
return is_mobile ? VK_IMAGE_VIEW_TYPE_2D_ARRAY : VK_IMAGE_VIEW_TYPE_1D_ARRAY;
|
||||||
case VideoCommon::ImageViewType::e2DArray:
|
case VideoCommon::ImageViewType::e2DArray:
|
||||||
return VK_IMAGE_VIEW_TYPE_2D_ARRAY;
|
return VK_IMAGE_VIEW_TYPE_2D_ARRAY;
|
||||||
case VideoCommon::ImageViewType::CubeArray:
|
case VideoCommon::ImageViewType::CubeArray:
|
||||||
|
|
@ -2119,7 +2147,7 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI
|
||||||
};
|
};
|
||||||
const auto create = [&](TextureType tex_type, std::optional<u32> num_layers) {
|
const auto create = [&](TextureType tex_type, std::optional<u32> num_layers) {
|
||||||
VkImageViewCreateInfo ci{create_info};
|
VkImageViewCreateInfo ci{create_info};
|
||||||
ci.viewType = ImageViewType(tex_type);
|
ci.viewType = ImageViewType(tex_type, *device);
|
||||||
if (num_layers) {
|
if (num_layers) {
|
||||||
ci.subresourceRange.layerCount = *num_layers;
|
ci.subresourceRange.layerCount = *num_layers;
|
||||||
}
|
}
|
||||||
|
|
@ -2260,7 +2288,7 @@ vk::ImageView ImageView::MakeView(VkFormat vk_format, VkImageAspectFlags aspect_
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.image = image_handle,
|
.image = image_handle,
|
||||||
.viewType = ImageViewType(type),
|
.viewType = ImageViewType(type, *device),
|
||||||
.format = vk_format,
|
.format = vk_format,
|
||||||
.components{
|
.components{
|
||||||
.r = VK_COMPONENT_SWIZZLE_IDENTITY,
|
.r = VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue