rename functions in VertexDeclaration

This commit is contained in:
Adam Jensen 2023-07-18 22:08:40 +01:00
parent 9e03ab108d
commit 0c883cb3f7
4 changed files with 9 additions and 9 deletions

View File

@ -9,7 +9,7 @@
namespace cdc {
DXGI_FORMAT decodeFormat(uint16_t format);
DXGI_FORMAT MakeElementFormat(uint16_t format);
PCDX11StreamDecl *PCDX11StreamDeclCache::buildStreamDecl(
VertexDecl *layout,
@ -22,7 +22,7 @@ PCDX11StreamDecl *PCDX11StreamDeclCache::buildStreamDecl(
if (it.second) {
D3D11_INPUT_ELEMENT_DESC *inputElementDesc = new D3D11_INPUT_ELEMENT_DESC[layout->numAttr];
memset(inputElementDesc, 0, sizeof(D3D11_INPUT_ELEMENT_DESC) * layout->numAttr);
decodeVertexAttribA(inputElementDesc, layout->attrib, layout->numAttr, shaderSub->wineWorkaround);
MakeD3DVertexElements(inputElementDesc, layout->attrib, layout->numAttr, shaderSub->wineWorkaround);
streamDecl = new PCDX11StreamDecl(renderDevice, inputElementDesc, layout->numAttr, shaderSub);
// HACK
@ -95,7 +95,7 @@ PCDX11StreamDecl *PCDX11StreamDeclCache::buildStreamDecl(
inputElementDesc[numElements].InputSlot = 0;
inputElementDesc[numElements].AlignedByteOffset = layoutA->attrib[indexA].offset;
inputElementDesc[numElements].Format = decodeFormat(layoutA->attrib[indexA].format);
inputElementDesc[numElements].Format = MakeElementFormat(layoutA->attrib[indexA].format);
if (attribB->attribKindB >= 10 && attribB->attribKindB < 14) {
if (layoutA->attrib[indexA].format < 19 ||

View File

@ -14,7 +14,7 @@ uint16_t getLayoutAIndexFromHash(
return 0xffff;
}
DXGI_FORMAT decodeFormat(uint16_t format) {
DXGI_FORMAT MakeElementFormat(uint16_t format) {
switch (format) {
case 0: return DXGI_FORMAT_R32_FLOAT; // 41
case 1: return DXGI_FORMAT_R32G32_FLOAT; // 16
@ -50,18 +50,18 @@ DXGI_FORMAT decodeFormat(uint16_t format) {
}
// very confusingly, the mesh will sometimes have two inputs called
// Texcoord1 and Texcoord2, which when decoded using decodeVertexAttribA
// Texcoord1 and Texcoord2, which when decoded using MakeD3DVertexElements
// will turn into the same semantics in d3d.
// But when using semanticFromEnum they will be mapped to Texcoord0 and
// Texcoord1, which is what the pixel shader expects.
void decodeVertexAttribA(D3D11_INPUT_ELEMENT_DESC *dst, VertexAttributeA *src, uint32_t count, bool wineWorkaround) {
void MakeD3DVertexElements(D3D11_INPUT_ELEMENT_DESC *dst, VertexAttributeA *src, uint32_t count, bool wineWorkaround) {
uint32_t customSlots = 0;
for (uint32_t i=0; i<count; i++) {
dst[i].SemanticName = "";
dst[i].InputSlot = 0;
dst[i].AlignedByteOffset = (uint32_t)(int32_t)(int16_t)src[i].offset; // 0xffff -> 0xffffffff
dst[i].Format = decodeFormat(src[i].format);
dst[i].Format = MakeElementFormat(src[i].format);
auto& elem = dst[i];
auto kind = src[i].attribKind;
if (kind == VertexAttributeA::kPosition) {

View File

@ -82,7 +82,7 @@ uint16_t getLayoutAIndexFromHash(
VertexDecl *layoutA,
uint32_t hash);
void decodeVertexAttribA(
void MakeD3DVertexElements(
D3D11_INPUT_ELEMENT_DESC *dst,
VertexAttributeA *src,
uint32_t count,

View File

@ -1439,7 +1439,7 @@ int spinnyCube(HWND window,
ImGui::TableSetColumnIndex(0);
if (auto *vertexDecl = uiact.selectedVertexDecl) {
D3D11_INPUT_ELEMENT_DESC elems[vertexDecl->numAttr];
decodeVertexAttribA(elems, vertexDecl->attrib, vertexDecl->numAttr, false);
MakeD3DVertexElements(elems, vertexDecl->attrib, vertexDecl->numAttr, false);
for (uint32_t i = 0; i < vertexDecl->numAttr; i++)
ImGui::Text("%08x %s %d",
vertexDecl->attrib[i].attribKind,