vk: push back border color to sampler (#1832)

* vk: push back border color to sampler

* use approximate color

* Add TODO for VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK
This commit is contained in:
raven02 2016-06-26 21:25:25 +08:00 committed by GitHub
parent 4a08e8cd0b
commit d69a4173fa
4 changed files with 14 additions and 3 deletions

View File

@ -65,6 +65,16 @@ VkFilter get_mag_filter(rsx::texture_magnify_filter mag_filter)
throw EXCEPTION("Invalid mag filter (0x%x)", mag_filter); throw EXCEPTION("Invalid mag filter (0x%x)", mag_filter);
} }
VkBorderColor get_border_color(u8 color)
{
if ((color / 0x10) >= 0x8)
return VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE;
else
return VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK;
// TODO: VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK
}
VkSamplerAddressMode vk_wrap_mode(rsx::texture_wrap_mode gcm_wrap) VkSamplerAddressMode vk_wrap_mode(rsx::texture_wrap_mode gcm_wrap)
{ {
switch (gcm_wrap) switch (gcm_wrap)

View File

@ -15,6 +15,7 @@ namespace vk
VkStencilOp get_stencil_op(u32 op); VkStencilOp get_stencil_op(u32 op);
VkLogicOp get_logic_op(u32 op); VkLogicOp get_logic_op(u32 op);
VkFrontFace get_front_face_ccw(u32 ffv); VkFrontFace get_front_face_ccw(u32 ffv);
VkBorderColor get_border_color(u8 color);
std::tuple<VkFilter, VkSamplerMipmapMode> get_min_filter_and_mip(rsx::texture_minify_filter min_filter); std::tuple<VkFilter, VkSamplerMipmapMode> get_min_filter_and_mip(rsx::texture_minify_filter min_filter);
VkFilter get_mag_filter(rsx::texture_magnify_filter mag_filter); VkFilter get_mag_filter(rsx::texture_magnify_filter mag_filter);

View File

@ -655,7 +655,7 @@ void VKGSRender::end()
vk::vk_wrap_mode(textures[i].wrap_s()), vk::vk_wrap_mode(textures[i].wrap_t()), vk::vk_wrap_mode(textures[i].wrap_r()), vk::vk_wrap_mode(textures[i].wrap_s()), vk::vk_wrap_mode(textures[i].wrap_t()), vk::vk_wrap_mode(textures[i].wrap_r()),
!!(textures[i].format() & CELL_GCM_TEXTURE_UN), !!(textures[i].format() & CELL_GCM_TEXTURE_UN),
textures[i].bias(), vk::max_aniso(textures[i].max_aniso()), textures[i].min_lod(), textures[i].max_lod(), textures[i].bias(), vk::max_aniso(textures[i].max_aniso()), textures[i].min_lod(), textures[i].max_lod(),
min_filter, vk::get_mag_filter(textures[i].mag_filter()), mip_mode min_filter, vk::get_mag_filter(textures[i].mag_filter()), mip_mode, vk::get_border_color(textures[i].border_color())
)); ));
m_program->bind_uniform({ m_sampler_to_clean.back()->value, texture0->value, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }, "tex" + std::to_string(i), descriptor_sets); m_program->bind_uniform({ m_sampler_to_clean.back()->value, texture0->value, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }, "tex" + std::to_string(i), descriptor_sets);
} }

View File

@ -552,7 +552,7 @@ namespace vk
sampler(VkDevice dev, VkSamplerAddressMode clamp_u, VkSamplerAddressMode clamp_v, VkSamplerAddressMode clamp_w, sampler(VkDevice dev, VkSamplerAddressMode clamp_u, VkSamplerAddressMode clamp_v, VkSamplerAddressMode clamp_w,
bool unnormalized_coordinates, float mipLodBias, float max_anisotropy, float min_lod, float max_lod, bool unnormalized_coordinates, float mipLodBias, float max_anisotropy, float min_lod, float max_lod,
VkFilter min_filter, VkFilter mag_filter, VkSamplerMipmapMode mipmap_mode) VkFilter min_filter, VkFilter mag_filter, VkSamplerMipmapMode mipmap_mode, VkBorderColor border_color)
: m_device(dev) : m_device(dev)
{ {
VkSamplerCreateInfo info = {}; VkSamplerCreateInfo info = {};
@ -571,7 +571,7 @@ namespace vk
info.minFilter = min_filter; info.minFilter = min_filter;
info.mipmapMode = mipmap_mode; info.mipmapMode = mipmap_mode;
info.compareOp = VK_COMPARE_OP_NEVER; info.compareOp = VK_COMPARE_OP_NEVER;
info.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK; info.borderColor = border_color;
CHECK_RESULT(vkCreateSampler(m_device, &info, nullptr, &value)); CHECK_RESULT(vkCreateSampler(m_device, &info, nullptr, &value));
} }