Commit c30f45d3 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Rename PipelineDesc/Cache to Graphics&

PipelineDesc describes a Vertex-Fragment pipeline and PipelineCache (not to be confused with vk::PipelineCache) implements a cache of such pipeline objects. In preparation for Compute support, these data structures are prefixed with Graphics. Bug: angleproject:2959 Change-Id: I9181586fb946b787216ca0b2ad6340f90c3ab55f Reviewed-on: https://chromium-review.googlesource.com/c/1333971Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent d9ee8bf9
......@@ -210,8 +210,8 @@ angle::Result ContextVk::initialize()
mRenderer->getPhysicalDeviceProperties().limits.minUniformBufferOffsetAlignment);
mDriverUniformsBuffer.init(minAlignment, mRenderer);
mPipelineDesc.reset(new vk::PipelineDesc());
mPipelineDesc->initDefaults();
mGraphicsPipelineDesc.reset(new vk::GraphicsPipelineDesc());
mGraphicsPipelineDesc->initDefaults();
// Initialize current value/default attribute buffers.
for (vk::DynamicBuffer &buffer : mDefaultAttribBuffers)
......@@ -240,13 +240,13 @@ angle::Result ContextVk::initPipeline()
mProgram->getState().getActiveAttribLocationsMask();
// Ensure the topology of the pipeline description is updated.
mPipelineDesc->updateTopology(mCurrentDrawMode);
mGraphicsPipelineDesc->updateTopology(mCurrentDrawMode);
// Copy over the latest attrib and binding descriptions.
mVertexArray->getPackedInputDescriptions(mPipelineDesc.get());
mVertexArray->getPackedInputDescriptions(mGraphicsPipelineDesc.get());
// Ensure that the RenderPass description is updated.
mPipelineDesc->updateRenderPassDesc(mDrawFramebuffer->getRenderPassDesc());
mGraphicsPipelineDesc->updateRenderPassDesc(mDrawFramebuffer->getRenderPassDesc());
// Trigger draw call shader patching and fill out the pipeline desc.
const vk::ShaderAndSerial *vertexShaderAndSerial = nullptr;
......@@ -255,12 +255,12 @@ angle::Result ContextVk::initPipeline()
ANGLE_TRY(mProgram->initShaders(this, mCurrentDrawMode, &vertexShaderAndSerial,
&fragmentShaderAndSerial, &pipelineLayout));
mPipelineDesc->updateShaders(vertexShaderAndSerial->getSerial(),
fragmentShaderAndSerial->getSerial());
mGraphicsPipelineDesc->updateShaders(vertexShaderAndSerial->getSerial(),
fragmentShaderAndSerial->getSerial());
ANGLE_TRY(mRenderer->getPipeline(this, *vertexShaderAndSerial, *fragmentShaderAndSerial,
*pipelineLayout, *mPipelineDesc, activeAttribLocationsMask,
&mCurrentPipeline));
*pipelineLayout, *mGraphicsPipelineDesc,
activeAttribLocationsMask, &mCurrentPipeline));
return angle::Result::Continue();
}
......@@ -651,8 +651,8 @@ void ContextVk::updateColorMask(const gl::BlendState &blendState)
blendState.colorMaskBlue, blendState.colorMaskAlpha);
FramebufferVk *framebufferVk = vk::GetImpl(mState.getState().getDrawFramebuffer());
mPipelineDesc->updateColorWriteMask(mClearColorMask,
framebufferVk->getEmulatedAlphaAttachmentMask());
mGraphicsPipelineDesc->updateColorWriteMask(mClearColorMask,
framebufferVk->getEmulatedAlphaAttachmentMask());
}
void ContextVk::updateViewport(FramebufferVk *framebufferVk,
......@@ -717,16 +717,16 @@ angle::Result ContextVk::syncState(const gl::Context *context,
updateDepthRange(glState.getNearPlane(), glState.getFarPlane());
break;
case gl::State::DIRTY_BIT_BLEND_ENABLED:
mPipelineDesc->updateBlendEnabled(glState.isBlendEnabled());
mGraphicsPipelineDesc->updateBlendEnabled(glState.isBlendEnabled());
break;
case gl::State::DIRTY_BIT_BLEND_COLOR:
mPipelineDesc->updateBlendColor(glState.getBlendColor());
mGraphicsPipelineDesc->updateBlendColor(glState.getBlendColor());
break;
case gl::State::DIRTY_BIT_BLEND_FUNCS:
mPipelineDesc->updateBlendFuncs(glState.getBlendState());
mGraphicsPipelineDesc->updateBlendFuncs(glState.getBlendState());
break;
case gl::State::DIRTY_BIT_BLEND_EQUATIONS:
mPipelineDesc->updateBlendEquations(glState.getBlendState());
mGraphicsPipelineDesc->updateBlendEquations(glState.getBlendState());
break;
case gl::State::DIRTY_BIT_COLOR_MASK:
updateColorMask(glState.getBlendState());
......@@ -742,60 +742,61 @@ angle::Result ContextVk::syncState(const gl::Context *context,
case gl::State::DIRTY_BIT_SAMPLE_MASK:
break;
case gl::State::DIRTY_BIT_DEPTH_TEST_ENABLED:
mPipelineDesc->updateDepthTestEnabled(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
mGraphicsPipelineDesc->updateDepthTestEnabled(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
break;
case gl::State::DIRTY_BIT_DEPTH_FUNC:
mPipelineDesc->updateDepthFunc(glState.getDepthStencilState());
mGraphicsPipelineDesc->updateDepthFunc(glState.getDepthStencilState());
break;
case gl::State::DIRTY_BIT_DEPTH_MASK:
mPipelineDesc->updateDepthWriteEnabled(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
mGraphicsPipelineDesc->updateDepthWriteEnabled(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
break;
case gl::State::DIRTY_BIT_STENCIL_TEST_ENABLED:
mPipelineDesc->updateStencilTestEnabled(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
mGraphicsPipelineDesc->updateStencilTestEnabled(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
break;
case gl::State::DIRTY_BIT_STENCIL_FUNCS_FRONT:
mPipelineDesc->updateStencilFrontFuncs(glState.getStencilRef(),
glState.getDepthStencilState());
mGraphicsPipelineDesc->updateStencilFrontFuncs(glState.getStencilRef(),
glState.getDepthStencilState());
break;
case gl::State::DIRTY_BIT_STENCIL_FUNCS_BACK:
mPipelineDesc->updateStencilBackFuncs(glState.getStencilBackRef(),
glState.getDepthStencilState());
mGraphicsPipelineDesc->updateStencilBackFuncs(glState.getStencilBackRef(),
glState.getDepthStencilState());
break;
case gl::State::DIRTY_BIT_STENCIL_OPS_FRONT:
mPipelineDesc->updateStencilFrontOps(glState.getDepthStencilState());
mGraphicsPipelineDesc->updateStencilFrontOps(glState.getDepthStencilState());
break;
case gl::State::DIRTY_BIT_STENCIL_OPS_BACK:
mPipelineDesc->updateStencilBackOps(glState.getDepthStencilState());
mGraphicsPipelineDesc->updateStencilBackOps(glState.getDepthStencilState());
break;
case gl::State::DIRTY_BIT_STENCIL_WRITEMASK_FRONT:
mPipelineDesc->updateStencilFrontWriteMask(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
mGraphicsPipelineDesc->updateStencilFrontWriteMask(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
break;
case gl::State::DIRTY_BIT_STENCIL_WRITEMASK_BACK:
mPipelineDesc->updateStencilBackWriteMask(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
mGraphicsPipelineDesc->updateStencilBackWriteMask(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
break;
case gl::State::DIRTY_BIT_CULL_FACE_ENABLED:
case gl::State::DIRTY_BIT_CULL_FACE:
mPipelineDesc->updateCullMode(glState.getRasterizerState());
mGraphicsPipelineDesc->updateCullMode(glState.getRasterizerState());
break;
case gl::State::DIRTY_BIT_FRONT_FACE:
mPipelineDesc->updateFrontFace(glState.getRasterizerState(),
isViewportFlipEnabledForDrawFBO());
mGraphicsPipelineDesc->updateFrontFace(glState.getRasterizerState(),
isViewportFlipEnabledForDrawFBO());
break;
case gl::State::DIRTY_BIT_POLYGON_OFFSET_FILL_ENABLED:
mPipelineDesc->updatePolygonOffsetFillEnabled(glState.isPolygonOffsetFillEnabled());
mGraphicsPipelineDesc->updatePolygonOffsetFillEnabled(
glState.isPolygonOffsetFillEnabled());
break;
case gl::State::DIRTY_BIT_POLYGON_OFFSET:
mPipelineDesc->updatePolygonOffset(glState.getRasterizerState());
mGraphicsPipelineDesc->updatePolygonOffset(glState.getRasterizerState());
break;
case gl::State::DIRTY_BIT_RASTERIZER_DISCARD_ENABLED:
break;
case gl::State::DIRTY_BIT_LINE_WIDTH:
mPipelineDesc->updateLineWidth(glState.getLineWidth());
mGraphicsPipelineDesc->updateLineWidth(glState.getLineWidth());
break;
case gl::State::DIRTY_BIT_PRIMITIVE_RESTART_ENABLED:
break;
......@@ -840,18 +841,18 @@ angle::Result ContextVk::syncState(const gl::Context *context,
updateViewport(mDrawFramebuffer, glState.getViewport(), glState.getNearPlane(),
glState.getFarPlane(), isViewportFlipEnabledForDrawFBO());
updateColorMask(glState.getBlendState());
mPipelineDesc->updateCullMode(glState.getRasterizerState());
mGraphicsPipelineDesc->updateCullMode(glState.getRasterizerState());
updateScissor(glState);
mPipelineDesc->updateDepthTestEnabled(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
mPipelineDesc->updateDepthWriteEnabled(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
mPipelineDesc->updateStencilTestEnabled(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
mPipelineDesc->updateStencilFrontWriteMask(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
mPipelineDesc->updateStencilBackWriteMask(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
mGraphicsPipelineDesc->updateDepthTestEnabled(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
mGraphicsPipelineDesc->updateDepthWriteEnabled(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
mGraphicsPipelineDesc->updateStencilTestEnabled(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
mGraphicsPipelineDesc->updateStencilFrontWriteMask(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
mGraphicsPipelineDesc->updateStencilBackWriteMask(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
break;
}
case gl::State::DIRTY_BIT_RENDERBUFFER_BINDING:
......
......@@ -267,7 +267,7 @@ class ContextVk : public ContextImpl, public vk::Context
// Keep a cached pipeline description structure that can be used to query the pipeline cache.
// Kept in a pointer so allocations can be aligned, and structs can be portably packed.
std::unique_ptr<vk::PipelineDesc> mPipelineDesc;
std::unique_ptr<vk::GraphicsPipelineDesc> mGraphicsPipelineDesc;
// The descriptor pools are externally sychronized, so cannot be accessed from different
// threads simultaneously. Hence, we keep them in the ContextVk instead of the RendererVk.
......
......@@ -1043,7 +1043,7 @@ angle::Result FramebufferVk::clearWithDraw(ContextVk *contextVk,
bool invertViewport = contextVk->isViewportFlipEnabledForDrawFBO();
// This pipeline desc could be cached.
vk::PipelineDesc pipelineDesc;
vk::GraphicsPipelineDesc pipelineDesc;
pipelineDesc.initDefaults();
pipelineDesc.updateColorWriteMask(colorMaskFlags, getEmulatedAlphaAttachmentMask());
pipelineDesc.updateRenderPassDesc(getRenderPassDesc());
......
......@@ -330,7 +330,7 @@ void RendererVk::onDestroy(vk::Context *context)
mDescriptorSetLayoutCache.destroy(mDevice);
mRenderPassCache.destroy(mDevice);
mPipelineCache.destroy(mDevice);
mGraphicsPipelineCache.destroy(mDevice);
mPipelineCacheVk.destroy(mDevice);
mSubmitSemaphorePool.destroy(mDevice);
mShaderLibrary.destroy(mDevice);
......@@ -1143,7 +1143,7 @@ angle::Result RendererVk::getPipeline(vk::Context *context,
const vk::ShaderAndSerial &vertexShader,
const vk::ShaderAndSerial &fragmentShader,
const vk::PipelineLayout &pipelineLayout,
const vk::PipelineDesc &pipelineDesc,
const vk::GraphicsPipelineDesc &pipelineDesc,
const gl::AttributesMask &activeAttribLocationsMask,
vk::PipelineAndSerial **pipelineOut)
{
......@@ -1157,9 +1157,9 @@ angle::Result RendererVk::getPipeline(vk::Context *context,
ANGLE_TRY(
getCompatibleRenderPass(context, pipelineDesc.getRenderPassDesc(), &compatibleRenderPass));
return mPipelineCache.getPipeline(context, mPipelineCacheVk, *compatibleRenderPass,
pipelineLayout, activeAttribLocationsMask, vertexShader.get(),
fragmentShader.get(), pipelineDesc, pipelineOut);
return mGraphicsPipelineCache.getPipeline(
context, mPipelineCacheVk, *compatibleRenderPass, pipelineLayout, activeAttribLocationsMask,
vertexShader.get(), fragmentShader.get(), pipelineDesc, pipelineOut);
}
angle::Result RendererVk::getDescriptorSetLayout(
......
......@@ -136,7 +136,7 @@ class RendererVk : angle::NonCopyable
const vk::ShaderAndSerial &vertexShader,
const vk::ShaderAndSerial &fragmentShader,
const vk::PipelineLayout &pipelineLayout,
const vk::PipelineDesc &pipelineDesc,
const vk::GraphicsPipelineDesc &pipelineDesc,
const gl::AttributesMask &activeAttribLocationsMask,
vk::PipelineAndSerial **pipelineOut);
......@@ -269,7 +269,7 @@ class RendererVk : angle::NonCopyable
vk::FormatTable mFormatTable;
RenderPassCache mRenderPassCache;
PipelineCache mPipelineCache;
GraphicsPipelineCache mGraphicsPipelineCache;
vk::PipelineCache mPipelineCacheVk;
egl::BlobCache::Key mPipelineCacheVkBlobKey;
......
......@@ -367,7 +367,7 @@ angle::Result VertexArrayVk::syncDirtyAttrib(ContextVk *contextVk,
return angle::Result::Continue();
}
void VertexArrayVk::getPackedInputDescriptions(vk::PipelineDesc *pipelineDesc)
void VertexArrayVk::getPackedInputDescriptions(vk::GraphicsPipelineDesc *pipelineDesc)
{
updatePackedInputDescriptions();
pipelineDesc->updateVertexInputInfo(mPackedInputBindings, mPackedInputAttributes);
......
......@@ -36,7 +36,7 @@ class VertexArrayVk : public VertexArrayImpl
const gl::VertexArray::DirtyAttribBitsArray &attribBits,
const gl::VertexArray::DirtyBindingBitsArray &bindingBits) override;
void getPackedInputDescriptions(vk::PipelineDesc *pipelineDesc);
void getPackedInputDescriptions(vk::GraphicsPipelineDesc *pipelineDesc);
void updateDefaultAttrib(RendererVk *renderer,
size_t attribIndex,
......
......@@ -347,49 +347,49 @@ bool operator==(const RenderPassDesc &lhs, const RenderPassDesc &rhs)
return (memcmp(&lhs, &rhs, sizeof(RenderPassDesc)) == 0);
}
// PipelineDesc implementation.
// GraphicsPipelineDesc implementation.
// Use aligned allocation and free so we can use the alignas keyword.
void *PipelineDesc::operator new(std::size_t size)
void *GraphicsPipelineDesc::operator new(std::size_t size)
{
return angle::AlignedAlloc(size, 32);
}
void PipelineDesc::operator delete(void *ptr)
void GraphicsPipelineDesc::operator delete(void *ptr)
{
return angle::AlignedFree(ptr);
}
PipelineDesc::PipelineDesc()
GraphicsPipelineDesc::GraphicsPipelineDesc()
{
memset(this, 0, sizeof(PipelineDesc));
memset(this, 0, sizeof(GraphicsPipelineDesc));
}
PipelineDesc::~PipelineDesc() = default;
GraphicsPipelineDesc::~GraphicsPipelineDesc() = default;
PipelineDesc::PipelineDesc(const PipelineDesc &other)
GraphicsPipelineDesc::GraphicsPipelineDesc(const GraphicsPipelineDesc &other)
{
memcpy(this, &other, sizeof(PipelineDesc));
memcpy(this, &other, sizeof(GraphicsPipelineDesc));
}
PipelineDesc &PipelineDesc::operator=(const PipelineDesc &other)
GraphicsPipelineDesc &GraphicsPipelineDesc::operator=(const GraphicsPipelineDesc &other)
{
memcpy(this, &other, sizeof(PipelineDesc));
memcpy(this, &other, sizeof(GraphicsPipelineDesc));
return *this;
}
size_t PipelineDesc::hash() const
size_t GraphicsPipelineDesc::hash() const
{
return angle::ComputeGenericHash(*this);
}
bool PipelineDesc::operator==(const PipelineDesc &other) const
bool GraphicsPipelineDesc::operator==(const GraphicsPipelineDesc &other) const
{
return (memcmp(this, &other, sizeof(PipelineDesc)) == 0);
return (memcmp(this, &other, sizeof(GraphicsPipelineDesc)) == 0);
}
// TODO(jmadill): We should prefer using Packed GLenums. http://anglebug.com/2169
void PipelineDesc::initDefaults()
void GraphicsPipelineDesc::initDefaults()
{
mRasterizationAndMultisampleStateInfo.depthClampEnable = 0;
mRasterizationAndMultisampleStateInfo.rasterizationDiscardEnable = 0;
......@@ -468,14 +468,15 @@ void PipelineDesc::initDefaults()
inputAndBlend.primitiveRestartEnable = 0;
}
angle::Result PipelineDesc::initializePipeline(vk::Context *context,
const vk::PipelineCache &pipelineCacheVk,
const RenderPass &compatibleRenderPass,
const PipelineLayout &pipelineLayout,
const gl::AttributesMask &activeAttribLocationsMask,
const ShaderModule &vertexModule,
const ShaderModule &fragmentModule,
Pipeline *pipelineOut) const
angle::Result GraphicsPipelineDesc::initializePipeline(
vk::Context *context,
const vk::PipelineCache &pipelineCacheVk,
const RenderPass &compatibleRenderPass,
const PipelineLayout &pipelineLayout,
const gl::AttributesMask &activeAttribLocationsMask,
const ShaderModule &vertexModule,
const ShaderModule &fragmentModule,
Pipeline *pipelineOut) const
{
VkPipelineShaderStageCreateInfo shaderStages[2] = {};
VkPipelineVertexInputStateCreateInfo vertexInputState = {};
......@@ -671,12 +672,12 @@ angle::Result PipelineDesc::initializePipeline(vk::Context *context,
return angle::Result::Continue();
}
const ShaderStageInfo &PipelineDesc::getShaderStageInfo() const
const ShaderStageInfo &GraphicsPipelineDesc::getShaderStageInfo() const
{
return mShaderStageInfo;
}
void PipelineDesc::updateShaders(Serial vertexSerial, Serial fragmentSerial)
void GraphicsPipelineDesc::updateShaders(Serial vertexSerial, Serial fragmentSerial)
{
ASSERT(vertexSerial < std::numeric_limits<uint32_t>::max());
mShaderStageInfo[ShaderType::VertexShader].moduleSerial =
......@@ -686,42 +687,43 @@ void PipelineDesc::updateShaders(Serial vertexSerial, Serial fragmentSerial)
static_cast<uint32_t>(fragmentSerial.getValue());
}
void PipelineDesc::updateVertexInputInfo(const VertexInputBindings &bindings,
const VertexInputAttributes &attribs)
void GraphicsPipelineDesc::updateVertexInputInfo(const VertexInputBindings &bindings,
const VertexInputAttributes &attribs)
{
mVertexInputBindings = bindings;
mVertexInputAttribs = attribs;
}
void PipelineDesc::updateTopology(gl::PrimitiveMode drawMode)
void GraphicsPipelineDesc::updateTopology(gl::PrimitiveMode drawMode)
{
mInputAssembltyAndColorBlendStateInfo.topology =
static_cast<uint32_t>(gl_vk::GetPrimitiveTopology(drawMode));
}
void PipelineDesc::updateCullMode(const gl::RasterizerState &rasterState)
void GraphicsPipelineDesc::updateCullMode(const gl::RasterizerState &rasterState)
{
mRasterizationAndMultisampleStateInfo.cullMode =
static_cast<uint16_t>(gl_vk::GetCullMode(rasterState));
}
void PipelineDesc::updateFrontFace(const gl::RasterizerState &rasterState, bool invertFrontFace)
void GraphicsPipelineDesc::updateFrontFace(const gl::RasterizerState &rasterState,
bool invertFrontFace)
{
mRasterizationAndMultisampleStateInfo.frontFace =
static_cast<uint16_t>(gl_vk::GetFrontFace(rasterState.frontFace, invertFrontFace));
}
void PipelineDesc::updateLineWidth(float lineWidth)
void GraphicsPipelineDesc::updateLineWidth(float lineWidth)
{
mRasterizationAndMultisampleStateInfo.lineWidth = lineWidth;
}
const RenderPassDesc &PipelineDesc::getRenderPassDesc() const
const RenderPassDesc &GraphicsPipelineDesc::getRenderPassDesc() const
{
return mRenderPassDesc;
}
void PipelineDesc::updateBlendColor(const gl::ColorF &color)
void GraphicsPipelineDesc::updateBlendColor(const gl::ColorF &color)
{
mInputAssembltyAndColorBlendStateInfo.blendConstants[0] = color.red;
mInputAssembltyAndColorBlendStateInfo.blendConstants[1] = color.green;
......@@ -729,7 +731,7 @@ void PipelineDesc::updateBlendColor(const gl::ColorF &color)
mInputAssembltyAndColorBlendStateInfo.blendConstants[3] = color.alpha;
}
void PipelineDesc::updateBlendEnabled(bool isBlendEnabled)
void GraphicsPipelineDesc::updateBlendEnabled(bool isBlendEnabled)
{
gl::DrawBufferMask blendEnabled;
if (isBlendEnabled)
......@@ -738,7 +740,7 @@ void PipelineDesc::updateBlendEnabled(bool isBlendEnabled)
static_cast<uint8_t>(blendEnabled.bits());
}
void PipelineDesc::updateBlendEquations(const gl::BlendState &blendState)
void GraphicsPipelineDesc::updateBlendEquations(const gl::BlendState &blendState)
{
for (PackedColorBlendAttachmentState &blendAttachmentState :
mInputAssembltyAndColorBlendStateInfo.attachments)
......@@ -748,7 +750,7 @@ void PipelineDesc::updateBlendEquations(const gl::BlendState &blendState)
}
}
void PipelineDesc::updateBlendFuncs(const gl::BlendState &blendState)
void GraphicsPipelineDesc::updateBlendFuncs(const gl::BlendState &blendState)
{
for (PackedColorBlendAttachmentState &blendAttachmentState :
mInputAssembltyAndColorBlendStateInfo.attachments)
......@@ -760,8 +762,8 @@ void PipelineDesc::updateBlendFuncs(const gl::BlendState &blendState)
}
}
void PipelineDesc::updateColorWriteMask(VkColorComponentFlags colorComponentFlags,
const gl::DrawBufferMask &alphaMask)
void GraphicsPipelineDesc::updateColorWriteMask(VkColorComponentFlags colorComponentFlags,
const gl::DrawBufferMask &alphaMask)
{
PackedInputAssemblyAndColorBlendStateInfo &inputAndBlend =
mInputAssembltyAndColorBlendStateInfo;
......@@ -774,8 +776,8 @@ void PipelineDesc::updateColorWriteMask(VkColorComponentFlags colorComponentFlag
}
}
void PipelineDesc::updateDepthTestEnabled(const gl::DepthStencilState &depthStencilState,
const gl::Framebuffer *drawFramebuffer)
void GraphicsPipelineDesc::updateDepthTestEnabled(const gl::DepthStencilState &depthStencilState,
const gl::Framebuffer *drawFramebuffer)
{
// Only enable the depth test if the draw framebuffer has a depth buffer. It's possible that
// we're emulating a stencil-only buffer with a depth-stencil buffer
......@@ -783,21 +785,21 @@ void PipelineDesc::updateDepthTestEnabled(const gl::DepthStencilState &depthSten
static_cast<uint8_t>(depthStencilState.depthTest && drawFramebuffer->hasDepth());
}
void PipelineDesc::updateDepthFunc(const gl::DepthStencilState &depthStencilState)
void GraphicsPipelineDesc::updateDepthFunc(const gl::DepthStencilState &depthStencilState)
{
mDepthStencilStateInfo.depthCompareOp = PackGLCompareFunc(depthStencilState.depthFunc);
}
void PipelineDesc::updateDepthWriteEnabled(const gl::DepthStencilState &depthStencilState,
const gl::Framebuffer *drawFramebuffer)
void GraphicsPipelineDesc::updateDepthWriteEnabled(const gl::DepthStencilState &depthStencilState,
const gl::Framebuffer *drawFramebuffer)
{
// Don't write to depth buffers that should not exist
mDepthStencilStateInfo.depthWriteEnable =
static_cast<uint8_t>(drawFramebuffer->hasDepth() ? depthStencilState.depthMask : 0);
}
void PipelineDesc::updateStencilTestEnabled(const gl::DepthStencilState &depthStencilState,
const gl::Framebuffer *drawFramebuffer)
void GraphicsPipelineDesc::updateStencilTestEnabled(const gl::DepthStencilState &depthStencilState,
const gl::Framebuffer *drawFramebuffer)
{
// Only enable the stencil test if the draw framebuffer has a stencil buffer. It's possible
// that we're emulating a depth-only buffer with a depth-stencil buffer
......@@ -805,15 +807,16 @@ void PipelineDesc::updateStencilTestEnabled(const gl::DepthStencilState &depthSt
static_cast<uint8_t>(depthStencilState.stencilTest && drawFramebuffer->hasStencil());
}
void PipelineDesc::updateStencilFrontFuncs(GLint ref,
const gl::DepthStencilState &depthStencilState)
void GraphicsPipelineDesc::updateStencilFrontFuncs(GLint ref,
const gl::DepthStencilState &depthStencilState)
{
mDepthStencilStateInfo.frontStencilReference = static_cast<uint8_t>(ref);
mDepthStencilStateInfo.front.compareOp = PackGLCompareFunc(depthStencilState.stencilFunc);
mDepthStencilStateInfo.front.compareMask = static_cast<uint8_t>(depthStencilState.stencilMask);
}
void PipelineDesc::updateStencilBackFuncs(GLint ref, const gl::DepthStencilState &depthStencilState)
void GraphicsPipelineDesc::updateStencilBackFuncs(GLint ref,
const gl::DepthStencilState &depthStencilState)
{
mDepthStencilStateInfo.backStencilReference = static_cast<uint8_t>(ref);
mDepthStencilStateInfo.back.compareOp = PackGLCompareFunc(depthStencilState.stencilBackFunc);
......@@ -821,7 +824,7 @@ void PipelineDesc::updateStencilBackFuncs(GLint ref, const gl::DepthStencilState
static_cast<uint8_t>(depthStencilState.stencilBackMask);
}
void PipelineDesc::updateStencilFrontOps(const gl::DepthStencilState &depthStencilState)
void GraphicsPipelineDesc::updateStencilFrontOps(const gl::DepthStencilState &depthStencilState)
{
mDepthStencilStateInfo.front.passOp = PackGLStencilOp(depthStencilState.stencilPassDepthPass);
mDepthStencilStateInfo.front.failOp = PackGLStencilOp(depthStencilState.stencilFail);
......@@ -829,7 +832,7 @@ void PipelineDesc::updateStencilFrontOps(const gl::DepthStencilState &depthStenc
PackGLStencilOp(depthStencilState.stencilPassDepthFail);
}
void PipelineDesc::updateStencilBackOps(const gl::DepthStencilState &depthStencilState)
void GraphicsPipelineDesc::updateStencilBackOps(const gl::DepthStencilState &depthStencilState)
{
mDepthStencilStateInfo.back.passOp =
PackGLStencilOp(depthStencilState.stencilBackPassDepthPass);
......@@ -838,34 +841,36 @@ void PipelineDesc::updateStencilBackOps(const gl::DepthStencilState &depthStenci
PackGLStencilOp(depthStencilState.stencilBackPassDepthFail);
}
void PipelineDesc::updateStencilFrontWriteMask(const gl::DepthStencilState &depthStencilState,
const gl::Framebuffer *drawFramebuffer)
void GraphicsPipelineDesc::updateStencilFrontWriteMask(
const gl::DepthStencilState &depthStencilState,
const gl::Framebuffer *drawFramebuffer)
{
// Don't write to stencil buffers that should not exist
mDepthStencilStateInfo.front.writeMask = static_cast<uint8_t>(
drawFramebuffer->hasStencil() ? depthStencilState.stencilWritemask : 0);
}
void PipelineDesc::updateStencilBackWriteMask(const gl::DepthStencilState &depthStencilState,
const gl::Framebuffer *drawFramebuffer)
void GraphicsPipelineDesc::updateStencilBackWriteMask(
const gl::DepthStencilState &depthStencilState,
const gl::Framebuffer *drawFramebuffer)
{
// Don't write to stencil buffers that should not exist
mDepthStencilStateInfo.back.writeMask = static_cast<uint8_t>(
drawFramebuffer->hasStencil() ? depthStencilState.stencilBackWritemask : 0);
}
void PipelineDesc::updatePolygonOffsetFillEnabled(bool enabled)
void GraphicsPipelineDesc::updatePolygonOffsetFillEnabled(bool enabled)
{
mRasterizationAndMultisampleStateInfo.depthBiasEnable = enabled;
}
void PipelineDesc::updatePolygonOffset(const gl::RasterizerState &rasterState)
void GraphicsPipelineDesc::updatePolygonOffset(const gl::RasterizerState &rasterState)
{
mRasterizationAndMultisampleStateInfo.depthBiasSlopeFactor = rasterState.polygonOffsetFactor;
mRasterizationAndMultisampleStateInfo.depthBiasConstantFactor = rasterState.polygonOffsetUnits;
}
void PipelineDesc::updateRenderPassDesc(const RenderPassDesc &renderPassDesc)
void GraphicsPipelineDesc::updateRenderPassDesc(const RenderPassDesc &renderPassDesc)
{
mRenderPassDesc = renderPassDesc;
}
......@@ -1127,15 +1132,15 @@ angle::Result RenderPassCache::getRenderPassWithOps(vk::Context *context,
return angle::Result::Continue();
}
// PipelineCache implementation.
PipelineCache::PipelineCache() = default;
// GraphicsPipelineCache implementation.
GraphicsPipelineCache::GraphicsPipelineCache() = default;
PipelineCache::~PipelineCache()
GraphicsPipelineCache::~GraphicsPipelineCache()
{
ASSERT(mPayload.empty());
}
void PipelineCache::destroy(VkDevice device)
void GraphicsPipelineCache::destroy(VkDevice device)
{
for (auto &item : mPayload)
{
......@@ -1145,15 +1150,16 @@ void PipelineCache::destroy(VkDevice device)
mPayload.clear();
}
angle::Result PipelineCache::getPipeline(vk::Context *context,
const vk::PipelineCache &pipelineCacheVk,
const vk::RenderPass &compatibleRenderPass,
const vk::PipelineLayout &pipelineLayout,
const gl::AttributesMask &activeAttribLocationsMask,
const vk::ShaderModule &vertexModule,
const vk::ShaderModule &fragmentModule,
const vk::PipelineDesc &desc,
vk::PipelineAndSerial **pipelineOut)
angle::Result GraphicsPipelineCache::getPipeline(
vk::Context *context,
const vk::PipelineCache &pipelineCacheVk,
const vk::RenderPass &compatibleRenderPass,
const vk::PipelineLayout &pipelineLayout,
const gl::AttributesMask &activeAttribLocationsMask,
const vk::ShaderModule &vertexModule,
const vk::ShaderModule &fragmentModule,
const vk::GraphicsPipelineDesc &desc,
vk::PipelineAndSerial **pipelineOut)
{
auto item = mPayload.find(desc);
if (item != mPayload.end())
......@@ -1180,7 +1186,7 @@ angle::Result PipelineCache::getPipeline(vk::Context *context,
return angle::Result::Continue();
}
void PipelineCache::populate(const vk::PipelineDesc &desc, vk::Pipeline &&pipeline)
void GraphicsPipelineCache::populate(const vk::GraphicsPipelineDesc &desc, vk::Pipeline &&pipeline)
{
auto item = mPayload.find(desc);
if (item != mPayload.end())
......
......@@ -243,20 +243,20 @@ constexpr size_t kShaderStageInfoSize = sizeof(ShaderStageInfo);
constexpr size_t kVertexInputBindingsSize = sizeof(VertexInputBindings);
constexpr size_t kVertexInputAttributesSize = sizeof(VertexInputAttributes);
class PipelineDesc final
class GraphicsPipelineDesc final
{
public:
// Use aligned allocation and free so we can use the alignas keyword.
void *operator new(std::size_t size);
void operator delete(void *ptr);
PipelineDesc();
~PipelineDesc();
PipelineDesc(const PipelineDesc &other);
PipelineDesc &operator=(const PipelineDesc &other);
GraphicsPipelineDesc();
~GraphicsPipelineDesc();
GraphicsPipelineDesc(const GraphicsPipelineDesc &other);
GraphicsPipelineDesc &operator=(const GraphicsPipelineDesc &other);
size_t hash() const;
bool operator==(const PipelineDesc &other) const;
bool operator==(const GraphicsPipelineDesc &other) const;
void initDefaults();
......@@ -334,13 +334,13 @@ class PipelineDesc final
// This is not guaranteed by the spec, but is validated by a compile-time check.
// No gaps or padding at the end ensures that hashing and memcmp checks will not run
// into uninitialized memory regions.
constexpr size_t kPipelineDescSumOfSizes =
constexpr size_t kGraphicsPipelineDescSumOfSizes =
kShaderStageInfoSize + kVertexInputBindingsSize + kVertexInputAttributesSize +
kPackedInputAssemblyAndColorBlendStateSize + kPackedRasterizationAndMultisampleStateSize +
kPackedDepthStencilStateSize + kRenderPassDescSize;
static constexpr size_t kPipelineDescSize = sizeof(PipelineDesc);
static_assert(kPipelineDescSize == kPipelineDescSumOfSizes, "Size mismatch");
static constexpr size_t kGraphicsPipelineDescSize = sizeof(GraphicsPipelineDesc);
static_assert(kGraphicsPipelineDescSize == kGraphicsPipelineDescSumOfSizes, "Size mismatch");
constexpr uint32_t kMaxDescriptorSetLayoutBindings = gl::IMPLEMENTATION_MAX_ACTIVE_TEXTURES;
......@@ -348,8 +348,8 @@ using DescriptorSetLayoutBindingVector =
angle::FixedVector<VkDescriptorSetLayoutBinding, kMaxDescriptorSetLayoutBindings>;
// A packed description of a descriptor set layout. Use similarly to RenderPassDesc and
// PipelineDesc. Currently we only need to differentiate layouts based on sampler usage. In the
// future we could generalize this.
// GraphicsPipelineDesc. Currently we only need to differentiate layouts based on sampler usage. In
// the future we could generalize this.
class DescriptorSetLayoutDesc final
{
public:
......@@ -454,9 +454,9 @@ struct hash<rx::vk::AttachmentOpsArray>
};
template <>
struct hash<rx::vk::PipelineDesc>
struct hash<rx::vk::GraphicsPipelineDesc>
{
size_t operator()(const rx::vk::PipelineDesc &key) const { return key.hash(); }
size_t operator()(const rx::vk::GraphicsPipelineDesc &key) const { return key.hash(); }
};
template <>
......@@ -503,15 +503,15 @@ class RenderPassCache final : angle::NonCopyable
};
// TODO(jmadill): Add cache trimming/eviction.
class PipelineCache final : angle::NonCopyable
class GraphicsPipelineCache final : angle::NonCopyable
{
public:
PipelineCache();
~PipelineCache();
GraphicsPipelineCache();
~GraphicsPipelineCache();
void destroy(VkDevice device);
void populate(const vk::PipelineDesc &desc, vk::Pipeline &&pipeline);
void populate(const vk::GraphicsPipelineDesc &desc, vk::Pipeline &&pipeline);
angle::Result getPipeline(vk::Context *context,
const vk::PipelineCache &pipelineCacheVk,
const vk::RenderPass &compatibleRenderPass,
......@@ -519,11 +519,11 @@ class PipelineCache final : angle::NonCopyable
const gl::AttributesMask &activeAttribLocationsMask,
const vk::ShaderModule &vertexModule,
const vk::ShaderModule &fragmentModule,
const vk::PipelineDesc &desc,
const vk::GraphicsPipelineDesc &desc,
vk::PipelineAndSerial **pipelineOut);
private:
std::unordered_map<vk::PipelineDesc, vk::PipelineAndSerial> mPayload;
std::unordered_map<vk::GraphicsPipelineDesc, vk::PipelineAndSerial> mPayload;
};
class DescriptorSetLayoutCache final : angle::NonCopyable
......
......@@ -26,15 +26,15 @@ class VulkanPipelineCachePerfTest : public ANGLEPerfTest
void SetUp() override;
void step() override;
PipelineCache mCache;
GraphicsPipelineCache mCache;
angle::RNG mRNG;
std::vector<vk::PipelineDesc> mCacheHits;
std::vector<vk::PipelineDesc> mCacheMisses;
std::vector<vk::GraphicsPipelineDesc> mCacheHits;
std::vector<vk::GraphicsPipelineDesc> mCacheMisses;
size_t mMissIndex = 0;
private:
void randomizeDesc(vk::PipelineDesc *desc);
void randomizeDesc(vk::GraphicsPipelineDesc *desc);
};
VulkanPipelineCachePerfTest::VulkanPipelineCachePerfTest()
......@@ -53,7 +53,7 @@ void VulkanPipelineCachePerfTest::SetUp()
for (int pipelineCount = 0; pipelineCount < 100; ++pipelineCount)
{
vk::Pipeline pipeline;
vk::PipelineDesc desc;
vk::GraphicsPipelineDesc desc;
randomizeDesc(&desc);
if (pipelineCount < 10)
......@@ -65,17 +65,17 @@ void VulkanPipelineCachePerfTest::SetUp()
for (int missCount = 0; missCount < 10000; ++missCount)
{
vk::PipelineDesc desc;
vk::GraphicsPipelineDesc desc;
randomizeDesc(&desc);
mCacheMisses.push_back(desc);
}
}
void VulkanPipelineCachePerfTest::randomizeDesc(vk::PipelineDesc *desc)
void VulkanPipelineCachePerfTest::randomizeDesc(vk::GraphicsPipelineDesc *desc)
{
std::vector<uint8_t> bytes(sizeof(vk::PipelineDesc));
std::vector<uint8_t> bytes(sizeof(vk::GraphicsPipelineDesc));
FillVectorWithRandomUBytes(&mRNG, &bytes);
memcpy(desc, bytes.data(), sizeof(vk::PipelineDesc));
memcpy(desc, bytes.data(), sizeof(vk::GraphicsPipelineDesc));
}
void VulkanPipelineCachePerfTest::step()
......
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