Plumb PipelineLayouts down to SpirvRoutine
This initializes arrays to hold the descriptor sets in the routine. Nothing uses this yet.
Bug: b/126330097
Change-Id: If052d0b93e62e4f32e88ed02f9bc21f4203587f5
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/25553
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
diff --git a/src/Pipeline/PixelProgram.hpp b/src/Pipeline/PixelProgram.hpp
index 2959418..71c46df 100644
--- a/src/Pipeline/PixelProgram.hpp
+++ b/src/Pipeline/PixelProgram.hpp
@@ -23,8 +23,11 @@
class PixelProgram : public PixelRoutine
{
public:
- PixelProgram(const PixelProcessor::State &state, SpirvShader const *spirvShader) :
- PixelRoutine(state, spirvShader)
+ PixelProgram(
+ const PixelProcessor::State &state,
+ vk::PipelineLayout const *pipelineLayout,
+ SpirvShader const *spirvShader) :
+ PixelRoutine(state, pipelineLayout, spirvShader)
{
}
diff --git a/src/Pipeline/PixelRoutine.cpp b/src/Pipeline/PixelRoutine.cpp
index ce32f32..fd6a85c 100644
--- a/src/Pipeline/PixelRoutine.cpp
+++ b/src/Pipeline/PixelRoutine.cpp
@@ -29,8 +29,12 @@
extern bool exactColorRounding;
extern bool forceClearRegisters;
- PixelRoutine::PixelRoutine(const PixelProcessor::State &state, SpirvShader const *spirvShader)
- : QuadRasterizer(state, spirvShader) /* addressing */
+ PixelRoutine::PixelRoutine(
+ const PixelProcessor::State &state,
+ vk::PipelineLayout const *pipelineLayout,
+ SpirvShader const *spirvShader)
+ : QuadRasterizer(state, spirvShader),
+ routine(pipelineLayout)
{
spirvShader->emitProlog(&routine);
diff --git a/src/Pipeline/PixelRoutine.hpp b/src/Pipeline/PixelRoutine.hpp
index a2b2b6e..7b8f780 100644
--- a/src/Pipeline/PixelRoutine.hpp
+++ b/src/Pipeline/PixelRoutine.hpp
@@ -25,7 +25,9 @@
class PixelRoutine : public sw::QuadRasterizer, public ShaderCore
{
public:
- PixelRoutine(const PixelProcessor::State &state, SpirvShader const *spirvShader);
+ PixelRoutine(const PixelProcessor::State &state,
+ vk::PipelineLayout const *pipelineLayout,
+ SpirvShader const *spirvShader);
virtual ~PixelRoutine();
diff --git a/src/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp
index 77d3393..d3c0061 100644
--- a/src/Pipeline/SpirvShader.cpp
+++ b/src/Pipeline/SpirvShader.cpp
@@ -16,6 +16,7 @@
#include "SpirvShader.hpp"
#include "System/Math.hpp"
#include "Vulkan/VkDebug.hpp"
+#include "Vulkan/VkPipelineLayout.hpp"
#include "Device/Config.hpp"
namespace sw
@@ -1437,4 +1438,10 @@
}
}
}
+
+ SpirvRoutine::SpirvRoutine(vk::PipelineLayout const *pipelineLayout) :
+ pipelineLayout(pipelineLayout)
+ {
+ }
+
}
diff --git a/src/Pipeline/SpirvShader.hpp b/src/Pipeline/SpirvShader.hpp
index ecac7a7..76400c0 100644
--- a/src/Pipeline/SpirvShader.hpp
+++ b/src/Pipeline/SpirvShader.hpp
@@ -15,11 +15,13 @@
#ifndef sw_SpirvShader_hpp
#define sw_SpirvShader_hpp
-#include "System/Types.hpp"
-#include "Vulkan/VkDebug.hpp"
#include "ShaderCore.hpp"
#include "SpirvID.hpp"
+#include "System/Types.hpp"
+#include "Vulkan/VkDebug.hpp"
+#include "Vulkan/VkConfig.h"
+#include <array>
#include <cstring>
#include <string>
#include <vector>
@@ -30,6 +32,11 @@
#include <spirv/unified1/spirv.hpp>
#include <Device/Config.hpp>
+namespace vk
+{
+ class PipelineLayout;
+} // namespace vk
+
namespace sw
{
// Forward declarations.
@@ -412,8 +419,12 @@
class SpirvRoutine
{
public:
+ SpirvRoutine(vk::PipelineLayout const *pipelineLayout);
+
using Value = Array<SIMD::Float>;
+ vk::PipelineLayout const * const pipelineLayout;
+
std::unordered_map<SpirvShader::ObjectID, Value> lvalues;
std::unordered_map<SpirvShader::ObjectID, Intermediate> intermediates;
@@ -421,6 +432,8 @@
Value inputs = Value{MAX_INTERFACE_COMPONENTS};
Value outputs = Value{MAX_INTERFACE_COMPONENTS};
+ std::array<Pointer<Byte>, vk::MAX_BOUND_DESCRIPTOR_SETS> descriptorSets;
+
void createLvalue(SpirvShader::ObjectID id, uint32_t size)
{
lvalues.emplace(id, Value(size));
diff --git a/src/Pipeline/VertexProgram.cpp b/src/Pipeline/VertexProgram.cpp
index 56eb4ce..182e7bd 100644
--- a/src/Pipeline/VertexProgram.cpp
+++ b/src/Pipeline/VertexProgram.cpp
@@ -22,8 +22,11 @@
namespace sw
{
- VertexProgram::VertexProgram(const VertexProcessor::State &state, SpirvShader const *spirvShader)
- : VertexRoutine(state, spirvShader)
+ VertexProgram::VertexProgram(
+ const VertexProcessor::State &state,
+ vk::PipelineLayout const *pipelineLayout,
+ SpirvShader const *spirvShader)
+ : VertexRoutine(state, pipelineLayout, spirvShader)
{
ifDepth = 0;
loopRepDepth = 0;
diff --git a/src/Pipeline/VertexProgram.hpp b/src/Pipeline/VertexProgram.hpp
index 358ed5f..5fe1252 100644
--- a/src/Pipeline/VertexProgram.hpp
+++ b/src/Pipeline/VertexProgram.hpp
@@ -29,7 +29,10 @@
class VertexProgram : public VertexRoutine, public ShaderCore
{
public:
- VertexProgram(const VertexProcessor::State &state, SpirvShader const *spirvShader);
+ VertexProgram(
+ const VertexProcessor::State &state,
+ vk::PipelineLayout const *pipelineLayout,
+ SpirvShader const *spirvShader);
virtual ~VertexProgram();
diff --git a/src/Pipeline/VertexRoutine.cpp b/src/Pipeline/VertexRoutine.cpp
index c4e5db5..df2c813 100644
--- a/src/Pipeline/VertexRoutine.cpp
+++ b/src/Pipeline/VertexRoutine.cpp
@@ -24,8 +24,12 @@
namespace sw
{
- VertexRoutine::VertexRoutine(const VertexProcessor::State &state, SpirvShader const *spirvShader)
- : state(state),
+ VertexRoutine::VertexRoutine(
+ const VertexProcessor::State &state,
+ vk::PipelineLayout const *pipelineLayout,
+ SpirvShader const *spirvShader)
+ : routine(pipelineLayout),
+ state(state),
spirvShader(spirvShader)
{
spirvShader->emitProlog(&routine);
diff --git a/src/Pipeline/VertexRoutine.hpp b/src/Pipeline/VertexRoutine.hpp
index 943e560..757fc51 100644
--- a/src/Pipeline/VertexRoutine.hpp
+++ b/src/Pipeline/VertexRoutine.hpp
@@ -20,6 +20,11 @@
#include "ShaderCore.hpp"
#include "SpirvShader.hpp"
+namespace vk
+{
+ class PipelineLayout;
+} // namespace vk
+
namespace sw
{
class VertexRoutinePrototype : public Function<Void(Pointer<Byte>, Pointer<Byte>, Pointer<Byte>, Pointer<Byte>)>
@@ -38,7 +43,10 @@
class VertexRoutine : public VertexRoutinePrototype
{
public:
- VertexRoutine(const VertexProcessor::State &state, SpirvShader const *spirvShader);
+ VertexRoutine(
+ const VertexProcessor::State &state,
+ vk::PipelineLayout const *pipelineLayout,
+ SpirvShader const *spirvShader);
virtual ~VertexRoutine();
void generate();