Add native pipeline support and texture related functionality#8871
Add native pipeline support and texture related functionality#8871harry-cpp merged 13 commits intoMonoGame:developfrom
Conversation
- Updated .gitignore to include Premake generated files. - Added new submodule for stb_image. - Created native pipeline library with C API for bitmap import. - Implemented texture importing using native methods in TextureImporter. - Enhanced build process for native pipeline with Premake and MSBuild. - Added README and API headers for the native pipeline.
harry-cpp
left a comment
There was a problem hiding this comment.
You can remove the test that is failing, for the switching to stb_image we have decided to not support any image format not supported by it for importing.
MonoGame.Framework.Content.Pipeline/MonoGame.Framework.Content.Pipeline.csproj
Outdated
Show resolved
Hide resolved
d3cfc00 to
8589466
Compare
- Rename native pipeline to `mgpipeline` - Remove TIFF format test and asset - Update .gitignore and enhance BuildContentPipelineTask for cross-platform support - Remove system-specific path from platform target in premake5.lua - Refactor API export macros for improved cross-platform compatibility - Refactor `MGCP_Bitmap` to use reference types for better memory management and error handling - Fix Linux native pipeline library reference in project file - Refactor `MP_ImportBitmap` to satisfy GCC
|
To totally remove FreeImage and StbImage(Write)Sharp, there are few more APIs to implement:
However, there's a critical bug in MonoGame/MonoGame.Framework.Content.Pipeline/Utilities/BasisUHelpers.cs Lines 375 to 377 in 7c11dd0 That means all textures are converts to rgba8 regardless of there original color depth (16bit or float) |
|
Since its happening on the current develop branch I'd recommend just leaving it working as is in here, and just opening a new issue about it (with a couple of comments in code about the issue). Tho if its something thats easy to fix, feel free to do it here. |
Okay, it's weird but works. I opened an issue for it here #8874 |
harry-cpp
left a comment
There was a problem hiding this comment.
You'll need to setup a way to package up MonoGame.Content.Pipeline for all the platforms, right now each platform is makings its own nuget that only has 1 native assembly in it for itself which would break stuff.
To do this I recommend:
- Upload each mgpipeline native lib as an artifact during build
- Download each mgpipeline native lib during Deploy, place them in the Artifacts folder and combine then rebuild just the MonoGame.Content.Pipeline by creating a brand new cake task
We use GitHub actions located in .github/workflows and C# Cake project located by opening Build.sln in root for CI operations, I believe you just need to modify the C# side of things for this, you can test on your local fork by enabling github actions on it.
Another thing to note is that mgpipeline needs to be statically linked and the CI should check for that. You can grab the code for that from: https://github.com/MonoGame/MonoGame.Library.BuildScripts/blob/5cd1ee39dfa0e570b125260d4d19753232c1c29e/Tasks/TestLinuxTask.cs#L5 (there is 1 task for each platform)
MonoGame.Framework.Content.Pipeline/MonoGame.Framework.Content.Pipeline.csproj
Outdated
Show resolved
Hide resolved
|
PS. Feel free to ping me on discord for me to review the PR or if you have any questions about this, I should notice it much quicker then on github ^^ |
…p processing, add resizing functionality, and update related enums and structures.
…stom export functionality.
…y management, update import/export paths.
da0fe76 to
6ae52f8
Compare
- Fix bpp calculation bug to avoid wasting memory - Add static library check task - Fix premake5 configuration for macOS universal support, static linkage on Windows
|
|
||
| #define MG_FIELD_OFFSET(off, type, name) struct { char _pad_##name[off]; type name; } | ||
|
|
||
| #if defined(_WIN32) || defined(__CYGWIN__) |
There was a problem hiding this comment.
Not sure how these changes in the export will affect the consoles... will have to test it later and fix things. It however worked before.
…Check class for clarity
|
Looking good so merging! Thank you very much for getting this work done @sepcnt ! |
This PR addresses bounty #8641 by replacing the
FreeImageandStbImageSharpdependencies with a new, in-house native C++ pipeline library (mgpipeline) for texture importing.The changes improve modularity and performance by consolidating image-related operations into the
mgpipelinelibrary. Additionally, submodule management and project dependencies have been updated to reflect these changes.Image Processing Refactor:
MonoGame.Framework.Content.Pipeline/Graphics/GraphicsUtil.cs: Refactored theResizemethod to use theMGCP_Bitmapstructure andMGCP.MP_ResizeBitmapfunction from themgpipelinelibrary, replacing FreeImage-based resizing logic.MonoGame.Framework.Content.Pipeline/TextureImporter.cs: Replaced FreeImage and Stb-based image importing withMGCP.MP_ImportBitmapand added support for new texture types. Removed redundant methods for channel swapping and BMP loading.Native Library Integration:
MonoGame.Framework.Content.Pipeline/Native/Texture.Interop.cs: Introduced a new interop file definingMGCP_Bitmapstructure and native methods (MP_ImportBitmap,MP_ResizeBitmap,MP_ExportBitmap, etc.) for interacting with themgpipelinelibrary.MonoGame.Framework.Content.Pipeline/MonoGame.Framework.Content.Pipeline.csproj: Addedmgpipelinenative library files (mgpipeline.dll,libmgpipeline.so,libmgpipeline.dylib) to the project for cross-platform support. Removed references to FreeImage and Stb libraries.Submodule and Workflow Updates:
.gitmodules: Added a new submodule forexternal/stb, ensuring proper version control for dependencies..github/workflows/main.yml: Updated the repository cloning step to include submodules recursively in deploy stage.File Format Export:
MonoGame.Framework.Content.Pipeline/Utilities/FileHelpers.cs: Refactored PNG export logic to useMGCP.MP_ExportBitmapinstead of StbImageWriteSharp, improving error handling and efficiency.Cleanup and Simplification:
MonoGame.Framework.Content.Pipeline/MonoGame.Framework.Content.Pipeline.csproj: Removed unused references to StbImageSharp and StbImageWriteSharp, as well as the FreeImage library. [1] [2]MonoGame.Framework.Content.Pipeline/Graphics/GraphicsUtil.cs: Removed theBGRAtoRGBAmethod, as channel swapping is no longer required with the new library.