aboutsummaryrefslogtreecommitdiff
path: root/src/Engine/Engine.h
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-08-18 15:00:34 +0200
committerhachem <im@hachem.wtf>2026-08-18 15:00:34 +0200
commitdfe9da43dab6c933bc1024f992383f08e01386de (patch)
tree8f52e80e0b2a65eaacdbf5fa056721e7fa4e9fa5 /src/Engine/Engine.h
parent86df8b19063f73b7803daaa1e5b21da33ac976ed (diff)
[fix]: macos compatibility
Diffstat (limited to 'src/Engine/Engine.h')
-rw-r--r--src/Engine/Engine.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/Engine/Engine.h b/src/Engine/Engine.h
index c3cfdd0..f8ef628 100644
--- a/src/Engine/Engine.h
+++ b/src/Engine/Engine.h
@@ -89,7 +89,16 @@ namespace Donut
void SetTargetFPS(int fps) { m_TargetFPS = fps; }
int GetTargetFPS() const { return m_TargetFPS; }
float GetCurrentFPS() const { return m_CurrentFPS; }
- void SetComputeHeight(int height) { m_ComputeHeight = height; }
+ void SetComputeHeight(int height)
+ {
+#ifdef __APPLE__
+ // Without compute shaders the geodesic pass runs as a tiled
+ // fragment shader (see DrawGeodesicPass), so very high working
+ // resolutions make each frame take many seconds. Cap it on macOS.
+ if (height > 256) height = 256;
+#endif
+ m_ComputeHeight = height;
+ }
int GetComputeHeight() const { return m_ComputeHeight; }
int GetComputeWidth() const { return (m_Width * m_ComputeHeight) / m_Height; }
void UpdateComputeDimensions();
@@ -125,6 +134,11 @@ namespace Donut
private:
Ref<Shader> CreateComputeProgram(const char* path);
std::pair<Ref<VertexArray>, Ref<Texture2D>> QuadVAO();
+
+ // Draws the bound geodesic shader over a cw x ch target. On macOS this
+ // is split into scissored tiles (with a flush each) so no single GPU
+ // submission trips the OS watchdog; elsewhere it is one fast draw.
+ void DrawGeodesicPass(int cw, int ch);
private:
Ref<VertexArray> m_QuadVAO;
Ref<Texture2D> m_Texture;
@@ -137,6 +151,11 @@ namespace Donut
Ref<UniformBuffer> m_ObjectsUBO;
Ref<UniformBuffer> m_SimulationUBO;
+ // FBO used to render the geodesic pass into m_Texture. The geodesic
+ // shader is a fragment shader (macOS has no compute), so it draws a
+ // fullscreen quad into this framebuffer instead of dispatching compute.
+ uint32_t m_GeodesicFBO = 0;
+
int m_Width;
int m_Height;
float m_Width_f = 100.0f*1e10f;