Hi,
i have a complex compute shader project that refuses to work since i've replaced gtx670/480 against R9 280X.
Hopefully at the end i can give some useful GPGPU performance comparison without the need to compare OpenCL against Cuda.
The first issue is: I'm unable to modify a Shader Storage Buffers by shader - maybe i miss some stupid little thing...
The setup code is this:
int sizeLists = sizeof(int) * 4096;
gpuData.dataDbgOut = (int*)_aligned_malloc (sizeLists, 16);
gpuData.dataDbgOut[0] = 10;
gpuData.dataDbgOut[1] = 20;
gpuData.dataDbgOut[2] = 30;
gpuData.dataDbgOut[3] = 40;
glGenBuffers (1, &gpuData.ssbDbgOut);
glBindBuffer (GL_SHADER_STORAGE_BUFFER, gpuData.ssbDbgOut);
glBufferData (GL_SHADER_STORAGE_BUFFER, sizeLists, gpuData.dataDbgOut, GL_DYNAMIC_COPY);
glBindBufferBase (GL_SHADER_STORAGE_BUFFER, 1, gpuData.ssbDbgOut);
gpuData.computeShaderTestATI = GL_Helper::CompileShaderFile ("..\\Engine\\shader\\gi_TestATI.glsl", GL_COMPUTE_SHADER, 1, includeAll);
gpuData.computeProgramHandleTestATI = glCreateProgram();
if (!gpuData.computeProgramHandleTestATI) { SystemTools::Log ("Error creating compute program object.\n"); return 0; }
glAttachShader (gpuData.computeProgramHandleTestATI, gpuData.computeShaderTestATI);
if (!GL_Helper::LinkProgram (gpuData.computeProgramHandleTestATI)) return 0;
Per frame code:
glBegin (GL_POINTS); glVertex3f (0,0,0); glEnd (); // <- remove this and it works
glUseProgram (gpuData.computeProgramHandleTestATI);
glDispatchCompute (1, 1, 1);
glMemoryBarrier (GL_ALL_BARRIER_BITS);
glBindBuffer (GL_SHADER_STORAGE_BUFFER, gpuData.ssbDbgOut);
int* result = (int*) glMapBuffer (GL_SHADER_STORAGE_BUFFER, GL_READ_ONLY);
for (int i=0; i<4; i++) base_debug::logF->Print ("dbg: ", float(result));
glUnmapBuffer (GL_SHADER_STORAGE_BUFFER);
Shader:
layout (local_size_x = 1) in;
layout (binding = 1, std430) buffer dbg_block
{
uint dbgout[];
};
void main (void)
{
dbgout[0] = 0;
dbgout[1] = 1;
dbgout[2] = 2;
dbgout[3] = 3;
}
For the output i' expect 1,2,3,4 as modified by shader, but it is still 10,20,30,40
I've tried GL error checking but there is none, also the shader program is definitively called, and there are no shader compiler errors.
Any idea what's wrong? Version is ok too:
OpenGL ok
GL Vendor : ATI Technologies Inc.
GL Renderer : AMD Radeon R9 200 Series
GL Version (string) : 4.3.12967 Compatibility Profile Context 14.200.1004.0
GL Version (integer) : 4.3
GLSL Version : 4.40
EDIT: Added the stupid little thing :)