Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .sdk-revision
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d53a65890222868d2329792569770b2294cd828e
82335d3971d3d98a4f85d2993809c272a4b7b108
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<DndBuildNative Condition="'$(DndBuildNative)' == ''">false</DndBuildNative>
<IsPackable>false</IsPackable>
<DolphinDotNetPackageVersion>0.1.0-preview.328.1</DolphinDotNetPackageVersion>
<DolphinDotNetPackageVersion>0.1.0-preview.372.1</DolphinDotNetPackageVersion>
<HypercubeNativePasses Condition="'$(HypercubeNativePasses)' == ''">true</HypercubeNativePasses>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Experimental GameCube engine built on [DolphinDotNet](https://github.com/capz/Do
[Indexed mesh caching](docs/indexed-mesh-cache.md) retains exact native geometry
prefixes for stable assets and shares terrain vertices without capacity padding.

[Full-resolution hardware AA](docs/full-resolution-aa.md) replays prepared scenes
through `FrameRenderer` without a frame-sized recording buffer.

Open **Hypercube.sln** for the engine, runtime adapter, host checks and console validation sample. The existing DolphinDotNet texture stress/comparison samples remain in the SDK repository.

## Build
Expand Down
17 changes: 17 additions & 0 deletions docs/full-resolution-aa.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Full-resolution GameCube AA

Set `DisplayOptions.AntialiasingMode` to `AntialiasingMode.FullResolution`
for 640×480 output. Implement `IFrameScene.SubmitFramePart` and pass the prepared
scene to `FrameRenderer.Draw`. It submits once with AA off and twice with full AA.

Update simulation, animation, visibility and resource residency **before** Draw.
Submission may reset and refill bounded draw batches, but must not advance time,
load/release assets, change display mode or consume input. Render world and HUD
inside the callback. Capture water/refraction within each part, then draw it.
The SDK crops perspective, orthographic and 2D projections and maps scissors.

Full AA uses hardware three-sample RGB565/Z16, without destination alpha.
It retains 640×480 logical resolution and the existing double XFB allocation;
there is no extra full-screen AA texture. Submission/geometry work repeats and
resolve copies cost bandwidth. Applications should offer a persisted off/on
option and measure their own scenes. This is independent of emulator host MSAA.
24 changes: 24 additions & 0 deletions src/Hypercube.GameCube/FrameRenderer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Dolphin.Graphics;
namespace Hypercube.GameCube;

/// <summary>A prepared scene whose drawing can be replayed without updating
/// simulation, animation, input or resource ownership.</summary>
public interface IFrameScene
{
void SubmitFramePart();
}

/// <summary>Owns one logical frame. Full-resolution GX AA submits the prepared
/// scene twice, resolving overlapping EFB bands into the existing XFB pair.
/// No display-list recording, frame-sized allocation or per-frame delegate.</summary>
public static class FrameRenderer
{
public static void Draw(GraphicsDevice device,Color32 clear,IFrameScene scene)
{
if(device==null)throw new ArgumentNullException(nameof(device));
if(scene==null)throw new ArgumentNullException(nameof(scene));
device.BeginFrame(clear);
do{scene.SubmitFramePart();}while(device.NextFramePart());
device.EndFrame();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<PropertyGroup><OutputType>Exe</OutputType>
<DefineConstants Condition="'$(HypercubeNativePasses)' == 'true'">$(DefineConstants);HYPERCUBE_NATIVE_PASSES</DefineConstants>
</PropertyGroup>
<ItemGroup><Compile Include="../../src/Hypercube.GameCube/OrderedMeshPasses.cs" Link="OrderedMeshPasses.cs" /></ItemGroup>
<ItemGroup><Compile Include="../../src/Hypercube.GameCube/OrderedMeshPasses.cs" Link="OrderedMeshPasses.cs" /><Compile Include="../../src/Hypercube.GameCube/FrameRenderer.cs" Link="FrameRenderer.cs" /></ItemGroup>
</Project>
26 changes: 24 additions & 2 deletions tests/OrderedMeshPasses.Tests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,23 @@ static class Program
{
static void Check(bool b){if(!b)throw new Exception("Pass contract failed");}
static void Reject(Action a){try{a();}catch(ArgumentException){return;}catch(InvalidOperationException){return;}throw new Exception("Expected rejection");}
static void Main(){
private sealed class PreparedScene:IFrameScene {
internal int Calls;internal int Snapshot=17;
public void SubmitFramePart(){if(!GraphicsDevice.Default.IsFrameActive||Snapshot!=17)throw new Exception("Unprepared scene");Calls++;}
}
static void Frames(){
var d=GraphicsDevice.Default;var scene=new PreparedScene();
foreach(int parts in new[]{1,2}){
d.Parts=parts;d.Begins=d.Presents=scene.Calls=0;
FrameRenderer.Draw(d,Color32.White,scene);
Check(d.Begins==1&&d.Presents==1&&scene.Calls==parts&&!d.IsFrameActive);
long before=GC.GetAllocatedBytesForCurrentThread();
for(int n=0;n<1000;n++)FrameRenderer.Draw(d,Color32.White,scene);
Check(GC.GetAllocatedBytesForCurrentThread()==before);
}
Console.WriteLine("Prepared frame replay: single presentation, one/two scene submissions and zero allocations passed.");
}
static void Main(){Frames();
var mesh=new Mesh();Reject(()=>new OrderedMeshPasses(mesh,0));Reject(()=>new OrderedMeshPasses(mesh,257));
var p=new OrderedMeshPasses(mesh,3);var m=new Material{Texture=new Texture2D(),Color=new Color32(9),TextureTransform=new UvTransform(9)};var r=new Renderer();var t=new Transform();
for(int i=0;i<3;i++)p.Set(i,new Color32(i),new UvTransform(i));
Expand Down Expand Up @@ -32,7 +48,13 @@ public sealed class MeshPasses{
public enum LightingMode{Unlit,Diffuse}public enum TextureCoordinateMode{Uv0,ViewNormal}
public readonly struct Color32{public readonly int Value;public Color32(int v){Value=v;}public static Color32 White=>new(255);}
public readonly struct UvTransform{public readonly int Value;public UvTransform(int v){Value=v;}}
public sealed class GraphicsDevice{public static readonly GraphicsDevice Default=new();public bool IsFrameActive;}
public sealed class GraphicsDevice{
public static readonly GraphicsDevice Default=new();public bool IsFrameActive;
public int Parts=1,Begins,Presents,Part;
public void BeginFrame(Color32 clear){if(IsFrameActive)throw new InvalidOperationException();IsFrameActive=true;Part=0;Begins++;}
public bool NextFramePart(){if(!IsFrameActive)throw new InvalidOperationException();return ++Part<Parts;}
public void EndFrame(){if(!IsFrameActive||Part!=Parts)throw new InvalidOperationException();IsFrameActive=false;Presents++;}
}
public readonly struct SamplerState{}
public sealed class Material{
public Texture2D? Texture,SecondaryTexture;public object? Effect;public LightingMode Lighting;public TextureCoordinateMode TextureCoordinates;public Color32 Color;
Expand Down
Loading