-
Notifications
You must be signed in to change notification settings - Fork 3
Implement toJson() methods for command buffer classes and enhance JSAR vGPU Profiler integration #146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
yorkie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each commandbuffer JSON structure should be:
- id
- type
- typeName
- ...
- parameters: the params to the gles call,
- context: extra context info such current program, vao, etc..
And at the profiler page, we can add parameters to the template to render each commandbuffer, and when user clicks the specific commandbuffer, it could shows the detailed information (show context, view texture data, etc...) in a right sidebar.
…ntext structure Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Updated the JSON structure as requested in commit 207fc67. Each command buffer now uses:
Example new structure: {
"id": 12345,
"type": 42,
"typeName": "COMMAND_BUFFER_DRAW_ARRAYS_REQ",
"parameters": {
"mode": 4,
"first": 0,
"count": 6
},
"context": {
"contextId": 13,
"xrRenderingInfo": {...}
}
}This structure will make it easy to add current program, VAO, and other GPU state information to the context object, and the parameters can be used for rendering each command buffer in the profiler template. |
src/common/command_buffers/base.hpp
Outdated
| cmdInfo.AddMember("typeName", rapidjson::Value().SetString(typeName.c_str(), allocator), allocator); | ||
|
|
||
| // Create empty parameters object - derived classes will populate this | ||
| rapidjson::Value parameters(rapidjson::kObjectType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameters should be an array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to use array structure for parameters as requested in commit 4822dc2. All command buffer classes now use parameters.PushBack() instead of parameters.AddMember(), creating ordered arrays that match OpenGL function signatures (e.g., glDrawArrays(mode, first, count) → [mode, first, count]).
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
yorkie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now you can add these features to the profiler tool page (at fixtures/inspector-client/):
- Show parameters in the command buffer item
- Click command buffer item will show its detailed on right sidebar
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Implemented both features in commit 5e12361:
The UI now provides full GPU command analysis capabilities for debugging and optimization. |

This PR implements detailed
toJson()methods for critical command buffer classes to enable comprehensive GPU command profiling and debugging through the JSAR vGPU Profiler.Changes Made
🎯 Core Implementation
TrCommandBufferBase::toJson()with comprehensive documentation explaining JSON structure and usage patterns for derived classestoJson()overrides for all critical command buffer categories:📊 Command Buffer Categories Implemented
Buffer Operations
CreateBufferCommandBufferRequest- Buffer creation with client ID trackingDeleteBufferCommandBufferRequest- Buffer deletion with resource IDBindBufferCommandBufferRequest- Buffer binding with target enum decodingBufferDataCommandBufferRequest- Buffer data upload with size and usage patternsBufferSubDataCommandBufferRequest- Buffer sub-data updates with offset trackingDraw Commands (Critical for GPU profiling)
DrawArraysCommandBufferRequest- Basic draw calls with primitive countsDrawArraysInstancedCommandBufferRequest- Instanced rendering with total primitive calculationsDrawElementsCommandBufferRequest- Indexed drawing with mode name decodingClear Operations
ClearCommandBufferRequest- Clear operations with buffer mask decoding (COLOR_BUFFER_BIT, DEPTH_BUFFER_BIT, STENCIL_BUFFER_BIT)ClearColorCommandBufferRequest- Clear color with RGBA values and hex representationFramebuffer Operations
CreateFramebufferCommandBufferRequest- Framebuffer creation trackingBindFramebufferCommandBufferRequest- Framebuffer binding with default framebuffer detectionTexture Operations
CreateTextureCommandBufferRequest- Texture resource creationDeleteTextureCommandBufferRequest- Texture resource cleanupShader Pipeline
AttachShaderCommandBufferRequest- Shader attachment for program linkingCreateProgramCommandBufferRequest- Shader program creationState Management
SetViewportCommandBufferRequest- Viewport setup with aspect ratio calculationSetScissorCommandBufferRequest- Scissor test configuration with area computationUniforms
UniformBlockBindingCommandBufferRequest- Uniform block binding for shader data🔧 Rich Data Structure
Each
toJson()implementation provides:Example JSON output for a draw call:
{ "id": 12345, "contextId": 13, "type": 42, "typeName": "COMMAND_BUFFER_DRAW_ARRAYS_REQ", "drawDetails": { "mode": 4, "first": 0, "count": 6, "operation": "drawArrays", "primitiveCount": 6 } }🖥️ JSAR vGPU Profiler Integration
The JSAR vGPU Profiler was already integrated and calling
toJson()methods. This implementation enhances the existing infrastructure:The profiler provides:
📝 Documentation
toJson()method explaining structure🔮 Future Extensions
The established pattern makes it straightforward to implement
toJson()for the remaining command buffer classes. The base class documentation provides clear guidelines for maintaining consistency.Testing
cdp_jsar_universal_rendering_server_domain.cppFixes #145.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.