Commit f8b28678 by Xiaoxuan Liu Committed by Commit Bot

Vulkan: Add support for VK_EXT_index_type_uint8

Enable VK_EXT_index_type_uint8 Vulkan extension if supported by VkDevice. Bug: angleproject:4405 Change-Id: I84d030497898c5944a36d9a88a31e7377ccd5e9e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2082391 Commit-Queue: Xiaoxuan Liu <xiaoxuan.liu@arm.com> Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent c3655c3a
......@@ -153,6 +153,12 @@ struct FeaturesVk : FeatureSetBase
"Transform feedback uses the VK_EXT_transform_feedback extension.", &members,
"http://anglebug.com/3206"};
// Whether the VkDevice supports the VK_EXT_index_type_uint8 extension
// http://anglebug.com/4405
Feature supportsIndexTypeUint8 = {"supports_index_type_uint8", FeatureCategory::VulkanFeatures,
"VkDevice supports the VK_EXT_index_type_uint8 extension",
&members, "http://anglebug.com/4405"};
// VK_PRESENT_MODE_FIFO_KHR causes random timeouts on Linux Intel. http://anglebug.com/3153
Feature disableFifoPresentMode = {
"disable_fifo_present_mode", FeatureCategory::VulkanWorkarounds,
......
......@@ -90,9 +90,11 @@
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertIndex.comp.00000003.inc":
"0d3eb0f82f328837ef4c0fe5f978ef3f",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertIndexIndirectLineLoop.comp.00000000.inc":
"76d8265a6ccec813fb7f7ad1b503947e",
"bb07b6941cee943efaf627da12fab504",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertIndexIndirectLineLoop.comp.00000001.inc":
"a1964fd9d0b75701a384a11ac23242fb",
"48de7900fe4d96446a61abcb1b86f0ca",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertIndexIndirectLineLoop.comp.00000002.inc":
"53475dec809dddaf902dd12253acba19",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertIndirectLineLoop.comp.00000000.inc":
"523d3207d424614197ace9601ce56950",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.00000000.inc":
......@@ -240,7 +242,7 @@
"src/libANGLE/renderer/vulkan/shaders/src/ConvertIndex.comp":
"a46b48d7d5b19c74eb377f275525ab8d",
"src/libANGLE/renderer/vulkan/shaders/src/ConvertIndexIndirectLineLoop.comp":
"63418a915d0a63a26c17fea3091cd42d",
"ee94f2dab39583c17cb5739199229427",
"src/libANGLE/renderer/vulkan/shaders/src/ConvertIndirectLineLoop.comp":
"c4fe0f463b41cd59bae33f9711e0b67b",
"src/libANGLE/renderer/vulkan/shaders/src/ConvertVertex.comp":
......@@ -256,9 +258,9 @@
"src/libANGLE/renderer/vulkan/shaders/src/OverlayDraw.comp":
"dcc246b398b2e07a869a264666499362",
"src/libANGLE/renderer/vulkan/vk_internal_shaders_autogen.cpp":
"7e0bc36d24abb773260a7bbd47b9d1d0",
"7a38442f63d6fb7b931390d3776cc964",
"src/libANGLE/renderer/vulkan/vk_internal_shaders_autogen.h":
"350020dbc136ae8cc67455694ed13f31",
"3eea961399cc31bedac5128770d5175d",
"tools/glslang/glslang_validator.exe.sha1":
"289f30598865a987a21b79ae525fc66f",
"tools/glslang/glslang_validator.sha1":
......
......@@ -761,6 +761,9 @@ angle::Result ContextVk::initialize()
vk::kDefaultTimestampQueryPoolSize));
}
// Init gles to vulkan index type map
initIndexTypeMap();
// Init driver uniforms and get the descriptor set layouts.
constexpr angle::PackedEnumMap<PipelineType, VkShaderStageFlags> kPipelineStages = {
{PipelineType::Graphics, VK_SHADER_STAGE_ALL_GRAPHICS},
......@@ -954,9 +957,7 @@ angle::Result ContextVk::setupIndexedDraw(const gl::Context *context,
mLastIndexBufferOffset = indices;
mVertexArray->updateCurrentElementArrayBufferOffset(mLastIndexBufferOffset);
}
if (indexType == gl::DrawElementsType::UnsignedByte &&
mGraphicsDirtyBits[DIRTY_BIT_INDEX_BUFFER])
if (shouldConvertUint8VkIndexType(indexType) && mGraphicsDirtyBits[DIRTY_BIT_INDEX_BUFFER])
{
BufferVk *bufferVk = vk::GetImpl(elementArrayBuffer);
vk::BufferHelper &bufferHelper = bufferVk->getBuffer();
......@@ -1298,7 +1299,7 @@ angle::Result ContextVk::handleDirtyGraphicsIndexBuffer(const gl::Context *conte
commandBuffer->bindIndexBuffer(elementArrayBuffer->getBuffer(),
mVertexArray->getCurrentElementArrayBufferOffset(),
gl_vk::kIndexTypeMap[mCurrentDrawElementsType]);
getVkIndexType(mCurrentDrawElementsType));
mRenderPassCommands.bufferRead(&mResourceUseList, VK_ACCESS_INDEX_READ_BIT, elementArrayBuffer);
......@@ -2122,7 +2123,7 @@ angle::Result ContextVk::drawElementsIndirect(const gl::Context *context,
return angle::Result::Continue;
}
if (type == gl::DrawElementsType::UnsignedByte && mGraphicsDirtyBits[DIRTY_BIT_INDEX_BUFFER])
if (shouldConvertUint8VkIndexType(type) && mGraphicsDirtyBits[DIRTY_BIT_INDEX_BUFFER])
{
vk::BufferHelper *dstIndirectBuf;
VkDeviceSize dstIndirectBufOffset;
......@@ -4055,6 +4056,38 @@ void ContextVk::dumpCommandStreamDiagnostics()
out << "}\n";
}
void ContextVk::initIndexTypeMap()
{
// Init gles-vulkan index type map
mIndexTypeMap[gl::DrawElementsType::UnsignedByte] =
mRenderer->getFeatures().supportsIndexTypeUint8.enabled ? VK_INDEX_TYPE_UINT8_EXT
: VK_INDEX_TYPE_UINT16;
mIndexTypeMap[gl::DrawElementsType::UnsignedShort] = VK_INDEX_TYPE_UINT16;
mIndexTypeMap[gl::DrawElementsType::UnsignedInt] = VK_INDEX_TYPE_UINT32;
}
VkIndexType ContextVk::getVkIndexType(gl::DrawElementsType glIndexType) const
{
return mIndexTypeMap[glIndexType];
}
size_t ContextVk::getVkIndexTypeSize(gl::DrawElementsType glIndexType) const
{
gl::DrawElementsType elementsType = shouldConvertUint8VkIndexType(glIndexType)
? gl::DrawElementsType::UnsignedShort
: glIndexType;
ASSERT(elementsType < gl::DrawElementsType::EnumCount);
// Use GetDrawElementsTypeSize() to get the size
return static_cast<size_t>(gl::GetDrawElementsTypeSize(elementsType));
}
bool ContextVk::shouldConvertUint8VkIndexType(gl::DrawElementsType glIndexType) const
{
return (glIndexType == gl::DrawElementsType::UnsignedByte &&
!mRenderer->getFeatures().supportsIndexTypeUint8.enabled);
}
CommandBufferHelper::CommandBufferHelper()
: mImageBarrierSrcStageMask(0),
mImageBarrierDstStageMask(0),
......
......@@ -650,6 +650,10 @@ class ContextVk : public ContextImpl, public vk::Context
void addCommandBufferDiagnostics(const std::string &commandBufferDiagnostics);
VkIndexType getVkIndexType(gl::DrawElementsType glIndexType) const;
size_t getVkIndexTypeSize(gl::DrawElementsType glIndexType) const;
bool shouldConvertUint8VkIndexType(gl::DrawElementsType glIndexType) const;
private:
// Dirty bits.
enum DirtyBitType : size_t
......@@ -905,6 +909,8 @@ class ContextVk : public ContextImpl, public vk::Context
ANGLE_INLINE void onRenderPassFinished() { mRenderPassCommandBuffer = nullptr; }
void initIndexTypeMap();
std::array<DirtyBitHandler, DIRTY_BIT_MAX> mGraphicsDirtyBitHandlers;
std::array<DirtyBitHandler, DIRTY_BIT_MAX> mComputeDirtyBitHandlers;
......@@ -951,6 +957,7 @@ class ContextVk : public ContextImpl, public vk::Context
// The offset we had the last time we bound the index buffer.
const GLvoid *mLastIndexBufferOffset;
gl::DrawElementsType mCurrentDrawElementsType;
angle::PackedEnumMap<gl::DrawElementsType, VkIndexType> mIndexTypeMap;
// Cache the current draw call's firstVertex to be passed to
// TransformFeedbackVk::getBufferOffsets. Unfortunately, gl_BaseVertex support in Vulkan is
......
......@@ -962,6 +962,9 @@ void RendererVk::queryDeviceExtensionFeatures(const ExtensionNameList &deviceExt
mTransformFeedbackFeatures.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT;
mIndexTypeUint8Features = {};
mIndexTypeUint8Features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INDEX_TYPE_UINT8_FEATURES_EXT;
mPhysicalDeviceSubgroupProperties = {};
mPhysicalDeviceSubgroupProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES;
......@@ -1006,6 +1009,12 @@ void RendererVk::queryDeviceExtensionFeatures(const ExtensionNameList &deviceExt
vk::AddToPNextChain(&deviceFeatures, &mTransformFeedbackFeatures);
}
// Query uint8 index type features
if (ExtensionFound(VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME, deviceExtensionNames))
{
vk::AddToPNextChain(&deviceFeatures, &mIndexTypeUint8Features);
}
// Query external memory host properties
if (ExtensionFound(VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME, deviceExtensionNames))
{
......@@ -1024,6 +1033,7 @@ void RendererVk::queryDeviceExtensionFeatures(const ExtensionNameList &deviceExt
mVertexAttributeDivisorFeatures.pNext = nullptr;
mVertexAttributeDivisorProperties.pNext = nullptr;
mTransformFeedbackFeatures.pNext = nullptr;
mIndexTypeUint8Features.pNext = nullptr;
mPhysicalDeviceSubgroupProperties.pNext = nullptr;
mPhysicalDeviceExternalMemoryHostProperties.pNext = nullptr;
}
......@@ -1259,6 +1269,12 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF
vk::AddToPNextChain(&createInfo, &mTransformFeedbackFeatures);
}
if (getFeatures().supportsIndexTypeUint8.enabled)
{
enabledDeviceExtensions.push_back(VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME);
vk::AddToPNextChain(&createInfo, &mIndexTypeUint8Features);
}
if (getFeatures().supportsExternalMemoryHost.enabled)
{
enabledDeviceExtensions.push_back(VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME);
......@@ -1612,6 +1628,9 @@ void RendererVk::initFeatures(DisplayVk *displayVk, const ExtensionNameList &dev
ANGLE_FEATURE_CONDITION((&mFeatures), supportsTransformFeedbackExtension,
mTransformFeedbackFeatures.transformFeedback == VK_TRUE);
ANGLE_FEATURE_CONDITION((&mFeatures), supportsIndexTypeUint8,
mIndexTypeUint8Features.indexTypeUint8 == VK_TRUE);
ANGLE_FEATURE_CONDITION((&mFeatures), emulateTransformFeedback,
(mFeatures.supportsTransformFeedbackExtension.enabled == VK_FALSE &&
mPhysicalDeviceFeatures.vertexPipelineStoresAndAtomics == VK_TRUE));
......
......@@ -287,6 +287,7 @@ class RendererVk : angle::NonCopyable
VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT mVertexAttributeDivisorFeatures;
VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT mVertexAttributeDivisorProperties;
VkPhysicalDeviceTransformFeedbackFeaturesEXT mTransformFeedbackFeatures;
VkPhysicalDeviceIndexTypeUint8FeaturesEXT mIndexTypeUint8Features;
VkPhysicalDeviceSubgroupProperties mPhysicalDeviceSubgroupProperties;
VkPhysicalDeviceExternalMemoryHostPropertiesEXT mPhysicalDeviceExternalMemoryHostProperties;
std::vector<VkQueueFamilyProperties> mQueueFamilyProperties;
......
......@@ -17,14 +17,15 @@
namespace rx
{
namespace BufferUtils_comp = vk::InternalShader::BufferUtils_comp;
namespace ConvertVertex_comp = vk::InternalShader::ConvertVertex_comp;
namespace ImageClear_frag = vk::InternalShader::ImageClear_frag;
namespace ImageCopy_frag = vk::InternalShader::ImageCopy_frag;
namespace BlitResolve_frag = vk::InternalShader::BlitResolve_frag;
namespace BlitResolveStencilNoExport_comp = vk::InternalShader::BlitResolveStencilNoExport_comp;
namespace OverlayCull_comp = vk::InternalShader::OverlayCull_comp;
namespace OverlayDraw_comp = vk::InternalShader::OverlayDraw_comp;
namespace BufferUtils_comp = vk::InternalShader::BufferUtils_comp;
namespace ConvertVertex_comp = vk::InternalShader::ConvertVertex_comp;
namespace ImageClear_frag = vk::InternalShader::ImageClear_frag;
namespace ImageCopy_frag = vk::InternalShader::ImageCopy_frag;
namespace BlitResolve_frag = vk::InternalShader::BlitResolve_frag;
namespace BlitResolveStencilNoExport_comp = vk::InternalShader::BlitResolveStencilNoExport_comp;
namespace OverlayCull_comp = vk::InternalShader::OverlayCull_comp;
namespace OverlayDraw_comp = vk::InternalShader::OverlayDraw_comp;
namespace ConvertIndexIndirectLineLoop_comp = vk::InternalShader::ConvertIndexIndirectLineLoop_comp;
namespace
{
......@@ -297,6 +298,22 @@ uint32_t GetBlitResolveFlags(bool blitColor,
}
}
uint32_t GetConvertIndexIndirectLineLoopFlag(uint32_t indicesBitsWidth)
{
switch (indicesBitsWidth)
{
case 8:
return ConvertIndexIndirectLineLoop_comp::kIs8Bits;
case 16:
return ConvertIndexIndirectLineLoop_comp::kIs16Bits;
case 32:
return ConvertIndexIndirectLineLoop_comp::kIs32Bits;
default:
UNREACHABLE();
return 0;
}
}
uint32_t GetFormatDefaultChannelMask(const vk::Format &format)
{
uint32_t mask = 0;
......@@ -990,11 +1007,7 @@ angle::Result UtilsVk::convertLineLoopIndexIndirectBuffer(
params.indirectBufferOffset >> 2, params.dstIndirectBufferOffset >> 2,
params.dstIndexBufferOffset >> 2, contextVk->getState().isPrimitiveRestartEnabled()};
uint32_t flags = 0;
if (params.is32Bit)
{
flags |= vk::InternalShader::ConvertIndexIndirectLineLoop_comp::kIs32Bit;
}
uint32_t flags = GetConvertIndexIndirectLineLoopFlag(params.indicesBitsWidth);
vk::RefCounted<vk::ShaderAndSerial> *shader = nullptr;
ANGLE_TRY(contextVk->getShaderLibrary().getConvertIndexIndirectLineLoop_comp(contextVk, flags,
......
......@@ -67,7 +67,7 @@ class UtilsVk : angle::NonCopyable
uint32_t indirectBufferOffset = 0;
uint32_t dstIndirectBufferOffset = 0;
uint32_t dstIndexBufferOffset = 0;
uint32_t is32Bit = 0;
uint32_t indicesBitsWidth = 0;
};
struct ConvertLineLoopArrayIndirectParameters
......
......@@ -296,21 +296,14 @@ angle::Result VertexArrayVk::convertIndexBufferCPU(ContextVk *contextVk,
mDynamicIndexData.releaseInFlightBuffers(contextVk);
size_t elementSize = gl::GetDrawElementsTypeSize(indexType);
if (indexType == gl::DrawElementsType::UnsignedByte)
{
// 8-bit indices are not supported by Vulkan, so they are promoted to
// 16-bit indices below
elementSize = sizeof(GLushort);
}
size_t elementSize = contextVk->getVkIndexTypeSize(indexType);
const size_t amount = elementSize * indexCount;
GLubyte *dst = nullptr;
ANGLE_TRY(mDynamicIndexData.allocate(contextVk, amount, &dst, nullptr,
&mCurrentElementArrayBufferOffset, nullptr));
mCurrentElementArrayBuffer = mDynamicIndexData.getCurrentBuffer();
if (indexType == gl::DrawElementsType::UnsignedByte)
if (contextVk->shouldConvertUint8VkIndexType(indexType))
{
// Unsigned bytes don't have direct support in Vulkan so we have to expand the
// memory to a GLushort.
......
......@@ -8,12 +8,29 @@
//
// The following defines tweak the functionality, and a different shader is built based on these.
//
// - Flags:
// * Is32Bit: Process 32-bit indices, otherwise process 16-bit.
// - IndicesBitsWidth:
// * Is8Bits: Process 8-bit indices.
// * Is16Bits: Process 16-bit indices.
// * Is32Bits: Process 32-bit indices.
//
#version 450 core
#if Is32Bits
#define BITSMASK 0xffffffff
#elif Is16Bits
#define BITSMASK 0xffff
#define IDXSHIFT 1 // 16bits index division shift
#define SRCSHIFT(index) ((index & 0x1) << 4) // 16bits data shift value in 32bits index
#elif Is8Bits
#define BITSMASK 0xff
#define IDXSHIFT 2 // 8bits index division shift
#define SRCSHIFT(index) ((index & 0x3) << 3) // 8bits data shift value in 32bits index
#else
// Early error out
#error "Not all bits are accounted for"
#endif
layout (local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
layout (set = 0, binding = 0) buffer dst
......@@ -64,43 +81,42 @@ layout (push_constant) uniform PushConstants
uint GetIndexValue(uint index)
{
#ifdef Is32Bit
#if Is32Bits
return srcData[index];
#else
#elif Is16Bits || Is8Bits
// srcData points to 32bit words, get the word with our index value
uint srcBlock = srcData[index >> 1];
uint srcBlock = srcData[index >> IDXSHIFT];
// Compute the shift necessary to access desired index value
uint srcShift = (index & 0x1) << 4;
// Only want 16bits
uint srcMask = 0xffff;
// unpacking correct 16bit index value from the 32bit word
uint value = (srcBlock >> srcShift) & srcMask;
uint srcShift = SRCSHIFT(index);
// unpacking correct 8/16 bits index value from the 32bit word
uint value = (srcBlock >> srcShift) & BITSMASK;
return value;
#endif
#else
#error "Not all bits are accounted for"
#endif // Is32Bits
}
void PutIndexValue(uint index, uint value)
{
#ifdef Is32Bit
#if Is32Bits
dstData[dstOffsetDiv4 + index] = value;
return;
#else
#elif Is16Bits || Is8Bits
// Compute index into dstData for our index value
uint dstIndex = dstOffsetDiv4 + (index >> 1);
uint dstIndex = dstOffsetDiv4 + (index >> IDXSHIFT);
// Get dest index value
uint srcBlock = dstData[dstIndex];
// Compute the shift for our index value
uint srcShift = (index & 0x1) << 4;
uint srcMask = 0xffff;
uint srcShift = SRCSHIFT(index);
// Clear appropriate 16bits of 32bit word
srcBlock &= ~(srcMask << srcShift);
// Shift value to pack 16bit value into 32bit word
// Clear appropriate bits of 32bit word
srcBlock &= ~(BITSMASK << srcShift);
// Shift value to pack 8/16 bits value into 32bit word
srcBlock |= value << srcShift;
// Store updated value in destination
dstData[dstIndex] = srcBlock;
#endif
#else
#error "Not all bits are accounted for"
#endif // Is32Bits
}
void main()
......@@ -122,12 +138,7 @@ void main()
while (indicesRemaining > 0)
{
uint indexValue;
#ifdef Is32Bit
uint restartValue = 0xffffffff;
#else
uint restartValue = 0xffff;
#endif
uint restartValue = BITSMASK;
indexValue = GetIndexValue(srcIdx++);
if (lineSize == 0)
{
......
{
"Description": [
"Copyright 2019 The ANGLE Project Authors. All rights reserved.",
"Copyright 2020 The ANGLE Project Authors. All rights reserved.",
"Use of this source code is governed by a BSD-style license that can be",
"found in the LICENSE file.",
"",
"ConvertIndexIndirectLineLoop.comp.json: Build parameters for ConvertIndexIndirectLineLoop.comp."
],
"Flags": [
"Is32Bit"
"IndicesBitsWidth": [
"Is8Bits",
"Is16Bits",
"Is32Bits"
]
}
......@@ -264,7 +264,8 @@ VkImageCreateFlags GetImageCreateFlags(gl::TextureType textureType)
}
}
void HandlePrimitiveRestart(gl::DrawElementsType glIndexType,
void HandlePrimitiveRestart(ContextVk *contextVk,
gl::DrawElementsType glIndexType,
GLsizei indexCount,
const uint8_t *srcPtr,
uint8_t *outPtr)
......@@ -272,7 +273,14 @@ void HandlePrimitiveRestart(gl::DrawElementsType glIndexType,
switch (glIndexType)
{
case gl::DrawElementsType::UnsignedByte:
CopyLineLoopIndicesWithRestart<uint8_t, uint16_t>(indexCount, srcPtr, outPtr);
if (contextVk->getFeatures().supportsIndexTypeUint8.enabled)
{
CopyLineLoopIndicesWithRestart<uint8_t, uint8_t>(indexCount, srcPtr, outPtr);
}
else
{
CopyLineLoopIndicesWithRestart<uint8_t, uint16_t>(indexCount, srcPtr, outPtr);
}
break;
case gl::DrawElementsType::UnsignedShort:
CopyLineLoopIndicesWithRestart<uint16_t, uint16_t>(indexCount, srcPtr, outPtr);
......@@ -1254,11 +1262,8 @@ angle::Result LineLoopHelper::getIndexBufferForElementArrayBuffer(ContextVk *con
*indexCountOut = indexCount + 1;
VkIndexType indexType = gl_vk::kIndexTypeMap[glIndexType];
ASSERT(indexType == VK_INDEX_TYPE_UINT16 || indexType == VK_INDEX_TYPE_UINT32);
uint32_t *indices = nullptr;
auto unitSize = (indexType == VK_INDEX_TYPE_UINT16 ? sizeof(uint16_t) : sizeof(uint32_t));
uint32_t *indices = nullptr;
size_t unitSize = contextVk->getVkIndexTypeSize(glIndexType);
size_t allocateBytes = unitSize * (indexCount + 1) + 1;
mDynamicIndexBuffer.releaseInFlightBuffers(contextVk);
......@@ -1290,11 +1295,10 @@ angle::Result LineLoopHelper::streamIndices(ContextVk *contextVk,
VkDeviceSize *bufferOffsetOut,
uint32_t *indexCountOut)
{
VkIndexType indexType = gl_vk::kIndexTypeMap[glIndexType];
size_t unitSize = contextVk->getVkIndexTypeSize(glIndexType);
uint8_t *indices = nullptr;
auto unitSize = (indexType == VK_INDEX_TYPE_UINT16 ? sizeof(uint16_t) : sizeof(uint32_t));
uint32_t numOutIndices = indexCount + 1;
if (contextVk->getState().isPrimitiveRestartEnabled())
{
......@@ -1309,13 +1313,14 @@ angle::Result LineLoopHelper::streamIndices(ContextVk *contextVk,
if (contextVk->getState().isPrimitiveRestartEnabled())
{
HandlePrimitiveRestart(glIndexType, indexCount, srcPtr, indices);
HandlePrimitiveRestart(contextVk, glIndexType, indexCount, srcPtr, indices);
}
else
{
if (glIndexType == gl::DrawElementsType::UnsignedByte)
if (contextVk->shouldConvertUint8VkIndexType(glIndexType))
{
// Vulkan doesn't support uint8 index types, so we need to emulate it.
// If vulkan doesn't support uint8 index types, we need to emulate it.
VkIndexType indexType = contextVk->getVkIndexType(glIndexType);
ASSERT(indexType == VK_INDEX_TYPE_UINT16);
uint16_t *indicesDst = reinterpret_cast<uint16_t *>(indices);
for (int i = 0; i < indexCount; i++)
......@@ -1346,9 +1351,7 @@ angle::Result LineLoopHelper::streamIndicesIndirect(ContextVk *contextVk,
BufferHelper **indirectBufferOut,
VkDeviceSize *indirectBufferOffsetOut)
{
VkIndexType indexType = gl_vk::kIndexTypeMap[glIndexType];
auto unitSize = (indexType == VK_INDEX_TYPE_UINT16 ? sizeof(uint16_t) : sizeof(uint32_t));
size_t unitSize = contextVk->getVkIndexTypeSize(glIndexType);
size_t allocateBytes = static_cast<size_t>(indexBuffer->getSize() + unitSize);
if (contextVk->getState().isPrimitiveRestartEnabled())
......@@ -1385,7 +1388,7 @@ angle::Result LineLoopHelper::streamIndicesIndirect(ContextVk *contextVk,
params.indirectBufferOffset = static_cast<uint32_t>(indirectBufferOffset);
params.dstIndirectBufferOffset = static_cast<uint32_t>(*indirectBufferOffsetOut);
params.dstIndexBufferOffset = static_cast<uint32_t>(*indexBufferOffsetOut);
params.is32Bit = unitSize == 4;
params.indicesBitsWidth = static_cast<uint32_t>(unitSize * 8);
ANGLE_TRY(contextVk->getUtils().convertLineLoopIndexIndirectBuffer(
contextVk, indirectBuffer, destIndirectBuffer, destIndexBuffer, indexBuffer, params));
......
// GENERATED FILE - DO NOT EDIT.
// Generated by gen_vk_internal_shaders.py using data from shaders/src/*
//
// Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
......@@ -62,6 +62,7 @@ namespace
#include "libANGLE/renderer/vulkan/shaders/gen/ConvertIndex.comp.00000003.inc"
#include "libANGLE/renderer/vulkan/shaders/gen/ConvertIndexIndirectLineLoop.comp.00000000.inc"
#include "libANGLE/renderer/vulkan/shaders/gen/ConvertIndexIndirectLineLoop.comp.00000001.inc"
#include "libANGLE/renderer/vulkan/shaders/gen/ConvertIndexIndirectLineLoop.comp.00000002.inc"
#include "libANGLE/renderer/vulkan/shaders/gen/ConvertIndirectLineLoop.comp.00000000.inc"
#include "libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.00000000.inc"
#include "libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.00000001.inc"
......@@ -196,6 +197,8 @@ constexpr ShaderBlob kConvertIndexIndirectLineLoop_comp_shaders[] = {
sizeof(kConvertIndexIndirectLineLoop_comp_00000000)},
{kConvertIndexIndirectLineLoop_comp_00000001,
sizeof(kConvertIndexIndirectLineLoop_comp_00000001)},
{kConvertIndexIndirectLineLoop_comp_00000002,
sizeof(kConvertIndexIndirectLineLoop_comp_00000002)},
};
constexpr ShaderBlob kConvertIndirectLineLoop_comp_shaders[] = {
{kConvertIndirectLineLoop_comp_00000000, sizeof(kConvertIndirectLineLoop_comp_00000000)},
......
# GENERATED FILE - DO NOT EDIT.
# Generated by gen_vk_internal_shaders.py using data from shaders/src/*
#
# Copyright 2019 The ANGLE Project Authors. All rights reserved.
# Copyright 2020 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
......@@ -55,6 +55,7 @@ angle_vulkan_internal_shaders = [
"shaders/gen/ConvertIndex.comp.00000003.inc",
"shaders/gen/ConvertIndexIndirectLineLoop.comp.00000000.inc",
"shaders/gen/ConvertIndexIndirectLineLoop.comp.00000001.inc",
"shaders/gen/ConvertIndexIndirectLineLoop.comp.00000002.inc",
"shaders/gen/ConvertIndirectLineLoop.comp.00000000.inc",
"shaders/gen/ConvertVertex.comp.00000000.inc",
"shaders/gen/ConvertVertex.comp.00000001.inc",
......
// GENERATED FILE - DO NOT EDIT.
// Generated by gen_vk_internal_shaders.py using data from shaders/src/*
//
// Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
......@@ -80,11 +80,13 @@ constexpr size_t kArrayLen = 0x00000004;
namespace ConvertIndexIndirectLineLoop_comp
{
enum flags
enum IndicesBitsWidth
{
kIs32Bit = 0x00000001,
kIs8Bits = 0x00000000,
kIs16Bits = 0x00000001,
kIs32Bits = 0x00000002,
};
constexpr size_t kArrayLen = 0x00000002;
constexpr size_t kArrayLen = 0x00000003;
} // namespace ConvertIndexIndirectLineLoop_comp
namespace ConvertIndirectLineLoop_comp
......
......@@ -640,12 +640,6 @@ VkSampleCountFlagBits GetSamples(GLint sampleCount);
VkComponentSwizzle GetSwizzle(const GLenum swizzle);
VkCompareOp GetCompareOp(const GLenum compareFunc);
constexpr angle::PackedEnumMap<gl::DrawElementsType, VkIndexType> kIndexTypeMap = {
{gl::DrawElementsType::UnsignedByte, VK_INDEX_TYPE_UINT16},
{gl::DrawElementsType::UnsignedShort, VK_INDEX_TYPE_UINT16},
{gl::DrawElementsType::UnsignedInt, VK_INDEX_TYPE_UINT32},
};
constexpr gl::ShaderMap<VkShaderStageFlagBits> kShaderStageMap = {
{gl::ShaderType::Vertex, VK_SHADER_STAGE_VERTEX_BIT},
{gl::ShaderType::Fragment, VK_SHADER_STAGE_FRAGMENT_BIT},
......
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