<commit_before># Copyright (c) 2015 <NAME>.
# Cura is released under the terms of the AGPLv3 or higher.

from UM.Application import Application
from UM.Resources import Resources

from UM.Math.Matrix import Matrix

from UM.View.RenderPass import RenderPass
from UM.View.GL.OpenGL import OpenGL

class CompositePass(RenderPass):
    def __init__(self, width, height):
        super().__init__("composite", width, height)

        self._shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "composite.shader"))
        self._gl = OpenGL.getInstance().getBindingsObject()
        self._renderer = Application.getInstance().getRenderer()

    def setCompositeShader(self, shader):
        self._shader = shader

    def renderContents(self):
        pass

    def renderOutput(self):
        self._shader.bind()

        texture_unit = 0
        for render_pass in self._renderer.getRenderPasses():
            self._gl.glActiveTexture(texture_unit)
            self._gl.glBindTexture(self._gl.GL_TEXTURE_2D, render_pass.getTextureId())
            texture_unit += 1

        self._renderer.renderQuad(self._shader)

        for i in range(texture_unit):
            self._gl.glActiveTexture(texture_unit)
            self._gl.glBindTexture(self._gl.GL_TEXTURE_2D, 0)

        self._shader.release()<commit_msg>Add explicit render layer binding instead of assuming all render passes can be used for compositing<commit_after># Copyright (c) 2015 <NAME>.
# Cura is released under the terms of the AGPLv3 or higher.

from UM.Application import Application
from UM.Resources import Resources

from UM.Math.Matrix import Matrix

from UM.View.RenderPass import RenderPass
from UM.View.GL.OpenGL import OpenGL

class CompositePass(RenderPass):
    def __init__(self, width, height):
        super().__init__("composite", width, height, 999)

        self._shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "composite.shader"))
        self._gl = OpenGL.getInstance().getBindingsObject()
        self._renderer = Application.getInstance().getRenderer()

        self._layer_bindings = [ "default", "selection" ]

    def setCompositeShader(self, shader):
        self._shader = shader

    def setLayerBindings(self, bindings):
        self._layer_bindings = bindings

    def render(self):
        self._shader.bind()

        texture_unit = 0
        for binding in self._layer_bindings:
            render_pass = self._renderer.getRenderPass(binding)
            if not render_pass:
                continue

            self._gl.glActiveTexture(getattr(self._gl, "GL_TEXTURE{0}".format(texture_unit)))
            self._gl.glBindTexture(self._gl.GL_TEXTURE_2D, render_pass.getTextureId())
            texture_unit += 1

        self._renderer.renderFullScreenQuad(self._shader)

        for i in range(texture_unit):
            self._gl.glActiveTexture(getattr(self._gl, "GL_TEXTURE{0}".format(i)))
            self._gl.glBindTexture(self._gl.GL_TEXTURE_2D, 0)

        self._shader.release()
{'fraction_non_alphanumeric': 0.0975130890052356, 'fraction_numerical': 0.008180628272251309, 'mean_word_length': 3.1762295081967213, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7115182', 'n_tokens_mistral': 903, 'n_tokens_neox': 864, 'n_words': 194}