Commit d06466ec by Antonio Maiorano

Modify VertexRoutine to implement FunctionT

Bug: b/143479561 Change-Id: I1a63f7eab9d5b6ce12f5d858018c4c6582ab9c90 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/37669 Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarAntonio Maiorano <amaiorano@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 03935ae2
...@@ -147,7 +147,7 @@ namespace sw ...@@ -147,7 +147,7 @@ namespace sw
} }
} }
return nullptr; // Not found return {}; // Not found
} }
template<class Key, class Data> template<class Key, class Data>
......
...@@ -269,7 +269,6 @@ namespace sw ...@@ -269,7 +269,6 @@ namespace sw
draw->vertexRoutine = vertexRoutine; draw->vertexRoutine = vertexRoutine;
draw->setupRoutine = setupRoutine; draw->setupRoutine = setupRoutine;
draw->pixelRoutine = pixelRoutine; draw->pixelRoutine = pixelRoutine;
draw->vertexPointer = (VertexProcessor::RoutinePointer)vertexRoutine->getEntry();
draw->setupPointer = (SetupProcessor::RoutinePointer)setupRoutine->getEntry(); draw->setupPointer = (SetupProcessor::RoutinePointer)setupRoutine->getEntry();
draw->pixelPointer = (PixelProcessor::RoutinePointer)pixelRoutine->getEntry(); draw->pixelPointer = (PixelProcessor::RoutinePointer)pixelRoutine->getEntry();
draw->setupPrimitives = setupPrimitives; draw->setupPrimitives = setupPrimitives;
...@@ -433,7 +432,7 @@ namespace sw ...@@ -433,7 +432,7 @@ namespace sw
occlusionQuery->finish(); occlusionQuery->finish();
} }
vertexRoutine.reset(); vertexRoutine = {};
setupRoutine.reset(); setupRoutine.reset();
pixelRoutine.reset(); pixelRoutine.reset();
} }
...@@ -515,7 +514,7 @@ namespace sw ...@@ -515,7 +514,7 @@ namespace sw
vertexTask.vertexCache.drawCall = draw->id; vertexTask.vertexCache.drawCall = draw->id;
} }
draw->vertexPointer(&batch->triangles.front().v0, &triangleIndices[0][0], &vertexTask, draw->data); draw->vertexRoutine(&batch->triangles.front().v0, &triangleIndices[0][0], &vertexTask, draw->data);
} }
void DrawCall::processPrimitives(DrawCall* draw, BatchData* batch) void DrawCall::processPrimitives(DrawCall* draw, BatchData* batch)
......
...@@ -154,11 +154,10 @@ namespace sw ...@@ -154,11 +154,10 @@ namespace sw
VkIndexType indexType; VkIndexType indexType;
VkLineRasterizationModeEXT lineRasterizationMode; VkLineRasterizationModeEXT lineRasterizationMode;
std::shared_ptr<Routine> vertexRoutine; VertexProcessor::RoutineType vertexRoutine;
std::shared_ptr<Routine> setupRoutine; std::shared_ptr<Routine> setupRoutine;
std::shared_ptr<Routine> pixelRoutine; std::shared_ptr<Routine> pixelRoutine;
VertexProcessor::RoutinePointer vertexPointer;
SetupProcessor::RoutinePointer setupPointer; SetupProcessor::RoutinePointer setupPointer;
PixelProcessor::RoutinePointer pixelPointer; PixelProcessor::RoutinePointer pixelPointer;
...@@ -237,7 +236,7 @@ namespace sw ...@@ -237,7 +236,7 @@ namespace sw
SetupProcessor::State setupState; SetupProcessor::State setupState;
PixelProcessor::State pixelState; PixelProcessor::State pixelState;
std::shared_ptr<Routine> vertexRoutine; VertexProcessor::RoutineType vertexRoutine;
std::shared_ptr<Routine> setupRoutine; std::shared_ptr<Routine> setupRoutine;
std::shared_ptr<Routine> pixelRoutine; std::shared_ptr<Routine> pixelRoutine;
......
...@@ -25,6 +25,9 @@ namespace sw ...@@ -25,6 +25,9 @@ namespace sw
template<class State> template<class State>
using RoutineCache = LRUCache<State, std::shared_ptr<Routine>>; using RoutineCache = LRUCache<State, std::shared_ptr<Routine>>;
template<class State, class FunctionType>
using RoutineCacheT = LRUCache<State, RoutineT<FunctionType>>;
} }
#endif // sw_RoutineCache_hpp #endif // sw_RoutineCache_hpp
...@@ -96,7 +96,7 @@ namespace sw ...@@ -96,7 +96,7 @@ namespace sw
void VertexProcessor::setRoutineCacheSize(int cacheSize) void VertexProcessor::setRoutineCacheSize(int cacheSize)
{ {
delete routineCache; delete routineCache;
routineCache = new RoutineCache<State>(clamp(cacheSize, 1, 65536)); routineCache = new RoutineCacheType(clamp(cacheSize, 1, 65536));
} }
const VertexProcessor::State VertexProcessor::update(const sw::Context* context) const VertexProcessor::State VertexProcessor::update(const sw::Context* context)
...@@ -122,7 +122,7 @@ namespace sw ...@@ -122,7 +122,7 @@ namespace sw
return state; return state;
} }
std::shared_ptr<Routine> VertexProcessor::routine(const State &state, VertexProcessor::RoutineType VertexProcessor::routine(const State &state,
vk::PipelineLayout const *pipelineLayout, vk::PipelineLayout const *pipelineLayout,
SpirvShader const *vertexShader, SpirvShader const *vertexShader,
const vk::DescriptorSet::Bindings &descriptorSets) const vk::DescriptorSet::Bindings &descriptorSets)
......
...@@ -50,6 +50,8 @@ namespace sw ...@@ -50,6 +50,8 @@ namespace sw
VertexCache vertexCache; VertexCache vertexCache;
}; };
using VertexRoutineFunction = FunctionT<void(Vertex* output, unsigned int* batch, VertexTask* vertextask, DrawData* draw)>;
class VertexProcessor class VertexProcessor
{ {
public: public:
...@@ -88,7 +90,7 @@ namespace sw ...@@ -88,7 +90,7 @@ namespace sw
uint32_t hash; uint32_t hash;
}; };
typedef void (*RoutinePointer)(Vertex *output, unsigned int *batch, VertexTask *vertexTask, DrawData *draw); using RoutineType = VertexRoutineFunction::RoutineType;
VertexProcessor(); VertexProcessor();
...@@ -96,13 +98,14 @@ namespace sw ...@@ -96,13 +98,14 @@ namespace sw
protected: protected:
const State update(const sw::Context* context); const State update(const sw::Context* context);
std::shared_ptr<Routine> routine(const State &state, vk::PipelineLayout const *pipelineLayout, RoutineType routine(const State &state, vk::PipelineLayout const *pipelineLayout,
SpirvShader const *vertexShader, const vk::DescriptorSet::Bindings &descriptorSets); SpirvShader const *vertexShader, const vk::DescriptorSet::Bindings &descriptorSets);
void setRoutineCacheSize(int cacheSize); void setRoutineCacheSize(int cacheSize);
private: private:
RoutineCache<State> *routineCache; using RoutineCacheType = RoutineCacheT<State, VertexRoutineFunction::CFunctionType>;
RoutineCacheType *routineCache;
}; };
} }
......
...@@ -27,7 +27,7 @@ namespace vk ...@@ -27,7 +27,7 @@ namespace vk
namespace sw namespace sw
{ {
class VertexRoutinePrototype : public Function<Void(Pointer<Byte>, Pointer<UInt>, Pointer<Byte>, Pointer<Byte>)> class VertexRoutinePrototype : public VertexRoutineFunction
{ {
public: public:
VertexRoutinePrototype() : vertex(Arg<0>()), batch(Arg<1>()), task(Arg<2>()), data(Arg<3>()) {} VertexRoutinePrototype() : vertex(Arg<0>()), batch(Arg<1>()), task(Arg<2>()), data(Arg<3>()) {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment