Commit e60921e4 by Antonio Maiorano

Modify PixelRoutine to implement FunctionT

Bug: b/143479561 Change-Id: Iedd6b62b5b3dcc46a789f15112656cfe191cb4de Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/37708Tested-by: 's avatarAntonio Maiorano <amaiorano@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent d06466ec
...@@ -147,7 +147,7 @@ namespace sw ...@@ -147,7 +147,7 @@ namespace sw
void PixelProcessor::setRoutineCacheSize(int cacheSize) void PixelProcessor::setRoutineCacheSize(int cacheSize)
{ {
delete routineCache; delete routineCache;
routineCache = new RoutineCache<State>(clamp(cacheSize, 1, 65536)); routineCache = new RoutineCacheType(clamp(cacheSize, 1, 65536));
} }
const PixelProcessor::State PixelProcessor::update(const Context* context) const const PixelProcessor::State PixelProcessor::update(const Context* context) const
...@@ -206,7 +206,7 @@ namespace sw ...@@ -206,7 +206,7 @@ namespace sw
return state; return state;
} }
std::shared_ptr<Routine> PixelProcessor::routine(const State &state, PixelProcessor::RoutineType PixelProcessor::routine(const State &state,
vk::PipelineLayout const *pipelineLayout, vk::PipelineLayout const *pipelineLayout,
SpirvShader const *pixelShader, SpirvShader const *pixelShader,
const vk::DescriptorSet::Bindings &descriptorSets) const vk::DescriptorSet::Bindings &descriptorSets)
......
...@@ -28,6 +28,8 @@ namespace sw ...@@ -28,6 +28,8 @@ namespace sw
struct DrawData; struct DrawData;
struct Primitive; struct Primitive;
using RasterizerFunction = FunctionT<void(const Primitive* primitive, int count, int cluster, int clusterCount, DrawData* draw)>;
class PixelProcessor class PixelProcessor
{ {
public: public:
...@@ -136,7 +138,7 @@ namespace sw ...@@ -136,7 +138,7 @@ namespace sw
}; };
public: public:
typedef void (*RoutinePointer)(const Primitive *primitive, int count, int cluster, int clusterCount, DrawData *draw); using RoutineType = RasterizerFunction::RoutineType;
PixelProcessor(); PixelProcessor();
...@@ -146,7 +148,7 @@ namespace sw ...@@ -146,7 +148,7 @@ namespace sw
protected: protected:
const State update(const Context* context) const; const State update(const Context* context) const;
std::shared_ptr<Routine> routine(const State &state, vk::PipelineLayout const *pipelineLayout, RoutineType routine(const State &state, vk::PipelineLayout const *pipelineLayout,
SpirvShader const *pixelShader, const vk::DescriptorSet::Bindings &descriptorSets); SpirvShader const *pixelShader, const vk::DescriptorSet::Bindings &descriptorSets);
void setRoutineCacheSize(int routineCacheSize); void setRoutineCacheSize(int routineCacheSize);
...@@ -154,7 +156,8 @@ namespace sw ...@@ -154,7 +156,8 @@ namespace sw
Factor factor; Factor factor;
private: private:
RoutineCache<State> *routineCache; using RoutineCacheType = RoutineCacheT<State, RasterizerFunction::CFunctionType>;
RoutineCacheType *routineCache;
}; };
} }
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
namespace sw namespace sw
{ {
class Rasterizer : public Function<Void(Pointer<Byte>, Int, Int, Int, Pointer<Byte>)> class Rasterizer : public RasterizerFunction
{ {
public: public:
Rasterizer() : primitive(Arg<0>()), count(Arg<1>()), cluster(Arg<2>()), clusterCount(Arg<3>()), data(Arg<4>()) {} Rasterizer() : primitive(Arg<0>()), count(Arg<1>()), cluster(Arg<2>()), clusterCount(Arg<3>()), data(Arg<4>()) {}
......
...@@ -270,7 +270,6 @@ namespace sw ...@@ -270,7 +270,6 @@ namespace sw
draw->setupRoutine = setupRoutine; draw->setupRoutine = setupRoutine;
draw->pixelRoutine = pixelRoutine; draw->pixelRoutine = pixelRoutine;
draw->setupPointer = (SetupProcessor::RoutinePointer)setupRoutine->getEntry(); draw->setupPointer = (SetupProcessor::RoutinePointer)setupRoutine->getEntry();
draw->pixelPointer = (PixelProcessor::RoutinePointer)pixelRoutine->getEntry();
draw->setupPrimitives = setupPrimitives; draw->setupPrimitives = setupPrimitives;
draw->setupState = setupState; draw->setupState = setupState;
...@@ -434,7 +433,7 @@ namespace sw ...@@ -434,7 +433,7 @@ namespace sw
vertexRoutine = {}; vertexRoutine = {};
setupRoutine.reset(); setupRoutine.reset();
pixelRoutine.reset(); pixelRoutine = {};
} }
void DrawCall::run(const marl::Loan<DrawCall>& draw, marl::Ticket::Queue* tickets, marl::Ticket::Queue clusterQueues[MaxClusterCount]) void DrawCall::run(const marl::Loan<DrawCall>& draw, marl::Ticket::Queue* tickets, marl::Ticket::Queue clusterQueues[MaxClusterCount])
...@@ -543,7 +542,7 @@ namespace sw ...@@ -543,7 +542,7 @@ namespace sw
auto& draw = data->draw; auto& draw = data->draw;
auto& batch = data->batch; auto& batch = data->batch;
MARL_SCOPED_EVENT("PIXEL draw %d, batch %d, cluster %d", draw->id, batch->id, cluster); MARL_SCOPED_EVENT("PIXEL draw %d, batch %d, cluster %d", draw->id, batch->id, cluster);
draw->pixelPointer(&batch->primitives.front(), batch->numVisible, cluster, MaxClusterCount, draw->data); draw->pixelRoutine(&batch->primitives.front(), batch->numVisible, cluster, MaxClusterCount, draw->data);
batch->clusterTickets[cluster].done(); batch->clusterTickets[cluster].done();
}); });
} }
......
...@@ -156,10 +156,9 @@ namespace sw ...@@ -156,10 +156,9 @@ namespace sw
VertexProcessor::RoutineType vertexRoutine; VertexProcessor::RoutineType vertexRoutine;
std::shared_ptr<Routine> setupRoutine; std::shared_ptr<Routine> setupRoutine;
std::shared_ptr<Routine> pixelRoutine; PixelProcessor::RoutineType pixelRoutine;
SetupProcessor::RoutinePointer setupPointer; SetupProcessor::RoutinePointer setupPointer;
PixelProcessor::RoutinePointer pixelPointer;
SetupFunction setupPrimitives; SetupFunction setupPrimitives;
SetupProcessor::State setupState; SetupProcessor::State setupState;
...@@ -238,7 +237,7 @@ namespace sw ...@@ -238,7 +237,7 @@ namespace sw
VertexProcessor::RoutineType vertexRoutine; VertexProcessor::RoutineType vertexRoutine;
std::shared_ptr<Routine> setupRoutine; std::shared_ptr<Routine> setupRoutine;
std::shared_ptr<Routine> pixelRoutine; PixelProcessor::RoutineType pixelRoutine;
vk::Device* device; vk::Device* device;
}; };
......
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