Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
pull_request:

jobs:
format:
format_and_compile:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -19,4 +19,4 @@ jobs:
with:
jvm: graalvm-java21
apps: sbt
- run: sbt "formatCheckAll"
- run: sbt "formatCheckAll; compile"
1 change: 1 addition & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ optIn.configStyleArguments = false
rewrite.rules = [RedundantBraces, RedundantParens, SortModifiers, PreferCurlyFors, Imports]
rewrite.sortModifiers.preset = styleGuide
rewrite.trailingCommas.style = always
rewrite.scala3.convertToNewSyntax = true

indent.defnSite = 2
newlines.inInterpolation = "avoid"
Expand Down
24 changes: 20 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ lazy val vulkanNatives =
else Seq.empty

lazy val commonSettings = Seq(
scalacOptions ++= Seq("-feature", "-deprecation", "-unchecked", "-language:implicitConversions"),
libraryDependencies ++= Seq(
"dev.zio" % "izumi-reflect_3" % "2.3.10",
"com.lihaoyi" % "pprint_3" % "0.9.0",
Expand All @@ -47,11 +48,10 @@ lazy val commonSettings = Seq(
"org.lwjgl" % "lwjgl-vma" % lwjglVersion classifier lwjglNatives,
"org.joml" % "joml" % jomlVersion,
"commons-io" % "commons-io" % "2.16.1",
"org.slf4j" % "slf4j-api" % "1.7.30",
"org.slf4j" % "slf4j-simple" % "1.7.30" % Test,
"org.scalameta" % "munit_3" % "1.0.0" % Test,
"com.lihaoyi" %% "sourcecode" % "0.4.3-M5",
"org.slf4j" % "slf4j-api" % "2.0.17",
"org.apache.logging.log4j" % "log4j-slf4j2-impl" % "2.24.3",
) ++ vulkanNatives,
)

Expand All @@ -60,9 +60,14 @@ lazy val runnerSettings = Seq(libraryDependencies += "org.apache.logging.log4j"
lazy val utility = (project in file("cyfra-utility"))
.settings(commonSettings)

lazy val spirvTools = (project in file("cyfra-spirv-tools"))
.settings(commonSettings)
.dependsOn(utility)

lazy val vulkan = (project in file("cyfra-vulkan"))
.settings(commonSettings)
.dependsOn(utility)
.settings(libraryDependencies ++= Seq("org.lwjgl" % "lwjgl-glfw" % lwjglVersion, "org.lwjgl" % "lwjgl-glfw" % lwjglVersion classifier lwjglNatives))

lazy val dsl = (project in file("cyfra-dsl"))
.settings(commonSettings)
Expand All @@ -74,7 +79,7 @@ lazy val compiler = (project in file("cyfra-compiler"))

lazy val runtime = (project in file("cyfra-runtime"))
.settings(commonSettings)
.dependsOn(compiler, dsl, vulkan, utility)
.dependsOn(compiler, dsl, vulkan, utility, spirvTools)

lazy val foton = (project in file("cyfra-foton"))
.settings(commonSettings)
Expand All @@ -92,9 +97,20 @@ lazy val e2eTest = (project in file("cyfra-e2e-test"))
.settings(commonSettings, runnerSettings)
.dependsOn(runtime)

lazy val rtrp = (project in file("cyfra-rtrp"))
.settings(commonSettings)
.dependsOn(utility, vulkan)
.settings(
libraryDependencies ++= Seq(
"org.lwjgl" % "lwjgl-glfw" % lwjglVersion,
"org.lwjgl" % "lwjgl-glfw" % lwjglVersion classifier lwjglNatives,
"org.scalatest" %% "scalatest" % "3.2.15" % Test,
),
)

lazy val root = (project in file("."))
.settings(name := "Cyfra")
.aggregate(compiler, dsl, foton, runtime, vulkan, examples)
.aggregate(compiler, dsl, foton, runtime, vulkan, examples, rtrp)

e2eTest / Test / javaOptions ++= Seq("-Dorg.lwjgl.system.stackSize=1024", "-DuniqueLibraryNames=true")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
package io.computenode.cyfra.spirv

import io.computenode.cyfra.dsl.Control.Scope
import io.computenode.cyfra.dsl.Expression.{E, FunctionCall}
import io.computenode.cyfra.dsl.Value
import io.computenode.cyfra.dsl.macros.Source
import izumi.reflect.Tag
import io.computenode.cyfra.dsl.Expression.E

import scala.collection.mutable
import scala.quoted.Expr

private[cyfra] object BlockBuilder:

def buildBlock(tree: E[_], providedExprIds: Set[Int] = Set.empty): List[E[_]] =
val allVisited = mutable.Map[Int, E[_]]()
def buildBlock(tree: E[?], providedExprIds: Set[Int] = Set.empty): List[E[?]] =
val allVisited = mutable.Map[Int, E[?]]()
val inDegrees = mutable.Map[Int, Int]().withDefaultValue(0)
val q = mutable.Queue[E[_]]()
val q = mutable.Queue[E[?]]()
q.enqueue(tree)
allVisited(tree.treeid) = tree

Expand All @@ -28,8 +23,8 @@ private[cyfra] object BlockBuilder:
allVisited(childId) = child
q.enqueue(child)

val l = mutable.ListBuffer[E[_]]()
val roots = mutable.Queue[E[_]]()
val l = mutable.ListBuffer[E[?]]()
val roots = mutable.Queue[E[?]]()
allVisited.values.foreach: node =>
if inDegrees(node.treeid) == 0 then roots.enqueue(node)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package io.computenode.cyfra.spirv

import io.computenode.cyfra.dsl.macros.FnCall.FnIdentifier
import io.computenode.cyfra.dsl.macros.Source
import io.computenode.cyfra.spirv.compilers.FunctionCompiler.SprivFunction
import io.computenode.cyfra.spirv.SpirvConstants.HEADER_REFS_TOP
import io.computenode.cyfra.spirv.compilers.FunctionCompiler.SprivFunction
import io.computenode.cyfra.spirv.compilers.SpirvProgramCompiler.ArrayBufferBlock
import izumi.reflect.Tag
import izumi.reflect.macrortti.LightTypeTag
Expand All @@ -18,7 +17,7 @@ private[cyfra] case class Context(
voidFuncTypeRef: Int = -1,
workerIndexRef: Int = -1,
uniformVarRef: Int = -1,
constRefs: Map[(Tag[_], Any), Int] = Map(),
constRefs: Map[(Tag[?], Any), Int] = Map(),
exprRefs: Map[Int, Int] = Map(),
inBufferBlocks: List[ArrayBufferBlock] = List(),
outBufferBlocks: List[ArrayBufferBlock] = List(),
Expand Down
Loading