Commit bd0ab1be by Ben Clayton

Pass around sw::TaskEvents* instead of vk::Fence*.

Bug: b/133127573 Change-Id: I0ce0164de401524014eb295547b899f24f437e21 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31683Tested-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 6d33e8c3
...@@ -185,7 +185,7 @@ namespace sw ...@@ -185,7 +185,7 @@ namespace sw
references = -1; references = -1;
fence = nullptr; events = nullptr;
data = (DrawData*)allocate(sizeof(DrawData)); data = (DrawData*)allocate(sizeof(DrawData));
data->constants = &constants; data->constants = &constants;
...@@ -299,7 +299,7 @@ namespace sw ...@@ -299,7 +299,7 @@ namespace sw
return false; return false;
} }
void Renderer::draw(const sw::Context* context, VkIndexType indexType, unsigned int count, int baseVertex, vk::Fence* fence, bool update) void Renderer::draw(const sw::Context* context, VkIndexType indexType, unsigned int count, int baseVertex, TaskEvents *events, bool update)
{ {
if(count == 0) { return; } if(count == 0) { return; }
...@@ -403,12 +403,13 @@ namespace sw ...@@ -403,12 +403,13 @@ namespace sw
data->descriptorSets = context->descriptorSets; data->descriptorSets = context->descriptorSets;
data->descriptorDynamicOffsets = context->descriptorDynamicOffsets; data->descriptorDynamicOffsets = context->descriptorDynamicOffsets;
if(fence) if(events)
{ {
fence->start(); events->start();
} }
ASSERT(!draw->fence);
draw->fence = fence; ASSERT(!draw->events);
draw->events = events;
for(int i = 0; i < MAX_VERTEX_INPUTS; i++) for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{ {
...@@ -889,10 +890,10 @@ namespace sw ...@@ -889,10 +890,10 @@ namespace sw
draw.setupRoutine->unbind(); draw.setupRoutine->unbind();
draw.pixelRoutine->unbind(); draw.pixelRoutine->unbind();
if(draw.fence) if(draw.events)
{ {
draw.fence->finish(); draw.events->finish();
draw.fence = nullptr; draw.events = nullptr;
} }
sync->unlock(); sync->unlock();
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
namespace vk namespace vk
{ {
class DescriptorSet; class DescriptorSet;
class Fence;
struct Query; struct Query;
} }
...@@ -41,6 +40,7 @@ namespace sw ...@@ -41,6 +40,7 @@ namespace sw
class VertexShader; class VertexShader;
class SwiftConfig; class SwiftConfig;
struct Task; struct Task;
class TaskEvents;
class Resource; class Resource;
struct Constants; struct Constants;
...@@ -200,7 +200,7 @@ namespace sw ...@@ -200,7 +200,7 @@ namespace sw
bool hasQueryOfType(VkQueryType type) const; bool hasQueryOfType(VkQueryType type) const;
void draw(const sw::Context* context, VkIndexType indexType, unsigned int count, int baseVertex, vk::Fence* fence, bool update = true); void draw(const sw::Context* context, VkIndexType indexType, unsigned int count, int baseVertex, TaskEvents *events, bool update = true);
// Viewport & Clipper // Viewport & Clipper
void setViewport(const VkViewport &viewport); void setViewport(const VkViewport &viewport);
...@@ -333,7 +333,7 @@ namespace sw ...@@ -333,7 +333,7 @@ namespace sw
vk::ImageView *renderTarget[RENDERTARGETS]; vk::ImageView *renderTarget[RENDERTARGETS];
vk::ImageView *depthBuffer; vk::ImageView *depthBuffer;
vk::ImageView *stencilBuffer; vk::ImageView *stencilBuffer;
vk::Fence* fence; TaskEvents *events;
std::list<vk::Query*> *queries; std::list<vk::Query*> *queries;
......
...@@ -601,7 +601,7 @@ struct DrawBase : public CommandBuffer::Command ...@@ -601,7 +601,7 @@ struct DrawBase : public CommandBuffer::Command
{ {
const uint32_t primitiveCount = indexBuffer.first; const uint32_t primitiveCount = indexBuffer.first;
context.indexBuffer = indexBuffer.second; context.indexBuffer = indexBuffer.second;
executionState.renderer->draw(&context, executionState.indexType, primitiveCount, vertexOffset, executionState.fence); executionState.renderer->draw(&context, executionState.indexType, primitiveCount, vertexOffset, executionState.events);
} }
executionState.renderer->advanceInstanceAttributes(context.input); executionState.renderer->advanceInstanceAttributes(context.input);
......
...@@ -26,12 +26,12 @@ namespace sw ...@@ -26,12 +26,12 @@ namespace sw
{ {
class Context; class Context;
class Renderer; class Renderer;
class TaskEvents;
} }
namespace vk namespace vk
{ {
class Fence;
class Framebuffer; class Framebuffer;
class Pipeline; class Pipeline;
class RenderPass; class RenderPass;
...@@ -133,7 +133,7 @@ public: ...@@ -133,7 +133,7 @@ public:
}; };
sw::Renderer* renderer = nullptr; sw::Renderer* renderer = nullptr;
Fence* fence = nullptr; sw::TaskEvents* events = nullptr;
RenderPass* renderPass = nullptr; RenderPass* renderPass = nullptr;
Framebuffer* renderPassFramebuffer = nullptr; Framebuffer* renderPassFramebuffer = nullptr;
std::array<PipelineState, VK_PIPELINE_BIND_POINT_RANGE_SIZE> pipelineState; std::array<PipelineState, VK_PIPELINE_BIND_POINT_RANGE_SIZE> pipelineState;
......
...@@ -102,11 +102,11 @@ VkResult Queue::submit(uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFen ...@@ -102,11 +102,11 @@ VkResult Queue::submit(uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFen
Task task; Task task;
task.submitCount = submitCount; task.submitCount = submitCount;
task.pSubmits = DeepCopySubmitInfo(submitCount, pSubmits); task.pSubmits = DeepCopySubmitInfo(submitCount, pSubmits);
task.fence = (fence != VK_NULL_HANDLE) ? vk::Cast(fence) : nullptr; task.events = (fence != VK_NULL_HANDLE) ? vk::Cast(fence) : nullptr;
if(task.fence) if(task.events)
{ {
task.fence->start(); task.events->start();
} }
pending.put(task); pending.put(task);
...@@ -132,7 +132,7 @@ void Queue::submitQueue(const Task& task) ...@@ -132,7 +132,7 @@ void Queue::submitQueue(const Task& task)
{ {
CommandBuffer::ExecutionState executionState; CommandBuffer::ExecutionState executionState;
executionState.renderer = renderer.get(); executionState.renderer = renderer.get();
executionState.fence = task.fence; executionState.events = task.events;
for(uint32_t j = 0; j < submitInfo.commandBufferCount; j++) for(uint32_t j = 0; j < submitInfo.commandBufferCount; j++)
{ {
vk::Cast(submitInfo.pCommandBuffers[j])->submit(executionState); vk::Cast(submitInfo.pCommandBuffers[j])->submit(executionState);
...@@ -150,12 +150,12 @@ void Queue::submitQueue(const Task& task) ...@@ -150,12 +150,12 @@ void Queue::submitQueue(const Task& task)
toDelete.put(task.pSubmits); toDelete.put(task.pSubmits);
} }
if(task.fence) if(task.events)
{ {
// TODO: fix renderer signaling so that work submitted separately from (but before) a fence // TODO: fix renderer signaling so that work submitted separately from (but before) a fence
// is guaranteed complete by the time the fence signals. // is guaranteed complete by the time the fence signals.
renderer->synchronize(); renderer->synchronize();
task.fence->finish(); task.events->finish();
} }
} }
...@@ -187,7 +187,7 @@ VkResult Queue::waitIdle() ...@@ -187,7 +187,7 @@ VkResult Queue::waitIdle()
fence.start(); fence.start();
Task task; Task task;
task.fence = &fence; task.events = &fence;
pending.put(task); pending.put(task);
fence.wait(); fence.wait();
......
...@@ -56,7 +56,7 @@ private: ...@@ -56,7 +56,7 @@ private:
{ {
uint32_t submitCount = 0; uint32_t submitCount = 0;
VkSubmitInfo* pSubmits = nullptr; VkSubmitInfo* pSubmits = nullptr;
Fence* fence = nullptr; sw::TaskEvents* events = nullptr;
enum Type { KILL_THREAD, SUBMIT_QUEUE }; enum Type { KILL_THREAD, SUBMIT_QUEUE };
Type type = SUBMIT_QUEUE; Type type = SUBMIT_QUEUE;
......
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