Skip to content

sokol: add opt-in Windows D3D11 support#27654

Merged
medvednikov merged 2 commits into
vlang:masterfrom
GGRei:sokol-d3d11-windows
Jul 5, 2026
Merged

sokol: add opt-in Windows D3D11 support#27654
medvednikov merged 2 commits into
vlang:masterfrom
GGRei:sokol-d3d11-windows

Conversation

@GGRei

@GGRei GGRei commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds opt-in Windows D3D11 support for sokol.

Windows keeps OpenGL as the default backend. D3D11 is enabled explicitly with:

v -d sokol_d3d11 examples/gg/minimal.v

This wires D3D11 backend selection, sapp device/swapchain glue, gg through sokol, and backend-aware screenshot readback while preserving the existing public screenshot API.

Fix #27652

Validation

Passed locally:

  • ./v test vlib/sokol/gfx vlib/sokol/sapp vlib/v/live
  • ./v check-md vlib/sokol/README.md
  • ./v fmt -verify on touched V files
  • git diff --check

Windows smoke CI passed with MSVC and GCC:

  • default OpenGL compile/link
  • D3D11 compile/link for gg/minimal, 2048, tetris
  • D3D11 screenshot probe compile/link

Windows Manual Testing

CI validates compile/link only. Please test on real Windows:

  • v -d sokol_d3d11 examples/gg/minimal.v
  • v -d sokol_d3d11 examples/2048/2048.v
  • v -d sokol_d3d11 examples/tetris/tetris.v

Please confirm rendering, input, resize, clean close, and screenshot PNG/PPM correctness.

Note: D3D11 screenshot/readback is implemented for normal Windows builds, but -sharedlive -d sokol_d3d11 screenshot/readback is not supported yet and should be handled in a separate follow-up.

@GGRei GGRei marked this pull request as ready for review July 4, 2026 18:03
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

@GGRei

GGRei commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ae02dc8fa2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread thirdparty/sokol/sokol_v.post.h
@JalonSolov

Copy link
Copy Markdown
Collaborator

Why not make d3d default on Windows? If it'll be used at all, may as well be the default... unless this is a temp measure so it can be tested for a while, first.

@GGRei

GGRei commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

@JalonSolov Yes, exactly. This is intentional as a safety step. I prefer keeping OpenGL as the Windows default for now, while D3D11 gets tested by users on real Windows setups. ^^

@GGRei GGRei force-pushed the sokol-d3d11-windows branch from ae02dc8 to 219cc04 Compare July 4, 2026 18:33
@GGRei

GGRei commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 219cc04d8a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread vlib/gg/gg.c.v
@GGRei

GGRei commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 917cf4e1bd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@medvednikov medvednikov closed this Jul 4, 2026
@medvednikov medvednikov reopened this Jul 4, 2026
@medvednikov medvednikov closed this Jul 4, 2026
@medvednikov medvednikov reopened this Jul 4, 2026
@squidink7

Copy link
Copy Markdown
Contributor

Thanks! this works great for gg examples, however it doesn't seem to work for the gui library, which as far as I am aware uses gg/sokol behind the scenes. That may be a separate issue however it was exhibiting similar problems where a blank window would open but then close immediately after with nothing logged to the console.

@medvednikov medvednikov merged commit 523e163 into vlang:master Jul 5, 2026
133 of 255 checks passed
@GGRei

GGRei commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback!

This PR does not cover that part yet. The base gg/sokol D3D11 path works, but v-gui has its own custom shader pipelines, and those are still GLSL/Metal only. With D3D11, v-gui will need proper HLSL/D3D shader support too.

@squidink7 Could you open a separate issue in vlang/gui for that? It is exactly the kind of follow-up that should be tracked there.

This is also why I prefer keeping D3D11 opt-in for now instead of making it the default immediately, it helps expose this kind of collateral issue without breaking existing Windows users.

@squidink7 squidink7 mentioned this pull request Jul 5, 2026
@squidink7

Copy link
Copy Markdown
Contributor

Done! vlang/gui#72

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.

sokol: D3D support on Windows

4 participants