From: Mikko Rasa Date: Sun, 10 Dec 2023 09:05:34 +0000 (+0200) Subject: Use nullptr instead of 0 X-Git-Url: https://git.tdb.fi/?a=commitdiff_plain;h=69fa7e35d5259fd661d49afaff9bce4b6ef9ee34;p=libs%2Fgl.git Use nullptr instead of 0 --- diff --git a/source/animation/animation.cpp b/source/animation/animation.cpp index 1048cc9e..1de1ff4e 100644 --- a/source/animation/animation.cpp +++ b/source/animation/animation.cpp @@ -452,7 +452,7 @@ Animation::Iterator &Animation::Iterator::operator+=(const Time::TimeDelta &t) void Animation::Iterator::dispatch_events(AnimationEventObserver &observer) { for(; (event_iter!=animation->events.end() && event_iter->time<=elapsed); ++event_iter) - observer.animation_event(0, event_iter->name, event_iter->value); + observer.animation_event(nullptr, event_iter->name, event_iter->value); } Matrix Animation::Iterator::get_matrix() const @@ -487,7 +487,7 @@ Matrix Animation::Iterator::get_pose_matrix(unsigned link) const /* These shortcut constructors must be defined here to avoid an undefined reference to vftable. */ Animation::Loader::Loader(Animation &a): - Loader(a, 0) + Loader(a, nullptr) { } Animation::Loader::Loader(Animation &a, Collection &c): diff --git a/source/animation/animation.h b/source/animation/animation.h index 576cb9a5..d3ea724f 100644 --- a/source/animation/animation.h +++ b/source/animation/animation.h @@ -164,7 +164,7 @@ public: }; private: - const Armature *armature = 0; + const Armature *armature = nullptr; std::vector keyframes; std::vector events; bool looping = false; diff --git a/source/animation/animationplayer.cpp b/source/animation/animationplayer.cpp index 44b8e466..6da93d1c 100644 --- a/source/animation/animationplayer.cpp +++ b/source/animation/animationplayer.cpp @@ -222,8 +222,8 @@ AnimationPlayer::PlayingAnimation::PlayingAnimation(const Animation &a, float s) AnimationPlayer::Target::Target(Placeable &p): placeable(p), - object(0), - armature(0), + object(nullptr), + armature(nullptr), stacked(false) { } diff --git a/source/animation/armature.cpp b/source/animation/armature.cpp index acfffbf7..64e9dc44 100644 --- a/source/animation/armature.cpp +++ b/source/animation/armature.cpp @@ -40,7 +40,7 @@ unsigned Armature::get_max_link_index() const Armature::Link::Link(const string &n, unsigned i): name(n), index(i), - parent(0) + parent(nullptr) { } void Armature::Link::set_parent(const Link *p) diff --git a/source/animation/keyframe.h b/source/animation/keyframe.h index e5067158..55f8c341 100644 --- a/source/animation/keyframe.h +++ b/source/animation/keyframe.h @@ -24,7 +24,7 @@ public: std::string inline_base_name; public: - Loader(KeyFrame &k): Loader(k, 0) { } + Loader(KeyFrame &k): Loader(k, nullptr) { } Loader(KeyFrame &k, Collection &c): Loader(k, &c) { } private: Loader(KeyFrame &, Collection *); @@ -68,7 +68,7 @@ public: private: Transform transform; UniformMap uniforms; - const Pose *pose = 0; + const Pose *pose = nullptr; public: void set_transform(const Transform &); diff --git a/source/animation/pose.h b/source/animation/pose.h index b4ee9cf0..1c0cbf77 100644 --- a/source/animation/pose.h +++ b/source/animation/pose.h @@ -41,7 +41,7 @@ private: void rotation(float, float, float, float); }; - const Armature *armature = 0; + const Armature *armature = nullptr; std::vector links; public: diff --git a/source/backends/opengl/buffer_backend.cpp b/source/backends/opengl/buffer_backend.cpp index dc081b1c..5e794fba 100644 --- a/source/backends/opengl/buffer_backend.cpp +++ b/source/backends/opengl/buffer_backend.cpp @@ -45,19 +45,19 @@ void OpenGLBuffer::allocate() { static const int flags = GL_MAP_READ_BIT|GL_MAP_WRITE_BIT|GL_DYNAMIC_STORAGE_BIT; if(ARB_direct_state_access) - glNamedBufferStorage(id, size, 0, flags); + glNamedBufferStorage(id, size, nullptr, flags); else { bind_scratch(); - glBufferStorage(GL_ARRAY_BUFFER, size, 0, flags); + glBufferStorage(GL_ARRAY_BUFFER, size, nullptr, flags); } } else if(ARB_direct_state_access) - glNamedBufferData(id, size, 0, GL_STATIC_DRAW); + glNamedBufferData(id, size, nullptr, GL_STATIC_DRAW); else { bind_scratch(); - glBufferData(GL_ARRAY_BUFFER, size, 0, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, size, nullptr, GL_STATIC_DRAW); } } @@ -128,7 +128,7 @@ void OpenGLBuffer::unbind_scratch() if(scratch_binding) { glBindBuffer(GL_ARRAY_BUFFER, 0); - scratch_binding = 0; + scratch_binding = nullptr; } } diff --git a/source/backends/opengl/commands_backend.cpp b/source/backends/opengl/commands_backend.cpp index 0a4416c6..ac3692bd 100644 --- a/source/backends/opengl/commands_backend.cpp +++ b/source/backends/opengl/commands_backend.cpp @@ -33,7 +33,7 @@ void OpenGLCommands::use_pipeline(const PipelineState *ps) void OpenGLCommands::clear(const ClearValue *values) { - const Framebuffer *target = (pipeline_state ? pipeline_state->get_framebuffer() : 0); + const Framebuffer *target = (pipeline_state ? pipeline_state->get_framebuffer() : nullptr); if(!target) throw invalid_operation("OpenGLCommands::clear"); @@ -92,7 +92,7 @@ void OpenGLCommands::dispatch(unsigned count_x, unsigned count_y, unsigned count void OpenGLCommands::resolve_multisample() { - const Framebuffer *framebuffer = (pipeline_state ? pipeline_state->get_framebuffer() : 0); + const Framebuffer *framebuffer = (pipeline_state ? pipeline_state->get_framebuffer() : nullptr); if(!framebuffer) throw invalid_operation("OpenGLCommands::resolve_multisample"); diff --git a/source/backends/opengl/commands_backend.h b/source/backends/opengl/commands_backend.h index 128d0ccf..0315c866 100644 --- a/source/backends/opengl/commands_backend.h +++ b/source/backends/opengl/commands_backend.h @@ -15,7 +15,7 @@ class QueryPool; class MSPGL_API OpenGLCommands { protected: - const PipelineState *pipeline_state = 0; + const PipelineState *pipeline_state = nullptr; OpenGLCommands() = default; diff --git a/source/backends/opengl/device_backend.h b/source/backends/opengl/device_backend.h index ea526e1a..e81dcf76 100644 --- a/source/backends/opengl/device_backend.h +++ b/source/backends/opengl/device_backend.h @@ -15,15 +15,15 @@ class OpenGLTexture; struct OpenGLDeviceState { - const OpenGLPipelineState *last_pipeline = 0; + const OpenGLPipelineState *last_pipeline = nullptr; std::vector bound_tex_targets; std::vector bound_storage_textures; std::vector bound_uniform_blocks; std::vector bound_storage_buffers; unsigned restart_index = 0; unsigned n_clip_distances = 0; - const OpenGLBuffer *scratch_buffer = 0; - const OpenGLTexture *scratch_texture = 0; + const OpenGLBuffer *scratch_buffer = nullptr; + const OpenGLTexture *scratch_texture = nullptr; }; class MSPGL_API OpenGLDevice: public NonCopyable diff --git a/source/backends/opengl/pipelinestate_backend.cpp b/source/backends/opengl/pipelinestate_backend.cpp index af6584a7..51be6151 100644 --- a/source/backends/opengl/pipelinestate_backend.cpp +++ b/source/backends/opengl/pipelinestate_backend.cpp @@ -37,7 +37,7 @@ namespace GL { OpenGLPipelineState::~OpenGLPipelineState() { if(applied_to) - applied_to->get_state().last_pipeline = 0; + applied_to->get_state().last_pipeline = nullptr; } void OpenGLPipelineState::apply() const @@ -47,7 +47,7 @@ void OpenGLPipelineState::apply() const if(applied_to && applied_to!=&device) { - applied_to->get_state().last_pipeline = 0; + applied_to->get_state().last_pipeline = nullptr; changes = ~0U; } @@ -58,7 +58,7 @@ void OpenGLPipelineState::apply() const if(this!=dev_state.last_pipeline) { if(dev_state.last_pipeline) - dev_state.last_pipeline->applied_to = 0; + dev_state.last_pipeline->applied_to = nullptr; changes = ~0U; } @@ -330,8 +330,8 @@ void OpenGLPipelineState::clear() glDisable(GL_STENCIL_TEST); glDisable(GL_BLEND); - dev_state.last_pipeline->applied_to = 0; - dev_state.last_pipeline = 0; + dev_state.last_pipeline->applied_to = nullptr; + dev_state.last_pipeline = nullptr; } } diff --git a/source/backends/opengl/pipelinestate_backend.h b/source/backends/opengl/pipelinestate_backend.h index 6da1375c..4f358295 100644 --- a/source/backends/opengl/pipelinestate_backend.h +++ b/source/backends/opengl/pipelinestate_backend.h @@ -15,7 +15,7 @@ class MSPGL_API OpenGLPipelineState: public NonCopyable friend class OpenGLCommands; protected: - mutable Device *applied_to = 0; + mutable Device *applied_to = nullptr; mutable unsigned changes = 0; OpenGLPipelineState() = default; diff --git a/source/backends/opengl/program_backend.cpp b/source/backends/opengl/program_backend.cpp index 35e2230b..2bc43899 100644 --- a/source/backends/opengl/program_backend.cpp +++ b/source/backends/opengl/program_backend.cpp @@ -503,7 +503,7 @@ void OpenGLProgram::query_storage_blocks() GLenum prop = GL_BUFFER_BINDING; int value; - glGetProgramResourceiv(id, GL_SHADER_STORAGE_BLOCK, i, 1, &prop, 1, 0, &value); + glGetProgramResourceiv(id, GL_SHADER_STORAGE_BLOCK, i, 1, &prop, 1, nullptr, &value); info.bind_point = value; } } @@ -518,7 +518,7 @@ void OpenGLProgram::finalize_uniforms() for(const ReflectData::UniformInfo *u: i->uniforms) if(u->location>=0) { - UniformCall::FuncPtr func = 0; + UniformCall::FuncPtr func = nullptr; if(u->type==FLOAT) func = &uniform_wrapper; else if(u->type==FLOAT_VEC2) diff --git a/source/backends/opengl/renderer_backend.cpp b/source/backends/opengl/renderer_backend.cpp index e49f6ce6..6b32191e 100644 --- a/source/backends/opengl/renderer_backend.cpp +++ b/source/backends/opengl/renderer_backend.cpp @@ -6,7 +6,7 @@ namespace GL { void OpenGLRenderer::end() { - static_cast(this)->commands.use_pipeline(0); + static_cast(this)->commands.use_pipeline(nullptr); } } // namespace GL diff --git a/source/backends/opengl/texture1d_backend.cpp b/source/backends/opengl/texture1d_backend.cpp index f7831dbd..93b92e56 100644 --- a/source/backends/opengl/texture1d_backend.cpp +++ b/source/backends/opengl/texture1d_backend.cpp @@ -42,7 +42,7 @@ void OpenGLTexture1D::allocate() for(unsigned i=0; iunmap(); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pixel_buffer->id); - self.texture->OpenGLTexture2D::sub_image(self.level, self.x, self.y, self.width, self.height, 0); + self.texture->OpenGLTexture2D::sub_image(self.level, self.x, self.y, self.width, self.height, nullptr); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); } diff --git a/source/backends/opengl/texture2d_backend.h b/source/backends/opengl/texture2d_backend.h index 470884d3..d1f4735e 100644 --- a/source/backends/opengl/texture2d_backend.h +++ b/source/backends/opengl/texture2d_backend.h @@ -15,7 +15,7 @@ protected: class MSPGL_API AsyncTransfer: public NonCopyable { protected: - Buffer *pixel_buffer = 0; + Buffer *pixel_buffer = nullptr; AsyncTransfer() = default; AsyncTransfer(AsyncTransfer &&); diff --git a/source/backends/opengl/texture2dmultisample_backend.h b/source/backends/opengl/texture2dmultisample_backend.h index 88a98fd4..a2ca6aa6 100644 --- a/source/backends/opengl/texture2dmultisample_backend.h +++ b/source/backends/opengl/texture2dmultisample_backend.h @@ -15,7 +15,7 @@ protected: void allocate(); public: - virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; } + virtual AsyncLoader *load(IO::Seekable &, const Resources * = nullptr) { return nullptr; } virtual std::size_t get_data_size() const; virtual void unload() { } }; diff --git a/source/backends/opengl/texture3d_backend.cpp b/source/backends/opengl/texture3d_backend.cpp index b71ad811..3e1984a7 100644 --- a/source/backends/opengl/texture3d_backend.cpp +++ b/source/backends/opengl/texture3d_backend.cpp @@ -46,7 +46,7 @@ void OpenGLTexture3D::allocate() for(unsigned i=0; itarget, 0); - scratch_binding = 0; + scratch_binding = nullptr; } } diff --git a/source/backends/opengl/texturecube_backend.cpp b/source/backends/opengl/texturecube_backend.cpp index 9b703c05..18dab01c 100644 --- a/source/backends/opengl/texturecube_backend.cpp +++ b/source/backends/opengl/texturecube_backend.cpp @@ -54,7 +54,7 @@ void OpenGLTextureCube::allocate() { unsigned lv_size = static_cast(this)->get_level_size(i); for(unsigned j=0; j<6; ++j) - glTexImage2D(get_gl_cube_face(j), i, gl_fmt, lv_size, lv_size, 0, comp, type, 0); + glTexImage2D(get_gl_cube_face(j), i, gl_fmt, lv_size, lv_size, 0, comp, type, nullptr); } glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, n_levels-1); } diff --git a/source/backends/opengl/texturecube_backend.h b/source/backends/opengl/texturecube_backend.h index 7434a4ef..a2424434 100644 --- a/source/backends/opengl/texturecube_backend.h +++ b/source/backends/opengl/texturecube_backend.h @@ -16,7 +16,7 @@ protected: void sub_image(unsigned, unsigned, int, int, unsigned, unsigned, const void *); public: - virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; } + virtual AsyncLoader *load(IO::Seekable &, const Resources * = nullptr) { return nullptr; } virtual std::size_t get_data_size() const; virtual void unload() { } }; diff --git a/source/backends/opengl/vertexsetup_backend.cpp b/source/backends/opengl/vertexsetup_backend.cpp index 59b5c66e..0f6e966f 100644 --- a/source/backends/opengl/vertexsetup_backend.cpp +++ b/source/backends/opengl/vertexsetup_backend.cpp @@ -141,14 +141,14 @@ void OpenGLVertexSetup::unload() { unsigned sem = get_attribute_semantic(a); glDisableVertexAttribArray(sem); - glVertexAttribPointer(sem, 1, GL_FLOAT, false, 0, 0); + glVertexAttribPointer(sem, 1, GL_FLOAT, false, 0, nullptr); } for(VertexAttribute a: self.inst_format) if(!is_padding(a)) { unsigned sem = get_attribute_semantic(a); glDisableVertexAttribArray(sem); - glVertexAttribPointer(sem, 1, GL_FLOAT, false, 0, 0); + glVertexAttribPointer(sem, 1, GL_FLOAT, false, 0, nullptr); } glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); diff --git a/source/backends/vulkan/buffer_backend.cpp b/source/backends/vulkan/buffer_backend.cpp index e83ccdac..e9c7e41a 100644 --- a/source/backends/vulkan/buffer_backend.cpp +++ b/source/backends/vulkan/buffer_backend.cpp @@ -19,9 +19,9 @@ VulkanBuffer::VulkanBuffer(VulkanBuffer &&other): mapped_address(other.mapped_address), debug_name(move(other.debug_name)) { - other.handle = 0; + other.handle = nullptr; other.memory_id = 0; - other.mapped_address = 0; + other.mapped_address = nullptr; } VulkanBuffer::~VulkanBuffer() @@ -77,7 +77,7 @@ void *VulkanBuffer::map() bool VulkanBuffer::unmap() { device.get_allocator().unmap(memory_id); - mapped_address = 0; + mapped_address = nullptr; return true; } diff --git a/source/backends/vulkan/buffer_backend.h b/source/backends/vulkan/buffer_backend.h index 55e24e69..a265560a 100644 --- a/source/backends/vulkan/buffer_backend.h +++ b/source/backends/vulkan/buffer_backend.h @@ -18,9 +18,9 @@ class MSPGL_API VulkanBuffer: public NonCopyable protected: Device &device; - VkBuffer handle = 0; + VkBuffer handle = nullptr; unsigned memory_id = 0; - void *mapped_address = 0; + void *mapped_address = nullptr; std::string debug_name; VulkanBuffer(); diff --git a/source/backends/vulkan/commands_backend.cpp b/source/backends/vulkan/commands_backend.cpp index 7f56c984..6921b9fb 100644 --- a/source/backends/vulkan/commands_backend.cpp +++ b/source/backends/vulkan/commands_backend.cpp @@ -77,7 +77,7 @@ void VulkanCommands::begin_buffer(VkRenderPass render_pass) } vk.BeginCommandBuffer(buffer, begin_info); - last_pipeline = 0; + last_pipeline = nullptr; } void VulkanCommands::begin_render_pass(bool clear, const ClearValue *clear_values) @@ -89,7 +89,7 @@ void VulkanCommands::begin_render_pass(bool clear, const ClearValue *clear_value viewport = pipeline_state->get_viewport(); if(!primary_buffer) - begin_buffer(0); + begin_buffer(nullptr); fb_is_swapchain = framebuffer->is_presentable(); framebuffer->refresh(); @@ -128,9 +128,9 @@ void VulkanCommands::end_render_pass() vkCmd.ExecuteCommands(1, &pass_buffer); vkCmd.EndRenderPass(); - framebuffer = 0; + framebuffer = nullptr; viewport = Rect::max(); - pass_buffer = 0; + pass_buffer = nullptr; } void VulkanCommands::begin_frame(unsigned fnum) @@ -186,7 +186,7 @@ void VulkanCommands::submit_frame(Semaphore *wait_sem, Semaphore *signal_sem) vk.QueueSubmit(1, &submit_info, command_pools[frame_index].fence.handle); - primary_buffer = 0; + primary_buffer = nullptr; } void VulkanCommands::use_pipeline(const PipelineState *ps) @@ -217,7 +217,7 @@ void VulkanCommands::draw_instanced(const Batch &batch, unsigned count) throw invalid_operation("VulkanCommands::draw_instanced"); if(!framebuffer) - begin_render_pass(false, 0); + begin_render_pass(false, nullptr); VulkanCommandRecorder vkCmd(device.get_functions(), pass_buffer); @@ -241,7 +241,7 @@ void VulkanCommands::dispatch(unsigned count_x, unsigned count_y, unsigned count pipeline_state->refresh(); pipeline_state->synchronize_resources(); device.get_synchronizer().barrier(vkCmd); - pipeline_state->apply(vkCmd, 0, frame_index, false); + pipeline_state->apply(vkCmd, nullptr, frame_index, false); vkCmd.Dispatch(count_x, count_y, count_z); } @@ -284,7 +284,7 @@ VulkanCommands::CommandPool::CommandPool(CommandPool &&other): fence(move(other.fence)), in_use(other.in_use) { - other.pool = 0; + other.pool = nullptr; } VulkanCommands::CommandPool::~CommandPool() diff --git a/source/backends/vulkan/commands_backend.h b/source/backends/vulkan/commands_backend.h index efc1dbd3..ae3eea02 100644 --- a/source/backends/vulkan/commands_backend.h +++ b/source/backends/vulkan/commands_backend.h @@ -31,7 +31,7 @@ protected: struct CommandPool { Device &device; - VkCommandPool pool = 0; + VkCommandPool pool = nullptr; CommandBuffers primary; CommandBuffers secondary; Fence fence; @@ -46,11 +46,11 @@ protected: std::vector command_pools; unsigned frame_number = 0; unsigned frame_index = 0; - VkCommandBuffer primary_buffer = 0; - VkCommandBuffer pass_buffer = 0; - const PipelineState *pipeline_state = 0; - const PipelineState *last_pipeline = 0; - const Framebuffer *framebuffer = 0; + VkCommandBuffer primary_buffer = nullptr; + VkCommandBuffer pass_buffer = nullptr; + const PipelineState *pipeline_state = nullptr; + const PipelineState *last_pipeline = nullptr; + const Framebuffer *framebuffer = nullptr; Rect viewport = Rect::max(); bool fb_is_swapchain = false; bool discard_fb_contents = false; diff --git a/source/backends/vulkan/descriptorpool.cpp b/source/backends/vulkan/descriptorpool.cpp index 5a9cd93e..46ee1927 100644 --- a/source/backends/vulkan/descriptorpool.cpp +++ b/source/backends/vulkan/descriptorpool.cpp @@ -58,7 +58,7 @@ void DescriptorPool::begin_frame() add_pool(capacity); for(auto &s: sets) - fill(s.begin(), s.end(), static_cast(0)); + fill(s.begin(), s.end(), static_cast(nullptr)); used = Counts(); } @@ -77,7 +77,7 @@ unsigned DescriptorPool::get_descriptor_set_slot(const PipelineState &ps, unsign slot = next_slot++; slots.emplace(i, hash, slot); for(auto &s: sets) - s.push_back(0); + s.push_back(nullptr); } if(ps.is_descriptor_set_dynamic(index)) @@ -135,7 +135,7 @@ VkDescriptorSet DescriptorPool::get_descriptor_set(unsigned slot, const Pipeline for(unsigned i=0; i(desc_set); - vk.UpdateDescriptorSets(n_writes, writes, 0, 0); + vk.UpdateDescriptorSets(n_writes, writes, 0, nullptr); return desc_set; } diff --git a/source/backends/vulkan/destroyqueue.h b/source/backends/vulkan/destroyqueue.h index e8da7a0c..bf1de025 100644 --- a/source/backends/vulkan/destroyqueue.h +++ b/source/backends/vulkan/destroyqueue.h @@ -15,8 +15,8 @@ class DestroyQueue private: struct Entry { - void *handle = 0; - void (*destroy_func)(const VulkanFunctions &, void *) = 0; + void *handle = nullptr; + void (*destroy_func)(const VulkanFunctions &, void *) = nullptr; unsigned memory_id = 0; unsigned on_frame = 0; }; diff --git a/source/backends/vulkan/fence.cpp b/source/backends/vulkan/fence.cpp index f5b75442..7ba65e06 100644 --- a/source/backends/vulkan/fence.cpp +++ b/source/backends/vulkan/fence.cpp @@ -24,7 +24,7 @@ Fence::Fence(Fence &&other): device(other.device), handle(other.handle) { - other.handle = 0; + other.handle = nullptr; } Fence::~Fence() diff --git a/source/backends/vulkan/framebuffer_backend.cpp b/source/backends/vulkan/framebuffer_backend.cpp index c2ab2dfa..52f874fa 100644 --- a/source/backends/vulkan/framebuffer_backend.cpp +++ b/source/backends/vulkan/framebuffer_backend.cpp @@ -20,7 +20,7 @@ VulkanFramebuffer::VulkanFramebuffer(VulkanFramebuffer &&other): handle(other.handle), debug_name(move(other.debug_name)) { - other.handle = 0; + other.handle = nullptr; } VulkanFramebuffer::~VulkanFramebuffer() diff --git a/source/backends/vulkan/framebuffer_backend.h b/source/backends/vulkan/framebuffer_backend.h index 729898a7..6007cb66 100644 --- a/source/backends/vulkan/framebuffer_backend.h +++ b/source/backends/vulkan/framebuffer_backend.h @@ -20,7 +20,7 @@ class MSPGL_API VulkanFramebuffer: public NonCopyable protected: Device &device; - mutable VkFramebuffer handle = 0; + mutable VkFramebuffer handle = nullptr; mutable std::vector view_handles; std::string debug_name; diff --git a/source/backends/vulkan/memoryallocator.cpp b/source/backends/vulkan/memoryallocator.cpp index 8dbe94eb..24ffa7c8 100644 --- a/source/backends/vulkan/memoryallocator.cpp +++ b/source/backends/vulkan/memoryallocator.cpp @@ -388,7 +388,7 @@ void MemoryAllocator::unmap(unsigned id) { const VulkanFunctions &vk = device.get_functions(); vk.UnmapMemory(region.memory); - region.mapped_address = 0; + region.mapped_address = nullptr; } } diff --git a/source/backends/vulkan/memoryallocator.h b/source/backends/vulkan/memoryallocator.h index 6e3413f3..2bd2ab3a 100644 --- a/source/backends/vulkan/memoryallocator.h +++ b/source/backends/vulkan/memoryallocator.h @@ -43,9 +43,9 @@ private: { int pool = -1; bool direct = false; - VkDeviceMemory memory = 0; + VkDeviceMemory memory = nullptr; std::size_t size = 0; - void *mapped_address = 0; + void *mapped_address = nullptr; unsigned map_count = 0; }; diff --git a/source/backends/vulkan/module_backend.cpp b/source/backends/vulkan/module_backend.cpp index b0c39989..b5e97b51 100644 --- a/source/backends/vulkan/module_backend.cpp +++ b/source/backends/vulkan/module_backend.cpp @@ -17,7 +17,7 @@ VulkanSpirVModule::VulkanSpirVModule(VulkanSpirVModule &&other): device(other.device), handle(other.handle) { - other.handle = 0; + other.handle = nullptr; } VulkanSpirVModule::~VulkanSpirVModule() diff --git a/source/backends/vulkan/module_backend.h b/source/backends/vulkan/module_backend.h index d717b53d..f6be266a 100644 --- a/source/backends/vulkan/module_backend.h +++ b/source/backends/vulkan/module_backend.h @@ -15,7 +15,7 @@ class MSPGL_API VulkanSpirVModule protected: Device &device; - VkShaderModule handle = 0; + VkShaderModule handle = nullptr; std::string debug_name; VulkanSpirVModule(); diff --git a/source/backends/vulkan/pipelinecache.cpp b/source/backends/vulkan/pipelinecache.cpp index 618ddc93..fe30b67f 100644 --- a/source/backends/vulkan/pipelinecache.cpp +++ b/source/backends/vulkan/pipelinecache.cpp @@ -61,12 +61,12 @@ VkPipeline PipelineCache::get_pipeline(const PipelineState &ps) if(type==VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO) { const VkComputePipelineCreateInfo *creation_info = reinterpret_cast(buffer.data()); - vk.CreateComputePipelines(0, 1, creation_info, &pipeline); + vk.CreateComputePipelines(nullptr, 1, creation_info, &pipeline); } else { const VkGraphicsPipelineCreateInfo *creation_info = reinterpret_cast(buffer.data()); - vk.CreateGraphicsPipelines(0, 1, creation_info, &pipeline); + vk.CreateGraphicsPipelines(nullptr, 1, creation_info, &pipeline); } pipelines.insert(make_pair(key, pipeline)); diff --git a/source/backends/vulkan/pipelinestate_backend.cpp b/source/backends/vulkan/pipelinestate_backend.cpp index dd3b8347..d0bae663 100644 --- a/source/backends/vulkan/pipelinestate_backend.cpp +++ b/source/backends/vulkan/pipelinestate_backend.cpp @@ -210,9 +210,9 @@ void VulkanPipelineState::fill_graphics_creation_info(vector &buffer) cons viewport_info->sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; viewport_info->viewportCount = 1; - viewport_info->pViewports = 0; + viewport_info->pViewports = nullptr; viewport_info->scissorCount = 1; - viewport_info->pScissors = 0; + viewport_info->pScissors = nullptr; raster_info->sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; raster_info->depthClampEnable = VK_FALSE; @@ -233,7 +233,7 @@ void VulkanPipelineState::fill_graphics_creation_info(vector &buffer) cons multisample_info->rasterizationSamples = static_cast(get_vulkan_samples(format.get_samples())); multisample_info->sampleShadingEnable = VK_FALSE; multisample_info->minSampleShading = 1.0f; - multisample_info->pSampleMask = 0; + multisample_info->pSampleMask = nullptr; multisample_info->alphaToCoverageEnable = (format.get_samples()>1 && self.blend.alpha_to_coverage ? VK_TRUE : VK_FALSE); multisample_info->alphaToOneEnable = VK_FALSE; @@ -279,7 +279,7 @@ void VulkanPipelineState::fill_graphics_creation_info(vector &buffer) cons pipeline_info->sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; pipeline_info->pInputAssemblyState = input_assembly_info; - pipeline_info->pTessellationState = (has_tessellation ? tessellation_info : 0); + pipeline_info->pTessellationState = (has_tessellation ? tessellation_info : nullptr); pipeline_info->pViewportState = viewport_info; pipeline_info->pRasterizationState = raster_info; pipeline_info->pMultisampleState = multisample_info; @@ -320,7 +320,7 @@ uint64_t VulkanPipelineState::compute_descriptor_set_hash(unsigned index) const { const PipelineState &self = *static_cast(this); - uint64_t result = hash<64>(0, 0); + uint64_t result = hash<64>(nullptr, 0); bool empty = true; auto i = lower_bound_member(self.resources, static_cast(index)<<20, &PipelineState::BoundResource::binding); @@ -550,7 +550,7 @@ void VulkanPipelineState::apply(const VulkanCommandRecorder &vkCmd, const Vulkan self.descriptor_set_slots[i], self, i, frame)); vkCmd.BindDescriptorSets(bind_point, self.shprog->layout_handle, - first_changed_desc_set, descriptor_set_handles.size(), descriptor_set_handles.data(), 0, 0); + first_changed_desc_set, descriptor_set_handles.size(), descriptor_set_handles.data(), 0, nullptr); } if(!self.shprog->is_compute() && (unapplied&(PipelineState::VIEWPORT|PipelineState::SCISSOR))) diff --git a/source/backends/vulkan/pipelinestate_backend.h b/source/backends/vulkan/pipelinestate_backend.h index f59bc760..a8624f42 100644 --- a/source/backends/vulkan/pipelinestate_backend.h +++ b/source/backends/vulkan/pipelinestate_backend.h @@ -21,7 +21,7 @@ protected: Device &device; mutable unsigned changes = 0; mutable unsigned unapplied = 0; - mutable VkPipeline handle = 0; + mutable VkPipeline handle = nullptr; mutable std::vector descriptor_set_slots; mutable unsigned first_changed_desc_set = 0; mutable std::uint32_t push_const_compat = 0; diff --git a/source/backends/vulkan/program_backend.cpp b/source/backends/vulkan/program_backend.cpp index 73df3396..b6ddb12d 100644 --- a/source/backends/vulkan/program_backend.cpp +++ b/source/backends/vulkan/program_backend.cpp @@ -26,7 +26,7 @@ VulkanProgram::VulkanProgram(VulkanProgram &&other): debug_name(move(other.debug_name)) { other.desc_set_layout_handles.clear(); - other.layout_handle = 0; + other.layout_handle = nullptr; } VulkanProgram::~VulkanProgram() @@ -114,7 +114,7 @@ void VulkanProgram::finalize_uniforms() const ReflectData &rd = static_cast(this)->reflect_data; auto i = find_member(rd.blocks, static_cast(ReflectData::PUSH_CONSTANT), &ReflectData::BlockInfo::bind_point); - const ReflectData::BlockInfo *push_const_block = (i!=rd.blocks.end() ? &*i : 0); + const ReflectData::BlockInfo *push_const_block = (i!=rd.blocks.end() ? &*i : nullptr); desc_set_layout_handles.resize(rd.n_descriptor_sets); for(unsigned j=0; j creation_info; std::vector desc_set_layout_handles; - VkPipelineLayout layout_handle = 0; + VkPipelineLayout layout_handle = nullptr; std::string debug_name; VulkanProgram(); diff --git a/source/backends/vulkan/renderer_backend.cpp b/source/backends/vulkan/renderer_backend.cpp index 3b9281b5..166e66f3 100644 --- a/source/backends/vulkan/renderer_backend.cpp +++ b/source/backends/vulkan/renderer_backend.cpp @@ -10,8 +10,8 @@ VulkanRenderer::VulkanRenderer(): void VulkanRenderer::begin() { - begin_semaphore = 0; - end_semaphore = 0; + begin_semaphore = nullptr; + end_semaphore = nullptr; } void VulkanRenderer::begin(Semaphore &sem) @@ -24,7 +24,7 @@ void VulkanRenderer::begin(Semaphore &sem) void VulkanRenderer::end() { Renderer &self = *static_cast(this); - self.commands.use_pipeline(0); + self.commands.use_pipeline(nullptr); self.commands.submit_frame(begin_semaphore, end_semaphore); } diff --git a/source/backends/vulkan/renderer_backend.h b/source/backends/vulkan/renderer_backend.h index 577d29a4..dd9ec3a8 100644 --- a/source/backends/vulkan/renderer_backend.h +++ b/source/backends/vulkan/renderer_backend.h @@ -13,9 +13,9 @@ class MSPGL_API VulkanRenderer: public NonCopyable { protected: std::map pipeline_states; - PipelineState *current_pipeline = 0; - Semaphore *begin_semaphore = 0; - Semaphore *end_semaphore = 0; + PipelineState *current_pipeline = nullptr; + Semaphore *begin_semaphore = nullptr; + Semaphore *end_semaphore = nullptr; VulkanRenderer(); diff --git a/source/backends/vulkan/renderpass.h b/source/backends/vulkan/renderpass.h index e59dc164..97299e8c 100644 --- a/source/backends/vulkan/renderpass.h +++ b/source/backends/vulkan/renderpass.h @@ -13,13 +13,13 @@ union ClearValue; struct RenderPass { - const Framebuffer *framebuffer = 0; + const Framebuffer *framebuffer = nullptr; Rect render_area; bool clear = false; - const ClearValue *clear_values = 0; + const ClearValue *clear_values = nullptr; bool to_present = false; bool discard_fb_contents = false; - VkRenderPass handle = 0; + VkRenderPass handle = nullptr; void update(Device &); diff --git a/source/backends/vulkan/sampler_backend.cpp b/source/backends/vulkan/sampler_backend.cpp index 134be91b..2b54524b 100644 --- a/source/backends/vulkan/sampler_backend.cpp +++ b/source/backends/vulkan/sampler_backend.cpp @@ -18,7 +18,7 @@ VulkanSampler::VulkanSampler(VulkanSampler &&other): handle(other.handle), debug_name(move(other.debug_name)) { - other.handle = 0; + other.handle = nullptr; } VulkanSampler::~VulkanSampler() diff --git a/source/backends/vulkan/sampler_backend.h b/source/backends/vulkan/sampler_backend.h index 2603d13f..5e2204d5 100644 --- a/source/backends/vulkan/sampler_backend.h +++ b/source/backends/vulkan/sampler_backend.h @@ -15,7 +15,7 @@ class MSPGL_API VulkanSampler protected: Device &device; - mutable VkSampler handle = 0; + mutable VkSampler handle = nullptr; std::string debug_name; VulkanSampler(); diff --git a/source/backends/vulkan/structurebuilder.h b/source/backends/vulkan/structurebuilder.h index 1cb1e8ce..dd8a0426 100644 --- a/source/backends/vulkan/structurebuilder.h +++ b/source/backends/vulkan/structurebuilder.h @@ -13,7 +13,7 @@ private: struct Part { std::size_t offset = 0; - void *pointer = 0; + void *pointer = nullptr; }; std::vector &storage; diff --git a/source/backends/vulkan/swapchain.cpp b/source/backends/vulkan/swapchain.cpp index ba2d922b..572a42fe 100644 --- a/source/backends/vulkan/swapchain.cpp +++ b/source/backends/vulkan/swapchain.cpp @@ -40,7 +40,7 @@ SwapChain::SwapChain(unsigned w, unsigned h, unsigned n_images_min): surface_caps.supportedCompositeAlpha&~(surface_caps.supportedCompositeAlpha-1)); uint32_t n_formats = 0; - vk.GetPhysicalDeviceSurfaceFormats(surface, n_formats, 0); + vk.GetPhysicalDeviceSurfaceFormats(surface, n_formats, nullptr); vector surface_formats(n_formats); vk.GetPhysicalDeviceSurfaceFormats(surface, n_formats, surface_formats.data()); @@ -60,7 +60,7 @@ SwapChain::SwapChain(unsigned w, unsigned h, unsigned n_images_min): throw runtime_error("no suitable swapchain pixelformat"); uint32_t n_present_modes = 0; - vk.GetPhysicalDeviceSurfacePresentModes(surface, n_present_modes, 0); + vk.GetPhysicalDeviceSurfacePresentModes(surface, n_present_modes, nullptr); vector present_modes(n_present_modes); vk.GetPhysicalDeviceSurfacePresentModes(surface, n_present_modes, present_modes.data()); @@ -72,7 +72,7 @@ SwapChain::SwapChain(unsigned w, unsigned h, unsigned n_images_min): vk.CreateSwapchain(swapchain_info, handle); uint32_t n_images = 0; - vk.GetSwapchainImages(handle, n_images, 0); + vk.GetSwapchainImages(handle, n_images, nullptr); vector image_handles(n_images); vk.GetSwapchainImages(handle, n_images, image_handles.data()); @@ -96,7 +96,7 @@ unsigned SwapChain::begin_frame(Semaphore &sem) const VulkanFunctions &vk = device.get_functions(); uint32_t image_index; - vk.AcquireNextImage(handle, numeric_limits::max(), sem.handle, 0, image_index); + vk.AcquireNextImage(handle, numeric_limits::max(), sem.handle, nullptr, image_index); current_index = image_index; diff --git a/source/backends/vulkan/swapchain.h b/source/backends/vulkan/swapchain.h index b34b487c..88a95e6e 100644 --- a/source/backends/vulkan/swapchain.h +++ b/source/backends/vulkan/swapchain.h @@ -16,8 +16,8 @@ class SwapChain private: Device &device; - VkSwapchain handle = 0; - VkSurface surface = 0; + VkSwapchain handle = nullptr; + VkSurface surface = nullptr; unsigned width = 0; unsigned height = 0; std::vector images; diff --git a/source/backends/vulkan/swapchaintexture.cpp b/source/backends/vulkan/swapchaintexture.cpp index c5ccf2f2..a037a233 100644 --- a/source/backends/vulkan/swapchaintexture.cpp +++ b/source/backends/vulkan/swapchaintexture.cpp @@ -11,7 +11,7 @@ SwapChainTexture::SwapChainTexture(PixelFormat f, unsigned w, unsigned h, VkImag SwapChainTexture::~SwapChainTexture() { - handle = 0; + handle = nullptr; } } // namespace GL diff --git a/source/backends/vulkan/synchronizer.cpp b/source/backends/vulkan/synchronizer.cpp index 28488fd0..06bb4701 100644 --- a/source/backends/vulkan/synchronizer.cpp +++ b/source/backends/vulkan/synchronizer.cpp @@ -199,7 +199,7 @@ void Synchronizer::barrier(const VulkanCommandRecorder &vkCmd) if(!dst_stage) dst_stage = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; - vkCmd.PipelineBarrier(src_stage, dst_stage, 0, 0, 0, + vkCmd.PipelineBarrier(src_stage, dst_stage, 0, 0, nullptr, buffer_barriers.size(), buffer_barriers.data(), image_barriers.size(), image_barriers.data()); for(auto i=buffer_accesses.begin(); i!=buffer_accesses.end(); ) diff --git a/source/backends/vulkan/synchronizer.h b/source/backends/vulkan/synchronizer.h index 32a4d979..30dea564 100644 --- a/source/backends/vulkan/synchronizer.h +++ b/source/backends/vulkan/synchronizer.h @@ -15,7 +15,7 @@ class Synchronizer private: struct ImageAccess { - VkImage image = 0; + VkImage image = nullptr; unsigned aspect; int level = -1; unsigned current_layout; @@ -24,7 +24,7 @@ private: struct BufferAccess { - VkBuffer buffer = 0; + VkBuffer buffer = nullptr; std::size_t offset = 0; std::size_t size = 0; bool was_written = false; diff --git a/source/backends/vulkan/texture1d_backend.h b/source/backends/vulkan/texture1d_backend.h index 691ccdb9..48ae32df 100644 --- a/source/backends/vulkan/texture1d_backend.h +++ b/source/backends/vulkan/texture1d_backend.h @@ -17,7 +17,7 @@ protected: virtual void fill_mipmap_blit(unsigned, void *); public: - virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; } + virtual AsyncLoader *load(IO::Seekable &, const Resources * = nullptr) { return nullptr; } virtual std::size_t get_data_size() const; virtual void unload() { } }; diff --git a/source/backends/vulkan/texture2dmultisample_backend.h b/source/backends/vulkan/texture2dmultisample_backend.h index b5931e19..d898ede5 100644 --- a/source/backends/vulkan/texture2dmultisample_backend.h +++ b/source/backends/vulkan/texture2dmultisample_backend.h @@ -17,7 +17,7 @@ protected: virtual void fill_mipmap_blit(unsigned, void *) { } public: - virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; } + virtual AsyncLoader *load(IO::Seekable &, const Resources * = nullptr) { return nullptr; } virtual std::size_t get_data_size() const; virtual void unload() { } }; diff --git a/source/backends/vulkan/texture3d_backend.h b/source/backends/vulkan/texture3d_backend.h index 134f3d4d..421eca3a 100644 --- a/source/backends/vulkan/texture3d_backend.h +++ b/source/backends/vulkan/texture3d_backend.h @@ -20,7 +20,7 @@ protected: bool is_array() const; public: - virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; } + virtual AsyncLoader *load(IO::Seekable &, const Resources * = nullptr) { return nullptr; } virtual std::size_t get_data_size() const; virtual void unload() { } }; diff --git a/source/backends/vulkan/texture_backend.cpp b/source/backends/vulkan/texture_backend.cpp index b0ddb2ee..62c04491 100644 --- a/source/backends/vulkan/texture_backend.cpp +++ b/source/backends/vulkan/texture_backend.cpp @@ -24,8 +24,8 @@ VulkanTexture::VulkanTexture(VulkanTexture &&other): view_type(other.view_type), debug_name(move(other.debug_name)) { - other.handle = 0; - other.view_handle = 0; + other.handle = nullptr; + other.view_handle = nullptr; other.memory_id = 0; } diff --git a/source/backends/vulkan/texture_backend.h b/source/backends/vulkan/texture_backend.h index ce4e540f..69c456dd 100644 --- a/source/backends/vulkan/texture_backend.h +++ b/source/backends/vulkan/texture_backend.h @@ -17,8 +17,8 @@ class MSPGL_API VulkanTexture: public NonCopyable protected: Device &device; - VkImage handle = 0; - VkImageView view_handle = 0; + VkImage handle = nullptr; + VkImageView view_handle = nullptr; mutable std::vector mip_view_handles; unsigned memory_id = 0; unsigned view_type; diff --git a/source/backends/vulkan/texturecube_backend.h b/source/backends/vulkan/texturecube_backend.h index 7fdb8189..91c4b7ec 100644 --- a/source/backends/vulkan/texturecube_backend.h +++ b/source/backends/vulkan/texturecube_backend.h @@ -17,7 +17,7 @@ protected: virtual void fill_mipmap_blit(unsigned, void *); public: - virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; } + virtual AsyncLoader *load(IO::Seekable &, const Resources * = nullptr) { return nullptr; } virtual std::size_t get_data_size() const; virtual void unload() { } }; diff --git a/source/backends/vulkan/transferqueue.cpp b/source/backends/vulkan/transferqueue.cpp index 95f170d4..df5c037c 100644 --- a/source/backends/vulkan/transferqueue.cpp +++ b/source/backends/vulkan/transferqueue.cpp @@ -93,7 +93,7 @@ void TransferQueue::dispatch_transfers(const VulkanCommandRecorder &vkCmd, unsig for(; i!=j; ++i) { - VkBuffer buffer = (i->buffer_index>=0 ? buffers[i->buffer_index].buffer : 0); + VkBuffer buffer = (i->buffer_index>=0 ? buffers[i->buffer_index].buffer : nullptr); i->transfer(vkCmd, buffer, i->offset); if(i->buffer_index>=0) buffers[i->buffer_index].last_frame = current_frame; @@ -137,9 +137,9 @@ TransferQueue::StagingBuffer::StagingBuffer(StagingBuffer &&other): used(other.used), mapped_address(other.mapped_address) { - other.buffer = 0; + other.buffer = nullptr; other.memory_id = 0; - other.mapped_address = 0; + other.mapped_address = nullptr; } TransferQueue::StagingBuffer::~StagingBuffer() diff --git a/source/backends/vulkan/transferqueue.h b/source/backends/vulkan/transferqueue.h index 14654b76..5d6c926c 100644 --- a/source/backends/vulkan/transferqueue.h +++ b/source/backends/vulkan/transferqueue.h @@ -18,11 +18,11 @@ private: struct StagingBuffer { Device &device; - VkBuffer buffer = 0; + VkBuffer buffer = nullptr; unsigned memory_id = 0; std::size_t size = 0; std::size_t used = 0; - void *mapped_address = 0; + void *mapped_address = nullptr; unsigned async_count = 0; unsigned last_frame = 0; @@ -33,12 +33,12 @@ private: struct PendingTransfer { - const void *object = 0; + const void *object = nullptr; unsigned order = 0; int buffer_index = -1; std::size_t offset = 0; std::size_t size = 0; - void *staging_address = 0; + void *staging_address = nullptr; std::function synchronize; std::function transfer; }; diff --git a/source/backends/vulkan/vertexsetup_backend.cpp b/source/backends/vulkan/vertexsetup_backend.cpp index 1ac823b5..035f3d30 100644 --- a/source/backends/vulkan/vertexsetup_backend.cpp +++ b/source/backends/vulkan/vertexsetup_backend.cpp @@ -85,7 +85,7 @@ uint64_t VulkanVertexSetup::compute_hash() const { const VertexSetup &self = *static_cast(this); - uint64_t result = hash<64>(0, 0); + uint64_t result = hash<64>(nullptr, 0); for(VertexAttribute a: self.vertex_format) result = hash_update<64>(result, a); for(VertexAttribute a: self.inst_format) diff --git a/source/backends/vulkan/vulkan.h b/source/backends/vulkan/vulkan.h index 6c3726f6..b287b4dd 100644 --- a/source/backends/vulkan/vulkan.h +++ b/source/backends/vulkan/vulkan.h @@ -98,83 +98,83 @@ private: ::VkPhysicalDevice physicalDevice; ::VkQueue graphicsQueue; - PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDeviceProperties = 0; // 5.1 - PFN_vkCreateCommandPool vkCreateCommandPool = 0; // 6.2 - PFN_vkResetCommandPool vkResetCommandPool = 0; // 6.2 - PFN_vkDestroyCommandPool vkDestroyCommandPool = 0; // 6.2 - PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers = 0; // 6.3 - PFN_vkBeginCommandBuffer vkBeginCommandBuffer = 0; // 6.4 - PFN_vkEndCommandBuffer vkEndCommandBuffer = 0; // 6.4 - PFN_vkQueueSubmit vkQueueSubmit = 0; // 6.5 - PFN_vkCmdExecuteCommands vkCmdExecuteCommands = 0; // 6.7 - PFN_vkCreateFence vkCreateFence = 0; // 7.3 - PFN_vkDestroyFence vkDestroyFence = 0; // 7.3 - PFN_vkGetFenceStatus vkGetFenceStatus = 0; // 7.3 - PFN_vkResetFences vkResetFences = 0; // 7.3 - PFN_vkWaitForFences vkWaitForFences = 0; // 7.3 - PFN_vkCreateSemaphore vkCreateSemaphore = 0; // 7.4 - PFN_vkDestroySemaphore vkDestroySemaphore = 0; // 7.4 - PFN_vkCmdPipelineBarrier vkCmdPipelineBarrier = 0; // 7.6 - PFN_vkQueueWaitIdle vkQueueWaitIdle = 0; // 7.8 - PFN_vkCreateRenderPass vkCreateRenderPass = 0; // 8.1 - PFN_vkCreateRenderPass2 vkCreateRenderPass2 = 0; // 8.1 - PFN_vkDestroyRenderPass vkDestroyRenderPass = 0; // 8.1 - PFN_vkCreateFramebuffer vkCreateFramebuffer = 0; // 8.3 - PFN_vkDestroyFramebuffer vkDestroyFramebuffer = 0; // 8.3 - PFN_vkCmdBeginRenderPass vkCmdBeginRenderPass = 0; // 8.4 - PFN_vkCmdEndRenderPass vkCmdEndRenderPass = 0; // 8.4 - PFN_vkCreateShaderModule vkCreateShaderModule = 0; // 9.1 - PFN_vkDestroyShaderModule vkDestroyShaderModule = 0; // 9.1 - PFN_vkCreateComputePipelines vkCreateComputePipelines = 0; // 10.1 - PFN_vkCreateGraphicsPipelines vkCreateGraphicsPipelines = 0; // 10.2 - PFN_vkDestroyPipeline vkDestroyPipeline = 0; // 10.4 - PFN_vkCmdBindPipeline vkCmdBindPipeline = 0; // 10.10 - PFN_vkGetPhysicalDeviceMemoryProperties vkGetPhysicalDeviceMemoryProperties = 0; // 11.2.1 - PFN_vkAllocateMemory vkAllocateMemory = 0; // 11.2.3 - PFN_vkFreeMemory vkFreeMemory = 0; // 11.2.8 - PFN_vkMapMemory vkMapMemory = 0; // 11.2.9 - PFN_vkUnmapMemory vkUnmapMemory = 0; // 11.2.9 - PFN_vkCreateBuffer vkCreateBuffer = 0; // 12.1 - PFN_vkDestroyBuffer vkDestroyBuffer = 0; // 12.1 - PFN_vkCreateImage vkCreateImage = 0; // 12.3 - PFN_vkDestroyImage vkDestroyImage = 0; // 12.3 - PFN_vkCreateImageView vkCreateImageView = 0; // 12.5 - PFN_vkDestroyImageView vkDestroyImageView = 0; // 12.5 - PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements = 0; // 12.7 - PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements = 0; // 12.7 - PFN_vkBindBufferMemory vkBindBufferMemory = 0; // 12.7 - PFN_vkBindImageMemory vkBindImageMemory = 0; // 12.7 - PFN_vkCreateSampler vkCreateSampler = 0; // 13 - PFN_vkDestroySampler vkDestroySampler = 0; // 13 - PFN_vkCreateDescriptorSetLayout vkCreateDescriptorSetLayout = 0; // 14.2.1 - PFN_vkDestroyDescriptorSetLayout vkDestroyDescriptorSetLayout = 0; // 14.2.1 - PFN_vkCreatePipelineLayout vkCreatePipelineLayout = 0; // 14.2.2 - PFN_vkDestroyPipelineLayout vkDestroyPipelineLayout = 0; // 14.2.2 - PFN_vkCreateDescriptorPool vkCreateDescriptorPool = 0; // 14.2.3 - PFN_vkDestroyDescriptorPool vkDestroyDescriptorPool = 0; // 14.2.3 - PFN_vkAllocateDescriptorSets vkAllocateDescriptorSets = 0; // 14.2.3 - PFN_vkUpdateDescriptorSets vkUpdateDescriptorSets = 0; // 14.2.4 - PFN_vkCmdBindDescriptorSets vkCmdBindDescriptorSets = 0; // 14.2.7 - PFN_vkCmdPushConstants vkCmdPushConstants = 0; // 14.2.10 - PFN_vkCmdCopyBuffer vkCmdCopyBuffer = 0; // 19.2 - PFN_vkCmdCopyBufferToImage vkCmdCopyBufferToImage = 0; // 19.4 - PFN_vkCmdBlitImage vkCmdBlitImage = 0; // 19.5 - PFN_vkCmdBindIndexBuffer vkCmdBindIndexBuffer = 0; // 20.3 - PFN_vkCmdDrawIndexed vkCmdDrawIndexed = 0; // 20.3 - PFN_vkCmdBindVertexBuffers vkCmdBindVertexBuffers = 0; // 21.2 - PFN_vkCmdSetViewport vkCmdSetViewport = 0; // 24.5 - PFN_vkCmdSetScissor vkCmdSetScissor = 0; // 26.1 - PFN_vkCmdDispatch vkCmdDispatch = 0; // 28 - PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilities = 0; // 30.5.1 - PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormats = 0; // 30.5.2 - PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModes = 0; // 30.5.3 - PFN_vkCreateSwapchainKHR vkCreateSwapchain = 0; // 30.8 - PFN_vkDestroySwapchainKHR vkDestroySwapchain = 0; // 30.8 - PFN_vkGetSwapchainImagesKHR vkGetSwapchainImages = 0; // 30.8 - PFN_vkAcquireNextImageKHR vkAcquireNextImage = 0; // 30.8 - PFN_vkQueuePresentKHR vkQueuePresent = 0; // 30.8 - PFN_vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceFormatProperties = 0; // 39.2 - PFN_vkSetDebugUtilsObjectNameEXT vkSetDebugUtilsObjectName = 0; // 45.1.1 + PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDeviceProperties = nullptr; // 5.1 + PFN_vkCreateCommandPool vkCreateCommandPool = nullptr; // 6.2 + PFN_vkResetCommandPool vkResetCommandPool = nullptr; // 6.2 + PFN_vkDestroyCommandPool vkDestroyCommandPool = nullptr; // 6.2 + PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers = nullptr; // 6.3 + PFN_vkBeginCommandBuffer vkBeginCommandBuffer = nullptr; // 6.4 + PFN_vkEndCommandBuffer vkEndCommandBuffer = nullptr; // 6.4 + PFN_vkQueueSubmit vkQueueSubmit = nullptr; // 6.5 + PFN_vkCmdExecuteCommands vkCmdExecuteCommands = nullptr; // 6.7 + PFN_vkCreateFence vkCreateFence = nullptr; // 7.3 + PFN_vkDestroyFence vkDestroyFence = nullptr; // 7.3 + PFN_vkGetFenceStatus vkGetFenceStatus = nullptr; // 7.3 + PFN_vkResetFences vkResetFences = nullptr; // 7.3 + PFN_vkWaitForFences vkWaitForFences = nullptr; // 7.3 + PFN_vkCreateSemaphore vkCreateSemaphore = nullptr; // 7.4 + PFN_vkDestroySemaphore vkDestroySemaphore = nullptr; // 7.4 + PFN_vkCmdPipelineBarrier vkCmdPipelineBarrier = nullptr; // 7.6 + PFN_vkQueueWaitIdle vkQueueWaitIdle = nullptr; // 7.8 + PFN_vkCreateRenderPass vkCreateRenderPass = nullptr; // 8.1 + PFN_vkCreateRenderPass2 vkCreateRenderPass2 = nullptr; // 8.1 + PFN_vkDestroyRenderPass vkDestroyRenderPass = nullptr; // 8.1 + PFN_vkCreateFramebuffer vkCreateFramebuffer = nullptr; // 8.3 + PFN_vkDestroyFramebuffer vkDestroyFramebuffer = nullptr; // 8.3 + PFN_vkCmdBeginRenderPass vkCmdBeginRenderPass = nullptr; // 8.4 + PFN_vkCmdEndRenderPass vkCmdEndRenderPass = nullptr; // 8.4 + PFN_vkCreateShaderModule vkCreateShaderModule = nullptr; // 9.1 + PFN_vkDestroyShaderModule vkDestroyShaderModule = nullptr; // 9.1 + PFN_vkCreateComputePipelines vkCreateComputePipelines = nullptr; // 10.1 + PFN_vkCreateGraphicsPipelines vkCreateGraphicsPipelines = nullptr; // 10.2 + PFN_vkDestroyPipeline vkDestroyPipeline = nullptr; // 10.4 + PFN_vkCmdBindPipeline vkCmdBindPipeline = nullptr; // 10.10 + PFN_vkGetPhysicalDeviceMemoryProperties vkGetPhysicalDeviceMemoryProperties = nullptr; // 11.2.1 + PFN_vkAllocateMemory vkAllocateMemory = nullptr; // 11.2.3 + PFN_vkFreeMemory vkFreeMemory = nullptr; // 11.2.8 + PFN_vkMapMemory vkMapMemory = nullptr; // 11.2.9 + PFN_vkUnmapMemory vkUnmapMemory = nullptr; // 11.2.9 + PFN_vkCreateBuffer vkCreateBuffer = nullptr; // 12.1 + PFN_vkDestroyBuffer vkDestroyBuffer = nullptr; // 12.1 + PFN_vkCreateImage vkCreateImage = nullptr; // 12.3 + PFN_vkDestroyImage vkDestroyImage = nullptr; // 12.3 + PFN_vkCreateImageView vkCreateImageView = nullptr; // 12.5 + PFN_vkDestroyImageView vkDestroyImageView = nullptr; // 12.5 + PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements = nullptr; // 12.7 + PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements = nullptr; // 12.7 + PFN_vkBindBufferMemory vkBindBufferMemory = nullptr; // 12.7 + PFN_vkBindImageMemory vkBindImageMemory = nullptr; // 12.7 + PFN_vkCreateSampler vkCreateSampler = nullptr; // 13 + PFN_vkDestroySampler vkDestroySampler = nullptr; // 13 + PFN_vkCreateDescriptorSetLayout vkCreateDescriptorSetLayout = nullptr; // 14.2.1 + PFN_vkDestroyDescriptorSetLayout vkDestroyDescriptorSetLayout = nullptr; // 14.2.1 + PFN_vkCreatePipelineLayout vkCreatePipelineLayout = nullptr; // 14.2.2 + PFN_vkDestroyPipelineLayout vkDestroyPipelineLayout = nullptr; // 14.2.2 + PFN_vkCreateDescriptorPool vkCreateDescriptorPool = nullptr; // 14.2.3 + PFN_vkDestroyDescriptorPool vkDestroyDescriptorPool = nullptr; // 14.2.3 + PFN_vkAllocateDescriptorSets vkAllocateDescriptorSets = nullptr; // 14.2.3 + PFN_vkUpdateDescriptorSets vkUpdateDescriptorSets = nullptr; // 14.2.4 + PFN_vkCmdBindDescriptorSets vkCmdBindDescriptorSets = nullptr; // 14.2.7 + PFN_vkCmdPushConstants vkCmdPushConstants = nullptr; // 14.2.10 + PFN_vkCmdCopyBuffer vkCmdCopyBuffer = nullptr; // 19.2 + PFN_vkCmdCopyBufferToImage vkCmdCopyBufferToImage = nullptr; // 19.4 + PFN_vkCmdBlitImage vkCmdBlitImage = nullptr; // 19.5 + PFN_vkCmdBindIndexBuffer vkCmdBindIndexBuffer = nullptr; // 20.3 + PFN_vkCmdDrawIndexed vkCmdDrawIndexed = nullptr; // 20.3 + PFN_vkCmdBindVertexBuffers vkCmdBindVertexBuffers = nullptr; // 21.2 + PFN_vkCmdSetViewport vkCmdSetViewport = nullptr; // 24.5 + PFN_vkCmdSetScissor vkCmdSetScissor = nullptr; // 26.1 + PFN_vkCmdDispatch vkCmdDispatch = nullptr; // 28 + PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilities = nullptr; // 30.5.1 + PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormats = nullptr; // 30.5.2 + PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModes = nullptr; // 30.5.3 + PFN_vkCreateSwapchainKHR vkCreateSwapchain = nullptr; // 30.8 + PFN_vkDestroySwapchainKHR vkDestroySwapchain = nullptr; // 30.8 + PFN_vkGetSwapchainImagesKHR vkGetSwapchainImages = nullptr; // 30.8 + PFN_vkAcquireNextImageKHR vkAcquireNextImage = nullptr; // 30.8 + PFN_vkQueuePresentKHR vkQueuePresent = nullptr; // 30.8 + PFN_vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceFormatProperties = nullptr; // 39.2 + PFN_vkSetDebugUtilsObjectNameEXT vkSetDebugUtilsObjectName = nullptr; // 45.1.1 public: VulkanFunctions(const Graphics::VulkanContext &); @@ -185,13 +185,13 @@ public: // Chapter 6: Command Buffers Result CreateCommandPool(const VkCommandPoolCreateInfo &rCreateInfo, VkCommandPool &rCommandPool) const - { return { vkCreateCommandPool(device, &rCreateInfo, 0, handle_cast<::VkCommandPool *>(&rCommandPool)), "vkCreateCommandPool" }; } + { return { vkCreateCommandPool(device, &rCreateInfo, nullptr, handle_cast<::VkCommandPool *>(&rCommandPool)), "vkCreateCommandPool" }; } Result ResetCommandPool(VkCommandPool commandPool, VkCommandPoolResetFlags flags) const { return { vkResetCommandPool(device, handle_cast<::VkCommandPool>(commandPool), flags), "vkResetCommandPool" }; } void DestroyCommandPool(VkCommandPool commandPool) const - { vkDestroyCommandPool(device, handle_cast<::VkCommandPool>(commandPool), 0); } + { vkDestroyCommandPool(device, handle_cast<::VkCommandPool>(commandPool), nullptr); } Result AllocateCommandBuffers(const VkCommandBufferAllocateInfo &rAllocateInfo, VkCommandBuffer *pCommandBuffers) const { return { vkAllocateCommandBuffers(device, &rAllocateInfo, handle_cast<::VkCommandBuffer *>(pCommandBuffers)), "vkAllocateCommandBuffers" }; } @@ -210,10 +210,10 @@ public: // Chapter 7: Synchronization and Cache Control Result CreateFence(const VkFenceCreateInfo &rCreateInfo, VkFence &rFence) const - { return { vkCreateFence(device, &rCreateInfo, 0, handle_cast<::VkFence *>(&rFence)), "vkCreateFence" }; } + { return { vkCreateFence(device, &rCreateInfo, nullptr, handle_cast<::VkFence *>(&rFence)), "vkCreateFence" }; } void DestroyFence(VkFence fence) const - { vkDestroyFence(device, handle_cast<::VkFence>(fence), 0); } + { vkDestroyFence(device, handle_cast<::VkFence>(fence), nullptr); } Result GetFenceStatus(VkFence fence) const { return { vkGetFenceStatus(device, handle_cast<::VkFence>(fence)), "vkGetFenceStatus" }; } @@ -225,10 +225,10 @@ public: { return { vkWaitForFences(device, fenceCount, handle_cast(pFences), waitAll, timeout), "vkWaitForFences" }; } Result CreateSemaphore(const VkSemaphoreCreateInfo &rCreateInfo, VkSemaphore &rSemaphore) const - { return { vkCreateSemaphore(device, &rCreateInfo, 0, handle_cast<::VkSemaphore *>(&rSemaphore)), "vkCreateSemaphore" }; } + { return { vkCreateSemaphore(device, &rCreateInfo, nullptr, handle_cast<::VkSemaphore *>(&rSemaphore)), "vkCreateSemaphore" }; } void DestroySemaphore(VkSemaphore semaphore) const - { vkDestroySemaphore(device, handle_cast<::VkSemaphore>(semaphore), 0); } + { vkDestroySemaphore(device, handle_cast<::VkSemaphore>(semaphore), nullptr); } void CmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier *pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier *pImageMemoryBarriers) const { vkCmdPipelineBarrier(handle_cast<::VkCommandBuffer>(commandBuffer), srcStageMask, dstStageMask, dependencyFlags, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers); } @@ -238,19 +238,19 @@ public: // Chapter 8: Render Pass Result CreateRenderPass(const VkRenderPassCreateInfo &rCreateInfo, VkRenderPass &rRenderPass) const - { return { vkCreateRenderPass(device, &rCreateInfo, 0, handle_cast<::VkRenderPass *>(&rRenderPass)), "vkCreateRenderPass" }; } + { return { vkCreateRenderPass(device, &rCreateInfo, nullptr, handle_cast<::VkRenderPass *>(&rRenderPass)), "vkCreateRenderPass" }; } Result CreateRenderPass2(const VkRenderPassCreateInfo2 &rCreateInfo, VkRenderPass &rRenderPass) const - { return { vkCreateRenderPass2(device, &rCreateInfo, 0, handle_cast<::VkRenderPass *>(&rRenderPass)), "vkCreateRenderPass2" }; } + { return { vkCreateRenderPass2(device, &rCreateInfo, nullptr, handle_cast<::VkRenderPass *>(&rRenderPass)), "vkCreateRenderPass2" }; } void DestroyRenderPass(VkRenderPass renderPass) const - { vkDestroyRenderPass(device, handle_cast<::VkRenderPass>(renderPass), 0); } + { vkDestroyRenderPass(device, handle_cast<::VkRenderPass>(renderPass), nullptr); } Result CreateFramebuffer(const VkFramebufferCreateInfo &rCreateInfo, VkFramebuffer &rFramebuffer) const - { return { vkCreateFramebuffer(device, &rCreateInfo, 0, handle_cast<::VkFramebuffer *>(&rFramebuffer)), "vkCreateFramebuffer" }; } + { return { vkCreateFramebuffer(device, &rCreateInfo, nullptr, handle_cast<::VkFramebuffer *>(&rFramebuffer)), "vkCreateFramebuffer" }; } void DestroyFramebuffer(VkFramebuffer framebuffer) const - { vkDestroyFramebuffer(device, handle_cast<::VkFramebuffer>(framebuffer), 0); } + { vkDestroyFramebuffer(device, handle_cast<::VkFramebuffer>(framebuffer), nullptr); } void CmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo &rRenderPassBegin, VkSubpassContents contents) const { vkCmdBeginRenderPass(handle_cast<::VkCommandBuffer>(commandBuffer), &rRenderPassBegin, contents); } @@ -260,20 +260,20 @@ public: // Chapter 9: Shaders Result CreateShaderModule(const VkShaderModuleCreateInfo &rCreateInfo, VkShaderModule &rShaderModule) const - { return { vkCreateShaderModule(device, &rCreateInfo, 0, handle_cast<::VkShaderModule *>(&rShaderModule)), "vkCreateShaderModule" }; } + { return { vkCreateShaderModule(device, &rCreateInfo, nullptr, handle_cast<::VkShaderModule *>(&rShaderModule)), "vkCreateShaderModule" }; } void DestroyShaderModule(VkShaderModule shaderModule) const - { vkDestroyShaderModule(device, handle_cast<::VkShaderModule>(shaderModule), 0); } + { vkDestroyShaderModule(device, handle_cast<::VkShaderModule>(shaderModule), nullptr); } // Chapter 10: Pipelines Result CreateComputePipelines(VkPipelineCache pipelineCache, std::uint32_t createInfoCount, const VkComputePipelineCreateInfo *pCreateInfos, VkPipeline *pPipelines) const - { return { vkCreateComputePipelines(device, handle_cast<::VkPipelineCache>(pipelineCache), createInfoCount, pCreateInfos, 0, handle_cast<::VkPipeline *>(pPipelines)), "vkCreateComputePipelines" }; } + { return { vkCreateComputePipelines(device, handle_cast<::VkPipelineCache>(pipelineCache), createInfoCount, pCreateInfos, nullptr, handle_cast<::VkPipeline *>(pPipelines)), "vkCreateComputePipelines" }; } Result CreateGraphicsPipelines(VkPipelineCache pipelineCache, std::uint32_t createInfoCount, const VkGraphicsPipelineCreateInfo *pCreateInfos, VkPipeline *pPipelines) const - { return { vkCreateGraphicsPipelines(device, handle_cast<::VkPipelineCache>(pipelineCache), createInfoCount, pCreateInfos, 0, handle_cast<::VkPipeline *>(pPipelines)), "vkCreateGraphicsPipelines" }; } + { return { vkCreateGraphicsPipelines(device, handle_cast<::VkPipelineCache>(pipelineCache), createInfoCount, pCreateInfos, nullptr, handle_cast<::VkPipeline *>(pPipelines)), "vkCreateGraphicsPipelines" }; } void DestroyPipeline(VkPipeline pipeline) const - { vkDestroyPipeline(device, handle_cast<::VkPipeline>(pipeline), 0); } + { vkDestroyPipeline(device, handle_cast<::VkPipeline>(pipeline), nullptr); } void CmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) const { vkCmdBindPipeline(handle_cast<::VkCommandBuffer>(commandBuffer), pipelineBindPoint, handle_cast<::VkPipeline>(pipeline)); } @@ -283,7 +283,7 @@ public: { vkGetPhysicalDeviceMemoryProperties(physicalDevice, &rMemoryProperties); } Result AllocateMemory(const VkMemoryAllocateInfo &rAllocateInfo, VkDeviceMemory &rMemory) const - { return { vkAllocateMemory(device, &rAllocateInfo, 0, handle_cast<::VkDeviceMemory *>(&rMemory)), "vkAllocateMemory" }; } + { return { vkAllocateMemory(device, &rAllocateInfo, nullptr, handle_cast<::VkDeviceMemory *>(&rMemory)), "vkAllocateMemory" }; } Result MapMemory(VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void **ppData) const { return { vkMapMemory(device, handle_cast<::VkDeviceMemory>(memory), offset, size, flags, ppData), "vkMapMemory" }; } @@ -292,26 +292,26 @@ public: { vkUnmapMemory(device, handle_cast<::VkDeviceMemory>(memory)); } void FreeMemory(VkDeviceMemory memory) const - { vkFreeMemory(device, handle_cast<::VkDeviceMemory>(memory), 0); } + { vkFreeMemory(device, handle_cast<::VkDeviceMemory>(memory), nullptr); } // Chapter 12: Resource Creation Result CreateBuffer(const VkBufferCreateInfo &rCreateInfo, VkBuffer &rBuffer) const - { return { vkCreateBuffer(device, &rCreateInfo, 0, handle_cast<::VkBuffer *>(&rBuffer)), "vkCreateBuffer" }; } + { return { vkCreateBuffer(device, &rCreateInfo, nullptr, handle_cast<::VkBuffer *>(&rBuffer)), "vkCreateBuffer" }; } void DestroyBuffer(VkBuffer image) const - { vkDestroyBuffer(device, handle_cast<::VkBuffer>(image), 0); } + { vkDestroyBuffer(device, handle_cast<::VkBuffer>(image), nullptr); } Result CreateImage(const VkImageCreateInfo &rCreateInfo, VkImage &rImage) const - { return { vkCreateImage(device, &rCreateInfo, 0, handle_cast<::VkImage *>(&rImage)), "vkCreateImage" }; } + { return { vkCreateImage(device, &rCreateInfo, nullptr, handle_cast<::VkImage *>(&rImage)), "vkCreateImage" }; } void DestroyImage(VkImage image) const - { vkDestroyImage(device, handle_cast<::VkImage>(image), 0); } + { vkDestroyImage(device, handle_cast<::VkImage>(image), nullptr); } Result CreateImageView(const VkImageViewCreateInfo &rCreateInfo, VkImageView &rView) const - { return { vkCreateImageView(device, &rCreateInfo, 0, handle_cast<::VkImageView *>(&rView)), "vkCreateImageView" }; } + { return { vkCreateImageView(device, &rCreateInfo, nullptr, handle_cast<::VkImageView *>(&rView)), "vkCreateImageView" }; } void DestroyImageView(VkImageView imageView) const - { vkDestroyImageView(device, handle_cast<::VkImageView>(imageView), 0); } + { vkDestroyImageView(device, handle_cast<::VkImageView>(imageView), nullptr); } void GetBufferMemoryRequirements(VkBuffer image, VkMemoryRequirements &rMemoryRequirements) const { vkGetBufferMemoryRequirements(device, handle_cast<::VkBuffer>(image), &rMemoryRequirements); } @@ -327,29 +327,29 @@ public: // Chapter 13: Samplers Result CreateSampler(const VkSamplerCreateInfo &rCreateInfo, VkSampler &rSampler) const - { return { vkCreateSampler(device, &rCreateInfo, 0, handle_cast<::VkSampler *>(&rSampler)), "vkCreateSampler" }; } + { return { vkCreateSampler(device, &rCreateInfo, nullptr, handle_cast<::VkSampler *>(&rSampler)), "vkCreateSampler" }; } void DestroySampler(VkSampler sampler) const - { vkDestroySampler(device, handle_cast<::VkSampler>(sampler), 0); } + { vkDestroySampler(device, handle_cast<::VkSampler>(sampler), nullptr); } // Chapter 14: Resource Descriptors Result CreateDescriptorSetLayout(const VkDescriptorSetLayoutCreateInfo &rCreateInfo, VkDescriptorSetLayout &rSetLayout) const - { return { vkCreateDescriptorSetLayout(device, &rCreateInfo, 0, handle_cast<::VkDescriptorSetLayout *>(&rSetLayout)), "vkCreateDescriptorSetLayout" }; } + { return { vkCreateDescriptorSetLayout(device, &rCreateInfo, nullptr, handle_cast<::VkDescriptorSetLayout *>(&rSetLayout)), "vkCreateDescriptorSetLayout" }; } void DestroyDescriptorSetLayout(VkDescriptorSetLayout descriptorSetLayout) const - { vkDestroyDescriptorSetLayout(device, handle_cast<::VkDescriptorSetLayout>(descriptorSetLayout), 0); } + { vkDestroyDescriptorSetLayout(device, handle_cast<::VkDescriptorSetLayout>(descriptorSetLayout), nullptr); } Result CreatePipelineLayout(const VkPipelineLayoutCreateInfo &rCreateInfo, VkPipelineLayout &rPipelineLayout) const - { return { vkCreatePipelineLayout(device, &rCreateInfo, 0, handle_cast<::VkPipelineLayout *>(&rPipelineLayout)), "vkCreatePipelineLayout" }; } + { return { vkCreatePipelineLayout(device, &rCreateInfo, nullptr, handle_cast<::VkPipelineLayout *>(&rPipelineLayout)), "vkCreatePipelineLayout" }; } void DestroyPipelineLayout(VkPipelineLayout pipelineLayout) const - { vkDestroyPipelineLayout(device, handle_cast<::VkPipelineLayout>(pipelineLayout), 0); } + { vkDestroyPipelineLayout(device, handle_cast<::VkPipelineLayout>(pipelineLayout), nullptr); } Result CreateDescriptorPool(const VkDescriptorPoolCreateInfo &rCreateInfo, VkDescriptorPool &rDescriptorPool) const - { return { vkCreateDescriptorPool(device, &rCreateInfo, 0, handle_cast<::VkDescriptorPool *>(&rDescriptorPool)), "vkCreateDescriptorPool" }; } + { return { vkCreateDescriptorPool(device, &rCreateInfo, nullptr, handle_cast<::VkDescriptorPool *>(&rDescriptorPool)), "vkCreateDescriptorPool" }; } void DestroyDescriptorPool(VkDescriptorPool descriptorPool) const - { vkDestroyDescriptorPool(device, handle_cast<::VkDescriptorPool>(descriptorPool), 0); } + { vkDestroyDescriptorPool(device, handle_cast<::VkDescriptorPool>(descriptorPool), nullptr); } Result AllocateDescriptorSets(const VkDescriptorSetAllocateInfo &rAllocateInfo, VkDescriptorSet *pDescriptorSets) const { return { vkAllocateDescriptorSets(device, &rAllocateInfo, handle_cast<::VkDescriptorSet *>(pDescriptorSets)), "vkAllocateDescriptorSets" }; } @@ -407,10 +407,10 @@ public: { return { vkGetPhysicalDeviceSurfacePresentModes(physicalDevice, handle_cast<::VkSurfaceKHR>(surface), &rPresentModeCount, pPresentModes), "vkGetPhysicalDeviceSurfacePresentModes" }; } Result CreateSwapchain(const VkSwapchainCreateInfoKHR &rCreateInfo, VkSwapchain &rSwapchain) const - { return { vkCreateSwapchain(device, &rCreateInfo, 0, handle_cast<::VkSwapchainKHR *>(&rSwapchain)), "vkCreateSwapchain" }; } + { return { vkCreateSwapchain(device, &rCreateInfo, nullptr, handle_cast<::VkSwapchainKHR *>(&rSwapchain)), "vkCreateSwapchain" }; } void DestroySwapchain(VkSwapchain swapchain) const - { vkDestroySwapchain(device, handle_cast<::VkSwapchainKHR>(swapchain), 0); } + { vkDestroySwapchain(device, handle_cast<::VkSwapchainKHR>(swapchain), nullptr); } void GetSwapchainImages(VkSwapchain swapchain, std::uint32_t &rSwapchainImageCount, VkImage *pSwapchainImages) const { vkGetSwapchainImages(device, handle_cast<::VkSwapchainKHR>(swapchain), &rSwapchainImageCount, handle_cast<::VkImage *>(pSwapchainImages)); } diff --git a/source/backends/vulkan/windowview_backend.h b/source/backends/vulkan/windowview_backend.h index f2658c27..9ca2cbba 100644 --- a/source/backends/vulkan/windowview_backend.h +++ b/source/backends/vulkan/windowview_backend.h @@ -14,9 +14,9 @@ namespace GL { class MSPGL_API VulkanWindowView: public View { protected: - SwapChain *swap_chain = 0; + SwapChain *swap_chain = nullptr; std::vector framebuffers; - Framebuffer *current_target = 0; + Framebuffer *current_target = nullptr; Semaphore semaphores[MAX_FRAMES_IN_FLIGHT*2]; unsigned frame_index = 0; diff --git a/source/builders/font.h b/source/builders/font.h index 26af2cbb..fb51b2b0 100644 --- a/source/builders/font.h +++ b/source/builders/font.h @@ -60,7 +60,7 @@ private: typedef std::map KerningMap; typedef std::map LigatureMap; - const Texture2D *texture = 0; + const Texture2D *texture = nullptr; float native_size = 1.0f; float ascent = 1.0f; float descent = 0.0f; diff --git a/source/builders/meshbuilder.cpp b/source/builders/meshbuilder.cpp index 79770725..395827a4 100644 --- a/source/builders/meshbuilder.cpp +++ b/source/builders/meshbuilder.cpp @@ -9,7 +9,7 @@ namespace GL { MeshBuilder::MeshBuilder(Mesh &m): PrimitiveBuilder(m.vertices), mesh(m), - batch(0) + batch(nullptr) { } MeshBuilder::~MeshBuilder() @@ -31,7 +31,7 @@ void MeshBuilder::end_() { mesh.add_batch(move(*batch)); delete batch; - batch = 0; + batch = nullptr; } void MeshBuilder::element_(unsigned i) diff --git a/source/builders/sequencebuilder.cpp b/source/builders/sequencebuilder.cpp index 4a2c6f63..4947e252 100644 --- a/source/builders/sequencebuilder.cpp +++ b/source/builders/sequencebuilder.cpp @@ -20,7 +20,7 @@ SequenceBuilder::SequenceBuilder(const SequenceTemplate &t): renderables[r.slot_name] = r.renderable; for(const SequenceTemplate::PostProcessor &p: tmpl.get_postprocessors()) if(!p.slot_name.empty()) - postprocessors[p.slot_name] = 0; + postprocessors[p.slot_name] = nullptr; } void SequenceBuilder::set_renderable(const string &name, Renderable &rend) @@ -114,7 +114,7 @@ void SequenceBuilder::build(Sequence &sequence) const #endif for(const SequenceTemplate::PostProcessor &p: tmpl.get_postprocessors()) { - PostProcessor *proc = 0; + PostProcessor *proc = nullptr; if(!p.slot_name.empty()) proc = get_item(postprocessors, p.slot_name); if(!proc) diff --git a/source/builders/sequencetemplate.h b/source/builders/sequencetemplate.h index a1d841e8..12b4f717 100644 --- a/source/builders/sequencetemplate.h +++ b/source/builders/sequencetemplate.h @@ -63,9 +63,9 @@ public: struct Renderable { - Effect::Template *effect_template = 0; - GL::Renderable *renderable = 0; - SequenceTemplate *sequence_template = 0; + Effect::Template *effect_template = nullptr; + GL::Renderable *renderable = nullptr; + SequenceTemplate *sequence_template = nullptr; std::map sequence_renderables; std::string slot_name; }; @@ -96,7 +96,7 @@ public: }; std::string tag; - const Lighting *lighting = 0; + const Lighting *lighting = nullptr; DepthTest depth_test; StencilTest stencil_test; std::string renderable_name; @@ -107,7 +107,7 @@ public: GL::PostProcessor::Template *postprocessor_template; std::string slot_name; - PostProcessor(GL::PostProcessor::Template * = 0); + PostProcessor(GL::PostProcessor::Template * = nullptr); }; private: diff --git a/source/core/buffer.cpp b/source/core/buffer.cpp index 36ac440a..ae72f78c 100644 --- a/source/core/buffer.cpp +++ b/source/core/buffer.cpp @@ -79,7 +79,7 @@ Buffer::AsyncTransfer::AsyncTransfer(Buffer &b, size_t o, size_t s): buffer(&b), offset(o), size(s), - dest_addr(0) + dest_addr(nullptr) { allocate(); } @@ -90,7 +90,7 @@ Buffer::AsyncTransfer::AsyncTransfer(AsyncTransfer &&other): size(other.size), dest_addr(other.dest_addr) { - other.dest_addr = 0; + other.dest_addr = nullptr; } Buffer::AsyncTransfer &Buffer::AsyncTransfer::operator=(AsyncTransfer &&other) @@ -103,7 +103,7 @@ Buffer::AsyncTransfer &Buffer::AsyncTransfer::operator=(AsyncTransfer &&other) size = other.size; dest_addr = other.dest_addr; - other.dest_addr = 0; + other.dest_addr = nullptr; return *this; } diff --git a/source/core/buffer.h b/source/core/buffer.h index 7dde1ac3..f7bbf82e 100644 --- a/source/core/buffer.h +++ b/source/core/buffer.h @@ -48,10 +48,10 @@ public: friend class Buffer; private: - Buffer *buffer = 0; + Buffer *buffer = nullptr; std::size_t offset = 0; std::size_t size = 0; - void *dest_addr = 0; + void *dest_addr = nullptr; AsyncTransfer(Buffer &, std::size_t, std::size_t); public: diff --git a/source/core/bufferable.cpp b/source/core/bufferable.cpp index d8f3c9c4..0cfd04c6 100644 --- a/source/core/bufferable.cpp +++ b/source/core/bufferable.cpp @@ -15,9 +15,9 @@ Bufferable::Bufferable(Bufferable &&other): location_dirty(other.location_dirty), dirty(other.dirty) { - other.buffer = 0; - other.next_in_buffer = 0; - other.prev_in_buffer = 0; + other.buffer = nullptr; + other.next_in_buffer = nullptr; + other.prev_in_buffer = nullptr; if(next_in_buffer) next_in_buffer->prev_in_buffer = this; if(prev_in_buffer) @@ -94,9 +94,9 @@ void Bufferable::unlink_from_buffer() next_in_buffer->prev_in_buffer = prev_in_buffer; next_in_buffer->update_offset(); } - prev_in_buffer = 0; - next_in_buffer = 0; - buffer = 0; + prev_in_buffer = nullptr; + next_in_buffer = nullptr; + buffer = nullptr; offset = 0; } diff --git a/source/core/bufferable.h b/source/core/bufferable.h index b3ebcdd7..3504972d 100644 --- a/source/core/bufferable.h +++ b/source/core/bufferable.h @@ -37,10 +37,10 @@ public: }; private: - Buffer *buffer = 0; + Buffer *buffer = nullptr; std::size_t offset = 0; - Bufferable *next_in_buffer = 0; - Bufferable *prev_in_buffer = 0; + Bufferable *next_in_buffer = nullptr; + Bufferable *prev_in_buffer = nullptr; mutable bool location_dirty = false; mutable uint8_t dirty = 0; @@ -54,7 +54,7 @@ public: buffer, and this object is inserted after it. Data is not uploaded immediately, but only when refresh() is called. */ - void use_buffer(Buffer *, Bufferable *prev = 0); + void use_buffer(Buffer *, Bufferable *prev = nullptr); /** Sets the buffer for the entire chain of objects. */ void change_buffer(Buffer *); @@ -64,11 +64,11 @@ public: std::size_t get_required_buffer_size(bool = false) const; /** Uploads new data into the buffer if necessary. */ - void refresh(unsigned f) const { if(dirty) upload_data(f, 0); } + void refresh(unsigned f) const { if(dirty) upload_data(f, nullptr); } /** Returns an object which can be used to upload data to the buffer using mapped memory. If data is not dirty, returns null. */ - AsyncUpdater *refresh_async() const { return dirty ? create_async_updater() : 0; } + AsyncUpdater *refresh_async() const { return dirty ? create_async_updater() : nullptr; } private: void unlink_from_buffer(); diff --git a/source/core/device.cpp b/source/core/device.cpp index 3186015c..26be8952 100644 --- a/source/core/device.cpp +++ b/source/core/device.cpp @@ -4,7 +4,7 @@ namespace Msp { namespace GL { -Device *Device::current = 0; +Device *Device::current = nullptr; Device::Device(Graphics::Window &w): Device(w, create_default_options()) @@ -22,7 +22,7 @@ Device::Device(Graphics::Window &w, const DeviceOptions &o): Device::~Device() { if(this==current) - current = 0; + current = nullptr; } Device &Device::get_current() diff --git a/source/core/framebuffer.cpp b/source/core/framebuffer.cpp index 4f30dbb1..4e868082 100644 --- a/source/core/framebuffer.cpp +++ b/source/core/framebuffer.cpp @@ -127,7 +127,7 @@ void Framebuffer::set_attachment(FrameAttachment attch, Texture &tex, Texture *r void Framebuffer::attach(FrameAttachment attch, Texture2D &tex, unsigned level) { - set_attachment(make_typed_attachment(attch, tex.get_format()), tex, 0, level, 0, 0); + set_attachment(make_typed_attachment(attch, tex.get_format()), tex, nullptr, level, 0, 0); } void Framebuffer::attach(FrameAttachment attch, Texture2DMultisample &tex, Texture2D *res) @@ -137,24 +137,24 @@ void Framebuffer::attach(FrameAttachment attch, Texture2DMultisample &tex, Textu void Framebuffer::attach(FrameAttachment attch, Texture3D &tex, unsigned layer, unsigned level) { - set_attachment(make_typed_attachment(attch, tex.get_format()), tex, 0, level, layer, 0); + set_attachment(make_typed_attachment(attch, tex.get_format()), tex, nullptr, level, layer, 0); } void Framebuffer::attach(FrameAttachment attch, TextureCube &tex, TextureCubeFace face, unsigned level) { - set_attachment(make_typed_attachment(attch, tex.get_format()), tex, 0, level, face, 0); + set_attachment(make_typed_attachment(attch, tex.get_format()), tex, nullptr, level, face, 0); } void Framebuffer::attach_layered(FrameAttachment attch, Texture3D &tex, unsigned level) { require_layered(); - set_attachment(make_typed_attachment(attch, tex.get_format()), tex, 0, level, -1, 0); + set_attachment(make_typed_attachment(attch, tex.get_format()), tex, nullptr, level, -1, 0); } void Framebuffer::attach_layered(FrameAttachment attch, TextureCube &tex, unsigned level) { require_layered(); - set_attachment(make_typed_attachment(attch, tex.get_format()), tex, 0, level, -1, 0); + set_attachment(make_typed_attachment(attch, tex.get_format()), tex, nullptr, level, -1, 0); } void Framebuffer::detach(FrameAttachment attch) @@ -174,29 +174,29 @@ void Framebuffer::detach(FrameAttachment attch) const Texture *Framebuffer::get_attachment(FrameAttachment attch) const { if(attachments.empty()) - return 0; + return nullptr; int i = format.index(attch); - return (i>=0 ? attachments[i].tex : 0); + return (i>=0 ? attachments[i].tex : nullptr); } const Texture *Framebuffer::get_attachment(unsigned i) const { - return (i=0 ? attachments[i].resolve : 0); + return (i>=0 ? attachments[i].resolve : nullptr); } const Texture *Framebuffer::get_resolve_attachment(unsigned i) const { - return (iuse_buffer(0); + (--i)->use_buffer(nullptr); } Batch *prev = &batches.back(); batches.emplace_back(move(b)); if(reallocate) { - prev = 0; + prev = nullptr; for(Batch &a: batches) { a.use_buffer(ibuf, prev); @@ -167,7 +167,7 @@ void Mesh::set_winding(FaceWinding w) void Mesh::draw(Renderer &renderer) const { - draw(renderer, 0, 0); + draw(renderer, nullptr, 0); } void Mesh::draw_instanced(Renderer &renderer, const VertexSetup &vs, unsigned count) const @@ -235,13 +235,13 @@ uint64_t Mesh::get_data_size() const void Mesh::unload() { vertices.clear(); - vertices.use_buffer(0); + vertices.use_buffer(nullptr); batches.clear(); vtx_setup.unload(); delete vbuf; delete ibuf; - vbuf = 0; - ibuf = 0; + vbuf = nullptr; + ibuf = nullptr; } void Mesh::set_debug_name(const string &name) @@ -348,9 +348,9 @@ bool Mesh::AsyncLoader::process() else if(phase==3) { delete vertex_updater; - vertex_updater = 0; + vertex_updater = nullptr; delete index_updater; - index_updater = 0; + index_updater = nullptr; } ++phase; diff --git a/source/core/mesh.h b/source/core/mesh.h index 717f7f93..70f3ba43 100644 --- a/source/core/mesh.h +++ b/source/core/mesh.h @@ -53,8 +53,8 @@ private: private: Mesh &mesh; IO::Seekable &io; - Bufferable::AsyncUpdater *vertex_updater = 0; - Bufferable::AsyncUpdater *index_updater = 0; + Bufferable::AsyncUpdater *vertex_updater = nullptr; + Bufferable::AsyncUpdater *index_updater = nullptr; unsigned phase = 0; public: @@ -73,8 +73,8 @@ private: VertexArray vertices; std::vector batches; - Buffer *vbuf = 0; - Buffer *ibuf = 0; + Buffer *vbuf = nullptr; + Buffer *ibuf = nullptr; VertexSetup vtx_setup; mutable unsigned short dirty = 0; bool disallow_rendering = false; @@ -125,7 +125,7 @@ private: public: virtual int get_load_priority() const { return 1; } - virtual Resource::AsyncLoader *load(IO::Seekable &, const Resources * = 0); + virtual Resource::AsyncLoader *load(IO::Seekable &, const Resources * = nullptr); virtual std::uint64_t get_data_size() const; virtual void unload(); diff --git a/source/core/module.cpp b/source/core/module.cpp index 04a37fcc..e987c165 100644 --- a/source/core/module.cpp +++ b/source/core/module.cpp @@ -81,7 +81,7 @@ void Module::load_source(IO::Base &io, Resources *res, const string &name) void Module::load_source(IO::Base &io, const string &name) { - load_source(io, 0, name); + load_source(io, nullptr, name); } SL::Features Module::create_features() const @@ -176,7 +176,7 @@ void SpirVModule::reflect() if(m.struct_type) { auto i = struct_indices.find(m.struct_type); - m.struct_type = (i!=struct_indices.end() ? &structs[i->second] : 0); + m.struct_type = (i!=struct_indices.end() ? &structs[i->second] : nullptr); } const StructMember *last_member = &s.members.back(); @@ -215,7 +215,7 @@ void SpirVModule::reflect() if(v.struct_type) { auto i = struct_indices.find(v.struct_type); - v.struct_type = (i!=struct_indices.end() ? &structs[i->second] : 0); + v.struct_type = (i!=struct_indices.end() ? &structs[i->second] : nullptr); } entry_points.reserve(reflection.entry_points.size()); @@ -226,7 +226,7 @@ void SpirVModule::reflect() for(const Variable *&v: entry.globals) { auto i = var_indices.find(v); - v = (i!=var_indices.end() ? &variables[i->second] : 0); + v = (i!=var_indices.end() ? &variables[i->second] : nullptr); } } @@ -241,20 +241,20 @@ void SpirVModule::reflect() for(InstructionBlock &b: blocks) { auto i = spec_indices.find(b.condition); - b.condition = (i!=spec_indices.end() ? &spec_constants[i->second] : 0); + b.condition = (i!=spec_indices.end() ? &spec_constants[i->second] : nullptr); if(b.condition) specializable = true; for(const Variable *&v: b.accessed_variables) { auto j = var_indices.find(v); - v = (j!=var_indices.end() ? &variables[j->second] : 0); + v = (j!=var_indices.end() ? &variables[j->second] : nullptr); } for(const InstructionBlock *&s: b.successors) { auto j = block_indices.find(s); - s = (j!=block_indices.end() ? &blocks[j->second] : 0); + s = (j!=block_indices.end() ? &blocks[j->second] : nullptr); } } } diff --git a/source/core/module.h b/source/core/module.h index 09d94076..9e313632 100644 --- a/source/core/module.h +++ b/source/core/module.h @@ -145,7 +145,7 @@ public: { std::string name; DataType type = VOID; - const Structure *struct_type = 0; + const Structure *struct_type = nullptr; unsigned offset = 0; unsigned array_size = 0; unsigned array_stride = 0; @@ -166,7 +166,7 @@ public: std::string name; unsigned id = 0; DataType type = VOID; - const Structure *struct_type = 0; + const Structure *struct_type = nullptr; StorageClass storage = static_cast(-1); unsigned array_size = 0; int location = -1; @@ -194,7 +194,7 @@ public: { unsigned id = 0; bool negate_condition = false; - const Constant *condition = 0; + const Constant *condition = nullptr; std::vector accessed_variables; std::vector successors; }; @@ -203,7 +203,7 @@ private: struct TypeInfo { DataType type = VOID; - const Structure *struct_type = 0; + const Structure *struct_type = nullptr; unsigned array_size = 0; unsigned array_stride = 0; StorageClass storage = static_cast(-1); @@ -222,7 +222,7 @@ private: std::map blocks; std::map access_chain_bases; Constant true_condition; - InstructionBlock *current_block = 0; + InstructionBlock *current_block = nullptr; static std::uint32_t get_opcode(std::uint32_t); static CodeIterator get_op_end(const CodeIterator &); diff --git a/source/core/pipelinestate.cpp b/source/core/pipelinestate.cpp index fa6784f1..719be0c1 100644 --- a/source/core/pipelinestate.cpp +++ b/source/core/pipelinestate.cpp @@ -13,19 +13,19 @@ namespace GL { void PipelineState::reset() { - set(framebuffer, static_cast(0), FRAMEBUFFER); + set(framebuffer, static_cast(nullptr), FRAMEBUFFER); set(viewport, Rect::max(), VIEWPORT); set(scissor, Rect::max(), SCISSOR); - set(shprog, static_cast(0), SHPROG); + set(shprog, static_cast(nullptr), SHPROG); for(BoundResource &r: resources) { r.changed = (r.type!=NO_RESOURCE); r.type = NO_RESOURCE; r.used = false; - r.block = 0; - r.buffer = 0; + r.block = nullptr; + r.buffer = nullptr; } - set(vertex_setup, static_cast(0), VERTEX_SETUP); + set(vertex_setup, static_cast(nullptr), VERTEX_SETUP); set(primitive_type, TRIANGLES, PRIMITIVE_TYPE); set(patch_size, 0U, PATCH_SIZE); set(front_face, COUNTERCLOCKWISE, FACE_CULL); @@ -72,7 +72,7 @@ void PipelineState::set_uniform_block(int binding, const UniformBlock *block) i = resources.insert(i, BoundResource(binding)); ResourceType type = (block ? UNIFORM_BLOCK : NO_RESOURCE); - const Buffer *buffer = (block ? block->get_buffer() : 0); + const Buffer *buffer = (block ? block->get_buffer() : nullptr); if(i->type!=type || block!=i->block || buffer!=i->buffer || binding<0) { i->type = type; @@ -86,7 +86,7 @@ void PipelineState::set_uniform_block(int binding, const UniformBlock *block) void PipelineState::set_storage_block(unsigned binding, const Buffer *buffer) { - set_buffer_resource(binding, 0, buffer); + set_buffer_resource(binding, nullptr, buffer); } void PipelineState::set_texture(unsigned binding, const Texture *tex, const Sampler *samp) @@ -96,7 +96,7 @@ void PipelineState::set_texture(unsigned binding, const Texture *tex, const Samp void PipelineState::set_texture(unsigned binding, const Texture *tex, int level, const Sampler *samp) { - if((tex!=0)!=(samp!=0)) + if((tex!=nullptr)!=(samp!=nullptr)) throw invalid_argument("PipelineState::set_texture"); if(level>=0 && !can_bind_tex_level(level)) throw invalid_operation("PipelineState::set_texture"); @@ -106,7 +106,7 @@ void PipelineState::set_texture(unsigned binding, const Texture *tex, int level, void PipelineState::set_storage_texture(unsigned binding, const Texture *tex) { - set_texture_resource(binding, tex, 0, 0); + set_texture_resource(binding, tex, 0, nullptr); } void PipelineState::set_buffer_resource(unsigned binding, const UniformBlock *block, const Buffer *buffer) diff --git a/source/core/pipelinestate.h b/source/core/pipelinestate.h index eec44084..0c0969a4 100644 --- a/source/core/pipelinestate.h +++ b/source/core/pipelinestate.h @@ -60,7 +60,7 @@ private: }; int mip_level = -1; - BoundResource(int b): binding(b), texture(0), sampler(0) { } + BoundResource(int b): binding(b), texture(nullptr), sampler(nullptr) { } }; enum ChangeMask @@ -79,12 +79,12 @@ private: PATCH_SIZE = 4096 }; - const Framebuffer *framebuffer = 0; + const Framebuffer *framebuffer = nullptr; Rect viewport = Rect::max(); Rect scissor = Rect::max(); - const Program *shprog = 0; + const Program *shprog = nullptr; std::vector resources; - const VertexSetup *vertex_setup = 0; + const VertexSetup *vertex_setup = nullptr; PrimitiveType primitive_type = TRIANGLES; unsigned patch_size = 0; FaceWinding front_face = COUNTERCLOCKWISE; diff --git a/source/core/program.cpp b/source/core/program.cpp index bbc420f8..3c0022ad 100644 --- a/source/core/program.cpp +++ b/source/core/program.cpp @@ -17,7 +17,7 @@ Program::Program(Program &&other): reflect_data(move(other.reflect_data)), specialized_spirv(other.specialized_spirv) { - other.specialized_spirv = 0; + other.specialized_spirv = nullptr; } Program::~Program() diff --git a/source/core/program.h b/source/core/program.h index 0f47cb4b..892729f0 100644 --- a/source/core/program.h +++ b/source/core/program.h @@ -51,7 +51,7 @@ private: }; ReflectData reflect_data; - SpirVModule *specialized_spirv = 0; + SpirVModule *specialized_spirv = nullptr; public: /// Constructs an empty Program with no shader stages attached. diff --git a/source/core/reflectdata.h b/source/core/reflectdata.h index 5b913c40..4b0cbd2c 100644 --- a/source/core/reflectdata.h +++ b/source/core/reflectdata.h @@ -28,7 +28,7 @@ struct ReflectData struct UniformInfo { std::string name; - const BlockInfo *block = 0; + const BlockInfo *block = nullptr; union { int location = -1; diff --git a/source/core/texture.cpp b/source/core/texture.cpp index a65715e7..407333e1 100644 --- a/source/core/texture.cpp +++ b/source/core/texture.cpp @@ -162,7 +162,7 @@ void Texture::Loader::generate_mipmap(bool gm) void Texture::Loader::image_data(const string &data) { if(obj.manager) - obj.set_manager(0); + obj.set_manager(nullptr); Graphics::Image img; IO::Memory mem(data.data(), data.size()); @@ -179,7 +179,7 @@ void Texture::Loader::mipmap_levels(unsigned l) void Texture::Loader::raw_data(const string &data) { if(obj.manager) - obj.set_manager(0); + obj.set_manager(nullptr); obj.image(0, data.data()); } diff --git a/source/core/texture.h b/source/core/texture.h index 6a9f6255..106c478f 100644 --- a/source/core/texture.h +++ b/source/core/texture.h @@ -38,7 +38,7 @@ protected: unsigned levels; public: - Loader(Texture &t): Loader(t, 0) { } + Loader(Texture &t): Loader(t, nullptr) { } Loader(Texture &t, Collection &c): Loader(t, &c) { } private: Loader(Texture &, Collection *); diff --git a/source/core/texture2d.cpp b/source/core/texture2d.cpp index e38c99de..4457dc0a 100644 --- a/source/core/texture2d.cpp +++ b/source/core/texture2d.cpp @@ -15,8 +15,8 @@ private: IO::Seekable &io; Texture2D::AsyncTransfer transfer; Graphics::Image image; - Graphics::ImageLoader *img_loader = 0; - DataFile::RawData *raw_data = 0; + Graphics::ImageLoader *img_loader = nullptr; + DataFile::RawData *raw_data = nullptr; unsigned n_bytes = 0; int phase = 0; @@ -31,7 +31,7 @@ public: Texture2D::~Texture2D() { - set_manager(0); + set_manager(nullptr); } void Texture2D::storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned lv) @@ -138,7 +138,7 @@ Texture2D::AsyncTransfer::AsyncTransfer(Texture2D &t, unsigned l, unsigned x_, u width(wd), height(ht), data_size(width*height*get_pixel_size(texture->storage_fmt)), - dest_addr(0) + dest_addr(nullptr) { dest_addr = allocate(); } @@ -154,7 +154,7 @@ Texture2D::AsyncTransfer::AsyncTransfer(AsyncTransfer &&other): data_size(other.data_size), dest_addr(other.dest_addr) { - other.dest_addr = 0; + other.dest_addr = nullptr; } Texture2D::AsyncTransfer &Texture2D::AsyncTransfer::operator=(AsyncTransfer &&other) @@ -173,7 +173,7 @@ Texture2D::AsyncTransfer &Texture2D::AsyncTransfer::operator=(AsyncTransfer &&ot data_size = other.data_size; dest_addr = other.dest_addr; - other.dest_addr = 0; + other.dest_addr = nullptr; return *this; } diff --git a/source/core/texture2d.h b/source/core/texture2d.h index 12803df2..7256e059 100644 --- a/source/core/texture2d.h +++ b/source/core/texture2d.h @@ -38,14 +38,14 @@ public: friend class Texture2DBackend::AsyncTransfer; private: - Texture2D *texture = 0; + Texture2D *texture = nullptr; unsigned level = 0; unsigned x = 0; unsigned y = 0; unsigned width = 0; unsigned height = 0; std::size_t data_size = 0; - void *dest_addr = 0; + void *dest_addr = nullptr; AsyncTransfer(Texture2D &, unsigned, unsigned, unsigned, unsigned, unsigned); public: @@ -95,7 +95,7 @@ private: LinAl::Vector get_level_size(unsigned) const; public: - virtual Resource::AsyncLoader *load(IO::Seekable &, const Resources * = 0); + virtual Resource::AsyncLoader *load(IO::Seekable &, const Resources * = nullptr); }; } // namespace GL diff --git a/source/core/vertexsetup.cpp b/source/core/vertexsetup.cpp index 2994916e..7df3b67b 100644 --- a/source/core/vertexsetup.cpp +++ b/source/core/vertexsetup.cpp @@ -86,11 +86,11 @@ void VertexSetup::unload() { VertexSetupBackend::unload(); - vertex_array = 0; + vertex_array = nullptr; vertex_format = VertexFormat(); - inst_array = 0; + inst_array = nullptr; inst_format = VertexFormat(); - index_buffer = 0; + index_buffer = nullptr; } } // namespace GL diff --git a/source/core/vertexsetup.h b/source/core/vertexsetup.h index 2ea5dfdf..11497c75 100644 --- a/source/core/vertexsetup.h +++ b/source/core/vertexsetup.h @@ -31,11 +31,11 @@ private: }; mutable unsigned dirty = 0; - const VertexArray *vertex_array = 0; + const VertexArray *vertex_array = nullptr; VertexFormat vertex_format; - const VertexArray *inst_array = 0; + const VertexArray *inst_array = nullptr; VertexFormat inst_format; - const Buffer *index_buffer = 0; + const Buffer *index_buffer = nullptr; DataType index_type = UNSIGNED_SHORT; public: diff --git a/source/effects/ambientocclusion.cpp b/source/effects/ambientocclusion.cpp index 780f0515..a50177fe 100644 --- a/source/effects/ambientocclusion.cpp +++ b/source/effects/ambientocclusion.cpp @@ -113,12 +113,12 @@ void AmbientOcclusion::render(Renderer &renderer, const Texture2D &color, const renderer.set_pipeline_key(this); renderer.set_framebuffer(&occlude_target.get_framebuffer()); - renderer.clear(0); + renderer.clear(nullptr); quad.draw(renderer); renderer.set_pipeline_key(this, 1); renderer.set_framebuffer(out_fbo); - renderer.clear(0); + renderer.clear(nullptr); renderer.set_shader_program(&combine_shader); quad.draw(renderer); } diff --git a/source/effects/bloom.cpp b/source/effects/bloom.cpp index 2aec1838..43a22b3e 100644 --- a/source/effects/bloom.cpp +++ b/source/effects/bloom.cpp @@ -71,14 +71,14 @@ void Bloom::render(Renderer &renderer, const Texture2D &src, const Texture2D &) Renderer::Push push2(renderer); renderer.set_pipeline_key(this, i); renderer.set_framebuffer(&target[i]->get_framebuffer()); - renderer.clear(0); + renderer.clear(nullptr); renderer.set_texture("source", (i ? &target[0]->get_target_texture(COLOR_ATTACHMENT) : &src), &nearest_sampler); renderer.add_shader_data(blur_shdata[i]); quad.draw(renderer); } renderer.set_pipeline_key(this, 2); - renderer.clear(0); + renderer.clear(nullptr); renderer.set_texture("source", &src, &nearest_sampler); renderer.set_texture("blurred", &target[1]->get_target_texture(COLOR_ATTACHMENT), &linear_sampler); renderer.set_shader_program(&combine_shader); diff --git a/source/effects/colorcurve.cpp b/source/effects/colorcurve.cpp index 2865743b..b1371794 100644 --- a/source/effects/colorcurve.cpp +++ b/source/effects/colorcurve.cpp @@ -72,7 +72,7 @@ void ColorCurve::render(Renderer &renderer, const Texture2D &color_buf, const Te { Renderer::Push push(renderer); renderer.set_pipeline_key(this); - renderer.clear(0); + renderer.clear(nullptr); renderer.set_shader_program(&shprog, &shdata); renderer.set_texture("source", &color_buf, &nearest_sampler); renderer.set_texture("curve", &curve, &linear_sampler); diff --git a/source/effects/shadowmap.cpp b/source/effects/shadowmap.cpp index 0c345d4e..d9ee677e 100644 --- a/source/effects/shadowmap.cpp +++ b/source/effects/shadowmap.cpp @@ -40,7 +40,7 @@ ShadowMap::ShadowMap(unsigned w, unsigned h, Renderable &c, const Lighting *l): } ShadowMap::ShadowMap(unsigned s, Renderable &c, const DirectionalLight &l, Renderable &sc): - ShadowMap(s, s, c, 0) + ShadowMap(s, s, c, nullptr) { add_light(l, s, sc); } diff --git a/source/effects/shadowmap.h b/source/effects/shadowmap.h index 980be57c..2d2d04db 100644 --- a/source/effects/shadowmap.h +++ b/source/effects/shadowmap.h @@ -63,14 +63,14 @@ public: virtual void init_actions(); }; - const Light *light = 0; + const Light *light = nullptr; unsigned size; std::string shadow_caster_name; }; unsigned width = 2048; unsigned height = 2048; - const Lighting *lighting = 0; + const Lighting *lighting = nullptr; std::vector lights; Vector3 target; float radius = 1.0f; diff --git a/source/effects/sky.h b/source/effects/sky.h index 64ab6f12..8785f9f7 100644 --- a/source/effects/sky.h +++ b/source/effects/sky.h @@ -58,7 +58,7 @@ public: virtual void init_actions(); }; - DirectionalLight *sun = 0; + DirectionalLight *sun = nullptr; virtual Sky *create(const std::map &) const; }; diff --git a/source/glsl/builtin.cpp b/source/glsl/builtin.cpp index 217509a2..d8540aae 100644 --- a/source/glsl/builtin.cpp +++ b/source/glsl/builtin.cpp @@ -32,7 +32,7 @@ Module *get_builtins_module() RefPtr io = Resources::get_builtins().open("_builtin.glsl"); if(!io) - return 0; + return nullptr; builtins_module = new Module; add_builtin_type(builtins_module->shared, "void", BasicTypeDeclaration::VOID, 0, true); @@ -43,12 +43,12 @@ Module *get_builtins_module() try { - Parser parser(0); + Parser parser(nullptr); parser.parse(*builtins_module, *io, "", BUILTIN_SOURCE); } catch(...) { - builtins_module = 0; + builtins_module = nullptr; throw; } } @@ -59,12 +59,12 @@ const Stage *get_builtins(Stage::Type type) { Module *module = get_builtins_module(); if(!module) - return 0; + return nullptr; if(type==Stage::SHARED) return &module->shared; auto i = find_member(module->stages, type, &Stage::type); - return (i!=module->stages.end() ? &*i : 0); + return (i!=module->stages.end() ? &*i : nullptr); } } // namespace SL diff --git a/source/glsl/compiler.cpp b/source/glsl/compiler.cpp index 7355321e..e61cf10d 100644 --- a/source/glsl/compiler.cpp +++ b/source/glsl/compiler.cpp @@ -44,7 +44,7 @@ void Compiler::set_source(const string &source, const string &src_name) { clear(); imported_names.push_back(src_name); - ModuleCache mod_cache(0); + ModuleCache mod_cache(nullptr); append_module(mod_cache.add_module(source, src_name), mod_cache); } @@ -58,7 +58,7 @@ void Compiler::load_source(IO::Base &io, DataFile::Collection *res, const string void Compiler::load_source(IO::Base &io, const string &src_name) { - load_source(io, 0, src_name); + load_source(io, nullptr, src_name); } void Compiler::specialize(const map &sv) @@ -104,7 +104,7 @@ void Compiler::compile(Mode mode) ++i; } - Stage *prev_stage = 0; + Stage *prev_stage = nullptr; for(auto i=module->stages.begin(); i!=module->stages.end(); ) { if(i->functions.empty()) @@ -263,7 +263,7 @@ void Compiler::append_module(const Module &mod, ModuleCache &mod_cache) void Compiler::append_stage(const Stage &stage) { - Stage *target = 0; + Stage *target = nullptr; if(stage.type==Stage::SHARED) target = &module->shared; else diff --git a/source/glsl/compiler.h b/source/glsl/compiler.h index 85be3013..dde50841 100644 --- a/source/glsl/compiler.h +++ b/source/glsl/compiler.h @@ -41,7 +41,7 @@ private: }; Features features; - Module *module = 0; + Module *module = nullptr; std::vector imported_names; bool compiled = false; bool specialized = false; @@ -63,7 +63,7 @@ public: /** Loads source code from an I/O object. If a collection is used, imports can be fetched from it. */ - void load_source(IO::Base &, DataFile::Collection * = 0, const std::string & = ""); + void load_source(IO::Base &, DataFile::Collection * = nullptr, const std::string & = ""); /** Loads source code from an I/O object. Only builtin imports are available. */ diff --git a/source/glsl/debug.h b/source/glsl/debug.h index b3682e7b..f347aca5 100644 --- a/source/glsl/debug.h +++ b/source/glsl/debug.h @@ -27,8 +27,8 @@ private: std::string text; Node *node; - Branch(const char *t, Node *n = 0): text(t), node(n) { } - Branch(const std::string &t, Node *n = 0): text(t), node(n) { } + Branch(const char *t, Node *n = nullptr): text(t), node(n) { } + Branch(const std::string &t, Node *n = nullptr): text(t), node(n) { } Branch(Node *n): node(n) { } }; diff --git a/source/glsl/finalize.cpp b/source/glsl/finalize.cpp index 2c902376..609f36e5 100644 --- a/source/glsl/finalize.cpp +++ b/source/glsl/finalize.cpp @@ -22,7 +22,7 @@ void StructOrganizer::visit(VariableDeclaration &var) { if(offset>=0) { - int *layout_offset = 0; + int *layout_offset = nullptr; bool has_matrix_order = false; if(var.layout) { @@ -501,11 +501,11 @@ void StructuralFeatureConverter::visit(Block &block) void StructuralFeatureConverter::visit(RefPtr &expr) { - r_replaced_reference = 0; + r_replaced_reference = nullptr; expr->visit(*this); if(r_replaced_reference) expr = r_replaced_reference; - r_replaced_reference = 0; + r_replaced_reference = nullptr; } bool StructuralFeatureConverter::supports_stage(Stage::Type st) const @@ -548,7 +548,7 @@ void StructuralFeatureConverter::visit(VariableReference &var) if(var.declaration==frag_out && !supports_unified_interface_syntax()) { var.name = "gl_FragColor"; - var.declaration = 0; + var.declaration = nullptr; } r_flattened_interface = nodes_to_remove.count(var.declaration); @@ -570,7 +570,7 @@ void StructuralFeatureConverter::visit(Assignment &assign) { TraversingVisitor::visit(assign); if(assign.target.declaration==frag_out && !supports_unified_interface_syntax()) - assign.target.declaration = 0; + assign.target.declaration = nullptr; } bool StructuralFeatureConverter::supports_unified_sampling_functions() const @@ -805,7 +805,7 @@ void QualifierConverter::visit(VariableDeclaration &var) } if(var.layout->qualifiers.empty()) - var.layout = 0; + var.layout = nullptr; else if(!check_version(Version(1, 40))) unsupported("Layout qualifiers require GLSL 1.40"); } diff --git a/source/glsl/finalize.h b/source/glsl/finalize.h index 7b47e8ec..45a1bdaa 100644 --- a/source/glsl/finalize.h +++ b/source/glsl/finalize.h @@ -93,7 +93,7 @@ according to the requirements of the target API. */ class PrecisionConverter: private TraversingVisitor { private: - Stage *stage = 0; + Stage *stage = nullptr; std::set have_default; NodeList::iterator insert_point; std::set nodes_to_remove; @@ -111,7 +111,7 @@ private: class FeatureConverter: protected TraversingVisitor { protected: - Stage *stage = 0; + Stage *stage = nullptr; Features features; FeatureConverter() = default; @@ -132,7 +132,7 @@ features. */ class StructuralFeatureConverter: public FeatureConverter { private: - VariableDeclaration *frag_out = 0; + VariableDeclaration *frag_out = nullptr; NodeList::iterator uniform_insert_point; std::set nodes_to_remove; RefPtr r_replaced_reference; diff --git a/source/glsl/generate.cpp b/source/glsl/generate.cpp index ff43b99f..4c1039bd 100644 --- a/source/glsl/generate.cpp +++ b/source/glsl/generate.cpp @@ -99,10 +99,10 @@ string InterfaceGenerator::change_prefix(const string &name, const string &prefi VariableDeclaration *InterfaceGenerator::generate_interface(VariableDeclaration &var, const string &iface, const string &name) { if(stage->content.variables.count(name)) - return 0; + return nullptr; if(stage->type==Stage::GEOMETRY && var.interface=="out" && var.array) - return 0; + return nullptr; VariableDeclaration* iface_var = new VariableDeclaration; iface_var->sampling = var.sampling; @@ -234,7 +234,7 @@ void InterfaceGenerator::visit(VariableDeclaration &var) { /* For output variables in function scope, generate a global interface and replace the local declaration with an assignment. */ - VariableDeclaration *out_var = 0; + VariableDeclaration *out_var = nullptr; if(function_scope && (out_var=generate_interface(var, "out", var.name))) { out_var->source = var.source; @@ -415,9 +415,9 @@ void ArraySizer::visit(VariableReference &var) void ArraySizer::visit(MemberAccess &memacc) { - r_declaration = 0; + r_declaration = nullptr; TraversingVisitor::visit(memacc); - VariableDeclaration *member_declaration = 0; + VariableDeclaration *member_declaration = nullptr; if(r_declaration) if(StructDeclaration *strct = dynamic_cast(r_declaration->type_declaration)) { @@ -431,13 +431,13 @@ void ArraySizer::visit(MemberAccess &memacc) void ArraySizer::visit(Swizzle &swizzle) { TraversingVisitor::visit(swizzle); - r_declaration = 0; + r_declaration = nullptr; } void ArraySizer::visit(UnaryExpression &unary) { TraversingVisitor::visit(unary); - r_declaration = 0; + r_declaration = nullptr; } void ArraySizer::visit(BinaryExpression &binary) @@ -446,7 +446,7 @@ void ArraySizer::visit(BinaryExpression &binary) if(const Literal *literal_index = dynamic_cast(binary.right.get())) if(literal_index->value.has_type()) { - r_declaration = 0; + r_declaration = nullptr; binary.left->visit(*this); if(r_declaration) { @@ -461,13 +461,13 @@ void ArraySizer::visit(BinaryExpression &binary) void ArraySizer::visit(TernaryExpression &ternary) { TraversingVisitor::visit(ternary); - r_declaration = 0; + r_declaration = nullptr; } void ArraySizer::visit(FunctionCall &call) { TraversingVisitor::visit(call); - r_declaration = 0; + r_declaration = nullptr; } void ArraySizer::visit(InterfaceLayout &layout) diff --git a/source/glsl/generate.h b/source/glsl/generate.h index aba2c353..1eddfb16 100644 --- a/source/glsl/generate.h +++ b/source/glsl/generate.h @@ -37,13 +37,13 @@ Unresolved variables are looked up in the previous stage's out variables. */ class InterfaceGenerator: private TraversingVisitor { private: - Stage *stage = 0; + Stage *stage = nullptr; std::string in_prefix; std::string out_prefix; bool function_scope = false; bool copy_block = false; std::vector declared_inputs; - Block *iface_target_block = 0; + Block *iface_target_block = nullptr; NodeList::iterator iface_insert_point; NodeList::iterator assignment_insert_point; std::set nodes_to_remove; @@ -66,7 +66,7 @@ private: class LayoutDefaulter: private TraversingVisitor { private: - InterfaceLayout *in_iface = 0; + InterfaceLayout *in_iface = nullptr; bool need_winding = true; bool need_spacing = true; diff --git a/source/glsl/optimize.cpp b/source/glsl/optimize.cpp index e914ad03..d35b4351 100644 --- a/source/glsl/optimize.cpp +++ b/source/glsl/optimize.cpp @@ -29,7 +29,7 @@ void ConstantSpecializer::visit(VariableDeclaration &var) specializable = true; qualifiers.erase(i); if(qualifiers.empty()) - var.layout = 0; + var.layout = nullptr; } } @@ -148,7 +148,7 @@ string InlineContentInjector::apply(Stage &stage, FunctionDeclaration &target_fu for(const RefPtr &s: source_func->body.body) { - r_inlined_statement = 0; + r_inlined_statement = nullptr; s->visit(*this); if(!r_inlined_statement) r_inlined_statement = s->clone(); @@ -256,14 +256,14 @@ bool FunctionInliner::apply(Stage &s) void FunctionInliner::visit(RefPtr &ptr) { - r_inline_result = 0; + r_inline_result = nullptr; ptr->visit(*this); if(r_inline_result) { ptr = r_inline_result; r_any_inlined = true; } - r_inline_result = 0; + r_inline_result = nullptr; } void FunctionInliner::visit(Block &block) @@ -351,7 +351,7 @@ bool ExpressionInliner::apply(Stage &s) void ExpressionInliner::visit(RefPtr &expr) { - r_ref_info = 0; + r_ref_info = nullptr; expr->visit(*this); if(r_ref_info && r_ref_info->expression) { @@ -377,7 +377,7 @@ void ExpressionInliner::visit(RefPtr &expr) r_ref_info->uses.push_back(use); } r_oper = expr->oper; - r_ref_info = 0; + r_ref_info = nullptr; } void ExpressionInliner::visit(VariableReference &var) @@ -426,7 +426,7 @@ void ExpressionInliner::visit(Assignment &assign) SetFlag set_write(access_write); visit(assign.left); } - r_oper = 0; + r_oper = nullptr; r_trivial = true; visit(assign.right); @@ -478,7 +478,7 @@ void ExpressionInliner::visit(FunctionCall &call) void ExpressionInliner::visit(VariableDeclaration &var) { - r_oper = 0; + r_oper = nullptr; r_trivial = true; TraversingVisitor::visit(var); @@ -582,7 +582,7 @@ void AggregateDismantler::visit(Block &block) void AggregateDismantler::visit(RefPtr &expr) { - r_aggregate_ref = 0; + r_aggregate_ref = nullptr; expr->visit(*this); if(r_aggregate_ref && r_reference.chain_len==1) { @@ -596,7 +596,7 @@ void AggregateDismantler::visit(RefPtr &expr) referenced. */ r_aggregate_ref->referenced = true; } - r_aggregate_ref = 0; + r_aggregate_ref = nullptr; } void AggregateDismantler::visit(VariableReference &var) @@ -631,10 +631,10 @@ void AggregateDismantler::visit(MemberAccess &memacc) if(r_reference.declaration && r_reference.chain_len==1) { auto i = aggregates.find(r_reference.declaration); - r_aggregate_ref = (i!=aggregates.end() ? &i->second : 0); + r_aggregate_ref = (i!=aggregates.end() ? &i->second : nullptr); } else - r_aggregate_ref = 0; + r_aggregate_ref = nullptr; } void AggregateDismantler::visit(BinaryExpression &binary) @@ -656,10 +656,10 @@ void AggregateDismantler::visit(BinaryExpression &binary) if(r_reference.declaration && r_reference.chain_len==1) { auto i = aggregates.find(r_reference.declaration); - r_aggregate_ref = (i!=aggregates.end() ? &i->second : 0); + r_aggregate_ref = (i!=aggregates.end() ? &i->second : nullptr); } else - r_aggregate_ref = 0; + r_aggregate_ref = nullptr; } else { @@ -1029,7 +1029,7 @@ void ConstantFolder::visit(Iteration &iter) /* The iteration variable is not normally inlined into expressions, so we process it specially here. If the initial value causes the loop condition to evaluate to false, then the expression can be folded. */ - iteration_var = 0; + iteration_var = nullptr; if(iter.init_statement) { SetFlag set_init(iteration_init); @@ -1047,7 +1047,7 @@ void ConstantFolder::visit(Iteration &iter) iter.condition = literal; } } - iteration_var = 0; + iteration_var = nullptr; iter.body.visit(*this); if(iter.loop_expression) @@ -1082,11 +1082,11 @@ void ConstantConditionEliminator::visit(Block &block) void ConstantConditionEliminator::visit(RefPtr &expr) { - r_ternary_result = 0; + r_ternary_result = nullptr; expr->visit(*this); if(r_ternary_result) expr = r_ternary_result; - r_ternary_result = 0; + r_ternary_result = nullptr; } void ConstantConditionEliminator::visit(UnaryExpression &unary) @@ -1116,7 +1116,7 @@ void ConstantConditionEliminator::visit(TernaryExpression &ternary) if(result!=NOT_CONSTANT) r_ternary_result = (result==CONSTANT_TRUE ? ternary.true_expr : ternary.false_expr); else - r_ternary_result = 0; + r_ternary_result = nullptr; } void ConstantConditionEliminator::visit(FunctionCall &call) @@ -1435,7 +1435,7 @@ void UnusedVariableRemover::record_assignment(const Assignment::Target &target, void UnusedVariableRemover::visit(ExpressionStatement &expr) { - r_assignment = 0; + r_assignment = nullptr; r_side_effects = false; TraversingVisitor::visit(expr); if(r_assignment && r_assignment->target.declaration) diff --git a/source/glsl/optimize.h b/source/glsl/optimize.h index 807b7a89..5f55e10c 100644 --- a/source/glsl/optimize.h +++ b/source/glsl/optimize.h @@ -14,7 +14,7 @@ constants. */ class ConstantSpecializer: private TraversingVisitor { private: - const std::map *values = 0; + const std::map *values = nullptr; public: void apply(Stage &, const std::map &); @@ -31,7 +31,7 @@ class InlineableFunctionLocator: private TraversingVisitor private: std::map refcounts; std::set inlineable; - FunctionDeclaration *current_function = 0; + FunctionDeclaration *current_function = nullptr; unsigned return_count = 0; public: @@ -58,7 +58,7 @@ private: RENAME }; - FunctionDeclaration *source_func = 0; + FunctionDeclaration *source_func = nullptr; Block staging_block; Pass pass = REFERENCED; RefPtr r_inlined_statement; @@ -82,9 +82,9 @@ are inlined. */ class FunctionInliner: private TraversingVisitor { private: - Stage *stage = 0; + Stage *stage = nullptr; std::set inlineable; - FunctionDeclaration *current_function = 0; + FunctionDeclaration *current_function = nullptr; NodeList::iterator insert_point; RefPtr r_inline_result; bool r_any_inlined = false; @@ -109,8 +109,8 @@ class ExpressionInliner: private TraversingVisitor private: struct ExpressionUse { - RefPtr *reference = 0; - Block *ref_scope = 0; + RefPtr *reference = nullptr; + Block *ref_scope = nullptr; bool blocked = false; }; @@ -118,7 +118,7 @@ private: { Assignment::Target target; RefPtr expression; - Block *assign_scope = 0; + Block *assign_scope = nullptr; std::vector uses; bool trivial = false; bool blocked = false; @@ -126,13 +126,13 @@ private: std::list expressions; std::map assignments; - ExpressionInfo *r_ref_info = 0; + ExpressionInfo *r_ref_info = nullptr; bool r_trivial = false; bool access_read = true; bool access_write = false; bool iteration_init = false; - Block *iteration_body = 0; - const Operator *r_oper = 0; + Block *iteration_body = nullptr; + const Operator *r_oper = nullptr; public: bool apply(Stage &); @@ -160,7 +160,7 @@ class AggregateDismantler: public TraversingVisitor private: struct AggregateMember { - const VariableDeclaration *declaration = 0; + const VariableDeclaration *declaration = nullptr; unsigned index = 0; RefPtr initializer; std::vector *> references; @@ -168,8 +168,8 @@ private: struct Aggregate { - VariableDeclaration *declaration = 0; - Block *decl_scope = 0; + VariableDeclaration *declaration = nullptr; + Block *decl_scope = nullptr; NodeList::iterator insert_point; std::vector members; bool referenced = false; @@ -180,7 +180,7 @@ private: std::map aggregates; bool composite_reference = false; Assignment::Target r_reference; - Aggregate *r_aggregate_ref = 0; + Aggregate *r_aggregate_ref = nullptr; public: bool apply(Stage &); @@ -202,7 +202,7 @@ evaluating the expression.*/ class ConstantFolder: private TraversingVisitor { private: - VariableDeclaration *iteration_var = 0; + VariableDeclaration *iteration_var = nullptr; Variant iter_init_value; Variant r_constant_value; bool iteration_init = false; @@ -319,7 +319,7 @@ class UnusedVariableRemover: private TraversingVisitor private: struct AssignmentInfo { - Node *node = 0; + Node *node = nullptr; Assignment::Target target; std::vector used_by; unsigned in_loop = 0; @@ -335,10 +335,10 @@ private: typedef std::map BlockVariableMap; - Stage *stage = 0; + Stage *stage = nullptr; BlockVariableMap variables; std::list assignments; - Assignment *r_assignment = 0; + Assignment *r_assignment = nullptr; bool assignment_target = false; bool r_side_effects = false; bool in_struct = false; diff --git a/source/glsl/output.h b/source/glsl/output.h index ec794912..57abed75 100644 --- a/source/glsl/output.h +++ b/source/glsl/output.h @@ -13,7 +13,7 @@ namespace SL { class Formatter: private TraversingVisitor { private: - Stage *stage = 0; + Stage *stage = nullptr; std::string formatted; unsigned source_index = 0; unsigned source_line = 1; diff --git a/source/glsl/parser.cpp b/source/glsl/parser.cpp index db607894..907cb7fe 100644 --- a/source/glsl/parser.cpp +++ b/source/glsl/parser.cpp @@ -19,7 +19,7 @@ namespace SL { Parser::Parser(ModuleCache *s): mod_cache(s), preprocessor(tokenizer), - module(0) + module(nullptr) { tokenizer.signal_preprocess.connect(sigc::mem_fun(&preprocessor, &Preprocessor::preprocess)); preprocessor.signal_version.connect(sigc::mem_fun(this, &Parser::set_required_version)); @@ -71,7 +71,7 @@ void Parser::parse_source(const string &name, int index) if(next_global_declaration) { cur_stage->content.body.push_back(next_global_declaration); - next_global_declaration = 0; + next_global_declaration = nullptr; } } @@ -332,7 +332,7 @@ RefPtr Parser::parse_global_declaration() return parse_variable_declaration(); } else if(token.empty()) - return 0; + return nullptr; else throw parse_error(tokenizer.get_location(), token, "a global declaration"); } @@ -476,12 +476,12 @@ RefPtr Parser::parse_expression(const Operator *outer_oper) { unsigned outer_precedence = (outer_oper ? outer_oper->precedence+(outer_oper->assoc==Operator::RIGHT_TO_LEFT) : 20); RefPtr left; - VariableReference *left_var = 0; + VariableReference *left_var = nullptr; while(1) { string token = tokenizer.peek_token(); - const Operator *oper = 0; + const Operator *oper = nullptr; for(const Operator *i=Operator::operators; (!oper && i->type); ++i) if(token==i->token && (!left || i->type!=Operator::PREFIX) && (left || i->type!=Operator::POSTFIX)) oper = i; @@ -525,7 +525,7 @@ RefPtr Parser::parse_expression(const Operator *outer_oper) left = parse_ternary(left, *oper); else throw parse_error(tokenizer.get_location(), token, "an operator"); - left_var = 0; + left_var = nullptr; } else { diff --git a/source/glsl/parser.h b/source/glsl/parser.h index 51616378..d1dd379d 100644 --- a/source/glsl/parser.h +++ b/source/glsl/parser.h @@ -75,7 +75,7 @@ private: RefPtr parse_layout(); template void parse_block(Block &, bool, RefPtr (Parser::*)()); - RefPtr parse_expression(const Operator * = 0); + RefPtr parse_expression(const Operator * = nullptr); RefPtr parse_literal(); RefPtr parse_binary(const RefPtr &, const Operator &); RefPtr parse_ternary(const RefPtr &, const Operator &); diff --git a/source/glsl/reflect.cpp b/source/glsl/reflect.cpp index 818ccc97..c4fba068 100644 --- a/source/glsl/reflect.cpp +++ b/source/glsl/reflect.cpp @@ -23,7 +23,7 @@ BasicTypeDeclaration *get_element_type(BasicTypeDeclaration &type) if(is_vector_or_matrix(type) || type.kind==BasicTypeDeclaration::ARRAY) { BasicTypeDeclaration *basic_base = dynamic_cast(type.base_type); - return (basic_base ? get_element_type(*basic_base) : 0); + return (basic_base ? get_element_type(*basic_base) : nullptr); } else return &type; @@ -71,7 +71,7 @@ T *TypeComparer::multi_visit(T &node) Node *s = second; first = &node; first_tag = tag; - second = 0; + second = nullptr; s->visit(*this); } else if(!first || tag!=first_tag) @@ -79,11 +79,11 @@ T *TypeComparer::multi_visit(T &node) else { T *f = static_cast(first); - first = 0; + first = nullptr; return f; } - return 0; + return nullptr; } void TypeComparer::visit(Literal &literal) diff --git a/source/glsl/reflect.h b/source/glsl/reflect.h index 308d7c80..13528c0d 100644 --- a/source/glsl/reflect.h +++ b/source/glsl/reflect.h @@ -16,8 +16,8 @@ bool can_convert(const BasicTypeDeclaration &, const BasicTypeDeclaration &); class TypeComparer: private NodeVisitor { private: - Node *first = 0; - Node *second = 0; + Node *first = nullptr; + Node *second = nullptr; unsigned first_tag = 0; bool r_result = false; diff --git a/source/glsl/resolve.cpp b/source/glsl/resolve.cpp index ffcec7b9..e1d2065b 100644 --- a/source/glsl/resolve.cpp +++ b/source/glsl/resolve.cpp @@ -69,7 +69,7 @@ TypeDeclaration *TypeResolver::get_or_create_image_type(ImageTypeDeclaration &ty void TypeResolver::resolve_type(TypeDeclaration *&type, const string &name, bool array, const Layout *layout) { - TypeDeclaration *resolved = 0; + TypeDeclaration *resolved = nullptr; auto i = stage->types.find(name); if(i!=stage->types.end()) { @@ -158,7 +158,7 @@ void TypeResolver::visit(VariableDeclaration &var) { resolve_type(var.type_declaration, var.type, var.array, var.layout.get()); - var.block_declaration = 0; + var.block_declaration = nullptr; if(StructDeclaration *strct = dynamic_cast(get_ultimate_base_type(var.type_declaration))) if(!strct->block_name.empty()) { @@ -206,17 +206,17 @@ void VariableResolver::enter(Block &block) void VariableResolver::visit(RefPtr &expr) { - r_replacement_expr = 0; + r_replacement_expr = nullptr; expr->visit(*this); if(r_replacement_expr) { expr = r_replacement_expr; /* Don't record assignment target when doing a replacement, because chain information won't be correct. */ - r_assignment_target.declaration = 0; + r_assignment_target.declaration = nullptr; r_any_resolved = true; } - r_replacement_expr = 0; + r_replacement_expr = nullptr; } void VariableResolver::check_assignment_target(VariableDeclaration *declaration) @@ -228,7 +228,7 @@ void VariableResolver::check_assignment_target(VariableDeclaration *declaration) /* More than one reference found in assignment target. Unable to determine what the primary target is. */ record_target = false; - r_assignment_target.declaration = 0; + r_assignment_target.declaration = nullptr; } else r_assignment_target.declaration = declaration; @@ -240,7 +240,7 @@ void VariableResolver::check_assignment_target(VariableDeclaration *declaration) void VariableResolver::visit(VariableReference &var) { - VariableDeclaration *declaration = 0; + VariableDeclaration *declaration = nullptr; /* Look for variable declarations in the block hierarchy first. Interface blocks are always defined in the top level so we can't accidentally skip @@ -286,7 +286,7 @@ void VariableResolver::visit(MemberAccess &memacc) { TraversingVisitor::visit(memacc); - VariableDeclaration *declaration = 0; + VariableDeclaration *declaration = nullptr; int index = -1; if(StructDeclaration *strct = dynamic_cast(memacc.left->type)) { @@ -423,8 +423,8 @@ void VariableResolver::visit(VariableDeclaration &var) TraversingVisitor::visit(var); auto i = current_block->variables.find(var.name); - VariableDeclaration *existing = 0; - VariableDeclaration *block = 0; + VariableDeclaration *existing = nullptr; + VariableDeclaration *block = nullptr; if(i!=current_block->variables.end()) existing = i->second; else if(!current_block->parent) @@ -714,7 +714,7 @@ void ExpressionResolver::visit(BinaryExpression &binary, bool assign) if(assign && (compat==LEFT_CONVERTIBLE || elem_compat==LEFT_CONVERTIBLE)) return; - TypeDeclaration *type = 0; + TypeDeclaration *type = nullptr; char oper2 = binary.oper->token[1]; if((oper=='<' && oper2!='<') || (oper=='>' && oper2!='>')) { @@ -833,7 +833,7 @@ void ExpressionResolver::visit(BinaryExpression &binary, bool assign) converted = convert_to_element(binary.right, *elem_left); if(!converted) - type = 0; + type = nullptr; resolve(binary, type, assign); } @@ -875,7 +875,7 @@ void ExpressionResolver::visit(TernaryExpression &ternary) if(!basic_cond || basic_cond->kind!=BasicTypeDeclaration::BOOL) return; - TypeDeclaration *type = 0; + TypeDeclaration *type = nullptr; if(ternary.true_expr->type==ternary.false_expr->type) type = ternary.true_expr->type; else @@ -1236,7 +1236,7 @@ bool FunctionResolver::can_convert_arguments(const FunctionCall &call, const Fun void FunctionResolver::visit(FunctionCall &call) { - FunctionDeclaration *declaration = 0; + FunctionDeclaration *declaration = nullptr; if(stage->types.count(call.name)) call.constructor = true; else @@ -1268,7 +1268,7 @@ void FunctionResolver::visit(FunctionCall &call) { if(declaration) { - declaration = 0; + declaration = nullptr; break; } else @@ -1326,7 +1326,7 @@ void FunctionResolver::visit(FunctionDeclaration &func) } else { - FunctionDeclaration *definition = (stage_decl ? stage_decl->definition : 0); + FunctionDeclaration *definition = (stage_decl ? stage_decl->definition : nullptr); r_any_resolved |= (definition!=func.definition); func.definition = definition; diff --git a/source/glsl/resolve.h b/source/glsl/resolve.h index c014891a..43326cfb 100644 --- a/source/glsl/resolve.h +++ b/source/glsl/resolve.h @@ -28,13 +28,13 @@ private: class TypeResolver: private TraversingVisitor { private: - Stage *stage = 0; + Stage *stage = nullptr; std::map alias_map; std::map, TypeDeclaration *> array_types; std::map, ImageTypeDeclaration *> image_types; NodeList::iterator type_insert_point; NodeList::iterator block_member_type_ins_pt; - VariableDeclaration *iface_block = 0; + VariableDeclaration *iface_block = nullptr; bool r_any_resolved = false; public: @@ -43,7 +43,7 @@ public: private: TypeDeclaration *get_or_create_array_type(TypeDeclaration &); TypeDeclaration *get_or_create_image_type(ImageTypeDeclaration &, const std::string &); - void resolve_type(TypeDeclaration *&, const std::string &, bool, const Layout * = 0); + void resolve_type(TypeDeclaration *&, const std::string &, bool, const Layout * = nullptr); virtual void visit(Block &); virtual void visit(BasicTypeDeclaration &); virtual void visit(ImageTypeDeclaration &); @@ -56,7 +56,7 @@ private: class VariableResolver: private TraversingVisitor { private: - Stage *stage = 0; + Stage *stage = nullptr; RefPtr r_replacement_expr; bool r_any_resolved = false; bool record_target = false; @@ -96,12 +96,12 @@ private: struct ArgumentInfo { - BasicTypeDeclaration *type = 0; + BasicTypeDeclaration *type = nullptr; unsigned component_count = 0; }; - Stage *stage = 0; - const FunctionDeclaration *current_function = 0; + Stage *stage = nullptr; + const FunctionDeclaration *current_function = nullptr; std::vector basic_types; NodeList::iterator insert_point; bool r_any_resolved = false; @@ -141,7 +141,7 @@ private: class FunctionResolver: private TraversingVisitor { private: - Stage *stage = 0; + Stage *stage = nullptr; std::map > declarations; bool r_any_resolved = false; diff --git a/source/glsl/spirv.cpp b/source/glsl/spirv.cpp index a9cb302d..88ab30b9 100644 --- a/source/glsl/spirv.cpp +++ b/source/glsl/spirv.cpp @@ -12,102 +12,102 @@ namespace SL { const SpirVGenerator::BuiltinFunctionInfo SpirVGenerator::builtin_functions[] = { - { "radians", "f", "GLSL.std.450", GLSL450_RADIANS, { 1 }, 0, 0 }, - { "degrees", "f", "GLSL.std.450", GLSL450_DEGREES, { 1 }, 0, 0 }, - { "sin", "f", "GLSL.std.450", GLSL450_SIN, { 1 }, 0, 0 }, - { "cos", "f", "GLSL.std.450", GLSL450_COS, { 1 }, 0, 0 }, - { "tan", "f", "GLSL.std.450", GLSL450_TAN, { 1 }, 0, 0 }, - { "asin", "f", "GLSL.std.450", GLSL450_ASIN, { 1 }, 0, 0 }, - { "acos", "f", "GLSL.std.450", GLSL450_ACOS, { 1 }, 0, 0 }, - { "atan", "f", "GLSL.std.450", GLSL450_ATAN, { 1 }, 0, 0 }, - { "atan", "ff", "GLSL.std.450", GLSL450_ATAN2, { 1, 2 }, 0, 0 }, - { "sinh", "f", "GLSL.std.450", GLSL450_SINH, { 1 }, 0, 0 }, - { "cosh", "f", "GLSL.std.450", GLSL450_COSH, { 1 }, 0, 0 }, - { "tanh", "f", "GLSL.std.450", GLSL450_TANH, { 1 }, 0, 0 }, - { "asinh", "f", "GLSL.std.450", GLSL450_ASINH, { 1 }, 0, 0 }, - { "acosh", "f", "GLSL.std.450", GLSL450_ACOSH, { 1 }, 0, 0 }, - { "atanh", "f", "GLSL.std.450", GLSL450_ATANH, { 1 }, 0, 0 }, - { "pow", "ff", "GLSL.std.450", GLSL450_POW, { 1, 2 }, 0, 0 }, - { "exp", "f", "GLSL.std.450", GLSL450_EXP, { 1 }, 0, 0 }, - { "log", "f", "GLSL.std.450", GLSL450_LOG, { 1 }, 0, 0 }, - { "exp2", "f", "GLSL.std.450", GLSL450_EXP2, { 1 }, 0, 0 }, - { "log2", "f", "GLSL.std.450", GLSL450_LOG2, { 1 }, 0, 0 }, - { "sqrt", "f", "GLSL.std.450", GLSL450_SQRT, { 1 }, 0, 0 }, - { "inversesqrt", "f", "GLSL.std.450", GLSL450_INVERSE_SQRT, { 1 }, 0, 0 }, - { "abs", "f", "GLSL.std.450", GLSL450_F_ABS, { 1 }, 0, 0 }, - { "abs", "i", "GLSL.std.450", GLSL450_S_ABS, { 1 }, 0, 0 }, - { "sign", "f", "GLSL.std.450", GLSL450_F_SIGN, { 1 }, 0, 0 }, - { "sign", "i", "GLSL.std.450", GLSL450_S_SIGN, { 1 }, 0, 0 }, - { "floor", "f", "GLSL.std.450", GLSL450_FLOOR, { 1 }, 0, 0 }, - { "trunc", "f", "GLSL.std.450", GLSL450_TRUNC, { 1 }, 0, 0 }, - { "round", "f", "GLSL.std.450", GLSL450_ROUND, { 1 }, 0, 0 }, - { "roundEven", "f", "GLSL.std.450", GLSL450_ROUND_EVEN, { 1 }, 0, 0 }, - { "ceil", "f", "GLSL.std.450", GLSL450_CEIL, { 1 }, 0, 0 }, - { "fract", "f", "GLSL.std.450", GLSL450_FRACT, { 1 }, 0, 0 }, - { "mod", "f", "", OP_F_MOD, { 1, 2 }, 0, 0 }, - { "min", "ff", "GLSL.std.450", GLSL450_F_MIN, { 1, 2 }, 0, 0 }, - { "min", "ii", "GLSL.std.450", GLSL450_S_MIN, { 1, 2 }, 0, 0 }, - { "min", "uu", "GLSL.std.450", GLSL450_U_MIN, { 1, 2 }, 0, 0 }, - { "max", "ff", "GLSL.std.450", GLSL450_F_MAX, { 1, 2 }, 0, 0 }, - { "max", "ii", "GLSL.std.450", GLSL450_S_MAX, { 1, 2 }, 0, 0 }, - { "max", "uu", "GLSL.std.450", GLSL450_U_MAX, { 1, 2 }, 0, 0 }, - { "clamp", "fff", "GLSL.std.450", GLSL450_F_CLAMP, { 1, 2, 3 }, 0, 0 }, - { "clamp", "iii", "GLSL.std.450", GLSL450_S_CLAMP, { 1, 2, 3 }, 0, 0 }, - { "clamp", "uuu", "GLSL.std.450", GLSL450_U_CLAMP, { 1, 2, 3 }, 0, 0 }, - { "mix", "fff", "GLSL.std.450", GLSL450_F_MIX, { 1, 2, 3 }, 0, 0 }, - { "mix", "ffb", "", OP_SELECT, { 3, 2, 1 }, 0, 0 }, - { "mix", "iib", "", OP_SELECT, { 3, 2, 1 }, 0, 0 }, - { "mix", "uub", "", OP_SELECT, { 3, 2, 1 }, 0, 0 }, - { "step", "ff", "GLSL.std.450", GLSL450_F_STEP, { 1, 2 }, 0, 0 }, - { "smoothstep", "fff", "GLSL.std.450", GLSL450_F_SMOOTH_STEP, { 1, 2, 3 }, 0, 0 }, - { "isnan", "f", "", OP_IS_NAN, { 1 }, 0, 0 }, - { "isinf", "f", "", OP_IS_INF, { 1 }, 0, 0 }, - { "fma", "fff", "GLSL.std.450", GLSL450_F_FMA, { 1, 2, 3 }, 0, 0 }, - { "length", "f", "GLSL.std.450", GLSL450_LENGTH, { 1 }, 0, 0 }, - { "distance", "ff", "GLSL.std.450", GLSL450_DISTANCE, { 1, 2 }, 0, 0 }, - { "dot", "ff", "", OP_DOT, { 1, 2 }, 0, 0 }, - { "cross", "ff", "GLSL.std.450", GLSL450_CROSS, { 1, 2 }, 0, 0 }, - { "normalize", "f", "GLSL.std.450", GLSL450_NORMALIZE, { 1 }, 0, 0 }, - { "faceforward", "fff", "GLSL.std.450", GLSL450_FACE_FORWARD, { 1, 2, 3 }, 0, 0 }, - { "reflect", "ff", "GLSL.std.450", GLSL450_REFLECT, { 1, 2 }, 0, 0 }, - { "refract", "fff", "GLSL.std.450", GLSL450_REFRACT, { 1, 2, 3 }, 0, 0 }, + { "radians", "f", "GLSL.std.450", GLSL450_RADIANS, { 1 }, 0, nullptr }, + { "degrees", "f", "GLSL.std.450", GLSL450_DEGREES, { 1 }, 0, nullptr }, + { "sin", "f", "GLSL.std.450", GLSL450_SIN, { 1 }, 0, nullptr }, + { "cos", "f", "GLSL.std.450", GLSL450_COS, { 1 }, 0, nullptr }, + { "tan", "f", "GLSL.std.450", GLSL450_TAN, { 1 }, 0, nullptr }, + { "asin", "f", "GLSL.std.450", GLSL450_ASIN, { 1 }, 0, nullptr }, + { "acos", "f", "GLSL.std.450", GLSL450_ACOS, { 1 }, 0, nullptr }, + { "atan", "f", "GLSL.std.450", GLSL450_ATAN, { 1 }, 0, nullptr }, + { "atan", "ff", "GLSL.std.450", GLSL450_ATAN2, { 1, 2 }, 0, nullptr }, + { "sinh", "f", "GLSL.std.450", GLSL450_SINH, { 1 }, 0, nullptr }, + { "cosh", "f", "GLSL.std.450", GLSL450_COSH, { 1 }, 0, nullptr }, + { "tanh", "f", "GLSL.std.450", GLSL450_TANH, { 1 }, 0, nullptr }, + { "asinh", "f", "GLSL.std.450", GLSL450_ASINH, { 1 }, 0, nullptr }, + { "acosh", "f", "GLSL.std.450", GLSL450_ACOSH, { 1 }, 0, nullptr }, + { "atanh", "f", "GLSL.std.450", GLSL450_ATANH, { 1 }, 0, nullptr }, + { "pow", "ff", "GLSL.std.450", GLSL450_POW, { 1, 2 }, 0, nullptr }, + { "exp", "f", "GLSL.std.450", GLSL450_EXP, { 1 }, 0, nullptr }, + { "log", "f", "GLSL.std.450", GLSL450_LOG, { 1 }, 0, nullptr }, + { "exp2", "f", "GLSL.std.450", GLSL450_EXP2, { 1 }, 0, nullptr }, + { "log2", "f", "GLSL.std.450", GLSL450_LOG2, { 1 }, 0, nullptr }, + { "sqrt", "f", "GLSL.std.450", GLSL450_SQRT, { 1 }, 0, nullptr }, + { "inversesqrt", "f", "GLSL.std.450", GLSL450_INVERSE_SQRT, { 1 }, 0, nullptr }, + { "abs", "f", "GLSL.std.450", GLSL450_F_ABS, { 1 }, 0, nullptr }, + { "abs", "i", "GLSL.std.450", GLSL450_S_ABS, { 1 }, 0, nullptr }, + { "sign", "f", "GLSL.std.450", GLSL450_F_SIGN, { 1 }, 0, nullptr }, + { "sign", "i", "GLSL.std.450", GLSL450_S_SIGN, { 1 }, 0, nullptr }, + { "floor", "f", "GLSL.std.450", GLSL450_FLOOR, { 1 }, 0, nullptr }, + { "trunc", "f", "GLSL.std.450", GLSL450_TRUNC, { 1 }, 0, nullptr }, + { "round", "f", "GLSL.std.450", GLSL450_ROUND, { 1 }, 0, nullptr }, + { "roundEven", "f", "GLSL.std.450", GLSL450_ROUND_EVEN, { 1 }, 0, nullptr }, + { "ceil", "f", "GLSL.std.450", GLSL450_CEIL, { 1 }, 0, nullptr }, + { "fract", "f", "GLSL.std.450", GLSL450_FRACT, { 1 }, 0, nullptr }, + { "mod", "f", "", OP_F_MOD, { 1, 2 }, 0, nullptr }, + { "min", "ff", "GLSL.std.450", GLSL450_F_MIN, { 1, 2 }, 0, nullptr }, + { "min", "ii", "GLSL.std.450", GLSL450_S_MIN, { 1, 2 }, 0, nullptr }, + { "min", "uu", "GLSL.std.450", GLSL450_U_MIN, { 1, 2 }, 0, nullptr }, + { "max", "ff", "GLSL.std.450", GLSL450_F_MAX, { 1, 2 }, 0, nullptr }, + { "max", "ii", "GLSL.std.450", GLSL450_S_MAX, { 1, 2 }, 0, nullptr }, + { "max", "uu", "GLSL.std.450", GLSL450_U_MAX, { 1, 2 }, 0, nullptr }, + { "clamp", "fff", "GLSL.std.450", GLSL450_F_CLAMP, { 1, 2, 3 }, 0, nullptr }, + { "clamp", "iii", "GLSL.std.450", GLSL450_S_CLAMP, { 1, 2, 3 }, 0, nullptr }, + { "clamp", "uuu", "GLSL.std.450", GLSL450_U_CLAMP, { 1, 2, 3 }, 0, nullptr }, + { "mix", "fff", "GLSL.std.450", GLSL450_F_MIX, { 1, 2, 3 }, 0, nullptr }, + { "mix", "ffb", "", OP_SELECT, { 3, 2, 1 }, 0, nullptr }, + { "mix", "iib", "", OP_SELECT, { 3, 2, 1 }, 0, nullptr }, + { "mix", "uub", "", OP_SELECT, { 3, 2, 1 }, 0, nullptr }, + { "step", "ff", "GLSL.std.450", GLSL450_F_STEP, { 1, 2 }, 0, nullptr }, + { "smoothstep", "fff", "GLSL.std.450", GLSL450_F_SMOOTH_STEP, { 1, 2, 3 }, 0, nullptr }, + { "isnan", "f", "", OP_IS_NAN, { 1 }, 0, nullptr }, + { "isinf", "f", "", OP_IS_INF, { 1 }, 0, nullptr }, + { "fma", "fff", "GLSL.std.450", GLSL450_F_FMA, { 1, 2, 3 }, 0, nullptr }, + { "length", "f", "GLSL.std.450", GLSL450_LENGTH, { 1 }, 0, nullptr }, + { "distance", "ff", "GLSL.std.450", GLSL450_DISTANCE, { 1, 2 }, 0, nullptr }, + { "dot", "ff", "", OP_DOT, { 1, 2 }, 0, nullptr }, + { "cross", "ff", "GLSL.std.450", GLSL450_CROSS, { 1, 2 }, 0, nullptr }, + { "normalize", "f", "GLSL.std.450", GLSL450_NORMALIZE, { 1 }, 0, nullptr }, + { "faceforward", "fff", "GLSL.std.450", GLSL450_FACE_FORWARD, { 1, 2, 3 }, 0, nullptr }, + { "reflect", "ff", "GLSL.std.450", GLSL450_REFLECT, { 1, 2 }, 0, nullptr }, + { "refract", "fff", "GLSL.std.450", GLSL450_REFRACT, { 1, 2, 3 }, 0, nullptr }, { "matrixCompMult", "ff", "", 0, { 0 }, 0, &SpirVGenerator::visit_builtin_matrix_comp_mult }, - { "outerProduct", "ff", "", OP_OUTER_PRODUCT, { 1, 2 }, 0, 0 }, - { "transpose", "f", "", OP_TRANSPOSE, { 1 }, 0, 0 }, - { "determinant", "f", "GLSL.std.450", GLSL450_DETERMINANT, { 1 }, 0, 0 }, - { "inverse", "f", "GLSL.std.450", GLSL450_MATRIX_INVERSE, { 1 }, 0, 0 }, - { "lessThan", "ff", "", OP_F_ORD_LESS_THAN, { 1, 2 }, 0, 0 }, - { "lessThan", "ii", "", OP_S_LESS_THAN, { 1, 2 }, 0, 0 }, - { "lessThan", "uu", "", OP_U_LESS_THAN, { 1, 2 }, 0, 0 }, - { "lessThanEqual", "ff", "", OP_F_ORD_LESS_THAN_EQUAL, { 1, 2 }, 0, 0 }, - { "lessThanEqual", "ii", "", OP_S_LESS_THAN_EQUAL, { 1, 2 }, 0, 0 }, - { "lessThanEqual", "uu", "", OP_U_LESS_THAN_EQUAL, { 1, 2 }, 0, 0 }, - { "greaterThan", "ff", "", OP_F_ORD_GREATER_THAN, { 1, 2 }, 0, 0 }, - { "greaterThan", "ii", "", OP_S_GREATER_THAN, { 1, 2 }, 0, 0 }, - { "greaterThan", "uu", "", OP_U_GREATER_THAN, { 1, 2 }, 0, 0 }, - { "greaterThanEqual", "ff", "", OP_F_ORD_GREATER_THAN_EQUAL, { 1, 2 }, 0, 0 }, - { "greaterThanEqual", "ii", "", OP_S_GREATER_THAN_EQUAL, { 1, 2 }, 0, 0 }, - { "greaterThanEqual", "uu", "", OP_U_GREATER_THAN_EQUAL, { 1, 2 }, 0, 0 }, - { "equal", "ff", "", OP_F_ORD_EQUAL, { 1, 2 }, 0, 0 }, - { "equal", "ii", "", OP_I_EQUAL, { 1, 2 }, 0, 0 }, - { "equal", "uu", "", OP_I_EQUAL, { 1, 2 }, 0, 0 }, - { "notEqual", "ff", "", OP_F_ORD_NOT_EQUAL, { 1, 2 }, 0, 0 }, - { "notEqual", "ii", "", OP_I_NOT_EQUAL, { 1, 2 }, 0, 0 }, - { "notEqual", "uu", "", OP_I_NOT_EQUAL, { 1, 2 }, 0, 0 }, - { "any", "b", "", OP_ANY, { 1 }, 0, 0 }, - { "all", "b", "", OP_ALL, { 1 }, 0, 0 }, - { "not", "b", "", OP_LOGICAL_NOT, { 1 }, 0, 0 }, - { "bitfieldExtract", "iii", "", OP_BIT_FIELD_S_EXTRACT, { 1, 2, 3 }, 0, 0 }, - { "bitfieldExtract", "uii", "", OP_BIT_FIELD_U_EXTRACT, { 1, 2, 3 }, 0, 0 }, - { "bitfieldInsert", "iiii", "", OP_BIT_FIELD_INSERT, { 1, 2, 3, 4 }, 0, 0 }, - { "bitfieldInsert", "uuii", "", OP_BIT_FIELD_INSERT, { 1, 2, 3, 4 }, 0, 0 }, - { "bitfieldReverse", "i", "", OP_BIT_REVERSE, { 1 }, 0, 0 }, - { "bitfieldReverse", "u", "", OP_BIT_REVERSE, { 1 }, 0, 0 }, - { "bitCount", "i", "", OP_BIT_COUNT, { 1 }, 0, 0 }, - { "findLSB", "i", "GLSL.std.450", GLSL450_FIND_I_LSB, { 1 }, 0, 0 }, - { "findLSB", "u", "GLSL.std.450", GLSL450_FIND_I_LSB, { 1 }, 0, 0 }, - { "findMSB", "i", "GLSL.std.450", GLSL450_FIND_S_MSB, { 1 }, 0, 0 }, - { "findMSB", "u", "GLSL.std.450", GLSL450_FIND_U_MSB, { 1 }, 0, 0 }, + { "outerProduct", "ff", "", OP_OUTER_PRODUCT, { 1, 2 }, 0, nullptr }, + { "transpose", "f", "", OP_TRANSPOSE, { 1 }, 0, nullptr }, + { "determinant", "f", "GLSL.std.450", GLSL450_DETERMINANT, { 1 }, 0, nullptr }, + { "inverse", "f", "GLSL.std.450", GLSL450_MATRIX_INVERSE, { 1 }, 0, nullptr }, + { "lessThan", "ff", "", OP_F_ORD_LESS_THAN, { 1, 2 }, 0, nullptr }, + { "lessThan", "ii", "", OP_S_LESS_THAN, { 1, 2 }, 0, nullptr }, + { "lessThan", "uu", "", OP_U_LESS_THAN, { 1, 2 }, 0, nullptr }, + { "lessThanEqual", "ff", "", OP_F_ORD_LESS_THAN_EQUAL, { 1, 2 }, 0, nullptr }, + { "lessThanEqual", "ii", "", OP_S_LESS_THAN_EQUAL, { 1, 2 }, 0, nullptr }, + { "lessThanEqual", "uu", "", OP_U_LESS_THAN_EQUAL, { 1, 2 }, 0, nullptr }, + { "greaterThan", "ff", "", OP_F_ORD_GREATER_THAN, { 1, 2 }, 0, nullptr }, + { "greaterThan", "ii", "", OP_S_GREATER_THAN, { 1, 2 }, 0, nullptr }, + { "greaterThan", "uu", "", OP_U_GREATER_THAN, { 1, 2 }, 0, nullptr }, + { "greaterThanEqual", "ff", "", OP_F_ORD_GREATER_THAN_EQUAL, { 1, 2 }, 0, nullptr }, + { "greaterThanEqual", "ii", "", OP_S_GREATER_THAN_EQUAL, { 1, 2 }, 0, nullptr }, + { "greaterThanEqual", "uu", "", OP_U_GREATER_THAN_EQUAL, { 1, 2 }, 0, nullptr }, + { "equal", "ff", "", OP_F_ORD_EQUAL, { 1, 2 }, 0, nullptr }, + { "equal", "ii", "", OP_I_EQUAL, { 1, 2 }, 0, nullptr }, + { "equal", "uu", "", OP_I_EQUAL, { 1, 2 }, 0, nullptr }, + { "notEqual", "ff", "", OP_F_ORD_NOT_EQUAL, { 1, 2 }, 0, nullptr }, + { "notEqual", "ii", "", OP_I_NOT_EQUAL, { 1, 2 }, 0, nullptr }, + { "notEqual", "uu", "", OP_I_NOT_EQUAL, { 1, 2 }, 0, nullptr }, + { "any", "b", "", OP_ANY, { 1 }, 0, nullptr }, + { "all", "b", "", OP_ALL, { 1 }, 0, nullptr }, + { "not", "b", "", OP_LOGICAL_NOT, { 1 }, 0, nullptr }, + { "bitfieldExtract", "iii", "", OP_BIT_FIELD_S_EXTRACT, { 1, 2, 3 }, 0, nullptr }, + { "bitfieldExtract", "uii", "", OP_BIT_FIELD_U_EXTRACT, { 1, 2, 3 }, 0, nullptr }, + { "bitfieldInsert", "iiii", "", OP_BIT_FIELD_INSERT, { 1, 2, 3, 4 }, 0, nullptr }, + { "bitfieldInsert", "uuii", "", OP_BIT_FIELD_INSERT, { 1, 2, 3, 4 }, 0, nullptr }, + { "bitfieldReverse", "i", "", OP_BIT_REVERSE, { 1 }, 0, nullptr }, + { "bitfieldReverse", "u", "", OP_BIT_REVERSE, { 1 }, 0, nullptr }, + { "bitCount", "i", "", OP_BIT_COUNT, { 1 }, 0, nullptr }, + { "findLSB", "i", "GLSL.std.450", GLSL450_FIND_I_LSB, { 1 }, 0, nullptr }, + { "findLSB", "u", "GLSL.std.450", GLSL450_FIND_I_LSB, { 1 }, 0, nullptr }, + { "findMSB", "i", "GLSL.std.450", GLSL450_FIND_S_MSB, { 1 }, 0, nullptr }, + { "findMSB", "u", "GLSL.std.450", GLSL450_FIND_U_MSB, { 1 }, 0, nullptr }, { "textureSize", "", "", 0, { }, CAP_IMAGE_QUERY, &SpirVGenerator::visit_builtin_texture_query }, { "textureQueryLod", "", "", 0, { }, CAP_IMAGE_QUERY, &SpirVGenerator::visit_builtin_texture_query }, { "textureQueryLevels", "", "", 0, { }, CAP_IMAGE_QUERY, &SpirVGenerator::visit_builtin_texture_query }, @@ -119,21 +119,21 @@ const SpirVGenerator::BuiltinFunctionInfo SpirVGenerator::builtin_functions[] = { "imageSamples", "", "", 0, { }, CAP_IMAGE_QUERY, &SpirVGenerator::visit_builtin_texture_query }, { "imageLoad", "", "", 0, { }, 0, &SpirVGenerator::visit_builtin_texture_fetch }, { "imageStore", "", "", 0, { }, 0, &SpirVGenerator::visit_builtin_texture_store }, - { "EmitVertex", "", "", OP_EMIT_VERTEX, { }, 0, 0 }, - { "EndPrimitive", "", "", OP_END_PRIMITIVE, { }, 0, 0 }, - { "dFdx", "f", "", OP_DP_DX, { 1 }, 0, 0 }, - { "dFdy", "f", "", OP_DP_DY, { 1 }, 0, 0 }, - { "dFdxFine", "f", "", OP_DP_DX_FINE, { 1 }, CAP_DERIVATIVE_CONTROL, 0 }, - { "dFdyFine", "f", "", OP_DP_DY_FINE, { 1 }, CAP_DERIVATIVE_CONTROL, 0 }, - { "dFdxCoarse", "f", "", OP_DP_DX_COARSE, { 1 }, CAP_DERIVATIVE_CONTROL, 0 }, - { "dFdyCoarse", "f", "", OP_DP_DY_COARSE, { 1 }, CAP_DERIVATIVE_CONTROL, 0 }, - { "fwidth", "f", "", OP_FWIDTH, { 1 }, 0, 0 }, - { "fwidthFine", "f", "", OP_FWIDTH_FINE, { 1 }, CAP_DERIVATIVE_CONTROL, 0 }, - { "fwidthCoarse", "f", "", OP_FWIDTH_COARSE, { 1 }, CAP_DERIVATIVE_CONTROL, 0 }, + { "EmitVertex", "", "", OP_EMIT_VERTEX, { }, 0, nullptr }, + { "EndPrimitive", "", "", OP_END_PRIMITIVE, { }, 0, nullptr }, + { "dFdx", "f", "", OP_DP_DX, { 1 }, 0, nullptr }, + { "dFdy", "f", "", OP_DP_DY, { 1 }, 0, nullptr }, + { "dFdxFine", "f", "", OP_DP_DX_FINE, { 1 }, CAP_DERIVATIVE_CONTROL, nullptr }, + { "dFdyFine", "f", "", OP_DP_DY_FINE, { 1 }, CAP_DERIVATIVE_CONTROL, nullptr }, + { "dFdxCoarse", "f", "", OP_DP_DX_COARSE, { 1 }, CAP_DERIVATIVE_CONTROL, nullptr }, + { "dFdyCoarse", "f", "", OP_DP_DY_COARSE, { 1 }, CAP_DERIVATIVE_CONTROL, nullptr }, + { "fwidth", "f", "", OP_FWIDTH, { 1 }, 0, nullptr }, + { "fwidthFine", "f", "", OP_FWIDTH_FINE, { 1 }, CAP_DERIVATIVE_CONTROL, nullptr }, + { "fwidthCoarse", "f", "", OP_FWIDTH_COARSE, { 1 }, CAP_DERIVATIVE_CONTROL, nullptr }, { "interpolateAtCentroid", "", "", 0, { }, CAP_INTERPOLATION_FUNCTION, &SpirVGenerator::visit_builtin_interpolate }, { "interpolateAtSample", "", "", 0, { }, CAP_INTERPOLATION_FUNCTION, &SpirVGenerator::visit_builtin_interpolate }, { "interpolateAtOffset", "", "", 0, { }, CAP_INTERPOLATION_FUNCTION, &SpirVGenerator::visit_builtin_interpolate }, - { "", "", "", 0, { }, 0, 0 } + { "", "", "", 0, { }, 0, nullptr } }; SpirVGenerator::SpirVGenerator(): @@ -672,7 +672,7 @@ void SpirVGenerator::visit_composite(Expression &base_expr, unsigned index, Type { if(!composite_access) { - r_composite_base = 0; + r_composite_base = nullptr; r_composite_base_id = 0; r_composite_chain.clear(); } @@ -983,7 +983,7 @@ void SpirVGenerator::visit(BinaryExpression &binary) swap_operands = (basic_right.kind==BasicTypeDeclaration::VECTOR); } } - else if((basic_left.base_type!=0)!=(basic_right.base_type!=0)) + else if((basic_left.base_type!=nullptr)!=(basic_right.base_type!=nullptr)) { /* One operand is scalar and the other is a vector or a matrix. Expand the scalar to a vector of appropriate size. */ @@ -1715,7 +1715,7 @@ void SpirVGenerator::visit(VariableDeclaration &var) throw internal_error("const variable without initializer"); int spec_id = get_layout_value(var.layout.get(), "constant_id"); - Id *spec_var_id = (spec_id>=0 ? &declared_spec_ids[spec_id] : 0); + Id *spec_var_id = (spec_id>=0 ? &declared_spec_ids[spec_id] : nullptr); if(spec_id>=0 && *spec_var_id) { insert_unique(declared_ids, &var, Declaration(*spec_var_id, type_id)); diff --git a/source/glsl/spirv.h b/source/glsl/spirv.h index e98fd91e..af30212e 100644 --- a/source/glsl/spirv.h +++ b/source/glsl/spirv.h @@ -71,8 +71,8 @@ private: }; Features features; - Stage *stage = 0; - FunctionDeclaration *current_function = 0; + Stage *stage = nullptr; + FunctionDeclaration *current_function = nullptr; std::vector interface_layouts; SpirVContent content; SpirVWriter writer; @@ -96,7 +96,7 @@ private: bool reachable = false; bool composite_access = false; Id r_composite_base_id = 0; - Node *r_composite_base = 0; + Node *r_composite_base = nullptr; std::vector r_composite_chain; Id assignment_source_id = 0; Id loop_merge_block_id = 0; diff --git a/source/glsl/spirvwriter.cpp b/source/glsl/spirvwriter.cpp index 30369f2c..c73b725a 100644 --- a/source/glsl/spirvwriter.cpp +++ b/source/glsl/spirvwriter.cpp @@ -9,7 +9,7 @@ namespace SL { SpirVWriter::SpirVWriter(SpirVContent &c): content(c), - op_target(0), + op_target(nullptr), op_head_pos(0), current_block_id(0) { } @@ -82,7 +82,7 @@ void SpirVWriter::end_op(Opcode opcode) else op_head |= (words<<16); - op_target = 0; + op_target = nullptr; op_head_pos = 0; } diff --git a/source/glsl/syntax.cpp b/source/glsl/syntax.cpp index c37ad089..f69c70bf 100644 --- a/source/glsl/syntax.cpp +++ b/source/glsl/syntax.cpp @@ -268,7 +268,7 @@ VariableDeclaration::VariableDeclaration(const VariableDeclaration &other): VariableDeclaration::~VariableDeclaration() { if(linked_declaration && linked_declaration->linked_declaration==this) - linked_declaration->linked_declaration = 0; + linked_declaration->linked_declaration = nullptr; } void VariableDeclaration::visit(NodeVisitor &visitor) @@ -286,7 +286,7 @@ FunctionDeclaration::FunctionDeclaration(const FunctionDeclaration &other): overrd(other.overrd), body(other.body), signature(other.signature), - definition(other.definition==&other ? this : 0) + definition(other.definition==&other ? this : nullptr) // Do not copy return type declaration { } @@ -365,7 +365,7 @@ string get_unused_variable_name(const Block &block, const string &base) TypeDeclaration *get_ultimate_base_type(TypeDeclaration *type) { if(!type) - return 0; + return nullptr; while(const BasicTypeDeclaration *basic = dynamic_cast(type)) { if(!basic->base_type) diff --git a/source/glsl/syntax.h b/source/glsl/syntax.h index 1f2a5182..b3932c6f 100644 --- a/source/glsl/syntax.h +++ b/source/glsl/syntax.h @@ -81,7 +81,7 @@ class NodePtr: public RefPtr public: NodePtr() = default; NodePtr(T *p): RefPtr(p) { } - NodePtr(const NodePtr &p): RefPtr(p ? p->clone() : 0) { } + NodePtr(const NodePtr &p): RefPtr(p ? p->clone() : nullptr) { } NodePtr &operator=(const NodePtr &p) = default; template @@ -128,7 +128,7 @@ struct Block: Node bool use_braces = false; std::map variables; - Block *parent = 0; + Block *parent = nullptr; Block() = default; Block(const Block &); @@ -139,9 +139,9 @@ struct Block: Node struct Expression: Node { - const Operator *oper = 0; + const Operator *oper = nullptr; - TypeDeclaration *type = 0; + TypeDeclaration *type = nullptr; bool lvalue = false; virtual Expression *clone() const = 0; @@ -160,7 +160,7 @@ struct VariableReference: Expression { std::string name; - VariableDeclaration *declaration = 0; + VariableDeclaration *declaration = nullptr; VariableReference() = default; VariableReference(const VariableReference &); @@ -174,7 +174,7 @@ struct MemberAccess: Expression NodePtr left; std::string member; - VariableDeclaration *declaration = 0; + VariableDeclaration *declaration = nullptr; int index = -1; MemberAccess() = default; @@ -223,11 +223,11 @@ struct Assignment: BinaryExpression ARRAY = 0xC0 }; - VariableDeclaration *declaration = 0; + VariableDeclaration *declaration = nullptr; std::uint8_t chain_len = 0; std::uint8_t chain[7] = { }; - Target(VariableDeclaration *d = 0): declaration(d) { } + Target(VariableDeclaration *d = nullptr): declaration(d) { } bool operator<(const Target &) const; }; @@ -259,7 +259,7 @@ struct FunctionCall: Expression bool constructor = false; NodeArray arguments; - FunctionDeclaration *declaration = 0; + FunctionDeclaration *declaration = nullptr; FunctionCall() = default; FunctionCall(const FunctionCall &); @@ -347,7 +347,7 @@ struct BasicTypeDeclaration: TypeDeclaration bool extended_alignment = false; std::string base; - TypeDeclaration *base_type = 0; + TypeDeclaration *base_type = nullptr; BasicTypeDeclaration() = default; BasicTypeDeclaration(const BasicTypeDeclaration &); @@ -374,8 +374,8 @@ struct ImageTypeDeclaration: TypeDeclaration std::string base; std::string format; - TypeDeclaration *base_type = 0; - ImageTypeDeclaration *base_image = 0; + TypeDeclaration *base_type = nullptr; + ImageTypeDeclaration *base_image = nullptr; virtual ImageTypeDeclaration *clone() const { return new ImageTypeDeclaration(*this); } virtual void visit(NodeVisitor &); @@ -387,7 +387,7 @@ struct StructDeclaration: TypeDeclaration std::string block_name; bool extended_alignment = false; - VariableDeclaration *block_declaration = 0; + VariableDeclaration *block_declaration = nullptr; StructDeclaration(); StructDeclaration(const StructDeclaration &); @@ -410,9 +410,9 @@ struct VariableDeclaration: Statement NodePtr array_size; NodePtr init_expression; - TypeDeclaration *type_declaration = 0; - StructDeclaration *block_declaration = 0; - VariableDeclaration *linked_declaration = 0; + TypeDeclaration *type_declaration = nullptr; + StructDeclaration *block_declaration = nullptr; + VariableDeclaration *linked_declaration = nullptr; VariableDeclaration() = default; VariableDeclaration(const VariableDeclaration &); @@ -432,8 +432,8 @@ struct FunctionDeclaration: Statement Block body; std::string signature; - FunctionDeclaration *definition = 0; - TypeDeclaration *return_type_declaration = 0; + FunctionDeclaration *definition = nullptr; + TypeDeclaration *return_type_declaration = nullptr; FunctionDeclaration() = default; FunctionDeclaration(const FunctionDeclaration &); @@ -501,7 +501,7 @@ struct Stage }; Type type; - Stage *previous = 0; + Stage *previous = nullptr; Block content; std::map types; std::map interface_blocks; diff --git a/source/glsl/validate.cpp b/source/glsl/validate.cpp index 304bcd9e..3ef58181 100644 --- a/source/glsl/validate.cpp +++ b/source/glsl/validate.cpp @@ -40,7 +40,7 @@ void DeclarationValidator::apply(Stage &s, const Features &f) features = f; s.content.visit(*this); - Node *global_err_node = 0; + Node *global_err_node = nullptr; auto i = s.functions.find("main()"); if(i!=s.functions.end()) global_err_node = i->second; diff --git a/source/glsl/validate.h b/source/glsl/validate.h index c90a9d75..da1ed1c3 100644 --- a/source/glsl/validate.h +++ b/source/glsl/validate.h @@ -15,8 +15,8 @@ messages. */ class Validator: protected TraversingVisitor { protected: - Stage *stage = 0; - Node *last_provoker = 0; + Stage *stage = nullptr; + Node *last_provoker = nullptr; Validator() = default; @@ -41,9 +41,9 @@ private: Features features; ScopeType scope = GLOBAL; - InterfaceLayout *iface_layout = 0; - VariableDeclaration *iface_block = 0; - VariableDeclaration *variable = 0; + InterfaceLayout *iface_layout = nullptr; + VariableDeclaration *iface_block = nullptr; + VariableDeclaration *variable = nullptr; bool have_input_primitive = false; bool have_output_primitive = false; bool have_output_vertex_count = false; @@ -122,7 +122,7 @@ private: SPEC_CONSTANT }; - FunctionDeclaration *current_function = 0; + FunctionDeclaration *current_function = nullptr; bool in_struct = false; ConstantKind constant_expression = NOT_CONSTANT; @@ -186,8 +186,8 @@ class GlobalInterfaceValidator: private Validator private: struct Uniform { - Node *node = 0; - TypeDeclaration *type = 0; + Node *node = nullptr; + TypeDeclaration *type = nullptr; std::string name; int location = -1; unsigned loc_count = 1; diff --git a/source/glsl/visitor.cpp b/source/glsl/visitor.cpp index bcd6051a..d3a08d8d 100644 --- a/source/glsl/visitor.cpp +++ b/source/glsl/visitor.cpp @@ -172,7 +172,7 @@ void NodeRemover::visit(StructDeclaration &strct) string key = format("%s %s", strct.block_declaration->interface, strct.block_name); remove_from_map(stage->interface_blocks, key, *strct.block_declaration); remove_from_map(stage->interface_blocks, strct.block_declaration->name, *strct.block_declaration); - strct.block_declaration->block_declaration = 0; + strct.block_declaration->block_declaration = nullptr; } } } @@ -186,14 +186,14 @@ void NodeRemover::visit(VariableDeclaration &var) { remove_from_map(stage->interface_blocks, format("%s %s", var.interface, var.block_declaration->block_name), var); remove_from_map(stage->interface_blocks, var.name, var); - var.block_declaration->block_declaration = 0; + var.block_declaration->block_declaration = nullptr; } stage->locations.erase(var.name); if(var.linked_declaration) - var.linked_declaration->linked_declaration = 0; + var.linked_declaration->linked_declaration = nullptr; } else if(var.init_expression && to_remove->count(var.init_expression.get())) - var.init_expression = 0; + var.init_expression = nullptr; } void NodeRemover::visit(FunctionDeclaration &func) @@ -210,7 +210,7 @@ void NodeRemover::visit(FunctionDeclaration &func) void NodeRemover::visit(Iteration &iter) { if(to_remove->count(iter.init_statement.get())) - iter.init_statement = 0; + iter.init_statement = nullptr; TraversingVisitor::visit(iter); } diff --git a/source/glsl/visitor.h b/source/glsl/visitor.h index 0b561b8d..9a5aaff7 100644 --- a/source/glsl/visitor.h +++ b/source/glsl/visitor.h @@ -48,7 +48,7 @@ public: class TraversingVisitor: public NodeVisitor { protected: - Block *current_block = 0; + Block *current_block = nullptr; TraversingVisitor() = default; @@ -79,8 +79,8 @@ public: class NodeRemover: private TraversingVisitor { private: - Stage *stage = 0; - const std::set *to_remove = 0; + Stage *stage = nullptr; + const std::set *to_remove = nullptr; public: void apply(Stage &, const std::set &); @@ -105,8 +105,8 @@ on the same hierarchly level as the target node are reordered. */ class NodeReorderer: private TraversingVisitor { private: - Node *reorder_before = 0; - const std::set *to_reorder = 0; + Node *reorder_before = nullptr; + const std::set *to_reorder = nullptr; public: void apply(Stage &, Node &, const std::set &); diff --git a/source/materials/basicmaterial.cpp b/source/materials/basicmaterial.cpp index 3a4b7487..412bb719 100644 --- a/source/materials/basicmaterial.cpp +++ b/source/materials/basicmaterial.cpp @@ -28,17 +28,17 @@ BasicMaterial::BasicMaterial() void BasicMaterial::fill_program_info(string &module_name, map &spec_values) const { module_name = "phong.glsl"; - spec_values["use_diffuse_map"] = (diffuse.texture!=0); + spec_values["use_diffuse_map"] = (diffuse.texture!=nullptr); bool use_specular = (specular.texture || specular.value.r || specular.value.g || specular.value.b); spec_values["use_specular"] = use_specular; - spec_values["use_specular_map"] = (specular.texture!=0); - spec_values["use_shininess_map"] = (use_specular && shininess.texture!=0); - spec_values["use_normal_map"] = (normal.texture!=0); + spec_values["use_specular_map"] = (specular.texture!=nullptr); + spec_values["use_shininess_map"] = (use_specular && shininess.texture!=nullptr); + spec_values["use_normal_map"] = (normal.texture!=nullptr); bool use_emission = (emission.texture || emission.value.r || emission.value.g || emission.value.b); spec_values["use_emission"] = use_emission; - spec_values["use_emission_map"] = (emission.texture!=0); - spec_values["use_reflectivity"] = (reflectivity.value!=0 || reflectivity.texture!=0); - spec_values["use_reflectivity_map"] = (reflectivity.texture!=0); + spec_values["use_emission_map"] = (emission.texture!=nullptr); + spec_values["use_reflectivity"] = (reflectivity.value!=0 || reflectivity.texture!=nullptr); + spec_values["use_reflectivity_map"] = (reflectivity.texture!=nullptr); } const Texture *BasicMaterial::get_texture(Tag tag) const @@ -56,7 +56,7 @@ const Texture *BasicMaterial::get_texture(Tag tag) const else if(tag==texture_tags[5]) return reflectivity.texture; else - return 0; + return nullptr; } void BasicMaterial::set_diffuse(const Color &color) diff --git a/source/materials/material.h b/source/materials/material.h index d2d741cc..f9ae8087 100644 --- a/source/materials/material.h +++ b/source/materials/material.h @@ -40,7 +40,7 @@ protected: T value; const Texture *texture; - Property(): value(T()), texture(0) { } + Property(): value(T()), texture(nullptr) { } }; template @@ -74,7 +74,7 @@ public: }; protected: - const Sampler *sampler = 0; + const Sampler *sampler = nullptr; float alpha_cutoff = 0.0f; float alpha_feather = 1.0f; ProgramData shdata; diff --git a/source/materials/pbrmaterial.cpp b/source/materials/pbrmaterial.cpp index 41da18b5..43da3491 100644 --- a/source/materials/pbrmaterial.cpp +++ b/source/materials/pbrmaterial.cpp @@ -70,14 +70,14 @@ const Texture2D &PbrMaterial::get_or_create_fresnel_lookup() void PbrMaterial::fill_program_info(string &module_name, map &spec_values) const { module_name = "pbr_material.glsl"; - spec_values["use_base_color_map"] = (base_color.texture!=0); - spec_values["use_normal_map"] = (normal.texture!=0); - spec_values["use_metalness_map"] = (metalness.texture!=0); - spec_values["use_roughness_map"] = (roughness.texture!=0); - spec_values["use_occlusion_map"] = (occlusion.texture!=0); + spec_values["use_base_color_map"] = (base_color.texture!=nullptr); + spec_values["use_normal_map"] = (normal.texture!=nullptr); + spec_values["use_metalness_map"] = (metalness.texture!=nullptr); + spec_values["use_roughness_map"] = (roughness.texture!=nullptr); + spec_values["use_occlusion_map"] = (occlusion.texture!=nullptr); bool use_emission = (emission.texture || emission.value.r || emission.value.g || emission.value.b); spec_values["use_emission"] = use_emission; - spec_values["use_emission_map"] = (emission.texture!=0); + spec_values["use_emission_map"] = (emission.texture!=nullptr); } const Texture *PbrMaterial::get_texture(Tag tag) const @@ -97,7 +97,7 @@ const Texture *PbrMaterial::get_texture(Tag tag) const else if(tag==texture_tags[6]) return &fresnel_lookup; else - return 0; + return nullptr; } const Sampler *PbrMaterial::get_sampler(Tag tag) const @@ -186,7 +186,7 @@ void PbrMaterial::Loader::init_actions() add_property("roughness", &PbrMaterial::set_roughness, &PbrMaterial::set_roughness_map); add_property("occlusion", &PbrMaterial::set_occlusion_map); add_property("emission", &PbrMaterial::set_emission, &PbrMaterial::set_emission_map, false); - add_property("tint", &PbrMaterial::set_tint, 0, true); + add_property("tint", &PbrMaterial::set_tint, nullptr, true); } } // namespace GL diff --git a/source/materials/programdata.cpp b/source/materials/programdata.cpp index f0214666..ac63585e 100644 --- a/source/materials/programdata.cpp +++ b/source/materials/programdata.cpp @@ -33,7 +33,7 @@ ProgramData::ProgramData(ProgramData &&other): debug_name(move(other.debug_name)) { other.blocks.clear(); - other.buffer = 0; + other.buffer = nullptr; } ProgramData::~ProgramData() @@ -644,7 +644,7 @@ vector::const_iterator ProgramData::prepare_program(c if(shared.dirty==ALL_ONES) update_block_uniform_indices(shared, b); prog_begin->masks.used |= shared.used; - j->block = (shared.used ? shared.block : 0); + j->block = (shared.used ? shared.block : nullptr); ++j; } } @@ -718,7 +718,7 @@ ProgramData::SharedBlock::SharedBlock(ReflectData::LayoutHash h): block_hash(h), used(0), dirty(0), - block(0) + block(nullptr) { indices.type_flag = 0xFD; } diff --git a/source/materials/programdata.h b/source/materials/programdata.h index f60f712e..41121e44 100644 --- a/source/materials/programdata.h +++ b/source/materials/programdata.h @@ -156,14 +156,14 @@ private: unsigned generation = 0; mutable std::vector blocks; mutable std::vector programs; - mutable UniformBlock *last_buffer_block = 0; - mutable Buffer *buffer = 0; + mutable UniformBlock *last_buffer_block = nullptr; + mutable Buffer *buffer = nullptr; bool streaming = false; mutable Mask dirty = 0; std::string debug_name; public: - ProgramData(const Program * = 0); + ProgramData(const Program * = nullptr); ProgramData(ProgramData &&); ~ProgramData(); diff --git a/source/materials/rendermethod.cpp b/source/materials/rendermethod.cpp index e489dbe7..9a7b637b 100644 --- a/source/materials/rendermethod.cpp +++ b/source/materials/rendermethod.cpp @@ -60,7 +60,7 @@ void RenderMethod::set_shader_program(const Program *prog, const ProgramData *da shdata->copy_uniforms(*data); } else - shdata = 0; + shdata = nullptr; maybe_create_material_shader(); } diff --git a/source/materials/rendermethod.h b/source/materials/rendermethod.h index b3140dd3..e0356b82 100644 --- a/source/materials/rendermethod.h +++ b/source/materials/rendermethod.h @@ -76,14 +76,14 @@ private: const Texture *texture; const Sampler *sampler; - TextureSlot(Tag t): tag(t), texture(0), sampler(0) { } + TextureSlot(Tag t): tag(t), texture(nullptr), sampler(nullptr) { } }; - const Program *shprog = 0; + const Program *shprog = nullptr; bool shprog_from_material = false; RefPtr shdata; std::map uniform_slots; - const Material *material = 0; + const Material *material = nullptr; std::string material_slot; std::vector textures; CullMode face_cull = NO_CULL; @@ -109,7 +109,7 @@ public: const Material *get_material() const { return material; } const std::string &get_material_slot_name() const { return material_slot; } - void set_texture(Tag, const Texture *, const Sampler * = 0); + void set_texture(Tag, const Texture *, const Sampler * = nullptr); Tag get_texture_tag(const std::string &) const; const Texture *get_texture(Tag) const; const Sampler *get_sampler(Tag) const; diff --git a/source/materials/splatmaterial.cpp b/source/materials/splatmaterial.cpp index a1295bba..70af9bbb 100644 --- a/source/materials/splatmaterial.cpp +++ b/source/materials/splatmaterial.cpp @@ -72,7 +72,7 @@ const Texture *SplatMaterial::get_texture(Tag tag) const else if(tag==texture_tags[6]) return &fresnel_lookup; else - return 0; + return nullptr; } const Sampler *SplatMaterial::get_sampler(Tag tag) const diff --git a/source/materials/splatmaterial.h b/source/materials/splatmaterial.h index d957c71c..9fc7de4e 100644 --- a/source/materials/splatmaterial.h +++ b/source/materials/splatmaterial.h @@ -72,7 +72,7 @@ private: struct MapArray { - Texture2DArray *texture = 0; + Texture2DArray *texture = nullptr; PixelFormat format = NO_PIXELFORMAT; unsigned width = 0; unsigned height = 0; diff --git a/source/materials/technique.cpp b/source/materials/technique.cpp index 92ccde46..55914f35 100644 --- a/source/materials/technique.cpp +++ b/source/materials/technique.cpp @@ -30,7 +30,7 @@ const RenderMethod &Technique::get_method(Tag tag) const const RenderMethod *Technique::find_method(Tag tag) const { auto i = methods.find(tag); - return (i!=methods.end() ? &i->second : 0); + return (i!=methods.end() ? &i->second : nullptr); } bool Technique::replace_texture(const string &slot, const Texture &tex) diff --git a/source/materials/unlitmaterial.cpp b/source/materials/unlitmaterial.cpp index e1979051..7c3d26fc 100644 --- a/source/materials/unlitmaterial.cpp +++ b/source/materials/unlitmaterial.cpp @@ -19,7 +19,7 @@ UnlitMaterial::UnlitMaterial() void UnlitMaterial::fill_program_info(string &module_name, map &spec_values) const { module_name = "unlit.glsl"; - spec_values["use_texture"] = (texture!=0); + spec_values["use_texture"] = (texture!=nullptr); spec_values["use_vertex_color"] = vertex_color; } @@ -28,7 +28,7 @@ const Texture *UnlitMaterial::get_texture(Tag tag) const if(tag==texture_tags[0]) return texture; else - return 0; + return nullptr; } void UnlitMaterial::set_texture(const Texture *tex) @@ -60,7 +60,7 @@ void UnlitMaterial::Loader::init_actions() { Material::PropertyLoader::init_actions(); add("texture", &Loader::property_texture, &UnlitMaterial::set_texture); - add_property("color", &UnlitMaterial::set_color, 0, true); + add_property("color", &UnlitMaterial::set_color, nullptr, true); add("vertex_color", &UnlitMaterial::vertex_color); } diff --git a/source/materials/unlitmaterial.h b/source/materials/unlitmaterial.h index 8640e7c5..a89e46ec 100644 --- a/source/materials/unlitmaterial.h +++ b/source/materials/unlitmaterial.h @@ -29,7 +29,7 @@ public: }; private: - const Texture *texture = 0; + const Texture *texture = nullptr; Color color; bool vertex_color = false; diff --git a/source/render/instancearray.h b/source/render/instancearray.h index e3fdf9a7..cd7b333b 100644 --- a/source/render/instancearray.h +++ b/source/render/instancearray.h @@ -37,8 +37,8 @@ protected: private: struct Block { - char *begin = 0; - char *end = 0; + char *begin = nullptr; + char *end = nullptr; }; struct Slot @@ -55,7 +55,7 @@ private: const Object &object; VertexArray instance_data; - Buffer *instance_buffer = 0; + Buffer *instance_buffer = nullptr; VertexSetup vtx_setup; int matrix_location = -1; unsigned matrix_offset = 0; diff --git a/source/render/object.cpp b/source/render/object.cpp index e46274f6..0ae739a3 100644 --- a/source/render/object.cpp +++ b/source/render/object.cpp @@ -127,7 +127,7 @@ void Object::update_bounding_sphere() const Mesh *Object::get_mesh(unsigned i) const { if(i>=lods.size()) - return 0; + return nullptr; return lods[i].mesh; } @@ -140,7 +140,7 @@ void Object::set_technique(unsigned i, const Technique *t) const Technique *Object::get_technique(unsigned i) const { if(i>=lods.size()) - return 0; + return nullptr; return lods[i].technique; } diff --git a/source/render/occludedscene.cpp b/source/render/occludedscene.cpp index cb37a60e..9858ec0a 100644 --- a/source/render/occludedscene.cpp +++ b/source/render/occludedscene.cpp @@ -54,7 +54,7 @@ void OccludedScene::populate_cache() const j++->renderable = r; for(; j!=occluded_cache.end(); ++j) { - j->renderable = 0; + j->renderable = nullptr; j->in_frustum = false; } diff --git a/source/render/occludedscene.h b/source/render/occludedscene.h index b14e4f67..2a9f18a3 100644 --- a/source/render/occludedscene.h +++ b/source/render/occludedscene.h @@ -30,8 +30,8 @@ public: private: struct OccludedRenderable { - Renderable *renderable = 0; - const Geometry::BoundingSphere *bounding_sphere = 0; + Renderable *renderable = nullptr; + const Geometry::BoundingSphere *bounding_sphere = nullptr; bool in_frustum = false; bool occluder = false; }; diff --git a/source/render/renderable.h b/source/render/renderable.h index e9a0e064..bf31a43e 100644 --- a/source/render/renderable.h +++ b/source/render/renderable.h @@ -36,12 +36,12 @@ public: /** Returns the model matrix of the Renderable. Null is returned if no such matrix exists. The matrix should be in world space for some effects to work correctly. */ - virtual const Matrix *get_matrix() const { return 0; } + virtual const Matrix *get_matrix() const { return nullptr; } /** Returns a bounding sphere that completely encloses the Renderable. The bounding sphere is expressed in the renderable's coordinates. Null is returned if the bounding sphere cannot be determined. */ - virtual const Geometry::BoundingSphere *get_bounding_sphere() const { return 0; } + virtual const Geometry::BoundingSphere *get_bounding_sphere() const { return nullptr; } /** Called when starting to render a new frame. */ virtual void setup_frame(Renderer &) { } diff --git a/source/render/renderer.cpp b/source/render/renderer.cpp index 36228545..e941d9fd 100644 --- a/source/render/renderer.cpp +++ b/source/render/renderer.cpp @@ -52,7 +52,7 @@ void Renderer::end() RendererBackend::end(); - current_state = 0; + current_state = nullptr; state_stack.clear(); texture_stack.clear(); shdata_stack.clear(); @@ -191,7 +191,7 @@ void Renderer::set_texture(Tag tag, const Texture *tex, int level, const Sampler } } else - samp = 0; + samp = nullptr; set_resource(texture_stack, state.texture_count, tag, { tex, samp, level }); } @@ -199,7 +199,7 @@ void Renderer::set_texture(Tag tag, const Texture *tex, int level, const Sampler void Renderer::set_storage_texture(Tag tag, const Texture *tex) { State &state = get_state(); - set_resource(texture_stack, state.texture_count, tag, { tex, 0, 0 }); + set_resource(texture_stack, state.texture_count, tag, { tex, nullptr, 0 }); } template diff --git a/source/render/renderer.h b/source/render/renderer.h index e9c15fdc..1703ddb1 100644 --- a/source/render/renderer.h +++ b/source/render/renderer.h @@ -65,8 +65,8 @@ public: private: struct SampledTexture { - const Texture *texture = 0; - const Sampler *sampler = 0; + const Texture *texture = nullptr; + const Sampler *sampler = nullptr; int level = -1; SampledTexture() = default; @@ -95,21 +95,21 @@ private: struct State { std::uintptr_t pipeline_key = 0; - const Camera *camera = 0; + const Camera *camera = nullptr; Matrix model_matrix; - const Framebuffer *framebuffer = 0; - const Rect *viewport = 0; - const Rect *scissor = 0; + const Framebuffer *framebuffer = nullptr; + const Rect *viewport = nullptr; + const Rect *scissor = nullptr; unsigned texture_count = 0; - const Program *shprog = 0; + const Program *shprog = nullptr; unsigned shdata_count = 0; unsigned buffer_count = 0; - const VertexSetup *vertex_setup = 0; + const VertexSetup *vertex_setup = nullptr; FaceWinding front_face = NON_MANIFOLD; CullMode face_cull = NO_CULL; - const DepthTest *depth_test = 0; - const StencilTest *stencil_test = 0; - const Blend *blend = 0; + const DepthTest *depth_test = nullptr; + const StencilTest *stencil_test = nullptr; + const Blend *blend = nullptr; unsigned object_lod_bias = 0; }; @@ -124,14 +124,14 @@ private: unsigned frame_number = 0; unsigned char changed = 0; std::vector state_stack; - State *current_state = 0; + State *current_state = nullptr; ProgramData standard_shdata; std::vector shdata_stack; std::vector> buffer_stack; std::vector> texture_stack; - const Texture *placeholder_texture = 0; - const Sampler *default_sampler = 0; - PipelineState *last_pipeline = 0; + const Texture *placeholder_texture = nullptr; + const Sampler *default_sampler = nullptr; + PipelineState *last_pipeline = nullptr; Commands commands; static const Tag world_obj_matrix_tag; @@ -190,7 +190,7 @@ public: /** Sets the shader program to use. As a convenience, uniform values may be specified at the same time. */ - void set_shader_program(const Program *prog, const ProgramData *data = 0); + void set_shader_program(const Program *prog, const ProgramData *data = nullptr); /** Adds uniform values, which will be available for shader programs. If multiple ProgramData objects with the same uniforms are added, the one added @@ -199,8 +199,8 @@ public: void set_storage_buffer(Tag, const Buffer *); - void set_texture(Tag, const Texture *, const Sampler * = 0); - void set_texture(Tag, const Texture *, int, const Sampler * = 0); + void set_texture(Tag, const Texture *, const Sampler * = nullptr); + void set_texture(Tag, const Texture *, int, const Sampler * = nullptr); void set_storage_texture(Tag, const Texture *); private: diff --git a/source/render/scene.h b/source/render/scene.h index bb694858..0e53e869 100644 --- a/source/render/scene.h +++ b/source/render/scene.h @@ -36,7 +36,7 @@ protected: static unsigned inline_counter; public: - Loader(Scene &s, Collection &c): Loader(s, c, 0) { } + Loader(Scene &s, Collection &c): Loader(s, c, nullptr) { } Loader(Scene &s, Collection &c, ContentMap &m) : Loader(s, c, &m) { } private: Loader(Scene &, Collection &, ContentMap *); diff --git a/source/render/sequence.cpp b/source/render/sequence.cpp index a98ed508..6fe2cc08 100644 --- a/source/render/sequence.cpp +++ b/source/render/sequence.cpp @@ -150,9 +150,9 @@ void Sequence::render(Renderer &renderer, Tag tag) const source = target_ms; } - renderer.set_depth_test(0); - renderer.set_stencil_test(0); - renderer.set_blend(0); + renderer.set_depth_test(nullptr); + renderer.set_stencil_test(nullptr); + renderer.set_blend(nullptr); for(unsigned i=0; i clear_colors; float clear_depth = 1.0f; diff --git a/source/render/slot.cpp b/source/render/slot.cpp index eb2a2e3e..564474be 100644 --- a/source/render/slot.cpp +++ b/source/render/slot.cpp @@ -11,12 +11,12 @@ void Slot::set(Renderable *c) const Matrix *Slot::get_matrix() const { - return content ? content->get_matrix() : 0; + return content ? content->get_matrix() : nullptr; } const Geometry::BoundingSphere *Slot::get_bounding_sphere() const { - return content ? content->get_bounding_sphere() : 0; + return content ? content->get_bounding_sphere() : nullptr; } void Slot::setup_frame(Renderer &renderer) diff --git a/source/render/slot.h b/source/render/slot.h index f80330d3..91dca7c1 100644 --- a/source/render/slot.h +++ b/source/render/slot.h @@ -14,7 +14,7 @@ needs to be switched without affecting the rest. class MSPGL_API Slot: public Renderable { private: - Renderable *content = 0; + Renderable *content = nullptr; public: void set(Renderable *); diff --git a/source/render/text.cpp b/source/render/text.cpp index 3415ab30..012b96a9 100644 --- a/source/render/text.cpp +++ b/source/render/text.cpp @@ -49,7 +49,7 @@ void Text::set_technique(const Technique *tech, Tag tex_tag) } else { - object.set_technique(0); + object.set_technique(nullptr); texture_tag = Tag(); sampler = nullptr; } diff --git a/source/render/text.h b/source/render/text.h index d16d97e5..812ab71f 100644 --- a/source/render/text.h +++ b/source/render/text.h @@ -48,7 +48,7 @@ private: float width = 0.0f; public: - Text(const Font &, const Technique * = 0, Tag = Tag()); + Text(const Font &, const Technique * = nullptr, Tag = Tag()); const Mesh *get_mesh() const { return &mesh; } diff --git a/source/render/view.cpp b/source/render/view.cpp index cac82d5d..b55c5b4c 100644 --- a/source/render/view.cpp +++ b/source/render/view.cpp @@ -16,7 +16,7 @@ View::View(View &&other): content(other.content), internal_renderer(other.internal_renderer) { - other.internal_renderer = 0; + other.internal_renderer = nullptr; } void View::set_camera(Camera *c) diff --git a/source/render/view.h b/source/render/view.h index 48048d32..1c63f84b 100644 --- a/source/render/view.h +++ b/source/render/view.h @@ -22,9 +22,9 @@ Sequence can be used to specify other tags and add post-processing. class MSPGL_API View: public NonCopyable { protected: - Camera *camera = 0; - Renderable *content = 0; - Renderer *internal_renderer = 0; + Camera *camera = nullptr; + Renderable *content = nullptr; + Renderer *internal_renderer = nullptr; View() = default; public: diff --git a/source/resources/resource.cpp b/source/resources/resource.cpp index 60d611f8..a517ddbe 100644 --- a/source/resources/resource.cpp +++ b/source/resources/resource.cpp @@ -19,8 +19,8 @@ Resource::Resource(Resource &&other): manager->move_resource(other, *this); manager_data = manager->get_data_for_resource(*this); } - other.manager = 0; - other.manager_data = 0; + other.manager = nullptr; + other.manager_data = nullptr; } void Resource::set_manager(ResourceManager *m) @@ -34,7 +34,7 @@ void Resource::set_manager(ResourceManager *m) manager_data = manager->get_data_for_resource(*this); } else - manager_data = 0; + manager_data = nullptr; } bool Resource::is_loaded() const diff --git a/source/resources/resource.h b/source/resources/resource.h index 9ab8c553..465f81dc 100644 --- a/source/resources/resource.h +++ b/source/resources/resource.h @@ -27,8 +27,8 @@ public: }; protected: - ResourceManager *manager = 0; - void *manager_data = 0; + ResourceManager *manager = nullptr; + void *manager_data = nullptr; Resource() = default; Resource(Resource &&); @@ -39,7 +39,7 @@ public: ResourceManager *get_manager() const { return manager; } void *get_manager_data() const { return manager_data; } virtual int get_load_priority() const { return 0; } - virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) = 0; + virtual AsyncLoader *load(IO::Seekable &, const Resources * = nullptr) = 0; virtual bool is_loaded() const; /** Returns the amount of graphics memory used by this resource. The diff --git a/source/resources/resourcemanager.cpp b/source/resources/resourcemanager.cpp index 36b7091d..af780bf0 100644 --- a/source/resources/resourcemanager.cpp +++ b/source/resources/resourcemanager.cpp @@ -31,7 +31,7 @@ ResourceManager::~ResourceManager() thread.terminate(); while(!resources.empty()) - resources.begin()->second.resource->set_manager(0); + resources.begin()->second.resource->set_manager(nullptr); } void ResourceManager::set_loading_policy(LoadingPolicy p) @@ -109,7 +109,7 @@ void ResourceManager::set_resource_location(Resource &r, const ResourceLocation const ResourceManager::ResourceLocation *ResourceManager::get_resource_location(const Resource &r) const { const ManagedResource &managed = get_managed_resource(r); - return managed.location.collection ? &managed.location : 0; + return managed.location.collection ? &managed.location : nullptr; } void ResourceManager::load_resource(Resource &r) @@ -256,7 +256,7 @@ void ResourceManager::unload_by_size() while(total_data_size>size_limit) { - ManagedResource *best = 0; + ManagedResource *best = nullptr; uint64_t best_impact = 0; for(auto &kvp: resources) if(kvp.second.state==ManagedResource::LOADED && kvp.second.last_used().suffix(".anim").keyword("animation"); add_type().suffix(".arma").keyword("armature"); add_type().base().suffix(".mat") - .creator([this](const string &n) -> BasicMaterial * { create_generic(n); return 0; }) + .creator([this](const string &n) -> BasicMaterial * { create_generic(n); return nullptr; }) .notify(&set_debug_name); add_type().keyword("camera") .notify(&set_debug_name); add_type().base().suffix(".light") - .creator([this](const string &n) -> DirectionalLight * { create_generic(n); return 0; }); + .creator([this](const string &n) -> DirectionalLight * { create_generic(n); return nullptr; }); add_type().keyword("font"); add_type().suffix(".kframe").keyword("keyframe"); add_type().suffix(".lightn").keyword("lighting") @@ -68,14 +68,14 @@ Resources::Resources(bool set_as_global): .notify(&set_debug_name); add_type().base().keyword("object"); add_type().base().base().suffix(".scene") - .creator([this](const string &n) -> OccludedScene * { create_generic(n); return 0; }); + .creator([this](const string &n) -> OccludedScene * { create_generic(n); return nullptr; }); add_type().base().base().suffix(".scene") - .creator([this](const string &n) -> OrderedScene * { create_generic(n); return 0; }); + .creator([this](const string &n) -> OrderedScene * { create_generic(n); return nullptr; }); add_type().base().suffix(".mat") - .creator([this](const string &n) -> PbrMaterial * { create_generic(n); return 0; }) + .creator([this](const string &n) -> PbrMaterial * { create_generic(n); return nullptr; }) .notify(&set_debug_name); add_type().base().suffix(".light") - .creator([this](const string &n) -> PointLight * { create_generic(n); return 0; }); + .creator([this](const string &n) -> PointLight * { create_generic(n); return nullptr; }); add_type().suffix(".seq").keyword("sequence"); add_type().keyword("pose"); add_type().keyword("shader") @@ -84,32 +84,32 @@ Resources::Resources(bool set_as_global): add_type().suffix(".samp").keyword("sampler") .notify(&set_debug_name); add_type().base().base().suffix(".scene") - .creator([this](const string &n) -> SimpleScene * { create_generic(n); return 0; }); + .creator([this](const string &n) -> SimpleScene * { create_generic(n); return nullptr; }); add_type().base().suffix(".mat") - .creator([this](const string &n) -> SplatMaterial * { create_generic(n); return 0; }) + .creator([this](const string &n) -> SplatMaterial * { create_generic(n); return nullptr; }) .notify(&set_debug_name); add_type().suffix(".tech").keyword("technique") .notify(&set_debug_name); add_type().base().suffix(".tex") - .creator([this](const string &n) -> Texture1D * { create_texture(n); return 0; }) + .creator([this](const string &n) -> Texture1D * { create_texture(n); return nullptr; }) .notify(&set_debug_name); add_type().base().suffix(".tex").suffix(".png").suffix(".jpg") - .creator([this](const string &n) -> Texture2D * { create_texture(n); return 0; }) + .creator([this](const string &n) -> Texture2D * { create_texture(n); return nullptr; }) .notify(&set_debug_name); add_type().base().suffix(".tex") - .creator([this](const string &n) -> Texture3D * { create_texture(n); return 0; }) + .creator([this](const string &n) -> Texture3D * { create_texture(n); return nullptr; }) .notify(&set_debug_name); add_type().base().suffix(".tex") - .creator([this](const string &n) -> TextureCube * { create_texture(n); return 0; }) + .creator([this](const string &n) -> TextureCube * { create_texture(n); return nullptr; }) .notify(&set_debug_name); add_type().base().suffix(".tex") - .creator([this](const string &n) -> Texture2DArray * { create_texture(n); return 0; }) + .creator([this](const string &n) -> Texture2DArray * { create_texture(n); return nullptr; }) .notify(&set_debug_name); add_type().base().suffix(".mat") - .creator([this](const string &n) -> UnlitMaterial * { create_generic(n); return 0; }) + .creator([this](const string &n) -> UnlitMaterial * { create_generic(n); return nullptr; }) .notify(&set_debug_name); add_type().base().base().suffix(".scene") - .creator([this](const string &n) -> ZSortedScene * { create_generic(n); return 0; }); + .creator([this](const string &n) -> ZSortedScene * { create_generic(n); return nullptr; }); add_source(get_builtins()); @@ -120,7 +120,7 @@ Resources::Resources(bool set_as_global): Resources::~Resources() { if(this==global_resources) - global_resources = 0; + global_resources = nullptr; } Resources &Resources::get_global() @@ -161,13 +161,13 @@ T *Resources::create_generic(const string &name) ldr.store_object(*this, name); } - return 0; + return nullptr; } Mesh *Resources::create_mesh(const string &name) { if(!resource_manager || name[0]=='_') - return 0; + return nullptr; if(RefPtr io = open_raw(name)) { @@ -177,7 +177,7 @@ Mesh *Resources::create_mesh(const string &name) return mesh.release(); } - return 0; + return nullptr; } Texture *Resources::create_texture(const string &name) @@ -216,14 +216,14 @@ Texture *Resources::create_texture(const string &name) tex.release(); } - return 0; + return nullptr; } Module *Resources::create_module(const string &name) { string ext = FS::extpart(name); if(ext!=".glsl" && ext!=".spv") - return 0; + return nullptr; if(RefPtr io = open_raw(name)) { @@ -254,7 +254,7 @@ Module *Resources::create_module(const string &name) } } - return 0; + return nullptr; } Program *Resources::create_program(const string &name) @@ -270,7 +270,7 @@ Program *Resources::create_program(const string &name) return shprog.release(); } - return 0; + return nullptr; } template diff --git a/tools/viewer.cpp b/tools/viewer.cpp index 7d562397..f4bb924d 100644 --- a/tools/viewer.cpp +++ b/tools/viewer.cpp @@ -135,10 +135,10 @@ Viewer::Viewer(int argc, char **argv): gl_device(window), mouse(window), view(window), - sequence(0), - renderable(0), - anim_object(0), - anim_player(0), + sequence(nullptr), + renderable(nullptr), + anim_object(nullptr), + anim_player(nullptr), distance(10), dragging(0) { @@ -156,12 +156,12 @@ Viewer::Viewer(int argc, char **argv): } } - GL::Object *object = 0; + GL::Object *object = nullptr; string ext = FS::extpart(opts.renderable_name); if(ext==".mesh") { - GL::Mesh *mesh = 0; + GL::Mesh *mesh = nullptr; if(FS::exists(opts.renderable_name)) { mesh = new GL::Mesh; @@ -173,7 +173,7 @@ Viewer::Viewer(int argc, char **argv): object = new GL::Object; GL::Technique *tech = new GL::Technique; - tech->add_method(0); + tech->add_method(GL::Tag()); object->set_mesh(mesh); object->set_technique(tech); renderable = object; @@ -235,7 +235,7 @@ Viewer::Viewer(int argc, char **argv): sequence = new GL::Sequence(); sequence->set_debug_name("Sequence"); sequence->set_clear_enabled(true); - GL::Sequence::Step &step = sequence->add_step(0, *renderable); + GL::Sequence::Step &step = sequence->add_step(GL::Tag(), *renderable); step.set_lighting(&lighting); step.set_depth_test(GL::LEQUAL); }