Browse Source

vulkan: initial support for clampzero and clampone wrap modes.

slime 2 years ago
parent
commit
3c3ba7d658
2 changed files with 12 additions and 5 deletions
  1. 10 3
      src/modules/graphics/vulkan/Graphics.cpp
  2. 2 2
      src/modules/graphics/vulkan/Vulkan.cpp

+ 10 - 3
src/modules/graphics/vulkan/Graphics.cpp

@@ -557,8 +557,8 @@ void Graphics::initCapabilities()
 {
 {
 	// fixme: unsure what the first few features are for.
 	// fixme: unsure what the first few features are for.
 	capabilities.features[FEATURE_MULTI_RENDER_TARGET_FORMATS] = true;
 	capabilities.features[FEATURE_MULTI_RENDER_TARGET_FORMATS] = true;
-	capabilities.features[FEATURE_CLAMP_ZERO] = false;
-	capabilities.features[FEATURE_CLAMP_ONE] = false;
+	capabilities.features[FEATURE_CLAMP_ZERO] = true;
+	capabilities.features[FEATURE_CLAMP_ONE] = true;
 	capabilities.features[FEATURE_BLEND_MINMAX] = false;
 	capabilities.features[FEATURE_BLEND_MINMAX] = false;
 	capabilities.features[FEATURE_LIGHTEN] = false;
 	capabilities.features[FEATURE_LIGHTEN] = false;
 	capabilities.features[FEATURE_FULL_NPOT] = false;
 	capabilities.features[FEATURE_FULL_NPOT] = false;
@@ -2527,7 +2527,14 @@ VkSampler Graphics::createSampler(const SamplerState &samplerState)
 	samplerInfo.addressModeW = Vulkan::getWrapMode(samplerState.wrapW);
 	samplerInfo.addressModeW = Vulkan::getWrapMode(samplerState.wrapW);
 	samplerInfo.anisotropyEnable = VK_TRUE;
 	samplerInfo.anisotropyEnable = VK_TRUE;
 	samplerInfo.maxAnisotropy = static_cast<float>(samplerState.maxAnisotropy);
 	samplerInfo.maxAnisotropy = static_cast<float>(samplerState.maxAnisotropy);
-	samplerInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
+
+	// TODO: This probably needs to branch on a pixel format to determine whether
+	// it should be float vs int, and opaque vs transparent.
+	bool clampone = samplerState.wrapU == SamplerState::WRAP_CLAMP_ONE
+		|| samplerState.wrapV == SamplerState::WRAP_CLAMP_ONE
+		|| samplerState.wrapW == SamplerState::WRAP_CLAMP_ONE;
+	samplerInfo.borderColor = clampone ? VK_BORDER_COLOR_INT_OPAQUE_WHITE : VK_BORDER_COLOR_INT_OPAQUE_BLACK;
+
 	samplerInfo.unnormalizedCoordinates = VK_FALSE;
 	samplerInfo.unnormalizedCoordinates = VK_FALSE;
 	if (samplerState.depthSampleMode.hasValue)
 	if (samplerState.depthSampleMode.hasValue)
 	{
 	{

+ 2 - 2
src/modules/graphics/vulkan/Vulkan.cpp

@@ -665,11 +665,11 @@ VkSamplerAddressMode Vulkan::getWrapMode(SamplerState::WrapMode mode)
 {
 {
 	switch (mode)
 	switch (mode)
 	{
 	{
-		//fixme: not accounting for different clamps (how does that work in vulkan?)
 	case SamplerState::WRAP_CLAMP:
 	case SamplerState::WRAP_CLAMP:
+		return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
 	case SamplerState::WRAP_CLAMP_ZERO:
 	case SamplerState::WRAP_CLAMP_ZERO:
 	case SamplerState::WRAP_CLAMP_ONE:
 	case SamplerState::WRAP_CLAMP_ONE:
-		return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
+		return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;
 	case SamplerState::WRAP_REPEAT:
 	case SamplerState::WRAP_REPEAT:
 		return VK_SAMPLER_ADDRESS_MODE_REPEAT;
 		return VK_SAMPLER_ADDRESS_MODE_REPEAT;
 	case SamplerState::WRAP_MIRRORED_REPEAT:
 	case SamplerState::WRAP_MIRRORED_REPEAT: