We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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