forked from IrisShaders/Iris
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '1.20.1-new' of https://github.com/IrisShaders/Iris into…
… 1.20.1-new
- Loading branch information
Showing
809 changed files
with
13,605 additions
and
13,832 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Iris 1.7.0 Changelog | ||
|
||
## New Features | ||
|
||
- Added Tessellation shaders. These new shader types allow you to subdivide and add more detail to geometry. | ||
- These take the form of `.tcs` and `.tes` shaders respectively for control and evaluation. See the Khronos wiki for | ||
details. | ||
- Added an attribute that allows you to see the emission value of a block. It is stored in `at_midBlock.w` and ranges | ||
from 0-15. | ||
- Added `cameraPositionInt` and `cameraPositionFract` for better precision, along with their respective previous | ||
uniforms. *These values are unshifted, unlike the normal ones.* | ||
- Added `occlusion.culling` option. | ||
- Added support for Distant Horizons 2.0.3. This version is not officially released yet. | ||
- Added debug groups. This groups together information in RenderDoc for easy viewing. | ||
- Added support for Indirect Compute shaders. This allows you to dispatch a compute shader with the work group amount | ||
specified from a SSBO. | ||
- To use this, you must use `indirect.pass = bufferObjectNumber offsetInBuffer` in shaders.properties, and the | ||
object at offset in the | ||
SSBO must be an `uvec3`. | ||
- ***If you do not do this, your PC will most likely crash trying to dispatch 2147483647^3 work groups. Don't do | ||
that.*** | ||
- Added a keybind to see a wireframe view of the world. This is only usable in singleplayer. | ||
- Added some uniforms, mostly `isRightHanded`. | ||
|
||
## Technical Changes | ||
|
||
- Relocated Iris from `net.coderbot` to `net.irisshaders` | ||
- This will break any mods depending on Iris 1.6.17 and below. | ||
- Added whitespace detection code to property files. | ||
- This fixes SEUS PTGI GFME. | ||
- Redesigned the pipeline layout. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Debugging Shader Packs With Iris | ||
|
||
Iris has some built-in functionality that can assist you in developing a shader pack for Iris. This page will give some context and explain how to use these features. | ||
|
||
## Shader Code Transformation | ||
|
||
Iris uses [glsl-transformer](https://github.com/IrisShaders/glsl-transformer) to apply various patches to the GLSL code of a shader pack before sending it to the driver for compilation. There are generally two types of patches being applied; those necessary for compatibility with Iris, and compatibility patches that are done to make sure the shader pack works on as many systems as possible. For reference, the compatibility patches can be found in [`CompatibilityTransformer`](/src/main/java/net/irisshaders/iris/pipeline/transform/CompatibilityTransformer.java) while the other patches are grouped into the other files. | ||
|
||
Some terms: | ||
|
||
- **Translation Unit**: The GLSL code in a single file | ||
- **External Declaration**: Anything at the top level of a translation unit, like a declaration or a function definition | ||
- **Statement**: A single line of code in a function | ||
- **Declaration** (Statement): The declaration of something in a function scope | ||
- **Expression**: Code that evaluates to a value | ||
|
||
### Effects of Shader Code Transformation | ||
|
||
Roughly, glsl-transformer parses the GLSL code into an internal representation called an AST, applies the patches, and then prints the code back into a string. For better performance, the result of the patches is cached on multiple levels throughout the system. This results in faster loading times for shader packs that have already been loaded before or that have only been changed slightly. | ||
|
||
Since the internal representation omits formatting, comments, whitespace and preprocessor directives (not including extensions and the version marker of course), none of these are preserved when printing the code back into a string. Because of this, the code that is printed back out is not necessarily the same as the code that was originally provided. This can make debugging shader packs a bit more difficult, since the line numbers in the error messages will not match up with the line numbers in the source code. A feature called line annotation is being worked on in glsl-transformer that aims to fix this issue by inserting `#line` directives into the code. In the interim, enabling the printing of the patched code provides a workaround for this issue (See [Pretty Printing](#pretty-printing)). Additionally, non-essential whitespace is omitted from the output for better performance, this can also be enabled by the user if required. | ||
|
||
- The version statement is required. See [Version Statement](#version-statement) for more information. | ||
- It is forbidden to use Iris internals, namely variables and functions prefixed with `iris_`, `irisMain` or `moj_import`. An exception will be thrown if these are encountered in the source code. | ||
|
||
### Compatibility Patches | ||
|
||
Since Iris aims to be compatible with many shader packs, hardware configurations and software environments, it is necessary to apply some compatibility patches to the shader packs to ensure wide compatibility. All known graphics drivers have some bugs or quirks that can cause issues with shader packs, and Iris aims to work around these issues where it is feasible. | ||
|
||
The goal is to present a maximally uniform interface to the shader pack by smoothing out the differences between the drivers. Since many existing shader packs have been developed for Nvidia drivers and hardware, they sometimes rely on Nvidia-specific quirks. Furthermore, in some situations drivers may be more stringent by either adhering to the GLSL specification more closely or through their own limitations. Of course there are also bugs in the drivers that may need to be worked around. Some of these issues can be fixed by adding or removing specific pieces of code if necessary. | ||
|
||
Naturally, shader packs that are currently in development could simply be fixed by their maintainers, but not all shader packs are still actively developed even if they have a significant following. Some shader packs don't test on certain systems which can also create incompatibilities that are often fixable through patching. **The compatibility patches are only applied if problematic pieces of code are detected, and they always print a warning message to the log prefixed with `(CompatibilityTransformer)` each time they do something**. | ||
|
||
The following is a list of the compatibility patches that are applied to shader packs. Additional information on the specifics of each patch can be found in the [source code](/src/main/java/net/irisshaders/iris/pipeline/transform/transformer/CompatibilityTransformer.java). | ||
|
||
- Empty external declarations, which are just a single semicolon at the global level `;`, are removed. This is a workaround for a bug where they are not recognized as legal external declarations by some drivers. A semicolon following a function definition like `void main() {};` is in fact not part of the function definition but its own external declaration, namely an empty one. | ||
- The `const` keyword is removed from declaration (statements) that refer to `const` parameters in their initializer expression, the part that comes after the `=`. Parameters with the `const` qualifier are not constant but rather immutable, meaning they may not be assigned to. Declarations with `const` are, depending on the driver and GLSL version, treated as constant meaning they only accept expressions that can be evaluated at compile time. Immutable parameters don't fulfill this requirement and thus cause a compilation error when they are used in the initializer of a constant. This is done to ensure better compatibility drivers' varying behavior at different versions. See Section 4.3.2 on Constant Qualifiers and Section 4.3.3 on Constant Expressions in the GLSL 4.1 and 4.2 specifications for more information. Additionally, see https://wiki.shaderlabs.org/wiki/Compiler_Behavior_Notes for the varying behavior of drivers. | ||
- When an input variable, declared with `in`, is declared and used in a geometry or fragment shader, but there is no corresponding output variable in the shader of the previous stage, some drivers will error. To mitigate this, the missing declaration is inserted and initialized with a default value at the top of the `main` function. | ||
- If the out declaration does exist but is never assigned to, an initialization is created. If the out declaration has an array type, compatibility patching is skipped for it and a warning is produced. | ||
- When the types of declared and used input and output variables don't match, some drivers will error. To mitigate this, the type of the declaration is changed to match the type in the later stage (the fragment shader). An internal variable with the original type is added so that the code can assign a value to it. At the end of the `main` function this value is either truncated or padded to patch the expected type. | ||
- Unused functions are removed. Some drivers don't do certain semantic checks on unused functions which may result in errors when the code is then compiled with stricter drivers that do perform these checks before unused code removal. This heuristic is not perfect and may fail to remove unreachable functions that are used in another unreachable function. | ||
- In struct bodies (of the form `{ <struct members> }`) unsized array specifiers are moved from the type to the identifier of the member. A member `int[] foo` is transformed into `int foo[]`. This is done because the specification only requires support for the latter form while the former is unsupported by some drivers. | ||
|
||
### Version Statement | ||
|
||
The version statement `#version <number> <profile>` where the number is required, but the profile is optionally one of `core` or `compatibility` is patched on versions starting with 1.17. For reference, the relevant code can be found in [`TransformPatcher`](/src/main/java/net/irisshaders/iris/pipeline/transform/TransformPatcher.java) in the section afer `Root.indexBuildSession`. If the core profile is used or the profile is missing, and the version is at least 150, then only compatibility patches are applied, as long as the shader is not a vertex shader. On vertex shaders an exception is thrown in this case. They are required to either use a version lower than 330, which is then changed to be exactly 330, or declare the compatibility profile, which is then changed to the core profile. | ||
|
||
The profile of compute shaders is always set to core. | ||
|
||
## Debug Mode | ||
|
||
The debug mode can be activated by pressing CTRL + D or Command + D on macOS on the shader selection screen or by setting the option `enableDebugOptions=true` in Iris' settings file. With this mode enabled a number of debug features are activated. | ||
|
||
- Pretty printing: The patched shader pack code is saved to the `patched_shaders` folder that is created game instance folder. Any previous files in this folder will be deleted. The files are named based on the input files they originate from and are numbered based on their order of processing. In debug mode, the code is printed with indentation whitespace. Otherwise, you'll notice that the code has been effectively minified. Also note that enabling this mode will slow down patching somewhat since more work is being done and files are written to disk. | ||
- Printing of errored programs: When the transformer fails to parse a shader pack or an exception occurs during transformation, the exception is printed in the console but with debug mode enabled the program the error originated from is printed as `errored_program` in `patched_shaders`. | ||
- Unused functions aren't removed in debug mode | ||
|
||
## List of GLSL Language Specifications | ||
|
||
- [GLSL 1.10](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.1.10.pdf) | ||
- [GLSL 1.20](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.1.20.pdf) | ||
- [GLSL 1.30](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.1.30.pdf) | ||
- [GLSL 1.40](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.1.40.pdf) | ||
- [GLSL 1.50](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.1.50.pdf) | ||
- [GLSL 3.30](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.3.30.pdf) | ||
- [GLSL 4.00](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.00.pdf) | ||
- [GLSL 4.10](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.10.pdf) | ||
- [GLSL 4.20](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.20.pdf) | ||
- [GLSL 4.30](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.30.pdf) | ||
- [GLSL 4.40](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.40.pdf) | ||
- [GLSL 4.50](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.50.pdf) | ||
- [GLSL 4.60](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.60.pdf) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package net.irisshaders.iris; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.io.IOException; | ||
import java.net.URI; | ||
|
||
public class LaunchWarn { | ||
public static void main(String[] args) { | ||
// TODO: make this translatable | ||
String message = DesktopBuildConfig.IS_SHARED_BETA | ||
? "If you're seeing this, you didn't read instructions.\n (Hint: This isn't a installer or a Forge mod. It's a Fabric mod.)" | ||
: "This file is the Fabric version of Iris, meant to be installed as a mod. Would you like to get the Iris Installer instead?"; | ||
String fallback = DesktopBuildConfig.IS_SHARED_BETA | ||
? "If you're seeing this, you didn't read instructions.\n (Hint: This isn't a installer or a Forge mod. It's a Fabric mod.)" | ||
: "This file is the Fabric version of Iris, meant to be installed as a mod. Please download the Iris Installer from https://irisshaders.dev."; | ||
if (GraphicsEnvironment.isHeadless()) { | ||
System.err.println(fallback); | ||
} else { | ||
try { | ||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); | ||
} catch (ReflectiveOperationException | UnsupportedLookAndFeelException ignored) { | ||
// Ignored | ||
} | ||
|
||
if (Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { | ||
int option = JOptionPane.showOptionDialog(null, message, "Iris Installer", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null); | ||
|
||
if (option == JOptionPane.YES_OPTION) { | ||
try { | ||
Desktop.getDesktop().browse(URI.create("https://irisshaders.dev")); | ||
} catch (IOException e) { | ||
System.out.println("Welp; we're screwed."); | ||
e.printStackTrace(); | ||
} | ||
} | ||
} else { | ||
// Fallback for Linux, etc users with no "default" browser | ||
JOptionPane.showMessageDialog(null, fallback); | ||
} | ||
} | ||
|
||
System.exit(0); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/disabledTest/java/kroppeb/stareval/parser/IrisParserOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package kroppeb.stareval.parser; | ||
|
||
public class IrisParserOptions { | ||
public static final ParserOptions options; | ||
static final BinaryOp Multiply = new BinaryOp("multiply", 0); | ||
static final BinaryOp Divide = new BinaryOp("divide", 0); | ||
static final BinaryOp Remainder = new BinaryOp("remainder", 0); | ||
static final BinaryOp Add = new BinaryOp("add", 1); | ||
static final BinaryOp Subtract = new BinaryOp("subtract", 1); | ||
static final BinaryOp Equals = new BinaryOp("equals", 2); | ||
static final BinaryOp NotEquals = new BinaryOp("notEquals", 2); | ||
static final BinaryOp LessThan = new BinaryOp("lessThan", 2); | ||
static final BinaryOp MoreThan = new BinaryOp("moreThan", 2); | ||
static final BinaryOp LessThanOrEquals = new BinaryOp("lessThanOrEquals", 2); | ||
static final BinaryOp MoreThanOrEquals = new BinaryOp("moreThanOrEquals", 2); | ||
static final BinaryOp And = new BinaryOp("or", 3); | ||
static final BinaryOp Or = new BinaryOp("and", 3); | ||
static final UnaryOp Not = new UnaryOp("not"); | ||
static final UnaryOp Negate = new UnaryOp("negate"); | ||
|
||
static { | ||
final ParserOptions.Builder builder = new ParserOptions.Builder(); | ||
builder.addBinaryOp("*", Multiply); | ||
builder.addBinaryOp("/", Divide); | ||
builder.addBinaryOp("%", Remainder); | ||
|
||
builder.addBinaryOp("+", Add); | ||
builder.addBinaryOp("-", Subtract); | ||
|
||
builder.addBinaryOp("==", Equals); | ||
builder.addBinaryOp("!=", NotEquals); | ||
builder.addBinaryOp("<", LessThan); | ||
builder.addBinaryOp(">", MoreThan); | ||
builder.addBinaryOp("<=", LessThanOrEquals); | ||
builder.addBinaryOp(">=", MoreThanOrEquals); | ||
|
||
builder.addBinaryOp("&&", And); | ||
builder.addBinaryOp("||", Or); | ||
|
||
builder.addUnaryOp("!", Not); | ||
builder.addUnaryOp("-", Negate); | ||
|
||
options = builder.build(); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/disabledTest/java/kroppeb/stareval/parser/ParserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package kroppeb.stareval.parser; | ||
|
||
import kroppeb.stareval.element.Element; | ||
import kroppeb.stareval.exception.ParseException; | ||
import kroppeb.stareval.element.ExpressionElement; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.CsvFileSource; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
class ParserTest { | ||
private static ExpressionElement parse(String string) throws ParseException { | ||
return Parser.parse(string, IrisParserOptions.options); | ||
} | ||
|
||
@ParameterizedTest | ||
@CsvFileSource(resources = "/shouldBeAbleToBeParsed.csv", delimiter = ';') | ||
void checkIfValidExpressionsParse(String input) throws ParseException { | ||
parse(input); | ||
} | ||
|
||
@ParameterizedTest | ||
@CsvFileSource(resources = "/shouldNotBeAbleToBeParsed.csv", delimiter = ';') | ||
void checkIfInvalidExpressionsDontParse(String input) { | ||
try { | ||
parse(input); | ||
} catch (ParseException parseException) { | ||
parseException.printStackTrace(); | ||
return; | ||
} catch (RuntimeException runtimeException) { | ||
fail("Unexpected exception has been thrown", runtimeException); | ||
return; | ||
} | ||
fail("No exception has been thrown"); | ||
} | ||
|
||
@ParameterizedTest | ||
@CsvFileSource(resources = "/fullyEquivalent.csv", delimiter = ';') | ||
void checkOrderOfOperationsParse(String input1, String input2) throws ParseException { | ||
Element exp1 = parse(input1); | ||
Element exp2 = parse(input2); | ||
assertEquals(exp1.toString(), exp2.toString()); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/disabledTest/java/net/irisshaders/iris/test/IrisTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package net.irisshaders.iris.test; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import net.irisshaders.iris.Iris; | ||
import net.irisshaders.iris.helpers.StringPair; | ||
import net.irisshaders.iris.shaderpack.ShaderPack; | ||
import org.junit.jupiter.api.Assertions; | ||
|
||
import java.net.URISyntaxException; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
public class IrisTests { | ||
public static ImmutableList<StringPair> TEST_ENVIRONMENT_DEFINES = ImmutableList.of( | ||
new StringPair("MC_OS_WINDOWS", ""), | ||
new StringPair("MC_VERSION", "11605"), | ||
new StringPair("MC_GL_VERSION", "460"), | ||
new StringPair("MC_GLSL_VERSION", "460"), | ||
new StringPair("MC_GL_RENDERER_GEFORCE", ""), | ||
new StringPair("MC_GL_VENDOR_NVIDIA", ""), | ||
new StringPair("MC_RENDER_QUALITY", "1.0"), | ||
new StringPair("MC_SHADOW_QUALITY", "1.0"), | ||
new StringPair("MC_NORMAL_MAP", ""), | ||
new StringPair("MC_SPECULAR_MAP", ""), | ||
new StringPair("MC_HAND_DEPTH", "0.125") | ||
); | ||
|
||
static { | ||
Iris.testing = true; | ||
} | ||
|
||
public static ShaderPack loadPackOrFail(String name) { | ||
try { | ||
return new ShaderPack(IrisTests.getTestShaderPackPath(name), TEST_ENVIRONMENT_DEFINES); | ||
} catch (Exception e) { | ||
Assertions.fail("Couldn't load test shader pack " + name, e); | ||
throw new AssertionError(); | ||
} | ||
} | ||
|
||
public static Path getTestShaderPackPath(String name) { | ||
try { | ||
return Paths.get(IrisTests.class.getResource("/shaderpacks/" + name + "/shaders/").toURI()); | ||
} catch (URISyntaxException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
Oops, something went wrong.