Fix: GPU: Assert due to new GPU requirements regarding wide lines
The formats was not using the correct attribute type. Fixes assert in graph drawing and potential assert in cursor drawing Fixes assert in sequencer and file browser
This commit is contained in:
@@ -3230,8 +3230,8 @@ blender::gpu::Batch *DRW_cache_cursor_get(bool crosshair_lines)
|
||||
const int vert_len = segments + 8;
|
||||
const int index_len = vert_len + 5;
|
||||
|
||||
const uchar red[3] = {255, 0, 0};
|
||||
const uchar white[3] = {255, 255, 255};
|
||||
const float red[3] = {1.0f, 0.0f, 0.0f};
|
||||
const float white[3] = {1.0f, 1.0f, 1.0f};
|
||||
|
||||
static GPUVertFormat format = {0};
|
||||
static struct {
|
||||
@@ -3239,8 +3239,7 @@ blender::gpu::Batch *DRW_cache_cursor_get(bool crosshair_lines)
|
||||
} attr_id;
|
||||
if (format.attr_len == 0) {
|
||||
attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
attr_id.color = GPU_vertformat_attr_add(
|
||||
&format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
||||
attr_id.color = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
||||
}
|
||||
|
||||
GPUIndexBufBuilder elb;
|
||||
@@ -3263,9 +3262,10 @@ blender::gpu::Batch *DRW_cache_cursor_get(bool crosshair_lines)
|
||||
GPU_indexbuf_add_generic_vert(&elb, 0);
|
||||
|
||||
if (crosshair_lines) {
|
||||
uchar crosshair_color[3];
|
||||
UI_GetThemeColor3ubv(TH_VIEW_OVERLAY, crosshair_color);
|
||||
float crosshair_color[3];
|
||||
UI_GetThemeColor3fv(TH_VIEW_OVERLAY, crosshair_color);
|
||||
|
||||
/* TODO(fclem): Remove primitive restart. Incompatible with wide lines. */
|
||||
GPU_indexbuf_add_primitive_restart(&elb);
|
||||
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.pos, v, blender::float2{-f20, 0});
|
||||
|
||||
@@ -879,18 +879,17 @@ static void draw_dividers(FileLayout *layout, View2D *v2d)
|
||||
|
||||
if (vertex_len > 0) {
|
||||
int v1[2], v2[2];
|
||||
uchar col_hi[3], col_lo[3];
|
||||
float col_hi[3], col_lo[3];
|
||||
|
||||
UI_GetThemeColorShade3ubv(TH_BACK, 30, col_hi);
|
||||
UI_GetThemeColorShade3ubv(TH_BACK, -30, col_lo);
|
||||
UI_GetThemeColorShade3fv(TH_BACK, 30, col_hi);
|
||||
UI_GetThemeColorShade3fv(TH_BACK, -30, col_lo);
|
||||
|
||||
v1[1] = v2d->cur.ymax - layout->tile_border_y;
|
||||
v2[1] = v2d->cur.ymin;
|
||||
|
||||
GPUVertFormat *format = immVertexFormat();
|
||||
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
|
||||
uint color = GPU_vertformat_attr_add(
|
||||
format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
||||
uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
|
||||
immBegin(GPU_PRIM_LINES, vertex_len);
|
||||
@@ -902,13 +901,13 @@ static void draw_dividers(FileLayout *layout, View2D *v2d)
|
||||
v1[0] = v2[0] = sx;
|
||||
immAttrSkip(color);
|
||||
immVertex2iv(pos, v1);
|
||||
immAttr3ubv(color, col_lo);
|
||||
immAttr3fv(color, col_lo);
|
||||
immVertex2iv(pos, v2);
|
||||
|
||||
v1[0] = v2[0] = sx + 1;
|
||||
immAttrSkip(color);
|
||||
immVertex2iv(pos, v1);
|
||||
immAttr3ubv(color, col_hi);
|
||||
immAttr3fv(color, col_hi);
|
||||
immVertex2iv(pos, v2);
|
||||
}
|
||||
|
||||
|
||||
@@ -444,8 +444,7 @@ static void draw_fcurve_handles(SpaceGraph *sipo, ARegion *region, const FCurve
|
||||
|
||||
GPUVertFormat *format = immVertexFormat();
|
||||
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
uint color = GPU_vertformat_attr_add(
|
||||
format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
||||
uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
|
||||
if (U.animation_flag & USER_ANIM_HIGH_QUALITY_DRAWING) {
|
||||
GPU_line_smooth(true);
|
||||
@@ -462,7 +461,7 @@ static void draw_fcurve_handles(SpaceGraph *sipo, ARegion *region, const FCurve
|
||||
*/
|
||||
for (int sel = 0; sel < 2; sel++) {
|
||||
int basecol = (sel) ? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE;
|
||||
uchar col[4];
|
||||
float col[4];
|
||||
|
||||
BezTriple *prevbezt = nullptr;
|
||||
for (const int i : index_range) {
|
||||
@@ -483,21 +482,21 @@ static void draw_fcurve_handles(SpaceGraph *sipo, ARegion *region, const FCurve
|
||||
if ((!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) ||
|
||||
(prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ)))
|
||||
{
|
||||
UI_GetThemeColor3ubv(basecol + bezt->h1, col);
|
||||
col[3] = fcurve_display_alpha(fcu) * 255;
|
||||
immAttr4ubv(color, col);
|
||||
UI_GetThemeColor3fv(basecol + bezt->h1, col);
|
||||
col[3] = fcurve_display_alpha(fcu);
|
||||
immAttr4fv(color, col);
|
||||
immVertex2fv(pos, bezt->vec[0]);
|
||||
immAttr4ubv(color, col);
|
||||
immAttr4fv(color, col);
|
||||
immVertex2fv(pos, bezt->vec[1]);
|
||||
}
|
||||
|
||||
/* only draw second handle if this segment is bezier */
|
||||
if (bezt->ipo == BEZT_IPO_BEZ) {
|
||||
UI_GetThemeColor3ubv(basecol + bezt->h2, col);
|
||||
col[3] = fcurve_display_alpha(fcu) * 255;
|
||||
immAttr4ubv(color, col);
|
||||
UI_GetThemeColor3fv(basecol + bezt->h2, col);
|
||||
col[3] = fcurve_display_alpha(fcu);
|
||||
immAttr4fv(color, col);
|
||||
immVertex2fv(pos, bezt->vec[1]);
|
||||
immAttr4ubv(color, col);
|
||||
immAttr4fv(color, col);
|
||||
immVertex2fv(pos, bezt->vec[2]);
|
||||
}
|
||||
}
|
||||
@@ -506,21 +505,21 @@ static void draw_fcurve_handles(SpaceGraph *sipo, ARegion *region, const FCurve
|
||||
if (((bezt->f1 & SELECT) == sel) && ((!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) ||
|
||||
(prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))))
|
||||
{
|
||||
UI_GetThemeColor3ubv(basecol + bezt->h1, col);
|
||||
col[3] = fcurve_display_alpha(fcu) * 255;
|
||||
immAttr4ubv(color, col);
|
||||
UI_GetThemeColor3fv(basecol + bezt->h1, col);
|
||||
col[3] = fcurve_display_alpha(fcu);
|
||||
immAttr4fv(color, col);
|
||||
immVertex2fv(pos, bezt->vec[0]);
|
||||
immAttr4ubv(color, col);
|
||||
immAttr4fv(color, col);
|
||||
immVertex2fv(pos, bezt->vec[1]);
|
||||
}
|
||||
|
||||
/* only draw second handle if this segment is bezier, and selection is ok */
|
||||
if (((bezt->f3 & SELECT) == sel) && (bezt->ipo == BEZT_IPO_BEZ)) {
|
||||
UI_GetThemeColor3ubv(basecol + bezt->h2, col);
|
||||
col[3] = fcurve_display_alpha(fcu) * 255;
|
||||
immAttr4ubv(color, col);
|
||||
UI_GetThemeColor3fv(basecol + bezt->h2, col);
|
||||
col[3] = fcurve_display_alpha(fcu);
|
||||
immAttr4fv(color, col);
|
||||
immVertex2fv(pos, bezt->vec[1]);
|
||||
immAttr4ubv(color, col);
|
||||
immAttr4fv(color, col);
|
||||
immVertex2fv(pos, bezt->vec[2]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,15 @@
|
||||
|
||||
struct ColorVertex {
|
||||
blender::float2 pos;
|
||||
blender::ColorTheme4b color;
|
||||
blender::ColorTheme4f color;
|
||||
|
||||
/* TODO(fclem): Temporary fix. Better convert the whole code to use float colors. */
|
||||
ColorVertex(const blender::float2 &pos_, const uchar ucolor[4]) : pos(pos_)
|
||||
{
|
||||
rgba_uchar_to_float(color, ucolor);
|
||||
}
|
||||
};
|
||||
static_assert(sizeof(ColorVertex) == 12);
|
||||
static_assert(sizeof(ColorVertex) == 24);
|
||||
|
||||
static blender::gpu::IndexBuf *create_quads_index_buffer(int quads_count)
|
||||
{
|
||||
@@ -43,7 +49,7 @@ SeqQuadsBatch::SeqQuadsBatch()
|
||||
GPUVertFormat format;
|
||||
GPU_vertformat_clear(&format);
|
||||
GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
GPU_vertformat_attr_add(&format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
||||
GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
|
||||
|
||||
vbo_quads = GPU_vertbuf_create_with_format_ex(format, GPU_USAGE_STREAM);
|
||||
GPU_vertbuf_data_alloc(*vbo_quads, MAX_QUADS * 4);
|
||||
|
||||
Reference in New Issue
Block a user