Skip to content

Commit

Permalink
Merge branch 'main' into fix/missing-xlib-struct-and-querypool-stride
Browse files Browse the repository at this point in the history
  • Loading branch information
skalarproduktraum authored Apr 9, 2024
2 parents 4da3227 + 63b9f81 commit 31c612b
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 605 deletions.
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ dependencies {
}
}
implementation("org.xerial.snappy:snappy-java:1.1.10.5")
implementation("com.fasterxml.jackson.core:jackson-databind:2.16.1")
implementation("com.fasterxml.jackson.core:jackson-databind:2.17.0")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.16.1")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.16.1")
implementation("org.zeromq:jeromq:0.5.4")
implementation("com.esotericsoftware:kryo:5.5.0")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.17.0")
implementation("org.zeromq:jeromq:0.6.0")
implementation("com.esotericsoftware:kryo:5.6.0")
implementation("de.javakaffee:kryo-serializers:0.45")
implementation("org.msgpack:msgpack-core:0.9.8")
implementation("org.msgpack:jackson-dataformat-msgpack:0.9.8")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ class RenderConfigReader {
mapper.registerModule(
KotlinModule.Builder()
.withReflectionCacheSize(512)
.configure(KotlinFeature.NullToEmptyCollection, false)
.configure(KotlinFeature.NullToEmptyMap, false)
.configure(KotlinFeature.NullToEmptyCollection, true)
.configure(KotlinFeature.NullToEmptyMap, true)
.configure(KotlinFeature.NullIsSameAsDefault, false)
.configure(KotlinFeature.SingletonSupport, false)
.configure(KotlinFeature.StrictNullChecks, false)
.configure(KotlinFeature.SingletonSupport, true)
.configure(KotlinFeature.StrictNullChecks, true)
.build()
)

Expand Down
11 changes: 10 additions & 1 deletion src/main/kotlin/graphics/scenery/controls/OpenVRHMD.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
import com.fasterxml.jackson.module.kotlin.KotlinFeature
import com.fasterxml.jackson.module.kotlin.KotlinModule
import graphics.scenery.*
import graphics.scenery.backends.Display
Expand Down Expand Up @@ -1271,7 +1272,15 @@ open class OpenVRHMD(val seated: Boolean = false, val useCompositor: Boolean = t
compositeFile.exists() && compositeFile.length() > 1024 -> {
logger.info("Loading model from composite JSON, ${compositeFile.absolutePath}")
val mapper = ObjectMapper(YAMLFactory())
mapper.registerModule(KotlinModule())
mapper.registerModule(
KotlinModule.Builder()
.configure(KotlinFeature.NullToEmptyCollection, true)
.configure(KotlinFeature.NullToEmptyMap, true)
.configure(KotlinFeature.NullIsSameAsDefault, false)
.configure(KotlinFeature.SingletonSupport, true)
.configure(KotlinFeature.StrictNullChecks, true)
.build()
)
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
mapper.configure(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, false)

Expand Down
11 changes: 10 additions & 1 deletion src/main/kotlin/graphics/scenery/controls/ScreenConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.joml.Vector3f
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
import com.fasterxml.jackson.module.kotlin.KotlinFeature
import com.fasterxml.jackson.module.kotlin.KotlinModule
import graphics.scenery.utils.JsonDeserialisers
import graphics.scenery.utils.lazyLogger
Expand Down Expand Up @@ -142,7 +143,15 @@ class ScreenConfig {
*/
@JvmStatic fun loadFromFile(path: String): ScreenConfig.Config {
val mapper = ObjectMapper(YAMLFactory())
mapper.registerModule(KotlinModule())
mapper.registerModule(
KotlinModule.Builder()
.configure(KotlinFeature.NullToEmptyCollection, true)
.configure(KotlinFeature.NullToEmptyMap, true)
.configure(KotlinFeature.NullIsSameAsDefault, false)
.configure(KotlinFeature.SingletonSupport, true)
.configure(KotlinFeature.StrictNullChecks, true)
.build()
)

var stream = ScreenConfig::class.java.getResourceAsStream(path)

Expand Down
29 changes: 22 additions & 7 deletions src/main/kotlin/graphics/scenery/utils/extensions/TextureUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,36 @@ package graphics.scenery.utils.extensions
import graphics.scenery.backends.vulkan.VulkanTexture
import graphics.scenery.textures.Texture
import graphics.scenery.utils.lazyLogger
import org.jetbrains.annotations.ApiStatus.Experimental

fun Texture.fetchTexture(texture: Texture): Int {

/**
* Fetches this [Texture] from the GPU. This replaced the texture's
* contents with whatever is fetched from the GPU and returns true.
* If the texture is not known to the renderer, or no storage buffer
* is available, it'll return false.
*/
@Experimental
fun Texture.fetchFromGPU(): Boolean {
val logger by lazyLogger()

val ref = VulkanTexture.getReference(texture)
val buffer = texture.contents ?: return -1
val buffer = this.contents
if(buffer == null) {
logger.error("Texture copy from GPU requested, but no storage available.")
return false
}

val ref = VulkanTexture.getReference(this)

if(ref != null) {
val start = System.nanoTime()
texture.contents = ref.copyTo(buffer, true)
this.contents = ref.copyTo(buffer, true)
val end = System.nanoTime()
logger.info("The request textures of size ${texture.contents?.remaining()?.toFloat()?.div((1024f*1024f))} took: ${(end.toDouble()-start.toDouble())/1000000.0}")
logger.info("The request textures of size ${this.contents?.remaining()?.toFloat()?.div((1024f*1024f))} took: ${(end.toDouble()-start.toDouble())/1000000.0}")
} else {
logger.error("In fetchTexture: Texture not accessible")
logger.error("In fetchFromGPU: Texture not accessible")
return false
}

return 0
return true
}
2 changes: 2 additions & 0 deletions src/main/kotlin/graphics/scenery/volumes/vdi/VDIData.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package graphics.scenery.volumes.vdi

import org.jetbrains.annotations.ApiStatus.Experimental
import org.joml.Matrix4f
import org.joml.Vector2i
import org.joml.Vector3f
Expand All @@ -18,6 +19,7 @@ import org.joml.Vector3f
*
* @author Aryaman Gupta <[email protected]> and Ulrik Günther <[email protected]>
*/
@Experimental
data class VDIMetadata(
val version: Int = 1,
var index: Int = 0,
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/graphics/scenery/volumes/vdi/VDIDataIO.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package graphics.scenery.volumes.vdi
import com.esotericsoftware.kryo.Kryo
import com.esotericsoftware.kryo.io.Input
import com.esotericsoftware.kryo.io.Output
import org.jetbrains.annotations.ApiStatus.Experimental
import org.joml.Matrix4f
import org.joml.Vector2i
import org.joml.Vector3f
Expand All @@ -15,6 +16,7 @@ import java.io.OutputStream
*
* @author Aryaman Gupta <[email protected]> and Ulrik Günther <[email protected]>
*/
@Experimental
class VDIDataIO {
companion object {

Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/graphics/scenery/volumes/vdi/VDINode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import graphics.scenery.utils.Image
import graphics.scenery.utils.extensions.applyVulkanCoordinateSystem
import net.imglib2.type.numeric.integer.UnsignedIntType
import net.imglib2.type.numeric.real.FloatType
import org.jetbrains.annotations.ApiStatus.Experimental
import org.joml.Matrix4f
import org.joml.Vector3f
import org.joml.Vector3i
Expand All @@ -29,6 +30,7 @@ import java.nio.ByteBuffer
* @param[vdiData] The metadata ([VDIData]) associated with the VDI.
*/

@Experimental
class VDINode(windowWidth: Int, windowHeight: Int, val numSupersegments: Int, vdiData: VDIData) : RichNode() {

/** The projection matrix of the camera viewport that was used to generate the VDI in the first (default) buffer */
Expand Down
12 changes: 6 additions & 6 deletions src/main/kotlin/graphics/scenery/volumes/vdi/VDIStreamer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package graphics.scenery.volumes.vdi
import graphics.scenery.Camera
import graphics.scenery.Settings
import graphics.scenery.backends.Renderer
import graphics.scenery.textures.Texture
import graphics.scenery.utils.DataCompressor
import graphics.scenery.utils.extensions.fetchTexture
import graphics.scenery.utils.extensions.fetchFromGPU
import graphics.scenery.utils.lazyLogger
import graphics.scenery.volumes.VDIVolumeManager
import graphics.scenery.volumes.Volume
import graphics.scenery.volumes.VolumeManager
import org.jetbrains.annotations.ApiStatus.Experimental
import org.joml.Vector2i
import org.joml.Vector3f
import org.lwjgl.system.MemoryUtil
Expand All @@ -29,6 +28,7 @@ import kotlin.system.measureNanoTime
* Class to support streaming of Volumetric Depth Images (VDIs). Provides public functions to stream generated VDIs on the
* server side and to receive and update them on the client side.
*/
@Experimental
class VDIStreamer {

private val logger by lazyLogger()
Expand Down Expand Up @@ -112,9 +112,9 @@ class VDIStreamer {

if (!firstFrame && vdiStreaming.get()) {

Texture().fetchTexture(vdiColor)
Texture().fetchTexture(vdiDepth)
Texture().fetchTexture(gridCells)
vdiColor.fetchFromGPU()
vdiDepth.fetchFromGPU()
gridCells.fetchFromGPU()

val model = volume.spatial().world

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package graphics.scenery.volumes
package graphics.scenery.volumes.vdi

import bvv.core.shadergen.generate.SegmentTemplate
import bvv.core.shadergen.generate.SegmentType
Expand All @@ -12,9 +12,11 @@ import graphics.scenery.compute.InvocationType
import graphics.scenery.textures.Texture
import graphics.scenery.utils.Image
import graphics.scenery.utils.lazyLogger
import graphics.scenery.volumes.VolumeManager
import net.imglib2.type.numeric.integer.IntType
import net.imglib2.type.numeric.integer.UnsignedIntType
import net.imglib2.type.numeric.real.FloatType
import org.jetbrains.annotations.ApiStatus.Experimental
import org.joml.Vector3f
import org.joml.Vector3i
import org.lwjgl.system.MemoryUtil
Expand All @@ -32,6 +34,8 @@ import kotlin.math.ceil
*
* @author Aryaman Gupta <[email protected]> and Wissal Salhi
*/

@Experimental
class VDIVolumeManager (var hub: Hub, val windowWidth: Int, val windowHeight: Int, val maxSupersegments: Int, val scene: Scene)
{
private val logger by lazyLogger()
Expand Down
Loading

0 comments on commit 31c612b

Please sign in to comment.