OpenGL 4.3 Compute Shaders Quick Test on AMD Radeon (Linux and Windows)



OpenGL 4.3 compute shader test with GLSL Hacker, Linux



With the release of a new graphics driver with full OpenGL 4.3 support by AMD for Windows and Linux, I couldn’t resist to test compute shaders, one of the media features of OpenGL 4.3.

I did two tests: one under Windows 8 64-bit with a Radeon HD 7970 and a second under Linux Mint 15 with a Radeon HD 7770. For the tests, I used GLSL Hacker and loaded two demos of the Code Sample Pack: GLSL_Compute_Shaders_PostFX/ and GLSL_Compute_Shaders_Particles/.






The first compute shader test (GLSL_Compute_Shaders_PostFX/) performs a post processing effect and uses the imageStore() function to write the new data into the destination texture. The test worked fine with HD 7970 (Win8) and HD 7770 (Linux Mint 15).

OpenGL 4.3 compute shader test with GLSL Hacker, Windows 8
Compute shaders test – Windows 8


OpenGL 4.3 compute shader test with GLSL Hacker, Linux Mint 15
Compute shaders test – Linux Mint 15



The second compute shader test (GLSL_Compute_Shaders_Particles/) deforms a grid of vertices using some sin+cos functions. Once again, the test worked perfectly fine on the HD 7970 (Win8) and HD 7770 (Linux Mint 15).

OpenGL 4.3 compute shader test with GLSL Hacker, Windows 8
Compute shaders test – Windows 8


OpenGL 4.3 compute shader test with GLSL Hacker, Linux Mint 15
Compute shaders test – Linux Mint 15

Here is the code of that compute shader:

#version 430
#extension GL_ARB_compute_shader : enable
#extension GL_ARB_shader_storage_buffer_object : enable

struct particle
{
  vec4	pos;
  vec4	c;
  vec4	n;
  vec4	t;
};

layout(std430, binding=0) buffer particles
{
  particle p[];
};

uniform uint max_particles;
uniform float time;
layout (local_size_x = 128, local_size_y = 1, local_size_z = 1) in;
void main() 
{
  uint gid = gl_GlobalInvocationID.x;
  if (gid <= max_particles)
  {
    particle part = p[gid];
    part.pos.y = 2.0 * cos(time + part.pos.x * 0.1) + sin(time + part.pos.z * 0.1);
    part.pos.y *= 2.0 * sin(time + part.pos.x * 0.1) + cos(time + part.pos.z * 0.1);
    p[gid] = part;
  }
}



It's a good news for the OpenGL community, compute shaders and more generally OpenGL 4.3 seem to be now fully supported by NVIDIA and now by AMD!




Geeks3D.com

↑ Grab this Headline Animator