PyGPU: call 'GPU_shader_bind' in 'GPUShader.uniform_' methods

This simplifies python code.

When we call a method like shader.uniform_float("color", (1,1,1,1)),
we expect the shader's uniform to be updated regardless of whether the
shader is bound or not.

And `batch.draw()` already calls `GPU_shader_bind` inside.

Differential Revision: https://developer.blender.org/D15929
This commit is contained in:
Germano Cavalcante
2022-09-19 09:39:48 -03:00
parent 2fffd7d7a8
commit 2ce8b01c59
11 changed files with 7 additions and 10 deletions

View File

@@ -742,7 +742,6 @@ class Gizmo(StructRNA):
matrix = self.matrix_world
batch, shader = shape
shader.bind()
if select_id is not None:
gpu.select.load_id(select_id)

View File

@@ -78,7 +78,6 @@ def draw_texture_2d(texture, position, width, height):
gpu.matrix.scale((width, height))
shader = gpu.shader.from_builtin('IMAGE')
shader.bind()
if isinstance(texture, int):
# Call the legacy bgl to not break the existing API

View File

@@ -19,7 +19,6 @@ def draw_callback_px(self, context):
gpu.state.blend_set('ALPHA')
gpu.state.line_width_set(2.0)
batch = batch_for_shader(shader, 'LINE_STRIP', {"pos": self.mouse_path})
shader.bind()
shader.uniform_float("color", (0.0, 0.0, 0.0, 0.5))
batch.draw(shader)