Class ShaderManager
java.lang.Object
dev.engine.graphics.common.ShaderManager
Manages shader compilation via Slang (native FFM or process fallback).
Produces
CompiledShader with reflection metadata for binding resolution.-
Constructor Summary
ConstructorsConstructorDescriptionShaderManager(RenderDevice device, GpuResourceManager gpu, GlobalParamsRegistry globalParams, ShaderCompiler compiler) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Destroys all cached pipelines.compileSlangFile(String path) compileSlangSource(String source, String name) compileSlangSource(String source, String name, VertexFormat vertexFormat) Compiles a Slang source with a custom vertex format (null = standard format).extractBufferBindings(CompiledShader compiled) Extracts buffer name → binding slot map from a CompiledShader's reflection.getEntityShader(Handle<?> entity) Returns the compiled shader previously resolved for an entity, or null.getPipeline(String shaderName) Returns just the pipeline handle (no reflection).Gets or compiles the shader for a shader name (e.g.getShaderWithMaterial(String shaderHint, Set<? extends PropertyKey<?, ?>> materialKeys) Compiles a shader with material param blocks based on the material's keys.voidinvalidate(String key) voidloadResource(String shaderPath) Loads a shader source from the asset system or classpath.voidremoveEntityShader(Handle<?> entity) Removes the cached shader for a destroyed entity.resolveForEntity(Handle<?> entity, MaterialData material) Resolves a shader for an entity based on its material's shader hint and keys.voidsetAssetManager(AssetManager assetManager) intReturns the texture binding offset for the current backend (e.g.
-
Constructor Details
-
ShaderManager
public ShaderManager(RenderDevice device, GpuResourceManager gpu, GlobalParamsRegistry globalParams, ShaderCompiler compiler)
-
-
Method Details
-
textureBindingOffset
public int textureBindingOffset()Returns the texture binding offset for the current backend (e.g. 16 for Vulkan, 0 for OpenGL). -
setAssetManager
-
getShader
Gets or compiles the shader for a shader name (e.g. "PBR", "UNLIT"). Returns CompiledShader with reflection data. -
getPipeline
Returns just the pipeline handle (no reflection). -
compileSlangSource
-
compileSlangSource
Compiles a Slang source with a custom vertex format (null = standard format). -
compileSlangFile
-
getShaderWithMaterial
public CompiledShader getShaderWithMaterial(String shaderHint, Set<? extends PropertyKey<?, ?>> materialKeys) Compiles a shader with material param blocks based on the material's keys. Uses generic specialization when native compiler is available, falls back to static global instance for the process-based compiler. Cached by shader hint + key set combination. -
invalidate
-
resolveForEntity
Resolves a shader for an entity based on its material's shader hint and keys. Returns null if no material or shader hint, or if compilation fails. Caches the result per entity. -
getEntityShader
Returns the compiled shader previously resolved for an entity, or null. -
removeEntityShader
Removes the cached shader for a destroyed entity. -
extractBufferBindings
Extracts buffer name → binding slot map from a CompiledShader's reflection. Only includes constant buffer bindings. -
invalidateAll
public void invalidateAll() -
close
public void close()Destroys all cached pipelines. Call on shutdown. -
loadResource
-