├── .github
└── workflows
│ └── build.yml
├── .gitignore
├── LICENSE
├── README.md
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
└── main
├── java
└── net
│ └── vulkanmod
│ ├── Initializer.java
│ ├── config
│ ├── Config.java
│ ├── CyclingOption.java
│ ├── Option.java
│ ├── OptionList2.java
│ ├── OptionScreenV.java
│ ├── Options.java
│ ├── OptionsList.java
│ ├── RangeOption.java
│ ├── SliderWidgetImpl.java
│ ├── SwitchOption.java
│ ├── VideoResolution.java
│ ├── VideoSettingsScreen.java
│ └── widget
│ │ ├── CustomButtonWidget.java
│ │ ├── CyclingOptionWidget.java
│ │ ├── OptionWidget.java
│ │ ├── RangeOptionWidget.java
│ │ └── SwitchOptionWidget.java
│ ├── gl
│ ├── TextureMap.java
│ └── Util.java
│ ├── interfaces
│ ├── ExtendedVertexBuilder.java
│ ├── FrustumMixed.java
│ ├── ModelPartCubeMixed.java
│ ├── ShaderMixed.java
│ ├── VAbstractTextureI.java
│ ├── VertexFormatMixed.java
│ └── math
│ │ └── Vec3Extended.java
│ ├── mixin
│ ├── ClientLevelM.java
│ ├── MixinPlugin.java
│ ├── WindowMixin.java
│ ├── chunk
│ │ ├── DirectionMixin.java
│ │ ├── FrustumMixin.java
│ │ ├── LevelRendererMixin.java
│ │ └── VisibilitySetMixin.java
│ ├── compatibility
│ │ ├── EffectInstanceM.java
│ │ └── UniformM.java
│ ├── debug
│ │ ├── ChunkBorderRendererM.java
│ │ ├── DebugHudM.java
│ │ ├── GlDebugInfoM.java
│ │ └── KeyboardHandlerM.java
│ ├── gui
│ │ ├── ChatHudM.java
│ │ ├── DebugHudM.java
│ │ └── InGameHudM.java
│ ├── math
│ │ ├── Matrix4fM.java
│ │ └── internal
│ │ │ ├── Matrix4f.java
│ │ │ └── Vertex3fM.java
│ ├── model
│ │ ├── ModelPartCubeM.java
│ │ └── ModelPartM.java
│ ├── render
│ │ ├── BakedQuadFactoryM.java
│ │ ├── BufferBuilderM.java
│ │ ├── BufferRendererM.java
│ │ ├── FramebufferMixin.java
│ │ ├── GameRendererMixin.java
│ │ ├── GlProgramManagerMixin.java
│ │ ├── GlStateManagerM.java
│ │ ├── IndexTypeMixin.java
│ │ ├── LevelRendererMixin.java
│ │ ├── MinecraftMixin.java
│ │ ├── RenderSystemMixin.java
│ │ ├── ShaderMixin.java
│ │ ├── VertexBufferM.java
│ │ ├── VertexConsumerM.java
│ │ ├── VertexFormatMixin.java
│ │ └── WindowFramebufferMixin.java
│ ├── screen
│ │ └── OptionsScreenM.java
│ ├── texture
│ │ ├── MAbstractTexture.java
│ │ ├── MDynamicTexture.java
│ │ ├── MFontTexture.java
│ │ ├── MLightMap.java
│ │ ├── MNativeImage.java
│ │ ├── MOverlayTexture.java
│ │ ├── MPlayerSkinTexture.java
│ │ ├── MSimpleTexture.java
│ │ ├── MSpriteAtlasTexture.java
│ │ ├── MTextureManager.java
│ │ └── MTextureUtil.java
│ ├── util
│ │ └── ScreenshotRecorderM.java
│ └── vertex
│ │ ├── SpriteCoordinateExpanderM.java
│ │ └── VertexConsumersM.java
│ ├── model
│ └── CubeModel.java
│ ├── render
│ ├── Profiler.java
│ ├── VBO.java
│ ├── chunk
│ │ ├── ChunkArea.java
│ │ ├── ChunkAreaManager.java
│ │ ├── ChunkGrid.java
│ │ ├── ChunkRenderer.java
│ │ ├── ChunkTask.java
│ │ ├── RenderSection.java
│ │ ├── TaskDispatcher.java
│ │ ├── VFrustum.java
│ │ ├── WorldRenderer.java
│ │ └── util
│ │ │ ├── ChunkQueue.java
│ │ │ ├── CircularIntList.java
│ │ │ └── Util.java
│ ├── gui
│ │ └── GuiBatchRenderer.java
│ └── vertex
│ │ └── VertexUtil.java
│ └── vulkan
│ ├── DeviceInfo.java
│ ├── Drawer.java
│ ├── ShaderSPIRVUtils.java
│ ├── Synchronization.java
│ ├── TransferQueue.java
│ ├── VRenderSystem.java
│ ├── Vulkan.java
│ ├── memory
│ ├── AutoIndexBuffer.java
│ ├── Buffer.java
│ ├── IndexBuffer.java
│ ├── MemoryManager.java
│ ├── MemoryType.java
│ ├── MemoryTypes.java
│ ├── StagingBuffer.java
│ ├── UniformBuffers.java
│ └── VertexBuffer.java
│ ├── shader
│ ├── Pipeline.java
│ ├── PipelineState.java
│ ├── layout
│ │ ├── AlignedStruct.java
│ │ ├── Field.java
│ │ ├── Mat4f.java
│ │ ├── PushConstants.java
│ │ ├── UBO.java
│ │ ├── Vec1f.java
│ │ ├── Vec1i.java
│ │ ├── Vec2f.java
│ │ ├── Vec3f.java
│ │ └── Vec4f.java
│ └── parser
│ │ ├── GlslConverter.java
│ │ ├── InputOutputParser.java
│ │ └── UniformParser.java
│ ├── texture
│ ├── VTextureSelector.java
│ └── VulkanImage.java
│ └── util
│ ├── MappedBuffer.java
│ ├── Pair.java
│ └── VUtil.java
└── resources
├── assets
└── vulkanmod
│ ├── Vlogo.png
│ └── shaders
│ └── core
│ ├── blit_screen.fsh
│ ├── blit_screen.json
│ ├── blit_screen.vsh
│ ├── particle.fsh
│ ├── particle.json
│ ├── particle.vsh
│ ├── position.fsh
│ ├── position.json
│ ├── position.vsh
│ ├── position_color.fsh
│ ├── position_color.json
│ ├── position_color.vsh
│ ├── position_color_lightmap.fsh
│ ├── position_color_lightmap.json
│ ├── position_color_lightmap.vsh
│ ├── position_color_normal.fsh
│ ├── position_color_normal.json
│ ├── position_color_normal.vsh
│ ├── position_color_tex.fsh
│ ├── position_color_tex.json
│ ├── position_color_tex.vsh
│ ├── position_color_tex_lightmap.fsh
│ ├── position_color_tex_lightmap.json
│ ├── position_color_tex_lightmap.vsh
│ ├── position_tex.fsh
│ ├── position_tex.json
│ ├── position_tex.vsh
│ ├── position_tex_color.fsh
│ ├── position_tex_color.json
│ ├── position_tex_color.vsh
│ ├── position_tex_color_normal.fsh
│ ├── position_tex_color_normal.json
│ ├── position_tex_color_normal.vsh
│ ├── rendertype_armor_cutout_no_cull.fsh
│ ├── rendertype_armor_cutout_no_cull.json
│ ├── rendertype_armor_cutout_no_cull.vsh
│ ├── rendertype_armor_entity_glint.fsh
│ ├── rendertype_armor_entity_glint.json
│ ├── rendertype_armor_entity_glint.vsh
│ ├── rendertype_armor_glint.fsh
│ ├── rendertype_armor_glint.json
│ ├── rendertype_armor_glint.vsh
│ ├── rendertype_beacon_beam.fsh
│ ├── rendertype_beacon_beam.json
│ ├── rendertype_beacon_beam.vsh
│ ├── rendertype_crumbling.fsh
│ ├── rendertype_crumbling.json
│ ├── rendertype_crumbling.vsh
│ ├── rendertype_cutout.fsh
│ ├── rendertype_cutout.json
│ ├── rendertype_cutout.vsh
│ ├── rendertype_cutout_mipped.fsh
│ ├── rendertype_cutout_mipped.json
│ ├── rendertype_cutout_mipped.vsh
│ ├── rendertype_end_portal.fsh
│ ├── rendertype_end_portal.json
│ ├── rendertype_end_portal.vsh
│ ├── rendertype_energy_swirl.fsh
│ ├── rendertype_energy_swirl.json
│ ├── rendertype_energy_swirl.vsh
│ ├── rendertype_entity_alpha.fsh
│ ├── rendertype_entity_alpha.json
│ ├── rendertype_entity_alpha.vsh
│ ├── rendertype_entity_cutout.fsh
│ ├── rendertype_entity_cutout.json
│ ├── rendertype_entity_cutout.vsh
│ ├── rendertype_entity_cutout_no_cull.fsh
│ ├── rendertype_entity_cutout_no_cull.json
│ ├── rendertype_entity_cutout_no_cull.vsh
│ ├── rendertype_entity_cutout_no_cull_z_offset.fsh
│ ├── rendertype_entity_cutout_no_cull_z_offset.json
│ ├── rendertype_entity_cutout_no_cull_z_offset.vsh
│ ├── rendertype_entity_decal.fsh
│ ├── rendertype_entity_decal.json
│ ├── rendertype_entity_decal.vsh
│ ├── rendertype_entity_glint.fsh
│ ├── rendertype_entity_glint.json
│ ├── rendertype_entity_glint.vsh
│ ├── rendertype_entity_glint_direct.fsh
│ ├── rendertype_entity_glint_direct.json
│ ├── rendertype_entity_glint_direct.vsh
│ ├── rendertype_entity_no_outline.fsh
│ ├── rendertype_entity_no_outline.json
│ ├── rendertype_entity_no_outline.vsh
│ ├── rendertype_entity_shadow.fsh
│ ├── rendertype_entity_shadow.json
│ ├── rendertype_entity_shadow.vsh
│ ├── rendertype_entity_smooth_cutout.fsh
│ ├── rendertype_entity_smooth_cutout.json
│ ├── rendertype_entity_smooth_cutout.vsh
│ ├── rendertype_entity_solid.fsh
│ ├── rendertype_entity_solid.json
│ ├── rendertype_entity_solid.vsh
│ ├── rendertype_entity_translucent.fsh
│ ├── rendertype_entity_translucent.json
│ ├── rendertype_entity_translucent.vsh
│ ├── rendertype_entity_translucent_cull.fsh
│ ├── rendertype_entity_translucent_cull.json
│ ├── rendertype_entity_translucent_cull.vsh
│ ├── rendertype_entity_translucent_emissive.fsh
│ ├── rendertype_entity_translucent_emissive.json
│ ├── rendertype_entity_translucent_emissive.vsh
│ ├── rendertype_eyes.fsh
│ ├── rendertype_eyes.json
│ ├── rendertype_eyes.vsh
│ ├── rendertype_glint.fsh
│ ├── rendertype_glint.json
│ ├── rendertype_glint.vsh
│ ├── rendertype_glint_direct.fsh
│ ├── rendertype_glint_direct.json
│ ├── rendertype_glint_direct.vsh
│ ├── rendertype_glint_translucent.fsh
│ ├── rendertype_glint_translucent.json
│ ├── rendertype_glint_translucent.vsh
│ ├── rendertype_item_entity_translucent_cull.fsh
│ ├── rendertype_item_entity_translucent_cull.json
│ ├── rendertype_item_entity_translucent_cull.vsh
│ ├── rendertype_leash.fsh
│ ├── rendertype_leash.json
│ ├── rendertype_leash.vsh
│ ├── rendertype_lightning.fsh
│ ├── rendertype_lightning.json
│ ├── rendertype_lightning.vsh
│ ├── rendertype_lines.fsh
│ ├── rendertype_lines.json
│ ├── rendertype_lines.vsh
│ ├── rendertype_outline.fsh
│ ├── rendertype_outline.json
│ ├── rendertype_outline.vsh
│ ├── rendertype_solid.fsh
│ ├── rendertype_solid.json
│ ├── rendertype_solid.vsh
│ ├── rendertype_text.fsh
│ ├── rendertype_text.json
│ ├── rendertype_text.vsh
│ ├── rendertype_text_see_through.fsh
│ ├── rendertype_text_see_through.json
│ ├── rendertype_text_see_through.vsh
│ ├── rendertype_translucent.fsh
│ ├── rendertype_translucent.json
│ ├── rendertype_translucent.vsh
│ ├── rendertype_translucent_moving_block.fsh
│ ├── rendertype_translucent_moving_block.json
│ ├── rendertype_translucent_moving_block.vsh
│ ├── rendertype_translucent_no_crumbling.fsh
│ ├── rendertype_translucent_no_crumbling.json
│ ├── rendertype_translucent_no_crumbling.vsh
│ ├── rendertype_tripwire.fsh
│ ├── rendertype_tripwire.json
│ ├── rendertype_tripwire.vsh
│ ├── rendertype_water_mask.fsh
│ ├── rendertype_water_mask.json
│ └── rendertype_water_mask.vsh
├── fabric.mod.json
├── vulkanmod.accesswidener
└── vulkanmod.mixins.json
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | # Automatically build the project and run any configured tests for every push
2 | # and submitted pull request. This can help catch issues that only occur on
3 | # certain platforms or Java versions, and provides a first line of defence
4 | # against bad commits.
5 |
6 | name: build
7 | on: [pull_request, push, workflow_dispatch]
8 |
9 | jobs:
10 | build:
11 | strategy:
12 | matrix:
13 | # Use these Java versions
14 | java: [
15 | 17, # Current Java LTS & minimum supported by Minecraft
16 | ]
17 | # and run on both Linux and Windows
18 | os: [ubuntu-20.04] #, windows-2022]
19 | runs-on: ${{ matrix.os }}
20 | steps:
21 | - name: checkout repository
22 | uses: actions/checkout@v2
23 | - name: validate gradle wrapper
24 | uses: gradle/wrapper-validation-action@v1
25 | - name: setup jdk ${{ matrix.java }}
26 | uses: actions/setup-java@v1
27 | with:
28 | java-version: ${{ matrix.java }}
29 | - name: make gradle wrapper executable
30 | if: ${{ runner.os != 'Windows' }}
31 | run: chmod +x ./gradlew
32 | - name: build
33 | run: |
34 | ./gradlew build
35 | # patch to make LWJGL 3.3.1 as optional
36 | jar xf build/libs/*.jar fabric.mod.json
37 | echo "$(jq '.jars=[{"file":"META-INF/jars/joml-1.10.4.jar"}]' fabric.mod.json)" > fabric.mod.json
38 | find build/libs -name '*.jar' -exec jar uf {} fabric.mod.json \;
39 | - name: capture build artifacts
40 | if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
41 | uses: actions/upload-artifact@v2
42 | with:
43 | name: Artifacts
44 | path: build/libs/
45 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # gradle
2 |
3 | .gradle/
4 | build/
5 | out/
6 | classes/
7 |
8 | # eclipse
9 |
10 | *.launch
11 |
12 | # idea
13 |
14 | .idea/
15 | *.iml
16 | *.ipr
17 | *.iws
18 |
19 | # vscode
20 |
21 | .settings/
22 | .vscode/
23 | bin/
24 | .classpath
25 | .project
26 |
27 | # macos
28 |
29 | *.DS_Store
30 |
31 | # fabric
32 |
33 | run/
34 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | [](#)
4 |
5 | # VulkanMod
6 |
7 | This is a fabric mod that rewrites Minecraft OpenGL renderer to use Vulkan API.
8 |
9 | Demostration Video:
10 |
11 | [](https://youtu.be/sbr7UxcAmOE)
12 |
13 | 
14 |
15 | [](https://discord.gg/FVXg7AYR2Q)
16 |
17 | [](https://ko-fi.com/V7V7CHHJV)
18 |
19 | ## Installation
20 |
21 | ### Download
22 |
23 | [](https://modrinth.com/mod/vulkanmod)
24 |
25 | [](https://www.curseforge.com/minecraft/mc-mods/vulkanmod)
26 |
27 | [](https://www.curseforge.com/minecraft/mc-mods/vulkanmod)
28 |
29 | - Fabric mod loader is needed.
30 | - Move `VulkanMod.jar` to `mods` folder of your Minecraft Instance.
31 |
32 | ## Known Issues
33 |
34 | - Linux and macOS may not work.
35 |
36 | ## Notes
37 | This is still a pre-alpha mod. Bugs are to be expected.
38 |
39 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Done to increase the memory available to gradle.
2 | org.gradle.jvmargs=-Xmx1G
3 |
4 | # Fabric Properties
5 | # check these on https://fabricmc.net/develop
6 | minecraft_version=1.19.2
7 | yarn_mappings=1.19.2+build.1
8 | loader_version=0.14.10
9 |
10 | # Mod Properties
11 | mod_version = 0.2.4
12 | maven_group = net.vulkanmod
13 | archives_base_name = VulkanMod_1.19.2
14 |
15 | # Dependencies
16 | fabric_version=0.66.0+1.19.2
17 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PojavLauncherTeam/VulkanMod/3f2b48e514f4e3335fe9d0d8a5a3f78f6c4eea72/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PojavLauncherTeam/VulkanMod/3f2b48e514f4e3335fe9d0d8a5a3f78f6c4eea72/gradlew
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | maven {
4 | name = 'Fabric'
5 | url = 'https://maven.fabricmc.net/'
6 | }
7 | mavenCentral()
8 | gradlePluginPortal()
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/Initializer.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod;
2 |
3 | import net.fabricmc.api.ModInitializer;
4 | import net.fabricmc.loader.api.FabricLoader;
5 | import net.vulkanmod.config.Config;
6 | import net.vulkanmod.config.VideoResolution;
7 | import org.apache.logging.log4j.LogManager;
8 | import org.apache.logging.log4j.Logger;
9 |
10 | import java.nio.file.Path;
11 |
12 | public class Initializer implements ModInitializer {
13 | public static final Logger LOGGER = LogManager.getLogger("VulkanMod");
14 |
15 | private static String VERSION;
16 | public static Config CONFIG;
17 |
18 | @Override
19 | public void onInitialize() {
20 |
21 | VERSION = FabricLoader.getInstance()
22 | .getModContainer("vulkanmod")
23 | .get()
24 | .getMetadata()
25 | .getVersion().getFriendlyString();
26 |
27 | LOGGER.info("== VulkanMod ==");
28 |
29 | VideoResolution.init();
30 |
31 | var configPath = FabricLoader.getInstance()
32 | .getConfigDir()
33 | .resolve("vulkanmod_settings.json");
34 |
35 | CONFIG = loadConfig(configPath);
36 |
37 | }
38 |
39 | private static Config loadConfig(Path path) {
40 | Config config = Config.load(path);
41 | if(config == null) {
42 | config = new Config();
43 | config.write();
44 | }
45 | return config;
46 | }
47 |
48 | public static String getVersion() {
49 | return VERSION;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/config/Config.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.config;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.GsonBuilder;
5 |
6 | import java.io.FileReader;
7 | import java.io.IOException;
8 | import java.lang.reflect.Modifier;
9 | import java.nio.file.Files;
10 | import java.nio.file.Path;
11 | import java.util.Collections;
12 |
13 | public class Config {
14 |
15 | public int frameQueueSize = 2;
16 | public VideoResolution resolution = VideoResolution.getFirstAvailable();
17 | public boolean windowedFullscreen = false;
18 | public boolean guiOptimizations = false;
19 | public int advCulling = 2;
20 |
21 | private static Path path;
22 |
23 | private static final Gson GSON = new GsonBuilder()
24 | .setPrettyPrinting()
25 | .excludeFieldsWithModifiers(Modifier.PRIVATE)
26 | .create();
27 |
28 | public static Config load(Path path) {
29 | Config config;
30 | Config.path = path;
31 |
32 | if (Files.exists(path)) {
33 | try (FileReader fileReader = new FileReader(path.toFile())) {
34 | config = GSON.fromJson(fileReader, Config.class);
35 | }
36 | catch (IOException exception) {
37 | throw new RuntimeException(exception.getMessage());
38 | }
39 | }
40 | else {
41 | config = null;
42 | }
43 |
44 | return config;
45 | }
46 |
47 | public void write() {
48 |
49 | if(!Files.exists(path.getParent())) {
50 | try {
51 | Files.createDirectories(path);
52 | } catch (IOException e) {
53 | e.printStackTrace();
54 | }
55 | }
56 |
57 | try {
58 | Files.write(path, Collections.singleton(GSON.toJson(this)));
59 | } catch (IOException e) {
60 | e.printStackTrace();
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/config/Option.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.config;
2 |
3 | import net.minecraft.client.gui.components.AbstractWidget;
4 | import net.minecraft.network.chat.Component;
5 | import net.vulkanmod.config.widget.OptionWidget;
6 |
7 | import java.util.function.Consumer;
8 | import java.util.function.Supplier;
9 |
10 | public abstract class Option {
11 | protected final Component name;
12 | protected Component tooltip;
13 |
14 | protected Consumer setter;
15 | protected Supplier getter;
16 |
17 | protected T value;
18 | protected T newValue;
19 |
20 | public Option(String name, Consumer setter, Supplier getter) {
21 | this.name = Component.literal(name);
22 |
23 | this.setter = setter;
24 | this.getter = getter;
25 |
26 | this.newValue = this.value = this.getter.get();
27 | }
28 |
29 | public abstract AbstractWidget createWidget(int x, int y, int width, int height);
30 |
31 | public abstract OptionWidget createOptionWidget(int x, int y, int width, int height);
32 |
33 | public abstract void setValue(T t);
34 |
35 | public Component getName() {
36 | return this.name;
37 | }
38 |
39 | public boolean isModified() {
40 | return !this.newValue.equals(this.value);
41 | }
42 |
43 | protected void apply() {
44 | if(!isModified()) return;
45 | setter.accept(this.newValue);
46 | this.value = this.newValue;
47 | }
48 |
49 | public T getValue() {
50 | return this.newValue;
51 | }
52 |
53 | public Option setTooltip(Component text) {
54 | this.tooltip = text;
55 | return this;
56 | }
57 |
58 | public Component getTooltip() {
59 | return this.tooltip;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/config/SliderWidgetImpl.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.config;
2 |
3 | import net.minecraft.client.gui.components.AbstractSliderButton;
4 | import net.minecraft.network.chat.Component;
5 |
6 | public class SliderWidgetImpl extends AbstractSliderButton {
7 | private RangeOption option;
8 |
9 | public SliderWidgetImpl(RangeOption option, int x, int y, int width, int height, Component text, double value) {
10 | super(x, y, width, height, text, value);
11 | this.option = option;
12 | }
13 |
14 | @Override
15 | protected void updateMessage() {
16 | this.setMessage(option.getName());
17 | }
18 |
19 | @Override
20 | protected void applyValue() {
21 | option.setValue((float) this.value);
22 | this.value = option.getScaledValue();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/config/SwitchOption.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.config;
2 |
3 | import net.minecraft.client.gui.components.AbstractWidget;
4 | import net.vulkanmod.config.widget.OptionWidget;
5 | import net.vulkanmod.config.widget.SwitchOptionWidget;
6 |
7 | import java.util.function.Consumer;
8 | import java.util.function.Supplier;
9 |
10 | public class SwitchOption extends Option {
11 | public SwitchOption(String name, Consumer setter, Supplier getter) {
12 | super(name, setter, getter);
13 | }
14 |
15 | @Override
16 | public AbstractWidget createWidget(int x, int y, int width, int height) {
17 | return null;
18 | }
19 |
20 | @Override
21 | public OptionWidget createOptionWidget(int x, int y, int width, int height) {
22 | return new SwitchOptionWidget(this, x, y, width, height, this.name);
23 | }
24 |
25 | @Override
26 | public void setValue(Boolean aBoolean) {
27 | this.newValue = aBoolean;
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/config/widget/SwitchOptionWidget.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.config.widget;
2 |
3 | import net.minecraft.network.chat.Component;
4 | import net.vulkanmod.config.SwitchOption;
5 |
6 | public class SwitchOptionWidget extends OptionWidget {
7 | SwitchOption option;
8 |
9 | public SwitchOptionWidget(SwitchOption option, int x, int y, int width, int height, Component name) {
10 | super(x, y, width, height, name);
11 | this.option = option;
12 | updateDisplayedValue();
13 | }
14 |
15 | public void onClick(double mouseX, double mouseY) {
16 | this.option.setValue(!this.option.getValue());
17 | updateDisplayedValue();
18 | }
19 |
20 | private void updateDisplayedValue() {
21 | this.displayedValue = option.getValue() ? Component.nullToEmpty("On") : Component.nullToEmpty("Off");
22 | }
23 |
24 | public Component getTooltip() {
25 | return this.option.getTooltip();
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/gl/TextureMap.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.gl;
2 |
3 | import it.unimi.dsi.fastutil.ints.Int2ReferenceOpenHashMap;
4 | import net.vulkanmod.vulkan.texture.VulkanImage;
5 |
6 | public class TextureMap {
7 |
8 | static Int2ReferenceOpenHashMap textures = new Int2ReferenceOpenHashMap<>();
9 |
10 | public static void addTexture(VulkanImage vulkanImage) {
11 | textures.put(getId(vulkanImage), vulkanImage);
12 | }
13 |
14 | public static VulkanImage getTexture(int id) {
15 | return textures.get(id);
16 | }
17 |
18 | public static boolean removeTexture(int id) { return textures.remove(id) != null; }
19 |
20 | public static int getId(VulkanImage vulkanImage) {
21 | return (int) vulkanImage.getId();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/gl/Util.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.gl;
2 |
3 | import net.vulkanmod.vulkan.ShaderSPIRVUtils;
4 |
5 | public class Util {
6 |
7 | public static ShaderSPIRVUtils.ShaderKind extToShaderKind(String in) {
8 | return switch (in) {
9 | case ".vsh" -> ShaderSPIRVUtils.ShaderKind.VERTEX_SHADER;
10 | case ".fsh" -> ShaderSPIRVUtils.ShaderKind.FRAGMENT_SHADER;
11 | default -> throw new RuntimeException("unknown shader type: " + in);
12 | };
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/interfaces/ExtendedVertexBuilder.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.interfaces;
2 |
3 | import net.vulkanmod.render.vertex.VertexUtil;
4 |
5 | public interface ExtendedVertexBuilder {
6 |
7 | void vertex(float x, float y, float z, int packedColor, float u, float v, int overlay, int light, int packedNormal);
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/interfaces/FrustumMixed.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.interfaces;
2 |
3 | import net.vulkanmod.render.chunk.VFrustum;
4 |
5 | public interface FrustumMixed {
6 |
7 | VFrustum customFrustum();
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/interfaces/ModelPartCubeMixed.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.interfaces;
2 |
3 | import net.vulkanmod.model.CubeModel;
4 |
5 | public interface ModelPartCubeMixed {
6 |
7 | CubeModel getCubeModel();
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/interfaces/ShaderMixed.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.interfaces;
2 |
3 | import net.vulkanmod.vulkan.shader.Pipeline;
4 |
5 | public interface ShaderMixed {
6 |
7 | Pipeline getPipeline();
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/interfaces/VAbstractTextureI.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.interfaces;
2 |
3 | import net.vulkanmod.vulkan.texture.VulkanImage;
4 |
5 | public interface VAbstractTextureI {
6 |
7 | public void bindTexture();
8 |
9 | void setId(int i);
10 |
11 | public VulkanImage getVulkanImage();
12 |
13 | public void setVulkanImage(VulkanImage image);
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/interfaces/VertexFormatMixed.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.interfaces;
2 |
3 | import com.mojang.blaze3d.vertex.VertexFormatElement;
4 |
5 | import java.util.List;
6 |
7 | public interface VertexFormatMixed {
8 |
9 | int getOffset(int i);
10 |
11 | List getFastList();
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/interfaces/math/Vec3Extended.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.interfaces.math;
2 |
3 | import com.mojang.math.Vector3f;
4 | import org.joml.Matrix4fc;
5 |
6 | public interface Vec3Extended {
7 |
8 | Vector3f mulPosition(Matrix4fc mat, Vector3f dest);
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/ClientLevelM.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin;
2 |
3 | import net.minecraft.client.multiplayer.ClientLevel;
4 | import net.vulkanmod.render.chunk.RenderSection;
5 | import net.vulkanmod.render.chunk.WorldRenderer;
6 | import org.spongepowered.asm.mixin.Mixin;
7 | import org.spongepowered.asm.mixin.injection.At;
8 | import org.spongepowered.asm.mixin.injection.Inject;
9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
10 |
11 | @Mixin(ClientLevel.class)
12 | public class ClientLevelM {
13 |
14 | @Inject(method = "setLightReady", at = @At("RETURN"))
15 | private void setLightReady(int i, int j, CallbackInfo ci) {
16 | WorldRenderer.getInstance().setSectionsLightReady(i, j);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/MixinPlugin.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin;
2 |
3 | import net.vulkanmod.config.Config;
4 | import net.vulkanmod.config.VideoResolution;
5 | import org.objectweb.asm.tree.ClassNode;
6 | import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
7 | import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
8 |
9 | import java.io.File;
10 | import java.util.HashSet;
11 | import java.util.List;
12 | import java.util.Set;
13 |
14 | public class MixinPlugin implements IMixinConfigPlugin {
15 |
16 | private static Config config;
17 | @Override
18 | public void onLoad(String mixinPackage) {
19 | config = Config.load(new File("./config/vulkanmod_settings.json").toPath().toAbsolutePath());
20 | if(config == null) config = new Config();
21 | }
22 |
23 | @Override
24 | public String getRefMapperConfig() {
25 | return null;
26 | }
27 |
28 | @Override
29 | public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
30 |
31 | if(mixinClassName.startsWith("net.vulkanmod.mixin.gui") && !config.guiOptimizations) {
32 | return false;
33 | }
34 |
35 | return true;
36 | }
37 |
38 | @Override
39 | public void acceptTargets(Set myTargets, Set otherTargets) {
40 |
41 | }
42 |
43 | @Override
44 | public List getMixins() {
45 | return null;
46 | }
47 |
48 | @Override
49 | public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
50 | }
51 |
52 | @Override
53 | public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
54 |
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/chunk/DirectionMixin.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.chunk;
2 |
3 | import net.minecraft.core.Direction;
4 | import org.spongepowered.asm.mixin.Final;
5 | import org.spongepowered.asm.mixin.Mixin;
6 | import org.spongepowered.asm.mixin.Overwrite;
7 | import org.spongepowered.asm.mixin.Shadow;
8 |
9 | @Mixin(Direction.class)
10 | public class DirectionMixin {
11 |
12 | @Shadow @Final private static Direction[] BY_3D_DATA;
13 |
14 | @Shadow @Final private int oppositeIndex;
15 |
16 | /**
17 | * @author
18 | * @reason
19 | */
20 | @Overwrite
21 | public Direction getOpposite() {
22 | return BY_3D_DATA[this.oppositeIndex];
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/chunk/FrustumMixin.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.chunk;
2 |
3 | import com.mojang.math.Matrix4f;
4 | import net.minecraft.client.renderer.culling.Frustum;
5 | import net.vulkanmod.interfaces.FrustumMixed;
6 | import net.vulkanmod.render.chunk.VFrustum;
7 | import org.spongepowered.asm.mixin.Mixin;
8 | import org.spongepowered.asm.mixin.Shadow;
9 | import org.spongepowered.asm.mixin.injection.At;
10 | import org.spongepowered.asm.mixin.injection.Inject;
11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
12 |
13 | @Mixin(Frustum.class)
14 | public class FrustumMixin implements FrustumMixed {
15 |
16 | @Shadow private double camX;
17 | @Shadow private double camY;
18 | @Shadow private double camZ;
19 | private VFrustum vFrustum;
20 |
21 | @Inject(method = "calculateFrustum", at = @At("RETURN"))
22 | private void calculateFrustum(Matrix4f modelView, Matrix4f projection, CallbackInfo ci) {
23 | this.vFrustum = new VFrustum(modelView, projection);
24 | }
25 |
26 | @Inject(method = "prepare", at = @At("RETURN"))
27 | public void prepare(double d, double e, double f, CallbackInfo ci) {
28 | this.vFrustum.prepare(this.camX, this.camY, this.camZ);
29 | }
30 |
31 | @Override
32 | public VFrustum customFrustum() {
33 | return vFrustum;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/chunk/VisibilitySetMixin.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.chunk;
2 |
3 | import net.minecraft.client.renderer.chunk.VisibilitySet;
4 | import net.minecraft.core.Direction;
5 | import org.spongepowered.asm.mixin.Mixin;
6 | import org.spongepowered.asm.mixin.Overwrite;
7 |
8 | @Mixin(VisibilitySet.class)
9 | public class VisibilitySetMixin {
10 |
11 | // private int vis = 0;
12 | private long vis = 0;
13 |
14 | /**
15 | * @author
16 | * @reason
17 | */
18 | @Overwrite
19 | public void set(Direction dir1, Direction dir2, boolean p_112989_) {
20 | // this.vis |= 1 << (dir1.ordinal() * 5 + dir2.ordinal()) | 1 << (dir2.ordinal() * 5 + dir1.ordinal());
21 | this.vis |= 1L << ((dir1.ordinal() << 3) + dir2.ordinal()) | 1L << ((dir2.ordinal() << 3) + dir1.ordinal());
22 | }
23 |
24 | /**
25 | * @author
26 | * @reason
27 | */
28 | @Overwrite
29 | public void setAll(boolean bl) {
30 | if(bl) this.vis = 0xFFFFFFFFFFFFFFFFL;
31 | }
32 |
33 | /**
34 | * @author
35 | * @reason
36 | */
37 | @Overwrite
38 | public boolean visibilityBetween(Direction dir1, Direction dir2) {
39 | // return (this.vis & (1 << (dir1.ordinal() * 5 + dir2.ordinal()))) != 0;
40 | return (this.vis & (1L << ((dir1.ordinal() << 3) + dir2.ordinal()))) != 0;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/compatibility/UniformM.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.compatibility;
2 |
3 | import com.mojang.blaze3d.shaders.Uniform;
4 | import org.spongepowered.asm.mixin.Mixin;
5 | import org.spongepowered.asm.mixin.Overwrite;
6 | import org.spongepowered.asm.mixin.injection.At;
7 | import org.spongepowered.asm.mixin.injection.Inject;
8 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
9 |
10 | @Mixin(Uniform.class)
11 | public class UniformM {
12 |
13 | /**
14 | * @author
15 | * @reason
16 | */
17 | @Overwrite
18 | public static int glGetUniformLocation(int i, CharSequence charSequence) {
19 | //TODO
20 | return 1;
21 | }
22 |
23 | /**
24 | * @author
25 | * @reason
26 | */
27 | @Overwrite
28 | public static int glGetAttribLocation(int i, CharSequence charSequence) {
29 | return 0;
30 | }
31 |
32 | @Inject(method = "upload", at = @At("HEAD"), cancellable = true)
33 | public void cancelUpload(CallbackInfo ci) {
34 | ci.cancel();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/debug/GlDebugInfoM.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.debug;
2 |
3 | import com.mojang.blaze3d.platform.GlUtil;
4 | import net.vulkanmod.vulkan.DeviceInfo;
5 | import net.vulkanmod.vulkan.Vulkan;
6 | import org.spongepowered.asm.mixin.Mixin;
7 | import org.spongepowered.asm.mixin.Overwrite;
8 |
9 | @Mixin(GlUtil.class)
10 | public class GlDebugInfoM {
11 |
12 | /**
13 | * @author
14 | */
15 | @Overwrite
16 | public static String getVendor() {
17 | return Vulkan.getDeviceInfo() != null ? Vulkan.getDeviceInfo().vendorId : "n/a";
18 | }
19 |
20 | /**
21 | * @author
22 | */
23 | @Overwrite
24 | public static String getRenderer() {
25 | return Vulkan.getDeviceInfo() != null ? Vulkan.getDeviceInfo().deviceName : "n/a";
26 | }
27 |
28 | /**
29 | * @author
30 | */
31 | @Overwrite
32 | public static String getOpenGLVersion() {
33 | return Vulkan.getDeviceInfo() != null ? Vulkan.getDeviceInfo().driverVersion : "n/a";
34 | }
35 |
36 | /**
37 | * @author
38 | */
39 | @Overwrite
40 | public static String getCpuInfo() {
41 | return DeviceInfo.cpuInfo;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/debug/KeyboardHandlerM.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.debug;
2 |
3 | import com.mojang.blaze3d.platform.InputConstants;
4 | import net.minecraft.client.KeyboardHandler;
5 | import net.minecraft.client.Minecraft;
6 | import org.spongepowered.asm.mixin.Mixin;
7 | import org.spongepowered.asm.mixin.Shadow;
8 | import org.spongepowered.asm.mixin.injection.At;
9 | import org.spongepowered.asm.mixin.injection.Inject;
10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
11 |
12 | @Mixin(KeyboardHandler.class)
13 | public abstract class KeyboardHandlerM {
14 |
15 | @Shadow protected abstract boolean handleChunkDebugKeys(int i);
16 |
17 | @Shadow private boolean handledDebugKey;
18 |
19 | @Inject(method = "keyPress", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/InputConstants;isKeyDown(JI)Z", ordinal = 5, shift = At.Shift.AFTER))
20 | private void chunkDebug(long l, int i, int j, int k, int m, CallbackInfo ci) {
21 | this.handledDebugKey |= InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), 296) && this.handleChunkDebugKeys(i);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/math/Matrix4fM.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.math;
2 |
3 | import org.joml.Matrix4f;
4 | import org.spongepowered.asm.mixin.Mixin;
5 | import org.spongepowered.asm.mixin.Overwrite;
6 |
7 | @Mixin(Matrix4f.class)
8 | public class Matrix4fM {
9 |
10 | /**
11 | * @author
12 | * @reason
13 | */
14 | @Overwrite(remap = false)
15 | public Matrix4f setOrtho(float left, float right, float bottom, float top, float zNear, float zFar) {
16 | return new Matrix4f().setOrtho(left, right, bottom, top, zNear, zFar, true);
17 | }
18 |
19 | /**
20 | * @author
21 | * @reason
22 | */
23 | @Overwrite(remap = false)
24 | public Matrix4f ortho(float left, float right, float bottom, float top, float zNear, float zFar) {
25 | return new Matrix4f().ortho(left, right, bottom, top, zNear, zFar, true);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/math/internal/Vertex3fM.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.math.internal;
2 |
3 | import com.mojang.math.Vector3f;
4 | import net.vulkanmod.interfaces.math.Vec3Extended;
5 | import org.joml.Math;
6 | import org.joml.Matrix4fc;
7 | import org.spongepowered.asm.mixin.Mixin;
8 | import org.spongepowered.asm.mixin.Shadow;
9 |
10 | @Mixin(Vector3f.class)
11 | public class Vertex3fM implements Vec3Extended {
12 |
13 | @Shadow private float x;
14 |
15 | @Shadow private float y;
16 |
17 | @Shadow private float z;
18 |
19 | public Vector3f mulPosition(Matrix4fc mat, Vector3f dest) {
20 | float x = this.x, y = this.y, z = this.z;
21 | float xd = Math.fma(mat.m00(), x, Math.fma(mat.m10(), y, Math.fma(mat.m20(), z, mat.m30())));
22 | float yd = Math.fma(mat.m01(), x, Math.fma(mat.m11(), y, Math.fma(mat.m21(), z, mat.m31())));
23 | float zd = Math.fma(mat.m02(), x, Math.fma(mat.m12(), y, Math.fma(mat.m22(), z, mat.m32())));
24 | dest.set(xd, yd, zd);
25 | return dest;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/model/ModelPartCubeM.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.model;
2 |
3 | import net.minecraft.client.model.geom.ModelPart;
4 | import net.vulkanmod.interfaces.ModelPartCubeMixed;
5 | import net.vulkanmod.model.CubeModel;
6 | import org.spongepowered.asm.mixin.Mixin;
7 | import org.spongepowered.asm.mixin.injection.At;
8 | import org.spongepowered.asm.mixin.injection.Inject;
9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
10 |
11 | @Mixin(ModelPart.Cube.class)
12 | public class ModelPartCubeM implements ModelPartCubeMixed {
13 |
14 | CubeModel cube;
15 |
16 | @Inject(method = "", at = @At(value = "FIELD",
17 | target = "Lnet/minecraft/client/model/geom/ModelPart$Cube;polygons:[Lnet/minecraft/client/model/geom/ModelPart$Polygon;",
18 | ordinal = 0, shift = At.Shift.AFTER))
19 | private void getVertices(int i, int j, float f, float g, float h, float k, float l, float m, float n, float o, float p, boolean bl, float q, float r, CallbackInfo ci) {
20 | CubeModel cube = new CubeModel();
21 | cube.setVertices(i, j, f, g, h, k, l, m, n, o, p, bl, q, r);
22 | this.cube = cube;
23 | }
24 |
25 |
26 | @Override
27 | public CubeModel getCubeModel() {
28 | return this.cube;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/render/BufferRendererM.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.render;
2 |
3 | import com.mojang.blaze3d.systems.RenderSystem;
4 | import com.mojang.blaze3d.vertex.BufferBuilder;
5 | import com.mojang.blaze3d.vertex.BufferUploader;
6 | import net.vulkanmod.vulkan.Drawer;
7 | import org.spongepowered.asm.mixin.Mixin;
8 | import org.spongepowered.asm.mixin.Overwrite;
9 |
10 | @Mixin(BufferUploader.class)
11 | public class BufferRendererM {
12 |
13 | /**
14 | * @author
15 | */
16 | @Overwrite
17 | public static void reset() {}
18 |
19 | /**
20 | * @author
21 | */
22 | @Overwrite
23 | public static void drawWithShader(BufferBuilder.RenderedBuffer buffer) {
24 | RenderSystem.assertOnRenderThread();
25 | buffer.release();
26 |
27 | BufferBuilder.DrawState parameters = buffer.drawState();
28 |
29 | int glMode;
30 | switch (parameters.mode()) {
31 | case QUADS:
32 | case LINES:
33 | glMode = 7;
34 | break;
35 | case TRIANGLE_FAN:
36 | glMode = 6;
37 | break;
38 | case TRIANGLE_STRIP:
39 | case LINE_STRIP:
40 | glMode = 5;
41 | break;
42 | default:
43 | glMode = 4;
44 | }
45 |
46 | // Drawer.setModelViewMatrix(RenderSystem.getModelViewMatrix());
47 | // Drawer.setProjectionMatrix(RenderSystem.getProjectionMatrix());
48 |
49 | Drawer drawer = Drawer.getInstance();
50 | drawer.draw(buffer.vertexBuffer(), glMode, parameters.format(), parameters.vertexCount());
51 | }
52 |
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/render/FramebufferMixin.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.render;
2 |
3 | import com.mojang.blaze3d.pipeline.RenderTarget;
4 | import com.mojang.blaze3d.platform.GlStateManager;
5 | import com.mojang.blaze3d.systems.RenderSystem;
6 | import org.spongepowered.asm.mixin.Mixin;
7 | import org.spongepowered.asm.mixin.Overwrite;
8 | import org.spongepowered.asm.mixin.Shadow;
9 |
10 | @Mixin(RenderTarget.class)
11 | public class FramebufferMixin {
12 |
13 | @Shadow public int viewWidth;
14 |
15 | @Shadow public int viewHeight;
16 |
17 | @Shadow public int width;
18 |
19 | @Shadow public int height;
20 |
21 | /**
22 | * @author
23 | */
24 | @Overwrite
25 | public void clear(boolean getError) {}
26 |
27 | /**
28 | * @author
29 | */
30 | @Overwrite
31 | private void _resize(int i, int j, boolean bl) {
32 | this.viewWidth = i;
33 | this.viewHeight = j;
34 | this.width = i;
35 | this.height = j;
36 | }
37 |
38 | /**
39 | * @author
40 | */
41 | @Overwrite
42 | private void _bindWrite(boolean updateViewport) {}
43 |
44 | /**
45 | * @author
46 | */
47 | @Overwrite
48 | public void unbindWrite() {}
49 |
50 | /**
51 | * @author
52 | */
53 | @Overwrite
54 | private void _blitToScreen(int width, int height, boolean disableBlend) {}
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/render/GlProgramManagerMixin.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.render;
2 |
3 | import com.mojang.blaze3d.shaders.ProgramManager;
4 | import com.mojang.blaze3d.shaders.Shader;
5 | import org.spongepowered.asm.mixin.Mixin;
6 | import org.spongepowered.asm.mixin.injection.At;
7 | import org.spongepowered.asm.mixin.injection.Inject;
8 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
10 |
11 | import java.io.IOException;
12 |
13 | @Mixin(ProgramManager.class)
14 | public class GlProgramManagerMixin {
15 |
16 | @Inject(method = "createProgram", at = @At("HEAD"), cancellable = true)
17 | private static void createProgram(CallbackInfoReturnable cir) throws IOException {
18 | cir.setReturnValue(-1);
19 | }
20 |
21 | @Inject(method = "linkShader", at = @At("HEAD"), cancellable = true)
22 | private static void linkProgram(Shader shader, CallbackInfo ci) throws IOException {
23 | ci.cancel();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/render/IndexTypeMixin.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.render;
2 |
3 | import com.mojang.blaze3d.vertex.VertexFormat;
4 | import org.spongepowered.asm.mixin.Mixin;
5 | import org.spongepowered.asm.mixin.Overwrite;
6 |
7 | @Mixin(VertexFormat.IndexType.class)
8 | public class IndexTypeMixin {
9 |
10 | /**
11 | * @author
12 | */
13 | @Overwrite
14 | public static VertexFormat.IndexType least(int number) {
15 | return VertexFormat.IndexType.SHORT;
16 | }
17 | }
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/render/LevelRendererMixin.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.render;
2 |
3 | import it.unimi.dsi.fastutil.objects.ObjectArrayList;
4 | import net.minecraft.client.Minecraft;
5 | import net.minecraft.client.renderer.LevelRenderer;
6 | import net.minecraft.client.renderer.PostChain;
7 | import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher;
8 | import org.jetbrains.annotations.Nullable;
9 | import org.spongepowered.asm.mixin.Final;
10 | import org.spongepowered.asm.mixin.Mixin;
11 | import org.spongepowered.asm.mixin.Overwrite;
12 | import org.spongepowered.asm.mixin.Shadow;
13 |
14 | @Mixin(LevelRenderer.class)
15 | public abstract class LevelRendererMixin {
16 |
17 | @Shadow private @Nullable PostChain entityEffect;
18 |
19 | /**
20 | * @author
21 | */
22 | @Overwrite
23 | public void initOutline() {
24 | if (this.entityEffect != null) {
25 | this.entityEffect.close();
26 | }
27 | // Identifier identifier = new Identifier("shaders/post/entity_outline.json");
28 | // try {
29 | // this.entityOutlineShader = new ShaderEffect(this.minecraft.getTextureManager(), this.minecraft.getResourceManager(), this.minecraft.getFramebuffer(), identifier);
30 | // this.entityOutlineShader.setupDimensions(this.minecraft.getWindow().getFramebufferWidth(), this.minecraft.getWindow().getFramebufferHeight());
31 | // this.entityOutlinesFramebuffer = this.entityOutlineShader.getSecondaryTarget("final");
32 | // }
33 | // catch (IOException iOException) {
34 | // LOGGER.warn("Failed to load shader: {}", (Object)identifier, (Object)iOException);
35 | // this.entityOutlineShader = null;
36 | // this.entityOutlinesFramebuffer = null;
37 | // }
38 | // catch (JsonSyntaxException iOException) {
39 | // LOGGER.warn("Failed to parse shader: {}", (Object)identifier, (Object)iOException);
40 | // this.entityOutlineShader = null;
41 | // this.entityOutlinesFramebuffer = null;
42 | // }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/render/VertexFormatMixin.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.render;
2 |
3 | import com.google.common.collect.ImmutableMap;
4 | import com.mojang.blaze3d.vertex.VertexFormat;
5 | import com.mojang.blaze3d.vertex.VertexFormatElement;
6 | import it.unimi.dsi.fastutil.ints.IntList;
7 | import it.unimi.dsi.fastutil.objects.ObjectArrayList;
8 | import net.vulkanmod.interfaces.VertexFormatMixed;
9 | import org.spongepowered.asm.mixin.Mixin;
10 | import org.spongepowered.asm.mixin.Shadow;
11 | import org.spongepowered.asm.mixin.injection.At;
12 | import org.spongepowered.asm.mixin.injection.Inject;
13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
14 |
15 | import java.util.List;
16 |
17 | @Mixin(VertexFormat.class)
18 | public class VertexFormatMixin implements VertexFormatMixed {
19 | @Shadow private IntList offsets;
20 |
21 | private ObjectArrayList fastList;
22 |
23 | public int getOffset(int i) {
24 | return offsets.getInt(i);
25 | }
26 |
27 | public VertexFormatElement getElement(int i) {
28 | return this.fastList.get(i);
29 | }
30 |
31 | public List getFastList() {
32 | return this.fastList;
33 | }
34 |
35 | @Inject(method = "", at = @At("RETURN"))
36 | private void injectList(ImmutableMap immutableMap, CallbackInfo ci) {
37 | ObjectArrayList list = new ObjectArrayList<>();
38 | list.addAll(immutableMap.values());
39 |
40 | this.fastList = list;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/render/WindowFramebufferMixin.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.render;
2 |
3 | import com.mojang.blaze3d.pipeline.MainTarget;
4 | import com.mojang.blaze3d.pipeline.RenderTarget;
5 | import org.spongepowered.asm.mixin.Mixin;
6 | import org.spongepowered.asm.mixin.Overwrite;
7 |
8 | @Mixin(MainTarget.class)
9 | public class WindowFramebufferMixin extends RenderTarget {
10 |
11 | public WindowFramebufferMixin(boolean useDepth) {
12 | super(useDepth);
13 | }
14 |
15 | /**
16 | * @author
17 | */
18 | @Overwrite
19 | private void createFrameBuffer(int width, int height) {
20 |
21 | this.viewWidth = width;
22 | this.viewHeight = height;
23 | this.width = width;
24 | this.height = height;
25 | }
26 |
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/screen/OptionsScreenM.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.screen;
2 |
3 | import net.minecraft.client.Options;
4 | import net.minecraft.client.gui.components.Button;
5 | import net.minecraft.client.gui.screens.OptionsScreen;
6 | import net.minecraft.client.gui.screens.Screen;
7 | import net.minecraft.network.chat.Component;
8 | import net.vulkanmod.config.OptionScreenV;
9 | import net.vulkanmod.config.VideoSettingsScreen;
10 | import org.spongepowered.asm.mixin.Final;
11 | import org.spongepowered.asm.mixin.Mixin;
12 | import org.spongepowered.asm.mixin.Shadow;
13 | import org.spongepowered.asm.mixin.injection.At;
14 | import org.spongepowered.asm.mixin.injection.Inject;
15 | import org.spongepowered.asm.mixin.injection.Redirect;
16 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
17 |
18 | @Mixin(OptionsScreen.class)
19 | public class OptionsScreenM extends Screen {
20 |
21 | @Shadow @Final private Screen lastScreen;
22 |
23 | @Shadow @Final private Options options;
24 |
25 | protected OptionsScreenM(Component title) {
26 | super(title);
27 | }
28 |
29 | @Inject(method = "method_19828", at = @At("HEAD"), cancellable = true)
30 | private void injectVideoOptionScreen(Button button, CallbackInfo ci) {
31 | // this.minecraft.setScreen(new VideoSettingsScreen(this, this.options));
32 | this.minecraft.setScreen(new OptionScreenV(Component.literal("Video Setting"), this));
33 | ci.cancel();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/texture/MFontTexture.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.texture;
2 |
3 | import com.mojang.blaze3d.platform.NativeImage;
4 | import net.minecraft.client.gui.font.FontTexture;
5 | import net.vulkanmod.interfaces.VAbstractTextureI;
6 | import net.vulkanmod.vulkan.texture.VulkanImage;
7 | import org.spongepowered.asm.mixin.Mixin;
8 | import org.spongepowered.asm.mixin.injection.At;
9 | import org.spongepowered.asm.mixin.injection.Redirect;
10 |
11 | @Mixin(FontTexture.class)
12 | public class MFontTexture {
13 |
14 | @Redirect(method = "", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/TextureUtil;prepareImage(Lcom/mojang/blaze3d/platform/NativeImage$InternalGlFormat;III)V"))
15 | private void redirect(NativeImage.InternalGlFormat internalFormat, int id, int width, int height) {
16 | //this.vulkanImage = new VulkanImage(1, 256, 256, 4, false, false);
17 | ((VAbstractTextureI)(this)).setVulkanImage(new VulkanImage(1, 256, 256, 4, false, false));
18 | //((VAbstractTextureI)(this)).bind();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/texture/MLightMap.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.texture;
2 |
3 | import com.mojang.blaze3d.systems.RenderSystem;
4 | import net.minecraft.client.renderer.LightTexture;
5 | import net.minecraft.client.renderer.texture.DynamicTexture;
6 | import net.vulkanmod.interfaces.VAbstractTextureI;
7 | import net.vulkanmod.vulkan.texture.VTextureSelector;
8 | import org.spongepowered.asm.mixin.Final;
9 | import org.spongepowered.asm.mixin.Mixin;
10 | import org.spongepowered.asm.mixin.Overwrite;
11 | import org.spongepowered.asm.mixin.Shadow;
12 |
13 | @Mixin(LightTexture.class)
14 | public class MLightMap {
15 |
16 | @Shadow @Final private DynamicTexture lightTexture;
17 |
18 | /**
19 | * @author
20 | */
21 | @Overwrite
22 | public void turnOnLightLayer() {
23 | // RenderSystem.setShaderTexture(2, this.textureIdentifier);
24 | // this.client.getTextureManager().bindTexture(this.textureIdentifier);
25 | // RenderSystem.texParameter(3553, 10241, 9729);
26 | // RenderSystem.texParameter(3553, 10240, 9729);
27 | VTextureSelector.setLightTexture(((VAbstractTextureI)this.lightTexture).getVulkanImage());
28 | RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/texture/MOverlayTexture.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.texture;
2 |
3 | import net.minecraft.client.renderer.texture.DynamicTexture;
4 | import net.minecraft.client.renderer.texture.OverlayTexture;
5 | import net.vulkanmod.interfaces.VAbstractTextureI;
6 | import net.vulkanmod.vulkan.texture.VTextureSelector;
7 | import org.spongepowered.asm.mixin.Final;
8 | import org.spongepowered.asm.mixin.Mixin;
9 | import org.spongepowered.asm.mixin.Shadow;
10 | import org.spongepowered.asm.mixin.injection.At;
11 | import org.spongepowered.asm.mixin.injection.Inject;
12 | import org.spongepowered.asm.mixin.injection.Redirect;
13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
14 |
15 | @Mixin(OverlayTexture.class)
16 | public class MOverlayTexture {
17 |
18 | @Shadow @Final private DynamicTexture texture;
19 |
20 | @Redirect(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/texture/DynamicTexture;bind()V"))
21 | private void overlay(DynamicTexture instance) {
22 | VTextureSelector.setOverlayTexture(((VAbstractTextureI)this.texture).getVulkanImage());
23 | VTextureSelector.setActiveTexture(2);
24 | }
25 |
26 | @Inject(method = "", at = @At(value = "RETURN", target = "Lnet/minecraft/client/texture/NativeImageBackedTexture;bindTexture()V"))
27 | private void overlay(CallbackInfo ci) {
28 | VTextureSelector.setActiveTexture(0);
29 | }
30 |
31 | @Inject(method = "setupOverlayColor", at = @At(value = "HEAD"), cancellable = true)
32 | private void setupOverlay(CallbackInfo ci) {
33 | VTextureSelector.setOverlayTexture(((VAbstractTextureI)this.texture).getVulkanImage());
34 | ci.cancel();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/texture/MPlayerSkinTexture.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.texture;
2 |
3 | import com.mojang.blaze3d.platform.NativeImage;
4 | import net.minecraft.client.renderer.texture.HttpTexture;
5 | import net.vulkanmod.interfaces.VAbstractTextureI;
6 | import net.vulkanmod.vulkan.texture.VulkanImage;
7 | import org.spongepowered.asm.mixin.Mixin;
8 | import org.spongepowered.asm.mixin.Overwrite;
9 |
10 | @Mixin(HttpTexture.class)
11 | public class MPlayerSkinTexture {
12 |
13 | /**
14 | * @author
15 | */
16 | @Overwrite
17 | private void upload(NativeImage image) {
18 | ((VAbstractTextureI)this).setVulkanImage(new VulkanImage(image.getWidth(), image.getHeight()));
19 | ((VAbstractTextureI)this).bindTexture();
20 | image.upload(0, 0, 0, true);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/texture/MSimpleTexture.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.texture;
2 |
3 | import com.mojang.blaze3d.platform.NativeImage;
4 | import net.minecraft.client.renderer.texture.SimpleTexture;
5 | import net.vulkanmod.interfaces.VAbstractTextureI;
6 | import net.vulkanmod.vulkan.texture.VulkanImage;
7 | import org.spongepowered.asm.mixin.Mixin;
8 | import org.spongepowered.asm.mixin.Overwrite;
9 |
10 | @Mixin(SimpleTexture.class)
11 | public class MSimpleTexture {
12 |
13 |
14 |
15 | /**
16 | * @author
17 | */
18 | @Overwrite
19 | private void doLoad(NativeImage nativeImage, boolean blur, boolean clamp) {
20 | ((VAbstractTextureI)this).setVulkanImage(new VulkanImage(1, nativeImage.getWidth(), nativeImage.getHeight(), nativeImage.format().components(), blur, clamp));
21 | ((VAbstractTextureI)this).bindTexture();
22 | nativeImage.upload(0, 0, 0, 0, 0, nativeImage.getWidth(), nativeImage.getHeight(), blur, clamp, false, true);
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/texture/MSpriteAtlasTexture.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.texture;
2 |
3 | import net.minecraft.client.renderer.texture.TextureAtlas;
4 | import net.vulkanmod.interfaces.VAbstractTextureI;
5 | import net.vulkanmod.vulkan.texture.VulkanImage;
6 | import org.spongepowered.asm.mixin.Mixin;
7 | import org.spongepowered.asm.mixin.Overwrite;
8 | import org.spongepowered.asm.mixin.injection.At;
9 | import org.spongepowered.asm.mixin.injection.Redirect;
10 |
11 | @Mixin(TextureAtlas.class)
12 | public class MSpriteAtlasTexture {
13 |
14 | private VulkanImage vulkanImage;
15 |
16 | @Redirect(method = "reload", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/TextureUtil;prepareImage(IIII)V"))
17 | private void redirect(int id, int maxLevel, int width, int height) {
18 | //this.vulkanImage = new VulkanImage(1, 256, 256, 4, false, false);
19 | ((VAbstractTextureI)(this)).setVulkanImage(new VulkanImage(maxLevel + 1, width, height));
20 | ((VAbstractTextureI)(this)).bindTexture();
21 | }
22 |
23 | /**
24 | * @author
25 | */
26 | @Overwrite
27 | public void updateFilter(TextureAtlas.Preparations data) {
28 | //this.setFilter(false, data.maxLevel > 0);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/texture/MTextureManager.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.texture;
2 |
3 | import net.minecraft.client.renderer.texture.AbstractTexture;
4 | import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite;
5 | import net.minecraft.client.renderer.texture.TextureManager;
6 | import net.minecraft.client.renderer.texture.Tickable;
7 | import net.minecraft.resources.ResourceLocation;
8 | import net.vulkanmod.vulkan.Drawer;
9 | import net.vulkanmod.vulkan.TransferQueue;
10 | import org.spongepowered.asm.mixin.Final;
11 | import org.spongepowered.asm.mixin.Mixin;
12 | import org.spongepowered.asm.mixin.Overwrite;
13 | import org.spongepowered.asm.mixin.Shadow;
14 |
15 | import java.util.Set;
16 |
17 | @Mixin(TextureManager.class)
18 | public abstract class MTextureManager {
19 |
20 |
21 | @Shadow @Final private Set tickableTextures;
22 |
23 |
24 | @Shadow public abstract AbstractTexture getTexture(ResourceLocation resourceLocation, AbstractTexture abstractTexture);
25 |
26 | /**
27 | * @author
28 | */
29 | @Overwrite
30 | public void tick() {
31 | if(Drawer.skipRendering) return;
32 | TransferQueue.startRecording();
33 | for (Tickable tickable : this.tickableTextures) {
34 | tickable.tick();
35 | }
36 | TransferQueue.endRecording();
37 | }
38 |
39 | /**
40 | * @author
41 | */
42 | @Overwrite
43 | public void release(ResourceLocation id) {
44 | AbstractTexture abstractTexture = this.getTexture(id, MissingTextureAtlasSprite.getTexture());
45 | if (abstractTexture != MissingTextureAtlasSprite.getTexture()) {
46 | //TODO: delete
47 | abstractTexture.releaseId();
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/texture/MTextureUtil.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.texture;
2 |
3 | import com.mojang.blaze3d.platform.GlStateManager;
4 | import com.mojang.blaze3d.platform.TextureUtil;
5 | import com.mojang.blaze3d.systems.RenderSystem;
6 | import net.minecraft.SharedConstants;
7 | import org.spongepowered.asm.mixin.Mixin;
8 | import org.spongepowered.asm.mixin.Overwrite;
9 |
10 | import java.nio.IntBuffer;
11 | import java.util.concurrent.ThreadLocalRandom;
12 |
13 | @Mixin(TextureUtil.class)
14 | public class MTextureUtil {
15 |
16 | /**
17 | * @author
18 | */
19 | @Overwrite(remap = false)
20 | public static void initTexture(IntBuffer imageData, int width, int height) {}
21 |
22 | /**
23 | * @author
24 | */
25 | @Overwrite(remap = false)
26 | public static int generateTextureId() { return -1; }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/util/ScreenshotRecorderM.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.util;
2 |
3 | import com.mojang.blaze3d.pipeline.RenderTarget;
4 | import com.mojang.blaze3d.platform.NativeImage;
5 | import net.minecraft.client.Screenshot;
6 | import org.spongepowered.asm.mixin.Mixin;
7 | import org.spongepowered.asm.mixin.Overwrite;
8 |
9 | @Mixin(Screenshot.class)
10 | public class ScreenshotRecorderM {
11 |
12 | /**
13 | * @author
14 | */
15 | @Overwrite
16 | public static NativeImage takeScreenshot(RenderTarget framebuffer) {
17 | int i = framebuffer.width;
18 | int j = framebuffer.height;
19 |
20 | NativeImage nativeimage = new NativeImage(i, j, false);
21 | //RenderSystem.bindTexture(p_92282_.getColorTextureId());
22 | nativeimage.downloadTexture(0, true);
23 | //nativeimage.flipY();
24 | return nativeimage;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/mixin/vertex/SpriteCoordinateExpanderM.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.mixin.vertex;
2 |
3 | import com.mojang.blaze3d.vertex.VertexConsumer;
4 | import net.minecraft.client.renderer.SpriteCoordinateExpander;
5 | import net.minecraft.client.renderer.texture.TextureAtlasSprite;
6 | import net.vulkanmod.interfaces.ExtendedVertexBuilder;
7 | import org.spongepowered.asm.mixin.Final;
8 | import org.spongepowered.asm.mixin.Mixin;
9 | import org.spongepowered.asm.mixin.Shadow;
10 | import org.spongepowered.asm.mixin.injection.At;
11 | import org.spongepowered.asm.mixin.injection.Inject;
12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
13 |
14 | //TODO move
15 | @Mixin(SpriteCoordinateExpander.class)
16 | public class SpriteCoordinateExpanderM implements ExtendedVertexBuilder {
17 |
18 | @Shadow @Final private VertexConsumer delegate;
19 |
20 | @Shadow @Final private TextureAtlasSprite sprite;
21 | private ExtendedVertexBuilder extDelegate;
22 |
23 | @Inject(method = "", at = @At("RETURN"))
24 | private void getExtBuilder(VertexConsumer vertexConsumer, TextureAtlasSprite textureAtlasSprite, CallbackInfo ci) {
25 | this.extDelegate = (ExtendedVertexBuilder) vertexConsumer;
26 | }
27 |
28 | @Override
29 | public void vertex(float x, float y, float z, int packedColor, float u, float v, int overlay, int light, int packedNormal) {
30 | this.extDelegate.vertex(x, y, z, packedColor, this.sprite.getU(u * 16.0F), this.sprite.getV(v * 16.0F), overlay, light, packedNormal);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/net/vulkanmod/render/chunk/ChunkRenderer.java:
--------------------------------------------------------------------------------
1 | package net.vulkanmod.render.chunk;
2 |
3 | import net.minecraft.client.renderer.ChunkBufferBuilderPack;
4 | import net.minecraft.client.renderer.chunk.RenderRegionCache;
5 |
6 | import java.util.Queue;
7 | import java.util.concurrent.ConcurrentLinkedQueue;
8 |
9 | public class ChunkRenderer {
10 |
11 | private final static int threadCount = 4;
12 | private Thread[] threads;
13 | private Queue