Skip to content

Render commands and friends#1830

Merged
pohky merged 29 commits into
aers:mainfrom
universalconquistador:render-commands-and-friends
Jun 12, 2026
Merged

Render commands and friends#1830
pohky merged 29 commits into
aers:mainfrom
universalconquistador:render-commands-and-friends

Conversation

@universalconquistador

Copy link
Copy Markdown
Contributor

A few different rendering things in support of under-UI overlay drawing:

  • Initial ThreadLocals support. Feel free to suggest any changes to how it's presented in ClientStructs.
  • Adds the Context for generating and enqueueing render commands
  • Adds lots of stuff to ImmediateContext where the render commands are processed
  • Adds structs to help with bitfield rendering states
  • Adds AtkServer that turns UI draw commands into render commands
  • Adds Texture fields for getting the render target view / depth stencil view

[MemberFunction("48 89 5C 24 ?? 48 89 6C 24 ?? 56 57 41 54 41 56 41 57 48 83 EC 50 44 8B 05")]
public partial ulong Draw(bool unk);

[MemberFunction("E9 ?? ?? ?? ?? CC CC CC CC CC CC CC CC CC CC 48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 7C 24 ?? 41 56")]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I realize this is a terrible signature, let me know if you have any better ideas for how to do this!

@github-actions github-actions Bot added the breaking change PR contains breaking changes and wont be merged before a new patch label May 14, 2026
@universalconquistador

Copy link
Copy Markdown
Contributor Author

Breaking Changes

Member exists in left but not in right

FFXIVClientStructs.FFXIV.Client.Graphics.Kernel: 2

RenderCommandScissorsRect: 4

  • int Left
  • int Top
  • int Right
  • int Bottom

RenderCommandClearDepth: 2

  • float ClearType
  • int ClearCheck

I believe basically none of these changed render command fields were correct? So I think we're good to make these breaking changes.


[StructLayout(LayoutKind.Explicit, Size = 0x40)]
public unsafe struct TextureMipRenderTarget {
[FieldOffset(0x00)] public void* D3D11RenderTargetViewOrDepthStencilView; // ID3D11RenderTargetView(1?) or ID3D11DepthStencilView(1?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I bet we could use a CExporterUnion here to present both the ID3D11RenderTargetView* and the ID3D11DepthStencilView*

Comment thread FFXIVClientStructs/FFXIV/Client/Graphics/Render/RenderTargetManager.cs Outdated
Comment thread FFXIVClientStructs/FFXIV/Client/UI/UIModule.cs Outdated

@Haselnussbomber Haselnussbomber left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed some changes, but other than that it looks fine to me.

public static partial Device* Instance();

[FieldOffset(0x8)] public void* ContextArray; // Client::Graphics::Kernel::Context array
[FieldOffset(0x8)] public void* ContextArray; // TODO: We have a struct for this now (breaking change)

@Haselnussbomber Haselnussbomber May 27, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as a note, I would have no idea what to change this to. I guess Context* something?
Would rather add a Span for that if the size is constant and the length is known.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what the length is, whether it's fixed size or not, and where the contexts come from. I didn't look into it because it wasn't critical for what I was doing; any function you hook that does drawing is going to have a thread-local context nice and ready to be used.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to add it, its max length is 16. The actual length is stored in 0x68.

DeviceDX11_Initialize:

  v7 = 16;
  *(_QWORD *)(v3 + 0xC0) = (v4 >> 1) & 0x7FFFFFFFFFFFFFF0i64;
  if ( *((_DWORD *)a2 + 2) < 16u )
    v7 = *((_DWORD *)a2 + 2);
  *(_DWORD *)(v3 + 0x68) = v7;

Comment thread FFXIVClientStructs/FFXIV/Client/Graphics/Kernel/ImmediateContext.cs Outdated
Comment thread FFXIVClientStructs/FFXIV/Client/Graphics/Kernel/Context.cs Outdated
@github-actions github-actions Bot removed the breaking change PR contains breaking changes and wont be merged before a new patch label Jun 9, 2026
Comment thread FFXIVClientStructs/FFXIV/Client/Graphics/Kernel/PackedDepthStencilDesc.cs Outdated
Comment thread FFXIVClientStructs/FFXIV/Client/Graphics/Kernel/PackedDepthStencilDesc.cs Outdated
Comment thread FFXIVClientStructs/FFXIV/Component/GUI/AtkServer.cs Outdated
Comment thread FFXIVClientStructs/FFXIV/Component/GUI/AtkServer.cs Outdated
Comment thread FFXIVClientStructs/Interop/ThreadLocals.cs Outdated
[FieldOffset(0x10)] public ShaderCodeResourceHandle* PrimitiveUIVSResource;
[FieldOffset(0x18)] internal ShaderCodeResourceHandle* _primitiveUIVSResource_2;
[FieldOffset(0x20)] internal ShaderCodeResourceHandle* _primitiveUIVSResource_3;
[FieldOffset(0x28)] internal ShaderCodeResourceHandle* _primitiveUIVSResource_4;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use a FixedSizeArray like GBuffers?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are all the same shaderresourcehandle, I'm not really sure whether they are treated like an array. But if someone really cares one way or another I could change it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misunderstood; I didn't realize they were all pointing to the same shader handle. I think it makes sense to do it this way since I guess they are useless padding.

[FieldOffset(0xE8)] public VertexShader* PrimitiveUIVS;
[FieldOffset(0xF0)] internal VertexShader* _primitiveUIVS_2;
[FieldOffset(0xF8)] internal VertexShader* _primitiveUIVS_3;
[FieldOffset(0x100)] internal VertexShader* _primitiveUIVS_4;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also FixedSizeArray?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are all the same VertexShader*, I'm not really sure whether they are treated like an array. But if someone really cares one way or another I could change it.

@sourpuh sourpuh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few changes and LGTM

Comment thread FFXIVClientStructs/FFXIV/Client/Graphics/Render/RenderTargetManager.cs Outdated
Comment thread FFXIVClientStructs/Interop/ThreadLocals.cs Outdated
Comment thread FFXIVClientStructs/FFXIV/Component/GUI/AtkServer.cs Outdated
Comment thread FFXIVClientStructs/FFXIV/Client/Graphics/Kernel/Device.cs Outdated
[FieldOffset(0x10)] public ShaderCodeResourceHandle* PrimitiveUIVSResource;
[FieldOffset(0x18)] internal ShaderCodeResourceHandle* _primitiveUIVSResource_2;
[FieldOffset(0x20)] internal ShaderCodeResourceHandle* _primitiveUIVSResource_3;
[FieldOffset(0x28)] internal ShaderCodeResourceHandle* _primitiveUIVSResource_4;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misunderstood; I didn't realize they were all pointing to the same shader handle. I think it makes sense to do it this way since I guess they are useless padding.

@pohky pohky merged commit 024256e into aers:main Jun 12, 2026
5 checks passed
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.

5 participants