Use Nucleus::adjustDefaultConfig for Vulkan's default reactor config.
Remove all the explicit config passing to each of the functions.
Bug: b/137167988
Change-Id: Ie8ea956d2365f1901d75b0d10c9e649485d78bf4
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/33769
Tested-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Device/Blitter.cpp b/src/Device/Blitter.cpp
index e5b41fc..fb4885e 100644
--- a/src/Device/Blitter.cpp
+++ b/src/Device/Blitter.cpp
@@ -1535,7 +1535,7 @@
}
}
- return function(vk::ReactorConfig, "BlitRoutine");
+ return function("BlitRoutine");
}
Routine *Blitter::getBlitRoutine(const State &state)
@@ -1890,7 +1890,7 @@
}
}
- return function(vk::ReactorConfig, "BlitRoutine");
+ return function("BlitRoutine");
}
void Blitter::updateBorders(vk::Image* image, const VkImageSubresourceLayers& subresourceLayers)
diff --git a/src/Device/PixelProcessor.cpp b/src/Device/PixelProcessor.cpp
index 286880f..898da83 100644
--- a/src/Device/PixelProcessor.cpp
+++ b/src/Device/PixelProcessor.cpp
@@ -238,7 +238,7 @@
{
QuadRasterizer *generator = new PixelProgram(state, pipelineLayout, pixelShader, descriptorSets);
generator->generate();
- routine = (*generator)(vk::ReactorConfig, "PixelRoutine_%0.8X", state.shaderID);
+ routine = (*generator)("PixelRoutine_%0.8X", state.shaderID);
delete generator;
routineCache->add(state, routine);
diff --git a/src/Device/VertexProcessor.cpp b/src/Device/VertexProcessor.cpp
index 6dc4367..f6cf89f 100644
--- a/src/Device/VertexProcessor.cpp
+++ b/src/Device/VertexProcessor.cpp
@@ -105,7 +105,7 @@
{
VertexRoutine *generator = new VertexProgram(state, pipelineLayout, vertexShader, descriptorSets);
generator->generate();
- routine = (*generator)(vk::ReactorConfig, "VertexRoutine_%0.8X", state.shaderID);
+ routine = (*generator)("VertexRoutine_%0.8X", state.shaderID);
delete generator;
routineCache->add(state, routine);
diff --git a/src/Pipeline/SetupRoutine.cpp b/src/Pipeline/SetupRoutine.cpp
index 6bd887d..a87aac6 100644
--- a/src/Pipeline/SetupRoutine.cpp
+++ b/src/Pipeline/SetupRoutine.cpp
@@ -453,7 +453,7 @@
Return(1);
}
- routine = function(vk::ReactorConfig, "SetupRoutine");
+ routine = function("SetupRoutine");
}
void SetupRoutine::setupGradient(Pointer<Byte> &primitive, Pointer<Byte> &triangle, Float4 &w012, Float4 (&m)[3], Pointer<Byte> &v0, Pointer<Byte> &v1, Pointer<Byte> &v2, int attribute, int planeEquation, bool flat, bool perspective, int component)
diff --git a/src/Pipeline/SpirvShaderSampling.cpp b/src/Pipeline/SpirvShaderSampling.cpp
index b7d8c66..6d067e1 100644
--- a/src/Pipeline/SpirvShaderSampling.cpp
+++ b/src/Pipeline/SpirvShaderSampling.cpp
@@ -231,7 +231,7 @@
}
}
- return (ImageSampler*)function(vk::ReactorConfig, "sampler")->getEntry();
+ return (ImageSampler*)function("sampler")->getEntry();
}
sw::TextureType SpirvShader::convertTextureType(VkImageViewType imageViewType)
diff --git a/src/Vulkan/VkConfig.h b/src/Vulkan/VkConfig.h
index f6465b0..157f34e 100644
--- a/src/Vulkan/VkConfig.h
+++ b/src/Vulkan/VkConfig.h
@@ -17,8 +17,6 @@
#include "Version.h"
-#include "Reactor/Nucleus.hpp" // ReactorConfig
-
#include <Vulkan/VulkanPlatform.h>
namespace vk
@@ -79,9 +77,6 @@
MAX_POINT_SIZE = 1, // Large points are not supported. If/when we turn this on, must be >= 64.
};
-// Configuration to use for JIT functions.
-static const auto ReactorConfig = rr::Config::Edit().set(rr::Optimization::Level::Default);
-
}
#endif // VK_CONFIG_HPP_
diff --git a/src/Vulkan/VkPipeline.cpp b/src/Vulkan/VkPipeline.cpp
index a9f1cec..e6bb5be 100644
--- a/src/Vulkan/VkPipeline.cpp
+++ b/src/Vulkan/VkPipeline.cpp
@@ -262,7 +262,7 @@
// TODO(b/119409619): use allocator.
auto program = std::make_shared<sw::ComputeProgram>(key.getShader(), key.getLayout(), descriptorSets);
program->generate();
- program->finalize(vk::ReactorConfig);
+ program->finalize();
return program;
}
diff --git a/src/Vulkan/libVulkan.cpp b/src/Vulkan/libVulkan.cpp
index fc1e210..3c7ad2c 100644
--- a/src/Vulkan/libVulkan.cpp
+++ b/src/Vulkan/libVulkan.cpp
@@ -54,6 +54,8 @@
#include "WSI/VkSwapchainKHR.hpp"
+#include "Reactor/Nucleus.hpp"
+
#include <algorithm>
#include <cstring>
#include <string>
@@ -75,6 +77,27 @@
return false;
}
+// setReactorDefaultConfig() sets the default configuration for Vulkan's use of
+// Reactor.
+void setReactorDefaultConfig()
+{
+ auto cfg = rr::Config::Edit()
+ .set(rr::Optimization::Level::Default);
+
+ rr::Nucleus::adjustDefaultConfig(cfg);
+}
+
+// initializeLibrary() is called by vkCreateInstance() to perform one-off global
+// initialization of the swiftshader driver.
+void initializeLibrary()
+{
+ static bool doOnce = [] {
+ setReactorDefaultConfig();
+ return true;
+ }();
+ (void)doOnce;
+}
+
}
extern "C"
@@ -139,6 +162,8 @@
TRACE("(const VkInstanceCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkInstance* pInstance = %p)",
pCreateInfo, pAllocator, pInstance);
+ initializeLibrary();
+
if(pCreateInfo->enabledLayerCount)
{
UNIMPLEMENTED("pCreateInfo->enabledLayerCount");