noradninja

cGPT GXM context convo

Jul 20th, 2026
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.96 KB | None | 0 0
  1. Yes—but it would be closer to a Vita-specific API trace recorder than RenderDoc. A useful first version is feasible, especially for your own Unity Vita build, but complete GPU-state capture and accurate per-draw GPU timing would be substantially harder.
  2.  
  3. What is realistically possible
  4.  
  5. A taiHEN user plugin could be loaded into the game process and hook the exported SceGxm functions used by Unity. taiHEN explicitly supports function replacement and hooks inside applications and system modules.
  6.  
  7. The plugin could watch calls such as:
  8.  
  9. * sceGxmBeginScene / sceGxmEndScene
  10. * sceGxmDraw and sceGxmDrawPrecomputed
  11. * sceGxmSetVertexProgram
  12. * sceGxmSetFragmentProgram
  13. * texture bindings
  14. * vertex and index stream bindings
  15. * uniform-buffer reservations and updates
  16. * blend, depth, stencil, culling and viewport state
  17. * render-target and depth-surface selection
  18. * display-queue submission
  19.  
  20. The public VitaSDK headers expose a large portion of this GXM API, including draw calls, shader selection, render state, texture formats and surface layouts.
  21.  
  22. On a requested frame, the recorder would serialize the state seen at every draw into a capture file:
  23.  
  24. Frame
  25. ├── Render target information
  26. ├── Depth/stencil information
  27. ├── Draw 0
  28. │ ├── vertex program
  29. │ ├── fragment program
  30. │ ├── textures
  31. │ ├── vertex/index buffers
  32. │ ├── uniforms
  33. │ ├── render state
  34. │ └── primitive and index count
  35. ├── Draw 1
  36. └── ...
  37.  
  38. A PC viewer could then present a draw-call timeline and aggregate useful statistics.
  39.  
  40. What you could obtain reliably
  41.  
  42. A first-generation tool could give us:
  43.  
  44. Information Feasibility
  45. Final displayed color buffer High
  46. Draw-call count High
  47. Triangle/index count High
  48. Shader/program changes High
  49. Texture binding changes High
  50. Render-target changes High
  51. Blend/depth/cull state High
  52. Texture dimensions and formats High
  53. Vertex/index-buffer sizes Medium–high
  54. Uniform data at each draw Medium–high
  55. Estimated texture and buffer bandwidth Medium
  56. CPU time spent submitting each draw High
  57. Total frame GPU completion time Medium–high
  58. Exact GPU duration per draw Low
  59. Hardware utilization counters Unknown/low
  60. Fragment count or overdraw directly from GPU Low
  61. Perfect standalone replay on a PC Very low
  62.  
  63. This alone would be valuable for your project. It could answer questions such as:
  64.  
  65. * Which shader produced the most draws?
  66. * How many triangles were submitted for each pass?
  67. * How often did textures, shaders or blend states change?
  68. * How much texture data was potentially sampled?
  69. * Which draws used alpha test or blending?
  70. * Which render targets were active?
  71. * How many objects were rendered more than once?
  72. * How much CPU time was spent inside GXM submission?
  73. * Which frame stages were separated by BeginScene, EndScene, flushes or synchronization?
  74.  
  75. The important limitation: GXM is tile-based
  76.  
  77. The Vita’s SGX543MP4+ is a PowerVR tile-based renderer. The framebuffer after an individual sceGxmDraw call is not necessarily sitting in memory as a completed image. Much of the fragment work may remain deferred until the tile is processed or the scene ends.
  78.  
  79. Consequently, hooking this sequence:
  80.  
  81. sceGxmDraw(...);
  82. copyFramebuffer();
  83.  
  84. would not reliably produce the visual result “after that draw.”
  85.  
  86. That is one of the largest differences from a desktop immediate-mode frame debugger.
  87.  
  88. To inspect individual draw output, we would need one of these approaches:
  89.  
  90. 1. Capture and replay the frame one draw at a time.
  91. Record every call and resource, then replay draw 0, draws 0–1, draws 0–2, and so forth into a diagnostic render target.
  92. 2. Recapture the same deterministic frame repeatedly.
  93. On capture pass 1, stop after draw 1; on pass 2, stop after draw 2; and so on.
  94. 3. Instrument the game itself.
  95. Unity-side code supplies object, material, pass and camera names while the native plugin captures the lower-level GXM activity.
  96.  
  97. The third option would be particularly effective for your project.
  98.  
  99. “Attach” versus loading a plugin
  100.  
  101. Attaching to an already-running process after it has started is more difficult and unnecessary for the initial implementation.
  102.  
  103. The cleaner design is:
  104.  
  105. taiHEN loads FrameCapture.suprx with the game
  106. ↓
  107. plugin installs GXM hooks
  108. ↓
  109. game runs normally with capture disabled
  110. ↓
  111. button combination or network command arms capture
  112. ↓
  113. next complete frame is recorded
  114. ↓
  115. capture is written or sent to PC
  116.  
  117. The plugin remains mostly dormant until capture is requested. That avoids needing a conventional debugger-style process attachment mechanism.
  118.  
  119. It could be controlled by:
  120.  
  121. * a Vita button combination;
  122. * a small TCP command from the PC;
  123. * a file placed in a known directory;
  124. * a Unity FrameCapture.Trigger() native-plugin call.
  125.  
  126. For development, I would use both a Unity call and a button fallback.
  127.  
  128. How I would design it
  129.  
  130. Vita component
  131.  
  132. A user-mode taiHEN plugin:
  133.  
  134. vita-framecapture.suprx
  135.  
  136. Responsibilities:
  137.  
  138. * Hook GXM entry points.
  139. * Maintain a shadow copy of the current GXM state.
  140. * Assign stable IDs to programs, textures, buffers and surfaces.
  141. * Start a frame at sceGxmBeginScene.
  142. * Emit a draw record at each sceGxmDraw.
  143. * Finish capture at sceGxmEndScene or display submission.
  144. * Wait for GPU completion before copying final surfaces.
  145. * Write a binary capture to ux0:data/framecapture/.
  146. * Optionally stream captures over TCP.
  147.  
  148. sceGxmFinish is documented as blocking CPU execution until the GPU has completed rendering, so it can provide a reliable synchronization point for an explicitly requested capture, although it would intentionally stall that frame.
  149.  
  150. PC component
  151.  
  152. A desktop application that reads the capture and provides:
  153.  
  154. * event browser;
  155. * per-draw state;
  156. * texture viewer;
  157. * vertex/index statistics;
  158. * shader/program grouping;
  159. * render-pass grouping;
  160. * state-change analysis;
  161. * estimated bandwidth;
  162. * final color-buffer viewer;
  163. * export to CSV or JSON.
  164.  
  165. Initially, this could be a C# desktop application because the difficult part is the Vita plugin, not the viewer.
  166.  
  167. Unity integration
  168.  
  169. For your Unity project, a managed component could add semantic metadata:
  170.  
  171. VitaFrameCapture.BeginMarker("Camera.Main");
  172. VitaFrameCapture.BeginMarker("Building Exterior");
  173. VitaFrameCapture.SetObjectInfo(
  174. renderer.GetInstanceID(),
  175. renderer.name,
  176. material.name,
  177. shader.name);
  178. Graphics.DrawMesh(...);
  179. VitaFrameCapture.EndMarker();
  180.  
  181. GXM itself exposes user-marker functions such as sceGxmPushUserMarker, sceGxmPopUserMarker and sceGxmSetUserMarker.
  182.  
  183. Unity may not emit those automatically, but we can introduce markers around your custom managers, shadow pass, camera stages and important render groups. That would turn anonymous GXM draws into something much more understandable:
  184.  
  185. Camera.Main
  186. ShadowMap.PlayerSpotlight
  187. Building_17_Walls
  188. Building_17_Trim
  189. ForwardBase.Opaque
  190. Road_Section_04
  191. Building_17_Walls
  192. AlphaTest
  193. Tree_03_Leaves
  194. GrassShell_04
  195. Transparent
  196. Puddle_02
  197.  
  198. GPU timing
  199.  
  200. This is where expectations need to be controlled.
  201.  
  202. Feasible
  203.  
  204. We can measure:
  205.  
  206. * total CPU frame duration;
  207. * CPU time spent in each hooked function;
  208. * CPU submission duration;
  209. * time between end-of-scene and completed GPU synchronization;
  210. * total synchronized GPU workload for the frame;
  211. * the cost difference between two captures with selected draws disabled.
  212.  
  213. Probably not feasible initially
  214.  
  215. Without access to undocumented PowerVR performance counters or Sony’s official development profiling interfaces, we probably cannot directly report:
  216.  
  217. Draw 128: vertex stage 34 µs
  218. Draw 128: fragment stage 241 µs
  219. Draw 128: 38,200 shader invocations
  220. Draw 128: 82% texture-unit utilization
  221.  
  222. A useful substitute is differential timing:
  223.  
  224. 1. Capture a repeatable frame.
  225. 2. Measure its total GPU-completion time.
  226. 3. Disable a draw group.
  227. 4. Measure it again.
  228. 5. Attribute the difference approximately to that group.
  229.  
  230. For your project, grouping by shader, building section, alpha-tested grass, trees, shadows and transparency would make this surprisingly useful.
  231.  
  232. Resource capture complications
  233.  
  234. A draw record contains pointers to resources, not necessarily self-contained assets. During capture we would need to determine the allocations behind:
  235.  
  236. * textures;
  237. * vertex buffers;
  238. * index buffers;
  239. * uniform buffers;
  240. * shader programs;
  241. * render targets.
  242.  
  243. The most robust approach is to hook resource creation and mapping functions from process startup, rather than trying to discover everything only when the capture button is pressed.
  244.  
  245. That allows the plugin to build a registry:
  246.  
  247. GPU address → allocation ID, CPU address, size, type and format
  248.  
  249. When capture begins, resources referenced by the captured frame can then be copied into the capture file.
  250.  
  251. Without this registry, we could still collect draw statistics, but standalone resource inspection and replay would be unreliable.
  252.  
  253. Recommended development stages
  254.  
  255. Stage 1: frame event analyzer
  256.  
  257. Capture only:
  258.  
  259. * begin/end scene;
  260. * draw calls;
  261. * primitive type;
  262. * index count;
  263. * active shader pointers;
  264. * textures and state pointers;
  265. * render-state changes;
  266. * CPU timestamps;
  267. * final screenshot.
  268.  
  269. This would already expose draw count, approximate triangles, state churn and pass structure.
  270.  
  271. Stage 2: resource descriptions
  272.  
  273. Track:
  274.  
  275. * texture format, dimensions, mip count and memory location;
  276. * vertex/index allocation sizes;
  277. * render-target formats;
  278. * depth formats;
  279. * shader program identifiers;
  280. * memory estimates.
  281.  
  282. Stage 3: resource snapshots
  283.  
  284. Copy:
  285.  
  286. * textures;
  287. * vertex data;
  288. * indices;
  289. * uniforms;
  290. * final color and depth surfaces where readable.
  291.  
  292. Stage 4: Unity-assisted labels
  293.  
  294. Add object, material, shader, pass and LOD metadata from your Unity code.
  295.  
  296. Stage 5: diagnostic replay
  297.  
  298. Replay captured commands on the Vita itself, initially only for:
  299.  
  300. * draw suppression;
  301. * wireframe substitutions;
  302. * texture replacement;
  303. * overdraw visualization;
  304. * shader-cost grouping;
  305. * cumulative draw output.
  306.  
  307. A full desktop replay backend should not be the initial objective. Vita GXM shader binaries and hardware behavior do not map directly onto desktop graphics APIs.
  308.  
  309. My overall assessment
  310.  
  311. A tool that captures everything Sony’s official GPU debugger would have exposed is probably unrealistic without proprietary SDK/debug interfaces and substantial reverse engineering.
  312.  
  313. A tool that captures:
  314.  
  315. * frame structure;
  316. * all GXM draw calls;
  317. * pipeline state;
  318. * resources;
  319. * final framebuffer;
  320. * Unity object labels;
  321. * approximate memory and bandwidth costs;
  322. * total and differential GPU timing;
  323.  
  324. is absolutely plausible.
  325.  
  326. For your Vita project, that narrower tool could still be extremely useful. In fact, because we control the Unity-side code, a hybrid Unity instrumentation + native GXM hook system would likely provide more actionable information than attempting a completely generic black-box debugger.
Advertisement
Add Comment
Please, Sign In to add comment