Implement support for all Int32 vertex formats. (#179)

This commit is contained in:
Stephen White 2018-04-10 14:35:17 -04:00 committed by Corentin Wallez
parent e5ae3274a3
commit 10a659ad91
6 changed files with 50 additions and 8 deletions

View File

@ -1239,14 +1239,18 @@
"vertex format": {
"category": "enum",
"values": [
{"value": 0, "name": "float r32 g32 b32 a32"},
{"value": 1, "name": "float r32 g32 b32"},
{"value": 2, "name": "float r32 g32"},
{"value": 3, "name": "float r32"},
{"value": 4, "name": "ushort r16 g16 b16 a16"},
{"value": 5, "name": "ushort r16 g16"},
{"value": 6, "name": "unorm r8 g8 b8 a8"},
{"value": 7, "name": "unorm r8 g8"}
{"value": 0, "name": "float r32 g32 b32 a32"},
{"value": 1, "name": "float r32 g32 b32"},
{"value": 2, "name": "float r32 g32"},
{"value": 3, "name": "float r32"},
{"value": 4, "name": "int r32 g32 b32 a32"},
{"value": 5, "name": "int r32 g32 b32"},
{"value": 6, "name": "int r32 g32"},
{"value": 7, "name": "int r32"},
{"value": 8, "name": "ushort r16 g16 b16 a16"},
{"value": 9, "name": "ushort r16 g16"},
{"value": 10, "name": "unorm r8 g8 b8 a8"},
{"value": 11, "name": "unorm r8 g8"}
]
},
"void": {

View File

@ -35,16 +35,20 @@ namespace backend {
uint32_t VertexFormatNumComponents(nxt::VertexFormat format) {
switch (format) {
case nxt::VertexFormat::FloatR32G32B32A32:
case nxt::VertexFormat::IntR32G32B32A32:
case nxt::VertexFormat::UshortR16G16B16A16:
case nxt::VertexFormat::UnormR8G8B8A8:
return 4;
case nxt::VertexFormat::FloatR32G32B32:
case nxt::VertexFormat::IntR32G32B32:
return 3;
case nxt::VertexFormat::FloatR32G32:
case nxt::VertexFormat::IntR32G32:
case nxt::VertexFormat::UshortR16G16:
case nxt::VertexFormat::UnormR8G8:
return 2;
case nxt::VertexFormat::FloatR32:
case nxt::VertexFormat::IntR32:
return 1;
default:
UNREACHABLE();
@ -58,6 +62,11 @@ namespace backend {
case nxt::VertexFormat::FloatR32G32:
case nxt::VertexFormat::FloatR32:
return sizeof(float);
case nxt::VertexFormat::IntR32G32B32A32:
case nxt::VertexFormat::IntR32G32B32:
case nxt::VertexFormat::IntR32G32:
case nxt::VertexFormat::IntR32:
return sizeof(int32_t);
case nxt::VertexFormat::UshortR16G16B16A16:
case nxt::VertexFormat::UshortR16G16:
return sizeof(uint16_t);

View File

@ -28,6 +28,14 @@ namespace backend { namespace d3d12 {
return DXGI_FORMAT_R32G32_FLOAT;
case nxt::VertexFormat::FloatR32:
return DXGI_FORMAT_R32_FLOAT;
case nxt::VertexFormat::IntR32G32B32A32:
return DXGI_FORMAT_R32G32B32A32_SINT;
case nxt::VertexFormat::IntR32G32B32:
return DXGI_FORMAT_R32G32B32_SINT;
case nxt::VertexFormat::IntR32G32:
return DXGI_FORMAT_R32G32_SINT;
case nxt::VertexFormat::IntR32:
return DXGI_FORMAT_R32_SINT;
case nxt::VertexFormat::UshortR16G16B16A16:
return DXGI_FORMAT_R16G16B16A16_UINT;
case nxt::VertexFormat::UshortR16G16:

View File

@ -30,6 +30,14 @@ namespace backend { namespace metal {
return MTLVertexFormatFloat2;
case nxt::VertexFormat::FloatR32:
return MTLVertexFormatFloat;
case nxt::VertexFormat::IntR32G32B32A32:
return MTLVertexFormatInt4;
case nxt::VertexFormat::IntR32G32B32:
return MTLVertexFormatInt3;
case nxt::VertexFormat::IntR32G32:
return MTLVertexFormatInt2;
case nxt::VertexFormat::IntR32:
return MTLVertexFormatInt;
case nxt::VertexFormat::UshortR16G16B16A16:
return MTLVertexFormatUShort4;
case nxt::VertexFormat::UshortR16G16:

View File

@ -49,6 +49,11 @@ namespace backend { namespace opengl {
case nxt::VertexFormat::FloatR32G32:
case nxt::VertexFormat::FloatR32:
return GL_FLOAT;
case nxt::VertexFormat::IntR32G32B32A32:
case nxt::VertexFormat::IntR32G32B32:
case nxt::VertexFormat::IntR32G32:
case nxt::VertexFormat::IntR32:
return GL_INT;
case nxt::VertexFormat::UshortR16G16B16A16:
case nxt::VertexFormat::UshortR16G16:
return GL_UNSIGNED_SHORT;

View File

@ -41,6 +41,14 @@ namespace backend { namespace vulkan {
return VK_FORMAT_R32G32_SFLOAT;
case nxt::VertexFormat::FloatR32:
return VK_FORMAT_R32_SFLOAT;
case nxt::VertexFormat::IntR32G32B32A32:
return VK_FORMAT_R32G32B32A32_SINT;
case nxt::VertexFormat::IntR32G32B32:
return VK_FORMAT_R32G32B32_SINT;
case nxt::VertexFormat::IntR32G32:
return VK_FORMAT_R32G32_SINT;
case nxt::VertexFormat::IntR32:
return VK_FORMAT_R32_SINT;
case nxt::VertexFormat::UshortR16G16B16A16:
return VK_FORMAT_R16G16B16A16_UINT;
case nxt::VertexFormat::UshortR16G16: