-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated to iris 1.6.9 and added basic ssbo support
- Loading branch information
Showing
13 changed files
with
158 additions
and
27 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
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
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
46 changes: 46 additions & 0 deletions
46
src/main/java/me/cortex/vulkanite/mixin/iris/MixinShaderStorageBuffer.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,46 @@ | ||
package me.cortex.vulkanite.mixin.iris; | ||
|
||
import me.cortex.vulkanite.client.Vulkanite; | ||
import me.cortex.vulkanite.compat.IVGBuffer; | ||
import me.cortex.vulkanite.lib.memory.VGBuffer; | ||
import net.coderbot.iris.gl.IrisRenderSystem; | ||
import net.coderbot.iris.gl.buffer.ShaderStorageBuffer; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
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.Redirect; | ||
|
||
import static org.lwjgl.opengl.GL15C.glDeleteBuffers; | ||
|
||
@Mixin(value = ShaderStorageBuffer.class, remap = false) | ||
public class MixinShaderStorageBuffer implements IVGBuffer { | ||
@Shadow protected int id; | ||
@Unique | ||
private VGBuffer vkBuffer; | ||
|
||
public VGBuffer getBuffer() { | ||
return vkBuffer; | ||
} | ||
|
||
public void setBuffer(VGBuffer buffer) { | ||
if (vkBuffer != null && buffer != null) { | ||
throw new IllegalStateException("Override buffer not null"); | ||
} | ||
this.vkBuffer = buffer; | ||
if (buffer != null) { | ||
glDeleteBuffers(id); | ||
id = vkBuffer.glId; | ||
} | ||
} | ||
|
||
@Redirect(method = "destroy", at = @At(value = "INVOKE", target = "Lnet/coderbot/iris/gl/IrisRenderSystem;deleteBuffers(I)V")) | ||
private void redirectDelete(int id) { | ||
if (vkBuffer != null) { | ||
Vulkanite.INSTANCE.addSyncedCallback(vkBuffer::free); | ||
} else { | ||
IrisRenderSystem.deleteBuffers(id); | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/me/cortex/vulkanite/mixin/iris/MixinShaderStorageBufferHolder.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,46 @@ | ||
package me.cortex.vulkanite.mixin.iris; | ||
|
||
import com.mojang.blaze3d.platform.GlStateManager; | ||
import me.cortex.vulkanite.client.Vulkanite; | ||
import me.cortex.vulkanite.compat.IVGBuffer; | ||
import me.cortex.vulkanite.lib.memory.VGBuffer; | ||
import net.coderbot.iris.gl.IrisRenderSystem; | ||
import net.coderbot.iris.gl.buffer.ShaderStorageBuffer; | ||
import net.coderbot.iris.gl.buffer.ShaderStorageBufferHolder; | ||
import net.coderbot.iris.gl.buffer.ShaderStorageInfo; | ||
import org.lwjgl.opengl.GL43C; | ||
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.Redirect; | ||
|
||
import static org.lwjgl.vulkan.VK10.VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; | ||
import static org.lwjgl.vulkan.VK10.VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; | ||
|
||
@Mixin(value = ShaderStorageBufferHolder.class, remap = false) | ||
public class MixinShaderStorageBufferHolder { | ||
@Unique private ShaderStorageInfo storageInfo; | ||
|
||
@Redirect(method = "lambda$new$0", at = @At(value = "INVOKE", target = "Lnet/coderbot/iris/gl/buffer/ShaderStorageInfo;relative()Z")) | ||
private boolean alwaysReturnTrue(ShaderStorageInfo instance) { | ||
this.storageInfo = instance; | ||
return true; | ||
} | ||
|
||
private static VGBuffer alloc(int size) { | ||
return Vulkanite.INSTANCE.getCtx().memory.createSharedBuffer(size, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); | ||
} | ||
|
||
@Redirect(method = "lambda$new$0", at = @At(value = "INVOKE", target = "Lnet/coderbot/iris/gl/buffer/ShaderStorageBuffer;resizeIfRelative(II)V")) | ||
private void redirectSizeAllocation(ShaderStorageBuffer instance, int width, int height) { | ||
if (storageInfo.relative()) { | ||
instance.resizeIfRelative(width, height); | ||
} else { | ||
((IVGBuffer)instance).setBuffer(alloc(storageInfo.size())); | ||
GlStateManager._glBindBuffer(GL43C.GL_SHADER_STORAGE_BUFFER, instance.getId()); | ||
IrisRenderSystem.clearBufferSubData(GL43C.GL_SHADER_STORAGE_BUFFER, GL43C.GL_R8, 0, storageInfo.size(), GL43C.GL_RED, GL43C.GL_BYTE, new int[] {0}); | ||
IrisRenderSystem.bindBufferBase(GL43C.GL_SHADER_STORAGE_BUFFER, instance.getIndex(), instance.getId()); | ||
} | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/me/cortex/vulkanite/mixin/iris/ShaderStorageBufferHolderAccessor.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,12 @@ | ||
package me.cortex.vulkanite.mixin.iris; | ||
|
||
import net.coderbot.iris.gl.buffer.ShaderStorageBuffer; | ||
import net.coderbot.iris.gl.buffer.ShaderStorageBufferHolder; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(value = ShaderStorageBufferHolder.class, remap = false) | ||
public interface ShaderStorageBufferHolderAccessor { | ||
@Accessor | ||
ShaderStorageBuffer[] getBuffers(); | ||
} |
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
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
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