Commit 03bc3db8 by Jamie Madill Committed by Commit Bot

Vulkan: Minor cleanup to UtilsVk.

Renames "ContextVk *context" to "ContextVk *contextVk" for consistency. Also adds an "allocateDescriptorSet" helper function. Bug: angleproject:3117 Change-Id: Id03e30432d8e5e35b682350a8e98fd2e62cdf89a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1644776 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent eef34e17
...@@ -271,13 +271,13 @@ void UtilsVk::destroy(VkDevice device) ...@@ -271,13 +271,13 @@ void UtilsVk::destroy(VkDevice device)
} }
} }
angle::Result UtilsVk::ensureResourcesInitialized(ContextVk *context, angle::Result UtilsVk::ensureResourcesInitialized(ContextVk *contextVk,
Function function, Function function,
VkDescriptorPoolSize *setSizes, VkDescriptorPoolSize *setSizes,
size_t setSizesCount, size_t setSizesCount,
size_t pushConstantsSize) size_t pushConstantsSize)
{ {
RendererVk *renderer = context->getRenderer(); RendererVk *renderer = contextVk->getRenderer();
vk::DescriptorSetLayoutDesc descriptorSetDesc; vk::DescriptorSetLayoutDesc descriptorSetDesc;
bool isCompute = function >= Function::ComputeStartIndex; bool isCompute = function >= Function::ComputeStartIndex;
...@@ -292,7 +292,7 @@ angle::Result UtilsVk::ensureResourcesInitialized(ContextVk *context, ...@@ -292,7 +292,7 @@ angle::Result UtilsVk::ensureResourcesInitialized(ContextVk *context,
currentBinding += setSizes[i].descriptorCount; currentBinding += setSizes[i].descriptorCount;
} }
ANGLE_TRY(renderer->getDescriptorSetLayout(context, descriptorSetDesc, ANGLE_TRY(renderer->getDescriptorSetLayout(contextVk, descriptorSetDesc,
&mDescriptorSetLayouts[function][kSetIndex])); &mDescriptorSetLayouts[function][kSetIndex]));
gl::ShaderType pushConstantsShaderStage = gl::ShaderType pushConstantsShaderStage =
...@@ -304,18 +304,19 @@ angle::Result UtilsVk::ensureResourcesInitialized(ContextVk *context, ...@@ -304,18 +304,19 @@ angle::Result UtilsVk::ensureResourcesInitialized(ContextVk *context,
pipelineLayoutDesc.updateDescriptorSetLayout(kSetIndex, descriptorSetDesc); pipelineLayoutDesc.updateDescriptorSetLayout(kSetIndex, descriptorSetDesc);
pipelineLayoutDesc.updatePushConstantRange(pushConstantsShaderStage, 0, pushConstantsSize); pipelineLayoutDesc.updatePushConstantRange(pushConstantsShaderStage, 0, pushConstantsSize);
ANGLE_TRY(renderer->getPipelineLayout( ANGLE_TRY(renderer->getPipelineLayout(contextVk, pipelineLayoutDesc,
context, pipelineLayoutDesc, mDescriptorSetLayouts[function], &mPipelineLayouts[function])); mDescriptorSetLayouts[function],
&mPipelineLayouts[function]));
if (setSizesCount > 0) if (setSizesCount > 0)
{ {
ANGLE_TRY(mDescriptorPools[function].init(context, setSizes, setSizesCount)); ANGLE_TRY(mDescriptorPools[function].init(contextVk, setSizes, setSizesCount));
} }
return angle::Result::Continue; return angle::Result::Continue;
} }
angle::Result UtilsVk::ensureBufferClearResourcesInitialized(ContextVk *context) angle::Result UtilsVk::ensureBufferClearResourcesInitialized(ContextVk *contextVk)
{ {
if (mPipelineLayouts[Function::BufferClear].valid()) if (mPipelineLayouts[Function::BufferClear].valid())
{ {
...@@ -326,11 +327,11 @@ angle::Result UtilsVk::ensureBufferClearResourcesInitialized(ContextVk *context) ...@@ -326,11 +327,11 @@ angle::Result UtilsVk::ensureBufferClearResourcesInitialized(ContextVk *context)
{VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 1}, {VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 1},
}; };
return ensureResourcesInitialized(context, Function::BufferClear, setSizes, ArraySize(setSizes), return ensureResourcesInitialized(contextVk, Function::BufferClear, setSizes,
sizeof(BufferUtilsShaderParams)); ArraySize(setSizes), sizeof(BufferUtilsShaderParams));
} }
angle::Result UtilsVk::ensureConvertIndexResourcesInitialized(ContextVk *context) angle::Result UtilsVk::ensureConvertIndexResourcesInitialized(ContextVk *contextVk)
{ {
if (mPipelineLayouts[Function::ConvertIndexBuffer].valid()) if (mPipelineLayouts[Function::ConvertIndexBuffer].valid())
{ {
...@@ -342,11 +343,11 @@ angle::Result UtilsVk::ensureConvertIndexResourcesInitialized(ContextVk *context ...@@ -342,11 +343,11 @@ angle::Result UtilsVk::ensureConvertIndexResourcesInitialized(ContextVk *context
{VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1}, {VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1},
}; };
return ensureResourcesInitialized(context, Function::ConvertIndexBuffer, setSizes, return ensureResourcesInitialized(contextVk, Function::ConvertIndexBuffer, setSizes,
ArraySize(setSizes), sizeof(ConvertIndexShaderParams)); ArraySize(setSizes), sizeof(ConvertIndexShaderParams));
} }
angle::Result UtilsVk::ensureConvertVertexResourcesInitialized(ContextVk *context) angle::Result UtilsVk::ensureConvertVertexResourcesInitialized(ContextVk *contextVk)
{ {
if (mPipelineLayouts[Function::ConvertVertexBuffer].valid()) if (mPipelineLayouts[Function::ConvertVertexBuffer].valid())
{ {
...@@ -358,11 +359,11 @@ angle::Result UtilsVk::ensureConvertVertexResourcesInitialized(ContextVk *contex ...@@ -358,11 +359,11 @@ angle::Result UtilsVk::ensureConvertVertexResourcesInitialized(ContextVk *contex
{VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1}, {VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1},
}; };
return ensureResourcesInitialized(context, Function::ConvertVertexBuffer, setSizes, return ensureResourcesInitialized(contextVk, Function::ConvertVertexBuffer, setSizes,
ArraySize(setSizes), sizeof(ConvertVertexShaderParams)); ArraySize(setSizes), sizeof(ConvertVertexShaderParams));
} }
angle::Result UtilsVk::ensureImageClearResourcesInitialized(ContextVk *context) angle::Result UtilsVk::ensureImageClearResourcesInitialized(ContextVk *contextVk)
{ {
if (mPipelineLayouts[Function::ImageClear].valid()) if (mPipelineLayouts[Function::ImageClear].valid())
{ {
...@@ -370,11 +371,11 @@ angle::Result UtilsVk::ensureImageClearResourcesInitialized(ContextVk *context) ...@@ -370,11 +371,11 @@ angle::Result UtilsVk::ensureImageClearResourcesInitialized(ContextVk *context)
} }
// The shader does not use any descriptor sets. // The shader does not use any descriptor sets.
return ensureResourcesInitialized(context, Function::ImageClear, nullptr, 0, return ensureResourcesInitialized(contextVk, Function::ImageClear, nullptr, 0,
sizeof(ImageClearShaderParams)); sizeof(ImageClearShaderParams));
} }
angle::Result UtilsVk::ensureImageCopyResourcesInitialized(ContextVk *context) angle::Result UtilsVk::ensureImageCopyResourcesInitialized(ContextVk *contextVk)
{ {
if (mPipelineLayouts[Function::ImageCopy].valid()) if (mPipelineLayouts[Function::ImageCopy].valid())
{ {
...@@ -385,11 +386,11 @@ angle::Result UtilsVk::ensureImageCopyResourcesInitialized(ContextVk *context) ...@@ -385,11 +386,11 @@ angle::Result UtilsVk::ensureImageCopyResourcesInitialized(ContextVk *context)
{VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1}, {VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1},
}; };
return ensureResourcesInitialized(context, Function::ImageCopy, setSizes, ArraySize(setSizes), return ensureResourcesInitialized(contextVk, Function::ImageCopy, setSizes, ArraySize(setSizes),
sizeof(ImageCopyShaderParams)); sizeof(ImageCopyShaderParams));
} }
angle::Result UtilsVk::ensureBlitResolveResourcesInitialized(ContextVk *context) angle::Result UtilsVk::ensureBlitResolveResourcesInitialized(ContextVk *contextVk)
{ {
if (mPipelineLayouts[Function::BlitResolve].valid()) if (mPipelineLayouts[Function::BlitResolve].valid())
{ {
...@@ -401,11 +402,11 @@ angle::Result UtilsVk::ensureBlitResolveResourcesInitialized(ContextVk *context) ...@@ -401,11 +402,11 @@ angle::Result UtilsVk::ensureBlitResolveResourcesInitialized(ContextVk *context)
{VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1}, {VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1},
}; };
return ensureResourcesInitialized(context, Function::BlitResolve, setSizes, ArraySize(setSizes), return ensureResourcesInitialized(contextVk, Function::BlitResolve, setSizes,
sizeof(BlitResolveShaderParams)); ArraySize(setSizes), sizeof(BlitResolveShaderParams));
} }
angle::Result UtilsVk::ensureBlitResolveStencilNoExportResourcesInitialized(ContextVk *context) angle::Result UtilsVk::ensureBlitResolveStencilNoExportResourcesInitialized(ContextVk *contextVk)
{ {
if (mPipelineLayouts[Function::BlitResolveStencilNoExport].valid()) if (mPipelineLayouts[Function::BlitResolveStencilNoExport].valid())
{ {
...@@ -417,12 +418,12 @@ angle::Result UtilsVk::ensureBlitResolveStencilNoExportResourcesInitialized(Cont ...@@ -417,12 +418,12 @@ angle::Result UtilsVk::ensureBlitResolveStencilNoExportResourcesInitialized(Cont
{VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1}, {VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1},
}; };
return ensureResourcesInitialized(context, Function::BlitResolveStencilNoExport, setSizes, return ensureResourcesInitialized(contextVk, Function::BlitResolveStencilNoExport, setSizes,
ArraySize(setSizes), ArraySize(setSizes),
sizeof(BlitResolveStencilNoExportShaderParams)); sizeof(BlitResolveStencilNoExportShaderParams));
} }
angle::Result UtilsVk::setupProgram(ContextVk *context, angle::Result UtilsVk::setupProgram(ContextVk *contextVk,
Function function, Function function,
vk::RefCounted<vk::ShaderAndSerial> *fsCsShader, vk::RefCounted<vk::ShaderAndSerial> *fsCsShader,
vk::RefCounted<vk::ShaderAndSerial> *vsShader, vk::RefCounted<vk::ShaderAndSerial> *vsShader,
...@@ -433,7 +434,7 @@ angle::Result UtilsVk::setupProgram(ContextVk *context, ...@@ -433,7 +434,7 @@ angle::Result UtilsVk::setupProgram(ContextVk *context,
size_t pushConstantsSize, size_t pushConstantsSize,
vk::CommandBuffer *commandBuffer) vk::CommandBuffer *commandBuffer)
{ {
RendererVk *renderer = context->getRenderer(); RendererVk *renderer = contextVk->getRenderer();
bool isCompute = function >= Function::ComputeStartIndex; bool isCompute = function >= Function::ComputeStartIndex;
VkShaderStageFlags pushConstantsShaderStage = VkShaderStageFlags pushConstantsShaderStage =
...@@ -445,13 +446,13 @@ angle::Result UtilsVk::setupProgram(ContextVk *context, ...@@ -445,13 +446,13 @@ angle::Result UtilsVk::setupProgram(ContextVk *context,
const vk::BindingPointer<vk::PipelineLayout> &pipelineLayout = mPipelineLayouts[function]; const vk::BindingPointer<vk::PipelineLayout> &pipelineLayout = mPipelineLayouts[function];
Serial serial = context->getCurrentQueueSerial(); Serial serial = contextVk->getCurrentQueueSerial();
if (isCompute) if (isCompute)
{ {
vk::PipelineAndSerial *pipelineAndSerial; vk::PipelineAndSerial *pipelineAndSerial;
program->setShader(gl::ShaderType::Compute, fsCsShader); program->setShader(gl::ShaderType::Compute, fsCsShader);
ANGLE_TRY(program->getComputePipeline(context, pipelineLayout.get(), &pipelineAndSerial)); ANGLE_TRY(program->getComputePipeline(contextVk, pipelineLayout.get(), &pipelineAndSerial));
pipelineAndSerial->updateSerial(serial); pipelineAndSerial->updateSerial(serial);
commandBuffer->bindComputePipeline(pipelineAndSerial->get()); commandBuffer->bindComputePipeline(pipelineAndSerial->get());
if (descriptorSet != VK_NULL_HANDLE) if (descriptorSet != VK_NULL_HANDLE)
...@@ -472,7 +473,7 @@ angle::Result UtilsVk::setupProgram(ContextVk *context, ...@@ -472,7 +473,7 @@ angle::Result UtilsVk::setupProgram(ContextVk *context,
vk::PipelineHelper *helper; vk::PipelineHelper *helper;
ANGLE_TRY(program->getGraphicsPipeline( ANGLE_TRY(program->getGraphicsPipeline(
context, &context->getRenderPassCache(), renderer->getPipelineCache(), serial, contextVk, &contextVk->getRenderPassCache(), renderer->getPipelineCache(), serial,
pipelineLayout.get(), *pipelineDesc, gl::AttributesMask(), &descPtr, &helper)); pipelineLayout.get(), *pipelineDesc, gl::AttributesMask(), &descPtr, &helper));
helper->updateSerial(serial); helper->updateSerial(serial);
commandBuffer->bindGraphicsPipeline(helper->getPipeline()); commandBuffer->bindGraphicsPipeline(helper->getPipeline());
...@@ -489,14 +490,14 @@ angle::Result UtilsVk::setupProgram(ContextVk *context, ...@@ -489,14 +490,14 @@ angle::Result UtilsVk::setupProgram(ContextVk *context,
return angle::Result::Continue; return angle::Result::Continue;
} }
angle::Result UtilsVk::clearBuffer(ContextVk *context, angle::Result UtilsVk::clearBuffer(ContextVk *contextVk,
vk::BufferHelper *dest, vk::BufferHelper *dest,
const ClearParameters &params) const ClearParameters &params)
{ {
ANGLE_TRY(ensureBufferClearResourcesInitialized(context)); ANGLE_TRY(ensureBufferClearResourcesInitialized(contextVk));
vk::CommandBuffer *commandBuffer; vk::CommandBuffer *commandBuffer;
ANGLE_TRY(dest->recordCommands(context, &commandBuffer)); ANGLE_TRY(dest->recordCommands(contextVk, &commandBuffer));
// Tell dest it's being written to. // Tell dest it's being written to.
dest->onWrite(VK_ACCESS_SHADER_WRITE_BIT); dest->onWrite(VK_ACCESS_SHADER_WRITE_BIT);
...@@ -512,10 +513,8 @@ angle::Result UtilsVk::clearBuffer(ContextVk *context, ...@@ -512,10 +513,8 @@ angle::Result UtilsVk::clearBuffer(ContextVk *context,
VkDescriptorSet descriptorSet; VkDescriptorSet descriptorSet;
vk::RefCountedDescriptorPoolBinding descriptorPoolBinding; vk::RefCountedDescriptorPoolBinding descriptorPoolBinding;
ANGLE_TRY(mDescriptorPools[Function::BufferClear].allocateSets( ANGLE_TRY(allocateDescriptorSet(contextVk, Function::BufferClear, &descriptorPoolBinding,
context, mDescriptorSetLayouts[Function::BufferClear][kSetIndex].get().ptr(), 1, &descriptorSet));
&descriptorPoolBinding, &descriptorSet));
descriptorPoolBinding.get().updateSerial(context->getCurrentQueueSerial());
VkWriteDescriptorSet writeInfo = {}; VkWriteDescriptorSet writeInfo = {};
...@@ -526,12 +525,12 @@ angle::Result UtilsVk::clearBuffer(ContextVk *context, ...@@ -526,12 +525,12 @@ angle::Result UtilsVk::clearBuffer(ContextVk *context,
writeInfo.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; writeInfo.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER;
writeInfo.pTexelBufferView = dest->getBufferView().ptr(); writeInfo.pTexelBufferView = dest->getBufferView().ptr();
vkUpdateDescriptorSets(context->getDevice(), 1, &writeInfo, 0, nullptr); vkUpdateDescriptorSets(contextVk->getDevice(), 1, &writeInfo, 0, nullptr);
vk::RefCounted<vk::ShaderAndSerial> *shader = nullptr; vk::RefCounted<vk::ShaderAndSerial> *shader = nullptr;
ANGLE_TRY(context->getShaderLibrary().getBufferUtils_comp(context, flags, &shader)); ANGLE_TRY(contextVk->getShaderLibrary().getBufferUtils_comp(contextVk, flags, &shader));
ANGLE_TRY(setupProgram(context, Function::BufferClear, shader, nullptr, ANGLE_TRY(setupProgram(contextVk, Function::BufferClear, shader, nullptr,
&mBufferUtilsPrograms[flags], nullptr, descriptorSet, &shaderParams, &mBufferUtilsPrograms[flags], nullptr, descriptorSet, &shaderParams,
sizeof(shaderParams), commandBuffer)); sizeof(shaderParams), commandBuffer));
...@@ -542,15 +541,15 @@ angle::Result UtilsVk::clearBuffer(ContextVk *context, ...@@ -542,15 +541,15 @@ angle::Result UtilsVk::clearBuffer(ContextVk *context,
return angle::Result::Continue; return angle::Result::Continue;
} }
angle::Result UtilsVk::convertIndexBuffer(ContextVk *context, angle::Result UtilsVk::convertIndexBuffer(ContextVk *contextVk,
vk::BufferHelper *dest, vk::BufferHelper *dest,
vk::BufferHelper *src, vk::BufferHelper *src,
const ConvertIndexParameters &params) const ConvertIndexParameters &params)
{ {
ANGLE_TRY(ensureConvertIndexResourcesInitialized(context)); ANGLE_TRY(ensureConvertIndexResourcesInitialized(contextVk));
vk::CommandBuffer *commandBuffer; vk::CommandBuffer *commandBuffer;
ANGLE_TRY(dest->recordCommands(context, &commandBuffer)); ANGLE_TRY(dest->recordCommands(contextVk, &commandBuffer));
// Tell src we are going to read from it. // Tell src we are going to read from it.
src->onRead(dest, VK_ACCESS_SHADER_READ_BIT); src->onRead(dest, VK_ACCESS_SHADER_READ_BIT);
...@@ -559,10 +558,8 @@ angle::Result UtilsVk::convertIndexBuffer(ContextVk *context, ...@@ -559,10 +558,8 @@ angle::Result UtilsVk::convertIndexBuffer(ContextVk *context,
VkDescriptorSet descriptorSet; VkDescriptorSet descriptorSet;
vk::RefCountedDescriptorPoolBinding descriptorPoolBinding; vk::RefCountedDescriptorPoolBinding descriptorPoolBinding;
ANGLE_TRY(mDescriptorPools[Function::ConvertIndexBuffer].allocateSets( ANGLE_TRY(allocateDescriptorSet(contextVk, Function::ConvertIndexBuffer, &descriptorPoolBinding,
context, mDescriptorSetLayouts[Function::ConvertIndexBuffer][kSetIndex].get().ptr(), 1, &descriptorSet));
&descriptorPoolBinding, &descriptorSet));
descriptorPoolBinding.get().updateSerial(context->getCurrentQueueSerial());
std::array<VkDescriptorBufferInfo, 2> buffers = {{ std::array<VkDescriptorBufferInfo, 2> buffers = {{
{dest->getBuffer().getHandle(), 0, VK_WHOLE_SIZE}, {dest->getBuffer().getHandle(), 0, VK_WHOLE_SIZE},
...@@ -577,15 +574,15 @@ angle::Result UtilsVk::convertIndexBuffer(ContextVk *context, ...@@ -577,15 +574,15 @@ angle::Result UtilsVk::convertIndexBuffer(ContextVk *context,
writeInfo.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; writeInfo.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
writeInfo.pBufferInfo = buffers.data(); writeInfo.pBufferInfo = buffers.data();
vkUpdateDescriptorSets(context->getDevice(), 1, &writeInfo, 0, nullptr); vkUpdateDescriptorSets(contextVk->getDevice(), 1, &writeInfo, 0, nullptr);
ConvertIndexShaderParams shaderParams = {params.srcOffset, params.dstOffset >> 2, ConvertIndexShaderParams shaderParams = {params.srcOffset, params.dstOffset >> 2,
params.maxIndex, 0}; params.maxIndex, 0};
vk::RefCounted<vk::ShaderAndSerial> *shader = nullptr; vk::RefCounted<vk::ShaderAndSerial> *shader = nullptr;
ANGLE_TRY(context->getShaderLibrary().getConvertIndex_comp(context, 0, &shader)); ANGLE_TRY(contextVk->getShaderLibrary().getConvertIndex_comp(contextVk, 0, &shader));
ANGLE_TRY(setupProgram(context, Function::ConvertIndexBuffer, shader, nullptr, ANGLE_TRY(setupProgram(contextVk, Function::ConvertIndexBuffer, shader, nullptr,
&mConvertIndexProgram, nullptr, descriptorSet, &shaderParams, &mConvertIndexProgram, nullptr, descriptorSet, &shaderParams,
sizeof(ConvertIndexShaderParams), commandBuffer)); sizeof(ConvertIndexShaderParams), commandBuffer));
...@@ -601,15 +598,15 @@ angle::Result UtilsVk::convertIndexBuffer(ContextVk *context, ...@@ -601,15 +598,15 @@ angle::Result UtilsVk::convertIndexBuffer(ContextVk *context,
return angle::Result::Continue; return angle::Result::Continue;
} }
angle::Result UtilsVk::convertVertexBuffer(ContextVk *context, angle::Result UtilsVk::convertVertexBuffer(ContextVk *contextVk,
vk::BufferHelper *dest, vk::BufferHelper *dest,
vk::BufferHelper *src, vk::BufferHelper *src,
const ConvertVertexParameters &params) const ConvertVertexParameters &params)
{ {
ANGLE_TRY(ensureConvertVertexResourcesInitialized(context)); ANGLE_TRY(ensureConvertVertexResourcesInitialized(contextVk));
vk::CommandBuffer *commandBuffer; vk::CommandBuffer *commandBuffer;
ANGLE_TRY(dest->recordCommands(context, &commandBuffer)); ANGLE_TRY(dest->recordCommands(contextVk, &commandBuffer));
// Tell src we are going to read from it. // Tell src we are going to read from it.
src->onRead(dest, VK_ACCESS_SHADER_READ_BIT); src->onRead(dest, VK_ACCESS_SHADER_READ_BIT);
...@@ -645,10 +642,8 @@ angle::Result UtilsVk::convertVertexBuffer(ContextVk *context, ...@@ -645,10 +642,8 @@ angle::Result UtilsVk::convertVertexBuffer(ContextVk *context,
VkDescriptorSet descriptorSet; VkDescriptorSet descriptorSet;
vk::RefCountedDescriptorPoolBinding descriptorPoolBinding; vk::RefCountedDescriptorPoolBinding descriptorPoolBinding;
ANGLE_TRY(mDescriptorPools[Function::ConvertVertexBuffer].allocateSets( ANGLE_TRY(allocateDescriptorSet(contextVk, Function::ConvertVertexBuffer,
context, mDescriptorSetLayouts[Function::ConvertVertexBuffer][kSetIndex].get().ptr(), 1, &descriptorPoolBinding, &descriptorSet));
&descriptorPoolBinding, &descriptorSet));
descriptorPoolBinding.get().updateSerial(context->getCurrentQueueSerial());
VkWriteDescriptorSet writeInfo = {}; VkWriteDescriptorSet writeInfo = {};
VkDescriptorBufferInfo buffers[2] = { VkDescriptorBufferInfo buffers[2] = {
...@@ -665,12 +660,12 @@ angle::Result UtilsVk::convertVertexBuffer(ContextVk *context, ...@@ -665,12 +660,12 @@ angle::Result UtilsVk::convertVertexBuffer(ContextVk *context,
writeInfo.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; writeInfo.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
writeInfo.pBufferInfo = buffers; writeInfo.pBufferInfo = buffers;
vkUpdateDescriptorSets(context->getDevice(), 1, &writeInfo, 0, nullptr); vkUpdateDescriptorSets(contextVk->getDevice(), 1, &writeInfo, 0, nullptr);
vk::RefCounted<vk::ShaderAndSerial> *shader = nullptr; vk::RefCounted<vk::ShaderAndSerial> *shader = nullptr;
ANGLE_TRY(context->getShaderLibrary().getConvertVertex_comp(context, flags, &shader)); ANGLE_TRY(contextVk->getShaderLibrary().getConvertVertex_comp(contextVk, flags, &shader));
ANGLE_TRY(setupProgram(context, Function::ConvertVertexBuffer, shader, nullptr, ANGLE_TRY(setupProgram(contextVk, Function::ConvertVertexBuffer, shader, nullptr,
&mConvertVertexPrograms[flags], nullptr, descriptorSet, &shaderParams, &mConvertVertexPrograms[flags], nullptr, descriptorSet, &shaderParams,
sizeof(shaderParams), commandBuffer)); sizeof(shaderParams), commandBuffer));
...@@ -876,10 +871,8 @@ angle::Result UtilsVk::blitResolveImpl(ContextVk *contextVk, ...@@ -876,10 +871,8 @@ angle::Result UtilsVk::blitResolveImpl(ContextVk *contextVk,
VkDescriptorSet descriptorSet; VkDescriptorSet descriptorSet;
vk::RefCountedDescriptorPoolBinding descriptorPoolBinding; vk::RefCountedDescriptorPoolBinding descriptorPoolBinding;
ANGLE_TRY(mDescriptorPools[Function::BlitResolve].allocateSets( ANGLE_TRY(allocateDescriptorSet(contextVk, Function::BlitResolve, &descriptorPoolBinding,
contextVk, mDescriptorSetLayouts[Function::BlitResolve][kSetIndex].get().ptr(), 1, &descriptorSet));
&descriptorPoolBinding, &descriptorSet));
descriptorPoolBinding.get().updateSerial(contextVk->getCurrentQueueSerial());
vk::GraphicsPipelineDesc pipelineDesc; vk::GraphicsPipelineDesc pipelineDesc;
pipelineDesc.initDefaults(); pipelineDesc.initDefaults();
...@@ -1001,11 +994,8 @@ angle::Result UtilsVk::stencilBlitResolveNoShaderExport(ContextVk *contextVk, ...@@ -1001,11 +994,8 @@ angle::Result UtilsVk::stencilBlitResolveNoShaderExport(ContextVk *contextVk,
VkDescriptorSet descriptorSet; VkDescriptorSet descriptorSet;
vk::RefCountedDescriptorPoolBinding descriptorPoolBinding; vk::RefCountedDescriptorPoolBinding descriptorPoolBinding;
ANGLE_TRY(mDescriptorPools[Function::BlitResolveStencilNoExport].allocateSets( ANGLE_TRY(allocateDescriptorSet(contextVk, Function::BlitResolveStencilNoExport,
contextVk, &descriptorPoolBinding, &descriptorSet));
mDescriptorSetLayouts[Function::BlitResolveStencilNoExport][kSetIndex].get().ptr(), 1,
&descriptorPoolBinding, &descriptorSet));
descriptorPoolBinding.get().updateSerial(contextVk->getCurrentQueueSerial());
// Create a temporary buffer to resolve stencil into. // Create a temporary buffer to resolve stencil into.
vk::Scoped<vk::BufferHelper> resolveBuffer(contextVk->getDevice()); vk::Scoped<vk::BufferHelper> resolveBuffer(contextVk->getDevice());
...@@ -1182,10 +1172,8 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk, ...@@ -1182,10 +1172,8 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk,
VkDescriptorSet descriptorSet; VkDescriptorSet descriptorSet;
vk::RefCountedDescriptorPoolBinding descriptorPoolBinding; vk::RefCountedDescriptorPoolBinding descriptorPoolBinding;
ANGLE_TRY(mDescriptorPools[Function::ImageCopy].allocateSets( ANGLE_TRY(allocateDescriptorSet(contextVk, Function::ImageCopy, &descriptorPoolBinding,
contextVk, mDescriptorSetLayouts[Function::ImageCopy][kSetIndex].get().ptr(), 1, &descriptorSet));
&descriptorPoolBinding, &descriptorSet));
descriptorPoolBinding.get().updateSerial(contextVk->getCurrentQueueSerial());
vk::RenderPassDesc renderPassDesc; vk::RenderPassDesc renderPassDesc;
renderPassDesc.setSamples(dest->getSamples()); renderPassDesc.setSamples(dest->getSamples());
...@@ -1263,6 +1251,18 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk, ...@@ -1263,6 +1251,18 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk,
return angle::Result::Continue; return angle::Result::Continue;
} }
angle::Result UtilsVk::allocateDescriptorSet(ContextVk *contextVk,
Function function,
vk::RefCountedDescriptorPoolBinding *bindingOut,
VkDescriptorSet *descriptorSetOut)
{
ANGLE_TRY(mDescriptorPools[function].allocateSets(
contextVk, mDescriptorSetLayouts[function][kSetIndex].get().ptr(), 1,
bindingOut, descriptorSetOut));
bindingOut->get().updateSerial(contextVk->getCurrentQueueSerial());
return angle::Result::Continue;
}
UtilsVk::ClearFramebufferParameters::ClearFramebufferParameters() UtilsVk::ClearFramebufferParameters::ClearFramebufferParameters()
: clearColor(false), : clearColor(false),
clearStencil(false), clearStencil(false),
......
...@@ -112,14 +112,14 @@ class UtilsVk : angle::NonCopyable ...@@ -112,14 +112,14 @@ class UtilsVk : angle::NonCopyable
bool destFlipY; bool destFlipY;
}; };
angle::Result clearBuffer(ContextVk *context, angle::Result clearBuffer(ContextVk *contextVk,
vk::BufferHelper *dest, vk::BufferHelper *dest,
const ClearParameters &params); const ClearParameters &params);
angle::Result convertIndexBuffer(ContextVk *context, angle::Result convertIndexBuffer(ContextVk *contextVk,
vk::BufferHelper *dest, vk::BufferHelper *dest,
vk::BufferHelper *src, vk::BufferHelper *src,
const ConvertIndexParameters &params); const ConvertIndexParameters &params);
angle::Result convertVertexBuffer(ContextVk *context, angle::Result convertVertexBuffer(ContextVk *contextVk,
vk::BufferHelper *dest, vk::BufferHelper *dest,
vk::BufferHelper *src, vk::BufferHelper *src,
const ConvertVertexParameters &params); const ConvertVertexParameters &params);
...@@ -262,7 +262,7 @@ class UtilsVk : angle::NonCopyable ...@@ -262,7 +262,7 @@ class UtilsVk : angle::NonCopyable
// compute shader, vsShader and pipelineDesc should be nullptr, and this will set up a dispatch // compute shader, vsShader and pipelineDesc should be nullptr, and this will set up a dispatch
// call. Otherwise fsCsShader is expected to be a fragment shader and this will set up a draw // call. Otherwise fsCsShader is expected to be a fragment shader and this will set up a draw
// call. // call.
angle::Result setupProgram(ContextVk *context, angle::Result setupProgram(ContextVk *contextVk,
Function function, Function function,
vk::RefCounted<vk::ShaderAndSerial> *fsCsShader, vk::RefCounted<vk::ShaderAndSerial> *fsCsShader,
vk::RefCounted<vk::ShaderAndSerial> *vsShader, vk::RefCounted<vk::ShaderAndSerial> *vsShader,
...@@ -278,7 +278,7 @@ class UtilsVk : angle::NonCopyable ...@@ -278,7 +278,7 @@ class UtilsVk : angle::NonCopyable
// this array has two entries {STORAGE_TEXEL_BUFFER, 1} and {UNIFORM_TEXEL_BUFFER, 3}, then the // this array has two entries {STORAGE_TEXEL_BUFFER, 1} and {UNIFORM_TEXEL_BUFFER, 3}, then the
// created set layout would be binding 0 for storage texel buffer and bindings 1 through 3 for // created set layout would be binding 0 for storage texel buffer and bindings 1 through 3 for
// uniform texel buffer. All resources are put in set 0. // uniform texel buffer. All resources are put in set 0.
angle::Result ensureResourcesInitialized(ContextVk *context, angle::Result ensureResourcesInitialized(ContextVk *contextVk,
Function function, Function function,
VkDescriptorPoolSize *setSizes, VkDescriptorPoolSize *setSizes,
size_t setSizesCount, size_t setSizesCount,
...@@ -286,13 +286,13 @@ class UtilsVk : angle::NonCopyable ...@@ -286,13 +286,13 @@ class UtilsVk : angle::NonCopyable
// Initializers corresponding to functions, calling into ensureResourcesInitialized with the // Initializers corresponding to functions, calling into ensureResourcesInitialized with the
// appropriate parameters. // appropriate parameters.
angle::Result ensureBufferClearResourcesInitialized(ContextVk *context); angle::Result ensureBufferClearResourcesInitialized(ContextVk *contextVk);
angle::Result ensureConvertIndexResourcesInitialized(ContextVk *context); angle::Result ensureConvertIndexResourcesInitialized(ContextVk *contextVk);
angle::Result ensureConvertVertexResourcesInitialized(ContextVk *context); angle::Result ensureConvertVertexResourcesInitialized(ContextVk *contextVk);
angle::Result ensureImageClearResourcesInitialized(ContextVk *context); angle::Result ensureImageClearResourcesInitialized(ContextVk *contextVk);
angle::Result ensureImageCopyResourcesInitialized(ContextVk *context); angle::Result ensureImageCopyResourcesInitialized(ContextVk *contextVk);
angle::Result ensureBlitResolveResourcesInitialized(ContextVk *context); angle::Result ensureBlitResolveResourcesInitialized(ContextVk *contextVk);
angle::Result ensureBlitResolveStencilNoExportResourcesInitialized(ContextVk *context); angle::Result ensureBlitResolveStencilNoExportResourcesInitialized(ContextVk *contextVk);
angle::Result startRenderPass(ContextVk *contextVk, angle::Result startRenderPass(ContextVk *contextVk,
vk::ImageHelper *image, vk::ImageHelper *image,
...@@ -310,6 +310,12 @@ class UtilsVk : angle::NonCopyable ...@@ -310,6 +310,12 @@ class UtilsVk : angle::NonCopyable
const vk::ImageView *srcStencilView, const vk::ImageView *srcStencilView,
const BlitResolveParameters &params); const BlitResolveParameters &params);
// Allocates a single descriptor set.
angle::Result allocateDescriptorSet(ContextVk *contextVk,
Function function,
vk::RefCountedDescriptorPoolBinding *bindingOut,
VkDescriptorSet *descriptorSetOut);
angle::PackedEnumMap<Function, vk::DescriptorSetLayoutPointerArray> mDescriptorSetLayouts; angle::PackedEnumMap<Function, vk::DescriptorSetLayoutPointerArray> mDescriptorSetLayouts;
angle::PackedEnumMap<Function, vk::BindingPointer<vk::PipelineLayout>> mPipelineLayouts; angle::PackedEnumMap<Function, vk::BindingPointer<vk::PipelineLayout>> mPipelineLayouts;
angle::PackedEnumMap<Function, vk::DynamicDescriptorPool> mDescriptorPools; angle::PackedEnumMap<Function, vk::DynamicDescriptorPool> mDescriptorPools;
......
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