vulkan: Tweaks to sampler state fallback paths

- Make all texture access on non-existent textures return 0
- If border color is closer to 0, then set alpha to 0 as well (might break some corner cases with alpha test)
- Zero initialize null sampler
This commit is contained in:
kd-11 2017-12-21 16:27:26 +03:00
parent 4819847c46
commit 8b31a9448a
2 changed files with 13 additions and 7 deletions

View File

@ -71,12 +71,11 @@ VkFilter get_mag_filter(rsx::texture_magnify_filter mag_filter)
VkBorderColor get_border_color(u8 color)
{
// TODO: Handle simulated alpha tests and modify texture operations accordingly
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
return VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
}
VkSamplerAddressMode vk_wrap_mode(rsx::texture_wrap_mode gcm_wrap)

View File

@ -194,9 +194,9 @@ namespace vk
VkSamplerCreateInfo sampler_info = {};
sampler_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
sampler_info.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;
sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;
sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;
sampler_info.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
sampler_info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST;
sampler_info.anisotropyEnable = VK_FALSE;
sampler_info.compareEnable = VK_FALSE;
@ -225,7 +225,14 @@ namespace vk
VK_FORMAT_B8G8R8A8_UNORM, {VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A},
{VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}));
change_image_layout(cmd, g_null_texture.get(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1});
// Initialize memory to transparent black
VkClearColorValue clear_color = {};
VkImageSubresourceRange range = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 };
change_image_layout(cmd, g_null_texture.get(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, range);
vkCmdClearColorImage(cmd, g_null_texture->value, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clear_color, 1, &range);
// Prep for shader access
change_image_layout(cmd, g_null_texture.get(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, range);
return g_null_image_view->value;
}