This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

GLSL Compute Shader: ERROR: xxx: S0001: Function call discards 'readonly' access qualifier.

Hi, I have compute shader with following code:

...
struct CullingObjInfo {
...
    vec4 boundingSphere; // radius(float) + position(float3)
...
    vec4 lodDistance;
};
...
layout(std430, binding = 2) restrict readonly buffer CullingObjectInfo {
    CullingObjInfo cullingObjInfo[];
};
...
bool SelectLodByDistance(const CullingObjInfo cullingObjectInfo, const vec4 cameraPosition) {
    float distanceSq = dot(cullingObjectInfo.boundingSphere.xyz, cameraPosition.xyz);
    return distanceSq >= cullingObjectInfo.lodDistance.x && distanceSq <= cullingObjectInfo.lodDistance.y;
}

layout (local_size_x = 1, local_size_y = 1) in;
void main() {
    if (!SelectLodByDistance(cullingObjInfo[gl_GlobalInvocationID.x], cameraInfo.cameraPosition)) {
        return;
    }
...
}

During compiling i have got error for calling function "SelectLodByDistance": ERROR: xxx: S0001: Function call discards 'readonly' access qualifier.

But if I change code:

...
bool SelectLodByDistance(uint index, const vec4 cameraPosition) {
    float distanceSq = dot(cullingObjInfo[index].boundingSphere.xyz, cameraPosition.xyz);
    return distanceSq >= cullingObjInfo[index].lodDistance.x && distanceSq <= cullingObjInfo[index].lodDistance.y;
}

layout (local_size_x = 1, local_size_y = 1) in;
    void main() {
    if (!SelectLodByDistance(gl_GlobalInvocationID.x, cameraInfo.cameraPosition)) {
        return;
    }
...
}

It works, What do i do wrong ?

BR, Andrey

Parents Reply Children
No data