Skip to content

Commit

Permalink
Rename NewInputBinding to CreateInputBinding
Browse files Browse the repository at this point in the history
  • Loading branch information
hyazinthh committed May 22, 2023
1 parent 78a6abe commit 5000600
Show file tree
Hide file tree
Showing 19 changed files with 83 additions and 71 deletions.
6 changes: 3 additions & 3 deletions src/Aardvark.GPGPU/Jpeg.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,7 @@ and JpegCompressorInstance internal(parent : JpegCompressor, size : V2i, quality
let scan = parent.Scan(codewordCountView, codewordCountView)

let dctInput =
let i = runtime.NewInputBinding parent.DctShader
let i = runtime.CreateInputBinding parent.DctShader
i.["size"] <- alignedSize
i.["ImageSize"] <- size
i.["target"] <- dctBuffer
Expand All @@ -1329,7 +1329,7 @@ and JpegCompressorInstance internal(parent : JpegCompressor, size : V2i, quality


let codewordInput =
let i = runtime.NewInputBinding parent.CodewordShader
let i = runtime.CreateInputBinding parent.CodewordShader
i.["data"] <- dctBuffer
i.["codewords"] <- codewordBuffer
i.["DCLum"] <- encoder.dcLuminance.table
Expand All @@ -1340,7 +1340,7 @@ and JpegCompressorInstance internal(parent : JpegCompressor, size : V2i, quality
i

let assembleInput =
let i = runtime.NewInputBinding parent.AssembleShader
let i = runtime.CreateInputBinding parent.AssembleShader
i.["codewords"] <- codewordBuffer
i.["target"] <- outputBuffer
i.["codewordCount"] <- int codewordBuffer.Count
Expand Down
24 changes: 12 additions & 12 deletions src/Aardvark.GPGPU/Primitives.fs
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ type private Map<'a, 'b when 'a : unmanaged and 'b : unmanaged>(runtime : ICompu
let map = runtime.CreateComputeShader (Kernels.map map)

let build (src : IBufferVector<'a>) (dst : IBufferVector<'b>) =
let args = runtime.NewInputBinding(map)
let args = runtime.CreateInputBinding(map)

args.["src"] <- src.Buffer
args.["SrcOffset"] <- src.Origin
Expand Down Expand Up @@ -713,7 +713,7 @@ type private Scan<'a when 'a : unmanaged>(runtime : IComputeRuntime, add : Expr<
let rec build (args : HashSet<MutableComputeInputBinding>) (input : IBufferVector<'a>) (output : IBufferVector<'a>) =
let cnt = int input.Count
if cnt > 1 then
let args0 = runtime.NewInputBinding(scan)
let args0 = runtime.CreateInputBinding(scan)

args0.["inputOffset"] <- input.Origin |> int
args0.["inputDelta"] <- input.Delta |> int
Expand All @@ -738,7 +738,7 @@ type private Scan<'a when 'a : unmanaged>(runtime : IComputeRuntime, add : Expr<
if oSums.Count > 0 then
let inner = build args oSums oSums

let args1 = runtime.NewInputBinding fixup
let args1 = runtime.CreateInputBinding fixup
args1.["inputData"] <- oSums.Buffer
args1.["inputOffset"] <- oSums.Origin |> int
args1.["inputDelta"] <- oSums.Delta |> int
Expand Down Expand Up @@ -798,7 +798,7 @@ type private Reduce<'a when 'a : unmanaged>(runtime : IComputeRuntime, add : Exp
let rec build (args : HashSet<System.IDisposable>) (input : IBufferVector<'a>) (target : 'a[]) =
let cnt = int input.Count
if cnt > 1 then
let args0 = runtime.NewInputBinding(reduce)
let args0 = runtime.CreateInputBinding(reduce)

let groupCount = ceilDiv (int input.Count) Kernels.scanSize
let temp = runtime.CreateBuffer<'a>(groupCount)
Expand Down Expand Up @@ -876,7 +876,7 @@ type private MapReduce<'a, 'b when 'a : unmanaged and 'b : unmanaged>(runtime :
let rec build (args : HashSet<System.IDisposable>) (input : IBufferVector<'b>) (target : 'b[]) =
let cnt = int input.Count
if cnt > 1 then
let args0 = runtime.NewInputBinding(reduce)
let args0 = runtime.CreateInputBinding(reduce)

let groupCount = ceilDiv (int input.Count) Kernels.scanSize
let temp = runtime.CreateBuffer<'b>(groupCount)
Expand Down Expand Up @@ -914,7 +914,7 @@ type private MapReduce<'a, 'b when 'a : unmanaged and 'b : unmanaged>(runtime :

let buildTop (args : HashSet<System.IDisposable>) (input : IBufferVector<'a>) (target : 'b[]) =
let cnt = int input.Count
let args0 = runtime.NewInputBinding(mapReduce)
let args0 = runtime.CreateInputBinding(mapReduce)

let groupCount = ceilDiv (int input.Count) Kernels.scanSize
let temp = runtime.CreateBuffer<'b>(groupCount)
Expand Down Expand Up @@ -992,7 +992,7 @@ type private MapReduceImage<'b when 'b : unmanaged>(runtime : IComputeRuntime, r
let rec build (args : HashSet<System.IDisposable>) (input : IBufferVector<'b>) (target : 'b[]) =
let cnt = int input.Count
if cnt > 1 then
let args0 = runtime.NewInputBinding(reduce)
let args0 = runtime.CreateInputBinding(reduce)

let groupCount = ceilDiv (int input.Count) Kernels.scanSize
let temp = runtime.CreateBuffer<'b>(groupCount)
Expand Down Expand Up @@ -1038,7 +1038,7 @@ type private MapReduceImage<'b when 'b : unmanaged>(runtime : IComputeRuntime, r

match dimensions with
| 2 ->
let args0 = runtime.NewInputBinding(mapReduce2d)
let args0 = runtime.CreateInputBinding(mapReduce2d)

let size = input.Size.XY
let groupCount = ceilDiv2 size Kernels.imageScanSize2d
Expand Down Expand Up @@ -1069,7 +1069,7 @@ type private MapReduceImage<'b when 'b : unmanaged>(runtime : IComputeRuntime, r
else
cmd
| 3 ->
let args0 = runtime.NewInputBinding(mapReduce3d)
let args0 = runtime.CreateInputBinding(mapReduce3d)

let size = input.Size
let groupCount = ceilDiv3 size Kernels.imageScanSize3d
Expand Down Expand Up @@ -1230,7 +1230,7 @@ type private ScanImage2d(runtime : IComputeRuntime, add : Expr<V4d -> V4d -> V4d
let scanBlocks (args : HashSet<MutableComputeInputBinding>) (imgDim : int) (dim : int) (image : ITextureSubResource) (range : ScanRange) =
let scan = scan(imgDim).Value

let input = runtime.NewInputBinding(scan)
let input = runtime.CreateInputBinding(scan)
input.["inOutImage"] <- image
input.["dimension"] <- dim
input.["Offset"] <- range.offset
Expand Down Expand Up @@ -1258,7 +1258,7 @@ type private ScanImage2d(runtime : IComputeRuntime, add : Expr<V4d -> V4d -> V4d

let innerRange = next range

let args1 = runtime.NewInputBinding fixup
let args1 = runtime.CreateInputBinding fixup
args1.["inOutImage"] <- image
args1.["dimension"] <- dim
args1.["inputOffset"] <- innerRange.offset
Expand Down Expand Up @@ -1312,7 +1312,7 @@ type private ScanImage2d(runtime : IComputeRuntime, add : Expr<V4d -> V4d -> V4d

let scanTexture = scanTexture(imageDim).Value

let xInput = runtime.NewInputBinding(scanTexture)
let xInput = runtime.CreateInputBinding(scanTexture)
xInput.["inputTexture"] <- input.Texture
xInput.["inOutImage"] <- output
xInput.["dimension"] <- 0
Expand Down
12 changes: 6 additions & 6 deletions src/Aardvark.GPGPU/RadixSort.fs
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ type RadixSort(runtime : IRuntime) =
let mutable outputKeys = keyCache :> IBufferVector<_>
let mutable outputValues = valueCache :> IBufferVector<_>

use radixSumInput = runtime.NewInputBinding radixSum
use radixPrefixSumInput = runtime.NewInputBinding radixPrefixSum
use radixAddOffsetsAndShuffleInput = runtime.NewInputBinding radixAddOffsetsAndShuffle
use radixSumInput = runtime.CreateInputBinding radixSum
use radixPrefixSumInput = runtime.CreateInputBinding radixPrefixSum
use radixAddOffsetsAndShuffleInput = runtime.CreateInputBinding radixAddOffsetsAndShuffle

let mutable shift = 0
radixSumInput.["elements"] <- cnt
Expand Down Expand Up @@ -504,9 +504,9 @@ type RadixSort(runtime : IRuntime) =
let mutable inputKeys = input
let mutable outputKeys = keyCache :> IBufferVector<_>

use radixSumInput = runtime.NewInputBinding radixSum
use radixPrefixSumInput = runtime.NewInputBinding radixPrefixSum
use radixAddOffsetsAndShuffleInput = runtime.NewInputBinding radixAddOffsetsAndShuffleKeysOnly
use radixSumInput = runtime.CreateInputBinding radixSum
use radixPrefixSumInput = runtime.CreateInputBinding radixPrefixSum
use radixAddOffsetsAndShuffleInput = runtime.CreateInputBinding radixAddOffsetsAndShuffleKeysOnly

let mutable shift = 0
radixSumInput.["elements"] <- cnt
Expand Down
8 changes: 4 additions & 4 deletions src/Aardvark.GPGPU/Sorting.fs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ and BitonicSorterInstance<'a when 'a : unmanaged>(parent : BitonicSorter<'a>, el
parent.Runtime.CompileCompute [

// initialize the permutation-buffer
let binding = runtime.NewInputBinding parent.InitPerm
let binding = runtime.CreateInputBinding parent.InitPerm
binding.["perm"] <- permBuffer
binding.["N"] <- elements
binding.Flush()
Expand All @@ -275,7 +275,7 @@ and BitonicSorterInstance<'a when 'a : unmanaged>(parent : BitonicSorter<'a>, el
yield ComputeCommand.Sync permBuffer.Buffer

// start the initial k/j loop
let binding = runtime.NewInputBinding parent.StepKJ
let binding = runtime.CreateInputBinding parent.StepKJ
binding.["maxK"] <- maxK
binding.["xs"] <- dummy
binding.["perm"] <- permBuffer
Expand All @@ -301,7 +301,7 @@ and BitonicSorterInstance<'a when 'a : unmanaged>(parent : BitonicSorter<'a>, el


// start the single-step
let binding = runtime.NewInputBinding parent.Simple
let binding = runtime.CreateInputBinding parent.Simple
let groupSizeP = (j <<< 1) - 1
binding.["j"] <- j
binding.["jMask"] <- (~~~(j - 1))
Expand All @@ -322,7 +322,7 @@ and BitonicSorterInstance<'a when 'a : unmanaged>(parent : BitonicSorter<'a>, el
yield ComputeCommand.Sync permBuffer.Buffer

// start the j loop
let binding = runtime.NewInputBinding parent.StepJ
let binding = runtime.CreateInputBinding parent.StepJ
let groupSizeP = (j <<< 1) - 1
binding.["j"] <- j
binding.["isFirst"] <- isFirst
Expand Down
6 changes: 3 additions & 3 deletions src/Aardvark.Rendering.GL/Runtime/Runtime.fs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ type Runtime(debug : IDebugConfig) =
member x.CreateComputeShader(shader) =
x.CreateComputeShader(shader)

member x.NewInputBinding(shader, inputs) =
x.NewInputBinding(shader, inputs)
member x.CreateInputBinding(shader, inputs) =
x.CreateInputBinding(shader, inputs)

member x.CompileCompute (commands) =
x.CompileCompute commands
Expand Down Expand Up @@ -738,7 +738,7 @@ type Runtime(debug : IDebugConfig) =
member x.CreateComputeShader (shader : FShade.ComputeShader) =
ctx.CompileKernel shader :> IComputeShader

member x.NewInputBinding(shader : IComputeShader, inputs : IUniformProvider) =
member x.CreateInputBinding(shader : IComputeShader, inputs : IUniformProvider) =
let program = unbox<ComputeProgram> shader
ComputeInputBinding(manager, program, inputs) :> IComputeInputBinding

Expand Down
6 changes: 3 additions & 3 deletions src/Aardvark.Rendering.Vulkan/Runtime/Runtime.fs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ type Runtime(device : Device) as this =
member x.CreateComputeShader(shader : FShade.ComputeShader) =
ComputeProgram.ofFShade shader device :> IComputeShader

member x.NewInputBinding(shader : IComputeShader, inputs : IUniformProvider) : IComputeInputBinding =
member x.CreateInputBinding(shader : IComputeShader, inputs : IUniformProvider) : IComputeInputBinding =
let program = unbox<ComputeProgram> shader
manager.CreateComputeInputBinding(program, inputs)

Expand Down Expand Up @@ -519,8 +519,8 @@ type Runtime(device : Device) as this =
member x.CreateComputeShader(shader : FShade.ComputeShader) =
x.CreateComputeShader shader

member x.NewInputBinding(shader : IComputeShader, inputs : IUniformProvider) =
x.NewInputBinding(shader, inputs)
member x.CreateInputBinding(shader : IComputeShader, inputs : IUniformProvider) =
x.CreateInputBinding(shader, inputs)

member x.CompileCompute (commands : alist<ComputeCommand>) =
x.CompileCompute commands
Expand Down
2 changes: 1 addition & 1 deletion src/Aardvark.Rendering/Runtime/Compute/Compute.fs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ and IComputeRuntime =
abstract member ContextLock : IDisposable
abstract member MaxLocalSize : V3i
abstract member CreateComputeShader : shader: FShade.ComputeShader -> IComputeShader
abstract member NewInputBinding : shader: IComputeShader * inputs: IUniformProvider -> IComputeInputBinding
abstract member CreateInputBinding : shader: IComputeShader * inputs: IUniformProvider -> IComputeInputBinding
abstract member CompileCompute : commands: alist<ComputeCommand> -> IComputeTask

and [<RequireQualifiedAccess>]
Expand Down
12 changes: 10 additions & 2 deletions src/Aardvark.Rendering/Runtime/Compute/ComputeExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,16 @@ type IComputeRuntimeExtensions private() =
type IComputeShaderExtensions private() =

[<Extension>]
static member CreateInputBinding(shader : IComputeShader, inputs : IUniformProvider) =
shader.Runtime.CreateInputBinding(shader, inputs)

[<Extension; Obsolete("Use CreateInputBinding instead.")>]
static member NewInputBinding(_runtime : IComputeRuntime, shader : IComputeShader, inputs : IUniformProvider) =
_runtime.CreateInputBinding(shader, inputs)

[<Extension; Obsolete("Use CreateInputBinding instead.")>]
static member NewInputBinding(shader : IComputeShader, inputs : IUniformProvider) =
shader.Runtime.NewInputBinding(shader, inputs)
shader.Runtime.CreateInputBinding(shader, inputs)

[<Extension>]
static member Invoke(shader : IComputeShader, groupCount : V3i, input : IComputeInputBinding, renderToken : RenderToken) =
Expand Down Expand Up @@ -111,7 +119,7 @@ module ``InputBinding Builder`` =
inherit UniformMapBuilder()

member x.Run(map : UniformMap) =
shader.NewInputBinding map
shader.CreateInputBinding map

type IComputeShader with
member x.inputBinding = InputBindingBuilder x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,9 @@ type IComputeRuntimeMutableInputBindingExtensions private() =
/// Creates a mutable input binding for the given shader.
/// For backwards-compatible only, new code should create input bindings from an IUniformProvider.
[<Extension>]
static member CreateInputBinding(_runtime : IComputeRuntime, shader : IComputeShader) =
new MutableComputeInputBinding(shader)

[<Extension; Obsolete("Use CreateInputBinding instead.")>]
static member NewInputBinding(_runtime : IComputeRuntime, shader : IComputeShader) =
new MutableComputeInputBinding(shader)
_runtime.CreateInputBinding(shader)
6 changes: 3 additions & 3 deletions src/Demo/Examples/ComputeShader.fs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ module ComputeShader =
par.CompileMap(<@ fun i e -> if e < 10 then 1 else 0 @>, input, bits).Run()
let scanned = par.Scan(<@ (+) @>, bits, bitsum)
let targetWriteShader = runtime.CreateComputeShader Shaders.toTarget
let targetWrite = runtime.NewInputBinding targetWriteShader
let targetWrite = runtime.CreateInputBinding targetWriteShader
targetWrite.["src"] <- input
targetWrite.["n"] <- input.Count
targetWrite.["bits"] <- bits
Expand Down Expand Up @@ -466,14 +466,14 @@ module ComputeShader =
)


let updateInputs = runtime.NewInputBinding update
let updateInputs = runtime.CreateInputBinding update
updateInputs.["pos"] <- positions
updateInputs.["acc"] <- accelerations
updateInputs.["masses"] <- masses
updateInputs.["n"] <- particeCount
updateInputs.Flush()

let stepInputs = runtime.NewInputBinding step
let stepInputs = runtime.CreateInputBinding step
stepInputs.["pos"] <- positions
stepInputs.["vel"] <- velocities
stepInputs.["acc"] <- accelerations
Expand Down
4 changes: 2 additions & 2 deletions src/Examples (netcore)/10 - NBodyCompute/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ let main argv =
) |> ignore


let updateInputs = runtime.NewInputBinding update
let updateInputs = runtime.CreateInputBinding update
updateInputs.["pos"] <- positions
updateInputs.["acc"] <- accelerations
updateInputs.["masses"] <- masses
updateInputs.["n"] <- particeCount
updateInputs.Flush()

let stepInputs = runtime.NewInputBinding step
let stepInputs = runtime.CreateInputBinding step
stepInputs.["pos"] <- positions
stepInputs.["vel"] <- velocities
stepInputs.["acc"] <- accelerations
Expand Down
2 changes: 1 addition & 1 deletion src/Examples (netcore)/11 - ParallelPrimitives/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ let parallelFilter<'a when 'a : unmanaged> (par : ParallelPrimitives) (arr : 'a[

// compile our custom resolve-shader and setup its inputs
let resolveShader = runtime.CreateComputeShader Shader.resolve
use resolveInputs = runtime.NewInputBinding resolveShader
use resolveInputs = runtime.CreateInputBinding resolveShader
resolveInputs.["src"] <- input
resolveInputs.["n"] <- input.Count
resolveInputs.["targets"] <- bits
Expand Down
6 changes: 3 additions & 3 deletions src/Examples (netcore)/21 - LoD/DistanceField.fs
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,19 @@ let computeDistanceGPU (pi : PixImage<byte>) =
let dt = runtime.CreateTexture2D(pi.Size,TextureFormat.Rgba32f,1,1)

let toBinary = runtime.CreateComputeShader(Shaders.toBinary)
use toBinaryInput = runtime.NewInputBinding(toBinary)
use toBinaryInput = runtime.CreateInputBinding(toBinary)
toBinaryInput.["i"] <- input
toBinaryInput.["b"] <- b
toBinaryInput.Flush()

let phase1 = runtime.CreateComputeShader(Shaders.phase1)
let phase1Input = runtime.NewInputBinding(phase1)
let phase1Input = runtime.CreateInputBinding(phase1)
phase1Input.["b"] <- b
phase1Input.["g"] <- g
phase1Input.Flush()

let phase2 = runtime.CreateComputeShader(Shaders.phase2)
let phase2Input = runtime.NewInputBinding(phase2)
let phase2Input = runtime.CreateInputBinding(phase2)
phase2Input.["g"] <- g
phase2Input.["s"] <- s
phase2Input.["t"] <- t
Expand Down
4 changes: 2 additions & 2 deletions src/Examples (netcore)/26 - Splines/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ module Sg =
let size = size.GetValue t
let threshold = threshold.GetValue t

use ip = runtime.NewInputBinding prepare
use ip = runtime.CreateInputBinding prepare
ip.["cpIn"] <- cps
ip.["div"] <- div
ip.["ts"] <- ts
Expand Down Expand Up @@ -274,7 +274,7 @@ module Sg =


//let evalulate (scannedDiv : int[]) (scannedCount : int) (ts : V2f[]) (cps : V4f[]) (lines : V4f[])
use ip = runtime.NewInputBinding evaluate
use ip = runtime.CreateInputBinding evaluate
ip.["scannedDiv"] <- div
ip.["scannedCount"] <- cnt
ip.["ts"] <- ts
Expand Down

0 comments on commit 5000600

Please sign in to comment.