mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 18:53:28 +01:00
vulkan: Move vk_wrap_mode and max_aniso to vkFormat
This commit is contained in:
parent
b6bcdade81
commit
4484e8c3f0
@ -39,4 +39,38 @@ VkFormat get_compatible_depth_surface_format(const gpu_formats_support &support,
|
||||
throw EXCEPTION("Invalid format (0x%x)", format);
|
||||
}
|
||||
|
||||
VkSamplerAddressMode vk_wrap_mode(u32 gcm_wrap)
|
||||
{
|
||||
switch (gcm_wrap)
|
||||
{
|
||||
case CELL_GCM_TEXTURE_WRAP: return VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
case CELL_GCM_TEXTURE_MIRROR: return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT;
|
||||
case CELL_GCM_TEXTURE_CLAMP_TO_EDGE: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
||||
case CELL_GCM_TEXTURE_BORDER: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;
|
||||
case CELL_GCM_TEXTURE_CLAMP: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP_TO_EDGE: return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE;
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_BORDER: return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE;
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP: return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE;
|
||||
default:
|
||||
throw EXCEPTION("unhandled texture clamp mode 0x%X", gcm_wrap);
|
||||
}
|
||||
}
|
||||
|
||||
float max_aniso(u32 gcm_aniso)
|
||||
{
|
||||
switch (gcm_aniso)
|
||||
{
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_1: return 1.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_2: return 2.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_4: return 4.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_6: return 6.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_8: return 8.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_10: return 10.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_12: return 12.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_16: return 16.0f;
|
||||
}
|
||||
|
||||
throw EXCEPTION("Texture anisotropy error: bad max aniso (%d).", gcm_aniso);
|
||||
}
|
||||
|
||||
}
|
@ -11,4 +11,6 @@ namespace vk
|
||||
|
||||
gpu_formats_support get_optimal_tiling_supported_formats(VkPhysicalDevice physical_device);
|
||||
VkFormat get_compatible_depth_surface_format(const gpu_formats_support &support, rsx::surface_depth_format format);
|
||||
VkSamplerAddressMode vk_wrap_mode(u32 gcm_wrap);
|
||||
float max_aniso(u32 gcm_aniso);
|
||||
}
|
@ -357,9 +357,6 @@ namespace vk
|
||||
|
||||
vk::texture *staging_texture = nullptr;
|
||||
bool ready = false;
|
||||
|
||||
VkSamplerAddressMode vk_wrap_mode(u32 gcm_wrap_mode);
|
||||
float max_aniso(u32 gcm_aniso);
|
||||
void sampler_setup(rsx::texture& tex, VkImageViewType type, VkComponentMapping swizzle);
|
||||
|
||||
public:
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "../RSXTexture.h"
|
||||
#include "../rsx_utils.h"
|
||||
#include "../Common/TextureUtils.h"
|
||||
#include "VKFormats.h"
|
||||
|
||||
namespace vk
|
||||
{
|
||||
@ -268,46 +269,11 @@ namespace vk
|
||||
create(device, format, usage, tiling, width, height, mipmaps, gpu_only, swizzle);
|
||||
}
|
||||
|
||||
VkSamplerAddressMode texture::vk_wrap_mode(u32 gcm_wrap)
|
||||
{
|
||||
switch (gcm_wrap)
|
||||
{
|
||||
case CELL_GCM_TEXTURE_WRAP: return VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
case CELL_GCM_TEXTURE_MIRROR: return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT;
|
||||
case CELL_GCM_TEXTURE_CLAMP_TO_EDGE: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
||||
case CELL_GCM_TEXTURE_BORDER: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;
|
||||
case CELL_GCM_TEXTURE_CLAMP: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP_TO_EDGE: return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE;
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_BORDER: return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE;
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP: return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE;
|
||||
default:
|
||||
throw EXCEPTION("unhandled texture clamp mode 0x%X", gcm_wrap);
|
||||
}
|
||||
}
|
||||
|
||||
float texture::max_aniso(u32 gcm_aniso)
|
||||
{
|
||||
switch (gcm_aniso)
|
||||
{
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_1: return 1.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_2: return 2.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_4: return 4.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_6: return 6.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_8: return 8.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_10: return 10.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_12: return 12.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_16: return 16.0f;
|
||||
}
|
||||
|
||||
LOG_ERROR(RSX, "Texture anisotropy error: bad max aniso (%d).", gcm_aniso);
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
void texture::sampler_setup(rsx::texture &tex, VkImageViewType type, VkComponentMapping swizzle)
|
||||
{
|
||||
VkSamplerAddressMode clamp_s = vk_wrap_mode(tex.wrap_s());
|
||||
VkSamplerAddressMode clamp_t = vk_wrap_mode(tex.wrap_t());
|
||||
VkSamplerAddressMode clamp_r = vk_wrap_mode(tex.wrap_r());
|
||||
VkSamplerAddressMode clamp_s = vk::vk_wrap_mode(tex.wrap_s());
|
||||
VkSamplerAddressMode clamp_t = vk::vk_wrap_mode(tex.wrap_t());
|
||||
VkSamplerAddressMode clamp_r = vk::vk_wrap_mode(tex.wrap_r());
|
||||
|
||||
VkSamplerCreateInfo sampler_info = {};
|
||||
sampler_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
||||
@ -318,7 +284,7 @@ namespace vk
|
||||
sampler_info.compareEnable = VK_FALSE;
|
||||
sampler_info.unnormalizedCoordinates = !!(tex.format() & CELL_GCM_TEXTURE_UN);
|
||||
sampler_info.mipLodBias = tex.bias();
|
||||
sampler_info.maxAnisotropy = max_aniso(tex.max_aniso());
|
||||
sampler_info.maxAnisotropy = vk::max_aniso(tex.max_aniso());
|
||||
sampler_info.maxLod = tex.max_lod();
|
||||
sampler_info.minLod = tex.min_lod();
|
||||
sampler_info.magFilter = VK_FILTER_LINEAR;
|
||||
|
Loading…
Reference in New Issue
Block a user