Open
Conversation
490a040 to
c076115
Compare
Author
Demonese
reviewed
Feb 22, 2026
47ec385 to
8856c99
Compare
There was a problem hiding this comment.
Pull request overview
This pull request adds comprehensive video texture support to the engine, enabling videos to be loaded and rendered as textures. The implementation integrates video decoding through Microsoft Media Foundation (Direct3D 11 platform) with the existing graphics and resource management systems.
Changes:
- Implemented
VideoDecoderandVideoTextureclasses with hardware-accelerated decoding support via Media Foundation - Extended
IGraphicsDeviceandITexture2Dinterfaces to support video textures - Added
LoadVideomethod to resource manager for loading videos into the texture pool - Created Lua bindings (both modern OOP-style
lstg.Videoclass and classiclstg.LoadVideofunction) - Added configuration option to disable hardware video decoding
- Provided example scripts demonstrating video playback with manual time-based updates
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| engine/graphics/d3d11/VideoDecoder.cpp | Core video decoder implementation using Media Foundation with hardware acceleration support |
| engine/graphics/d3d11/VideoDecoder.hpp | Video decoder interface with playback control and stream enumeration |
| engine/graphics/d3d11/VideoTexture.cpp | VideoTexture wrapper combining ITexture2D and IVideoDecoder interfaces |
| engine/graphics/d3d11/VideoTexture.hpp | VideoTexture class definition |
| engine/graphics/core/VideoDecoder.hpp | IVideoDecoder interface with VideoOpenOptions configuration |
| engine/graphics/core/Texture2D.hpp | Added isVideoTexture() and getVideoDecoder() to ITexture2D interface |
| engine/graphics/core/GraphicsDevice.hpp | Added createVideoTexture() and createVideoDecoder() methods |
| engine/graphics/d3d11/Texture2D.hpp | Implemented new interface methods for standard textures |
| engine/graphics/d3d11/GraphicsDevice.hpp | Added video creation method declarations |
| engine/graphics/CMakeLists.txt | Linked Media Foundation libraries |
| engine/configuration/core/Configuration.hpp | Added disable_hardware_video_decode configuration option |
| engine/configuration/core/Configuration.cpp | Configuration loading for hardware decode option |
| LuaSTG/LuaSTG/LuaBinding/modern/Video.cpp | Modern OOP-style Lua binding for video control |
| LuaSTG/LuaSTG/LuaBinding/modern/Video.hpp | Video class interface |
| LuaSTG/LuaSTG/LuaBinding/LuaWrapper.cpp | Registered Video class |
| LuaSTG/LuaSTG/LuaBinding/LW_ResourceMgr.cpp | Classic Lua bindings for video loading and control functions |
| LuaSTG/LuaSTG/GameResource/ResourcePool.cpp | Implemented LoadVideo method in ResourcePool |
| LuaSTG/LuaSTG/GameResource/ResourceManager.h | Added LoadVideo declaration |
| LuaSTG/LuaSTG/GameResource/ResourceDebug.cpp | Updated debug view to display video texture information |
| data/example/video_example.lua | Example demonstrating classic API usage |
| data/example/video_example_modern.lua | Example demonstrating modern OOP API usage |
| LuaSTG/CMakeLists.txt | Added Video.cpp/hpp to build |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6302f8d to
9208c6a
Compare
Demonese
reviewed
Feb 25, 2026
Demonese
reviewed
Feb 25, 2026
Demonese
reviewed
Feb 25, 2026
Demonese
reviewed
Feb 25, 2026
…esource management
…erance adjustments
… and stream handling
…usting frame size handling
- Add Video.hpp and Video.cpp Lua binding classes for video resource management - Implement video information methods (getWidth, getHeight, getDuration, getCurrentTime, getFPS) - Implement playback control methods (seek, update, setLooping, setLoopRange, getLoopRange) - Add stream enumeration methods (getVideoStreams, getAudioStreams, getSubtitleStreams) - Add stream selection methods (selectVideoStream, selectAudioStream, selectSubtitleStream) - Implement getTexture method to retrieve associated Texture2D object - Register Video class in LuaWrapper for Lua API exposure - Add video_example_modern.lua example demonstrating video loading and playback - Update CMakeLists.txt to include new Video binding source files - Extend Texture2D and VideoTexture interfaces to support video decoder access
- Add null pointer checks for video decoder in Lua resource manager seek, updateToTime, and getLastOpenOptions methods - Extract VideoOpenOptions parsing logic into reusable parseVideoOptions helper function - Replace duplicated video options parsing code in reopen and createFromFile methods with helper function call - Define constants for maximum stream enumeration (kMaxStreams) and post-seek decode frames (kMaxDecodeFramesAfterSeek) - Replace magic number 16 with kMaxStreams constant for stream enumeration loops - Replace magic number 360 with kMaxDecodeFramesAfterSeek constant for frame decode limit - Improves code maintainability by reducing duplication and centralizing configuration constants
…e handling - Introduce new configuration option for allowing hardware video decoding - Refactor logic to handle enabling/disabling hardware video decode based on configuration - Update VideoDecoder to utilize new frame rate settings, defaulting to 30 fps - Adjust VideoTexture initialization to improve memory management with SmartReference
3189871 to
77dc3f0
Compare
- Remove all Chinese language comments from VideoDecoder interface and implementation - Replace inline HRESULT error checking with win32::check_hresult_as_boolean utility function - Simplify error logging by removing hex error codes where utility function handles reporting - Add string_view_literals using declaration for error message handling - Improve code consistency and maintainability by standardizing error handling patterns - Add blank line between VideoStreamInfo and AudioStreamInfo struct definitions for clarity
- Extract video options parsing logic into VideoBindingHelpers module for reusability - Add MediaFoundationHelpers header for Media Foundation utilities - Separate VideoDecoderImpl and VideoDecoderConfig into dedicated files for better organization - Refactor video control functions to use centralized getDecoderFromResourceName helper - Simplify error handling in VideoSeek, VideoSetLooping, VideoSetLoopRange, VideoUpdate, and VideoGetInfo functions - Remove duplicate decoder lookup logic across multiple Lua binding functions - Update CMakeLists.txt to include new helper source files - Consolidate video texture and decoder retrieval into reusable helper functions
Demonese
reviewed
Feb 27, 2026
Demonese
reviewed
Feb 27, 2026
Demonese
reviewed
Feb 27, 2026
…iant - Remove custom MediaFoundationHelpers.hpp with PropVariantGuard RAII wrapper - Replace all PropVariantGuard instances with wil::unique_prop_variant from WIL library - Update variable access patterns from pointer-based (var.get(), var->member) to direct member access (var.member) - Add wil/resource.h include to VideoDecoder.cpp and VideoDecoderImpl.cpp - Simplify PROPVARIANT management by leveraging WIL's built-in resource handling - Reduces code duplication and improves maintainability by using standard library utilities
- Replace raw Lua C API calls with lua::stack_t wrapper for type-safe stack operations - Simplify VideoBindingHelpers by removing custom getOptionalField and using stack.get_map_value - Update LoadVideo, VideoSeek, VideoSetLooping, VideoUpdate, and VideoReopen functions to use stack API - Replace lua_gettop/lua_istable with ctx.index_of_top/ctx.is_table for cleaner stack checks - Replace lua_pushboolean with ctx.push_value for consistent value pushing - Refactor parseVideoOptions to use lua::stack_t for table field extraction - Update pushVideoStreamsToLua to use stack.create_array and stack.set_map_value helpers - Change include from "lua.hpp" to "lua/plus.hpp" for access to stack wrapper utilities - Improves code maintainability and reduces boilerplate in video resource management
Demonese
reviewed
Feb 27, 2026
Demonese
reviewed
Feb 27, 2026
Demonese
reviewed
Feb 27, 2026
Demonese
reviewed
Feb 27, 2026
- Remove unnecessary explicit casts in video binding helpers for array/map values - Simplify stack_index_t usage by removing redundant static_cast operations - Add constexpr constructors to stack_index_t for automatic size_t and uint32_t conversion - Mark unused return values with [[maybe_unused]] in Video binding registration - Add const qualifier to Video::class_name static member - Remove unused pragma comment directives for media foundation libraries in VideoDecoder - Remove unused include of VideoTexture.hpp from ResourceDebug.cpp - Improves code clarity and reduces boilerplate type conversions
Demonese
reviewed
Feb 27, 2026
Demonese
reviewed
Feb 27, 2026
…cludes - Remove unused `VideoTexture.hpp` include from ResourcePool.cpp - Eliminate unnecessary intermediate variables in method table creation - Eliminate unnecessary intermediate variables in metatable creation - Remove `[[maybe_unused]]` pragmas that are no longer needed - Simplify stack index retrieval by directly using create_module and create_metatable return values
- Add IsVideoTexture() virtual method to IResourceTexture interface - Implement IsVideoTexture() in ResourceTextureImpl to check underlying texture - Implement IsVideoTexture() in RenderTargetStackResourceTextureImpl returning false - Add IsVideoTexture Lua binding to ResourceManager for texture queries - Enable runtime detection of video textures from Lua scripts
- Add video texture detection function `IsVideoTexture` to ResourceManager - Add comprehensive video loading and playback API documentation including `LoadVideo`, `VideoSeek`, `VideoSetLooping`, `VideoSetLoopRange`, `VideoUpdate`, `VideoGetInfo`, `VideoGetVideoStreams`, `VideoGetAudioStreams`, and `VideoReopen` - Create new Video.lua type definition file with complete Video class API including static methods, properties, and instance methods - Export all video-related functions to main lstg module for public API access - Remove outdated video example files (video_example.lua and video_example_modern.lua) - Include bilingual documentation (English and Chinese) with usage examples and parameter descriptions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This pull request introduces comprehensive support for video textures in the engine, including their loading, management, and control from both C++ and Lua APIs. It adds new resource management functions for video, exposes detailed video control and information retrieval functions to Lua, and provides example scripts for both classic and modern APIs. Additionally, it adds a configuration option to control hardware video decoding.
Video Texture Support and Resource Management
LoadVideotoResourcePool, allowing video textures to be loaded and managed similarly to images, with support for custom options. [1] [2]Video.hppandVideo.cppto the engine sources and relevant includes throughout the resource and binding code. [1] [2] [3] [4]Lua API Enhancements for Video
lstg.LoadVideo,lstg.VideoSeek,lstg.VideoSetLooping,lstg.VideoSetLoopRange,lstg.VideoUpdate,lstg.VideoGetInfo,lstg.VideoGetVideoStreams,lstg.VideoGetAudioStreams, andlstg.VideoReopen. These allow for fine-grained playback and information control from scripts. [1] [2] [3]Modern API and Object-Oriented Bindings
Videoclass binding for the modern object-oriented Lua API, with methods for creation, property access, and registration. [1] [2]video_example_modern.lua) demonstrating object-oriented video playback and rendering.Debug and UI Improvements
Configuration
disable_hardware_video_decodeto the graphics system, controllable via config file or command-line, to allow disabling hardware video decoding if needed. [1] [2]Examples
video_example.luafor classic API usage andvideo_example_modern.luafor the modern object-oriented API, demonstrating video loading, playback, and control. [1] [2]This pull request introduces video texture support to the engine, enabling videos to be loaded and controlled as textures in the resource system. The changes span the engine’s graphics layer, Lua bindings, and resource management, providing both API and implementation for video playback and control. The most important changes are grouped below.Video Texture and Decoder Implementation
VideoTextureandVideoDecoderclasses to support loading, decoding, and rendering video files as textures. This includes new interfaces (IVideoDecoder) and their Direct3D 11 implementations, as well as integration with the graphics device and resource management systems. ([1], [2], [3], [4])IGraphicsDevice) and its D3D11 implementation to create video textures and decoders, and linked Media Foundation libraries for video support. ([1], [2], [3])Resource Manager and Lua Binding Enhancements
LoadVideomethod to the resource manager, allowing videos to be loaded into the texture pool and accessed like regular textures. ([1], [2])Example and Documentation
video_example.lua) demonstrating video playback, manual update with a stopwatch, and available control functions. This serves as documentation for the new video API. (data/example/video_example.luaR1-R26)These changes collectively enable video playback as textures, with full control and integration into the engine’s resource and scripting systems.