Commit 9917988a by James Dong Committed by Commit Bot

Vulkan: change packed attrib to ANGLE format ID

This prevents later issues with some VkFormat values being over 256, as well as providing more information to pipeline creation. A preliminary step towards handling mismatched vertex attributes. Bug: angleproject:3634 Change-Id: Idb15a14088a2d73b43b4b92d3cfdb12587c5f711 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1696212Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 53aff41e
......@@ -1631,11 +1631,27 @@ angle::FormatID GetVertexFormatID(const VertexAttribute &attrib, VertexAttribTyp
{
if (!attrib.enabled)
{
return angle::FormatID::R32G32B32A32_FLOAT;
return GetCurrentValueFormatID(currentValueType);
}
return attrib.format->id;
}
angle::FormatID GetCurrentValueFormatID(VertexAttribType currentValueType)
{
switch (currentValueType)
{
case VertexAttribType::Float:
return angle::FormatID::R32G32B32A32_FLOAT;
case VertexAttribType::Int:
return angle::FormatID::R32G32B32A32_SINT;
case VertexAttribType::UnsignedInt:
return angle::FormatID::R32G32B32A32_UINT;
default:
UNREACHABLE();
return angle::FormatID::NONE;
}
}
const VertexFormat &GetVertexFormatFromID(angle::FormatID vertexFormatID)
{
switch (vertexFormatID)
......
......@@ -253,6 +253,7 @@ angle::FormatID GetVertexFormatID(VertexAttribType type,
bool pureInteger);
angle::FormatID GetVertexFormatID(const VertexAttribute &attrib, VertexAttribType currentValueType);
angle::FormatID GetCurrentValueFormatID(VertexAttribType currentValueType);
const VertexFormat &GetVertexFormatFromID(angle::FormatID vertexFormatID);
size_t GetVertexFormatSize(angle::FormatID vertexFormatID);
......
......@@ -185,7 +185,7 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff
ANGLE_INLINE void onVertexAttributeChange(size_t attribIndex,
GLuint stride,
GLuint divisor,
VkFormat format,
angle::FormatID format,
GLuint relativeOffset)
{
invalidateVertexAndIndexBuffers();
......
......@@ -407,24 +407,9 @@ ANGLE_INLINE void VertexArrayVk::setDefaultPackedInput(ContextVk *contextVk, siz
const gl::VertexAttribCurrentValueData &defaultValue =
glState.getVertexAttribCurrentValues()[attribIndex];
switch (defaultValue.Type)
{
case gl::VertexAttribType::Float:
contextVk->onVertexAttributeChange(attribIndex, 0, 0, VK_FORMAT_R32G32B32A32_SFLOAT, 0);
break;
case gl::VertexAttribType::Int:
contextVk->onVertexAttributeChange(attribIndex, 0, 0, VK_FORMAT_R32G32B32A32_SINT, 0);
break;
angle::FormatID format = GetCurrentValueFormatID(defaultValue.Type);
case gl::VertexAttribType::UnsignedInt:
contextVk->onVertexAttributeChange(attribIndex, 0, 0, VK_FORMAT_R32G32B32A32_UINT, 0);
break;
default:
UNREACHABLE();
break;
}
contextVk->onVertexAttributeChange(attribIndex, 0, 0, format, 0);
}
angle::Result VertexArrayVk::syncDirtyAttrib(ContextVk *contextVk,
......@@ -504,7 +489,7 @@ angle::Result VertexArrayVk::syncDirtyAttrib(ContextVk *contextVk,
}
contextVk->onVertexAttributeChange(attribIndex, stride, binding.getDivisor(),
vertexFormat.vkBufferFormat, attrib.relativeOffset);
attrib.format->id, attrib.relativeOffset);
}
else
{
......
......@@ -648,9 +648,13 @@ angle::Result GraphicsPipelineDesc::initializePipeline(
bindingDesc.inputRate = static_cast<VkVertexInputRate>(VK_VERTEX_INPUT_RATE_VERTEX);
}
// Get the corresponding VkFormat for the attrib's format.
angle::FormatID angleFormat = static_cast<angle::FormatID>(packedAttrib.format);
VkFormat vkFormat = context->getRenderer()->getFormat(angleFormat).vkBufferFormat;
// The binding index could become more dynamic in ES 3.1.
attribDesc.binding = attribIndex;
attribDesc.format = static_cast<VkFormat>(packedAttrib.format);
attribDesc.format = vkFormat;
attribDesc.location = static_cast<uint32_t>(attribIndex);
attribDesc.offset = packedAttrib.offset;
......@@ -804,7 +808,7 @@ void GraphicsPipelineDesc::updateVertexInput(GraphicsPipelineTransitionBits *tra
uint32_t attribIndex,
GLuint stride,
GLuint divisor,
VkFormat format,
angle::FormatID format,
GLuint relativeOffset)
{
vk::PackedAttribDesc &packedAttrib = mVertexInputAttribs.attribs[attribIndex];
......@@ -816,7 +820,7 @@ void GraphicsPipelineDesc::updateVertexInput(GraphicsPipelineTransitionBits *tra
SetBitField(packedAttrib.stride, stride);
SetBitField(packedAttrib.divisor, divisor);
if (format == VK_FORMAT_UNDEFINED)
if (format == angle::FormatID::NONE)
{
UNIMPLEMENTED();
}
......
......@@ -370,7 +370,7 @@ class GraphicsPipelineDesc final
uint32_t attribIndex,
GLuint stride,
GLuint divisor,
VkFormat format,
angle::FormatID format,
GLuint relativeOffset);
// Input assembly info
......
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