e
This commit is contained in:
@@ -102,7 +102,7 @@ public class Capabilities {
|
|||||||
if (this.compute&&this.isAmd) {
|
if (this.compute&&this.isAmd) {
|
||||||
this.hasBrokenDepthSampler = testDepthSampler();
|
this.hasBrokenDepthSampler = testDepthSampler();
|
||||||
if (this.hasBrokenDepthSampler) {
|
if (this.hasBrokenDepthSampler) {
|
||||||
//throw new IllegalStateException("it bork, amd is bork");
|
throw new IllegalStateException("it bork, amd is bork");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.hasBrokenDepthSampler = false;
|
this.hasBrokenDepthSampler = false;
|
||||||
@@ -115,15 +115,20 @@ public class Capabilities {
|
|||||||
private static boolean testDepthSampler() {
|
private static boolean testDepthSampler() {
|
||||||
String src = """
|
String src = """
|
||||||
#version 460 core
|
#version 460 core
|
||||||
layout(local_size_x=1) in;
|
layout(local_size_x=16,local_size_y=16) in;
|
||||||
|
|
||||||
layout(binding = 0) uniform sampler2D depthSampler;
|
layout(binding = 0) uniform sampler2D depthSampler;
|
||||||
layout(binding = 1) buffer OutData {
|
layout(binding = 1) buffer OutData {
|
||||||
float[] outData;
|
float[] outData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
layout(location = 2) uniform int dynamicSampleThing;
|
||||||
|
layout(location = 3) uniform float sampleData;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
outData[0] = texelFetch(depthSampler, ivec2(31, 31), 0).r;
|
if (abs(texelFetch(depthSampler, ivec2(gl_GlobalInvocationID.xy), dynamicSampleThing).r-sampleData)>0.000001f) {
|
||||||
|
outData[0] = 1.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
""";
|
""";
|
||||||
int program = GL20C.glCreateProgram();
|
int program = GL20C.glCreateProgram();
|
||||||
@@ -144,14 +149,15 @@ public class Capabilities {
|
|||||||
glNamedBufferStorage(buffer, 4096, GL_DYNAMIC_STORAGE_BIT|GL_MAP_READ_BIT);
|
glNamedBufferStorage(buffer, 4096, GL_DYNAMIC_STORAGE_BIT|GL_MAP_READ_BIT);
|
||||||
|
|
||||||
int tex = glCreateTextures(GL_TEXTURE_2D);
|
int tex = glCreateTextures(GL_TEXTURE_2D);
|
||||||
glTextureStorage2D(tex, 1, GL_DEPTH24_STENCIL8, 64, 64);
|
glTextureStorage2D(tex, 2, GL_DEPTH24_STENCIL8, 256, 256);
|
||||||
glTextureParameteri(tex, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTextureParameteri(tex, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTextureParameteri(tex, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTextureParameteri(tex, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
|
||||||
int fb = glCreateFramebuffers();
|
int fb = glCreateFramebuffers();
|
||||||
glNamedFramebufferTexture(fb, GL_DEPTH_STENCIL_ATTACHMENT, tex, 0);
|
|
||||||
|
|
||||||
boolean isCorrect = true;
|
boolean isCorrect = true;
|
||||||
|
for (int lvl = 0; lvl <= 1; lvl++) {
|
||||||
|
glNamedFramebufferTexture(fb, GL_DEPTH_STENCIL_ATTACHMENT, tex, lvl);
|
||||||
|
|
||||||
for (int i = 0; i <= 10; i++) {
|
for (int i = 0; i <= 10; i++) {
|
||||||
float value = (float) (i / 10.0);
|
float value = (float) (i / 10.0);
|
||||||
|
|
||||||
@@ -159,10 +165,12 @@ public class Capabilities {
|
|||||||
glClearNamedFramebufferfi(fb, GL_DEPTH_STENCIL, 0, value, 1);//Set the depth texture
|
glClearNamedFramebufferfi(fb, GL_DEPTH_STENCIL, 0, value, 1);//Set the depth texture
|
||||||
|
|
||||||
glUseProgram(program);
|
glUseProgram(program);
|
||||||
|
glUniform1i(2, lvl);
|
||||||
|
glUniform1f(3, value);
|
||||||
glBindTextureUnit(0, tex);
|
glBindTextureUnit(0, tex);
|
||||||
GL30.glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, buffer);
|
GL30.glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, buffer);
|
||||||
|
|
||||||
glDispatchCompute(1,1,1);
|
glDispatchCompute(256>>(lvl+4), 256>>(lvl+4), 1);
|
||||||
glFinish();
|
glFinish();
|
||||||
|
|
||||||
long ptr = nglMapNamedBuffer(buffer, GL_READ_ONLY);
|
long ptr = nglMapNamedBuffer(buffer, GL_READ_ONLY);
|
||||||
@@ -173,12 +181,13 @@ public class Capabilities {
|
|||||||
glBindTextureUnit(0, 0);
|
glBindTextureUnit(0, 0);
|
||||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
||||||
|
|
||||||
boolean localCorrect = Math.abs(value - gottenValue)<0.0000001f;
|
boolean localCorrect = gottenValue==0.0f;
|
||||||
if (!localCorrect) {
|
if (!localCorrect) {
|
||||||
Logger.error("Depth read test failed at value: " + value);
|
Logger.error("Depth read test failed at value: " + value);
|
||||||
}
|
}
|
||||||
isCorrect &= localCorrect;
|
isCorrect &= localCorrect;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
glDeleteFramebuffers(fb);
|
glDeleteFramebuffers(fb);
|
||||||
glDeleteTextures(tex);
|
glDeleteTextures(tex);
|
||||||
|
|||||||
Reference in New Issue
Block a user