diff --git a/src/igl/VertexInputState.cpp b/src/igl/VertexInputState.cpp index 06ecca9b19..69f5222c09 100644 --- a/src/igl/VertexInputState.cpp +++ b/src/igl/VertexInputState.cpp @@ -72,6 +72,7 @@ size_t VertexInputStateDesc::sizeForVertexAttributeFormat(VertexAttributeFormat return sizeof(int16_t[4]); case VertexAttributeFormat::UShort1: + case VertexAttributeFormat::UShort1Norm: return sizeof(uint16_t); case VertexAttributeFormat::UShort2: @@ -79,6 +80,7 @@ size_t VertexInputStateDesc::sizeForVertexAttributeFormat(VertexAttributeFormat return sizeof(uint16_t[2]); case VertexAttributeFormat::UShort3: + case VertexAttributeFormat::UShort3Norm: return sizeof(uint16_t[3]); case VertexAttributeFormat::UShort4: diff --git a/src/igl/VertexInputState.h b/src/igl/VertexInputState.h index 6316629a54..5119ab490a 100644 --- a/src/igl/VertexInputState.h +++ b/src/igl/VertexInputState.h @@ -58,7 +58,9 @@ enum class VertexAttributeFormat { Short3Norm, Short4Norm, + UShort1Norm, UShort2Norm, + UShort3Norm, UShort4Norm, Int1, diff --git a/src/igl/metal/VertexInputState.mm b/src/igl/metal/VertexInputState.mm index fb04035acb..1eaa638b7f 100644 --- a/src/igl/metal/VertexInputState.mm +++ b/src/igl/metal/VertexInputState.mm @@ -76,8 +76,12 @@ case VertexAttributeFormat::Short4Norm: return MTLVertexFormatShort4Normalized; + case VertexAttributeFormat::UShort1Norm: + return MTLVertexFormatUShortNormalized; case VertexAttributeFormat::UShort2Norm: return MTLVertexFormatUShort2Normalized; + case VertexAttributeFormat::UShort3Norm: + return MTLVertexFormatUShort3Normalized; case VertexAttributeFormat::UShort4Norm: return MTLVertexFormatUShort4Normalized; diff --git a/src/igl/opengl/VertexInputState.cpp b/src/igl/opengl/VertexInputState.cpp index b691b57429..35dc4713b6 100644 --- a/src/igl/opengl/VertexInputState.cpp +++ b/src/igl/opengl/VertexInputState.cpp @@ -217,12 +217,24 @@ static void toOGLAttribute(const VertexAttribute& attrib, normalized = GL_TRUE; break; + case VertexAttributeFormat::UShort1Norm: + numComponents = 1; + componentType = GL_UNSIGNED_SHORT; + normalized = GL_TRUE; + break; + case VertexAttributeFormat::UShort2Norm: numComponents = 2; componentType = GL_UNSIGNED_SHORT; normalized = GL_TRUE; break; + case VertexAttributeFormat::UShort3Norm: + numComponents = 3; + componentType = GL_UNSIGNED_SHORT; + normalized = GL_TRUE; + break; + case VertexAttributeFormat::UShort4Norm: numComponents = 4; componentType = GL_UNSIGNED_SHORT; diff --git a/src/igl/tests/VertexInputState.cpp b/src/igl/tests/VertexInputState.cpp index e8f3ca3982..b9e12779cb 100644 --- a/src/igl/tests/VertexInputState.cpp +++ b/src/igl/tests/VertexInputState.cpp @@ -86,8 +86,12 @@ TEST_F(VertexInputStateTest, VertexAttributeSizes) { VertexInputStateDesc::sizeForVertexAttributeFormat(VertexAttributeFormat::Short3Norm)); ASSERT_EQ(8, VertexInputStateDesc::sizeForVertexAttributeFormat(VertexAttributeFormat::Short4Norm)); + ASSERT_EQ(2, + VertexInputStateDesc::sizeForVertexAttributeFormat(VertexAttributeFormat::UShort1Norm)); ASSERT_EQ(4, VertexInputStateDesc::sizeForVertexAttributeFormat(VertexAttributeFormat::UShort2Norm)); + ASSERT_EQ(6, + VertexInputStateDesc::sizeForVertexAttributeFormat(VertexAttributeFormat::UShort3Norm)); ASSERT_EQ(8, VertexInputStateDesc::sizeForVertexAttributeFormat(VertexAttributeFormat::UShort4Norm)); ASSERT_EQ(2, diff --git a/src/igl/tests/metal/VertexInputState.mm b/src/igl/tests/metal/VertexInputState.mm index 60a8a2117e..a209c13c12 100644 --- a/src/igl/tests/metal/VertexInputState.mm +++ b/src/igl/tests/metal/VertexInputState.mm @@ -366,9 +366,15 @@ void TearDown() override {} ASSERT_EQ(igl::metal::VertexInputState::convertAttributeFormat(VertexAttributeFormat::Short4Norm), MTLVertexFormatShort4Normalized); + ASSERT_EQ( + igl::metal::VertexInputState::convertAttributeFormat(VertexAttributeFormat::UShort1Norm), + MTLVertexFormatUShortNormalized); ASSERT_EQ( igl::metal::VertexInputState::convertAttributeFormat(VertexAttributeFormat::UShort2Norm), MTLVertexFormatUShort2Normalized); + ASSERT_EQ( + igl::metal::VertexInputState::convertAttributeFormat(VertexAttributeFormat::UShort3Norm), + MTLVertexFormatUShort3Normalized); ASSERT_EQ( igl::metal::VertexInputState::convertAttributeFormat(VertexAttributeFormat::UShort4Norm), MTLVertexFormatUShort4Normalized); diff --git a/src/igl/vulkan/RenderPipelineState.cpp b/src/igl/vulkan/RenderPipelineState.cpp index bda8ab7cf7..5fb0d6bbd1 100644 --- a/src/igl/vulkan/RenderPipelineState.cpp +++ b/src/igl/vulkan/RenderPipelineState.cpp @@ -119,8 +119,12 @@ VkFormat vertexAttributeFormatToVkFormat(igl::VertexAttributeFormat fmt) { return VK_FORMAT_R16G16B16_SNORM; case VertexAttributeFormat::Short4Norm: return VK_FORMAT_R16G16B16A16_SNORM; + case VertexAttributeFormat::UShort1Norm: + return VK_FORMAT_R16_UNORM; case VertexAttributeFormat::UShort2Norm: return VK_FORMAT_R16G16_UNORM; + case VertexAttributeFormat::UShort3Norm: + return VK_FORMAT_R16G16B16_UNORM; case VertexAttributeFormat::UShort4Norm: return VK_FORMAT_R16G16B16A16_UNORM; // Integer formats