Differential D14171 Diff 48840 source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc
| Show First 20 Lines • Show All 227 Lines • ▼ Show 20 Lines | if (format.attr_len == 0) { | ||||
| else { | else { | ||||
| GPU_vertformat_attr_add(&format, "wd", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT); | GPU_vertformat_attr_add(&format, "wd", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT); | ||||
| } | } | ||||
| } | } | ||||
| return &format; | return &format; | ||||
| } | } | ||||
| static void extract_edge_fac_init_subdiv(const DRWSubdivCache *subdiv_cache, | static void extract_edge_fac_init_subdiv(const DRWSubdivCache *subdiv_cache, | ||||
| const MeshRenderData *mr, | const MeshRenderData *UNUSED(mr), | ||||
| struct MeshBatchCache *cache, | struct MeshBatchCache *cache, | ||||
| void *buffer, | void *buffer, | ||||
| void *UNUSED(data)) | void *UNUSED(data)) | ||||
| { | { | ||||
| const DRWSubdivLooseGeom &loose_geom = subdiv_cache->loose_geom; | |||||
| GPUVertBuf *edge_idx = cache->final.buff.vbo.edge_idx; | GPUVertBuf *edge_idx = cache->final.buff.vbo.edge_idx; | ||||
| GPUVertBuf *pos_nor = cache->final.buff.vbo.pos_nor; | GPUVertBuf *pos_nor = cache->final.buff.vbo.pos_nor; | ||||
| GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buffer); | GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buffer); | ||||
| GPU_vertbuf_init_build_on_device( | GPU_vertbuf_init_build_on_device( | ||||
| vbo, get_subdiv_edge_fac_format(), subdiv_cache->num_subdiv_loops + mr->loop_loose_len); | vbo, get_subdiv_edge_fac_format(), subdiv_cache->num_subdiv_loops + loose_geom.loop_len); | ||||
| /* Create a temporary buffer for the edge original indices if it was not requested. */ | /* Create a temporary buffer for the edge original indices if it was not requested. */ | ||||
| const bool has_edge_idx = edge_idx != nullptr; | const bool has_edge_idx = edge_idx != nullptr; | ||||
| GPUVertBuf *loop_edge_idx = nullptr; | GPUVertBuf *loop_edge_idx = nullptr; | ||||
| if (has_edge_idx) { | if (has_edge_idx) { | ||||
| loop_edge_idx = edge_idx; | loop_edge_idx = edge_idx; | ||||
| } | } | ||||
| else { | else { | ||||
| Show All 9 Lines | static void extract_edge_fac_init_subdiv(const DRWSubdivCache *subdiv_cache, | ||||
| if (!has_edge_idx) { | if (!has_edge_idx) { | ||||
| GPU_vertbuf_discard(loop_edge_idx); | GPU_vertbuf_discard(loop_edge_idx); | ||||
| } | } | ||||
| } | } | ||||
| static void extract_edge_fac_loose_geom_subdiv(const DRWSubdivCache *subdiv_cache, | static void extract_edge_fac_loose_geom_subdiv(const DRWSubdivCache *subdiv_cache, | ||||
| const MeshRenderData *UNUSED(mr), | const MeshRenderData *UNUSED(mr), | ||||
| const MeshExtractLooseGeom *loose_geom, | |||||
| void *buffer, | void *buffer, | ||||
| void *UNUSED(data)) | void *UNUSED(data)) | ||||
| { | { | ||||
| if (loose_geom->edge_len == 0) { | const DRWSubdivLooseGeom &loose_geom = subdiv_cache->loose_geom; | ||||
| if (loose_geom.edge_len == 0) { | |||||
| return; | return; | ||||
| } | } | ||||
| GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buffer); | GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buffer); | ||||
| /* Make sure buffer is active for sending loose data. */ | /* Make sure buffer is active for sending loose data. */ | ||||
| GPU_vertbuf_use(vbo); | GPU_vertbuf_use(vbo); | ||||
| uint offset = subdiv_cache->num_subdiv_loops; | uint offset = subdiv_cache->num_subdiv_loops; | ||||
| for (int i = 0; i < loose_geom->edge_len; i++) { | for (int i = 0; i < loose_geom.edge_len; i++) { | ||||
| if (GPU_crappy_amd_driver()) { | if (GPU_crappy_amd_driver()) { | ||||
| float loose_edge_fac[2] = {1.0f, 1.0f}; | float loose_edge_fac[2] = {1.0f, 1.0f}; | ||||
| GPU_vertbuf_update_sub(vbo, offset * sizeof(float), sizeof(loose_edge_fac), loose_edge_fac); | GPU_vertbuf_update_sub(vbo, offset * sizeof(float), sizeof(loose_edge_fac), loose_edge_fac); | ||||
| } | } | ||||
| else { | else { | ||||
| char loose_edge_fac[2] = {255, 255}; | char loose_edge_fac[2] = {255, 255}; | ||||
| GPU_vertbuf_update_sub(vbo, offset * sizeof(char), sizeof(loose_edge_fac), loose_edge_fac); | GPU_vertbuf_update_sub(vbo, offset * sizeof(char), sizeof(loose_edge_fac), loose_edge_fac); | ||||
| } | } | ||||
| Show All 30 Lines | |||||