Commit 2ad498eb by Frank Henigman Committed by Commit Bot

Vulkan: get vertex formats from format table.

Use the Vulkan format table to look up the Vulkan format for vertex data. This will let us support more vertex formats by adding them to the table. It also eliminates one usage of gl::VertexFormatType. No functional change. BUG=angleproject:2405 BUG=angleproject:2531 Change-Id: I73eb69ccac50d427de3e7d5479f92bb17c49aed3 Reviewed-on: https://chromium-review.googlesource.com/1051028Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarLuc Ferron <lucferron@chromium.org> Commit-Queue: Frank Henigman <fjhenigman@chromium.org>
parent 9c4c0926
......@@ -120,7 +120,7 @@ gl::Error ContextVk::initPipeline()
mPipelineDesc->updateTopology(mCurrentDrawMode);
// Copy over the latest attrib and binding descriptions.
vertexArrayVk->getPackedInputDescriptions(mPipelineDesc.get());
vertexArrayVk->getPackedInputDescriptions(mRenderer, mPipelineDesc.get());
// Ensure that the RenderPass description is updated.
mPipelineDesc->updateRenderPassDesc(framebufferVk->getRenderPassDesc());
......
......@@ -98,6 +98,8 @@ class RendererVk : angle::NonCopyable
return mFormatTable[internalFormat];
}
const vk::Format &getFormat(angle::Format::ID formatID) const { return mFormatTable[formatID]; }
vk::Error getCompatibleRenderPass(const vk::RenderPassDesc &desc,
vk::RenderPass **renderPassOut);
vk::Error getRenderPassWithOps(const vk::RenderPassDesc &desc,
......
......@@ -299,13 +299,14 @@ void VertexArrayVk::updateElementArrayBufferReadDependency(
}
}
void VertexArrayVk::getPackedInputDescriptions(vk::PipelineDesc *pipelineDesc)
void VertexArrayVk::getPackedInputDescriptions(const RendererVk *rendererVk,
vk::PipelineDesc *pipelineDesc)
{
updatePackedInputDescriptions();
updatePackedInputDescriptions(rendererVk);
pipelineDesc->updateVertexInputInfo(mPackedInputBindings, mPackedInputAttributes);
}
void VertexArrayVk::updatePackedInputDescriptions()
void VertexArrayVk::updatePackedInputDescriptions(const RendererVk *rendererVk)
{
if (!mDirtyPackedInputs.any())
{
......@@ -321,7 +322,7 @@ void VertexArrayVk::updatePackedInputDescriptions()
const auto &binding = bindings[attrib.bindingIndex];
if (attrib.enabled)
{
updatePackedInputInfo(static_cast<uint32_t>(attribIndex), binding, attrib);
updatePackedInputInfo(rendererVk, static_cast<uint32_t>(attribIndex), binding, attrib);
}
else
{
......@@ -332,7 +333,8 @@ void VertexArrayVk::updatePackedInputDescriptions()
mDirtyPackedInputs.reset();
}
void VertexArrayVk::updatePackedInputInfo(uint32_t attribIndex,
void VertexArrayVk::updatePackedInputInfo(const RendererVk *rendererVk,
uint32_t attribIndex,
const gl::VertexBinding &binding,
const gl::VertexAttribute &attrib)
{
......@@ -345,8 +347,7 @@ void VertexArrayVk::updatePackedInputInfo(uint32_t attribIndex,
bindingDesc.inputRate = static_cast<uint16_t>(
binding.getDivisor() > 0 ? VK_VERTEX_INPUT_RATE_INSTANCE : VK_VERTEX_INPUT_RATE_VERTEX);
gl::VertexFormatType vertexFormatType = gl::GetVertexFormatType(attrib);
VkFormat vkFormat = vk::GetNativeVertexFormat(vertexFormatType);
VkFormat vkFormat = rendererVk->getFormat(GetVertexFormatID(attrib)).vkBufferFormat;
ASSERT(vkFormat <= std::numeric_limits<uint16_t>::max());
vk::PackedVertexInputAttributeDesc &attribDesc = mPackedInputAttributes[attribIndex];
......
......@@ -51,7 +51,7 @@ class VertexArrayVk : public VertexArrayImpl
Serial serial,
bool isDrawElements);
void getPackedInputDescriptions(vk::PipelineDesc *pipelineDesc);
void getPackedInputDescriptions(const RendererVk *rendererVk, vk::PipelineDesc *pipelineDesc);
// Draw call handling.
gl::Error drawArrays(const gl::Context *context,
......@@ -71,8 +71,9 @@ class VertexArrayVk : public VertexArrayImpl
// update vertex info for attributes the program doesn't use, (very silly edge case). The
// advantage is the cached state then doesn't depend on the Program, so doesn't have to be
// updated when the active Program changes.
void updatePackedInputDescriptions();
void updatePackedInputInfo(uint32_t attribIndex,
void updatePackedInputDescriptions(const RendererVk *rendererVk);
void updatePackedInputInfo(const RendererVk *rendererVk,
uint32_t attribIndex,
const gl::VertexBinding &binding,
const gl::VertexAttribute &attrib);
......
......@@ -70,15 +70,13 @@ class FormatTable final : angle::NonCopyable
std::vector<GLenum> *outCompressedTextureFormats);
const Format &operator[](GLenum internalFormat) const;
const Format &operator[](angle::Format::ID formatID) const;
private:
// The table data is indexed by angle::Format::ID.
std::array<Format, angle::kNumANGLEFormats> mFormatData;
};
// TODO(jmadill): This is temporary. Figure out how to handle format conversions.
VkFormat GetNativeVertexFormat(gl::VertexFormatType vertexFormat);
// This will return a reference to a VkFormatProperties with the feature flags supported
// if the format is a mandatory format described in section 31.3.3. Required Format Support
// of the Vulkan spec. If the vkFormat isn't mandatory, it will return a VkFormatProperties
......
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