Quantcast
Channel: AMD Developer Forums: Message List - OpenGL & Vulkan
Viewing all articles
Browse latest Browse all 631

Re: Re: GLSL compute shader incompatibilities

$
0
0

As I said, I have workarounds. I am able to use the std430 layout in shaders while clearing the buffer with same default for the three (RGB) channels. The function glClearBufferData works without any problem when supplied with parameters GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT. Originally, I wanted to clear the buffer with different default values for each channel.

 

The GLSL code for the second case follows. I also tried with the default value 0 instead of 0xffffffff, but the result was the same.

 

struct entry {    uint key;    uint k;    uint index;
};

layout(std430) buffer Hashes {
    entry hashes[];
};

uint hash(uint value, uint iteration, uint capacity) {
    value = ((value ^ 65521) + 2039) % 65537;    return (value + iteration * iteration) % capacity; // quadratic probing
}

void main() {
   // writeHash is used
}

void writeHash(uint i, uint j, uint k, uint elemIdx) {
    uint key = i * maxCount + j; // compute 1D index of 2D data    bool written = false;    uint iteration = 0;    uint maxIterations = min(maxHashIterations, 3 * maxNumTotalElements);    while (!written && iteration < maxIterations) {        uint index = hash(key, iteration, 3 * maxNumTotalElements);        //uint oldKey = atomicCompSwap(hashes[index].key, INVALID_KEY, key); // NVIDIA follows OpenGL spec        uint oldKey = atomicCompSwap(hashes[index].key, key, INVALID_KEY); // ATI atomicCompSwap BUG        if (oldKey == INVALID_KEY) { // INVALID_KEY == 0xffffffff (default value)            hashes[index].k = k;            hashes[index].index = elemIdx;            written = true;        }        iteration++;    }    if (!written) {        atomicCounterIncrement(hashErrorCount); // count not hashed elements    }
}

Viewing all articles
Browse latest Browse all 631

Trending Articles