Commit f9f18ef0 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Allow vertex-only pipelines

This allows issuing draw calls which only manipulate depth/stencil. Bug: angleproject:3241 Change-Id: I62ab18a185ea5b234d3559f30c5b2b8ecb317bbb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1550900 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 13264033
......@@ -494,11 +494,11 @@ angle::Result GraphicsPipelineDesc::initializePipeline(
const RenderPass &compatibleRenderPass,
const PipelineLayout &pipelineLayout,
const gl::AttributesMask &activeAttribLocationsMask,
const ShaderModule &vertexModule,
const ShaderModule &fragmentModule,
const ShaderModule *vertexModule,
const ShaderModule *fragmentModule,
Pipeline *pipelineOut) const
{
VkPipelineShaderStageCreateInfo shaderStages[2] = {};
angle::FixedVector<VkPipelineShaderStageCreateInfo, 2> shaderStages;
VkPipelineVertexInputStateCreateInfo vertexInputState = {};
VkPipelineInputAssemblyStateCreateInfo inputAssemblyState = {};
VkPipelineViewportStateCreateInfo viewportState = {};
......@@ -510,19 +510,29 @@ angle::Result GraphicsPipelineDesc::initializePipeline(
VkPipelineColorBlendStateCreateInfo blendState = {};
VkGraphicsPipelineCreateInfo createInfo = {};
shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
shaderStages[0].flags = 0;
shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT;
shaderStages[0].module = vertexModule.getHandle();
shaderStages[0].pName = "main";
shaderStages[0].pSpecializationInfo = nullptr;
shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
shaderStages[1].flags = 0;
shaderStages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT;
shaderStages[1].module = fragmentModule.getHandle();
shaderStages[1].pName = "main";
shaderStages[1].pSpecializationInfo = nullptr;
// Vertex shader is always expected to be present.
ASSERT(vertexModule != nullptr);
VkPipelineShaderStageCreateInfo vertexStage = {};
vertexStage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
vertexStage.flags = 0;
vertexStage.stage = VK_SHADER_STAGE_VERTEX_BIT;
vertexStage.module = vertexModule->getHandle();
vertexStage.pName = "main";
vertexStage.pSpecializationInfo = nullptr;
shaderStages.push_back(vertexStage);
// Fragment shader is optional.
if (fragmentModule)
{
VkPipelineShaderStageCreateInfo fragmentStage = {};
fragmentStage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
fragmentStage.flags = 0;
fragmentStage.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
fragmentStage.module = fragmentModule->getHandle();
fragmentStage.pName = "main";
fragmentStage.pSpecializationInfo = nullptr;
shaderStages.push_back(fragmentStage);
}
// TODO(jmadill): Possibly use different path for ES 3.1 split bindings/attribs.
gl::AttribArray<VkVertexInputBindingDescription> bindingDescs;
......@@ -683,8 +693,8 @@ angle::Result GraphicsPipelineDesc::initializePipeline(
createInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
createInfo.flags = 0;
createInfo.stageCount = 2;
createInfo.pStages = shaderStages;
createInfo.stageCount = shaderStages.size();
createInfo.pStages = shaderStages.data();
createInfo.pVertexInputState = &vertexInputState;
createInfo.pInputAssemblyState = &inputAssemblyState;
createInfo.pTessellationState = nullptr;
......@@ -1359,8 +1369,8 @@ angle::Result GraphicsPipelineCache::insertPipeline(
const vk::RenderPass &compatibleRenderPass,
const vk::PipelineLayout &pipelineLayout,
const gl::AttributesMask &activeAttribLocationsMask,
const vk::ShaderModule &vertexModule,
const vk::ShaderModule &fragmentModule,
const vk::ShaderModule *vertexModule,
const vk::ShaderModule *fragmentModule,
const vk::GraphicsPipelineDesc &desc,
const vk::GraphicsPipelineDesc **descPtrOut,
vk::PipelineHelper **pipelineOut)
......
......@@ -328,8 +328,8 @@ class GraphicsPipelineDesc final
const RenderPass &compatibleRenderPass,
const PipelineLayout &pipelineLayout,
const gl::AttributesMask &activeAttribLocationsMask,
const ShaderModule &vertexModule,
const ShaderModule &fragmentModule,
const ShaderModule *vertexModule,
const ShaderModule *fragmentModule,
Pipeline *pipelineOut) const;
// Vertex input state. For ES 3.1 this should be separated into binding and attribute.
......@@ -728,8 +728,8 @@ class GraphicsPipelineCache final : angle::NonCopyable
const vk::RenderPass &compatibleRenderPass,
const vk::PipelineLayout &pipelineLayout,
const gl::AttributesMask &activeAttribLocationsMask,
const vk::ShaderModule &vertexModule,
const vk::ShaderModule &fragmentModule,
const vk::ShaderModule *vertexModule,
const vk::ShaderModule *fragmentModule,
const vk::GraphicsPipelineDesc &desc,
const vk::GraphicsPipelineDesc **descPtrOut,
vk::PipelineHelper **pipelineOut)
......@@ -753,8 +753,8 @@ class GraphicsPipelineCache final : angle::NonCopyable
const vk::RenderPass &compatibleRenderPass,
const vk::PipelineLayout &pipelineLayout,
const gl::AttributesMask &activeAttribLocationsMask,
const vk::ShaderModule &vertexModule,
const vk::ShaderModule &fragmentModule,
const vk::ShaderModule *vertexModule,
const vk::ShaderModule *fragmentModule,
const vk::GraphicsPipelineDesc &desc,
const vk::GraphicsPipelineDesc **descPtrOut,
vk::PipelineHelper **pipelineOut);
......
......@@ -844,10 +844,15 @@ class ShaderProgramHelper : angle::NonCopyable
ANGLE_TRY(renderPassCache->getCompatibleRenderPass(
context, currentQueueSerial, pipelineDesc.getRenderPassDesc(), &compatibleRenderPass));
return mGraphicsPipelines.getPipeline(
context, pipelineCache, *compatibleRenderPass, pipelineLayout,
activeAttribLocationsMask, mShaders[gl::ShaderType::Vertex].get().get(),
mShaders[gl::ShaderType::Fragment].get().get(), pipelineDesc, descPtrOut, pipelineOut);
ShaderModule *vertexShader = &mShaders[gl::ShaderType::Vertex].get().get();
ShaderModule *fragmentShader = mShaders[gl::ShaderType::Fragment].valid()
? &mShaders[gl::ShaderType::Fragment].get().get()
: nullptr;
return mGraphicsPipelines.getPipeline(context, pipelineCache, *compatibleRenderPass,
pipelineLayout, activeAttribLocationsMask,
vertexShader, fragmentShader, pipelineDesc,
descPtrOut, pipelineOut);
}
angle::Result getComputePipeline(Context *context,
......
......@@ -91,7 +91,7 @@ void VulkanPipelineCachePerfTest::step()
{
for (const auto &hit : mCacheHits)
{
(void)mCache.getPipeline(VK_NULL_HANDLE, pc, rp, pl, am, sm, sm, hit, &desc, &result);
(void)mCache.getPipeline(VK_NULL_HANDLE, pc, rp, pl, am, &sm, &sm, hit, &desc, &result);
}
}
......@@ -99,7 +99,7 @@ void VulkanPipelineCachePerfTest::step()
++missCount, ++mMissIndex)
{
const auto &miss = mCacheMisses[mMissIndex];
(void)mCache.getPipeline(VK_NULL_HANDLE, pc, rp, pl, am, sm, sm, miss, &desc, &result);
(void)mCache.getPipeline(VK_NULL_HANDLE, pc, rp, pl, am, &sm, &sm, miss, &desc, &result);
}
}
......
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