Cleanup: DRW: Remove support for ModelViewProjectionMatrix

This has been replace by manual model+viewproj transform inside the shader.
This commit is contained in:
2020-06-03 10:58:05 +02:00
parent 75015f27ba
commit 0e14eb7b31
3 changed files with 6 additions and 24 deletions

View File

@@ -290,7 +290,6 @@ typedef enum {
DRW_UNIFORM_BASE_INSTANCE,
DRW_UNIFORM_MODEL_MATRIX,
DRW_UNIFORM_MODEL_MATRIX_INVERSE,
DRW_UNIFORM_MODELVIEWPROJECTION_MATRIX,
/* WARNING: set DRWUniform->type
* bit length accordingly. */
} DRWUniformType;

View File

@@ -1198,9 +1198,10 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader)
shgroup, model_ubo_location, DRW_UNIFORM_BLOCK_OBMATS, NULL, 0, 1);
}
else {
/* Note: This is only here to support old hardware fallback where uniform buffer is still
* too slow or buggy. */
int model = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODEL);
int modelinverse = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODEL_INV);
int modelviewprojection = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MVP);
if (model != -1) {
drw_shgroup_uniform_create_ex(shgroup, model, DRW_UNIFORM_MODEL_MATRIX, NULL, 0, 1);
}
@@ -1208,10 +1209,6 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader)
drw_shgroup_uniform_create_ex(
shgroup, modelinverse, DRW_UNIFORM_MODEL_MATRIX_INVERSE, NULL, 0, 1);
}
if (modelviewprojection != -1) {
drw_shgroup_uniform_create_ex(
shgroup, modelviewprojection, DRW_UNIFORM_MODELVIEWPROJECTION_MATRIX, NULL, 0, 1);
}
}
if (info_ubo_location != -1) {
@@ -1241,6 +1238,7 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader)
BLI_assert(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_PROJECTION) == -1);
BLI_assert(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_PROJECTION_INV) == -1);
BLI_assert(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_CLIPPLANES) == -1);
BLI_assert(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MVP) == -1);
}
static DRWShadingGroup *drw_shgroup_create_ex(struct GPUShader *shader, DRWPass *pass)

View File

@@ -66,7 +66,6 @@ typedef struct DRWCommandsState {
/* Legacy matrix support. */
int obmat_loc;
int obinv_loc;
int mvp_loc;
/* Selection ID state. */
GPUVertBuf *select_buf;
uint select_id;
@@ -656,8 +655,7 @@ static void draw_compute_culling(DRWView *view)
BLI_INLINE void draw_legacy_matrix_update(DRWShadingGroup *shgroup,
DRWResourceHandle *handle,
float obmat_loc,
float obinv_loc,
float mvp_loc)
float obinv_loc)
{
/* Still supported for compatibility with gpu_shader_* but should be forbidden. */
DRWObjectMatrix *ob_mats = DRW_memblock_elem_from_handle(DST.vmempool->obmats, handle);
@@ -667,13 +665,6 @@ BLI_INLINE void draw_legacy_matrix_update(DRWShadingGroup *shgroup,
if (obinv_loc != -1) {
GPU_shader_uniform_vector(shgroup->shader, obinv_loc, 16, 1, (float *)ob_mats->modelinverse);
}
/* Still supported for compatibility with gpu_shader_* but should be forbidden
* and is slow (since it does not cache the result). */
if (mvp_loc != -1) {
float mvp[4][4];
mul_m4_m4m4(mvp, DST.view_active->storage.persmat, ob_mats->model);
GPU_shader_uniform_vector(shgroup->shader, mvp_loc, 16, 1, (float *)mvp);
}
}
BLI_INLINE void draw_geometry_bind(DRWShadingGroup *shgroup, GPUBatch *geom)
@@ -866,9 +857,6 @@ static void draw_update_uniforms(DRWShadingGroup *shgroup,
case DRW_UNIFORM_MODEL_MATRIX_INVERSE:
state->obinv_loc = uni->location;
break;
case DRW_UNIFORM_MODELVIEWPROJECTION_MATRIX:
state->mvp_loc = uni->location;
break;
}
}
}
@@ -1004,10 +992,8 @@ static void draw_call_single_do(DRWShadingGroup *shgroup,
draw_call_resource_bind(state, &handle);
/* TODO This is Legacy. Need to be removed. */
if (state->obmats_loc == -1 &&
(state->obmat_loc != -1 || state->obinv_loc != -1 || state->mvp_loc != -1)) {
draw_legacy_matrix_update(
shgroup, &handle, state->obmat_loc, state->obinv_loc, state->mvp_loc);
if (state->obmats_loc == -1 && (state->obmat_loc != -1 || state->obinv_loc != -1)) {
draw_legacy_matrix_update(shgroup, &handle, state->obmat_loc, state->obinv_loc);
}
if (G.f & G_FLAG_PICKSEL) {
@@ -1113,7 +1099,6 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
.resourceid_loc = -1,
.obmat_loc = -1,
.obinv_loc = -1,
.mvp_loc = -1,
.drw_state_enabled = 0,
.drw_state_disabled = 0,
};