Add nxt::VertexFormat::FloatR32

This commit is contained in:
Corentin Wallez 2017-07-03 14:01:30 -04:00 committed by Corentin Wallez
parent 4cd65f03b7
commit 8859178703
5 changed files with 12 additions and 1 deletions

View File

@ -945,7 +945,8 @@
"values": [ "values": [
{"value": 0, "name": "float r32 g32 b32 a32"}, {"value": 0, "name": "float r32 g32 b32 a32"},
{"value": 1, "name": "float r32 g32 b32"}, {"value": 1, "name": "float r32 g32 b32"},
{"value": 2, "name": "float r32 g32"} {"value": 2, "name": "float r32 g32"},
{"value": 3, "name": "float r32"}
] ]
}, },
"void": { "void": {

View File

@ -37,6 +37,8 @@ namespace backend {
return 3; return 3;
case nxt::VertexFormat::FloatR32G32: case nxt::VertexFormat::FloatR32G32:
return 2; return 2;
case nxt::VertexFormat::FloatR32:
return 1;
} }
} }
@ -45,6 +47,7 @@ namespace backend {
case nxt::VertexFormat::FloatR32G32B32A32: case nxt::VertexFormat::FloatR32G32B32A32:
case nxt::VertexFormat::FloatR32G32B32: case nxt::VertexFormat::FloatR32G32B32:
case nxt::VertexFormat::FloatR32G32: case nxt::VertexFormat::FloatR32G32:
case nxt::VertexFormat::FloatR32:
return VertexFormatNumComponents(format) * sizeof(float); return VertexFormatNumComponents(format) * sizeof(float);
} }
} }

View File

@ -25,6 +25,8 @@ namespace d3d12 {
return DXGI_FORMAT_R32G32B32_FLOAT; return DXGI_FORMAT_R32G32B32_FLOAT;
case nxt::VertexFormat::FloatR32G32: case nxt::VertexFormat::FloatR32G32:
return DXGI_FORMAT_R32G32_FLOAT; return DXGI_FORMAT_R32G32_FLOAT;
case nxt::VertexFormat::FloatR32:
return DXGI_FORMAT_R32_FLOAT;
} }
} }

View File

@ -28,6 +28,8 @@ namespace metal {
return MTLVertexFormatFloat3; return MTLVertexFormatFloat3;
case nxt::VertexFormat::FloatR32G32: case nxt::VertexFormat::FloatR32G32:
return MTLVertexFormatFloat2; return MTLVertexFormatFloat2;
case nxt::VertexFormat::FloatR32:
return MTLVertexFormatFloat;
} }
} }
@ -71,6 +73,8 @@ namespace metal {
if (info.stride == 0) { if (info.stride == 0) {
// For MTLVertexStepFunctionConstant, the stepRate must be 0, // For MTLVertexStepFunctionConstant, the stepRate must be 0,
// but the stride must NOT be 0, so I made up a value (256). // but the stride must NOT be 0, so I made up a value (256).
// TODO(cwallez@chromium.org): the made up value will need to be at least
// max(attrib.offset + sizeof(attrib) for each attrib)
layoutDesc.stepFunction = MTLVertexStepFunctionConstant; layoutDesc.stepFunction = MTLVertexStepFunctionConstant;
layoutDesc.stepRate = 0; layoutDesc.stepRate = 0;
layoutDesc.stride = 256; layoutDesc.stride = 256;

View File

@ -49,6 +49,7 @@ namespace opengl {
case nxt::VertexFormat::FloatR32G32B32A32: case nxt::VertexFormat::FloatR32G32B32A32:
case nxt::VertexFormat::FloatR32G32B32: case nxt::VertexFormat::FloatR32G32B32:
case nxt::VertexFormat::FloatR32G32: case nxt::VertexFormat::FloatR32G32:
case nxt::VertexFormat::FloatR32:
return GL_FLOAT; return GL_FLOAT;
} }
} }