void HdxColorCorrectionTask::Execute(HdTaskContext* ctx) { HD_TRACE_FUNCTION(); HF_MALLOC_TAG_FUNCTION(); if (!_CreateBufferResources()) { return; } if (!_CreateShaderResources()) { return; } _CreateFramebufferResources(&_texture); _CopyTexture(); _ApplyColorCorrection(); }
void HdxCompositor::Draw(GLuint colorId, GLuint depthId, bool remapDepth) { // No-op if no color data was specified. if (colorId == 0) { return; } // Create draw buffers if they haven't been created yet. if (_vertexBuffer == 0) { _CreateBufferResources(); } bool useDepthProgram = (depthId != 0); // Load the shader if it hasn't been loaded, or we're changing modes. if (!_compositorProgram || _useDepthProgram != useDepthProgram) { _CreateShaderResources(useDepthProgram); _useDepthProgram = useDepthProgram; } // No-op if the shader failed to compile. if (!_compositorProgram) { return; } // A note here: HdxCompositor is used for all of our plugins and has to be // robust to poor GL support. OSX compatibility profile provides a // GL 2.1 API, slightly restricting our choice of API and heavily // restricting our shader syntax. GLuint programId = _compositorProgram->GetProgram().GetId(); glUseProgram(programId); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, colorId); glUniform1i(_locations[colorIn], 0); if (depthId != 0) { glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, depthId); glUniform1i(_locations[depthIn], 1); } glUniform1i(_locations[remapDepthIn], (GLint)remapDepth); glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer); glVertexAttribPointer(_locations[position], 4, GL_FLOAT, GL_FALSE, sizeof(float)*6, 0); glEnableVertexAttribArray(_locations[position]); glVertexAttribPointer(_locations[uvIn], 2, GL_FLOAT, GL_FALSE, sizeof(float)*6, reinterpret_cast<void*>(sizeof(float)*4)); glEnableVertexAttribArray(_locations[uvIn]); GLboolean restoreAlphaToCoverage; glGetBooleanv(GL_SAMPLE_ALPHA_TO_COVERAGE, &restoreAlphaToCoverage); glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); glDrawArrays(GL_TRIANGLES, 0, 3); if (restoreAlphaToCoverage) { glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE); } glBindBuffer(GL_ARRAY_BUFFER, 0); glDisableVertexAttribArray(_locations[position]); glDisableVertexAttribArray(_locations[uvIn]); glUseProgram(0); if (depthId != 0) { glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, 0); } glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); GLF_POST_PENDING_GL_ERRORS(); }