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