Skip to content

Commit

Permalink
Rename Shader.Transpiler.SingleTarget to Simple
Browse files Browse the repository at this point in the history
  • Loading branch information
Laxystem committed Jan 23, 2025
1 parent 4aa51b6 commit a2588fc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions core/src/commonMain/kotlin/Shader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public interface Shader {
* @see Transpiler
* @see Transpiler.Dynamic
*/
public interface SingleTarget<out L, out F> : Transpiler<L, F> where L : Language, F : FormFactor {
public interface Simple<out L, out F> : Transpiler<L, F> where L : Language, F : FormFactor {
/**
* The [Kind] of all [Shader]s outputted by this [Transpiler].
*
Expand All @@ -153,11 +153,13 @@ public interface Shader {
}

/**
* Transpile [Shader]s to any of the pre-selected [outputKinds].
* Transpiles [Shader]s to any of the pre-selected [outputKinds].
*
* It is up to the implementation to select the optimal [Kind].
*
* @see 0.0.1-alpha.4
* @see Transpiler
* @see Transpiler.Simple
*/
public interface Dynamic<out L, out F> : Transpiler<L, F> where L : Language, F : FormFactor {
/**
Expand Down
6 changes: 3 additions & 3 deletions core/src/commonMain/kotlin/Shaders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ public val Shader.kind: Shader.Kind<*, *> get() = Shader.Kind<Shader.Language, S
* @since 0.0.1-alpha.4
* @see Shader.isOfAnyKindOutputtedBy
* @see Shader.Transpiler.Dynamic.outputKinds
* @see Shader.Transpiler.SingleTarget.outputKind
* @see Shader.Transpiler.Simple.outputKind
*/
public val <L, F> Shader.Transpiler<L, F>.outputKinds: ImmutableSet<Shader.Kind<L, F>> where L : Shader.Language, F : Shader.FormFactor
get() = when (this) {
is Shader.Transpiler.Dynamic -> outputKinds
is Shader.Transpiler.SingleTarget -> persistentHashSetOf(outputKind)
is Shader.Transpiler.Simple -> persistentHashSetOf(outputKind)
}

/**
Expand All @@ -124,7 +124,7 @@ private inline fun Shader.isAnyKindOutputtedBy(
predicate: Shader.(Shader.Kind<*, *>) -> Boolean
) = when (transpiler) {
is Shader.Transpiler.Dynamic -> transpiler.outputKinds.any { predicate(it) }
is Shader.Transpiler.SingleTarget -> predicate(transpiler.outputKind)
is Shader.Transpiler.Simple -> predicate(transpiler.outputKind)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion example/src/commonMain/kotlin/AdvancedRenderer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class AdvancedRenderer<Vertex : Any>(
override val format: TextureFormat = surface.textureFormat,
public val scene: RenderScene<Vertex>,
public val vertexKind: VertexKind<Vertex>,
transpiler: Shader.Transpiler.SingleTarget<Wgsl, StringShader.FormFactor>
transpiler: Shader.Transpiler.Simple<Wgsl, StringShader.FormFactor>
) : WebGpuRenderer, Closer by Closer(surface, device) {
private val shaders = +ShaderCache(transpiler)
private val shaderDescriptors = +ManualCache<Shader, ShaderModuleDescriptor> {
Expand Down

0 comments on commit a2588fc

Please sign in to comment.