diff options
author | Hans Goudey <h.goudey@me.com> | 2020-09-13 01:37:49 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-09-13 01:37:49 +0300 |
commit | 8f6740b2754ff1f5c936ee95e2cd7ed837627608 (patch) | |
tree | 53bd01cb29fc8beadfa466226814965aa939ef90 | |
parent | 68a5d4c56da022d9b54c878c1d139bec8ccd405d (diff) | |
parent | f9dd47475ac7edf8c864bc321149ab5c1bd3b110 (diff) |
Merge branch 'property-search-add-theme-color' into property-search-single-tab
132 files changed, 737 insertions, 694 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f1e84dd6df..602616ca286 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -546,14 +546,14 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") [HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\LLVM\\LLVM;]/lib/clang/6.0.0/lib/windows ) elseif(APPLE) - execute_process(COMMAND ${CMAKE_CXX_COMPILER} - -print-file-name=lib + execute_process(COMMAND ${CMAKE_CXX_COMPILER} + -print-file-name=lib OUTPUT_VARIABLE CLANG_LIB_DIR ) string(STRIP "${CLANG_LIB_DIR}" CLANG_LIB_DIR) find_library( COMPILER_ASAN_LIBRARY NAMES libclang_rt.asan_osx_dynamic.dylib - PATHS + PATHS "${CLANG_LIB_DIR}/darwin/" ) unset(CLANG_LIB_DIR) @@ -1610,7 +1610,7 @@ if(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17") # Make MSVC properly report the value of the __cplusplus preprocessor macro # Available MSVC 15.7 (1914) and up, without this it reports 199711L regardless - # of the C++ standard chosen above + # of the C++ standard chosen above if(MSVC_VERSION GREATER 1913) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus") endif() diff --git a/intern/ghost/intern/GHOST_SystemSDL.h b/intern/ghost/intern/GHOST_SystemSDL.h index 57e8d17861d..1c92762ea01 100644 --- a/intern/ghost/intern/GHOST_SystemSDL.h +++ b/intern/ghost/intern/GHOST_SystemSDL.h @@ -98,6 +98,6 @@ class GHOST_SystemSDL : public GHOST_System { void processEvent(SDL_Event *sdl_event); - /// The vector of windows that need to be updated. + /** The vector of windows that need to be updated. */ std::vector<GHOST_WindowSDL *> m_dirty_windows; }; diff --git a/intern/ghost/intern/GHOST_WindowX11.h b/intern/ghost/intern/GHOST_WindowX11.h index ef5d1755f1a..a4d17d1add3 100644 --- a/intern/ghost/intern/GHOST_WindowX11.h +++ b/intern/ghost/intern/GHOST_WindowX11.h @@ -225,7 +225,7 @@ class GHOST_WindowX11 : public GHOST_Window { bool canInvertColor); private: - /// Force use of public constructor. + /* Force use of public constructor. */ GHOST_WindowX11(); diff --git a/intern/memutil/MEM_RefCounted.h b/intern/memutil/MEM_RefCounted.h index 42e595aadf4..06828fc32c3 100644 --- a/intern/memutil/MEM_RefCounted.h +++ b/intern/memutil/MEM_RefCounted.h @@ -76,7 +76,7 @@ class MEM_RefCounted { } protected: - /// The reference count. + /** The reference count. */ int m_refCount; }; diff --git a/intern/opencolorio/ocio_impl_glsl.cc b/intern/opencolorio/ocio_impl_glsl.cc index 6a4b03976e4..a0bb9828bd5 100644 --- a/intern/opencolorio/ocio_impl_glsl.cc +++ b/intern/opencolorio/ocio_impl_glsl.cc @@ -95,11 +95,11 @@ struct OCIO_GLSLShader { struct GPUShader *shader; /** Uniform locations. */ - GLint dither_loc; - GLint overlay_loc; - GLint predivide_loc; - GLint curve_mapping_loc; - GLint ubo_bind; + int dither_loc; + int overlay_loc; + int predivide_loc; + int curve_mapping_loc; + int ubo_bind; /** Error checking. */ bool valid; }; diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index bf14d34ed20..1c31eaa39d0 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -352,16 +352,15 @@ class _GenericBone: @property def _other_bones(self): id_data = self.id_data - id_data_type = type(id_data) - if id_data_type == bpy_types.Object: - bones = id_data.pose.bones - elif id_data_type == bpy_types.Armature: - bones = id_data.edit_bones - if not bones: # not in edit mode - bones = id_data.bones - - return bones + # `id_data` is an 'Object' for `PosePone`, otherwise it's an `Armature`. + if isinstance(self, PoseBone): + return id_data.pose.bones + if isinstance(self, EditBone): + return id_data.edit_bones + if isinstance(self, Bone): + return id_data.bones + raise RuntimeError("Invalid type %r" % self) class PoseBone(StructRNA, _GenericBone, metaclass=StructMetaPropGroup): diff --git a/source/blender/blenfont/CMakeLists.txt b/source/blender/blenfont/CMakeLists.txt index ac927dd388d..3fd0dd95ef8 100644 --- a/source/blender/blenfont/CMakeLists.txt +++ b/source/blender/blenfont/CMakeLists.txt @@ -33,7 +33,6 @@ set(INC ) set(INC_SYS - ${GLEW_INCLUDE_PATH} ${FREETYPE_INCLUDE_DIRS} ) @@ -75,6 +74,5 @@ if(WITH_PYTHON) ) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_blenfont "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 5e8b371e604..3421aa9e900 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -254,23 +254,23 @@ typedef struct bNodeType { * \note Used as a fallback when #bNode.label isn't set. */ void (*labelfunc)(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen); - /// Optional custom resize handle polling. + /** Optional custom resize handle polling. */ int (*resize_area_func)(struct bNode *node, int x, int y); - /// Optional selection area polling. + /** Optional selection area polling. */ int (*select_area_func)(struct bNode *node, int x, int y); - /// Optional tweak area polling (for grabbing). + /** Optional tweak area polling (for grabbing). */ int (*tweak_area_func)(struct bNode *node, int x, int y); - /// Called when the node is updated in the editor. + /** Called when the node is updated in the editor. */ void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node); - /// Check and update if internal ID data has changed. + /** Check and update if internal ID data has changed. */ void (*group_update_func)(struct bNodeTree *ntree, struct bNode *node); - /// Initialize a new node instance of this type after creation. + /** Initialize a new node instance of this type after creation. */ void (*initfunc)(struct bNodeTree *ntree, struct bNode *node); - /// Free the node instance. + /** Free the node instance. */ void (*freefunc)(struct bNode *node); - /// Make a copy of the node instance. + /** Make a copy of the node instance. */ void (*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, const struct bNode *src_node); diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index cf43d0fe845..cc5226a1ab7 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -57,7 +57,6 @@ set(INC ) set(INC_SYS - ${GLEW_INCLUDE_PATH} ${ZLIB_INCLUDE_DIRS} ) @@ -457,7 +456,6 @@ if(WITH_BINRELOC) add_definitions(-DWITH_BINRELOC) endif() -add_definitions(${GL_DEFINITIONS}) if(WIN32) list(APPEND INC diff --git a/source/blender/blenkernel/intern/hair.c b/source/blender/blenkernel/intern/hair.c index 72e3d355ba5..57997eaf3a1 100644 --- a/source/blender/blenkernel/intern/hair.c +++ b/source/blender/blenkernel/intern/hair.c @@ -49,8 +49,8 @@ #include "BLO_read_write.h" -const char *HAIR_ATTR_POSITION = "Position"; -const char *HAIR_ATTR_RADIUS = "Radius"; +static const char *HAIR_ATTR_POSITION = "Position"; +static const char *HAIR_ATTR_RADIUS = "Radius"; /* Hair datablock */ diff --git a/source/blender/blenkernel/intern/pointcloud.c b/source/blender/blenkernel/intern/pointcloud.c index 2cdc717b793..6ec305a971c 100644 --- a/source/blender/blenkernel/intern/pointcloud.c +++ b/source/blender/blenkernel/intern/pointcloud.c @@ -53,8 +53,8 @@ static void pointcloud_random(PointCloud *pointcloud); -const char *POINTCLOUD_ATTR_POSITION = "Position"; -const char *POINTCLOUD_ATTR_RADIUS = "Radius"; +static const char *POINTCLOUD_ATTR_POSITION = "Position"; +static const char *POINTCLOUD_ATTR_RADIUS = "Radius"; static void pointcloud_init_data(ID *id) { diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index f030a733752..73f8c2717b0 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -202,7 +202,7 @@ const float bvhtree_kdop_axes[13][3] = { }; /* Used to correct the epsilon and thus match the overlap distance. */ -const float bvhtree_kdop_axes_length[13] = { +static const float bvhtree_kdop_axes_length[13] = { 1.0f, 1.0f, 1.0f, diff --git a/source/blender/blenlib/intern/math_bits_inline.c b/source/blender/blenlib/intern/math_bits_inline.c index 3a0cea182ba..ba18bb73850 100644 --- a/source/blender/blenlib/intern/math_bits_inline.c +++ b/source/blender/blenlib/intern/math_bits_inline.c @@ -48,7 +48,7 @@ MINLINE unsigned int bitscan_forward_uint64(unsigned long long a) _BitScanForward64(&ctz, a); return ctz; #else - return (unsigned int)__builtin_ctz(a); + return (unsigned int)__builtin_ctzll(a); #endif } diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp index e5dfee7d0cd..08f794d7eba 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp @@ -198,13 +198,13 @@ void ExecutionGroup::execute(ExecutionSystem *graph) const bNodeTree *bTree = context.getbNodeTree(); if (this->m_width == 0 || this->m_height == 0) { return; - } /// \note Break out... no pixels to calculate. + } /** \note Break out... no pixels to calculate. */ if (bTree->test_break && bTree->test_break(bTree->tbh)) { return; - } /// \note Early break out for blur and preview nodes. + } /** \note Early break out for blur and preview nodes. */ if (this->m_numberOfChunks == 0) { return; - } /// \note Early break out. + } /** \note Early break out. */ unsigned int chunkNumber; this->m_executionStartTime = PIL_check_seconds_timer(); diff --git a/source/blender/compositor/intern/COM_NodeGraph.cpp b/source/blender/compositor/intern/COM_NodeGraph.cpp index 01dd662ad11..fe680f61a90 100644 --- a/source/blender/compositor/intern/COM_NodeGraph.cpp +++ b/source/blender/compositor/intern/COM_NodeGraph.cpp @@ -184,7 +184,7 @@ NodeOutput *NodeGraph::find_output(const NodeRange &node_range, bNodeSocket *b_s void NodeGraph::add_bNodeLink(const NodeRange &node_range, bNodeLink *b_nodelink) { - /// \note Ignore invalid links. + /** \note Ignore invalid links. */ if (!(b_nodelink->flag & NODE_LINK_VALID)) { return; } diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp index 06929f0037e..570e1eeba20 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.cpp +++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp @@ -44,26 +44,26 @@ # error COM_CURRENT_THREADING_MODEL No threading model selected #endif -/// \brief list of all CPUDevices. for every hardware thread an instance of CPUDevice is created +/** \brief list of all CPUDevices. for every hardware thread an instance of CPUDevice is created */ static vector<CPUDevice *> g_cpudevices; static ThreadLocal(CPUDevice *) g_thread_device; #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE -/// \brief list of all thread for every CPUDevice in cpudevices a thread exists +/** \brief list of all thread for every CPUDevice in cpudevices a thread exists. */ static ListBase g_cputhreads; static bool g_cpuInitialized = false; -/// \brief all scheduled work for the cpu +/** \brief all scheduled work for the cpu */ static ThreadQueue *g_cpuqueue; static ThreadQueue *g_gpuqueue; # ifdef COM_OPENCL_ENABLED static cl_context g_context; static cl_program g_program; -/// \brief list of all OpenCLDevices. for every OpenCL GPU device an instance of OpenCLDevice is -/// created +/** \brief list of all OpenCLDevices. for every OpenCL GPU device an instance of OpenCLDevice is + * created. */ static vector<OpenCLDevice *> g_gpudevices; -/// \brief list of all thread for every GPUDevice in cpudevices a thread exists +/** \brief list of all thread for every GPUDevice in cpudevices a thread exists. */ static ListBase g_gputhreads; -/// \brief all scheduled work for the gpu +/** \brief all scheduled work for the GPU. */ static bool g_openclActive = false; static bool g_openclInitialized = false; # endif diff --git a/source/blender/compositor/nodes/COM_ImageNode.cpp b/source/blender/compositor/nodes/COM_ImageNode.cpp index 3dbd3773247..c178722a23f 100644 --- a/source/blender/compositor/nodes/COM_ImageNode.cpp +++ b/source/blender/compositor/nodes/COM_ImageNode.cpp @@ -72,7 +72,7 @@ NodeOperation *ImageNode::doMultilayerCheck(NodeConverter &converter, void ImageNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const { - /// Image output + /** Image output */ NodeOutput *outputImage = this->getOutputSocket(0); bNode *editorNode = this->getbNode(); Image *image = (Image *)editorNode->id; diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp index 70aaab560cd..99cc9f5dd01 100644 --- a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp @@ -41,7 +41,7 @@ void ReadBufferOperation::determineResolution(unsigned int resolution[2], operation->determineResolution(resolution, preferredResolution); operation->setResolution(resolution); - /// \todo: may not occur!, but does with blur node + /** \todo: may not occur!, but does with blur node */ if (this->m_memoryProxy->getExecutor()) { this->m_memoryProxy->getExecutor()->setResolution(resolution); } diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 8fbf30507a5..1344d390871 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -44,10 +44,6 @@ set(INC ../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC intern/draw_cache.c intern/draw_cache_extract_mesh.c @@ -442,7 +438,6 @@ if(WITH_GTESTS) endif() endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_draw "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index 8216d2545ac..e731ed071b2 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -84,9 +84,7 @@ extern struct DrawEngineType draw_engine_eevee_type; #define EEVEE_PROBE_MAX min_ii(MAX_PROBE, GPU_max_texture_layers() / 6) #define EEVEE_VELOCITY_TILE_SIZE 32 -#define USE_VOLUME_OPTI \ - (GLEW_ARB_shader_image_load_store && GLEW_ARB_shading_language_420pack && \ - !GPU_crappy_amd_driver()) +#define USE_VOLUME_OPTI (GPU_shader_image_load_store_support()) #define SWAP_DOUBLE_BUFFERS() \ { \ diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c index 69b916244b5..93701887b51 100644 --- a/source/blender/draw/engines/eevee/eevee_volumes.c +++ b/source/blender/draw/engines/eevee/eevee_volumes.c @@ -601,6 +601,10 @@ void EEVEE_volumes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo); DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo); DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined); + if (USE_VOLUME_OPTI) { + DRW_shgroup_uniform_image_ref(grp, "finalScattering_img", &txl->volume_scatter_history); + DRW_shgroup_uniform_image_ref(grp, "finalTransmittance_img", &txl->volume_transmit_history); + } DRW_shgroup_call_procedural_triangles( grp, NULL, USE_VOLUME_OPTI ? 1 : common_data->vol_tex_size[2]); @@ -610,6 +614,7 @@ void EEVEE_volumes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) DRW_shgroup_uniform_texture_ref(grp, "inScattering", &txl->volume_scatter); DRW_shgroup_uniform_texture_ref(grp, "inTransmittance", &txl->volume_transmit); DRW_shgroup_uniform_texture_ref(grp, "inSceneDepth", &e_data.depth_src); + DRW_shgroup_uniform_block(grp, "light_block", sldata->light_ubo); DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo); DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo); DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined); @@ -714,15 +719,7 @@ void EEVEE_volumes_compute(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) DRW_draw_pass(psl->volumetric_scatter_ps); if (USE_VOLUME_OPTI) { - int tex_scatter = GPU_texture_opengl_bindcode(txl->volume_scatter_history); - int tex_transmit = GPU_texture_opengl_bindcode(txl->volume_transmit_history); - /* TODO(fclem) Encapsulate these GL calls into DRWManager. */ - glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT); - /* Subtlety here! we need to tell the GL that the texture is layered (GL_TRUE) - * in order to bind the full 3D texture and not just a 2D slice. */ - glBindImageTexture(0, tex_scatter, 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_R11F_G11F_B10F); - glBindImageTexture(1, tex_transmit, 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_R11F_G11F_B10F); - + /* Avoid feedback loop assert. */ GPU_framebuffer_bind(fbl->volumetric_fb); } else { @@ -731,13 +728,6 @@ void EEVEE_volumes_compute(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) DRW_draw_pass(psl->volumetric_integration_ps); - if (USE_VOLUME_OPTI) { - glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT); - - glBindImageTexture(0, 0, 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_R11F_G11F_B10F); - glBindImageTexture(1, 0, 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_R11F_G11F_B10F); - } - SWAP(struct GPUFrameBuffer *, fbl->volumetric_scat_fb, fbl->volumetric_integ_fb); SWAP(GPUTexture *, txl->volume_scatter, txl->volume_scatter_history); SWAP(GPUTexture *, txl->volume_transmit, txl->volume_transmit_history); @@ -763,6 +753,10 @@ void EEVEE_volumes_resolve(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *veda DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); e_data.depth_src = dtxl->depth; + if (USE_VOLUME_OPTI) { + GPU_memory_barrier(GPU_BARRIER_TEXTURE_FETCH); + } + /* Apply for opaque geometry. */ GPU_framebuffer_bind(fbl->main_color_fb); DRW_draw_pass(psl->volumetric_resolve_ps); diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl index f4276bd61bd..12b7d8acbea 100644 --- a/source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl @@ -11,8 +11,8 @@ uniform sampler3D volumeScattering; /* Result of the scatter step */ uniform sampler3D volumeExtinction; #ifdef USE_VOLUME_OPTI -uniform layout(binding = 0, r11f_g11f_b10f) writeonly restrict image3D finalScattering_img; -uniform layout(binding = 1, r11f_g11f_b10f) writeonly restrict image3D finalTransmittance_img; +uniform layout(r11f_g11f_b10f) writeonly restrict image3D finalScattering_img; +uniform layout(r11f_g11f_b10f) writeonly restrict image3D finalTransmittance_img; vec3 finalScattering; vec3 finalTransmittance; diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 8e3562216e9..30c6f0ad4dc 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -557,6 +557,9 @@ void DRW_shgroup_uniform_ivec4(DRWShadingGroup *shgroup, int arraysize); void DRW_shgroup_uniform_mat3(DRWShadingGroup *shgroup, const char *name, const float (*value)[3]); void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const float (*value)[4]); +/* Only to be used when image load store is supported (GPU_shader_image_load_store_support()). */ +void DRW_shgroup_uniform_image(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex); +void DRW_shgroup_uniform_image_ref(DRWShadingGroup *shgroup, const char *name, GPUTexture **tex); /* Store value instead of referencing it. */ void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value); void DRW_shgroup_uniform_ivec2_copy(DRWShadingGroup *shgroup, const char *name, const int *value); diff --git a/source/blender/draw/intern/draw_fluid.c b/source/blender/draw/intern/draw_fluid.c index af14f11e6e9..809512bd7dd 100644 --- a/source/blender/draw/intern/draw_fluid.c +++ b/source/blender/draw/intern/draw_fluid.c @@ -183,6 +183,10 @@ static GPUTexture *create_volume_texture(const int dim[3], GPUTexture *tex = NULL; int final_dim[3] = {UNPACK3(dim)}; + if (data == NULL) { + return NULL; + } + while (1) { tex = GPU_texture_create_3d("volume", UNPACK3(final_dim), 1, format, NULL); @@ -292,6 +296,10 @@ static GPUTexture *create_density_texture(FluidDomainSettings *fds, int highres) data = manta_smoke_get_density(fds->fluid); } + if (data == NULL) { + return NULL; + } + GPUTexture *tex = create_volume_texture(dim, GPU_R8, data); swizzle_texture_channel_single(tex); return tex; diff --git a/source/blender/draw/intern/draw_hair.c b/source/blender/draw/intern/draw_hair.c index 9b503e00b36..cc0aa09ed97 100644 --- a/source/blender/draw/intern/draw_hair.c +++ b/source/blender/draw/intern/draw_hair.c @@ -346,10 +346,10 @@ void DRW_hair_update(void) GPU_framebuffer_read_color(fb, 0, 0, width, height, 4, 0, GPU_DATA_FLOAT, data); /* Upload back to VBO. */ GPU_vertbuf_use(pr_call->vbo); - glBufferSubData(GL_ARRAY_BUFFER, - sizeof(float[4]) * g_tf_id_offset, - sizeof(float[4]) * max_read_px_len, - data); + GPU_vertbuf_update_sub(pr_call->vbo, + sizeof(float[4]) * g_tf_id_offset, + sizeof(float[4]) * max_read_px_len, + data); g_tf_id_offset += max_read_px_len; pr_call->vert_len -= max_read_px_len; diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 203f8af130d..834505ca349 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1365,6 +1365,8 @@ void DRW_draw_callbacks_pre_scene(void) if (DST.draw_ctx.evil_C) { ED_region_draw_cb_draw(DST.draw_ctx.evil_C, DST.draw_ctx.region, REGION_DRAW_PRE_VIEW); + /* Callback can be nasty and do whatever they want with the state. + * Don't trust them! */ DRW_state_reset(); } } @@ -1400,6 +1402,9 @@ void DRW_draw_callbacks_post_scene(void) drw_debug_draw(); GPU_depth_test(GPU_DEPTH_NONE); + /* Apply state for callbacks. */ + GPU_apply_state(); + ED_region_draw_cb_draw(DST.draw_ctx.evil_C, DST.draw_ctx.region, REGION_DRAW_POST_VIEW); /* Callback can be nasty and do whatever they want with the state. diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index c0bcb0e679f..9f6a970ea22 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -278,6 +278,8 @@ typedef enum { DRW_UNIFORM_FLOAT_COPY, DRW_UNIFORM_TEXTURE, DRW_UNIFORM_TEXTURE_REF, + DRW_UNIFORM_IMAGE, + DRW_UNIFORM_IMAGE_REF, DRW_UNIFORM_BLOCK, DRW_UNIFORM_BLOCK_REF, DRW_UNIFORM_TFEEDBACK_TARGET, diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index a4fc44e9571..81842f5d2ec 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -199,10 +199,12 @@ static void drw_shgroup_uniform_create_ex(DRWShadingGroup *shgroup, case DRW_UNIFORM_BLOCK_REF: uni->block_ref = (GPUUniformBuf **)value; break; + case DRW_UNIFORM_IMAGE: case DRW_UNIFORM_TEXTURE: uni->texture = (GPUTexture *)value; uni->sampler_state = sampler_state; break; + case DRW_UNIFORM_IMAGE_REF: case DRW_UNIFORM_TEXTURE_REF: uni->texture_ref = (GPUTexture **)value; uni->sampler_state = sampler_state; @@ -261,6 +263,20 @@ void DRW_shgroup_uniform_texture_ref(DRWShadingGroup *shgroup, const char *name, DRW_shgroup_uniform_texture_ref_ex(shgroup, name, tex, GPU_SAMPLER_MAX); } +void DRW_shgroup_uniform_image(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex) +{ + BLI_assert(tex != NULL); + int loc = GPU_shader_get_texture_binding(shgroup->shader, name); + drw_shgroup_uniform_create_ex(shgroup, loc, DRW_UNIFORM_IMAGE, tex, 0, 0, 1); +} + +void DRW_shgroup_uniform_image_ref(DRWShadingGroup *shgroup, const char *name, GPUTexture **tex) +{ + BLI_assert(tex != NULL); + int loc = GPU_shader_get_texture_binding(shgroup->shader, name); + drw_shgroup_uniform_create_ex(shgroup, loc, DRW_UNIFORM_IMAGE_REF, tex, 0, 0, 1); +} + void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup, const char *name, const GPUUniformBuf *ubo) diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index 79d74e1f67d..84f618c1c15 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -596,6 +596,12 @@ static void draw_update_uniforms(DRWShadingGroup *shgroup, case DRW_UNIFORM_TEXTURE_REF: GPU_texture_bind_ex(*uni->texture_ref, uni->sampler_state, uni->location, false); break; + case DRW_UNIFORM_IMAGE: + GPU_texture_image_bind(uni->texture, uni->location); + break; + case DRW_UNIFORM_IMAGE_REF: + GPU_texture_image_bind(*uni->texture_ref, uni->location); + break; case DRW_UNIFORM_BLOCK: GPU_uniformbuf_bind(uni->block, uni->location); break; diff --git a/source/blender/draw/intern/draw_manager_profiling.c b/source/blender/draw/intern/draw_manager_profiling.c index 57887c11c02..f8587555480 100644 --- a/source/blender/draw/intern/draw_manager_profiling.c +++ b/source/blender/draw/intern/draw_manager_profiling.c @@ -44,8 +44,8 @@ #define GPU_TIMER_FALLOFF 0.1 typedef struct DRWTimer { - GLuint query[2]; - GLuint64 time_average; + uint32_t query[2]; + uint64_t time_average; char name[MAX_TIMER_NAME]; int lvl; /* Hierarchy level for nested timer. */ bool is_query; /* Does this timer actually perform queries or is it just a group. */ @@ -64,10 +64,10 @@ static struct DRWTimerPool { void DRW_stats_free(void) { if (DTP.timers != NULL) { - for (int i = 0; i < DTP.timer_count; i++) { - DRWTimer *timer = &DTP.timers[i]; - glDeleteQueries(2, timer->query); - } + // for (int i = 0; i < DTP.timer_count; i++) { + // DRWTimer *timer = &DTP.timers[i]; + // glDeleteQueries(2, timer->query); + // } MEM_freeN(DTP.timers); DTP.timers = NULL; } @@ -117,12 +117,12 @@ static void drw_stats_timer_start_ex(const char *name, const bool is_query) BLI_assert(!DTP.is_querying); if (timer->is_query) { if (timer->query[0] == 0) { - glGenQueries(1, timer->query); + // glGenQueries(1, timer->query); } - glFinish(); + // glFinish(); /* Issue query for the next frame */ - glBeginQuery(GL_TIME_ELAPSED, timer->query[0]); + // glBeginQuery(GL_TIME_ELAPSED, timer->query[0]); DTP.is_querying = true; } } @@ -154,7 +154,7 @@ void DRW_stats_query_end(void) if (DTP.is_recording) { DTP.end_increment++; BLI_assert(DTP.is_querying); - glEndQuery(GL_TIME_ELAPSED); + // glEndQuery(GL_TIME_ELAPSED); DTP.is_querying = false; } } @@ -167,19 +167,19 @@ void DRW_stats_reset(void) "You forgot a DRW_stats_group/query_start somewhere!"); if (DTP.is_recording) { - GLuint64 lvl_time[MAX_NESTED_TIMER] = {0}; + uint64_t lvl_time[MAX_NESTED_TIMER] = {0}; /* Swap queries for the next frame and sum up each lvl time. */ for (int i = DTP.timer_increment - 1; i >= 0; i--) { DRWTimer *timer = &DTP.timers[i]; - SWAP(GLuint, timer->query[0], timer->query[1]); + SWAP(uint32_t, timer->query[0], timer->query[1]); BLI_assert(timer->lvl < MAX_NESTED_TIMER); if (timer->is_query) { - GLuint64 time; + uint64_t time = 0; if (timer->query[0] != 0) { - glGetQueryObjectui64v(timer->query[0], GL_QUERY_RESULT, &time); + // glGetQueryObjectui64v(timer->query[0], GL_QUERY_RESULT, &time); } else { time = 1000000000; /* 1ms default */ diff --git a/source/blender/editors/animation/CMakeLists.txt b/source/blender/editors/animation/CMakeLists.txt index ce6778a1ff9..1ca9a844feb 100644 --- a/source/blender/editors/animation/CMakeLists.txt +++ b/source/blender/editors/animation/CMakeLists.txt @@ -30,9 +30,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC anim_channels_defines.c @@ -69,6 +66,5 @@ if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_animation "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/armature/CMakeLists.txt b/source/blender/editors/armature/CMakeLists.txt index 71c7febe192..98c050950be 100644 --- a/source/blender/editors/armature/CMakeLists.txt +++ b/source/blender/editors/armature/CMakeLists.txt @@ -31,10 +31,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC armature_add.c armature_edit.c @@ -67,6 +63,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_armature "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/curve/CMakeLists.txt b/source/blender/editors/curve/CMakeLists.txt index ff80c47baa8..877c2d99102 100644 --- a/source/blender/editors/curve/CMakeLists.txt +++ b/source/blender/editors/curve/CMakeLists.txt @@ -31,10 +31,6 @@ set(INC ../../../../extern/curve_fit_nd ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC curve_ops.c editcurve.c @@ -59,6 +55,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_curve "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/gizmo_library/CMakeLists.txt b/source/blender/editors/gizmo_library/CMakeLists.txt index 1f3edf31b19..eeb1e60166b 100644 --- a/source/blender/editors/gizmo_library/CMakeLists.txt +++ b/source/blender/editors/gizmo_library/CMakeLists.txt @@ -32,10 +32,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC gizmo_draw_utils.c gizmo_geometry.h @@ -59,6 +55,5 @@ set(SRC set(LIB ) -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_gizmo_library "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/gpencil/CMakeLists.txt b/source/blender/editors/gpencil/CMakeLists.txt index 735ad8bc039..20408327105 100644 --- a/source/blender/editors/gpencil/CMakeLists.txt +++ b/source/blender/editors/gpencil/CMakeLists.txt @@ -31,10 +31,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC annotate_draw.c annotate_paint.c @@ -75,6 +71,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_gpencil "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/include/ED_fileselect.h b/source/blender/editors/include/ED_fileselect.h index 47b8eb543f4..341f97943a5 100644 --- a/source/blender/editors/include/ED_fileselect.h +++ b/source/blender/editors/include/ED_fileselect.h @@ -150,6 +150,7 @@ int ED_file_extension_icon(const char *path); void ED_file_read_bookmarks(void); +void ED_file_change_dir_ex(struct bContext *C, struct bScreen *screen, struct ScrArea *area); void ED_file_change_dir(struct bContext *C); void ED_file_path_button(struct bScreen *screen, diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt index e4fb0631f06..680cf3ea01a 100644 --- a/source/blender/editors/interface/CMakeLists.txt +++ b/source/blender/editors/interface/CMakeLists.txt @@ -34,10 +34,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC interface.c interface_align.c @@ -113,6 +109,5 @@ if(WIN32) endif() endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_interface "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 8c564ecd1d4..b0530c797a8 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -6700,7 +6700,7 @@ static void operator_enum_search_update_fn(const struct bContext *C, } } - MEM_freeN(filtered_items); + MEM_freeN((void *)filtered_items); BLI_string_search_free(search); if (do_free) { diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index c91b4d826a7..d22ddb5f2b7 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -256,7 +256,7 @@ static void def_internal_vicon(int icon_id, VectorDrawFunc drawFunc) /* Utilities */ -static void viconutil_set_point(GLint pt[2], int x, int y) +static void viconutil_set_point(int pt[2], int x, int y) { pt[0] = x; pt[1] = y; @@ -264,7 +264,7 @@ static void viconutil_set_point(GLint pt[2], int x, int y) static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float alpha) { - GLint pts[3][2]; + int pts[3][2]; const int cx = x + w / 2 - 4; const int cy = y + w / 2; const int d = w / 5, d2 = w / 7; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index c1d87421ee1..59807dce8be 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -87,8 +87,8 @@ * highlighted together. */ typedef struct uiButtonGroup { - uiButtonGroup *next, *prev; - ListBase *buttons; + void *next, *prev; + ListBase buttons; /* #LinkData with #uiBut data field. */ } uiButtonGroup; typedef struct uiLayoutRoot { @@ -435,6 +435,43 @@ static void ui_item_move(uiItem *item, int delta_xmin, int delta_xmax) /** \} */ /* -------------------------------------------------------------------- */ +/** \name Button Groups + * \{ */ + +/** + * Every function that adds a set of buttons must create another group, + * then #ui_def_but adds buttons to the current group (the last). + */ +static void layout_root_new_button_group(uiLayoutRoot *root) +{ + uiButtonGroup *new_group = MEM_mallocN(sizeof(uiButtonGroup), __func__); + BLI_listbase_clear(&new_group->buttons); + BLI_addtail(&root->button_groups, new_group); +} + +static void button_group_add_but(uiLayoutRoot *root, uiBut *but) +{ + BLI_assert(root != NULL); + + uiButtonGroup *current_button_group = root->button_groups.last; + BLI_assert(current_button_group != NULL); + + /* We can't use the button directly because adding it to + * this list would mess with its prev and next pointers. */ + LinkData *button_link = MEM_mallocN(sizeof(LinkData), __func__); + button_link->data = but; + BLI_addtail(¤t_button_group->buttons, button_link); +} + +static void button_group_free(uiButtonGroup *button_group) +{ + BLI_freelistN(&button_group->buttons); + MEM_freeN(button_group); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ /** \name Special RNA Items * \{ */ @@ -2866,6 +2903,7 @@ static uiBut *ui_item_menu(uiLayout *layout, int w, h; UI_block_layout_set_current(block, layout); + layout_root_new_button_group(layout->root); if (!name) { name = ""; @@ -3133,6 +3171,7 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon) int w; UI_block_layout_set_current(block, layout); + layout_root_new_button_group(layout->root); if (!name) { name = ""; @@ -5170,44 +5209,44 @@ static bool button_matches_search_filter(uiBut *but, const char *search_filter) } /** - * Test for a search result within the block. Tag every button - * in the group as a search match if any button matches. - * - * \return Whether the group has a match. + * Test for a search result within the a specific button group. */ -static bool button_group_tag_search_matches(uiButtonGroup *button_group, const char *search_filter) +static bool button_group_has_search_match(uiButtonGroup *button_group, const char *search_filter) { - bool has_result = false; - LISTBASE_FOREACH (uiBut *, but, &button_group->buttons) { + LISTBASE_FOREACH (LinkData *, link, &button_group->buttons) { + uiBut *but = link->data; if (button_matches_search_filter(but, search_filter)) { - has_result = true; - break; - } - } - if (has_result) { - LISTBASE_FOREACH (uiBut *, but, &button_group->buttons) { - but->flag |= UI_SEARCH_FILTER_MATCHES; + return true; } } - return has_result; + return false; } /** * Apply the search filter, tagging all buttons with whether they match or not. + * Tag every button in the group as a search match if any button matches. + * + * \note It would be great to return early here if we found a match, but because + * the results could be visible we have to continue searching the entire block. * * \return Whether the block has any search results. */ static bool block_search_filter_tag_buttons(uiBlock *block) { + bool has_result = false; LISTBASE_FOREACH (uiLayoutRoot *, root, &block->layouts) { LISTBASE_FOREACH (uiButtonGroup *, button_group, &root->button_groups) { - if (button_group_tag_search_matches(button_group, block->search_filter)) { - return true; + if (button_group_has_search_match(button_group, block->search_filter)) { + LISTBASE_FOREACH (LinkData *, link, &button_group->buttons) { + uiBut *but = link->data; + but->flag |= UI_SEARCH_FILTER_MATCHES; + } + has_result = true; } } } - return false; + return has_result; } static void block_search_deactivate_buttons(uiBlock *block) @@ -5491,29 +5530,12 @@ static void ui_layout_free(uiLayout *layout) static void layout_root_free(uiLayoutRoot *root) { - BLI_freelistN(&root->button_groups); ui_layout_free(root->layout); - MEM_freeN(root); -} -/** - * Every function that adds a set of buttons must create another group, - * then #ui_def_but adds buttons to the current group (the last). - */ -static void layout_root_new_button_group(uiLayoutRoot *root) -{ - uiButtonGroup *new_group = MEM_mallocN(sizeof(uiButtonGroup), __func__); - BLI_listbase_clear(&new_group->buttons); - BLI_addtail(&root->button_groups, new_group); -} - -static void button_group_add_but(uiLayoutRoot *root, uiBut *but) -{ - uiButtonGroup *current_button_group = root->button_groups.last; - - BLI_assert(current_button_group != NULL); - - BLI_addtail(¤t_button_group->buttons, but); + LISTBASE_FOREACH_MUTABLE (uiButtonGroup *, button_group, &root->button_groups) { + button_group_free(button_group); + } + MEM_freeN(root); } static void ui_layout_add_padding_button(uiLayoutRoot *root) @@ -5551,6 +5573,7 @@ uiLayout *UI_block_layout(uiBlock *block, root->opcontext = WM_OP_INVOKE_REGION_WIN; BLI_listbase_clear(&root->button_groups); + layout_root_new_button_group(root); layout = MEM_callocN(sizeof(uiLayout), "uiLayout"); layout->item.type = (type == UI_LAYOUT_VERT_BAR) ? ITEM_LAYOUT_COLUMN : ITEM_LAYOUT_ROOT; @@ -5714,6 +5737,8 @@ void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y) layout_root_free(root); } + BLI_listbase_clear(&block->layouts); + /* XXX silly trick, interface_templates.c doesn't get linked * because it's not used by other files in this module? */ { diff --git a/source/blender/editors/mask/CMakeLists.txt b/source/blender/editors/mask/CMakeLists.txt index 66c055d9426..dd04732a814 100644 --- a/source/blender/editors/mask/CMakeLists.txt +++ b/source/blender/editors/mask/CMakeLists.txt @@ -30,10 +30,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC mask_add.c mask_draw.c @@ -51,6 +47,5 @@ set(SRC set(LIB ) -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_mask "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt index 589b51ce942..035af772a55 100644 --- a/source/blender/editors/mesh/CMakeLists.txt +++ b/source/blender/editors/mesh/CMakeLists.txt @@ -35,10 +35,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC editface.c editmesh_add.c @@ -97,6 +93,5 @@ if(WITH_GMP) add_definitions(-DWITH_GMP) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_mesh "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt index 953ef8114f9..be6c0658b1f 100644 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@ -39,10 +39,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC object_add.c object_bake.c @@ -81,7 +77,6 @@ set(LIB bf_windowmanager ) -add_definitions(${GL_DEFINITIONS}) if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) diff --git a/source/blender/editors/physics/CMakeLists.txt b/source/blender/editors/physics/CMakeLists.txt index 0998280c381..2b9d9aaa0e1 100644 --- a/source/blender/editors/physics/CMakeLists.txt +++ b/source/blender/editors/physics/CMakeLists.txt @@ -30,10 +30,6 @@ set(INC ../../../../intern/mantaflow/extern ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC dynamicpaint_ops.c particle_boids.c @@ -74,6 +70,5 @@ if(WITH_BULLET) add_definitions(-DWITH_BULLET) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_physics "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/render/CMakeLists.txt b/source/blender/editors/render/CMakeLists.txt index 7f7748bf52f..642e92592f1 100644 --- a/source/blender/editors/render/CMakeLists.txt +++ b/source/blender/editors/render/CMakeLists.txt @@ -34,10 +34,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC render_internal.c render_opengl.c @@ -61,7 +57,6 @@ else() ) endif() -add_definitions(${GL_DEFINITIONS}) if(WITH_FREESTYLE) list(APPEND INC diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt index dc355148ad3..1de5ad729c5 100644 --- a/source/blender/editors/screen/CMakeLists.txt +++ b/source/blender/editors/screen/CMakeLists.txt @@ -33,10 +33,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC area.c area_query.c @@ -64,6 +60,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_screen "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt index 51cfb912722..930f9890dd9 100644 --- a/source/blender/editors/sculpt_paint/CMakeLists.txt +++ b/source/blender/editors/sculpt_paint/CMakeLists.txt @@ -36,10 +36,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC paint_cursor.c paint_curve.c @@ -90,6 +86,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_sculpt_paint "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 3d8c718c8a9..55abb269660 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -142,7 +142,7 @@ typedef struct LoadTexData { ViewContext *vc; MTex *mtex; - GLubyte *buffer; + uchar *buffer; bool col; struct ImagePool *pool; @@ -160,7 +160,7 @@ static void load_tex_task_cb_ex(void *__restrict userdata, ViewContext *vc = data->vc; MTex *mtex = data->mtex; - GLubyte *buffer = data->buffer; + uchar *buffer = data->buffer; const bool col = data->col; struct ImagePool *pool = data->pool; @@ -230,7 +230,7 @@ static void load_tex_task_cb_ex(void *__restrict userdata, /* Clamp to avoid precision overflow. */ CLAMP(avg, 0.0f, 1.0f); - buffer[index] = 255 - (GLubyte)(255 * avg); + buffer[index] = 255 - (uchar)(255 * avg); } } else { @@ -254,7 +254,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima MTex *mtex = (primary) ? &br->mtex : &br->mask_mtex; ePaintOverlayControlFlags overlay_flags = BKE_paint_get_overlay_flags(); - GLubyte *buffer = NULL; + uchar *buffer = NULL; int size; bool refresh; @@ -309,10 +309,10 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima target->old_col = col; } if (col) { - buffer = MEM_mallocN(sizeof(GLubyte) * size * size * 4, "load_tex"); + buffer = MEM_mallocN(sizeof(uchar) * size * size * 4, "load_tex"); } else { - buffer = MEM_mallocN(sizeof(GLubyte) * size * size, "load_tex"); + buffer = MEM_mallocN(sizeof(uchar) * size * size, "load_tex"); } pool = BKE_image_pool_new(); @@ -381,7 +381,7 @@ static void load_tex_cursor_task_cb(void *__restrict userdata, LoadTexData *data = userdata; Brush *br = data->br; - GLubyte *buffer = data->buffer; + uchar *buffer = data->buffer; const int size = data->size; @@ -398,7 +398,7 @@ static void load_tex_cursor_task_cb(void *__restrict userdata, /* Falloff curve. */ float avg = BKE_brush_curve_strength_clamped(br, len, 1.0f); - buffer[index] = (GLubyte)(255 * avg); + buffer[index] = (uchar)(255 * avg); } else { buffer[index] = 0; @@ -411,7 +411,7 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom) bool init; ePaintOverlayControlFlags overlay_flags = BKE_paint_get_overlay_flags(); - GLubyte *buffer = NULL; + uchar *buffer = NULL; int size; const bool refresh = !cursor_snap.overlay_texture || @@ -452,7 +452,7 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom) cursor_snap.size = size; } - buffer = MEM_mallocN(sizeof(GLubyte) * size * size, "load_tex"); + buffer = MEM_mallocN(sizeof(uchar) * size * size, "load_tex"); BKE_curvemapping_init(br->curve); diff --git a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c index f07d22ed639..9b4b5b8d1e2 100644 --- a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c +++ b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c @@ -36,6 +36,7 @@ #include "BKE_brush.h" #include "BKE_context.h" +#include "BKE_global.h" #include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_mesh_mapping.h" @@ -58,6 +59,7 @@ #include "ED_object.h" #include "ED_screen.h" #include "ED_sculpt.h" +#include "ED_undo.h" #include "ED_view3d.h" #include "paint_intern.h" #include "sculpt_intern.h" @@ -285,11 +287,17 @@ void sculpt_dynamic_topology_disable_with_undo(Main *bmain, Object *ob) { SculptSession *ss = ob->sculpt; - if (ss->bm) { - SCULPT_undo_push_begin("Dynamic topology disable"); - SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_END); + if (ss->bm != NULL) { + /* May be false in background mode. */ + const bool use_undo = G.background ? (ED_undo_stack_get() != NULL) : true; + if (use_undo) { + SCULPT_undo_push_begin("Dynamic topology disable"); + SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_END); + } SCULPT_dynamic_topology_disable_ex(bmain, depsgraph, scene, ob, NULL); - SCULPT_undo_push_end(); + if (use_undo) { + SCULPT_undo_push_end(); + } } } @@ -300,10 +308,16 @@ static void sculpt_dynamic_topology_enable_with_undo(Main *bmain, { SculptSession *ss = ob->sculpt; if (ss->bm == NULL) { - SCULPT_undo_push_begin("Dynamic topology enable"); + /* May be false in background mode. */ + const bool use_undo = G.background ? (ED_undo_stack_get() != NULL) : true; + if (use_undo) { + SCULPT_undo_push_begin("Dynamic topology enable"); + } SCULPT_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob); - SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN); - SCULPT_undo_push_end(); + if (use_undo) { + SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN); + SCULPT_undo_push_end(); + } } } diff --git a/source/blender/editors/space_action/CMakeLists.txt b/source/blender/editors/space_action/CMakeLists.txt index 6c43f8b9549..10dcc77fc24 100644 --- a/source/blender/editors/space_action/CMakeLists.txt +++ b/source/blender/editors/space_action/CMakeLists.txt @@ -28,10 +28,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC action_buttons.c action_data.c @@ -49,6 +45,5 @@ set(LIB bf_blenlib ) -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_action "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_api/CMakeLists.txt b/source/blender/editors/space_api/CMakeLists.txt index d948d84f1c3..573afb76f0e 100644 --- a/source/blender/editors/space_api/CMakeLists.txt +++ b/source/blender/editors/space_api/CMakeLists.txt @@ -20,6 +20,7 @@ set(INC ../io ../../blenkernel ../../blenlib + ../../gpu ../../makesdna ../../makesrna ../../windowmanager diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 29ad314cd65..2a18ffafc6c 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -33,6 +33,8 @@ #include "BKE_context.h" #include "BKE_screen.h" +#include "GPU_state.h" + #include "UI_interface.h" #include "UI_view2d.h" @@ -269,12 +271,18 @@ void ED_region_draw_cb_exit(ARegionType *art, void *handle) void ED_region_draw_cb_draw(const bContext *C, ARegion *region, int type) { RegionDrawCB *rdc; + bool has_drawn_something = false; for (rdc = region->type->drawcalls.first; rdc; rdc = rdc->next) { if (rdc->type == type) { rdc->draw(C, region, rdc->customdata); + has_drawn_something = true; } } + if (has_drawn_something) { + /* This is needed until we get rid of BGL which can change the states we are tracking. */ + GPU_force_state(); + } } /* ********************* space template *********************** */ diff --git a/source/blender/editors/space_buttons/CMakeLists.txt b/source/blender/editors/space_buttons/CMakeLists.txt index 75d91174470..ce0787dbdb9 100644 --- a/source/blender/editors/space_buttons/CMakeLists.txt +++ b/source/blender/editors/space_buttons/CMakeLists.txt @@ -28,10 +28,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC buttons_context.c buttons_ops.c @@ -48,7 +44,6 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) if(WITH_FREESTYLE) add_definitions(-DWITH_FREESTYLE) diff --git a/source/blender/editors/space_clip/CMakeLists.txt b/source/blender/editors/space_clip/CMakeLists.txt index 2ea4bc97d18..8c7f59d61dd 100644 --- a/source/blender/editors/space_clip/CMakeLists.txt +++ b/source/blender/editors/space_clip/CMakeLists.txt @@ -33,10 +33,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC clip_buttons.c clip_dopesheet_draw.c @@ -68,7 +64,6 @@ set(LIB bf_blenlib ) -add_definitions(${GL_DEFINITIONS}) if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) diff --git a/source/blender/editors/space_console/CMakeLists.txt b/source/blender/editors/space_console/CMakeLists.txt index 33934832ccc..e5aedd0d0de 100644 --- a/source/blender/editors/space_console/CMakeLists.txt +++ b/source/blender/editors/space_console/CMakeLists.txt @@ -28,10 +28,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC console_draw.c console_ops.c @@ -49,6 +45,5 @@ if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_console "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_file/CMakeLists.txt b/source/blender/editors/space_file/CMakeLists.txt index 84df11ea39c..dcacf5e2504 100644 --- a/source/blender/editors/space_file/CMakeLists.txt +++ b/source/blender/editors/space_file/CMakeLists.txt @@ -33,10 +33,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC file_draw.c file_ops.c @@ -95,7 +91,6 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) if(WITH_FREESTYLE) add_definitions(-DWITH_FREESTYLE) diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h index 44131693628..b459c02d9e5 100644 --- a/source/blender/editors/space_file/file_intern.h +++ b/source/blender/editors/space_file/file_intern.h @@ -39,6 +39,7 @@ struct View2D; void file_calc_previews(const bContext *C, ARegion *region); void file_draw_list(const bContext *C, ARegion *region); +void file_draw_check_ex(bContext *C, struct ScrArea *area); void file_draw_check(bContext *C); void file_draw_check_cb(bContext *C, void *arg1, void *arg2); bool file_draw_check_exists(SpaceFile *sfile); @@ -80,13 +81,13 @@ void file_filename_enter_handle(bContext *C, void *arg_unused, void *arg_but); int file_highlight_set(struct SpaceFile *sfile, struct ARegion *region, int mx, int my); void file_sfile_filepath_set(struct SpaceFile *sfile, const char *filepath); -void file_sfile_to_operator_ex(bContext *C, +void file_sfile_to_operator_ex(struct Main *bmain, struct wmOperator *op, struct SpaceFile *sfile, char *filepath); -void file_sfile_to_operator(bContext *C, struct wmOperator *op, struct SpaceFile *sfile); +void file_sfile_to_operator(struct Main *bmain, struct wmOperator *op, struct SpaceFile *sfile); -void file_operator_to_sfile(bContext *C, struct SpaceFile *sfile, struct wmOperator *op); +void file_operator_to_sfile(struct Main *bmain, struct SpaceFile *sfile, struct wmOperator *op); /* filesel.c */ void fileselect_file_set(SpaceFile *sfile, const int index); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 8c4b2a1b8a6..b3587fc7f97 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -1432,9 +1432,8 @@ void FILE_OT_cancel(struct wmOperatorType *ot) /** \name Operator Utilities * \{ */ -void file_sfile_to_operator_ex(bContext *C, wmOperator *op, SpaceFile *sfile, char *filepath) +void file_sfile_to_operator_ex(Main *bmain, wmOperator *op, SpaceFile *sfile, char *filepath) { - Main *bmain = CTX_data_main(C); PropertyRNA *prop; /* XXX, not real length */ @@ -1507,16 +1506,15 @@ void file_sfile_to_operator_ex(bContext *C, wmOperator *op, SpaceFile *sfile, ch } } } -void file_sfile_to_operator(bContext *C, wmOperator *op, SpaceFile *sfile) +void file_sfile_to_operator(Main *bmain, wmOperator *op, SpaceFile *sfile) { - char filepath[FILE_MAX]; + char filepath_dummy[FILE_MAX]; - file_sfile_to_operator_ex(C, op, sfile, filepath); + file_sfile_to_operator_ex(bmain, op, sfile, filepath_dummy); } -void file_operator_to_sfile(bContext *C, SpaceFile *sfile, wmOperator *op) +void file_operator_to_sfile(Main *bmain, SpaceFile *sfile, wmOperator *op) { - Main *bmain = CTX_data_main(C); PropertyRNA *prop; /* If neither of the above are set, split the filepath back */ @@ -1569,25 +1567,37 @@ void file_sfile_filepath_set(SpaceFile *sfile, const char *filepath) } } -void file_draw_check(bContext *C) +void file_draw_check_ex(bContext *C, ScrArea *area) { - SpaceFile *sfile = CTX_wm_space_file(C); + /* May happen when manipulating non-active spaces. */ + if (UNLIKELY(area->spacetype != SPACE_FILE)) { + return; + } + SpaceFile *sfile = area->spacedata.first; wmOperator *op = sfile->op; if (op) { /* fail on reload */ if (op->type->check) { - file_sfile_to_operator(C, op, sfile); + Main *bmain = CTX_data_main(C); + file_sfile_to_operator(bmain, op, sfile); /* redraw */ if (op->type->check(C, op)) { - file_operator_to_sfile(C, sfile, op); + file_operator_to_sfile(bmain, sfile, op); /* redraw, else the changed settings wont get updated */ - ED_area_tag_redraw(CTX_wm_area(C)); + ED_area_tag_redraw(area); } } } } +void file_draw_check(bContext *C) +{ + SpaceFile *sfile = CTX_wm_space_file(C); + ScrArea *area = CTX_wm_area(C); + file_draw_check_ex(C, area); +} + /* for use with; UI_block_func_set */ void file_draw_check_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) { @@ -1675,7 +1685,7 @@ static int file_exec(bContext *C, wmOperator *exec_op) sfile->op = NULL; - file_sfile_to_operator_ex(C, op, sfile, filepath); + file_sfile_to_operator_ex(bmain, op, sfile, filepath); if (BLI_exists(sfile->params->dir)) { fsmenu_insert_entry(ED_fsmenu_get(), @@ -2091,6 +2101,7 @@ void FILE_OT_smoothscroll(wmOperatorType *ot) static int filepath_drop_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); SpaceFile *sfile = CTX_wm_space_file(C); if (sfile) { @@ -2105,7 +2116,7 @@ static int filepath_drop_exec(bContext *C, wmOperator *op) file_sfile_filepath_set(sfile, filepath); if (sfile->op) { - file_sfile_to_operator(C, sfile->op, sfile); + file_sfile_to_operator(bmain, sfile->op, sfile); file_draw_check(C); } diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 306d6cba50e..9fc4e8936f4 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -828,13 +828,23 @@ FileLayout *ED_fileselect_get_layout(struct SpaceFile *sfile, ARegion *region) return sfile->layout; } -void ED_file_change_dir(bContext *C) +/** + * Support updating the directory even when this isn't the active space + * needed so RNA properties update function isn't context sensitive, see T70255. + */ +void ED_file_change_dir_ex(bContext *C, bScreen *screen, ScrArea *area) { - wmWindowManager *wm = CTX_wm_manager(C); - SpaceFile *sfile = CTX_wm_space_file(C); - + /* May happen when manipulating non-active spaces. */ + if (UNLIKELY(area->spacetype != SPACE_FILE)) { + return; + } + SpaceFile *sfile = area->spacedata.first; if (sfile->params) { - ED_fileselect_clear(wm, CTX_data_scene(C), sfile); + wmWindowManager *wm = CTX_wm_manager(C); + Scene *scene = WM_windows_scene_get_from_screen(wm, screen); + if (LIKELY(scene != NULL)) { + ED_fileselect_clear(wm, scene, sfile); + } /* Clear search string, it is very rare to want to keep that filter while changing dir, * and usually very annoying to keep it actually! */ @@ -853,10 +863,17 @@ void ED_file_change_dir(bContext *C) folderlist_pushdir(sfile->folders_prev, sfile->params->dir); - file_draw_check(C); + file_draw_check_ex(C, area); } } +void ED_file_change_dir(bContext *C) +{ + bScreen *screen = CTX_wm_screen(C); + ScrArea *area = CTX_wm_area(C); + ED_file_change_dir_ex(C, screen, area); +} + int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matched_file) { int match = 0; diff --git a/source/blender/editors/space_graph/CMakeLists.txt b/source/blender/editors/space_graph/CMakeLists.txt index 8170c920990..fd5c5863608 100644 --- a/source/blender/editors/space_graph/CMakeLists.txt +++ b/source/blender/editors/space_graph/CMakeLists.txt @@ -29,10 +29,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC graph_buttons.c graph_draw.c @@ -67,6 +63,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_graph "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt index 24ec7a89397..96aab8b5d1a 100644 --- a/source/blender/editors/space_image/CMakeLists.txt +++ b/source/blender/editors/space_image/CMakeLists.txt @@ -35,10 +35,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC image_buttons.c image_draw.c @@ -81,6 +77,5 @@ if(WITH_IMAGE_CINEON) add_definitions(-DWITH_CINEON) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_image "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 85d153feb4c..60dd134646d 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -55,6 +55,7 @@ #include "BIF_glutil.h" +#include "GPU_framebuffer.h" #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_matrix.h" @@ -570,7 +571,8 @@ static void draw_image_buffer(const bContext *C, float zoomy) { /* Image are still drawn in display space. */ - glDisable(GL_FRAMEBUFFER_SRGB); + GPUFrameBuffer *fb = GPU_framebuffer_active_get(); + GPU_framebuffer_bind_no_srgb(fb); int x, y; int sima_flag = sima->flag & ED_space_image_get_display_channel_mask(ibuf); @@ -660,7 +662,7 @@ static void draw_image_buffer(const bContext *C, } } - glEnable(GL_FRAMEBUFFER_SRGB); + GPU_framebuffer_bind(fb); } static void draw_image_buffer_repeated(const bContext *C, diff --git a/source/blender/editors/space_info/CMakeLists.txt b/source/blender/editors/space_info/CMakeLists.txt index ad410e0aade..b6df07eec4e 100644 --- a/source/blender/editors/space_info/CMakeLists.txt +++ b/source/blender/editors/space_info/CMakeLists.txt @@ -33,10 +33,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC info_draw.c info_ops.c @@ -56,6 +52,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_info "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_nla/CMakeLists.txt b/source/blender/editors/space_nla/CMakeLists.txt index 60152bffaf4..9a94d28c604 100644 --- a/source/blender/editors/space_nla/CMakeLists.txt +++ b/source/blender/editors/space_nla/CMakeLists.txt @@ -29,9 +29,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC nla_buttons.c @@ -54,6 +51,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_nla "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_node/CMakeLists.txt b/source/blender/editors/space_node/CMakeLists.txt index f8c30f9a688..fc831bf8490 100644 --- a/source/blender/editors/space_node/CMakeLists.txt +++ b/source/blender/editors/space_node/CMakeLists.txt @@ -34,9 +34,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC drawnode.c @@ -75,6 +72,5 @@ if(WITH_OPENIMAGEDENOISE) add_definitions(-DWITH_OPENIMAGEDENOISE) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_node "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt index 616915dbc2c..db38839f959 100644 --- a/source/blender/editors/space_outliner/CMakeLists.txt +++ b/source/blender/editors/space_outliner/CMakeLists.txt @@ -30,9 +30,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC outliner_collections.c @@ -60,6 +57,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_outliner "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_script/CMakeLists.txt b/source/blender/editors/space_script/CMakeLists.txt index 0bd2a01a151..f2dd39ea13d 100644 --- a/source/blender/editors/space_script/CMakeLists.txt +++ b/source/blender/editors/space_script/CMakeLists.txt @@ -27,9 +27,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC script_edit.c @@ -49,6 +46,5 @@ if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_script "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt index 8105891e157..caf75349454 100644 --- a/source/blender/editors/space_sequencer/CMakeLists.txt +++ b/source/blender/editors/space_sequencer/CMakeLists.txt @@ -32,9 +32,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC sequencer_add.c @@ -73,6 +70,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_sequencer "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_statusbar/CMakeLists.txt b/source/blender/editors/space_statusbar/CMakeLists.txt index ad4c060a1f6..a0f3afecaf9 100644 --- a/source/blender/editors/space_statusbar/CMakeLists.txt +++ b/source/blender/editors/space_statusbar/CMakeLists.txt @@ -29,9 +29,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC space_statusbar.c @@ -42,6 +39,5 @@ set(LIB bf_blenlib ) -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_statusbar "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_text/CMakeLists.txt b/source/blender/editors/space_text/CMakeLists.txt index 740fc9948ef..abd7620ea2b 100644 --- a/source/blender/editors/space_text/CMakeLists.txt +++ b/source/blender/editors/space_text/CMakeLists.txt @@ -29,9 +29,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC space_text.c @@ -56,7 +53,6 @@ set(LIB bf_blenlib ) -add_definitions(${GL_DEFINITIONS}) if(WITH_PYTHON) list(APPEND INC diff --git a/source/blender/editors/space_topbar/CMakeLists.txt b/source/blender/editors/space_topbar/CMakeLists.txt index d56e1da334d..15e71e2296d 100644 --- a/source/blender/editors/space_topbar/CMakeLists.txt +++ b/source/blender/editors/space_topbar/CMakeLists.txt @@ -29,9 +29,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC space_topbar.c @@ -40,6 +37,5 @@ set(SRC set(LIB ) -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_topbar "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt index f2536cfac62..f4d6f7e322c 100644 --- a/source/blender/editors/space_view3d/CMakeLists.txt +++ b/source/blender/editors/space_view3d/CMakeLists.txt @@ -38,9 +38,6 @@ set(INC ${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC drawobject.c @@ -85,7 +82,6 @@ if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) endif() -add_definitions(${GL_DEFINITIONS}) if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index f3300f21628..0b5daece556 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1065,7 +1065,7 @@ static void draw_rotation_guide(const RegionView3D *rv3d) float o[3]; /* center of rotation */ float end[3]; /* endpoints for drawing */ - GLubyte color[4] = {0, 108, 255, 255}; /* bright blue so it matches device LEDs */ + uchar color[4] = {0, 108, 255, 255}; /* bright blue so it matches device LEDs */ negate_v3_v3(o, rv3d->ofs); diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt index b284ba0af2d..f905e96dbdd 100644 --- a/source/blender/editors/transform/CMakeLists.txt +++ b/source/blender/editors/transform/CMakeLists.txt @@ -33,9 +33,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC transform.c @@ -125,6 +122,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_transform "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 84eac3bbf8f..0eaae7f17cd 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -163,41 +163,6 @@ void constraintNumInput(TransInfo *t, float vec[3]) } } -static void postConstraintChecks(TransInfo *t, float vec[3]) -{ - mul_m3_v3(t->spacemtx_inv, vec); - - transform_snap_increment(t, vec); - - if (t->flag & T_NULL_ONE) { - if (!(t->con.mode & CON_AXIS0)) { - vec[0] = 1.0f; - } - - if (!(t->con.mode & CON_AXIS1)) { - vec[1] = 1.0f; - } - - if (!(t->con.mode & CON_AXIS2)) { - vec[2] = 1.0f; - } - } - - if (applyNumInput(&t->num, vec)) { - constraintNumInput(t, vec); - removeAspectRatio(t, vec); - } - - /* If `t->values` is operator param, use that directly but not if snapping is forced */ - if (t->flag & T_INPUT_IS_VALUES_FINAL && (t->tsnap.status & SNAP_FORCED) == 0) { - copy_v3_v3(vec, t->values); - constraintValuesFinal(t, vec); - /* inverse transformation at the end */ - } - - mul_m3_v3(t->spacemtx, vec); -} - static void viewAxisCorrectCenter(const TransInfo *t, float t_con_center[3]) { if (t->spacetype == SPACE_VIEW3D) { @@ -432,15 +397,22 @@ static void applyAxisConstraintVec( { copy_v3_v3(out, in); if (!td && t->con.mode & CON_APPLY) { + bool is_snap_to_point = false, is_snap_to_edge = false, is_snap_to_face = false; mul_m3_v3(t->con.pmtx, out); - bool is_snap_to_edge = false, is_snap_to_face = false; + if (activeSnap(t)) { - is_snap_to_edge = (t->tsnap.snapElem & SCE_SNAP_MODE_EDGE) != 0; - is_snap_to_face = (t->tsnap.snapElem & SCE_SNAP_MODE_FACE) != 0; + if (validSnap(t)) { + is_snap_to_point = (t->tsnap.snapElem & SCE_SNAP_MODE_VERTEX) != 0; + is_snap_to_edge = (t->tsnap.snapElem & SCE_SNAP_MODE_EDGE) != 0; + is_snap_to_face = (t->tsnap.snapElem & SCE_SNAP_MODE_FACE) != 0; + } + else if (t->tsnap.snapElem & SCE_SNAP_MODE_GRID) { + is_snap_to_point = true; + } } /* With snap points, a projection is alright, no adjustments needed. */ - if (!validSnap(t) || is_snap_to_edge || is_snap_to_face) { + if (!is_snap_to_point || is_snap_to_edge || is_snap_to_face) { const int dims = getConstraintSpaceDimension(t); if (dims == 2) { if (!is_zero_v3(out)) { @@ -486,7 +458,6 @@ static void applyAxisConstraintVec( } } } - postConstraintChecks(t, out); } } diff --git a/source/blender/editors/transform/transform_convert_mesh.c b/source/blender/editors/transform/transform_convert_mesh.c index 7ad54a56545..06ab60d992c 100644 --- a/source/blender/editors/transform/transform_convert_mesh.c +++ b/source/blender/editors/transform/transform_convert_mesh.c @@ -1296,6 +1296,9 @@ void mesh_customdatacorrect_init(TransInfo *t) use_merge_group = (t->settings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT_KEEP_CONNECTED) != 0; } } + else { + return; + } FOREACH_TRANS_DATA_CONTAINER (t, tc) { mesh_customdatacorrect_init_container(tc, use_merge_group); diff --git a/source/blender/editors/transform/transform_mode_edge_seq_slide.c b/source/blender/editors/transform/transform_mode_edge_seq_slide.c index 141f9acdeb4..d2474d78387 100644 --- a/source/blender/editors/transform/transform_mode_edge_seq_slide.c +++ b/source/blender/editors/transform/transform_mode_edge_seq_slide.c @@ -93,22 +93,29 @@ static void applySeqSlideValue(TransInfo *t, const float val[2]) static void applySeqSlide(TransInfo *t, const int mval[2]) { char str[UI_MAX_DRAW_STR]; + float values_final[3]; snapSequenceBounds(t, mval); - - if (t->con.mode & CON_APPLY) { - float tvec[3]; - t->con.applyVec(t, NULL, NULL, t->values, tvec); - copy_v3_v3(t->values_final, tvec); + if (applyNumInput(&t->num, values_final)) { + if (t->con.mode & CON_APPLY) { + if (t->con.mode & CON_AXIS0) { + /* Do nothing. */ + } + else { + mul_v2_v2fl(values_final, t->spacemtx[1], values_final[0]); + } + } + } + else if (t->con.mode & CON_APPLY) { + t->con.applyVec(t, NULL, NULL, t->values, values_final); } else { - // transform_snap_increment(t, t->values); - applyNumInput(&t->num, t->values); - copy_v3_v3(t->values_final, t->values); + copy_v2_v2(values_final, t->values); } - t->values_final[0] = floorf(t->values_final[0] + 0.5f); - t->values_final[1] = floorf(t->values_final[1] + 0.5f); + values_final[0] = floorf(values_final[0] + 0.5f); + values_final[1] = floorf(values_final[1] + 0.5f); + copy_v2_v2(t->values_final, values_final); headerSeqSlide(t, t->values_final, str); applySeqSlideValue(t, t->values_final); diff --git a/source/blender/editors/transform/transform_mode_translate.c b/source/blender/editors/transform/transform_mode_translate.c index 866b9d921c8..758a6d04f11 100644 --- a/source/blender/editors/transform/transform_mode_translate.c +++ b/source/blender/editors/transform/transform_mode_translate.c @@ -360,42 +360,49 @@ static void applyTranslation(TransInfo *t, const int UNUSED(mval[2])) if (t->flag & T_INPUT_IS_VALUES_FINAL) { mul_v3_m3v3(global_dir, t->spacemtx, t->values); } + else if (applyNumInput(&t->num, global_dir)) { + if (t->con.mode & CON_APPLY) { + if (t->con.mode & CON_AXIS0) { + /* Do nothing. */ + } + else if (t->con.mode & CON_AXIS1) { + mul_v3_v3fl(global_dir, t->spacemtx[1], global_dir[0]); + } + else if (t->con.mode & CON_AXIS2) { + mul_v3_v3fl(global_dir, t->spacemtx[2], global_dir[0]); + } + } + } else { copy_v3_v3(global_dir, t->values); - if (applyNumInput(&t->num, global_dir)) { - removeAspectRatio(t, global_dir); + + t->tsnap.snapElem = 0; + applySnapping(t, global_dir); + transform_snap_grid(t, global_dir); + + if (t->con.mode & CON_APPLY) { + float in[3]; + copy_v3_v3(in, global_dir); + t->con.applyVec(t, NULL, NULL, in, global_dir); } - else { - applySnapping(t, global_dir); - if (!validSnap(t) && !(t->con.mode & CON_APPLY)) { - float dist_sq = FLT_MAX; - if (transform_snap_grid(t, global_dir)) { - dist_sq = len_squared_v3v3(t->values, global_dir); - } + float incr_dir[3]; + mul_v3_m3v3(incr_dir, t->spacemtx_inv, global_dir); + if (transform_snap_increment(t, incr_dir)) { + mul_v3_m3v3(incr_dir, t->spacemtx, incr_dir); - /* Check the snap distance to the initial value to work with mixed snap. */ - float increment_loc[3]; - copy_v3_v3(increment_loc, t->values); - if (transform_snap_increment(t, increment_loc)) { - if ((dist_sq == FLT_MAX) || (len_squared_v3v3(t->values, increment_loc) < dist_sq)) { - copy_v3_v3(global_dir, increment_loc); - } - } + /* Test for mixed snap with grid. */ + float snap_dist_sq = FLT_MAX; + if (t->tsnap.snapElem != 0) { + snap_dist_sq = len_squared_v3v3(t->values, global_dir); + } + if ((snap_dist_sq == FLT_MAX) || (len_squared_v3v3(global_dir, incr_dir) < snap_dist_sq)) { + copy_v3_v3(global_dir, incr_dir); } } } - if (t->con.mode & CON_APPLY) { - float in[3]; - copy_v3_v3(in, global_dir); - t->con.applyVec(t, NULL, NULL, in, global_dir); - headerTranslation(t, global_dir, str); - } - else { - headerTranslation(t, global_dir, str); - } - + headerTranslation(t, global_dir, str); applyTranslationValue(t, global_dir); /* evil hack - redo translation if clipping needed */ diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 1813acadb9e..a546aabd095 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -464,6 +464,7 @@ void applySnapping(TransInfo *t, float *vec) void resetSnapping(TransInfo *t) { t->tsnap.status = 0; + t->tsnap.snapElem = 0; t->tsnap.align = false; t->tsnap.project = 0; t->tsnap.mode = 0; @@ -1412,12 +1413,12 @@ void snapSequenceBounds(TransInfo *t, const int mval[2]) t->values[0] = frame_near - frame_snap; } -static void snap_grid_apply_ex( +static void snap_grid_apply( TransInfo *t, const int max_index, const float grid_dist, const float loc[3], float r_out[3]) { + BLI_assert(max_index <= 2); const float *center_global = t->center_global; const float *asp = t->aspect; - bool use_local_axis = false; /* use a fallback for cursor selection, * this isn't useful as a global center for absolute grid snapping @@ -1427,74 +1428,27 @@ static void snap_grid_apply_ex( center_global = cd->global; } - if (t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2)) { - use_local_axis = true; + float in[3]; + if (t->con.mode & CON_APPLY) { + BLI_assert(t->tsnap.snapElem == 0); + t->con.applyVec(t, NULL, NULL, loc, in); + } + else { + copy_v3_v3(in, loc); } for (int i = 0; i <= max_index; i++) { - /* do not let unconstrained axis jump to absolute grid increments */ - if (!(t->con.mode & CON_APPLY) || t->con.mode & (CON_AXIS0 << i)) { - const float iter_fac = grid_dist * asp[i]; - - if (use_local_axis) { - float local_axis[3]; - float pos_on_axis[3]; - - copy_v3_v3(local_axis, t->spacemtx[i]); - copy_v3_v3(pos_on_axis, t->spacemtx[i]); - - /* amount of movement on axis from initial pos */ - mul_v3_fl(pos_on_axis, loc[i]); - - /* actual global position on axis */ - add_v3_v3(pos_on_axis, center_global); - - float min_dist = INFINITY; - for (int j = 0; j < 3; j++) { - if (fabs(local_axis[j]) < 0.01f) { - /* Ignore very small (normalized) axis changes */ - continue; - } - - /* closest point on grid */ - float grid_p = iter_fac * roundf(pos_on_axis[j] / iter_fac); - float dist_p = fabs((grid_p - pos_on_axis[j]) / local_axis[j]); - - /* The amount of distance needed to travel along the - * local axis to snap to the closest grid point */ - /* in the global j axis direction */ - float move_dist = (grid_p - center_global[j]) / local_axis[j]; - - if (dist_p < min_dist) { - min_dist = dist_p; - r_out[i] = move_dist; - } - } - } - else { - r_out[i] = iter_fac * roundf((loc[i] + center_global[i]) / iter_fac) - center_global[i]; - } - } + const float iter_fac = grid_dist * asp[i]; + r_out[i] = iter_fac * roundf((in[i] + center_global[i]) / iter_fac) - center_global[i]; } } -static void snap_grid_apply(TransInfo *t, int max_index, const float grid_dist, float *r_val) +bool transform_snap_grid(TransInfo *t, float *val) { - BLI_assert(t->tsnap.mode & SCE_SNAP_MODE_GRID); - BLI_assert(max_index <= 2); - - /* Early bailing out if no need to snap */ - if (grid_dist == 0.0f) { - return; + if (!activeSnap(t)) { + return false; } - /* absolute snapping on grid based on global center. - * for now only 3d view (others can be added if we want) */ - snap_grid_apply_ex(t, max_index, grid_dist, r_val, r_val); -} - -bool transform_snap_grid(TransInfo *t, float *val) -{ if ((!(t->tsnap.mode & SCE_SNAP_MODE_GRID)) || validSnap(t)) { /* Don't do grid snapping if there is a valid snap point. */ return false; @@ -1508,10 +1462,15 @@ bool transform_snap_grid(TransInfo *t, float *val) return false; } - float grid_dist = activeSnap(t) ? (t->modifiers & MOD_PRECISION) ? t->snap[2] : t->snap[1] : - t->snap[0]; + float grid_dist = (t->modifiers & MOD_PRECISION) ? t->snap[2] : t->snap[1]; + + /* Early bailing out if no need to snap */ + if (grid_dist == 0.0f) { + return false; + } - snap_grid_apply(t, t->idx_max, grid_dist, val); + snap_grid_apply(t, t->idx_max, grid_dist, val, val); + t->tsnap.snapElem = SCE_SNAP_MODE_GRID; return true; } diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt index 207606c2dcd..e05d1fedf6d 100644 --- a/source/blender/editors/util/CMakeLists.txt +++ b/source/blender/editors/util/CMakeLists.txt @@ -33,9 +33,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC ed_transverts.c @@ -106,7 +103,6 @@ set(SRC set(LIB ) -add_definitions(${GL_DEFINITIONS}) if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) diff --git a/source/blender/editors/uvedit/CMakeLists.txt b/source/blender/editors/uvedit/CMakeLists.txt index a39234561c2..f1751ef8d27 100644 --- a/source/blender/editors/uvedit/CMakeLists.txt +++ b/source/blender/editors/uvedit/CMakeLists.txt @@ -31,9 +31,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC uvedit_buttons.c @@ -58,6 +55,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_uvedit "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt index 497cb4a10a5..22f8f01be4b 100644 --- a/source/blender/gpencil_modifiers/CMakeLists.txt +++ b/source/blender/gpencil_modifiers/CMakeLists.txt @@ -76,6 +76,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_gpencil_modifiers "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 72dc610f3c8..b7ffa59538a 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -62,7 +62,6 @@ set(SRC intern/gpu_capabilities.cc intern/gpu_codegen.c intern/gpu_context.cc - intern/gpu_debug.cc intern/gpu_drawlist.cc intern/gpu_framebuffer.cc intern/gpu_immediate.cc @@ -113,10 +112,8 @@ set(SRC GPU_capabilities.h GPU_common.h GPU_context.h - GPU_debug.h GPU_drawlist.h GPU_framebuffer.h - GPU_glew.h GPU_immediate.h GPU_immediate_util.h GPU_index_buffer.h diff --git a/source/blender/gpu/GPU_capabilities.h b/source/blender/gpu/GPU_capabilities.h index b8a48735548..9d55fe73708 100644 --- a/source/blender/gpu/GPU_capabilities.h +++ b/source/blender/gpu/GPU_capabilities.h @@ -45,6 +45,8 @@ bool GPU_depth_blitting_workaround(void); bool GPU_use_main_context_workaround(void); bool GPU_crappy_amd_driver(void); +bool GPU_shader_image_load_store_support(void); + bool GPU_mem_stats_supported(void); void GPU_mem_stats_get(int *totalmem, int *freemem); diff --git a/source/blender/gpu/GPU_common.h b/source/blender/gpu/GPU_common.h index 8fd1baba2f7..1be74701176 100644 --- a/source/blender/gpu/GPU_common.h +++ b/source/blender/gpu/GPU_common.h @@ -32,10 +32,6 @@ # define TRUST_NO_ONE 1 #endif -#if defined(WITH_OPENGL) -# include <GL/glew.h> -#endif - #include "BLI_sys_types.h" #include <stdbool.h> #include <stdint.h> diff --git a/source/blender/gpu/GPU_debug.h b/source/blender/gpu/GPU_debug.h deleted file mode 100644 index 09dc02c0fc6..00000000000 --- a/source/blender/gpu/GPU_debug.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - */ - -/** \file - * \ingroup gpu - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -/* prints something if debug mode is active only */ -void GPU_print_error_debug(const char *str); - -#ifdef __cplusplus -} -#endif diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h index 5e872001267..a857736acd5 100644 --- a/source/blender/gpu/GPU_state.h +++ b/source/blender/gpu/GPU_state.h @@ -35,6 +35,14 @@ typedef enum eGPUWriteMask { ENUM_OPERATORS(eGPUWriteMask) +typedef enum eGPUBarrier { + GPU_BARRIER_NONE = 0, + GPU_BARRIER_SHADER_IMAGE_ACCESS = (1 << 0), + GPU_BARRIER_TEXTURE_FETCH = (1 << 1), +} eGPUBarrier; + +ENUM_OPERATORS(eGPUBarrier) + /** * Defines the fixed pipeline blending equation. * SRC is the output color from the shader. @@ -151,6 +159,10 @@ eGPUStencilTest GPU_stencil_test_get(void); void GPU_flush(void); void GPU_finish(void); +void GPU_apply_state(void); +void GPU_force_state(void); + +void GPU_memory_barrier(eGPUBarrier barrier); #ifdef __cplusplus } diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h index 2ce2ba093cf..99a7c6a5f0c 100644 --- a/source/blender/gpu/GPU_texture.h +++ b/source/blender/gpu/GPU_texture.h @@ -243,6 +243,10 @@ void GPU_texture_bind_ex(GPUTexture *tex, eGPUSamplerState state, int unit, cons void GPU_texture_unbind(GPUTexture *tex); void GPU_texture_unbind_all(void); +void GPU_texture_image_bind(GPUTexture *tex, int unit); +void GPU_texture_image_unbind(GPUTexture *tex); +void GPU_texture_image_unbind_all(void); + void GPU_texture_copy(GPUTexture *dst, GPUTexture *src); void GPU_texture_generate_mipmap(GPUTexture *tex); @@ -253,7 +257,6 @@ void GPU_texture_mipmap_mode(GPUTexture *tex, bool use_mipmap, bool use_filter); void GPU_texture_wrap_mode(GPUTexture *tex, bool use_repeat, bool use_clamp); void GPU_texture_swizzle_set(GPUTexture *tex, const char swizzle[4]); -int GPU_texture_target(const GPUTexture *tex); int GPU_texture_width(const GPUTexture *tex); int GPU_texture_height(const GPUTexture *tex); int GPU_texture_orig_width(const GPUTexture *tex); diff --git a/source/blender/gpu/GPU_vertex_buffer.h b/source/blender/gpu/GPU_vertex_buffer.h index 2af9929db35..36caee10072 100644 --- a/source/blender/gpu/GPU_vertex_buffer.h +++ b/source/blender/gpu/GPU_vertex_buffer.h @@ -139,6 +139,9 @@ GPUVertBufStatus GPU_vertbuf_get_status(const GPUVertBuf *verts); void GPU_vertbuf_use(GPUVertBuf *); +/* XXX do not use. */ +void GPU_vertbuf_update_sub(GPUVertBuf *verts, uint start, uint len, void *data); + /* Metrics */ uint GPU_vertbuf_get_memory_usage(void); diff --git a/source/blender/gpu/intern/gpu_capabilities.cc b/source/blender/gpu/intern/gpu_capabilities.cc index a79ce27ba63..63e29654e1c 100644 --- a/source/blender/gpu/intern/gpu_capabilities.cc +++ b/source/blender/gpu/intern/gpu_capabilities.cc @@ -102,6 +102,11 @@ bool GPU_crappy_amd_driver(void) return GCaps.broken_amd_driver; } +bool GPU_shader_image_load_store_support(void) +{ + return GCaps.shader_image_load_store_support; +} + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/gpu/intern/gpu_capabilities_private.hh b/source/blender/gpu/intern/gpu_capabilities_private.hh index a51525fa932..abe5b706a7d 100644 --- a/source/blender/gpu/intern/gpu_capabilities_private.hh +++ b/source/blender/gpu/intern/gpu_capabilities_private.hh @@ -42,6 +42,7 @@ struct GPUCapabilities { int max_textures_geom = 0; int max_textures_frag = 0; bool mem_stats_support = false; + bool shader_image_load_store_support = false; /* OpenGL related workarounds. */ bool mip_render_workaround = false; bool depth_blitting_workaround = false; @@ -52,4 +53,4 @@ struct GPUCapabilities { extern GPUCapabilities GCaps; -} // namespace blender::gpu
\ No newline at end of file +} // namespace blender::gpu diff --git a/source/blender/gpu/intern/gpu_context_private.hh b/source/blender/gpu/intern/gpu_context_private.hh index bc07bea4bb1..38f94b8dde9 100644 --- a/source/blender/gpu/intern/gpu_context_private.hh +++ b/source/blender/gpu/intern/gpu_context_private.hh @@ -46,7 +46,7 @@ class Context { Shader *shader = NULL; FrameBuffer *active_fb = NULL; GPUMatrixState *matrix_state = NULL; - GPUStateManager *state_manager = NULL; + StateManager *state_manager = NULL; Immediate *imm = NULL; /** diff --git a/source/blender/gpu/intern/gpu_debug.cc b/source/blender/gpu/intern/gpu_debug.cc deleted file mode 100644 index f179a241926..00000000000 --- a/source/blender/gpu/intern/gpu_debug.cc +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - */ - -/** \file - * \ingroup gpu - */ - -#include "BLI_compiler_attrs.h" -#include "BLI_sys_types.h" -#include "BLI_system.h" -#include "BLI_utildefines.h" - -#include "BKE_global.h" - -#include "GPU_debug.h" -#include "GPU_glew.h" -#include "intern/gpu_private.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -void GPU_print_error_debug(const char *str) -{ - if (G.debug & G_DEBUG) { - fprintf(stderr, "GPU: %s\n", str); - } -} diff --git a/source/blender/gpu/intern/gpu_immediate.cc b/source/blender/gpu/intern/gpu_immediate.cc index 9c3a88e30f0..8d781978857 100644 --- a/source/blender/gpu/intern/gpu_immediate.cc +++ b/source/blender/gpu/intern/gpu_immediate.cc @@ -416,7 +416,7 @@ static void immEndVertex(void) /* and move on to the next vertex */ printf("copying %s from vertex %u to %u\n", a->name, imm->vertex_idx - 1, imm->vertex_idx); #endif - GLubyte *data = imm->vertex_data + a->offset; + uchar *data = imm->vertex_data + a->offset; memcpy(data, data - imm->vertex_format.stride, a->sz); /* TODO: consolidate copy of adjacent attributes */ } diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c index 769b52bf593..c76ce0f1094 100644 --- a/source/blender/gpu/intern/gpu_select_pick.c +++ b/source/blender/gpu/intern/gpu_select_pick.c @@ -28,7 +28,6 @@ #include <string.h> #include "GPU_framebuffer.h" -#include "GPU_glew.h" #include "GPU_immediate.h" #include "GPU_select.h" #include "GPU_state.h" diff --git a/source/blender/gpu/intern/gpu_shader_interface.hh b/source/blender/gpu/intern/gpu_shader_interface.hh index f76339d3adb..fce6fda5f14 100644 --- a/source/blender/gpu/intern/gpu_shader_interface.hh +++ b/source/blender/gpu/intern/gpu_shader_interface.hh @@ -63,6 +63,7 @@ class ShaderInterface { /** Enabled bindpoints that needs to be fed with data. */ uint16_t enabled_attr_mask_ = 0; uint16_t enabled_ubo_mask_ = 0; + uint8_t enabled_ima_mask_ = 0; uint64_t enabled_tex_mask_ = 0; /** Location of builtin uniforms. Fast access, no lookup needed. */ int32_t builtins_[GPU_NUM_UNIFORMS]; diff --git a/source/blender/gpu/intern/gpu_state.cc b/source/blender/gpu/intern/gpu_state.cc index be523020e8a..b63abb3d57f 100644 --- a/source/blender/gpu/intern/gpu_state.cc +++ b/source/blender/gpu/intern/gpu_state.cc @@ -30,7 +30,6 @@ #include "BKE_global.h" -#include "GPU_glew.h" #include "GPU_state.h" #include "gpu_context_private.hh" @@ -41,7 +40,7 @@ using namespace blender::gpu; #define SET_STATE(_prefix, _state, _value) \ do { \ - GPUStateManager *stack = Context::get()->state_manager; \ + StateManager *stack = Context::get()->state_manager; \ auto &state_object = stack->_prefix##state; \ state_object._state = (_value); \ } while (0) @@ -105,7 +104,7 @@ void GPU_write_mask(eGPUWriteMask mask) void GPU_color_mask(bool r, bool g, bool b, bool a) { - GPUStateManager *stack = Context::get()->state_manager; + StateManager *stack = Context::get()->state_manager; auto &state = stack->state; uint32_t write_mask = state.write_mask; SET_FLAG_FROM_TEST(write_mask, r, (uint32_t)GPU_WRITE_RED); @@ -117,7 +116,7 @@ void GPU_color_mask(bool r, bool g, bool b, bool a) void GPU_depth_mask(bool depth) { - GPUStateManager *stack = Context::get()->state_manager; + StateManager *stack = Context::get()->state_manager; auto &state = stack->state; uint32_t write_mask = state.write_mask; SET_FLAG_FROM_TEST(write_mask, depth, (uint32_t)GPU_WRITE_DEPTH); @@ -142,7 +141,7 @@ void GPU_state_set(eGPUWriteMask write_mask, eGPUStencilOp stencil_op, eGPUProvokingVertex provoking_vert) { - GPUStateManager *stack = Context::get()->state_manager; + StateManager *stack = Context::get()->state_manager; auto &state = stack->state; state.write_mask = (uint32_t)write_mask; state.blend = (uint32_t)blend; @@ -161,7 +160,7 @@ void GPU_state_set(eGPUWriteMask write_mask, void GPU_depth_range(float near, float far) { - GPUStateManager *stack = Context::get()->state_manager; + StateManager *stack = Context::get()->state_manager; auto &state = stack->mutable_state; copy_v2_fl2(state.depth_range, near, far); } @@ -173,7 +172,7 @@ void GPU_line_width(float width) void GPU_point_size(float size) { - GPUStateManager *stack = Context::get()->state_manager; + StateManager *stack = Context::get()->state_manager; auto &state = stack->mutable_state; /* Keep the sign of point_size since it represents the enable state. */ state.point_size = size * ((state.point_size > 0.0) ? 1.0f : -1.0f); @@ -185,7 +184,7 @@ void GPU_point_size(float size) /* TODO remove and use program point size everywhere */ void GPU_program_point_size(bool enable) { - GPUStateManager *stack = Context::get()->state_manager; + StateManager *stack = Context::get()->state_manager; auto &state = stack->mutable_state; /* Set point size sign negative to disable. */ state.point_size = fabsf(state.point_size) * (enable ? 1 : -1); @@ -306,18 +305,35 @@ void GPU_finish(void) Context::get()->finish(); } +void GPU_apply_state(void) +{ + Context::get()->state_manager->apply_state(); +} + +/* Will set all the states regardless of the current ones. */ +void GPU_force_state(void) +{ + Context::get()->state_manager->force_state(); +} + /** \} */ /* -------------------------------------------------------------------- */ -/** \name Default OpenGL State - * - * This is called on startup, for opengl offscreen render. - * Generally we should always return to this state when - * temporarily modifying the state for drawing, though that are (undocumented) - * exceptions that we should try to get rid of. +/** \name Synchronisation Utils + * \{ */ + +void GPU_memory_barrier(eGPUBarrier barrier) +{ + Context::get()->state_manager->issue_barrier(barrier); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Default State * \{ */ -GPUStateManager::GPUStateManager(void) +StateManager::StateManager(void) { /* Set default state. */ state.write_mask = GPU_WRITE_COLOR; diff --git a/source/blender/gpu/intern/gpu_state_private.hh b/source/blender/gpu/intern/gpu_state_private.hh index 9fee45e7bd4..b8d247ec175 100644 --- a/source/blender/gpu/intern/gpu_state_private.hh +++ b/source/blender/gpu/intern/gpu_state_private.hh @@ -98,9 +98,6 @@ union GPUStateMutable { /* Viewport State */ /** TODO remove */ float depth_range[2]; - /** TODO remove, use explicit clear calls. */ - float clear_color[4]; - float clear_depth; /** Negative if using program point size. */ /* TODO(fclem) should be passed as uniform to all shaders. */ float point_size; @@ -152,21 +149,28 @@ inline GPUStateMutable operator~(const GPUStateMutable &a) * State manager keeping track of the draw state and applying it before drawing. * Base class which is then specialized for each implementation (GL, VK, ...). **/ -class GPUStateManager { +class StateManager { public: GPUState state; GPUStateMutable mutable_state; public: - GPUStateManager(); - virtual ~GPUStateManager(){}; + StateManager(); + virtual ~StateManager(){}; virtual void apply_state(void) = 0; + virtual void force_state(void) = 0; + + virtual void issue_barrier(eGPUBarrier barrier_bits) = 0; virtual void texture_bind(Texture *tex, eGPUSamplerState sampler, int unit) = 0; virtual void texture_unbind(Texture *tex) = 0; virtual void texture_unbind_all(void) = 0; + virtual void image_bind(Texture *tex, int unit) = 0; + virtual void image_unbind(Texture *tex) = 0; + virtual void image_unbind_all(void) = 0; + virtual void texture_unpack_row_length_set(uint len) = 0; }; diff --git a/source/blender/gpu/intern/gpu_texture.cc b/source/blender/gpu/intern/gpu_texture.cc index b22fd53f0f6..eb6881164b2 100644 --- a/source/blender/gpu/intern/gpu_texture.cc +++ b/source/blender/gpu/intern/gpu_texture.cc @@ -418,6 +418,21 @@ void GPU_texture_unbind_all(void) Context::get()->state_manager->texture_unbind_all(); } +void GPU_texture_image_bind(GPUTexture *tex, int unit) +{ + Context::get()->state_manager->image_bind(unwrap(tex), unit); +} + +void GPU_texture_image_unbind(GPUTexture *tex) +{ + Context::get()->state_manager->image_unbind(unwrap(tex)); +} + +void GPU_texture_image_unbind_all(void) +{ + Context::get()->state_manager->image_unbind_all(); +} + void GPU_texture_generate_mipmap(GPUTexture *tex) { reinterpret_cast<Texture *>(tex)->generate_mipmap(); @@ -498,12 +513,6 @@ void GPU_texture_ref(GPUTexture *tex) reinterpret_cast<Texture *>(tex)->refcount++; } -/* TODO(fclem) Remove! This is broken as it is! */ -int GPU_texture_target(const GPUTexture *UNUSED(tex)) -{ - return GL_TEXTURE_2D; -} - int GPU_texture_width(const GPUTexture *tex) { return reinterpret_cast<const Texture *>(tex)->width_get(); diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.cc b/source/blender/gpu/intern/gpu_vertex_buffer.cc index 4cc2af889e6..ea149aaa254 100644 --- a/source/blender/gpu/intern/gpu_vertex_buffer.cc +++ b/source/blender/gpu/intern/gpu_vertex_buffer.cc @@ -324,4 +324,11 @@ void GPU_vertbuf_use(GPUVertBuf *verts) unwrap(verts)->upload(); } +/* XXX this is just a wrapper for the use of the Hair refine workaround. + * To be used with GPU_vertbuf_use(). */ +void GPU_vertbuf_update_sub(GPUVertBuf *verts, uint start, uint len, void *data) +{ + unwrap(verts)->update_sub(start, len, data); +} + /** \} */
\ No newline at end of file diff --git a/source/blender/gpu/intern/gpu_vertex_buffer_private.hh b/source/blender/gpu/intern/gpu_vertex_buffer_private.hh index f1de0a2ac96..3cce7e79857 100644 --- a/source/blender/gpu/intern/gpu_vertex_buffer_private.hh +++ b/source/blender/gpu/intern/gpu_vertex_buffer_private.hh @@ -95,6 +95,8 @@ class VertBuf { } } + virtual void update_sub(uint start, uint len, void *data) = 0; + protected: virtual void acquire_data(void) = 0; virtual void resize_data(void) = 0; diff --git a/source/blender/gpu/intern/gpu_vertex_format.cc b/source/blender/gpu/intern/gpu_vertex_format.cc index ac8439167e3..3b0aa055588 100644 --- a/source/blender/gpu/intern/gpu_vertex_format.cc +++ b/source/blender/gpu/intern/gpu_vertex_format.cc @@ -70,7 +70,7 @@ static uint comp_sz(GPUVertCompType type) #if TRUST_NO_ONE assert(type <= GPU_COMP_F32); /* other types have irregular sizes (not bytes) */ #endif - const GLubyte sizes[] = {1, 1, 2, 2, 4, 4, 4}; + const uint sizes[] = {1, 1, 2, 2, 4, 4, 4}; return sizes[type]; } diff --git a/source/blender/gpu/opengl/gl_backend.cc b/source/blender/gpu/opengl/gl_backend.cc index edaa84cdcf8..46e048d7f7c 100644 --- a/source/blender/gpu/opengl/gl_backend.cc +++ b/source/blender/gpu/opengl/gl_backend.cc @@ -210,6 +210,7 @@ static void detect_workarounds(void) GLContext::debug_layer_workaround = true; GLContext::unused_fb_slot_workaround = true; /* Turn off extensions. */ + GCaps.shader_image_load_store_support = false; GLContext::base_instance_support = false; GLContext::clear_texture_support = false; GLContext::copy_image_support = false; @@ -250,17 +251,20 @@ static void detect_workarounds(void) (strstr(version, "4.5.13399") || strstr(version, "4.5.13417") || strstr(version, "4.5.13422"))) { GLContext::unused_fb_slot_workaround = true; + GCaps.shader_image_load_store_support = false; GCaps.broken_amd_driver = true; } /* We have issues with this specific renderer. (see T74024) */ if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE) && strstr(renderer, "AMD VERDE")) { GLContext::unused_fb_slot_workaround = true; + GCaps.shader_image_load_store_support = false; GCaps.broken_amd_driver = true; } /* Fix slowdown on this particular driver. (see T77641) */ if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE) && strstr(version, "Mesa 19.3.4")) { + GCaps.shader_image_load_store_support = false; GCaps.broken_amd_driver = true; } /* There is an issue with the #glBlitFramebuffer on MacOS with radeon pro graphics. @@ -349,10 +353,10 @@ static void detect_workarounds(void) } /** Internal capabilities. */ -GLint GLContext::max_texture_3d_size; -GLint GLContext::max_cubemap_size; -GLint GLContext::max_ubo_size; -GLint GLContext::max_ubo_binds; +GLint GLContext::max_cubemap_size = 0; +GLint GLContext::max_texture_3d_size = 0; +GLint GLContext::max_ubo_binds = 0; +GLint GLContext::max_ubo_size = 0; /** Extensions. */ bool GLContext::base_instance_support = false; bool GLContext::clear_texture_support = false; @@ -383,6 +387,7 @@ void GLBackend::capabilities_init(void) glGetIntegerv(GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS, &GCaps.max_textures_geom); glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &GCaps.max_textures); GCaps.mem_stats_support = GLEW_NVX_gpu_memory_info || GLEW_ATI_meminfo; + GCaps.shader_image_load_store_support = GLEW_ARB_shader_image_load_store; /* GL specific capabilities. */ glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &GLContext::max_texture_3d_size); glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &GLContext::max_cubemap_size); @@ -413,4 +418,4 @@ void GLBackend::capabilities_init(void) /** \} */ -} // namespace blender::gpu
\ No newline at end of file +} // namespace blender::gpu diff --git a/source/blender/gpu/opengl/gl_context.hh b/source/blender/gpu/opengl/gl_context.hh index 9822c842ce7..4d9c2470db0 100644 --- a/source/blender/gpu/opengl/gl_context.hh +++ b/source/blender/gpu/opengl/gl_context.hh @@ -56,8 +56,8 @@ class GLSharedOrphanLists { class GLContext : public Context { public: /** Capabilities. */ - static GLint max_texture_3d_size; static GLint max_cubemap_size; + static GLint max_texture_3d_size; static GLint max_ubo_size; static GLint max_ubo_binds; /** Extensions. */ diff --git a/source/blender/gpu/opengl/gl_debug.cc b/source/blender/gpu/opengl/gl_debug.cc index db99e90d0ec..747d8ee2e3e 100644 --- a/source/blender/gpu/opengl/gl_debug.cc +++ b/source/blender/gpu/opengl/gl_debug.cc @@ -200,13 +200,16 @@ void check_gl_resources(const char *info) * be big enough to feed the data range the shader awaits. */ uint16_t ubo_needed = interface->enabled_ubo_mask_; ubo_needed &= ~ctx->bound_ubo_slots; - /* NOTE: This only check binding. To be valid, the bound texture needs to * be the same format/target the shader expects. */ uint64_t tex_needed = interface->enabled_tex_mask_; tex_needed &= ~GLContext::state_manager_active_get()->bound_texture_slots(); + /* NOTE: This only check binding. To be valid, the bound image needs to + * be the same format/target the shader expects. */ + uint8_t ima_needed = interface->enabled_ima_mask_; + ima_needed &= ~GLContext::state_manager_active_get()->bound_image_slots(); - if (ubo_needed == 0 && tex_needed == 0) { + if (ubo_needed == 0 && tex_needed == 0 && ima_needed == 0) { return; } @@ -223,6 +226,7 @@ void check_gl_resources(const char *info) for (int i = 0; tex_needed != 0; i++, tex_needed >>= 1) { if ((tex_needed & 1) != 0) { + /* FIXME: texture_get might return an image input instead. */ const ShaderInput *tex_input = interface->texture_get(i); const char *tex_name = interface->input_name_get(tex_input); const char *sh_name = ctx->shader->name_get(); @@ -231,6 +235,18 @@ void check_gl_resources(const char *info) debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, NULL); } } + + for (int i = 0; ima_needed != 0; i++, ima_needed >>= 1) { + if ((ima_needed & 1) != 0) { + /* FIXME: texture_get might return a texture input instead. */ + const ShaderInput *tex_input = interface->texture_get(i); + const char *tex_name = interface->input_name_get(tex_input); + const char *sh_name = ctx->shader->name_get(); + char msg[256]; + SNPRINTF(msg, "Missing Image bind at slot %d : %s > %s : %s", i, sh_name, tex_name, info); + debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, NULL); + } + } } void raise_gl_error(const char *info) diff --git a/source/blender/gpu/opengl/gl_drawlist.hh b/source/blender/gpu/opengl/gl_drawlist.hh index 3a731559e3a..5c1e698c0a1 100644 --- a/source/blender/gpu/opengl/gl_drawlist.hh +++ b/source/blender/gpu/opengl/gl_drawlist.hh @@ -31,7 +31,6 @@ #include "BLI_sys_types.h" #include "GPU_batch.h" -#include "GPU_glew.h" #include "gpu_drawlist_private.hh" diff --git a/source/blender/gpu/opengl/gl_shader_interface.cc b/source/blender/gpu/opengl/gl_shader_interface.cc index d611efcd975..2d55c222e9c 100644 --- a/source/blender/gpu/opengl/gl_shader_interface.cc +++ b/source/blender/gpu/opengl/gl_shader_interface.cc @@ -100,6 +100,31 @@ static inline int sampler_binding(int32_t program, return -1; } } + +static inline int image_binding(int32_t program, + uint32_t uniform_index, + int32_t uniform_location, + int *image_len) +{ + /* Identify image uniforms and asign image units to them. */ + GLint type; + glGetActiveUniformsiv(program, 1, &uniform_index, GL_UNIFORM_TYPE, &type); + + switch (type) { + case GL_IMAGE_1D: + case GL_IMAGE_2D: + case GL_IMAGE_3D: { + /* For now just assign a consecutive index. In the future, we should set it in + * the shader using layout(binding = i) and query its value. */ + int binding = *image_len; + glUniform1i(uniform_location, binding); + (*image_len)++; + return binding; + } + default: + return -1; + } +} /** \} */ /* -------------------------------------------------------------------- */ @@ -207,8 +232,8 @@ GLShaderInterface::GLShaderInterface(GLuint program) enabled_ubo_mask_ |= (1 << input->binding); } - /* Uniforms */ - for (int i = 0, sampler = 0; i < active_uniform_len; i++) { + /* Uniforms & samplers & images */ + for (int i = 0, sampler = 0, image = 0; i < active_uniform_len; i++) { if (BLI_BITMAP_TEST(uniforms_from_blocks, i)) { continue; } @@ -224,6 +249,12 @@ GLShaderInterface::GLShaderInterface(GLuint program) name_buffer_offset += this->set_input_name(input, name, name_len); enabled_tex_mask_ |= (input->binding != -1) ? (1lu << input->binding) : 0lu; + + if (input->binding == -1) { + input->binding = image_binding(program, i, input->location, &image); + + enabled_ima_mask_ |= (input->binding != -1) ? (1lu << input->binding) : 0lu; + } } /* Builtin Uniforms */ @@ -296,4 +327,4 @@ void GLShaderInterface::ref_remove(GLVaoCache *ref) /** \} */ -} // namespace blender::gpu
\ No newline at end of file +} // namespace blender::gpu diff --git a/source/blender/gpu/opengl/gl_state.cc b/source/blender/gpu/opengl/gl_state.cc index 1678760e9cd..cd24fa0e0e4 100644 --- a/source/blender/gpu/opengl/gl_state.cc +++ b/source/blender/gpu/opengl/gl_state.cc @@ -42,7 +42,7 @@ namespace blender::gpu { /** \name GLStateManager * \{ */ -GLStateManager::GLStateManager(void) : GPUStateManager() +GLStateManager::GLStateManager(void) : StateManager() { /* Set other states that never change. */ glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); @@ -76,9 +76,21 @@ void GLStateManager::apply_state(void) this->set_state(this->state); this->set_mutable_state(this->mutable_state); this->texture_bind_apply(); + this->image_bind_apply(); active_fb->apply_state(); }; +void GLStateManager::force_state(void) +{ + /* Little exception for clip distances since they need to keep the old count correct. */ + uint32_t clip_distances = current_.clip_distances; + current_ = ~this->state; + current_.clip_distances = clip_distances; + current_mutable_ = ~this->mutable_state; + this->set_state(this->state); + this->set_mutable_state(this->mutable_state); +}; + void GLStateManager::set_state(const GPUState &state) { GPUState changed = state ^ current_; @@ -538,4 +550,98 @@ uint64_t GLStateManager::bound_texture_slots(void) /** \} */ +/* -------------------------------------------------------------------- */ +/** \name Image Binding (from image load store) + * \{ */ + +void GLStateManager::image_bind(Texture *tex_, int unit) +{ + /* Minimum support is 8 image in the fragment shader. No image for other stages. */ + BLI_assert(GPU_shader_image_load_store_support() && unit < 8); + GLTexture *tex = static_cast<GLTexture *>(tex_); + if (G.debug & G_DEBUG_GPU) { + tex->check_feedback_loop(); + } + images_[unit] = tex->tex_id_; + formats_[unit] = to_gl_internal_format(tex->format_); + tex->is_bound_ = true; + dirty_image_binds_ |= 1ULL << unit; +} + +void GLStateManager::image_unbind(Texture *tex_) +{ + GLTexture *tex = static_cast<GLTexture *>(tex_); + if (!tex->is_bound_) { + return; + } + + GLuint tex_id = tex->tex_id_; + for (int i = 0; i < ARRAY_SIZE(images_); i++) { + if (images_[i] == tex_id) { + images_[i] = 0; + dirty_image_binds_ |= 1ULL << i; + } + } + tex->is_bound_ = false; +} + +void GLStateManager::image_unbind_all(void) +{ + for (int i = 0; i < ARRAY_SIZE(images_); i++) { + if (images_[i] != 0) { + images_[i] = 0; + dirty_image_binds_ |= 1ULL << i; + } + } + this->image_bind_apply(); +} + +void GLStateManager::image_bind_apply(void) +{ + if (dirty_image_binds_ == 0) { + return; + } + uint32_t dirty_bind = dirty_image_binds_; + dirty_image_binds_ = 0; + + int first = bitscan_forward_uint(dirty_bind); + int last = 32 - bitscan_reverse_uint(dirty_bind); + int count = last - first; + + if (GLContext::multi_bind_support) { + glBindImageTextures(first, count, images_ + first); + } + else { + for (int unit = first; unit < last; unit++) { + if ((dirty_bind >> unit) & 1UL) { + glBindImageTexture(unit, images_[unit], 0, GL_TRUE, 0, GL_READ_WRITE, formats_[unit]); + } + } + } +} + +uint8_t GLStateManager::bound_image_slots(void) +{ + uint8_t bound_slots = 0; + for (int i = 0; i < ARRAY_SIZE(images_); i++) { + if (images_[i] != 0) { + bound_slots |= 1ULL << i; + } + } + return bound_slots; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Memory barrier + * \{ */ + +void GLStateManager::issue_barrier(eGPUBarrier barrier_bits) +{ + glMemoryBarrier(to_gl(barrier_bits)); +} + +/** \} */ + } // namespace blender::gpu diff --git a/source/blender/gpu/opengl/gl_state.hh b/source/blender/gpu/opengl/gl_state.hh index fb2ed3403f7..cab654006c6 100644 --- a/source/blender/gpu/opengl/gl_state.hh +++ b/source/blender/gpu/opengl/gl_state.hh @@ -40,7 +40,7 @@ class GLTexture; * State manager keeping track of the draw state and applying it before drawing. * Opengl Implementation. **/ -class GLStateManager : public GPUStateManager { +class GLStateManager : public StateManager { public: /** Anothter reference to the active framebuffer. */ GLFrameBuffer *active_fb = nullptr; @@ -64,19 +64,31 @@ class GLStateManager : public GPUStateManager { GLuint samplers_[64] = {0}; uint64_t dirty_texture_binds_ = 0; + GLuint images_[8] = {0}; + GLenum formats_[8] = {0}; + uint8_t dirty_image_binds_ = 0; + public: GLStateManager(); void apply_state(void) override; + void force_state(void) override; + + void issue_barrier(eGPUBarrier barrier_bits) override; void texture_bind(Texture *tex, eGPUSamplerState sampler, int unit) override; void texture_bind_temp(GLTexture *tex); void texture_unbind(Texture *tex) override; void texture_unbind_all(void) override; + void image_bind(Texture *tex, int unit) override; + void image_unbind(Texture *tex) override; + void image_unbind_all(void) override; + void texture_unpack_row_length_set(uint len) override; uint64_t bound_texture_slots(void); + uint8_t bound_image_slots(void); private: static void set_write_mask(const eGPUWriteMask value); @@ -95,9 +107,22 @@ class GLStateManager : public GPUStateManager { void set_mutable_state(const GPUStateMutable &state); void texture_bind_apply(void); + void image_bind_apply(void); MEM_CXX_CLASS_ALLOC_FUNCS("GLStateManager") }; +static inline GLbitfield to_gl(eGPUBarrier barrier_bits) +{ + GLbitfield barrier = 0; + if (barrier_bits & GPU_BARRIER_SHADER_IMAGE_ACCESS) { + barrier |= GL_SHADER_IMAGE_ACCESS_BARRIER_BIT; + } + if (barrier_bits & GPU_BARRIER_TEXTURE_FETCH) { + barrier |= GL_TEXTURE_FETCH_BARRIER_BIT; + } + return barrier; +} + } // namespace gpu } // namespace blender diff --git a/source/blender/gpu/opengl/gl_vertex_buffer.cc b/source/blender/gpu/opengl/gl_vertex_buffer.cc index a724c94775e..d97fc2c1600 100644 --- a/source/blender/gpu/opengl/gl_vertex_buffer.cc +++ b/source/blender/gpu/opengl/gl_vertex_buffer.cc @@ -106,4 +106,9 @@ void GLVertBuf::bind(void) } } +void GLVertBuf::update_sub(uint start, uint len, void *data) +{ + glBufferSubData(GL_ARRAY_BUFFER, start, len, data); +} + } // namespace blender::gpu
\ No newline at end of file diff --git a/source/blender/gpu/opengl/gl_vertex_buffer.hh b/source/blender/gpu/opengl/gl_vertex_buffer.hh index eee5222f467..e2bf6cd00e8 100644 --- a/source/blender/gpu/opengl/gl_vertex_buffer.hh +++ b/source/blender/gpu/opengl/gl_vertex_buffer.hh @@ -45,6 +45,8 @@ class GLVertBuf : public VertBuf { public: void bind(void); + void update_sub(uint start, uint len, void *data) override; + protected: void acquire_data(void) override; void resize_data(void) override; diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c index ba096653e0f..c7d8a8b3723 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.c +++ b/source/blender/ikplugin/intern/iksolver_plugin.c @@ -583,8 +583,8 @@ static void free_posetree(PoseTree *tree) MEM_freeN(tree); } -///---------------------------------------- -/// Plugin API for legacy iksolver +/* ------------------------------ + * Plugin API for legacy iksolver */ void iksolver_initialize_tree(struct Depsgraph *UNUSED(depsgraph), struct Scene *UNUSED(scene), diff --git a/source/blender/imbuf/intern/dds/BlockDXT.cpp b/source/blender/imbuf/intern/dds/BlockDXT.cpp index 1fbe7b46963..8978b823e2a 100644 --- a/source/blender/imbuf/intern/dds/BlockDXT.cpp +++ b/source/blender/imbuf/intern/dds/BlockDXT.cpp @@ -247,14 +247,14 @@ void BlockDXT1::setIndices(const int *idx) } } -/// Flip DXT1 block vertically. +/** Flip DXT1 block vertically. */ inline void BlockDXT1::flip4() { swap(row[0], row[3]); swap(row[1], row[2]); } -/// Flip half DXT1 block vertically. +/** Flip half DXT1 block vertically. */ inline void BlockDXT1::flip2() { swap(row[0], row[1]); @@ -299,27 +299,27 @@ void AlphaBlockDXT3::decodeBlock(ColorBlock *block) const block->color(0xF).a = (alphaF << 4) | alphaF; } -/// Flip DXT3 alpha block vertically. +/** Flip DXT3 alpha block vertically. */ void AlphaBlockDXT3::flip4() { swap(row[0], row[3]); swap(row[1], row[2]); } -/// Flip half DXT3 alpha block vertically. +/** Flip half DXT3 alpha block vertically. */ void AlphaBlockDXT3::flip2() { swap(row[0], row[1]); } -/// Flip DXT3 block vertically. +/** Flip DXT3 block vertically. */ void BlockDXT3::flip4() { alpha.flip4(); color.flip4(); } -/// Flip half DXT3 block vertically. +/** Flip half DXT3 block vertically. */ void BlockDXT3::flip2() { alpha.flip2(); @@ -458,21 +458,21 @@ void BlockDXT5::decodeBlockNV5x(ColorBlock *block) const alpha.decodeBlock(block); } -/// Flip DXT5 block vertically. +/** Flip DXT5 block vertically. */ void BlockDXT5::flip4() { alpha.flip4(); color.flip4(); } -/// Flip half DXT5 block vertically. +/** Flip half DXT5 block vertically. */ void BlockDXT5::flip2() { alpha.flip2(); color.flip2(); } -/// Decode ATI1 block. +/** Decode ATI1 block. */ void BlockATI1::decodeBlock(ColorBlock *block) const { uint8 alpha_array[8]; @@ -488,19 +488,19 @@ void BlockATI1::decodeBlock(ColorBlock *block) const } } -/// Flip ATI1 block vertically. +/** Flip ATI1 block vertically. */ void BlockATI1::flip4() { alpha.flip4(); } -/// Flip half ATI1 block vertically. +/** Flip half ATI1 block vertically. */ void BlockATI1::flip2() { alpha.flip2(); } -/// Decode ATI2 block. +/** Decode ATI2 block. */ void BlockATI2::decodeBlock(ColorBlock *block) const { uint8 alpha_array[8]; @@ -525,14 +525,14 @@ void BlockATI2::decodeBlock(ColorBlock *block) const } } -/// Flip ATI2 block vertically. +/** Flip ATI2 block vertically. */ void BlockATI2::flip4() { x.flip4(); y.flip4(); } -/// Flip half ATI2 block vertically. +/** Flip half ATI2 block vertically. */ void BlockATI2::flip2() { x.flip2(); @@ -586,14 +586,14 @@ void BlockCTX1::setIndices(const int *idx) } } -/// Flip CTX1 block vertically. +/** Flip CTX1 block vertically. */ inline void BlockCTX1::flip4() { swap(row[0], row[3]); swap(row[1], row[2]); } -/// Flip half CTX1 block vertically. +/** Flip half CTX1 block vertically. */ inline void BlockCTX1::flip2() { swap(row[0], row[1]); diff --git a/source/blender/imbuf/intern/dds/BlockDXT.h b/source/blender/imbuf/intern/dds/BlockDXT.h index 70ec8808c61..83cc147c76c 100644 --- a/source/blender/imbuf/intern/dds/BlockDXT.h +++ b/source/blender/imbuf/intern/dds/BlockDXT.h @@ -55,7 +55,7 @@ #include <Common.h> #include <Stream.h> -/// DXT1 block. +/** DXT1 block. */ struct BlockDXT1 { Color16 col0; Color16 col1; @@ -81,13 +81,13 @@ struct BlockDXT1 { void flip2(); }; -/// Return true if the block uses four color mode, false otherwise. +/** Return true if the block uses four color mode, false otherwise. */ inline bool BlockDXT1::isFourColorMode() const { return col0.u > col1.u; } -/// DXT3 alpha block with explicit alpha. +/** DXT3 alpha block with explicit alpha. */ struct AlphaBlockDXT3 { union { struct { @@ -117,7 +117,7 @@ struct AlphaBlockDXT3 { void flip2(); }; -/// DXT3 block. +/** DXT3 block. */ struct BlockDXT3 { AlphaBlockDXT3 alpha; BlockDXT1 color; @@ -129,7 +129,7 @@ struct BlockDXT3 { void flip2(); }; -/// DXT5 alpha block. +/** DXT5 alpha block. */ struct AlphaBlockDXT5 { // uint64 unions do not compile on all platforms #if 0 @@ -245,7 +245,7 @@ struct AlphaBlockDXT5 { void flip2(); }; -/// DXT5 block. +/** DXT5 block. */ struct BlockDXT5 { AlphaBlockDXT5 alpha; BlockDXT1 color; @@ -257,7 +257,7 @@ struct BlockDXT5 { void flip2(); }; -/// ATI1 block. +/** ATI1 block. */ struct BlockATI1 { AlphaBlockDXT5 alpha; @@ -267,7 +267,7 @@ struct BlockATI1 { void flip2(); }; -/// ATI2 block. +/** ATI2 block. */ struct BlockATI2 { AlphaBlockDXT5 x; AlphaBlockDXT5 y; @@ -278,7 +278,7 @@ struct BlockATI2 { void flip2(); }; -/// CTX1 block. +/** CTX1 block. */ struct BlockCTX1 { uint8 col0[2]; uint8 col1[2]; diff --git a/source/blender/imbuf/intern/dds/Color.h b/source/blender/imbuf/intern/dds/Color.h index d0b67d4638c..4a9202617f5 100644 --- a/source/blender/imbuf/intern/dds/Color.h +++ b/source/blender/imbuf/intern/dds/Color.h @@ -29,7 +29,7 @@ #pragma once -/// 32 bit color stored as BGRA. +/** 32 bit color stored as BGRA. */ class Color32 { public: Color32() @@ -93,7 +93,7 @@ class Color32 { }; }; -/// 16 bit 565 BGR color. +/** 16 bit 565 BGR color. */ class Color16 { public: Color16() diff --git a/source/blender/imbuf/intern/dds/ColorBlock.cpp b/source/blender/imbuf/intern/dds/ColorBlock.cpp index 69757d797b5..f2e8e0b0313 100644 --- a/source/blender/imbuf/intern/dds/ColorBlock.cpp +++ b/source/blender/imbuf/intern/dds/ColorBlock.cpp @@ -46,12 +46,12 @@ inline static uint colorDistance(Color32 c0, Color32 c1) } #endif -/// Default constructor. +/** Default constructor. */ ColorBlock::ColorBlock() { } -/// Init the color block from an array of colors. +/** Init the color block from an array of colors. */ ColorBlock::ColorBlock(const uint *linearImage) { for (uint i = 0; i < 16; i++) { @@ -59,7 +59,7 @@ ColorBlock::ColorBlock(const uint *linearImage) } } -/// Init the color block with the contents of the given block. +/** Init the color block with the contents of the given block. */ ColorBlock::ColorBlock(const ColorBlock &block) { for (uint i = 0; i < 16; i++) { @@ -67,7 +67,7 @@ ColorBlock::ColorBlock(const ColorBlock &block) } } -/// Initialize this color block. +/** Initialize this color block. */ ColorBlock::ColorBlock(const Image *img, uint x, uint y) { init(img, x, y); @@ -159,7 +159,7 @@ void ColorBlock::swizzle(uint x, uint y, uint z, uint w) } } -/// Returns true if the block has a single color. +/** Returns true if the block has a single color. */ bool ColorBlock::isSingleColor(Color32 mask /*= Color32(0xFF, 0xFF, 0xFF, 0x00)*/) const { uint u = m_color[0].u & mask.u; @@ -174,7 +174,7 @@ bool ColorBlock::isSingleColor(Color32 mask /*= Color32(0xFF, 0xFF, 0xFF, 0x00)* } #if 0 -/// Returns true if the block has a single color, ignoring transparent pixels. +/** Returns true if the block has a single color, ignoring transparent pixels. */ bool ColorBlock::isSingleColorNoAlpha() const { Color32 c; @@ -199,7 +199,7 @@ bool ColorBlock::isSingleColorNoAlpha() const #endif #if 0 -/// Count number of unique colors in this color block. +/** Count number of unique colors in this color block. */ uint ColorBlock::countUniqueColors() const { uint count = 0; @@ -223,7 +223,7 @@ uint ColorBlock::countUniqueColors() const #endif #if 0 -/// Get average color of the block. +/** Get average color of the block. */ Color32 ColorBlock::averageColor() const { uint r, g, b, a; @@ -240,7 +240,7 @@ Color32 ColorBlock::averageColor() const } #endif -/// Return true if the block is not fully opaque. +/** Return true if the block is not fully opaque. */ bool ColorBlock::hasAlpha() const { for (uint i = 0; i < 16; i++) { @@ -253,7 +253,7 @@ bool ColorBlock::hasAlpha() const #if 0 -/// Get diameter color range. +/** Get diameter color range. */ void ColorBlock::diameterRange(Color32 *start, Color32 *end) const { Color32 c0, c1; @@ -274,7 +274,7 @@ void ColorBlock::diameterRange(Color32 *start, Color32 *end) const *end = c1; } -/// Get luminance color range. +/** Get luminance color range. */ void ColorBlock::luminanceRange(Color32 *start, Color32 *end) const { Color32 minColor, maxColor; @@ -299,7 +299,7 @@ void ColorBlock::luminanceRange(Color32 *start, Color32 *end) const *end = maxColor; } -/// Get color range based on the bounding box. +/** Get color range based on the bounding box. */ void ColorBlock::boundsRange(Color32 *start, Color32 *end) const { Color32 minColor(255, 255, 255); @@ -344,7 +344,7 @@ void ColorBlock::boundsRange(Color32 *start, Color32 *end) const *end = maxColor; } -/// Get color range based on the bounding box. +/** Get color range based on the bounding box. */ void ColorBlock::boundsRangeAlpha(Color32 *start, Color32 *end) const { Color32 minColor(255, 255, 255, 255); @@ -400,7 +400,7 @@ void ColorBlock::boundsRangeAlpha(Color32 *start, Color32 *end) const #endif #if 0 -/// Sort colors by abosolute value in their 16 bit representation. +/** Sort colors by abosolute value in their 16 bit representation. */ void ColorBlock::sortColorsByAbsoluteValue() { // Dummy selection sort. @@ -422,7 +422,7 @@ void ColorBlock::sortColorsByAbsoluteValue() #endif #if 0 -/// Find extreme colors in the given axis. +/** Find extreme colors in the given axis. */ void ColorBlock::computeRange(Vector3::Arg axis, Color32 *start, Color32 *end) const { @@ -452,7 +452,7 @@ void ColorBlock::computeRange(Vector3::Arg axis, Color32 *start, Color32 *end) c #endif #if 0 -/// Sort colors in the given axis. +/** Sort colors in the given axis. */ void ColorBlock::sortColors(const Vector3 &axis) { float luma_array[16]; @@ -477,7 +477,7 @@ void ColorBlock::sortColors(const Vector3 &axis) #endif #if 0 -/// Get the volume of the color block. +/** Get the volume of the color block. */ float ColorBlock::volume() const { Box bounds; diff --git a/source/blender/imbuf/intern/dds/ColorBlock.h b/source/blender/imbuf/intern/dds/ColorBlock.h index dd63286e230..98b4c9cb40a 100644 --- a/source/blender/imbuf/intern/dds/ColorBlock.h +++ b/source/blender/imbuf/intern/dds/ColorBlock.h @@ -32,7 +32,7 @@ #include <Color.h> #include <Image.h> -/// Uncompressed 4x4 color block. +/** Uncompressed 4x4 color block. */ struct ColorBlock { ColorBlock(); ColorBlock(const uint *linearImage); @@ -61,31 +61,31 @@ struct ColorBlock { Color32 m_color[4 * 4]; }; -/// Get pointer to block colors. +/** Get pointer to block colors. */ inline const Color32 *ColorBlock::colors() const { return m_color; } -/// Get block color. +/** Get block color. */ inline Color32 ColorBlock::color(uint i) const { return m_color[i]; } -/// Get block color. +/** Get block color. */ inline Color32 &ColorBlock::color(uint i) { return m_color[i]; } -/// Get block color. +/** Get block color. */ inline Color32 ColorBlock::color(uint x, uint y) const { return m_color[y * 4 + x]; } -/// Get block color. +/** Get block color. */ inline Color32 &ColorBlock::color(uint x, uint y) { return m_color[y * 4 + x]; diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.h b/source/blender/imbuf/intern/dds/DirectDrawSurface.h index ac7f893fddd..373d5974a5e 100644 --- a/source/blender/imbuf/intern/dds/DirectDrawSurface.h +++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.h @@ -73,7 +73,7 @@ struct DDSCaps { uint caps4; }; -/// DDS file header for DX10. +/** DDS file header for DX10. */ struct DDSHeader10 { uint dxgiFormat; uint resourceDimension; @@ -82,7 +82,7 @@ struct DDSHeader10 { uint reserved; }; -/// DDS file header. +/** DDS file header. */ struct DDSHeader { uint fourcc; uint size; @@ -132,7 +132,7 @@ struct DDSHeader { uint d3d9Format() const; }; -/// DirectDraw Surface. (DDS) +/** DirectDraw Surface. (DDS) */ class DirectDrawSurface { public: DirectDrawSurface(unsigned char *mem, uint size); diff --git a/source/blender/imbuf/intern/dds/Image.h b/source/blender/imbuf/intern/dds/Image.h index 4ccfec99445..0f977641d89 100644 --- a/source/blender/imbuf/intern/dds/Image.h +++ b/source/blender/imbuf/intern/dds/Image.h @@ -32,7 +32,7 @@ #include "Color.h" #include "Common.h" -/// 32 bit RGBA image. +/** 32 bit RGBA image. */ class Image { public: enum Format { diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 0387f83d695..976035b9886 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -385,10 +385,6 @@ blender_include_dirs( ../../../../intern/mantaflow/extern ) -blender_include_dirs_sys( - "${GLEW_INCLUDE_PATH}" -) - add_cc_flags_custom_test(makesrna) setup_platform_linker_flags() @@ -443,7 +439,6 @@ set(LIB bf_editor_undo ) -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_rna "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 1a911494f09..13b316a9d5d 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2617,9 +2617,10 @@ static void rna_FileBrowser_FSMenu_active_range(PointerRNA *UNUSED(ptr), *max = *softmax = ED_fsmenu_get_nentries(fsmenu, category) - 1; } -static void rna_FileBrowser_FSMenu_active_update(struct bContext *C, PointerRNA *UNUSED(ptr)) +static void rna_FileBrowser_FSMenu_active_update(struct bContext *C, PointerRNA *ptr) { - ED_file_change_dir(C); + ScrArea *area = rna_area_from_space(ptr); + ED_file_change_dir_ex(C, (bScreen *)ptr->owner_id, area); } static int rna_FileBrowser_FSMenuSystem_active_get(PointerRNA *ptr) diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt index 01770abeca0..7f65e72bf3e 100644 --- a/source/blender/modifiers/CMakeLists.txt +++ b/source/blender/modifiers/CMakeLists.txt @@ -178,7 +178,6 @@ if(WITH_GMP) endif() # So we can have special tricks in modifier system. -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_modifiers "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 33b95d50cc0..4172dc06a9f 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -41,9 +41,6 @@ set(INC ../../../intern/sky/include ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC composite/nodes/node_composite_alphaOver.c @@ -343,7 +340,6 @@ if(WITH_COMPOSITOR) add_definitions(-DWITH_COMPOSITOR) endif() -add_definitions(${GL_DEFINITIONS}) if(WITH_FREESTYLE) add_definitions(-DWITH_FREESTYLE) diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index 89fe9f8c6aa..8a5c4f4a11b 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -27,12 +27,12 @@ #include <Python.h> #include "BLI_utildefines.h" - -#include "GPU_glew.h" #include "MEM_guardedalloc.h" #include "../generic/py_capi_utils.h" +#include "glew-mx.h" + #include "bgl.h" /* -------------------------------------------------------------------- */ diff --git a/source/blender/python/gpu/gpu_py_offscreen.c b/source/blender/python/gpu/gpu_py_offscreen.c index 15c39de990b..31440dadd03 100644 --- a/source/blender/python/gpu/gpu_py_offscreen.c +++ b/source/blender/python/gpu/gpu_py_offscreen.c @@ -157,6 +157,7 @@ static PyObject *bpygpu_offscreen_bind(BPyGPUOffScreen *self, PyObject *args, Py } GPU_offscreen_bind(self->ofs, save); + GPU_apply_state(); self->is_saved = save; Py_INCREF(self); @@ -185,6 +186,7 @@ static PyObject *bpygpu_offscreen_unbind(BPyGPUOffScreen *self, PyObject *args, } GPU_offscreen_unbind(self->ofs, restore); + GPU_apply_state(); Py_RETURN_NONE; } diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt index 6c3f422d3f0..febb0d1cad5 100644 --- a/source/blender/python/intern/CMakeLists.txt +++ b/source/blender/python/intern/CMakeLists.txt @@ -341,6 +341,5 @@ if(WITH_XR_OPENXR) add_definitions(-DWITH_XR_OPENXR) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_python "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/python/intern/bpy_rna_ui.c b/source/blender/python/intern/bpy_rna_ui.c index 9f37b8300db..27e4cb069ce 100644 --- a/source/blender/python/intern/bpy_rna_ui.c +++ b/source/blender/python/intern/bpy_rna_ui.c @@ -29,6 +29,7 @@ #include "UI_interface.h" #include "bpy_rna.h" +#include "bpy_rna_ui.h" PyDoc_STRVAR(bpy_rna_uilayout_introspect_doc, ".. method:: introspect()\n" diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt index e3c3cf712f9..2652ec2f8cb 100644 --- a/source/blender/render/CMakeLists.txt +++ b/source/blender/render/CMakeLists.txt @@ -39,9 +39,6 @@ set(INC ../../../intern/mantaflow/extern ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC intern/source/bake_api.c @@ -108,6 +105,5 @@ if(APPLE) endif() endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib_nolist(bf_render "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/shader_fx/CMakeLists.txt b/source/blender/shader_fx/CMakeLists.txt index a12f36f9713..a68b343d416 100644 --- a/source/blender/shader_fx/CMakeLists.txt +++ b/source/blender/shader_fx/CMakeLists.txt @@ -67,6 +67,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_shader_fx "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index 7c749c60168..b9efc0e386a 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -46,7 +46,6 @@ set(INC set(INC_SYS ${ZLIB_INCLUDE_DIRS} - ${GLEW_INCLUDE_PATH} ) set(SRC @@ -131,7 +130,6 @@ if(WITH_AUDASPACE) ) endif() -add_definitions(${GL_DEFINITIONS}) if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 1d3db3e7609..eb5f8ca5ef1 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -396,9 +396,6 @@ static void wm_draw_offscreen_texture_parameters(GPUOffScreen *offscreen) /* Setup offscreen color texture for drawing. */ GPUTexture *texture = GPU_offscreen_color_texture(offscreen); - /* We don't support multisample textures here. */ - BLI_assert(GPU_texture_target(texture) == GL_TEXTURE_2D); - /* No mipmaps or filtering. */ GPU_texture_mipmap_mode(texture, false, false); } diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index d00285adb02..2798cec8c58 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -51,9 +51,6 @@ if(WITH_TBB) list(INSERT LIB 0 bf_blenkernel) endif() -add_definitions(${GL_DEFINITIONS}) -blender_include_dirs("${GLEW_INCLUDE_PATH}") - if(WIN32) blender_include_dirs(../../intern/utfconv) endif() |