aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShahbaz Youssefi <syoussefi@google.com>2023-11-27 11:23:50 -0500
committerswiftshader-scoped@luci-project-accounts.iam.gserviceaccount.com <swiftshader-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-11-27 19:57:58 +0000
commit35b1a501141a4c77353376fc47121e95d2559e9a (patch)
treef1295ec80d6f67e56384d2c7a787546936bb898e
parent50dbfc35468c1ffa037e3e90bc71327d16a5e0cc (diff)
downloadswiftshader-35b1a501141a4c77353376fc47121e95d2559e9a.tar.gz
Make high precision filtering a build flag
The Vulkan extension used for this is not registered. The functionality is only used by Chromium, and so is turned into a build flag. This avoids having to register this extension with dubious arguments; it's only there to satisfy Chrome's stringent tests. Bug: chromium:726075 Change-Id: I6441135ae5280e935ce5d2a81b37ea47a7f0ccdf Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/72708 Presubmit-Ready: Shahbaz Youssefi <syoussefi@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Tested-by: Shahbaz Youssefi <syoussefi@google.com>
-rw-r--r--src/Pipeline/SpirvShaderSampling.cpp2
-rw-r--r--src/Vulkan/BUILD.gn51
-rw-r--r--src/Vulkan/VkSampler.cpp6
-rw-r--r--src/Vulkan/VkSampler.hpp6
-rw-r--r--src/Vulkan/libVulkan.cpp9
5 files changed, 31 insertions, 43 deletions
diff --git a/src/Pipeline/SpirvShaderSampling.cpp b/src/Pipeline/SpirvShaderSampling.cpp
index 5225a79f3..47ce57b64 100644
--- a/src/Pipeline/SpirvShaderSampling.cpp
+++ b/src/Pipeline/SpirvShaderSampling.cpp
@@ -66,7 +66,7 @@ SpirvEmitter::ImageSampler *SpirvEmitter::getImageSampler(const vk::Device *devi
samplerState.customBorder = vkSamplerState->customBorderColor;
samplerState.mipmapFilter = convertMipmapMode(vkSamplerState);
- samplerState.highPrecisionFiltering = (vkSamplerState->filteringPrecision == VK_SAMPLER_FILTERING_PRECISION_MODE_HIGH_GOOGLE);
+ samplerState.highPrecisionFiltering = vkSamplerState->highPrecisionFiltering;
samplerState.compareEnable = (vkSamplerState->compareEnable != VK_FALSE);
samplerState.compareOp = vkSamplerState->compareOp;
diff --git a/src/Vulkan/BUILD.gn b/src/Vulkan/BUILD.gn
index 5556abdf0..81ba736e8 100644
--- a/src/Vulkan/BUILD.gn
+++ b/src/Vulkan/BUILD.gn
@@ -12,18 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import("//build/config/ozone.gni")
import("//build_overrides/build.gni")
import("//build_overrides/wayland.gni")
-import("//build/config/ozone.gni")
import("../swiftshader.gni")
import("vulkan.gni")
# Need a separate config to ensure the warnings are added to the end.
config("swiftshader_libvulkan_private_config") {
if (is_linux) {
- defines = [
- "VK_EXPORT=__attribute__((visibility(\"default\")))",
- ]
+ defines = [ "VK_EXPORT=__attribute__((visibility(\"default\")))" ]
if (ozone_platform_x11) {
defines += [ "VK_USE_PLATFORM_XCB_KHR" ]
}
@@ -31,9 +29,7 @@ config("swiftshader_libvulkan_private_config") {
defines += [ "VK_USE_PLATFORM_WAYLAND_KHR" ]
}
} else if (is_chromeos) {
- defines = [
- "VK_EXPORT=__attribute__((visibility(\"default\")))",
- ]
+ defines = [ "VK_EXPORT=__attribute__((visibility(\"default\")))" ]
} else if (is_fuchsia) {
defines = [
"VK_USE_PLATFORM_FUCHSIA=1",
@@ -62,10 +58,16 @@ config("swiftshader_libvulkan_private_config") {
}
defines += [
- "SWIFTSHADER_ENABLE_ASTC", # TODO(b/150130101)
- "SWIFTSHADER_LEGACY_PRECISION=true", # TODO(chromium:1299047)
- "SWIFTSHADER_ZERO_INITIALIZE_DEVICE_MEMORY",
+ "SWIFTSHADER_ENABLE_ASTC", # TODO(b/150130101)
+ "SWIFTSHADER_LEGACY_PRECISION=true", # TODO(chromium:1299047)
+ "SWIFTSHADER_ZERO_INITIALIZE_DEVICE_MEMORY",
]
+
+ if (build_with_chromium) {
+ # Chromium requires higher precision filtering to pass the layout tests with SwiftShader.
+ # http://crbug.com/726075
+ defines += [ "SWIFTSHADER_HIGH_PRECISION_FILTERING" ]
+ }
}
swiftshader_source_set("swiftshader_libvulkan_headers") {
@@ -118,9 +120,7 @@ swiftshader_source_set("swiftshader_libvulkan_headers") {
"VkSemaphoreExternalLinux.hpp",
]
} else if (is_mac) {
- sources += [
- "VkDeviceMemoryExternalMac.hpp",
- ]
+ sources += [ "VkDeviceMemoryExternalMac.hpp" ]
} else if (is_fuchsia) {
sources += [ "VkSemaphoreExternalFuchsia.hpp" ]
}
@@ -195,21 +195,20 @@ swiftshader_shared_library("swiftshader_libvulkan") {
rebase_path("vk_swiftshader.exports", root_build_dir),
]
} else if (is_linux || is_chromeos || is_fuchsia) {
- inputs = [
- "vk_swiftshader.lds",
- ]
+ inputs = [ "vk_swiftshader.lds" ]
ldflags = [
# -Bsymbolic binds symbol references to their global definitions within
# a shared object, thereby preventing symbol preemption.
"-Wl,-Bsymbolic",
"-Wl,--version-script=" +
- rebase_path("vk_swiftshader.lds", root_build_dir) ]
+ rebase_path("vk_swiftshader.lds", root_build_dir),
+ ]
}
deps = [
+ "../../third_party/SPIRV-Tools:spvtools_headers",
"../../third_party/SPIRV-Tools:spvtools_opt",
"../../third_party/SPIRV-Tools:spvtools_val",
- "../../third_party/SPIRV-Tools:spvtools_headers",
"../../third_party/marl:Marl",
"../Device",
"../Pipeline",
@@ -225,9 +224,7 @@ swiftshader_shared_library("swiftshader_libvulkan") {
"../../third_party/SPIRV-Headers/include",
]
- public_deps = [
- ":swiftshader_libvulkan_headers",
- ]
+ public_deps = [ ":swiftshader_libvulkan_headers" ]
}
# Generates an ICD JSON file that can be used by all targets in this GN build
@@ -256,14 +253,8 @@ action("icd_file") {
library_path,
]
- inputs = [
- input_file,
- ]
- outputs = [
- output_icd_file,
- ]
+ inputs = [ input_file ]
+ outputs = [ output_icd_file ]
- deps = [
- ":swiftshader_libvulkan",
- ]
+ deps = [ ":swiftshader_libvulkan" ]
}
diff --git a/src/Vulkan/VkSampler.cpp b/src/Vulkan/VkSampler.cpp
index 1458fa31f..0458f0adf 100644
--- a/src/Vulkan/VkSampler.cpp
+++ b/src/Vulkan/VkSampler.cpp
@@ -17,7 +17,7 @@
namespace vk {
SamplerState::SamplerState(const VkSamplerCreateInfo *pCreateInfo, const vk::SamplerYcbcrConversion *ycbcrConversion,
- VkSamplerFilteringPrecisionModeGOOGLE filteringPrecision, const VkClearColorValue &customBorderColor)
+ const VkClearColorValue &customBorderColor)
: Memset(this, 0)
, magFilter(pCreateInfo->magFilter)
, minFilter(pCreateInfo->minFilter)
@@ -35,7 +35,9 @@ SamplerState::SamplerState(const VkSamplerCreateInfo *pCreateInfo, const vk::Sam
, borderColor(pCreateInfo->borderColor)
, customBorderColor(customBorderColor)
, unnormalizedCoordinates(pCreateInfo->unnormalizedCoordinates)
- , filteringPrecision(filteringPrecision)
+#ifdef SWIFTSHADER_HIGH_PRECISION_FILTERING
+ , highPrecisionFiltering(true)
+#endif
{
if(ycbcrConversion)
{
diff --git a/src/Vulkan/VkSampler.hpp b/src/Vulkan/VkSampler.hpp
index 868418879..4a627c18b 100644
--- a/src/Vulkan/VkSampler.hpp
+++ b/src/Vulkan/VkSampler.hpp
@@ -27,7 +27,7 @@ namespace vk {
struct SamplerState : sw::Memset<SamplerState>
{
SamplerState(const VkSamplerCreateInfo *pCreateInfo, const vk::SamplerYcbcrConversion *ycbcrConversion,
- VkSamplerFilteringPrecisionModeGOOGLE filteringPrecision, const VkClearColorValue &customBorderColor);
+ const VkClearColorValue &customBorderColor);
// Prevents accessing mipmap levels out of range.
static float ClampLod(float lod)
@@ -53,7 +53,7 @@ struct SamplerState : sw::Memset<SamplerState>
const VkBool32 unnormalizedCoordinates = VK_FALSE;
VkSamplerYcbcrModelConversion ycbcrModel = VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY;
- const VkSamplerFilteringPrecisionModeGOOGLE filteringPrecision = VK_SAMPLER_FILTERING_PRECISION_MODE_LOW_GOOGLE;
+ const bool highPrecisionFiltering = false;
bool studioSwing = false; // Narrow range
bool swappedChroma = false; // Cb/Cr components in reverse order
};
@@ -115,4 +115,4 @@ static inline SamplerYcbcrConversion *Cast(VkSamplerYcbcrConversion object)
} // namespace vk
-#endif // VK_SAMPLER_HPP_ \ No newline at end of file
+#endif // VK_SAMPLER_HPP_
diff --git a/src/Vulkan/libVulkan.cpp b/src/Vulkan/libVulkan.cpp
index 626499e8e..4d9a94d9e 100644
--- a/src/Vulkan/libVulkan.cpp
+++ b/src/Vulkan/libVulkan.cpp
@@ -2485,7 +2485,6 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateSampler(VkDevice device, const VkSamplerC
const VkBaseInStructure *extensionCreateInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
const vk::SamplerYcbcrConversion *ycbcrConversion = nullptr;
- VkSamplerFilteringPrecisionModeGOOGLE filteringPrecision = VK_SAMPLER_FILTERING_PRECISION_MODE_LOW_GOOGLE;
VkClearColorValue borderColor = {};
while(extensionCreateInfo)
@@ -2501,11 +2500,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateSampler(VkDevice device, const VkSamplerC
break;
#if !defined(__ANDROID__)
case VK_STRUCTURE_TYPE_SAMPLER_FILTERING_PRECISION_GOOGLE:
- {
- const VkSamplerFilteringPrecisionGOOGLE *filteringInfo =
- reinterpret_cast<const VkSamplerFilteringPrecisionGOOGLE *>(extensionCreateInfo);
- filteringPrecision = filteringInfo->samplerFilteringPrecisionMode;
- }
+ // Ignore. Deprecated.
break;
#endif
case VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT:
@@ -2524,7 +2519,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateSampler(VkDevice device, const VkSamplerC
extensionCreateInfo = extensionCreateInfo->pNext;
}
- vk::SamplerState samplerState(pCreateInfo, ycbcrConversion, filteringPrecision, borderColor);
+ vk::SamplerState samplerState(pCreateInfo, ycbcrConversion, borderColor);
uint32_t samplerID = vk::Cast(device)->indexSampler(samplerState);
VkResult result = vk::Sampler::Create(pAllocator, pCreateInfo, pSampler, samplerState, samplerID);