Skip to content

Commit

Permalink
Make sure buffer is properly driver created before naming; should fix…
Browse files Browse the repository at this point in the history
… an AMD crash
  • Loading branch information
IMS212 committed Mar 9, 2024
1 parent e54da73 commit 813b5b3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
19 changes: 18 additions & 1 deletion src/main/java/net/irisshaders/iris/gl/IrisRenderSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,11 @@ public static void bindBuffer(int target, int buffer) {
GL46C.glBindBuffer(target, buffer);
}

public interface DSAAccess {
public static int createBuffers() {
return dsaState.createBuffers();
}

public interface DSAAccess {
void generateMipmaps(int texture, int target);

void texParameteri(int texture, int target, int pname, int param);
Expand Down Expand Up @@ -479,6 +483,8 @@ public interface DSAAccess {
int createFramebuffer();

int createTexture(int target);

int createBuffers();
}

public static class DSACore extends DSAARB {
Expand Down Expand Up @@ -546,6 +552,11 @@ public int bufferStorage(int target, float[] data, int usage) {
return buffer;
}

@Override
public int createBuffers() {
return ARBDirectStateAccess.glCreateBuffers();
}

@Override
public void blitFramebuffer(int source, int dest, int offsetX, int offsetY, int width, int height, int offsetX2, int offsetY2, int width2, int height2, int bufferChoice, int filter) {
ARBDirectStateAccess.glBlitNamedFramebuffer(source, dest, offsetX, offsetY, width, height, offsetX2, offsetY2, width2, height2, bufferChoice, filter);
Expand Down Expand Up @@ -662,6 +673,12 @@ public int createTexture(int target) {
GlStateManager._bindTexture(texture);
return texture;
}

@Override
public int createBuffers() {
int value = GlStateManager._glGenBuffers();
return value;
}
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ShaderStorageBuffer {
protected int id;

public ShaderStorageBuffer(int index, ShaderStorageInfo info) {
this.id = GlStateManager._glGenBuffers();
this.id = IrisRenderSystem.createBuffers();
GLDebug.nameObject(GL43C.GL_BUFFER, id, "SSBO " + index);
this.index = index;
this.info = info;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public void setupBuffers() {
}

for (ShaderStorageBuffer buffer : buffers) {
buffer.bind();
if (buffer != null) {
buffer.bind();
}
}
}

Expand All @@ -76,7 +78,9 @@ public int getBufferIndex(int index) {

public void destroyBuffers() {
for (ShaderStorageBuffer buffer : buffers) {
buffer.destroy();
if (buffer != null) {
buffer.destroy();
}
}
buffers = null;
destroyed = true;
Expand Down

0 comments on commit 813b5b3

Please sign in to comment.