Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-swiftshader: Commit

external/swiftshader


Commit MetaInfo

Revisionbc2af94feb4038664fe6744042cfa212088ccd86 (tree)
Time2020-04-15 02:41:45
AuthorBen Clayton <bclayton@goog...>
CommiterBen Clayton

Log Message

Device: Don't inherit [Vertex,Setup,Pixel]Processor.

Prefer composition over inheritance.
Makes it clear that the virtual destructors on these processors are unnecessary.

Bug: b/126126820
Change-Id: I062c06191ec1cdfb81f2a2773a976bf5c596e658
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/43817
Tested-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>

Change Summary

Incremental Difference

--- a/src/Device/PixelProcessor.hpp
+++ b/src/Device/PixelProcessor.hpp
@@ -150,7 +150,6 @@ public:
150150
151151 void setBlendConstant(const float4 &blendConstant);
152152
153-protected:
154153 const State update(const Context *context) const;
155154 RoutineType routine(const State &state, vk::PipelineLayout const *pipelineLayout,
156155 SpirvShader const *pixelShader, const vk::DescriptorSet::Bindings &descriptorSets);
--- a/src/Device/Renderer.cpp
+++ b/src/Device/Renderer.cpp
@@ -156,9 +156,9 @@ DrawCall::~DrawCall()
156156 Renderer::Renderer(vk::Device *device)
157157 : device(device)
158158 {
159- VertexProcessor::setRoutineCacheSize(1024);
160- PixelProcessor::setRoutineCacheSize(1024);
161- SetupProcessor::setRoutineCacheSize(1024);
159+ vertexProcessor.setRoutineCacheSize(1024);
160+ pixelProcessor.setRoutineCacheSize(1024);
161+ setupProcessor.setRoutineCacheSize(1024);
162162 }
163163
164164 Renderer::~Renderer()
@@ -204,13 +204,13 @@ void Renderer::draw(const sw::Context *context, VkIndexType indexType, unsigned
204204 if(update)
205205 {
206206 MARL_SCOPED_EVENT("update");
207- vertexState = VertexProcessor::update(context);
208- setupState = SetupProcessor::update(context);
209- pixelState = PixelProcessor::update(context);
207+ vertexState = vertexProcessor.update(context);
208+ setupState = setupProcessor.update(context);
209+ pixelState = pixelProcessor.update(context);
210210
211- vertexRoutine = VertexProcessor::routine(vertexState, context->pipelineLayout, context->vertexShader, context->descriptorSets);
212- setupRoutine = SetupProcessor::routine(setupState);
213- pixelRoutine = PixelProcessor::routine(pixelState, context->pipelineLayout, context->pixelShader, context->descriptorSets);
211+ vertexRoutine = vertexProcessor.routine(vertexState, context->pipelineLayout, context->vertexShader, context->descriptorSets);
212+ setupRoutine = setupProcessor.routine(setupState);
213+ pixelRoutine = pixelProcessor.routine(pixelState, context->pipelineLayout, context->pixelShader, context->descriptorSets);
214214 }
215215
216216 DrawCall::SetupFunction setupPrimitives = nullptr;
@@ -285,7 +285,7 @@ void Renderer::draw(const sw::Context *context, VkIndexType indexType, unsigned
285285
286286 data->lineWidth = context->lineWidth;
287287
288- data->factor = factor;
288+ data->factor = pixelProcessor.factor;
289289
290290 if(pixelState.alphaToCoverage)
291291 {
@@ -1184,4 +1184,9 @@ void Renderer::setScissor(const VkRect2D &scissor)
11841184 this->scissor = scissor;
11851185 }
11861186
1187+void Renderer::setBlendConstant(const float4 &blendConstant)
1188+{
1189+ pixelProcessor.setBlendConstant(blendConstant);
1190+}
1191+
11871192 } // namespace sw
--- a/src/Device/Renderer.hpp
+++ b/src/Device/Renderer.hpp
@@ -189,7 +189,7 @@ struct DrawCall
189189 static bool setupPoint(Primitive &primitive, Triangle &triangle, const DrawCall &draw);
190190 };
191191
192-class alignas(16) Renderer : public VertexProcessor, public PixelProcessor, public SetupProcessor
192+class alignas(16) Renderer
193193 {
194194 public:
195195 Renderer(vk::Device *device);
@@ -209,6 +209,8 @@ public:
209209 void setViewport(const VkViewport &viewport);
210210 void setScissor(const VkRect2D &scissor);
211211
212+ void setBlendConstant(const float4 &blendConstant);
213+
212214 void addQuery(vk::Query *query);
213215 void removeQuery(vk::Query *query);
214216
@@ -229,6 +231,10 @@ private:
229231 marl::Ticket::Queue drawTickets;
230232 marl::Ticket::Queue clusterQueues[MaxClusterCount];
231233
234+ VertexProcessor vertexProcessor;
235+ PixelProcessor pixelProcessor;
236+ SetupProcessor setupProcessor;
237+
232238 VertexProcessor::State vertexState;
233239 SetupProcessor::State setupState;
234240 PixelProcessor::State pixelState;
--- a/src/Device/SetupProcessor.hpp
+++ b/src/Device/SetupProcessor.hpp
@@ -73,7 +73,6 @@ public:
7373
7474 ~SetupProcessor();
7575
76-protected:
7776 State update(const sw::Context *context) const;
7877 RoutineType routine(const State &state);
7978
--- a/src/Device/VertexProcessor.hpp
+++ b/src/Device/VertexProcessor.hpp
@@ -93,7 +93,6 @@ public:
9393
9494 virtual ~VertexProcessor();
9595
96-protected:
9796 const State update(const sw::Context *context);
9897 RoutineType routine(const State &state, vk::PipelineLayout const *pipelineLayout,
9998 SpirvShader const *vertexShader, const vk::DescriptorSet::Bindings &descriptorSets);
Show on old repository browser