Skip to content

Commit

Permalink
Merge branch 'master' into v55
Browse files Browse the repository at this point in the history
  • Loading branch information
hyazinthh committed Jul 8, 2024
2 parents 5f7d812 + d938b5e commit a8fb504
Show file tree
Hide file tree
Showing 16 changed files with 261 additions and 174 deletions.
9 changes: 9 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
- [Vulkan] Removed unused `Pipeline` type
- [Vulkan] Removed `TextureFormat.ofGLSLType`

### 5.4.11
- [Application.WPF.GL] SharingRenderControl implementation now uses Silk.NET.Direct3D9 instead of SharpDX
- Removed SharpDX dependency
- Re-added dynamic shader caches
- Fixed multi-threading issue in PrimitiveValueConverter
- [Sg] Use single value attributes for IndexedGeometry
- [IndexedGeometry] Fixed Union() and added ToIndexed() overload
- [IndexedGeometry] Added overload Clone() for deep copy

### 5.4.10
- [OpenVR] changed GL texture submit to 2 textures (previously side by side, issue with Quest 3)
- [GL] Improved querying of supported sample counts
Expand Down
2 changes: 1 addition & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ nuget CommonMark.NET ~> 0.15.1
nuget GLSLangSharp ~> 0.4.14

nuget Unofficial.LibTessDotNet ~> 2.0.2
nuget SharpDX.Direct3D9 ~> 4.0.1
nuget AssimpNet ~> 5.0.0-beta1
nuget Offler ~> 2.0.3
nuget FSharp.Data ~> 4.2.10
Expand All @@ -41,6 +40,7 @@ nuget Unofficial.OpenTK ~> 3.0.21
nuget Unofficial.OpenTK.GLControl ~> 3.0.21
nuget Silk.NET.GLFW = 2.15.0
nuget Silk.NET.Core = 2.15.0
nuget Silk.NET.Direct3D9 = 2.15.0

nuget SharpZipLib ~> 1.4.1

Expand Down
33 changes: 14 additions & 19 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,12 @@ NUGET
System.Runtime.InteropServices.RuntimeInformation (>= 4.3) - restriction: || (== net471) (&& (== net6.0) (>= net461)) (&& (== net6.0-windows7.0) (>= net461)) (&& (== netstandard2.0) (>= net461))
System.Text.Encodings.Web (>= 6.0)
System.Text.Json (>= 6.0)
Microsoft.NETCore.App (2.2.8) - restriction: || (&& (== net471) (>= netcoreapp1.0)) (== net6.0) (== net6.0-windows7.0) (&& (== netstandard2.0) (>= netcoreapp1.0))
Microsoft.NETCore.DotNetHostPolicy (>= 2.2.8) - restriction: || (&& (== net471) (>= netcoreapp2.2)) (== net6.0) (== net6.0-windows7.0) (&& (== netstandard2.0) (>= netcoreapp2.2))
Microsoft.NETCore.Platforms (>= 2.2.4) - restriction: || (&& (== net471) (>= netcoreapp2.2)) (== net6.0) (== net6.0-windows7.0) (&& (== netstandard2.0) (>= netcoreapp2.2))
Microsoft.NETCore.Targets (>= 2.0) - restriction: || (&& (== net471) (>= netcoreapp2.2)) (== net6.0) (== net6.0-windows7.0) (&& (== netstandard2.0) (>= netcoreapp2.2))
NETStandard.Library (>= 2.0.3) - restriction: || (&& (== net471) (>= netcoreapp2.2)) (== net6.0) (== net6.0-windows7.0) (&& (== netstandard2.0) (>= netcoreapp2.2))
Microsoft.NETCore.DotNetAppHost (6.0.5) - restriction: || (&& (== net471) (>= netcoreapp2.2)) (== net6.0) (== net6.0-windows7.0) (&& (== netstandard2.0) (>= netcoreapp2.2))
Microsoft.NETCore.DotNetHostPolicy (6.0.5) - restriction: || (&& (== net471) (>= netcoreapp2.2)) (== net6.0) (== net6.0-windows7.0) (&& (== netstandard2.0) (>= netcoreapp2.2))
Microsoft.NETCore.DotNetHostResolver (>= 6.0.5)
Microsoft.NETCore.DotNetHostResolver (6.0.5) - restriction: || (&& (== net471) (>= netcoreapp2.2)) (== net6.0) (== net6.0-windows7.0) (&& (== netstandard2.0) (>= netcoreapp2.2))
Microsoft.NETCore.DotNetAppHost (>= 6.0.5)
Microsoft.NETCore.Platforms (6.0.3) - restriction: || (&& (== net471) (< net45)) (&& (== net471) (>= netcoreapp2.2)) (== net6.0) (== net6.0-windows7.0) (== netstandard2.0)
Microsoft.NETCore.Targets (5.0) - restriction: || (&& (== net471) (< net45)) (&& (== net471) (>= netcoreapp2.2)) (== net6.0) (== net6.0-windows7.0) (== netstandard2.0)
Microsoft.NETCore.Platforms (6.0.3) - restriction: || (&& (== net471) (< net45)) (== net6.0) (== net6.0-windows7.0) (== netstandard2.0)
Microsoft.NETCore.Targets (5.0) - restriction: || (&& (== net471) (< net45)) (== net6.0) (== net6.0-windows7.0) (== netstandard2.0)
Microsoft.NETFramework.ReferenceAssemblies (1.0)
Microsoft.NETFramework.ReferenceAssemblies.net471 (>= 1.0) - restriction: || (== net471) (&& (== net6.0) (>= net471)) (&& (== net6.0-windows7.0) (>= net471)) (&& (== netstandard2.0) (>= net471))
Microsoft.NETFramework.ReferenceAssemblies.net471 (1.0.2) - restriction: || (== net471) (&& (== net6.0) (>= net471)) (&& (== net6.0-windows7.0) (>= net471)) (&& (== netstandard2.0) (>= net471))
NETStandard.Library (2.0.3) - restriction: || (&& (== net471) (< net35)) (&& (== net471) (< net40)) (&& (== net471) (>= netcoreapp2.2)) (== net6.0) (== net6.0-windows7.0) (== netstandard2.0)
NETStandard.Library (2.0.3) - restriction: || (&& (== net471) (< net35)) (== net6.0) (== net6.0-windows7.0) (== netstandard2.0)
Microsoft.NETCore.Platforms (>= 1.1)
Newtonsoft.Json (13.0.1)
Offler (2.0.9)
Expand All @@ -152,12 +142,6 @@ NUGET
FSharp.Core (>= 4.7)
FSys (>= 0.0.1 < 0.1)
Newtonsoft.Json (>= 12.0.3)
SharpDX (4.2)
NETStandard.Library (>= 1.6.1) - restriction: || (&& (== net471) (< net40)) (== net6.0) (== net6.0-windows7.0) (== netstandard2.0)
SharpDX.Direct3D9 (4.0.1)
Microsoft.NETCore.App (>= 1.0.5) - restriction: || (&& (== net471) (>= netcoreapp1.0)) (== net6.0) (== net6.0-windows7.0) (&& (== netstandard2.0) (>= netcoreapp1.0))
NETStandard.Library (>= 1.6.1) - restriction: || (&& (== net471) (== net6.0)) (&& (== net471) (== net6.0-windows7.0)) (&& (== net471) (< net40)) (&& (== net6.0) (< netcoreapp1.0)) (&& (== net6.0-windows7.0) (< netcoreapp1.0)) (== netstandard2.0)
SharpDX (>= 4.0.1)
SharpZipLib (1.4.2)
System.Memory (>= 4.5.4) - restriction: || (== net471) (&& (== net6.0) (< netstandard2.1)) (&& (== net6.0-windows7.0) (< netstandard2.1)) (== netstandard2.0)
System.Threading.Tasks.Extensions (>= 4.5.2) - restriction: || (== net471) (&& (== net6.0) (< netstandard2.1)) (&& (== net6.0-windows7.0) (< netstandard2.1)) (== netstandard2.0)
Expand All @@ -169,9 +153,15 @@ NUGET
System.Memory (>= 4.5.4)
System.Numerics.Vectors (>= 4.5)
System.Runtime.CompilerServices.Unsafe (>= 6.0)
Silk.NET.Direct3D9 (2.15)
Silk.NET.Core (>= 2.15)
Silk.NET.Maths (>= 2.15)
Silk.NET.GLFW (2.15)
Silk.NET.Core (>= 2.15)
Ultz.Native.GLFW (>= 3.3.3.1)
Silk.NET.Maths (2.21)
Microsoft.Bcl.HashCode (>= 1.1.1) - restriction: || (== net471) (&& (== net6.0) (< netstandard2.1)) (&& (== net6.0-windows7.0) (< netstandard2.1)) (== netstandard2.0)
Ultz.Bcl.Half (>= 1.0) - restriction: || (== net471) (&& (== net6.0) (< net5.0)) (&& (== net6.0) (>= net6.0-android)) (&& (== net6.0) (>= net6.0-ios)) (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (< netstandard2.1)) (&& (== net6.0-windows7.0) (< net5.0)) (&& (== net6.0-windows7.0) (>= net6.0-android)) (&& (== net6.0-windows7.0) (>= net6.0-ios)) (&& (== net6.0-windows7.0) (< netcoreapp3.1)) (&& (== net6.0-windows7.0) (< netstandard2.1)) (== netstandard2.0)
SixLabors.ImageSharp (2.1.3)
System.Buffers (>= 4.5.1) - restriction: || (== net471) (&& (== net6.0) (>= net472)) (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0-windows7.0) (>= net472)) (&& (== net6.0-windows7.0) (< netcoreapp2.1)) (== netstandard2.0)
System.Memory (>= 4.5.4) - restriction: || (== net471) (&& (== net6.0) (>= net472)) (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0-windows7.0) (>= net472)) (&& (== net6.0-windows7.0) (< netcoreapp2.1)) (== netstandard2.0)
Expand Down Expand Up @@ -319,6 +309,11 @@ NUGET
System.Threading.Tasks.Extensions (4.5.4) - restriction: || (== net471) (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (< netstandard2.1)) (&& (== net6.0-windows7.0) (>= net461)) (&& (== net6.0-windows7.0) (< netcoreapp3.1)) (&& (== net6.0-windows7.0) (< netstandard2.1)) (== netstandard2.0)
System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (== net471) (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (< netstandard1.0)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= wp8)) (&& (== net6.0-windows7.0) (>= net461)) (&& (== net6.0-windows7.0) (< netcoreapp2.1)) (&& (== net6.0-windows7.0) (< netstandard1.0)) (&& (== net6.0-windows7.0) (< netstandard2.0)) (&& (== net6.0-windows7.0) (>= wp8)) (== netstandard2.0)
System.ValueTuple (4.5) - restriction: || (== net471) (&& (== net6.0) (>= net461)) (&& (== net6.0-windows7.0) (>= net461)) (&& (== netstandard2.0) (>= net461))
Ultz.Bcl.Half (1.0) - restriction: || (== net471) (&& (== net6.0) (< net5.0)) (&& (== net6.0) (>= net6.0-android)) (&& (== net6.0) (>= net6.0-ios)) (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (< netstandard2.1)) (&& (== net6.0-windows7.0) (< net5.0)) (&& (== net6.0-windows7.0) (>= net6.0-android)) (&& (== net6.0-windows7.0) (>= net6.0-ios)) (&& (== net6.0-windows7.0) (< netcoreapp3.1)) (&& (== net6.0-windows7.0) (< netstandard2.1)) (== netstandard2.0)
Ultz.Bcl.Half.Fallback (>= 1.0) - restriction: || (== net471) (&& (== net6.0) (< net5.0)) (&& (== net6.0-windows7.0) (< net5.0)) (== netstandard2.0)
Ultz.Bcl.Half.Fallback (1.0) - restriction: || (== net471) (&& (== net6.0) (< net5.0)) (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (< netstandard2.1)) (&& (== net6.0-windows7.0) (< net5.0)) (&& (== net6.0-windows7.0) (< netcoreapp3.1)) (&& (== net6.0-windows7.0) (< netstandard2.1)) (== netstandard2.0)
System.Memory (>= 4.5.4)
System.Runtime.CompilerServices.Unsafe (>= 4.7.1)
Ultz.Native.GLFW (3.3.3.1)
Unofficial.LibTessDotNet (2.0.2)
Unofficial.OpenTK (3.0.21)
Expand Down
12 changes: 6 additions & 6 deletions src/Aardvark.GPGPU/Primitives.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1133,23 +1133,23 @@ type private MapReduceImage<'b when 'b : unmanaged>(runtime : IComputeRuntime, r
member x.Dispose() = x.Dispose()

type private ExpressionCache() =
let store = System.Collections.Concurrent.ConcurrentDictionary<list<string>, obj>()
let store = System.Collections.Concurrent.ConcurrentDictionary<list<string>, Lazy<obj>>()

member x.GetOrCreate(e : Expr<'a>, create : Expr<'a> -> 'b) =
let hash = [ Expr.ComputeHash e ]
store.GetOrAdd(hash, fun _ ->
create e :> obj
) |> unbox<'b>
lazy (create e :> obj)
).Value |> unbox<'b>

member x.GetOrCreate(a : Expr<'a>, b : Expr<'b>, create : Expr<'a> -> Expr<'b> -> 'c) =
let hash = [ Expr.ComputeHash a; Expr.ComputeHash b ]
store.GetOrAdd(hash, fun _ ->
create a b :> obj
) |> unbox<'c>
lazy (create a b :> obj)
).Value |> unbox<'c>

member x.Dispose() =
for KeyValue(_, obj) in store do
match obj with
match obj.Value with
| :? IDisposable as d -> d.Dispose()
| _ -> ()

Expand Down
16 changes: 9 additions & 7 deletions src/Aardvark.Rendering.GL/Management/ResourceCache.fs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ type internal Resource<'Handle, 'View when 'View : unmanaged>(kind : ResourceKin
member x.Pointer = pointer

and internal ResourceCache<'Handle, 'View when 'View : unmanaged>(parent : Option<ResourceCache<'Handle, 'View>>, renderTaskLock : Option<RenderTaskLock>) =
let store = ConcurrentDictionary<list<obj>, Resource<'Handle, 'View>>()
let store = ConcurrentDictionary<list<obj>, Lazy<Resource<'Handle, 'View>>>()

static let handleNonPrimitive =
not typeof<'Handle>.IsPrimitive && not typeof<'Handle>.IsEnum
Expand Down Expand Up @@ -184,16 +184,18 @@ and internal ResourceCache<'Handle, 'View when 'View : unmanaged>(parent : Optio

member x.TryGet(key : list<obj>) =
match store.TryGetValue(key) with
| (true, v) -> Some v
| (true, v) -> Some v.Value
| _ -> None

member x.GetOrCreateLocal(key : list<obj>, create : unit -> Resource<'Handle, 'View>) =
let resource =
store.GetOrAdd(key, fun _ ->
let res = create()
res.OnDispose.Add(fun () -> store.TryRemove key |> ignore)
res
)
lazy (
let res = create()
res.OnDispose.Add(fun () -> store.TryRemove key |> ignore)
res
)
).Value
resource.AddRef()
resource :> IResource<_,_>

Expand Down Expand Up @@ -330,5 +332,5 @@ and internal ResourceCache<'Handle, 'View when 'View : unmanaged>(parent : Optio
let remaining = store |> Seq.map (fun (KeyValue(_,r)) -> r) |> Seq.toArray
for r in remaining do
Log.warn "leaking resource: %A" r
r.ForceDispose()
r.Value.ForceDispose()
store.Clear()
26 changes: 14 additions & 12 deletions src/Aardvark.Rendering.GL/Management/ResourceManager.fs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ type ResourceManager private (parent : Option<ResourceManager>, ctx : Context, r

let textureArrayCache =
UnaryCache<aval<ITexture[]>, _>(
fun _arr -> ConcurrentDictionary<int * TextureProperties, IResource<Texture, TextureBinding>[]>()
fun _arr -> ConcurrentDictionary<int * TextureProperties, Lazy<IResource<Texture, TextureBinding>[]>>()
)

let staticSamplerStateCache = ConcurrentDictionary<FShade.SamplerState, aval<SamplerState>>()
Expand Down Expand Up @@ -397,18 +397,20 @@ type ResourceManager private (parent : Option<ResourceManager>, ctx : Context, r
let properties = samplerType.Properties

innerCache.GetOrAdd((slotCount, properties), fun _ ->
Array.init slotCount (fun i ->
let arr =
textureArray |> AVal.map (fun t ->
if i < t.Length then
t.[i]
else
nullTexture
)

x.CreateTexture(arr, properties)
lazy (
Array.init slotCount (fun i ->
let arr =
textureArray |> AVal.map (fun t ->
if i < t.Length then
t.[i]
else
nullTexture
)

x.CreateTexture(arr, properties)
)
)
)
).Value

member x.CreateSampler (sam : aval<SamplerState>) =
samplerCache.GetOrCreate<SamplerState>(sam, fun () -> {
Expand Down
18 changes: 13 additions & 5 deletions src/Aardvark.Rendering.GL/Resources/Textures/TextureCopy.fs
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,27 @@ module internal TextureCopyUtilities =

[<AutoOpen>]
module private CopyDispatch =
open System.Collections.Concurrent

type private Dispatcher() =

static member CopyNativeToNative<'T when 'T : unmanaged>(src : nativeint, srcInfo : Tensor4Info, dst : nativeint, dstInfo : Tensor4Info) =
copyBytes<'T> src srcInfo dst dstInfo

module Method =
module CopyNativeToNative =
type Delegate = delegate of nativeint * Tensor4Info * nativeint * Tensor4Info -> unit
let private flags = BindingFlags.Static ||| BindingFlags.NonPublic ||| BindingFlags.Public
let copyNativeToNative = typeof<Dispatcher>.GetMethod("CopyNativeToNative", flags)
let private definition = typeof<Dispatcher>.GetMethod(nameof Dispatcher.CopyNativeToNative, flags)
let private delegates = ConcurrentDictionary<Type, Delegate>()

let getDelegate (t: Type) =
delegates.GetOrAdd(t, fun t ->
let mi = definition.MakeGenericMethod [| t |]
unbox<Delegate> <| Delegate.CreateDelegate(typeof<Delegate>, null, mi)
)

let copyBytesTyped (elementType : Type) (src : nativeint) (srcInfo : Tensor4Info) (dst : nativeint) (dstInfo : Tensor4Info) =
let mi = Method.copyNativeToNative.MakeGenericMethod [| elementType |]
mi.Invoke(null, [| src; srcInfo; dst; dstInfo |]) |> ignore
let del = CopyNativeToNative.getDelegate elementType
del.Invoke(src, srcInfo, dst, dstInfo)

let copyBytesWithSize (elementSize : int) (src : nativeint) (srcInfo : Tensor4Info) (dst : nativeint) (dstInfo : Tensor4Info) =
copyBytesTyped StructTypes.types.[elementSize] src srcInfo dst dstInfo
Expand Down
48 changes: 26 additions & 22 deletions src/Aardvark.Rendering.GL/Runtime/GeometryPool.fs
Original file line number Diff line number Diff line change
Expand Up @@ -903,9 +903,9 @@ module GeometryPoolData =
if a % b = 0 then a / b
else 1 + a / b

static let cullingCache = System.Collections.Concurrent.ConcurrentDictionary<Context, ComputeProgram>()
static let boundCache = System.Collections.Concurrent.ConcurrentDictionary<Context, Program>()

static let cullingCache = System.Collections.Concurrent.ConcurrentDictionary<Context, Lazy<ComputeProgram>>()
static let boundCache = System.Collections.Concurrent.ConcurrentDictionary<Context, Lazy<Program>>()
let initialCapacity = Fun.NextPowerOfTwo initialCapacity
let adjust (call : DrawCallInfo) =
if indexed then
Expand Down Expand Up @@ -963,10 +963,12 @@ module GeometryPoolData =

do if bounds then
culling <- cullingCache.GetOrAdd(ctx, fun ctx ->
let cs = ComputeShader.ofFunction (V3i(1024, 1024, 1024)) CullingShader.culling
let shader = ctx.CreateComputeProgram cs
shader
)
lazy (
let cs = ComputeShader.ofFunction (V3i(1024, 1024, 1024)) CullingShader.culling
let shader = ctx.CreateComputeProgram cs
shader
)
).Value

infoSlot <- culling.Interface.storageBuffers.["infos"].ssbBinding
boundSlot <- culling.Interface.storageBuffers.["bounds"].ssbBinding
Expand All @@ -980,21 +982,23 @@ module GeometryPoolData =
countOffset <- nativeint countField.ufOffset

boxShader <- boundCache.GetOrAdd(ctx, fun ctx ->
let effect =
FShade.Effect.compose [
Effect.ofFunction CullingShader.renderBounds
Effect.ofFunction (DefaultSurfaces.constantColor C4f.Red)
]

let compile() =
effect
|> Effect.link signature IndexedGeometryMode.LineList false
|> ModuleCompiler.compileGLSL ctx.FShadeBackend

match ctx.TryGetOrCompileEffect(effect.Id, signature, IndexedGeometryMode.LineList, compile) with
| Success v -> v
| Error e -> failwith e
)
lazy (
let effect =
FShade.Effect.compose [
Effect.ofFunction CullingShader.renderBounds
Effect.ofFunction (DefaultSurfaces.constantColor C4f.Red)
]

let compile() =
effect
|> Effect.link signature IndexedGeometryMode.LineList false
|> ModuleCompiler.compileGLSL ctx.FShadeBackend

match ctx.TryGetOrCompileEffect(effect.Id, signature, IndexedGeometryMode.LineList, compile) with
| Success v -> v
| Error e -> failwith e
)
).Value

boxBoundSlot <- boxShader.Interface.storageBuffers |> Seq.pick (fun (KeyValue(a,b)) -> if a = "Bounds" then Some b.ssbBinding else None)
boxViewProjSlot <- boxShader.Interface.storageBuffers |> Seq.pick (fun (KeyValue(a,b)) -> if a = "ViewProjs" then Some b.ssbBinding else None)
Expand Down
Loading

0 comments on commit a8fb504

Please sign in to comment.