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( ...@@ -494,11 +494,11 @@ angle::Result GraphicsPipelineDesc::initializePipeline(
const RenderPass &compatibleRenderPass, const RenderPass &compatibleRenderPass,
const PipelineLayout &pipelineLayout, const PipelineLayout &pipelineLayout,
const gl::AttributesMask &activeAttribLocationsMask, const gl::AttributesMask &activeAttribLocationsMask,
const ShaderModule &vertexModule, const ShaderModule *vertexModule,
const ShaderModule &fragmentModule, const ShaderModule *fragmentModule,
Pipeline *pipelineOut) const Pipeline *pipelineOut) const
{ {
VkPipelineShaderStageCreateInfo shaderStages[2] = {}; angle::FixedVector<VkPipelineShaderStageCreateInfo, 2> shaderStages;
VkPipelineVertexInputStateCreateInfo vertexInputState = {}; VkPipelineVertexInputStateCreateInfo vertexInputState = {};
VkPipelineInputAssemblyStateCreateInfo inputAssemblyState = {}; VkPipelineInputAssemblyStateCreateInfo inputAssemblyState = {};
VkPipelineViewportStateCreateInfo viewportState = {}; VkPipelineViewportStateCreateInfo viewportState = {};
...@@ -510,19 +510,29 @@ angle::Result GraphicsPipelineDesc::initializePipeline( ...@@ -510,19 +510,29 @@ angle::Result GraphicsPipelineDesc::initializePipeline(
VkPipelineColorBlendStateCreateInfo blendState = {}; VkPipelineColorBlendStateCreateInfo blendState = {};
VkGraphicsPipelineCreateInfo createInfo = {}; VkGraphicsPipelineCreateInfo createInfo = {};
shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; // Vertex shader is always expected to be present.
shaderStages[0].flags = 0; ASSERT(vertexModule != nullptr);
shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; VkPipelineShaderStageCreateInfo vertexStage = {};
shaderStages[0].module = vertexModule.getHandle(); vertexStage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
shaderStages[0].pName = "main"; vertexStage.flags = 0;
shaderStages[0].pSpecializationInfo = nullptr; vertexStage.stage = VK_SHADER_STAGE_VERTEX_BIT;
vertexStage.module = vertexModule->getHandle();
shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; vertexStage.pName = "main";
shaderStages[1].flags = 0; vertexStage.pSpecializationInfo = nullptr;
shaderStages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT; shaderStages.push_back(vertexStage);
shaderStages[1].module = fragmentModule.getHandle();
shaderStages[1].pName = "main"; // Fragment shader is optional.
shaderStages[1].pSpecializationInfo = nullptr; 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. // TODO(jmadill): Possibly use different path for ES 3.1 split bindings/attribs.
gl::AttribArray<VkVertexInputBindingDescription> bindingDescs; gl::AttribArray<VkVertexInputBindingDescription> bindingDescs;
...@@ -683,8 +693,8 @@ angle::Result GraphicsPipelineDesc::initializePipeline( ...@@ -683,8 +693,8 @@ angle::Result GraphicsPipelineDesc::initializePipeline(
createInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; createInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
createInfo.flags = 0; createInfo.flags = 0;
createInfo.stageCount = 2; createInfo.stageCount = shaderStages.size();
createInfo.pStages = shaderStages; createInfo.pStages = shaderStages.data();
createInfo.pVertexInputState = &vertexInputState; createInfo.pVertexInputState = &vertexInputState;
createInfo.pInputAssemblyState = &inputAssemblyState; createInfo.pInputAssemblyState = &inputAssemblyState;
createInfo.pTessellationState = nullptr; createInfo.pTessellationState = nullptr;
...@@ -1359,8 +1369,8 @@ angle::Result GraphicsPipelineCache::insertPipeline( ...@@ -1359,8 +1369,8 @@ angle::Result GraphicsPipelineCache::insertPipeline(
const vk::RenderPass &compatibleRenderPass, const vk::RenderPass &compatibleRenderPass,
const vk::PipelineLayout &pipelineLayout, const vk::PipelineLayout &pipelineLayout,
const gl::AttributesMask &activeAttribLocationsMask, const gl::AttributesMask &activeAttribLocationsMask,
const vk::ShaderModule &vertexModule, const vk::ShaderModule *vertexModule,
const vk::ShaderModule &fragmentModule, const vk::ShaderModule *fragmentModule,
const vk::GraphicsPipelineDesc &desc, const vk::GraphicsPipelineDesc &desc,
const vk::GraphicsPipelineDesc **descPtrOut, const vk::GraphicsPipelineDesc **descPtrOut,
vk::PipelineHelper **pipelineOut) vk::PipelineHelper **pipelineOut)
......
...@@ -328,8 +328,8 @@ class GraphicsPipelineDesc final ...@@ -328,8 +328,8 @@ class GraphicsPipelineDesc final
const RenderPass &compatibleRenderPass, const RenderPass &compatibleRenderPass,
const PipelineLayout &pipelineLayout, const PipelineLayout &pipelineLayout,
const gl::AttributesMask &activeAttribLocationsMask, const gl::AttributesMask &activeAttribLocationsMask,
const ShaderModule &vertexModule, const ShaderModule *vertexModule,
const ShaderModule &fragmentModule, const ShaderModule *fragmentModule,
Pipeline *pipelineOut) const; Pipeline *pipelineOut) const;
// Vertex input state. For ES 3.1 this should be separated into binding and attribute. // Vertex input state. For ES 3.1 this should be separated into binding and attribute.
...@@ -728,8 +728,8 @@ class GraphicsPipelineCache final : angle::NonCopyable ...@@ -728,8 +728,8 @@ class GraphicsPipelineCache final : angle::NonCopyable
const vk::RenderPass &compatibleRenderPass, const vk::RenderPass &compatibleRenderPass,
const vk::PipelineLayout &pipelineLayout, const vk::PipelineLayout &pipelineLayout,
const gl::AttributesMask &activeAttribLocationsMask, const gl::AttributesMask &activeAttribLocationsMask,
const vk::ShaderModule &vertexModule, const vk::ShaderModule *vertexModule,
const vk::ShaderModule &fragmentModule, const vk::ShaderModule *fragmentModule,
const vk::GraphicsPipelineDesc &desc, const vk::GraphicsPipelineDesc &desc,
const vk::GraphicsPipelineDesc **descPtrOut, const vk::GraphicsPipelineDesc **descPtrOut,
vk::PipelineHelper **pipelineOut) vk::PipelineHelper **pipelineOut)
...@@ -753,8 +753,8 @@ class GraphicsPipelineCache final : angle::NonCopyable ...@@ -753,8 +753,8 @@ class GraphicsPipelineCache final : angle::NonCopyable
const vk::RenderPass &compatibleRenderPass, const vk::RenderPass &compatibleRenderPass,
const vk::PipelineLayout &pipelineLayout, const vk::PipelineLayout &pipelineLayout,
const gl::AttributesMask &activeAttribLocationsMask, const gl::AttributesMask &activeAttribLocationsMask,
const vk::ShaderModule &vertexModule, const vk::ShaderModule *vertexModule,
const vk::ShaderModule &fragmentModule, const vk::ShaderModule *fragmentModule,
const vk::GraphicsPipelineDesc &desc, const vk::GraphicsPipelineDesc &desc,
const vk::GraphicsPipelineDesc **descPtrOut, const vk::GraphicsPipelineDesc **descPtrOut,
vk::PipelineHelper **pipelineOut); vk::PipelineHelper **pipelineOut);
......
...@@ -844,10 +844,15 @@ class ShaderProgramHelper : angle::NonCopyable ...@@ -844,10 +844,15 @@ class ShaderProgramHelper : angle::NonCopyable
ANGLE_TRY(renderPassCache->getCompatibleRenderPass( ANGLE_TRY(renderPassCache->getCompatibleRenderPass(
context, currentQueueSerial, pipelineDesc.getRenderPassDesc(), &compatibleRenderPass)); context, currentQueueSerial, pipelineDesc.getRenderPassDesc(), &compatibleRenderPass));
return mGraphicsPipelines.getPipeline( ShaderModule *vertexShader = &mShaders[gl::ShaderType::Vertex].get().get();
context, pipelineCache, *compatibleRenderPass, pipelineLayout, ShaderModule *fragmentShader = mShaders[gl::ShaderType::Fragment].valid()
activeAttribLocationsMask, mShaders[gl::ShaderType::Vertex].get().get(), ? &mShaders[gl::ShaderType::Fragment].get().get()
mShaders[gl::ShaderType::Fragment].get().get(), pipelineDesc, descPtrOut, pipelineOut); : nullptr;
return mGraphicsPipelines.getPipeline(context, pipelineCache, *compatibleRenderPass,
pipelineLayout, activeAttribLocationsMask,
vertexShader, fragmentShader, pipelineDesc,
descPtrOut, pipelineOut);
} }
angle::Result getComputePipeline(Context *context, angle::Result getComputePipeline(Context *context,
......
...@@ -91,7 +91,7 @@ void VulkanPipelineCachePerfTest::step() ...@@ -91,7 +91,7 @@ void VulkanPipelineCachePerfTest::step()
{ {
for (const auto &hit : mCacheHits) 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() ...@@ -99,7 +99,7 @@ void VulkanPipelineCachePerfTest::step()
++missCount, ++mMissIndex) ++missCount, ++mMissIndex)
{ {
const auto &miss = mCacheMisses[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