Fix #139816: Corrupt wireframe with antialiasing off and subdivision
Caused by 1e1ac2bb9b.
Previous removal of < 4 byte aligned GPU vertex buffer formats was
incomplete. The edge factor buffer still used a single-byte format.
Pull Request: https://projects.blender.org/blender/blender/pulls/139839
This commit is contained in:
@@ -34,9 +34,6 @@ static blender::StringRefNull get_subdiv_shader_info_name(SubdivShaderType shade
|
||||
return "subdiv_tris_multiple_materials";
|
||||
|
||||
case SubdivShaderType::BUFFER_EDGE_FAC:
|
||||
if (GPU_crappy_amd_driver()) {
|
||||
return "subdiv_edge_fac_amd_legacy";
|
||||
}
|
||||
return "subdiv_edge_fac";
|
||||
|
||||
case SubdivShaderType::BUFFER_SCULPT_DATA:
|
||||
|
||||
@@ -202,18 +202,9 @@ gpu::VertBufPtr extract_edge_factor_subdiv(const DRWSubdivCache &subdiv_cache,
|
||||
GPU_vertbuf_use(vbo.get());
|
||||
|
||||
const int offset = subdiv_cache.num_subdiv_loops;
|
||||
if (GPU_crappy_amd_driver() || GPU_minimum_per_vertex_stride() > 1) {
|
||||
const float values[2] = {1.0f, 1.0f};
|
||||
for (const int i : IndexRange(loose_edges_num)) {
|
||||
GPU_vertbuf_update_sub(vbo.get(), (offset + i * 2) * sizeof(float), sizeof(values), values);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const uint8_t values[2] = {255, 255};
|
||||
for (const int i : IndexRange(loose_edges_num)) {
|
||||
GPU_vertbuf_update_sub(
|
||||
vbo.get(), (offset + i * 2) * sizeof(uint8_t), sizeof(values), values);
|
||||
}
|
||||
const float values[2] = {1.0f, 1.0f};
|
||||
for (const int i : IndexRange(loose_edges_num)) {
|
||||
GPU_vertbuf_update_sub(vbo.get(), (offset + i * 2) * sizeof(float), sizeof(values), values);
|
||||
}
|
||||
return vbo;
|
||||
}
|
||||
|
||||
@@ -174,25 +174,14 @@ GPU_SHADER_CREATE_END()
|
||||
/** \name Edge data for object mode wireframe
|
||||
* \{ */
|
||||
|
||||
GPU_SHADER_CREATE_INFO(subdiv_edge_fac_base)
|
||||
GPU_SHADER_CREATE_INFO(subdiv_edge_fac)
|
||||
ADDITIONAL_INFO(subdiv_base)
|
||||
DO_STATIC_COMPILATION()
|
||||
STORAGE_BUF(EDGE_FAC_POS_NOR_BUF_SLOT, read, PosNorLoop, pos_nor[])
|
||||
STORAGE_BUF(EDGE_FAC_EDGE_DRAW_FLAG_BUF_SLOT, read, uint, input_edge_draw_flag[])
|
||||
STORAGE_BUF(EDGE_FAC_POLY_OTHER_MAP_BUF_SLOT, read, int, input_poly_other_map[])
|
||||
COMPUTE_SOURCE("subdiv_vbo_edge_fac_comp.glsl")
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
GPU_SHADER_CREATE_INFO(subdiv_edge_fac)
|
||||
DO_STATIC_COMPILATION()
|
||||
STORAGE_BUF(EDGE_FAC_EDGE_FAC_BUF_SLOT, write, uint, output_edge_fac[])
|
||||
ADDITIONAL_INFO(subdiv_edge_fac_base)
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
GPU_SHADER_CREATE_INFO(subdiv_edge_fac_amd_legacy)
|
||||
DO_STATIC_COMPILATION()
|
||||
DEFINE("GPU_AMD_DRIVER_BYTE_BUG")
|
||||
STORAGE_BUF(EDGE_FAC_EDGE_FAC_BUF_SLOT, write, float, output_edge_fac[])
|
||||
ADDITIONAL_INFO(subdiv_edge_fac_base)
|
||||
COMPUTE_SOURCE("subdiv_vbo_edge_fac_comp.glsl")
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -6,27 +6,13 @@
|
||||
|
||||
#include "subdiv_lib.glsl"
|
||||
|
||||
#ifdef GPU_AMD_DRIVER_BYTE_BUG
|
||||
COMPUTE_SHADER_CREATE_INFO(subdiv_edge_fac_amd_legacy)
|
||||
#else
|
||||
COMPUTE_SHADER_CREATE_INFO(subdiv_edge_fac)
|
||||
#endif
|
||||
|
||||
void write_vec4(uint index, float4 edge_facs)
|
||||
{
|
||||
#ifdef GPU_AMD_DRIVER_BYTE_BUG
|
||||
for (uint i = 0; i < 4; i++) {
|
||||
output_edge_fac[index + i] = edge_facs[i];
|
||||
}
|
||||
#else
|
||||
/* Use same scaling as in extract_edge_fac_iter_face_mesh. */
|
||||
uint a = uint(edge_facs.x * 255);
|
||||
uint b = uint(edge_facs.y * 255);
|
||||
uint c = uint(edge_facs.z * 255);
|
||||
uint d = uint(edge_facs.w * 255);
|
||||
uint packed_edge_fac = d << 24 | c << 16 | b << 8 | a;
|
||||
output_edge_fac[index] = packed_edge_fac;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* From extract_mesh_vbo_edge_fac.cc, keep in sync! */
|
||||
@@ -90,10 +76,5 @@ void main()
|
||||
edge_facs[i] = compute_line_factor(start_loop_index + i, face_normal);
|
||||
}
|
||||
|
||||
#ifdef GPU_AMD_DRIVER_BYTE_BUG
|
||||
write_vec4(start_loop_index, edge_facs);
|
||||
#else
|
||||
/* When packed into bytes, the index is the same as for the quad. */
|
||||
write_vec4(quad_index, edge_facs);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user