Bug Cleanup after 2.9RC2 (#2239)

This commit is contained in:
Eclipse-Sol authored and GitHub committed 2026-10-10 13:22:49 -07:00
1 parent 990dadc03f
commit 2f1f380e8e
73 files changed
+3950 -330

No files matched your search

+2 -1
View File
@@ -898,8 +898,9 @@ public class Iris {
PerFrameUniformBlockHarvester.harvest(programs);
final DeferredWorldRenderingPipeline pipeline = new DeferredWorldRenderingPipeline(programs);
try {
// Both are otherwise built lazily on first draw, after this pipeline is gone
// These are otherwise built lazily on first draw, after this pipeline is gone
pipeline.compileInstancedVariants();
pipeline.compileWideLinePrograms();
if (IrisShaderProviderHolder.getProvider() instanceof IrisCeleritasShaderProvider terrain) {
terrain.compileTerrainPrograms(pipeline.getCeleritasTerrainPipeline());
}
@@ -21,6 +21,7 @@ public enum RenderCondition {
RAIN_SNOW,
WORLD_BORDER,
LIGHTNING,
LINES,
SHADOW_TRANSLUCENT,
// NB: Must be last due to implementation details of DeferredWorldRenderingPipeline
SHADOW
@@ -189,6 +189,9 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
private final Map<Pair<String, InputAvailability>, Map<PatchShaderType, String>> attributeTransforms;
private final EnumMap<Instancing, Map<Pair<String, InputAvailability>, Map<PatchShaderType, String>>> instancedAttributeTransforms = new EnumMap<>(Instancing.class);
private final boolean[] supportsInstancing = initialInstancingSupport();
private final Map<Pair<String, InputAvailability>, Map<PatchShaderType, String>> wideLineTransforms = new HashMap<>();
private final Map<SharedProgramKey, WideLineProgram> wideLinePrograms = new HashMap<>();
private final boolean packWidensLines;
private final ParityFlipState parityState = new ParityFlipState(AngelicaConfig.shaderParityFlip);
private final Supplier<ImmutableSet<Integer>> flippedGbuffers;
private final Supplier<ImmutableSet<Integer>> flippedShadowGbuffers;
@@ -266,6 +269,8 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
resolver = new ProgramFallbackResolver(programs);
final Map<String, Boolean> mvBuiltinsMemo = new ConcurrentHashMap<>();
final Map<Pair<String, InputAvailability>, CompletableFuture<Map<PatchShaderType, String>>> attributeTransformFutures = submitAttributeTransforms(resolver, attributeProgramIds(Instancing.NONE), Instancing.NONE, mvBuiltinsMemo);
packWidensLines = programs.get(ProgramId.Line).isPresent();
final Map<Pair<String, InputAvailability>, CompletableFuture<Map<PatchShaderType, String>>> wideLineTransformFutures = submitWideLineTransforms(resolver, packWidensLines);
final EnumMap<Instancing, Map<Pair<String, InputAvailability>, CompletableFuture<Map<PatchShaderType, String>>>> instancedTransformFutures = new EnumMap<>(Instancing.class);
for (Instancing kind : Instancing.VALUES) {
if (kind != Instancing.NONE) {
@@ -502,6 +507,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
// world border uses textured_lit even though it has no lightmap :/
null, ProgramId.TexturedLit, ProgramId.TexturedLit,
ProgramId.Lightning, ProgramId.Lightning, ProgramId.Lightning,
ProgramId.Line, ProgramId.Line, ProgramId.Line,
ProgramId.ShadowWater, ProgramId.ShadowWater, ProgramId.ShadowWater,
ProgramId.Shadow, ProgramId.Shadow, ProgramId.Shadow
};
@@ -522,6 +528,14 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
Iris.logger.info("[Load #{}] DWRP phase=attribute-join elapsed_ms={}", Iris.getShaderPackLoadId(), String.format("%.1f", (System.nanoTime() - _tLast) / 1_000_000.0));
_tLast = System.nanoTime();
for (Map.Entry<Pair<String, InputAvailability>, CompletableFuture<Map<PatchShaderType, String>>> entry : wideLineTransformFutures.entrySet()) {
try {
this.wideLineTransforms.put(entry.getKey(), entry.getValue().join());
} catch (Exception e) {
Iris.logger.warn("Wide line transform failed for {}; lines there stay 1 px wide!", entry.getKey().getLeft(), e);
}
}
for (Map.Entry<Instancing, Map<Pair<String, InputAvailability>, CompletableFuture<Map<PatchShaderType, String>>>> kindEntry : instancedTransformFutures.entrySet()) {
final Instancing kind = kindEntry.getKey();
final Map<Pair<String, InputAvailability>, Map<PatchShaderType, String>> joined = new HashMap<>();
@@ -546,7 +560,8 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
final Map<SharedProgramKey, BuiltProgram> builtPrograms = new HashMap<>();
this.table = new ProgramTable<>((condition, availability) -> {
this.table = new ProgramTable<>((condition, requested) -> {
final InputAvailability availability = condition == RenderCondition.LINES ? LINE_INPUTS : requested;
final ProgramId finalId = gbufferProgramId(ids, condition, availability);
return cachedPasses.computeIfAbsent(Pair.of(finalId, availability), p -> {
@@ -1046,6 +1061,8 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
/** Availability used for every shadow pass draw and for the shadow program lookups at load time. */
private static final InputAvailability SHADOW_INPUTS = InputAvailability.of(true, true);
private static final InputAvailability LINE_INPUTS = InputAvailability.NONE;
@Override
public void onEntityRenderBoundary() {
GLSMHooks.resolvePendingProgram();
@@ -1061,7 +1078,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
}
public void beginPass(Pass pass) {
IrisDisplayListState.runProgramTransition(() -> beginPassNow(pass));
IrisDisplayListState.runProgramTransition(DeferredWorldRenderingPipeline::beginPassNow, this, pass);
}
private void beginPassNow(Pass pass) {
@@ -1399,6 +1416,9 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
private boolean instancingShadow;
private final Program[] instancedVariants = new Program[Instancing.VALUES.length];
private final boolean[] instancedVariantAttempted = new boolean[Instancing.VALUES.length];
@Nullable
private WideLineProgram wideLineProgram;
private boolean wideLineProgramAttempted;
private Pass(@Nullable Program program, GlFramebuffer framebufferBeforeTranslucents, GlFramebuffer framebufferAfterTranslucents,
@Nullable AlphaTestOverride alphaTestOverride, @Nullable BlendModeOverride blendModeOverride, @Nullable List<BufferBlendOverride> bufferBlendOverrides, boolean shadowViewport) {
@@ -1412,7 +1432,12 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
}
public void use() {
IrisDisplayListState.runProgramTransition(this::useNow);
IrisDisplayListState.runProgramTransition(Pass::useNow, this);
}
void rebindProgram() {
if (program != null) program.use();
DeferredWorldRenderingPipeline.this.customUniforms.push(this);
}
private void useNow() {
@@ -1494,6 +1519,17 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
return instancedVariants[i];
}
@Nullable
WideLineProgram wideLineProgram() {
if (!wideLineProgramAttempted) {
wideLineProgramAttempted = true;
if (instancingSourceName != null) {
wideLineProgram = sharedWideLineProgram(instancingSourceName, instancingAvailability, instancingShadow);
}
}
return wideLineProgram;
}
public void destroy() {
if (this.program != null) {
this.program.destroy();
@@ -1568,6 +1604,98 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
this.customUniforms.push(variant);
}
private record WideLineProgram(Program program, int lineWidthLocation, int screenSizeLocation) {}
@Nullable
private WideLineProgram sharedWideLineProgram(String sourceName, InputAvailability availability, boolean shadow) {
final SharedProgramKey key = new SharedProgramKey(sourceName, availability, shadow);
if (wideLinePrograms.containsKey(key)) return wideLinePrograms.get(key);
final WideLineProgram built = buildWideLineProgram(sourceName, availability, shadow);
wideLinePrograms.put(key, built);
return built;
}
@Nullable
private WideLineProgram buildWideLineProgram(String sourceName, InputAvailability availability, boolean shadow) {
final Map<PatchShaderType, String> transformed = wideLineTransforms.get(Pair.of(sourceName, availability));
if (transformed == null) {
return null;
}
final String name = sourceName + "_widelines";
try {
final ProgramBuilder builder = beginBuilder(name, transformed);
wireGbufferProgram(builder, availability, shadow);
final Program program = builder.build();
vertexWriteReplays.attach(name, program, transformed, (samplers, images) -> wireGbufferResources(samplers, images, availability, shadow));
this.customUniforms.mapholderToPass(builder, program);
final int id = program.getProgramId();
return new WideLineProgram(program, GLStateManager.glGetUniformLocation(id, "iris_LineWidth"), GLStateManager.glGetUniformLocation(id, "iris_ScreenSize"));
} catch (Exception e) {
Iris.logger.warn("Wide line program link failed for {}; lines there stay 1 px wide", sourceName, e);
return null;
}
}
@Nullable
private Pass passBeforeLines;
public boolean bindLineProgram() {
if (!shouldOverrideShaders() || DisplayListManager.isRecording()) {
return false;
}
GLSMHooks.resolvePendingProgram();
final Pass pass = current;
if (pass == null || pass.getProgram() == null || activeInstancing != Instancing.NONE
|| GLStateManager.getActiveProgram() != pass.getProgram().getProgramId()) {
return false;
}
final boolean shadow = currentCondition == RenderCondition.SHADOW || currentCondition == RenderCondition.SHADOW_TRANSLUCENT;
final Pass linePass = shadow ? pass : table.match(RenderCondition.LINES, LINE_INPUTS);
if (linePass.getProgram() == null) {
return false;
}
final boolean needsWidening = shadow || !packWidensLines;
final WideLineProgram wide = needsWidening ? linePass.wideLineProgram() : null;
if (needsWidening && wide == null) {
return false;
}
passBeforeLines = pass;
if (linePass != pass) {
beginPass(linePass);
}
if (wide != null) {
wide.program().use();
this.customUniforms.push(wide.program());
final var viewport = GLStateManager.getViewportState();
RenderSystem.uniform1f(wide.lineWidthLocation(), GLStateManager.getLineState().getWidth());
RenderSystem.uniform2f(wide.screenSizeLocation(), viewport.width, viewport.height);
}
return true;
}
public void restoreAfterLines() {
final Pass previous = passBeforeLines;
passBeforeLines = null;
if (previous == null) {
return;
}
if (current != previous) {
beginPass(previous);
} else {
previous.rebindProgram();
}
}
public void compileWideLinePrograms() {
table.match(RenderCondition.LINES, LINE_INPUTS).wideLineProgram();
final Pass shadowPass = table.match(RenderCondition.SHADOW, SHADOW_INPUTS);
if (shadowPass != null) shadowPass.wideLineProgram();
final Pass shadowWaterPass = table.match(RenderCondition.SHADOW_TRANSLUCENT, SHADOW_INPUTS);
if (shadowWaterPass != null) shadowWaterPass.wideLineProgram();
}
@Override
public void destroy() {
clearPendingSelection();
@@ -1612,6 +1740,9 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
}
}
}
for (WideLineProgram wide : wideLinePrograms.values()) {
if (wide != null) wide.program().destroy();
}
vertexWriteReplays.destroy();
if (shadowVoxelizationCompute != null) {
shadowVoxelizationCompute.destroy();
@@ -2444,6 +2575,31 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
return futures;
}
private static Map<Pair<String, InputAvailability>, CompletableFuture<Map<PatchShaderType, String>>>
submitWideLineTransforms(ProgramFallbackResolver resolver, boolean packWidensLines) {
final Map<Pair<String, InputAvailability>, CompletableFuture<Map<PatchShaderType, String>>> futures = new HashMap<>();
if (!packWidensLines) {
submitWideLineTransform(futures, resolver.resolveNullable(ProgramId.Line), LINE_INPUTS);
}
submitWideLineTransform(futures, resolver.resolveNullable(ProgramId.Shadow), SHADOW_INPUTS);
submitWideLineTransform(futures, resolver.resolveNullable(ProgramId.ShadowWater), SHADOW_INPUTS);
return futures;
}
private static void submitWideLineTransform(Map<Pair<String, InputAvailability>, CompletableFuture<Map<PatchShaderType, String>>> futures,
@Nullable ProgramSource source, InputAvailability inputs) {
if (source == null || futures.containsKey(Pair.of(source.getName(), inputs))) {
return;
}
futures.put(Pair.of(source.getName(), inputs), Iris.ShaderTransformExecutor.submitTracked(() -> TransformPatcher.patchAttributesWideLines(
source.getVertexSource().orElse(null),
source.getGeometrySource().orElse(null),
source.getTessControlSource().orElse(null),
source.getTessEvalSource().orElse(null),
source.getFragmentSource().orElse(null),
inputs)));
}
private static final ProgramId[] INSTANCED_PROGRAM_IDS = {
ProgramId.Block, ProgramId.BlockTrans, ProgramId.Entities, ProgramId.EntitiesTrans,
ProgramId.Shadow, ProgramId.ShadowWater, ProgramId.ArmorGlint
@@ -2469,7 +2625,8 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
private static final String[] MV_BUILTINS = {
"gl_ModelViewMatrix", "gl_ModelViewMatrixInverse",
"gl_ModelViewProjectionMatrix", "gl_ModelViewProjectionMatrixInverse",
"gl_NormalMatrix", "ftransform"
"gl_NormalMatrix", "ftransform",
"modelViewMatrix", "modelViewMatrixInverse", "normalMatrix"
};
static boolean referencesMvBuiltins(String source) {
@@ -10,6 +10,8 @@ import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.profiling.Tracy;
import com.gtnewhorizons.angelica.profiling.RenderClassTimings;
import com.gtnewhorizons.angelica.rendering.tesr.ModelPartBatcher;
import com.gtnewhorizons.angelica.rendering.tesr.PendingTesrDraws;
import com.gtnewhorizons.angelica.rendering.tesr.SectionBuiltBlockEntity;
import com.gtnewhorizons.angelica.rendering.tesr.TesrBatchRenderer;
import com.gtnewhorizons.angelica.rendering.tesr.TileEntityLight;
import com.gtnewhorizons.angelica.glsm.RenderSystem;
@@ -771,8 +773,13 @@ public class ShadowRenderer {
}
}
}
if (tile instanceof SectionBuiltBlockEntity built && built.angelica$drawBuilt(
(double) tile.xCoord - cameraX, (double) tile.yCoord - cameraY, (double) tile.zCoord - cameraZ)) {
return;
}
final World world = tile.getWorldObj();
int brightness = TileEntityLight.packedLight(world, tile.xCoord, tile.yCoord, tile.zCoord, world.getLightBrightnessForSkyBlocks(tile.xCoord, tile.yCoord, tile.zCoord, 0));
PendingTesrDraws.beforeTileEntity(tile);
GLStateManager.setLightmapTextureCoords(GL13.GL_TEXTURE1, (float) brightness % 65536, (float) brightness / 65536);
GLStateManager.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
TileEntityRendererDispatcher.instance.renderTileEntityAt(tile,
@@ -808,6 +815,7 @@ public class ShadowRenderer {
GbufferPrograms.beginBlockEntities();
GbufferPrograms.setBlockEntityDefaults();
ModelPartBatcher.INSTANCE.begin(ModelPartBatcher.Mode.BLOCK_ENTITIES, true);
PendingTesrDraws.beginPass();
for (int b = 0, bn = visibleTileEntities.size(); b < bn; b++) {
final List<TileEntity> bucket = visibleTileEntities.get(b);
@@ -840,6 +848,7 @@ public class ShadowRenderer {
}
}
PendingTesrDraws.endPass();
flushShadowModelParts();
TesrBatchRenderer.INSTANCE.flush();
@@ -11,7 +11,9 @@ import org.taumc.glsl.grammar.GLSLLexer;
import org.taumc.glsl.grammar.GLSLParser;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* Implements AttributeShaderTransformer using glsl-transformer AST
@@ -39,17 +41,28 @@ class AttributeTransformer {
final boolean cubeVertex = vertex && parameters.instancing == Instancing.CUBE;
final boolean particleVertex = vertex && parameters.instancing == Instancing.PARTICLE;
final boolean weatherVertex = vertex && parameters.instancing == Instancing.WEATHER;
final boolean lineVertex = vertex && parameters.wideLines;
final boolean matrixVertex = vertex && parameters.instancing.hasInstanceHead();
final boolean wantsMvInverse = matrixVertex && transformer.containsCall("gl_ModelViewMatrixInverse");
final Set<String> declaredInterface = declaredInterface(transformer);
CoreTransformHelper.injectMatrixUniforms(transformer, vertex ? parameters.instancing : Instancing.NONE);
aliasIfUsed(transformer, "projectionMatrix", "iris_ProjectionMatrix");
aliasIfUsed(transformer, "modelViewMatrix", "iris_ModelViewMatrix");
aliasIfUsed(transformer, "normalMatrix", "iris_NormalMatrix");
CORE_PROFILE_MATRICES.forEach((name, irisName) -> {
if (claimCoreProfileName(transformer, declaredInterface, name)) {
transformer.rename(name, irisName);
}
});
final boolean wantsMvInverse = matrixVertex && transformer.containsCall("iris_ModelViewMatrixInverse");
if (parameters.type == ShaderType.VERTEX) {
mapCoreProfileInputs(transformer, declaredInterface);
if (!particleVertex && !weatherVertex) {
transformer.injectVariable("layout(location = 0) in vec4 iris_Vertex;");
if (lineVertex) {
transformer.injectVariable("layout(location = 0) in vec4 iris_LineVertex;");
transformer.injectVariable("vec4 iris_Vertex = vec4(0.0, 0.0, 0.0, 1.0);");
} else {
transformer.injectVariable("layout(location = 0) in vec4 iris_Vertex;");
}
transformer.injectVariable("layout(location = 1) in vec4 iris_Color;");
if (cubeVertex) {
transformer.injectVariable("vec4 iris_MultiTexCoord0;");
@@ -62,15 +75,16 @@ class AttributeTransformer {
transformer.injectVariable("layout(location = " + SECONDARY_UV + ") in vec4 iris_MultiTexCoord1;");
}
}
transformer.injectVariable("layout(location = 4) in vec3 iris_Normal;");
if (lineVertex) {
transformer.injectVariable("layout(location = 4) in vec3 iris_LineDirection;");
transformer.injectVariable("const vec3 iris_Normal = vec3(0.0, 0.0, 1.0);");
} else {
transformer.injectVariable("layout(location = 4) in vec3 iris_Normal;");
}
transformer.rename("gl_Vertex", "iris_Vertex");
transformer.replaceExpression("gl_Color", matrixVertex ? "(iris_Color * iris_ColorModulator * iris_InstColor)" : "(iris_Color * iris_ColorModulator)");
transformer.rename("gl_Normal", "iris_Normal");
aliasIfUsed(transformer, "vaNormal", "iris_Normal");
if (transformer.containsCall("vaPosition") && !transformer.hasVariable("vaPosition")) {
transformer.replaceExpression("vaPosition", "iris_Vertex.xyz");
}
// ftransform() = gl_ModelViewProjectionMatrix * gl_Vertex
transformer.renameFunctionCall("ftransform", "iris_ftransform");
@@ -129,6 +143,42 @@ class AttributeTransformer {
transformer.prependMain(init.toString());
}
}
if (parameters.wideLines) {
widenLines(transformer, vertex);
}
}
private static void widenLines(Transformer transformer, boolean vertex) {
transformer.injectVariable("const mat4 iris_VIEW_SCALE = mat4(mat3(1.0 - (1.0 / 256.0)));");
transformer.replaceExpression("iris_ModelViewMatrix", "(iris_VIEW_SCALE * iris_ModelViewMatrix)", GLSLParser::postfix_expression);
if (!vertex) {
return;
}
transformer.injectVariable("uniform float iris_LineWidth;");
transformer.injectVariable("uniform vec2 iris_ScreenSize;");
transformer.rename("main", "irisMain");
transformer.injectAtEnd("void iris_widen_lines(vec4 linePosStart, vec4 linePosEnd) {"
+ " vec3 ndc1 = linePosStart.xyz / linePosStart.w;"
+ " vec3 ndc2 = linePosEnd.xyz / linePosEnd.w;"
+ " vec2 lineScreenDirection = normalize((ndc2.xy - ndc1.xy) * iris_ScreenSize);"
+ " vec2 lineOffset = vec2(-lineScreenDirection.y, lineScreenDirection.x) * iris_LineWidth / iris_ScreenSize;"
+ " if (lineOffset.x < 0.0) { lineOffset *= -1.0; }"
+ " if (gl_VertexID % 2 == 0) {"
+ " gl_Position = vec4((ndc1 + vec3(lineOffset, 0.0)) * linePosStart.w, linePosStart.w);"
+ " } else {"
+ " gl_Position = vec4((ndc1 - vec3(lineOffset, 0.0)) * linePosStart.w, linePosStart.w);"
+ " } }");
transformer.injectAtEnd("void main() {"
+ " iris_Vertex = iris_LineVertex + vec4(iris_LineDirection, 0.0);"
+ " irisMain();"
+ " vec4 linePosEnd = gl_Position;"
+ " gl_Position = vec4(0.0);"
+ " iris_Vertex = iris_LineVertex;"
+ " irisMain();"
+ " vec4 linePosStart = gl_Position;"
+ " iris_widen_lines(linePosStart, linePosEnd); }");
}
private static final int PRIMARY_UV = VertexFormatElement.Usage.PRIMARY_UV.getAttributeLocation();
@@ -200,9 +250,47 @@ class AttributeTransformer {
transformer.replaceExpression(name, replacement);
}
private static void aliasIfUsed(Transformer transformer, String modernName, String irisName) {
if (transformer.containsCall(modernName) && !transformer.hasVariable(modernName)) {
transformer.rename(modernName, irisName);
private static final Map<String, String> CORE_PROFILE_MATRICES = Map.of(
"projectionMatrix", "iris_ProjectionMatrix",
"projectionMatrixInverse", "iris_ProjectionMatrixInverse",
"modelViewMatrix", "iris_ModelViewMatrix",
"modelViewMatrixInverse", "iris_ModelViewMatrixInverse",
"normalMatrix", "iris_NormalMatrix",
"textureMatrix", "iris_TextureMatrix");
private static Set<String> declaredInterface(Transformer transformer) {
final Set<String> names = new HashSet<>(transformer.findQualifiers(GLSLLexer.UNIFORM).keySet());
names.addAll(transformer.findQualifiers(GLSLLexer.IN).keySet());
names.addAll(transformer.findQualifiers(GLSLLexer.ATTRIBUTE).keySet());
return names;
}
private static boolean claimCoreProfileName(Transformer transformer, Set<String> declaredInterface, String name) {
if (!transformer.containsCall(name)) {
return false;
}
if (declaredInterface.contains(name)) {
transformer.removeVariable(name);
return true;
}
return !transformer.hasVariable(name);
}
private static void mapCoreProfileInputs(Transformer transformer, Set<String> declaredInterface) {
final boolean overlayIsInt = transformer.findType("vaUV1") == GLSLLexer.IVEC2;
final boolean lightIsInt = transformer.findType("vaUV2") == GLSLLexer.IVEC2;
mapCoreProfileInput(transformer, declaredInterface, "vaPosition", "gl_Vertex.xyz");
mapCoreProfileInput(transformer, declaredInterface, "vaColor", "gl_Color");
mapCoreProfileInput(transformer, declaredInterface, "vaNormal", "gl_Normal");
mapCoreProfileInput(transformer, declaredInterface, "vaUV0", "gl_MultiTexCoord0.xy");
// There is no overlay attribute (entityColor carries the hurt tint), so every vertex reads "no overlay"
mapCoreProfileInput(transformer, declaredInterface, "vaUV1", overlayIsInt ? "ivec2(0, 10)" : "vec2(0.0, 10.0)");
mapCoreProfileInput(transformer, declaredInterface, "vaUV2", lightIsInt ? "ivec2(gl_MultiTexCoord1.xy)" : "gl_MultiTexCoord1.xy");
}
private static void mapCoreProfileInput(Transformer transformer, Set<String> declaredInterface, String name, String replacement) {
if (claimCoreProfileName(transformer, declaredInterface, name)) {
transformer.replaceExpression(name, replacement, GLSLParser::postfix_expression);
}
}
}
@@ -146,6 +146,10 @@ public class TransformPatcher {
return transform(vertex, geometry, tessControl, tessEval, fragment, new AttributeParameters(Patch.ATTRIBUTES, geometry != null, tessControl != null, inputs, scrollGlint, instancing));
}
public static Map<PatchShaderType, String> patchAttributesWideLines(String vertex, String geometry, String tessControl, String tessEval, String fragment, InputAvailability inputs) {
return transform(vertex, geometry, tessControl, tessEval, fragment, new AttributeParameters(Patch.ATTRIBUTES, geometry != null, tessControl != null, inputs, false, Instancing.NONE, true));
}
public static Map<PatchShaderType, String> patchAttributes(String vertex, String geometry, String tessControl, String tessEval, String fragment, InputAvailability inputs) {
return patchAttributes(vertex, geometry, tessControl, tessEval, fragment, inputs, false);
}
@@ -12,15 +12,21 @@ public class AttributeParameters extends Parameters {
public final InputAvailability inputs;
public final boolean scrollGlint;
public final Instancing instancing;
public final boolean wideLines;
// WARNING: adding new fields requires updating hashCode and equals methods!
public AttributeParameters(Patch patch, boolean hasGeometry, boolean hasTesselation, InputAvailability inputs, boolean scrollGlint, Instancing instancing) {
this(patch, hasGeometry, hasTesselation, inputs, scrollGlint, instancing, false);
}
public AttributeParameters(Patch patch, boolean hasGeometry, boolean hasTesselation, InputAvailability inputs, boolean scrollGlint, Instancing instancing, boolean wideLines) {
super(patch, null);
this.hasGeometry = hasGeometry;
this.hasTesselation = hasTesselation;
this.inputs = inputs;
this.scrollGlint = scrollGlint;
this.instancing = instancing;
this.wideLines = wideLines;
}
@Override
@@ -31,7 +37,7 @@ public class AttributeParameters extends Parameters {
@Override
public void appendDiskKey(ShaderDiskCache.Key k) {
super.appendDiskKey(k);
k.b(hasGeometry).b(hasTesselation).str(inputs == null ? null : inputs.name()).b(scrollGlint).str(instancing.name());
k.b(hasGeometry).b(hasTesselation).str(inputs == null ? null : inputs.name()).b(scrollGlint).str(instancing.name()).b(wideLines);
}
@Override
@@ -42,6 +48,7 @@ public class AttributeParameters extends Parameters {
result = prime * result + (hasTesselation ? 1231 : 1237);
result = prime * result + (scrollGlint ? 1231 : 1237);
result = prime * result + instancing.ordinal();
result = prime * result + (wideLines ? 1231 : 1237);
result = prime * result + ((inputs == null) ? 0 : inputs.hashCode());
return result;
}
@@ -63,11 +70,10 @@ public class AttributeParameters extends Parameters {
return false;
if (instancing != other.instancing)
return false;
if (inputs == null) {
if (other.inputs != null)
return false;
} else if (!inputs.equals(other.inputs))
if (wideLines != other.wideLines)
return false;
return true;
}
if (inputs == null) {
return other.inputs == null;
} else return inputs.equals(other.inputs);
}
}