Add support for ushort2 vertex format.

Also fix some vertex format computations.
This commit is contained in:
Stephen White 2018-02-28 20:42:36 -05:00 committed by Corentin Wallez
parent ceec97978e
commit 0b1fbd9322
5 changed files with 13 additions and 1 deletions

View File

@ -1244,7 +1244,8 @@
{"value": 2, "name": "float r32 g32"}, {"value": 2, "name": "float r32 g32"},
{"value": 3, "name": "float r32"}, {"value": 3, "name": "float r32"},
{"value": 4, "name": "unorm r8 g8 b8 a8"}, {"value": 4, "name": "unorm r8 g8 b8 a8"},
{"value": 5, "name": "unorm r8 g8"} {"value": 5, "name": "unorm r8 g8"},
{"value": 6, "name": "ushort r16 g16"}
] ]
}, },
"void": { "void": {

View File

@ -44,6 +44,8 @@ namespace backend {
return 2; return 2;
case nxt::VertexFormat::FloatR32: case nxt::VertexFormat::FloatR32:
return 1; return 1;
case nxt::VertexFormat::UshortR16G16:
return 2;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
@ -59,6 +61,8 @@ namespace backend {
case nxt::VertexFormat::UnormR8G8B8A8: case nxt::VertexFormat::UnormR8G8B8A8:
case nxt::VertexFormat::UnormR8G8: case nxt::VertexFormat::UnormR8G8:
return sizeof(uint8_t); return sizeof(uint8_t);
case nxt::VertexFormat::UshortR16G16:
return sizeof(unsigned short);
default: default:
UNREACHABLE(); UNREACHABLE();
} }

View File

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

View File

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

View File

@ -49,6 +49,8 @@ namespace backend { namespace opengl {
case nxt::VertexFormat::FloatR32G32: case nxt::VertexFormat::FloatR32G32:
case nxt::VertexFormat::FloatR32: case nxt::VertexFormat::FloatR32:
return GL_FLOAT; return GL_FLOAT;
case nxt::VertexFormat::UshortR16G16:
return GL_UNSIGNED_SHORT;
case nxt::VertexFormat::UnormR8G8B8A8: case nxt::VertexFormat::UnormR8G8B8A8:
case nxt::VertexFormat::UnormR8G8: case nxt::VertexFormat::UnormR8G8:
return GL_UNSIGNED_BYTE; return GL_UNSIGNED_BYTE;
@ -63,6 +65,7 @@ namespace backend { namespace opengl {
case nxt::VertexFormat::FloatR32G32B32: case nxt::VertexFormat::FloatR32G32B32:
case nxt::VertexFormat::FloatR32G32: case nxt::VertexFormat::FloatR32G32:
case nxt::VertexFormat::FloatR32: case nxt::VertexFormat::FloatR32:
case nxt::VertexFormat::UshortR16G16:
return GL_FALSE; return GL_FALSE;
case nxt::VertexFormat::UnormR8G8B8A8: case nxt::VertexFormat::UnormR8G8B8A8:
case nxt::VertexFormat::UnormR8G8: case nxt::VertexFormat::UnormR8G8: