Enable IndexFormatTests on Vulkan

This adds translation of the index format in the Vulkan backend. A test
is also added for an issue currently present in the Vulkan backend.
This commit is contained in:
Corentin Wallez
2018-02-06 19:21:16 -05:00
committed by Corentin Wallez
parent cf0ac7570d
commit abcf982e09
2 changed files with 55 additions and 4 deletions

View File

@@ -28,6 +28,17 @@ namespace backend { namespace vulkan {
namespace {
VkIndexType VulkanIndexType(nxt::IndexFormat format) {
switch (format) {
case nxt::IndexFormat::Uint16:
return VK_INDEX_TYPE_UINT16;
case nxt::IndexFormat::Uint32:
return VK_INDEX_TYPE_UINT32;
default:
UNREACHABLE();
}
}
VkBufferImageCopy ComputeBufferImageCopyRegion(uint32_t rowPitch,
const BufferCopyLocation& bufferLocation,
const TextureCopyLocation& textureLocation) {
@@ -255,9 +266,10 @@ namespace backend { namespace vulkan {
// TODO(cwallez@chromium.org): get the index type from the last render pipeline
// and rebind if needed on pipeline change
device->fn.CmdBindIndexBuffer(commands, indexBuffer,
static_cast<VkDeviceSize>(cmd->offset),
VK_INDEX_TYPE_UINT16);
ASSERT(lastRenderPipeline != nullptr);
VkIndexType indexType = VulkanIndexType(lastRenderPipeline->GetIndexFormat());
device->fn.CmdBindIndexBuffer(
commands, indexBuffer, static_cast<VkDeviceSize>(cmd->offset), indexType);
} break;
case Command::SetRenderPipeline: {