Commit a9da772f by Chris Forbes

Pass draw-to-draw varying state directly to Renderer::draw

There is no reason to plumb this through Context. Bug: b/132280877 Change-Id: I92819af587505b75b279a6aed70aa8067455df8d Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/35549Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarChris Forbes <chrisforbes@google.com>
parent 83cdd258
...@@ -128,8 +128,6 @@ namespace sw ...@@ -128,8 +128,6 @@ namespace sw
pixelShader = nullptr; pixelShader = nullptr;
vertexShader = nullptr; vertexShader = nullptr;
instanceID = 0;
occlusionEnabled = false; occlusionEnabled = false;
lineWidth = 1.0f; lineWidth = 1.0f;
......
...@@ -82,7 +82,6 @@ namespace sw ...@@ -82,7 +82,6 @@ namespace sw
vk::DescriptorSet::Bindings descriptorSets = {}; vk::DescriptorSet::Bindings descriptorSets = {};
vk::DescriptorSet::DynamicOffsets descriptorDynamicOffsets = {}; vk::DescriptorSet::DynamicOffsets descriptorDynamicOffsets = {};
Stream input[MAX_INTERFACE_COMPONENTS / 4]; Stream input[MAX_INTERFACE_COMPONENTS / 4];
void *indexBuffer;
vk::ImageView *renderTarget[RENDERTARGETS]; vk::ImageView *renderTarget[RENDERTARGETS];
vk::ImageView *depthBuffer; vk::ImageView *depthBuffer;
...@@ -94,10 +93,6 @@ namespace sw ...@@ -94,10 +93,6 @@ namespace sw
const SpirvShader *pixelShader; const SpirvShader *pixelShader;
const SpirvShader *vertexShader; const SpirvShader *vertexShader;
// Instancing
int instanceID;
int viewID;
bool occlusionEnabled; bool occlusionEnabled;
// Pixel processor states // Pixel processor states
...@@ -123,8 +118,6 @@ namespace sw ...@@ -123,8 +118,6 @@ namespace sw
unsigned int multiSampleMask; unsigned int multiSampleMask;
int sampleCount; int sampleCount;
bool alphaToCoverage; bool alphaToCoverage;
PushConstantStorage pushConstants;
}; };
} }
......
...@@ -233,7 +233,9 @@ namespace sw ...@@ -233,7 +233,9 @@ namespace sw
sw::deallocate(mem); sw::deallocate(mem);
} }
void Renderer::draw(const sw::Context* context, VkIndexType indexType, unsigned int count, int baseVertex, TaskEvents *events, bool update) void Renderer::draw(const sw::Context* context, VkIndexType indexType, unsigned int count, int baseVertex,
TaskEvents *events, int instanceID, int viewID, void *indexBuffer,
PushConstantStorage const & pushConstants, bool update)
{ {
if(count == 0) { return; } if(count == 0) { return; }
...@@ -347,10 +349,9 @@ namespace sw ...@@ -347,10 +349,9 @@ namespace sw
data->stride[i] = context->input[i].vertexStride; data->stride[i] = context->input[i].vertexStride;
} }
data->indices = context->indexBuffer; data->indices = indexBuffer;
data->viewID = context->viewID; data->viewID = viewID;
data->instanceID = context->instanceID; data->instanceID = instanceID;
data->baseVertex = baseVertex; data->baseVertex = baseVertex;
if(pixelState.stencilActive) if(pixelState.stencilActive)
...@@ -457,7 +458,7 @@ namespace sw ...@@ -457,7 +458,7 @@ namespace sw
// Push constants // Push constants
{ {
data->pushConstants = context->pushConstants; data->pushConstants = pushConstants;
} }
draw->primitive = 0; draw->primitive = 0;
......
...@@ -167,7 +167,9 @@ namespace sw ...@@ -167,7 +167,9 @@ namespace sw
bool hasOcclusionQuery() const { return occlusionQuery != nullptr; } bool hasOcclusionQuery() const { return occlusionQuery != nullptr; }
void draw(const sw::Context* context, VkIndexType indexType, unsigned int count, int baseVertex, TaskEvents *events, bool update = true); void draw(const sw::Context* context, VkIndexType indexType, unsigned int count, int baseVertex,
TaskEvents *events, int instanceID, int viewID, void *indexBuffer,
PushConstantStorage const & pushConstants, bool update = true);
// Viewport & Clipper // Viewport & Clipper
void setViewport(const VkViewport &viewport); void setViewport(const VkViewport &viewport);
......
...@@ -523,7 +523,6 @@ struct DrawBase : public CommandBuffer::Command ...@@ -523,7 +523,6 @@ struct DrawBase : public CommandBuffer::Command
context.descriptorSets = pipelineState.descriptorSets; context.descriptorSets = pipelineState.descriptorSets;
context.descriptorDynamicOffsets = pipelineState.descriptorDynamicOffsets; context.descriptorDynamicOffsets = pipelineState.descriptorDynamicOffsets;
context.pushConstants = executionState.pushConstants;
// Apply either pipeline state or dynamic state // Apply either pipeline state or dynamic state
executionState.renderer->setScissor(pipeline->hasDynamicState(VK_DYNAMIC_STATE_SCISSOR) ? executionState.renderer->setScissor(pipeline->hasDynamicState(VK_DYNAMIC_STATE_SCISSOR) ?
...@@ -569,7 +568,6 @@ struct DrawBase : public CommandBuffer::Command ...@@ -569,7 +568,6 @@ struct DrawBase : public CommandBuffer::Command
executionState.bindAttachments(context); executionState.bindAttachments(context);
context.multiSampleMask = context.sampleMask & ((unsigned) 0xFFFFFFFF >> (32 - context.sampleCount));
context.occlusionEnabled = executionState.renderer->hasOcclusionQuery(); context.occlusionEnabled = executionState.renderer->hasOcclusionQuery();
std::vector<std::pair<uint32_t, void *>> indexBuffers; std::vector<std::pair<uint32_t, void *>> indexBuffers;
...@@ -603,21 +601,18 @@ struct DrawBase : public CommandBuffer::Command ...@@ -603,21 +601,18 @@ struct DrawBase : public CommandBuffer::Command
for (uint32_t instance = firstInstance; instance != firstInstance + instanceCount; instance++) for (uint32_t instance = firstInstance; instance != firstInstance + instanceCount; instance++)
{ {
context.instanceID = instance;
// FIXME: reconsider instances/views nesting. // FIXME: reconsider instances/views nesting.
auto viewMask = executionState.renderPass->getViewMask(executionState.subpassIndex); auto viewMask = executionState.renderPass->getViewMask(executionState.subpassIndex);
while (viewMask) while (viewMask)
{ {
context.viewID = sw::log2i(viewMask); int viewID = sw::log2i(viewMask);
viewMask &= ~(1 << context.viewID); viewMask &= ~(1 << viewID);
for (auto indexBuffer : indexBuffers) for (auto indexBuffer : indexBuffers)
{ {
const uint32_t primitiveCount = indexBuffer.first; executionState.renderer->draw(&context, executionState.indexType, indexBuffer.first, vertexOffset,
context.indexBuffer = indexBuffer.second; executionState.events, instance, viewID, indexBuffer.second,
executionState.renderer->draw(&context, executionState.indexType, primitiveCount, vertexOffset, executionState.pushConstants);
executionState.events);
} }
} }
......
...@@ -478,6 +478,8 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn ...@@ -478,6 +478,8 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
context.sourceBlendFactorState = attachment.srcColorBlendFactor; context.sourceBlendFactorState = attachment.srcColorBlendFactor;
} }
} }
context.multiSampleMask = context.sampleMask & ((unsigned) 0xFFFFFFFF >> (32 - context.sampleCount));
} }
void GraphicsPipeline::destroyPipeline(const VkAllocationCallbacks* pAllocator) void GraphicsPipeline::destroyPipeline(const VkAllocationCallbacks* pAllocator)
......
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