Add support for R16G16B16A16 ushort.

Also implement both new formats in Vulkan.
This commit is contained in:
Stephen White
2018-04-10 10:16:57 -04:00
committed by Corentin Wallez
parent 0b1fbd9322
commit ee66f25c4f
6 changed files with 19 additions and 14 deletions

View File

@@ -35,17 +35,17 @@ namespace backend {
uint32_t VertexFormatNumComponents(nxt::VertexFormat format) {
switch (format) {
case nxt::VertexFormat::FloatR32G32B32A32:
case nxt::VertexFormat::UshortR16G16B16A16:
case nxt::VertexFormat::UnormR8G8B8A8:
return 4;
case nxt::VertexFormat::FloatR32G32B32:
return 3;
case nxt::VertexFormat::FloatR32G32:
case nxt::VertexFormat::UshortR16G16:
case nxt::VertexFormat::UnormR8G8:
return 2;
case nxt::VertexFormat::FloatR32:
return 1;
case nxt::VertexFormat::UshortR16G16:
return 2;
default:
UNREACHABLE();
}
@@ -58,11 +58,12 @@ namespace backend {
case nxt::VertexFormat::FloatR32G32:
case nxt::VertexFormat::FloatR32:
return sizeof(float);
case nxt::VertexFormat::UshortR16G16B16A16:
case nxt::VertexFormat::UshortR16G16:
return sizeof(uint16_t);
case nxt::VertexFormat::UnormR8G8B8A8:
case nxt::VertexFormat::UnormR8G8:
return sizeof(uint8_t);
case nxt::VertexFormat::UshortR16G16:
return sizeof(unsigned short);
default:
UNREACHABLE();
}

View File

@@ -28,6 +28,8 @@ namespace backend { namespace d3d12 {
return DXGI_FORMAT_R32G32_FLOAT;
case nxt::VertexFormat::FloatR32:
return DXGI_FORMAT_R32_FLOAT;
case nxt::VertexFormat::UshortR16G16B16A16:
return DXGI_FORMAT_R16G16B16A16_UINT;
case nxt::VertexFormat::UshortR16G16:
return DXGI_FORMAT_R16G16_UINT;
case nxt::VertexFormat::UnormR8G8B8A8:

View File

@@ -30,6 +30,8 @@ namespace backend { namespace metal {
return MTLVertexFormatFloat2;
case nxt::VertexFormat::FloatR32:
return MTLVertexFormatFloat;
case nxt::VertexFormat::UshortR16G16B16A16:
return MTLVertexFormatUShort4;
case nxt::VertexFormat::UshortR16G16:
return MTLVertexFormatUShort2;
case nxt::VertexFormat::UnormR8G8B8A8:

View File

@@ -49,6 +49,7 @@ namespace backend { namespace opengl {
case nxt::VertexFormat::FloatR32G32:
case nxt::VertexFormat::FloatR32:
return GL_FLOAT;
case nxt::VertexFormat::UshortR16G16B16A16:
case nxt::VertexFormat::UshortR16G16:
return GL_UNSIGNED_SHORT;
case nxt::VertexFormat::UnormR8G8B8A8:
@@ -61,17 +62,11 @@ namespace backend { namespace opengl {
GLboolean VertexFormatIsNormalized(nxt::VertexFormat format) {
switch (format) {
case nxt::VertexFormat::FloatR32G32B32A32:
case nxt::VertexFormat::FloatR32G32B32:
case nxt::VertexFormat::FloatR32G32:
case nxt::VertexFormat::FloatR32:
case nxt::VertexFormat::UshortR16G16:
return GL_FALSE;
case nxt::VertexFormat::UnormR8G8B8A8:
case nxt::VertexFormat::UnormR8G8:
return GL_TRUE;
default:
UNREACHABLE();
return GL_FALSE;
}
}

View File

@@ -41,6 +41,10 @@ namespace backend { namespace vulkan {
return VK_FORMAT_R32G32_SFLOAT;
case nxt::VertexFormat::FloatR32:
return VK_FORMAT_R32_SFLOAT;
case nxt::VertexFormat::UshortR16G16B16A16:
return VK_FORMAT_R16G16B16A16_UINT;
case nxt::VertexFormat::UshortR16G16:
return VK_FORMAT_R16G16_UINT;
case nxt::VertexFormat::UnormR8G8B8A8:
return VK_FORMAT_R8G8B8A8_UNORM;
case nxt::VertexFormat::UnormR8G8: