GPU: Move Polyline shader to primitive expansion

This port is not so straightforward.

This shader is used in different configurations and is
available to python bindings. So we need to keep
compatibility with different attributes configurations.

This is why attributes are loaded per component and a
uniform sets the length of the component.

Since this shader can be used from both the imm and batch
API, we need to inject some workarounds to bind the buffers
correctly.

The end result is still less versatile than the previous
metal workaround (i.e.: more attribute fetch mode supported),
but it is also way less code.

### Limitations:
The new shader has some limitation:
- Both `color` and `pos` attributes need to be `F32`.
- Each attribute needs to be 4byte aligned.
- Fetch type needs to be `GPU_FETCH_FLOAT`.
- Primitive type needs to be `GPU_PRIM_LINES`, `GPU_PRIM_LINE_STRIP` or `GPU_PRIM_LINE_LOOP`.
- If drawing using an index buffer, it must contain no primitive restart.

Rel #127493

Co-authored-by: Jeroen Bakker <jeroen@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/129315
This commit is contained in:
Clément Foucault
2024-11-27 17:37:04 +01:00
committed by Clément Foucault
parent 611940805e
commit 00a8d006fe
32 changed files with 564 additions and 370 deletions

View File

@@ -786,6 +786,12 @@ void GPU_shader_uniform_2iv(GPUShader *sh, const char *name, const int data[2])
GPU_shader_uniform_int_ex(sh, loc, 2, 1, data);
}
void GPU_shader_uniform_3iv(GPUShader *sh, const char *name, const int data[3])
{
const int loc = GPU_shader_get_uniform(sh, name);
GPU_shader_uniform_int_ex(sh, loc, 3, 1, data);
}
void GPU_shader_uniform_mat4(GPUShader *sh, const char *name, const float data[4][4])
{
const int loc = GPU_shader_get_uniform(sh, name);