Skip to content

Feature/openglnative#2

Draft
dellis1972 wants to merge 83 commits into
infinitespace-studios:developfrom
dellis1972:feature/openglnative
Draft

Feature/openglnative#2
dellis1972 wants to merge 83 commits into
infinitespace-studios:developfrom
dellis1972:feature/openglnative

Conversation

@dellis1972

Copy link
Copy Markdown

Fixes #

Description of Change

Contributor Declaration

  • I certify that no LLM's were used to generate any code or documentation in this contribution.

dellis1972 and others added 27 commits March 18, 2026 15:20
Pin Xcode to use 26.2 to fix the CI builds

### Contributor Declaration

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.
Turns out we were missing the float * Matrix operator on the Matrix
class all these years. We have Matrix * float, but not the other. This
adds it.


https://learn.microsoft.com/en-us/previous-versions/windows/xna/bb198123(v=xnagamestudio.40)

### Contributor Declaration

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.
…e#9271)

This increases the supported draw calls per frame, with more complex
shaders in place.

Fixes MonoGame#9269 and MonoGame#9270.

### Description of Change
We have 2 similar but separate issues:

1. The uniform ringbuffer size is set too low in the native Vulkan
backend. We currently set this at 4MiB, but this seems much too low for
any modern system, and it causes issues or crashes that don't appear on
the native DX12 backend.
2. The shader descriptor pool size is set too low in the native Vulkan
backend. Again, the 1024 descriptor limit seems too low for any modern
system.

The ringbuffer size issue is very easy to run into, and the descriptor
pool issue depends somewhat on the custom shaders being used. But both
are dependent on how crowded the scene is. Which also means it
particularly becomes an issue when the game is rendering against VR
targets.
This changeset fixes both.

### Contributor Declaration

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.
This PR rewrites how dependent assets... for example when an FBX
references different Effects and Textures.

Previously in XNA it would write the original asset name with an
underscored number for dependencies. So you would see `mytexture_0.xnb`.
`mytexture_1.xnb`, etc. Internally the XNA pipeline would add a new
asset when it found a new combination of importer/processor settings for
the same asset.

In the new Builder it was changed so that it would output the dependent
assets with the name of the parent asset that built it. So you would see
`mymodel_0.xnb`. mymodel_1.xnb`, etc. But in this case the 0 one was
actually the Effect and the 1 asset was the texture. This design is very
confusing, but worse causes duplicate assets as two models using the
same texture would have their own copies. With a large game with high
resolution assets this could be GBs of duplicate content.

The changes here instead revert to how XNA worked... keeping the
original asset name, but instead of an index you get a hash of the used
importer/processor settings. So you get assets like:
`mytexture.e9216cd.xnb`, `mytexture.7b9fd52.xnb` .. where each hash
represents the same source asset processed a different way.

The benefits of this method:

 - Makes clear what the source asset was.
- Clearly shows all assets built with the same processing settings (same
hash).
 - Reduces time building the same asset multiple times.
 - Reduces duplicate assets on disk.

There is more improvements that can be done here.

For example you can end up with `mytexture.xnb` and
`mytexture.7b9fd52.xnb` if you have a model that references a texture,
but you also include the same texture with the same settings directly
via the builder.
MonoGame#9176)

# Summary

Templates update to enable the Content Builder `.targets` file to work
for any build configuration.

- `Content.csproj` updated to not use the "target framework" in build
output to simplify launching
- `Builder.targets` updated to decouple itself from the host platforms
"configuration" and fixed to run as "Debug" when attached to a solution

`content.csproj` update:
```xml
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
```

`builder.targets` update:
```xml
<Project>
  <Target Name="BuildContent" BeforeTargets="BeforeCompile">
    <PropertyGroup>
      <ContentOutput>$(ProjectDir)$(OutputPath)</ContentOutput>
      <ContentTemp>$(ProjectDir)$(IntermediateOutputPath)</ContentTemp>
      <ContentArgs>build -p $(MonoGamePlatform) -s Content/Assets -o $(ContentOutput) -i $(ContentTemp)</ContentArgs>
      <ContentCommand>$(MSBuildThisFileDirectory)bin\Debug\Content</ContentCommand>
    </PropertyGroup>
    <MSBuild Projects="$(MSBuildThisFileDirectory)Content.csproj" Targets="Build" RemoveProperties="Configuration;TargetFramework;RuntimeIdentifier;RuntimeIdentifiers" />
    <Exec Command="$(ContentCommand) $(ContentArgs)" WorkingDirectory="$(MSBuildThisFileDirectory)..\" CustomErrorRegularExpression="\[E\] .+" CustomWarningRegularExpression="\[W\] .+" />
   </Target>
</Project>
```

Minor patch fix to CB StartKit to ignore `ttf` files to supress warning
that `ttf` file could not be processed (which is correct, it is consumed
in the `.spritefont` import.
…Game.Dispose(bool) method (MonoGame#9266)

<!--
Are you targeting develop? All PRs should target the develop branch
unless otherwise noted.
-->

Fixes MonoGame#9059 

<!--
Please try to make sure that there is a bug logged for the issue being
fixed if one is not present.
Especially for issues which are complex. 
The bug should describe the problem and how to reproduce it.
-->

### Description of Change

This unsubscribes from the ComponentAdded and ComponentRemoved events of
the Game's ComponentCollection during disposal.

<!-- 
Enter description of the fix in this section.
Please be as descriptive as possible, future contributors will need to
know *why* these changes are being made.
For inspiration review the commit/PR history in the MonoGame repository.
-->


### Contributor Declaration

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.
…ame#9264)

If you are using Song on the native platform we get a null reference
exception when closing because we have no null checks in place. This
happens if you load a song but never actually play it.

### Contributor Declaration

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.
…ndSystemState.NotInitialized (MonoGame#9262)

Fixes MonoGame#9026

### Description of Change

Based on OP's suggestion, but setting:
`_systemState = SoundSystemState.NotInitialized`

In a centralised location, so that all soundeffects follow this pattern,
regardless of platform.


### Contributor Declaration

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.
- Updated AssetRead function to accept a long count parameter instead of
int. This is because the underlying native API uses `mglong`.
- Add platform-specific resource location handling for macOS. When in an
.app package resources are NOT next to the executable, they are in a
Resources folder further up the package path. This change brings the
native platform on MacOS inline with the way DesktopGL works.

### Contributor Declaration

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.
(I accidentally closed my last PR about this, so I had to make a new
one. Sorry about that.)

The internal access of this field is inconvenient in some cases. For
example, in order to merge multiple GamePadButtons together, you must
check each property individually. With the public accessor, you can
simply or them together.
…onoGame#9249)

Fixes MonoGame#9221

In Linux using DesktopVK, setting `IsMouseVisible` is not respected.

### Description of Change

1. Call `OnIsMouseVisibleChanged()` in `NativeGamePlatform` class
constructor.
2. In `OnIsMouseVisibleChanged`, directly pull visibility from
`IsMouseVisible` rather than `Game.IsMouseVisible` as `Game` is
sometimes not yet initialized.

### Contributor Declaration

- [x ] I certify that no LLM's were used to generate any code or
documentation in this contribution.
…9252)

### Description of Change
When the window is closed and either `EventType.WindowClose` or
`EventType.Quit` is fired it does not properly exit the game. It
increments `_isExiting` instead of actually calling the proper
`Game.Exit()` method.


### Contributor Declaration

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.
Adding some missing transitions in the native Vulkan backend.

Fixes MonoGame#9275


### Description of Change

This changeset adds some missing valid image layout transitions in the
Vulkan backend.
I am very new to Vulkan, or even graphics in general, so please
double-check anything I might have missed. But my local testing has
shown this to work.

(Apologies for not sending this prior to the release of `preview.4`. I
wanted to take the time to double check the transitions before
cherry-picking them into a PR, and didn't realize preview.4 was at the
doorstep.)


### Contributor Declaration

- [X] I certify that no LLM's were used to generate any code or
documentation in this contribution.
We have a check that compares `dataStride` against itself where it
should be comparing it against `dataBytes`.

Fixes MonoGame#9277

<!--
Please try to make sure that there is a bug logged for the issue being
fixed if one is not present.
Especially for issues which are complex. 
The bug should describe the problem and how to reproduce it.
-->

### Description of Change

1. We replace the `if (dataStride == dataStride)` check with `if
(dataBytes == dataStride)` to fix the bug.
2. I've also added a `dataBytes < dataStride` check, but I'm not sure if
it makes sense. As in whether I'm being paranoid, or it's better safe
than sorry. I simply don't know the use-cases, so I'm not sure if it
could possibly be the target that has padding.
3. I've added the same check to the Vulkan backend too, so let me know
if it makes sense to keep them or not.
4. I've also added a `DX::ThrowIfFailed` check since
`Allocator::CreateResource` returns `HRESULT`, but I'm not sure whether
it's actually useful or not.

### Contributor Declaration

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.
…e#9261)

There is a bug when a gamepad get's added it doesn't use the proper
instance id.

The `SDL_ControllerDeviceEvent.which` returns a joystick device index
for `SDL_CONTROLLERDEVICEADDED` and an instance id for
`SDL_CONTROLLERDEVICEREMOVED`
https://wiki.libsdl.org/SDL2/SDL_ControllerDeviceEvent

The `SDL_ControllerButtonEvent.which` returns an instance id
https://wiki.libsdl.org/SDL2/SDL_ControllerButtonEvent

### Contributor Declaration

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.

---------

Co-authored-by: Simon (Darkside) Jackson <darkside@zenithmoon.com>
…oGame#9256)

Fixes MonoGame#9255

This fixes a bug where the game will stay in Fullscreen mode when
switching between Fullscreen Desktop and Windowed and changing the
`HardwareModeSwitch`.

Outlined more in detail in the issue.

### Description of Change

Simplifies the code for when to change the fullscreen mode. 

### Contributor Declaration

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.

---------

Co-authored-by: Simon (Darkside) Jackson <darkside@zenithmoon.com>
Lets add Vulkan and DX12 to the issue template for bug reports

### Contributor Declaration

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.
# Summary

Bumped the versions of all the NuGet dependencies for build
Bumped xcode to 26.3 to get around .net iOS build errors

### Contributor Declaration

- [X] I certify that no LLM's were used to generate any code or
documentation in this contribution.
Add step to update Homebrew for macOS runners.
This should fix the wine install errors we are seeing.

### Contributor Declaration

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.
…MonoGame#9283)

This will hopefully prevent some sporadic exceptions when the game shuts
down.
`MGG_GraphicsDevice_Destroy` begins cleaning up the swapchain without
ensuring we're not in the middle of a draw.
This can sporadically cause exceptions when we're shutting down the
game.

Fixes MonoGame#9282

### Description of Change

We wait for the GPU to idle before we start the cleanup, like we do in
`MGVK_RecreateSwapChain`.

### Contributor Declaration

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.

Co-authored-by: Dean Ellis <dellis1972@googlemail.com>
Increasing default `HttpClient.Timeout` to 2 minutes, and making it
configurable in the Build tool.

Fixes MonoGame#9288


### Description of Change

- Explicitly registered a factory function for Cake to retrieve
`HttpClient` instances.
It overrides the default 100s timeout value with 2m.
This is also configurable via a `HTTPCLIENT_TIMEOUT` env variable.
- Also added a `TestTimeoutTask` just to test that this works.



### Contributor Declaration

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.
Attempting to fix a DX12 bug that turned into 2 bugs during my testing:

1. `DepthFormat.Depth24Stencil8` handling was wrong in
`Texture::Create()`. This causes `RenderTarget2D` ctor to throw and
crash the game.
2. `ReferenceStencil` value was being ignored, which prevented stencil
masks from working.

Fixes MonoGame#9279



### Description of Change

- Changing `DepthFormatToSRV` mapping to return
`DXGI_FORMAT_R24_UNORM_X8_TYPELESS` instead of
`DXGI_FORMAT_R24G8_TYPELESS` for `Depth24Stencil8`.
- We store `ReferenceStencil` in `MGG_DepthStencilState`.
- We make sure `ReferenceStencil` is set for each frame in
`MGG_GraphicsDevice_SetDepthStencilState`.


### Contributor Declaration

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.
…ng (MonoGame#9254)

### Description of Change

Enable external code to wrap an already-opened D3D11 shared texture as a
MonoGame Texture2D, avoiding a per-frame CopyResource when
interoperating with other D3D11 devices (e.g. LibVLC).

I don't know if this is a change you're interested to take it, and if so
if other targets (opengl, vulkan) could be candidate for it as well,
just wanted to share in case.

### Contributor Declaration

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.
…g TargetSetCache Itself (MonoGame#9297)

Fixes MonoGame#9296


### Description of Change

- We're now calling `MGVK_DestroyPipelines` for the pipelines that point
at `targetSetCache` before destroying it in `cleanupSwapChain`.


### Contributor Declaration

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.
…oGame#9298)

# Summary

To further define and help to enforce the nature of AI use on the
official MonoGame repositories, issues and pull requests, this agents
file is being added to guide users in the use of AI and the submission
of fixes/updates.

## Sources of reference in building this policy

- Azure SDK for .NET -
https://github.com/Azure/azure-sdk-for-net/blob/main/AGENTS.md
- Uptime Kuma -
https://github.com/louislam/uptime-kuma/blob/master/AGENTS.md
- JabRef - https://github.com/JabRef/jabref/blob/main/AGENTS.md


### Contributor Declaration

- [X] I certify that no LLM's were used to generate any code or
documentation in this contribution.
Although AI was used to search for policies in use by other
organisations
Added steps to update Homebrew, setup Wine, and install Fonts on macOS
using the monogame-actions



### Contributor Declaration

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.
…nt types (MonoGame#9301)

Fixes MonoGame#9300 

### Description of Change

Added different method overloads for the Color.FromNonPremultiplied
method. Added overloads for another Color instance and float values.

Also updated the documentation comments for Color.FromNonPremultiplied's
arguments to reference their expected numerical value.

### Contributor Declaration

- [X] I certify that no LLM's were used to generate any code or
documentation in this contribution.
@dellis1972 dellis1972 force-pushed the feature/openglnative branch from e2f3a46 to 4bf2a5d Compare April 23, 2026 17:18
Echoflask and others added 2 commits April 28, 2026 16:15
🔥 we're hating on AI's with this one

### Description of Change

Currently existing AGENTS.MD file is primarily written to be read by a
human. This PR rewrites this file with language pointed directly at the
AI agent, while keeping the file understandable for the human. It also
creates file `claude.md` to be used specifically with Claude models, [as
their harnesses ignore `agents.md`
file](https://code.claude.com/docs/en/memory#agents-md).

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.
…nd win arm64 (MonoGame#9224)

Add support for Ubuntu 22.04 ARM in CI workflow
Add support for Windows ARM in CI workflow

We had to add an additional step to Package the `runtime` nugets since
we now build the linux binaries over multiple steps on different
machines.

### Contributor Declaration

- [x] I certify that no LLM's were used to generate any code or
documentation in this contribution.

---------

Co-authored-by: Tom Spilman <tom@sickheadgames.com>
Co-authored-by: Uygar Yilmaz <1023940+uygary@users.noreply.github.com>
@dellis1972 dellis1972 force-pushed the feature/openglnative branch from 6496a06 to e3d9fc8 Compare April 29, 2026 12:13
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.