| 79 | } |
| 80 | |
| 81 | Status GlShaderSync::NewSync(GlShaderSync* gl_sync) { |
| 82 | GlShaderSync sync; |
| 83 | RETURN_IF_ERROR(CreatePersistentBuffer(sizeof(int), &sync.flag_buffer_)); |
| 84 | static const std::string* kCode = new std::string(R"(#version 310 es |
| 85 | layout(local_size_x = 1, local_size_y = 1) in; |
| 86 | layout(std430) buffer; |
| 87 | layout(binding = 0) buffer Output { |
| 88 | int elements[]; |
| 89 | } output_data; |
| 90 | void main() { |
| 91 | output_data.elements[0] = 1; |
| 92 | })"); |
| 93 | GlShader shader; |
| 94 | RETURN_IF_ERROR(GlShader::CompileShader(GL_COMPUTE_SHADER, *kCode, &shader)); |
| 95 | RETURN_IF_ERROR(GlProgram::CreateWithShader(shader, &sync.flag_program_)); |
| 96 | *gl_sync = std::move(sync); |
| 97 | return OkStatus(); |
| 98 | } |
| 99 | |
| 100 | // How it works: GPU writes a buffer and CPU checks the buffer value to be |
| 101 | // changed. The buffer is accessible for writing by GPU and reading by CPU |
nothing calls this directly
no test coverage detected