-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved core shader modification detection
- Loading branch information
Showing
6 changed files
with
142 additions
and
29 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
32 changes: 32 additions & 0 deletions
32
common/src/main/java/net/raphimc/immediatelyfast/injection/interfaces/IShaderProgram.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,32 @@ | ||
/* | ||
* This file is part of ImmediatelyFast - https://github.com/RaphiMC/ImmediatelyFast | ||
* Copyright (C) 2023-2025 RK_01/RaphiMC and contributors | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package net.raphimc.immediatelyfast.injection.interfaces; | ||
|
||
import net.minecraft.client.gl.CompiledShader; | ||
|
||
public interface IShaderProgram { | ||
|
||
CompiledShader immediatelyFast$getVertexShader(); | ||
|
||
void immediatelyFast$setVertexShader(final CompiledShader vertexShader); | ||
|
||
CompiledShader immediatelyFast$getFragmentShader(); | ||
|
||
void immediatelyFast$setFragmentShader(final CompiledShader fragmentShader); | ||
|
||
} |
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
67 changes: 67 additions & 0 deletions
67
...ain/java/net/raphimc/immediatelyfast/injection/mixins/core/compat/MixinShaderProgram.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,67 @@ | ||
/* | ||
* This file is part of ImmediatelyFast - https://github.com/RaphiMC/ImmediatelyFast | ||
* Copyright (C) 2023-2025 RK_01/RaphiMC and contributors | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package net.raphimc.immediatelyfast.injection.mixins.core.compat; | ||
|
||
import net.minecraft.client.gl.CompiledShader; | ||
import net.minecraft.client.gl.ShaderProgram; | ||
import net.minecraft.client.render.VertexFormat; | ||
import net.raphimc.immediatelyfast.injection.interfaces.IShaderProgram; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(ShaderProgram.class) | ||
public abstract class MixinShaderProgram implements IShaderProgram { | ||
|
||
@Unique | ||
private CompiledShader immediatelyFast$vertexShader; | ||
|
||
@Unique | ||
private CompiledShader immediatelyFast$fragmentShader; | ||
|
||
@Inject(method = "create", at = @At("RETURN")) | ||
private static void storeShaderReferences(CompiledShader vertexShader, CompiledShader fragmentShader, VertexFormat format, CallbackInfoReturnable<ShaderProgram> cir) { | ||
if (cir.getReturnValue() instanceof IShaderProgram mixinShaderProgram) { | ||
mixinShaderProgram.immediatelyFast$setVertexShader(vertexShader); | ||
mixinShaderProgram.immediatelyFast$setFragmentShader(fragmentShader); | ||
} | ||
} | ||
|
||
@Override | ||
public CompiledShader immediatelyFast$getVertexShader() { | ||
return this.immediatelyFast$vertexShader; | ||
} | ||
|
||
@Override | ||
public void immediatelyFast$setVertexShader(final CompiledShader vertexShader) { | ||
this.immediatelyFast$vertexShader = vertexShader; | ||
} | ||
|
||
@Override | ||
public CompiledShader immediatelyFast$getFragmentShader() { | ||
return this.immediatelyFast$fragmentShader; | ||
} | ||
|
||
@Override | ||
public void immediatelyFast$setFragmentShader(final CompiledShader fragmentShader) { | ||
this.immediatelyFast$fragmentShader = fragmentShader; | ||
} | ||
|
||
} |
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
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