I cannot seem to get early fragment depth test to work as my fragment shader is still writing data into my storage buffer where the sample is suppose to be hidden. I have specified “layout(early_fragment_tests) in;” in my fragment shader as how it was done previously in OpenGL. The Vulkan spec mentions enabling the EarlyFragmentTests OpExecutionMode which I assume that’s what the layout qualifier is suppose to do. There are no validation, SPIR-V or rendering errors. Has anyone else run into this problem?
Hi Krooze thanks for the reply. I use glslangValidator.exe to translate GLSL to SPIRV. I do see the line “ExecutionMode 4 EarlyFragmentTests” in the human readable SIPRV.
Early depth test doesn’t seem to work as I place a mesh right in front of the camera blocking all the background meshes yet their hidden fragments are still processed. fragId is just my textureId used to index the storagebuffer, passed from vertex attribute into the vertex shader then into the fragment shader. I am clearing outSample’s id (at index fragId) to -1 in the vertex shader and I am just counting the number of non -1 values in the id buffer array after the frame is rendered.
I am sure depth testing is enabled in the pipeline:
my application tend to break arbitrarily at some line within the update loop. Is it a conflict caused by reading/writing the storage buffer by CPU and GPU at the same time and if so how can I fix it?