Skip to content

Commit

Permalink
[Text] Use FramebufferLayout as surface cache key
Browse files Browse the repository at this point in the history
  • Loading branch information
hyazinthh committed Aug 6, 2024
1 parent 6adc5ff commit 92da4f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
4 changes: 0 additions & 4 deletions src/Aardvark.Rendering.GL/Runtime/Runtime.fs
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,7 @@ type Runtime(debug : IDebugConfig) =
member x.PrepareBuffer (b : IBuffer, [<Optional; DefaultParameterValue(BufferStorage.Device)>] storage : BufferStorage) = ctx.CreateBuffer(b, storage)
member x.PrepareEffect (signature : IFramebufferSignature, effect : FShade.Effect, topology : IndexedGeometryMode) : IBackendSurface =
Operators.using ctx.ResourceLock (fun d ->
if signature.LayerCount > 1 then
Log.warn("[PrepareSurface] Using Triangle topology.")

let _, program = ctx.CreateProgram(signature, Surface.Effect effect, topology)

AVal.force program :> IBackendSurface
)

Expand Down
12 changes: 6 additions & 6 deletions src/Aardvark.Rendering.Text/Font.fs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ type ShapeCache(r : IRuntime) =
let ranges = ConcurrentDictionary<Shape, Range1i>()


let surfaceCache = ConcurrentDictionary<IFramebufferSignature, Lazy<IBackendSurface>>()
let boundarySurfaceCache = ConcurrentDictionary<IFramebufferSignature, Lazy<IBackendSurface>>()
let billboardSurfaceCache = ConcurrentDictionary<IFramebufferSignature, Lazy<IBackendSurface>>()
let surfaceCache = ConcurrentDictionary<FramebufferLayout, Lazy<IBackendSurface>>()
let boundarySurfaceCache = ConcurrentDictionary<FramebufferLayout, Lazy<IBackendSurface>>()
let billboardSurfaceCache = ConcurrentDictionary<FramebufferLayout, Lazy<IBackendSurface>>()


let pathShader =
Expand Down Expand Up @@ -154,7 +154,7 @@ type ShapeCache(r : IRuntime) =
]

let surface (s : IFramebufferSignature) =
surfaceCache.GetOrAdd(s, fun s ->
surfaceCache.GetOrAdd(s.Layout, fun _ ->
lazy (
r.PrepareEffect(
s, [
Expand All @@ -166,7 +166,7 @@ type ShapeCache(r : IRuntime) =
).Value

let boundarySurface (s : IFramebufferSignature) =
boundarySurfaceCache.GetOrAdd(s, fun s ->
boundarySurfaceCache.GetOrAdd(s.Layout, fun _ ->
lazy (
r.PrepareEffect(
s, [
Expand All @@ -178,7 +178,7 @@ type ShapeCache(r : IRuntime) =
).Value

let billboardSurface (s : IFramebufferSignature) =
billboardSurfaceCache.GetOrAdd(s, fun s ->
billboardSurfaceCache.GetOrAdd(s.Layout, fun _ ->
lazy (
r.PrepareEffect(
s, [
Expand Down

0 comments on commit 92da4f3

Please sign in to comment.