Skip to content

Commit

Permalink
improved wgsl shader generator
Browse files Browse the repository at this point in the history
  • Loading branch information
fabmax committed Jan 27, 2024
1 parent 6a86238 commit 54ef9f4
Show file tree
Hide file tree
Showing 6 changed files with 309 additions and 342 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ sealed class BindingLayout(
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other == null || this::class != other::class) return false
other as BindGroupLayout
other as BindingLayout
return hash == other.hash
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,24 @@ abstract class RenderBackendGl(internal val gl: GlApi, internal val ctx: KoolCon
}

private fun captureFramebuffer(scene: Scene) {
val viewport = scene.mainRenderPass.viewport
val targetTex = scene.capturedFramebuffer

if (targetTex.loadedTexture == null) {
targetTex.loadedTexture = LoadedTextureGl(gl.TEXTURE_2D, gl.createTexture(), this, targetTex, 4096 * 2048 * 4).apply {
applySamplerSettings(targetTex.props.defaultSamplerSettings)
}
targetTex.loadedTexture = LoadedTextureGl(
target = gl.TEXTURE_2D,
glTexture = gl.createTexture(),
backend = this,
texture = targetTex,
estimatedSize = viewport.width * viewport.height * 4L
).apply { applySamplerSettings(targetTex.props.defaultSamplerSettings) }
}
val tex = targetTex.loadedTexture as LoadedTextureGl
tex.bind()

val viewport = scene.mainRenderPass.viewport
if (tex.width != viewport.width || tex.height != viewport.height) {
tex.setSize(viewport.width, viewport.height, 1)
tex.applySamplerSettings(SamplerSettings().clamped().nearest())
tex.applySamplerSettings(targetTex.props.defaultSamplerSettings)
targetTex.loadingState = Texture.LoadingState.LOADED
gl.texImage2D(tex.target, 0, gl.RGBA8, viewport.width, viewport.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null)
}
Expand Down
Loading

0 comments on commit 54ef9f4

Please sign in to comment.