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
}
}
return nullptr; // Not found
return {}; // Not found
}
template<class Key, class Data>
......
......@@ -269,7 +269,6 @@ namespace sw
draw->vertexRoutine = vertexRoutine;
draw->setupRoutine = setupRoutine;
draw->pixelRoutine = pixelRoutine;
draw->vertexPointer = (VertexProcessor::RoutinePointer)vertexRoutine->getEntry();
draw->setupPointer = (SetupProcessor::RoutinePointer)setupRoutine->getEntry();
draw->pixelPointer = (PixelProcessor::RoutinePointer)pixelRoutine->getEntry();
draw->setupPrimitives = setupPrimitives;
......@@ -433,7 +432,7 @@ namespace sw
occlusionQuery->finish();
}
vertexRoutine.reset();
vertexRoutine = {};
setupRoutine.reset();
pixelRoutine.reset();
}
......@@ -515,7 +514,7 @@ namespace sw
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)
......
......@@ -154,11 +154,10 @@ namespace sw
VkIndexType indexType;
VkLineRasterizationModeEXT lineRasterizationMode;
std::shared_ptr<Routine> vertexRoutine;
VertexProcessor::RoutineType vertexRoutine;
std::shared_ptr<Routine> setupRoutine;
std::shared_ptr<Routine> pixelRoutine;
VertexProcessor::RoutinePointer vertexPointer;
SetupProcessor::RoutinePointer setupPointer;
PixelProcessor::RoutinePointer pixelPointer;
......@@ -237,7 +236,7 @@ namespace sw
SetupProcessor::State setupState;
PixelProcessor::State pixelState;
std::shared_ptr<Routine> vertexRoutine;
VertexProcessor::RoutineType vertexRoutine;
std::shared_ptr<Routine> setupRoutine;
std::shared_ptr<Routine> pixelRoutine;
......
......@@ -25,6 +25,9 @@ namespace sw
template<class State>
using RoutineCache = LRUCache<State, std::shared_ptr<Routine>>;
template<class State, class FunctionType>
using RoutineCacheT = LRUCache<State, RoutineT<FunctionType>>;
}
#endif // sw_RoutineCache_hpp
......@@ -96,7 +96,7 @@ namespace sw
void VertexProcessor::setRoutineCacheSize(int cacheSize)
{
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)
......@@ -122,10 +122,10 @@ namespace sw
return state;
}
std::shared_ptr<Routine> VertexProcessor::routine(const State &state,
vk::PipelineLayout const *pipelineLayout,
SpirvShader const *vertexShader,
const vk::DescriptorSet::Bindings &descriptorSets)
VertexProcessor::RoutineType VertexProcessor::routine(const State &state,
vk::PipelineLayout const *pipelineLayout,
SpirvShader const *vertexShader,
const vk::DescriptorSet::Bindings &descriptorSets)
{
auto routine = routineCache->query(state);
......
......@@ -50,6 +50,8 @@ namespace sw
VertexCache vertexCache;
};
using VertexRoutineFunction = FunctionT<void(Vertex* output, unsigned int* batch, VertexTask* vertextask, DrawData* draw)>;
class VertexProcessor
{
public:
......@@ -88,7 +90,7 @@ namespace sw
uint32_t hash;
};
typedef void (*RoutinePointer)(Vertex *output, unsigned int *batch, VertexTask *vertexTask, DrawData *draw);
using RoutineType = VertexRoutineFunction::RoutineType;
VertexProcessor();
......@@ -96,13 +98,14 @@ namespace sw
protected:
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);
void setRoutineCacheSize(int cacheSize);
private:
RoutineCache<State> *routineCache;
using RoutineCacheType = RoutineCacheT<State, VertexRoutineFunction::CFunctionType>;
RoutineCacheType *routineCache;
};
}
......
......@@ -27,7 +27,7 @@ namespace vk
namespace sw
{
class VertexRoutinePrototype : public Function<Void(Pointer<Byte>, Pointer<UInt>, Pointer<Byte>, Pointer<Byte>)>
class VertexRoutinePrototype : public VertexRoutineFunction
{
public:
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