Skip to content

Name every vertex input TEXCOORD<location>, as SDL's D3D12 backend does - #35

Merged
ivan-ushakov merged 1 commit into
crossplatformfrom
fix/d3d12-vertex-input-semantics
Aug 6, 2026
Merged

Name every vertex input TEXCOORD<location>, as SDL's D3D12 backend does#35
ivan-ushakov merged 1 commit into
crossplatformfrom
fix/d3d12-vertex-input-semantics

Conversation

@ivan-ushakov

Copy link
Copy Markdown
Collaborator

No description provided.

No pipeline could be created on Windows. Every SDL_CreateGPUGraphicsPipeline
call failed with a bare E_INVALIDARG (0x80070057); the D3D12 debug layer had
the real reason:

  CreateInputLayout: The provided input signature expects to read an element
  with SemanticName/Index: 'POSITION'/0, but the declaration doesn't provide
  a matching name. [CREATEINPUTLAYOUT_MISSINGELEMENT]

SDL_GPUVertexAttribute has no semantic field -- SPIR-V and MSL bind vertex
inputs by location, so there is nothing for it to carry. D3D12 does need one,
and its backend invents it: every D3D12_INPUT_ELEMENT_DESC gets SemanticName
"TEXCOORD" and SemanticIndex = the attribute's location. A shader declaring
POSITION, COLOR0, NORMAL or BLENDINDICES names elements the layout will never
provide, and CreateInputLayout refuses it.

Windows is the only platform this reaches, because it is the only one that
compiles our HLSL as HLSL -- dxc straight to DXIL, semantics intact. Linux and
macOS launder them through SPIR-V, where the names are dropped and the
locations are all that survive.

So the semantics now spell out the location instead of the D3D9 usage. Where
an #if drops an attribute from the middle of a layout (object3dx, rigid lods
carry no blend weights) the ones after it renumber with it, matching how
SDLObject3dxRenderer::pipelineFor numbers the attributes it actually binds.

Locations are untouched: compiling all 27 vertex entry points before and
after gives identical attribute types and bindings on the SPIR-V/MSL route,
so Vulkan and Metal see no change. Verified rendering unchanged on macOS.

Also stop four renderers reporting "pipeline ready" from their constructor.
They only create shaders there and build pipelines lazily, so the Windows log
read as if grass, cloud shadows, environment earth and the post-effects were
fine while every other renderer failed -- when in fact they had not yet tried.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ivan-ushakov
ivan-ushakov merged commit bc9cd7e into crossplatform Aug 6, 2026
4 checks passed
@ivan-ushakov
ivan-ushakov deleted the fix/d3d12-vertex-input-semantics branch August 6, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant